Arduino LMIC 6.0.1
Arduino LoRaWAN(r) MAC in C
Loading...
Searching...
No Matches
lmic_compliance.h
1/*
2
3Module: lmic_compliance.h
4
5Function:
6 Internal header file for compliance-related work.
7
8Copyright notice and license info:
9 See LICENSE file accompanying this project.
10
11Author:
12 Terry Moore, MCCI Corporation March 2019
13
14Description:
15 This header file allows us to break up the compliance
16 functions into multiple .c files if we wish.
17
18*/
19
20#ifndef _lmic_compliance_h_ /* prevent multiple includes */
21#define _lmic_compliance_h_
22
23#ifdef __cplusplus
24extern "C"{
25#endif
26
27#ifndef _lmic_h_
28# include "lmic.h"
29#endif
30
31#include <stdbool.h>
32#include <stdint.h>
33
34typedef struct lmic_compliance_s lmic_compliance_t;
35
36// concrete type for the state enumeration for the compliance engine.
37typedef uint8_t lmic_compliance_state_t;
38
39enum lmic_compliance_state_e {
40 LMIC_COMPLIANCE_STATE_IDLE = 0, // app state
41 LMIC_COMPLIANCE_STATE_STOPPING = 1, // transitioning back to app
42 LMIC_COMPLIANCE_STATE_ACTIVATING = 2, // transitioning to compliance state
43 LMIC_COMPLIANCE_STATE_ACTIVE = 3, // in compliance state
44};
45
46// return true if a state value indicates that the FSM is active.
47static inline bool
48lmic_compliance_state_IsActive(lmic_compliance_state_t s) {
49 return s >= LMIC_COMPLIANCE_STATE_ACTIVATING;
50}
51
52// events from the outside world to the FSM
53typedef uint8_t lmic_compliance_eventflags_t;
54
55enum lmic_compliance_eventflags_e {
56 LMIC_COMPLIANCE_EVENT_ACTIVATE = 1u << 0,
57 LMIC_COMPLIANCE_EVENT_DEACTIVATE = 1u << 1,
58 LMIC_COMPLIANCE_EVENT_TIMER_EXPIRED = 1u << 2,
59 LMIC_COMPLIANCE_EVENT_UPLINK_COMPLETE = 1u << 3,
60 LMIC_COMPLIANCE_EVENT_ECHO_REQUEST = 1u << 4,
61};
62
63typedef uint8_t lmic_compliance_fsmflags_t;
64enum lmic_compliance_fsmflags_e {
65 LMIC_COMPLIANCE_FSM_ACTIVE = 1u << 0,
66 LMIC_COMPLIANCE_FSM_REENTERED = 1u << 1,
67 LMIC_COMPLIANCE_FSM_CONFIRM = 1u << 2,
68};
69
70typedef uint8_t lmic_compliance_fsmstate_t;
71enum lmic_compliance_fsmstate_e {
72 LMIC_COMPLIANCE_FSMSTATE_INITIAL = 0,
73 LMIC_COMPLIANCE_FSMSTATE_NOCHANGE = 1,
74 LMIC_COMPLIANCE_FSMSTATE_ACTIVE = 2,
75 LMIC_COMPLIANCE_FSMSTATE_INACTIVE = 3,
76 LMIC_COMPLIANCE_FSMSTATE_TESTMODE = 4, // sending test uplinks
77 LMIC_COMPLIANCE_FSMSTATE_ECHOING = 5,
78 LMIC_COMPLIANCE_FSMSTATE_REPORTING = 6,
79 LMIC_COMPLIANCE_FSMSTATE_RECOVERY = 7,
80 LMIC_COMPLIANCE_FSMSTATE_TXBUSY = 8,
81};
82
83#define LMIC_COMPLIANCE_FSMSTATE__NAMES \
84 "INITIAL", "NOCHANGE", "ACTIVE", "INACTIVE", "TESTMODE", \
85 "ECHOING", "REPORTING", "RECOVERY", "TXBUSY"
86
87typedef struct lmic_compliance_eventcb_s lmic_compliance_eventcb_t;
89 // save the user's event CB while active.
90 lmic_event_cb_t *pEventCb;
91 // save the user's event data while active.
92 void *pUserData;
93};
94
95// structure for saving band settings during test
96typedef struct lmic_compliance_band_s lmic_compliance_band_t;
98 u2_t txcap; // saved 1/duty cycle
99};
100
101// the state of the compliance engine.
103 // uint64
104 // uintptr
105 osjob_t timerJob; // the job for driving uplinks
106 osjob_t fsmJob; // job for reevaluating the FSM.
107 lmic_compliance_eventcb_t saveEvent; // the user's event handler.
108
109 // uint32
110
111 // uint16
112#if CFG_LMIC_EU_like
113 lmic_compliance_band_t saveBands[MAX_BANDS];
114#endif // CFG_LMIC_EU_like
115
116 // we are required to maintain a downlink count
117 // that is reset on join/test entry and incremented for
118 // each valid test message.
119 uint16_t downlinkCount;
120
121 // uint8
122
123 lmic_compliance_state_t state; // current state of compliance engine.
124 lmic_compliance_eventflags_t eventflags; // incoming events.
125 lmic_compliance_fsmflags_t fsmFlags; // FSM operational flags
126 lmic_compliance_fsmstate_t fsmState; // FSM current state
127
128 uint8_t uplinkSize;
129 uint8_t uplinkMessage[MAX_LEN_PAYLOAD];
130};
131
132extern lmic_compliance_t LMIC_Compliance;
133
134#ifdef __cplusplus
135} // extern "C"
136#endif
137
138#endif /* _lmic_compliance_h_ */
LMIC API.
Definition lmic_compliance.h:97
Definition lmic_compliance.h:88
Definition lmic_compliance.h:102
Definition oslmic.h:170