Skip to content

Commit

Permalink
Give application access to RSSI and SNR values of downlink packets.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrschuster committed Nov 27, 2024
1 parent 4159906 commit af742f9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/STM32LoRaWAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,8 @@ void STM32LoRaWAN::MacMcpsIndication(McpsIndication_t* i, LoRaMacRxStatus_t* sta
if ((i->McpsIndication == MCPS_CONFIRMED || i->McpsIndication == MCPS_UNCONFIRMED) && i->Status == LORAMAC_EVENT_INFO_STATUS_OK) {
instance->add_rx(i->Buffer, i->BufferSize);
instance->rx_port = i->Port;
instance->rx_rssi = status->Rssi;
instance->rx_snr = status->Snr;
}
}

Expand Down
16 changes: 16 additions & 0 deletions src/STM32LoRaWAN.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,16 @@ class STM32LoRaWAN : public Stream {
* Returns the port number of the most recently received packet.
*/
uint8_t getDownlinkPort() { return rx_port; }

/**
* Returns the RSSI of the most recently received packet.
*/
int16_t getDownlinkRssi() { return rx_rssi; }

/**
* Returns the SNR of the most recently received packet.
*/
int8_t getDownlinkSnr() { return rx_snr; }
/// @}


Expand Down Expand Up @@ -1045,6 +1055,12 @@ class STM32LoRaWAN : public Stream {
/** Port for most recently received packet */
uint8_t rx_port = 0;

/** RSSI for most recently received packet */
int16_t rx_rssi = 0;

/** SNR for most recently received packet */
int8_t rx_snr = 0;

bool nwk_key_set = false;

// Buffer sizes match LORAMAC_PHY_MAXPAYLOAD (but that is not
Expand Down

0 comments on commit af742f9

Please sign in to comment.