Skip to content

Commit 7d0636b

Browse files
committed
Fix NimBLEClient::secureConnection incorrectly failing with BLE_HS_EAGAIN.
1 parent 020c617 commit 7d0636b

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/NimBLEClient.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,8 @@ bool NimBLEClient::secureConnection() const {
302302
do {
303303
m_pTaskData = &taskData;
304304

305-
int rc = NimBLEDevice::startSecurity(m_connHandle);
306-
if (rc != 0 && rc != BLE_HS_EALREADY) {
307-
m_lastErr = rc;
305+
if (!NimBLEDevice::startSecurity(m_connHandle)) {
306+
m_lastErr = BLE_HS_ENOTCONN;
308307
m_pTaskData = nullptr;
309308
return false;
310309
}

src/NimBLEDevice.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ bool NimBLEDevice::startSecurity(uint16_t connHandle) {
11271127
NIMBLE_LOGE(LOG_TAG, "ble_gap_security_initiate: rc=%d %s", rc, NimBLEUtils::returnCodeToString(rc));
11281128
}
11291129

1130-
return rc == 0;
1130+
return rc == 0 || rc == BLE_HS_EALREADY;
11311131
} // startSecurity
11321132

11331133
/**

0 commit comments

Comments
 (0)