[RF69] Replaced RSSI member variable with getRSSI method

pull/142/head
jgromes 2020-04-14 15:02:33 +02:00
rodzic e9f879aea6
commit 9f8ec689dd
4 zmienionych plików z 25 dodań i 10 usunięć

Wyświetl plik

@ -68,6 +68,12 @@ void loop() {
Serial.print(F("[RF69] Data:\t\t"));
Serial.println(str);
// print RSSI (Received Signal Strength Indicator)
// of the last received packet
Serial.print(F("[RF69] RSSI:\t\t"));
Serial.print(rf.getRSSI());
Serial.println(F(" dBm"));
} else if (state == ERR_RX_TIMEOUT) {
// timeout occurred while waiting for a packet
Serial.println(F("timeout!"));

Wyświetl plik

@ -112,9 +112,15 @@ void loop() {
Serial.println(F("[RF69] Received packet!"));
// print data of the packet
Serial.print(F("[RF69] Data:\t\t\t"));
Serial.print(F("[RF69] Data:\t\t"));
Serial.println(str);
// print RSSI (Received Signal Strength Indicator)
// of the last received packet
Serial.print(F("[RF69] RSSI:\t\t"));
Serial.print(rf.getRSSI());
Serial.println(F(" dBm"));
} else if (state == ERR_CRC_MISMATCH) {
// packet was received, but is malformed
Serial.println(F("CRC error!"));

Wyświetl plik

@ -147,7 +147,7 @@ int16_t RF69::receive(uint8_t* data, size_t len) {
uint32_t start = micros();
while(!digitalRead(_mod->getIrq())) {
yield();
if(micros() - start > timeout) {
standby();
clearIRQFlags();
@ -330,9 +330,6 @@ int16_t RF69::readData(uint8_t* data, size_t len) {
// read packet data
_mod->SPIreadRegisterBurst(RF69_REG_FIFO, length, data);
// update RSSI
lastPacketRSSI = -1.0 * (_mod->SPIgetRegValue(RF69_REG_RSSI_VALUE)/2.0);
// clear internal flag so getPacketLength can return the new packet length
_packetLengthQueried = false;
@ -701,6 +698,10 @@ int16_t RF69::setEncoding(uint8_t encoding) {
}
}
float RF69::getRSSI() {
return(-1.0 * (_mod->SPIgetRegValue(RF69_REG_RSSI_VALUE)/2.0));
}
int16_t RF69::config() {
int16_t state = ERR_NONE;

Wyświetl plik

@ -441,11 +441,6 @@ class RF69: public PhysicalLayer {
*/
RF69(Module* module);
/*!
\brief RSSI value of the last received packet.
*/
float lastPacketRSSI;
// basic methods
/*!
@ -791,6 +786,13 @@ class RF69: public PhysicalLayer {
*/
int16_t setEncoding(uint8_t encoding);
/*!
\brief Gets RSSI (Recorded Signal Strength Indicator) of the last received packet.
\returns Last packet RSSI in dBm.
*/
float getRSSI();
#ifndef RADIOLIB_GODMODE
protected:
#endif