Zephyr API 3.6.99
Loading...
Searching...
No Matches
lorawan.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Manivannan Sadhasivam <mani@kernel.org>
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_LORAWAN_LORAWAN_H_
8#define ZEPHYR_INCLUDE_LORAWAN_LORAWAN_H_
9
20#include <zephyr/device.h>
21#include <zephyr/sys/slist.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
35
43
59
81
97
105
130
144
161
163#define LW_RECV_PORT_ANY UINT16_MAX
164
190 void (*cb)(uint8_t port, bool data_pending,
191 int16_t rssi, int8_t snr,
192 uint8_t len, const uint8_t *data);
195};
196
205
212
224
231
241
251int lorawan_join(const struct lorawan_join_config *config);
252
261
278int lorawan_send(uint8_t port, uint8_t *data, uint8_t len, enum lorawan_message_type type);
279
291
300
312void lorawan_enable_adr(bool enable);
313
327int lorawan_set_channels_mask(uint16_t *channels_mask, size_t channels_mask_size);
328
339
349
360void lorawan_get_payload_sizes(uint8_t *max_next_payload_size,
361 uint8_t *max_payload_size);
362
374
375#ifdef CONFIG_LORAWAN_APP_CLOCK_SYNC
376
389int lorawan_clock_sync_run(void);
390
403int lorawan_clock_sync_get(uint32_t *gps_time);
404
405#endif /* CONFIG_LORAWAN_APP_CLOCK_SYNC */
406
407#ifdef CONFIG_LORAWAN_FRAG_TRANSPORT
408
421int lorawan_frag_transport_run(void (*transport_finished_cb)(void));
422
423#endif /* CONFIG_LORAWAN_FRAG_TRANSPORT */
424
425#ifdef __cplusplus
426}
427#endif
428
433#endif /* ZEPHYR_INCLUDE_LORAWAN_LORAWAN_H_ */
lorawan_channels_mask_size
LoRaWAN channels mask sizes.
Definition lorawan.h:47
int lorawan_set_conf_msg_tries(uint8_t tries)
Set the number of tries used for transmissions.
uint8_t(* lorawan_battery_level_cb_t)(void)
Defines the battery level callback handler function signature.
Definition lorawan.h:204
int lorawan_send(uint8_t port, uint8_t *data, uint8_t len, enum lorawan_message_type type)
Send data to the LoRaWAN network.
int lorawan_set_channels_mask(uint16_t *channels_mask, size_t channels_mask_size)
Set the channels mask.
lorawan_datarate
LoRaWAN datarate types.
Definition lorawan.h:63
lorawan_act_type
LoRaWAN activation types.
Definition lorawan.h:39
void lorawan_enable_adr(bool enable)
Enable Adaptive Data Rate (ADR)
void lorawan_register_dr_changed_callback(lorawan_dr_changed_cb_t cb)
Register a callback to be called when the datarate changes.
int lorawan_join(const struct lorawan_join_config *config)
Join the LoRaWAN network.
lorawan_message_type
LoRaWAN message types.
Definition lorawan.h:101
int lorawan_start(void)
Start the LoRaWAN stack.
enum lorawan_datarate lorawan_get_min_datarate(void)
Get the minimum possible datarate.
void(* lorawan_dr_changed_cb_t)(enum lorawan_datarate dr)
Defines the datarate changed callback handler function signature.
Definition lorawan.h:211
lorawan_class
LoRaWAN class types.
Definition lorawan.h:30
void lorawan_get_payload_sizes(uint8_t *max_next_payload_size, uint8_t *max_payload_size)
Get the current payload sizes.
void lorawan_register_battery_level_callback(lorawan_battery_level_cb_t cb)
Register a battery level callback function.
int lorawan_set_datarate(enum lorawan_datarate dr)
Set the default data rate.
int lorawan_set_region(enum lorawan_region region)
Set the region and frequency to be used.
void lorawan_register_downlink_callback(struct lorawan_downlink_cb *cb)
Register a callback to be run on downlink packets.
int lorawan_set_class(enum lorawan_class dev_class)
Set the current device class.
lorawan_region
LoRaWAN region types.
Definition lorawan.h:85
@ LORAWAN_CHANNELS_MASK_SIZE_US915
Region US915 mask size.
Definition lorawan.h:56
@ LORAWAN_CHANNELS_MASK_SIZE_AU915
Region AU915 mask size.
Definition lorawan.h:49
@ LORAWAN_CHANNELS_MASK_SIZE_CN470
Region CN470 mask size.
Definition lorawan.h:50
@ LORAWAN_CHANNELS_MASK_SIZE_EU433
Region EU433 mask size.
Definition lorawan.h:52
@ LORAWAN_CHANNELS_MASK_SIZE_EU868
Region EU868 mask size.
Definition lorawan.h:53
@ LORAWAN_CHANNELS_MASK_SIZE_AS923
Region AS923 mask size.
Definition lorawan.h:48
@ LORAWAN_CHANNELS_MASK_SIZE_KR920
Region KR920 mask size.
Definition lorawan.h:54
@ LORAWAN_CHANNELS_MASK_SIZE_CN779
Region CN779 mask size.
Definition lorawan.h:51
@ LORAWAN_CHANNELS_MASK_SIZE_IN865
Region IN865 mask size.
Definition lorawan.h:55
@ LORAWAN_CHANNELS_MASK_SIZE_RU864
Region RU864 mask size.
Definition lorawan.h:57
@ LORAWAN_DR_8
DR8 data rate.
Definition lorawan.h:72
@ LORAWAN_DR_5
DR5 data rate.
Definition lorawan.h:69
@ LORAWAN_DR_10
DR10 data rate.
Definition lorawan.h:74
@ LORAWAN_DR_12
DR12 data rate.
Definition lorawan.h:76
@ LORAWAN_DR_13
DR13 data rate.
Definition lorawan.h:77
@ LORAWAN_DR_14
DR14 data rate.
Definition lorawan.h:78
@ LORAWAN_DR_11
DR11 data rate.
Definition lorawan.h:75
@ LORAWAN_DR_15
DR15 data rate.
Definition lorawan.h:79
@ LORAWAN_DR_3
DR3 data rate.
Definition lorawan.h:67
@ LORAWAN_DR_0
DR0 data rate.
Definition lorawan.h:64
@ LORAWAN_DR_4
DR4 data rate.
Definition lorawan.h:68
@ LORAWAN_DR_2
DR2 data rate.
Definition lorawan.h:66
@ LORAWAN_DR_7
DR7 data rate.
Definition lorawan.h:71
@ LORAWAN_DR_6
DR6 data rate.
Definition lorawan.h:70
@ LORAWAN_DR_1
DR1 data rate.
Definition lorawan.h:65
@ LORAWAN_DR_9
DR9 data rate.
Definition lorawan.h:73
@ LORAWAN_ACT_ABP
Activation by Personalization (ABP)
Definition lorawan.h:41
@ LORAWAN_ACT_OTAA
Over-the-Air Activation (OTAA)
Definition lorawan.h:40
@ LORAWAN_MSG_CONFIRMED
Confirmed message.
Definition lorawan.h:103
@ LORAWAN_MSG_UNCONFIRMED
Unconfirmed message.
Definition lorawan.h:102
@ LORAWAN_CLASS_A
Class A device.
Definition lorawan.h:31
@ LORAWAN_CLASS_B
Class B device.
Definition lorawan.h:32
@ LORAWAN_CLASS_C
Class C device.
Definition lorawan.h:33
@ LORAWAN_REGION_AU915
Australia 915 MHz frequency band.
Definition lorawan.h:87
@ LORAWAN_REGION_EU868
Europe 868 MHz frequency band.
Definition lorawan.h:91
@ LORAWAN_REGION_CN470
China 470 MHz frequency band.
Definition lorawan.h:88
@ LORAWAN_REGION_AS923
Asia 923 MHz frequency band.
Definition lorawan.h:86
@ LORAWAN_REGION_US915
United States 915 MHz frequency band.
Definition lorawan.h:94
@ LORAWAN_REGION_IN865
India 865 MHz frequency band.
Definition lorawan.h:93
@ LORAWAN_REGION_EU433
Europe 433 MHz frequency band.
Definition lorawan.h:90
@ LORAWAN_REGION_RU864
Russia 864 MHz frequency band.
Definition lorawan.h:95
@ LORAWAN_REGION_CN779
China 779 MHz frequency band.
Definition lorawan.h:89
@ LORAWAN_REGION_KR920
South Korea 920 MHz frequency band.
Definition lorawan.h:92
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:39
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
__INT8_TYPE__ int8_t
Definition stdint.h:72
__INT16_TYPE__ int16_t
Definition stdint.h:73
LoRaWAN join parameters for activation by personalization (ABP)
Definition lorawan.h:134
uint8_t * app_eui
Application EUI.
Definition lorawan.h:142
uint8_t * app_skey
Application session key.
Definition lorawan.h:138
uint8_t * nwk_skey
Network session key.
Definition lorawan.h:140
uint32_t dev_addr
Device address on the network.
Definition lorawan.h:136
LoRaWAN join parameters.
Definition lorawan.h:148
struct lorawan_join_abp abp
ABP join parameters.
Definition lorawan.h:152
struct lorawan_join_otaa otaa
OTAA join parameters.
Definition lorawan.h:151
enum lorawan_act_type mode
Activation mode.
Definition lorawan.h:159
uint8_t * dev_eui
Device EUI.
Definition lorawan.h:156
LoRaWAN join parameters for over-the-Air activation (OTAA)
Definition lorawan.h:114
uint8_t * app_key
Application Key.
Definition lorawan.h:120
uint8_t * join_eui
Join EUI.
Definition lorawan.h:116
uint16_t dev_nonce
Device Nonce.
Definition lorawan.h:128
uint8_t * nwk_key
Network Key.
Definition lorawan.h:118