Skip to content

Commit

Permalink
Merge pull request #274 from mcci-catena/issue267
Browse files Browse the repository at this point in the history
Fix #267: compliance: count messages, don't use FcntDn
  • Loading branch information
terrillmoore authored Mar 19, 2019
2 parents e30e56e + 4d88dfa commit 6e5ebbe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/lmic/lmic_compliance.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ LMIC_complianceRxMessage(
) {
lmic_compliance_state_t const complianceState = LMIC_Compliance.state;

// update the counter used by the status message.
++LMIC_Compliance.downlinkCount;

// filter normal messages.
if (port != LORAWAN_PORT_COMPLIANCE) {
return lmic_compliance_state_IsActive(complianceState)
Expand Down Expand Up @@ -202,6 +205,7 @@ Name: evActivate()

static void evActivate(void) {
if (! lmic_compliance_state_IsActive(LMIC_Compliance.state)) {
LMIC_Compliance.downlinkCount = 0;
LMIC_Compliance.eventflags |= LMIC_COMPLIANCE_EVENT_ACTIVATE;
LMIC_Compliance.state = LMIC_COMPLIANCE_STATE_ACTIVATING;

Expand Down Expand Up @@ -665,7 +669,7 @@ static void acExitActiveMode(void) {

static void acSendUplink(void) {
uint8_t payload[2];
uint32_t const downlink = LMIC.seqnoDn;
uint32_t const downlink = LMIC_Compliance.downlinkCount;

// build the uplink message
payload[0] = (uint8_t) (downlink >> 8);
Expand Down Expand Up @@ -725,5 +729,6 @@ static void acDoJoin(void) {
LMIC_Compliance.eventflags &= ~LMIC_COMPLIANCE_EVENT_JOINED;

LMIC_unjoin();
LMIC_Compliance.downlinkCount = 0;
LMIC_startJoining();
}
5 changes: 5 additions & 0 deletions src/lmic/lmic_compliance.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ struct lmic_compliance_s {
// uint32
// uint16

// we are required to maintain a downlink count
// that is reset on join/test entry and incremented for
// each valid test message.
uint16_t downlinkCount;

// uint8

lmic_compliance_state_t state; // current state of compliance engine.
Expand Down

0 comments on commit 6e5ebbe

Please sign in to comment.