Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
LoRaWAN APIs

Data Structures

struct  lorawan_join_otaa
 LoRaWAN join parameters for over-the-Air activation (OTAA) More...
 
struct  lorawan_join_abp
 LoRaWAN join parameters for activation by personalization (ABP) More...
 
struct  lorawan_join_config
 LoRaWAN join parameters. More...
 
struct  lorawan_downlink_cb
 LoRaWAN downlink callback parameters. More...
 

Macros

#define LW_RECV_PORT_ANY   UINT16_MAX
 Flag to indicate receiving on any port.
 

Typedefs

typedef uint8_t(* lorawan_battery_level_cb_t) (void)
 Defines the battery level callback handler function signature.
 
typedef void(* lorawan_dr_changed_cb_t) (enum lorawan_datarate dr)
 Defines the datarate changed callback handler function signature.
 

Enumerations

enum  lorawan_class { LORAWAN_CLASS_A = 0x00 , LORAWAN_CLASS_B = 0x01 , LORAWAN_CLASS_C = 0x02 }
 LoRaWAN class types. More...
 
enum  lorawan_act_type { LORAWAN_ACT_OTAA = 0 , LORAWAN_ACT_ABP }
 LoRaWAN activation types. More...
 
enum  lorawan_channels_mask_size {
  LORAWAN_CHANNELS_MASK_SIZE_AS923 = 1 , LORAWAN_CHANNELS_MASK_SIZE_AU915 = 6 , LORAWAN_CHANNELS_MASK_SIZE_CN470 = 6 , LORAWAN_CHANNELS_MASK_SIZE_CN779 = 1 ,
  LORAWAN_CHANNELS_MASK_SIZE_EU433 = 1 , LORAWAN_CHANNELS_MASK_SIZE_EU868 = 1 , LORAWAN_CHANNELS_MASK_SIZE_KR920 = 1 , LORAWAN_CHANNELS_MASK_SIZE_IN865 = 1 ,
  LORAWAN_CHANNELS_MASK_SIZE_US915 = 6 , LORAWAN_CHANNELS_MASK_SIZE_RU864 = 1
}
 LoRaWAN channels mask sizes. More...
 
enum  lorawan_datarate {
  LORAWAN_DR_0 = 0 , LORAWAN_DR_1 , LORAWAN_DR_2 , LORAWAN_DR_3 ,
  LORAWAN_DR_4 , LORAWAN_DR_5 , LORAWAN_DR_6 , LORAWAN_DR_7 ,
  LORAWAN_DR_8 , LORAWAN_DR_9 , LORAWAN_DR_10 , LORAWAN_DR_11 ,
  LORAWAN_DR_12 , LORAWAN_DR_13 , LORAWAN_DR_14 , LORAWAN_DR_15
}
 LoRaWAN datarate types. More...
 
enum  lorawan_region {
  LORAWAN_REGION_AS923 , LORAWAN_REGION_AU915 , LORAWAN_REGION_CN470 , LORAWAN_REGION_CN779 ,
  LORAWAN_REGION_EU433 , LORAWAN_REGION_EU868 , LORAWAN_REGION_KR920 , LORAWAN_REGION_IN865 ,
  LORAWAN_REGION_US915 , LORAWAN_REGION_RU864
}
 LoRaWAN region types. More...
 
enum  lorawan_message_type { LORAWAN_MSG_UNCONFIRMED = 0 , LORAWAN_MSG_CONFIRMED }
 LoRaWAN message types. More...
 

Functions

void lorawan_register_battery_level_callback (lorawan_battery_level_cb_t cb)
 Register a battery level callback function.
 
void lorawan_register_downlink_callback (struct lorawan_downlink_cb *cb)
 Register a callback to be run on downlink packets.
 
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.
 
int lorawan_start (void)
 Start the LoRaWAN stack.
 
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_class (enum lorawan_class dev_class)
 Set the current device class.
 
int lorawan_set_conf_msg_tries (uint8_t tries)
 Set the number of tries used for transmissions.
 
void lorawan_enable_adr (bool enable)
 Enable Adaptive Data Rate (ADR)
 
int lorawan_set_channels_mask (uint16_t *channels_mask, size_t channels_mask_size)
 Set the channels mask.
 
int lorawan_set_datarate (enum lorawan_datarate dr)
 Set the default data rate.
 
enum lorawan_datarate lorawan_get_min_datarate (void)
 Get the minimum possible datarate.
 
void lorawan_get_payload_sizes (uint8_t *max_next_payload_size, uint8_t *max_payload_size)
 Get the current payload sizes.
 
int lorawan_set_region (enum lorawan_region region)
 Set the region and frequency to be used.
 

Detailed Description

Since
2.5
Version
0.1.0

Macro Definition Documentation

◆ LW_RECV_PORT_ANY

#define LW_RECV_PORT_ANY   UINT16_MAX

#include <include/zephyr/lorawan/lorawan.h>

Flag to indicate receiving on any port.

Typedef Documentation

◆ lorawan_battery_level_cb_t

