Skip to content

Commit

Permalink
fix(bHaptics): add GlobalConfig char
Browse files Browse the repository at this point in the history
Fixes #119
  • Loading branch information
leon0399 committed Jul 2, 2024
1 parent 4c52916 commit 282e3e7
Showing 1 changed file with 26 additions and 7 deletions.
33 changes: 26 additions & 7 deletions lib/bhaptics_ble/connection_bhble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void BH::ConnectionBHBLE::begin()
this->bleServer->getAdvertising()->setScanResponseData(*scanResponseData);

// Each characteristic needs 2 handles and descriptor 1 handle.
this->motorService = this->bleServer->createService(BH_BLE_SERVICE_MOTOR_UUID);
this->motorService = this->bleServer->createService(BH_BLE_SERVICE_MOTOR_UUID, 30, 0);

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

uint8_t config[3] = { 0, 0, 0 };
configChar->setValue(config, 3);
}

{
Expand Down Expand Up @@ -216,11 +219,27 @@ void BH::ConnectionBHBLE::begin()
monitorChar->setValue(audioCableState);
}

// 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 +265,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

0 comments on commit 282e3e7

Please sign in to comment.