Skip to content

Commit a679639

Browse files
committed
Disable duty rate during compliance test.
Add an event handler for compliance test to disable the duty rate during the join when compliance test is active.
1 parent 76793e7 commit a679639

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

examples/compliance-otaa-halconfig/compliance-otaa-halconfig.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ bool lastWasTxStart;
223223
uint32_t lastTxStartTime;
224224

225225
void myEventCb(void *pUserData, ev_t ev) {
226+
LMIC_complianceEvent(ev);
227+
226228
eventQueue.putEvent(ev);
227229

228230
if (ev == EV_TXSTART) {

src/lmic/lmic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,7 @@ enum lmic_compliance_rx_action_e {
716716
LMIC_COMPLIANCE_RX_ACTION_END // exit compliance mode, discard this message
717717
};
718718

719+
void LMIC_complianceEvent(ev_t ev);
719720
lmic_compliance_rx_action_t LMIC_complianceRxMessage(u1_t port, const u1_t *pMessage, size_t nMessage);
720721

721722
// Declare onEvent() function, to make sure any definition will have the

src/lmic/lmic_compliance.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,47 @@ lmic_compliance_t LMIC_Compliance;
7474

7575
/*
7676
77+
Name: LMIC_complianceEvent()
78+
79+
Function:
80+
Modify join state during compliance test.
81+
82+
Definition:
83+
void LMIC_complianceEvent(ev_t ev);
84+
85+
Description:
86+
Clients who want to handle the LoRaWAN compliance protocol on
87+
port 224 should call this routine in the event callback.
88+
This function will update the LMIC duty rate to allow the test
89+
to run in a raisonnable time.
90+
91+
Returns:
92+
nothing.
93+
94+
*/
95+
96+
97+
void LMIC_complianceEvent(ev_t ev) {
98+
lmic_compliance_state_t const complianceState = LMIC_Compliance.state;
99+
100+
// only handle event during compliance test.
101+
if(!lmic_compliance_state_IsActive(complianceState))
102+
return;
103+
104+
switch (ev)
105+
{
106+
case EV_JOINING:
107+
case EV_JOIN_TXCOMPLETE:
108+
// Remove duty rate during join test.
109+
LMIC.globalDutyRate = 0;
110+
break;
111+
default:
112+
break;
113+
}
114+
}
115+
116+
/*
117+
77118
Name: LMIC_complianceRxMessage()
78119
79120
Function:

0 commit comments

Comments
 (0)