Skip to content
This repository has been archived by the owner on Jun 12, 2023. It is now read-only.

fix rssi computation from rssic if SNR < 0 #1777

Merged
merged 1 commit into from
Aug 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/miner_lora.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

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

Couldn’t this line result in an arithmetic operation error if rssic is undefined?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like it would, yes. I think a missing rssic is a brutal fatal error, though. So the arithmetic error is appropriate to propagate?

Copy link
Contributor

Choose a reason for hiding this comment

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

it's defined to be present in this protocol version

_ -> maps:get(<<"rssic">>, Obj, undefined)
end
end
end,
BestRSSISelector =
Expand Down