Skip to content

Commit 94a8c52

Browse files
JordanYateskartben
authored andcommitted
samples: lora: send: counter in packet
Add an incrementing counter in the transmitted packet to differentiate one packet from the next. Signed-off-by: Jordan Yates <jordan@embeint.com>
1 parent b6e5e68 commit 94a8c52

File tree

4 files changed

+28
-21
lines changed

4 files changed

+28
-21
lines changed

samples/drivers/lora/receive/README.rst

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,45 +39,45 @@ Sample Output
3939
[00:00:00.235,000] <inf> lora_receive: Synchronous reception
4040
[00:00:00.956,000] <inf> lora_receive: LoRa RX RSSI: -60dBm, SNR: 7dB
4141
[00:00:00.956,000] <inf> lora_receive: LoRa RX payload
42-
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
42+
68 65 6c 6c 6f 77 6f 72 6c 64 20 30 |hellowor ld 0
4343
[00:00:02.249,000] <inf> lora_receive: LoRa RX RSSI: -57dBm, SNR: 9dB
4444
[00:00:02.249,000] <inf> lora_receive: LoRa RX payload
45-
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
45+
68 65 6c 6c 6f 77 6f 72 6c 64 20 31 |hellowor ld 1
4646
[00:00:03.541,000] <inf> lora_receive: LoRa RX RSSI: -57dBm, SNR: 9dB
4747
[00:00:03.541,000] <inf> lora_receive: LoRa RX payload
48-
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
48+
68 65 6c 6c 6f 77 6f 72 6c 64 20 32 |hellowor ld 2
4949
[00:00:04.834,000] <inf> lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB
5050
[00:00:04.834,000] <inf> lora_receive: LoRa RX payload
51-
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
51+
68 65 6c 6c 6f 77 6f 72 6c 64 20 33 |hellowor ld 3
5252
[00:00:04.834,000] <inf> lora_receive: Asynchronous reception
5353
[00:00:06.127,000] <inf> lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB
5454
[00:00:06.127,000] <inf> lora_receive: LoRa RX payload
55-
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
55+
68 65 6c 6c 6f 77 6f 72 6c 64 20 34 |hellowor ld 4
5656
[00:00:07.419,000] <inf> lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB
5757
[00:00:07.419,000] <inf> lora_receive: LoRa RX payload
58-
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
58+
68 65 6c 6c 6f 77 6f 72 6c 64 20 35 |hellowor ld 5
5959
[00:00:08.712,000] <inf> lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB
6060
[00:00:08.712,000] <inf> lora_receive: LoRa RX payload
61-
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
61+
68 65 6c 6c 6f 77 6f 72 6c 64 20 36 |hellowor ld 6
6262
[00:00:10.004,000] <inf> lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB
6363
[00:00:10.004,000] <inf> lora_receive: LoRa RX payload
64-
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
64+
68 65 6c 6c 6f 77 6f 72 6c 64 20 37 |hellowor ld 7
6565
[00:00:11.297,000] <inf> lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB
6666
[00:00:11.297,000] <inf> lora_receive: LoRa RX payload
67-
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
67+
68 65 6c 6c 6f 77 6f 72 6c 64 20 38 |hellowor ld 8
6868
[00:00:12.590,000] <inf> lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB
6969
[00:00:12.590,000] <inf> lora_receive: LoRa RX payload
70-
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
70+
68 65 6c 6c 6f 77 6f 72 6c 64 20 39 |hellowor ld 9
7171
[00:00:13.884,000] <inf> lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB
7272
[00:00:13.884,000] <inf> lora_receive: LoRa RX payload
73-
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
73+
68 65 6c 6c 6f 77 6f 72 6c 64 20 30 |hellowor ld 0
7474
[00:00:15.177,000] <inf> lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB
7575
[00:00:15.177,000] <inf> lora_receive: LoRa RX payload
76-
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
76+
68 65 6c 6c 6f 77 6f 72 6c 64 20 31 |hellowor ld 1
7777
[00:00:16.470,000] <inf> lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB
7878
[00:00:16.470,000] <inf> lora_receive: LoRa RX payload
79-
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
79+
68 65 6c 6c 6f 77 6f 72 6c 64 20 32 |hellowor ld 2
8080
[00:00:17.762,000] <inf> lora_receive: LoRa RX RSSI: -55dBm, SNR: 9dB
8181
[00:00:17.762,000] <inf> lora_receive: LoRa RX payload
82-
68 65 6c 6c 6f 77 6f 72 6c 64 |hellowor ld
82+
68 65 6c 6c 6f 77 6f 72 6c 64 20 33 |hellowor ld 3
8383
[00:00:17.762,000] <inf> lora_receive: Stopping packet receptions

samples/drivers/lora/send/README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ Sample Output
3232

3333
.. code-block:: console
3434
35-
[00:00:00.531,000] <inf> lora_send: Data sent!
36-
[00:00:01.828,000] <inf> lora_send: Data sent!
37-
[00:00:03.125,000] <inf> lora_send: Data sent!
35+
[00:00:00.531,000] <inf> lora_send: Data sent 0!
36+
[00:00:01.828,000] <inf> lora_send: Data sent 1!
37+
[00:00:03.125,000] <inf> lora_send: Data sent 2!

samples/drivers/lora/send/sample.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ tests:
1010
harness_config:
1111
type: one_line
1212
regex:
13-
- "<inf> lora_send: Data sent!"
13+
- "<inf> lora_send: Data sent 0!"
1414
integration_platforms:
1515
- b_l072z_lrwan1

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
BUILD_ASSERT(DT_NODE_HAS_STATUS_OKAY(DEFAULT_RADIO_NODE),
1515
"No default LoRa radio specified in DT");
1616

17-
#define MAX_DATA_LEN 10
17+
#define MAX_DATA_LEN 12
1818

1919
#define LOG_LEVEL CONFIG_LOG_DEFAULT_LEVEL
2020
#include <zephyr/logging/log.h>
2121
LOG_MODULE_REGISTER(lora_send);
2222

23-
char data[MAX_DATA_LEN] = {'h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd'};
23+
char data[MAX_DATA_LEN] = {'h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd', ' ', '0'};
2424

2525
int main(void)
2626
{
@@ -56,10 +56,17 @@ int main(void)
5656
return 0;
5757
}
5858

59-
LOG_INF("Data sent!");
59+
LOG_INF("Data sent %c!", data[MAX_DATA_LEN - 1]);
6060

6161
/* Send data at 1s interval */
6262
k_sleep(K_MSEC(1000));
63+
64+
/* Increment final character to differentiate packets */
65+
if (data[MAX_DATA_LEN - 1] == '9') {
66+
data[MAX_DATA_LEN - 1] = '0';
67+
} else {
68+
data[MAX_DATA_LEN - 1] += 1;
69+
}
6370
}
6471
return 0;
6572
}

0 commit comments

Comments
 (0)