Skip to content

Commit 128bbb2

Browse files
committed
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.
1 parent 2db4756 commit 128bbb2

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/NimBLEServer.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -554,18 +554,16 @@ int NimBLEServer::handleGapEvent(struct ble_gap_event *event, void *arg) {
554554

555555
for(auto &it : pServer->m_notifyChrVec) {
556556
if(it->getHandle() == event->subscribe.attr_handle) {
557-
if((it->getProperties() & BLE_GATT_CHR_F_READ_AUTHEN) ||
558-
(it->getProperties() & BLE_GATT_CHR_F_READ_AUTHOR) ||
559-
(it->getProperties() & BLE_GATT_CHR_F_READ_ENC))
560-
{
561-
rc = ble_gap_conn_find(event->subscribe.conn_handle, &peerInfo.m_desc);
562-
if (rc != 0) {
563-
break;
564-
}
565-
566-
if(!peerInfo.isEncrypted()) {
557+
rc = ble_gap_conn_find(event->subscribe.conn_handle, &peerInfo.m_desc);
558+
if (rc != 0) {
559+
break;
560+
}
561+
562+
if(((it->getProperties() & BLE_GATT_CHR_F_READ_AUTHEN) ||
563+
(it->getProperties() & BLE_GATT_CHR_F_READ_AUTHOR) ||
564+
(it->getProperties() & BLE_GATT_CHR_F_READ_ENC)) &&
565+
!peerInfo.isEncrypted()) {
567566
NimBLEDevice::startSecurity(event->subscribe.conn_handle);
568-
}
569567
}
570568

571569
it->setSubscribe(event, peerInfo);

0 commit comments

Comments
 (0)