Skip to content

Commit 90eb48b

Browse files
Thalleynashif
authored andcommitted
Bluetooth: samples: Update iso parameter check in iso_connected_benchmark
Update the iso parameter value checks from using literals to the defined #defines. Signed-off-by: Emil Gydesen <[email protected]>
1 parent d8d8d82 commit 90eb48b

File tree

1 file changed

+6
-8
lines changed
  • samples/bluetooth/iso_connected_benchmark/src

1 file changed

+6
-8
lines changed

samples/bluetooth/iso_connected_benchmark/src/main.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,7 @@ static int parse_rtn_arg(struct bt_iso_chan_io_qos *qos)
453453
}
454454

455455
rtn = strtoul(buffer, NULL, 0);
456-
/* TODO: Replace literal int with a #define once it has been created */
457-
if (rtn > 16) {
456+
if (rtn > BT_ISO_CONNECTED_RTN_MAX) {
458457
printk("Invalid RTN %llu", rtn);
459458
return -EINVAL;
460459
}
@@ -478,7 +477,7 @@ static int parse_interval_arg(void)
478477

479478
interval = strtoul(buffer, NULL, 0);
480479
/* TODO: Replace literal ints with a #define once it has been created */
481-
if (interval < 0x100 || interval > 0xFFFFF) {
480+
if (interval < BT_ISO_INTERVAL_MIN || interval > BT_ISO_INTERVAL_MAX) {
482481
printk("Invalid interval %llu", interval);
483482
return -EINVAL;
484483
}
@@ -501,8 +500,7 @@ static int parse_latency_arg(void)
501500
}
502501

503502
latency = strtoul(buffer, NULL, 0);
504-
/* TODO: Replace literal int with a #define once it has been created */
505-
if (latency > 0xFA0) {
503+
if (latency < BT_ISO_LATENCY_MIN || latency > BT_ISO_LATENCY_MAX) {
506504
printk("Invalid latency %llu", latency);
507505
return -EINVAL;
508506
}
@@ -551,8 +549,8 @@ static int parse_sdu_arg(struct bt_iso_chan_io_qos *qos)
551549
}
552550

553551
sdu = strtoul(buffer, NULL, 0);
554-
/* TODO: Replace literal int with a #define once it has been created */
555-
if (sdu > 0xFFF || sdu < sizeof(uint32_t) /* room for the counter */) {
552+
if (sdu > MIN(BT_ISO_MAX_SDU, sizeof(iso_data)) ||
553+
sdu < sizeof(uint32_t) /* room for the counter */) {
556554
printk("Invalid SDU %llu", sdu);
557555
return -EINVAL;
558556
}
@@ -575,7 +573,7 @@ static int parse_cis_count_arg(void)
575573
}
576574

577575
cis_count = strtoul(buffer, NULL, 0);
578-
if (cis_count > CONFIG_BT_ISO_MAX_CHAN) {
576+
if (cis_count > MAX(BT_ISO_MAX_GROUP_ISO_COUNT, CONFIG_BT_ISO_MAX_CHAN)) {
579577
printk("Invalid CIS count %llu", cis_count);
580578
return -EINVAL;
581579
}

0 commit comments

Comments
 (0)