Skip to content

Commit 422d612

Browse files
JordanYatesnashif
authored andcommitted
samples: lora: receive: update SNR unit to dB
Signal-to-noise ratio is a unitless quantity, so its unit is dB, not dBm (dBm is the power relative to 1 milliwatt). At the same time output the received payload using `LOG_HEXDUMP_INF`, instead of limiting the sample solely to string payloads. Fixes #82414 Signed-off-by: Jordan Yates <[email protected]>
1 parent 1069f57 commit 422d612

File tree

2 files changed

+49
-21
lines changed

2 files changed

+49
-21
lines changed

samples/drivers/lora/receive/README.rst

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,48 @@ Sample Output
3636

3737
.. code-block:: console
3838
39-
[00:00:00.235,000] <inf> lora_receive: Synchronous reception
40-
[00:00:00.956,000] <inf> lora_receive: Received data: helloworld (RSSI:-60dBm, SNR:7dBm)
41-
[00:00:02.249,000] <inf> lora_receive: Received data: helloworld (RSSI:-57dBm, SNR:9dBm)
42-
[00:00:03.541,000] <inf> lora_receive: Received data: helloworld (RSSI:-57dBm, SNR:9dBm)
43-
[00:00:04.834,000] <inf> lora_receive: Received data: helloworld (RSSI:-55dBm, SNR:9dBm)
44-
[00:00:04.834,000] <inf> lora_receive: Asynchronous reception
45-
[00:00:06.127,000] <inf> lora_receive: Received data: helloworld (RSSI:-55dBm, SNR:9dBm)
46-
[00:00:07.419,000] <inf> lora_receive: Received data: helloworld (RSSI:-55dBm, SNR:9dBm)
47-
[00:00:08.712,000] <inf> lora_receive: Received data: helloworld (RSSI:-55dBm, SNR:9dBm)
48-
[00:00:10.004,000] <inf> lora_receive: Received data: helloworld (RSSI:-55dBm, SNR:9dBm)
49-
[00:00:11.297,000] <inf> lora_receive: Received data: helloworld (RSSI:-55dBm, SNR:9dBm)
50-
[00:00:12.590,000] <inf> lora_receive: Received data: helloworld (RSSI:-55dBm, SNR:9dBm)
51-
[00:00:13.884,000] <inf> lora_receive: Received data: helloworld (RSSI:-55dBm, SNR:9dBm)
52-
[00:00:15.177,000] <inf> lora_receive: Received data: helloworld (RSSI:-55dBm, SNR:9dBm)
53-
[00:00:16.470,000] <inf> lora_receive: Received data: helloworld (RSSI:-55dBm, SNR:9dBm)
54-
[00:00:17.762,000] <inf> lora_receive: Received data: helloworld (RSSI:-55dBm, SNR:9dBm)
55-
[00:00:17.762,000] <inf> lora_receive: Stopping packet receptions
39+
[00:00:00.235,000] <inf> lora_receive: Synchronous reception
40+
[00:00:00.956,000] <inf> lora_receive: LoRa RX RSSI: -60dBm, SNR: 7dB
41+
[00:00:00.956,000] <inf> lora_receive: LoRa RX payload
42+
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
43+
[00:00:02.249,000] <inf> lora_receive: LoRa RX RSSI: -57dBm, SNR: 9dB
44+
[00:00:02.249,000] <inf> lora_receive: LoRa RX payload
45+
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
46+
[00:00:03.541,000] <inf> lora_receive: LoRa RX RSSI: -57dBm, SNR: 9dB
47+
[00:00:03.541,000] <inf> lora_receive: LoRa RX payload
48+
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
49+
[00:00:04.834,000] <inf> lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB
50+
[00:00:04.834,000] <inf> lora_receive: LoRa RX payload
51+
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
52+
[00:00:04.834,000] <inf> lora_receive: Asynchronous reception
53+
[00:00:06.127,000] <inf> lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB
54+
[00:00:06.127,000] <inf> lora_receive: LoRa RX payload
55+
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
56+
[00:00:07.419,000] <inf> lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB
57+
[00:00:07.419,000] <inf> lora_receive: LoRa RX payload
58+
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
59+
[00:00:08.712,000] <inf> lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB
60+
[00:00:08.712,000] <inf> lora_receive: LoRa RX payload
61+
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
62+
[00:00:10.004,000] <inf> lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB
63+
[00:00:10.004,000] <inf> lora_receive: LoRa RX payload
64+
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
65+
[00:00:11.297,000] <inf> lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB
66+
[00:00:11.297,000] <inf> lora_receive: LoRa RX payload
67+
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
68+
[00:00:12.590,000] <inf> lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB
69+
[00:00:12.590,000] <inf> lora_receive: LoRa RX payload
70+
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
71+
[00:00:13.884,000] <inf> lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB
72+
[00:00:13.884,000] <inf> lora_receive: LoRa RX payload
73+
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
74+
[00:00:15.177,000] <inf> lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB
75+
[00:00:15.177,000] <inf> lora_receive: LoRa RX payload
76+
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
77+
[00:00:16.470,000] <inf> lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB
78+
[00:00:16.470,000] <inf> lora_receive: LoRa RX payload
79+
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
80+
[00:00:17.762,000] <inf> lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB
81+
[00:00:17.762,000] <inf> lora_receive: LoRa RX payload
82+
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
83+
[00:00:17.762,000] <inf> lora_receive: Stopping packet receptions

samples/drivers/lora/receive/src/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ void lora_receive_cb(const struct device *dev, uint8_t *data, uint16_t size,
2828
ARG_UNUSED(dev);
2929
ARG_UNUSED(size);
3030

31-
LOG_INF("Received data: %s (RSSI:%ddBm, SNR:%ddBm)",
32-
data, rssi, snr);
31+
LOG_INF("LoRa RX RSSI: %d dBm, SNR: %d dB", rssi, snr);
32+
LOG_HEXDUMP_INF(data, size, "LoRa RX payload");
3333

3434
/* Stop receiving after 10 packets */
3535
if (++cnt == 10) {
@@ -79,8 +79,8 @@ int main(void)
7979
return 0;
8080
}
8181

82-
LOG_INF("Received data: %s (RSSI:%ddBm, SNR:%ddBm)",
83-
data, rssi, snr);
82+
LOG_INF("LoRa RX RSSI: %d dBm, SNR: %d dB", rssi, snr);
83+
LOG_HEXDUMP_INF(data, size, "LoRa RX payload");
8484
}
8585

8686
/* Enable asynchronous reception */

0 commit comments

Comments
 (0)