enhance ada_callback, add malloc len for cleaner usage
This commit is contained in:
11 files changed
+51
-75
No files matched your search
@@ -413,12 +413,7 @@ void BLEClientCharacteristic::_eventHandler(ble_evt_t* evt)
|
||||
// use AdaCallback or invoke directly
|
||||
if (_use_ada_cb.notify)
|
||||
{
|
||||
uint8_t* data = (uint8_t*) rtos_malloc(hvx->len);
|
||||
if (!data) return;
|
||||
memcpy(data, hvx->data, hvx->len);
|
||||
|
||||
// data is free after callback
|
||||
ada_callback(data, _notify_cb, this, data, hvx->len);
|
||||
ada_callback(hvx->data, hvx->len, _notify_cb, this, hvx->data, hvx->len);
|
||||
}else
|
||||
{
|
||||
_notify_cb(this, hvx->data, hvx->len);
|
||||
@@ -432,12 +427,7 @@ void BLEClientCharacteristic::_eventHandler(ble_evt_t* evt)
|
||||
// use AdaCallback or invoke directly
|
||||
if (_use_ada_cb.indicate)
|
||||
{
|
||||
uint8_t* data = (uint8_t*) rtos_malloc(hvx->len);
|
||||
if (!data) return;
|
||||
memcpy(data, hvx->data, hvx->len);
|
||||
|
||||
// data is free by callback
|
||||
ada_callback(data, _indicate_cb, this, data, hvx->len);
|
||||
ada_callback(hvx->data, hvx->len, _indicate_cb, this, hvx->data, hvx->len);
|
||||
}else
|
||||
{
|
||||
_indicate_cb(this, hvx->data, hvx->len);
|
||||
|
||||
Reference in new issue
Block a user