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 <emil.gydesen@nordicsemi.no>
This commit is contained in:
Emil Gydesen 2021-08-25 12:12:35 +02:00 committed by Anas Nashif
commit 90eb48b111

View file

@ -453,8 +453,7 @@ static int parse_rtn_arg(struct bt_iso_chan_io_qos *qos)
} }
rtn = strtoul(buffer, NULL, 0); rtn = strtoul(buffer, NULL, 0);
/* TODO: Replace literal int with a #define once it has been created */ if (rtn > BT_ISO_CONNECTED_RTN_MAX) {
if (rtn > 16) {
printk("Invalid RTN %llu", rtn); printk("Invalid RTN %llu", rtn);
return -EINVAL; return -EINVAL;
} }
@ -478,7 +477,7 @@ static int parse_interval_arg(void)
interval = strtoul(buffer, NULL, 0); interval = strtoul(buffer, NULL, 0);
/* TODO: Replace literal ints with a #define once it has been created */ /* TODO: Replace literal ints with a #define once it has been created */
if (interval < 0x100 || interval > 0xFFFFF) { if (interval < BT_ISO_INTERVAL_MIN || interval > BT_ISO_INTERVAL_MAX) {
printk("Invalid interval %llu", interval); printk("Invalid interval %llu", interval);
return -EINVAL; return -EINVAL;
} }
@ -501,8 +500,7 @@ static int parse_latency_arg(void)
} }
latency = strtoul(buffer, NULL, 0); latency = strtoul(buffer, NULL, 0);
/* TODO: Replace literal int with a #define once it has been created */ if (latency < BT_ISO_LATENCY_MIN || latency > BT_ISO_LATENCY_MAX) {
if (latency > 0xFA0) {
printk("Invalid latency %llu", latency); printk("Invalid latency %llu", latency);
return -EINVAL; return -EINVAL;
} }
@ -551,8 +549,8 @@ static int parse_sdu_arg(struct bt_iso_chan_io_qos *qos)
} }
sdu = strtoul(buffer, NULL, 0); sdu = strtoul(buffer, NULL, 0);
/* TODO: Replace literal int with a #define once it has been created */ if (sdu > MIN(BT_ISO_MAX_SDU, sizeof(iso_data)) ||
if (sdu > 0xFFF || sdu < sizeof(uint32_t) /* room for the counter */) { sdu < sizeof(uint32_t) /* room for the counter */) {
printk("Invalid SDU %llu", sdu); printk("Invalid SDU %llu", sdu);
return -EINVAL; return -EINVAL;
} }
@ -575,7 +573,7 @@ static int parse_cis_count_arg(void)
} }
cis_count = strtoul(buffer, NULL, 0); cis_count = strtoul(buffer, NULL, 0);
if (cis_count > CONFIG_BT_ISO_MAX_CHAN) { if (cis_count > MAX(BT_ISO_MAX_GROUP_ISO_COUNT, CONFIG_BT_ISO_MAX_CHAN)) {
printk("Invalid CIS count %llu", cis_count); printk("Invalid CIS count %llu", cis_count);
return -EINVAL; return -EINVAL;
} }