![](/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
- Committer:
- hux
- Date:
- 2017-01-07
- Revision:
- 26:fd06c8b57d16
- Parent:
- 24:0f08f68579bd
File content as of revision 26:fd06c8b57d16:
// 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 #define GattListLength(list) (sizeof(list) / sizeof(GattCharacteristic *)) typedef uint8_t byte; typedef const char *cptr; typedef uint8_t Buffer[10]; class Blob { public: BLE *pble; // to access THE ble object 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: Blob(); // standard constructor void init(void (*)(Blob&),void (*)(Blob&)); // initialize BLE system void init(void (*)(Blob&)); // initialize BLE system void sleep(void); // low power wait public: // some short hands (inline) GattServer& gatt() { return pble->gattServer(); } public: // setup GAP advertising void device(const char *name); // set device name characteristic // adding custom service void config(GattService &svc); // configure custom service // advertising flags void mode(const char *p); // Set advertising type and flags void data(const uint8_t*, size_t); // advertising data void data(const char *str); // advertising data void name(const char *str); // add name to device void start(void); // start advertising void start(int msec); // start advertising (msec: periode) void peripheral(cptr pmod,int ms=100);// advertise as a peripheral 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 }; // Setup Advertising Name (syntactic sugar) inline void name(Blob &o, const char *text) { o.name(text); // setup advertising name } // Setup Device Name (syntactic sugar) inline void device(Blob &o, const char *text) { o.device(text); // setup device name } // Setup Advertising Data (syntactic sugar) inline void data(Blob &o, const char *text) { o.data(text); // setup advertising data } #endif // _BLOB_H_