Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BLE_API by
Revision 655:4dce7c6d2eb3, committed 2015-06-19
- Comitter:
- rgrover1
- Date:
- Fri Jun 19 15:52:59 2015 +0100
- Parent:
- 654:3d76af29560a
- Child:
- 656:3508d314b9f8
- Commit message:
- Synchronized with git rev c01f76cf
Author: Rohit Grover
cleanup around GattCallbackParamTypes
Changed in this revision
--- a/public/BLEDevice.h Fri Jun 19 15:52:59 2015 +0100
+++ b/public/BLEDevice.h Fri Jun 19 15:52:59 2015 +0100
@@ -392,8 +392,8 @@
* @Note: it is also possible to setup a callback into a member function of
* some object.
*/
- void onDataWritten(void (*callback)(const GattCharacteristicWriteCBParams *eventDataP));
- template <typename T> void onDataWritten(T * objPtr, void (T::*memberPtr)(const GattCharacteristicWriteCBParams *context));
+ void onDataWritten(void (*callback)(const GattWriteCallbackParams *eventDataP));
+ template <typename T> void onDataWritten(T * objPtr, void (T::*memberPtr)(const GattWriteCallbackParams *context));
/**
* Setup a callback for when a characteristic is being read by a client.
@@ -413,8 +413,8 @@
* @return BLE_ERROR_NOT_IMPLEMENTED if this functionality isn't available;
* else BLE_ERROR_NONE.
*/
- ble_error_t onDataRead(void (*callback)(const GattCharacteristicReadCBParams *eventDataP));
- template <typename T> ble_error_t onDataRead(T * objPtr, void (T::*memberPtr)(const GattCharacteristicReadCBParams *context));
+ ble_error_t onDataRead(void (*callback)(const GattReadCallbackParams *eventDataP));
+ template <typename T> ble_error_t onDataRead(T * objPtr, void (T::*memberPtr)(const GattReadCallbackParams *context));
void onUpdatesEnabled(GattServer::EventCallback_t callback);
void onUpdatesDisabled(GattServer::EventCallback_t callback);
@@ -1001,22 +1001,22 @@
}
inline void
-BLEDevice::onDataWritten(void (*callback)(const GattCharacteristicWriteCBParams *eventDataP)) {
+BLEDevice::onDataWritten(void (*callback)(const GattWriteCallbackParams *eventDataP)) {
transport->getGattServer().setOnDataWritten(callback);
}
template <typename T> inline void
-BLEDevice::onDataWritten(T *objPtr, void (T::*memberPtr)(const GattCharacteristicWriteCBParams *context)) {
+BLEDevice::onDataWritten(T *objPtr, void (T::*memberPtr)(const GattWriteCallbackParams *context)) {
transport->getGattServer().setOnDataWritten(objPtr, memberPtr);
}
inline ble_error_t
-BLEDevice::onDataRead(void (*callback)(const GattCharacteristicReadCBParams *eventDataP)) {
+BLEDevice::onDataRead(void (*callback)(const GattReadCallbackParams *eventDataP)) {
return transport->getGattServer().setOnDataRead(callback);
}
template <typename T> inline ble_error_t
-BLEDevice::onDataRead(T *objPtr, void (T::*memberPtr)(const GattCharacteristicReadCBParams *context)) {
+BLEDevice::onDataRead(T *objPtr, void (T::*memberPtr)(const GattReadCallbackParams *context)) {
return transport->getGattServer().setOnDataRead(objPtr, memberPtr);
}
--- a/public/GattCharacteristic.h Fri Jun 19 15:52:59 2015 +0100
+++ b/public/GattCharacteristic.h Fri Jun 19 15:52:59 2015 +0100
@@ -355,21 +355,21 @@
/**
* Authorization.
*/
- void setWriteAuthorizationCallback(void (*callback)(GattCharacteristicWriteAuthCBParams *)) {
+ void setWriteAuthorizationCallback(void (*callback)(GattWriteAuthCallbackParams *)) {
writeAuthorizationCallback.attach(callback);
enabledWriteAuthorization = true;
}
template <typename T>
- void setWriteAuthorizationCallback(T *object, void (T::*member)(GattCharacteristicWriteAuthCBParams *)) {
+ void setWriteAuthorizationCallback(T *object, void (T::*member)(GattWriteAuthCallbackParams *)) {
writeAuthorizationCallback.attach(object, member);
enabledWriteAuthorization = true;
}
- void setReadAuthorizationCallback(void (*callback)(GattCharacteristicReadAuthCBParams *)) {
+ void setReadAuthorizationCallback(void (*callback)(GattReadAuthCallbackParams *)) {
readAuthorizationCallback.attach(callback);
enabledReadAuthorization = true;
}
template <typename T>
- void setReadAuthorizationCallback(T *object, void (T::*member)(GattCharacteristicReadAuthCBParams *)) {
+ void setReadAuthorizationCallback(T *object, void (T::*member)(GattReadAuthCallbackParams *)) {
readAuthorizationCallback.attach(object, member);
enabledReadAuthorization = true;
}
@@ -380,7 +380,7 @@
* @param params to capture the context of the write-auth request; and also contains an out-parameter for reply.
* @return true if the write is authorized to proceed.
*/
- GattCharacteristicAuthCBReply_t authorizeWrite(GattCharacteristicWriteAuthCBParams *params) {
+ GattAuthCallbackReply_t authorizeWrite(GattWriteAuthCallbackParams *params) {
if (!isWriteAuthorizationEnabled()) {
return AUTH_CALLBACK_REPLY_SUCCESS;
}
@@ -406,7 +406,7 @@
*
* @return true if the read is authorized to proceed.
*/
- GattCharacteristicAuthCBReply_t authorizeRead(GattCharacteristicReadAuthCBParams *params) {
+ GattAuthCallbackReply_t authorizeRead(GattReadAuthCallbackParams *params) {
if (!isReadAuthorizationEnabled()) {
return AUTH_CALLBACK_REPLY_SUCCESS;
}
@@ -444,8 +444,8 @@
bool enabledReadAuthorization;
bool enabledWriteAuthorization;
- FunctionPointerWithContext<GattCharacteristicReadAuthCBParams *> readAuthorizationCallback;
- FunctionPointerWithContext<GattCharacteristicWriteAuthCBParams *> writeAuthorizationCallback;
+ FunctionPointerWithContext<GattReadAuthCallbackParams *> readAuthorizationCallback;
+ FunctionPointerWithContext<GattWriteAuthCallbackParams *> writeAuthorizationCallback;
private:
/* disallow copy and assignment */
--- a/public/GattCharacteristicCallbackParams.h Fri Jun 19 15:52:59 2015 +0100
+++ b/public/GattCharacteristicCallbackParams.h Fri Jun 19 15:52:59 2015 +0100
@@ -14,33 +14,35 @@
* limitations under the License.
*/
-#ifndef __GATT_CHARACTERISTIC_CALLBACK_PARAMS_H__
-#define __GATT_CHARACTERISTIC_CALLBACK_PARAMS_H__
+#ifndef __GATT_CALLBACK_PARAM_TYPES_H__
+#define __GATT_CALLBACK_PARAM_TYPES_H__
-struct GattCharacteristicWriteCBParams {
- GattAttribute::Handle_t charHandle;
- enum Type {
- GATTS_CHAR_OP_INVALID = 0x00, /**< Invalid Operation. */
- GATTS_CHAR_OP_WRITE_REQ = 0x01, /**< Write Request. */
- GATTS_CHAR_OP_WRITE_CMD = 0x02, /**< Write Command. */
- GATTS_CHAR_OP_SIGN_WRITE_CMD = 0x03, /**< Signed Write Command. */
- GATTS_CHAR_OP_PREP_WRITE_REQ = 0x04, /**< Prepare Write Request. */
- GATTS_CHAR_OP_EXEC_WRITE_REQ_CANCEL = 0x05, /**< Execute Write Request: Cancel all prepared writes. */
- GATTS_CHAR_OP_EXEC_WRITE_REQ_NOW = 0x06, /**< Execute Write Request: Immediately execute all prepared writes. */
- } op; /**< Type of write operation, */
- uint16_t offset; /**< Offset for the write operation. */
- uint16_t len;
- const uint8_t *data; /* @note: data might not persist beyond the callback; make a local copy if needed. */
+struct GattWriteCallbackParams {
+ enum WriteOp_t {
+ OP_INVALID = 0x00, /**< Invalid Operation. */
+ OP_WRITE_REQ = 0x01, /**< Write Request. */
+ OP_WRITE_CMD = 0x02, /**< Write Command. */
+ OP_SIGN_WRITE_CMD = 0x03, /**< Signed Write Command. */
+ OP_PREP_WRITE_REQ = 0x04, /**< Prepare Write Request. */
+ OP_EXEC_WRITE_REQ_CANCEL = 0x05, /**< Execute Write Request: Cancel all prepared writes. */
+ OP_EXEC_WRITE_REQ_NOW = 0x06, /**< Execute Write Request: Immediately execute all prepared writes. */
+ };
+
+ GattAttribute::Handle_t handle;
+ WriteOp_t writeOp; /**< Type of write operation, */
+ uint16_t offset; /**< Offset for the write operation. */
+ uint16_t len;
+ const uint8_t *data; /* @note: data might not persist beyond the callback; make a local copy if needed. */
};
-struct GattCharacteristicReadCBParams {
- GattAttribute::Handle_t charHandle;
- uint16_t offset; /**< Offset for the read operation. */
+struct GattReadCallbackParams {
+ GattAttribute::Handle_t handle;
+ uint16_t offset; /**< Offset for the read operation. */
uint16_t len;
- const uint8_t *data; /* @note: data might not persist beyond the callback; make a local copy if needed. */
+ const uint8_t *data; /* @note: data might not persist beyond the callback; make a local copy if needed. */
};
-enum GattCharacteristicAuthCBReply_t {
+enum GattAuthCallbackReply_t {
AUTH_CALLBACK_REPLY_SUCCESS = 0x00, /**< Success. */
AUTH_CALLBACK_REPLY_ATTERR_INVALID_HANDLE = 0x0101, /**< ATT Error: Invalid Attribute Handle. */
AUTH_CALLBACK_REPLY_ATTERR_READ_NOT_PERMITTED = 0x0102, /**< ATT Error: Read not permitted. */
@@ -55,22 +57,22 @@
AUTH_CALLBACK_REPLY_ATTERR_INSUF_RESOURCES = 0x0111, /**< ATT Error: Encrypted link required. */
};
-struct GattCharacteristicWriteAuthCBParams {
- GattAttribute::Handle_t charHandle;
+struct GattWriteAuthCallbackParams {
+ GattAttribute::Handle_t handle;
uint16_t offset; /**< Offset for the write operation. */
uint16_t len; /**< Length of the incoming data. */
const uint8_t *data; /**< Incoming data, variable length. */
- GattCharacteristicAuthCBReply_t authorizationReply; /* This is the out parameter which needs to be set to true by the callback if the
- * request is to proceed; false otherwise. */
+ GattAuthCallbackReply_t authorizationReply; /* This is the out parameter which needs to be set to true by the callback if the
+ * request is to proceed; false otherwise. */
};
-struct GattCharacteristicReadAuthCBParams {
- GattAttribute::Handle_t charHandle;
+struct GattReadAuthCallbackParams {
+ GattAttribute::Handle_t handle;
uint16_t offset; /**< Offset for the read operation. */
uint16_t len; /**< Optional: new length of the outgoing data. */
uint8_t *data; /**< Optional: new outgoing data. Leave at NULL if data is unchanged. */
- GattCharacteristicAuthCBReply_t authorizationReply; /* This is the out parameter which needs to be set to true by the callback if the
- * request is to proceed; false otherwise. */
+ GattAuthCallbackReply_t authorizationReply; /* This is the out parameter which needs to be set to true by the callback if the
+ * request is to proceed; false otherwise. */
};
-#endif /*__GATT_CHARACTERISTIC_CALLBACK_PARAMS_H__*/
\ No newline at end of file
+#endif /*__GATT_CALLBACK_PARAM_TYPES_H__*/
\ No newline at end of file
--- a/public/GattClient.h Fri Jun 19 15:52:59 2015 +0100
+++ b/public/GattClient.h Fri Jun 19 15:52:59 2015 +0100
@@ -25,7 +25,7 @@
class GattClient {
public:
- typedef void (*ReadCallback_t)(const GattCharacteristicReadCBParams *params);
+ typedef void (*ReadCallback_t)(const GattReadCallbackParams *params);
enum WriteOp_t {
GATT_OP_INVALID = 0x00, /**< Invalid Operation. */
@@ -36,7 +36,7 @@
GATT_OP_EXEC_WRITE_REQ = 0x05, /**< Execute Write Request. */
};
- typedef void (*WriteCallback_t)(const GattCharacteristicWriteCBParams *params);
+ typedef void (*WriteCallback_t)(const GattWriteCallbackParams *params);
public:
/**
@@ -116,9 +116,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);
}
@@ -129,7 +129,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;
}
@@ -138,7 +138,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;
}
@@ -151,13 +151,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);
}
@@ -197,8 +197,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;
--- a/public/GattServer.h Fri Jun 19 15:52:59 2015 +0100
+++ b/public/GattServer.h Fri Jun 19 15:52:59 2015 +0100
@@ -63,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);
}
@@ -76,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;
}
@@ -85,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;
}
@@ -98,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);
}
@@ -144,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;
--- a/services/DFUService.h Fri Jun 19 15:52:59 2015 +0100
+++ b/services/DFUService.h Fri Jun 19 15:52:59 2015 +0100
@@ -94,8 +94,8 @@
* @param[in] params
* Information about the characterisitc being updated.
*/
- virtual void onDataWritten(const GattCharacteristicWriteCBParams *params) {
- if (params->charHandle == controlPoint.getValueHandle()) {
+ virtual void onDataWritten(const GattWriteCallbackParams *params) {
+ if (params->handle == controlPoint.getValueHandle()) {
/* At present, writing anything will do the trick--this needs to be improved. */
if (handoverCallback) {
handoverCallback();
--- a/services/HeartRateService.h Fri Jun 19 15:52:59 2015 +0100
+++ b/services/HeartRateService.h Fri Jun 19 15:52:59 2015 +0100
@@ -114,7 +114,7 @@
* @param[in] params
* Information about the characterisitc being updated.
*/
- virtual void onDataWritten(const GattCharacteristicWriteCBParams *params) {
+ virtual void onDataWritten(const GattWriteCallbackParams *params) {
if (params->charHandle == controlPoint.getValueAttribute().getHandle()) {
/* Do something here if the new value is 1; else you can override this method by
* extending this class.
--- a/services/LinkLossService.h Fri Jun 19 15:52:59 2015 +0100
+++ b/services/LinkLossService.h Fri Jun 19 15:52:59 2015 +0100
@@ -80,7 +80,7 @@
* @param[in] params
* Information about the characterisitc being updated.
*/
- virtual void onDataWritten(const GattCharacteristicWriteCBParams *params) {
+ virtual void onDataWritten(const GattWriteCallbackParams *params) {
if (params->charHandle == alertLevelChar.getValueHandle()) {
alertLevel = *reinterpret_cast<const AlertLevel_t *>(params->data);
}
--- a/services/UARTService.h Fri Jun 19 15:52:59 2015 +0100
+++ b/services/UARTService.h Fri Jun 19 15:52:59 2015 +0100
@@ -167,8 +167,8 @@
* function from the global onDataWritten() callback handler; or if that's
* not used, this method can be used as a callback directly.
*/
- void onDataWritten(const GattCharacteristicWriteCBParams *params) {
- if (params->charHandle == getTXCharacteristicHandle()) {
+ void onDataWritten(const GattWriteCallbackParams *params) {
+ if (params->handle == getTXCharacteristicHandle()) {
uint16_t bytesRead = params->len;
if (bytesRead <= BLE_UART_SERVICE_MAX_DATA_LEN) {
numBytesReceived = bytesRead;
--- a/services/URIBeaconConfigService.h Fri Jun 19 15:52:59 2015 +0100
+++ b/services/URIBeaconConfigService.h Fri Jun 19 15:52:59 2015 +0100
@@ -232,8 +232,8 @@
* characteristics of this service. Attempts to do so are also applied to
* the internal state of this service object.
*/
- void onDataWrittenCallback(const GattCharacteristicWriteCBParams *writeParams) {
- uint16_t handle = writeParams->charHandle;
+ void onDataWrittenCallback(const GattWriteCallbackParams *writeParams) {
+ uint16_t handle = writeParams->handle;
if (handle == lockChar.getValueHandle()) {
// Validated earlier
@@ -306,7 +306,7 @@
}
private:
- void lockAuthorizationCallback(GattCharacteristicWriteAuthCBParams *authParams) {
+ void lockAuthorizationCallback(GattWriteAuthCallbackParams *authParams) {
if (lockedState) {
authParams->authorizationReply = AUTH_CALLBACK_REPLY_ATTERR_INSUF_AUTHORIZATION;
} else if (authParams->len != sizeof(Lock_t)) {
@@ -319,7 +319,7 @@
}
- void unlockAuthorizationCallback(GattCharacteristicWriteAuthCBParams *authParams) {
+ void unlockAuthorizationCallback(GattWriteAuthCallbackParams *authParams) {
if (!lockedState) {
authParams->authorizationReply = AUTH_CALLBACK_REPLY_SUCCESS;
} else if (authParams->len != sizeof(Lock_t)) {
@@ -333,7 +333,7 @@
}
}
- void uriDataWriteAuthorizationCallback(GattCharacteristicWriteAuthCBParams *authParams) {
+ void uriDataWriteAuthorizationCallback(GattWriteAuthCallbackParams *authParams) {
if (lockedState) {
authParams->authorizationReply = AUTH_CALLBACK_REPLY_ATTERR_INSUF_AUTHORIZATION;
} else if (authParams->offset != 0) {
@@ -343,7 +343,7 @@
}
}
- void powerModeAuthorizationCallback(GattCharacteristicWriteAuthCBParams *authParams) {
+ void powerModeAuthorizationCallback(GattWriteAuthCallbackParams *authParams) {
if (lockedState) {
authParams->authorizationReply = AUTH_CALLBACK_REPLY_ATTERR_INSUF_AUTHORIZATION;
} else if (authParams->len != sizeof(uint8_t)) {
@@ -358,7 +358,7 @@
}
template <typename T>
- void basicAuthorizationCallback(GattCharacteristicWriteAuthCBParams *authParams) {
+ void basicAuthorizationCallback(GattWriteAuthCallbackParams *authParams) {
if (lockedState) {
authParams->authorizationReply = AUTH_CALLBACK_REPLY_ATTERR_INSUF_AUTHORIZATION;
} else if (authParams->len != sizeof(T)) {
