Fix notifications not being sent.

The connection handle was not initialized correctly when recording the subscibe status causing the call to send notification/indications to fail with BLE_HS_ENOTCONN.
This commit is contained in:
h2zero 2024-09-30 15:00:06 -06:00 committed by h2zero
parent 73f0277042
commit 5b24c8d681

View file

@ -554,18 +554,16 @@ int NimBLEServer::handleGapEvent(struct ble_gap_event *event, void *arg) {
for(auto &it : pServer->m_notifyChrVec) { for(auto &it : pServer->m_notifyChrVec) {
if(it->getHandle() == event->subscribe.attr_handle) { if(it->getHandle() == event->subscribe.attr_handle) {
if((it->getProperties() & BLE_GATT_CHR_F_READ_AUTHEN) || rc = ble_gap_conn_find(event->subscribe.conn_handle, &peerInfo.m_desc);
(it->getProperties() & BLE_GATT_CHR_F_READ_AUTHOR) || if (rc != 0) {
(it->getProperties() & BLE_GATT_CHR_F_READ_ENC)) break;
{ }
rc = ble_gap_conn_find(event->subscribe.conn_handle, &peerInfo.m_desc);
if (rc != 0) {
break;
}
if(!peerInfo.isEncrypted()) { if(((it->getProperties() & BLE_GATT_CHR_F_READ_AUTHEN) ||
(it->getProperties() & BLE_GATT_CHR_F_READ_AUTHOR) ||
(it->getProperties() & BLE_GATT_CHR_F_READ_ENC)) &&
!peerInfo.isEncrypted()) {
NimBLEDevice::startSecurity(event->subscribe.conn_handle); NimBLEDevice::startSecurity(event->subscribe.conn_handle);
}
} }
it->setSubscribe(event, peerInfo); it->setSubscribe(event, peerInfo);