Mistake on this page?
Report an issue in GitHub or email us
lorawan_data_structures.h
Go to the documentation of this file.
1 /**
2  * @file lorawan_data_structures.h
3  *
4  * @brief Contains common data structures used by Mbed-OS
5  * LoRaWAN mplementation.
6  *
7  * \code
8  * ______ _
9  * / _____) _ | |
10  * ( (____ _____ ____ _| |_ _____ ____| |__
11  * \____ \| ___ | (_ _) ___ |/ ___) _ \
12  * _____) ) ____| | | || |_| ____( (___| | | |
13  * (______/|_____)_|_|_| \__)_____)\____)_| |_|
14  * (C)2013 Semtech
15  * ___ _____ _ ___ _ _____ ___ ___ ___ ___
16  * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __|
17  * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _|
18  * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
19  * embedded.connectivity.solutions===============
20  *
21  * \endcode
22  *
23  * Description: LoRa PHY layer
24  *
25  * License: Revised BSD License, see LICENSE.TXT file include in the project
26  *
27  * Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jaeckle ( STACKFORCE )
28  *
29  * Copyright (c) 2017, Arm Limited and affiliates.
30  * SPDX-License-Identifier: BSD-3-Clause
31  *
32  */
33 
34 #ifndef LORAWAN_SYSTEM_LORAWAN_DATA_STRUCTURES_H_
35 #define LORAWAN_SYSTEM_LORAWAN_DATA_STRUCTURES_H_
36 
37 #include <inttypes.h>
38 #include "lorawan_types.h"
39 
40 /*!
41  * \brief Timer time variable definition
42  */
43 #ifndef lorawan_time_t
44 typedef uint32_t lorawan_time_t;
45 #endif
46 
47 /*!
48  * Sets the length of the LoRaMAC footer field.
49  * Mainly indicates the MIC field length.
50  */
51 #define LORAMAC_MFR_LEN 4
52 
53 /*!
54  * The FRMPayload overhead to be used when setting the `Radio.SetMaxPayloadLength`
55  * in the `RxWindowSetup` function.
56  * The maximum PHYPayload = MaxPayloadOfDatarate/MaxPayloadOfDatarateRepeater + LORA_MAC_FRMPAYLOAD_OVERHEAD
57  */
58 #define LORA_MAC_FRMPAYLOAD_OVERHEAD 13 // MHDR(1) + FHDR(7) + Port(1) + MIC(4)
59 
60 /**
61  * LoRaMac maximum number of channels
62  */
63 #define LORA_MAX_NB_CHANNELS 16
64 
65 /**
66  * Maximum PHY layer payload size for reception.
67  */
68 #define LORAMAC_PHY_MAXPAYLOAD 255
69 
70 #define LORAWAN_DEFAULT_QOS 1
71 
72 /**
73  *
74  * Default user application maximum data size for transmission
75  */
76 // reject if user tries to set more than MTU
77 #if MBED_CONF_LORA_TX_MAX_SIZE > 255
78 #warning "Cannot set TX Max size more than MTU=255"
79 #define MBED_CONF_LORA_TX_MAX_SIZE 255
80 #endif
81 
82 /*!
83  * LoRaMAC band parameters definition.
84  */
85 typedef struct {
86  /*!
87  * The duty cycle.
88  */
89  uint16_t duty_cycle;
90  /*!
91  * The maximum TX power.
92  */
93  int8_t max_tx_pwr;
94  /*!
95  * The timestamp of the last Join Request TX frame.
96  */
98  /*!
99  * The timestamp of the last TX frame.
100  */
102  /*!
103  * The device off time.
104  */
106  /*!
107  * Lower band boundry
108  */
109  uint32_t lower_band_freq;
110  /*!
111  * Higher band boundry
112  */
114 } band_t;
115 
116 /*!
117  * LoRaMAC receive window 2 channel parameters.
118  */
119 typedef struct {
120  /*!
121  * The frequency in Hz.
122  */
123  uint32_t frequency;
124  /*!
125  * The data rate.
126  *
127  * LoRaWAN Regional Parameters V1.0.2rB.
128  *
129  * The allowed ranges are region-specific. Please refer to \ref DR_0 to \ref DR_15 for details.
130  */
131  uint8_t datarate;
133 
134 /*!
135  * LoRaMAC receive window enumeration
136  */
137 typedef enum {
138  /*!
139  * LoRaMAC receive window 1
140  */
142  /*!
143  * LoRaMAC receive window 2
144  */
146  /*!
147  * LoRaMAC receive window 2 for class c - continuous listening
148  */
150  /*!
151  * LoRaMAC class b ping slot window
152  */
154 } rx_slot_t;
155 
156 /*!
157  * The global MAC layer parameters.
158  */
159 typedef struct {
160  /*!
161  * The TX power in channels.
162  */
164  /*!
165  * The data rate in channels.
166  */
168  /*!
169  * LoRaMac maximum time a reception window stays open.
170  */
171  uint32_t max_rx_win_time;
172  /*!
173  * Receive delay 1.
174  */
175  uint32_t recv_delay1;
176  /*!
177  * Receive delay 2.
178  */
179  uint32_t recv_delay2;
180  /*!
181  * Join accept delay 1.
182  */
184  /*!
185  * Join accept delay 1.
186  */
188  /*!
189  * The number of uplink messages repetitions for QOS set by network server
190  * in LinkADRReq mac command (unconfirmed messages only).
191  */
192  uint8_t nb_trans;
193  /*!
194  * The datarate offset between uplink and downlink on first window.
195  */
196  uint8_t rx1_dr_offset;
197  /*!
198  * LoRaMAC 2nd reception window settings.
199  */
201  /*!
202  * The uplink dwell time configuration. 0: No limit, 1: 400ms
203  */
205  /*!
206  * The downlink dwell time configuration. 0: No limit, 1: 400ms
207  */
209  /*!
210  * The maximum possible EIRP.
211  */
212  float max_eirp;
213  /*!
214  * The antenna gain of the node.
215  */
217 
218  /*!
219  * Maximum duty cycle
220  * \remark Possibility to shutdown the device.
221  */
222  uint8_t max_duty_cycle;
223  /*!
224  * Aggregated duty cycle management
225  */
227 
228  /*!
229  * LoRaMac ADR control status
230  */
231  bool adr_on;
233 
234 /*!
235  * LoRaMAC multicast channel parameter.
236  */
237 typedef struct multicast_params_s {
238  /*!
239  * Address.
240  */
241  uint32_t address;
242  /*!
243  * Network session key.
244  */
245  uint8_t nwk_skey[16];
246  /*!
247  * Application session key.
248  */
249  uint8_t app_skey[16];
250  /*!
251  * Downlink counter.
252  */
254  /*!
255  * A reference pointer to the next multicast channel parameters in the list.
256  */
259 
260 /*!
261  * LoRaMAC frame types.
262  *
263  * LoRaWAN Specification V1.0.2, chapter 4.2.1, table 1.
264  */
265 typedef enum {
266  /*!
267  * LoRaMAC join request frame.
268  */
270  /*!
271  * LoRaMAC join accept frame.
272  */
274  /*!
275  * LoRaMAC unconfirmed uplink frame.
276  */
278  /*!
279  * LoRaMAC unconfirmed downlink frame.
280  */
282  /*!
283  * LoRaMAC confirmed uplink frame.
284  */
286  /*!
287  * LoRaMAC confirmed downlink frame.
288  */
290  /*!
291  * LoRaMAC RFU frame.
292  */
294  /*!
295  * LoRaMAC proprietary frame.
296  */
299 
300 /*!
301  * LoRaMAC mote MAC commands.
302  *
303  * LoRaWAN Specification V1.0.2, chapter 5, table 4.
304  */
305 typedef enum {
306  /*!
307  * LinkCheckReq
308  */
310  /*!
311  * LinkADRAns
312  */
314  /*!
315  * DutyCycleAns
316  */
318  /*!
319  * RXParamSetupAns
320  */
322  /*!
323  * DevStatusAns
324  */
326  /*!
327  * NewChannelAns
328  */
330  /*!
331  * RXTimingSetupAns
332  */
334  /*!
335  * TXParamSetupAns
336  */
338  /*!
339  * DlChannelAns
340  */
343 
344 /*!
345  * LoRaMAC server MAC commands.
346  *
347  * LoRaWAN Specification V1.0.2 chapter 5, table 4.
348  */
349 typedef enum {
350  /*!
351  * LinkCheckAns
352  */
354  /*!
355  * LinkADRReq
356  */
358  /*!
359  * DutyCycleReq
360  */
362  /*!
363  * RXParamSetupReq
364  */
366  /*!
367  * DevStatusReq
368  */
370  /*!
371  * NewChannelReq
372  */
374  /*!
375  * RXTimingSetupReq
376  */
378  /*!
379  * NewChannelReq
380  */
382  /*!
383  * DlChannelReq
384  */
387 
388 /*!
389  * LoRaMAC battery level indicator.
390  */
391 typedef enum {
392  /*!
393  * An external power source.
394  */
396  /*!
397  * Battery level empty.
398  */
400  /*!
401  * Battery level full.
402  */
404  /*!
405  * Battery level - no measurement available.
406  */
409 
410 /*!
411  * LoRaMAC header field definition (MHDR field).
412  *
413  * LoRaWAN Specification V1.0.2, chapter 4.2.
414  */
415 typedef union {
416  /*!
417  * Byte-access to the bits.
418  */
419  uint8_t value;
420  /*!
421  * The structure containing single access to header bits.
422  */
423  struct hdr_bits_s {
424  /*!
425  * Major version.
426  */
427  uint8_t major : 2;
428  /*!
429  * RFU
430  */
431  uint8_t RFU : 3;
432  /*!
433  * Message type
434  */
435  uint8_t mtype : 3;
436  } bits;
438 
439 /*!
440  * LoRaMAC frame control field definition (FCtrl).
441  *
442  * LoRaWAN Specification V1.0.2, chapter 4.3.1.
443  */
444 typedef union {
445  /*!
446  * Byte-access to the bits.
447  */
448  uint8_t value;
449  /*!
450  * The structure containing single access to bits.
451  */
452  struct ctrl_bits_s {
453  /*!
454  * Frame options length.
455  */
456  uint8_t fopts_len : 4;
457  /*!
458  * Frame pending bit.
459  */
460  uint8_t fpending : 1;
461  /*!
462  * Message acknowledge bit.
463  */
464  uint8_t ack : 1;
465  /*!
466  * ADR acknowledgment request bit.
467  */
468  uint8_t adr_ack_req : 1;
469  /*!
470  * ADR control in the frame header.
471  */
472  uint8_t adr : 1;
473  } bits;
475 
476 /*!
477  * The enumeration containing the status of the operation of a MAC service.
478  */
479 typedef enum {
480  /*!
481  * Service performed successfully.
482  */
484  /*!
485  * An error occurred during the execution of the service.
486  */
488  /*!
489  * A TX timeout occurred.
490  */
492  /*!
493  * An RX timeout occurred on receive window 1.
494  */
496  /*!
497  * An RX timeout occurred on receive window 2.
498  */
500  /*!
501  * An RX error occurred on receive window 1.
502  */
504  /*!
505  * An RX error occurred on receive window 2.
506  */
508  /*!
509  * An error occurred in the join procedure.
510  */
512  /*!
513  * A frame with an invalid downlink counter was received. The
514  * downlink counter of the frame was equal to the local copy
515  * of the downlink counter of the node.
516  */
518  /*!
519  * The MAC could not retransmit a frame since the MAC decreased the datarate. The
520  * payload size is not applicable for the datarate.
521  */
523  /*!
524  * The node has lost MAX_FCNT_GAP or more frames.
525  */
527  /*!
528  * An address error occurred.
529  */
531  /*!
532  * Message integrity check failure.
533  */
535  /*!
536  * Crypto methods failure
537  */
540 
541 /*!
542  *
543  * \brief LoRaMAC data services
544  *
545  * \details The following table list the primitives supported by a
546  * specific MAC data service:
547  *
548  * Name | Request | Indication | Response | Confirm
549  * --------------------- | :-----: | :--------: | :------: | :-----:
550  * \ref MCPS_UNCONFIRMED | YES | YES | NO | YES
551  * \ref MCPS_CONFIRMED | YES | YES | NO | YES
552  * \ref MCPS_MULTICAST | NO | YES | NO | NO
553  * \ref MCPS_PROPRIETARY | YES | YES | NO | YES
554  *
555  */
556 typedef enum {
557  /*!
558  * Unconfirmed LoRaMAC frame.
559  */
561  /*!
562  * Confirmed LoRaMAC frame.
563  */
565  /*!
566  * Multicast LoRaMAC frame.
567  */
569  /*!
570  * Proprietary frame.
571  */
573 } mcps_type_t;
574 
575 /*!
576  * LoRaMAC MCPS-Confirm.
577  */
578 typedef struct {
579  /*!
580  * Holds the previously performed MCPS-Request type. i.e., the type of
581  * the MCPS request for which this confirmation is being generated
582  */
584  /*!
585  * The status of the operation.
586  */
588  /*!
589  * The uplink datarate.
590  */
591  uint8_t data_rate;
592  /*!
593  * The transmission power.
594  */
595  int8_t tx_power;
596  /*!
597  * Set if an acknowledgement was received.
598  */
600  /*!
601  * Provides the number of retransmissions.
602  */
603  uint8_t nb_retries;
604  /*!
605  * The transmission time on air of the frame.
606  */
608  /*!
609  * The uplink counter value related to the frame.
610  */
612  /*!
613  * The uplink channel related to the frame.
614  */
615  uint32_t channel;
617 
618 /*!
619  * LoRaMAC MCPS-Indication primitive.
620  */
621 typedef struct {
622  /*!
623  * True if an MCPS indication was pending
624  */
625  bool pending;
626  /*!
627  * MCPS-Indication type.
628  */
630  /*!
631  * The status of the operation.
632  */
634  /*!
635  * Multicast.
636  */
637  uint8_t multicast;
638  /*!
639  * The application port.
640  */
641  uint8_t port;
642  /*!
643  * The downlink datarate.
644  */
645  uint8_t rx_datarate;
646  /*!
647  * Frame pending status.
648  */
650  /*!
651  * A pointer to the received data stream.
652  */
653  const uint8_t *buffer;
654  /*!
655  * The size of the received data stream.
656  */
657  uint16_t buffer_size;
658  /*!
659  * Indicates, if data is available.
660  */
662  /*!
663  * The RSSI of the received packet.
664  */
665  int16_t rssi;
666  /*!
667  * The SNR of the received packet.
668  */
669  int8_t snr;
670  /*!
671  * The receive window.
672  *
673  * [0: Rx window 1, 1: Rx window 2]
674  */
676  /*!
677  * Set if an acknowledgement was received.
678  */
680  /*!
681  * The downlink counter value for the received frame.
682  */
684  /*!
685  * The downlink channel
686  */
687  uint32_t channel;
688  /*!
689  * The time on air of the received frame.
690  */
693 
694 /*!
695  * \brief LoRaMAC management services.
696  *
697  * \details The following table list the primitives supported by a
698  * specific MAC management service:
699  *
700  * Name | Request | Indication | Response | Confirm
701  * ---------------------------- | :-----: | :--------: | :------: | :-----:
702  * \ref MLME_JOIN | YES | NO | NO | YES
703  * \ref MLME_LINK_CHECK | YES | NO | NO | YES
704  * \ref MLME_TXCW | YES | NO | NO | YES
705  * \ref MLME_SCHEDULE_UPLINK | NO | YES | NO | NO
706  *
707  */
708 typedef enum {
709  /*!
710  * Initiates the Over-the-Air activation.
711  *
712  * LoRaWAN Specification V1.0.2, chapter 6.2.
713  */
715  /*!
716  * LinkCheckReq - Connectivity validation.
717  *
718  * LoRaWAN Specification V1.0.2, chapter 5, table 4.
719  */
721  /*!
722  * Sets TX continuous wave mode.
723  *
724  * LoRaWAN end-device certification.
725  */
727  /*!
728  * Sets TX continuous wave mode (new LoRa-Alliance CC definition).
729  *
730  * LoRaWAN end-device certification.
731  */
733  /*!
734  * Indicates that the application shall perform an uplink as
735  * soon as possible.
736  */
738 } mlme_type_t;
739 
740 /*!
741  * LoRaMAC MLME-Request for the join service.
742  */
743 typedef struct {
744  /*!
745  * A globally unique end-device identifier.
746  *
747  * LoRaWAN Specification V1.0.2, chapter 6.2.1.
748  */
749  uint8_t *dev_eui;
750  /*!
751  * An application identifier.
752  *
753  * LoRaWAN Specification V1.0.2, chapter 6.1.2
754  */
755  uint8_t *app_eui;
756  /*!
757  * AES-128 application key.
758  *
759  * LoRaWAN Specification V1.0.2, chapter 6.2.2.
760  */
761  uint8_t *app_key;
762  /*!
763  * The number of trials for the join request.
764  */
765  uint8_t nb_trials;
767 
768 /*!
769  * LoRaMAC MLME-Request for TX continuous wave mode.
770  */
771 typedef struct {
772  /*!
773  * The time while the radio is kept in continuous wave mode, in seconds.
774  */
775  uint16_t timeout;
776  /*!
777  * The RF frequency to set (only used with the new way).
778  */
779  uint32_t frequency;
780  /*!
781  * The RF output power to set (only used with the new way).
782  */
783  uint8_t power;
785 
786 
787 /*!
788  * LoRaMAC MLME-Confirm primitive.
789  */
790 typedef struct {
791  /*!
792  * Indicates if a request is pending or not
793  */
794  bool pending;
795  /*!
796  * The previously performed MLME-Request. i.e., the request type
797  * for which the confirmation is being generated
798  */
800  /*!
801  * The status of the operation.
802  */
804  /*!
805  * The transmission time on air of the frame.
806  */
808  /*!
809  * The demodulation margin. Contains the link margin [dB] of the last LinkCheckReq
810  * successfully received.
811  */
812  uint8_t demod_margin;
813  /*!
814  * The number of gateways which received the last LinkCheckReq.
815  */
816  uint8_t nb_gateways;
817  /*!
818  * The number of retransmissions.
819  */
820  uint8_t nb_retries;
822 
823 /*!
824  * LoRaMAC MLME-Indication primitive
825  */
826 typedef struct {
827  /*!
828  * MLME-Indication type
829  */
831  bool pending;
833 
834 /**
835  * End-device states.
836  */
837 typedef enum device_states {
838  DEVICE_STATE_NOT_INITIALIZED,
839  DEVICE_STATE_JOINING,
840  DEVICE_STATE_IDLE,
841  DEVICE_STATE_CONNECTING,
842  DEVICE_STATE_AWAITING_JOIN_ACCEPT,
843  DEVICE_STATE_RECEIVING,
844  DEVICE_STATE_CONNECTED,
845  DEVICE_STATE_SCHEDULING,
846  DEVICE_STATE_SENDING,
847  DEVICE_STATE_AWAITING_ACK,
848  DEVICE_STATE_STATUS_CHECK,
849  DEVICE_STATE_SHUTDOWN
851 
852 /**
853  * Stack level TX message structure
854  */
855 typedef struct {
856 
857  /**
858  * TX Ongoing flag
859  */
861 
862  /**
863  * Application Port Number
864  */
865  uint8_t port;
866 
867  /**
868  * Message type
869  */
871 
872  /*!
873  * Frame port field. Must be set if the payload is not empty. Use the
874  * application-specific frame port values: [1...223].
875  *
876  * LoRaWAN Specification V1.0.2, chapter 4.3.2.
877  */
878  uint8_t fport;
879 
880  /*!
881  * Uplink datarate, if ADR is off.
882  */
883  int8_t data_rate;
884  /*!
885  *
886  * For CONFIRMED Messages:
887  *
888  * The number of trials to transmit the frame, if the LoRaMAC layer did not
889  * receive an acknowledgment. The MAC performs a datarate adaptation
890  * according to the LoRaWAN Specification V1.0.2, chapter 18.4, as in
891  * the following table:
892  *
893  * Transmission nb | Data Rate
894  * ----------------|-----------
895  * 1 (first) | DR
896  * 2 | DR
897  * 3 | max(DR-1,0)
898  * 4 | max(DR-1,0)
899  * 5 | max(DR-2,0)
900  * 6 | max(DR-2,0)
901  * 7 | max(DR-3,0)
902  * 8 | max(DR-3,0)
903  *
904  * Note that if nb_trials is set to 1 or 2, the MAC will not decrease
905  * the datarate, if the LoRaMAC layer did not receive an acknowledgment.
906  *
907  * For UNCONFIRMED Messages:
908  *
909  * Provides a certain QOS level set by network server in LinkADRReq MAC
910  * command. The device will transmit the given UNCONFIRMED message nb_trials
911  * time with same frame counter until a downlink is received. Standard defined
912  * range is 1:15. Data rates will NOT be adapted according to chapter 18.4.
913  */
914  uint8_t nb_trials;
915 
916  /** Payload data
917  *
918  * Base pointer to the buffer
919  */
920  uint8_t f_buffer[MBED_CONF_LORA_TX_MAX_SIZE];
921 
922  /** Payload size.
923  *
924  * The size of the frame payload.
925  */
926  uint16_t f_buffer_size;
927 
928  /**
929  * Pending data size
930  */
931  uint16_t pending_size;
932 
934 
935 /** lora_mac_rx_message_type_t
936  *
937  * An enum representing a structure for RX messages.
938  */
939 typedef enum {
940  LORAMAC_RX_MLME_CONFIRM = 0, /**< lora_mac_mlme_confirm_t */
941  LORAMAC_RX_MCPS_CONFIRM, /**< lora_mac_mcps_confirm_t */
942  LORAMAC_RX_MCPS_INDICATION /**< lora_mac_mcps_indication_t */
943 } rx_msg_type;
944 
945 /** lora_mac_rx_message_by_type_t union
946  *
947  * A union representing a structure for RX messages.
948  */
949 typedef union {
950  loramac_mlme_confirm_t mlme_confirm;
951  loramac_mcps_confirm_t mcps_confirm;
952  loramac_mcps_indication_t mcps_indication;
953 } rx_message_u;
954 
955 /** loramac_rx_message_t
956  *
957  * A structure representing a structure for an RX message.
958  */
959 typedef struct {
960  bool receive_ready;
961  rx_msg_type type;
962  rx_message_u msg;
963  uint16_t pending_size;
964  uint16_t prev_read_size;
966 
967 /** LoRaWAN session
968  *
969  * A structure for keeping session details.
970  */
971 typedef struct lorawan_session {
972  /**
973  * True if the session is active
974  */
975  bool active;
976 
977  /*!
978  * Select the connection type, either LORAWAN_CONNECTION_OTAA
979  * or LORAWAN_CONNECTION_ABP.
980  */
981  uint8_t connect_type;
982 
983  /**
984  * LoRaWAN uplink counter
985  */
986  uint32_t uplink_counter;
987  /**
988  * LoRaWAN downlink counter
989  */
992 
993 /*!
994  * The parameter structure for the function for regional rx configuration.
995  */
996 typedef struct {
997  /*!
998  * Type of modulation used (LoRa or FSK)
999  */
1000  uint8_t modem_type;
1001  /*!
1002  * The RX channel.
1003  */
1004  uint8_t channel;
1005  /*!
1006  * The RX datarate index.
1007  */
1008  uint8_t datarate;
1009  /*!
1010  * The RX bandwidth.
1011  */
1012  uint8_t bandwidth;
1013  /*!
1014  * The RX datarate offset.
1015  */
1016  int8_t dr_offset;
1017  /*!
1018  * The RX frequency.
1019  */
1020  uint32_t frequency;
1021  /*!
1022  * The RX window timeout - Symbols
1023  */
1024  uint32_t window_timeout;
1025  /*!
1026  * The RX window timeout - Milliseconds
1027  */
1029  /*!
1030  * The RX window offset
1031  */
1032  int32_t window_offset;
1033  /*!
1034  * The downlink dwell time.
1035  */
1036  uint8_t dl_dwell_time;
1037  /*!
1038  * Set to true, if a repeater is supported.
1039  */
1041  /*!
1042  * Set to true, if RX should be continuous.
1043  */
1045  /*!
1046  * Sets the RX window.
1047  */
1050 
1051 /*!
1052  * \brief Timer object description
1053  */
1054 typedef struct {
1056  int timer_id;
1057 } timer_event_t;
1058 
1059 /*!
1060  * A composite structure containing device identifiers and security keys
1061  */
1062 typedef struct {
1063  /*!
1064  * Device IEEE EUI
1065  */
1066  uint8_t *dev_eui;
1067 
1068  /*!
1069  * Application IEEE EUI
1070  */
1071  uint8_t *app_eui;
1072 
1073  /*!
1074  * AES encryption/decryption cipher application key
1075  */
1076  uint8_t *app_key;
1077 
1078  /*!
1079  * AES encryption/decryption cipher network session key
1080  * NOTE! LoRaMac determines the length of the key based on sizeof this variable
1081  */
1082  uint8_t nwk_skey[16];
1083 
1084  /*!
1085  * AES encryption/decryption cipher application session key
1086  * NOTE! LoRaMac determines the length of the key based on sizeof this variable
1087  */
1088  uint8_t app_skey[16];
1089 
1090 } loramac_keys;
1091 
1092 /*!
1093  * A composite structure containing all the timers used in the LoRaWAN operation
1094  */
1095 typedef struct {
1096  /*!
1097  * Aggregated duty cycle management
1098  */
1100  lorawan_time_t aggregated_timeoff;
1101 
1102  /*!
1103  * Stores the time at LoRaMac initialization.
1104  *
1105  * \remark Used for the BACKOFF_DC computation.
1106  */
1108 
1109  /*!
1110  * Last transmission time on air
1111  */
1113 
1114  /*!
1115  * LoRaMac duty cycle backoff timer
1116  */
1118 
1119  /*!
1120  * LoRaMac reception windows timers
1121  */
1123  timer_event_t rx_window2_timer;
1124 
1125  /*!
1126  * Acknowledge timeout timer. Used for packet retransmissions.
1127  */
1129 
1130 } lorawan_timers;
1131 
1132 /*!
1133  * Global MAC layer configuration parameters
1134  */
1135 typedef struct {
1136 
1137  /*!
1138  * Holds the type of current Receive window slot
1139  */
1141 
1142  /*!
1143  * Indicates if the node is connected to a private or public network
1144  */
1146 
1147  /*!
1148  * Indicates if the node supports repeaters
1149  */
1151 
1152  /*!
1153  * Used for test purposes. Disables the opening of the reception windows.
1154  */
1156 
1157  /*!
1158  * Indicates if the MAC layer has already joined a network.
1159  */
1161 
1162  /*!
1163  * If the node has sent a FRAME_TYPE_DATA_CONFIRMED_UP this variable indicates
1164  * if the nodes needs to manage the server acknowledgement.
1165  */
1167 
1168  /*!
1169  * If the server has sent a FRAME_TYPE_DATA_CONFIRMED_DOWN this variable indicates
1170  * if the ACK bit must be set for the next transmission
1171  */
1173 
1174  /*!
1175  * Enables/Disables duty cycle management (Test only)
1176  */
1178 
1179  /*!
1180  * Set to true, if the last uplink was a join request
1181  */
1183 
1184  /*!
1185  * Indicates if the AckTimeout timer has expired or not
1186  */
1188 
1189  /*!
1190  * Current channel index
1191  */
1192  uint8_t channel;
1193 
1194  /*!
1195  * Current channel index
1196  */
1198 
1199  /*!
1200  * Uplink messages repetitions counter
1201  */
1203 
1204  /*!
1205  * TX buffer used for encrypted outgoing frames
1206  */
1207  uint8_t tx_buffer[LORAMAC_PHY_MAXPAYLOAD];
1208 
1209  /*!
1210  * Length of TX buffer
1211  */
1212  uint16_t tx_buffer_len;
1213 
1214  /*!
1215  * Used for storing decrypted RX data.
1216  */
1217  uint8_t rx_buffer[LORAMAC_PHY_MAXPAYLOAD];
1218 
1219  /*!
1220  * Length of the RX buffer
1221  */
1222  uint8_t rx_buffer_len;
1223 
1224  /*!
1225  * Number of trials to get a frame acknowledged
1226  */
1228 
1229  /*!
1230  * Number of trials to get a frame acknowledged
1231  */
1233 
1234  /*!
1235  * Maximum number of trials for the Join Request
1236  */
1238 
1239  /*!
1240  * Number of trials for the Join Request
1241  */
1243 
1244  /*!
1245  * Mac keys
1246  */
1248 
1249  /*!
1250  * Device nonce is a random value extracted by issuing a sequence of RSSI
1251  * measurements
1252  */
1253  uint16_t dev_nonce;
1254 
1255  /*!
1256  * Network ID ( 3 bytes )
1257  */
1258  uint32_t net_id;
1259 
1260  /*!
1261  * Mote Address
1262  */
1263  uint32_t dev_addr;
1264 
1265  /*!
1266  * LoRaMAC frame counter. Each time a packet is sent the counter is incremented.
1267  * Only the 16 LSB bits are sent
1268  */
1270 
1271  /*!
1272  * LoRaMAC frame counter. Each time a packet is received the counter is incremented.
1273  * Only the 16 LSB bits are received
1274  */
1276 
1277  /*!
1278  * Counts the number of missed ADR acknowledgements
1279  */
1281 
1282  /*!
1283  * LoRaMac reception windows delay
1284  * \remark normal frame: RxWindowXDelay = ReceiveDelayX - Offset
1285  * join frame : RxWindowXDelay = JoinAcceptDelayX - Offset
1286  */
1288  uint32_t rx_window2_delay;
1289 
1290  /*!
1291  * Timer objects and stored values
1292  */
1294 
1295  /*!
1296  * LoRaMac parameters
1297  */
1299 
1300  /*!
1301  * Receive Window configurations for PHY layer
1302  */
1304  rx_config_params_t rx_window2_config;
1305 
1306  /*!
1307  * Multicast channels linked list
1308  */
1310 
1312 
1313 #endif /* LORAWAN_SYSTEM_LORAWAN_DATA_STRUCTURES_H_ */
timer_event_t rx_window1_timer
struct multicast_params_s * next
uint16_t f_buffer_size
Payload size.
uint16_t pending_size
Pending data size.
uint32_t downlink_counter
LoRaWAN downlink counter.
multicast_params_t * multicast_channels
lorawan_time_t aggregated_last_tx_time
rx_msg_type
lora_mac_rx_message_type_t
loramac_rx_message_t
lorawan_time_t last_join_tx_time
lora_mac_rx_message_by_type_t union
device_states
End-device states.
lora_mac_system_params_t sys_params
Stack level TX message structure.
mcps_type_t type
Message type.
lora_mac_mcps_confirm_t
Timer object description.
lora_mac_mcps_indication_t
rx_config_params_t rx_window1_config
uint32_t lorawan_time_t
Timer time variable definition.
Contains data structures required by LoRaWANBase class.
loramac_event_info_status_t status
Callback< R(ArgTs...)> callback(R(*func)(ArgTs...)=nullptr) noexcept
Create a callback class with type inferred from the arguments.
Definition: Callback.h:678
uint16_t duty_cycle
uint32_t uplink_counter
LoRaWAN uplink counter.
#define LORAMAC_PHY_MAXPAYLOAD
Maximum PHY layer payload size for reception.
enum device_states device_states_t
End-device states.
struct multicast_params_s multicast_params_t
struct lorawan_session lorawan_session_t
LoRaWAN session.
loramac_event_info_status_t status
loramac_event_info_status_t
device_battery_level_t
uint32_t higher_band_freq
lora_mac_mlme_confirm_t
mlme_type_t
LoRaMAC management services.
loramac_event_info_status_t status
mcps_type_t
LoRaMAC data services.
bool active
True if the session is active.
uint8_t port
Application Port Number.
timer_event_t ack_timeout_timer
lorawan_time_t off_time
bool tx_ongoing
TX Ongoing flag.
Default user application maximum data size for transmission.
lorawan_time_t last_tx_time
lorawan_time_t mac_init_time
uint32_t lower_band_freq
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.