Skip to content

Commit 20cbf42

Browse files
committed
[Bugfix](workaround) OnConnect not being called.
Upstream changes have resulted in a possible status of BLE_ERR_UNSUPP_REM_FEATURE, this resulted in the onConnect callback not being called despite the connection actually being created. This works around that bug to ensure that the connections are correctly tracked.
1 parent 2edf8d3 commit 20cbf42

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/NimBLEClient.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,10 @@ int NimBLEClient::handleGapEvent(struct ble_gap_event* event, void* arg) {
988988
}
989989

990990
rc = event->connect.status;
991+
if (rc == BLE_ERR_UNSUPP_REM_FEATURE) {
992+
rc = 0; // Workaround: Ignore unsupported remote feature error as it is not a real error.
993+
}
994+
991995
if (rc == 0) {
992996
pClient->m_connHandle = event->connect.conn_handle;
993997

src/NimBLEServer.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,15 @@ int NimBLEServer::handleGapEvent(ble_gap_event* event, void* arg) {
354354

355355
switch (event->type) {
356356
case BLE_GAP_EVENT_CONNECT: {
357-
if (event->connect.status != 0) {
358-
NIMBLE_LOGE(LOG_TAG, "Connection failed");
357+
rc = event->connect.status;
358+
if (rc == BLE_ERR_UNSUPP_REM_FEATURE) {
359+
rc = 0; // Workaround: Ignore unsupported remote feature error as it is not a real error.
360+
}
361+
362+
if (rc != 0) {
363+
NIMBLE_LOGE(LOG_TAG, "Connection failed rc = %d %s",
364+
rc,
365+
NimBLEUtils::returnCodeToString(rc));
359366
# if !CONFIG_BT_NIMBLE_EXT_ADV && CONFIG_BT_NIMBLE_ROLE_BROADCASTER
360367
NimBLEDevice::startAdvertising();
361368
# endif

0 commit comments

Comments
 (0)