typedef uint8_t(* lorawan_battery_level_cb_t) (void)

#include <include/zephyr/lorawan/lorawan.h>

Defines the battery level callback handler function signature.

Return values
0if the node is connected to an external power source
1..254battery level, where 1 is the minimum and 254 is the maximum value
255if the node was not able to measure the battery level

◆ lorawan_dr_changed_cb_t

typedef void(* lorawan_dr_changed_cb_t) (enum lorawan_datarate dr)

#include <include/zephyr/lorawan/lorawan.h>

Defines the datarate changed callback handler function signature.

Parameters
drUpdated datarate.

Enumeration Type Documentation

◆ lorawan_act_type

#include <include/zephyr/lorawan/lorawan.h>

LoRaWAN activation types.

Enumerator
LORAWAN_ACT_OTAA 

Over-the-Air Activation (OTAA)

LORAWAN_ACT_ABP 

Activation by Personalization (ABP)

◆ lorawan_channels_mask_size

#include <include/zephyr/lorawan/lorawan.h>

LoRaWAN channels mask sizes.

Enumerator
LORAWAN_CHANNELS_MASK_SIZE_AS923 

Region AS923 mask size.

LORAWAN_CHANNELS_MASK_SIZE_AU915 

Region AU915 mask size.

LORAWAN_CHANNELS_MASK_SIZE_CN470 

Region CN470 mask size.

LORAWAN_CHANNELS_MASK_SIZE_CN779 

Region CN779 mask size.

LORAWAN_CHANNELS_MASK_SIZE_EU433 

Region EU433 mask size.

LORAWAN_CHANNELS_MASK_SIZE_EU868 

Region EU868 mask size.

LORAWAN_CHANNELS_MASK_SIZE_KR920 

Region KR920 mask size.

LORAWAN_CHANNELS_MASK_SIZE_IN865 

Region IN865 mask size.

LORAWAN_CHANNELS_MASK_SIZE_US915 

Region US915 mask size.

LORAWAN_CHANNELS_MASK_SIZE_RU864 

Region RU864 mask size.

◆ lorawan_class

#include <include/zephyr/lorawan/lorawan.h>

LoRaWAN class types.

Enumerator
LORAWAN_CLASS_A 

Class A device.

LORAWAN_CLASS_B 

Class B device.

LORAWAN_CLASS_C 

Class C device.

◆ lorawan_datarate

#include <include/zephyr/lorawan/lorawan.h>

LoRaWAN datarate types.

Enumerator
LORAWAN_DR_0 

DR0 data rate.

LORAWAN_DR_1 

DR1 data rate.

LORAWAN_DR_2 

DR2 data rate.

LORAWAN_DR_3 

DR3 data rate.

LORAWAN_DR_4 

DR4 data rate.

LORAWAN_DR_5 

DR5 data rate.

LORAWAN_DR_6 

DR6 data rate.

LORAWAN_DR_7 

DR7 data rate.

LORAWAN_DR_8 

DR8 data rate.

LORAWAN_DR_9 

DR9 data rate.

LORAWAN_DR_10 

DR10 data rate.

LORAWAN_DR_11 

DR11 data rate.

LORAWAN_DR_12 

DR12 data rate.

LORAWAN_DR_13 

DR13 data rate.

LORAWAN_DR_14 

DR14 data rate.

LORAWAN_DR_15 

DR15 data rate.

◆ lorawan_message_type

#include <include/zephyr/lorawan/lorawan.h>

LoRaWAN message types.

Enumerator
LORAWAN_MSG_UNCONFIRMED 

Unconfirmed message.

LORAWAN_MSG_CONFIRMED 

Confirmed message.

◆ lorawan_region

#include <include/zephyr/lorawan/lorawan.h>

LoRaWAN region types.

Enumerator
LORAWAN_REGION_AS923 

Asia 923 MHz frequency band.

LORAWAN_REGION_AU915 

Australia 915 MHz frequency band.

LORAWAN_REGION_CN470 

China 470 MHz frequency band.

LORAWAN_REGION_CN779 

China 779 MHz frequency band.

LORAWAN_REGION_EU433 

Europe 433 MHz frequency band.

LORAWAN_REGION_EU868 

Europe 868 MHz frequency band.

LORAWAN_REGION_KR920 

South Korea 920 MHz frequency band.

LORAWAN_REGION_IN865 

India 865 MHz frequency band.

LORAWAN_REGION_US915 

United States 915 MHz frequency band.

LORAWAN_REGION_RU864 

Russia 864 MHz frequency band.

Function Documentation

◆ lorawan_enable_adr()

void lorawan_enable_adr ( bool  enable)

#include <include/zephyr/lorawan/lorawan.h>

Enable Adaptive Data Rate (ADR)

Control whether adaptive data rate (ADR) is enabled. When ADR is enabled, the data rate is treated as a default data rate that will be used if the ADR algorithm has not established a data rate. ADR should normally only be enabled for devices with stable RF conditions (i.e., devices in a mostly static location).

Parameters
enableEnable or Disable adaptive data rate.

