Skip to content

Commit 3b15397

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 f2e11a6 commit 3b15397

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

samples/bluetooth/central_gatt_write/src/gatt_write_common.c

Lines changed: 40 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--) != 0U) {
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 != 0) {
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,14 @@ 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+
/* Every 1 second the acknowledged total GATT Write without Response data size is used for
293+
* the throughput calculation.
294+
* PHY update is performed in reference to this calculation interval, and connection update
295+
* is offset by 1 of this interval so that connection update is initiated one such interval
296+
* after PHY update was requested.
297+
*/
298+
param_update_countdown = PARAM_UPDATE_COUNTDOWN + 1U;
259299
}
260300

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

0 commit comments

Comments
 (0)