fix(bluetooth): Improved checking for conn status.

* Check the actual connection status before considering
  a discovered connection as connected.
This commit is contained in:
Peter Johanson 2023-05-05 22:56:58 -07:00 committed by Pete Johanson
parent 864394b40a
commit 5aac2743b1

View file

@ -118,6 +118,7 @@ void set_profile_address(uint8_t index, const bt_addr_le_t *addr) {
bool zmk_ble_active_profile_is_connected() { bool zmk_ble_active_profile_is_connected() {
struct bt_conn *conn; struct bt_conn *conn;
struct bt_conn_info info;
bt_addr_le_t *addr = zmk_ble_active_profile_addr(); bt_addr_le_t *addr = zmk_ble_active_profile_addr();
if (!bt_addr_le_cmp(addr, BT_ADDR_LE_ANY)) { if (!bt_addr_le_cmp(addr, BT_ADDR_LE_ANY)) {
return false; return false;
@ -125,9 +126,11 @@ bool zmk_ble_active_profile_is_connected() {
return false; return false;
} }
bt_conn_get_info(conn, &info);
bt_conn_unref(conn); bt_conn_unref(conn);
return true; return info.state == BT_CONN_STATE_CONNECTED;
} }
#define CHECKED_ADV_STOP() \ #define CHECKED_ADV_STOP() \