![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
A blue button is always a nice toy ...
Dependencies: BLE_API X_NUCLEO_IDB0XA1 mbed
Fork of BLE_HeartRate_IDB0XA1 by
bricks/get.h@29:a6b74dfdd5f2, 2017-10-01 (annotated)
- Committer:
- hux
- Date:
- Sun Oct 01 12:49:25 2017 +0000
- Revision:
- 29:a6b74dfdd5f2
A blue button is always a nice toy ...
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hux | 29:a6b74dfdd5f2 | 1 | // get.h - get data from a characteristics |
hux | 29:a6b74dfdd5f2 | 2 | // |
hux | 29:a6b74dfdd5f2 | 3 | // Synopsis: |
hux | 29:a6b74dfdd5f2 | 4 | // |
hux | 29:a6b74dfdd5f2 | 5 | // Get data from a 'characteristic' into a 'data' variable |
hux | 29:a6b74dfdd5f2 | 6 | // |
hux | 29:a6b74dfdd5f2 | 7 | // get(characteristic,data) |
hux | 29:a6b74dfdd5f2 | 8 | // |
hux | 29:a6b74dfdd5f2 | 9 | // The 'get' function (overloaded function family) is implemented for all |
hux | 29:a6b74dfdd5f2 | 10 | // types defined in "bricks/types.h". |
hux | 29:a6b74dfdd5f2 | 11 | // |
hux | 29:a6b74dfdd5f2 | 12 | // See also: CHARACTERISTIC, SET |
hux | 29:a6b74dfdd5f2 | 13 | // |
hux | 29:a6b74dfdd5f2 | 14 | #ifndef _GET_H_ |
hux | 29:a6b74dfdd5f2 | 15 | #define _GET_H_ |
hux | 29:a6b74dfdd5f2 | 16 | |
hux | 29:a6b74dfdd5f2 | 17 | #include "ble/BLE.h" |
hux | 29:a6b74dfdd5f2 | 18 | #include "ble/Gap.h" |
hux | 29:a6b74dfdd5f2 | 19 | #include "ble/GattClient.h" |
hux | 29:a6b74dfdd5f2 | 20 | #include "bricks/o.h" |
hux | 29:a6b74dfdd5f2 | 21 | #include "bricks/types.h" |
hux | 29:a6b74dfdd5f2 | 22 | #include "bricks/characteristic.h" |
hux | 29:a6b74dfdd5f2 | 23 | |
hux | 29:a6b74dfdd5f2 | 24 | inline void get(O&o, Characteristic<Bool> &chr, Bool &data) |
hux | 29:a6b74dfdd5f2 | 25 | { |
hux | 29:a6b74dfdd5f2 | 26 | uint16_t size = sizeof(Bool)/sizeof(uint8_t); |
hux | 29:a6b74dfdd5f2 | 27 | o.gattServer().read(chr.getValueHandle(), (uint8_t*)&data,&size); |
hux | 29:a6b74dfdd5f2 | 28 | } |
hux | 29:a6b74dfdd5f2 | 29 | |
hux | 29:a6b74dfdd5f2 | 30 | inline void get(O&o, Characteristic<ObjectId> &chr, ObjectId &data) |
hux | 29:a6b74dfdd5f2 | 31 | { |
hux | 29:a6b74dfdd5f2 | 32 | uint16_t size = sizeof(ObjectId)/sizeof(uint8_t); |
hux | 29:a6b74dfdd5f2 | 33 | o.gattServer().read(chr.getValueHandle(), (uint8_t*)&data,&size); |
hux | 29:a6b74dfdd5f2 | 34 | } |
hux | 29:a6b74dfdd5f2 | 35 | |
hux | 29:a6b74dfdd5f2 | 36 | inline void get(O&o, Characteristic<Buffer> &chr, Buffer &data) |
hux | 29:a6b74dfdd5f2 | 37 | { |
hux | 29:a6b74dfdd5f2 | 38 | uint16_t size = sizeof(Buffer)/sizeof(uint8_t); |
hux | 29:a6b74dfdd5f2 | 39 | o.gattServer().read(chr.getValueHandle(), (uint8_t*)&data,&size); |
hux | 29:a6b74dfdd5f2 | 40 | } |
hux | 29:a6b74dfdd5f2 | 41 | |
hux | 29:a6b74dfdd5f2 | 42 | // we provide also some GET methods for GattCharacteristics. However the use |
hux | 29:a6b74dfdd5f2 | 43 | // of these methods are more dangerous, because a GattCharacteristics can be |
hux | 29:a6b74dfdd5f2 | 44 | // of any type and the compiler cannot help us to check !!! |
hux | 29:a6b74dfdd5f2 | 45 | |
hux | 29:a6b74dfdd5f2 | 46 | inline void get(O&o,GattCharacteristic &chr, Bool &data) |
hux | 29:a6b74dfdd5f2 | 47 | { |
hux | 29:a6b74dfdd5f2 | 48 | uint16_t size = sizeof(Bool)/sizeof(uint8_t); |
hux | 29:a6b74dfdd5f2 | 49 | o.gattServer().read(chr.getValueHandle(), (uint8_t*)&data, &size); |
hux | 29:a6b74dfdd5f2 | 50 | } |
hux | 29:a6b74dfdd5f2 | 51 | |
hux | 29:a6b74dfdd5f2 | 52 | #endif // _GET_H_ |