LoRa-BLE-Sensor
Loading...
Searching...
No Matches
sensor_lorawan.h
Go to the documentation of this file.
1
12#ifndef SENSOR_LORAWAN_H
13#define SENSOR_LORAWAN_H
14
15#include <zephyr/lorawan/lorawan.h>
16#include <stdint.h>
17#include <zephyr/device.h>
18
19#define MAX_LORAWAN_PAYLOAD 255
20
24typedef struct {
25 /* Whether the LoRaWAN is enabled. */
26 uint8_t is_lorawan_enabled;
27 /* LoRaWAN frequency. */
28 uint8_t lorawan_frequency;
29 /* LoRaWAN Device. */
30 const struct device *lora_dev;
31 /* LoRaWAN uplink class. */
32 enum lorawan_class uplink_class;
33 /* LoRaWAN downlink callback. */
34 struct lorawan_downlink_cb downlink_callback;
35 /* How many attempts to join the network. If 0, it will attempt to join indefinitely. */
36 int join_attempts;
37 /* Device Nonce for LoRaWAN Network. Should be tracked seperately for different euis. */
38 uint16_t dev_nonce;
39 /* Delay between joinattempts in milliseconds. */
40 uint32_t delay;
41 /* Device EUI for LoRaWAN Network. */
42 uint8_t dev_eui[8];
43 /* Join EUI for LoRaWAN Network. */
44 uint8_t join_eui[8];
45 /* App Key for LoRaWAN Network. */
46 uint8_t app_key[16];
47 /* How many attempts to send data when waiting for an ack, if 0, it will send an unconfirmed message. */
48 uint8_t send_attempts;
50
54typedef struct {
55 /* Data to send. */
56 uint8_t data[MAX_LORAWAN_PAYLOAD];
57 /* Length of the data to send. */
58 uint16_t length;
59 /* LoRaWAN port to send the data to. */
60 uint8_t port;
61 /* How many attempts to send data when waiting for an ack, if 0, it will send an unconfirmed message. */
62 uint8_t attempts;
63 /* Delay between attempts in milliseconds. */
64 uint32_t delay;
66
74
81
89
97
103int is_lorawan_connected(void);
104
105#endif
106
int sensor_lorawan_send_data(lorawan_data_t *data)
Send data to the LoRaWAN Network.
Definition sensor_lorawan.c:174
int sensor_lorawan_setup(lorawan_setup_t *setup)
Setup LoRaWAN Network with a given lorawan_setup_t configuration.
Definition sensor_lorawan.c:78
void sensor_lorawan_log_network_config(lorawan_setup_t *setup)
Print the LoRaWAN Network dev_eui, join_eui, and app_key for a given lorawan_setup_t configuration.
Definition sensor_lorawan.c:63
int is_lorawan_connected(void)
Check if the LoRaWAN Network is connected.
Definition sensor_lorawan.c:216
int is_lorawan_configured(lorawan_setup_t *setup)
Check if the LoRaWAN Network is configured with valid lorawan keys.
Definition sensor_lorawan.c:48
Structure to hold the LoRaWAN data to send.
Definition sensor_lorawan.h:54
Structure to hold the LoRaWAN setup, used to join the network.
Definition sensor_lorawan.h:24