Skip to content

Commit

Permalink
fix(bluetooth): Improved checking for conn status.
Browse files Browse the repository at this point in the history
* Check the actual connection status before considering
  a discovered connection as connected.
  • Loading branch information
petejohanson committed May 23, 2023
1 parent 864394b commit 5aac274
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/src/ble.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,19 @@ 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;
} else if ((conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, addr)) == NULL) {
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() \
Expand Down

0 comments on commit 5aac274

Please sign in to comment.