-
Notifications
You must be signed in to change notification settings - Fork 0
/
lorawan.h
1516 lines (1408 loc) · 46.7 KB
/
lorawan.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/********************************************************************
* Copyright (C) 2016 Microchip Technology Inc. and its subsidiaries
* (Microchip). All rights reserved.
*
* You are permitted to use the software and its derivatives with Microchip
* products. See the license agreement accompanying this software, if any, for
* more info about your rights and obligations.
*
* SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
* MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR
* PURPOSE. IN NO EVENT SHALL MICROCHIP, SMSC, OR ITS LICENSORS BE LIABLE OR
* OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH
* OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY FOR ANY DIRECT OR INDIRECT
* DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES, OR OTHER SIMILAR COSTS. To the fullest
* extend allowed by law, Microchip and its licensors liability will not exceed
* the amount of fees, if any, that you paid directly to Microchip to use this
* software.
*************************************************************************
*
* lorawan.h
*
* LoRaWAN header file
*
******************************************************************************/
#ifndef _LORAWAN_H
#define _LORAWAN_H
#ifdef __cplusplus
extern "C" {
#endif
/****************************** INCLUDES **************************************/
#include "lorawan_types.h"
/****************************** DEFINES ***************************************/
// Recommended protocol parameters
#define RECEIVE_DELAY1 1000UL
#define RECEIVE_DELAY2 2000UL
//#define RECEIVE_DELAY1 1000UL
//#define RECEIVE_DELAY2 10000UL
#define JOIN_ACCEPT_DELAY1 5000UL
#define JOIN_ACCEPT_DELAY2 6000UL
#define MAX_FCNT_GAP 16384
#define MAX_MCAST_FCNT_GAP MAX_FCNT_GAP
#define ADR_ACK_LIMIT 64
#define ADR_ACK_DELAY 32
#define ACK_TIMEOUT 2000
/***************************** TYPEDEFS ***************************************/
/*************************** FUNCTIONS PROTOTYPE ******************************/
typedef struct
{
void (*RxAppData)(uint8_t* pData, uint8_t dataLength, OpStatus_t status);
void (*RxJoinResponse)(bool status);
} RxAppData_t;
typedef void (*RxAppDataCb_t)(uint8_t* pData, uint8_t dataLength, OpStatus_t status);
typedef void (*RxJoinResponseCb_t)(bool status);
// Initialization functions
/**
* @Summary
LoRaWAN Initialization function
* @Description
This function initializes LoRaWAN stack and the radio module.
* @Preconditions
None
* @Param
RxPayload - pointer to function that gets called after the bidirectional communication ended.
RxJoinResponse - pointer to function that gets called after the activation procedure
* @Return
None
* @Example
*/
void LORAWAN_Init(RxAppDataCb_t RxPayload, RxJoinResponseCb_t RxJoinResponse);
/**
* @Summary
LoRaWAN activation procedure.
* @Description
This function starts LoRaWAN activation procedure.
* @Preconditions
None
* @Param
activationTypeNew - activation type: OTAA or ABP
* @Returns
Function returns the status of the operation (LorawanError_t).
* @Example
*/
LorawanError_t LORAWAN_Join(ActivationType_t activationTypeNew);
/**
* @Summary
Bidirectional communication start.
* @Description
This function starts a bidirectional communication process.
* @Preconditions
None
* @Param
confirmed - represents the transmission type; can be either UNCNF - unconfirmed or CNF - confirmed (TransmissionType_t)
port - represents the port on which the transmission is being made; it's a number between 0 and 255 (uint8_t)
buffer - a data buffer used to store the data to be sent
bufferLength - the length in bytes of the data buffer (uint8_t)
* @Returns
Function returns the status of the operation (LorawanError_t).
* @Example
uint8_t dataToSend = 45;
LORAWAN_Send (UNCNF, 20, &dataToSend, sizeof(dataToSend));
*/
LorawanError_t LORAWAN_Send (TransmissionType_t confirmed, uint8_t port, void *buffer, uint8_t bufferLength);
/**
* @Summary
* Set the status of multicast.
* @Description
* This function enables or disables the multicast operation.
* @Preconditions
* Before enabling the multicast, one must join a network and the multicast parameters mult be set (mcastNetworkSessionKey, mcastApplicationSessionKey, mcastDeviceAddressNew)
* @Param
None
* @Returns
Function returns the status of the operation (LorawanError_t)
* @Example
*/
LorawanError_t LORAWAN_SetMcast(bool status);
/**
* @Summary
* Returns the status of multicast
* @Description
* This function return the status of the multicast
* @Preconditions
* None
* @Param
None
* @Returns
true: multicast is enabled
false: multicast is disabled
* @Example
*/
bool LORAWAN_GetMcast(void);
/**
* @Summary
* Multicast device address set.
* @Description
* This function sets device multicast address.
* @Preconditions
* None
* @Param
mcastDeviceAddressNew - new value of the multicast device address.
* @Returns
None
* @Example
*/
void LORAWAN_SetMcastDeviceAddress (uint32_t mcastDeviceAddressNew);
/**
* @Summary
* Multicast device address get.
* @Description
* This function returns the value of the device multicast address.
* @Preconditions
* None
* @Param
None
* @Returns
Device multicast address value.
* @Example
*/
uint32_t LORAWAN_GetMcastDeviceAddress (void);
/**
* @Summary
* Multicast network session key set.
* @Description
* This function sets the value of the multicast network session key.
* @Preconditions
* None
* @Param
mcastNetworkSessionKeyNew - address where the new value is stored
* @Returns
None
* @Example
*/
void LORAWAN_SetMcastNetworkSessionKey (uint8_t *mcastNetworkSessionKeyNew);
/**
* @Summary
* Multicast network session key get.
* @Description
* This function gets the value of the multicast network session key.
* @Preconditions
* None
* @Param
mcastNetworkSessionKey - address where the value will be copied.
* @Returns
None
* @Example
*/
void LORAWAN_GetMcastNetworkSessionKey (uint8_t *mcastNetworkSessionKey);
/**
* @Summary
* Multicast application session key set.
* @Description
* This function sets the value of the multicast application session key.
* @Preconditions
* None
* @Param
mcastApplicationSessionKeyNew - address where the new value is stored
* @Returns
None
* @Example
*/
void LORAWAN_SetMcastApplicationSessionKey (uint8_t *mcastApplicationSessionKeyNew);
/**
* @Summary
* Multicast application session key get.
* @Description
* This function gets the value of the multicast application session key.
* @Preconditions
* None
* @Param
mcastApplicationSessionKey - address where the value will be copied
* @Returns
None
* @Example
*/
void LORAWAN_GetMcastApplicationSessionKey (uint8_t *mcastApplicationSessionKey);
/**
* @Summary
Function sets the end-device identifier.
* @Description
This function sets the end-device identifier (DevEUI).
The DevEUI is a global end-device ID in IEEE EUI64 address space that uniquely identifies end-device.
* @Preconditions
Pointer must be allocated by caller.
* @Param
deviceEuiNew - buffer where EUI is stored
* @Returns
None
* @Example
*/
void LORAWAN_SetDeviceEui (GenericEui_t *deviceEuiNew);
/**
* @Summary
Gets the value of the end-device identifier.
* @Description
This function gets the end-device identifier (DevEUI).
The DevEUI is a global end-device ID in IEEE EUI64 address space that uniquely identifies end-device.
* @Preconditions
Pointer must be allocated by caller.
* @Param
deviceEui - buffer where the value is stored
* @Returns
None
* @Example
*/
void LORAWAN_GetDeviceEui (GenericEui_t *deviceEui);
/**
* @Summary
Sets the application identifier.
* @Description
This function sets the end-device Application identifier (AppEUI)
The AppEUI is a global application ID in IEEE EUI64 address space that uniquely identifies the application provider (i.e., owner) of the end-device.
* @Preconditions
Pointer must be allocated by caller.
* @Param
applicationEuiNew - buffer where AppEUI is stored
* @Returns
None
* @Example
*/
void LORAWAN_SetApplicationEui (GenericEui_t *applicationEuiNew);
/**
* @Summary
Sets the join identifier.
* @Description
This function sets the end-device Application identifier (JoinEUI)
The JoinEUI is a global application ID in IEEE EUI64 address space that uniquely identifies the join server of the end-device.
* @Preconditions
Pointer must be allocated by caller.
* @Param
joinEuiNew - buffer where JoinEUI is stored
* @Returns
None
* @Example
*/
void LORAWAN_SetJoinEui (GenericEui_t *joinEuiNew);
/**
* @Summary
Gets the value of the application identifier.
* @Description
This function gets the end-device Application identifier (AppEUI)
The AppEUI is a global application ID in IEEE EUI64 address space that uniquely
identifies the application provider (i.e. owner) of the end-device.
* @Preconditions
Pointer must be allocated by caller.
* @Param
applicationEui - buffer where the value is stored
* @Returns
None
* @Example
*/
void LORAWAN_GetApplicationEui (GenericEui_t *applicationEui);
/**
* @Summary
Gets the value of the join identifier.
* @Description
This function gets the end-device Join identifier (JoinEUI)
The JoinEUI is a global application ID in IEEE EUI64 address space that uniquely
identifies the join server of the end-device.
* @Preconditions
Pointer must be allocated by caller.
* @Param
joinEui - buffer where the value is stored
* @Returns
None
* @Example
*/
void LORAWAN_GetJoinEui (GenericEui_t *joinEui);
/**
* @Summary
Sets end-device address.
* @Description
This function sets the end-device address (DevAddr).
The DevAddr is a 32bit identifier of the end-device within the current network.
* @Preconditions
None
* @Param
deviceAddressNew - the value of the new address to be set
* @Returns
None
* @Example
*/
void LORAWAN_SetDeviceAddress (uint32_t deviceAddressNew);
/**
* @Summary
Returns the address of end-device.
* @Description
This function gets the end-device address (DevAddr)
The DevAddr is a 32bit identifier of the end-device within the current network.
* @Preconditions
None
* @Param
None
* @Returns
32 bits device address.
* @Example
*/
uint32_t LORAWAN_GetDeviceAddress (void);
/**
@Summary
* Sets LoRa class.
@Description
* This function sets LoRaWAN stack class to A or C.
@Preconditions
* None
@Param
* class - new class
@Returns
* None
@Example
*/
void LORAWAN_SetClass (LoRaClass_t deviceClass);
/**
@Summary
* Returns LoRa class.
@Description
* This function returns LoRaWAN stack class.
@Preconditions
@Param
* None
@Returns
* Returns LoRa Class Type.
@Example
*/
LoRaClass_t LORAWAN_GetClass (void);
/**
@Summary
* Sets downlink counter for multicast communication.
@Description
* This function sets the value for the counter used in multicast downlink communication.
@Preconditions
@Param
* newCnt - new counter value;
@Returns
* None
@Example
*/
void LORAWAN_SetMcastDownCounter(uint32_t newCnt);
/**
@Summary
* Gets downlink counter for multicast communication.
@Description
* This function gets the value for the counter used in multicast downlink communication.
@Preconditions
@Param
* None;
@Returns
* Returns counter value.
@Example
*/
uint32_t LORAWAN_GetMcastDownCounter();
/**
* @Summary
Sets the network session key.
* @Description
This function sets the Network Session key (NwkSKey).
The NwkSKey is a network session key specific for the end-device and
it is used to calculate and verify the MIC (Message Integrity Code).
* @Preconditions
Pointer must be allocated by caller.
* @Param
networkSessionKeyNew - buffer where the value is stored
* @Returns
None
* @Example
*/
void LORAWAN_SetNetworkSessionKey (uint8_t *networkSessionKeyNew);
/**
* @Summary
Gets the network session key.
* @Description
This function gets the Network Session key (NwkSKey).
The NwkSKey is a network session key specific for the end-device and
it is used to calculate and verify the MIC (message integrity code).
* @Preconditions
Pointer must be allocated by caller.
* @Param
networkSessionKey - buffer where the value is stored
* @Returns
None
* @Example
*/
void LORAWAN_GetNetworkSessionKey (uint8_t *networkSessionKey);
/**
* @Summary
Sets the application session key.
* @Description
This function sets the Application Session Key (AppSKey).
The AppSKey is an application session key specific for the end-device;
it is used to encrypt/decrypt the payload field of application-specific data messages,
and also to calculate/verify an application-level MIC (Message Integrity Code)that may be included in the payload.
* @Preconditions
Pointer must be allocated by caller.
* @Param
applicationSessionKeyNew - buffer where the value is stored
* @Returns
None
* @Example
*/
void LORAWAN_SetApplicationSessionKey (uint8_t *applicationSessionKeyNew);
/**
* @Summary
Gets the application session key.
* @Description
This function gets the Application Session Key (AppSKey).
The AppSKey is an application session key specific for the end-device
it is used to encrypt/decrypt the payload field of application-specific data messages,
and also to calculate/verify an application-level MIC that may be included in the payload.
* @Preconditions
Pointer must be allocated by caller.
* @Param
applicationSessionKey - buffer where the value is stored
* @Returns
None
* @Example
*/
void LORAWAN_GetApplicationSessionKey (uint8_t *applicationSessionKey);
/**
* @Summary
Sets the application key.
* @Description
This function sets the Application Key (AppKey).
The AppKey is an AES-128 application key specific for the end-device that is assigned by the application owner to the end-device.
* @Preconditions
Pointer must be allocated by caller.
* @Param
applicationKeyNew - buffer where the value is stored
* @Returns
None
* @Example
*/
void LORAWAN_SetApplicationKey (uint8_t *applicationKeyNew);
/**
* @Summary
Gets the application key.
* @Description
This function gets the Application Key (AppKey).
The AppKey is an AES-128 application key specific for the end-device that is assigned by the application owner to the end-device.
* @Preconditions
Pointer must be allocated by caller.
* @Param
applicationKey - buffer where the value is stored
* @Returns
None
* @Example
*/
void LORAWAN_GetApplicationKey (uint8_t *applicationKey);
/**
* @Summary
Sets the adaptive data rate mode
* @Description
This function sets the Adaptive Data Rate (ADR) mode.
LoRa network allows the end-devices to individually use any of the possible data rates, this is referred to as Adaptive Data Rate (ADR).
If the ADR is set, the network will control the data rate of the end-device through the appropriate MAC commands.
If the ADR is not set, the network will not attempt to control the data rate of the end-device regardless of the received signal quality.
* @Preconditions
None
* @Param
status - true/false
* @Returns
None
* @Example
*/
void LORAWAN_SetAdr (bool status);
/**
* @Summary
Returns the adaptive data rate mode
* @Description
This function returns the Adaptive Data Rate (ADR) mode.
LoRa network allows the end-devices to individually use any of the possible
data rates, this is referred to as Adaptive Data Rate (ADR).
If the ADR is set, the network will control the data rate of the end-device
through the appropriate MAC commands.
If the ADR is not set, the network will not attempt to control the data rate
of the end-device regardless of the received signal quality.
* @Preconditions
None
* @Param
None
* @Returns
true/false
* @Example
*/
bool LORAWAN_GetAdr (void);
/**
* @Summary
Sets the data rate for the next uplink.
* @Description
Communication between end-devices and gateways is spread out on different
frequency channels and data rates.
The selection of the data rate is a trade-off between communication range and
message duration, communications with different data rates do not interfere with each other.
* @Preconditions
None
* @Param
valueNew - new data rate value
* @Returns
Return LoRaWAN Error type (LorawanError_t).
* @Example
*/
LorawanError_t LORAWAN_SetCurrentDataRate (uint8_t valueNew);
/**
* @Summary
Returns the data rate for the next uplink.
* @Description
Communication between end-devices and gateways is spread out on different
frequency channels and data rates.
The selection of the data rate is a trade-off between communication range and
message duration, communications with different data rates do not interfere with each other.
* @Preconditions
None
* @Param
None
* @Returns
Returns the value of data rate for the next uplink (uint8_t).
* @Example
*/
uint8_t LORAWAN_GetCurrentDataRate (void);
/**
* @Summary
Sets TX output power.
* @Description
The TX output power (TXPower) is region-specific.
txPowerNew must be provided as an index between 0 - 15.
For more details please refer to LoRaWAN Specification V1.0 document.
* @Preconditions
None
* @Param
txPowerNew - new TX power value
* @Returns
Return LoRaWAN Error type (LorawanError_t).
* @Example
*/
LorawanError_t LORAWAN_SetTxPower (uint8_t txPowerNew);
/**
* @Summary
Returns TX output power.
* @Description
The TX output power (TXPower) is region-specific.
Tx Power is returned as an index between 0 - 15.
For more details please refer to LoRaWAN Specification V1.0 document.
* @Preconditions
None
* @Param
None
* @Returns
Returns TX output power value (uint8_t).
* @Example
*/
uint8_t LORAWAN_GetTxPower (void);
/**
* @Summary
Sets the synchronization word.
* @Description
This function sets the current synchronization word used during the communication.
For more details please refer to LoRaWAN Specification V1.0 document.
* @Preconditions
None
* @Param
syncWord - the value for the new sync word
* @Returns
None
* @Example
*/
void LORAWAN_SetSyncWord (uint8_t syncWord);
/**
* @Summary
Returns the synchronization word.
* @Description
This function returns the current synchronization word used during the communication.
For more details please refer to LoRaWAN Specification V1.0 document.
* @Preconditions
None
* @Param
None
* @Returns
The value of the sync word (uint8_t).
* @Example
*/
uint8_t LORAWAN_GetSyncWord (void);
/**
* @Summary
Function sets the current uplink counter.
* @Description
This function sets the current uplink counter used during the communication.
This may be used to synchronize the uplink counter with the value stored by the server.
* @Preconditions
None
* @Param
ctr - value of the new counter to be set
* @Returns
None
* @Example
*/
void LORAWAN_SetUplinkCounter (uint32_t ctr);
/**
* @Summary
Function returns the current uplink counter.
* @Description
This function returns the current uplink counter used during the communication.
This may be used to synchronize the uplink counter with the value stored by the server.
* @Preconditions
None
* @Param
None
* @Returns
Current uplink counter (uint32_t).
* @Example
*/
uint32_t LORAWAN_GetUplinkCounter (void);
/**
* @Summary
Function sets the current downlink counter.
* @Description
This function sets the current downlink counter used during the communication.
This may be used to synchronize the downlink counter with the value stored by the server.
* @Preconditions
None
* @Param
ctr - value of the new counter
* @Returns
None
* @Example
*/
void LORAWAN_SetDownlinkCounter (uint32_t ctr);
/**
* @Summary
Function returns the current downlink counter.
* @Description
This function returns the current downlink counter used during the communication.
This may be used to synchronize the downlink counter with the value stored by the server.
* @Preconditions
None
* @Param
None
* @Returns
Current downlink counter (uint32_t).
* @Example
*/
uint32_t LORAWAN_GetDownlinkCounter (void);
/**
* @Summary
Function sets the value for the first receive delay (RECEIVE_DELAY1).
* @Description
This function will set the delay between the transmission and the first Reception window.
The delay between the transmission and the second Reception window is calculated in software
as the delay between the transmission and the first Reception window + 1000 (in milliseconds).
* @Preconditions
None
* @Param
receiveDelay1New - value of the new delay (must be provided in milliseconds).
* @Returns
None
* @Example
*/
void LORAWAN_SetReceiveDelay1 (uint16_t receiveDelay1New);
/**
* @Summary
Function returns the value for the first receive delay (RECEIVE_DELAY1)
* @Description
This function will return the delay between the transmission and the first Reception window.
The delay between the transmission and the second Reception window is calculated
in software as the delay between the transmission and the first Reception window + 1000 (in milliseconds).
* @Preconditions
None
* @Param
None
* @Returns
Value of the receive delay (shall be returned in milliseconds - uint16_t)
* @Example
*/
uint16_t LORAWAN_GetReceiveDelay1 (void);
/**
* @Summary
Function returns the value for the second receive delay (RECEIVE_DELAY2)
* @Description
This function will return the delay between the transmission and the second Reception window.
The delay between the transmission and the second Reception window is calculated
in software as the delay between the transmission and the first Reception window + 1000 (in milliseconds).
* @Preconditions
None
* @Param
None
* @Returns
Value of the second receive delay (shall be returned in milliseconds - uint16_t)
* @Example
*/
uint16_t LORAWAN_GetReceiveDelay2 (void); // receive delay 2 is receive delay 1 + 1 s
/**
* @Summary
Function sets the value for the first join accept delay (JOIN_ACCEPT_DELAY1).
* @Description
The network server will respond to the join-request message with a join-accept
message if the end-device is permitted to join a network.
The join-accept message is sent like a normal downlink but uses delays JOIN_ACCEPT_DELAY1
or JOIN_ACCEPT_DELAY2 (instead of RECEIVE_DELAY1 and RECEIVE_DELAY2, respectively).
* @Preconditions
None
* @Param
joinAcceptDelay1New - value of the new join accept delay
* @Returns
None
* @Example
*/
void LORAWAN_SetJoinAcceptDelay1 (uint16_t joinAcceptDelay1New);
/**
* @Summary
Function returns the value for the first join accept delay (JOIN_ACCEPT_DELAY1).
* @Description
The network server will respond to the join-request message with a join-accept
message if the end-device is permitted to join a network.
The join-accept message is sent like a normal downlink but uses delays JOIN_ACCEPT_DELAY1
or JOIN_ACCEPT_DELAY2 (instead of RECEIVE_DELAY1 and RECEIVE_DELAY2, respectively).
* @Preconditions
None
* @Param
None
* @Returns
Value of the first join accept delay (uint16_t).
* @Example
*/
uint16_t LORAWAN_GetJoinAcceptDelay1 (void);
/**
* @Summary
Function sets the value for the second join accept delay (JOIN_ACCEPT_DELAY2).
* @Description
The network server will respond to the join-request message with a join-accept
message if the end-device is permitted to join a network.
The join-accept message is sent like a normal downlink but uses delays JOIN_ACCEPT_DELAY1
or JOIN_ACCEPT_DELAY2 (instead of RECEIVE_DELAY1 and RECEIVE_DELAY2, respectively).
* @Preconditions
None
* @Param
joinAcceptDelay2New - value of the new join accept delay (must be provided in milliseconds)
* @Returns
None
* @Example
*/
void LORAWAN_SetJoinAcceptDelay2 (uint16_t joinAcceptDelay2New);
/**
* @Summary
Function returns the value for the second join accept delay (JOIN_ACCEPT_DELAY2).
* @Description
The network server will respond to the join-request message with a join-accept
message if the end-device is permitted to join a network.
The join-accept message is sent like a normal downlink but uses delays JOIN_ACCEPT_DELAY1
or JOIN_ACCEPT_DELAY2 (instead of RECEIVE_DELAY1 and RECEIVE_DELAY2, respectively).
* @Preconditions
None
* @Param
None
* @Returns
Value of the first join accept delay (shall be returned in milliseconds - uint16_t)
* @Example
*/
uint16_t LORAWAN_GetJoinAcceptDelay2 (void);
/**
* @Summary
Function sets the value for the maximum frame counter gap (MAX_FCNT_GAP).
* @Description
Each end-device has two frame counters to keep track of the number of data frames
sent uplink to the network server (FCntUp), incremented by the end-device and
received by the end-device downlink from the network server (FCntDown), which is
incremented by the network server.
At the receiver side, the corresponding counter is kept in sync with the value
received provided the value received has incremented compared to the current
counter value and is less than the value specified by MAX_FCNT_GAP after considering
counter rollovers.
If this difference is greater than the value of MAX_FCNT_GAP then too many data
frames have been lost then subsequent will be discarded.
* @Preconditions
None
* @Param
maxFcntGapNew - value for the new maximum frame counter
* @Returns
None
* @Example
*/
void LORAWAN_SetMaxFcntGap (uint16_t maxFcntGapNew);
/**
* @Summary
Function sets the value for adaptive data rate acknowledge limit (ADR_ACK_LIMIT).
* @Description
Each time the uplink frame counter is incremented (for each new uplink, repeated
transmissions do not increase the counter), the device increments an ADR_ACK_CNT counter.
After ADR_ACK_LIMIT uplinks (ADR_ACK_CNT >= ADR_ACK_LIMIT) without any downlink response,
it sets the ADR acknowledgment request bit (ADRACKReq).
The network is required to respond with a downlink frame within the next ADR_ACK_DELAY frames,
any received downlink frame following an uplink frame resets the ADR_ACK_CNT counter.
* @Preconditions
None
* @Param
none
* @Returns
Value of the maximum frame counter
* @Example
*/
uint16_t LORAWAN_GetMaxFcntGap (void);
/**
* @Summary
Function sets the value for adaptive data rate acknowledge limit (ADR_ACK_LIMIT).
* @Description
Each time the uplink frame counter is incremented (for each new uplink, repeated
transmissions do not increase the counter), the device increments an ADR_ACK_CNT counter.
After ADR_ACK_LIMIT uplinks (ADR_ACK_CNT >= ADR_ACK_LIMIT) without any downlink response,
it sets the ADR acknowledgment request bit (ADRACKReq).
The network is required to respond with a downlink frame within the next ADR_ACK_DELAY frames,
any received downlink frame following an uplink frame resets the ADR_ACK_CNT counter.
* @Preconditions
None
* @Param
adrAckLimitNew - the new value
* @Returns
None
* @Example
*/
void LORAWAN_SetAdrAckLimit (uint8_t adrAckLimitNew);
/**
* @Summary
Function returns the value for adaptive data rate acknowledge limit (ADR_ACK_LIMIT).
* @Description
Each time the uplink frame counter is incremented (for each new uplink, repeated
transmissions do not increase the counter), the device increments an ADR_ACK_CNT counter.
After ADR_ACK_LIMIT uplinks (ADR_ACK_CNT >= ADR_ACK_LIMIT) without any downlink response,
it sets the ADR acknowledgment request bit (ADRACKReq).
The network is required to respond with a downlink frame within the next ADR_ACK_DELAY frames,
any received downlink frame following an uplink frame resets the ADR_ACK_CNT counter.
* @Preconditions
None
* @Param
None
* @Returns
Value of the limit (uint8_t).
* @Example
*/
uint8_t LORAWAN_GetAdrAckLimit (void);
/**
* @Summary
Function sets the value for adaptive data rate acknowledge delay (ADR_ACK_DELAY)
* @Description
Each time the uplink frame counter is incremented (for each new uplink, repeated
transmissions do not increase the counter), the device increments an ADR_ACK_CNT counter.
After ADR_ACK_LIMIT uplinks (ADR_ACK_CNT >= ADR_ACK_LIMIT) without any downlink response,
it sets the ADR acknowledgment request bit (ADRACKReq).
The network is required to respond with a downlink frame within the next ADR_ACK_DELAY frames,
any received downlink frame following an uplink frame resets the ADR_ACK_CNT counter.
* @Preconditions
None
* @Param
adrAckDelayNew - the new value
* @Returns
None
* @Example
*/
void LORAWAN_SetAdrAckDelay(uint8_t adrAckDelayNew);
/**
* @Summary
Function returns the value for adaptive data rate acknowledge delay (ADR_ACK_DELAY)
* @Description
Each time the uplink frame counter is incremented (for each new uplink, repeated
transmissions do not increase the counter), the device increments an ADR_ACK_CNT counter.
After ADR_ACK_LIMIT uplinks (ADR_ACK_CNT >= ADR_ACK_LIMIT) without any downlink response,
it sets the ADR acknowledgment request bit (ADRACKReq).
The network is required to respond with a downlink frame within the next ADR_ACK_DELAY frames,
any received downlink frame following an uplink frame resets the ADR_ACK_CNT counter.
* @Preconditions
None
* @Param
None
* @Returns
Value of the delay (uint8_t).
* @Example
*/
uint8_t LORAWAN_GetAdrAckDelay (void);
/**
* @Summary
Function sets the value for acknowledge timeout (ACK_TIMEOUT).
* @Description
If an end-device does not receive a frame with the ACK bit set in one of the two receive
windows immediately following the uplink transmission, it may resend the same frame with
the same payload and frame counter again at least ACK_TIMEOUT seconds after the second reception window.
* @Preconditions
None
* @Param
ackTimeoutNew - new value of the timeout
* @Returns
None
* @Example
*/
void LORAWAN_SetAckTimeout(uint16_t ackTimeoutNew);
/**