Skip to content

Commit 92ea1a8

Browse files
olivier-le-sagerlubos
authored andcommitted
samples: handle failure to connect in RAS samples
Handle errors while connecting more gracefully. Signed-off-by: Olivier Lesage <[email protected]>
1 parent ea822e3 commit 92ea1a8

File tree

2 files changed

+10
-10
lines changed
  • samples/bluetooth
    • channel_sounding_ras_initiator/src
    • channel_sounding_ras_reflector/src

2 files changed

+10
-10
lines changed

samples/bluetooth/channel_sounding_ras_initiator/src/main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,13 @@ static void connected_cb(struct bt_conn *conn, uint8_t err)
347347
if (err) {
348348
bt_conn_unref(conn);
349349
connection = NULL;
350-
}
351-
352-
connection = bt_conn_ref(conn);
350+
} else {
351+
connection = bt_conn_ref(conn);
353352

354-
k_sem_give(&sem_connected);
353+
k_sem_give(&sem_connected);
355354

356-
dk_set_led_on(CON_STATUS_LED);
355+
dk_set_led_on(CON_STATUS_LED);
356+
}
357357
}
358358

359359
static void disconnected_cb(struct bt_conn *conn, uint8_t reason)

samples/bluetooth/channel_sounding_ras_reflector/src/main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ static void connected_cb(struct bt_conn *conn, uint8_t err)
4545
if (err) {
4646
bt_conn_unref(conn);
4747
connection = NULL;
48-
}
49-
50-
connection = bt_conn_ref(conn);
48+
} else {
49+
connection = bt_conn_ref(conn);
5150

52-
k_sem_give(&sem_connected);
51+
k_sem_give(&sem_connected);
5352

54-
dk_set_led_on(CON_STATUS_LED);
53+
dk_set_led_on(CON_STATUS_LED);
54+
}
5555
}
5656

5757
static void disconnected_cb(struct bt_conn *conn, uint8_t reason)

0 commit comments

Comments
 (0)