◆ lorawan_get_min_datarate()

enum lorawan_datarate lorawan_get_min_datarate ( void  )

#include <include/zephyr/lorawan/lorawan.h>

Get the minimum possible datarate.

The minimum possible datarate may change in response to a TxParamSetupReq command from the network server.

Returns
Minimum possible data rate

◆ lorawan_get_payload_sizes()

void lorawan_get_payload_sizes ( uint8_t max_next_payload_size,
uint8_t max_payload_size 
)

#include <include/zephyr/lorawan/lorawan.h>

Get the current payload sizes.

Query the current payload sizes. The maximum payload size varies with datarate, while the current payload size can be less due to MAC layer commands which are inserted into uplink packets.

Parameters
max_next_payload_sizeMaximum payload size for the next transmission
max_payload_sizeMaximum payload size for this datarate

◆ lorawan_join()

int lorawan_join ( const struct lorawan_join_config config)

#include <include/zephyr/lorawan/lorawan.h>

Join the LoRaWAN network.

Join the LoRaWAN network using OTAA or AWB.

Parameters
configConfiguration to be used
Returns
0 if successful, negative errno code if failure

◆ lorawan_register_battery_level_callback()

void lorawan_register_battery_level_callback ( lorawan_battery_level_cb_t  cb)

#include <include/zephyr/lorawan/lorawan.h>

Register a battery level callback function.

Provide the LoRaWAN stack with a function to be called whenever a battery level needs to be read.

Should no callback be provided the lorawan backend will report 255.

Parameters
cbPointer to the battery level function

◆ lorawan_register_downlink_callback()

void lorawan_register_downlink_callback ( struct lorawan_downlink_cb cb)

#include <include/zephyr/lorawan/lorawan.h>

Register a callback to be run on downlink packets.

Parameters
cbPointer to structure containing callback parameters

◆ lorawan_register_dr_changed_callback()

void lorawan_register_dr_changed_callback ( lorawan_dr_changed_cb_t  cb)

#include <include/zephyr/lorawan/lorawan.h>

Register a callback to be called when the datarate changes.

The callback is called once upon successfully joining a network and again each time the datarate changes due to ADR.

Parameters
cbPointer to datarate update callback

◆ lorawan_send()

int lorawan_send ( uint8_t  port,
uint8_t data,
uint8_t  len,
enum lorawan_message_type  type 
)

#include <include/zephyr/lorawan/lorawan.h>

Send data to the LoRaWAN network.

Send data to the connected LoRaWAN network.

Parameters
portPort to be used for sending data. Must be set if the payload is not empty.
dataData buffer to be sent
lenLength of the buffer to be sent. Maximum length of this buffer is 255 bytes but the actual payload size varies with region and datarate.
typeSpecifies if the message shall be confirmed or unconfirmed. Must be one of lorawan_message_type.
Returns
0 if successful, negative errno code if failure

◆ lorawan_set_channels_mask()

int lorawan_set_channels_mask ( uint16_t channels_mask,
size_t  channels_mask_size 
)

#include <include/zephyr/lorawan/lorawan.h>

Set the channels mask.

Change the default channels mask. When mask is not changed, all the channels can be used for data transmission. Some Network Servers don't use all the channels, in this case, the channels mask must be provided.

Parameters
channels_maskBuffer with channels mask to be used.
channels_mask_sizeSize of channels mask buffer.
Return values
0successful
-EINVALchannels mask or channels mask size is wrong

◆ lorawan_set_class()

int lorawan_set_class ( enum lorawan_class  dev_class)

#include <include/zephyr/lorawan/lorawan.h>

Set the current device class.

Change the current device class. This function may be called before or after a network connection has been established.

Parameters
dev_classNew device class
Returns
0 if successful, negative errno code if failure

◆ lorawan_set_conf_msg_tries()

int lorawan_set_conf_msg_tries ( uint8_t  tries)

#include <include/zephyr/lorawan/lorawan.h>

Set the number of tries used for transmissions.

Parameters
triesNumber of tries to be used
Returns
0 if successful, negative errno code if failure

◆ lorawan_set_datarate()

int lorawan_set_datarate ( enum lorawan_datarate  dr)

#include <include/zephyr/lorawan/lorawan.h>

Set the default data rate.

Change the default data rate.

Parameters
drData rate used for transmissions
Returns
0 if successful, negative errno code if failure

◆ lorawan_set_region()

int lorawan_set_region ( enum lorawan_region  region)

#include <include/zephyr/lorawan/lorawan.h>

Set the region and frequency to be used.

Control the LoRa region and frequency settings. This should be called before lorawan_start(). If you only have support for a single region selected via Kconfig, this function does not need to be called at all.

Parameters
regionThe region to be selected
Returns
0 if successful, negative errno otherwise

◆ lorawan_start()

int lorawan_start ( void  )

#include <include/zephyr/lorawan/lorawan.h>

Start the LoRaWAN stack.

This function need to be called before joining the network.

Returns
0 if successful, negative errno code if failure