fix #53: add GattClient::onHVX() and GattHVXCallbackParams

master
Rohit Grover 2015-07-06 09:31:37 +01:00
parent 4b21112e34
commit 0d55096d82
3 changed files with 31 additions and 0 deletions

View File

@ -75,4 +75,12 @@ struct GattReadAuthCallbackParams {
* request is to proceed; false otherwise. */
};
/* For encapsulating handle-value update events (notifications or indications) generated at the remote server. */
struct GattHVXCallbackParams {
GattAttribute::Handle_t handle; /**< Attribute Handle to which the HVx operation applies. */
HVXType_t type; /**< Indication or Notification, see @ref HVXType_t. */
uint16_t len; /**< Attribute data length. */
const uint8_t *data; /**< Attribute data, variable length. */
};
#endif /*__GATT_CALLBACK_PARAM_TYPES_H__*/

View File

@ -34,6 +34,8 @@ public:
typedef void (*WriteCallback_t)(const GattWriteCallbackParams *params);
typedef void (*HVXCallback_t)(const GattHVXCallbackParams *params);
/*
* The following functions are meant to be overridden in the platform-specific sub-class.
*/
@ -263,6 +265,15 @@ public:
/* default implementation; override this API if this capability is supported. */
}
/**
* Setup a callback for when GattClient receives an update event
* corresponding to a change in value of a characteristic on the remote
* GattServer.
*/
void onHVX(HVXCallback_t callback) {
onHVXCallback = callback;
}
protected:
GattClient() {
/* empty */
@ -282,9 +293,16 @@ public:
}
}
void processHVXEvent(const GattHVXCallbackParams *params) {
if (onHVXCallback) {
onHVXCallback(params);
}
}
protected:
ReadCallback_t onDataReadCallback;
WriteCallback_t onDataWriteCallback;
HVXCallback_t onHVXCallback;
private:
/* disallow copy and assignment */

View File

@ -129,6 +129,11 @@ enum ble_error_t {
/** @brief Default MTU size. */
static const unsigned BLE_GATT_MTU_SIZE_DEFAULT = 23;
enum HVXType_t {
BLE_HVX_NOTIFICATION = 0x01, /**< Handle Value Notification. */
BLE_HVX_INDICATION = 0x02, /**< Handle Value Indication. */
};
#ifdef __cplusplus
}
#endif