Skip to content

Commit 264ccd2

Browse files
Frodevancarlescufi
authored andcommitted
samples: Bluetooth: Kconfig for limited printout in some ISO samples
Add kconfig to let the ISO broadcast and ISO receive samples report packets no more than once per set interval of packets. Signed-off-by: Frode van der Meeren <[email protected]>
1 parent 05e78fa commit 264ccd2

File tree

4 files changed

+52
-8
lines changed

4 files changed

+52
-8
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) 2023 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
source "Kconfig.zephyr"
5+
6+
mainmenu "Bluetooth: ISO Broadcast"
7+
8+
config ISO_PRINT_INTERVAL
9+
int "Interval between each packet report"
10+
range 1 360000
11+
default 1
12+
help
13+
Only print the packet report once in a given interval of ISO packets.

samples/bluetooth/iso_broadcast/src/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,13 +167,13 @@ void main(void)
167167

168168
}
169169

170-
iso_send_count++;
171-
seq_num++;
172-
173-
if ((iso_send_count % 100) == 0) {
170+
if ((iso_send_count % CONFIG_ISO_PRINT_INTERVAL) == 0) {
174171
printk("Sending value %u\n", iso_send_count);
175172
}
176173

174+
iso_send_count++;
175+
seq_num++;
176+
177177
timeout_counter--;
178178
if (!timeout_counter) {
179179
timeout_counter = INITIAL_TIMEOUT_COUNTER;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (c) 2023 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
source "Kconfig.zephyr"
5+
6+
mainmenu "Bluetooth: ISO Receive"
7+
8+
config ISO_PRINT_INTERVAL
9+
int "Interval between each packet report"
10+
range 1 360000
11+
default 1
12+
help
13+
Only print the packet report once in a given interval of ISO packets.
14+
15+
config ISO_ALIGN_PRINT_INTERVALS
16+
bool "Align report interval with incoming packets"
17+
help
18+
Align interval-counter with packet number from incoming ISO packets.
19+
This may be needed if report printouts are to be synchronized between
20+
the iso_broadcast sample and the iso_receive sample.

samples/bluetooth/iso_receive/src/main.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ static bt_addr_le_t per_addr;
3030
static uint8_t per_sid;
3131
static uint32_t per_interval_us;
3232

33+
static uint32_t iso_recv_count;
34+
3335
static K_SEM_DEFINE(sem_per_adv, 0, 1);
3436
static K_SEM_DEFINE(sem_per_sync, 0, 1);
3537
static K_SEM_DEFINE(sem_per_sync_lost, 0, 1);
@@ -215,12 +217,19 @@ static void iso_recv(struct bt_iso_chan *chan, const struct bt_iso_recv_info *in
215217

216218
if (buf->len == sizeof(count)) {
217219
count = sys_get_le32(buf->data);
220+
if (IS_ENABLED(CONFIG_ISO_ALIGN_PRINT_INTERVALS)) {
221+
iso_recv_count = count;
222+
}
218223
}
219224

220-
str_len = bin2hex(buf->data, buf->len, data_str, sizeof(data_str));
221-
printk("Incoming data channel %p flags 0x%x seq_num %u ts %u len %u: "
222-
"%s (counter value %u)\n", chan, info->flags, info->seq_num,
223-
info->ts, buf->len, data_str, count);
225+
if ((iso_recv_count % CONFIG_ISO_PRINT_INTERVAL) == 0) {
226+
str_len = bin2hex(buf->data, buf->len, data_str, sizeof(data_str));
227+
printk("Incoming data channel %p flags 0x%x seq_num %u ts %u len %u: "
228+
"%s (counter value %u)\n", chan, info->flags, info->seq_num,
229+
info->ts, buf->len, data_str, count);
230+
}
231+
232+
iso_recv_count++;
224233
}
225234

226235
static void iso_connected(struct bt_iso_chan *chan)
@@ -280,6 +289,8 @@ void main(void)
280289
uint32_t sem_timeout_us;
281290
int err;
282291

292+
iso_recv_count = 0;
293+
283294
printk("Starting Synchronized Receiver Demo\n");
284295

285296
#if defined(HAS_LED)

0 commit comments

Comments
 (0)