[SX126x] Unified getRSSI interface

This commit is contained in:
jgromes 2023-03-27 23:21:37 +02:00
parent 50318a6c60
commit ab9cf0d528
2 changed files with 7 additions and 24 deletions

View file

@ -1222,20 +1222,17 @@ float SX126x::getDataRate() const {
}
float SX126x::getRSSI(bool packet) {
if (packet) {
// get last packet RSSI from packet status
if(packet) {
// get last packet RSSI from packet status
uint32_t packetStatus = getPacketStatus();
uint8_t rssiPkt = packetStatus & 0xFF;
return(-1.0 * rssiPkt/2.0);
} else {
// get instantaneous RSSI value
// get instantaneous RSSI value
uint8_t data[3] = {0, 0, 0}; // RssiInst, Status, RFU
_mod->SPIreadStream(RADIOLIB_SX126X_CMD_GET_RSSI_INST, data, 3);
return (float)data[0] / (-2.0);
return((float)data[0] / (-2.0));
}
}
float SX126x::getSNR() {
@ -1337,13 +1334,6 @@ uint32_t SX126x::getTimeOnAir(size_t len) {
}
}
float SX126x::getRSSIInst() {
uint8_t data[3] = {0, 0, 0}; // RssiInst, Status, RFU
_mod->SPIreadStream(RADIOLIB_SX126X_CMD_GET_RSSI_INST, data, 3);
return (float)data[0] / (-2.0);
}
int16_t SX126x::implicitHeader(size_t len) {
return(setHeaderType(RADIOLIB_SX126X_LORA_HEADER_IMPLICIT, len));
}

View file

@ -915,11 +915,11 @@ class SX126x: public PhysicalLayer {
float getDataRate() const;
/*!
\brief Gets RSSI (Recorded Signal Strength Indicator) of the last received packet.
\brief GetsRSSI (Recorded Signal Strength Indicator).
\param packet Set to false to gets current RSSI measurement in LoRa mode.
\param packet Whether to read last packet RSSI, or the current value.
\returns RSSI of the last received packet in dBm.
\returns RSSI value in dBm.
*/
float getRSSI(bool packet = true);
@ -975,13 +975,6 @@ class SX126x: public PhysicalLayer {
*/
uint32_t getTimeOnAir(size_t len);
/*!
\brief Get instantaneous RSSI value during recption of the packet. Should switch to FSK receive mode for LBT implementation.
\returns Instantaneous RSSI value in dBm, in steps of 0.5dBm
*/
float getRSSIInst();
/*!
\brief Set implicit header mode for future reception/transmission.