From 5f929f96f6a99467824ece695c1647efa38c482c Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Fri, 5 May 2023 22:56:58 -0700 Subject: [PATCH] fix(bluetooth): Improved checking for conn status. * Check the actual connection status before considering a discovered connection as connected. --- app/src/ble.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/ble.c b/app/src/ble.c index a7037d0c..c7bdc401 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -118,6 +118,7 @@ void set_profile_address(uint8_t index, const bt_addr_le_t *addr) { bool zmk_ble_active_profile_is_connected() { struct bt_conn *conn; + struct bt_conn_info info; bt_addr_le_t *addr = zmk_ble_active_profile_addr(); if (!bt_addr_le_cmp(addr, BT_ADDR_LE_ANY)) { return false; @@ -125,9 +126,11 @@ bool zmk_ble_active_profile_is_connected() { return false; } + bt_conn_get_info(conn, &info); + bt_conn_unref(conn); - return true; + return info.state == BT_CONN_STATE_CONNECTED; } #define CHECKED_ADV_STOP() \