TOF based Presence Detector

Dependencies:   BLE_API X_NUCLEO_6180XA1 X_NUCLEO_IDB0XA1 mbed

Fork of BLE_HeartRate_IDB0XA1 by ST

Committer:
hux
Date:
Mon Aug 20 16:43:10 2018 +0000
Revision:
29:eceecbe28088
Parent:
28:a23b16555909
made in Shanghai

Who changed what in which revision?

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