Hardware
64-bit platforms
Firmware Version
any since the introduction of getCWsize() (?)
Description
I'm on the move and don't have the tools to properly debug this right now, so I might be totally wrong but...
RadioInterface::getCWsize(float snr) uses an unsigned integer type to store a negative number.
IMO this will result in map() always returning the maximum CW size of 8 and no preference for nodes with low SNR.
uint8_t RadioInterface::getCWsize(float snr)
{
// The minimum value for a LoRa SNR
const uint32_t SNR_MIN = -20; //<--- That becomes 4294967276
// The maximum value for a LoRa SNR
const uint32_t SNR_MAX = 10;
return map(snr, SNR_MIN, SNR_MAX, CWmin, CWmax);
}
I tried to recreate the behaviour in an online C++ compiler as a sanity check: https://onlinegdb.com/zTwCkEfEs
Results below.
Relevant log output
CW size for SNR = 10: DEBUG: map() called with inputs:
x: 10
in_min: 4294967276
in_max: 10
out_min: 3
out_max: 8
-> 8
CW size for SNR = 5: DEBUG: map() called with inputs:
x: 5
in_min: 4294967276
in_max: 10
out_min: 3
out_max: 8
-> 8
CW size for SNR = 0: DEBUG: map() called with inputs:
x: 0
in_min: 4294967276
in_max: 10
out_min: 3
out_max: 8
-> 8
CW size for SNR = -5: DEBUG: map() called with inputs:
x: -5
in_min: 4294967276
in_max: 10
out_min: 3
out_max: 8
-> 8
CW size for SNR = -10: DEBUG: map() called with inputs:
x: -10
in_min: 4294967276
in_max: 10
out_min: 3
out_max: 8
-> 8
CW size for SNR = -15: DEBUG: map() called with inputs:
x: -15
in_min: 4294967276
in_max: 10
out_min: 3
out_max: 8
-> 8
CW size for SNR = -20: DEBUG: map() called with inputs:
x: -20
in_min: 4294967276
in_max: 10
out_min: 3
out_max: 8
-> 8
...Program finished with exit code 0
Press ENTER to exit console.
Hardware
64-bit platforms
Firmware Version
any since the introduction of getCWsize() (?)
Description
I'm on the move and don't have the tools to properly debug this right now, so I might be totally wrong but...
RadioInterface::getCWsize(float snr) uses an unsigned integer type to store a negative number.IMO this will result in map() always returning the maximum CW size of 8 and no preference for nodes with low SNR.
I tried to recreate the behaviour in an online C++ compiler as a sanity check: https://onlinegdb.com/zTwCkEfEs
Results below.
Relevant log output