diff --git a/_lo_ra_w_a_n_8h_source.html b/_lo_ra_w_a_n_8h_source.html index afb7d1f3..0a317e6b 100644 --- a/_lo_ra_w_a_n_8h_source.html +++ b/_lo_ra_w_a_n_8h_source.html @@ -148,768 +148,769 @@ $(document).ready(function(){initNavTree('_lo_ra_w_a_n_8h_source.html',''); init
60 #define RADIOLIB_LORAWAN_DATA_RATE_SF_9 (0x02 << 3) // 5 3 SF9
61 #define RADIOLIB_LORAWAN_DATA_RATE_SF_8 (0x01 << 3) // 5 3 SF8
62 #define RADIOLIB_LORAWAN_DATA_RATE_SF_7 (0x00 << 3) // 5 3 SF7
-
63 #define RADIOLIB_LORAWAN_DATA_RATE_BW (0x03 << 1) // 2 1 bandwith mask
+
63 #define RADIOLIB_LORAWAN_DATA_RATE_BW (0x03 << 1) // 2 1 bandwidth mask
64 #define RADIOLIB_LORAWAN_DATA_RATE_BW_125_KHZ (0x00 << 1) // 2 1 125 kHz
65 #define RADIOLIB_LORAWAN_DATA_RATE_BW_250_KHZ (0x01 << 1) // 2 1 250 kHz
66 #define RADIOLIB_LORAWAN_DATA_RATE_BW_500_KHZ (0x02 << 1) // 2 1 LoRa bandwidth: 500 kHz
67 #define RADIOLIB_LORAWAN_DATA_RATE_BW_137_KHZ (0x00 << 1) // 2 1 137 kHz
68 #define RADIOLIB_LORAWAN_DATA_RATE_BW_336_KHZ (0x01 << 1) // 2 1 336 kHz
69 #define RADIOLIB_LORAWAN_DATA_RATE_BW_1523_KHZ (0x02 << 1) // 2 1 LR-FHSS bandwidth: 1523 kHz
-
70 #define RADIOLIB_LORAWAN_DATA_RATE_CR_1_3 (0x00 << 0) // 0 0 LR-FHSS coding rate: 1/3
-
71 #define RADIOLIB_LORAWAN_DATA_RATE_CR_2_3 (0x01 << 0) // 0 0 2/3
-
72 #define RADIOLIB_LORAWAN_DATA_RATE_UNUSED (0xFF << 0) // 7 0 unused data rate
-
73 
-
74 // channels and channel plans
-
75 #define RADIOLIB_LORAWAN_UPLINK (0x00 << 0)
-
76 #define RADIOLIB_LORAWAN_DOWNLINK (0x01 << 0)
-
77 #define RADIOLIB_LORAWAN_DIR_RX2 (0x02 << 0)
-
78 #define RADIOLIB_LORAWAN_BAND_DYNAMIC (0)
-
79 #define RADIOLIB_LORAWAN_BAND_FIXED (1)
-
80 #define RADIOLIB_LORAWAN_CHANNEL_NUM_DATARATES (15)
-
81 #define RADIOLIB_LORAWAN_CHANNEL_INDEX_NONE (0xFF >> 0)
-
82 
-
83 // recommended default settings
-
84 #define RADIOLIB_LORAWAN_RECEIVE_DELAY_1_MS (1000)
-
85 #define RADIOLIB_LORAWAN_RECEIVE_DELAY_2_MS ((RADIOLIB_LORAWAN_RECEIVE_DELAY_1_MS) + 1000)
-
86 #define RADIOLIB_LORAWAN_RX1_DR_OFFSET (0)
-
87 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_DELAY_1_MS (5000)
-
88 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_DELAY_2_MS (6000)
-
89 #define RADIOLIB_LORAWAN_MAX_FCNT_GAP (16384)
-
90 #define RADIOLIB_LORAWAN_ADR_ACK_LIMIT_EXP (0x06)
-
91 #define RADIOLIB_LORAWAN_ADR_ACK_DELAY_EXP (0x05)
-
92 #define RADIOLIB_LORAWAN_RETRANSMIT_TIMEOUT_MIN_MS (1000)
-
93 #define RADIOLIB_LORAWAN_RETRANSMIT_TIMEOUT_MAX_MS (3000)
-
94 #define RADIOLIB_LORAWAN_POWER_STEP_SIZE_DBM (-2)
-
95 #define RADIOLIB_LORAWAN_REJOIN_MAX_COUNT_N (10) // send rejoin request 16384 uplinks
-
96 #define RADIOLIB_LORAWAN_REJOIN_MAX_TIME_N (15) // once every year, not actually implemented
-
97 
-
98 // join request message layout
-
99 #define RADIOLIB_LORAWAN_JOIN_REQUEST_LEN (23)
-
100 #define RADIOLIB_LORAWAN_JOIN_REQUEST_JOIN_EUI_POS (1)
-
101 #define RADIOLIB_LORAWAN_JOIN_REQUEST_DEV_EUI_POS (9)
-
102 #define RADIOLIB_LORAWAN_JOIN_REQUEST_DEV_NONCE_POS (17)
-
103 #define RADIOLIB_LORAWAN_JOIN_REQUEST_TYPE (0xFF)
-
104 #define RADIOLIB_LORAWAN_JOIN_REQUEST_TYPE_0 (0x00)
-
105 #define RADIOLIB_LORAWAN_JOIN_REQUEST_TYPE_1 (0x01)
-
106 #define RADIOLIB_LORAWAN_JOIN_REQUEST_TYPE_2 (0x02)
-
107 
-
108 // join accept message layout
-
109 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_MAX_LEN (33)
-
110 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_JOIN_NONCE_POS (1)
-
111 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_HOME_NET_ID_POS (4)
-
112 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_DEV_ADDR_POS (7)
-
113 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_DL_SETTINGS_POS (11)
-
114 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_RX_DELAY_POS (12)
-
115 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_CFLIST_POS (13)
-
116 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_CFLIST_LEN (16)
-
117 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_CFLIST_TYPE_POS (RADIOLIB_LORAWAN_JOIN_ACCEPT_CFLIST_POS + RADIOLIB_LORAWAN_JOIN_ACCEPT_CFLIST_LEN - 1)
-
118 
-
119 // join accept key derivation layout
-
120 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_AES_JOIN_NONCE_POS (1) // regular keys
-
121 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_AES_JOIN_EUI_POS (4)
-
122 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_AES_DEV_NONCE_POS (12)
-
123 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_AES_DEV_ADDR_POS (1) // relay keys
-
124 
-
125 // join accept message variables
-
126 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_R_1_0 (0x00 << 7) // 7 7 LoRaWAN revision: 1.0
-
127 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_R_1_1 (0x01 << 7) // 7 7 1.1
-
128 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_F_NWK_S_INT_KEY (0x01)
-
129 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_APP_S_KEY (0x02)
-
130 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_S_NWK_S_INT_KEY (0x03)
-
131 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_NWK_S_ENC_KEY (0x04)
-
132 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_JS_ENC_KEY (0x05)
-
133 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_JS_INT_KEY (0x06)
-
134 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_ROOT_WOR_S_KEY (0x01)
-
135 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_WOR_S_INT_KEY (0x01)
-
136 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_WOR_S_ENC_KEY (0x02)
-
137 
-
138 // frame header layout
-
139 #define RADIOLIB_LORAWAN_FHDR_LEN_START_OFFS (16)
-
140 #define RADIOLIB_LORAWAN_FHDR_DEV_ADDR_POS (RADIOLIB_LORAWAN_FHDR_LEN_START_OFFS + 1)
-
141 #define RADIOLIB_LORAWAN_FHDR_FCTRL_POS (RADIOLIB_LORAWAN_FHDR_LEN_START_OFFS + 5)
-
142 #define RADIOLIB_LORAWAN_FHDR_FCNT_POS (RADIOLIB_LORAWAN_FHDR_LEN_START_OFFS + 6)
-
143 #define RADIOLIB_LORAWAN_FHDR_FOPTS_POS (RADIOLIB_LORAWAN_FHDR_LEN_START_OFFS + 8)
-
144 #define RADIOLIB_LORAWAN_FHDR_FOPTS_LEN_MASK (0x0F)
-
145 #define RADIOLIB_LORAWAN_FHDR_FOPTS_MAX_LEN (15)
-
146 #define RADIOLIB_LORAWAN_FHDR_FPORT_POS(FOPTS) (RADIOLIB_LORAWAN_FHDR_LEN_START_OFFS + 8 + (FOPTS))
-
147 #define RADIOLIB_LORAWAN_FRAME_PAYLOAD_POS(FOPTS) (RADIOLIB_LORAWAN_FHDR_LEN_START_OFFS + 9 + (FOPTS))
-
148 #define RADIOLIB_LORAWAN_FRAME_LEN(PAYLOAD, FOPTS) (16 + 13 + (PAYLOAD) + (FOPTS))
-
149 
-
150 // payload encryption/MIC blocks common layout
-
151 #define RADIOLIB_LORAWAN_BLOCK_MAGIC_POS (0)
-
152 #define RADIOLIB_LORAWAN_BLOCK_CONF_FCNT_POS (1)
-
153 #define RADIOLIB_LORAWAN_BLOCK_DIR_POS (5)
-
154 #define RADIOLIB_LORAWAN_BLOCK_DEV_ADDR_POS (6)
-
155 #define RADIOLIB_LORAWAN_BLOCK_FCNT_POS (10)
-
156 
-
157 // payload encryption block layout
-
158 #define RADIOLIB_LORAWAN_ENC_BLOCK_MAGIC (0x01)
-
159 #define RADIOLIB_LORAWAN_ENC_BLOCK_COUNTER_ID_POS (4)
-
160 #define RADIOLIB_LORAWAN_ENC_BLOCK_COUNTER_POS (15)
-
161 
-
162 // payload MIC blocks layout
-
163 #define RADIOLIB_LORAWAN_MIC_BLOCK_MAGIC (0x49)
-
164 #define RADIOLIB_LORAWAN_MIC_BLOCK_LEN_POS (15)
-
165 #define RADIOLIB_LORAWAN_MIC_DATA_RATE_POS (3)
-
166 #define RADIOLIB_LORAWAN_MIC_CH_INDEX_POS (4)
-
167 
-
168 // maximum allowed dwell time on bands that implement dwell time limitations
-
169 #define RADIOLIB_LORAWAN_DWELL_TIME (400)
-
170 
-
171 // unused frame counter value
-
172 #define RADIOLIB_LORAWAN_FCNT_NONE (0xFFFFFFFF)
-
173 
-
174 // TR013 CSMA recommended values
-
175 #define RADIOLIB_LORAWAN_DIFS_DEFAULT (2)
-
176 #define RADIOLIB_LORAWAN_BACKOFF_MAX_DEFAULT (6)
-
177 #define RADIOLIB_LORAWAN_MAX_CHANGES_DEFAULT (4)
-
178 
-
179 // MAC commands
-
180 #define RADIOLIB_LORAWAN_NUM_MAC_COMMANDS (23)
-
181 
-
182 #define RADIOLIB_LORAWAN_MAC_RESET (0x01)
-
183 #define RADIOLIB_LORAWAN_MAC_LINK_CHECK (0x02)
-
184 #define RADIOLIB_LORAWAN_MAC_LINK_ADR (0x03)
-
185 #define RADIOLIB_LORAWAN_MAC_DUTY_CYCLE (0x04)
-
186 #define RADIOLIB_LORAWAN_MAC_RX_PARAM_SETUP (0x05)
-
187 #define RADIOLIB_LORAWAN_MAC_DEV_STATUS (0x06)
-
188 #define RADIOLIB_LORAWAN_MAC_NEW_CHANNEL (0x07)
-
189 #define RADIOLIB_LORAWAN_MAC_RX_TIMING_SETUP (0x08)
-
190 #define RADIOLIB_LORAWAN_MAC_TX_PARAM_SETUP (0x09)
-
191 #define RADIOLIB_LORAWAN_MAC_DL_CHANNEL (0x0A)
-
192 #define RADIOLIB_LORAWAN_MAC_REKEY (0x0B)
-
193 #define RADIOLIB_LORAWAN_MAC_ADR_PARAM_SETUP (0x0C)
-
194 #define RADIOLIB_LORAWAN_MAC_DEVICE_TIME (0x0D)
-
195 #define RADIOLIB_LORAWAN_MAC_FORCE_REJOIN (0x0E)
-
196 #define RADIOLIB_LORAWAN_MAC_REJOIN_PARAM_SETUP (0x0F)
-
197 #define RADIOLIB_LORAWAN_MAC_PROPRIETARY (0x80)
-
198 
-
199 // the length of internal MAC command queue - hopefully this is enough for most use cases
-
200 #define RADIOLIB_LORAWAN_MAC_COMMAND_QUEUE_SIZE (9)
-
201 
-
202 // the maximum number of simultaneously available channels
-
203 #define RADIOLIB_LORAWAN_NUM_AVAILABLE_CHANNELS (16)
-
204 
-
205 // maximum MAC command sizes
-
206 #define RADIOLIB_LORAWAN_MAX_MAC_COMMAND_LEN_DOWN (5)
-
207 #define RADIOLIB_LORAWAN_MAX_MAC_COMMAND_LEN_UP (2)
-
208 #define RADIOLIB_LORAWAN_MAX_NUM_ADR_COMMANDS (8)
-
209 
-
214 struct LoRaWANMacCommand_t {
-
216  const uint8_t cid;
-
217 
-
219  const uint8_t lenDn;
-
220 
-
222  const uint8_t lenUp;
-
223 
-
225  const bool persist;
-
226 
-
228  const bool user;
-
229 };
-
230 
-
231 #define RADIOLIB_LORAWAN_MAC_COMMAND_NONE { .cid = 0, .lenDn = 0, .lenUp = 0, .persist = false, .user = false }
-
232 
-
233 constexpr LoRaWANMacCommand_t MacTable[RADIOLIB_LORAWAN_NUM_MAC_COMMANDS] = {
-
234  { RADIOLIB_LORAWAN_MAC_RESET, 1, 1, false, false },
-
235  { RADIOLIB_LORAWAN_MAC_LINK_CHECK, 2, 0, false, true },
-
236  { RADIOLIB_LORAWAN_MAC_LINK_ADR, 4, 1, false, false },
-
237  { RADIOLIB_LORAWAN_MAC_DUTY_CYCLE, 1, 0, false, false },
-
238  { RADIOLIB_LORAWAN_MAC_RX_PARAM_SETUP, 4, 1, true, false },
-
239  { RADIOLIB_LORAWAN_MAC_DEV_STATUS, 0, 2, false, false },
-
240  { RADIOLIB_LORAWAN_MAC_NEW_CHANNEL, 5, 1, false, false },
-
241  { RADIOLIB_LORAWAN_MAC_RX_TIMING_SETUP, 1, 0, true, false },
-
242  { RADIOLIB_LORAWAN_MAC_TX_PARAM_SETUP, 1, 0, true, false },
-
243  { RADIOLIB_LORAWAN_MAC_DL_CHANNEL, 4, 1, true, false },
-
244  { RADIOLIB_LORAWAN_MAC_REKEY, 1, 1, false, false },
-
245  { RADIOLIB_LORAWAN_MAC_ADR_PARAM_SETUP, 1, 0, false, false },
-
246  { RADIOLIB_LORAWAN_MAC_DEVICE_TIME, 5, 0, false, true },
-
247  { RADIOLIB_LORAWAN_MAC_FORCE_REJOIN, 2, 0, false, false },
-
248  { RADIOLIB_LORAWAN_MAC_REJOIN_PARAM_SETUP, 1, 1, false, false },
-
249  { RADIOLIB_LORAWAN_MAC_PROPRIETARY, 5, 0, false, true },
-
250 };
-
251 
-
252 #define RADIOLIB_LORAWAN_NONCES_VERSION_VAL (0x0001)
-
253 
-
254 enum LoRaWANSchemeBase_t {
-
255  RADIOLIB_LORAWAN_NONCES_START = 0x00,
-
256  RADIOLIB_LORAWAN_NONCES_VERSION = RADIOLIB_LORAWAN_NONCES_START, // 2 bytes
-
257  RADIOLIB_LORAWAN_NONCES_MODE = RADIOLIB_LORAWAN_NONCES_VERSION + sizeof(uint16_t), // 2 bytes
-
258  RADIOLIB_LORAWAN_NONCES_CLASS = RADIOLIB_LORAWAN_NONCES_MODE + sizeof(uint16_t), // 1 byte
-
259  RADIOLIB_LORAWAN_NONCES_PLAN = RADIOLIB_LORAWAN_NONCES_CLASS + sizeof(uint8_t), // 1 byte
-
260  RADIOLIB_LORAWAN_NONCES_CHECKSUM = RADIOLIB_LORAWAN_NONCES_PLAN + sizeof(uint8_t), // 2 bytes
-
261  RADIOLIB_LORAWAN_NONCES_DEV_NONCE = RADIOLIB_LORAWAN_NONCES_CHECKSUM + sizeof(uint16_t), // 2 bytes
-
262  RADIOLIB_LORAWAN_NONCES_JOIN_NONCE = RADIOLIB_LORAWAN_NONCES_DEV_NONCE + sizeof(uint16_t), // 3 bytes
-
263  RADIOLIB_LORAWAN_NONCES_ACTIVE = RADIOLIB_LORAWAN_NONCES_JOIN_NONCE + 3, // 1 byte
-
264  RADIOLIB_LORAWAN_NONCES_SIGNATURE = RADIOLIB_LORAWAN_NONCES_ACTIVE + sizeof(uint8_t), // 2 bytes
-
265  RADIOLIB_LORAWAN_NONCES_BUF_SIZE = RADIOLIB_LORAWAN_NONCES_SIGNATURE + sizeof(uint16_t) // Nonces buffer size
-
266 };
-
267 
-
268 enum LoRaWANSchemeSession_t {
-
269  RADIOLIB_LORAWAN_SESSION_START = 0x00,
-
270  RADIOLIB_LORAWAN_SESSION_NWK_SENC_KEY = RADIOLIB_LORAWAN_SESSION_START, // 16 bytes
-
271  RADIOLIB_LORAWAN_SESSION_APP_SKEY = RADIOLIB_LORAWAN_SESSION_NWK_SENC_KEY + RADIOLIB_AES128_KEY_SIZE, // 16 bytes
-
272  RADIOLIB_LORAWAN_SESSION_FNWK_SINT_KEY = RADIOLIB_LORAWAN_SESSION_APP_SKEY + RADIOLIB_AES128_KEY_SIZE, // 16 bytes
-
273  RADIOLIB_LORAWAN_SESSION_SNWK_SINT_KEY = RADIOLIB_LORAWAN_SESSION_FNWK_SINT_KEY + RADIOLIB_AES128_KEY_SIZE, // 16 bytes
-
274  RADIOLIB_LORAWAN_SESSION_DEV_ADDR = RADIOLIB_LORAWAN_SESSION_SNWK_SINT_KEY + RADIOLIB_AES128_KEY_SIZE, // 4 bytes
-
275  RADIOLIB_LORAWAN_SESSION_NONCES_SIGNATURE = RADIOLIB_LORAWAN_SESSION_DEV_ADDR + sizeof(uint32_t), // 2 bytes
-
276  RADIOLIB_LORAWAN_SESSION_FCNT_UP = RADIOLIB_LORAWAN_SESSION_NONCES_SIGNATURE + 2, // 4 bytes
-
277  RADIOLIB_LORAWAN_SESSION_N_FCNT_DOWN = RADIOLIB_LORAWAN_SESSION_FCNT_UP + sizeof(uint32_t), // 4 bytes
-
278  RADIOLIB_LORAWAN_SESSION_A_FCNT_DOWN = RADIOLIB_LORAWAN_SESSION_N_FCNT_DOWN + sizeof(uint32_t), // 4 bytes
-
279  RADIOLIB_LORAWAN_SESSION_ADR_FCNT = RADIOLIB_LORAWAN_SESSION_A_FCNT_DOWN + sizeof(uint32_t), // 4 bytes
-
280  RADIOLIB_LORAWAN_SESSION_CONF_FCNT_UP = RADIOLIB_LORAWAN_SESSION_ADR_FCNT + sizeof(uint32_t), // 4 bytes
-
281  RADIOLIB_LORAWAN_SESSION_CONF_FCNT_DOWN = RADIOLIB_LORAWAN_SESSION_CONF_FCNT_UP + sizeof(uint32_t), // 4 bytes
-
282  RADIOLIB_LORAWAN_SESSION_RJ_COUNT0 = RADIOLIB_LORAWAN_SESSION_CONF_FCNT_DOWN + sizeof(uint32_t), // 2 bytes
-
283  RADIOLIB_LORAWAN_SESSION_RJ_COUNT1 = RADIOLIB_LORAWAN_SESSION_RJ_COUNT0 + sizeof(uint16_t), // 2 bytes
-
284  RADIOLIB_LORAWAN_SESSION_HOMENET_ID = RADIOLIB_LORAWAN_SESSION_RJ_COUNT1 + sizeof(uint16_t), // 4 bytes
-
285  RADIOLIB_LORAWAN_SESSION_VERSION = RADIOLIB_LORAWAN_SESSION_HOMENET_ID + sizeof(uint32_t), // 1 byte
-
286  RADIOLIB_LORAWAN_SESSION_LINK_ADR = RADIOLIB_LORAWAN_SESSION_VERSION + sizeof(uint8_t), // 14 bytes
-
287  RADIOLIB_LORAWAN_SESSION_DUTY_CYCLE = RADIOLIB_LORAWAN_SESSION_LINK_ADR + 14, // 1 byte
-
288  RADIOLIB_LORAWAN_SESSION_RX_PARAM_SETUP = RADIOLIB_LORAWAN_SESSION_DUTY_CYCLE + 1, // 4 bytes
-
289  RADIOLIB_LORAWAN_SESSION_RX_TIMING_SETUP = RADIOLIB_LORAWAN_SESSION_RX_PARAM_SETUP + 4, // 1 byte
-
290  RADIOLIB_LORAWAN_SESSION_TX_PARAM_SETUP = RADIOLIB_LORAWAN_SESSION_RX_TIMING_SETUP + 1, // 1 byte
-
291  RADIOLIB_LORAWAN_SESSION_ADR_PARAM_SETUP = RADIOLIB_LORAWAN_SESSION_TX_PARAM_SETUP + 1, // 1 byte
-
292  RADIOLIB_LORAWAN_SESSION_REJOIN_PARAM_SETUP = RADIOLIB_LORAWAN_SESSION_ADR_PARAM_SETUP + 1, // 1 byte
-
293  RADIOLIB_LORAWAN_SESSION_BEACON_FREQ = RADIOLIB_LORAWAN_SESSION_REJOIN_PARAM_SETUP + 1, // 3 bytes
-
294  RADIOLIB_LORAWAN_SESSION_PING_SLOT_CHANNEL = RADIOLIB_LORAWAN_SESSION_BEACON_FREQ + 3, // 4 bytes
-
295  RADIOLIB_LORAWAN_SESSION_PERIODICITY = RADIOLIB_LORAWAN_SESSION_PING_SLOT_CHANNEL + 4, // 1 byte
-
296  RADIOLIB_LORAWAN_SESSION_LAST_TIME = RADIOLIB_LORAWAN_SESSION_PERIODICITY + 1, // 4 bytes
-
297  RADIOLIB_LORAWAN_SESSION_UL_CHANNELS = RADIOLIB_LORAWAN_SESSION_LAST_TIME + 4, // 16*5 bytes
-
298  RADIOLIB_LORAWAN_SESSION_DL_CHANNELS = RADIOLIB_LORAWAN_SESSION_UL_CHANNELS + RADIOLIB_LORAWAN_NUM_AVAILABLE_CHANNELS*5, // 16*4 bytes
-
299  RADIOLIB_LORAWAN_SESSION_AVAILABLE_CHANNELS = RADIOLIB_LORAWAN_SESSION_DL_CHANNELS + RADIOLIB_LORAWAN_NUM_AVAILABLE_CHANNELS*4, // 2 bytes
-
300  RADIOLIB_LORAWAN_SESSION_MAC_QUEUE = RADIOLIB_LORAWAN_SESSION_AVAILABLE_CHANNELS + sizeof(uint16_t), // 15 bytes
-
301  RADIOLIB_LORAWAN_SESSION_MAC_QUEUE_LEN = RADIOLIB_LORAWAN_SESSION_MAC_QUEUE + RADIOLIB_LORAWAN_FHDR_FOPTS_MAX_LEN, // 1 byte
-
302  RADIOLIB_LORAWAN_SESSION_SIGNATURE = RADIOLIB_LORAWAN_SESSION_MAC_QUEUE_LEN + sizeof(uint8_t), // 2 bytes
-
303  RADIOLIB_LORAWAN_SESSION_BUF_SIZE = RADIOLIB_LORAWAN_SESSION_SIGNATURE + sizeof(uint16_t) // Session buffer size
-
304 };
-
305 
-
311 struct LoRaWANChannel_t {
-
313  bool enabled;
-
314 
-
316  uint8_t idx;
-
317 
-
319  uint32_t freq;
-
320 
-
322  uint8_t drMin;
-
323 
-
325  uint8_t drMax;
-
326 
-
328  uint8_t dr;
-
329 
-
331  bool available;
-
332 };
-
333 
-
334 // alias for unused channel
-
335 #define RADIOLIB_LORAWAN_CHANNEL_NONE { .enabled = false, .idx = RADIOLIB_LORAWAN_CHANNEL_INDEX_NONE, .freq = 0, \
-
336  .drMin = 0, .drMax = 0, .dr = RADIOLIB_LORAWAN_DATA_RATE_UNUSED, .available = false }
-
337 
-
343 struct LoRaWANChannelSpan_t {
-
345  uint8_t numChannels;
-
346 
-
348  uint32_t freqStart;
-
349 
-
351  uint32_t freqStep;
-
352 
-
354  uint8_t drMin;
-
355 
-
357  uint8_t drMax;
-
358 
-
360  uint8_t drJoinRequest;
-
361 };
-
362 
-
363 // alias for unused channel span
-
364 #define RADIOLIB_LORAWAN_CHANNEL_SPAN_NONE { .numChannels = 0, .freqStart = 0, .freqStep = 0, .drMin = 0, .drMax = 0, .drJoinRequest = RADIOLIB_LORAWAN_DATA_RATE_UNUSED }
-
365 
-
370 struct LoRaWANBand_t {
-
372  uint8_t bandNum;
-
373 
-
375  uint8_t bandType;
-
376 
-
378  uint32_t freqMin;
-
379 
-
381  uint32_t freqMax;
-
382 
-
384  uint8_t payloadLenMax[RADIOLIB_LORAWAN_CHANNEL_NUM_DATARATES];
-
385 
-
387  int8_t powerMax;
-
388 
-
390  int8_t powerNumSteps;
-
391 
-
393  RadioLibTime_t dutyCycle;
-
394 
-
396  RadioLibTime_t dwellTimeUp;
-
397 
-
399  RadioLibTime_t dwellTimeDn;
-
400 
-
402  bool txParamSupported;
-
403 
-
405  LoRaWANChannel_t txFreqs[3];
-
406 
-
408  LoRaWANChannel_t txJoinReq[3];
-
409 
-
411  uint8_t numTxSpans;
-
412 
-
414  LoRaWANChannelSpan_t txSpans[2];
-
415 
-
417  LoRaWANChannelSpan_t rx1Span;
-
418 
-
419  uint8_t rx1DrTable[RADIOLIB_LORAWAN_CHANNEL_NUM_DATARATES][8];
-
420 
-
422  LoRaWANChannel_t rx2;
-
423 
-
425  LoRaWANChannel_t txWoR[2];
-
426 
-
428  LoRaWANChannel_t txAck[2];
-
429 
-
431  uint8_t dataRates[RADIOLIB_LORAWAN_CHANNEL_NUM_DATARATES];
-
432 };
-
433 
-
434 // supported bands
-
435 extern const LoRaWANBand_t EU868;
-
436 extern const LoRaWANBand_t US915;
-
437 extern const LoRaWANBand_t EU433;
-
438 extern const LoRaWANBand_t AU915;
-
439 extern const LoRaWANBand_t CN500;
-
440 extern const LoRaWANBand_t AS923;
-
441 extern const LoRaWANBand_t AS923_2;
-
442 extern const LoRaWANBand_t AS923_3;
-
443 extern const LoRaWANBand_t AS923_4;
-
444 extern const LoRaWANBand_t KR920;
-
445 extern const LoRaWANBand_t IN865;
-
446 
-
451 enum LoRaWANBandNum_t {
-
452  BandEU868,
-
453  BandUS915,
-
454  BandEU433,
-
455  BandAU915,
-
456  BandCN500,
-
457  BandAS923,
-
458  BandAS923_2,
-
459  BandAS923_3,
-
460  BandAS923_4,
-
461  BandKR920,
-
462  BandIN865,
-
463  BandLast
-
464 };
-
465 
-
466 // provide easy access to the number of currently supported bands
-
467 #define RADIOLIB_LORAWAN_NUM_SUPPORTED_BANDS (BandLast - BandEU868)
-
468 
-
469 // array of currently supported bands
-
470 extern const LoRaWANBand_t* LoRaWANBands[];
-
471 
-
476 struct LoRaWANJoinEvent_t {
-
478  bool newSession = false;
-
479 
-
481  uint16_t devNonce = 0;
-
482 
-
484  uint32_t joinNonce = 0;
-
485 };
-
486 
-
491 struct LoRaWANEvent_t {
-
493  uint8_t dir;
-
494 
-
496  bool confirmed;
-
497 
-
500  bool confirming;
-
501 
-
503  bool frmPending;
-
504 
-
506  uint8_t datarate;
-
507 
-
509  float freq;
-
510 
-
512  int16_t power;
-
513 
-
515  uint32_t fCnt;
-
516 
-
518  uint8_t fPort;
-
519 
-
521  uint8_t nbTrans;
-
522 };
-
523 
-
528 class LoRaWANNode {
-
529  public:
-
530 
-
537  LoRaWANNode(PhysicalLayer* phy, const LoRaWANBand_t* band, uint8_t subBand = 0);
-
538 
-
543  uint8_t* getBufferNonces();
-
544 
-
550  int16_t setBufferNonces(uint8_t* persistentBuffer);
-
551 
-
555  void clearSession();
-
556 
-
561  uint8_t* getBufferSession();
-
562 
-
568  int16_t setBufferSession(uint8_t* persistentBuffer);
-
569 
-
578  int16_t beginOTAA(uint64_t joinEUI, uint64_t devEUI, uint8_t* nwkKey, uint8_t* appKey);
-
579 
-
590  int16_t beginABP(uint32_t addr, uint8_t* fNwkSIntKey, uint8_t* sNwkSIntKey, uint8_t* nwkSEncKey, uint8_t* appSKey);
-
591 
-
598  virtual int16_t activateOTAA(uint8_t initialDr = RADIOLIB_LORAWAN_DATA_RATE_UNUSED, LoRaWANJoinEvent_t *joinEvent = NULL);
-
599 
-
606  virtual int16_t activateABP(uint8_t initialDr = RADIOLIB_LORAWAN_DATA_RATE_UNUSED);
-
607 
-
609  bool isActivated();
-
610 
-
611  #if defined(RADIOLIB_BUILD_ARDUINO)
-
624  virtual int16_t sendReceive(String& strUp, uint8_t fPort, String& strDown, bool isConfirmed = false, LoRaWANEvent_t* eventUp = NULL, LoRaWANEvent_t* eventDown = NULL);
-
625  #endif
-
626 
-
638  virtual int16_t sendReceive(const char* strUp, uint8_t fPort, bool isConfirmed = false, LoRaWANEvent_t* eventUp = NULL, LoRaWANEvent_t* eventDown = NULL);
-
639 
-
653  virtual int16_t sendReceive(const char* strUp, uint8_t fPort, uint8_t* dataDown, size_t* lenDown, bool isConfirmed = false, LoRaWANEvent_t* eventUp = NULL, LoRaWANEvent_t* eventDown = NULL);
-
654 
-
667  virtual int16_t sendReceive(uint8_t* dataUp, size_t lenUp, uint8_t fPort = 1, bool isConfirmed = false, LoRaWANEvent_t* eventUp = NULL, LoRaWANEvent_t* eventDown = NULL);
-
668 
-
683  virtual int16_t sendReceive(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);
-
684 
-
692  int16_t sendMacCommandReq(uint8_t cid);
-
693 
-
702  int16_t getMacLinkCheckAns(uint8_t* margin, uint8_t* gwCnt);
-
703 
-
713  int16_t getMacDeviceTimeAns(uint32_t* gpsEpoch, uint8_t* fraction, bool returnUnix = true);
-
714 
-
720  int16_t setDatarate(uint8_t drUp);
-
721 
-
727  int16_t setTxPower(int8_t txPower);
-
728 
-
735  int16_t setRx2Dr(uint8_t dr);
-
736 
-
741  void setADR(bool enable = true);
-
742 
-
749  void setDutyCycle(bool enable = true, RadioLibTime_t msPerHour = 0);
-
750 
-
757  void setDwellTime(bool enable, RadioLibTime_t msPerUplink = 0);
-
758 
-
766  void setCSMA(bool csmaEnabled, uint8_t maxChanges = 4, uint8_t backoffMax = 0, uint8_t difsSlots = 2);
-
767 
-
773  void setDeviceStatus(uint8_t battLevel);
-
774 
-
782  void scheduleTransmission(RadioLibTime_t tUplink);
-
783 
-
788  uint32_t getFCntUp();
-
789 
-
794  uint32_t getNFCntDown();
-
795 
-
800  uint32_t getAFCntDown();
-
801 
-
807  void resetFCntDown();
-
808 
-
813  uint32_t getDevAddr();
-
814 
-
819  RadioLibTime_t getLastToA();
-
820 
-
828  RadioLibTime_t dutyCycleInterval(RadioLibTime_t msPerHour, RadioLibTime_t airtime);
-
829 
-
831  RadioLibTime_t timeUntilUplink();
-
832 
-
837  uint8_t getMaxPayloadLen();
-
838 
-
843  bool TS009 = false;
-
844 
-
857  RadioLibTime_t scanGuard = 10;
-
858 
-
859 #if !RADIOLIB_GODMODE
-
860  protected:
-
861 #endif
-
862  PhysicalLayer* phyLayer = NULL;
-
863  const LoRaWANBand_t* band = NULL;
-
864 
-
865  // a buffer that holds all LW base parameters that should persist at all times!
-
866  uint8_t bufferNonces[RADIOLIB_LORAWAN_NONCES_BUF_SIZE] = { 0 };
-
867 
-
868  // a buffer that holds all LW session parameters that preferably persist, but can be afforded to get lost
-
869  uint8_t bufferSession[RADIOLIB_LORAWAN_SESSION_BUF_SIZE] = { 0 };
-
870 
-
871  uint8_t fOptsUp[RADIOLIB_LORAWAN_FHDR_FOPTS_MAX_LEN] = { 0 };
-
872  uint8_t fOptsDown[RADIOLIB_LORAWAN_FHDR_FOPTS_MAX_LEN] = { 0 };
-
873  uint8_t fOptsUpLen = 0;
-
874  uint8_t fOptsDownLen = 0;
-
875 
-
876  uint16_t lwMode = RADIOLIB_LORAWAN_MODE_NONE;
-
877  uint8_t lwClass = RADIOLIB_LORAWAN_CLASS_A;
-
878  bool isActive = false;
-
879 
-
880  uint64_t joinEUI = 0;
-
881  uint64_t devEUI = 0;
-
882  uint8_t nwkKey[RADIOLIB_AES128_KEY_SIZE] = { 0 };
-
883  uint8_t appKey[RADIOLIB_AES128_KEY_SIZE] = { 0 };
-
884 
-
885  // the following is either provided by the network server (OTAA)
-
886  // or directly entered by the user (ABP)
-
887  uint32_t devAddr = 0;
-
888  uint8_t appSKey[RADIOLIB_AES128_KEY_SIZE] = { 0 };
-
889  uint8_t fNwkSIntKey[RADIOLIB_AES128_KEY_SIZE] = { 0 };
-
890  uint8_t sNwkSIntKey[RADIOLIB_AES128_KEY_SIZE] = { 0 };
-
891  uint8_t nwkSEncKey[RADIOLIB_AES128_KEY_SIZE] = { 0 };
-
892  uint8_t jSIntKey[RADIOLIB_AES128_KEY_SIZE] = { 0 };
-
893 
-
894  uint16_t keyCheckSum = 0;
-
895 
-
896  // device-specific parameters, persistent through sessions
-
897  uint16_t devNonce = 0;
-
898  uint32_t joinNonce = 0;
-
899 
-
900  // session-specific parameters
-
901  uint32_t homeNetId = 0;
-
902  uint8_t adrLimitExp = RADIOLIB_LORAWAN_ADR_ACK_LIMIT_EXP;
-
903  uint8_t adrDelayExp = RADIOLIB_LORAWAN_ADR_ACK_DELAY_EXP;
-
904  uint8_t nbTrans = 1; // Number of allowed frame retransmissions
-
905  uint8_t txPowerSteps = 0;
-
906  uint8_t txPowerMax = 0;
-
907  uint32_t fCntUp = 0;
-
908  uint32_t aFCntDown = 0;
-
909  uint32_t nFCntDown = 0;
-
910  uint32_t confFCntUp = RADIOLIB_LORAWAN_FCNT_NONE;
-
911  uint32_t confFCntDown = RADIOLIB_LORAWAN_FCNT_NONE;
-
912  uint32_t adrFCnt = 0;
-
913 
-
914  // ADR is enabled by default
-
915  bool adrEnabled = true;
-
916 
-
917  // duty cycle is set upon initialization and activated in regions that impose this
-
918  bool dutyCycleEnabled = false;
-
919  uint32_t dutyCycle = 0;
-
920 
-
921  // dwell time is set upon initialization and activated in regions that impose this
-
922  bool dwellTimeEnabledUp = false;
-
923  uint16_t dwellTimeUp = 0;
-
924  bool dwellTimeEnabledDn = false;
-
925  uint16_t dwellTimeDn = 0;
-
926 
-
927  RadioLibTime_t tUplink = 0; // scheduled uplink transmission time (internal clock)
-
928  RadioLibTime_t tDownlink = 0; // time at end of downlink reception
-
929 
-
930  // enable/disable CSMA for LoRaWAN
-
931  bool csmaEnabled = false;
-
932 
-
933  // maximum number of channel hops during CSMA
-
934  uint8_t maxChanges = RADIOLIB_LORAWAN_MAX_CHANGES_DEFAULT;
-
935 
-
936  // number of backoff slots to be checked after DIFS phase.
-
937  // A random BO avoids collisions in the case where two or more nodes start the CSMA
-
938  // process at the same time.
-
939  uint8_t backoffMax = RADIOLIB_LORAWAN_BACKOFF_MAX_DEFAULT;
-
940 
-
941  // number of CADs to estimate a clear CH
-
942  uint8_t difsSlots = RADIOLIB_LORAWAN_DIFS_DEFAULT;
-
943 
-
944  // available channel frequencies from list passed during OTA activation
-
945  LoRaWANChannel_t channelPlan[2][RADIOLIB_LORAWAN_NUM_AVAILABLE_CHANNELS];
-
946 
-
947  // currently configured channels for TX, RX1, RX2
-
948  LoRaWANChannel_t channels[3] = { RADIOLIB_LORAWAN_CHANNEL_NONE, RADIOLIB_LORAWAN_CHANNEL_NONE,
-
949  RADIOLIB_LORAWAN_CHANNEL_NONE };
-
950 
-
951  // delays between the uplink and RX1/2 windows
-
952  // the first field is meaningless, but is used for offsetting for Rx windows 1 and 2
-
953  RadioLibTime_t rxDelays[3] = { 0, RADIOLIB_LORAWAN_RECEIVE_DELAY_1_MS, RADIOLIB_LORAWAN_RECEIVE_DELAY_2_MS };
-
954 
-
955  // offset between TX and RX1 (such that RX1 has equal or lower DR)
-
956  uint8_t rx1DrOffset = 0;
-
957 
-
958  // LoRaWAN revision (1.0 vs 1.1)
-
959  uint8_t rev = 0;
-
960 
-
961  // Time on Air of last uplink
-
962  RadioLibTime_t lastToA = 0;
-
963 
-
964  // timestamp to measure the RX1/2 delay (from uplink end)
-
965  RadioLibTime_t rxDelayStart = 0;
-
966 
-
967  // timestamp when the Rx1/2 windows were closed (timeout or uplink received)
-
968  RadioLibTime_t rxDelayEnd = 0;
-
969 
-
970  // device status - battery level
-
971  uint8_t battLevel = 0xFF;
-
972 
-
973  // indicates whether an uplink has MAC commands as payload
-
974  bool isMACPayload = false;
-
975 
-
976  // save the selected sub-band in case this must be restored in ADR control
-
977  uint8_t subBand = 0;
-
978 
-
979  // allow port 226 for devices implementing TS011
-
980  bool TS011 = false;
-
981 
-
982  // this will reset the device credentials, so the device starts completely new
-
983  void clearNonces();
-
984 
-
985  // start a fresh session using default parameters
-
986  void createSession(uint16_t lwMode, uint8_t initialDr);
-
987 
-
988  // setup Join-Request payload
-
989  void composeJoinRequest(uint8_t* joinRequestMsg);
-
990 
-
991  // extract Join-Accept payload and start a new session
-
992  int16_t processJoinAccept(LoRaWANJoinEvent_t *joinEvent);
-
993 
-
994  // a join-accept can piggy-back a set of channels or channel masks
-
995  void processCFList(uint8_t* cfList);
-
996 
-
997  // check whether payload length and fport are allowed
-
998  int16_t isValidUplink(uint8_t* len, uint8_t fPort);
-
999 
-
1000  // perform ADR backoff
-
1001  void adrBackoff();
-
1002 
-
1003  // create an encrypted uplink buffer, composing metadata, user data and MAC data
-
1004  void composeUplink(uint8_t* in, uint8_t lenIn, uint8_t* out, uint8_t fPort, bool isConfirmed);
-
1005 
-
1006  // generate and set the MIC of an uplink buffer (depends on selected channels)
-
1007  void micUplink(uint8_t* inOut, uint8_t lenInOut);
-
1008 
-
1009  // transmit uplink buffer on a specified channel
-
1010  int16_t transmitUplink(LoRaWANChannel_t* chnl, uint8_t* in, uint8_t len, bool retrans);
-
1011 
-
1012  // wait for, open and listen during receive windows; only performs listening
-
1013  int16_t receiveCommon(uint8_t dir, const LoRaWANChannel_t* dlChannels, const RadioLibTime_t* dlDelays, uint8_t numWindows, RadioLibTime_t tReference);
-
1014 
-
1015  // extract downlink payload and process MAC commands
-
1016  int16_t parseDownlink(uint8_t* data, size_t* len, LoRaWANEvent_t* event = NULL);
-
1017 
-
1018  // execute mac command, return the number of processed bytes for sequential processing
-
1019  bool execMacCommand(uint8_t cid, uint8_t* optIn, uint8_t lenIn);
-
1020  bool execMacCommand(uint8_t cid, uint8_t* optIn, uint8_t lenIn, uint8_t* optOut);
-
1021 
-
1022  // possible override for additional MAC commands that are not in the base specification
-
1023  virtual bool derivedMacHandler(uint8_t cid, uint8_t* optIn, uint8_t lenIn, uint8_t* optOut);
-
1024 
-
1025  // pre-process a (set of) LinkAdrReq commands into one super-channel-mask + Tx/Dr/NbTrans fields
-
1026  void preprocessMacLinkAdr(uint8_t* mPtr, uint8_t cLen, uint8_t* mAdrOpt);
-
1027 
-
1028  // post-process a (set of) LinkAdrAns commands depending on LoRaWAN version
-
1029  void postprocessMacLinkAdr(uint8_t* ack, uint8_t cLen);
-
1030 
-
1031  // get the properties of a MAC command given a certain command ID
-
1032  int16_t getMacCommand(uint8_t cid, LoRaWANMacCommand_t* cmd);
-
1033 
-
1034  // possible override for additional MAC commands that are not in the base specification
-
1035  virtual int16_t derivedMacFinder(uint8_t cid, LoRaWANMacCommand_t* cmd);
-
1036 
-
1037  // get the length of a certain MAC command in a specific direction (up/down)
-
1038  // if inclusive is true, add one for the CID byte
-
1039  int16_t getMacLen(uint8_t cid, uint8_t* len, uint8_t dir, bool inclusive = false);
-
1040 
-
1041  // find out of a MAC command should persist destruction
-
1042  // in uplink direction, some commands must persist if no downlink is received
-
1043  // in downlink direction, the user-accessible MAC commands remain available for retrieval
-
1044  bool isPersistentMacCommand(uint8_t cid, uint8_t dir);
-
1045 
-
1046  // push MAC command to queue, done by copy
-
1047  int16_t pushMacCommand(uint8_t cid, uint8_t* cOcts, uint8_t* out, uint8_t* lenOut, uint8_t dir);
-
1048 
-
1049  // retrieve the payload of a certain MAC command, if present in the buffer
-
1050  int16_t getMacPayload(uint8_t cid, uint8_t* in, uint8_t lenIn, uint8_t* out, uint8_t dir);
-
1051 
-
1052  // delete a specific MAC command from queue, indicated by the command ID
-
1053  int16_t deleteMacCommand(uint8_t cid, uint8_t* inOut, uint8_t* lenInOut, uint8_t dir);
-
1054 
-
1055  // clear a MAC buffer, possible retaining persistent MAC commands
-
1056  void clearMacCommands(uint8_t* inOut, uint8_t* lenInOut, uint8_t dir);
-
1057 
-
1058  // configure the common physical layer properties (frequency, sync word etc.)
-
1059  int16_t setPhyProperties(const LoRaWANChannel_t* chnl, uint8_t dir, int8_t pwr, size_t pre = 0);
-
1060 
-
1061  // Performs CSMA as per LoRa Alliance Technical Recommendation 13 (TR-013).
-
1062  bool csmaChannelClear(uint8_t difs, uint8_t numBackoff);
-
1063 
-
1064  // perform a single CAD operation for the under SF/CH combination. Returns either busy or otherwise.
-
1065  bool cadChannelClear();
-
1066 
-
1067  // (dynamic bands:) get or (fixed bands:) create a complete 80-bit channel mask for current configuration
-
1068  void getChannelPlanMask(uint64_t* chMaskGrp0123, uint32_t* chMaskGrp45);
-
1069 
-
1070  // setup uplink/downlink channel data rates and frequencies
-
1071  // for dynamic channels, there is a small set of predefined channels
-
1072  // in case of JoinRequest, add some optional extra frequencies
-
1073  void selectChannelPlanDyn(bool joinRequest = false);
-
1074 
-
1075  // setup uplink/downlink channel data rates and frequencies
-
1076  // for fixed bands, we only allow one sub-band at a time to be selected
-
1077  void selectChannelPlanFix();
-
1078 
-
1079  // get the number of available channels,
-
1080  // along with a 16-bit mask indicating which channels can be used next for uplink/downlink
-
1081  uint8_t getAvailableChannels(uint16_t* mask);
-
1082 
-
1083  // (re)set/restore which channels can be used next for uplink/downlink
-
1084  void setAvailableChannels(uint16_t mask);
-
1085 
-
1086  // select a set of random TX/RX channels for up- and downlink
-
1087  int16_t selectChannels();
-
1088 
-
1089  // apply a 96-bit channel mask
-
1090  bool applyChannelMask(uint64_t chMaskGrp0123, uint32_t chMaskGrp45);
-
1091 
-
1092 #if RADIOLIB_DEBUG_PROTOCOL
-
1093  // print the available channels through debug
-
1094  void printChannels();
-
1095 #endif
-
1096 
-
1097  // method to generate message integrity code
-
1098  uint32_t generateMIC(uint8_t* msg, size_t len, uint8_t* key);
-
1099 
-
1100  // method to verify message integrity code
-
1101  // it assumes that the MIC is the last 4 bytes of the message
-
1102  bool verifyMIC(uint8_t* msg, size_t len, uint8_t* key);
-
1103 
-
1104  // find the first usable data rate for the given band
-
1105  int16_t findDataRate(uint8_t dr, DataRate_t* dataRate);
-
1106 
-
1107  // function to encrypt and decrypt payloads (regular uplink/downlink)
-
1108  void processAES(const uint8_t* in, size_t len, uint8_t* key, uint8_t* out, uint32_t fCnt, uint8_t dir, uint8_t ctrId, bool counter);
-
1109 
-
1110  // 16-bit checksum method that takes a uint8_t array of even length and calculates the checksum
-
1111  static uint16_t checkSum16(const uint8_t *key, uint16_t keyLen);
-
1112 
-
1113  // check the integrity of a buffer using a 16-bit checksum located in the last two bytes of the buffer
-
1114  static int16_t checkBufferCommon(uint8_t *buffer, uint16_t size);
-
1115 
-
1116  // network-to-host conversion method - takes data from network packet and converts it to the host endians
-
1117  template<typename T>
-
1118  static T ntoh(uint8_t* buff, size_t size = 0);
-
1119 
-
1120  // host-to-network conversion method - takes data from host variable and and converts it to network packet endians
-
1121  template<typename T>
-
1122  static void hton(uint8_t* buff, T val, size_t size = 0);
-
1123 };
-
1124 
-
1125 template<typename T>
-
1126 T LoRaWANNode::ntoh(uint8_t* buff, size_t size) {
-
1127  uint8_t* buffPtr = buff;
-
1128  size_t targetSize = sizeof(T);
-
1129  if(size != 0) {
-
1130  targetSize = size;
-
1131  }
-
1132  T res = 0;
-
1133  for(size_t i = 0; i < targetSize; i++) {
-
1134  res |= (uint32_t)(*(buffPtr++)) << 8*i;
-
1135  }
-
1136  return(res);
-
1137 }
-
1138 
-
1139 template<typename T>
-
1140 void LoRaWANNode::hton(uint8_t* buff, T val, size_t size) {
-
1141  uint8_t* buffPtr = buff;
-
1142  size_t targetSize = sizeof(T);
-
1143  if(size != 0) {
-
1144  targetSize = size;
-
1145  }
-
1146  for(size_t i = 0; i < targetSize; i++) {
-
1147  *(buffPtr++) = val >> 8*i;
-
1148  }
-
1149 }
-
1150 
-
1151 #endif
-
LoRaWANNode
LoRaWAN-compatible node (class A device).
Definition: LoRaWAN.h:528
+
70 #define RADIOLIB_LORAWAN_DATA_RATE_CR (0x01 << 0) // 0 0 coding rate mask
+
71 #define RADIOLIB_LORAWAN_DATA_RATE_CR_1_3 (0x00 << 0) // 0 0 LR-FHSS coding rate: 1/3
+
72 #define RADIOLIB_LORAWAN_DATA_RATE_CR_2_3 (0x01 << 0) // 0 0 2/3
+
73 #define RADIOLIB_LORAWAN_DATA_RATE_UNUSED (0xFF << 0) // 7 0 unused data rate
+
74 
+
75 // channels and channel plans
+
76 #define RADIOLIB_LORAWAN_UPLINK (0x00 << 0)
+
77 #define RADIOLIB_LORAWAN_DOWNLINK (0x01 << 0)
+
78 #define RADIOLIB_LORAWAN_DIR_RX2 (0x02 << 0)
+
79 #define RADIOLIB_LORAWAN_BAND_DYNAMIC (0)
+
80 #define RADIOLIB_LORAWAN_BAND_FIXED (1)
+
81 #define RADIOLIB_LORAWAN_CHANNEL_NUM_DATARATES (15)
+
82 #define RADIOLIB_LORAWAN_CHANNEL_INDEX_NONE (0xFF >> 0)
+
83 
+
84 // recommended default settings
+
85 #define RADIOLIB_LORAWAN_RECEIVE_DELAY_1_MS (1000)
+
86 #define RADIOLIB_LORAWAN_RECEIVE_DELAY_2_MS ((RADIOLIB_LORAWAN_RECEIVE_DELAY_1_MS) + 1000)
+
87 #define RADIOLIB_LORAWAN_RX1_DR_OFFSET (0)
+
88 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_DELAY_1_MS (5000)
+
89 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_DELAY_2_MS (6000)
+
90 #define RADIOLIB_LORAWAN_MAX_FCNT_GAP (16384)
+
91 #define RADIOLIB_LORAWAN_ADR_ACK_LIMIT_EXP (0x06)
+
92 #define RADIOLIB_LORAWAN_ADR_ACK_DELAY_EXP (0x05)
+
93 #define RADIOLIB_LORAWAN_RETRANSMIT_TIMEOUT_MIN_MS (1000)
+
94 #define RADIOLIB_LORAWAN_RETRANSMIT_TIMEOUT_MAX_MS (3000)
+
95 #define RADIOLIB_LORAWAN_POWER_STEP_SIZE_DBM (-2)
+
96 #define RADIOLIB_LORAWAN_REJOIN_MAX_COUNT_N (10) // send rejoin request 16384 uplinks
+
97 #define RADIOLIB_LORAWAN_REJOIN_MAX_TIME_N (15) // once every year, not actually implemented
+
98 
+
99 // join request message layout
+
100 #define RADIOLIB_LORAWAN_JOIN_REQUEST_LEN (23)
+
101 #define RADIOLIB_LORAWAN_JOIN_REQUEST_JOIN_EUI_POS (1)
+
102 #define RADIOLIB_LORAWAN_JOIN_REQUEST_DEV_EUI_POS (9)
+
103 #define RADIOLIB_LORAWAN_JOIN_REQUEST_DEV_NONCE_POS (17)
+
104 #define RADIOLIB_LORAWAN_JOIN_REQUEST_TYPE (0xFF)
+
105 #define RADIOLIB_LORAWAN_JOIN_REQUEST_TYPE_0 (0x00)
+
106 #define RADIOLIB_LORAWAN_JOIN_REQUEST_TYPE_1 (0x01)
+
107 #define RADIOLIB_LORAWAN_JOIN_REQUEST_TYPE_2 (0x02)
+
108 
+
109 // join accept message layout
+
110 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_MAX_LEN (33)
+
111 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_JOIN_NONCE_POS (1)
+
112 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_HOME_NET_ID_POS (4)
+
113 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_DEV_ADDR_POS (7)
+
114 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_DL_SETTINGS_POS (11)
+
115 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_RX_DELAY_POS (12)
+
116 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_CFLIST_POS (13)
+
117 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_CFLIST_LEN (16)
+
118 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_CFLIST_TYPE_POS (RADIOLIB_LORAWAN_JOIN_ACCEPT_CFLIST_POS + RADIOLIB_LORAWAN_JOIN_ACCEPT_CFLIST_LEN - 1)
+
119 
+
120 // join accept key derivation layout
+
121 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_AES_JOIN_NONCE_POS (1) // regular keys
+
122 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_AES_JOIN_EUI_POS (4)
+
123 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_AES_DEV_NONCE_POS (12)
+
124 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_AES_DEV_ADDR_POS (1) // relay keys
+
125 
+
126 // join accept message variables
+
127 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_R_1_0 (0x00 << 7) // 7 7 LoRaWAN revision: 1.0
+
128 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_R_1_1 (0x01 << 7) // 7 7 1.1
+
129 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_F_NWK_S_INT_KEY (0x01)
+
130 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_APP_S_KEY (0x02)
+
131 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_S_NWK_S_INT_KEY (0x03)
+
132 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_NWK_S_ENC_KEY (0x04)
+
133 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_JS_ENC_KEY (0x05)
+
134 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_JS_INT_KEY (0x06)
+
135 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_ROOT_WOR_S_KEY (0x01)
+
136 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_WOR_S_INT_KEY (0x01)
+
137 #define RADIOLIB_LORAWAN_JOIN_ACCEPT_WOR_S_ENC_KEY (0x02)
+
138 
+
139 // frame header layout
+
140 #define RADIOLIB_LORAWAN_FHDR_LEN_START_OFFS (16)
+
141 #define RADIOLIB_LORAWAN_FHDR_DEV_ADDR_POS (RADIOLIB_LORAWAN_FHDR_LEN_START_OFFS + 1)
+
142 #define RADIOLIB_LORAWAN_FHDR_FCTRL_POS (RADIOLIB_LORAWAN_FHDR_LEN_START_OFFS + 5)
+
143 #define RADIOLIB_LORAWAN_FHDR_FCNT_POS (RADIOLIB_LORAWAN_FHDR_LEN_START_OFFS + 6)
+
144 #define RADIOLIB_LORAWAN_FHDR_FOPTS_POS (RADIOLIB_LORAWAN_FHDR_LEN_START_OFFS + 8)
+
145 #define RADIOLIB_LORAWAN_FHDR_FOPTS_LEN_MASK (0x0F)
+
146 #define RADIOLIB_LORAWAN_FHDR_FOPTS_MAX_LEN (15)
+
147 #define RADIOLIB_LORAWAN_FHDR_FPORT_POS(FOPTS) (RADIOLIB_LORAWAN_FHDR_LEN_START_OFFS + 8 + (FOPTS))
+
148 #define RADIOLIB_LORAWAN_FRAME_PAYLOAD_POS(FOPTS) (RADIOLIB_LORAWAN_FHDR_LEN_START_OFFS + 9 + (FOPTS))
+
149 #define RADIOLIB_LORAWAN_FRAME_LEN(PAYLOAD, FOPTS) (16 + 13 + (PAYLOAD) + (FOPTS))
+
150 
+
151 // payload encryption/MIC blocks common layout
+
152 #define RADIOLIB_LORAWAN_BLOCK_MAGIC_POS (0)
+
153 #define RADIOLIB_LORAWAN_BLOCK_CONF_FCNT_POS (1)
+
154 #define RADIOLIB_LORAWAN_BLOCK_DIR_POS (5)
+
155 #define RADIOLIB_LORAWAN_BLOCK_DEV_ADDR_POS (6)
+
156 #define RADIOLIB_LORAWAN_BLOCK_FCNT_POS (10)
+
157 
+
158 // payload encryption block layout
+
159 #define RADIOLIB_LORAWAN_ENC_BLOCK_MAGIC (0x01)
+
160 #define RADIOLIB_LORAWAN_ENC_BLOCK_COUNTER_ID_POS (4)
+
161 #define RADIOLIB_LORAWAN_ENC_BLOCK_COUNTER_POS (15)
+
162 
+
163 // payload MIC blocks layout
+
164 #define RADIOLIB_LORAWAN_MIC_BLOCK_MAGIC (0x49)
+
165 #define RADIOLIB_LORAWAN_MIC_BLOCK_LEN_POS (15)
+
166 #define RADIOLIB_LORAWAN_MIC_DATA_RATE_POS (3)
+
167 #define RADIOLIB_LORAWAN_MIC_CH_INDEX_POS (4)
+
168 
+
169 // maximum allowed dwell time on bands that implement dwell time limitations
+
170 #define RADIOLIB_LORAWAN_DWELL_TIME (400)
+
171 
+
172 // unused frame counter value
+
173 #define RADIOLIB_LORAWAN_FCNT_NONE (0xFFFFFFFF)
+
174 
+
175 // TR013 CSMA recommended values
+
176 #define RADIOLIB_LORAWAN_DIFS_DEFAULT (2)
+
177 #define RADIOLIB_LORAWAN_BACKOFF_MAX_DEFAULT (6)
+
178 #define RADIOLIB_LORAWAN_MAX_CHANGES_DEFAULT (4)
+
179 
+
180 // MAC commands
+
181 #define RADIOLIB_LORAWAN_NUM_MAC_COMMANDS (23)
+
182 
+
183 #define RADIOLIB_LORAWAN_MAC_RESET (0x01)
+
184 #define RADIOLIB_LORAWAN_MAC_LINK_CHECK (0x02)
+
185 #define RADIOLIB_LORAWAN_MAC_LINK_ADR (0x03)
+
186 #define RADIOLIB_LORAWAN_MAC_DUTY_CYCLE (0x04)
+
187 #define RADIOLIB_LORAWAN_MAC_RX_PARAM_SETUP (0x05)
+
188 #define RADIOLIB_LORAWAN_MAC_DEV_STATUS (0x06)
+
189 #define RADIOLIB_LORAWAN_MAC_NEW_CHANNEL (0x07)
+
190 #define RADIOLIB_LORAWAN_MAC_RX_TIMING_SETUP (0x08)
+
191 #define RADIOLIB_LORAWAN_MAC_TX_PARAM_SETUP (0x09)
+
192 #define RADIOLIB_LORAWAN_MAC_DL_CHANNEL (0x0A)
+
193 #define RADIOLIB_LORAWAN_MAC_REKEY (0x0B)
+
194 #define RADIOLIB_LORAWAN_MAC_ADR_PARAM_SETUP (0x0C)
+
195 #define RADIOLIB_LORAWAN_MAC_DEVICE_TIME (0x0D)
+
196 #define RADIOLIB_LORAWAN_MAC_FORCE_REJOIN (0x0E)
+
197 #define RADIOLIB_LORAWAN_MAC_REJOIN_PARAM_SETUP (0x0F)
+
198 #define RADIOLIB_LORAWAN_MAC_PROPRIETARY (0x80)
+
199 
+
200 // the length of internal MAC command queue - hopefully this is enough for most use cases
+
201 #define RADIOLIB_LORAWAN_MAC_COMMAND_QUEUE_SIZE (9)
+
202 
+
203 // the maximum number of simultaneously available channels
+
204 #define RADIOLIB_LORAWAN_NUM_AVAILABLE_CHANNELS (16)
+
205 
+
206 // maximum MAC command sizes
+
207 #define RADIOLIB_LORAWAN_MAX_MAC_COMMAND_LEN_DOWN (5)
+
208 #define RADIOLIB_LORAWAN_MAX_MAC_COMMAND_LEN_UP (2)
+
209 #define RADIOLIB_LORAWAN_MAX_NUM_ADR_COMMANDS (8)
+
210 
+
215 struct LoRaWANMacCommand_t {
+
217  const uint8_t cid;
+
218 
+
220  const uint8_t lenDn;
+
221 
+
223  const uint8_t lenUp;
+
224 
+
226  const bool persist;
+
227 
+
229  const bool user;
+
230 };
+
231 
+
232 #define RADIOLIB_LORAWAN_MAC_COMMAND_NONE { .cid = 0, .lenDn = 0, .lenUp = 0, .persist = false, .user = false }
+
233 
+
234 constexpr LoRaWANMacCommand_t MacTable[RADIOLIB_LORAWAN_NUM_MAC_COMMANDS] = {
+
235  { RADIOLIB_LORAWAN_MAC_RESET, 1, 1, false, false },
+
236  { RADIOLIB_LORAWAN_MAC_LINK_CHECK, 2, 0, false, true },
+
237  { RADIOLIB_LORAWAN_MAC_LINK_ADR, 4, 1, false, false },
+
238  { RADIOLIB_LORAWAN_MAC_DUTY_CYCLE, 1, 0, false, false },
+
239  { RADIOLIB_LORAWAN_MAC_RX_PARAM_SETUP, 4, 1, true, false },
+
240  { RADIOLIB_LORAWAN_MAC_DEV_STATUS, 0, 2, false, false },
+
241  { RADIOLIB_LORAWAN_MAC_NEW_CHANNEL, 5, 1, false, false },
+
242  { RADIOLIB_LORAWAN_MAC_RX_TIMING_SETUP, 1, 0, true, false },
+
243  { RADIOLIB_LORAWAN_MAC_TX_PARAM_SETUP, 1, 0, true, false },
+
244  { RADIOLIB_LORAWAN_MAC_DL_CHANNEL, 4, 1, true, false },
+
245  { RADIOLIB_LORAWAN_MAC_REKEY, 1, 1, false, false },
+
246  { RADIOLIB_LORAWAN_MAC_ADR_PARAM_SETUP, 1, 0, false, false },
+
247  { RADIOLIB_LORAWAN_MAC_DEVICE_TIME, 5, 0, false, true },
+
248  { RADIOLIB_LORAWAN_MAC_FORCE_REJOIN, 2, 0, false, false },
+
249  { RADIOLIB_LORAWAN_MAC_REJOIN_PARAM_SETUP, 1, 1, false, false },
+
250  { RADIOLIB_LORAWAN_MAC_PROPRIETARY, 5, 0, false, true },
+
251 };
+
252 
+
253 #define RADIOLIB_LORAWAN_NONCES_VERSION_VAL (0x0001)
+
254 
+
255 enum LoRaWANSchemeBase_t {
+
256  RADIOLIB_LORAWAN_NONCES_START = 0x00,
+
257  RADIOLIB_LORAWAN_NONCES_VERSION = RADIOLIB_LORAWAN_NONCES_START, // 2 bytes
+
258  RADIOLIB_LORAWAN_NONCES_MODE = RADIOLIB_LORAWAN_NONCES_VERSION + sizeof(uint16_t), // 2 bytes
+
259  RADIOLIB_LORAWAN_NONCES_CLASS = RADIOLIB_LORAWAN_NONCES_MODE + sizeof(uint16_t), // 1 byte
+
260  RADIOLIB_LORAWAN_NONCES_PLAN = RADIOLIB_LORAWAN_NONCES_CLASS + sizeof(uint8_t), // 1 byte
+
261  RADIOLIB_LORAWAN_NONCES_CHECKSUM = RADIOLIB_LORAWAN_NONCES_PLAN + sizeof(uint8_t), // 2 bytes
+
262  RADIOLIB_LORAWAN_NONCES_DEV_NONCE = RADIOLIB_LORAWAN_NONCES_CHECKSUM + sizeof(uint16_t), // 2 bytes
+
263  RADIOLIB_LORAWAN_NONCES_JOIN_NONCE = RADIOLIB_LORAWAN_NONCES_DEV_NONCE + sizeof(uint16_t), // 3 bytes
+
264  RADIOLIB_LORAWAN_NONCES_ACTIVE = RADIOLIB_LORAWAN_NONCES_JOIN_NONCE + 3, // 1 byte
+
265  RADIOLIB_LORAWAN_NONCES_SIGNATURE = RADIOLIB_LORAWAN_NONCES_ACTIVE + sizeof(uint8_t), // 2 bytes
+
266  RADIOLIB_LORAWAN_NONCES_BUF_SIZE = RADIOLIB_LORAWAN_NONCES_SIGNATURE + sizeof(uint16_t) // Nonces buffer size
+
267 };
+
268 
+
269 enum LoRaWANSchemeSession_t {
+
270  RADIOLIB_LORAWAN_SESSION_START = 0x00,
+
271  RADIOLIB_LORAWAN_SESSION_NWK_SENC_KEY = RADIOLIB_LORAWAN_SESSION_START, // 16 bytes
+
272  RADIOLIB_LORAWAN_SESSION_APP_SKEY = RADIOLIB_LORAWAN_SESSION_NWK_SENC_KEY + RADIOLIB_AES128_KEY_SIZE, // 16 bytes
+
273  RADIOLIB_LORAWAN_SESSION_FNWK_SINT_KEY = RADIOLIB_LORAWAN_SESSION_APP_SKEY + RADIOLIB_AES128_KEY_SIZE, // 16 bytes
+
274  RADIOLIB_LORAWAN_SESSION_SNWK_SINT_KEY = RADIOLIB_LORAWAN_SESSION_FNWK_SINT_KEY + RADIOLIB_AES128_KEY_SIZE, // 16 bytes
+
275  RADIOLIB_LORAWAN_SESSION_DEV_ADDR = RADIOLIB_LORAWAN_SESSION_SNWK_SINT_KEY + RADIOLIB_AES128_KEY_SIZE, // 4 bytes
+
276  RADIOLIB_LORAWAN_SESSION_NONCES_SIGNATURE = RADIOLIB_LORAWAN_SESSION_DEV_ADDR + sizeof(uint32_t), // 2 bytes
+
277  RADIOLIB_LORAWAN_SESSION_FCNT_UP = RADIOLIB_LORAWAN_SESSION_NONCES_SIGNATURE + 2, // 4 bytes
+
278  RADIOLIB_LORAWAN_SESSION_N_FCNT_DOWN = RADIOLIB_LORAWAN_SESSION_FCNT_UP + sizeof(uint32_t), // 4 bytes
+
279  RADIOLIB_LORAWAN_SESSION_A_FCNT_DOWN = RADIOLIB_LORAWAN_SESSION_N_FCNT_DOWN + sizeof(uint32_t), // 4 bytes
+
280  RADIOLIB_LORAWAN_SESSION_ADR_FCNT = RADIOLIB_LORAWAN_SESSION_A_FCNT_DOWN + sizeof(uint32_t), // 4 bytes
+
281  RADIOLIB_LORAWAN_SESSION_CONF_FCNT_UP = RADIOLIB_LORAWAN_SESSION_ADR_FCNT + sizeof(uint32_t), // 4 bytes
+
282  RADIOLIB_LORAWAN_SESSION_CONF_FCNT_DOWN = RADIOLIB_LORAWAN_SESSION_CONF_FCNT_UP + sizeof(uint32_t), // 4 bytes
+
283  RADIOLIB_LORAWAN_SESSION_RJ_COUNT0 = RADIOLIB_LORAWAN_SESSION_CONF_FCNT_DOWN + sizeof(uint32_t), // 2 bytes
+
284  RADIOLIB_LORAWAN_SESSION_RJ_COUNT1 = RADIOLIB_LORAWAN_SESSION_RJ_COUNT0 + sizeof(uint16_t), // 2 bytes
+
285  RADIOLIB_LORAWAN_SESSION_HOMENET_ID = RADIOLIB_LORAWAN_SESSION_RJ_COUNT1 + sizeof(uint16_t), // 4 bytes
+
286  RADIOLIB_LORAWAN_SESSION_VERSION = RADIOLIB_LORAWAN_SESSION_HOMENET_ID + sizeof(uint32_t), // 1 byte
+
287  RADIOLIB_LORAWAN_SESSION_LINK_ADR = RADIOLIB_LORAWAN_SESSION_VERSION + sizeof(uint8_t), // 14 bytes
+
288  RADIOLIB_LORAWAN_SESSION_DUTY_CYCLE = RADIOLIB_LORAWAN_SESSION_LINK_ADR + 14, // 1 byte
+
289  RADIOLIB_LORAWAN_SESSION_RX_PARAM_SETUP = RADIOLIB_LORAWAN_SESSION_DUTY_CYCLE + 1, // 4 bytes
+
290  RADIOLIB_LORAWAN_SESSION_RX_TIMING_SETUP = RADIOLIB_LORAWAN_SESSION_RX_PARAM_SETUP + 4, // 1 byte
+
291  RADIOLIB_LORAWAN_SESSION_TX_PARAM_SETUP = RADIOLIB_LORAWAN_SESSION_RX_TIMING_SETUP + 1, // 1 byte
+
292  RADIOLIB_LORAWAN_SESSION_ADR_PARAM_SETUP = RADIOLIB_LORAWAN_SESSION_TX_PARAM_SETUP + 1, // 1 byte
+
293  RADIOLIB_LORAWAN_SESSION_REJOIN_PARAM_SETUP = RADIOLIB_LORAWAN_SESSION_ADR_PARAM_SETUP + 1, // 1 byte
+
294  RADIOLIB_LORAWAN_SESSION_BEACON_FREQ = RADIOLIB_LORAWAN_SESSION_REJOIN_PARAM_SETUP + 1, // 3 bytes
+
295  RADIOLIB_LORAWAN_SESSION_PING_SLOT_CHANNEL = RADIOLIB_LORAWAN_SESSION_BEACON_FREQ + 3, // 4 bytes
+
296  RADIOLIB_LORAWAN_SESSION_PERIODICITY = RADIOLIB_LORAWAN_SESSION_PING_SLOT_CHANNEL + 4, // 1 byte
+
297  RADIOLIB_LORAWAN_SESSION_LAST_TIME = RADIOLIB_LORAWAN_SESSION_PERIODICITY + 1, // 4 bytes
+
298  RADIOLIB_LORAWAN_SESSION_UL_CHANNELS = RADIOLIB_LORAWAN_SESSION_LAST_TIME + 4, // 16*5 bytes
+
299  RADIOLIB_LORAWAN_SESSION_DL_CHANNELS = RADIOLIB_LORAWAN_SESSION_UL_CHANNELS + RADIOLIB_LORAWAN_NUM_AVAILABLE_CHANNELS*5, // 16*4 bytes
+
300  RADIOLIB_LORAWAN_SESSION_AVAILABLE_CHANNELS = RADIOLIB_LORAWAN_SESSION_DL_CHANNELS + RADIOLIB_LORAWAN_NUM_AVAILABLE_CHANNELS*4, // 2 bytes
+
301  RADIOLIB_LORAWAN_SESSION_MAC_QUEUE = RADIOLIB_LORAWAN_SESSION_AVAILABLE_CHANNELS + sizeof(uint16_t), // 15 bytes
+
302  RADIOLIB_LORAWAN_SESSION_MAC_QUEUE_LEN = RADIOLIB_LORAWAN_SESSION_MAC_QUEUE + RADIOLIB_LORAWAN_FHDR_FOPTS_MAX_LEN, // 1 byte
+
303  RADIOLIB_LORAWAN_SESSION_SIGNATURE = RADIOLIB_LORAWAN_SESSION_MAC_QUEUE_LEN + sizeof(uint8_t), // 2 bytes
+
304  RADIOLIB_LORAWAN_SESSION_BUF_SIZE = RADIOLIB_LORAWAN_SESSION_SIGNATURE + sizeof(uint16_t) // Session buffer size
+
305 };
+
306 
+
312 struct LoRaWANChannel_t {
+
314  bool enabled;
+
315 
+
317  uint8_t idx;
+
318 
+
320  uint32_t freq;
+
321 
+
323  uint8_t drMin;
+
324 
+
326  uint8_t drMax;
+
327 
+
329  uint8_t dr;
+
330 
+
332  bool available;
+
333 };
+
334 
+
335 // alias for unused channel
+
336 #define RADIOLIB_LORAWAN_CHANNEL_NONE { .enabled = false, .idx = RADIOLIB_LORAWAN_CHANNEL_INDEX_NONE, .freq = 0, \
+
337  .drMin = 0, .drMax = 0, .dr = RADIOLIB_LORAWAN_DATA_RATE_UNUSED, .available = false }
+
338 
+
344 struct LoRaWANChannelSpan_t {
+
346  uint8_t numChannels;
+
347 
+
349  uint32_t freqStart;
+
350 
+
352  uint32_t freqStep;
+
353 
+
355  uint8_t drMin;
+
356 
+
358  uint8_t drMax;
+
359 
+
361  uint8_t drJoinRequest;
+
362 };
+
363 
+
364 // alias for unused channel span
+
365 #define RADIOLIB_LORAWAN_CHANNEL_SPAN_NONE { .numChannels = 0, .freqStart = 0, .freqStep = 0, .drMin = 0, .drMax = 0, .drJoinRequest = RADIOLIB_LORAWAN_DATA_RATE_UNUSED }
+
366 
+
371 struct LoRaWANBand_t {
+
373  uint8_t bandNum;
+
374 
+
376  uint8_t bandType;
+
377 
+
379  uint32_t freqMin;
+
380 
+
382  uint32_t freqMax;
+
383 
+
385  uint8_t payloadLenMax[RADIOLIB_LORAWAN_CHANNEL_NUM_DATARATES];
+
386 
+
388  int8_t powerMax;
+
389 
+
391  int8_t powerNumSteps;
+
392 
+
394  RadioLibTime_t dutyCycle;
+
395 
+
397  RadioLibTime_t dwellTimeUp;
+
398 
+
400  RadioLibTime_t dwellTimeDn;
+
401 
+
403  bool txParamSupported;
+
404 
+
406  LoRaWANChannel_t txFreqs[3];
+
407 
+
409  LoRaWANChannel_t txJoinReq[3];
+
410 
+
412  uint8_t numTxSpans;
+
413 
+
415  LoRaWANChannelSpan_t txSpans[2];
+
416 
+
418  LoRaWANChannelSpan_t rx1Span;
+
419 
+
420  uint8_t rx1DrTable[RADIOLIB_LORAWAN_CHANNEL_NUM_DATARATES][8];
+
421 
+
423  LoRaWANChannel_t rx2;
+
424 
+
426  LoRaWANChannel_t txWoR[2];
+
427 
+
429  LoRaWANChannel_t txAck[2];
+
430 
+
432  uint8_t dataRates[RADIOLIB_LORAWAN_CHANNEL_NUM_DATARATES];
+
433 };
+
434 
+
435 // supported bands
+
436 extern const LoRaWANBand_t EU868;
+
437 extern const LoRaWANBand_t US915;
+
438 extern const LoRaWANBand_t EU433;
+
439 extern const LoRaWANBand_t AU915;
+
440 extern const LoRaWANBand_t CN500;
+
441 extern const LoRaWANBand_t AS923;
+
442 extern const LoRaWANBand_t AS923_2;
+
443 extern const LoRaWANBand_t AS923_3;
+
444 extern const LoRaWANBand_t AS923_4;
+
445 extern const LoRaWANBand_t KR920;
+
446 extern const LoRaWANBand_t IN865;
+
447 
+
452 enum LoRaWANBandNum_t {
+
453  BandEU868,
+
454  BandUS915,
+
455  BandEU433,
+
456  BandAU915,
+
457  BandCN500,
+
458  BandAS923,
+
459  BandAS923_2,
+
460  BandAS923_3,
+
461  BandAS923_4,
+
462  BandKR920,
+
463  BandIN865,
+
464  BandLast
+
465 };
+
466 
+
467 // provide easy access to the number of currently supported bands
+
468 #define RADIOLIB_LORAWAN_NUM_SUPPORTED_BANDS (BandLast - BandEU868)
+
469 
+
470 // array of currently supported bands
+
471 extern const LoRaWANBand_t* LoRaWANBands[];
+
472 
+
477 struct LoRaWANJoinEvent_t {
+
479  bool newSession = false;
+
480 
+
482  uint16_t devNonce = 0;
+
483 
+
485  uint32_t joinNonce = 0;
+
486 };
+
487 
+
492 struct LoRaWANEvent_t {
+
494  uint8_t dir;
+
495 
+
497  bool confirmed;
+
498 
+
501  bool confirming;
+
502 
+
504  bool frmPending;
+
505 
+
507  uint8_t datarate;
+
508 
+
510  float freq;
+
511 
+
513  int16_t power;
+
514 
+
516  uint32_t fCnt;
+
517 
+
519  uint8_t fPort;
+
520 
+
522  uint8_t nbTrans;
+
523 };
+
524 
+
529 class LoRaWANNode {
+
530  public:
+
531 
+
538  LoRaWANNode(PhysicalLayer* phy, const LoRaWANBand_t* band, uint8_t subBand = 0);
+
539 
+
544  uint8_t* getBufferNonces();
+
545 
+
551  int16_t setBufferNonces(uint8_t* persistentBuffer);
+
552 
+
556  void clearSession();
+
557 
+
562  uint8_t* getBufferSession();
+
563 
+
569  int16_t setBufferSession(uint8_t* persistentBuffer);
+
570 
+
579  int16_t beginOTAA(uint64_t joinEUI, uint64_t devEUI, uint8_t* nwkKey, uint8_t* appKey);
+
580 
+
591  int16_t beginABP(uint32_t addr, uint8_t* fNwkSIntKey, uint8_t* sNwkSIntKey, uint8_t* nwkSEncKey, uint8_t* appSKey);
+
592 
+
599  virtual int16_t activateOTAA(uint8_t initialDr = RADIOLIB_LORAWAN_DATA_RATE_UNUSED, LoRaWANJoinEvent_t *joinEvent = NULL);
+
600 
+
607  virtual int16_t activateABP(uint8_t initialDr = RADIOLIB_LORAWAN_DATA_RATE_UNUSED);
+
608 
+
610  bool isActivated();
+
611 
+
612  #if defined(RADIOLIB_BUILD_ARDUINO)
+
625  virtual int16_t sendReceive(String& strUp, uint8_t fPort, String& strDown, bool isConfirmed = false, LoRaWANEvent_t* eventUp = NULL, LoRaWANEvent_t* eventDown = NULL);
+
626  #endif
+
627 
+
639  virtual int16_t sendReceive(const char* strUp, uint8_t fPort, bool isConfirmed = false, LoRaWANEvent_t* eventUp = NULL, LoRaWANEvent_t* eventDown = NULL);
+
640 
+
654  virtual int16_t sendReceive(const char* strUp, uint8_t fPort, uint8_t* dataDown, size_t* lenDown, bool isConfirmed = false, LoRaWANEvent_t* eventUp = NULL, LoRaWANEvent_t* eventDown = NULL);
+
655 
+
668  virtual int16_t sendReceive(uint8_t* dataUp, size_t lenUp, uint8_t fPort = 1, bool isConfirmed = false, LoRaWANEvent_t* eventUp = NULL, LoRaWANEvent_t* eventDown = NULL);
+
669 
+
684  virtual int16_t sendReceive(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);
+
685 
+
693  int16_t sendMacCommandReq(uint8_t cid);
+
694 
+
703  int16_t getMacLinkCheckAns(uint8_t* margin, uint8_t* gwCnt);
+
704 
+
714  int16_t getMacDeviceTimeAns(uint32_t* gpsEpoch, uint8_t* fraction, bool returnUnix = true);
+
715 
+
721  int16_t setDatarate(uint8_t drUp);
+
722 
+
728  int16_t setTxPower(int8_t txPower);
+
729 
+
736  int16_t setRx2Dr(uint8_t dr);
+
737 
+
742  void setADR(bool enable = true);
+
743 
+
750  void setDutyCycle(bool enable = true, RadioLibTime_t msPerHour = 0);
+
751 
+
758  void setDwellTime(bool enable, RadioLibTime_t msPerUplink = 0);
+
759 
+
767  void setCSMA(bool csmaEnabled, uint8_t maxChanges = 4, uint8_t backoffMax = 0, uint8_t difsSlots = 2);
+
768 
+
774  void setDeviceStatus(uint8_t battLevel);
+
775 
+
783  void scheduleTransmission(RadioLibTime_t tUplink);
+
784 
+
789  uint32_t getFCntUp();
+
790 
+
795  uint32_t getNFCntDown();
+
796 
+
801  uint32_t getAFCntDown();
+
802 
+
808  void resetFCntDown();
+
809 
+
814  uint32_t getDevAddr();
+
815 
+
820  RadioLibTime_t getLastToA();
+
821 
+
829  RadioLibTime_t dutyCycleInterval(RadioLibTime_t msPerHour, RadioLibTime_t airtime);
+
830 
+
832  RadioLibTime_t timeUntilUplink();
+
833 
+
838  uint8_t getMaxPayloadLen();
+
839 
+
844  bool TS009 = false;
+
845 
+
858  RadioLibTime_t scanGuard = 10;
+
859 
+
860 #if !RADIOLIB_GODMODE
+
861  protected:
+
862 #endif
+
863  PhysicalLayer* phyLayer = NULL;
+
864  const LoRaWANBand_t* band = NULL;
+
865 
+
866  // a buffer that holds all LW base parameters that should persist at all times!
+
867  uint8_t bufferNonces[RADIOLIB_LORAWAN_NONCES_BUF_SIZE] = { 0 };
+
868 
+
869  // a buffer that holds all LW session parameters that preferably persist, but can be afforded to get lost
+
870  uint8_t bufferSession[RADIOLIB_LORAWAN_SESSION_BUF_SIZE] = { 0 };
+
871 
+
872  uint8_t fOptsUp[RADIOLIB_LORAWAN_FHDR_FOPTS_MAX_LEN] = { 0 };
+
873  uint8_t fOptsDown[RADIOLIB_LORAWAN_FHDR_FOPTS_MAX_LEN] = { 0 };
+
874  uint8_t fOptsUpLen = 0;
+
875  uint8_t fOptsDownLen = 0;
+
876 
+
877  uint16_t lwMode = RADIOLIB_LORAWAN_MODE_NONE;
+
878  uint8_t lwClass = RADIOLIB_LORAWAN_CLASS_A;
+
879  bool isActive = false;
+
880 
+
881  uint64_t joinEUI = 0;
+
882  uint64_t devEUI = 0;
+
883  uint8_t nwkKey[RADIOLIB_AES128_KEY_SIZE] = { 0 };
+
884  uint8_t appKey[RADIOLIB_AES128_KEY_SIZE] = { 0 };
+
885 
+
886  // the following is either provided by the network server (OTAA)
+
887  // or directly entered by the user (ABP)
+
888  uint32_t devAddr = 0;
+
889  uint8_t appSKey[RADIOLIB_AES128_KEY_SIZE] = { 0 };
+
890  uint8_t fNwkSIntKey[RADIOLIB_AES128_KEY_SIZE] = { 0 };
+
891  uint8_t sNwkSIntKey[RADIOLIB_AES128_KEY_SIZE] = { 0 };
+
892  uint8_t nwkSEncKey[RADIOLIB_AES128_KEY_SIZE] = { 0 };
+
893  uint8_t jSIntKey[RADIOLIB_AES128_KEY_SIZE] = { 0 };
+
894 
+
895  uint16_t keyCheckSum = 0;
+
896 
+
897  // device-specific parameters, persistent through sessions
+
898  uint16_t devNonce = 0;
+
899  uint32_t joinNonce = 0;
+
900 
+
901  // session-specific parameters
+
902  uint32_t homeNetId = 0;
+
903  uint8_t adrLimitExp = RADIOLIB_LORAWAN_ADR_ACK_LIMIT_EXP;
+
904  uint8_t adrDelayExp = RADIOLIB_LORAWAN_ADR_ACK_DELAY_EXP;
+
905  uint8_t nbTrans = 1; // Number of allowed frame retransmissions
+
906  uint8_t txPowerSteps = 0;
+
907  uint8_t txPowerMax = 0;
+
908  uint32_t fCntUp = 0;
+
909  uint32_t aFCntDown = 0;
+
910  uint32_t nFCntDown = 0;
+
911  uint32_t confFCntUp = RADIOLIB_LORAWAN_FCNT_NONE;
+
912  uint32_t confFCntDown = RADIOLIB_LORAWAN_FCNT_NONE;
+
913  uint32_t adrFCnt = 0;
+
914 
+
915  // ADR is enabled by default
+
916  bool adrEnabled = true;
+
917 
+
918  // duty cycle is set upon initialization and activated in regions that impose this
+
919  bool dutyCycleEnabled = false;
+
920  uint32_t dutyCycle = 0;
+
921 
+
922  // dwell time is set upon initialization and activated in regions that impose this
+
923  bool dwellTimeEnabledUp = false;
+
924  uint16_t dwellTimeUp = 0;
+
925  bool dwellTimeEnabledDn = false;
+
926  uint16_t dwellTimeDn = 0;
+
927 
+
928  RadioLibTime_t tUplink = 0; // scheduled uplink transmission time (internal clock)
+
929  RadioLibTime_t tDownlink = 0; // time at end of downlink reception
+
930 
+
931  // enable/disable CSMA for LoRaWAN
+
932  bool csmaEnabled = false;
+
933 
+
934  // maximum number of channel hops during CSMA
+
935  uint8_t maxChanges = RADIOLIB_LORAWAN_MAX_CHANGES_DEFAULT;
+
936 
+
937  // number of backoff slots to be checked after DIFS phase.
+
938  // A random BO avoids collisions in the case where two or more nodes start the CSMA
+
939  // process at the same time.
+
940  uint8_t backoffMax = RADIOLIB_LORAWAN_BACKOFF_MAX_DEFAULT;
+
941 
+
942  // number of CADs to estimate a clear CH
+
943  uint8_t difsSlots = RADIOLIB_LORAWAN_DIFS_DEFAULT;
+
944 
+
945  // available channel frequencies from list passed during OTA activation
+
946  LoRaWANChannel_t channelPlan[2][RADIOLIB_LORAWAN_NUM_AVAILABLE_CHANNELS];
+
947 
+
948  // currently configured channels for TX, RX1, RX2
+
949  LoRaWANChannel_t channels[3] = { RADIOLIB_LORAWAN_CHANNEL_NONE, RADIOLIB_LORAWAN_CHANNEL_NONE,
+
950  RADIOLIB_LORAWAN_CHANNEL_NONE };
+
951 
+
952  // delays between the uplink and RX1/2 windows
+
953  // the first field is meaningless, but is used for offsetting for Rx windows 1 and 2
+
954  RadioLibTime_t rxDelays[3] = { 0, RADIOLIB_LORAWAN_RECEIVE_DELAY_1_MS, RADIOLIB_LORAWAN_RECEIVE_DELAY_2_MS };
+
955 
+
956  // offset between TX and RX1 (such that RX1 has equal or lower DR)
+
957  uint8_t rx1DrOffset = 0;
+
958 
+
959  // LoRaWAN revision (1.0 vs 1.1)
+
960  uint8_t rev = 0;
+
961 
+
962  // Time on Air of last uplink
+
963  RadioLibTime_t lastToA = 0;
+
964 
+
965  // timestamp to measure the RX1/2 delay (from uplink end)
+
966  RadioLibTime_t rxDelayStart = 0;
+
967 
+
968  // timestamp when the Rx1/2 windows were closed (timeout or uplink received)
+
969  RadioLibTime_t rxDelayEnd = 0;
+
970 
+
971  // device status - battery level
+
972  uint8_t battLevel = 0xFF;
+
973 
+
974  // indicates whether an uplink has MAC commands as payload
+
975  bool isMACPayload = false;
+
976 
+
977  // save the selected sub-band in case this must be restored in ADR control
+
978  uint8_t subBand = 0;
+
979 
+
980  // allow port 226 for devices implementing TS011
+
981  bool TS011 = false;
+
982 
+
983  // this will reset the device credentials, so the device starts completely new
+
984  void clearNonces();
+
985 
+
986  // start a fresh session using default parameters
+
987  void createSession(uint16_t lwMode, uint8_t initialDr);
+
988 
+
989  // setup Join-Request payload
+
990  void composeJoinRequest(uint8_t* joinRequestMsg);
+
991 
+
992  // extract Join-Accept payload and start a new session
+
993  int16_t processJoinAccept(LoRaWANJoinEvent_t *joinEvent);
+
994 
+
995  // a join-accept can piggy-back a set of channels or channel masks
+
996  void processCFList(uint8_t* cfList);
+
997 
+
998  // check whether payload length and fport are allowed
+
999  int16_t isValidUplink(uint8_t* len, uint8_t fPort);
+
1000 
+
1001  // perform ADR backoff
+
1002  void adrBackoff();
+
1003 
+
1004  // create an encrypted uplink buffer, composing metadata, user data and MAC data
+
1005  void composeUplink(uint8_t* in, uint8_t lenIn, uint8_t* out, uint8_t fPort, bool isConfirmed);
+
1006 
+
1007  // generate and set the MIC of an uplink buffer (depends on selected channels)
+
1008  void micUplink(uint8_t* inOut, uint8_t lenInOut);
+
1009 
+
1010  // transmit uplink buffer on a specified channel
+
1011  int16_t transmitUplink(LoRaWANChannel_t* chnl, uint8_t* in, uint8_t len, bool retrans);
+
1012 
+
1013  // wait for, open and listen during receive windows; only performs listening
+
1014  int16_t receiveCommon(uint8_t dir, const LoRaWANChannel_t* dlChannels, const RadioLibTime_t* dlDelays, uint8_t numWindows, RadioLibTime_t tReference);
+
1015 
+
1016  // extract downlink payload and process MAC commands
+
1017  int16_t parseDownlink(uint8_t* data, size_t* len, LoRaWANEvent_t* event = NULL);
+
1018 
+
1019  // execute mac command, return the number of processed bytes for sequential processing
+
1020  bool execMacCommand(uint8_t cid, uint8_t* optIn, uint8_t lenIn);
+
1021  bool execMacCommand(uint8_t cid, uint8_t* optIn, uint8_t lenIn, uint8_t* optOut);
+
1022 
+
1023  // possible override for additional MAC commands that are not in the base specification
+
1024  virtual bool derivedMacHandler(uint8_t cid, uint8_t* optIn, uint8_t lenIn, uint8_t* optOut);
+
1025 
+
1026  // pre-process a (set of) LinkAdrReq commands into one super-channel-mask + Tx/Dr/NbTrans fields
+
1027  void preprocessMacLinkAdr(uint8_t* mPtr, uint8_t cLen, uint8_t* mAdrOpt);
+
1028 
+
1029  // post-process a (set of) LinkAdrAns commands depending on LoRaWAN version
+
1030  void postprocessMacLinkAdr(uint8_t* ack, uint8_t cLen);
+
1031 
+
1032  // get the properties of a MAC command given a certain command ID
+
1033  int16_t getMacCommand(uint8_t cid, LoRaWANMacCommand_t* cmd);
+
1034 
+
1035  // possible override for additional MAC commands that are not in the base specification
+
1036  virtual int16_t derivedMacFinder(uint8_t cid, LoRaWANMacCommand_t* cmd);
+
1037 
+
1038  // get the length of a certain MAC command in a specific direction (up/down)
+
1039  // if inclusive is true, add one for the CID byte
+
1040  int16_t getMacLen(uint8_t cid, uint8_t* len, uint8_t dir, bool inclusive = false);
+
1041 
+
1042  // find out of a MAC command should persist destruction
+
1043  // in uplink direction, some commands must persist if no downlink is received
+
1044  // in downlink direction, the user-accessible MAC commands remain available for retrieval
+
1045  bool isPersistentMacCommand(uint8_t cid, uint8_t dir);
+
1046 
+
1047  // push MAC command to queue, done by copy
+
1048  int16_t pushMacCommand(uint8_t cid, uint8_t* cOcts, uint8_t* out, uint8_t* lenOut, uint8_t dir);
+
1049 
+
1050  // retrieve the payload of a certain MAC command, if present in the buffer
+
1051  int16_t getMacPayload(uint8_t cid, uint8_t* in, uint8_t lenIn, uint8_t* out, uint8_t dir);
+
1052 
+
1053  // delete a specific MAC command from queue, indicated by the command ID
+
1054  int16_t deleteMacCommand(uint8_t cid, uint8_t* inOut, uint8_t* lenInOut, uint8_t dir);
+
1055 
+
1056  // clear a MAC buffer, possible retaining persistent MAC commands
+
1057  void clearMacCommands(uint8_t* inOut, uint8_t* lenInOut, uint8_t dir);
+
1058 
+
1059  // configure the common physical layer properties (frequency, sync word etc.)
+
1060  int16_t setPhyProperties(const LoRaWANChannel_t* chnl, uint8_t dir, int8_t pwr, size_t pre = 0);
+
1061 
+
1062  // Performs CSMA as per LoRa Alliance Technical Recommendation 13 (TR-013).
+
1063  bool csmaChannelClear(uint8_t difs, uint8_t numBackoff);
+
1064 
+
1065  // perform a single CAD operation for the under SF/CH combination. Returns either busy or otherwise.
+
1066  bool cadChannelClear();
+
1067 
+
1068  // (dynamic bands:) get or (fixed bands:) create a complete 80-bit channel mask for current configuration
+
1069  void getChannelPlanMask(uint64_t* chMaskGrp0123, uint32_t* chMaskGrp45);
+
1070 
+
1071  // setup uplink/downlink channel data rates and frequencies
+
1072  // for dynamic channels, there is a small set of predefined channels
+
1073  // in case of JoinRequest, add some optional extra frequencies
+
1074  void selectChannelPlanDyn(bool joinRequest = false);
+
1075 
+
1076  // setup uplink/downlink channel data rates and frequencies
+
1077  // for fixed bands, we only allow one sub-band at a time to be selected
+
1078  void selectChannelPlanFix();
+
1079 
+
1080  // get the number of available channels,
+
1081  // along with a 16-bit mask indicating which channels can be used next for uplink/downlink
+
1082  uint8_t getAvailableChannels(uint16_t* mask);
+
1083 
+
1084  // (re)set/restore which channels can be used next for uplink/downlink
+
1085  void setAvailableChannels(uint16_t mask);
+
1086 
+
1087  // select a set of random TX/RX channels for up- and downlink
+
1088  int16_t selectChannels();
+
1089 
+
1090  // apply a 96-bit channel mask
+
1091  bool applyChannelMask(uint64_t chMaskGrp0123, uint32_t chMaskGrp45);
+
1092 
+
1093 #if RADIOLIB_DEBUG_PROTOCOL
+
1094  // print the available channels through debug
+
1095  void printChannels();
+
1096 #endif
+
1097 
+
1098  // method to generate message integrity code
+
1099  uint32_t generateMIC(uint8_t* msg, size_t len, uint8_t* key);
+
1100 
+
1101  // method to verify message integrity code
+
1102  // it assumes that the MIC is the last 4 bytes of the message
+
1103  bool verifyMIC(uint8_t* msg, size_t len, uint8_t* key);
+
1104 
+
1105  // find the first usable data rate for the given band
+
1106  int16_t findDataRate(uint8_t dr, DataRate_t* dataRate);
+
1107 
+
1108  // function to encrypt and decrypt payloads (regular uplink/downlink)
+
1109  void processAES(const uint8_t* in, size_t len, uint8_t* key, uint8_t* out, uint32_t fCnt, uint8_t dir, uint8_t ctrId, bool counter);
+
1110 
+
1111  // 16-bit checksum method that takes a uint8_t array of even length and calculates the checksum
+
1112  static uint16_t checkSum16(const uint8_t *key, uint16_t keyLen);
+
1113 
+
1114  // check the integrity of a buffer using a 16-bit checksum located in the last two bytes of the buffer
+
1115  static int16_t checkBufferCommon(uint8_t *buffer, uint16_t size);
+
1116 
+
1117  // network-to-host conversion method - takes data from network packet and converts it to the host endians
+
1118  template<typename T>
+
1119  static T ntoh(uint8_t* buff, size_t size = 0);
+
1120 
+
1121  // host-to-network conversion method - takes data from host variable and and converts it to network packet endians
+
1122  template<typename T>
+
1123  static void hton(uint8_t* buff, T val, size_t size = 0);
+
1124 };
+
1125 
+
1126 template<typename T>
+
1127 T LoRaWANNode::ntoh(uint8_t* buff, size_t size) {
+
1128  uint8_t* buffPtr = buff;
+
1129  size_t targetSize = sizeof(T);
+
1130  if(size != 0) {
+
1131  targetSize = size;
+
1132  }
+
1133  T res = 0;
+
1134  for(size_t i = 0; i < targetSize; i++) {
+
1135  res |= (uint32_t)(*(buffPtr++)) << 8*i;
+
1136  }
+
1137  return(res);
+
1138 }
+
1139 
+
1140 template<typename T>
+
1141 void LoRaWANNode::hton(uint8_t* buff, T val, size_t size) {
+
1142  uint8_t* buffPtr = buff;
+
1143  size_t targetSize = sizeof(T);
+
1144  if(size != 0) {
+
1145  targetSize = size;
+
1146  }
+
1147  for(size_t i = 0; i < targetSize; i++) {
+
1148  *(buffPtr++) = val >> 8*i;
+
1149  }
+
1150 }
+
1151 
+
1152 #endif
+
LoRaWANNode
LoRaWAN-compatible node (class A device).
Definition: LoRaWAN.h:529
LoRaWANNode::clearSession
void clearSession()
Clear an active session, so that the device will have to rejoin the network.
Definition: LoRaWAN.cpp:280
LoRaWANNode::setBufferNonces
int16_t setBufferNonces(uint8_t *persistentBuffer)
Fill the internal buffer that holds the LW base parameters with a supplied buffer.
Definition: LoRaWAN.cpp:244
LoRaWANNode::sendReceive
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:45
LoRaWANNode::setDatarate
int16_t setDatarate(uint8_t drUp)
Set uplink datarate. This should not be used when ADR is enabled.
Definition: LoRaWAN.cpp:2599
LoRaWANNode::scheduleTransmission
void scheduleTransmission(RadioLibTime_t tUplink)
Set the exact time a transmission should occur. Note: this is the internal clock time....
Definition: LoRaWAN.cpp:2730
-
LoRaWANNode::scanGuard
RadioLibTime_t scanGuard
Rx window padding in milliseconds according to the spec, the Rx window must be at least enough time t...
Definition: LoRaWAN.h:857
+
LoRaWANNode::scanGuard
RadioLibTime_t scanGuard
Rx window padding in milliseconds according to the spec, the Rx window must be at least enough time t...
Definition: LoRaWAN.h:858
LoRaWANNode::setCSMA
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:2712
LoRaWANNode::setDutyCycle
void setDutyCycle(bool enable=true, RadioLibTime_t msPerHour=0)
Toggle adherence to dutyCycle limits to on or off.
Definition: LoRaWAN.cpp:2689
LoRaWANNode::beginABP
int16_t beginABP(uint32_t addr, uint8_t *fNwkSIntKey, uint8_t *sNwkSIntKey, uint8_t *nwkSEncKey, uint8_t *appSKey)
Set the device credentials and activation configuration.
Definition: LoRaWAN.cpp:620
@@ -920,7 +921,7 @@ $(document).ready(function(){initNavTree('_lo_ra_w_a_n_8h_source.html',''); init
LoRaWANNode::getAFCntDown
uint32_t getAFCntDown()
Returns the last application downlink's frame counter; also 0 if no application downlink occured yet.
Definition: LoRaWAN.cpp:2746
LoRaWANNode::getLastToA
RadioLibTime_t getLastToA()
Get the Time-on-air of the last uplink message (in milliseconds).
Definition: LoRaWAN.cpp:2759
LoRaWANNode::activateABP
virtual int16_t activateABP(uint8_t initialDr=RADIOLIB_LORAWAN_DATA_RATE_UNUSED)
Join network by restoring ABP session or performing over-the-air activation. In this procedure,...
Definition: LoRaWAN.cpp:966
-
LoRaWANNode::TS009
bool TS009
TS009 Protocol Specification Verification switch (allows FPort 224 and cuts off uplink payload instea...
Definition: LoRaWAN.h:843
+
LoRaWANNode::TS009
bool TS009
TS009 Protocol Specification Verification switch (allows FPort 224 and cuts off uplink payload instea...
Definition: LoRaWAN.h:844
LoRaWANNode::getBufferNonces
uint8_t * getBufferNonces()
Returns the pointer to the internal buffer that holds the LW base parameters.
Definition: LoRaWAN.cpp:229
LoRaWANNode::getBufferSession
uint8_t * getBufferSession()
Returns the pointer to the internal buffer that holds the LW session parameters.
Definition: LoRaWAN.cpp:435
LoRaWANNode::isActivated
bool isActivated()
Whether there is an ongoing session active.
Definition: LoRaWAN.cpp:1057
@@ -941,64 +942,64 @@ $(document).ready(function(){initNavTree('_lo_ra_w_a_n_8h_source.html',''); init
LoRaWANNode::resetFCntDown
void resetFCntDown()
Reset the downlink frame counters (application and network) This is unsafe and can possibly allow rep...
Definition: LoRaWAN.cpp:2750
PhysicalLayer
Provides common interface for protocols that run on LoRa/FSK modules, such as RTTY or LoRaWAN....
Definition: PhysicalLayer.h:151
RadioLibTime_t
unsigned long RadioLibTime_t
Type used for durations in RadioLib.
Definition: TypeDef.h:642
-
LoRaWANBand_t
Structure to save information about LoRaWAN band.
Definition: LoRaWAN.h:370
-
LoRaWANBand_t::powerMax
int8_t powerMax
Maximum allowed output power in this band in dBm.
Definition: LoRaWAN.h:387
-
LoRaWANBand_t::txParamSupported
bool txParamSupported
Whether this band implements the MAC command TxParamSetupReq.
Definition: LoRaWAN.h:402
-
LoRaWANBand_t::txAck
LoRaWANChannel_t txAck[2]
Relay channels for ACK downlink.
Definition: LoRaWAN.h:428
-
LoRaWANBand_t::dutyCycle
RadioLibTime_t dutyCycle
Number of milliseconds per hour of allowed Time-on-Air.
Definition: LoRaWAN.h:393
-
LoRaWANBand_t::dataRates
uint8_t dataRates[RADIOLIB_LORAWAN_CHANNEL_NUM_DATARATES]
The corresponding datarates, bandwidths and coding rates for DR index.
Definition: LoRaWAN.h:431
-
LoRaWANBand_t::dwellTimeUp
RadioLibTime_t dwellTimeUp
Maximum dwell time per uplink message in milliseconds.
Definition: LoRaWAN.h:396
-
LoRaWANBand_t::txWoR
LoRaWANChannel_t txWoR[2]
Relay channels for WoR uplink.
Definition: LoRaWAN.h:425
-
LoRaWANBand_t::freqMin
uint32_t freqMin
Minimum allowed frequency (coded in 100 Hz steps)
Definition: LoRaWAN.h:378
-
LoRaWANBand_t::payloadLenMax
uint8_t payloadLenMax[RADIOLIB_LORAWAN_CHANNEL_NUM_DATARATES]
Array of allowed maximum application payload lengths for each data rate (N-value)
Definition: LoRaWAN.h:384
-
LoRaWANBand_t::txFreqs
LoRaWANChannel_t txFreqs[3]
A set of default uplink (TX) channels for dynamic bands.
Definition: LoRaWAN.h:405
-
LoRaWANBand_t::txJoinReq
LoRaWANChannel_t txJoinReq[3]
A set of possible extra channels for the Join-Request message for dynamic bands.
Definition: LoRaWAN.h:408
-
LoRaWANBand_t::powerNumSteps
int8_t powerNumSteps
Number of power steps in this band.
Definition: LoRaWAN.h:390
-
LoRaWANBand_t::txSpans
LoRaWANChannelSpan_t txSpans[2]
Default uplink (TX) channel spans for fixed bands, including Join-Request parameters.
Definition: LoRaWAN.h:414
-
LoRaWANBand_t::bandNum
uint8_t bandNum
Identier for this band.
Definition: LoRaWAN.h:372
-
LoRaWANBand_t::freqMax
uint32_t freqMax
Maximum allowed frequency (coded in 100 Hz steps)
Definition: LoRaWAN.h:381
-
LoRaWANBand_t::bandType
uint8_t bandType
Whether the channels are fixed per specification, or dynamically allocated through the network (plus ...
Definition: LoRaWAN.h:375
-
LoRaWANBand_t::rx2
LoRaWANChannel_t rx2
Backup channel for downlink (RX2) window.
Definition: LoRaWAN.h:422
-
LoRaWANBand_t::numTxSpans
uint8_t numTxSpans
The number of TX channel spans for fixed bands.
Definition: LoRaWAN.h:411
-
LoRaWANBand_t::dwellTimeDn
RadioLibTime_t dwellTimeDn
Maximum dwell time per downlink message in milliseconds.
Definition: LoRaWAN.h:399
-
LoRaWANBand_t::rx1Span
LoRaWANChannelSpan_t rx1Span
Default downlink (RX1) channel span for fixed bands.
Definition: LoRaWAN.h:417
+
LoRaWANBand_t
Structure to save information about LoRaWAN band.
Definition: LoRaWAN.h:371
+
LoRaWANBand_t::powerMax
int8_t powerMax
Maximum allowed output power in this band in dBm.
Definition: LoRaWAN.h:388
+
LoRaWANBand_t::txParamSupported
bool txParamSupported
Whether this band implements the MAC command TxParamSetupReq.
Definition: LoRaWAN.h:403
+
LoRaWANBand_t::txAck
LoRaWANChannel_t txAck[2]
Relay channels for ACK downlink.
Definition: LoRaWAN.h:429
+
LoRaWANBand_t::dutyCycle
RadioLibTime_t dutyCycle
Number of milliseconds per hour of allowed Time-on-Air.
Definition: LoRaWAN.h:394
+
LoRaWANBand_t::dataRates
uint8_t dataRates[RADIOLIB_LORAWAN_CHANNEL_NUM_DATARATES]
The corresponding datarates, bandwidths and coding rates for DR index.
Definition: LoRaWAN.h:432
+
LoRaWANBand_t::dwellTimeUp
RadioLibTime_t dwellTimeUp
Maximum dwell time per uplink message in milliseconds.
Definition: LoRaWAN.h:397
+
LoRaWANBand_t::txWoR
LoRaWANChannel_t txWoR[2]
Relay channels for WoR uplink.
Definition: LoRaWAN.h:426
+
LoRaWANBand_t::freqMin
uint32_t freqMin
Minimum allowed frequency (coded in 100 Hz steps)
Definition: LoRaWAN.h:379
+
LoRaWANBand_t::payloadLenMax
uint8_t payloadLenMax[RADIOLIB_LORAWAN_CHANNEL_NUM_DATARATES]
Array of allowed maximum application payload lengths for each data rate (N-value)
Definition: LoRaWAN.h:385
+
LoRaWANBand_t::txFreqs
LoRaWANChannel_t txFreqs[3]
A set of default uplink (TX) channels for dynamic bands.
Definition: LoRaWAN.h:406
+
LoRaWANBand_t::txJoinReq
LoRaWANChannel_t txJoinReq[3]
A set of possible extra channels for the Join-Request message for dynamic bands.
Definition: LoRaWAN.h:409
+
LoRaWANBand_t::powerNumSteps
int8_t powerNumSteps
Number of power steps in this band.
Definition: LoRaWAN.h:391
+
LoRaWANBand_t::txSpans
LoRaWANChannelSpan_t txSpans[2]
Default uplink (TX) channel spans for fixed bands, including Join-Request parameters.
Definition: LoRaWAN.h:415
+
LoRaWANBand_t::bandNum
uint8_t bandNum
Identier for this band.
Definition: LoRaWAN.h:373
+
LoRaWANBand_t::freqMax
uint32_t freqMax
Maximum allowed frequency (coded in 100 Hz steps)
Definition: LoRaWAN.h:382
+
LoRaWANBand_t::bandType
uint8_t bandType
Whether the channels are fixed per specification, or dynamically allocated through the network (plus ...
Definition: LoRaWAN.h:376
+
LoRaWANBand_t::rx2
LoRaWANChannel_t rx2
Backup channel for downlink (RX2) window.
Definition: LoRaWAN.h:423
+
LoRaWANBand_t::numTxSpans
uint8_t numTxSpans
The number of TX channel spans for fixed bands.
Definition: LoRaWAN.h:412
+
LoRaWANBand_t::dwellTimeDn
RadioLibTime_t dwellTimeDn
Maximum dwell time per downlink message in milliseconds.
Definition: LoRaWAN.h:400
+
LoRaWANBand_t::rx1Span
LoRaWANChannelSpan_t rx1Span
Default downlink (RX1) channel span for fixed bands.
Definition: LoRaWAN.h:418
LoRaWANBandNum_t
IDs of all currently supported bands.
-
LoRaWANChannel_t
Structure to save information about LoRaWAN channels. To save space, adjacent channels are saved in "...
Definition: LoRaWAN.h:311
-
LoRaWANChannel_t::available
bool available
Whether this channel is available for channel selection.
Definition: LoRaWAN.h:331
-
LoRaWANChannel_t::dr
uint8_t dr
Datarate currently in use on this channel.
Definition: LoRaWAN.h:328
-
LoRaWANChannel_t::freq
uint32_t freq
The channel frequency (coded in 100 Hz steps)
Definition: LoRaWAN.h:319
-
LoRaWANChannel_t::idx
uint8_t idx
The channel number, as specified by defaults or the network.
Definition: LoRaWAN.h:316
-
LoRaWANChannel_t::drMin
uint8_t drMin
Minimum allowed datarate for this channel.
Definition: LoRaWAN.h:322
-
LoRaWANChannel_t::enabled
bool enabled
Whether this channel is enabled (can be used) or is disabled.
Definition: LoRaWAN.h:313
-
LoRaWANChannel_t::drMax
uint8_t drMax
Maximum allowed datarate for this channel (inclusive)
Definition: LoRaWAN.h:325
-
LoRaWANChannelSpan_t
Structure to save information about LoRaWAN channels. To save space, adjacent channels are saved in "...
Definition: LoRaWAN.h:343
-
LoRaWANChannelSpan_t::drJoinRequest
uint8_t drJoinRequest
Allowed data rates for a join request message.
Definition: LoRaWAN.h:360
-
LoRaWANChannelSpan_t::freqStart
uint32_t freqStart
Center frequency of the first channel in span (coded in 100 Hz steps)
Definition: LoRaWAN.h:348
-
LoRaWANChannelSpan_t::numChannels
uint8_t numChannels
Total number of channels in the span.
Definition: LoRaWAN.h:345
-
LoRaWANChannelSpan_t::drMax
uint8_t drMax
Maximum allowed datarate for all channels in this span (inclusive)
Definition: LoRaWAN.h:357
-
LoRaWANChannelSpan_t::freqStep
uint32_t freqStep
Frequency step between adjacent channels (coded in 100 Hz steps)
Definition: LoRaWAN.h:351
-
LoRaWANChannelSpan_t::drMin
uint8_t drMin
Minimum allowed datarate for all channels in this span.
Definition: LoRaWAN.h:354
-
LoRaWANEvent_t
Structure to save extra information about uplink/downlink event.
Definition: LoRaWAN.h:491
-
LoRaWANEvent_t::freq
float freq
Frequency in MHz.
Definition: LoRaWAN.h:509
-
LoRaWANEvent_t::confirmed
bool confirmed
Whether the event is confirmed or not (e.g., confirmed uplink sent by user application)
Definition: LoRaWAN.h:496
-
LoRaWANEvent_t::fPort
uint8_t fPort
Port number.
Definition: LoRaWAN.h:518
-
LoRaWANEvent_t::power
int16_t power
Transmit power in dBm for uplink, or RSSI for downlink.
Definition: LoRaWAN.h:512
-
LoRaWANEvent_t::confirming
bool confirming
Whether the event is confirming a previous request (e.g., server downlink reply to confirmed uplink s...
Definition: LoRaWAN.h:500
-
LoRaWANEvent_t::datarate
uint8_t datarate
Datarate.
Definition: LoRaWAN.h:506
-
LoRaWANEvent_t::dir
uint8_t dir
Event direction, one of RADIOLIB_LORAWAN_CHANNEL_DIR_*.
Definition: LoRaWAN.h:493
-
LoRaWANEvent_t::nbTrans
uint8_t nbTrans
Number of times this uplink was transmitted (ADR)
Definition: LoRaWAN.h:521
-
LoRaWANEvent_t::fCnt
uint32_t fCnt
The appropriate frame counter - for different events, different frame counters will be reported!
Definition: LoRaWAN.h:515
-
LoRaWANEvent_t::frmPending
bool frmPending
Whether further downlink messages are pending on the server side.
Definition: LoRaWAN.h:503
-
LoRaWANJoinEvent_t
Structure to save extra information about activation event.
Definition: LoRaWAN.h:476
-
LoRaWANJoinEvent_t::newSession
bool newSession
Whether a new session was started.
Definition: LoRaWAN.h:478
-
LoRaWANJoinEvent_t::joinNonce
uint32_t joinNonce
The received Join-Request JoinNonce value.
Definition: LoRaWAN.h:484
-
LoRaWANJoinEvent_t::devNonce
uint16_t devNonce
The transmitted Join-Request DevNonce value.
Definition: LoRaWAN.h:481
-
LoRaWANMacCommand_t
MAC command specification structure.
Definition: LoRaWAN.h:214
-
LoRaWANMacCommand_t::lenDn
const uint8_t lenDn
Uplink message length.
Definition: LoRaWAN.h:219
-
LoRaWANMacCommand_t::user
const bool user
Whether this MAC command can be issued by the user or not.
Definition: LoRaWAN.h:228
-
LoRaWANMacCommand_t::cid
const uint8_t cid
Command ID.
Definition: LoRaWAN.h:216
-
LoRaWANMacCommand_t::lenUp
const uint8_t lenUp
Downlink message length.
Definition: LoRaWAN.h:222
-
LoRaWANMacCommand_t::persist
const bool persist
Some commands must be resent until Class A downlink received.
Definition: LoRaWAN.h:225
+
LoRaWANChannel_t
Structure to save information about LoRaWAN channels. To save space, adjacent channels are saved in "...
Definition: LoRaWAN.h:312
+
LoRaWANChannel_t::available
bool available
Whether this channel is available for channel selection.
Definition: LoRaWAN.h:332
+
LoRaWANChannel_t::dr
uint8_t dr
Datarate currently in use on this channel.
Definition: LoRaWAN.h:329
+
LoRaWANChannel_t::freq
uint32_t freq
The channel frequency (coded in 100 Hz steps)
Definition: LoRaWAN.h:320
+
LoRaWANChannel_t::idx
uint8_t idx
The channel number, as specified by defaults or the network.
Definition: LoRaWAN.h:317
+
LoRaWANChannel_t::drMin
uint8_t drMin
Minimum allowed datarate for this channel.
Definition: LoRaWAN.h:323
+
LoRaWANChannel_t::enabled
bool enabled
Whether this channel is enabled (can be used) or is disabled.
Definition: LoRaWAN.h:314
+
LoRaWANChannel_t::drMax
uint8_t drMax
Maximum allowed datarate for this channel (inclusive)
Definition: LoRaWAN.h:326
+
LoRaWANChannelSpan_t
Structure to save information about LoRaWAN channels. To save space, adjacent channels are saved in "...
Definition: LoRaWAN.h:344
+
LoRaWANChannelSpan_t::drJoinRequest
uint8_t drJoinRequest
Allowed data rates for a join request message.
Definition: LoRaWAN.h:361
+
LoRaWANChannelSpan_t::freqStart
uint32_t freqStart
Center frequency of the first channel in span (coded in 100 Hz steps)
Definition: LoRaWAN.h:349
+
LoRaWANChannelSpan_t::numChannels
uint8_t numChannels
Total number of channels in the span.
Definition: LoRaWAN.h:346
+
LoRaWANChannelSpan_t::drMax
uint8_t drMax
Maximum allowed datarate for all channels in this span (inclusive)
Definition: LoRaWAN.h:358
+
LoRaWANChannelSpan_t::freqStep
uint32_t freqStep
Frequency step between adjacent channels (coded in 100 Hz steps)
Definition: LoRaWAN.h:352
+
LoRaWANChannelSpan_t::drMin
uint8_t drMin
Minimum allowed datarate for all channels in this span.
Definition: LoRaWAN.h:355
+
LoRaWANEvent_t
Structure to save extra information about uplink/downlink event.
Definition: LoRaWAN.h:492
+
LoRaWANEvent_t::freq
float freq
Frequency in MHz.
Definition: LoRaWAN.h:510
+
LoRaWANEvent_t::confirmed
bool confirmed
Whether the event is confirmed or not (e.g., confirmed uplink sent by user application)
Definition: LoRaWAN.h:497
+
LoRaWANEvent_t::fPort
uint8_t fPort
Port number.
Definition: LoRaWAN.h:519
+
LoRaWANEvent_t::power
int16_t power
Transmit power in dBm for uplink, or RSSI for downlink.
Definition: LoRaWAN.h:513
+
LoRaWANEvent_t::confirming
bool confirming
Whether the event is confirming a previous request (e.g., server downlink reply to confirmed uplink s...
Definition: LoRaWAN.h:501
+
LoRaWANEvent_t::datarate
uint8_t datarate
Datarate.
Definition: LoRaWAN.h:507
+
LoRaWANEvent_t::dir
uint8_t dir
Event direction, one of RADIOLIB_LORAWAN_CHANNEL_DIR_*.
Definition: LoRaWAN.h:494
+
LoRaWANEvent_t::nbTrans
uint8_t nbTrans
Number of times this uplink was transmitted (ADR)
Definition: LoRaWAN.h:522
+
LoRaWANEvent_t::fCnt
uint32_t fCnt
The appropriate frame counter - for different events, different frame counters will be reported!
Definition: LoRaWAN.h:516
+
LoRaWANEvent_t::frmPending
bool frmPending
Whether further downlink messages are pending on the server side.
Definition: LoRaWAN.h:504
+
LoRaWANJoinEvent_t
Structure to save extra information about activation event.
Definition: LoRaWAN.h:477
+
LoRaWANJoinEvent_t::newSession
bool newSession
Whether a new session was started.
Definition: LoRaWAN.h:479
+
LoRaWANJoinEvent_t::joinNonce
uint32_t joinNonce
The received Join-Request JoinNonce value.
Definition: LoRaWAN.h:485
+
LoRaWANJoinEvent_t::devNonce
uint16_t devNonce
The transmitted Join-Request DevNonce value.
Definition: LoRaWAN.h:482
+
LoRaWANMacCommand_t
MAC command specification structure.
Definition: LoRaWAN.h:215
+
LoRaWANMacCommand_t::lenDn
const uint8_t lenDn
Uplink message length.
Definition: LoRaWAN.h:220
+
LoRaWANMacCommand_t::user
const bool user
Whether this MAC command can be issued by the user or not.
Definition: LoRaWAN.h:229
+
LoRaWANMacCommand_t::cid
const uint8_t cid
Command ID.
Definition: LoRaWAN.h:217
+
LoRaWANMacCommand_t::lenUp
const uint8_t lenUp
Downlink message length.
Definition: LoRaWAN.h:223
+
LoRaWANMacCommand_t::persist
const bool persist
Some commands must be resent until Class A downlink received.
Definition: LoRaWAN.h:226
DataRate_t
Common data rate structure.
Definition: PhysicalLayer.h:74
diff --git a/_physical_layer_8h_source.html b/_physical_layer_8h_source.html index 80911357..ad833d53 100644 --- a/_physical_layer_8h_source.html +++ b/_physical_layer_8h_source.html @@ -128,7 +128,7 @@ $(document).ready(function(){initNavTree('_physical_layer_8h_source.html',''); i
53 };
54 
59 struct LrFhssRate_t {
-
61  uint8_t bw;
+
61  float bw;
62 
64  uint8_t cr;
65 
@@ -390,7 +390,7 @@ $(document).ready(function(){initNavTree('_physical_layer_8h_source.html',''); i
BellClient
Client for Bell modem communication. The public interface is the same as Arduino Serial.
Definition: BellModem.h:54
FSK4Client
Client for FSK-4 communication. The public interface is the same as Arduino Serial.
Definition: FSK4.h:15
HellClient
Client for Hellschreiber transmissions.
Definition: Hellschreiber.h:90
-
LoRaWANNode
LoRaWAN-compatible node (class A device).
Definition: LoRaWAN.h:528
+
LoRaWANNode
LoRaWAN-compatible node (class A device).
Definition: LoRaWAN.h:529
Module
Implements all common low-level methods to control the wireless module. Every module class contains o...
Definition: Module.h:73
MorseClient
Client for Morse Code communication. The public interface is the same as Arduino Serial.
Definition: Morse.h:93
PagerClient
Client for Pager communication.
Definition: Pager.h:62
@@ -474,7 +474,7 @@ $(document).ready(function(){initNavTree('_physical_layer_8h_source.html',''); i
LrFhssRate_t
Data rate structure interpretation in case LR-FHSS is used.
Definition: PhysicalLayer.h:59
LrFhssRate_t::narrowGrid
bool narrowGrid
Grid spacing.
Definition: PhysicalLayer.h:67
LrFhssRate_t::cr
uint8_t cr
Coding rate.
Definition: PhysicalLayer.h:64
-
LrFhssRate_t::bw
uint8_t bw
Bandwidth.
Definition: PhysicalLayer.h:61
+
LrFhssRate_t::bw
float bw
Bandwidth.
Definition: PhysicalLayer.h:61
RSSIScanConfig_t
Channel scan configuration interpretation in case RSSI threshold is used.
Definition: PhysicalLayer.h:116
RSSIScanConfig_t::limit
float limit
RSSI limit in dBm.
Definition: PhysicalLayer.h:118
ChannelScanConfig_t
Common channel scan configuration structure.
Definition: PhysicalLayer.h:125
diff --git a/functions_b.html b/functions_b.html index 765ebe93..fb255b35 100644 --- a/functions_b.html +++ b/functions_b.html @@ -190,7 +190,7 @@ $(document).ready(function(){initNavTree('functions_b.html',''); initResizable() : FSKRate_t
  • bw -: LrFhssRate_t +: LrFhssRate_t
  • byteArr() : ITA2String diff --git a/functions_vars.html b/functions_vars.html index 55cae371..8eb2878e 100644 --- a/functions_vars.html +++ b/functions_vars.html @@ -123,7 +123,7 @@ $(document).ready(function(){initNavTree('functions_vars.html',''); initResizabl : FSKRate_t
  • bw -: LrFhssRate_t +: LrFhssRate_t
  • diff --git a/navtreeindex7.js b/navtreeindex7.js index 51b6957b..7daf7a5a 100644 --- a/navtreeindex7.js +++ b/navtreeindex7.js @@ -22,7 +22,7 @@ var NAVTREEINDEX7 = "struct_lr_fhss_rate__t.html":[3,0,39], "struct_lr_fhss_rate__t.html#a29dec307a472c34e9fafb10af3c4fb9c":[3,0,39,2], "struct_lr_fhss_rate__t.html#a3eb7a2c2f4f23face4d6706aa8084c6b":[3,0,39,1], -"struct_lr_fhss_rate__t.html#a965dcb7da1b9adc4818ae9e908585f21":[3,0,39,0], +"struct_lr_fhss_rate__t.html#afb7412c51412d19e9d3cc1534b5a7e90":[3,0,39,0], "struct_module_1_1_rf_switch_mode__t.html":[3,0,40,0], "struct_module_1_1_rf_switch_mode__t.html#a2442217bfabfb124a3f46bb128aa7462":[3,0,40,0,0], "struct_module_1_1_rf_switch_mode__t.html#a694fecae172f868d8ca400319920ed66":[3,0,40,0,1], diff --git a/search/all_1.js b/search/all_1.js index 43f6d738..481a4d43 100644 --- a/search/all_1.js +++ b/search/all_1.js @@ -18,6 +18,6 @@ var searchData= ['bellclient_28',['BellClient',['../class_bell_client.html#a20fcf0322ef40c31b3bc329f7d89a177',1,'BellClient::BellClient(PhysicalLayer *phy, uint32_t pin)'],['../class_bell_client.html#ab9d0d76bb88fc8bdc995ab800063c149',1,'BellClient::BellClient(AFSKClient *aud)'],['../class_bell_client.html',1,'BellClient']]], ['bellmodem_5ft_29',['BellModem_t',['../struct_bell_modem__t.html',1,'']]], ['bitrate_30',['bitRate',['../struct_f_s_k_rate__t.html#a2500c6dee65326b52d4e58ecf4b6d107',1,'FSKRate_t']]], - ['bw_31',['bw',['../struct_lr_fhss_rate__t.html#a965dcb7da1b9adc4818ae9e908585f21',1,'LrFhssRate_t']]], + ['bw_31',['bw',['../struct_lr_fhss_rate__t.html#afb7412c51412d19e9d3cc1534b5a7e90',1,'LrFhssRate_t']]], ['bytearr_32',['byteArr',['../class_i_t_a2_string.html#a3f42f7ad98473dbe36515e676622ed3d',1,'ITA2String']]] ]; diff --git a/search/variables_1.js b/search/variables_1.js index bad9c590..fedd5936 100644 --- a/search/variables_1.js +++ b/search/variables_1.js @@ -7,5 +7,5 @@ var searchData= ['beidou_1176',['beidou',['../struct_l_r11x0_gnss_almanac_status__t.html#a6ecc7d7bbc090f380ca6d2d8774f7ca0',1,'LR11x0GnssAlmanacStatus_t']]], ['beidousvnoalmanacflags_1177',['beidouSvNoAlmanacFlags',['../struct_l_r11x0_gnss_almanac_status__t.html#ab040b1d9ccf9c6497b008d11a93ebfdf',1,'LR11x0GnssAlmanacStatus_t']]], ['bitrate_1178',['bitRate',['../struct_f_s_k_rate__t.html#a2500c6dee65326b52d4e58ecf4b6d107',1,'FSKRate_t']]], - ['bw_1179',['bw',['../struct_lr_fhss_rate__t.html#a965dcb7da1b9adc4818ae9e908585f21',1,'LrFhssRate_t']]] + ['bw_1179',['bw',['../struct_lr_fhss_rate__t.html#afb7412c51412d19e9d3cc1534b5a7e90',1,'LrFhssRate_t']]] ]; diff --git a/struct_lr_fhss_rate__t-members.html b/struct_lr_fhss_rate__t-members.html index f376df75..37680104 100644 --- a/struct_lr_fhss_rate__t-members.html +++ b/struct_lr_fhss_rate__t-members.html @@ -89,7 +89,7 @@ $(document).ready(function(){initNavTree('struct_lr_fhss_rate__t.html',''); init

    This is the complete list of members for LrFhssRate_t, including all inherited members.

    - +
    bwLrFhssRate_t
    bwLrFhssRate_t
    crLrFhssRate_t
    narrowGridLrFhssRate_t
    diff --git a/struct_lr_fhss_rate__t.html b/struct_lr_fhss_rate__t.html index a8388a98..a3866467 100644 --- a/struct_lr_fhss_rate__t.html +++ b/struct_lr_fhss_rate__t.html @@ -97,10 +97,10 @@ $(document).ready(function(){initNavTree('struct_lr_fhss_rate__t.html',''); init - - - + + + diff --git a/struct_lr_fhss_rate__t.js b/struct_lr_fhss_rate__t.js index 5959c6ce..7a6851e6 100644 --- a/struct_lr_fhss_rate__t.js +++ b/struct_lr_fhss_rate__t.js @@ -1,6 +1,6 @@ var struct_lr_fhss_rate__t = [ - [ "bw", "struct_lr_fhss_rate__t.html#a965dcb7da1b9adc4818ae9e908585f21", null ], + [ "bw", "struct_lr_fhss_rate__t.html#afb7412c51412d19e9d3cc1534b5a7e90", null ], [ "cr", "struct_lr_fhss_rate__t.html#a3eb7a2c2f4f23face4d6706aa8084c6b", null ], [ "narrowGrid", "struct_lr_fhss_rate__t.html#a29dec307a472c34e9fafb10af3c4fb9c", null ] ]; \ No newline at end of file

    Public Attributes

    -uint8_t bw
     Bandwidth.
     
    +float bw
     Bandwidth.
     
    uint8_t cr
     Coding rate.