Skip to content

Commit d095989

Browse files
committed
bluetooth: host: Interval is deprecated, use interval_us
With the introduction of Shorter Connection Intervals, Zephyr has deprecated bt_conn_le_info.interval in favour of bt_conn_le_info.interval_us. Changing the unit from 1.25 milliseconds to microseconds. Signed-off-by: Timothy Keys <[email protected]>
1 parent 64f747f commit d095989

File tree

12 files changed

+37
-22
lines changed

12 files changed

+37
-22
lines changed

applications/nrf5340_audio/unicast_client/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ static void le_audio_msg_sub_thread(void)
288288
if (ret) {
289289
LOG_ERR("Failed to get conn info");
290290
} else {
291-
interval = conn_info.le.interval;
291+
interval = BT_GAP_US_TO_CONN_INTERVAL(conn_info.le.interval_us);
292292
}
293293

294294
/* Only update conn param once */

applications/nrf_desktop/src/modules/ble_conn_params.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@
2323
LOG_MODULE_REGISTER(MODULE, CONFIG_DESKTOP_BLE_CONN_PARAMS_LOG_LEVEL);
2424

2525
#define CONN_INTERVAL_LLPM_US 1000 /* 1 ms */
26-
#define CONN_INTERVAL_LLPM_REG 0x0d01 /* 1 ms */
2726
#if (CONFIG_CAF_BLE_USE_LLPM && (CONFIG_BT_MAX_CONN >= 2))
2827
#define CONN_INTERVAL_BLE_REG 0x0008 /* 10 ms */
28+
#define CONN_INTERVAL_BLE_US 10000
2929
#else
3030
#define CONN_INTERVAL_BLE_REG 0x0006 /* 7.5 ms */
31+
#define CONN_INTERVAL_BLE_US 7500
3132
#endif
3233
#define CONN_SUPERVISION_TIMEOUT 400
3334

@@ -77,8 +78,10 @@ static int set_le_conn_param(struct bt_conn *conn, uint16_t interval, uint16_t l
7778
return bt_conn_le_param_update(conn, &param);
7879
}
7980

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)
8183
{
84+
uint16_t reg = BT_GAP_US_TO_CONN_INTERVAL(interval_us);
8285
bool is_llpm = ((reg & 0x0d00) == 0x0d00) ? true : false;
8386

8487
return (reg & BIT_MASK(8)) * ((is_llpm) ? 1000 : 1250);
@@ -128,7 +131,7 @@ static int set_conn_params(struct connected_peer *peer)
128131
LOG_ERR("Cannot get conn info (%d)", err);
129132
return err;
130133
}
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);
132135

133136
if (curr_ci_us > CONN_INTERVAL_PRE_LLPM_MAX_US) {
134137
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)
192195

193196
__ASSERT_NO_MSG(info.role == BT_CONN_ROLE_CENTRAL);
194197

198+
uint32_t interval_us = strip_llpm_encoding_to_us(info.le.interval_us);
195199
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)) ||
197201
(info.le.latency != CONN_LATENCY_USB_SUSPEND)) {
198202
return true;
199203
}
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)) ||
202206
(info.le.latency != peer->requested_latency)) {
203207
return true;
204208
}

applications/nrf_desktop/src/modules/ble_latency.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ static void set_conn_latency(bool low_latency)
102102
/* Request with connection interval set to a LLPM value is rejected
103103
* by Zephyr Bluetooth API.
104104
*/
105-
uint16_t interval = (info.le.interval & REG_CONN_INTERVAL_LLPM_MASK) ?
106-
REG_CONN_INTERVAL_BLE_DEFAULT : info.le.interval;
105+
uint16_t info_interval_1250us = BT_GAP_US_TO_CONN_INTERVAL(info.le.interval_us);
106+
uint16_t interval = (info_interval_1250us & REG_CONN_INTERVAL_LLPM_MASK) ?
107+
REG_CONN_INTERVAL_BLE_DEFAULT : info_interval_1250us;
107108
const struct bt_le_conn_param param = {
108109
.interval_min = interval,
109110
.interval_max = interval,

samples/bluetooth/conn_time_sync/src/peripheral.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static uint32_t conn_interval_us_get(const struct bt_conn *conn)
3030
return 0;
3131
}
3232

33-
return BT_CONN_INTERVAL_TO_US(info.le.interval);
33+
return info.le.interval_us;
3434
}
3535

