![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Bluetooth Connected TOF Sensor
Dependencies: BLE_API X_NUCLEO_6180XA1 X_NUCLEO_IDB0XA1 mbed
Fork of BLE_HeartRate_IDB0XA1 by
Diff: bricks/blob.h
- Revision:
- 28:def5e0f0fb06
diff -r 32267cee7cb8 -r def5e0f0fb06 bricks/blob.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bricks/blob.h Wed Feb 01 22:08:56 2017 +0000 @@ -0,0 +1,59 @@ +// blob.h - 'BLOBs' are BLuetooth OBjects +#ifndef _BLOB_H_ +#define _BLOB_H_ + +#include "ble/BLE.h" +#include "ble/Gap.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 + + class Blob : public BLE + { + public: + const _ICCC *pComplete; // params to _ICCC context + const _GCCP *pConnect; // params to _GCCP context + const _GDCP *pDisconnect; // params to _GDPC context + const _GWCP *pWritten; // params to _GWCP context + + public: // construction + Blob() : BLE() // standard constructor + { + pComplete = 0; pDisconnect = 0; + } + }; + + +// Setup Advertising Name (syntactic sugar) + + inline void name(Blob &o, const char *str) + { + o.gap().accumulateAdvertisingPayload( + GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)str, strlen(str)+1); + } + + +// Setup Device Name (syntactic sugar) + + inline void device(Blob &o, const char *text) + { + o.gap().setDeviceName((const uint8_t *)text); + } + + +// Setup Advertising Data (syntactic sugar) + + inline void data(Blob &o, const uint8_t *buf, size_t buflen) + { + o.gap().accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, buf, buflen); + } + + inline void data(Blob &o, const char *text) + { + size_t len = strlen(text); + data(o,(const uint8_t*)text,len); + } + +#endif // _BLOB_H_ \ No newline at end of file