Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: BLE_API X_NUCLEO_6180XA1 X_NUCLEO_IDB0XA1 mbed
Fork of BLE_HeartRate_IDB0XA1 by
get.h
00001 // get.h - get data from a characteristics 00002 // 00003 // Synopsis: 00004 // 00005 // Get data from a 'characteristic' into a 'data' variable 00006 // 00007 // get(characteristic,data) 00008 // 00009 // The 'get' function (overloaded function family) is implemented for all 00010 // types defined in "bricks/types.h". 00011 // 00012 // See also: CHARACTERISTIC, SET 00013 // 00014 #ifndef _GET_H_ 00015 #define _GET_H_ 00016 00017 #include "ble/BLE.h" 00018 #include "ble/Gap.h" 00019 #include "ble/GattClient.h" 00020 #include "bricks/o.h" 00021 #include "bricks/types.h" 00022 #include "bricks/characteristic.h" 00023 00024 inline void get(O&o, Characteristic<Bool> &chr, Bool &data) 00025 { 00026 uint16_t size = sizeof(Bool)/sizeof(uint8_t); 00027 o.gattServer().read(chr.getValueHandle(), (uint8_t*)&data,&size); 00028 } 00029 00030 inline void get(O&o, Characteristic<Int> &chr, Int &data) 00031 { 00032 uint16_t size = sizeof(Int)/sizeof(uint8_t); 00033 o.gattServer().read(chr.getValueHandle(), (uint8_t*)&data,&size); 00034 } 00035 00036 inline void get(O&o, Characteristic<ObjectId> &chr, ObjectId &data) 00037 { 00038 uint16_t size = sizeof(ObjectId)/sizeof(uint8_t); 00039 o.gattServer().read(chr.getValueHandle(), (uint8_t*)&data,&size); 00040 } 00041 00042 inline void get(O&o, Characteristic<Buffer> &chr, Buffer &data) 00043 { 00044 uint16_t size = sizeof(Buffer)/sizeof(uint8_t); 00045 o.gattServer().read(chr.getValueHandle(), (uint8_t*)&data,&size); 00046 } 00047 00048 // we provide also some GET methods for GattCharacteristics. However the use 00049 // of these methods are more dangerous, because a GattCharacteristics can be 00050 // of any type and the compiler cannot help us to check !!! 00051 00052 inline void get(O&o,GattCharacteristic &chr, Bool &data) 00053 { 00054 uint16_t size = sizeof(Bool)/sizeof(uint8_t); 00055 o.gattServer().read(chr.getValueHandle(), (uint8_t*)&data, &size); 00056 } 00057 00058 #endif // _GET_H_
Generated on Sat Jul 16 2022 07:45:39 by
1.7.2
