A blue button is always a nice toy ...
Dependencies: BLE_API X_NUCLEO_IDB0XA1 mbed
Fork of BLE_HeartRate_IDB0XA1 by
bricks/set.h@23:677689000369, 2017-01-06 (annotated)
- Committer:
- hux
- Date:
- Fri Jan 06 15:28:18 2017 +0000
- Revision:
- 23:677689000369
- Child:
- 26:fd06c8b57d16
Already nice & easy level. Still bugs!
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hux | 23:677689000369 | 1 | // set.h - set data from a characteristics |
hux | 23:677689000369 | 2 | // |
hux | 23:677689000369 | 3 | // Synopsis: |
hux | 23:677689000369 | 4 | // |
hux | 23:677689000369 | 5 | // Set data from a 'characteristic' based on 'data' variable |
hux | 23:677689000369 | 6 | // |
hux | 23:677689000369 | 7 | // set(characteristic,data) |
hux | 23:677689000369 | 8 | // |
hux | 23:677689000369 | 9 | // The 'set' 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, GET |
hux | 23:677689000369 | 13 | // |
hux | 23:677689000369 | 14 | #ifndef _SET_H_ |
hux | 23:677689000369 | 15 | #define _SET_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/GattServer.h" |
hux | 23:677689000369 | 20 | #include "bricks/blob.h" |
hux | 23:677689000369 | 21 | #include "bricks/types.h" |
hux | 23:677689000369 | 22 | #include "bricks/characteristic.h" |
hux | 23:677689000369 | 23 | |
hux | 23:677689000369 | 24 | inline void set(Blob &blue, Characteristic<Digital> &chr, const Digital &data) |
hux | 23:677689000369 | 25 | { |
hux | 23:677689000369 | 26 | uint16_t size = sizeof(Digital)/sizeof(uint8_t); |
hux | 23:677689000369 | 27 | blue.gatt().write(chr.getValueHandle(), (uint8_t*)&data,size); |
hux | 23:677689000369 | 28 | } |
hux | 23:677689000369 | 29 | |
hux | 23:677689000369 | 30 | inline void set(Blob &blue, Characteristic<ObjectId> &chr, const ObjectId &data) |
hux | 23:677689000369 | 31 | { |
hux | 23:677689000369 | 32 | uint16_t size = sizeof(ObjectId)/sizeof(uint8_t); |
hux | 23:677689000369 | 33 | blue.gatt().write(chr.getValueHandle(), (uint8_t*)&data,size); |
hux | 23:677689000369 | 34 | } |
hux | 23:677689000369 | 35 | |
hux | 23:677689000369 | 36 | #endif // _SET_H_ |