diff --git a/README.md b/README.md index d48e3260..10f189b3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,16 @@ +**This fork was specifically created for those developpers wanting to build real low-power applications. Unlike the mainstream version and other forks, this version allows us to disable downlinks completely. Calling LMIC_setDownlinks(false) turns downlinks off anytime dynamically, reducing active times down to the minimum necessary to transmit uplink messages. As an example, typical uplink+downlink intervals at SF7 vary around 6-9 seconds. With downlinks deactivated, uplinks only take ~50 msec to complete.** + +# Important note + +This version of Arduino-lmic does not comply with LoRaWAN™ Specification v1.1 since downlinks should never be disabled. + +From LoRaWAN™ Specification v1.1: + +> 3.3.6 Important notice on receive windows +> An end-device SHALL NOT transmit another uplink message before it either has received a +> downlink message in the first or second receive window of the previous transmission, or the +> second receive window of the previous transmission is expired. + # Arduino-LMIC library This repository contains the IBM LMIC (LoRaWAN-MAC-in-C) library, slightly diff --git a/project_config/lmic_project_config.h b/project_config/lmic_project_config.h index 3f86e171..3c03376e 100644 --- a/project_config/lmic_project_config.h +++ b/project_config/lmic_project_config.h @@ -1,6 +1,6 @@ // project-specific definitions -//#define CFG_eu868 1 -#define CFG_us915 1 +#define CFG_eu868 1 +//#define CFG_us915 1 //#define CFG_au915 1 //#define CFG_as923 1 // #define LMIC_COUNTRY_CODE LMIC_COUNTRY_CODE_JP /* for as923-JP */ diff --git a/src/lmic/config.h b/src/lmic/config.h index 8673b46a..de106677 100644 --- a/src/lmic/config.h +++ b/src/lmic/config.h @@ -109,10 +109,10 @@ // define this in lmic_project_config.h to disable all code related to joining //#define DISABLE_JOIN // define this in lmic_project_config.h to disable all code related to ping -//#define DISABLE_PING +#define DISABLE_PING // define this in lmic_project_config.h to disable all code related to beacon tracking. // Requires ping to be disabled too -//#define DISABLE_BEACONS +#define DISABLE_BEACONS // define these in lmic_project_config.h to disable the corresponding MAC commands. // Class A diff --git a/src/lmic/lmic.c b/src/lmic/lmic.c index 957d6222..570ffa4b 100644 --- a/src/lmic/lmic.c +++ b/src/lmic/lmic.c @@ -1818,8 +1818,8 @@ static void setupRx2DnData (xref2osjob_t osjob) { static void processRx1DnData (xref2osjob_t osjob) { LMIC_API_PARAMETER(osjob); - if( LMIC.dataLen == 0 || !processDnData() ) - schedRx12(sec2osticks(LMIC.rxDelay +(int)DELAY_EXTDNW2), FUNC_ADDR(setupRx2DnData), LMIC.dn2Dr); + if( LMIC.dataLen == 0 || !processDnData() ) + schedRx12(sec2osticks(LMIC.rxDelay +(int)DELAY_EXTDNW2), FUNC_ADDR(setupRx2DnData), LMIC.dn2Dr); } @@ -1833,7 +1833,13 @@ static void setupRx1DnData (xref2osjob_t osjob) { static void updataDone (xref2osjob_t osjob) { LMIC_API_PARAMETER(osjob); - txDone(sec2osticks(LMIC.rxDelay), FUNC_ADDR(setupRx1DnData)); + if (LMIC.downlinkEnabled == 0) + { + LMIC.opmode &= ~(OP_TXDATA|OP_TXRXPEND); + reportEventAndUpdate(EV_TXCOMPLETE); + } + else + txDone(sec2osticks(LMIC.rxDelay), FUNC_ADDR(setupRx1DnData)); } // ======================================== @@ -2817,6 +2823,8 @@ void LMIC_reset (void) { LMIC.netDeviceTime = 0; // the "invalid" time. LMIC.netDeviceTimeFrac = 0; #endif // LMIC_ENABLE_DeviceTimeReq + + LMIC.downlinkEnabled = 1; } diff --git a/src/lmic/lmic.h b/src/lmic/lmic.h index 9463fa29..7c446961 100644 --- a/src/lmic/lmic.h +++ b/src/lmic/lmic.h @@ -643,6 +643,8 @@ struct lmic_t { u1_t noRXIQinversion; u1_t saveIrqFlags; // last LoRa IRQ flags + + u1_t downlinkEnabled; }; //! \var struct lmic_t LMIC @@ -723,6 +725,12 @@ lmic_compliance_rx_action_t LMIC_complianceRxMessage(u1_t port, const u1_t *pMes DECL_ON_LMIC_EVENT; #endif /* LMIC_ENABLE_onEvent */ +// Disable downlinks +inline void LMIC_setDownlinks(bit_t enabled) +{ + LMIC.downlinkEnabled = enabled; +} + // Special APIs - for development or testing // !!!See implementation for caveats!!!