forked from Lora-net/SWL2001
-
Notifications
You must be signed in to change notification settings - Fork 0
/
smtc_modem_api.h
executable file
·2148 lines (1984 loc) · 96.3 KB
/
smtc_modem_api.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
/**
* @file smtc_modem_api.h
*
* @brief Generic Modem API description
*
* The Clear BSD License
* Copyright Semtech Corporation 2021. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted (subject to the limitations in the disclaimer
* below) provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the Semtech corporation nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY
* THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SMTC_MODEM_API_H__
#define SMTC_MODEM_API_H__
#ifdef __cplusplus
extern "C" {
#endif
/*
* -----------------------------------------------------------------------------
* --- DEPENDENCIES ------------------------------------------------------------
*/
#include <stdint.h> // C99 types
#include <stdbool.h> // bool type
/*
* -----------------------------------------------------------------------------
* --- PUBLIC MACROS -----------------------------------------------------------
*/
/*
* -----------------------------------------------------------------------------
* --- PUBLIC CONSTANTS --------------------------------------------------------
*/
/**
* @brief EUI (joinEUI, devEUI, etc.) length in byte
*/
#define SMTC_MODEM_EUI_LENGTH 8
/**
* @brief Cryptographic key length in byte
*/
#define SMTC_MODEM_KEY_LENGTH 16
/**
* @brief Modem PIN code length in byte
*/
#define SMTC_MODEM_PIN_LENGTH 4
/**
* @brief ADR custom configuration length in byte
*/
#define SMTC_MODEM_CUSTOM_ADR_DATA_LENGTH 16
/**
* @brief Maximum payload size in byte of LoRaWAN payload
*/
#define SMTC_MODEM_MAX_LORAWAN_PAYLOAD_LENGTH 242
/**
* @brief Application-defined user data length in byte
*/
#define SMTC_MODEM_DM_USER_DATA_LENGTH 8
/*
* -----------------------------------------------------------------------------
* --- PUBLIC TYPES ------------------------------------------------------------
*/
/**
* @brief Modem Return Codes
* @remark Command output values must not be read if the return code differs from SMTC_MODEM_RC_OK
*/
typedef enum smtc_modem_return_code_e
{
SMTC_MODEM_RC_OK = 0x00, //!< command executed without errors
SMTC_MODEM_RC_NOT_INIT, //!< command not initialized
SMTC_MODEM_RC_INVALID, //!< command parameters invalid
SMTC_MODEM_RC_BUSY, //!< command cannot be executed now
SMTC_MODEM_RC_FAIL, //!< command execution failed
SMTC_MODEM_RC_NO_TIME, //!< no time available
SMTC_MODEM_RC_INVALID_STACK_ID, //!< invalid stack_id parameter
SMTC_MODEM_RC_NO_EVENT, //!< no event available
} smtc_modem_return_code_t;
/**
* @brief Modem region ID
*/
typedef enum smtc_modem_region_e
{
SMTC_MODEM_REGION_EU_868 = 1,
SMTC_MODEM_REGION_AS_923_GRP1 = 2,
SMTC_MODEM_REGION_US_915 = 3,
SMTC_MODEM_REGION_AU_915 = 4,
SMTC_MODEM_REGION_CN_470 = 5,
SMTC_MODEM_REGION_WW2G4 = 6,
SMTC_MODEM_REGION_AS_923_GRP2 = 7,
SMTC_MODEM_REGION_AS_923_GRP3 = 8,
SMTC_MODEM_REGION_IN_865 = 9,
SMTC_MODEM_REGION_KR_920 = 10,
SMTC_MODEM_REGION_RU_864 = 11,
SMTC_MODEM_REGION_CN_470_RP_1_0 = 12,
SMTC_MODEM_REGION_AS_923_GRP4 = 13,
} smtc_modem_region_t;
/**
* @brief Modem Datarate Profiles
*/
typedef enum smtc_modem_adr_profile_e
{
SMTC_MODEM_ADR_PROFILE_NETWORK_CONTROLLED = 0x00, //!< Network Server controlled for static devices
SMTC_MODEM_ADR_PROFILE_MOBILE_LONG_RANGE = 0x01, //!< Long range distribution for mobile devices
SMTC_MODEM_ADR_PROFILE_MOBILE_LOW_POWER = 0x02, //!< Low power distribution for mobile devices
SMTC_MODEM_ADR_PROFILE_CUSTOM = 0x03, //!< User defined distribution
} smtc_modem_adr_profile_t;
/**
* @brief Modem class enumeration
*/
typedef enum smtc_modem_class_e
{
SMTC_MODEM_CLASS_A = 0x00, //!< Modem class A
SMTC_MODEM_CLASS_B = 0x01, //!< Modem class B
SMTC_MODEM_CLASS_C = 0x02, //!< Modem class C
SMTC_MODEM_CLASS_MAX,
} smtc_modem_class_t;
/**
* @brief Modem firmware version structure definition
*/
typedef struct smtc_modem_version_s
{
uint8_t major; //!< Major value
uint8_t minor; //!< Minor value
uint8_t patch; //!< Patch value
} smtc_modem_version_t;
/**
* @brief Multicast group identifier
*/
typedef enum smtc_modem_mc_grp_id_e
{
SMTC_MODEM_MC_GRP_0,
SMTC_MODEM_MC_GRP_1,
SMTC_MODEM_MC_GRP_2,
SMTC_MODEM_MC_GRP_3,
} smtc_modem_mc_grp_id_t;
/**
* @brief Periodicity available for Class B ping slot
*/
typedef enum smtc_modem_class_b_ping_slot_periodicity_e
{
SMTC_MODEM_CLASS_B_PINGSLOT_1_S = 0,
SMTC_MODEM_CLASS_B_PINGSLOT_2_S,
SMTC_MODEM_CLASS_B_PINGSLOT_4_S,
SMTC_MODEM_CLASS_B_PINGSLOT_8_S,
SMTC_MODEM_CLASS_B_PINGSLOT_16_S,
SMTC_MODEM_CLASS_B_PINGSLOT_32_S,
SMTC_MODEM_CLASS_B_PINGSLOT_64_S,
SMTC_MODEM_CLASS_B_PINGSLOT_128_S,
} smtc_modem_class_b_ping_slot_periodicity_t;
/**
* @brief LoRaWAN Mac request mask definition
*/
enum smtc_modem_lorawan_mac_request_mask_e
{
SMTC_MODEM_LORAWAN_MAC_REQ_LINK_CHECK = ( 1 << 0 ),
SMTC_MODEM_LORAWAN_MAC_REQ_DEVICE_TIME = ( 1 << 1 ),
SMTC_MODEM_LORAWAN_MAC_REQ_PING_SLOT_INFO = ( 1 << 2 ),
};
typedef uint8_t smtc_modem_lorawan_mac_request_mask_t;
/**
* @brief Rx window type
*/
typedef enum smtc_modem_dl_window_e
{
SMTC_MODEM_DL_WINDOW_RX1 = 0x01,
SMTC_MODEM_DL_WINDOW_RX2 = 0x02,
SMTC_MODEM_DL_WINDOW_RXC = 0x03,
SMTC_MODEM_DL_WINDOW_RXC_MC_GRP0 = 0x04,
SMTC_MODEM_DL_WINDOW_RXC_MC_GRP1 = 0x05,
SMTC_MODEM_DL_WINDOW_RXC_MC_GRP2 = 0x06,
SMTC_MODEM_DL_WINDOW_RXC_MC_GRP3 = 0x07,
SMTC_MODEM_DL_WINDOW_RXB = 0x08,
SMTC_MODEM_DL_WINDOW_RXB_MC_GRP0 = 0x09,
SMTC_MODEM_DL_WINDOW_RXB_MC_GRP1 = 0x0A,
SMTC_MODEM_DL_WINDOW_RXB_MC_GRP2 = 0x0B,
SMTC_MODEM_DL_WINDOW_RXB_MC_GRP3 = 0x0C,
SMTC_MODEM_DL_WINDOW_RXBEACON = 0x0D,
SMTC_MODEM_DL_WINDOW_RXR = 0x0E,
} smtc_modem_dl_window_t;
/**
* @brief Definition of Store and forward enablement
*
*/
typedef enum smtc_modem_store_and_forward_state_e
{
SMTC_MODEM_STORE_AND_FORWARD_DISABLE = 0, // Service disabled
SMTC_MODEM_STORE_AND_FORWARD_ENABLE = 1, // Service enabled
SMTC_MODEM_STORE_AND_FORWARD_SUSPEND = 2, // Service enabled, but send data is suspend
} smtc_modem_store_and_forward_state_t;
/**
* @brief Downlink metadata structure
*/
typedef struct smtc_modem_dl_metadata_s
{
uint8_t stack_id;
int8_t rssi; //!< Signed value in dBm + 64
int8_t snr; //!< Signed value in dB given in 0.25dB step
smtc_modem_dl_window_t window;
uint8_t fport;
uint8_t fpending_bit;
uint32_t frequency_hz;
uint8_t datarate;
} smtc_modem_dl_metadata_t;
/**
* @brief Cipher mode for stream service
*/
typedef enum smtc_modem_stream_cipher_mode_e
{
SMTC_MODEM_STREAM_NO_CIPHER, //!< Do not encrypt stream
SMTC_MODEM_STREAM_AES_WITH_APPSKEY, //!< Encrypt stream using AES with appskey
} smtc_modem_stream_cipher_mode_t;
/**
* @brief Cipher mode for file upload service
*/
typedef enum smtc_modem_file_upload_cipher_mode_e
{
SMTC_MODEM_FILE_UPLOAD_NO_CIPHER, //!< Do not encrypt file
SMTC_MODEM_FILE_UPLOAD_AES_WITH_APPSKEY, //!< Encrypt file using AES with appskey
} smtc_modem_file_upload_cipher_mode_t;
/**
* @brief Modem status
*/
enum smtc_modem_status_mask_e
{
SMTC_MODEM_STATUS_BROWNOUT = ( 1 << 0 ),
SMTC_MODEM_STATUS_CRASH = ( 1 << 1 ),
SMTC_MODEM_STATUS_MUTE = ( 1 << 2 ),
SMTC_MODEM_STATUS_JOINED = ( 1 << 3 ),
SMTC_MODEM_STATUS_SUSPEND = ( 1 << 4 ),
SMTC_MODEM_STATUS_UPLOAD = ( 1 << 5 ),
SMTC_MODEM_STATUS_JOINING = ( 1 << 6 ),
SMTC_MODEM_STATUS_STREAM = ( 1 << 7 ),
};
/**
* @brief Modem Status masks
*/
typedef uint32_t smtc_modem_status_mask_t;
/**
* @brief DM uplink reporting internal format
*/
typedef enum smtc_modem_dm_info_interval_format_e
{
SMTC_MODEM_DM_INFO_INTERVAL_IN_SECOND = 0x00,
SMTC_MODEM_DM_INFO_INTERVAL_IN_DAY = 0x01,
SMTC_MODEM_DM_INFO_INTERVAL_IN_HOUR = 0x02,
SMTC_MODEM_DM_INFO_INTERVAL_IN_MINUTE = 0x03,
} smtc_modem_dm_info_interval_format_t;
/**
* @brief SMTC_MODEM_DM_INFO_DEF DM info fields codes
*/
typedef enum smtc_modem_dm_field_e
{
SMTC_MODEM_DM_FIELD_STATUS = 0x00, //!< modem status
SMTC_MODEM_DM_FIELD_CHARGE = 0x01, //!< charge counter [mAh]
SMTC_MODEM_DM_FIELD_VOLTAGE = 0x02, //!< supply voltage [1/50 V]
SMTC_MODEM_DM_FIELD_TEMPERATURE = 0x03, //!< junction temperature [deg Celsius]
SMTC_MODEM_DM_FIELD_SIGNAL = 0x04, //!< strength of last downlink (RSSI [dBm]+64, SNR [0.25 dB])
SMTC_MODEM_DM_FIELD_UP_TIME = 0x05, //!< duration since last reset [h]
SMTC_MODEM_DM_FIELD_RX_TIME = 0x06, //!< duration since last downlink [h]
SMTC_MODEM_DM_FIELD_ADR_MODE = 0x08, //!< ADR profile (0-3)
SMTC_MODEM_DM_FIELD_JOIN_EUI = 0x09, //!< JoinEUI
SMTC_MODEM_DM_FIELD_INTERVAL = 0x0A, //!< reporting interval [values 0-63, units s/m/h/d]
SMTC_MODEM_DM_FIELD_REGION = 0x0B, //!< regulatory region
SMTC_MODEM_DM_FIELD_CRASHLOG = 0x0D, //!< Crashlog data (cannot be part of periodic frame)
SMTC_MODEM_DM_FIELD_RST_COUNT = 0x0F, //!< modem reset count
SMTC_MODEM_DM_FIELD_DEV_EUI = 0x10, //!< DevEUI
SMTC_MODEM_DM_FIELD_SESSION = 0x12, //!< session id / join nonce
SMTC_MODEM_DM_FIELD_CHIP_EUI = 0x13, //!< ChipEUI
SMTC_MODEM_DM_INFO_STREAMPAR = 0x15, //!< data stream parameters
SMTC_MODEM_DM_FIELD_APP_STATUS = 0x16, //!< application-specific status
} smtc_modem_dm_field_t;
/**
* @brief Modem events
*/
typedef enum smtc_modem_event_type_e
{
SMTC_MODEM_EVENT_RESET = 0x00, //!< Modem has been reset
SMTC_MODEM_EVENT_ALARM, //!< Alarm timer expired
SMTC_MODEM_EVENT_JOINED, //!< Network successfully joined
SMTC_MODEM_EVENT_TXDONE, //!< Frame transmitted
SMTC_MODEM_EVENT_DOWNDATA, //!< Downlink data received
SMTC_MODEM_EVENT_JOINFAIL, //!< Attempt to join network failed
SMTC_MODEM_EVENT_ALCSYNC_TIME, //!< ALCSync time updated
SMTC_MODEM_EVENT_LINK_CHECK, //!< Link Check answered or not by network
SMTC_MODEM_EVENT_CLASS_B_PING_SLOT_INFO, //!< Ping Slot Info answered or not by network
SMTC_MODEM_EVENT_CLASS_B_STATUS, //!< Downlink class B is ready or not
SMTC_MODEM_EVENT_LORAWAN_MAC_TIME, //!< LoRaWAN mac device time answered or not by network
SMTC_MODEM_EVENT_LORAWAN_FUOTA_DONE, //!< End of FUOTA session
SMTC_MODEM_EVENT_NO_MORE_MULTICAST_SESSION_CLASS_C, //!< End of multicast session in class C
SMTC_MODEM_EVENT_NO_MORE_MULTICAST_SESSION_CLASS_B, //!< End of multicast session in class B
SMTC_MODEM_EVENT_NEW_MULTICAST_SESSION_CLASS_C, //!< New active multicast session in class C
SMTC_MODEM_EVENT_NEW_MULTICAST_SESSION_CLASS_B, //!< New active multicast session in class B
SMTC_MODEM_EVENT_FIRMWARE_MANAGEMENT, //!< Firmware Management Package (FMP) event
SMTC_MODEM_EVENT_STREAM_DONE, //!< Stream upload completed (stream data buffer depleted)
SMTC_MODEM_EVENT_UPLOAD_DONE, //!< File upload completed
SMTC_MODEM_EVENT_DM_SET_CONF, //!< Configuration has been changed by the Device Management
SMTC_MODEM_EVENT_MUTE, //!< Modem has been muted or un-muted by the Device Management
SMTC_MODEM_EVENT_GNSS_SCAN_DONE,
SMTC_MODEM_EVENT_GNSS_TERMINATED,
SMTC_MODEM_EVENT_GNSS_ALMANAC_DEMOD_UPDATE,
SMTC_MODEM_EVENT_WIFI_SCAN_DONE,
SMTC_MODEM_EVENT_WIFI_TERMINATED,
SMTC_MODEM_EVENT_RELAY_TX_DYNAMIC, //!< Relay TX dynamic mode has enable or disable the WOR protocol
SMTC_MODEM_EVENT_RELAY_TX_MODE, //!< Relay TX activation has been updated
SMTC_MODEM_EVENT_RELAY_TX_SYNC, //!< Relay TX synchronisation has changed
SMTC_MODEM_EVENT_MAX,
} smtc_modem_event_type_t;
/**
* @brief Status returned by the Tx done event
*/
typedef enum smtc_modem_event_txdone_status_e
{
SMTC_MODEM_EVENT_TXDONE_NOT_SENT = 0,
SMTC_MODEM_EVENT_TXDONE_SENT = 1,
SMTC_MODEM_EVENT_TXDONE_CONFIRMED = 2,
} smtc_modem_event_txdone_status_t;
/**
* @brief Status returned by the SMTC_MODEM_EVENT_CLASS_B_STATUS
*/
typedef enum smtc_modem_event_class_b_status_e
{
SMTC_MODEM_EVENT_CLASS_B_NOT_READY = 0,
SMTC_MODEM_EVENT_CLASS_B_READY = 1,
} smtc_modem_event_class_b_status_t;
/**
* @brief Status returned by the LoRaWAN mac request events
* (SMTC_MODEM_EVENT_LINK_CHECK,SMTC_MODEM_EVENT_CLASS_B_PING_SLOT_INFO,SMTC_MODEM_EVENT_LORAWAN_MAC_TIME)
*/
typedef enum smtc_modem_event_mac_request_status_e
{
SMTC_MODEM_EVENT_MAC_REQUEST_NOT_ANSWERED = 0,
SMTC_MODEM_EVENT_MAC_REQUEST_ANSWERED = 1,
} smtc_modem_event_mac_request_status_t;
/**
* @brief Status returned by the Firmware Management Package
*/
typedef enum smtc_modem_event_fmp_status_e
{
SMTC_MODEM_EVENT_FMP_REBOOT_IMMEDIATELY = 0,
SMTC_MODEM_EVENT_FMP_CANCEL_REBOOT = 1,
} smtc_modem_event_fmp_status_t;
typedef enum smtc_modem_event_setconf_e
{
SMTC_MODEM_EVENT_SETCONF_ADR_MODE_UPDATED = SMTC_MODEM_DM_FIELD_ADR_MODE,
SMTC_MODEM_EVENT_SETCONF_JOIN_EUI_UPDATED = SMTC_MODEM_DM_FIELD_JOIN_EUI,
SMTC_MODEM_EVENT_SETCONF_DM_INTERVAL_UPDATED = SMTC_MODEM_DM_FIELD_INTERVAL,
SMTC_MODEM_EVENT_SETCONF_REGION_UPDATED = SMTC_MODEM_DM_FIELD_REGION,
} smtc_modem_event_setconf_opcode_t;
/**
* @brief Status returned by the MUTE event
*/
typedef enum smtc_modem_event_mute_status_e
{
SMTC_MODEM_EVENT_MUTE_OFF = 0,
SMTC_MODEM_EVENT_MUTE_ON = 1,
} smtc_modem_event_mute_status_t;
/**
* @brief Status returned by the UPLOADDONE event
*/
typedef enum smtc_modem_event_uploaddone_status_e
{
SMTC_MODEM_EVENT_UPLOAD_DONE_ABORTED = 0,
SMTC_MODEM_EVENT_UPLOAD_DONE_SUCCESSFUL = 1,
} smtc_modem_event_uploaddone_status_t;
/**
* @brief Structure holding event-related data
*/
typedef struct smtc_modem_event_s
{
uint8_t stack_id;
smtc_modem_event_type_t event_type;
uint8_t missed_events; //!< Number of event_type events missed before the current one
union
{
struct
{
uint16_t count;
} reset;
struct
{
smtc_modem_event_txdone_status_t status;
} txdone;
struct
{
smtc_modem_event_mac_request_status_t status;
} link_check;
struct
{
smtc_modem_event_mac_request_status_t status;
} class_b_ping_slot_info;
struct
{
smtc_modem_event_mac_request_status_t status;
} lorawan_mac_time;
struct
{
smtc_modem_event_class_b_status_t status;
} class_b_status;
struct
{
bool successful;
} fuota_status;
struct
{
smtc_modem_mc_grp_id_t group_id;
} new_multicast_class_c;
struct
{
smtc_modem_mc_grp_id_t group_id;
} new_multicast_class_b;
struct
{
smtc_modem_event_fmp_status_t status;
} fmp;
struct
{
smtc_modem_event_uploaddone_status_t status;
} uploaddone;
struct
{
smtc_modem_event_setconf_opcode_t opcode;
} setconf;
struct
{
smtc_modem_event_mute_status_t status;
} mute;
struct
{
uint8_t status;
} relay_tx;
} event_data;
} smtc_modem_event_t;
/*
* -----------------------------------------------------------------------------
* --- PUBLIC FUNCTIONS PROTOTYPES ---------------------------------------------
*/
/*
* -----------------------------------------------------------------------------
* ----------- BASIC MODEM FUNCTIONS -------------------------------------------
*/
/**
* @brief Get the current LoRaWAN region
*
* @param [in] stack_id Stack identifier
* @param [out] region_list List of region builded in firmware
* @param [out] number_of_region Number of region in list
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_INVALID \p region is NULL
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_get_list_region( uint8_t stack_id, uint8_t* region_list,
uint8_t* number_of_region );
/**
* @brief Set the LoRaWAN region
*
* @param [in] stack_id Stack identifier
* @param [in] region LoRaWAN region to be configured
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_INVALID \p region is not supported
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode or in joining/joined state
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_set_region( uint8_t stack_id, smtc_modem_region_t region );
/**
* @brief Get the current LoRaWAN region
*
* @param [in] stack_id Stack identifier
* @param [out] region Current LoRaWAN region
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_INVALID \p region is NULL
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_get_region( uint8_t stack_id, smtc_modem_region_t* region );
/**
* @brief Join the network
*
* @param [in] stack_id Stack identifier
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors or modem has already joined the network
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode or in joining/joined state
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_join_network( uint8_t stack_id );
/**
* @brief Request a LoRaWAN uplink
*
* @remark LoRaWAN NbTrans parameter can be set in mobile and custom ADR modes with @ref smtc_modem_set_nb_trans
*
* @param [in] stack_id Stack identifier
* @param [in] fport LoRaWAN FPort on which the uplink is done
* @param [in] confirmed Message type (true: confirmed, false: unconfirmed)
* @param [in] payload Data to be sent
* @param [in] payload_length Number of bytes from payload to be sent
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_INVALID \p fport is out of the [1:223] range or equal to the DM LoRaWAN FPort
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
* @retval SMTC_MODEM_RC_FAIL Modem is not available (suspended, muted, or not joined)
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_request_uplink( uint8_t stack_id, uint8_t fport, bool confirmed,
const uint8_t* payload, uint8_t payload_length );
/**
* @brief Get the modem event
*
* @remark This command can be used to retrieve pending events from the modem.
*
* @param [out] event Structure holding event-related information
* @param [out] event_pending_count Number of pending event(s)
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_INVALID \p event or \p event_pending_count are NULL
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
* @retval SMTC_MODEM_RC_NO_EVENT No event available
*/
smtc_modem_return_code_t smtc_modem_get_event( smtc_modem_event_t* event, uint8_t* event_pending_count );
/**
* @brief Get all the data from a downlink
*
* @remark This command shall be called after the reception of a SMTC_MODEM_EVENT_DOWNDATA event
*
* @param [out] buff Buffer containing the downlink payload
* @param [out] length Length of the downlink payload
* @param [out] metadata Structure holding downlink metadata
* @param [out] remaining_data_nb Number of downlink data remaining
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_INVALID At least one parameter is NULL
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
* @retval SMTC_MODEM_RC_FAIL No downlink data is available
*/
smtc_modem_return_code_t smtc_modem_get_downlink_data( uint8_t buff[SMTC_MODEM_MAX_LORAWAN_PAYLOAD_LENGTH],
uint8_t* length, smtc_modem_dl_metadata_t* metadata,
uint8_t* remaining_data_nb );
/*
* -----------------------------------------------------------------------------
* ----------- CREDENTIAL MANAGEMENT FUNCTIONS ---------------------------------
*/
/**
* @brief Get the JoinEUI
*
* @param [in] stack_id Stack identifier
* @param [out] joineui Current JoinEUI
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_get_joineui( uint8_t stack_id, uint8_t joineui[SMTC_MODEM_EUI_LENGTH] );
/**
* @brief Set the JoinEUI
*
* @param [in] stack_id Stack identifier
* @param [in] joineui JoinEUI to be configured
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode or in joining/joined state
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_set_joineui( uint8_t stack_id, const uint8_t joineui[SMTC_MODEM_EUI_LENGTH] );
/**
* @brief Get the DevEUI
*
* @param [in] stack_id Stack identifier
* @param [out] deveui Current DevEUI
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_get_deveui( uint8_t stack_id, uint8_t deveui[SMTC_MODEM_EUI_LENGTH] );
/**
* @brief Set the DevEUI
*
* @param [in] stack_id Stack identifier
* @param [in] deveui DevEUI to be configured
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode or in joining/joined state
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_set_deveui( uint8_t stack_id, const uint8_t deveui[SMTC_MODEM_EUI_LENGTH] );
/**
* @brief Set the LoRaWAN v1.1.x Application Key (aka Gen Application Key in LoRaWAN v1.0.x)
*
* @param [in] stack_id Stack identifier
* @param [in] appkey Key to be configured
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode or in joining/joined state
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_set_appkey( uint8_t stack_id, const uint8_t appkey[SMTC_MODEM_KEY_LENGTH] );
/**
* @brief Set the LoRaWAN v1.1.x Network Key (aka Application Key in LoRaWAN v1.0.x)
*
* @param [in] stack_id Stack identifier
* @param [in] nwkkey Key to be configured
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode or in joining/joined state
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_set_nwkkey( uint8_t stack_id, const uint8_t nwkkey[SMTC_MODEM_KEY_LENGTH] );
/*!
* @brief Get the modem PIN code
*
* @remark This command can only be used with LR11XX radio
*
* @param [in] stack_id Stack identifier
* @param [out] chip_pin 4-byte PIN code
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
* @retval SMTC_MODEM_RC_FAIL Modem is already joined or is joining
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid stack_id
*/
smtc_modem_return_code_t smtc_modem_get_pin( uint8_t stack_id, uint8_t chip_pin[SMTC_MODEM_PIN_LENGTH] );
/*!
* @brief Get the modem chip EUI
*
* @remark This command can only be used with LR11XX radio
*
* @param [in] stack_id Stack identifier
* @param [out] chip_eui 8-byte chip EUI
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_get_chip_eui( uint8_t stack_id, uint8_t chip_eui[SMTC_MODEM_EUI_LENGTH] );
/*!
* @brief Derive keys
*
* @remark This command can only be used with LR11XX radio
* Derives application key taking saved dev_eui (default set to chip_eui) and saved join_eui
*
* @param [in] stack_id Stack identifier
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
* @retval SMTC_MODEM_RC_FAIL Modem is already joined or is joining
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_derive_keys( uint8_t stack_id );
/*
* -----------------------------------------------------------------------------
* ----------- ADVANCED MODEM FUNCTIONS ----------------------------------------
*/
/**
* @brief Get the modem status
*
* @param [in] stack_id Stack identifier
* @param [out] status_mask Modem status (see @ref smtc_modem_status_mask_e)
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_INVALID \p status_mask is NULL
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_get_status( uint8_t stack_id, smtc_modem_status_mask_t* status_mask );
/**
* @brief Get the modem firmware version
*
* @param [out] firmware_version Firmware version
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_INVALID \p firmware_version is NULL
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
*/
smtc_modem_return_code_t smtc_modem_get_modem_version( smtc_modem_version_t* firmware_version );
/**
* @brief Get the current value of the lost connection counter
*
* @remark The counter is incremented after any uplink and is only reset when a valid downlink is received from Network
* Server
*
* @param [in] stack_id Stack identifier
* @param [out] lost_connection_cnt Lost connection counter current value
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_INVALID \p lost_connection_cnt is NULL
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_lorawan_get_lost_connection_counter( uint8_t stack_id,
uint16_t* lost_connection_cnt );
/**
* @brief Get the current value of the lost connection counter
*
* @remark The counter is incremented after any uplink and is only reset when a valid downlink is received from Network
* Server
*
* @param [in] stack_id Stack identifier
* @param [out] lost_connection_s Lost connection in second since last downlink
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_INVALID \p lost_connection_cnt is NULL
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_lorawan_get_lost_connection_counter_since_s( uint8_t stack_id,
uint32_t* lost_connection_s );
/**
* @brief Get the status to bypass the join_duty-cycle backoff
*
* @remark The LoRaWAN certification_set enable/disable the backoff bypass
*
* @param [in] stack_id Stack identifier
* @param [out] enable True if bypass enabled
* @return smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_get_join_duty_cycle_backoff_bypass( uint8_t stack_id, bool* enable );
/**
* @brief Set the status to bypass the join_duty-cycle backoff
* @remark The LoRaWAN certification_set enable/disable the backoff bypass
*
* @param [in] stack_id Stack identifier
* @param [in] enable True to bypass
* @return smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_set_join_duty_cycle_backoff_bypass( uint8_t stack_id, bool enable );
/**
* @brief Get the status of the LoRaWAN certification service
*
* @param [in] stack_id Stack identifier
* @param [out] enable True if the certification is enabled, else False
* @return smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_get_certification_mode( uint8_t stack_id, bool* enable );
/**
* @brief Enable / disable the LoRaWAN certification mode
*
* @param [in] stack_id Stack identifier
* @param [in] enable Certification mode state (default: disabled)
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_set_certification_mode( uint8_t stack_id, bool enable );
/**
* @brief Request an immediate LoRaWAN uplink
*
* @remark It has higher priority than all other services and is not subject to duty cycle restrictions, if any
* @remark LoRaWAN NbTrans parameter can be set in mobiles and custom ADR modes with @ref smtc_modem_set_nb_trans
*
* @param [in] stack_id Stack identifier
* @param [in] fport LoRaWAN FPort on which the uplink is done
* @param [in] confirmed Message type (true: confirmed, false: unconfirmed)
* @param [in] payload Data to be sent
* @param [in] payload_length Number of bytes from payload to be sent
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_INVALID \p fport is out of the [1:223] range or equal to the DM LoRaWAN FPort
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
* @retval SMTC_MODEM_RC_FAIL Modem is not available (suspended, muted, or not joined)
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_request_emergency_uplink( uint8_t stack_id, uint8_t fport, bool confirmed,
const uint8_t* payload, uint8_t payload_length );
/**
* @brief Request a LoRaWAN uplink without payload, and an optional FPort
*
* @remark It can be used to create downlink opportunities / heartbeat without routing messages to an application server
*
* @param [in] stack_id Stack identifier
* @param [in] send_fport Add the FPort to the payload (true: add the FPort, false: send without FPort)
* @param [in] fport LoRaWAN FPort on which the uplink is done, if used
* @param [in] confirmed Message type (true: confirmed, false: unconfirmed)
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_INVALID \p fport is out of the [1:223] range or equal to the DM LoRaWAN FPort
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
* @retval SMTC_MODEM_RC_FAIL Modem is not available (suspended, muted, or not joined)
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_request_empty_uplink( uint8_t stack_id, bool send_fport, uint8_t fport,
bool confirmed );
/**
* @brief Leave an already joined network or cancels on ongoing join process
*
* @param [in] stack_id Stack identifier
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id
*/
smtc_modem_return_code_t smtc_modem_leave_network( uint8_t stack_id );
/**
* @brief Get the radio communications suspend status
*
* @param [in] stack_id Stack identifier
* @param [out] suspend Get the suspend status (true: suspend communications / false: resume communications)
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
*/
smtc_modem_return_code_t smtc_modem_get_suspend_radio_communications( uint8_t stack_id, bool* suspend );
/**
* @brief Suspend the radio communications initiated by the modem
*
* @param [in] suspend The configuration to be applied (true: suspend communications / false: resume communications)
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
*/
smtc_modem_return_code_t smtc_modem_suspend_radio_communications( bool suspend );
/**
* @brief Set and start the alarm timer (up to 864000s ie 10 days)
*
* @remark When the timer expires, an alarm event is generated
*
* @param [in] alarm_timer_in_s Alarm timer in second
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_INVALID \p alarm_timer_in_s exceed max value of 864000s (10 days)
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
*/
smtc_modem_return_code_t smtc_modem_alarm_start_timer( uint32_t alarm_timer_in_s );
/**
* @brief Stop and clear the alarm timer
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_NOT_INIT No alarm timer currently running
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
*/
smtc_modem_return_code_t smtc_modem_alarm_clear_timer( void );
/**
* @brief Get the number of seconds remaining before the alarm triggers an event
*
* @param [out] remaining_time_in_s Number of seconds remaining before the alarm triggers an event
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_NOT_INIT No alarm timer currently running
* @retval SMTC_MODEM_RC_INVALID \p remaining_time_in_s is NULL
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
*/
smtc_modem_return_code_t smtc_modem_alarm_get_remaining_time( uint32_t* remaining_time_in_s );
/*
* -----------------------------------------------------------------------------
* ----------- NETWORK MANAGEMENT MODEM FUNCTIONS ------------------------------
*/
/**
* @brief Get the maximum payload size that can be used for the next uplink
*
* @remark This value depends on the LoRaWAN regional parameters for the next transmission using the current data rate
*
* @param [in] stack_id Stack identifier
* @param [out] tx_max_payload_size Maximum payload size in byte
*
* @return Modem return code as defined in @ref smtc_modem_return_code_t
* @retval SMTC_MODEM_RC_OK Command executed without errors
* @retval SMTC_MODEM_RC_INVALID Parameters \p tx_max_payload_size is NULL
* @retval SMTC_MODEM_RC_BUSY Modem is currently in test mode
* @retval SMTC_MODEM_RC_FAIL Modem is not available (suspended, muted, or not joined)
* @retval SMTC_MODEM_RC_INVALID_STACK_ID Invalid \p stack_id