Fix NimBLEClient::secureConnection incorrectly failing with BLE_HS_EAGAIN.

This commit is contained in:
h2zero 2024-11-09 09:08:22 -07:00 committed by h2zero
parent 020c61700d
commit 7d0636bc91
2 changed files with 3 additions and 4 deletions

View file

@ -302,9 +302,8 @@ bool NimBLEClient::secureConnection() const {
do {
m_pTaskData = &taskData;
int rc = NimBLEDevice::startSecurity(m_connHandle);
if (rc != 0 && rc != BLE_HS_EALREADY) {
m_lastErr = rc;
if (!NimBLEDevice::startSecurity(m_connHandle)) {
m_lastErr = BLE_HS_ENOTCONN;
m_pTaskData = nullptr;
return false;
}

View file

@ -1127,7 +1127,7 @@ bool NimBLEDevice::startSecurity(uint16_t connHandle) {
NIMBLE_LOGE(LOG_TAG, "ble_gap_security_initiate: rc=%d %s", rc, NimBLEUtils::returnCodeToString(rc));
}
return rc == 0;
return rc == 0 || rc == BLE_HS_EALREADY;
} // startSecurity
/**