1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 05:12:57 +01:00

examples/twr_aloha: error on invalid short address

This commit is contained in:
Francisco Molina 2022-04-21 13:35:12 +02:00
parent 90af3bd026
commit f5a4a486f6

View File

@ -121,7 +121,8 @@ int _twr_handler(int argc, char **argv)
uint32_t count = 1;
uint32_t interval_ms = 1000;
int proto = UWB_DATA_CODE_SS_TWR;
uint8_t addr[IEEE802154_SHORT_ADDRESS_LEN_STR_MAX];
uint8_t addr[IEEE802154_SHORT_ADDRESS_LEN];
uint16_t short_addr = 0x0000;
int res = 0;
if (argc < 3) {
_print_usage();
@ -138,6 +139,11 @@ int _twr_handler(int argc, char **argv)
"(hex pairs delimited by colons)");
res = 1;
}
short_addr = addr[1] + (addr[0] << 8);
if (short_addr == 0x0000) {
printf("[ERROR]: invalid addr %s\n", arg);
res = 1;
}
}
else {
switch (arg[1]) {
@ -194,11 +200,10 @@ int _twr_handler(int argc, char **argv)
}
}
}
if (res != 0) {
if (res != 0 || (short_addr == 0x0000)) {
_print_usage();
return 1;
}
uint16_t short_addr = addr[1] + (addr[0] << 8);
puts("[twr]: start ranging");
uwb_core_rng_start(short_addr, proto, interval_ms, count);
if (IS_ACTIVE(CONFIG_TWR_SHELL_BLOCKING)) {