Skip to content

Commit ed46180

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

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

samples/bluetooth/iso_broadcast_benchmark/src/broadcaster.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ static int parse_rtn_arg(void)
114114
}
115115

116116
rtn = strtoul(buffer, NULL, 0);
117-
/* TODO: Replace literal int with a #define once it has been created */
118-
if (rtn > 16) {
117+
if (rtn > BT_ISO_BROADCAST_RTN_MAX) {
119118
printk("Invalid RTN %llu", rtn);
120119
return -EINVAL;
121120
}
@@ -138,8 +137,7 @@ static int parse_interval_arg(void)
138137
}
139138

140139
interval = strtoul(buffer, NULL, 0);
141-
/* TODO: Replace literal int with a #define once it has been created */
142-
if (interval < 0x100 || interval > 0xFFFFF) {
140+
if (interval < BT_ISO_INTERVAL_MIN || interval > BT_ISO_INTERVAL_MAX) {
143141
printk("Invalid interval %llu", interval);
144142
return -EINVAL;
145143
}
@@ -162,8 +160,7 @@ static int parse_latency_arg(void)
162160
}
163161

164162
latency = strtoul(buffer, NULL, 0);
165-
/* TODO: Replace literal int with a #define once it has been created */
166-
if (latency > 0xFA0) {
163+
if (latency < BT_ISO_LATENCY_MIN || latency > BT_ISO_LATENCY_MAX) {
167164
printk("Invalid latency %llu", latency);
168165
return -EINVAL;
169166
}
@@ -212,8 +209,7 @@ static int parse_sdu_arg(void)
212209
}
213210

214211
sdu = strtoul(buffer, NULL, 0);
215-
/* TODO: Replace literal int with a #define once it has been created */
216-
if (sdu > 0xFFF) {
212+
if (sdu > MIN(BT_ISO_MAX_SDU, sizeof(iso_data))) {
217213
printk("Invalid SDU %llu", sdu);
218214
return -EINVAL;
219215
}
@@ -236,8 +232,8 @@ static int parse_packing_arg(void)
236232
}
237233

238234
packing = strtoul(buffer, NULL, 0);
239-
/* TODO: Replace literal int with a #define once it has been created */
240-
if (packing > 1) {
235+
if (packing != BT_ISO_PACKING_SEQUENTIAL &&
236+
packing != BT_ISO_PACKING_INTERLEAVED) {
241237
printk("Invalid packing %llu", packing);
242238
return -EINVAL;
243239
}
@@ -260,8 +256,8 @@ static int parse_framing_arg(void)
260256
}
261257

262258
framing = strtoul(buffer, NULL, 0);
263-
/* TODO: Replace literal int with a #define once it has been created */
264-
if (framing > 1) {
259+
if (framing != BT_ISO_FRAMING_UNFRAMED &&
260+
framing != BT_ISO_FRAMING_FRAMED) {
265261
printk("Invalid framing %llu", framing);
266262
return -EINVAL;
267263
}
@@ -284,7 +280,7 @@ static int parse_bis_count_arg(void)
284280
}
285281

286282
bis_count = strtoul(buffer, NULL, 0);
287-
if (bis_count > CONFIG_BT_ISO_MAX_CHAN) {
283+
if (bis_count > MAX(BT_ISO_MAX_GROUP_ISO_COUNT, CONFIG_BT_ISO_MAX_CHAN)) {
288284
printk("Invalid BIS count %llu", bis_count);
289285
return -EINVAL;
290286
}

0 commit comments

Comments
 (0)