Don't assign negative SNR to unsigned int type

SNR-based contention windows are broken on systems with 64-bit long integers.
Fixes #8430
This commit is contained in:
korbinianbauer 2025-10-23 16:15:12 +02:00 committed by GitHub
parent 15ee1c2819
commit 39780656ef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -272,10 +272,10 @@ uint32_t RadioInterface::getTxDelayMsec()
uint8_t RadioInterface::getCWsize(float snr) uint8_t RadioInterface::getCWsize(float snr)
{ {
// The minimum value for a LoRa SNR // The minimum value for a LoRa SNR
const uint32_t SNR_MIN = -20; const int32_t SNR_MIN = -20;
// The maximum value for a LoRa SNR // The maximum value for a LoRa SNR
const uint32_t SNR_MAX = 10; const int32_t SNR_MAX = 10;
return map(snr, SNR_MIN, SNR_MAX, CWmin, CWmax); return map(snr, SNR_MIN, SNR_MAX, CWmin, CWmax);
} }