Unverified Commit cb52e569 authored by Rodrigo Garcia's avatar Rodrigo Garcia Committed by GitHub

Fixes BLE Server descriptor update (#6919)

Description of Change

This PR fixes an issue related to BLE Server and Descriptors.

The issue:
If the BLE Server code changes its own descriptors, it is not reflected in the GATTS database.
BLE2902 CCCD also didn't reflect any changes to the GATTS database.
Because of this issue, the client could never read the real Descriptor values from the remote Server.

Tests scenarios

Tested with ESP32.

Related links

Fixes #6863
Fixes #6868
parent 4a341c94
...@@ -46,6 +46,7 @@ void BLE2902::setIndications(bool flag) { ...@@ -46,6 +46,7 @@ void BLE2902::setIndications(bool flag) {
uint8_t *pValue = getValue(); uint8_t *pValue = getValue();
if (flag) pValue[0] |= 1 << 1; if (flag) pValue[0] |= 1 << 1;
else pValue[0] &= ~(1 << 1); else pValue[0] &= ~(1 << 1);
setValue(pValue, 2);
} // setIndications } // setIndications
...@@ -57,6 +58,7 @@ void BLE2902::setNotifications(bool flag) { ...@@ -57,6 +58,7 @@ void BLE2902::setNotifications(bool flag) {
uint8_t *pValue = getValue(); uint8_t *pValue = getValue();
if (flag) pValue[0] |= 1 << 0; if (flag) pValue[0] |= 1 << 0;
else pValue[0] &= ~(1 << 0); else pValue[0] &= ~(1 << 0);
setValue(pValue, 2);
} // setNotifications } // setNotifications
#endif #endif
...@@ -235,6 +235,10 @@ void BLEDescriptor::setValue(uint8_t* data, size_t length) { ...@@ -235,6 +235,10 @@ void BLEDescriptor::setValue(uint8_t* data, size_t length) {
} }
m_value.attr_len = length; m_value.attr_len = length;
memcpy(m_value.attr_value, data, 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 } // setValue
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment