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.
Diff: ble/GattClient.h
- Revision:
- 966:9451b90bbb66
- Parent:
- 960:76bbf8c803cf
- Child:
- 969:61f13bc8edbf
diff -r 212c16f6247f -r 9451b90bbb66 ble/GattClient.h
--- a/ble/GattClient.h Thu Nov 26 12:52:34 2015 +0000
+++ b/ble/GattClient.h Thu Nov 26 12:52:34 2015 +0000
@@ -23,23 +23,18 @@
#include "GattCallbackParamTypes.h"
-#include "CallChainOfFunctionPointersWithContext.h"
-
class GattClient {
public:
- typedef FunctionPointerWithContext<const GattReadCallbackParams*> ReadCallback_t;
- typedef CallChainOfFunctionPointersWithContext<const GattReadCallbackParams*> ReadCallbackChain_t;
+ typedef void (*ReadCallback_t)(const GattReadCallbackParams *params);
enum WriteOp_t {
GATT_OP_WRITE_REQ = 0x01, /**< Write request. */
GATT_OP_WRITE_CMD = 0x02, /**< Write command. */
};
- typedef FunctionPointerWithContext<const GattWriteCallbackParams*> WriteCallback_t;
- typedef CallChainOfFunctionPointersWithContext<const GattWriteCallbackParams*> WriteCallbackChain_t;
+ typedef void (*WriteCallback_t)(const GattWriteCallbackParams *params);
- typedef FunctionPointerWithContext<const GattHVXCallbackParams*> HVXCallback_t;
- typedef CallChainOfFunctionPointersWithContext<const GattHVXCallbackParams*> HVXCallbackChain_t;
+ typedef void (*HVXCallback_t)(const GattHVXCallbackParams *params);
/*
* The following functions are meant to be overridden in the platform-specific sub-class.
@@ -249,11 +244,7 @@
* Set up a callback for read response events.
*/
void onDataRead(ReadCallback_t callback) {
- onDataReadCallbackChain.add(callback);
- }
-
- ReadCallbackChain_t& onDataRead() {
- return onDataReadCallbackChain;
+ onDataReadCallback = callback;
}
/**
@@ -261,11 +252,7 @@
* @Note: Write commands (issued using writeWoResponse) don't generate a response.
*/
void onDataWritten(WriteCallback_t callback) {
- onDataWriteCallbackChain.add(callback);
- }
-
- WriteCallbackChain_t& onDataWritten() {
- return onDataWriteCallbackChain;
+ onDataWriteCallback = callback;
}
/**
@@ -294,11 +281,7 @@
* GATT server.
*/
void onHVX(HVXCallback_t callback) {
- onHVXCallbackChain.add(callback);
- }
-
- HVXCallbackChain_t& onHVX() {
- return onHVXCallbackChain;
+ onHVXCallback = callback;
}
protected:
@@ -309,23 +292,27 @@
/* Entry points for the underlying stack to report events back to the user. */
public:
void processReadResponse(const GattReadCallbackParams *params) {
- onDataReadCallbackChain(params);
+ if (onDataReadCallback) {
+ onDataReadCallback(params);
+ }
}
void processWriteResponse(const GattWriteCallbackParams *params) {
- onDataWriteCallbackChain(params);
+ if (onDataWriteCallback) {
+ onDataWriteCallback(params);
+ }
}
void processHVXEvent(const GattHVXCallbackParams *params) {
- if (onHVXCallbackChain) {
- onHVXCallbackChain(params);
+ if (onHVXCallback) {
+ onHVXCallback(params);
}
}
protected:
- ReadCallbackChain_t onDataReadCallbackChain;
- WriteCallbackChain_t onDataWriteCallbackChain;
- HVXCallbackChain_t onHVXCallbackChain;
+ ReadCallback_t onDataReadCallback;
+ WriteCallback_t onDataWriteCallback;
+ HVXCallback_t onHVXCallback;
private:
/* Disallow copy and assignment. */