Wiki source code of LoRaWAN Communication Debug

Version 40.1 by Bei Jinggeng on 2023/04/23 10:58

Show last authors
1 **~ Table of Contents:**
2
3 {{toc/}}
4
5
6
7 = 1.(% style="display:none" %) (%%) OTAA Join Process Debug =
8
9
10 These pages are useful to check what is wrong on the Join process. Below shows the four steps that we can check the Join Process.
11 \\**If user has checked below steps and still can't solve the problem, please send us (support @ dragino.com) the sceenshots for each step to check. They include:**
12
13 * End node console to show the Join freuqency and DR. (If possible)
14
15 * Gateway (from gateway UI) traffic to show the packet got from end node and receive from Server. (If possible)
16
17 * Gateway traffic (from server UI) to shows the data exchange between gateway and server. (Normaly possible)
18
19 * End Node traffic (from server UI) to shows end node activity in server. (Normaly possible)
20
21 * End Node Keys screen shot shows in end node and server. so we can check if the keys are correct. (In most case, we found keys doesn't match, especially APP EUI)
22
23 (% style="color:blue" %)**1. End Device Join Screen shot, we can check:**
24
25 * If the device is sending join request to server?
26
27 * What frequency the device is sending?
28
29 [[image:image-20220526164956-15.png||height="591" width="1153"]]
30
31 Console Output from End device to see the transmit frequency
32
33
34
35 (% style="color:blue" %)**2. Gateway packet traffic in gateway web or ssh. we can check:**
36
37 * If the gateway receive the Join request packet from sensor? (If this fail, check if the gateway and sensor works on the match frequency)
38
39 * If the gateway gets the Join Accept message from server and transmit it via LoRa?
40
41 [[image:image-20220526163608-2.png]]
42
43 Console Output from Gateway to see packets between end node and server.
44
45
46
47 (% style="color:blue" %)**3. Gateway Traffic Page in LoRaWAN Server**
48
49 * If the Join Request packet arrive the gateway traffic in server? If not, check the internet connection and gateway LoRaWAN server settings.
50
51 * If the server send back a Join Accept for the Join Request? if not, check if the keys from the device match the keys you put in the server, or try to choose a different server route for this end device.
52
53 * If the Join Accept message are in correct frequency? If you set the server to use US915 band, and your end node and gateway is EU868, you will see the Join Accept message are in US915 band so no possible to Join success.
54
55 [[image:image-20220526163633-3.png]]
56
57 The Traffic for the End node in the server, use TTN as example
58
59
60
61 (% style="color:blue" %)**4. Data Page in LoRaWAN server**
62
63 * If this data page shows the Join Request message from the end node? If not, most properly you have wrong settings in the keys. Keys in the server doesn't match the keys in End Node.
64
65 [[image:image-20220526163704-4.png]]
66
67 The data for the end device set in server
68
69
70 [[image:image-20220526163732-5.png]]
71
72 Check if OTAA Keys match the keys in device
73
74
75 = 2. Notice of US915/CN470/AU915 Frequency band =
76
77
78 (((
79 If user has problem to work with lorawan server in band US915/AU915/CN470, he can check:
80 )))
81
82 * (((
83 What **sub-band** the server support ?
84 )))
85 * (((
86 What is the **sub-band** the gateway support ?
87 )))
88 * (((
89 What is the **sub-band** the end node is using ?
90 )))
91
92 (((
93 All of above should match so End Node can properly Join the server and don't have packet lost.
94 )))
95
96 (((
97
98 )))
99
100 (((
101 In LoRaWAN protocol, the frequency bands US915, AU915, CN470 each includes at least 72 frequencies. Many gateways support only 8 or 16 frequencies, and server might support 8 frequency only. In this case, the OTAA join time and uplink schedule is long and unpredictable while the end node is hopping in 72 frequencies, because the end node will send data in many frequency that the gateway or server doesn,t support.
102 )))
103
104 (((
105
106 )))
107
108 (((
109 Here are the freuqency tables for these bands as reference:
110 )))
111
112 [[image:image-20220526163801-6.png]]
113
114 US915 Channels
115
116
117 [[image:image-20220526163926-7.png]]
118
119 AU915 Channels
120
121
122 [[image:image-20220526163941-8.png]]
123
124 (((
125 CN470 Channels
126
127
128 )))
129
130 (((
131 If we look at the [[TTN network server frequency plan>>url:https://www.thethingsnetwork.org/docs/lorawan/frequency-plans.html]], we can see the US915 frequency band use the channel 8~~15.So the End Node must work at the same frequency in US915 8~~15 channels for TTN server.
132 )))
133
134 [[image:image-20220526164052-9.png]]
135
136 (((
137 TTN FREQUENCY PLAN
138
139 (% style="display:none" %) (%%)
140 )))
141
142 (((
143 In dragino end node, user can use AT+CHE command to set what frequencies set the end node will use. The default settings for Dragino end node are preconfigure for TTN server, so use 8~~15 channels, which is **AT+CHE=2**. (AT+CHE=1 for first 8 channels, AT+CHE=2 for second 8 channels.. etc, and AT+CHE=0 for all 72 channels. )
144 )))
145
146 (% style="display:none" %) (%%)
147
148 = 3. Why i see data lost/unperiocially uplink data? Even the signal strength is good =
149
150
151 In this case, we can check if the frequency band matches in End Node, Gateway and LoRaWAN server. A typical case is using US915 in ChirpStack server as below:
152
153 * (% style="color:blue" %)**End node** (%%) ~-~-> Use Sub-band2 (Channel 8,9,10,11,12,13,14,15) for Dragino Sensor. ADR is also enable, this is the default settings for dragino sensors.
154
155 * (% style="color:blue" %)**Gateway** (%%) ~-~-> Use Sub-band2 (Channel 8,9,10,11,12,13,14,15) for Dragino Gateway. this is the default settings for dragino sensors.
156
157 * (% style="color:blue" %)**LoRaWAN server**  (%%) ~-~-> ChirpStack default installation and use Sub-band1, **enabled_uplink_channels=[0, 1, 2, 3, 4, 5, 6, 7]** in the file chirpstack-network-server.toml.
158
159 (((
160 When Sensor power on, it will use sub-band2 to join the network, the frequency matches the settings in gateway so all Join Request will be passed to the server for Join. Server will ask the sensor to change to Sub-band1 in the Join Accept downlink message. Sensor will change to sub-band1 for data upload. This cause the sensor and gateway have different frequencies so user see lost of most data or even no data.
161 )))
162
163
164 (((
165 Use Subband2 as a default subband cause the sensor to have problem to work with the LoRaWAN server which use other subband, and use need to access to the end node to change the subband by console. that is not user frendily,. So since Dragino LoRaWAN Stack version DLS-005(release on end of 2020), we have changed the device to use All Subbands for OTAA join, for example, device will use the first frequency in Sub-Band1 as firt OTAA join packet, then use the first frequency in Sub-Band 2 , then first frequency in sub-band 3, and so on. LoRaWAN server will normally provide the required subband in the OTAA accept process, so end node will know what subband it use after join. If LoRaWAN server doesn't provide subband info in OTAA join, end node will use the subband which join success as the working subband. So the new method cause a longer OTAA Join time but will be compatible with all LoRaWAN server. And new method won't affect the normal uplink after Join Success.
166 )))
167
168
169 = 4. Transmision on ABP Mode =
170
171
172 (((
173 In ABP mode, there is a Frame Counter Checks. With this check enabled, the server will only accept the frame with a higher counter. If you reboot the device in ABP mode, the device will start from count 0, so you won't be able to see the frame update in server.
174 )))
175
176 (((
177 So in ABP mode, first check if the packet already arrive your gateway, if the packet arrive gatewat but didn't arrive server. Please check if this is the issue.
178 )))
179
180 (((
181 To solve this, disable the Frame Counter Check will solve this issue , or reset the frame counter in the device page.
182 )))
183
184 [[image:image-20220526164508-10.png]]
185
186 Disable Frame Counter Check in ABP Mode
187
188
189 = 5. Downstream Debug =
190
191 == 5.1 How it work ==
192
193
194 LoRaWAN End node will open two receive windows to receive the downstream data. If the downstream packets arrive the end node at these receive windows, the end node will be able to get this packet and process it.
195
196 (((
197 Depends on Class A or Class C, the receive windows will be a little difference,
198 )))
199
200 [[image:image-20220531161828-1.png]]
201
202 receive windows for Class A and Class C
203
204
205 Below are the requirement for the End Device to receive the packets.
206
207 * The End Device must open the receive windows: RX1 or RX2
208
209 * The LoRaWAN server must send a downstream packet, and the gateway forward this downstream packet for this end node.
210
211 * This downstream packet must arrive to the end node while RX1 or RX2 is open.
212
213 * This packet must match the frequency of the RX1 or RX2 window.
214
215 * This packet must match the DataRate of RX1(RX1DR) or RX2 (RX2DR). (% style="color:red" %)**This is the common fail point, because different lorawan server might use different RX2DR and they don't info End Node via ADR message so cause the mismatch. If this happen, user need to change the RX2DR to the right value in end node. In OTAA, LoRaWAN Server will send the RX2DR setting in Join Accept message so the end node will auto adjust. but ABP uplink doesn't support this auto change.**
216
217
218 == 5.2 See Debug Info ==
219
220
221 (((
222 (% style="color:blue" %)**For LoRaWAN Server**
223 )))
224
225 (((
226 We can check if there is downlink message for this end node, use TTN for example:
227 )))
228
229 (((
230 Configure a downstream to the end device
231 )))
232
233 [[image:image-20220526164623-12.png]]
234
235 (((
236 Set a downstream in TTN and see it is sent
237 )))
238
239
240 (((
241 This downstream info will then pass to the gateway downstream list. and include the DR which is used (SF9BW125) in EU868 is DR3
242 )))
243
244 [[image:image-20220526164650-13.png]]
245
246 (((
247 Gateway Traffic can see this downstream info
248 )))
249
250
251
252 (((
253 (% style="color:blue" %)**For LoRaWAN Gateway**
254 )))
255
256 (((
257 When the downstream packet appear on the traffic of Gateway page. The LoRaWAN gateway can get it from LoRaWAN server and transmit it. In Dragion Gateway, this can be checked by runinng "logread -f" in the SSH console. and see below:
258 )))
259
260 [[image:image-20220526164734-14.png]]
261
262 (((
263 Gateway Sent out this packet
264 )))
265
266
267
268 (((
269 (% style="color:blue" %)**For End Node**
270 )))
271
272 (((
273 we can use AT Command (AT+CFG) to check the RX1 configure and RX2 configure. as below:
274 )))
275
276 (((
277 * (% style="color:#037691" %)**AT+RX2FQ=869525000**  (%%) **~-~-->**  The RX2 Window frequency
278
279 * (% style="color:#037691" %)**AT+RX2DR=3**          (%%) **~-~-->**  The RX2 DataRate
280
281 * (% style="color:#037691" %)**AT+RX1DL=1000**       (%%) ** ~-~-->**  Receive Delay 1
282
283 * (% style="color:#037691" %)**AT+RX2DL=2000**       (%%) **~-~--> ** Receive Delay 2
284 )))
285
286 (((
287 (% style="color:blue" %)**when the device running, we can see below info:**
288 )))
289
290 {{{ [12502]***** UpLinkCounter= 0 *****
291 [12503]TX on freq 868500000 Hz at DR 0
292 [13992]txDone
293 [15022]RX on freq 868500000 Hz at DR 0 --> RX1 window open at frequency: 868500000, DR0, after 15022-13992= 1030ms of txdone
294 [15222]rxTimeOut --> no packet arrive in RX1 window. (duration: 200ms)
295 [15987]RX on freq 869525000 Hz at DR 3 --> RX2 window open at frequency: 869525000, DR3, after 15987-13992= 1995ms of txdone
296 [16027]rxTimeOut --> no packet arrive in RX2 window. (duration: 40 ms)}}}
297
298 (((
299
300
301
302 )))
303
304 (((
305 (% style="color:blue" %)**Another message:**
306 )))
307
308 {{{ [12502]***** UpLinkCounter= 0 *****
309 [12503]TX on freq 868100000 Hz at DR 0
310 [13992]txDone
311 [15022]RX on freq 868100000 Hz at DR 0
312 [15222]rxTimeOut
313 [15987]RX on freq 869525000 Hz at DR 3
314 [16185]rxDone --> We have got the downstream packet.
315 Rssi= -64
316 Receive data
317 1:0012345678}}}
318
319
320 == 5.3 If problem doesn't solve ==
321
322
323 (% style="color:red" %)**If user has checked below steps and still can't solve the problem, please send us (support @ dragino.com) the sceenshots for each step to check. They include:**
324
325 * End node console to show the transmit freuqency and DR.
326
327 * Gateway (from gateway UI) traffic to show the packet got from end node and receive from Server.
328
329 * Gateway traffic (from server UI) to shows the data exchange between gateway and server.
330
331 * End Node traffic (from server UI) to shows end node activity in server.
332
333
334 = 6. Downlink Issue ~-~- Packet REJECTED, unsupported frequency =
335
336
337 (((
338 In LoRaWAN, the gatewat will use the frequency specify by the server to transmit a packet as downlink purpose. Each Frequency band has different downlink frequency. and the gateway has a frequency range limited to transmit downlink.
339 )))
340
341 (((
342
343 )))
344
345 (((
346 So if the LoRaWAN server is an AS923 server which ask the gateway to transmit at 923.2Mhz frequency, but the gateway is IN868 frequency band (support 865~~867Mhz to transmit). In the gateway log it will show something like below:
347 )))
348
349 {{{Sat Nov 21 08:04:17 2020 daemon.info lora_pkt_fwd[1680]: ERROR~ Packet REJECTED, unsupported frequency - 923200000 (min:865000000,max:867000000)}}}
350
351 (((
352
353 )))
354
355 (((
356 In this case, please double check the gateway frequency and the server frequency band.
357 )))
358
359
360 = 7. Decrypt a LoRaWAN Packet =
361
362
363 (% style="color:blue" %)**1. LHT65 End device configure:**
364
365 **Change to ABP Mode:  AT+NJM=0**
366
367 **Change to fix frequency:  AT+CHS=904900000**
368
369 **Change to fix DR:  AT+DR=0**
370
371
372 [[image:image-20220526165525-16.png]]
373
374
375
376 (% style="color:blue" %)**2. In LG02 , configure to receive above message**
377
378 [[image:image-20220526165612-17.png]]
379
380
381 In LG02 console, we can see the hex receive are:
382
383 [[image:image-20220526171112-21.png]]
384
385
386
387 (% style="color:blue" %)**3. Decode the info in web**
388
389 [[https:~~/~~/lorawan-packet-decoder-0ta6puiniaut.runkit.sh>>url:https://lorawan-packet-decoder-0ta6puiniaut.runkit.sh/]]
390
391 Need these three fields:
392
393 LoRa packet hex format: 40c1190126800100024926272bf18bbb6341584e27e23245 (from LG02)
394
395 AT+NWKSKEY=00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 11 (End node Network Session Key)
396
397 AT+APPSKEY=00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 11 (End Node App Session Key)
398
399
400 [[https:~~/~~/lorawan-packet-decoder-0ta6puiniaut.runkit.sh/?data=40c1190126800100024926272bf18bbb6341584e27e23245&nwkskey=00000000000000000000000000000111&appskey=00000000000000000000000000000111>>url:https://lorawan-packet-decoder-0ta6puiniaut.runkit.sh/?data=40c1190126800100024926272bf18bbb6341584e27e23245&nwkskey=00000000000000000000000000000111&appskey=00000000000000000000000000000111]]
401
402 [[image:image-20220526171029-20.png]]
403
404 (((
405 The FRMPayload is the device payload.
406 )))
407
408
409 = 8. Why i see uplink 0x00 periodcally on the LHT65 v1.8 firmware =
410
411
412 Since firmware v1.8, LHT65 will send MAC command to request time, in the case if DR only support max 11 bytes, this MAC command will be bundled to a separate uplink payload with 0x00.
413
414
415 = 9. Why do I see a "MIC Mismatch" error message from the server? =
416
417
418 (((
419 1)  If the user receives a "MIC Mismatch" message after registering the node on the server.
420 )))
421
422 (((
423 It is likely that the user filled in the wrong APPKEY when registering the node. Many users fill in "APPSKEY".
424 )))
425
426 * (((
427 Please note the distinction between "APPKEY" and "APPSKEY".
428 )))
429
430 (((
431 2)If the node works on the server for a period of time, the device stops working and receives a "MIC Mismatch" message.
432 )))
433
434 (((
435 The user needs a USB-TTL adapter to connect the serial port to modify the node APPKEY.
436 )))
437
438 * (((
439 If a node is registered with multiple servers, it may also cause the "mic mismatch" error.
440 )))
441
442 (% class="wikigeneratedid" %)
443 3)Wrong Regional Parameters version selected
444 We generally use versions above 1.0.2
445
446 (% class="wikigeneratedid" %)
447 [[image:image-20230322163227-1.png]]
448
449 (% class="wikigeneratedid" %)
450 4)We have had cases where it was automatically fixed the next day despite no manual changes, probably a server side issue
451
452
453 = 10. Why i got the payload only with "0x00" or "AA~=~="? =
454
455
456 (% style="color:blue" %)**Why this happen:**
457
458 For US915, AU915 or AS923 frequencies.It is possible because: .
459
460 When using the frequency mentioned above, the server sometimes adjusts the Data Rate (DR) of the node, because the end node has Adaptive Data Rate (ADR) Enabled.
461
462 1.
463
464 When the server adjusts end node data rate to 0, the maximum payload length is 11 bytes. The server sometimes sends an ADR packet to the end node, and the node will reply to the server after receiving the ADR packet, but the number of payload bytes exceeds the limit, so it will send a normal uplink packet, and following an additional 00 data packet to handle this MAC command response.
465
466 2.
467
468 The server downlinks a calibration time package
469 This calibration time packet will exceed the byte limit, causing its payload to become 00
470
471 (% style="color:blue" %)**How to solve:**
472
473 Solution:
474
475 ~1. Use the decoder to filter out this 0x00 packet.
476
477 2. Data rate changed from DR3 to DR5, increasing upload byte length
478 AT+ADR=0
479 AT+DR=3
480
481 Downlink:
482
483 [[http:~~/~~/wiki.dragino.com/xwiki/bin/view/Main/End%20Device%20AT%20Commands%20and%20Downlink%20Command/#H7.4DataRate>>http://wiki.dragino.com/xwiki/bin/view/Main/End%20Device%20AT%20Commands%20and%20Downlink%20Command/#H7.4DataRate]]
484
485 Some node decoders may not have the filter function, or you need decoders of other servers and formats. Please send an email to [[support@dragino.com>>mailto:support@dragino.com]]
486
487
488 = 11. Why my Dev EUI and APP EUI is 0x000000000000, how to solve? =
489
490
491 (((
492 It is possible the keys is erased during upgrading of firmware. and the console output shows below after AT+CFG
493 )))
494
495 (((
496 AT+APPKEY=00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
497 )))
498
499 (((
500 AT+NWKSKEY=00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
501 )))
502
503 (((
504 AT+APPSKEY=00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
505 )))
506
507 (((
508 AT+APPEUI=00 00 00 00 00 00 00 00
509 )))
510
511 (((
512
513 )))
514
515 (((
516 You can get the keys from the box sticker or send mail to Dragino Support to check keys with the provided SN number.
517 )))
518
519 (((
520 You can rewrites the keys by running commands in AT Console
521
522
523 )))
524
525 (((
526 **For example:**
527 )))
528
529 (((
530 AT+APPKEY=85 41 47 20 45 58 28 14 16 82 A0 F0 80 0D DD EE
531 )))
532
533 (((
534 AT+NWKSKEY=AA CC B0 20 30 45 37 32 14 1E 14 93 E2 3B 20 11
535 )))
536
537 (((
538 AT+APPSKEY=11 23 02 20 30 20 30 60 80 20 20 30 30 20 10 10
539 )))
540
541 (((
542 AT+APPEUI=2C 45 47 E3 24 12 23 24
543 )))
544
545 (((
546 (Any combination of 16 bit codes can be used)
547
548
549 = 12. I set my device is LoRaWAN Class C mode, why i still see Class A after boot? =
550 )))
551
552
553 Class C only refers to status after OTAA Join successfully. The OTAA Join Process will use Class A mode.
554
555
556 = 13. Why it takes longer time for OTAA joined in US915/CN470/AU915 band? =
557
558
559 In US915, AU915 or CN470 frequency band, there are 8 subbands, totally 72 channels. and LoRaWAN server normally use only one sub-band, for example Subband 2 in TTN. The gateway also configured to Subband 2 and cover eight channels in this subband. If the end node transfer data in Subband 2, it will reach to gateway and to the LoRaWAN server. If the end node transfer packets in other subbands, for example subband 1, the packet won't arrive both gateway or LoRaWAN server.
560
561
562 In Dragino Sensors old version firmware (before early 2022), the subband is fixed the subband to 2 , but this cause a problem, the end node is hard to use in other subband and need program. So the new logic is as below:
563
564 We have improved this, the end node will use frequency 1 from sub-band1, then frequency 1 from sub-band2, then frequency 1 from sub-band3, etc to process the OTAA join, In this case, In this case, the end node can support LoRaWAN servers with different subbands. To make sure the end node will only transmit the proper sub-band after OTAA Joined successfully, the end node will:
565
566 * (((
567 Check what sub-band the LoRaWAN server ask from the OTAA Join Accept message and switch to that subband
568 )))
569 * (((
570 Use the Join successful sub-band if the server doesn't include subband info in the OTAA Join Accept message ( TTN v2 doesn't include)
571 )))
572
573 This change will make the activation time a littler longer but make sure the device can be used in any subband.
574
575
576 Below is a photo to show why it takes longer time for OTAA Join. We can see in 72 channels mode, why it takes more time to join success. If users want to have faster OTAA Join success, he can change default CHE to the subband he use.
577
578
579 [[image:image-20221215223215-1.png||height="584" width="1280"]]
580
581 (% class="wikigeneratedid" %)
582