High level Bluetooth Low Energy API and radio abstraction layer
Fork of BLE_API by
Diff: public/GattServer.h
- Revision:
- 526:caa67c3187a0
- Parent:
- 524:6e97ab392e2a
- Child:
- 527:493185cebc03
--- a/public/GattServer.h Fri Jun 19 15:52:06 2015 +0100 +++ b/public/GattServer.h Fri Jun 19 15:52:06 2015 +0100 @@ -21,7 +21,7 @@ #include "GattService.h" #include "GattAttribute.h" #include "GattServerEvents.h" -#include "GattCallbackParamTypes.h" +#include "GattCharacteristicCallbackParams.h" #include "CallChainOfFunctionPointersWithContext.h" class GattServer { @@ -43,8 +43,7 @@ /* empty */ } - friend class BLEDevice; -private: +public: /* These functions must be defined in the sub-class */ virtual ble_error_t addService(GattService &) = 0; virtual ble_error_t readValue(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP) = 0; @@ -63,9 +62,9 @@ void setOnDataSent(T *objPtr, void (T::*memberPtr)(unsigned count)) { onDataSent.add(objPtr, memberPtr); } - void setOnDataWritten(void (*callback)(const GattWriteCallbackParams *eventDataP)) {onDataWritten.add(callback);} + void setOnDataWritten(void (*callback)(const GattCharacteristicWriteCBParams *eventDataP)) {onDataWritten.add(callback);} template <typename T> - void setOnDataWritten(T *objPtr, void (T::*memberPtr)(const GattWriteCallbackParams *context)) { + void setOnDataWritten(T *objPtr, void (T::*memberPtr)(const GattCharacteristicWriteCBParams *context)) { onDataWritten.add(objPtr, memberPtr); } @@ -76,7 +75,7 @@ virtual bool isOnDataReadAvailable() const { return false; } - ble_error_t setOnDataRead(void (*callback)(const GattReadCallbackParams *eventDataP)) { + ble_error_t setOnDataRead(void (*callback)(const GattCharacteristicReadCBParams *eventDataP)) { if (!isOnDataReadAvailable()) { return BLE_ERROR_NOT_IMPLEMENTED; } @@ -85,7 +84,7 @@ return BLE_ERROR_NONE; } template <typename T> - ble_error_t setOnDataRead(T *objPtr, void (T::*memberPtr)(const GattReadCallbackParams *context)) { + ble_error_t setOnDataRead(T *objPtr, void (T::*memberPtr)(const GattCharacteristicReadCBParams *context)) { if (!isOnDataReadAvailable()) { return BLE_ERROR_NOT_IMPLEMENTED; } @@ -98,13 +97,13 @@ void setOnConfirmationReceived(EventCallback_t callback) {onConfirmationReceived = callback;} protected: - void handleDataWrittenEvent(const GattWriteCallbackParams *params) { + void handleDataWrittenEvent(const GattCharacteristicWriteCBParams *params) { if (onDataWritten.hasCallbacksAttached()) { onDataWritten.call(params); } } - void handleDataReadEvent(const GattReadCallbackParams *params) { + void handleDataReadEvent(const GattCharacteristicReadCBParams *params) { if (onDataRead.hasCallbacksAttached()) { onDataRead.call(params); } @@ -144,8 +143,8 @@ private: CallChainOfFunctionPointersWithContext<unsigned> onDataSent; - CallChainOfFunctionPointersWithContext<const GattWriteCallbackParams *> onDataWritten; - CallChainOfFunctionPointersWithContext<const GattReadCallbackParams *> onDataRead; + CallChainOfFunctionPointersWithContext<const GattCharacteristicWriteCBParams *> onDataWritten; + CallChainOfFunctionPointersWithContext<const GattCharacteristicReadCBParams *> onDataRead; EventCallback_t onUpdatesEnabled; EventCallback_t onUpdatesDisabled; EventCallback_t onConfirmationReceived;