Skip to content

Fixes BLE Server descriptor update #6919

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

Merged
merged 5 commits into from
Jun 28, 2022
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 libraries/BLE/src/BLE2902.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void BLE2902::setIndications(bool flag) {
uint8_t *pValue = getValue();
if (flag) pValue[0] |= 1 << 1;
else pValue[0] &= ~(1 << 1);
setValue(pValue, 2);
} // setIndications


Expand All @@ -57,6 +58,7 @@ void BLE2902::setNotifications(bool flag) {
uint8_t *pValue = getValue();
if (flag) pValue[0] |= 1 << 0;
else pValue[0] &= ~(1 << 0);
setValue(pValue, 2);
} // setNotifications

#endif
6 changes: 5 additions & 1 deletion libraries/BLE/src/BLEDescriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ BLEDescriptor::BLEDescriptor(const char* uuid, uint16_t len) : BLEDescriptor(BLE
BLEDescriptor::BLEDescriptor(BLEUUID uuid, uint16_t max_len) {
m_bleUUID = uuid;
m_value.attr_len = 0; // Initial length is 0.
m_value.attr_max_len = max_len; // Maximum length of the data.
m_value.attr_max_len = max_len; // Maximum length of the data.
m_handle = NULL_HANDLE; // Handle is initially unknown.
m_pCharacteristic = nullptr; // No initial characteristic.
m_pCallback = nullptr; // No initial callback.
Expand Down Expand Up @@ -235,6 +235,10 @@ void BLEDescriptor::setValue(uint8_t* data, size_t length) {
}
m_value.attr_len = length;
memcpy(m_value.attr_value, data, length);
if (m_handle != NULL_HANDLE) {
esp_ble_gatts_set_attr_value(m_handle, length, (const uint8_t *)data);
log_d("Set the value in the GATTS database using handle 0x%x", m_handle);
}
} // setValue


Expand Down
2 changes: 1 addition & 1 deletion libraries/BLE/src/BLEDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class BLEDescriptor {
uint16_t m_handle;
BLEDescriptorCallbacks* m_pCallback;
BLECharacteristic* m_pCharacteristic;
esp_gatt_perm_t m_permissions = ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE;
esp_gatt_perm_t m_permissions = ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE;
FreeRTOS::Semaphore m_semaphoreCreateEvt = FreeRTOS::Semaphore("CreateEvt");
esp_attr_value_t m_value;

Expand Down