Skip to content

Commit 1946c34

Browse files
xudongzhengnot-in-stock
authored andcommitted
refactor(split): allow central to define connection parameters
Fixes zmkfirmware#1614
1 parent 5199707 commit 1946c34

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

app/src/split/bluetooth/Kconfig

+15-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ config ZMK_SPLIT_BLE_CENTRAL_SPLIT_RUN_QUEUE_SIZE
3333
int "Max number of behavior run events to queue to send to the peripheral(s)"
3434
default 5
3535

36+
config ZMK_SPLIT_BLE_PREF_INT
37+
int "Connection interval to use for split central/peripheral connection"
38+
default 6
39+
40+
config ZMK_SPLIT_BLE_PREF_LATENCY
41+
int "Latency to use for split central/peripheral connection"
42+
default 30
43+
44+
config ZMK_SPLIT_BLE_PREF_TIMEOUT
45+
int "Supervision timeout to use for split central/peripheral connection"
46+
default 400
47+
3648
endif # ZMK_SPLIT_ROLE_CENTRAL
3749

3850
if !ZMK_SPLIT_ROLE_CENTRAL
@@ -58,8 +70,9 @@ config BT_MAX_PAIRED
5870
config BT_MAX_CONN
5971
default 1
6072

61-
config BT_PERIPHERAL_PREF_MAX_INT
62-
default 6
73+
# Allow central to specify connection parameters.
74+
config BT_GAP_AUTO_UPDATE_CONN_PARAMS
75+
default n
6376

6477
#!ZMK_SPLIT_ROLE_CENTRAL
6578
endif

app/src/split/bluetooth/central.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,9 @@ static bool split_central_eir_found(const bt_addr_le_t *addr) {
383383
struct peripheral_slot *slot = &peripherals[slot_idx];
384384

385385
LOG_DBG("Initiating new connnection");
386-
struct bt_le_conn_param *param = BT_LE_CONN_PARAM(0x0006, 0x0006, 30, 400);
386+
struct bt_le_conn_param *param =
387+
BT_LE_CONN_PARAM(CONFIG_ZMK_SPLIT_BLE_PREF_INT, CONFIG_ZMK_SPLIT_BLE_PREF_INT,
388+
CONFIG_ZMK_SPLIT_BLE_PREF_LATENCY, CONFIG_ZMK_SPLIT_BLE_PREF_TIMEOUT);
387389
err = bt_conn_le_create(addr, BT_CONN_LE_CREATE_CONN, param, &slot->conn);
388390
if (err < 0) {
389391
LOG_ERR("Create conn failed (err %d) (create conn? 0x%04x)", err, BT_HCI_OP_LE_CREATE_CONN);

0 commit comments

Comments
 (0)