Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bHaptics): add GlobalConfig char #122

Merged
merged 2 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading