Skip to content

feat: Add SNR calculation functionality (Int & Float)#17

Open
ArshiaMadadii wants to merge 2 commits intoSMotlaq:masterfrom
ArshiaMadadii:get-SNR
Open

feat: Add SNR calculation functionality (Int & Float)#17
ArshiaMadadii wants to merge 2 commits intoSMotlaq:masterfrom
ArshiaMadadii:get-SNR

Conversation

@ArshiaMadadii
Copy link
Copy Markdown

Functionality Implemented

This PR adds support for reading the Signal-to-Noise Ratio (SNR) of the last received packet, which is critical for evaluating link quality in LoRa communications.

The implementation reads from the RegPktSnrValue (0x19) register. Since the SX127x module reports SNR in 0.25dB steps using a signed 2's complement format, I implemented logic to correctly handle negative values (common in long-range transmission).

Outputs

I have added two functions to offer flexibility between precision and performance:

  1. LoRa_getSNR_x4(LoRa* _LoRa)

    • Type: int16_t
    • Description: Returns the SNR value in "Quarter-dB" units. This avoids floating-point arithmetic.
    • Example Output: A return value of -50 corresponds to -12.5 dB.
  2. LoRa_getSNR(LoRa* _LoRa)

    • Type: float
    • Description: Returns the standard SNR value in dB.
    • Example Output: -12.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant