Bluetooth: tests: hfc: Avoid reconnecting too fast

The host refuses to connect to a peer with an address that is also used
by a connection object in disconnected state.

Add a guard to prevent `-EINVAL` from `bt_conn_le_create`.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
This commit is contained in:
Aleksander Wasaznik 2024-03-21 15:14:04 +01:00 committed by David Leach
commit 03d234d593

View file

@ -81,6 +81,13 @@ static void device_found(const bt_addr_le_t *addr, int8_t rssi, uint8_t type,
struct bt_conn *conn;
int err;
conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, addr);
if (conn) {
LOG_DBG("Old connection is not yet purged");
bt_conn_unref(conn);
return;
}
err = bt_le_scan_stop();
if (err) {
FAIL("Stop LE scan failed (err %d)", err);