ARMmbed / ble-nrf51822

Nordic stack and drivers for the mbed BLE_API
Other
46 stars 51 forks source link

Allow adding a User Description descriptor to a GattCharacteristic. #9

Closed rgrover closed 9 years ago

rgrover commented 9 years ago

This needs special handling since it is a reserved UUID. The present mechanism of adding descriptors through a table during construction doesn't work.

rgrover commented 9 years ago

I used the following patch to HeartRateService to test this change.

diff --git a/services/HeartRateService.h b/services/HeartRateService.h
index 8da7747..8d04b5e 100644
--- a/services/HeartRateService.h
+++ b/services/HeartRateService.h
@@ -18,6 +18,7 @@
 #define __BLE_HEART_RATE_SERVICE_H__

 #include "BLEDevice.h"
+#include "ble_srv_common.h"

 /**
 * @class HeartRateService
@@ -132,7 +133,15 @@ private:
             return;
         }

-        GattCharacteristic *charTable[] = {&hrmRate, &hrmLocation, &controlPoint};
+        GattAttribute desc(BLE_UUID_DESCRIPTOR_CHAR_USER_DESC, (uint8_t *)"something readable", strlen("s
+        uint8_t alertLevel = 1;
+
+        GattAttribute *descs[] = {&desc};
+
+        GattCharacteristic rohit(BLE_UUID_ALERT_LEVEL_CHAR, reinterpret_cast<uint8_t *>(&alertLevel),
+                                 sizeof(uint8_t), sizeof(uint8_t), GattCharacteristic::BLE_GATT_CHAR_PROP
+
+        GattCharacteristic *charTable[] = {&hrmRate,  &rohit, &hrmLocation, &controlPoint};
         GattService         hrmService(GattService::UUID_HEART_RATE_SERVICE, charTable, sizeof(charTable)

         ble.addService(hrmService);