High level Bluetooth Low Energy API and radio abstraction layer
Fork of BLE_API by
Diff: public/GattServer.h
- Revision:
- 667:875aecb84719
- Parent:
- 660:9d73254fd76b
- Child:
- 669:7179b4a5aa7d
diff -r b4a737539c2c -r 875aecb84719 public/GattServer.h --- a/public/GattServer.h Fri Jun 19 15:53:01 2015 +0100 +++ b/public/GattServer.h Fri Jun 19 15:53:01 2015 +0100 @@ -21,7 +21,7 @@ #include "GattService.h" #include "GattAttribute.h" #include "GattServerEvents.h" -#include "GattCharacteristicCallbackParams.h" +#include "GattCallbackParamTypes.h" #include "CallChainOfFunctionPointersWithContext.h" class GattServer { @@ -43,7 +43,8 @@ /* empty */ } -public: + friend class BLEDevice; +private: /* 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; @@ -62,9 +63,9 @@ void setOnDataSent(T *objPtr, void (T::*memberPtr)(unsigned count)) { onDataSent.add(objPtr, memberPtr); } - void setOnDataWritten(void (*callback)(const GattCharacteristicWriteCBParams *eventDataP)) {onDataWritten.add(callback);} + void setOnDataWritten(void (*callback)(const GattWriteCallbackParams *eventDataP)) {onDataWritten.add(callback);} template <typename T> - void setOnDataWritten(T *objPtr, void (T::*memberPtr)(const GattCharacteristicWriteCBParams *context)) { + void setOnDataWritten(T *objPtr, void (T::*memberPtr)(const GattWriteCallbackParams *context)) { onDataWritten.add(objPtr, memberPtr); } @@ -75,7 +76,7 @@ virtual bool isOnDataReadAvailable() const { return false; } - ble_error_t setOnDataRead(void (*callback)(const GattCharacteristicReadCBParams *eventDataP)) { + ble_error_t setOnDataRead(void (*callback)(const GattReadCallbackParams *eventDataP)) { if (!isOnDataReadAvailable()) { return BLE_ERROR_NOT_IMPLEMENTED; } @@ -84,7 +85,7 @@ return BLE_ERROR_NONE; } template <typename T> - ble_error_t setOnDataRead(T *objPtr, void (T::*memberPtr)(const GattCharacteristicReadCBParams *context)) { + ble_error_t setOnDataRead(T *objPtr, void (T::*memberPtr)(const GattReadCallbackParams *context)) { if (!isOnDataReadAvailable()) { return BLE_ERROR_NOT_IMPLEMENTED; } @@ -97,13 +98,13 @@ void setOnConfirmationReceived(EventCallback_t callback) {onConfirmationReceived = callback;} protected: - void handleDataWrittenEvent(const GattCharacteristicWriteCBParams *params) { + void handleDataWrittenEvent(const GattWriteCallbackParams *params) { if (onDataWritten.hasCallbacksAttached()) { onDataWritten.call(params); } } - void handleDataReadEvent(const GattCharacteristicReadCBParams *params) { + void handleDataReadEvent(const GattReadCallbackParams *params) { if (onDataRead.hasCallbacksAttached()) { onDataRead.call(params); } @@ -143,8 +144,8 @@ private: CallChainOfFunctionPointersWithContext<unsigned> onDataSent; - CallChainOfFunctionPointersWithContext<const GattCharacteristicWriteCBParams *> onDataWritten; - CallChainOfFunctionPointersWithContext<const GattCharacteristicReadCBParams *> onDataRead; + CallChainOfFunctionPointersWithContext<const GattWriteCallbackParams *> onDataWritten; + CallChainOfFunctionPointersWithContext<const GattReadCallbackParams *> onDataRead; EventCallback_t onUpdatesEnabled; EventCallback_t onUpdatesDisabled; EventCallback_t onConfirmationReceived;