From f26bd495ea0dad0a9b610752555ce428197e9cc8 Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 2 Aug 2020 14:51:42 -0500 Subject: Fix interval update, add PHY update --- app/src/ble.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/src/ble.c') diff --git a/app/src/ble.c b/app/src/ble.c index 559b04f..2afc983 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(default_conn, BT_CONN_LE_PHY_PARAM_2M); +#endif if (bt_conn_set_security(conn, BT_SECURITY_L2)) { -- cgit v1.2.3 From 880c6e0601b6313e26bc73e913843805666f4cf3 Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 2 Aug 2020 15:01:32 -0500 Subject: Fix variable name in peripheral PHY update --- app/src/ble.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/src/ble.c') diff --git a/app/src/ble.c b/app/src/ble.c index 2afc983..3a7755f 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -40,7 +40,7 @@ static void connected(struct bt_conn *conn, u8_t err) 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(default_conn, BT_CONN_LE_PHY_PARAM_2M); + bt_conn_le_phy_update(conn, BT_CONN_LE_PHY_PARAM_2M); #endif if (bt_conn_set_security(conn, BT_SECURITY_L2)) -- cgit v1.2.3 From f23ca9d7ee7481ebdbbed3234e902e5b7753ae41 Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 2 Aug 2020 15:51:38 -0500 Subject: Add two solutions to param updates --- app/src/ble.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'app/src/ble.c') diff --git a/app/src/ble.c b/app/src/ble.c index 3a7755f..db80a36 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -76,10 +76,39 @@ static void security_changed(struct bt_conn *conn, bt_security_t level, } } +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); + + if (info.role == BT_CONN_ROLE_MASTER && (param->interval_min != 6 || param->latency != 30)) { + return false; + } + + return true; +} + +static void le_param_updated(struct bt_conn *conn, u16_t interval, + u16_t latency, u16_t timeout) { + static struct bt_conn_info info; + + bt_conn_get_info(conn, &info); + + if (info.role == BT_CONN_ROLE_MASTER && (interval != 6 || latency != 30)) { + bt_conn_le_param_update(conn, BT_LE_CONN_PARAM(0x0006, 0x0006, 30, 400)); + } + + LOG_DBG("Params updated: Interval: %d, Latency: %d", interval, latency); +}; + 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, + .le_param_updated = le_param_updated, +#endif }; static void auth_passkey_display(struct bt_conn *conn, unsigned int passkey) -- cgit v1.2.3 From cfea5cceb1ecb5dc2984ac6e6c0a389d8392f79e Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 3 Aug 2020 17:22:11 -0500 Subject: Remove updated callback --- app/src/ble.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'app/src/ble.c') diff --git a/app/src/ble.c b/app/src/ble.c index db80a36..6526357 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -88,26 +88,12 @@ static bool le_param_req(struct bt_conn *conn, struct bt_le_conn_param *param) { return true; } -static void le_param_updated(struct bt_conn *conn, u16_t interval, - u16_t latency, u16_t timeout) { - static struct bt_conn_info info; - - bt_conn_get_info(conn, &info); - - if (info.role == BT_CONN_ROLE_MASTER && (interval != 6 || latency != 30)) { - bt_conn_le_param_update(conn, BT_LE_CONN_PARAM(0x0006, 0x0006, 30, 400)); - } - - LOG_DBG("Params updated: Interval: %d, Latency: %d", interval, latency); -}; - 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, - .le_param_updated = le_param_updated, #endif }; -- cgit v1.2.3 From 370cfcc59fdf2900feba653d4ce5b55a90050426 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 5 Aug 2020 22:38:40 -0500 Subject: Add if block and param req callback comment --- app/src/ble.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app/src/ble.c') diff --git a/app/src/ble.c b/app/src/ble.c index 6526357..7d986d7 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -76,17 +76,21 @@ 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, -- cgit v1.2.3