1#if !defined(_RADIOLIB_LORAWAN_H) && !RADIOLIB_EXCLUDE_LORAWAN
2#define _RADIOLIB_LORAWAN_H
4#include "../../TypeDef.h"
5#include "../PhysicalLayer/PhysicalLayer.h"
6#include "../../utils/Cryptography.h"
9#define RADIOLIB_LORAWAN_MODE_OTAA (0x07AA)
10#define RADIOLIB_LORAWAN_MODE_ABP (0x0AB9)
11#define RADIOLIB_LORAWAN_MODE_NONE (0x0000)
14#define RADIOLIB_LORAWAN_CLASS_A (0x00)
15#define RADIOLIB_LORAWAN_CLASS_B (0x01)
16#define RADIOLIB_LORAWAN_CLASS_C (0x02)
19#define RADIOLIB_LORAWAN_LORA_SYNC_WORD (0x34)
20#define RADIOLIB_LORAWAN_LORA_PREAMBLE_LEN (8)
21#define RADIOLIB_LORAWAN_GFSK_SYNC_WORD (0xC194C1)
22#define RADIOLIB_LORAWAN_GFSK_PREAMBLE_LEN (5)
23#define RADIOLIB_LORAWAN_LR_FHSS_SYNC_WORD (0x2C0F7995)
26#define RADIOLIB_LORAWAN_MHDR_MTYPE_JOIN_REQUEST (0x00 << 5)
27#define RADIOLIB_LORAWAN_MHDR_MTYPE_JOIN_ACCEPT (0x01 << 5)
28#define RADIOLIB_LORAWAN_MHDR_MTYPE_UNCONF_DATA_UP (0x02 << 5)
29#define RADIOLIB_LORAWAN_MHDR_MTYPE_UNCONF_DATA_DOWN (0x03 << 5)
30#define RADIOLIB_LORAWAN_MHDR_MTYPE_CONF_DATA_UP (0x04 << 5)
31#define RADIOLIB_LORAWAN_MHDR_MTYPE_CONF_DATA_DOWN (0x05 << 5)
32#define RADIOLIB_LORAWAN_MHDR_MTYPE_PROPRIETARY (0x07 << 5)
33#define RADIOLIB_LORAWAN_MHDR_MTYPE_MASK (0x07 << 5)
34#define RADIOLIB_LORAWAN_MHDR_MAJOR_R1 (0x00 << 0)
37#define RADIOLIB_LORAWAN_FCTRL_ADR_ENABLED (0x01 << 7)
38#define RADIOLIB_LORAWAN_FCTRL_ADR_DISABLED (0x00 << 7)
39#define RADIOLIB_LORAWAN_FCTRL_ADR_ACK_REQ (0x01 << 6)
40#define RADIOLIB_LORAWAN_FCTRL_ACK (0x01 << 5)
41#define RADIOLIB_LORAWAN_FCTRL_FRAME_PENDING (0x01 << 4)
44#define RADIOLIB_LORAWAN_FPORT_MAC_COMMAND (0x00 << 0)
45#define RADIOLIB_LORAWAN_FPORT_PAYLOAD_MIN (0x01 << 0)
46#define RADIOLIB_LORAWAN_FPORT_PAYLOAD_MAX (0xDF << 0)
47#define RADIOLIB_LORAWAN_FPORT_RESERVED (0xE0 << 0)
50#define RADIOLIB_LORAWAN_DATA_RATE_UNUSED (0x0F << 0)
51#define RADIOLIB_LORAWAN_TX_POWER_UNUSED (0x0F << 0)
54#define RADIOLIB_LORAWAN_UPLINK (0x00 << 0)
55#define RADIOLIB_LORAWAN_DOWNLINK (0x01 << 0)
56#define RADIOLIB_LORAWAN_RX1 (0x01 << 0)
57#define RADIOLIB_LORAWAN_RX2 (0x02 << 0)
58#define RADIOLIB_LORAWAN_RX_BC (0x03 << 0)
59#define RADIOLIB_LORAWAN_BAND_DYNAMIC (0)
60#define RADIOLIB_LORAWAN_BAND_FIXED (1)
61#define RADIOLIB_LORAWAN_CHANNEL_NUM_DATARATES (15)
64#define RADIOLIB_LORAWAN_RECEIVE_DELAY_1_MS (1000)
65#define RADIOLIB_LORAWAN_RECEIVE_DELAY_2_MS ((RADIOLIB_LORAWAN_RECEIVE_DELAY_1_MS) + 1000)
66#define RADIOLIB_LORAWAN_RX1_DR_OFFSET (0)
67#define RADIOLIB_LORAWAN_JOIN_ACCEPT_DELAY_1_MS (5000)
68#define RADIOLIB_LORAWAN_JOIN_ACCEPT_DELAY_2_MS (6000)
69#define RADIOLIB_LORAWAN_ADR_ACK_LIMIT_EXP (0x06)
70#define RADIOLIB_LORAWAN_ADR_ACK_DELAY_EXP (0x05)
71#define RADIOLIB_LORAWAN_RETRANSMIT_TIMEOUT_MIN_MS (1000)
72#define RADIOLIB_LORAWAN_RETRANSMIT_TIMEOUT_MAX_MS (3000)
73#define RADIOLIB_LORAWAN_POWER_STEP_SIZE_DBM (-2)
74#define RADIOLIB_LORAWAN_REJOIN_MAX_COUNT_N (10)
75#define RADIOLIB_LORAWAN_REJOIN_MAX_TIME_N (15)
78#define RADIOLIB_LORAWAN_JOIN_REQUEST_LEN (23)
79#define RADIOLIB_LORAWAN_JOIN_REQUEST_JOIN_EUI_POS (1)
80#define RADIOLIB_LORAWAN_JOIN_REQUEST_DEV_EUI_POS (9)
81#define RADIOLIB_LORAWAN_JOIN_REQUEST_DEV_NONCE_POS (17)
82#define RADIOLIB_LORAWAN_JOIN_REQUEST_TYPE (0xFF)
83#define RADIOLIB_LORAWAN_JOIN_REQUEST_TYPE_0 (0x00)
84#define RADIOLIB_LORAWAN_JOIN_REQUEST_TYPE_1 (0x01)
85#define RADIOLIB_LORAWAN_JOIN_REQUEST_TYPE_2 (0x02)
88#define RADIOLIB_LORAWAN_JOIN_ACCEPT_MAX_LEN (33)
89#define RADIOLIB_LORAWAN_JOIN_ACCEPT_JOIN_NONCE_POS (1)
90#define RADIOLIB_LORAWAN_JOIN_ACCEPT_HOME_NET_ID_POS (4)
91#define RADIOLIB_LORAWAN_JOIN_ACCEPT_DEV_ADDR_POS (7)
92#define RADIOLIB_LORAWAN_JOIN_ACCEPT_DL_SETTINGS_POS (11)
93#define RADIOLIB_LORAWAN_JOIN_ACCEPT_RX_DELAY_POS (12)
94#define RADIOLIB_LORAWAN_JOIN_ACCEPT_CFLIST_POS (13)
95#define RADIOLIB_LORAWAN_JOIN_ACCEPT_CFLIST_LEN (16)
96#define RADIOLIB_LORAWAN_JOIN_ACCEPT_CFLIST_TYPE_POS (RADIOLIB_LORAWAN_JOIN_ACCEPT_CFLIST_POS + RADIOLIB_LORAWAN_JOIN_ACCEPT_CFLIST_LEN - 1)
99#define RADIOLIB_LORAWAN_JOIN_ACCEPT_AES_JOIN_NONCE_POS (1)
100#define RADIOLIB_LORAWAN_JOIN_ACCEPT_AES_JOIN_EUI_POS (4)
101#define RADIOLIB_LORAWAN_JOIN_ACCEPT_AES_DEV_NONCE_POS (12)
102#define RADIOLIB_LORAWAN_JOIN_ACCEPT_AES_DEV_ADDR_POS (1)
105#define RADIOLIB_LORAWAN_JOIN_ACCEPT_R_1_0 (0x00 << 7)
106#define RADIOLIB_LORAWAN_JOIN_ACCEPT_R_1_1 (0x01 << 7)
107#define RADIOLIB_LORAWAN_JOIN_ACCEPT_F_NWK_S_INT_KEY (0x01)
108#define RADIOLIB_LORAWAN_JOIN_ACCEPT_APP_S_KEY (0x02)
109#define RADIOLIB_LORAWAN_JOIN_ACCEPT_S_NWK_S_INT_KEY (0x03)
110#define RADIOLIB_LORAWAN_JOIN_ACCEPT_NWK_S_ENC_KEY (0x04)
111#define RADIOLIB_LORAWAN_JOIN_ACCEPT_JS_ENC_KEY (0x05)
112#define RADIOLIB_LORAWAN_JOIN_ACCEPT_JS_INT_KEY (0x06)
113#define RADIOLIB_LORAWAN_JOIN_ACCEPT_ROOT_WOR_S_KEY (0x01)
114#define RADIOLIB_LORAWAN_JOIN_ACCEPT_WOR_S_INT_KEY (0x01)
115#define RADIOLIB_LORAWAN_JOIN_ACCEPT_WOR_S_ENC_KEY (0x02)
118#define RADIOLIB_LORAWAN_FHDR_LEN_START_OFFS (16)
119#define RADIOLIB_LORAWAN_FHDR_DEV_ADDR_POS (RADIOLIB_LORAWAN_FHDR_LEN_START_OFFS + 1)
120#define RADIOLIB_LORAWAN_FHDR_FCTRL_POS (RADIOLIB_LORAWAN_FHDR_LEN_START_OFFS + 5)
121#define RADIOLIB_LORAWAN_FHDR_FCNT_POS (RADIOLIB_LORAWAN_FHDR_LEN_START_OFFS + 6)
122#define RADIOLIB_LORAWAN_FHDR_FOPTS_POS (RADIOLIB_LORAWAN_FHDR_LEN_START_OFFS + 8)
123#define RADIOLIB_LORAWAN_FHDR_FOPTS_LEN_MASK (0x0F)
124#define RADIOLIB_LORAWAN_FHDR_FOPTS_MAX_LEN (15)
125#define RADIOLIB_LORAWAN_FHDR_FPORT_POS(FOPTS) (RADIOLIB_LORAWAN_FHDR_LEN_START_OFFS + 8 + (FOPTS))
126#define RADIOLIB_LORAWAN_FRAME_PAYLOAD_POS(FOPTS) (RADIOLIB_LORAWAN_FHDR_LEN_START_OFFS + 9 + (FOPTS))
127#define RADIOLIB_LORAWAN_FRAME_LEN(PAYLOAD, FOPTS) (16 + 13 + (PAYLOAD) + (FOPTS))
130#define RADIOLIB_LORAWAN_BLOCK_MAGIC_POS (0)
131#define RADIOLIB_LORAWAN_BLOCK_CONF_FCNT_POS (1)
132#define RADIOLIB_LORAWAN_BLOCK_DIR_POS (5)
133#define RADIOLIB_LORAWAN_BLOCK_DEV_ADDR_POS (6)
134#define RADIOLIB_LORAWAN_BLOCK_FCNT_POS (10)
137#define RADIOLIB_LORAWAN_ENC_BLOCK_MAGIC (0x01)
138#define RADIOLIB_LORAWAN_ENC_BLOCK_COUNTER_ID_POS (4)
139#define RADIOLIB_LORAWAN_ENC_BLOCK_COUNTER_POS (15)
142#define RADIOLIB_LORAWAN_MIC_BLOCK_MAGIC (0x49)
143#define RADIOLIB_LORAWAN_MIC_BLOCK_LEN_POS (15)
144#define RADIOLIB_LORAWAN_MIC_DATA_RATE_POS (3)
145#define RADIOLIB_LORAWAN_MIC_CH_INDEX_POS (4)
148#define RADIOLIB_LORAWAN_DWELL_TIME (400)
151#define RADIOLIB_LORAWAN_FCNT_NONE (0xFFFFFFFF)
154#define RADIOLIB_LORAWAN_DIFS_DEFAULT (2)
155#define RADIOLIB_LORAWAN_BACKOFF_MAX_DEFAULT (6)
156#define RADIOLIB_LORAWAN_MAX_CHANGES_DEFAULT (4)
159#define RADIOLIB_LORAWAN_NUM_MAC_COMMANDS (24)
161#define RADIOLIB_LORAWAN_MAC_RESET (0x01)
162#define RADIOLIB_LORAWAN_MAC_LINK_CHECK (0x02)
163#define RADIOLIB_LORAWAN_MAC_LINK_ADR (0x03)
164#define RADIOLIB_LORAWAN_MAC_DUTY_CYCLE (0x04)
165#define RADIOLIB_LORAWAN_MAC_RX_PARAM_SETUP (0x05)
166#define RADIOLIB_LORAWAN_MAC_DEV_STATUS (0x06)
167#define RADIOLIB_LORAWAN_MAC_NEW_CHANNEL (0x07)
168#define RADIOLIB_LORAWAN_MAC_RX_TIMING_SETUP (0x08)
169#define RADIOLIB_LORAWAN_MAC_TX_PARAM_SETUP (0x09)
170#define RADIOLIB_LORAWAN_MAC_DL_CHANNEL (0x0A)
171#define RADIOLIB_LORAWAN_MAC_REKEY (0x0B)
172#define RADIOLIB_LORAWAN_MAC_ADR_PARAM_SETUP (0x0C)
173#define RADIOLIB_LORAWAN_MAC_DEVICE_TIME (0x0D)
174#define RADIOLIB_LORAWAN_MAC_FORCE_REJOIN (0x0E)
175#define RADIOLIB_LORAWAN_MAC_REJOIN_PARAM_SETUP (0x0F)
176#define RADIOLIB_LORAWAN_MAC_DEVICE_MODE (0x20)
177#define RADIOLIB_LORAWAN_MAC_PROPRIETARY (0x80)
180#define RADIOLIB_LORAWAN_MAX_NUM_DYNAMIC_CHANNELS (24)
181#define RADIOLIB_LORAWAN_MAX_NUM_SUBBANDS (12)
182#define RADIOLIB_LORAWAN_MAX_NUM_FIXED_CHANNELS (96)
185#define RADIOLIB_LORAWAN_MAX_MAC_COMMAND_LEN_DOWN (5)
186#define RADIOLIB_LORAWAN_MAX_MAC_COMMAND_LEN_UP (2)
187#define RADIOLIB_LORAWAN_MAX_NUM_ADR_COMMANDS (8)
189#define RADIOLIB_LORAWAN_MAX_PAYLOAD_SIZE (242)
192#define RADIOLIB_LORAWAN_MAX_PHY_PAYLOAD_SIZE (255)
195#define RADIOLIB_LORAWAN_SESSION_NONE (0x00)
196#define RADIOLIB_LORAWAN_SESSION_ACTIVATING (0x01)
197#define RADIOLIB_LORAWAN_SESSION_PENDING (0x02)
198#define RADIOLIB_LORAWAN_SESSION_ACTIVE (0x03)
201#define RADIOLIB_LORAWAN_DELAY_SLEEP_THRESHOLD (10)
224#define RADIOLIB_LORAWAN_MAC_COMMAND_NONE { .cid = 0, .lenDn = 0, .lenUp = 0, .persist = false, .user = false }
227#define RADIOLIB_LORAWAN_MAX_NUM_MC_GROUPS (4)
258#define RADIOLIB_MULTICAST_GROUP_NONE \
259 { .cls = RADIOLIB_LORAWAN_CLASS_A, .mcAddr = 0, .mcAppSKey = { 0 }, .mcNwkSKey = { 0 }, \
260 .mcFCnt = 0, .mcFCntMax = 0xFFFFFFFF, .rxFCnt = 0, .mcFreq = 0, .mcDr = RADIOLIB_LORAWAN_DATA_RATE_UNUSED }
264#define RADIOLIB_LORAWAN_NUM_RESERVED_PACKAGES (3)
278#define RADIOLIB_LORAWAN_NONCES_VERSION_VAL (0x0004)
280enum LoRaWANSchemePersistence_t {
281 RADIOLIB_LORAWAN_NONCES_START = 0x00,
282 RADIOLIB_LORAWAN_PERSISTENCE_SIZE = RADIOLIB_LORAWAN_NONCES_START,
283 RADIOLIB_LORAWAN_PERSISTENCE_VERSION = RADIOLIB_LORAWAN_PERSISTENCE_SIZE + 1,
284 RADIOLIB_LORAWAN_PERSISTENCE_KEYS = RADIOLIB_LORAWAN_PERSISTENCE_VERSION + 2,
285 RADIOLIB_LORAWAN_PERSISTENCE_JOIN_NONCE = RADIOLIB_LORAWAN_PERSISTENCE_KEYS + 4,
286 RADIOLIB_LORAWAN_PERSISTENCE_DEV_NONCE = RADIOLIB_LORAWAN_PERSISTENCE_JOIN_NONCE + 3,
287 RADIOLIB_LORAWAN_PERSISTENCE_RJ_COUNT = RADIOLIB_LORAWAN_PERSISTENCE_DEV_NONCE + 2,
288 RADIOLIB_LORAWAN_PERSISTENCE_TS004 = RADIOLIB_LORAWAN_PERSISTENCE_RJ_COUNT + 2,
289 RADIOLIB_LORAWAN_PERSISTENCE_TS009 = RADIOLIB_LORAWAN_PERSISTENCE_TS004 + 8,
290 RADIOLIB_LORAWAN_PERSISTENCE_RFU = RADIOLIB_LORAWAN_PERSISTENCE_TS009 + 1,
291 RADIOLIB_LORAWAN_PERSISTENCE_SIGNATURE = RADIOLIB_LORAWAN_PERSISTENCE_RFU + 5,
292 RADIOLIB_LORAWAN_PERSISTENCE_BUF_SIZE = RADIOLIB_LORAWAN_PERSISTENCE_SIGNATURE + 4
295enum LoRaWANSchemeSession_t {
296 RADIOLIB_LORAWAN_SESSION_START = 0x00,
297 RADIOLIB_LORAWAN_SESSION_STATUS = RADIOLIB_LORAWAN_SESSION_START,
298 RADIOLIB_LORAWAN_SESSION_NWK_SENC_KEY = RADIOLIB_LORAWAN_SESSION_STATUS + 1,
299 RADIOLIB_LORAWAN_SESSION_APP_SKEY = RADIOLIB_LORAWAN_SESSION_NWK_SENC_KEY + RADIOLIB_AES128_KEY_SIZE,
300 RADIOLIB_LORAWAN_SESSION_FNWK_SINT_KEY = RADIOLIB_LORAWAN_SESSION_APP_SKEY + RADIOLIB_AES128_KEY_SIZE,
301 RADIOLIB_LORAWAN_SESSION_SNWK_SINT_KEY = RADIOLIB_LORAWAN_SESSION_FNWK_SINT_KEY + RADIOLIB_AES128_KEY_SIZE,
302 RADIOLIB_LORAWAN_SESSION_DEV_ADDR = RADIOLIB_LORAWAN_SESSION_SNWK_SINT_KEY + RADIOLIB_AES128_KEY_SIZE,
303 RADIOLIB_LORAWAN_SESSION_NONCES_SIGNATURE = RADIOLIB_LORAWAN_SESSION_DEV_ADDR +
sizeof(uint32_t),
304 RADIOLIB_LORAWAN_SESSION_FCNT_UP = RADIOLIB_LORAWAN_SESSION_NONCES_SIGNATURE +
sizeof(uint32_t),
305 RADIOLIB_LORAWAN_SESSION_N_FCNT_DOWN = RADIOLIB_LORAWAN_SESSION_FCNT_UP +
sizeof(uint32_t),
306 RADIOLIB_LORAWAN_SESSION_A_FCNT_DOWN = RADIOLIB_LORAWAN_SESSION_N_FCNT_DOWN +
sizeof(uint32_t),
307 RADIOLIB_LORAWAN_SESSION_ADR_FCNT = RADIOLIB_LORAWAN_SESSION_A_FCNT_DOWN +
sizeof(uint32_t),
308 RADIOLIB_LORAWAN_SESSION_CONF_FCNT_UP = RADIOLIB_LORAWAN_SESSION_ADR_FCNT +
sizeof(uint32_t),
309 RADIOLIB_LORAWAN_SESSION_CONF_FCNT_DOWN = RADIOLIB_LORAWAN_SESSION_CONF_FCNT_UP +
sizeof(uint32_t),
310 RADIOLIB_LORAWAN_SESSION_RX_A_FCNT = RADIOLIB_LORAWAN_SESSION_CONF_FCNT_DOWN +
sizeof(uint32_t),
311 RADIOLIB_LORAWAN_SESSION_VERSION = RADIOLIB_LORAWAN_SESSION_RX_A_FCNT +
sizeof(uint32_t),
312 RADIOLIB_LORAWAN_SESSION_BAND = RADIOLIB_LORAWAN_SESSION_VERSION + 1,
313 RADIOLIB_LORAWAN_SESSION_CLASS = RADIOLIB_LORAWAN_SESSION_BAND + 1,
314 RADIOLIB_LORAWAN_SESSION_LINK_ADR = RADIOLIB_LORAWAN_SESSION_CLASS +
sizeof(uint8_t),
315 RADIOLIB_LORAWAN_SESSION_DUTY_CYCLE = RADIOLIB_LORAWAN_SESSION_LINK_ADR + 14,
316 RADIOLIB_LORAWAN_SESSION_RX_PARAM_SETUP = RADIOLIB_LORAWAN_SESSION_DUTY_CYCLE + 1,
317 RADIOLIB_LORAWAN_SESSION_RX_TIMING_SETUP = RADIOLIB_LORAWAN_SESSION_RX_PARAM_SETUP + 4,
318 RADIOLIB_LORAWAN_SESSION_TX_PARAM_SETUP = RADIOLIB_LORAWAN_SESSION_RX_TIMING_SETUP + 1,
319 RADIOLIB_LORAWAN_SESSION_ADR_PARAM_SETUP = RADIOLIB_LORAWAN_SESSION_TX_PARAM_SETUP + 1,
320 RADIOLIB_LORAWAN_SESSION_REJOIN_PARAM_SETUP = RADIOLIB_LORAWAN_SESSION_ADR_PARAM_SETUP + 1,
321 RADIOLIB_LORAWAN_SESSION_UL_CHANNELS = RADIOLIB_LORAWAN_SESSION_REJOIN_PARAM_SETUP + 1,
322 RADIOLIB_LORAWAN_SESSION_DL_CHANNELS = RADIOLIB_LORAWAN_SESSION_UL_CHANNELS + RADIOLIB_LORAWAN_MAX_NUM_DYNAMIC_CHANNELS*5,
323 RADIOLIB_LORAWAN_SESSION_AVAILABLE_CHANNELS = RADIOLIB_LORAWAN_SESSION_DL_CHANNELS + RADIOLIB_LORAWAN_MAX_NUM_DYNAMIC_CHANNELS*4,
324 RADIOLIB_LORAWAN_SESSION_MAC_QUEUE = RADIOLIB_LORAWAN_SESSION_AVAILABLE_CHANNELS + RADIOLIB_LORAWAN_MAX_NUM_SUBBANDS,
325 RADIOLIB_LORAWAN_SESSION_MAC_QUEUE_LEN = RADIOLIB_LORAWAN_SESSION_MAC_QUEUE + RADIOLIB_LORAWAN_FHDR_FOPTS_MAX_LEN,
326 RADIOLIB_LORAWAN_SESSION_SIGNATURE = RADIOLIB_LORAWAN_SESSION_MAC_QUEUE_LEN +
sizeof(uint8_t),
327 RADIOLIB_LORAWAN_SESSION_BUF_SIZE = RADIOLIB_LORAWAN_SESSION_SIGNATURE +
sizeof(uint32_t)
353#define RADIOLIB_LORAWAN_CHANNEL_NONE { .idx = 0, .freq = 0, .drMin = 0, .drMax = 0, \
354 .dr = RADIOLIB_LORAWAN_DATA_RATE_UNUSED }
382#define RADIOLIB_LORAWAN_CHANNEL_SPAN_NONE { .numChannels = 0, .freqStart = 0, .freqStep = 0, .drMin = 0, .drMax = 0, .drJoinRequest = RADIOLIB_LORAWAN_DATA_RATE_UNUSED }
390#define RADIOLIB_DATARATE_NONE { .modem = RADIOLIB_MODEM_NONE, .dr = {.lora = {0, 0, 0}}, .pc = {.lora = { 8, 0, 0, 0}}}
442 uint8_t rx1DrTable[RADIOLIB_LORAWAN_CHANNEL_NUM_DATARATES][8];
490#define RADIOLIB_LORAWAN_NUM_SUPPORTED_BANDS (BandLast - BandEU868)
618 int16_t
beginOTAA(uint64_t joinEUI, uint64_t devEUI,
const uint8_t* nwkKey,
const uint8_t* appKey);
630 int16_t
beginABP(uint32_t addr,
const uint8_t* fNwkSIntKey,
const uint8_t* sNwkSIntKey,
const uint8_t* nwkSEncKey,
const uint8_t* appSKey);
664 int16_t
startMulticastSession(uint8_t cls, uint32_t mcAddr,
const uint8_t* mcAppSKey,
const uint8_t* mcNwkSKey,
665 uint32_t mcFCntMin = 0, uint32_t mcFCntMax = 0xFFFFFFFF, uint32_t mcFreq = 0,
666 uint8_t mcDr = RADIOLIB_LORAWAN_DATA_RATE_UNUSED);
685 #if defined(RADIOLIB_BUILD_ARDUINO)
757 virtual int16_t
sendReceive(
const uint8_t* dataUp,
size_t lenUp, uint8_t fPort, uint8_t* dataDown,
size_t* lenDown,
bool isConfirmed =
false,
LoRaWANEvent_t* eventUp = NULL,
LoRaWANEvent_t* eventDown = NULL);
796 int16_t
getMacDeviceTimeAns(uint32_t* timestamp, uint16_t* milliseconds,
bool returnUnix =
true);
832 void setADR(
bool enable =
true);
857 void setCSMA(
bool csmaEnabled, uint8_t maxChanges = 4, uint8_t backoffMax = 0, uint8_t difsSlots = 2);
1063#if !RADIOLIB_GODMODE
1070 uint8_t bufferPersist[RADIOLIB_LORAWAN_PERSISTENCE_BUF_SIZE] = { 0 };
1073 uint8_t bufferSession[RADIOLIB_LORAWAN_SESSION_BUF_SIZE] = { 0 };
1077 uint8_t bufferFrame[RADIOLIB_AES128_BLOCK_SIZE + RADIOLIB_LORAWAN_MAX_PHY_PAYLOAD_SIZE] = { 0 };
1078 uint8_t frameLength = 0;
1080 uint8_t fOptsUp[RADIOLIB_LORAWAN_FHDR_FOPTS_MAX_LEN] = { 0 };
1081 uint8_t fOptsDown[RADIOLIB_LORAWAN_FHDR_FOPTS_MAX_LEN] = { 0 };
1082 uint8_t fOptsUpLen = 0;
1083 uint8_t fOptsDownLen = 0;
1085 uint16_t lwMode = RADIOLIB_LORAWAN_MODE_NONE;
1086 uint8_t lwClass = RADIOLIB_LORAWAN_CLASS_A;
1087 uint8_t sessionStatus = RADIOLIB_LORAWAN_SESSION_NONE;
1089 uint64_t joinEUI = 0;
1090 uint64_t devEUI = 0;
1091 uint8_t nwkKey[RADIOLIB_AES128_KEY_SIZE] = { 0 };
1092 uint8_t appKey[RADIOLIB_AES128_KEY_SIZE] = { 0 };
1096 uint32_t devAddr = 0;
1097 uint8_t appSKey[RADIOLIB_AES128_KEY_SIZE] = { 0 };
1098 uint8_t fNwkSIntKey[RADIOLIB_AES128_KEY_SIZE] = { 0 };
1099 uint8_t sNwkSIntKey[RADIOLIB_AES128_KEY_SIZE] = { 0 };
1100 uint8_t nwkSEncKey[RADIOLIB_AES128_KEY_SIZE] = { 0 };
1101 uint8_t jSIntKey[RADIOLIB_AES128_KEY_SIZE] = { 0 };
1103 uint32_t keyCheckSum = 0;
1106 uint16_t devNonce = 0;
1107 uint32_t joinNonce = 0;
1110 uint8_t adrLimitExp = RADIOLIB_LORAWAN_ADR_ACK_LIMIT_EXP;
1111 uint8_t adrDelayExp = RADIOLIB_LORAWAN_ADR_ACK_DELAY_EXP;
1112 uint8_t nbTrans = 1;
1113 uint8_t txPowerSteps = 0;
1114 uint8_t txPowerMax = 0;
1115 uint32_t fCntUp = 0;
1116 uint32_t aFCntDown = 0;
1117 uint32_t nFCntDown = 0;
1118 uint32_t confFCntUp = RADIOLIB_LORAWAN_FCNT_NONE;
1119 uint32_t confFCntDown = RADIOLIB_LORAWAN_FCNT_NONE;
1120 uint32_t adrFCnt = 0;
1121 uint32_t rxAFCnt = 0;
1124 bool adrEnabled =
true;
1127 bool dutyCycleEnabled =
false;
1128 uint32_t dutyCycle = 0;
1131 uint16_t dwellTimeUp = 0;
1132 uint16_t dwellTimeDn = 0;
1135 bool uplinkScheduled =
false;
1140 MulticastGroup_t mcGroups[RADIOLIB_LORAWAN_MAX_NUM_MC_GROUPS];
1143 LoRaWANPackage_t packages[RADIOLIB_LORAWAN_NUM_RESERVED_PACKAGES];
1146 bool csmaEnabled =
false;
1149 uint8_t maxChanges = RADIOLIB_LORAWAN_MAX_CHANGES_DEFAULT;
1154 uint8_t backoffMax = RADIOLIB_LORAWAN_BACKOFF_MAX_DEFAULT;
1157 uint8_t difsSlots = RADIOLIB_LORAWAN_DIFS_DEFAULT;
1160 LoRaWANChannel_t dynamicChannels[2][RADIOLIB_LORAWAN_MAX_NUM_DYNAMIC_CHANNELS];
1163 uint16_t channelMasks[RADIOLIB_LORAWAN_MAX_NUM_FIXED_CHANNELS / 16] = { 0 };
1164 uint16_t channelFlags[RADIOLIB_LORAWAN_MAX_NUM_FIXED_CHANNELS / 16] = { 0 };
1167 LoRaWANChannel_t channels[4] = { RADIOLIB_LORAWAN_CHANNEL_NONE, RADIOLIB_LORAWAN_CHANNEL_NONE,
1168 RADIOLIB_LORAWAN_CHANNEL_NONE, RADIOLIB_LORAWAN_CHANNEL_NONE };
1173 RADIOLIB_LORAWAN_RECEIVE_DELAY_1_MS,
1174 RADIOLIB_LORAWAN_RECEIVE_DELAY_2_MS,
1177 uint32_t ledPins[4] = { RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC };
1180 uint8_t rx1DrOffset = 0;
1195 uint8_t battLevel = 0xFF;
1198 bool isMACPayload =
false;
1201 uint8_t subBand = 0;
1207 BufferCb_t storePersistenceBufferCb =
nullptr;
1208 BufferCb_t restorePersistenceBufferCb =
nullptr;
1213 void clearPersistence();
1216 void savePersistenceBuffer();
1219 int16_t loadPersistenceBuffer();
1222 void createSession();
1225 void saveSessionBuffer();
1228 int16_t loadSessionBuffer();
1231 void composeJoinRequest(uint8_t* joinRequestMsg);
1234 int16_t processJoinAccept(LoRaWANJoinEvent_t *joinEvent);
1237 void processCFList(
const uint8_t* cfList);
1240 int16_t isValidUplink(
size_t len, uint8_t fPort);
1247 void composeUplink(uint8_t* out, uint8_t lenIn, uint8_t fPort,
bool isConfirmed);
1250 void micUplink(uint8_t* inOut,
size_t lenInOut);
1253 int16_t transmitUplink(
const LoRaWANChannel_t* chnl, uint8_t* in, uint8_t len);
1256 int16_t receiveClassA(uint8_t dir,
const LoRaWANChannel_t* dlChannel, uint8_t window,
const RadioLibTime_t dlDelay,
RadioLibTime_t tReference);
1262 virtual int16_t receiveDownlink();
1265 int16_t checkDownlink(uint8_t window, uint8_t dr);
1268 int16_t parseDownlink(uint8_t* data,
size_t* len, uint8_t window, LoRaWANEvent_t* event = NULL);
1271 bool execMacCommand(uint8_t cid, uint8_t* optIn, uint8_t lenIn);
1272 bool execMacCommand(uint8_t cid, uint8_t* optIn, uint8_t lenIn, uint8_t* optOut);
1275 virtual bool derivedMacHandler(uint8_t cid, uint8_t* optIn, uint8_t lenIn, uint8_t* optOut);
1278 void preprocessMacLinkAdr(uint8_t* mPtr, uint8_t cLen, uint8_t* mAdrOpt);
1281 void postprocessMacLinkAdr(uint8_t* ack, uint8_t cLen);
1284 int16_t getMacCommand(uint8_t cid, LoRaWANMacCommand_t* cmd);
1287 virtual int16_t derivedMacFinder(uint8_t cid, LoRaWANMacCommand_t* cmd);
1292 virtual int16_t getMacLen(uint8_t cid, uint8_t* len, uint8_t dir,
bool inclusive =
false, uint8_t* payload = NULL);
1297 bool isPersistentMacCommand(uint8_t cid, uint8_t dir);
1300 int16_t pushMacCommand(uint8_t cid,
const uint8_t* cOcts, uint8_t* out, uint8_t* lenOut, uint8_t dir);
1303 int16_t getMacPayload(uint8_t cid,
const uint8_t* in, uint8_t lenIn, uint8_t* out, uint8_t dir);
1306 int16_t deleteMacCommand(uint8_t cid, uint8_t* inOut, uint8_t* lenInOut, uint8_t dir);
1309 void clearMacCommands(uint8_t* inOut, uint8_t* lenInOut, uint8_t dir);
1312 int16_t setPhyProperties(
const LoRaWANChannel_t* chnl, uint8_t dir, int8_t pwr,
size_t pre = 0);
1315 bool csmaChannelClear(uint8_t difs, uint8_t numBackoff);
1318 bool cadChannelClear();
1321 void enableDefaultChannels(
bool addDynamic =
false);
1325 bool calculateChannelFlags();
1328 int16_t selectChannels();
1331 uint32_t getMulticastFrequency();
1332 uint8_t getMulticastDatarate();
1333 bool isMulticastDevAddr(uint32_t devAddr, uint8_t* mcGroupId);
1336 uint32_t generateMIC(
const uint8_t* msg,
size_t len, uint8_t* key);
1340 bool verifyMIC(uint8_t* msg,
size_t len, uint8_t* key);
1343 void processAES(
const uint8_t* in,
size_t len, uint8_t* key, uint8_t* out, uint32_t addr, uint32_t fCnt, uint8_t dir, uint8_t ctrId,
bool counter);
1346 int16_t addPackage(uint8_t fPort,
bool isApp);
1352 template<
typename T>
1353 static T checkSum(
const uint8_t* buff,
size_t size);
1356 static int16_t checkBufferCommon(
const uint8_t *buffer, uint16_t size);
1359 template<
typename T>
1360 static T ntoh(
const uint8_t* buff,
size_t size = 0);
1363 template<
typename T>
1364 static void hton(uint8_t* buff, T val,
size_t size = 0);
1368T LoRaWANNode::ntoh(
const uint8_t* buff,
size_t size) {
1369 const uint8_t* buffPtr = buff;
1370 size_t targetSize =
sizeof(T);
1375 for(
size_t i = 0; i < targetSize; i++) {
1376 res |= (uint32_t)(*(buffPtr++)) << 8*i;
1382void LoRaWANNode::hton(uint8_t* buff, T val,
size_t size) {
1383 uint8_t* buffPtr = buff;
1384 size_t targetSize =
sizeof(T);
1388 for(
size_t i = 0; i < targetSize; i++) {
1389 *(buffPtr++) = val >> 8*i;
1394T LoRaWANNode::checkSum(
const uint8_t* buff,
size_t size) {
1396 for(
size_t i = 0; i < size; i +=
sizeof(T)) {
1398 for(
size_t j = 0; j <
sizeof(T); j++) {
1401 word |= buff[i + j];
void setPersistencePackage(uint8_t pIndex, const uint8_t *buff)
Set the persistent buffer for a certain package. NOTE: Do NOT use, for Packages only!
Definition LoRaWAN.cpp:3396
void clearSession()
Clear an active session. This requires the device to rejoin the network.
Definition LoRaWAN.cpp:374
virtual int16_t sendReceive(const char *strUp, uint8_t fPort, bool isConfirmed=false, LoRaWANEvent_t *eventUp=NULL, LoRaWANEvent_t *eventDown=NULL)
Send a message to the server and wait for a downlink during Rx1 and/or Rx2 window.
Definition LoRaWAN.cpp:85
void setSleepFunction(SleepCb_t cb)
Set custom delay/sleep function callback. If set, LoRaWAN node will call this function to wait for pe...
Definition LoRaWAN.cpp:3980
int16_t startMulticastSession(uint8_t cls, uint32_t mcAddr, const uint8_t *mcAppSKey, const uint8_t *mcNwkSKey, uint32_t mcFCntMin=0, uint32_t mcFCntMax=0xFFFFFFFF, uint32_t mcFreq=0, uint8_t mcDr=RADIOLIB_LORAWAN_DATA_RATE_UNUSED)
Start a Multicast session.
Definition LoRaWAN.cpp:1184
int16_t setDatarate(uint8_t drUp)
Set uplink datarate. This should not be used when ADR is enabled.
Definition LoRaWAN.cpp:3239
void scheduleTransmission(RadioLibTime_t tUplink)
Set the exact time a transmission should occur. Note: this is the internal clock time....
Definition LoRaWAN.cpp:3414
void setCallbackRestorePersistence(BufferCb_t cb)
Register a callback invoked by the library when the persistence buffer needs to be loaded....
Definition LoRaWAN.cpp:3988
uint8_t getClass()
Get the LoRaWAN class of this node.
Definition LoRaWAN.cpp:3431
RadioLibTime_t timeUntilUplink(bool seconds=false)
Calculate the time until next uplink is available under dutyCycle limits.
Definition LoRaWAN.cpp:3904
void setCSMA(bool csmaEnabled, uint8_t maxChanges=4, uint8_t backoffMax=0, uint8_t difsSlots=2)
Configures CSMA for LoRaWAN as per TR013, LoRa Alliance.
Definition LoRaWAN.cpp:3353
uint32_t getRxFCnt()
Returns the number of received application downlinks.
Definition LoRaWAN.cpp:3461
void setCallbackStorePersistence(BufferCb_t cb)
Register a callback invoked by the library when the persistence buffer needs to be saved....
Definition LoRaWAN.cpp:3984
const LoRaWANBand_t * getBand()
Get the LoRaWAN band used by this node.
Definition LoRaWAN.cpp:3423
void(* SleepCb_t)(RadioLibTime_t ms)
Callback to a user-provided sleep function.
Definition LoRaWAN.h:1013
void setDutyCycle(bool enable=true, RadioLibTime_t msPerHour=0)
Toggle adherence to dutyCycle limits to on or off.
Definition LoRaWAN.cpp:3327
RadioLibTime_t scanGuardC
Class C inverse Rx window padding in milliseconds. The Class C receive window should close early enou...
Definition LoRaWAN.h:1061
uint8_t getMulticastClass()
Request the currently configured class for Multicast.
Definition LoRaWAN.cpp:3820
int16_t beginABP(uint32_t addr, const uint8_t *fNwkSIntKey, const uint8_t *sNwkSIntKey, const uint8_t *nwkSEncKey, const uint8_t *appSKey)
Set the device credentials and activation configuration.
Definition LoRaWAN.cpp:732
int16_t setBand(const LoRaWANBand_t *band, uint8_t subBand=0)
Set LoRaWAN (sub)band. This cannot be done during an active session.
Definition LoRaWAN.cpp:3214
int16_t getDownlinkClassC(uint8_t *dataDown, size_t *lenDown, LoRaWANEvent_t *eventDown=NULL)
Check if there is an RxC downlink and parse it if available.
Definition LoRaWAN.cpp:2327
int16_t loadBuffers()
Trigger the registered buffer callbacks to restore persistence and session buffers.
Definition LoRaWAN.cpp:4000
void setDeviceStatus(uint8_t battLevel)
Set device status.
Definition LoRaWAN.cpp:3367
void getPersistencePackage(uint8_t pIndex, uint8_t *buff)
Get the persistent buffer for a certain package. NOTE: Do NOT use, for Packages only!
Definition LoRaWAN.cpp:3382
RadioLibTime_t dutyCycleInterval(RadioLibTime_t msPerHour, RadioLibTime_t airtime)
Calculate the minimum interval to adhere to a certain dutyCycle. This interval is based on the ToA of...
Definition LoRaWAN.cpp:3895
uint8_t getVersionMajor()
Get the LoRaWAN version of this node.
Definition LoRaWAN.cpp:3441
void removePackage(uint8_t fPort)
Disable a package that was previously added.
Definition LoRaWAN.cpp:4030
void setDwellTime(bool enable, RadioLibTime_t msPerUplink=0)
Set or disable uplink dwell time limitation; enabled by default if mandatory.
Definition LoRaWAN.cpp:3340
uint32_t getAFCntDown()
Returns the last application downlink's frame counter; also 0 if no application downlink occured yet.
Definition LoRaWAN.cpp:3457
RadioLibTime_t getLastToA()
Get the Time-on-air of the last uplink message (in milliseconds).
Definition LoRaWAN.cpp:3476
int16_t activateOTAA(LoRaWANJoinEvent_t *joinEvent=NULL)
Join network by restoring OTAA session or performing over-the-air activation. By this procedure,...
Definition LoRaWAN.cpp:952
virtual int16_t testPayloadLength(uint8_t len)
Test whether a certain payload length can be transmitted. Three options: NONE (ok),...
Definition LoRaWAN.cpp:3967
uint8_t getUnicastClass()
Get the LoRaWAN class of this node.
Definition LoRaWAN.cpp:3427
bool isActivated()
Whether there is an ongoing session active.
Definition LoRaWAN.cpp:1143
int16_t setTxPower(int8_t txPower)
Configure TX power of the radio module.
Definition LoRaWAN.cpp:3261
void(* BufferCb_t)(uint8_t *buf, size_t len)
Callback signature for buffer save/load operations.
Definition LoRaWAN.h:574
int16_t addNwkPackage(uint8_t fPort)
Enable a reserved FPort that can be used for network traffic.
Definition LoRaWAN.cpp:4016
uint32_t getNFCntDown()
Returns the last network downlink's frame counter; also 0 if no network downlink occured yet.
Definition LoRaWAN.cpp:3453
uint32_t getRxFCntMulticast(uint8_t mcGroupId)
Returns the number of received downlinks for a certain multicast group.
Definition LoRaWAN.cpp:3465
int16_t setClass(uint8_t cls)
Configure class (RADIOLIB_LORAWAN_CLASS_A or RADIOLIB_LORAWAN_CLASS_C).
Definition LoRaWAN.cpp:1147
LoRaWANNode(PhysicalLayer *phy, const LoRaWANBand_t *band, uint8_t subBand=0)
Default constructor.
Definition LoRaWAN.cpp:40
int16_t beginOTAA(uint64_t joinEUI, uint64_t devEUI, const uint8_t *nwkKey, const uint8_t *appKey)
Set the device credentials and activation configuration.
Definition LoRaWAN.cpp:702
virtual uint8_t getMaxPayloadLen()
Returns the maximum allowed uplink payload size given the current MAC state. Most importantly,...
Definition LoRaWAN.cpp:3929
int16_t activateABP()
Join network by restoring ABP session or performing over-the-air activation. In this procedure,...
Definition LoRaWAN.cpp:1049
void setCallbackRestoreSession(BufferCb_t cb)
Register a callback invoked by the library when the session buffer needs to be loaded....
Definition LoRaWAN.cpp:3996
int16_t addAppPackage(uint8_t fPort)
Enable a reserved FPort that can be used for application traffic.
Definition LoRaWAN.cpp:4012
bool stopMulticastSession(uint8_t id, bool addRxFCnt=false)
Stop an ongoing multicast session.
Definition LoRaWAN.cpp:1257
uint32_t getFCntUp()
Returns the last uplink's frame counter; also 0 if no uplink occured yet.
Definition LoRaWAN.cpp:3446
int16_t setRx2Dr(uint8_t dr)
Configure the Rx2 datarate for ABP mode. This should not be needed for LoRaWAN 1.1 as it is configure...
Definition LoRaWAN.cpp:3291
int16_t sendMacCommandReq(uint8_t cid)
Add a MAC command to the uplink queue. Only LinkCheck and DeviceTime are available to the user....
Definition LoRaWAN.cpp:3008
int16_t getMacLinkCheckAns(uint8_t *margin, uint8_t *gwCnt)
Returns the quality of connectivity after requesting a LinkCheck MAC command.
Definition LoRaWAN.cpp:3038
void setADR(bool enable=true)
Toggle ADR to on or off.
Definition LoRaWAN.cpp:3323
void setActivityLeds(const uint32_t pins[4])
Set pins for activity LEDs that will indicate when the radio is transmitting (Tx) or receiving (Rx).
Definition LoRaWAN.cpp:3371
int16_t getMacDeviceTimeAns(uint32_t *timestamp, uint16_t *milliseconds, bool returnUnix=true)
Returns the network time after requesting a DeviceTime MAC command. Note: the network returns the tim...
Definition LoRaWAN.cpp:3049
uint32_t getDevAddr()
Returns the DevAddr of the device, regardless of OTAA or ABP mode.
Definition LoRaWAN.cpp:3472
void setCallbackStoreSession(BufferCb_t cb)
Register a callback invoked by the library when the session buffer needs to be saved....
Definition LoRaWAN.cpp:3992
uint8_t getMacUplinkLen()
Get the length of the pending MAC uplink payload.
Definition LoRaWAN.cpp:3487
void syncClock()
Reset the internal timestamps after a clock synchronization.
Definition LoRaWAN.cpp:3922
RadioLibTime_t getLastDuration(bool seconds=false)
Get the duration of the last uplink/downlink cycle.
Definition LoRaWAN.cpp:3480
RadioLibTime_t scanGuardA
Class A Rx window padding in milliseconds. NOTE: If your clock has a stable drift,...
Definition LoRaWAN.h:1053
Provides common interface for protocols that run on LoRa/FSK modules, such as RTTY or LoRaWAN....
Definition PhysicalLayer.h:402
unsigned long RadioLibTime_t
Type used for durations in RadioLib.
Definition TypeDef.h:783
Structure to save information about LoRaWAN band.
Definition LoRaWAN.h:396
LoRaWANDataRate_t dataRates[RADIOLIB_LORAWAN_CHANNEL_NUM_DATARATES]
The corresponding datarates, bandwidths and coding rates for DR index.
Definition LoRaWAN.h:454
int8_t powerMax
Maximum allowed output power in this band in dBm.
Definition LoRaWAN.h:413
bool txParamSupported
Whether this band implements the MAC command TxParamSetupReq.
Definition LoRaWAN.h:428
LoRaWANChannel_t txAck[2]
Relay channels for ACK downlink.
Definition LoRaWAN.h:451
RadioLibTime_t dutyCycle
Number of milliseconds per hour of allowed Time-on-Air.
Definition LoRaWAN.h:419
RadioLibTime_t dwellTimeUp
Maximum dwell time per uplink message in milliseconds.
Definition LoRaWAN.h:422
LoRaWANChannel_t txWoR[2]
Relay channels for WoR uplink.
Definition LoRaWAN.h:448
uint32_t freqMin
Minimum allowed frequency (coded in 100 Hz steps).
Definition LoRaWAN.h:404
uint8_t payloadLenMax[RADIOLIB_LORAWAN_CHANNEL_NUM_DATARATES]
Array of allowed maximum application payload lengths for each data rate (N-value).
Definition LoRaWAN.h:410
LoRaWANChannel_t txFreqs[3]
A set of default uplink (TX) channels for dynamic bands.
Definition LoRaWAN.h:431
int8_t powerNumSteps
Number of power steps in this band.
Definition LoRaWAN.h:416
LoRaWANChannelSpan_t txSpans[2]
Default uplink (TX) channel spans for fixed bands, including Join-Request parameters.
Definition LoRaWAN.h:437
uint8_t bandNum
Identier for this band.
Definition LoRaWAN.h:398
uint32_t freqMax
Maximum allowed frequency (coded in 100 Hz steps).
Definition LoRaWAN.h:407
uint8_t bandType
Whether the channels are fixed per specification, or dynamically allocated through the network (plus ...
Definition LoRaWAN.h:401
LoRaWANChannel_t rx2
Backup channel for downlink (RX2) window.
Definition LoRaWAN.h:445
uint8_t numTxSpans
The number of TX channel spans for fixed bands.
Definition LoRaWAN.h:434
RadioLibTime_t dwellTimeDn
Maximum dwell time per downlink message in milliseconds.
Definition LoRaWAN.h:425
LoRaWANChannelSpan_t rx1Span
Default downlink (RX1) channel span for fixed bands.
Definition LoRaWAN.h:440
IDs of all currently supported bands.
Structure to save information about LoRaWAN channels. To save space, adjacent channels are saved in "...
Definition LoRaWAN.h:335
uint8_t dr
Datarate currently in use on this channel.
Definition LoRaWAN.h:349
uint32_t freq
The channel frequency (coded in 100 Hz steps).
Definition LoRaWAN.h:340
uint8_t idx
The channel number, as specified by defaults or the network.
Definition LoRaWAN.h:337
uint8_t drMin
Minimum allowed datarate for this channel.
Definition LoRaWAN.h:343
uint8_t drMax
Maximum allowed datarate for this channel (inclusive).
Definition LoRaWAN.h:346
Structure to save information about LoRaWAN channels. To save space, adjacent channels are saved in "...
Definition LoRaWAN.h:361
uint8_t drJoinRequest
Allowed data rates for a join request message.
Definition LoRaWAN.h:378
uint32_t freqStart
Center frequency of the first channel in span (coded in 100 Hz steps).
Definition LoRaWAN.h:366
uint8_t numChannels
Total number of channels in the span.
Definition LoRaWAN.h:363
uint8_t drMax
Maximum allowed datarate for all channels in this span (inclusive).
Definition LoRaWAN.h:375
uint32_t freqStep
Frequency step between adjacent channels (coded in 100 Hz steps).
Definition LoRaWAN.h:369
uint8_t drMin
Minimum allowed datarate for all channels in this span.
Definition LoRaWAN.h:372
Structure to save extra information about uplink/downlink event.
Definition LoRaWAN.h:514
bool confirmed
Whether the event is confirmed or not (e.g., confirmed uplink sent by user application).
Definition LoRaWAN.h:519
uint8_t fPort
Port number.
Definition LoRaWAN.h:541
uint32_t freq
Frequency in Hz.
Definition LoRaWAN.h:532
int16_t power
Transmit power in dBm for uplink, or RSSI for downlink.
Definition LoRaWAN.h:535
bool confirming
Whether the event is confirming a previous request (e.g., server downlink reply to confirmed uplink s...
Definition LoRaWAN.h:523
uint8_t datarate
Datarate.
Definition LoRaWAN.h:529
uint8_t dir
Event direction, one of RADIOLIB_LORAWAN_CHANNEL_DIR_*.
Definition LoRaWAN.h:516
uint8_t nbTrans
Number of times this uplink was transmitted (ADR).
Definition LoRaWAN.h:544
uint32_t fCnt
The appropriate frame counter - for different events, different frame counters will be reported!
Definition LoRaWAN.h:538
bool multicast
Multicast or unicast.
Definition LoRaWAN.h:547
uint8_t mcGroupId
Multicast Group ID if this was a multicast downlink.
Definition LoRaWAN.h:550
bool frmPending
Whether further downlink messages are pending on the server side.
Definition LoRaWAN.h:526
Structure to save extra information about activation event.
Definition LoRaWAN.h:499
bool newSession
Whether a new session was started.
Definition LoRaWAN.h:501
uint32_t joinNonce
The received Join-Request JoinNonce value.
Definition LoRaWAN.h:507
uint16_t devNonce
The transmitted Join-Request DevNonce value.
Definition LoRaWAN.h:504
MAC command specification structure.
Definition LoRaWAN.h:207
const uint8_t lenDn
Downlink payload length.
Definition LoRaWAN.h:212
const bool user
Whether this MAC command can be issued by the user or not.
Definition LoRaWAN.h:221
const uint8_t cid
Command ID.
Definition LoRaWAN.h:209
const uint8_t lenUp
Uplink payload length.
Definition LoRaWAN.h:215
const bool persist
Some commands must be resent until Class A downlink received.
Definition LoRaWAN.h:218
LoRaWAN Packages structure (for TSxxx documents).
Definition LoRaWAN.h:270
bool isAppPack
Whether the package runs through the Application layer.
Definition LoRaWAN.h:275
bool enabled
Whether the package is currently in use.
Definition LoRaWAN.h:272
uint8_t mcDr
The datarate used for the Multicast downlinks.
Definition LoRaWAN.h:255
uint32_t mcFreq
The frequency used for the Multicast downlinks (in Hz).
Definition LoRaWAN.h:252
uint32_t mcAddr
The Multicast address.
Definition LoRaWAN.h:234
uint8_t cls
The LoRaWAN Class used for this session (only C is supported).
Definition LoRaWAN.h:231
uint32_t mcFCntMax
The maximum allowed Multicast frame counter.
Definition LoRaWAN.h:246
uint32_t rxFCnt
The number of received Multicast frames in this group.
Definition LoRaWAN.h:249
uint32_t mcFCnt
The minimum (next) expected Multicast frame counter.
Definition LoRaWAN.h:243
uint8_t mcAppSKey[RADIOLIB_AES128_KEY_SIZE]
The Multicast payload session key.
Definition LoRaWAN.h:237
uint8_t mcNwkSKey[RADIOLIB_AES128_KEY_SIZE]
The Multicast network session key.
Definition LoRaWAN.h:240
Common data rate structure.
Definition PhysicalLayer.h:74
Common packet configuration structure.
Definition PhysicalLayer.h:119