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