mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2024-11-22 13:10:55 +01:00
Bugfix/onRead callback not called for non-long read commands.
This commit is contained in:
parent
9285a9b31f
commit
93de7ab8ed
2 changed files with 15 additions and 8 deletions
|
@ -273,11 +273,13 @@ int NimBLECharacteristic::handleGapEvent(uint16_t conn_handle, uint16_t attr_han
|
||||||
if(ble_uuid_cmp(uuid, &pCharacteristic->getUUID().getNative()->u) == 0){
|
if(ble_uuid_cmp(uuid, &pCharacteristic->getUUID().getNative()->u) == 0){
|
||||||
switch(ctxt->op) {
|
switch(ctxt->op) {
|
||||||
case BLE_GATT_ACCESS_OP_READ_CHR: {
|
case BLE_GATT_ACCESS_OP_READ_CHR: {
|
||||||
// If the packet header is only 8 bytes this is a follow up of a long read
|
|
||||||
// so we don't want to call the onRead() callback again.
|
|
||||||
if(ctxt->om->om_pkthdr_len > 8) {
|
|
||||||
rc = ble_gap_conn_find(conn_handle, &desc);
|
rc = ble_gap_conn_find(conn_handle, &desc);
|
||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
|
|
||||||
|
// If the packet header is only 8 bytes this is a follow up of a long read
|
||||||
|
// so we don't want to call the onRead() callback again.
|
||||||
|
if(ctxt->om->om_pkthdr_len > 8 ||
|
||||||
|
pCharacteristic->m_value.size() <= (ble_att_mtu(desc.conn_handle) - 3)) {
|
||||||
pCharacteristic->m_pCallbacks->onRead(pCharacteristic);
|
pCharacteristic->m_pCallbacks->onRead(pCharacteristic);
|
||||||
pCharacteristic->m_pCallbacks->onRead(pCharacteristic, &desc);
|
pCharacteristic->m_pCallbacks->onRead(pCharacteristic, &desc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,6 +155,7 @@ int NimBLEDescriptor::handleGapEvent(uint16_t conn_handle, uint16_t attr_handle,
|
||||||
|
|
||||||
const ble_uuid_t *uuid;
|
const ble_uuid_t *uuid;
|
||||||
int rc;
|
int rc;
|
||||||
|
struct ble_gap_conn_desc desc;
|
||||||
NimBLEDescriptor* pDescriptor = (NimBLEDescriptor*)arg;
|
NimBLEDescriptor* pDescriptor = (NimBLEDescriptor*)arg;
|
||||||
|
|
||||||
NIMBLE_LOGD(LOG_TAG, "Descriptor %s %s event", pDescriptor->getUUID().toString().c_str(),
|
NIMBLE_LOGD(LOG_TAG, "Descriptor %s %s event", pDescriptor->getUUID().toString().c_str(),
|
||||||
|
@ -164,9 +165,13 @@ int NimBLEDescriptor::handleGapEvent(uint16_t conn_handle, uint16_t attr_handle,
|
||||||
if(ble_uuid_cmp(uuid, &pDescriptor->getUUID().getNative()->u) == 0){
|
if(ble_uuid_cmp(uuid, &pDescriptor->getUUID().getNative()->u) == 0){
|
||||||
switch(ctxt->op) {
|
switch(ctxt->op) {
|
||||||
case BLE_GATT_ACCESS_OP_READ_DSC: {
|
case BLE_GATT_ACCESS_OP_READ_DSC: {
|
||||||
|
rc = ble_gap_conn_find(conn_handle, &desc);
|
||||||
|
assert(rc == 0);
|
||||||
|
|
||||||
// If the packet header is only 8 bytes this is a follow up of a long read
|
// If the packet header is only 8 bytes this is a follow up of a long read
|
||||||
// so we don't want to call the onRead() callback again.
|
// so we don't want to call the onRead() callback again.
|
||||||
if(ctxt->om->om_pkthdr_len > 8) {
|
if(ctxt->om->om_pkthdr_len > 8 ||
|
||||||
|
pDescriptor->m_value.size() <= (ble_att_mtu(desc.conn_handle) - 3)) {
|
||||||
pDescriptor->m_pCallbacks->onRead(pDescriptor);
|
pDescriptor->m_pCallbacks->onRead(pDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue