BLE NAND for ST Boards

Dependencies:   BLE_API X_NUCLEO_IDB0XA1 mbed

Fork of N06_NAND by Hugo Pristauz

Committer:
hux
Date:
Sun Jan 08 23:15:53 2017 +0000
Revision:
23:2e73c391bb12
A cute tiny piece of code implementing an Iot NAND device, demonstrating how to setup and advertise a cute GATT (NAND) service.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hux 23:2e73c391bb12 1 // sleep.h - sleep for some time
hux 23:2e73c391bb12 2 //
hux 23:2e73c391bb12 3 // Synopsis:
hux 23:2e73c391bb12 4 //
hux 23:2e73c391bb12 5 // void sleep(Blob &o) // low energy sleep for some mili seconds
hux 23:2e73c391bb12 6 // void sleep(Blob &o, int ms) // low enery sleep, handle BLE events
hux 23:2e73c391bb12 7 //
hux 23:2e73c391bb12 8 // Arguments:
hux 23:2e73c391bb12 9 //
hux 23:2e73c391bb12 10 // o: Blob object (to avoid name clashes)
hux 23:2e73c391bb12 11 // msec: sleeping interval in miliseconds
hux 23:2e73c391bb12 12 //
hux 23:2e73c391bb12 13 // Description:
hux 23:2e73c391bb12 14 //
hux 23:2e73c391bb12 15 //
hux 23:2e73c391bb12 16 // Example 1: main function body to setup BLE functionality
hux 23:2e73c391bb12 17 //
hux 23:2e73c391bb12 18 // main(void)
hux 23:2e73c391bb12 19 // {
hux 23:2e73c391bb12 20 // Blob o; // our Blob object
hux 23:2e73c391bb12 21 // init(o,onSetup,onError); // init BLE base layer, always do first
hux 23:2e73c391bb12 22 //
hux 23:2e73c391bb12 23 // while (true) // Infinite loop waiting for BLE events
hux 23:2e73c391bb12 24 // sleep(o); // low power waiting for BLE events
hux 23:2e73c391bb12 25 // }
hux 23:2e73c391bb12 26 //
hux 23:2e73c391bb12 27 // Example 2: Turn LED on for 2 seconds miliseconds
hux 23:2e73c391bb12 28 //
hux 23:2e73c391bb12 29 // led = 1; // turn LED on
hux 23:2e73c391bb12 30 // sleep(o,2000); // wait 2000 miliseconds (in LE mode)
hux 23:2e73c391bb12 31 // led = 0; // turn LED off
hux 23:2e73c391bb12 32 //
hux 23:2e73c391bb12 33 // See also: BLOB, INIT
hux 23:2e73c391bb12 34 //
hux 23:2e73c391bb12 35 #ifndef _SLEEP_H_
hux 23:2e73c391bb12 36 #define _SLEEP_H_
hux 23:2e73c391bb12 37
hux 23:2e73c391bb12 38 #include "bricks/blob.h"
hux 23:2e73c391bb12 39
hux 23:2e73c391bb12 40 inline void sleep(Blob &o) // low power waiting for BLE events
hux 23:2e73c391bb12 41 {
hux 23:2e73c391bb12 42 o.waitForEvent(); // low power waiting for BLE events
hux 23:2e73c391bb12 43 }
hux 23:2e73c391bb12 44
hux 23:2e73c391bb12 45 inline void sleep(Blob &o, int ms) // low power waiting for BLE events
hux 23:2e73c391bb12 46 {
hux 23:2e73c391bb12 47 wait_ms(ms); // low power waiting for some miliseconds
hux 23:2e73c391bb12 48 }
hux 23:2e73c391bb12 49
hux 23:2e73c391bb12 50 #endif // _SLEEP_H_