change BLECLientCharacteristic notify callback signature
from notify_cb(BLEClientCharacteristic& chr, uint8_t* data, uint16_t len) to notify_cb(BLEClientCharacteristic* chr, uint8_t* data, uint16_t len) Added
This commit is contained in:
1 parent
4747a9b7ae
commit
d0655b369d
9 files changed
+29
-23
No files matched your search
+5
-1
@@ -5,7 +5,11 @@
|
||||
- Fixed burning bootloader issue with MacOS
|
||||
- Added gpstest_swuart example sketch
|
||||
- Added indicate API for BLECharacteristic
|
||||
- Added useAdaCallback option to setNotifyCallback(), setIndicateCallback() for BLEClientCharacteristic
|
||||
- BLEClientCharacteristic
|
||||
- Added setIndicateCallback(), issue #113
|
||||
- Added useAdaCallback option to setNotifyCallback(), setIndicateCallback()
|
||||
- Change notify callback signature from
|
||||
notify_cb(BLEClientCharacteristic& chr, uint8_t* data, uint16_t len) to notify_cb(BLEClientCharacteristic* chr, uint8_t* data, uint16_t len)
|
||||
|
||||
## 0.8.1
|
||||
|
||||
|
||||
@@ -175,12 +175,12 @@ void disconnect_callback(uint16_t conn_handle, uint8_t reason)
|
||||
|
||||
/**
|
||||
* Hooked callback that triggered when a measurement value is sent from peripheral
|
||||
* @param chr Reference to client characteristic that even occurred,
|
||||
* @param chr Pointer client characteristic that even occurred,
|
||||
* in this example it should be hrmc
|
||||
* @param data Pointer to received data
|
||||
* @param len Length of received data
|
||||
*/
|
||||
void hrm_notify_callback(BLEClientCharacteristic& chr, uint8_t* data, uint16_t len)
|
||||
void hrm_notify_callback(BLEClientCharacteristic* chr, uint8_t* data, uint16_t len)
|
||||
{
|
||||
// https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.heart_rate_measurement.xml
|
||||
// Measurement contains of control byte0 and measurement (8 or 16 bit) + optional field
|
||||
|
||||
@@ -408,10 +408,11 @@ void BLEClientCharacteristic::_eventHandler(ble_evt_t* evt)
|
||||
if (!data) return;
|
||||
memcpy(data, hvx->data, hvx->len);
|
||||
|
||||
// data is free by callback
|
||||
ada_callback(data, _notify_cb, this, data, hvx->len);
|
||||
}else
|
||||
{
|
||||
_notify_cb(*this, hvx->data, hvx->len);
|
||||
_notify_cb(this, hvx->data, hvx->len);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -426,10 +427,11 @@ void BLEClientCharacteristic::_eventHandler(ble_evt_t* evt)
|
||||
if (!data) return;
|
||||
memcpy(data, hvx->data, hvx->len);
|
||||
|
||||
ada_callback(data, _notify_cb, this, data, hvx->len);
|
||||
// data is free by callback
|
||||
ada_callback(data, _indicate_cb, this, data, hvx->len);
|
||||
}else
|
||||
{
|
||||
_notify_cb(*this, hvx->data, hvx->len);
|
||||
_indicate_cb(this, hvx->data, hvx->len);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -47,8 +47,8 @@ class BLEClientCharacteristic
|
||||
{
|
||||
public:
|
||||
/*--------- Callback Signatures ----------*/
|
||||
typedef void (*notify_cb_t ) (BLEClientCharacteristic& chr, uint8_t* data, uint16_t len);
|
||||
typedef void (*indicate_cb_t) (BLEClientCharacteristic& chr, uint8_t* data, uint16_t len);
|
||||
typedef void (*notify_cb_t ) (BLEClientCharacteristic* chr, uint8_t* data, uint16_t len);
|
||||
typedef void (*indicate_cb_t) (BLEClientCharacteristic* chr, uint8_t* data, uint16_t len);
|
||||
|
||||
BLEUuid uuid;
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@
|
||||
|
||||
#define DEBUG_ANCS 0
|
||||
|
||||
void bleancs_notification_cb(BLEClientCharacteristic& chr, uint8_t* data, uint16_t len);
|
||||
void bleancs_data_cb(BLEClientCharacteristic& chr, uint8_t* data, uint16_t len);
|
||||
void bleancs_notification_cb(BLEClientCharacteristic* chr, uint8_t* data, uint16_t len);
|
||||
void bleancs_data_cb(BLEClientCharacteristic* chr, uint8_t* data, uint16_t len);
|
||||
|
||||
/* ANCS Service : 7905F431-B5CE-4E99-A40F-4B1E122D00D0
|
||||
* Control Point : 69D1D8F3-45E1-49A8-9821-9BBDFDAAD9D9
|
||||
@@ -383,14 +383,14 @@ bool BLEAncs::actNegative(uint32_t uid)
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Callback
|
||||
*------------------------------------------------------------------*/
|
||||
void bleancs_notification_cb(BLEClientCharacteristic& chr, uint8_t* data, uint16_t len)
|
||||
void bleancs_notification_cb(BLEClientCharacteristic* chr, uint8_t* data, uint16_t len)
|
||||
{
|
||||
BLEAncs& svc = (BLEAncs&) chr.parentService();
|
||||
BLEAncs& svc = (BLEAncs&) chr->parentService();
|
||||
svc._handleNotification(data, len);
|
||||
}
|
||||
|
||||
void bleancs_data_cb(BLEClientCharacteristic& chr, uint8_t* data, uint16_t len)
|
||||
void bleancs_data_cb(BLEClientCharacteristic* chr, uint8_t* data, uint16_t len)
|
||||
{
|
||||
BLEAncs& svc = (BLEAncs&) chr.parentService();
|
||||
BLEAncs& svc = (BLEAncs&) chr->parentService();
|
||||
svc._handleData(data, len);
|
||||
}
|
||||
@@ -177,8 +177,8 @@ class BLEAncs : public BLEClientService
|
||||
void _handleNotification(uint8_t* data, uint16_t len);
|
||||
void _handleData(uint8_t* data, uint16_t len);
|
||||
|
||||
friend void bleancs_notification_cb(BLEClientCharacteristic& chr, uint8_t* data, uint16_t len);
|
||||
friend void bleancs_data_cb (BLEClientCharacteristic& chr, uint8_t* data, uint16_t len);
|
||||
friend void bleancs_notification_cb(BLEClientCharacteristic* chr, uint8_t* data, uint16_t len);
|
||||
friend void bleancs_data_cb (BLEClientCharacteristic* chr, uint8_t* data, uint16_t len);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include "bluefruit.h"
|
||||
|
||||
void blects_central_notify_cb(BLEClientCharacteristic& chr, uint8_t* data, uint16_t len);
|
||||
void blects_central_notify_cb(BLEClientCharacteristic* chr, uint8_t* data, uint16_t len);
|
||||
|
||||
BLEClientCts::BLEClientCts(void)
|
||||
: BLEClientService(UUID16_SVC_CURRENT_TIME), _cur_time(UUID16_CHR_CURRENT_TIME), _local_info(UUID16_CHR_LOCAL_TIME_INFORMATION)
|
||||
@@ -107,7 +107,7 @@ void BLEClientCts::_cur_time_notify_cb(uint8_t* data, uint16_t len)
|
||||
if ( _adjust_cb ) _adjust_cb( Time.adjust_reason );
|
||||
}
|
||||
|
||||
void blects_central_notify_cb(BLEClientCharacteristic& chr, uint8_t* data, uint16_t len)
|
||||
void blects_central_notify_cb(BLEClientCharacteristic* chr, uint8_t* data, uint16_t len)
|
||||
{
|
||||
((BLEClientCts&) chr.parentService())._cur_time_notify_cb(data, len);
|
||||
((BLEClientCts&) chr->parentService())._cur_time_notify_cb(data, len);
|
||||
}
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include "bluefruit.h"
|
||||
|
||||
void bleuart_central_notify_cb(BLEClientCharacteristic& chr, uint8_t* data, uint16_t len);
|
||||
void bleuart_central_notify_cb(BLEClientCharacteristic* chr, uint8_t* data, uint16_t len);
|
||||
|
||||
BLEClientUart::BLEClientUart(uint16_t fifo_depth)
|
||||
: BLEClientService(BLEUART_UUID_SERVICE), _txd(BLEUART_UUID_CHR_TXD), _rxd(BLEUART_UUID_CHR_RXD),
|
||||
@@ -96,9 +96,9 @@ void BLEClientUart::disconnect(void)
|
||||
flush();
|
||||
}
|
||||
|
||||
void bleuart_central_notify_cb(BLEClientCharacteristic& chr, uint8_t* data, uint16_t len)
|
||||
void bleuart_central_notify_cb(BLEClientCharacteristic* chr, uint8_t* data, uint16_t len)
|
||||
{
|
||||
BLEClientUart& uart_svc = (BLEClientUart&) chr.parentService();
|
||||
BLEClientUart& uart_svc = (BLEClientUart&) chr->parentService();
|
||||
uart_svc._rx_fifo.write(data, len);
|
||||
|
||||
// invoke callback
|
||||
|
||||
@@ -83,7 +83,7 @@ class BLEClientUart : public BLEClientService, public Stream
|
||||
Adafruit_FIFO _rx_fifo;
|
||||
rx_callback_t _rx_cb;
|
||||
|
||||
friend void bleuart_central_notify_cb(BLEClientCharacteristic& chr, uint8_t* data, uint16_t len);
|
||||
friend void bleuart_central_notify_cb(BLEClientCharacteristic* chr, uint8_t* data, uint16_t len);
|
||||
};
|
||||
|
||||
#endif /* BLECLIENTUART_H_ */
|
||||
Reference in new issue
Block a user