From fc94d4c1582bc48f8626e387abe9120b2931a8fe Mon Sep 17 00:00:00 2001 From: Xudong Zheng <7pkvm5aw@slicealias.com> Date: Fri, 19 May 2023 18:41:08 -0400 Subject: [PATCH] refactor(split): allow central to define connection parameters Fixes #1614 --- app/src/split/bluetooth/Kconfig | 17 +++++++++++++++-- app/src/split/bluetooth/central.c | 4 +++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/app/src/split/bluetooth/Kconfig b/app/src/split/bluetooth/Kconfig index e2c8d5c3395..0610b667a26 100644 --- a/app/src/split/bluetooth/Kconfig +++ b/app/src/split/bluetooth/Kconfig @@ -33,6 +33,18 @@ config ZMK_SPLIT_BLE_CENTRAL_SPLIT_RUN_QUEUE_SIZE int "Max number of behavior run events to queue to send to the peripheral(s)" default 5 +config ZMK_SPLIT_BLE_PREF_INT + int "Connection interval to use for split central/peripheral connection" + default 6 + +config ZMK_SPLIT_BLE_PREF_LATENCY + int "Latency to use for split central/peripheral connection" + default 30 + +config ZMK_SPLIT_BLE_PREF_TIMEOUT + int "Supervision timeout to use for split central/peripheral connection" + default 400 + endif # ZMK_SPLIT_ROLE_CENTRAL if !ZMK_SPLIT_ROLE_CENTRAL @@ -58,8 +70,9 @@ config BT_MAX_PAIRED config BT_MAX_CONN default 1 -config BT_PERIPHERAL_PREF_MAX_INT - default 6 +# Allow central to specify connection parameters. +config BT_GAP_AUTO_UPDATE_CONN_PARAMS + default n #!ZMK_SPLIT_ROLE_CENTRAL endif diff --git a/app/src/split/bluetooth/central.c b/app/src/split/bluetooth/central.c index 53e61be621a..147760ffae7 100644 --- a/app/src/split/bluetooth/central.c +++ b/app/src/split/bluetooth/central.c @@ -383,7 +383,9 @@ static bool split_central_eir_found(const bt_addr_le_t *addr) { struct peripheral_slot *slot = &peripherals[slot_idx]; LOG_DBG("Initiating new connnection"); - struct bt_le_conn_param *param = BT_LE_CONN_PARAM(0x0006, 0x0006, 30, 400); + struct bt_le_conn_param *param = + BT_LE_CONN_PARAM(CONFIG_ZMK_SPLIT_BLE_PREF_INT, CONFIG_ZMK_SPLIT_BLE_PREF_INT, + CONFIG_ZMK_SPLIT_BLE_PREF_LATENCY, CONFIG_ZMK_SPLIT_BLE_PREF_TIMEOUT); err = bt_conn_le_create(addr, BT_CONN_LE_CREATE_CONN, param, &slot->conn); if (err < 0) { LOG_ERR("Create conn failed (err %d) (create conn? 0x%04x)", err, BT_HCI_OP_LE_CREATE_CONN);