Bluetooth Connected TOF Sensor

Dependencies:   BLE_API X_NUCLEO_6180XA1 X_NUCLEO_IDB0XA1 mbed

Fork of BLE_HeartRate_IDB0XA1 by ST

main.cpp

Committer:
hux
Date:
2017-01-06
Revision:
25:231d3f382583
Parent:
24:0f08f68579bd
Child:
26:fd06c8b57d16

File content as of revision 25:231d3f382583:

// T07N_Easy_GATT - Easy GATT setup using bricks

#include "bricks.h"
#include "easy.h"

//==============================================================================
// Callbacks
//==============================================================================

   void onError(Blob &o)               // Error Reporting Callback
   {
      (void) o;                        // Avoid compiler warnings    
      blink(FAULT);                    // indicate advertising
   }    

   void onConnect(Blob &blue)          // Connection Callback
   {
      blink("x x x   ",CONNECTED);     // indicate advertising
   }

   void onDisconnect(Blob &blue)       // Disconnection Callback
   {
      blue.start();                    // start advertising on client disconnect
      blink(ADVERTISE);                // indicate advertising
   }

   void onSetup(Blob &o)               // Immediately After Initializing BLE 
   {
      easy(o);                         // enroll EASY services & setup callbacks

      o.onConnect(onConnect);          // setup connection callback
      o.onDisconnect(onDisconnect);    // setup disconnection callback
   
      device(o,"nRF51-DK");            // setup device name
      data(o,"ABCDEF");                // setup advertising data
      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
   }
   
//==============================================================================
// Main Program
//==============================================================================

   int main(void)
   {
      verbose();                        // print all verbose messages
      blink(IDLE);                      // idle blinking - just started!

      Blob blue;                        // declare a blob (BLE OBject)
      blue.init(onSetup,onError);       // init BLE base layer, always do first
      
      while (true)                      // Infinite loop waiting for BLE events
         blue.sleep();                  // low power waiting for BLE events 
   }