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

sys/shell: add 'loramac set ch_mask' command

This commit is contained in:
Geovane Fedrecheski 2022-03-18 10:30:40 -03:00
parent d5b4492cf3
commit 26c55a91bd
2 changed files with 26 additions and 1 deletions

View File

@ -547,6 +547,15 @@ extern "C" {
*/
#define LORAMAC_NETWORK_ID_LEN (3U)
/**
* @brief Maximum length for channel mask
*
* The actual length is set by each region-specific LoRaMac
* implementation (see CHANNELS_MASK_SIZE), which
* automatically slices down the channel array mask.
*/
#define LORAMAC_CHANNELS_MASK_MAX_LEN (6U)
/** @} */
/**

View File

@ -58,7 +58,7 @@ static void _loramac_tx_usage(void)
static void _loramac_set_usage(void)
{
puts("Usage: loramac set <deveui|appeui|appkey|appskey|nwkskey|devaddr|"
"class|dr|adr|public|netid|tx_power|rx2_freq|rx2_dr|ul_cnt> <value>");
"class|dr|adr|public|netid|tx_power|rx2_freq|rx2_dr|ul_cnt|ch_mask> <value>");
}
static void _loramac_get_usage(void)
@ -347,6 +347,22 @@ int _loramac_handler(int argc, char **argv)
uint32_t counter = atoi(argv[3]);
semtech_loramac_set_uplink_counter(&loramac, counter);
}
else if (strcmp("ch_mask", argv[2]) == 0) {
if (argc < 4) {
puts("Usage: loramac set ch_mask <value>");
puts("Example (sets channels 0-3): loramac set ch_mask 000F00000000000000000000");
return 1;
}
uint16_t mask[LORAMAC_CHANNELS_MASK_MAX_LEN] = { 0 };
uint8_t tmp[LORAMAC_CHANNELS_MASK_MAX_LEN*2];
fmt_hex_bytes(tmp, argv[3]);
for (size_t i = 0, j = 0; i < LORAMAC_CHANNELS_MASK_MAX_LEN; i++, j+=2) {
/* copy over to span a 16-bit -wide unsigned integer */
mask[i] |= tmp[j] << 8;
mask[i] |= tmp[j+1];
}
semtech_loramac_set_channels_mask(&loramac, mask);
}
else {
_loramac_set_usage();
return 1;