Skip to content

Commit

Permalink
Merge pull request #122 from senseshift/hotfix/connect-quest-3
Browse files Browse the repository at this point in the history
fix(bHaptics): add GlobalConfig char
  • Loading branch information
leon0399 authored Jul 2, 2024
2 parents 4c52916 + 40044a2 commit 6d450ed
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ on:
branches:
- master
- develop
- support/*
paths-ignore:
- '**/*.md'
push:
branches:
- master
- develop
- support/*
paths-ignore:
- '**/*.md'

Expand Down
47 changes: 39 additions & 8 deletions lib/bhaptics_ble/connection_bhble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ void BH::ConnectionBHBLE::begin()
this->bleServer->getAdvertising()->setScanResponseData(*scanResponseData);

// Each characteristic needs 2 handles and descriptor 1 handle.
#if defined(BLUETOOTH_USE_NIMBLE) && BLUETOOTH_USE_NIMBLE == true
this->motorService = this->bleServer->createService(BH_BLE_SERVICE_MOTOR_UUID);
#else
this->motorService = this->bleServer->createService(BH_BLE_SERVICE_MOTOR_UUID, 30, 0);
#endif

{
MotorCharCallbacks* motorCallbacks = new MotorCharCallbacks(this->motorHandler);
Expand All @@ -160,6 +164,14 @@ void BH::ConnectionBHBLE::begin()
PROPERTY_READ | PROPERTY_WRITE
);
configChar->setCallbacks(new ConfigCharCallbacks());

uint8_t config[3] = {
0, // byte 0 - ?
0, // byte 1 - ?
0, // byte 2 - color,
// but for tactosy it is switching left/right position
};
configChar->setValue(config, 3);
}

{
Expand Down Expand Up @@ -212,15 +224,34 @@ void BH::ConnectionBHBLE::begin()
monitorChar->addDescriptor(new BLE2902());
#endif

uint16_t audioCableState = NO_AUDIO_CABLE;
monitorChar->setValue(audioCableState);
// bit 7 - audio jack (0: off, 1: on)
uint8_t status = 0b00000000;

uint8_t value[1] = { status };
monitorChar->setValue(value, 1);
}

// auto* athGlobalChar = this->motorService->createCharacteristic(
// BH_BLE_SERVICE_MOTOR_CHAR_ATH_GLOBAL_CONF_UUID,
// PROPERTY_READ | PROPERTY_WRITE | PROPERTY_NOTIFY | PROPERTY_BROADCAST | PROPERTY_INDICATE | PROPERTY_WRITE_NR
// );
// athGlobalChar->setCallbacks(new SerialOutputCharCallbacks());
{
auto* athGlobalChar = this->motorService->createCharacteristic(
BH_BLE_SERVICE_MOTOR_CHAR_ATH_GLOBAL_CONF_UUID,
PROPERTY_READ | PROPERTY_WRITE
);
athGlobalChar->setCallbacks(new SerialOutputCharCallbacks());

uint8_t athGlobalConfig[20] = {
0, // byte 0 - ?
0, // byte 1 - VSM
0, // byte 2 - AthConfigIndex
0, // byte 3 - AthConfigIndex
0, // byte 4 - SignaturePatternOnOff (0: off, 1: on)
0, // byte 5 - WaitMinutes
0, // byte 6 - DisableEmbedAth (0: off, 1: on)
0, // byte 7 - ButtonLock (0: off, 1: on)
0, // byte 8 - LedInfo
};

athGlobalChar->setValue(athGlobalConfig, 20);
}

// auto* athThemeChar = this->motorService->createCharacteristic(
// BH_BLE_SERVICE_MOTOR_CHAR_ATH_THEME_UUID,
Expand All @@ -246,7 +277,7 @@ void BH::ConnectionBHBLE::begin()
auto dfuService = this->bleServer->createService(BH_BLE_SERVICE_DFU_UUID);

auto* dfuControlChar = dfuService->createCharacteristic(
BH_BLE_SERVICE_MOTOR_CHAR_SIGNATURE_PATTERN_UUID,
BH_BLE_SERVICE_DFU_CHAR_CONTROL_UUID,
PROPERTY_READ | PROPERTY_WRITE
);
dfuService->start();
Expand Down

1 comment on commit 6d450ed

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage for this commit

39.11%

Please sign in to comment.