Bluetooth Connected TOF Sensor

Dependencies:   BLE_API X_NUCLEO_6180XA1 X_NUCLEO_IDB0XA1 mbed

Fork of BLE_HeartRate_IDB0XA1 by ST

Committer:
hux
Date:
Wed Feb 01 22:08:56 2017 +0000
Revision:
28:def5e0f0fb06
First S16_Blue_ToF application which runs nicely!; Digital display can be switched on/off with red slider

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hux 28:def5e0f0fb06 1 // blob.h - 'BLOBs' are BLuetooth OBjects
hux 28:def5e0f0fb06 2 #ifndef _BLOB_H_
hux 28:def5e0f0fb06 3 #define _BLOB_H_
hux 28:def5e0f0fb06 4
hux 28:def5e0f0fb06 5 #include "ble/BLE.h"
hux 28:def5e0f0fb06 6 #include "ble/Gap.h"
hux 28:def5e0f0fb06 7
hux 28:def5e0f0fb06 8 #define _ICCC BLE::InitializationCompleteCallbackContext // pure short hand
hux 28:def5e0f0fb06 9 #define _GDCP Gap::DisconnectionCallbackParams_t // pure short hand
hux 28:def5e0f0fb06 10 #define _GCCP Gap::ConnectionCallbackParams_t // pure short hand
hux 28:def5e0f0fb06 11 #define _GWCP GattWriteCallbackParams // pure short hand
hux 28:def5e0f0fb06 12
hux 28:def5e0f0fb06 13 class Blob : public BLE
hux 28:def5e0f0fb06 14 {
hux 28:def5e0f0fb06 15 public:
hux 28:def5e0f0fb06 16 const _ICCC *pComplete; // params to _ICCC context
hux 28:def5e0f0fb06 17 const _GCCP *pConnect; // params to _GCCP context
hux 28:def5e0f0fb06 18 const _GDCP *pDisconnect; // params to _GDPC context
hux 28:def5e0f0fb06 19 const _GWCP *pWritten; // params to _GWCP context
hux 28:def5e0f0fb06 20
hux 28:def5e0f0fb06 21 public: // construction
hux 28:def5e0f0fb06 22 Blob() : BLE() // standard constructor
hux 28:def5e0f0fb06 23 {
hux 28:def5e0f0fb06 24 pComplete = 0; pDisconnect = 0;
hux 28:def5e0f0fb06 25 }
hux 28:def5e0f0fb06 26 };
hux 28:def5e0f0fb06 27
hux 28:def5e0f0fb06 28
hux 28:def5e0f0fb06 29 // Setup Advertising Name (syntactic sugar)
hux 28:def5e0f0fb06 30
hux 28:def5e0f0fb06 31 inline void name(Blob &o, const char *str)
hux 28:def5e0f0fb06 32 {
hux 28:def5e0f0fb06 33 o.gap().accumulateAdvertisingPayload(
hux 28:def5e0f0fb06 34 GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)str, strlen(str)+1);
hux 28:def5e0f0fb06 35 }
hux 28:def5e0f0fb06 36
hux 28:def5e0f0fb06 37
hux 28:def5e0f0fb06 38 // Setup Device Name (syntactic sugar)
hux 28:def5e0f0fb06 39
hux 28:def5e0f0fb06 40 inline void device(Blob &o, const char *text)
hux 28:def5e0f0fb06 41 {
hux 28:def5e0f0fb06 42 o.gap().setDeviceName((const uint8_t *)text);
hux 28:def5e0f0fb06 43 }
hux 28:def5e0f0fb06 44
hux 28:def5e0f0fb06 45
hux 28:def5e0f0fb06 46 // Setup Advertising Data (syntactic sugar)
hux 28:def5e0f0fb06 47
hux 28:def5e0f0fb06 48 inline void data(Blob &o, const uint8_t *buf, size_t buflen)
hux 28:def5e0f0fb06 49 {
hux 28:def5e0f0fb06 50 o.gap().accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, buf, buflen);
hux 28:def5e0f0fb06 51 }
hux 28:def5e0f0fb06 52
hux 28:def5e0f0fb06 53 inline void data(Blob &o, const char *text)
hux 28:def5e0f0fb06 54 {
hux 28:def5e0f0fb06 55 size_t len = strlen(text);
hux 28:def5e0f0fb06 56 data(o,(const uint8_t*)text,len);
hux 28:def5e0f0fb06 57 }
hux 28:def5e0f0fb06 58
hux 28:def5e0f0fb06 59 #endif // _BLOB_H_