mbed-os/connectivity/lorawan
Mikhail Isaev 352e6fbd23 Fix overflow at extremely low RSSI
Some LoRaWAN modem like SX1272 can receive downlink packets with RSSI level less than -127. So "int8_t" is not enough for store all possible RSSI values. For example, SX1272 has sensitivity at -137 dBm.
Problem was manifested in the file "SX1272_LoRaRadio.cpp" at SX1272_LoRaRadio::handle_dio0_irq() method.
When value of _rf_settings.lora_packet_handler.rssi_value calculated incorrect RSSI will be stored. Example case:

Value readen from register REG_LR_PKTSNRVALUE _rf_settings.lora_packet_handler.snr_value equals -47.
Value readen from register REG_LR_PKTRSSIVALUE equals 17.
RSSI_OFFSET equals "-139", snr equals "-11".

For case MODEM_LORA value calculated by formula:
_rf_settings.lora_packet_handler.rssi_value = RSSI_OFFSET + rssi + (rssi >> 4) + snr;
and result value will be "124" because of int8_t overflow so it's not correct value (too high).

Correct value must be:
-139 + 17 + (1) + (-11) = -132.

Another motivation: at all other places int16_t type used to store RSSI value.
2021-11-24 21:56:42 +03:00
..
include/lorawan Fix overflow at extremely low RSSI 2021-11-24 21:56:42 +03:00
lorastack Lora: Clear callback ID when timer callback is executed. 2021-03-11 21:00:43 +00:00
source Moving headers and sources to their respective separate directories based on new component structure 2020-08-12 11:06:37 +01:00
system LoRaWANTimer: add new line at the end of the file 2021-03-12 08:24:16 +00:00
tests Unit tests: Remove redundant CMake target mbed-headers-base 2021-08-02 17:42:43 +01:00
CMakeLists.txt CMake: Add option to enable greentea tests 2021-08-10 16:35:11 +01:00
FSB_Usage.txt Mbed OS will soon be changing directory structure to the below: 2020-08-12 11:06:36 +01:00
LICENSE Mbed OS will soon be changing directory structure to the below: 2020-08-12 11:06:36 +01:00
mbed_lib.json Lora drivers: explicit lib requirement 2021-09-10 09:07:15 +02:00