mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
net/gnrc_lorawan: fix random_uint32_range upper bound
This commit is contained in:
parent
0ffd04c132
commit
179a2c2780
@ -100,10 +100,10 @@ uint32_t gnrc_lorawan_pick_channel(gnrc_lorawan_t *mac)
|
||||
{
|
||||
uint8_t index = 0;
|
||||
|
||||
uint8_t random_number = random_uint32_range(0, bitarithm_bits_set(mac->channel_mask));
|
||||
uint8_t pos = random_uint32_range(0, bitarithm_bits_set(mac->channel_mask));
|
||||
unsigned state = mac->channel_mask;
|
||||
|
||||
for (int i = 0; i < random_number; i++) {
|
||||
for (int i = 0; i < pos + 1; i++) {
|
||||
state = bitarithm_test_and_clear(state, &index);
|
||||
}
|
||||
return mac->channel[index];
|
||||
|
Loading…
Reference in New Issue
Block a user