Loading...
Searching...
No Matches
lorawan.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017 Fundación Inria Chile
3 * Copyright (C) 2019 HAW Hamburg
4 *
5 * This file is subject to the terms and conditions of the GNU Lesser
6 * General Public License v2.1. See the file LICENSE in the top level
7 * directory for more details.
8 */
9
10#pragma once
11
25
26#include "compiler_hints.h"
28#include "assert.h"
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
42#ifndef CONFIG_GNRC_LORAWAN_MIN_SYMBOLS_TIMEOUT
43#define CONFIG_GNRC_LORAWAN_MIN_SYMBOLS_TIMEOUT 30
44#endif
46
47#define GNRC_LORAWAN_REQ_STATUS_SUCCESS (0)
48#define GNRC_LORAWAN_REQ_STATUS_DEFERRED (1)
49
57
66
75
87
95
99typedef struct {
101 union {
103 void *dev_addr;
104 uint8_t rx2_dr;
105 };
106} mlme_mib_t;
107
118
122typedef struct {
123 union {
125 };
128
140
149
153typedef struct {
155 union {
157 };
159
163typedef struct {
166
173
180
187{
188 /* The failed reception is seen by the MAC layer as an RX timeout */
190}
191
198
206void gnrc_lorawan_init(gnrc_lorawan_t *mac, uint8_t *joineui, const gnrc_lorawan_key_ctx_t *ctx);
207
219 const mlme_request_t *mlme_request,
220 mlme_confirm_t *mlme_confirm);
221
233 const mcps_request_t *mcps_request,
234 mcps_confirm_t *mcps_confirm);
235
247ACCESS(read_write, 2, 3)
249 size_t size);
250
259
268
277
286
296
307int gnrc_lorawan_phy_set_channel_mask(gnrc_lorawan_t *mac, uint16_t channel_mask);
308
317
325
335 uint8_t redundancy)
336{
337 assert(redundancy <= (0xF - 1));
338 mac->mcps.redundancy = redundancy;
339}
340
341#ifdef __cplusplus
342}
343#endif
344
POSIX.1-2008 compliant version of the assert macro.
#define assert(cond)
abort the program if assertion is false
Definition assert.h:143
Common macros and compiler attributes/pragmas configuration.
#define ACCESS(mode, ptr_idx, size_idx)
Emit an attribute (if supported by the compiler) that declares how a function will access its paramet...
GNRC LoRaWAN internal header.
struct netdev netdev_t
Forward declaration for netdev struct.
Definition netdev.h:285
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:53
mlme_activation_t
LoRaWAN activation mechanism.
Definition lorawan.h:61
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:186
mlme_type_t
MLME primitive types.
Definition lorawan.h:79
void gnrc_lorawan_mlme_request(gnrc_lorawan_t *mac, const mlme_request_t *mlme_request, mlme_confirm_t *mlme_confirm)
Perform a MLME request.
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:334
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:91
netdev_t * gnrc_lorawan_get_netdev(gnrc_lorawan_t *mac)
Get netdev pointer from mac descriptor.
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:70
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:54
@ MCPS_EVENT_NO_RX
MCPS no RX event.
Definition lorawan.h:55
@ MLME_ACTIVATION_NONE
MAC layer is not activated.
Definition lorawan.h:62
@ MLME_ACTIVATION_ABP
MAC layer activated by ABP.
Definition lorawan.h:63
@ MLME_ACTIVATION_OTAA
MAC layer activated by OTAA.
Definition lorawan.h:64
@ MLME_GET
get the MIB
Definition lorawan.h:84
@ MLME_JOIN
join a LoRaWAN network
Definition lorawan.h:80
@ MLME_LINK_CHECK
perform a Link Check
Definition lorawan.h:81
@ MLME_SET
set the MIB
Definition lorawan.h:83
@ MLME_RESET
reset the MAC layer
Definition lorawan.h:82
@ MLME_SCHEDULE_UPLINK
schedule uplink indication
Definition lorawan.h:85
@ MCPS_UNCONFIRMED
unconfirmed data
Definition lorawan.h:93
@ MCPS_CONFIRMED
confirmed data
Definition lorawan.h:92
@ MIB_ACTIVATION_METHOD
type is activation method
Definition lorawan.h:71
@ MIB_RX2_DR
type is rx2 DR
Definition lorawan.h:73
@ MIB_DEV_ADDR
type is dev addr
Definition lorawan.h:72
struct iolist iolist_t
iolist forward declaration
Definition iolist.h:33
GNRC LoRaWAN key context struct.
GNRC LoRaWAN mac descriptor.
Mac Common Part Sublayer (MCPS) confirm representation.
Definition lorawan.h:144
int16_t status
status of the MCPS confirm
Definition lorawan.h:145
iolist_t * msdu
pointer to the msdu
Definition lorawan.h:147
mcps_type_t type
type of the MCPS confirm
Definition lorawan.h:146
Mac Common Part Sublayer (MCPS) indication representation.
Definition lorawan.h:153
mcps_data_t data
MCPS Data holder.
Definition lorawan.h:156
mcps_type_t type
type of the MCPS indication
Definition lorawan.h:154
Mac Common Part Sublayer (MCPS) request representation.
Definition lorawan.h:122
mcps_data_t data
MCPS data holder.
Definition lorawan.h:124
mcps_type_t type
type of the MCPS request
Definition lorawan.h:126
MAC (sub) Layer Management Entity (MLME) confirm representation.
Definition lorawan.h:132
mlme_type_t type
type of the MLME confirm
Definition lorawan.h:134
mlme_mib_t mib
MIB confirmation data.
Definition lorawan.h:137
int16_t status
status of the MLME confirm
Definition lorawan.h:133
mlme_link_req_confirm_t link_req
Link Check confirmation data.
Definition lorawan.h:136
MAC (sub) Layer Management Entity (MLME) indication representation.
Definition lorawan.h:163
mlme_type_t type
type of the MLME indication
Definition lorawan.h:164
MLME Join Request data.
MAC Information Base descriptor for MLME Request-Confirm.
Definition lorawan.h:99
mlme_mib_type_t type
MIB attribute identifier.
Definition lorawan.h:100
void * dev_addr
pointer to the dev_addr
Definition lorawan.h:103
mlme_activation_t activation
holds activation mechanism
Definition lorawan.h:102
MAC (sub) Layer Management Entity (MLME) request representation.
Definition lorawan.h:111
mlme_mib_t mib
MIB holder.
Definition lorawan.h:114
mlme_lorawan_join_t join
Join Data holder.
Definition lorawan.h:113
mlme_type_t type
type of the MLME request
Definition lorawan.h:116