From 4d88dfac9cd775738f9eb372cca0ce6dc8b470cf Mon Sep 17 00:00:00 2001 From: Terry Moore Date: Mon, 18 Mar 2019 23:30:50 -0400 Subject: [PATCH] Fix #267: compliance: count messages, don't use FcntDn --- src/lmic/lmic_compliance.c | 7 ++++++- src/lmic/lmic_compliance.h | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/lmic/lmic_compliance.c b/src/lmic/lmic_compliance.c index 222083f4..d46e1223 100644 --- a/src/lmic/lmic_compliance.c +++ b/src/lmic/lmic_compliance.c @@ -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) @@ -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; @@ -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); @@ -725,5 +729,6 @@ static void acDoJoin(void) { LMIC_Compliance.eventflags &= ~LMIC_COMPLIANCE_EVENT_JOINED; LMIC_unjoin(); + LMIC_Compliance.downlinkCount = 0; LMIC_startJoining(); } diff --git a/src/lmic/lmic_compliance.h b/src/lmic/lmic_compliance.h index ab326b3f..14853016 100644 --- a/src/lmic/lmic_compliance.h +++ b/src/lmic/lmic_compliance.h @@ -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.