Skip to content

Commit aeac33a

Browse files
Jordan Yatesnashif
authored andcommitted
samples: lorawan: class_a: add datarate callback
Add an example callback implementation that prints out the new maximum payload given the updated datarate. Signed-off-by: Jordan Yates <[email protected]>
1 parent 54d13ba commit aeac33a

File tree

1 file changed

+10
-0
lines changed
  • samples/lorawan/class_a/src

1 file changed

+10
-0
lines changed

samples/lorawan/class_a/src/main.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ LOG_MODULE_REGISTER(lorawan_class_a);
3232

3333
char data[] = {'h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd'};
3434

35+
static void lorwan_datarate_changed(enum lorawan_datarate dr)
36+
{
37+
uint8_t unused, max_size;
38+
39+
lorawan_get_payload_sizes(&unused, &max_size);
40+
LOG_INF("New Datarate: DR_%d, Max Payload %d", dr, max_size);
41+
}
42+
3543
void main(void)
3644
{
3745
const struct device *lora_dev;
@@ -53,6 +61,8 @@ void main(void)
5361
return;
5462
}
5563

64+
lorawan_register_dr_changed_callback(lorwan_datarate_changed);
65+
5666
join_cfg.mode = LORAWAN_ACT_OTAA;
5767
join_cfg.dev_eui = dev_eui;
5868
join_cfg.otaa.join_eui = join_eui;

0 commit comments

Comments
 (0)