diff options
Diffstat (limited to 'app/src/ble.c')
-rw-r--r-- | app/src/ble.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/app/src/ble.c b/app/src/ble.c index b00bd5c..817cb84 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -100,7 +100,7 @@ static void raise_profile_changed_event_callback(struct k_work *work) { K_WORK_DEFINE(raise_profile_changed_event_work, raise_profile_changed_event_callback); -static bool active_profile_is_open() { +bool zmk_ble_active_profile_is_open() { return !bt_addr_le_cmp(&profiles[active_profile].peer, BT_ADDR_LE_ANY); } @@ -169,7 +169,7 @@ int update_advertising() { struct bt_conn *conn; enum advertising_type desired_adv = ZMK_ADV_NONE; - if (active_profile_is_open()) { + if (zmk_ble_active_profile_is_open()) { desired_adv = ZMK_ADV_CONN; } else if (!zmk_ble_active_profile_is_connected()) { desired_adv = ZMK_ADV_CONN; @@ -226,6 +226,8 @@ int zmk_ble_clear_bonds() { return 0; }; +int zmk_ble_active_profile_index() { return active_profile; } + int zmk_ble_prof_select(u8_t index) { LOG_DBG("profile %d", index); if (active_profile == index) { @@ -448,8 +450,8 @@ static enum bt_security_err auth_pairing_accept(struct bt_conn *conn, struct bt_conn_info info; bt_conn_get_info(conn, &info); - LOG_DBG("role %d, open? %s", info.role, active_profile_is_open() ? "yes" : "no"); - if (info.role == BT_CONN_ROLE_SLAVE && !active_profile_is_open()) { + LOG_DBG("role %d, open? %s", info.role, zmk_ble_active_profile_is_open() ? "yes" : "no"); + if (info.role == BT_CONN_ROLE_SLAVE && !zmk_ble_active_profile_is_open()) { LOG_WRN("Rejecting pairing request to taken profile %d", active_profile); return BT_SECURITY_ERR_PAIR_NOT_ALLOWED; } @@ -472,7 +474,7 @@ static void auth_pairing_complete(struct bt_conn *conn, bool bonded) { } #if !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) - if (!active_profile_is_open()) { + if (!zmk_ble_active_profile_is_open()) { LOG_ERR("Pairing completed but current profile is not open: %s", log_strdup(addr)); bt_unpair(BT_ID_DEFAULT, dst); return; |