|
23 | 23 | LOG_MODULE_REGISTER(MODULE, CONFIG_DESKTOP_BLE_CONN_PARAMS_LOG_LEVEL); |
24 | 24 |
|
25 | 25 | #define CONN_INTERVAL_LLPM_US 1000 /* 1 ms */ |
26 | | -#define CONN_INTERVAL_LLPM_REG 0x0d01 /* 1 ms */ |
27 | 26 | #if (CONFIG_CAF_BLE_USE_LLPM && (CONFIG_BT_MAX_CONN >= 2)) |
28 | 27 | #define CONN_INTERVAL_BLE_REG 0x0008 /* 10 ms */ |
| 28 | + #define CONN_INTERVAL_BLE_US 10000 |
29 | 29 | #else |
30 | 30 | #define CONN_INTERVAL_BLE_REG 0x0006 /* 7.5 ms */ |
| 31 | + #define CONN_INTERVAL_BLE_US 7500 |
31 | 32 | #endif |
32 | 33 | #define CONN_SUPERVISION_TIMEOUT 400 |
33 | 34 |
|
@@ -77,8 +78,10 @@ static int set_le_conn_param(struct bt_conn *conn, uint16_t interval, uint16_t l |
77 | 78 | return bt_conn_le_param_update(conn, ¶m); |
78 | 79 | } |
79 | 80 |
|
80 | | -static int interval_reg_to_us(uint16_t reg) |
| 81 | +/* Handle llpm encoding in interval_us values */ |
| 82 | +static int strip_llpm_encoding_to_us(uint32_t interval_us) |
81 | 83 | { |
| 84 | + uint16_t reg = BT_GAP_US_TO_CONN_INTERVAL(interval_us); |
82 | 85 | bool is_llpm = ((reg & 0x0d00) == 0x0d00) ? true : false; |
83 | 86 |
|
84 | 87 | return (reg & BIT_MASK(8)) * ((is_llpm) ? 1000 : 1250); |
@@ -128,7 +131,7 @@ static int set_conn_params(struct connected_peer *peer) |
128 | 131 | LOG_ERR("Cannot get conn info (%d)", err); |
129 | 132 | return err; |
130 | 133 | } |
131 | | - uint32_t curr_ci_us = interval_reg_to_us(info.le.interval); |
| 134 | + uint32_t curr_ci_us = strip_llpm_encoding_to_us(info.le.interval_us); |
132 | 135 |
|
133 | 136 | if (curr_ci_us > CONN_INTERVAL_PRE_LLPM_MAX_US) { |
134 | 137 | err = set_le_conn_param(peer->conn, CONN_INTERVAL_BLE_REG, |
@@ -192,13 +195,14 @@ static bool conn_params_update_required(struct connected_peer *peer) |
192 | 195 |
|
193 | 196 | __ASSERT_NO_MSG(info.role == BT_CONN_ROLE_CENTRAL); |
194 | 197 |
|
| 198 | + uint32_t interval_us = strip_llpm_encoding_to_us(info.le.interval_us); |
195 | 199 | if (IS_ENABLED(CONFIG_DESKTOP_BLE_USB_MANAGED_CI) && usb_suspended) { |
196 | | - if ((info.le.interval != CONN_INTERVAL_USB_SUSPEND) || |
| 200 | + if ((interval_us != BT_CONN_INTERVAL_TO_US(CONN_INTERVAL_USB_SUSPEND)) || |
197 | 201 | (info.le.latency != CONN_LATENCY_USB_SUSPEND)) { |
198 | 202 | return true; |
199 | 203 | } |
200 | | - } else if ((peer->use_llpm && (info.le.interval != CONN_INTERVAL_LLPM_REG)) || |
201 | | - (!peer->use_llpm && (info.le.interval != CONN_INTERVAL_BLE_REG)) || |
| 204 | + } else if ((peer->use_llpm && (interval_us != CONN_INTERVAL_LLPM_US)) || |
| 205 | + (!peer->use_llpm && (interval_us != CONN_INTERVAL_BLE_US)) || |
202 | 206 | (info.le.latency != peer->requested_latency)) { |
203 | 207 | return true; |
204 | 208 | } |
|
0 commit comments