Zephyr API Documentation 4.2.99
A Scalable Open Source RTOS
|
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. | |
typedef void(* | lorawan_link_check_ans_cb_t) (uint8_t demod_margin, uint8_t nb_gateways) |
Defines the link check answer handler function signature. | |
typedef int(* | transport_descriptor_cb) (uint32_t descriptor) |
Defines the user's descriptor callback handler function signature. |
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. | |
void | lorawan_register_link_check_ans_callback (lorawan_link_check_ans_cb_t cb) |
Register a callback to be called when getting answer a to check link request. | |
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. | |
int | lorawan_request_device_time (bool force_request) |
Request for time according to DeviceTimeReq MAC cmd. | |
int | lorawan_device_time_get (uint32_t *gps_time) |
Retrieve the current time from LoRaWAN stack updated by DeviceTimeAns on MAC layer. | |
int | lorawan_request_link_check (bool force_request) |
Request for link check according to LinkCheckReq MAC cmd. | |
int | lorawan_clock_sync_run (void) |
Run Application Layer Clock Synchronization service. | |
int | lorawan_clock_sync_get (uint32_t *gps_time) |
Retrieve the current synchronized time. | |
void | lorawan_frag_transport_register_descriptor_callback (transport_descriptor_cb cb) |
Register a handle descriptor callback function. | |
int | lorawan_frag_transport_run (void(*transport_finished_cb)(void)) |
Run Fragmented Data Block Transport service. |
#define LW_RECV_PORT_ANY UINT16_MAX |
#include <zephyr/lorawan/lorawan.h>
Flag to indicate receiving on any port.
typedef uint8_t(* lorawan_battery_level_cb_t) (void) |
#include <zephyr/lorawan/lorawan.h>
Defines the battery level callback handler function signature.
0 | if the node is connected to an external power source |
1..254 | battery level, where 1 is the minimum and 254 is the maximum value |
255 | if the node was not able to measure the battery level |
typedef void(* lorawan_dr_changed_cb_t) (enum lorawan_datarate dr) |
#include <zephyr/lorawan/lorawan.h>
Defines the datarate changed callback handler function signature.
dr | Updated datarate. |
#include <zephyr/lorawan/lorawan.h>
Defines the link check answer handler function signature.
demod_margin | The demodulation margin in db. |
nb_gateways | The number of gateways the device is connected to. |
typedef int(* transport_descriptor_cb) (uint32_t descriptor) |
#include <zephyr/lorawan/lorawan.h>
Defines the user's descriptor callback handler function signature.
The use of this callback is optional. When Fragmented Data Block Transport is enabled, the application will be notified with the descriptor field present on the FragSessionSetupReq command.
descriptor | Descriptor value given on the FragSessionSetupReq command. |
The meaning of Descriptor is application dependent. When doing a FUOTA with a binary image, it may represent the version of the firmware transported.
enum lorawan_act_type |
#include <zephyr/lorawan/lorawan.h>
LoRaWAN activation types.
Enumerator | |
---|---|
LORAWAN_ACT_OTAA | Over-the-Air Activation (OTAA) |
LORAWAN_ACT_ABP | Activation by Personalization (ABP) |
#include <zephyr/lorawan/lorawan.h>
LoRaWAN channels mask sizes.
enum lorawan_class |
#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. |
enum lorawan_datarate |
#include <zephyr/lorawan/lorawan.h>
LoRaWAN datarate types.
enum lorawan_dl_flags |
#include <zephyr/lorawan/lorawan.h>
LoRaWAN downlink flags.
Enumerator | |
---|---|
LORAWAN_DATA_PENDING | |
LORAWAN_TIME_UPDATED |
enum lorawan_message_type |
#include <zephyr/lorawan/lorawan.h>
LoRaWAN message types.
Enumerator | |
---|---|
LORAWAN_MSG_UNCONFIRMED | Unconfirmed message. |
LORAWAN_MSG_CONFIRMED | Confirmed message. |
enum lorawan_region |
#include <zephyr/lorawan/lorawan.h>
LoRaWAN region types.
int lorawan_clock_sync_get | ( | uint32_t * | gps_time | ) |
#include <zephyr/lorawan/lorawan.h>
Retrieve the current synchronized time.
This function uses the GPS epoch format, as used in all LoRaWAN services.
The GPS epoch started on 1980-01-06T00:00:00Z, but has since diverged from UTC, as it does not consider corrections like leap seconds.
CONFIG_LORAWAN_APP_CLOCK_SYNC
.gps_time | Synchronized time in GPS epoch format truncated to 32-bit. |
int lorawan_clock_sync_run | ( | void | ) |
#include <zephyr/lorawan/lorawan.h>
Run Application Layer Clock Synchronization service.
This service sends out its current time in a regular interval (configurable via Kconfig, using CONFIG_LORAWAN_APP_CLOCK_SYNC_PERIODICITY
) and receives a correction offset from the application server if the clock deviation is considered too large.
Clock synchronization is required for firmware upgrades over multicast sessions, but can also be used independent of a FUOTA process.
CONFIG_LORAWAN_APP_CLOCK_SYNC
.int lorawan_device_time_get | ( | uint32_t * | gps_time | ) |
#include <zephyr/lorawan/lorawan.h>
Retrieve the current time from LoRaWAN stack updated by DeviceTimeAns on MAC layer.
This function uses the GPS epoch format, as used in all LoRaWAN services.
The GPS epoch started on 1980-01-06T00:00:00Z, but has since diverged from UTC, as it does not consider corrections like leap seconds.
gps_time | Synchronized time in GPS epoch format truncated to 32-bit. |
void lorawan_enable_adr | ( | bool | enable | ) |
#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).
enable | Enable or Disable adaptive data rate. |
void lorawan_frag_transport_register_descriptor_callback | ( | transport_descriptor_cb | cb | ) |
#include <zephyr/lorawan/lorawan.h>
Register a handle descriptor callback function.
Provide to the fragmentation transport service a function to be called whenever a FragSessionSetupReq is received and Descriptor field should be handled.
CONFIG_LORAWAN_FRAG_TRANSPORT
.cb | Callback for notification. |
int lorawan_frag_transport_run | ( | void(* | transport_finished_cb )(void) | ) |
#include <zephyr/lorawan/lorawan.h>
Run Fragmented Data Block Transport service.
This service receives fragmented data (usually firmware images) and stores them in the image-1 flash partition.
After all fragments have been received, the provided callback is invoked.
CONFIG_LORAWAN_FRAG_TRANSPORT
.transport_finished_cb | Callback for notification of finished data transfer. |
enum lorawan_datarate lorawan_get_min_datarate | ( | void | ) |
#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.
#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.
max_next_payload_size | Maximum payload size for the next transmission |
max_payload_size | Maximum payload size for this datarate |
int lorawan_join | ( | const struct lorawan_join_config * | config | ) |
#include <zephyr/lorawan/lorawan.h>
Join the LoRaWAN network.
Join the LoRaWAN network using OTAA or AWB.
config | Configuration to be used |
void lorawan_register_battery_level_callback | ( | lorawan_battery_level_cb_t | cb | ) |
#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.
cb | Pointer to the battery level function |
void lorawan_register_downlink_callback | ( | struct lorawan_downlink_cb * | cb | ) |
#include <zephyr/lorawan/lorawan.h>
Register a callback to be run on downlink packets.
cb | Pointer to structure containing callback parameters |
void lorawan_register_dr_changed_callback | ( | lorawan_dr_changed_cb_t | cb | ) |
#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.
cb | Pointer to datarate update callback |
void lorawan_register_link_check_ans_callback | ( | lorawan_link_check_ans_cb_t | cb | ) |
#include <zephyr/lorawan/lorawan.h>
Register a callback to be called when getting answer a to check link request.
cb | Pointer to link check ans callback |
int lorawan_request_device_time | ( | bool | force_request | ) |
#include <zephyr/lorawan/lorawan.h>
Request for time according to DeviceTimeReq MAC cmd.
Append MAC DevTimeReq command. It will be processed on next send message or force sending empty message to request time immediately.
force_request | Immediately send an empty message to execute the request |
int lorawan_request_link_check | ( | bool | force_request | ) |
#include <zephyr/lorawan/lorawan.h>
Request for link check according to LinkCheckReq MAC cmd.
Append MAC LinkCheckReq command. It will be processed on next send message or force sending empty message to request time immediately.
force_request | Immediately send an empty message to execute the request |
int lorawan_send | ( | uint8_t | port, |
uint8_t * | data, | ||
uint8_t | len, | ||
enum lorawan_message_type | type ) |
#include <zephyr/lorawan/lorawan.h>
Send data to the LoRaWAN network.
Send data to the connected LoRaWAN network.
port | Port to be used for sending data. Must be set if the payload is not empty. |
data | Data buffer to be sent |
len | Length of the buffer to be sent. Maximum length of this buffer is 255 bytes but the actual payload size varies with region and datarate. |
type | Specifies if the message shall be confirmed or unconfirmed. Must be one of lorawan_message_type. |
#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.
channels_mask | Buffer with channels mask to be used. |
channels_mask_size | Size of channels mask buffer. |
0 | successful |
-EINVAL | channels mask or channels mask size is wrong |
int lorawan_set_class | ( | enum lorawan_class | dev_class | ) |
#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.
dev_class | New device class |
int lorawan_set_conf_msg_tries | ( | uint8_t | tries | ) |
#include <zephyr/lorawan/lorawan.h>
Set the number of tries used for transmissions.
tries | Number of tries to be used |
int lorawan_set_datarate | ( | enum lorawan_datarate | dr | ) |
#include <zephyr/lorawan/lorawan.h>
Set the default data rate.
Change the default data rate.
dr | Data rate used for transmissions |
int lorawan_set_region | ( | enum lorawan_region | region | ) |
#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.
region | The region to be selected |
int lorawan_start | ( | void | ) |
#include <zephyr/lorawan/lorawan.h>
Start the LoRaWAN stack.
This function need to be called before joining the network.