![](/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
bricks/blob.h@28:307f58df778a, 2017-10-01 (annotated)
- Committer:
- hux
- Date:
- Sun Oct 01 12:48:58 2017 +0000
- Revision:
- 28:307f58df778a
A blue button is always a nice toy ...
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hux | 28:307f58df778a | 1 | // blob.h - 'BLOBs' are BLuetooth OBjects |
hux | 28:307f58df778a | 2 | #ifndef _BLOB_H_ |
hux | 28:307f58df778a | 3 | #define _BLOB_H_ |
hux | 28:307f58df778a | 4 | |
hux | 28:307f58df778a | 5 | #include "ble/BLE.h" |
hux | 28:307f58df778a | 6 | #include "ble/Gap.h" |
hux | 28:307f58df778a | 7 | |
hux | 28:307f58df778a | 8 | #define _ICCC BLE::InitializationCompleteCallbackContext // pure short hand |
hux | 28:307f58df778a | 9 | #define _GDCP Gap::DisconnectionCallbackParams_t // pure short hand |
hux | 28:307f58df778a | 10 | #define _GCCP Gap::ConnectionCallbackParams_t // pure short hand |
hux | 28:307f58df778a | 11 | #define _GWCP GattWriteCallbackParams // pure short hand |
hux | 28:307f58df778a | 12 | |
hux | 28:307f58df778a | 13 | class Blob : public BLE |
hux | 28:307f58df778a | 14 | { |
hux | 28:307f58df778a | 15 | public: |
hux | 28:307f58df778a | 16 | const _ICCC *pComplete; // params to _ICCC context |
hux | 28:307f58df778a | 17 | const _GCCP *pConnect; // params to _GCCP context |
hux | 28:307f58df778a | 18 | const _GDCP *pDisconnect; // params to _GDPC context |
hux | 28:307f58df778a | 19 | const _GWCP *pWritten; // params to _GWCP context |
hux | 28:307f58df778a | 20 | |
hux | 28:307f58df778a | 21 | public: // construction |
hux | 28:307f58df778a | 22 | Blob() : BLE() // standard constructor |
hux | 28:307f58df778a | 23 | { |
hux | 28:307f58df778a | 24 | pComplete = 0; pDisconnect = 0; |
hux | 28:307f58df778a | 25 | } |
hux | 28:307f58df778a | 26 | }; |
hux | 28:307f58df778a | 27 | |
hux | 28:307f58df778a | 28 | |
hux | 28:307f58df778a | 29 | // Setup Advertising Name (syntactic sugar) |
hux | 28:307f58df778a | 30 | |
hux | 28:307f58df778a | 31 | inline void name(Blob &o, const char *str) |
hux | 28:307f58df778a | 32 | { |
hux | 28:307f58df778a | 33 | o.gap().accumulateAdvertisingPayload( |
hux | 28:307f58df778a | 34 | GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)str, strlen(str)+1); |
hux | 28:307f58df778a | 35 | } |
hux | 28:307f58df778a | 36 | |
hux | 28:307f58df778a | 37 | |
hux | 28:307f58df778a | 38 | // Setup Device Name (syntactic sugar) |
hux | 28:307f58df778a | 39 | |
hux | 28:307f58df778a | 40 | inline void device(Blob &o, const char *text) |
hux | 28:307f58df778a | 41 | { |
hux | 28:307f58df778a | 42 | o.gap().setDeviceName((const uint8_t *)text); |
hux | 28:307f58df778a | 43 | } |
hux | 28:307f58df778a | 44 | |
hux | 28:307f58df778a | 45 | |
hux | 28:307f58df778a | 46 | // Setup Advertising Data (syntactic sugar) |
hux | 28:307f58df778a | 47 | |
hux | 28:307f58df778a | 48 | inline void data(Blob &o, const uint8_t *buf, size_t buflen) |
hux | 28:307f58df778a | 49 | { |
hux | 28:307f58df778a | 50 | o.gap().accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, buf, buflen); |
hux | 28:307f58df778a | 51 | } |
hux | 28:307f58df778a | 52 | |
hux | 28:307f58df778a | 53 | inline void data(Blob &o, const char *text) |
hux | 28:307f58df778a | 54 | { |
hux | 28:307f58df778a | 55 | size_t len = strlen(text); |
hux | 28:307f58df778a | 56 | data(o,(const uint8_t*)text,len); |
hux | 28:307f58df778a | 57 | } |
hux | 28:307f58df778a | 58 | |
hux | 28:307f58df778a | 59 | #endif // _BLOB_H_ |