markqvist / RNode_Firmware

RNode is an open, free and flexible digital radio interface with many uses
https://unsigned.io/rnode
GNU General Public License v3.0
166 stars 56 forks source link

Fix RSSI offset for pre-msg RSSI notification #4

Closed TheBlueMatt closed 4 years ago

TheBlueMatt commented 4 years ago

last_rssi is a large negative number, with rssi_offset being +292, intended to be added to put the value inside the range of a single byte uint. Before sending the data message, a RSSI message is automatically sent, which is quite nice, but the value ends up overflowing the 8-bit uint, giving a bogus value.

TheBlueMatt commented 4 years ago

This may also be a good opportunity to Went ahead and now calculate the RSSI using the formulas on the datasheet (ie if SNR <= 0, RSSI = RSSIRegister - 157 + SNRRegister/4, else RSSIRegister*16/15 - 157)

markqvist commented 4 years ago

Thanks for fixing that! It's merged now :)

markqvist commented 4 years ago

And you're also totally right that the way the RSSI is sent to the host is confusing and weird. I did it like it is now to be able to send it in a single byte as you noticed, the overflow being intentional (it just wraps around). But I'll probably change it to putting the actual calculated packet RSSI in a signed 16-bit int, and sending that over serial as well. It's probably more clean like that.