3636
static ssize_t time_sync_data_received(struct bt_conn *conn,

samples/bluetooth/llpm/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ static void connected(struct bt_conn *conn, uint8_t err)
201201

202202
printk("Connected as %s\n",
203203
conn_info.role == BT_CONN_ROLE_CENTRAL ? "central" : "peripheral");
204-
__ASSERT_NO_MSG(conn_info.le.interval == INTERVAL_LLPM);
204+
__ASSERT_NO_MSG(conn_info.le.interval_us == INTERVAL_LLPM * BT_HCI_LE_INTERVAL_UNIT_US);
205205
printk("Conn. interval is 1 ms\n");
206206
}
207207

samples/bluetooth/radio_notification_cb/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static void connected(struct bt_conn *conn, uint8_t conn_err)
8181
return;
8282
}
8383

84-
conn_interval_us = BT_CONN_INTERVAL_TO_US(info.le.interval);
84+
conn_interval_us = info.le.interval_us;
8585

8686
/*Start service discovery when link is encrypted*/
8787
err = bt_gatt_dm_start(conn, BT_UUID_LATENCY, &discovery_cb,

samples/bluetooth/throughput/src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ static void connected(struct bt_conn *conn, uint8_t hci_err)
199199

200200
printk("Connected as %s\n",
201201
info.role == BT_CONN_ROLE_CENTRAL ? "central" : "peripheral");
202-
printk("Conn. interval is %u units\n", info.le.interval);
202+
printk("Conn. interval is %u us\n", info.le.interval_us);
203203

204204
if (info.role == BT_CONN_ROLE_PERIPHERAL) {
205205
err = bt_conn_set_security(conn, BT_SECURITY_L2);
@@ -497,7 +497,7 @@ static int connection_configuration_set(const struct shell *shell,
497497
return err;
498498
}
499499

500-
if (info.le.interval != conn_param->interval_max) {
500+
if (BT_GAP_US_TO_CONN_INTERVAL(info.le.interval_us) != conn_param->interval_max) {
501501
err = bt_conn_le_param_update(default_conn, conn_param);
502502
if (err) {
503503
shell_error(shell,

samples/wifi/ble_coex/src/bt_throughput_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static void connected(struct bt_conn *conn, uint8_t hci_err)
207207
}
208208

209209
LOG_INF("Connected as %s", info.role == BT_CONN_ROLE_CENTRAL ? "central" : "peripheral");
210-
LOG_INF("Conn. interval is %u units", info.le.interval);
210+
LOG_INF("Conn. interval is %u us", info.le.interval_us);
211211

212212
if (info.role == BT_CONN_ROLE_CENTRAL) {
213213
err = bt_gatt_dm_start(default_conn,
@@ -475,7 +475,7 @@ int connection_configuration_set(const struct bt_le_conn_param *conn_param,
475475
}
476476
}
477477

478-
if (info.le.interval != conn_param->interval_max) {
478+
if (BT_GAP_US_TO_CONN_INTERVAL(info.le.interval_us) != conn_param->interval_max) {
479479
err = bt_conn_le_param_update(default_conn, conn_param);
480480
if (err) {
481481
LOG_ERR("Connection parameters update failed: %d", err);

subsys/bluetooth/host_extensions/radio_notification_conn_cb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static uint32_t conn_interval_us_get(const struct bt_conn *conn)
3434
return 0;
3535
}
3636

37-
return BT_CONN_INTERVAL_TO_US(info.le.interval);
37+
return info.le.interval_us;
3838
}
3939

4040
static void work_handler(struct k_work *work)

subsys/bluetooth/rpc/client/bt_rpc_conn_client.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,10 @@ static void bt_conn_info_dec(struct nrf_rpc_cbor_ctx *ctx, struct bt_conn *conn,
279279
info->id = nrf_rpc_decode_uint(ctx);
280280

281281
if (info->type == BT_CONN_TYPE_LE) {
282-
info->le.interval = nrf_rpc_decode_uint(ctx);
282+
info->le.interval_us = nrf_rpc_decode_uint(ctx);
283+
#if !defined(CONFIG_BT_SHORTER_CONNECTION_INTERVALS)
284+
info->le._interval = nrf_rpc_decode_uint(ctx);
285+
#endif
283286
info->le.latency = nrf_rpc_decode_uint(ctx);
284287
info->le.timeout = nrf_rpc_decode_uint(ctx);
285288
LOCK_CONN_INFO();

0 commit comments

Comments
 (0)