mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2024-11-24 06:00:55 +01:00
Remove descriptor asserts when the connection info is not found.
* Trigger onRead callbacks when the connection handle is NONE (internal).
This commit is contained in:
parent
b8d6e3d87f
commit
a5dd84b2f9
2 changed files with 5 additions and 6 deletions
|
@ -282,6 +282,7 @@ int NimBLECharacteristic::handleGapEvent(uint16_t conn_handle, uint16_t attr_han
|
||||||
// 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 ||
|
||||||
|
conn_handle == BLE_HS_CONN_HANDLE_NONE ||
|
||||||
pCharacteristic->m_value.size() <= (ble_att_mtu(peerInfo.m_desc.conn_handle) - 3)) {
|
pCharacteristic->m_value.size() <= (ble_att_mtu(peerInfo.m_desc.conn_handle) - 3)) {
|
||||||
pCharacteristic->m_pCallbacks->onRead(pCharacteristic, peerInfo);
|
pCharacteristic->m_pCallbacks->onRead(pCharacteristic, peerInfo);
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,7 +162,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;
|
||||||
NimBLEConnInfo peerInfo;
|
NimBLEConnInfo peerInfo{};
|
||||||
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(),
|
||||||
|
@ -172,12 +172,12 @@ 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, &peerInfo.m_desc);
|
ble_gap_conn_find(conn_handle, &peerInfo.m_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 ||
|
||||||
|
conn_handle == BLE_HS_CONN_HANDLE_NONE ||
|
||||||
pDescriptor->m_value.size() <= (ble_att_mtu(peerInfo.getConnHandle()) - 3)) {
|
pDescriptor->m_value.size() <= (ble_att_mtu(peerInfo.getConnHandle()) - 3)) {
|
||||||
pDescriptor->m_pCallbacks->onRead(pDescriptor, peerInfo);
|
pDescriptor->m_pCallbacks->onRead(pDescriptor, peerInfo);
|
||||||
}
|
}
|
||||||
|
@ -189,11 +189,9 @@ int NimBLEDescriptor::handleGapEvent(uint16_t conn_handle, uint16_t attr_handle,
|
||||||
}
|
}
|
||||||
|
|
||||||
case BLE_GATT_ACCESS_OP_WRITE_DSC: {
|
case BLE_GATT_ACCESS_OP_WRITE_DSC: {
|
||||||
rc = ble_gap_conn_find(conn_handle, &peerInfo.m_desc);
|
ble_gap_conn_find(conn_handle, &peerInfo.m_desc);
|
||||||
assert(rc == 0);
|
|
||||||
|
|
||||||
uint16_t att_max_len = pDescriptor->m_value.max_size();
|
uint16_t att_max_len = pDescriptor->m_value.max_size();
|
||||||
|
|
||||||
if (ctxt->om->om_len > att_max_len) {
|
if (ctxt->om->om_len > att_max_len) {
|
||||||
return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN;
|
return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue