#49: replace DiscoveredCharacteristic::setupOnDataRead() with GattClient::onDataRead()
This commit is contained in:
parent
27bc31ee0c
commit
2d59404877
3 changed files with 35 additions and 15 deletions
|
@ -135,14 +135,6 @@ public:
|
|||
*/
|
||||
ble_error_t write(uint16_t length, const uint8_t *value) const;
|
||||
|
||||
static void setupOnDataRead(GattClient::ReadCallback_t callback) {
|
||||
onDataReadCallback = callback;
|
||||
}
|
||||
|
||||
static void setupOnDataWrite(GattClient::WriteCallback_t callback) {
|
||||
onDataWriteCallback = callback;
|
||||
}
|
||||
|
||||
void setupLongUUID(UUID::LongUUIDBytes_t longUUID) {
|
||||
uuid.setupLong(longUUID);
|
||||
}
|
||||
|
@ -182,10 +174,6 @@ protected:
|
|||
GattAttribute::Handle_t valueHandle;
|
||||
|
||||
Gap::Handle_t connHandle;
|
||||
|
||||
public:
|
||||
static GattClient::ReadCallback_t onDataReadCallback;
|
||||
static GattClient::WriteCallback_t onDataWriteCallback;
|
||||
};
|
||||
|
||||
#endif /*__DISCOVERED_CHARACTERISTIC_H__*/
|
||||
|
|
|
@ -207,6 +207,23 @@ public:
|
|||
return BLE_ERROR_NOT_IMPLEMENTED; /* default implementation; override this API if this capability is supported. */
|
||||
}
|
||||
|
||||
/* Event callback handlers. */
|
||||
public:
|
||||
/**
|
||||
* Setup a callback for read response events.
|
||||
*/
|
||||
void onDataRead(ReadCallback_t callback) {
|
||||
onDataReadCallback = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup a callback for write response events.
|
||||
* @Note: write commands (issued using writeWoResponse) don't generate a response.
|
||||
*/
|
||||
void onDataWrite(WriteCallback_t callback) {
|
||||
onDataWriteCallback = callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup callback for when serviceDiscovery terminates.
|
||||
*/
|
||||
|
@ -219,6 +236,24 @@ protected:
|
|||
/* empty */
|
||||
}
|
||||
|
||||
/* Entry points for the underlying stack to report events back to the user. */
|
||||
public:
|
||||
void processReadResponse(const GattReadCallbackParams *params) {
|
||||
if (onDataReadCallback) {
|
||||
onDataReadCallback(params);
|
||||
}
|
||||
}
|
||||
|
||||
void processWriteResponse(const GattWriteCallbackParams *params) {
|
||||
if (onDataWriteCallback) {
|
||||
onDataWriteCallback(params);
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
ReadCallback_t onDataReadCallback;
|
||||
WriteCallback_t onDataWriteCallback;
|
||||
|
||||
private:
|
||||
/* disallow copy and assignment */
|
||||
GattClient(const GattClient &);
|
||||
|
|
|
@ -17,9 +17,6 @@
|
|||
#include "ble/DiscoveredCharacteristic.h"
|
||||
#include "ble/GattClient.h"
|
||||
|
||||
GattClient::ReadCallback_t DiscoveredCharacteristic::onDataReadCallback;
|
||||
GattClient::WriteCallback_t DiscoveredCharacteristic::onDataWriteCallback;
|
||||
|
||||
ble_error_t
|
||||
DiscoveredCharacteristic::read(uint16_t offset) const
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue