BLE_API for nRF51
Fork of BLE_API by
Diff: ble/GattServer.h
- Revision:
- 728:997ba5e7b3b6
- Parent:
- 727:1a1f5c5aedfe
- Child:
- 729:951b577529c9
--- a/ble/GattServer.h Mon Jul 06 10:10:34 2015 +0100 +++ b/ble/GattServer.h Mon Jul 06 10:10:34 2015 +0100 @@ -53,7 +53,7 @@ * characteristics contained within. */ virtual ble_error_t addService(GattService &) { - return BLE_ERROR_NOT_IMPLEMENTED; /* default implementation; override this API if this capability is supported. */ + return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ } /** @@ -72,7 +72,7 @@ * @return BLE_ERROR_NONE if a value was read successfully into the buffer. */ virtual ble_error_t read(GattAttribute::Handle_t attributeHandle, uint8_t buffer[], uint16_t *lengthP) { - return BLE_ERROR_NOT_IMPLEMENTED; /* default implementation; override this API if this capability is supported. */ + return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ } /** @@ -94,10 +94,10 @@ * * @note This API is a version of above with an additional connection handle * parameter to allow fetches for connection-specific multivalued - * attribtues (such as the CCCDs). + * attributes (such as the CCCDs). */ virtual ble_error_t read(Gap::Handle_t connectionHandle, GattAttribute::Handle_t attributeHandle, uint8_t *buffer, uint16_t *lengthP) { - return BLE_ERROR_NOT_IMPLEMENTED; /* default implementation; override this API if this capability is supported. */ + return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ } /** @@ -119,13 +119,13 @@ * @return BLE_ERROR_NONE if we have successfully set the value of the attribute. */ virtual ble_error_t write(GattAttribute::Handle_t, const uint8_t *, uint16_t, bool localOnly = false) { - return BLE_ERROR_NOT_IMPLEMENTED; /* default implementation; override this API if this capability is supported. */ + return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ } /** * Update the value of a characteristic on the local GattServer. A version * of the same as above with connection handle parameter to allow updates - * for connection-specific multivalued attribtues (such as the CCCDs). + * for connection-specific multivalued attributes (such as the CCCDs). * * @param[in] connectionHandle * Connection Handle. @@ -145,7 +145,38 @@ * @return BLE_ERROR_NONE if we have successfully set the value of the attribute. */ virtual ble_error_t write(Gap::Handle_t connectionHandle, GattAttribute::Handle_t, const uint8_t *, uint16_t, bool localOnly = false) { - return BLE_ERROR_NOT_IMPLEMENTED; /* default implementation; override this API if this capability is supported. */ + return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ + } + + /** + * Determine the updates-enabled status (notification/indication) for the current connection from a characteristic's CCCD. + * + * @param characteristic + * The characteristic + * @param[out] enabledP + * Upon return, *enabledP is true if updates are enabled, else false. + * + * @return BLE_ERROR_NONE if the connection and handle are found. false otherwise. + */ + virtual ble_error_t areUpdatesEnabled(const GattCharacteristic &characteristic, bool *enabledP) { + return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ + } + + /** + * Determine the connection-specific updates-enabled status (notification/indication) from a characteristic's CCCD. + * + * @param connectionHandle + * The connection handle + * @param[out] enabledP + * Upon return, *enabledP is true if updates are enabled, else false. + * + * @param characteristic + * The characteristic + * + * @return BLE_ERROR_NONE if the connection and handle are found. false otherwise. + */ + virtual ble_error_t areUpdatesEnabled(Gap::Handle_t connectionHandle, const GattCharacteristic &characteristic, bool *enabledP) { + return BLE_ERROR_NOT_IMPLEMENTED; /* Requesting action from porter(s): override this API if this capability is supported. */ } /** @@ -267,21 +298,21 @@ } } - void handleEvent(GattServerEvents::gattEvent_e type, GattAttribute::Handle_t charHandle) { + void handleEvent(GattServerEvents::gattEvent_e type, GattAttribute::Handle_t attributeHandle) { switch (type) { case GattServerEvents::GATT_EVENT_UPDATES_ENABLED: if (updatesEnabledCallback) { - updatesEnabledCallback(charHandle); + updatesEnabledCallback(attributeHandle); } break; case GattServerEvents::GATT_EVENT_UPDATES_DISABLED: if (updatesDisabledCallback) { - updatesDisabledCallback(charHandle); + updatesDisabledCallback(attributeHandle); } break; case GattServerEvents::GATT_EVENT_CONFIRMATION_RECEIVED: if (confirmationReceivedCallback) { - confirmationReceivedCallback(charHandle); + confirmationReceivedCallback(attributeHandle); } break; default: