kc1awv / KISSLoRaTNC

Arduino based LoRa KISS TNC
GNU General Public License v3.0
27 stars 5 forks source link

Adds SNR to RSSI report, Refactors receive funtion/ISR, fixes frequency initialization #7

Closed robojay closed 2 years ago

robojay commented 2 years ago

===

RSSI was being reported for each received frame, but the format didn't include a frame type byte (i.e. CMD_HARDWARE). This was added.

Additionally, in some cases where the RSSI is below the noise floor, RSSI alone does not provide complete insight without SNR as well (see SX1276 datasheet section "RSSI and SNR in LoRa Mode").

The per receive frame report has been modified to include SNR and RSSI with the format (unescaped):

is signed 8-bit (dB) is signed 16-bit (dBm) === Adding the SNR calls to resulted in too much processing being performed in the receiveCallback() ISR. This caused issues on the ESP32 (and possibly other platforms). Receive operation was refactored into two pieces - receiveCallback() obtains the packet size and sets a receiveReady flag. In loop(), the receiveReady flag is checked and receive() is called when it is set. This keeps the ISR execution very quick and to the point. === During startRadio(), stored settings were being obtained after LoRa.begin() was called, so the frequency set during LoRa.begin() was uninitialized memory. restoreSettings() was moved before LoRa.begin() so that a valid frequency would be used. === Config.h: - Added variables for SNR, RSSI and received data flag KISS.h: - Changed HW_RSSI to HW_SNR_RSSI KissLoRaTNC.cpp: - added set frequency to restoreSettings() - modified receiveCallback() ISR to simply save the packet size and set a receiveReady flag - moved what was previously in receiveCallback() to receive() - added SNR reporting to go along with RSSI in receive() - SNR is signed 8-bit (dB) - RSSI is signed 16-bit (dBm) - moved restoreSettings() before LoRa.begin() is attempted in startRadio() - added check for receiveReady flag in loop(), calls receive() README.md - Updated info on SetHardware -response- preceding received packet