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