Skip to content

Commit

Permalink
Use Packet RSSI formula from datasheet section 5.5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt committed Sep 26, 2019
1 parent 30a07a3 commit 68f403b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions LoRa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ uint8_t LoRaClass::packetRssiRaw() {

int LoRaClass::packetRssi() {
int pkt_rssi = (int)readRegister(REG_PKT_RSSI_VALUE);
int8_t pkt_snr = ((int8_t)readRegister(REG_PKT_SNR_VALUE));
if pkt_snr < 0 {
pkt_rssi = pkt_rssi * 16 / 15;
} else {
pkt_rssi += pkt_snr / 4;
}
// TODO: change this to look at the actual model code
if (_frequency < 820E6) pkt_rssi -= 7;
pkt_rssi -= 157;
Expand Down

1 comment on commit 68f403b

@markqvist
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had to revert this pull request, since it seems that this is not how to do it according to the datasheet. The correction of adding PacketSNR*0.25 should only be applied when the packet is below the noise floor, hence when pkt_snr < 0, you have it the other way around in this code ;)

Also, as I read the datasheet, the 16/16*rssi slope correction in the datasheet should be applied only when RSSI is above -100 dBm, and here you do the correction when pkt_snr < 0.

But thanks so much for pointing it out anyway. I think I choose to forego the slope adjustment originally, since it's not adding that much precision anyways, but I'll add it now anyways, since I just looked it all through.

Please sign in to comment.