BLE NAND for ST Boards

Dependencies:   BLE_API X_NUCLEO_IDB0XA1 mbed

Fork of N06_NAND by Hugo Pristauz

Committer:
hux
Date:
Sat May 19 14:10:17 2018 +0000
Revision:
26:dce30a5341bb
Published

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hux 26:dce30a5341bb 1 // init.h - initialize BLE system
hux 26:dce30a5341bb 2 //
hux 26:dce30a5341bb 3 // Synopsis:
hux 26:dce30a5341bb 4 //
hux 26:dce30a5341bb 5 // void init(Blob &o, void (*scb)(Blob&),void (*ecb)(Blob&)) // init BLE
hux 26:dce30a5341bb 6 // void init(Blob &o, void (*scb)(Blob&)) // init BLE
hux 26:dce30a5341bb 7 //
hux 26:dce30a5341bb 8 // Arguments:
hux 26:dce30a5341bb 9 //
hux 26:dce30a5341bb 10 // o: Blob object (to avoid name clashes)
hux 26:dce30a5341bb 11 // scb: setup callback
hux 26:dce30a5341bb 12 // ecb: error callback
hux 26:dce30a5341bb 13 //
hux 26:dce30a5341bb 14 // Description:
hux 26:dce30a5341bb 15 //
hux 26:dce30a5341bb 16 // Initialize BLE system, providing a setup callback and optionally an error
hux 26:dce30a5341bb 17 // callback. The actual initializing happens in the setup callback. If an
hux 26:dce30a5341bb 18 // error occurs during initializin, the error callback will be consulted. If
hux 26:dce30a5341bb 19 // no error callback is provided an implicit error callback will be called.
hux 26:dce30a5341bb 20 //
hux 26:dce30a5341bb 21 // Example 1: simple BLE system setup
hux 26:dce30a5341bb 22 //
hux 26:dce30a5341bb 23 // void cbSetup(Blob &o)
hux 26:dce30a5341bb 24 // {
hux 26:dce30a5341bb 25 // device(o,"IoT node"); // setup device name
hux 26:dce30a5341bb 26 // name(o,"Node #1"); // setup advertising name
hux 26:dce30a5341bb 27 // advertise("C:ng"); // start advertising
hux 26:dce30a5341bb 28 // }
hux 26:dce30a5341bb 29 //
hux 26:dce30a5341bb 30 // main(void)
hux 26:dce30a5341bb 31 // {
hux 26:dce30a5341bb 32 // Blob o; // our Blob object
hux 26:dce30a5341bb 33 // init(o,cbSetup); // init BLE base layer, always do first
hux 26:dce30a5341bb 34 // while (true) // Infinite loop waiting for BLE events
hux 26:dce30a5341bb 35 // sleep(o); // low energy waiting
hux 26:dce30a5341bb 36 // }
hux 26:dce30a5341bb 37 //
hux 26:dce30a5341bb 38 // Example 2: Provide also error handler
hux 26:dce30a5341bb 39 //
hux 26:dce30a5341bb 40 // void cbError(Blob &o)
hux 26:dce30a5341bb 41 // {
hux 26:dce30a5341bb 42 // trace(0,"init error!");
hux 26:dce30a5341bb 43 // }
hux 26:dce30a5341bb 44 //
hux 26:dce30a5341bb 45 // void cbSetup(Blob &o)
hux 26:dce30a5341bb 46 // {
hux 26:dce30a5341bb 47 // device(o,"IoT node"); // setup device name
hux 26:dce30a5341bb 48 // name(o,"Node #1"); // setup advertising name
hux 26:dce30a5341bb 49 // advertise("C:ng"); // start advertising
hux 26:dce30a5341bb 50 // }
hux 26:dce30a5341bb 51 //
hux 26:dce30a5341bb 52 // main(void)
hux 26:dce30a5341bb 53 // {
hux 26:dce30a5341bb 54 // Blob o; // our Blob object
hux 26:dce30a5341bb 55 // init(o,cbSetup,cbError); // init BLE base layer, always do first
hux 26:dce30a5341bb 56 // while (true) // Infinite loop waiting for BLE events
hux 26:dce30a5341bb 57 // sleep(o); // low energy waiting
hux 26:dce30a5341bb 58 // }
hux 26:dce30a5341bb 59 //
hux 26:dce30a5341bb 60 // Example 3: Without Callbacks (busy waiting until initialized)
hux 26:dce30a5341bb 61 //
hux 26:dce30a5341bb 62 // main(void)
hux 26:dce30a5341bb 63 // {
hux 26:dce30a5341bb 64 // Blob o; // our Blob object
hux 26:dce30a5341bb 65 // init(o); // init BLE base layer, always do first
hux 26:dce30a5341bb 66 //
hux 26:dce30a5341bb 67 // device(o,"IoT node"); // setup device name
hux 26:dce30a5341bb 68 // name(o,"Node #1"); // setup advertising name
hux 26:dce30a5341bb 69 // advertise("C:ng"); // start advertising
hux 26:dce30a5341bb 70 //
hux 26:dce30a5341bb 71 // while (true) // Infinite loop waiting for BLE events
hux 26:dce30a5341bb 72 // sleep(o); // low energy waiting
hux 26:dce30a5341bb 73 // }
hux 26:dce30a5341bb 74 //
hux 26:dce30a5341bb 75 // See also: BLOB, INIT
hux 26:dce30a5341bb 76 //
hux 26:dce30a5341bb 77 #ifndef _INIT_H_
hux 26:dce30a5341bb 78 #define _INIT_H_
hux 26:dce30a5341bb 79
hux 26:dce30a5341bb 80 #include "bricks/o.h"
hux 26:dce30a5341bb 81
hux 26:dce30a5341bb 82 //==============================================================================
hux 26:dce30a5341bb 83 // Initializing
hux 26:dce30a5341bb 84 //==============================================================================
hux 26:dce30a5341bb 85
hux 26:dce30a5341bb 86 void init(O&o, void (*scb)(O&o),void (*ecb)(O&o)); // init BLE system
hux 26:dce30a5341bb 87 void init(O&o, void (*scb)(O&o)); // init BLE system
hux 26:dce30a5341bb 88 void init(O&o); // init BLE system
hux 26:dce30a5341bb 89
hux 26:dce30a5341bb 90 #endif // _INIT_H_