22#ifndef NET_LORAWAN_HDR_H
23#define NET_LORAWAN_HDR_H
32#define LORAWAN_HDR_MTYPE_MASK (0xe0)
33#define LORAWAN_HDR_MTYPE_POS (5U)
34#define LORAWAN_HDR_MAJOR_MASK (0x03)
35#define LORAWAN_HDR_MAJOR_POS (0U)
36#define LORAWAN_HDR_ADR_MASK (0x80)
37#define LORAWAN_HDR_ADR_POS (7U)
38#define LORAWAN_HDR_ADR_ACK_MASK (0x40)
39#define LORAWAN_HDR_ADR_ACK_POS (6U)
40#define LORAWAN_HDR_ACK_MASK (0x20)
41#define LORAWAN_HDR_ACK_POS (5U)
42#define LORAWAN_HDR_FRAME_PENDING_MASK (0x10)
43#define LORAWAN_HDR_FRAME_PENDING_POS (4U)
44#define LORAWAN_HDR_FOPTS_LEN_MASK (0x0F)
45#define LORAWAN_HDR_FOPTS_LEN_POS (0U)
47#define LORAWAN_JA_HDR_OPTNEG_MASK (0x80)
48#define LORAWAN_JA_HDR_OPTNEG_POS (7U)
74typedef struct __attribute__((packed)) {
96typedef struct __attribute__((packed)) {
107typedef struct __attribute__((packed)) {
124 hdr->
mt_maj &= ~LORAWAN_HDR_MTYPE_MASK;
148 hdr->
mt_maj &= ~LORAWAN_HDR_MAJOR_MASK;
172 hdr->
fctrl &= ~LORAWAN_HDR_ADR_MASK;
196 hdr->
fctrl &= ~LORAWAN_HDR_ADR_ACK_MASK;
220 hdr->
fctrl &= ~LORAWAN_HDR_ACK_MASK;
244 hdr->
fctrl &= ~LORAWAN_HDR_FRAME_PENDING_MASK;
268 hdr->
fctrl &= ~LORAWAN_HDR_FOPTS_LEN_MASK;
Functions to work with different byte orders.
#define LORAMAC_DEVADDR_LEN
Device address length in bytes.
#define LORAMAC_JOIN_NONCE_LEN
Join nonce length in bytes.
#define LORAMAC_NETWORK_ID_LEN
Network ID length in bytes.
#define LORAWAN_HDR_MAJOR_POS
Major version position.
#define LORAWAN_HDR_FRAME_PENDING_POS
Frame pending bit position.
static void lorawan_hdr_set_ack(lorawan_hdr_t *hdr, bool ack)
Set LoRaWAN header ACK bit.
static void lorawan_hdr_set_frame_pending(lorawan_hdr_t *hdr, bool frame_pending)
Set LoRaWAN header frame pending bit.
static uint8_t lorawan_hdr_get_mtype(lorawan_hdr_t *hdr)
Get LoRaWAN header MType.
#define LORAWAN_HDR_ADR_MASK
ADR mask.
#define LORAWAN_HDR_ADR_ACK_POS
ADR ACK bit position.
static uint8_t lorawan_hdr_get_maj(lorawan_hdr_t *hdr)
Get LoRaWAN major version.
static bool lorawan_hdr_get_adr(lorawan_hdr_t *hdr)
Get LoRaWAN header Adaptive Data Rate bit.
static bool lorawan_ja_hdr_get_optneg(lorawan_join_accept_t *ja_hdr)
Get LoRaWAN join accept message OptNeg bit.
#define LORAWAN_HDR_ADR_ACK_MASK
ADR ACK bit mask.
#define LORAWAN_JA_HDR_OPTNEG_MASK
OptNeg bit mask.
static void lorawan_hdr_set_maj(lorawan_hdr_t *hdr, uint8_t maj)
Set LoRaWAN major version.
#define LORAWAN_HDR_FOPTS_LEN_POS
Frame options position.
#define LORAWAN_JA_HDR_OPTNEG_POS
OptNeg bit position.
static void lorawan_hdr_set_adr_ack_req(lorawan_hdr_t *hdr, bool adr_ack_req)
Set LoRaWAN header ADR ACK request bit.
#define LORAWAN_HDR_ADR_POS
ADR position.
static bool lorawan_hdr_get_frame_pending(lorawan_hdr_t *hdr)
Get LoRaWAN header frame pending bit.
#define LORAWAN_HDR_MTYPE_MASK
MType mask.
#define LORAWAN_HDR_ACK_POS
ACK bit position.
#define LORAWAN_HDR_ACK_MASK
ACK bit mask.
#define LORAWAN_HDR_FRAME_PENDING_MASK
Frame pending bit mask.
static bool lorawan_hdr_get_ack(lorawan_hdr_t *hdr)
Get LoRaWAN header ACK bit.
#define LORAWAN_HDR_MAJOR_MASK
Major version mask.
#define LORAWAN_HDR_MTYPE_POS
MType position.
static bool lorawan_hdr_get_adr_ack_req(lorawan_hdr_t *hdr)
Get LoRaWAN header ADR ACK request bit.
static void lorawan_hdr_set_adr(lorawan_hdr_t *hdr, bool adr)
Set LoRaWAN header Adaptive Data Rate bit.
#define LORAWAN_HDR_FOPTS_LEN_MASK
Frame options mask.
static void lorawan_hdr_set_frame_opts_len(lorawan_hdr_t *hdr, uint8_t len)
Set LoRaWAN header FOpts length.
static void lorawan_hdr_set_mtype(lorawan_hdr_t *hdr, uint8_t mtype)
Set LoRaWAN header MType.
static uint8_t lorawan_hdr_get_frame_opts_len(lorawan_hdr_t *hdr)
Get LoRaWAN header FOps length.
LoRaMAC header definitions.
stdio wrapper to extend the C libs stdio
Data type to represent a LoRaWAN packet header.
le_uint16_t fcnt
frame counter
uint8_t mt_maj
message type and major version
uint8_t fctrl
frame control
le_uint32_t addr
32 bit LoRaWAN address
Join accept packet representation.
uint8_t rx_delay
first reception window delay
uint8_t mt_maj
mtype and major version holder
uint8_t dl_settings
downlink settings
Join request packet representation.
le_uint64_t join_eui
join EUI.
le_uint16_t dev_nonce
device nonce
le_uint64_t dev_eui
device EUI
le_uint32_t mic
message integrity code
uint8_t mt_maj
mtype and major version holder
A 16 bit integer in little endian.
A 32 bit integer in little endian.
A 64 bit integer in little endian.