Skip to content

Commit 5524fd2

Browse files
committed
Double check we connected successfully
1 parent 0eb76cf commit 5524fd2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/NimBLEClient.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,9 +980,16 @@ int NimBLEClient::handleGapEvent(struct ble_gap_event *event, void *arg) {
980980
if (rc == 0) {
981981
NIMBLE_LOGI(LOG_TAG, "Connected event");
982982

983+
rc = ble_gap_conn_find(event->connect.conn_handle, NULL);
984+
if(rc != 0) {
985+
NIMBLE_LOGE(LOG_TAG, "Connection not found; rc=%d %s",
986+
rc, NimBLEUtils::returnCodeToString(rc));
987+
break;
988+
}
989+
983990
client->m_conn_id = event->connect.conn_handle;
984991

985-
rc = ble_gattc_exchange_mtu(client->m_conn_id, NULL,NULL);
992+
rc = ble_gattc_exchange_mtu(client->m_conn_id, NULL, NULL);
986993
if(rc != 0) {
987994
NIMBLE_LOGE(LOG_TAG, "MTU exchange error; rc=%d %s",
988995
rc, NimBLEUtils::returnCodeToString(rc));

0 commit comments

Comments
 (0)