File tree 4 files changed +24
-2
lines changed
4 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -194,7 +194,7 @@ The `onReceive` callback will be called when a packet is received.
194
194
int rssi = LoRa.packetRssi();
195
195
```
196
196
197
- Returns the RSSI of the received packet.
197
+ Returns the averaged RSSI of the last received packet (dBm) .
198
198
199
199
### Packet SNR
200
200
@@ -204,6 +204,14 @@ float snr = LoRa.packetSnr();
204
204
205
205
Returns the estimated SNR of the received packet in dB.
206
206
207
+ ## RSSI
208
+
209
+ ``` arduino
210
+ int rssi = LoRa.rssi();
211
+ ```
212
+
213
+ Returns the current RSSI of the radio (dBm). RSSI can be read at any time (during packet reception or not)
214
+
207
215
### Packet Frequency Error
208
216
209
217
``` arduino
Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ packetRssi KEYWORD2
23
23
packetSnr KEYWORD2
24
24
packetFrequencyError KEYWORD2
25
25
26
+ rssi KEYWORD2
27
+
26
28
write KEYWORD2
27
29
28
30
available KEYWORD2
Original file line number Diff line number Diff line change 20
20
#define REG_RX_NB_BYTES 0x13
21
21
#define REG_PKT_SNR_VALUE 0x19
22
22
#define REG_PKT_RSSI_VALUE 0x1a
23
+ #define REG_RSSI_VALUE 0x1b
23
24
#define REG_MODEM_CONFIG_1 0x1d
24
25
#define REG_MODEM_CONFIG_2 0x1e
25
26
#define REG_PREAMBLE_MSB 0x20
55
56
#define IRQ_PAYLOAD_CRC_ERROR_MASK 0x20
56
57
#define IRQ_RX_DONE_MASK 0x40
57
58
59
+ #define RF_MID_BAND_THRESHOLD 525E6
60
+ #define RSSI_OFFSET_HF_PORT 157
61
+ #define RSSI_OFFSET_LF_PORT 164
62
+
58
63
#define MAX_PKT_LENGTH 255
59
64
60
65
#if (ESP8266 || ESP32)
@@ -258,7 +263,7 @@ int LoRaClass::parsePacket(int size)
258
263
259
264
int LoRaClass::packetRssi ()
260
265
{
261
- return (readRegister (REG_PKT_RSSI_VALUE) - (_frequency < 868E6 ? 164 : 157 ));
266
+ return (readRegister (REG_PKT_RSSI_VALUE) - (_frequency < RF_MID_BAND_THRESHOLD ? RSSI_OFFSET_LF_PORT : RSSI_OFFSET_HF_PORT ));
262
267
}
263
268
264
269
float LoRaClass::packetSnr ()
@@ -285,6 +290,11 @@ long LoRaClass::packetFrequencyError()
285
290
return static_cast <long >(fError );
286
291
}
287
292
293
+ int LoRaClass::rssi ()
294
+ {
295
+ return (readRegister (REG_RSSI_VALUE) - (_frequency < RF_MID_BAND_THRESHOLD ? RSSI_OFFSET_LF_PORT : RSSI_OFFSET_HF_PORT));
296
+ }
297
+
288
298
size_t LoRaClass::write (uint8_t byte)
289
299
{
290
300
return write (&byte, sizeof (byte));
Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ class LoRaClass : public Stream {
45
45
float packetSnr ();
46
46
long packetFrequencyError ();
47
47
48
+ int rssi ();
49
+
48
50
// from Print
49
51
virtual size_t write (uint8_t byte);
50
52
virtual size_t write (const uint8_t *buffer, size_t size);
You can’t perform that action at this time.
0 commit comments