![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
A blue button is always a nice toy ...
Dependencies: BLE_API X_NUCLEO_IDB0XA1 mbed
Fork of BLE_HeartRate_IDB0XA1 by
Diff: bricks/blob.h
- Revision:
- 23:677689000369
- Parent:
- 22:d467526abc4a
- Child:
- 24:0f08f68579bd
diff -r d467526abc4a -r 677689000369 bricks/blob.h --- a/bricks/blob.h Sun Dec 18 05:33:58 2016 +0000 +++ b/bricks/blob.h Fri Jan 06 15:28:18 2017 +0000 @@ -4,40 +4,19 @@ #include "ble/BLE.h" #include "ble/Gap.h" +#include "bricks/service.h" #define ICCC BLE::InitializationCompleteCallbackContext // pure short hand #define GDCP Gap::DisconnectionCallbackParams_t // pure short hand #define GCCP Gap::ConnectionCallbackParams_t // pure short hand #define GWCP GattWriteCallbackParams // pure short hand +#define GattListLength(list) (sizeof(list) / sizeof(GattCharacteristic *)) + typedef uint8_t byte; typedef const char *cptr; + typedef uint8_t Buffer[10]; - class Service - { - public: - GattService *pService; - - private: - GattCharacteristic **pCharacteristics; - int count; - uint16_t uuid; - - public: - Service(uint16_t uid); - void add(GattCharacteristic *p); - GattService *create(); // actual creation of GATT service - }; - - class Characteristic - { - public: - GattCharacteristic *pc; - Characteristic(Service &svc, uint16_t uuid, cptr mode, cptr name); - Characteristic(Service &svc, uint16_t uuid, cptr mode); - }; - - class Blob { public: @@ -61,8 +40,8 @@ // adding custom service - void service(Service &svc); // add custom service - void service(GattService &svc); // add custom service + void config(Service &svc); // configure custom service + void config(GattService &svc); // configure custom service // advertising flags @@ -74,6 +53,9 @@ void start(int msec); // start advertising (msec: periode) void advertise(cptr pmod,int ms=100);// advertise + void copy(GattCharacteristic &dst); + void get(GattCharacteristic &chr, Buffer &data); + void onConnect(void (*fptr)(Blob&)); // setup disconnect callback void onDisconnect(void (*fptr)(Blob&));// setup disconnect callback void onWritten(void (*fptr)(Blob&)); // setup data written callback