mbed-os/connectivity
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
..
FEATURE_BLE Squashed 'connectivity/nanostack/coap-service/' changes from bbe01736bd..9a9085d4cd 2021-09-23 13:21:08 +03:00
cellular NetworkStack: Remove stub implementations of socket_x_control 2021-10-21 10:33:13 +02:00
docs Squashed 'connectivity/nanostack/coap-service/' changes from bbe01736bd..9a9085d4cd 2021-09-23 13:21:08 +03:00
drivers Merge pull request #15153 from bakatrouble/master 2021-11-17 15:22:30 +00:00
libraries Squashed 'connectivity/nanostack/coap-service/' changes from bbe01736bd..9a9085d4cd 2021-09-23 13:21:08 +03:00
lorawan Fix overflow at extremely low RSSI 2021-11-24 21:56:42 +03:00
lwipstack LWIP: Provide inline replacements for htons() and htonl() 2021-09-25 15:13:22 +07:00
mbedtls Squashed 'connectivity/nanostack/coap-service/' changes from bbe01736bd..9a9085d4cd 2021-09-23 13:21:08 +03:00
nanostack Merge pull request #15147 from boraozgen/bugfix/remove-socket-control-stubs 2021-10-25 11:41:04 +02:00
netsocket Merge pull request #15111 from world-direct/feature/dtlserror 2021-11-17 15:25:29 +00:00
nfc Squashed 'connectivity/nanostack/coap-service/' changes from bbe01736bd..9a9085d4cd 2021-09-23 13:21:08 +03:00
CMakeLists.txt Squashed 'connectivity/nanostack/coap-service/' changes from bbe01736bd..9a9085d4cd 2021-09-23 13:21:08 +03:00