meshtastic / Meshtastic-Apple

Apple iOS, iPadOS & macOS Clients For Meshtastic
https://meshtastic.org
GNU General Public License v3.0
214 stars 63 forks source link

🐞 [Bug]: nodes UIs always shows “signal good” when RSSI value is unknown (indicated by 0) #930

Open powersjcb opened 1 month ago

powersjcb commented 1 month ago

Firmware Version

2.5.*

What did you do?

View nodes list page

Expected Behavior

It should show unknown or some other indicator if the data is missing. Ideally hiding the value when zero.

Current Behavior

UI shows 0 and “good” signal when only SNR is present.

Participation

Additional comments

I don’t have a lot of context on this could use help defining more clear behavior when data is missing.

garthvh commented 1 month ago

Rssi is included in the snr and only tells us if there is noise, not sure what this would do

powersjcb commented 1 month ago

I think something might still be wrong in how we display this. I'm pretty sure our code assumes RSSI is always present, but a value of 0 represents. ("not available") Using RSSI of 0 would be extremely an strong signal.

This RSSI of 0 (actually null) seems to be getting plugged into some calculation for how we display link quality. ("good" "bad" "fair") I haven't dug into the source for this, but it looks like we are using something like SINR.

See these two nodes:

node 1: {
  rssi: 0 // actually an unknown value
  snr: -15
  display: "good"
node 2:
  rssi: -121
  snr: -10.75 // better signal to noise ratio than node 1
  display: "bad"

The node 2 has better SNR, but it's still showing up as a worse link than node 1.

image image
powersjcb commented 1 month ago

Yup, it looks like our code assumes that RSSI will always be available. (which isn't the case)

func getLoRaSignalStrength(snr: Float, rssi: Int32, preset: ModemPresets) -> LoRaSignalStrength {
    if rssi > -115 && snr > (preset.snrLimit()) {
        return .good
    } else if rssi < -126 && snr < (preset.snrLimit() - 7.5) {
        return .none
    } else if rssi <= -120 || snr <= (preset.snrLimit() - 5.5) {
        return .bad
    } else { return .fair }
}

I'm going to update this logic to ignore rssi when it's value is 0.

powersjcb commented 1 month ago

Per the discord #firmware channel

RSSI is not stored in NodeInfo, only SNR. So, if you haven't received any data from a node after connecting, you'll only see the SNR.