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