Skip to content

Commit 7eb5555

Browse files
henrlajukkar
authored andcommitted
samples: Bluetooth: update scanning_while_connecting
Move flag that protects application from establishing a new connection when there is already a connection establishment process pending. This is moved to after the if to check that we have established all connections. Otherwise, we get in the scan_recv call back an attempt to establish a connection when we have used all connection objects before we stop scanning in main. Signed-off-by: Henrik Lander <[email protected]>
1 parent 97093b5 commit 7eb5555

File tree

1 file changed

+4
-1
lines changed
  • samples/bluetooth/scanning_while_connecting/src

1 file changed

+4
-1
lines changed

samples/bluetooth/scanning_while_connecting/src/main.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ static void disconnected(struct bt_conn *conn, uint8_t reason)
161161

162162
static void connected(struct bt_conn *conn, uint8_t err)
163163
{
164-
connection_establishment_ongoing = false;
165164
char addr_str[BT_ADDR_LE_STR_LEN];
166165

167166
bt_addr_le_to_str(bt_conn_get_dst(conn), addr_str, sizeof(addr_str));
@@ -182,6 +181,8 @@ static void connected(struct bt_conn *conn, uint8_t err)
182181
}
183182
}
184183

184+
connection_establishment_ongoing = false;
185+
185186
struct bt_le_conn_param conn_param = {
186187
.interval_min = 500, /* Minimum Connection Interval (interval_min * 1.25 ms) */
187188
.interval_max = 500, /* Maximum Connection Interval (interval_max * 1.25 ms) */
@@ -201,6 +202,7 @@ static void connected(struct bt_conn *conn, uint8_t err)
201202
if (active_conn_establishment_mode == SEQUENTIAL_SCAN_AND_CONNECT) {
202203
scan_start();
203204
}
205+
204206
}
205207

206208
static void try_connect(void)
@@ -434,6 +436,7 @@ int main(void)
434436
active_conn_establishment_mode = conn_establishment_modes[i];
435437

436438
num_connections = 0;
439+
connection_establishment_ongoing = false;
437440
ring_buf_reset(&connectable_peers_ring_buf);
438441

439442
print_conn_establishment_mode(active_conn_establishment_mode);

0 commit comments

Comments
 (0)