From 808a90c507143a02f21a41a1702cd35768d72b8f Mon Sep 17 00:00:00 2001 From: Karel Tucek Date: Sun, 22 Dec 2024 18:13:29 +0100 Subject: [PATCH] Fix advertisement restart. --- device/src/bt_advertise.c | 4 ++-- device/src/bt_conn.c | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/device/src/bt_advertise.c b/device/src/bt_advertise.c index 2424025a..93c99ba7 100644 --- a/device/src/bt_advertise.c +++ b/device/src/bt_advertise.c @@ -84,8 +84,8 @@ void BtAdvertise_Start(uint8_t adv_type) printk("%s advertising continued\n", adv_type_string); } else { printk("%s advertising failed to start (err %d)\n", adv_type_string, err); - BtConn_ListCurrentConnections(); - EventScheduler_Schedule(CurrentTime + 1000, EventSchedulerEvent_BtStartAdvertisement, "BtStartAdvertisement"); + BtConn_DisconnectAll(); + EventScheduler_Schedule(CurrentTime + 50, EventSchedulerEvent_BtStartAdvertisement, "BtStartAdvertisement"); } } diff --git a/device/src/bt_conn.c b/device/src/bt_conn.c index 0bf3aa2d..cb8acc81 100644 --- a/device/src/bt_conn.c +++ b/device/src/bt_conn.c @@ -388,6 +388,10 @@ static void auth_passkey_display(struct bt_conn *conn, unsigned int passkey) } static void auth_passkey_confirm(struct bt_conn *conn, unsigned int passkey) { + if (auth_conn) { + bt_conn_unref(auth_conn); + } + auth_conn = bt_conn_ref(conn); printk("Received passkey pairing inquiry.\n");