High level Bluetooth Low Energy API and radio abstraction layer
Fork of BLE_API by
Revision 298:8785a8af8106, committed 2015-03-02
- Comitter:
- rgrover1
- Date:
- Mon Mar 02 11:50:47 2015 +0000
- Parent:
- 297:7036ac0bd496
- Child:
- 299:c1e4400af825
- Commit message:
- Synchronized with git rev 2a9ce45f
Author: Rohit Grover
Add a virtual function to allow underlying stacks to indicate if they support onDataRead()
Changed in this revision
public/GattServer.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/public/GattServer.h Mon Mar 02 11:50:47 2015 +0000 +++ b/public/GattServer.h Mon Mar 02 11:50:47 2015 +0000 @@ -64,12 +64,28 @@ void setOnDataWritten(T *objPtr, void (T::*memberPtr)(const GattCharacteristicWriteCBParams *context)) { onDataWritten.add(objPtr, memberPtr); } + + /** + * A virtual function to allow underlying stacks to indicate if they support + * onDataRead(). It should be overridden to return true as applicable. + */ + virtual bool isOnDataReadAvaialble() const { + return false; + } ble_error_t setOnDataRead(void (*callback)(const GattCharacteristicReadCBParams *eventDataP)) { + if (!isOnDataReadAvaialble()) { + return BLE_ERROR_NOT_IMPLEMENTED; + } + onDataRead.add(callback); return BLE_ERROR_NONE; } template <typename T> ble_error_t setOnDataRead(T *objPtr, void (T::*memberPtr)(const GattCharacteristicReadCBParams *context)) { + if (!isOnDataReadAvaialble()) { + return BLE_ERROR_NOT_IMPLEMENTED; + } + onDataRead.add(objPtr, memberPtr); return BLE_ERROR_NONE; }