lorawan.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2017 Fundación Inria Chile
3  * SPDX-FileCopyrightText: 2019 HAW Hamburg
4  * SPDX-License-Identifier: LGPL-2.1-only
5  */
6 
7 #pragma once
8 
23 #include "gnrc_lorawan_internal.h"
24 #include "assert.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
38 #ifndef CONFIG_GNRC_LORAWAN_MIN_SYMBOLS_TIMEOUT
39 #define CONFIG_GNRC_LORAWAN_MIN_SYMBOLS_TIMEOUT 30
40 #endif
43 #define GNRC_LORAWAN_REQ_STATUS_SUCCESS (0)
44 #define GNRC_LORAWAN_REQ_STATUS_DEFERRED (1)
49 typedef enum {
52 } mcps_event_t;
53 
57 typedef enum {
62 
66 typedef enum {
71 
75 typedef enum {
83 
87 typedef enum {
91 
95 typedef struct {
97  union {
99  void *dev_addr;
100  uint8_t rx2_dr;
101  };
102 } mlme_mib_t;
103 
107 typedef struct {
108  union {
111  };
114 
118 typedef struct {
119  union {
121  };
124 
128 typedef struct {
129  int16_t status;
131  union {
134  };
136 
140 typedef struct {
141  int16_t status;
145 
149 typedef struct {
151  union {
153  };
155 
159 typedef struct {
162 
169 
176 
183 {
184  /* The failed reception is seen by the MAC layer as an RX timeout */
186 }
187 
194 
202 void gnrc_lorawan_init(gnrc_lorawan_t *mac, uint8_t *joineui, const gnrc_lorawan_key_ctx_t *ctx);
203 
215  const mlme_request_t *mlme_request,
216  mlme_confirm_t *mlme_confirm);
217 
229  const mcps_request_t *mcps_request,
230  mcps_confirm_t *mcps_confirm);
231 
244  size_t size);
245 
254 
263 
272 
281 
291 
302 int gnrc_lorawan_phy_set_channel_mask(gnrc_lorawan_t *mac, uint16_t channel_mask);
303 
311 void gnrc_lorawan_set_timer(gnrc_lorawan_t *mac, uint32_t us);
312 
320 
330  uint8_t redundancy)
331 {
332  assert(redundancy <= (0xF - 1));
333  mac->mcps.redundancy = redundancy;
334 }
335 
336 #ifdef __cplusplus
337 }
338 #endif
339 
POSIX.1-2008 compliant version of the assert macro.
#define assert(cond)
abort the program if assertion is false
Definition: assert.h:143
GNRC LoRaWAN internal header.
void gnrc_lorawan_timeout_cb(gnrc_lorawan_t *mac)
Indicate the MAC layer that the timer was fired.
void gnrc_lorawan_mlme_indication(gnrc_lorawan_t *mac, mlme_indication_t *ind)
MLME indication callback.
mcps_event_t
MCPS events.
Definition: lorawan.h:49
mlme_activation_t
LoRaWAN activation mechanism.
Definition: lorawan.h:57
static void gnrc_lorawan_radio_rx_error_cb(gnrc_lorawan_t *mac)
Indicate the MAC layer reception of a frame went wrong.
Definition: lorawan.h:182
mlme_type_t
MLME primitive types.
Definition: lorawan.h:75
void gnrc_lorawan_mlme_request(gnrc_lorawan_t *mac, const mlme_request_t *mlme_request, mlme_confirm_t *mlme_confirm)
Perform a MLME request.
netdev_t * gnrc_lorawan_get_netdev(gnrc_lorawan_t *mac)
Get netdev pointer from mac descriptor.
void gnrc_lorawan_mcps_confirm(gnrc_lorawan_t *mac, mcps_confirm_t *confirm)
MCPS Confirm callback.
static void gnrc_lorawan_set_uncnf_redundancy(gnrc_lorawan_t *mac, uint8_t redundancy)
Set unconfirmed uplink redundancy.
Definition: lorawan.h:329
void gnrc_lorawan_set_timer(gnrc_lorawan_t *mac, uint32_t us)
Set a timer with the given time.
void gnrc_lorawan_mcps_request(gnrc_lorawan_t *mac, const mcps_request_t *mcps_request, mcps_confirm_t *mcps_confirm)
Perform a MCPS request.
void gnrc_lorawan_mcps_indication(gnrc_lorawan_t *mac, mcps_indication_t *ind)
MCPS indication callback.
void gnrc_lorawan_radio_rx_timeout_cb(gnrc_lorawan_t *mac)
Indicate the MAC layer there was a timeout event.
mcps_type_t
MCPS primitive types.
Definition: lorawan.h:87
void gnrc_lorawan_mlme_confirm(gnrc_lorawan_t *mac, mlme_confirm_t *confirm)
MLME confirm callback.
void gnrc_lorawan_radio_tx_done_cb(gnrc_lorawan_t *mac)
Indicate the MAC layer when the transmission finished.
void gnrc_lorawan_remove_timer(gnrc_lorawan_t *mac)
Remove the current timer.
int gnrc_lorawan_phy_set_channel_mask(gnrc_lorawan_t *mac, uint16_t channel_mask)
Set the channel mask in order to enable or disable LoRaWAN channels.
mlme_mib_type_t
MAC Information Base attributes.
Definition: lorawan.h:66
void gnrc_lorawan_radio_rx_done_cb(gnrc_lorawan_t *mac, uint8_t *data, size_t size)
Fetch a LoRaWAN packet from the radio.
void gnrc_lorawan_init(gnrc_lorawan_t *mac, uint8_t *joineui, const gnrc_lorawan_key_ctx_t *ctx)
Init GNRC LoRaWAN.
@ MCPS_EVENT_RX
MCPS RX event.
Definition: lorawan.h:50
@ MCPS_EVENT_NO_RX
MCPS no RX event.
Definition: lorawan.h:51
@ MLME_ACTIVATION_NONE
MAC layer is not activated.
Definition: lorawan.h:58
@ MLME_ACTIVATION_ABP
MAC layer activated by ABP.
Definition: lorawan.h:59
@ MLME_ACTIVATION_OTAA
MAC layer activated by OTAA.
Definition: lorawan.h:60
@ MLME_GET
get the MIB
Definition: lorawan.h:80
@ MLME_JOIN
join a LoRaWAN network
Definition: lorawan.h:76
@ MLME_LINK_CHECK
perform a Link Check
Definition: lorawan.h:77
@ MLME_SET
set the MIB
Definition: lorawan.h:79
@ MLME_RESET
reset the MAC layer
Definition: lorawan.h:78
@ MLME_SCHEDULE_UPLINK
schedule uplink indication
Definition: lorawan.h:81
@ MCPS_UNCONFIRMED
unconfirmed data
Definition: lorawan.h:89
@ MCPS_CONFIRMED
confirmed data
Definition: lorawan.h:88
@ MIB_ACTIVATION_METHOD
type is activation method
Definition: lorawan.h:67
@ MIB_RX2_DR
type is rx2 DR
Definition: lorawan.h:69
@ MIB_DEV_ADDR
type is dev addr
Definition: lorawan.h:68
GNRC LoRaWAN key context struct.
uint8_t redundancy
unconfirmed uplink redundancy
GNRC LoRaWAN mac descriptor.
gnrc_lorawan_mcps_t mcps
MCPS descriptor.
iolist structure definition
Definition: iolist.h:35
Mac Common Part Sublayer (MCPS) confirm representation.
Definition: lorawan.h:140
int16_t status
status of the MCPS confirm
Definition: lorawan.h:141
iolist_t * msdu
pointer to the msdu
Definition: lorawan.h:143
mcps_type_t type
type of the MCPS confirm
Definition: lorawan.h:142
Mac Common Part Sublayer (MCPS) indication representation.
Definition: lorawan.h:149
mcps_data_t data
MCPS Data holder.
Definition: lorawan.h:152
mcps_type_t type
type of the MCPS indication
Definition: lorawan.h:150
Mac Common Part Sublayer (MCPS) request representation.
Definition: lorawan.h:118
mcps_data_t data
MCPS data holder.
Definition: lorawan.h:120
mcps_type_t type
type of the MCPS request
Definition: lorawan.h:122
MAC (sub) Layer Management Entity (MLME) confirm representation.
Definition: lorawan.h:128
mlme_type_t type
type of the MLME confirm
Definition: lorawan.h:130
mlme_mib_t mib
MIB confirmation data.
Definition: lorawan.h:133
int16_t status
status of the MLME confirm
Definition: lorawan.h:129
mlme_link_req_confirm_t link_req
Link Check confirmation data.
Definition: lorawan.h:132
MAC (sub) Layer Management Entity (MLME) indication representation.
Definition: lorawan.h:159
mlme_type_t type
type of the MLME indication
Definition: lorawan.h:160
MLME Join Request data.
MAC Information Base descriptor for MLME Request-Confirm.
Definition: lorawan.h:95
mlme_mib_type_t type
MIB attribute identifier.
Definition: lorawan.h:96
void * dev_addr
pointer to the dev_addr
Definition: lorawan.h:99
mlme_activation_t activation
holds activation mechanism
Definition: lorawan.h:98
MAC (sub) Layer Management Entity (MLME) request representation.
Definition: lorawan.h:107
mlme_mib_t mib
MIB holder.
Definition: lorawan.h:110
mlme_lorawan_join_t join
Join Data holder.
Definition: lorawan.h:109
mlme_type_t type
type of the MLME request
Definition: lorawan.h:112
Structure to hold driver state.
Definition: netdev.h:365