-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix possible overflow at extremely low RSSI #15079
Conversation
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.
@danluck, thank you for your changes. |
This pull request has automatically been marked as stale because it has had no recent activity. @ARMmbed/mbed-os-maintainers, @ARMmbed/mbed-os-connectivity, please complete review of the changes to move the PR forward. Thank you for your contributions. |
CI started |
Jenkins CI Test : ✔️ SUCCESSBuild Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
@danluck I am not certain why frozen tools check. Can you rebase your branch to the latest master? I'll restart tests once done. |
@0xc0170 I did merge from master branch. Is it correct? I'm failed to rebase this branch to master. |
Merge commits are not allowed. You can try to rebase or create a new PR (or reset this branch to the latest master, and cherry pick this). |
Please remove the merge commit. |
I will create a new PR. |
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.
Summary of changes
Impact of changes
Migration actions required
Documentation
Pull request type
Test results
Reviewers