X_NUCLEO_IDB05A1
Dependencies: mbed-os-example-ble-Advertising
Revision 262:a3460768f3b7, committed 2016-09-15
- Comitter:
- Vincent Coubard
- Date:
- Thu Sep 15 10:51:24 2016 +0100
- Branch:
- a38223e17a624c1ac4d9e2589f363d2e202f12a5
- Parent:
- 261:16cdf278f70a
- Child:
- 263:8516afb5e29c
- Commit message:
- Sync with a38223e17a624c1ac4d9e2589f363d2e202f12a5
2016-07-08 18:04:01+01:00: Vincent Coubard
Fix characteristic descriptor discovery
Changed in this revision
| source/BlueNRGGattClient.cpp | Show annotated file Show diff for this revision Revisions of this file |
| source/BlueNRGGattServer.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/source/BlueNRGGattClient.cpp Thu Sep 15 10:51:23 2016 +0100
+++ b/source/BlueNRGGattClient.cpp Thu Sep 15 10:51:24 2016 +0100
@@ -72,6 +72,13 @@
}
if(_currentState == GATT_CHAR_DESC_DISCOVERY) {
+ if(charDescTerminationCallback != NULL) {
+ CharacteristicDescriptorDiscovery::TerminationCallbackParams_t params = {
+ _characteristic,
+ BLE_ERROR_NONE
+ };
+ charDescTerminationCallback(¶ms);
+ }
_currentState = GATT_IDLE;
}
@@ -711,8 +718,12 @@
offset = 0;
+ PRINTF("\r\ncharacteristic descriptor discovered: data length %u, format %u\r\n",
+ event_data_length, format);
+
+
for (i=0; i<numCharacDesc; i++) {
- attHandle = handle_uuid_pair[offset];
+ memcpy(&attHandle, handle_uuid_pair + offset, sizeof(attHandle));
// UUID Type
if (handle_uuid_length == 4) {
@@ -751,15 +762,6 @@
offset += handle_uuid_length;
}
-
- if(charDescTerminationCallback != NULL) {
- CharacteristicDescriptorDiscovery::TerminationCallbackParams_t params = {
- _characteristic,
- BLE_ERROR_NONE
- };
- charDescTerminationCallback(¶ms);
- }
-
}
ble_error_t BlueNRGGattClient::discoverCharacteristicDescriptors(
@@ -780,7 +782,7 @@
GattAttribute::Handle_t valueHandle = characteristic.getValueHandle();
GattAttribute::Handle_t lastHandle = characteristic.getLastHandle();
- PRINTF("Starting aci_gatt_disc_all_charac_descriptors...\n\r");
+ PRINTF("Starting aci_gatt_disc_all_charac_descriptors... [%u : %u]\n\r", valueHandle, lastHandle);
ret = aci_gatt_disc_all_charac_descriptors(connHandle, valueHandle, lastHandle);
if (ret == BLE_STATUS_SUCCESS) {
--- a/source/BlueNRGGattServer.cpp Thu Sep 15 10:51:23 2016 +0100
+++ b/source/BlueNRGGattServer.cpp Thu Sep 15 10:51:24 2016 +0100
@@ -273,12 +273,23 @@
for(uint8_t descIndex=0; descIndex<p_char->getDescriptorCount(); descIndex++) {
GattAttribute *descriptor = p_char->getDescriptor(descIndex);
- uint16_t shortUUID = descriptor->getUUID().getShortUUID();
- const uint8_t uuidArray[] = {(uint8_t)((shortUUID>>8)&0xFF), (uint8_t)((shortUUID&0xFF))};
+ uint8_t desc_uuid[16] = { 0 };
+
+
+ uint8_t desc_uuid_type = CHAR_DESC_TYPE_16_BIT;
+ STORE_LE_16(desc_uuid, descriptor->getUUID().getShortUUID());
+
+ if((descriptor->getUUID()).shortOrLong() == UUID::UUID_TYPE_LONG) {
+ desc_uuid_type = CHAR_DESC_TYPE_128_BIT;
+ const uint8_t* base_desc_uuid = descriptor->getUUID().getBaseUUID();
+
+ COPY_UUID_128(desc_uuid, base_desc_uuid[15], base_desc_uuid[14],base_desc_uuid[13],base_desc_uuid[12], base_desc_uuid[11], base_desc_uuid[10], base_desc_uuid[9], base_desc_uuid[8], base_desc_uuid[7], base_desc_uuid[6], base_desc_uuid[5], base_desc_uuid[4], base_desc_uuid[3], base_desc_uuid[2], base_desc_uuid[1], base_desc_uuid[0]);
+ }
+
ret = aci_gatt_add_char_desc(service.getHandle(),
bleCharacteristic,
- CHAR_DESC_TYPE_16_BIT,
- uuidArray,
+ desc_uuid_type,
+ desc_uuid,
descriptor->getMaxLength(),
descriptor->getLength(),
descriptor->getValuePtr(),