![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
TOF based Presence Detector
Dependencies: BLE_API X_NUCLEO_6180XA1 X_NUCLEO_IDB0XA1 mbed
Fork of BLE_HeartRate_IDB0XA1 by
Diff: main.cpp
- Revision:
- 27:32267cee7cb8
- Parent:
- 26:fd06c8b57d16
- Child:
- 28:a23b16555909
diff -r fd06c8b57d16 -r 32267cee7cb8 main.cpp --- a/main.cpp Sat Jan 07 15:38:15 2017 +0000 +++ b/main.cpp Sat Jan 14 08:43:14 2017 +0000 @@ -1,42 +1,41 @@ -// T07N_Easy_GATT - Easy GATT setup using bricks +// S07_Detection - Easy GATT setup using bricks for DETECTION services #include "bricks/bricks.h" -#include "easy.h" +#include "detection.h" //============================================================================== // Callbacks //============================================================================== - void onError(Blob &o) // Error Reporting Callback + void cbError(O&o) // Error Reporting Callback { - (void) o; // Avoid compiler warnings - blink(FAULT); // indicate advertising + blinkError(o); // 'error' blink sequence } - void onConnect(Blob &blue) // Connection Callback + void cbConnect(O&o) // Connection Callback { - blink("x x x ",CONNECTED); // indicate advertising + blinkConnected(o); // 'error' blink sequence } - void onDisconnect(Blob &blue) // Disconnection Callback + void cbDisconnect(O&o) // Disconnection Callback { - blue.start(); // start advertising on client disconnect - blink(ADVERTISE); // indicate advertising + advertise(o); // start advertising on client disconnect + blinkAdvertise(o); // 'advertise' blink sequence } - void onSetup(Blob &o) // Immediately After Initializing BLE + void cbSetup(O&o) // Immediately After Initializing BLE { - easy(o); // enroll EASY services & setup callbacks + services(o); // enroll all services & setup callbacks - o.onConnect(onConnect); // setup connection callback - o.onDisconnect(onDisconnect); // setup disconnection callback + onConnect(o,cbConnect); // setup connection callback + onDisconnect(o,cbDisconnect); // setup disconnection callback - device(o,"Easy"); // setup device name - data(o,"ABCDEF"); // setup advertising data - name(o,"T07N#2.4 Easy GATT"); // setup advertising name + device(o,"S07 Detector #3.47"); // setup device name + name(o,"Detector"); // setup advertising name + data(o,"My Layout"); // setup advertising data - peripheral(o,"C:ng",100); // start advertising @ 100 msec interval - blink(ADVERTISE); // show that board is advertising + advertise(o,"C:ng",100); // start advertising @ 100 msec interval + blinkAdvertise(o); // 'advertise' blink sequence } //============================================================================== @@ -45,12 +44,12 @@ int main(void) { - verbose(); // print all verbose messages - blink(IDLE); // idle blinking - just started! + O o; // declare a blob (BLE OBject) + verbose(o); // enable all trace messages + blinkIdle(o); // idle blinking - just started! - Blob blue; // declare a blob (BLE OBject) - blue.init(onSetup,onError); // init BLE base layer, always do first + init(o,cbSetup,cbError); // init BLE base layer, always do first while (true) // Infinite loop waiting for BLE events - blue.sleep(); // low power waiting for BLE events + sleep(o); // low power waiting for BLE events } \ No newline at end of file