From f0392bd1f8afc82eb6688bf9e20de8a7633c6899 Mon Sep 17 00:00:00 2001 From: Benoit Duffez Date: Thu, 21 Jul 2022 08:25:04 -0700 Subject: [PATCH] fix rssi computation from rssic if SNR < 0 rssis is supposed to be the useful signal strength rssic is supposed to be the received signal strength The blockchain excepts the rssi to be the rssis. However when falling back to rssic when rssis is unavailable, the computation is wrong when SNR < 0 Indeed, in that case the useful signal strenght is below the noise level, which is rssic. So the rssis = SNR + rssic when SNR < 0 This should help use the appropriate GWMPv2 value from the packet forwarders --- src/miner_lora.erl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/miner_lora.erl b/src/miner_lora.erl index 397dd3d09..508adee1c 100644 --- a/src/miner_lora.erl +++ b/src/miner_lora.erl @@ -842,7 +842,11 @@ packet_rssi(Packet, UseRSSIS) -> false -> %% Just use RSSIC. fun (Obj) -> - maps:get(<<"rssic">>, Obj, undefined) + SNR = maps:get(<<"lsnr">>, Obj, 0), + case SNR < 0 of + true -> SNR + maps:get(<<"rssic">>, Obj, undefined); + _ -> maps:get(<<"rssic">>, Obj, undefined) + end end end, BestRSSISelector =