Skip to content

Commit af0aeb3

Browse files
cvinayakfabiobaltieri
authored andcommitted
tests: bsim: Bluetooth: Test 1ms connection interval support
Test 1ms connection interval support. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]>
1 parent abfe5f1 commit af0aeb3

File tree

6 files changed

+90
-3
lines changed

6 files changed

+90
-3
lines changed

tests/bsim/bluetooth/ll/compile.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ app=tests/bsim/bluetooth/ll/advx \
1717
conf_overlay=overlay-ticker_expire_info.conf compile
1818

1919
app=tests/bsim/bluetooth/ll/conn conf_file=prj_split.conf compile
20+
app=tests/bsim/bluetooth/ll/conn conf_file=prj_split_1ms.conf compile
2021
app=tests/bsim/bluetooth/ll/conn conf_file=prj_split_tx_defer.conf compile
2122
app=tests/bsim/bluetooth/ll/conn conf_file=prj_split_privacy.conf compile
2223
app=tests/bsim/bluetooth/ll/conn conf_file=prj_split_low_lat.conf compile

tests/bsim/bluetooth/ll/conn/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright (c) 2024 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config TEST_CONN_INTERVAL_1MS
5+
bool "Test 1 ms connection interval support"
6+
help
7+
Test 1 ms connection interval support.
8+
9+
menu "Zephyr Kernel"
10+
source "Kconfig.zephyr"
11+
endmenu
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
CONFIG_BT=y
2+
CONFIG_LOG=y
3+
CONFIG_BT_CENTRAL=y
4+
CONFIG_BT_PERIPHERAL=y
5+
CONFIG_BT_PRIVACY=y
6+
CONFIG_BT_SMP=y
7+
CONFIG_BT_SIGNING=y
8+
CONFIG_BT_BAS=y
9+
CONFIG_BT_HRS=y
10+
CONFIG_BT_ATT_PREPARE_COUNT=2
11+
CONFIG_BT_GATT_CLIENT=y
12+
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
13+
CONFIG_BT_DEVICE_NAME="bsim_test_split_1m"
14+
CONFIG_BT_L2CAP_TX_BUF_COUNT=6
15+
16+
CONFIG_BT_CTLR_PRIVACY=n
17+
18+
CONFIG_BT_CONN_PARAM_ANY=y
19+
20+
CONFIG_BT_CTLR_ADVANCED_FEATURES=y
21+
CONFIG_BT_CTLR_CONN_INTERVAL_LOW_LATENCY=y
22+
23+
CONFIG_TEST_CONN_INTERVAL_1MS=y

tests/bsim/bluetooth/ll/conn/src/test_connect1.c

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,19 @@ static struct bt_uuid_16 uuid = BT_UUID_INIT_16(0);
2929
static struct bt_gatt_discover_params discover_params;
3030
static struct bt_gatt_subscribe_params subscribe_params;
3131

32+
#if defined(CONFIG_TEST_CONN_INTERVAL_1MS)
33+
#define UPDATE_PARAM_INTERVAL_MIN 1
34+
#define UPDATE_PARAM_INTERVAL_MAX 1
35+
#define UPDATE_PARAM_LATENCY 0
36+
#define UPDATE_PARAM_TIMEOUT 10
37+
#define TEST_NOTIFY_COUNT 3000
38+
#else /* !CONFIG_TEST_CONN_INTERVAL_1MS */
3239
#define UPDATE_PARAM_INTERVAL_MIN 25
3340
#define UPDATE_PARAM_INTERVAL_MAX 45
3441
#define UPDATE_PARAM_LATENCY 1
3542
#define UPDATE_PARAM_TIMEOUT 250
43+
#define TEST_NOTIFY_COUNT 3
44+
#endif /* !CONFIG_TEST_CONN_INTERVAL_1MS */
3645

3746
static struct bt_le_conn_param update_params = {
3847
.interval_min = UPDATE_PARAM_INTERVAL_MIN,
@@ -124,16 +133,32 @@ static uint8_t notify_func(struct bt_conn *conn,
124133
struct bt_gatt_subscribe_params *params,
125134
const void *data, uint16_t length)
126135
{
136+
static uint32_t cycle_stamp;
127137
static int notify_count;
138+
uint32_t cycle_now;
139+
uint64_t delta;
140+
128141
if (!data) {
129142
printk("[UNSUBSCRIBED]\n");
130143
params->value_handle = 0U;
131144
return BT_GATT_ITER_STOP;
132145
}
133146

134-
printk("[NOTIFICATION] data %p length %u\n", data, length);
147+
cycle_now = k_cycle_get_32();
148+
delta = cycle_now - cycle_stamp;
149+
cycle_stamp = cycle_now;
150+
delta = k_cyc_to_ns_floor64(delta);
151+
152+
if (!IS_ENABLED(CONFIG_TEST_CONN_INTERVAL_1MS) ||
153+
((delta > (NSEC_PER_MSEC / 2U)) &&
154+
(delta < (NSEC_PER_MSEC + (NSEC_PER_MSEC / 2U))))) {
155+
notify_count++;
156+
}
157+
158+
printk("[NOTIFICATION] %u. data %p length %u in %llu ns\n",
159+
notify_count, data, length, delta);
135160

136-
if (notify_count++ >= 1) { /* We consider it passed */
161+
if (notify_count >= TEST_NOTIFY_COUNT) { /* We consider it passed */
137162
int err;
138163

139164
/* Disconnect before actually passing */

tests/bsim/bluetooth/ll/conn/src/test_connect2.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ static void test_con2_main(void)
209209
* of starting delayed work so we do it here
210210
*/
211211
while (1) {
212-
if (IS_ENABLED(CONFIG_BT_CTLR_TX_DEFER)) {
212+
if (IS_ENABLED(CONFIG_TEST_CONN_INTERVAL_1MS) ||
213+
IS_ENABLED(CONFIG_BT_CTLR_TX_DEFER)) {
213214
k_sleep(K_MSEC(1));
214215
} else {
215216
k_sleep(K_SECONDS(1));
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2024 Nordic Semiconductor ASA
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
source ${ZEPHYR_BASE}/tests/bsim/sh_common.source
6+
7+
# Basic connection test: a central connects to a peripheral and expects a
8+
# notification, using the split controller (ULL LLL) and 1ms connection
9+
# interval
10+
simulation_id="basic_conn_split_1ms"
11+
verbosity_level=2
12+
13+
cd ${BSIM_OUT_PATH}/bin
14+
15+
Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_ll_conn_prj_split_1ms_conf \
16+
-v=${verbosity_level} -s=${simulation_id} -d=0 -RealEncryption=1 \
17+
-testid=peripheral -rs=23
18+
19+
Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_ll_conn_prj_split_1ms_conf\
20+
-v=${verbosity_level} -s=${simulation_id} -d=1 -RealEncryption=1 \
21+
-testid=central -rs=6
22+
23+
Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \
24+
-D=2 -sim_length=20e6 $@
25+
26+
wait_for_background_jobs

0 commit comments

Comments
 (0)