Add fast switching config

This commit is contained in:
Justin Ridgewell 2023-12-21 02:14:31 -05:00
parent bf6aa89e72
commit 5cf41b7596
3 changed files with 23 additions and 2 deletions

View file

@ -185,6 +185,10 @@ config BT_CTLR_PHY_2M
config BT_TINYCRYPT_ECC
default y if BT_HCI && !BT_CTLR
config ZMK_BLE_FAST_SWITCHING
bool "Fast switching between bluetooth profiles by maintaining connection"
default y
config SYSTEM_WORKQUEUE_STACK_SIZE
default 4096 if SOC_RP2040
default 2048

View file

@ -261,7 +261,10 @@ int zmk_ble_prof_select(uint8_t index) {
return 0;
}
#if !IS_ENABLED(CONFIG_ZMK_BLE_FAST_SWITCHING)
zmk_ble_prof_disconnect(active_profile);
#endif
active_profile = index;
ble_save_profile();
@ -454,12 +457,25 @@ static void connected(struct bt_conn *conn, uint8_t err) {
}
#endif // !IS_ENABLED(CONFIG_BT_GATT_AUTO_SEC_REQ)
update_advertising();
if (is_conn_active_profile(conn)) {
LOG_DBG("Active profile connected");
k_work_submit(&raise_profile_changed_event_work);
#if !IS_ENABLED(CONFIG_ZMK_BLE_FAST_SWITCHING)
// Due to a bug with directed advertising, we had to use open
// advertising and probably connected to multiple profiles.
// Now that we have the desired active connection, we disconnect
// everything else.
for (int i = 0; i < ZMK_BLE_PROFILE_COUNT; i++) {
if (i != active_profile && !bt_addr_le_cmp(&profiles[i].peer, BT_ADDR_LE_ANY)) {
zmk_ble_prof_disconnect(i);
}
}
#endif
}
update_advertising();
}
static void disconnected(struct bt_conn *conn, uint8_t reason) {

View file

@ -16,3 +16,4 @@ See [Configuration Overview](index.md) for instructions on how to change these s
| `CONFIG_ZMK_BLE_EXPERIMENTAL_FEATURES` | bool | Aggregate config that enables both `CONFIG_ZMK_BLE_EXPERIMENTAL_CONN` and `CONFIG_ZMK_BLE_EXPERIMENTAL_SEC`. | n |
| `CONFIG_ZMK_BLE_PASSKEY_ENTRY` | bool | Enable passkey entry during pairing for enhanced security. (Note: After enabling this, you will need to re-pair all previously paired hosts.) | n |
| `CONFIG_BT_GATT_ENFORCE_SUBSCRIPTION` | bool | Low level setting for GATT subscriptions. Set to `n` to work around an annoying Windows bug with battery notifications. | y |
| `CONFIG_ZMK_BLE_FAST_SWITCHING` | bool | Enables faster switching between profiles by maintaining the bluetooth connection even after switching to a different profile. Disabling this will disconnect (but remain paired) from the old profile when selecting a new one. | y |