TOF based Presence Detector
Dependencies: BLE_API X_NUCLEO_6180XA1 X_NUCLEO_IDB0XA1 mbed
Fork of BLE_HeartRate_IDB0XA1 by
bricks/init.h@27:32267cee7cb8, 2017-01-14 (annotated)
- Committer:
- hux
- Date:
- Sat Jan 14 08:43:14 2017 +0000
- Revision:
- 27:32267cee7cb8
Setup a GATT Detector Service. There is some bug in the GATT setup, resulting in different behavior between Nordic nRF51822-DK and NUCLEO-L476RG, but with the workaround it works also for the NUCLEO board. (using Bricks V1A)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hux | 27:32267cee7cb8 | 1 | // init.h - initialize BLE system |
hux | 27:32267cee7cb8 | 2 | // |
hux | 27:32267cee7cb8 | 3 | // Synopsis: |
hux | 27:32267cee7cb8 | 4 | // |
hux | 27:32267cee7cb8 | 5 | // void init(Blob &o, void (*scb)(Blob&),void (*ecb)(Blob&)) // init BLE |
hux | 27:32267cee7cb8 | 6 | // void init(Blob &o, void (*scb)(Blob&)) // init BLE |
hux | 27:32267cee7cb8 | 7 | // |
hux | 27:32267cee7cb8 | 8 | // Arguments: |
hux | 27:32267cee7cb8 | 9 | // |
hux | 27:32267cee7cb8 | 10 | // o: Blob object (to avoid name clashes) |
hux | 27:32267cee7cb8 | 11 | // scb: setup callback |
hux | 27:32267cee7cb8 | 12 | // ecb: error callback |
hux | 27:32267cee7cb8 | 13 | // |
hux | 27:32267cee7cb8 | 14 | // Description: |
hux | 27:32267cee7cb8 | 15 | // |
hux | 27:32267cee7cb8 | 16 | // Initialize BLE system, providing a setup callback and optionally an error |
hux | 27:32267cee7cb8 | 17 | // callback. The actual initializing happens in the setup callback. If an |
hux | 27:32267cee7cb8 | 18 | // error occurs during initializin, the error callback will be consulted. If |
hux | 27:32267cee7cb8 | 19 | // no error callback is provided an implicit error callback will be called. |
hux | 27:32267cee7cb8 | 20 | // |
hux | 27:32267cee7cb8 | 21 | // Example 1: simple BLE system setup |
hux | 27:32267cee7cb8 | 22 | // |
hux | 27:32267cee7cb8 | 23 | // void cbSetup(Blob &o) |
hux | 27:32267cee7cb8 | 24 | // { |
hux | 27:32267cee7cb8 | 25 | // device(o,"IoT node"); // setup device name |
hux | 27:32267cee7cb8 | 26 | // name(o,"Node #1"); // setup advertising name |
hux | 27:32267cee7cb8 | 27 | // advertise("C:ng"); // start advertising |
hux | 27:32267cee7cb8 | 28 | // } |
hux | 27:32267cee7cb8 | 29 | // |
hux | 27:32267cee7cb8 | 30 | // main(void) |
hux | 27:32267cee7cb8 | 31 | // { |
hux | 27:32267cee7cb8 | 32 | // Blob o; // our Blob object |
hux | 27:32267cee7cb8 | 33 | // init(o,cbSetup); // init BLE base layer, always do first |
hux | 27:32267cee7cb8 | 34 | // while (true) // Infinite loop waiting for BLE events |
hux | 27:32267cee7cb8 | 35 | // sleep(o); // low energy waiting |
hux | 27:32267cee7cb8 | 36 | // } |
hux | 27:32267cee7cb8 | 37 | // |
hux | 27:32267cee7cb8 | 38 | // Example 2: Provide also error handler |
hux | 27:32267cee7cb8 | 39 | // |
hux | 27:32267cee7cb8 | 40 | // void cbError(Blob &o) |
hux | 27:32267cee7cb8 | 41 | // { |
hux | 27:32267cee7cb8 | 42 | // trace(0,"init error!"); |
hux | 27:32267cee7cb8 | 43 | // } |
hux | 27:32267cee7cb8 | 44 | // |
hux | 27:32267cee7cb8 | 45 | // void cbSetup(Blob &o) |
hux | 27:32267cee7cb8 | 46 | // { |
hux | 27:32267cee7cb8 | 47 | // device(o,"IoT node"); // setup device name |
hux | 27:32267cee7cb8 | 48 | // name(o,"Node #1"); // setup advertising name |
hux | 27:32267cee7cb8 | 49 | // advertise("C:ng"); // start advertising |
hux | 27:32267cee7cb8 | 50 | // } |
hux | 27:32267cee7cb8 | 51 | // |
hux | 27:32267cee7cb8 | 52 | // main(void) |
hux | 27:32267cee7cb8 | 53 | // { |
hux | 27:32267cee7cb8 | 54 | // Blob o; // our Blob object |
hux | 27:32267cee7cb8 | 55 | // init(o,cbSetup,cbError); // init BLE base layer, always do first |
hux | 27:32267cee7cb8 | 56 | // while (true) // Infinite loop waiting for BLE events |
hux | 27:32267cee7cb8 | 57 | // sleep(o); // low energy waiting |
hux | 27:32267cee7cb8 | 58 | // } |
hux | 27:32267cee7cb8 | 59 | // |
hux | 27:32267cee7cb8 | 60 | // See also: BLOB, INIT |
hux | 27:32267cee7cb8 | 61 | // |
hux | 27:32267cee7cb8 | 62 | #ifndef _INIT_H_ |
hux | 27:32267cee7cb8 | 63 | #define _INIT_H_ |
hux | 27:32267cee7cb8 | 64 | |
hux | 27:32267cee7cb8 | 65 | #include "bricks/o.h" |
hux | 27:32267cee7cb8 | 66 | |
hux | 27:32267cee7cb8 | 67 | //============================================================================== |
hux | 27:32267cee7cb8 | 68 | // Initializing |
hux | 27:32267cee7cb8 | 69 | //============================================================================== |
hux | 27:32267cee7cb8 | 70 | |
hux | 27:32267cee7cb8 | 71 | void init(O&o, void (*scb)(O&o),void (*ecb)(O&o)); // init BLE |
hux | 27:32267cee7cb8 | 72 | void init(O&o, void (*scb)(O&o)); // init BLE system |
hux | 27:32267cee7cb8 | 73 | |
hux | 27:32267cee7cb8 | 74 | #endif // _INIT_H_ |