diff options
author | Pete Johanson <peter@peterjohanson.com> | 2020-08-06 11:11:48 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-06 11:11:48 -0400 |
commit | fd381e811787f62cd93744bffbce9a10393bb63c (patch) | |
tree | f2f7208a9448141d039a5063f8881a04cf792b33 /app/src | |
parent | 81090d9af017ce6070298a86de6f03db2d639251 (diff) | |
parent | 370cfcc59fdf2900feba653d4ce5b55a90050426 (diff) |
Merge pull request #70 from Nicell/split/2m-phy
Split connection parameter adjustments and 2M PHY added
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/ble.c | 25 | ||||
-rw-r--r-- | app/src/split/bluetooth/central.c | 14 |
2 files changed, 37 insertions, 2 deletions
diff --git a/app/src/ble.c b/app/src/ble.c index 559b04f..7d986d7 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -37,7 +37,11 @@ static void connected(struct bt_conn *conn, u8_t err) printk("Connected %s\n", addr); - bt_conn_le_param_update(conn, BT_LE_CONN_PARAM(0x0006, 0x000c, 5, 400)); + bt_conn_le_param_update(conn, BT_LE_CONN_PARAM(0x0006, 0x000c, 30, 400)); + +#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) + bt_conn_le_phy_update(conn, BT_CONN_LE_PHY_PARAM_2M); +#endif if (bt_conn_set_security(conn, BT_SECURITY_L2)) { @@ -72,10 +76,29 @@ static void security_changed(struct bt_conn *conn, bt_security_t level, } } +#if !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) +static bool le_param_req(struct bt_conn *conn, struct bt_le_conn_param *param) { + static struct bt_conn_info info; + + bt_conn_get_info(conn, &info); + + /* This captures a param change from central half of a split board connection + to stop default params from getting set over the top of our preferred ones */ + if (info.role == BT_CONN_ROLE_MASTER && (param->interval_min != 6 || param->latency != 30)) { + return false; + } + + return true; +} +#endif + static struct bt_conn_cb conn_callbacks = { .connected = connected, .disconnected = disconnected, .security_changed = security_changed, +#if !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) + .le_param_req = le_param_req, +#endif }; static void auth_passkey_display(struct bt_conn *conn, unsigned int passkey) diff --git a/app/src/split/bluetooth/central.c b/app/src/split/bluetooth/central.c index b6d7222..237096f 100644 --- a/app/src/split/bluetooth/central.c +++ b/app/src/split/bluetooth/central.c @@ -149,6 +149,12 @@ static void split_central_process_connection(struct bt_conn *conn) { return; } } + + struct bt_conn_info info; + + bt_conn_get_info(conn, &info); + + LOG_DBG("New connection params: Interval: %d, Latency: %d, PHY: %d", info.le.interval, info.le.latency, info.le.phy->rx_phy); } static bool split_central_eir_found(struct bt_data *data, void *user_data) @@ -199,13 +205,19 @@ static bool split_central_eir_found(struct bt_data *data, void *user_data) LOG_DBG("Found existing connection"); split_central_process_connection(default_conn); } else { - param = BT_LE_CONN_PARAM(0x0006, 0x000c, 5, 400); + param = BT_LE_CONN_PARAM(0x0006, 0x0006, 30, 400); err = bt_conn_le_create(addr, BT_CONN_LE_CREATE_CONN, param, &default_conn); if (err) { LOG_ERR("Create conn failed (err %d)", err); start_scan(); } + + err = bt_conn_le_phy_update(default_conn, BT_CONN_LE_PHY_PARAM_2M); + if (err) { + LOG_ERR("Update phy conn failed (err %d)", err); + start_scan(); + } } return false; |