![](/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: main.cpp
- Revision:
- 25:231d3f382583
- Parent:
- 24:0f08f68579bd
- Child:
- 26:fd06c8b57d16
diff -r 0f08f68579bd -r 231d3f382583 main.cpp --- a/main.cpp Fri Jan 06 20:49:58 2017 +0000 +++ b/main.cpp Fri Jan 06 21:36:47 2017 +0000 @@ -1,40 +1,7 @@ // T07N_Easy_GATT - Easy GATT setup using bricks #include "bricks.h" - -//============================================================================== -// Custom Service Setup -//============================================================================== - -// Detection Service - - Service detection(0xA010,"Detection"); // Detection Service - - Characteristic<Digital> chrPresence(detection,0xA011, "rn", "Presence"); - Characteristic<DateTime> chrTimestamp(detection,0xA012, "r", "Timestamp"); - -// Address Service - - Service address(0xA020,"Adress"); // Address Service - - Characteristic<Digital> chrId(address, 0xA021, "ran", "ID"); - Characteristic<Digital> chrName(address, 0xA022, "ran", "Name"); - Characteristic<Digital> chrLayout(address, 0xA023, "ran", "Layout"); - -// Debug Service - - Service debug(0xA030,"Debug"); // Debug Service - - Characteristic<Digital> chrTest (debug,0xA031, "w", "Test"); - -// Configure all supported services - - void services(Blob &o) // configure all supported services - { - address.config(o); // configure Address Service - detection.config(o); // configure Detection Service - debug.config(o); // configure Debug Service - } +#include "easy.h" //============================================================================== // Callbacks @@ -57,30 +24,16 @@ blink(ADVERTISE); // indicate advertising } - void onWritten(Blob &o) // Handle writes to writeCharacteristic - { - if (updated(o,chrTest)) // has chrTest been updated? - { Digital value; - - get(o,chrTest,value); // get value of chrTest - set(o,chrPresence,value); // and store this value to chrPresence - - print(o,chrTest,"test"); - blink("x x x xxx xxx xxx x ",CONNECTED); - } - } - void onSetup(Blob &o) // Immediately After Initializing BLE { - services(o); // config all services + easy(o); // enroll EASY services & setup callbacks o.onConnect(onConnect); // setup connection callback o.onDisconnect(onDisconnect); // setup disconnection callback - o.onWritten(onWritten); // setup data written callback device(o,"nRF51-DK"); // setup device name data(o,"ABCDEF"); // setup advertising data - name(o,"T07N#1.0 Easy GATT"); // setup advertising name + name(o,"T07N#1.1 Easy GATT"); // setup advertising name peripheral(o,"C:ng",100); // start advertising @ 100 msec interval blink(ADVERTISE); // show that board is advertising @@ -92,7 +45,7 @@ int main(void) { - verbose(10); // print all verbose messages + verbose(); // print all verbose messages blink(IDLE); // idle blinking - just started! Blob blue; // declare a blob (BLE OBject)