![](/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
Diff: bricks/set.h
- Revision:
- 29:a6b74dfdd5f2
diff -r 307f58df778a -r a6b74dfdd5f2 bricks/set.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bricks/set.h Sun Oct 01 12:49:25 2017 +0000 @@ -0,0 +1,46 @@ +// set.h - set data from a characteristics +// +// Synopsis: +// +// Set data from a 'characteristic' based on 'data' variable +// +// set(characteristic,data) +// +// The 'set' function (overloaded function family) is implemented for all +// types defined in "bricks/types.h". +// +// See also: CHARACTERISTIC, GET +// +#ifndef _SET_H_ +#define _SET_H_ + +#include "ble/BLE.h" +#include "ble/Gap.h" +#include "ble/GattServer.h" +#include "bricks/o.h" +#include "bricks/types.h" +#include "bricks/characteristic.h" + + inline void set(O&o, Characteristic<Bool> &chr, const Bool &data) + { + uint16_t size = sizeof(Bool)/sizeof(uint8_t); + o.gattServer().write(chr.getValueHandle(), (uint8_t*)&data,size); + } + + inline void set(O&o, Characteristic<ObjectId> &chr, const ObjectId &data) + { + uint16_t size = sizeof(ObjectId)/sizeof(uint8_t); + o.gattServer().write(chr.getValueHandle(), (uint8_t*)&data,size); + } + +// we provide also some SET methods for GattCharacteristics. However the use +// of these methods are more dangerous, because a GattCharacteristics can be +// of any type and the compiler cannot help us to check !!! + + inline void set(O&o,GattCharacteristic &chr,Bool data) + { + uint16_t size = sizeof(Bool)/sizeof(uint8_t); + o.gattServer().write(chr.getValueHandle(), (uint8_t*)&data,size); + } + +#endif // _SET_H_ \ No newline at end of file