Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API X_NUCLEO_6180XA1 X_NUCLEO_IDB0XA1 mbed
Fork of BLE_HeartRate_IDB0XA1 by
bricks/init.h@30:e324e95c68a9, 2017-02-02 (annotated)
- Committer:
- hux
- Date:
- Thu Feb 02 17:35:34 2017 +0000
- Revision:
- 30:e324e95c68a9
- Parent:
- 29:cf61a5826426
Final Version 2.0 of S16_Blue_ToF
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| hux | 29:cf61a5826426 | 1 | // init.h - initialize BLE system |
| hux | 29:cf61a5826426 | 2 | // |
| hux | 29:cf61a5826426 | 3 | // Synopsis: |
| hux | 29:cf61a5826426 | 4 | // |
| hux | 29:cf61a5826426 | 5 | // void init(Blob &o, void (*scb)(Blob&),void (*ecb)(Blob&)) // init BLE |
| hux | 29:cf61a5826426 | 6 | // void init(Blob &o, void (*scb)(Blob&)) // init BLE |
| hux | 29:cf61a5826426 | 7 | // |
| hux | 29:cf61a5826426 | 8 | // Arguments: |
| hux | 29:cf61a5826426 | 9 | // |
| hux | 29:cf61a5826426 | 10 | // o: Blob object (to avoid name clashes) |
| hux | 29:cf61a5826426 | 11 | // scb: setup callback |
| hux | 29:cf61a5826426 | 12 | // ecb: error callback |
| hux | 29:cf61a5826426 | 13 | // |
| hux | 29:cf61a5826426 | 14 | // Description: |
| hux | 29:cf61a5826426 | 15 | // |
| hux | 29:cf61a5826426 | 16 | // Initialize BLE system, providing a setup callback and optionally an error |
| hux | 29:cf61a5826426 | 17 | // callback. The actual initializing happens in the setup callback. If an |
| hux | 29:cf61a5826426 | 18 | // error occurs during initializin, the error callback will be consulted. If |
| hux | 29:cf61a5826426 | 19 | // no error callback is provided an implicit error callback will be called. |
| hux | 29:cf61a5826426 | 20 | // |
| hux | 29:cf61a5826426 | 21 | // Example 1: simple BLE system setup |
| hux | 29:cf61a5826426 | 22 | // |
| hux | 29:cf61a5826426 | 23 | // void cbSetup(Blob &o) |
| hux | 29:cf61a5826426 | 24 | // { |
| hux | 29:cf61a5826426 | 25 | // device(o,"IoT node"); // setup device name |
| hux | 29:cf61a5826426 | 26 | // name(o,"Node #1"); // setup advertising name |
| hux | 29:cf61a5826426 | 27 | // advertise("C:ng"); // start advertising |
| hux | 29:cf61a5826426 | 28 | // } |
| hux | 29:cf61a5826426 | 29 | // |
| hux | 29:cf61a5826426 | 30 | // main(void) |
| hux | 29:cf61a5826426 | 31 | // { |
| hux | 29:cf61a5826426 | 32 | // Blob o; // our Blob object |
| hux | 29:cf61a5826426 | 33 | // init(o,cbSetup); // init BLE base layer, always do first |
| hux | 29:cf61a5826426 | 34 | // while (true) // Infinite loop waiting for BLE events |
| hux | 29:cf61a5826426 | 35 | // sleep(o); // low energy waiting |
| hux | 29:cf61a5826426 | 36 | // } |
| hux | 29:cf61a5826426 | 37 | // |
| hux | 29:cf61a5826426 | 38 | // Example 2: Provide also error handler |
| hux | 29:cf61a5826426 | 39 | // |
| hux | 29:cf61a5826426 | 40 | // void cbError(Blob &o) |
| hux | 29:cf61a5826426 | 41 | // { |
| hux | 29:cf61a5826426 | 42 | // trace(0,"init error!"); |
| hux | 29:cf61a5826426 | 43 | // } |
| hux | 29:cf61a5826426 | 44 | // |
| hux | 29:cf61a5826426 | 45 | // void cbSetup(Blob &o) |
| hux | 29:cf61a5826426 | 46 | // { |
| hux | 29:cf61a5826426 | 47 | // device(o,"IoT node"); // setup device name |
| hux | 29:cf61a5826426 | 48 | // name(o,"Node #1"); // setup advertising name |
| hux | 29:cf61a5826426 | 49 | // advertise("C:ng"); // start advertising |
| hux | 29:cf61a5826426 | 50 | // } |
| hux | 29:cf61a5826426 | 51 | // |
| hux | 29:cf61a5826426 | 52 | // main(void) |
| hux | 29:cf61a5826426 | 53 | // { |
| hux | 29:cf61a5826426 | 54 | // Blob o; // our Blob object |
| hux | 29:cf61a5826426 | 55 | // init(o,cbSetup,cbError); // init BLE base layer, always do first |
| hux | 29:cf61a5826426 | 56 | // while (true) // Infinite loop waiting for BLE events |
| hux | 29:cf61a5826426 | 57 | // sleep(o); // low energy waiting |
| hux | 29:cf61a5826426 | 58 | // } |
| hux | 29:cf61a5826426 | 59 | // |
| hux | 29:cf61a5826426 | 60 | // Example 3: Without Callbacks (busy waiting until initialized) |
| hux | 29:cf61a5826426 | 61 | // |
| hux | 29:cf61a5826426 | 62 | // main(void) |
| hux | 29:cf61a5826426 | 63 | // { |
| hux | 29:cf61a5826426 | 64 | // Blob o; // our Blob object |
| hux | 29:cf61a5826426 | 65 | // init(o); // init BLE base layer, always do first |
| hux | 29:cf61a5826426 | 66 | // |
| hux | 29:cf61a5826426 | 67 | // device(o,"IoT node"); // setup device name |
| hux | 29:cf61a5826426 | 68 | // name(o,"Node #1"); // setup advertising name |
| hux | 29:cf61a5826426 | 69 | // advertise("C:ng"); // start advertising |
| hux | 29:cf61a5826426 | 70 | // |
| hux | 29:cf61a5826426 | 71 | // while (true) // Infinite loop waiting for BLE events |
| hux | 29:cf61a5826426 | 72 | // sleep(o); // low energy waiting |
| hux | 29:cf61a5826426 | 73 | // } |
| hux | 29:cf61a5826426 | 74 | // |
| hux | 29:cf61a5826426 | 75 | // See also: BLOB, INIT |
| hux | 29:cf61a5826426 | 76 | // |
| hux | 29:cf61a5826426 | 77 | #ifndef _INIT_H_ |
| hux | 29:cf61a5826426 | 78 | #define _INIT_H_ |
| hux | 29:cf61a5826426 | 79 | |
| hux | 29:cf61a5826426 | 80 | #include "bricks/o.h" |
| hux | 29:cf61a5826426 | 81 | |
| hux | 29:cf61a5826426 | 82 | //============================================================================== |
| hux | 29:cf61a5826426 | 83 | // Initializing |
| hux | 29:cf61a5826426 | 84 | //============================================================================== |
| hux | 29:cf61a5826426 | 85 | |
| hux | 29:cf61a5826426 | 86 | void init(O&o, void (*scb)(O&o),void (*ecb)(O&o)); // init BLE system |
| hux | 29:cf61a5826426 | 87 | void init(O&o, void (*scb)(O&o)); // init BLE system |
| hux | 29:cf61a5826426 | 88 | void init(O&o); // init BLE system |
| hux | 29:cf61a5826426 | 89 | |
| hux | 29:cf61a5826426 | 90 | #endif // _INIT_H_ |
