Ares LoRa Firmware
Loading...
Searching...
No Matches
lora.h
Go to the documentation of this file.
1
10
11#ifndef ARES_LORA_H
12#define ARES_LORA_H
13
14#include <lora/packet.h>
15#include <zephyr/drivers/lora.h>
16#include <zephyr/kernel.h>
17
26
34 void *ctx);
35
36#include <lora/lora_backend.h>
37
38struct ares_lora;
40
57 int (*init)(const struct ares_lora_transport *transport, const void *config,
58 lora_transport_handler_t evt_handler, void *context);
59
68 int (*uninit)(const struct ares_lora_transport *transport);
69
82 int (*enable)(const struct ares_lora_transport *transport, bool block_tx);
83
95 int (*write)(const struct ares_lora_transport *transport, const void *data,
96 size_t length, size_t *cnt);
97
109 int (*read)(const struct ares_lora_transport *transport, void *data,
110 size_t length, size_t *cnt);
111
122 int (*configure)(const struct ares_lora_transport *transport,
123 const struct lora_modem_config *config);
124};
125
135
139 void *ctx;
140};
141
153
154#if defined(CONFIG_ARES_LORA_TRX_BUF_SIZE)
158#define ARES_LORA_TRX_BUF_SIZE CONFIG_ARES_LORA_TRX_BUF_SIZE
159#else
163#define ARES_LORA_TRX_BUF_SIZE 512
164#endif // defined(CONFIG_ARES_LORA_TRX_BUF_SIZE)
165
175
179 size_t len;
180};
181
191
198 void (*handler)(const struct ares_lora *lora,
199 const struct ares_packet *packet);
200};
201
211
216
220 struct k_poll_signal signals[ARES_LORA_SIGNALS];
221
225 struct k_poll_event events[ARES_LORA_SIGNALS];
226
231
236
240 struct k_mutex wr_mtx;
241
245 k_tid_t tid;
246
250 uint16_t packet_id;
251
255 uint8_t seq_num;
256};
257
262struct ares_lora {
267
272
276 const char *name;
277
281 struct k_thread *thread;
282
286 k_thread_stack_t *stack;
287};
288
295#define ARES_LORA_DEFINE(_name, _transport) \
296 static struct ares_lora_ctx UTIL_CAT(_name, _ctx); \
297 static K_KERNEL_STACK_DEFINE(UTIL_CAT(_name, _stack), \
298 CONFIG_ARES_LORA_STACK_SIZE); \
299 static struct k_thread UTIL_CAT(_name, _thread); \
300 static const struct ares_lora _name = {.iface = (_transport), \
301 .ctx = &UTIL_CAT(_name, _ctx), \
302 .name = STRINGIFY(_name), \
303 .thread = \
304 &UTIL_CAT(_name, _thread), \
305 .stack = UTIL_CAT(_name, _stack)}
306
316int ares_lora_init(const struct ares_lora *lora, const void *transport_config);
317
329 const struct ares_lora *lora, const struct ares_lora_command *commands,
330 size_t num_commands);
331
344int ares_lora_write_packet(const struct ares_lora *lora,
345 const struct ares_packet *packet);
346
357int ares_lora_configure_lora(const struct ares_lora *lora,
358 const struct lora_modem_config *config);
359
370int ares_lora_set_packet_id(const struct ares_lora *lora,
371 struct ares_packet *packet);
372
373#endif // ARES_LORA_H
void(* lora_transport_handler_t)(enum lora_transport_evt evt, void *ctx)
LoRa transport event handler prototype.
Definition lora.h:33
int ares_lora_register_command_callbacks(const struct ares_lora *lora, const struct ares_lora_command *commands, size_t num_commands)
Function for registering the lora packet handlers.
int ares_lora_set_packet_id(const struct ares_lora *lora, struct ares_packet *packet)
Function to update the packet ID of the given packet from the lora instance.
int ares_lora_write_packet(const struct ares_lora *lora, const struct ares_packet *packet)
Function to write a packet to the LoRa transfer layer.
int ares_lora_configure_lora(const struct ares_lora *lora, const struct lora_modem_config *config)
Function to send new configurations to the LoRa transfer layer.
int ares_lora_init(const struct ares_lora *lora, const void *transport_config)
Function for initializing a transport layer and internal lora state.
#define ARES_LORA_TRX_BUF_SIZE
Definition lora.h:163
ares_lora_signal
Signals for the LoRa interface.
Definition lora.h:146
@ ARES_LORA_SIGNAL_TXDONE
Definition lora.h:148
@ ARES_LORA_SIGNALS
Last enumerator.
Definition lora.h:151
@ ARES_LORA_SIGNAL_RXRDY
Rx data ready.
Definition lora.h:147
lora_transport_evt
Definition lora.h:22
@ LORA_TRANSPORT_EVT_RX_RDY
LoRa Rx data ready.
Definition lora.h:23
@ LORA_TRANSPORT_EVT_TX_RDY
LoRa Tx ready.
Definition lora.h:24
LoRa transport layer header.
Ares Packet API.
ares_packet_payload_type
Packet payload types.
Definition packet.h:111
Unified buffer structure for LoRa.
Definition lora.h:170
uint8_t buf[ARES_LORA_TRX_BUF_SIZE]
Definition lora.h:174
size_t len
Definition lora.h:179
LoRa packet payload handler descriptor.
Definition lora.h:186
void(* handler)(const struct ares_lora *lora, const struct ares_packet *packet)
Definition lora.h:198
enum ares_packet_payload_type type
Definition lora.h:190
Ares LoRa instance context.
Definition lora.h:206
struct k_mutex wr_mtx
Definition lora.h:240
struct ares_lora_buf tx_buf
Definition lora.h:215
uint16_t packet_id
Definition lora.h:250
struct k_poll_signal signals[ARES_LORA_SIGNALS]
Definition lora.h:220
size_t num_commands
Definition lora.h:235
const struct ares_lora_command * commands
Definition lora.h:230
struct ares_lora_buf rx_buf
Definition lora.h:210
uint8_t seq_num
Definition lora.h:255
k_tid_t tid
Definition lora.h:245
struct k_poll_event events[ARES_LORA_SIGNALS]
Definition lora.h:225
Unified LoRa transport interface.
Definition lora.h:45
int(* write)(const struct ares_lora_transport *transport, const void *data, size_t length, size_t *cnt)
Function for writing data to the transfer interface.
Definition lora.h:95
int(* enable)(const struct ares_lora_transport *transport, bool block_tx)
Function for enabling transport in given TX mode.
Definition lora.h:82
int(* read)(const struct ares_lora_transport *transport, void *data, size_t length, size_t *cnt)
Function for reading data from the transport interface.
Definition lora.h:109
int(* init)(const struct ares_lora_transport *transport, const void *config, lora_transport_handler_t evt_handler, void *context)
Function for initializing the LoRa transport interface.
Definition lora.h:57
int(* configure)(const struct ares_lora_transport *transport, const struct lora_modem_config *config)
Function for reconfiguring the LoRa modem defined in the transport interface.
Definition lora.h:122
int(* uninit)(const struct ares_lora_transport *transport)
Function for uninitializing the LoRa transport interface.
Definition lora.h:68
Transfer interface.
Definition lora.h:130
void * ctx
Definition lora.h:139
const struct ares_lora_transport_api * api
Definition lora.h:134
Ares LoRa internals.
Definition lora.h:262
struct ares_lora_ctx * ctx
Definition lora.h:271
struct k_thread * thread
Definition lora.h:281
const struct ares_lora_transport * iface
Definition lora.h:266
const char * name
Definition lora.h:276
k_thread_stack_t * stack
Definition lora.h:286
Structured representation of an ares packet.
Definition packet.h:175