From 422d612cdc506d00dc6a605a6efa20bff8b63175 Mon Sep 17 00:00:00 2001 From: Jordan Yates Date: Tue, 3 Dec 2024 08:09:30 +1000 Subject: [PATCH] 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 --- samples/drivers/lora/receive/README.rst | 62 ++++++++++++++++++------- samples/drivers/lora/receive/src/main.c | 8 ++-- 2 files changed, 49 insertions(+), 21 deletions(-) diff --git a/samples/drivers/lora/receive/README.rst b/samples/drivers/lora/receive/README.rst index 1d142f8bb8f..d2d6d6233da 100644 --- a/samples/drivers/lora/receive/README.rst +++ b/samples/drivers/lora/receive/README.rst @@ -36,20 +36,48 @@ Sample Output .. code-block:: console - [00:00:00.235,000] lora_receive: Synchronous reception - [00:00:00.956,000] lora_receive: Received data: helloworld (RSSI:-60dBm, SNR:7dBm) - [00:00:02.249,000] lora_receive: Received data: helloworld (RSSI:-57dBm, SNR:9dBm) - [00:00:03.541,000] lora_receive: Received data: helloworld (RSSI:-57dBm, SNR:9dBm) - [00:00:04.834,000] lora_receive: Received data: helloworld (RSSI:-55dBm, SNR:9dBm) - [00:00:04.834,000] lora_receive: Asynchronous reception - [00:00:06.127,000] lora_receive: Received data: helloworld (RSSI:-55dBm, SNR:9dBm) - [00:00:07.419,000] lora_receive: Received data: helloworld (RSSI:-55dBm, SNR:9dBm) - [00:00:08.712,000] lora_receive: Received data: helloworld (RSSI:-55dBm, SNR:9dBm) - [00:00:10.004,000] lora_receive: Received data: helloworld (RSSI:-55dBm, SNR:9dBm) - [00:00:11.297,000] lora_receive: Received data: helloworld (RSSI:-55dBm, SNR:9dBm) - [00:00:12.590,000] lora_receive: Received data: helloworld (RSSI:-55dBm, SNR:9dBm) - [00:00:13.884,000] lora_receive: Received data: helloworld (RSSI:-55dBm, SNR:9dBm) - [00:00:15.177,000] lora_receive: Received data: helloworld (RSSI:-55dBm, SNR:9dBm) - [00:00:16.470,000] lora_receive: Received data: helloworld (RSSI:-55dBm, SNR:9dBm) - [00:00:17.762,000] lora_receive: Received data: helloworld (RSSI:-55dBm, SNR:9dBm) - [00:00:17.762,000] lora_receive: Stopping packet receptions + [00:00:00.235,000] lora_receive: Synchronous reception + [00:00:00.956,000] lora_receive: LoRa RX RSSI: -60dBm, SNR: 7dB + [00:00:00.956,000] lora_receive: LoRa RX payload + 68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld + [00:00:02.249,000] lora_receive: LoRa RX RSSI: -57dBm, SNR: 9dB + [00:00:02.249,000] lora_receive: LoRa RX payload + 68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld + [00:00:03.541,000] lora_receive: LoRa RX RSSI: -57dBm, SNR: 9dB + [00:00:03.541,000] lora_receive: LoRa RX payload + 68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld + [00:00:04.834,000] lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB + [00:00:04.834,000] lora_receive: LoRa RX payload + 68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld + [00:00:04.834,000] lora_receive: Asynchronous reception + [00:00:06.127,000] lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB + [00:00:06.127,000] lora_receive: LoRa RX payload + 68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld + [00:00:07.419,000] lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB + [00:00:07.419,000] lora_receive: LoRa RX payload + 68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld + [00:00:08.712,000] lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB + [00:00:08.712,000] lora_receive: LoRa RX payload + 68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld + [00:00:10.004,000] lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB + [00:00:10.004,000] lora_receive: LoRa RX payload + 68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld + [00:00:11.297,000] lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB + [00:00:11.297,000] lora_receive: LoRa RX payload + 68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld + [00:00:12.590,000] lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB + [00:00:12.590,000] lora_receive: LoRa RX payload + 68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld + [00:00:13.884,000] lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB + [00:00:13.884,000] lora_receive: LoRa RX payload + 68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld + [00:00:15.177,000] lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB + [00:00:15.177,000] lora_receive: LoRa RX payload + 68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld + [00:00:16.470,000] lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB + [00:00:16.470,000] lora_receive: LoRa RX payload + 68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld + [00:00:17.762,000] lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB + [00:00:17.762,000] lora_receive: LoRa RX payload + 68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld + [00:00:17.762,000] lora_receive: Stopping packet receptions diff --git a/samples/drivers/lora/receive/src/main.c b/samples/drivers/lora/receive/src/main.c index e6ba6086ae0..102e28fa8b1 100644 --- a/samples/drivers/lora/receive/src/main.c +++ b/samples/drivers/lora/receive/src/main.c @@ -28,8 +28,8 @@ void lora_receive_cb(const struct device *dev, uint8_t *data, uint16_t size, ARG_UNUSED(dev); ARG_UNUSED(size); - LOG_INF("Received data: %s (RSSI:%ddBm, SNR:%ddBm)", - data, rssi, snr); + LOG_INF("LoRa RX RSSI: %d dBm, SNR: %d dB", rssi, snr); + LOG_HEXDUMP_INF(data, size, "LoRa RX payload"); /* Stop receiving after 10 packets */ if (++cnt == 10) { @@ -79,8 +79,8 @@ int main(void) return 0; } - LOG_INF("Received data: %s (RSSI:%ddBm, SNR:%ddBm)", - data, rssi, snr); + LOG_INF("LoRa RX RSSI: %d dBm, SNR: %d dB", rssi, snr); + LOG_HEXDUMP_INF(data, size, "LoRa RX payload"); } /* Enable asynchronous reception */