Skip to content

Commit 509dc25

Browse files
committed
tests: bsim: Bluetooth: Add param update to throughput test
Add connection parameter update to throughput test to cover any connection timeout performing connection update while subjected to high throughput scenarios. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
1 parent 37f9995 commit 509dc25

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

samples/bluetooth/central_gatt_write/src/gatt_write_common.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
static uint32_t phy_update_countdown;
1818
static uint8_t phy_param_idx;
1919

20+
/* Count down number of metrics intervals before performing a param update */
21+
#define PARAM_UPDATE_COUNTDOWN PHY_UPDATE_COUNTDOWN
22+
static uint32_t param_update_countdown;
23+
2024
static void phy_update_iterate(struct bt_conn *conn)
2125
{
2226
const struct bt_conn_le_phy_param phy_param[] = {
@@ -178,6 +182,34 @@ static void write_cmd_cb(struct bt_conn *conn, void *user_data)
178182
phy_update_iterate(conn);
179183
}
180184

185+
const struct bt_le_conn_param update_params[2] = {{
186+
.interval_min = 0x0029,
187+
.interval_max = 0x0029,
188+
.latency = 0,
189+
.timeout = 31,
190+
}, {
191+
.interval_min = 0x0028,
192+
.interval_max = 0x0028,
193+
.latency = 0,
194+
.timeout = 30,
195+
},
196+
};
197+
static uint8_t param_update_count;
198+
int err;
199+
200+
if (param_update_countdown--) {
201+
return;
202+
}
203+
204+
param_update_countdown = PARAM_UPDATE_COUNTDOWN;
205+
206+
err = bt_conn_le_param_update(conn, &update_params[param_update_count & 0x1]);
207+
if (err) {
208+
printk("Parameter update failed (err %d)\n", err);
209+
}
210+
211+
param_update_count++;
212+
181213
} else {
182214
uint16_t len;
183215

@@ -256,6 +288,9 @@ static void connected(struct bt_conn *conn, uint8_t conn_err)
256288
phy_update_countdown = PHY_UPDATE_COUNTDOWN;
257289
phy_param_idx = 0U;
258290
}
291+
292+
/* Offset param update by 1 metric collection after PHY update */
293+
param_update_countdown = PARAM_UPDATE_COUNTDOWN + 1U;
259294
}
260295

261296
static void disconnected(struct bt_conn *conn, uint8_t reason)

tests/bsim/bluetooth/ll/throughput/src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static void test_central_main(void)
6767
write_rate = central_gatt_write(COUNT);
6868

6969
printk("%s: Write Rate = %u bps\n", __func__, write_rate);
70-
if (write_rate == WRITE_RATE) {
70+
if (write_rate >= WRITE_RATE) {
7171
PASS("Central tests passed\n");
7272
} else {
7373
FAIL("Central tests failed\n");
@@ -86,7 +86,7 @@ static void test_peripheral_main(void)
8686
write_rate = peripheral_gatt_write(COUNT);
8787

8888
printk("%s: Write Rate = %u bps\n", __func__, write_rate);
89-
if (write_rate == WRITE_RATE) {
89+
if (write_rate >= WRITE_RATE) {
9090
PASS("Peripheral tests passed\n");
9191
} else {
9292
FAIL("Peripheral tests failed\n");

0 commit comments

Comments
 (0)