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>
diff --git a/tests/bsim/bluetooth/host/misc/hfc/src/main.c b/tests/bsim/bluetooth/host/misc/hfc/src/main.c
index a3ab384..15e2777 100644
--- a/tests/bsim/bluetooth/host/misc/hfc/src/main.c
+++ b/tests/bsim/bluetooth/host/misc/hfc/src/main.c
@@ -81,6 +81,13 @@
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);