From 26fe712571d1292abbd08ff848f1282c44575ac6 Mon Sep 17 00:00:00 2001 From: dberenguer Date: Fri, 17 May 2019 18:01:58 +0200 Subject: [PATCH 01/13] Disable downlinks for low power nodes --- src/lmic/config.h | 10 +++++++++- src/lmic/lmic.c | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lmic/config.h b/src/lmic/config.h index 32e30a92..40d4ca36 100644 --- a/src/lmic/config.h +++ b/src/lmic/config.h @@ -47,7 +47,7 @@ //#define CFG_sx1272_radio 1 // This is the SX1276/SX1277/SX1278/SX1279 radio, which is also used on // the HopeRF RFM95 boards. -//#define CFG_sx1276_radio 1 +#define CFG_sx1276_radio 1 // ensure that a radio is defined. #if ! (defined(CFG_sx1272_radio) || defined(CFG_sx1276_radio)) @@ -190,4 +190,12 @@ # define LMIC_ENABLE_long_messages 1 /* PARAM */ #endif +// LMIC_DISABLE_DOWNLINK +// Disable any downlink action on the node. Trigger EV_TXCOMPLETE just after +// completing the uplink. This feature is specially useful for low-power devices +// not in the need to receive downlink packets from server. This flag prevents the +// node from having wait to around five seconds (DNW2_SAFETY_ZONE + LMICcore_rndDelay(2)) +// before going to sleep +#define LMIC_DISABLE_DOWNLINK 1 + #endif // _lmic_config_h_ diff --git a/src/lmic/lmic.c b/src/lmic/lmic.c index d825bddb..9f1b2f69 100644 --- a/src/lmic/lmic.c +++ b/src/lmic/lmic.c @@ -1476,11 +1476,16 @@ static void processRx2DnData (xref2osjob_t osjob) { if( LMIC.dataLen == 0 ) { initTxrxFlags(__func__, 0); // nothing in 1st/2nd DN slot + + #ifdef LMIC_DISABLE_DOWNLINK + os_setTimedCallback(&LMIC.osjob, os_getTime(), FUNC_ADDR(processRx2DnDataDelay)); + #else // Delay callback processing to avoid up TX while gateway is txing our missed frame! // Since DNW2 uses SF12 by default we wait 3 secs. os_setTimedCallback(&LMIC.osjob, (os_getTime() + DNW2_SAFETY_ZONE + LMICcore_rndDelay(2)), FUNC_ADDR(processRx2DnDataDelay)); + #endif return; } processDnData(); From 30cdc56092798cb1fa5223fd8c2a005dbea89f53 Mon Sep 17 00:00:00 2001 From: dberenguer Date: Fri, 17 May 2019 18:05:02 +0200 Subject: [PATCH 02/13] commented out radio definition --- src/lmic/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lmic/config.h b/src/lmic/config.h index 40d4ca36..23353382 100644 --- a/src/lmic/config.h +++ b/src/lmic/config.h @@ -47,7 +47,7 @@ //#define CFG_sx1272_radio 1 // This is the SX1276/SX1277/SX1278/SX1279 radio, which is also used on // the HopeRF RFM95 boards. -#define CFG_sx1276_radio 1 +//#define CFG_sx1276_radio 1 // ensure that a radio is defined. #if ! (defined(CFG_sx1272_radio) || defined(CFG_sx1276_radio)) From 30a98535c0c080c399f04d8cc47523c0fbd86cb4 Mon Sep 17 00:00:00 2001 From: dberenguer Date: Fri, 17 May 2019 20:20:50 +0200 Subject: [PATCH 03/13] Removing delays from updataDone and processRx1DnData whenever LMIC_DISABLE_DOWNLINK is defined --- src/lmic/lmic.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/lmic/lmic.c b/src/lmic/lmic.c index 9f1b2f69..dd2af05c 100644 --- a/src/lmic/lmic.c +++ b/src/lmic/lmic.c @@ -1503,8 +1503,14 @@ 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() ) + { + #ifdef LMIC_DISABLE_DOWNLINK + schedRx12(sec2osticks(0), FUNC_ADDR(setupRx2DnData), LMIC.dn2Dr); + #else + schedRx12(sec2osticks(LMIC.rxDelay +(int)DELAY_EXTDNW2), FUNC_ADDR(setupRx2DnData), LMIC.dn2Dr); + #endif + } } @@ -1518,7 +1524,11 @@ static void setupRx1DnData (xref2osjob_t osjob) { static void updataDone (xref2osjob_t osjob) { LMIC_API_PARAMETER(osjob); + #ifdef LMIC_DISABLE_DOWNLINK + txDone(0, FUNC_ADDR(setupRx1DnData)); + #else txDone(sec2osticks(LMIC.rxDelay), FUNC_ADDR(setupRx1DnData)); + #endif } // ======================================== From 0dad609d61c614a4179a5be024c28dc4f9b12c75 Mon Sep 17 00:00:00 2001 From: dberenguer Date: Sat, 18 May 2019 19:21:27 +0200 Subject: [PATCH 04/13] Pings and beacons disabled by default --- src/lmic/config.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lmic/config.h b/src/lmic/config.h index 23353382..19d1985c 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 From feee3e4b4994522f00ffcb5213a327d0a5081191 Mon Sep 17 00:00:00 2001 From: dberenguer Date: Sat, 18 May 2019 19:22:47 +0200 Subject: [PATCH 05/13] Downlinks totally disabled by LMIC_DISABLE_DOWNLINK --- src/lmic/lmic.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/src/lmic/lmic.c b/src/lmic/lmic.c index dd2af05c..b4dcbd22 100644 --- a/src/lmic/lmic.c +++ b/src/lmic/lmic.c @@ -1477,15 +1477,11 @@ static void processRx2DnData (xref2osjob_t osjob) { if( LMIC.dataLen == 0 ) { initTxrxFlags(__func__, 0); // nothing in 1st/2nd DN slot - #ifdef LMIC_DISABLE_DOWNLINK - os_setTimedCallback(&LMIC.osjob, os_getTime(), FUNC_ADDR(processRx2DnDataDelay)); - #else // Delay callback processing to avoid up TX while gateway is txing our missed frame! // Since DNW2 uses SF12 by default we wait 3 secs. os_setTimedCallback(&LMIC.osjob, (os_getTime() + DNW2_SAFETY_ZONE + LMICcore_rndDelay(2)), FUNC_ADDR(processRx2DnDataDelay)); - #endif return; } processDnData(); @@ -1504,13 +1500,7 @@ static void processRx1DnData (xref2osjob_t osjob) { LMIC_API_PARAMETER(osjob); if( LMIC.dataLen == 0 || !processDnData() ) - { - #ifdef LMIC_DISABLE_DOWNLINK - schedRx12(sec2osticks(0), FUNC_ADDR(setupRx2DnData), LMIC.dn2Dr); - #else schedRx12(sec2osticks(LMIC.rxDelay +(int)DELAY_EXTDNW2), FUNC_ADDR(setupRx2DnData), LMIC.dn2Dr); - #endif - } } @@ -1525,7 +1515,8 @@ static void updataDone (xref2osjob_t osjob) { LMIC_API_PARAMETER(osjob); #ifdef LMIC_DISABLE_DOWNLINK - txDone(0, FUNC_ADDR(setupRx1DnData)); + LMIC.opmode &= ~(OP_TXDATA|OP_TXRXPEND); + reportEventAndUpdate(EV_TXCOMPLETE); #else txDone(sec2osticks(LMIC.rxDelay), FUNC_ADDR(setupRx1DnData)); #endif From 3ffcac100434ab58e53fc06d32683387978b98ba Mon Sep 17 00:00:00 2001 From: Daniel Berenguer Date: Mon, 20 May 2019 15:52:02 +0200 Subject: [PATCH 06/13] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 6e0ff816..29be4ac8 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +** This fork was specifically created for those developpers wanting to create low-power applications. Unlike the mainstream version and other forks, this version allows disabling 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.*** + # Arduino-LMIC library This repository contains the IBM LMIC (LoraMAC-in-C) library, slightly From 1de10e0fe4870963bc7e3e19427da769c6e10521 Mon Sep 17 00:00:00 2001 From: Daniel Berenguer Date: Mon, 20 May 2019 15:52:53 +0200 Subject: [PATCH 07/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 29be4ac8..9b883c78 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -** This fork was specifically created for those developpers wanting to create low-power applications. Unlike the mainstream version and other forks, this version allows disabling 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.*** +** This fork was specifically created for those developpers wanting to create low-power applications. Unlike the mainstream version and other forks, this version allows disabling 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.** # Arduino-LMIC library From 99e6ffb73c9d8fe5902c372c41c9448207a37719 Mon Sep 17 00:00:00 2001 From: Daniel Berenguer Date: Mon, 20 May 2019 15:54:41 +0200 Subject: [PATCH 08/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9b883c78..af823ee7 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -** This fork was specifically created for those developpers wanting to create low-power applications. Unlike the mainstream version and other forks, this version allows disabling 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.** +**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 disabling 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.** # Arduino-LMIC library From e78e8cfdae40f24c9821e6a2e14add4395bd3927 Mon Sep 17 00:00:00 2001 From: Daniel Berenguer Date: Mon, 20 May 2019 15:56:53 +0200 Subject: [PATCH 09/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index af823ee7..e26bb28b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -**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 disabling 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.** +**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.** # Arduino-LMIC library From 64377528871325838604d8baf171c7ebec198de8 Mon Sep 17 00:00:00 2001 From: Daniel Berenguer Date: Tue, 21 May 2019 11:26:02 +0200 Subject: [PATCH 10/13] Update README.md --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index e26bb28b..f6057cea 100644 --- a/README.md +++ b/README.md @@ -1,5 +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 can not 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 (LoraMAC-in-C) library, slightly From 5292c2c1a7a69fedb82db795e5f383651ad657dc Mon Sep 17 00:00:00 2001 From: Daniel Berenguer Date: Tue, 21 May 2019 11:26:47 +0200 Subject: [PATCH 11/13] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f6057cea..5d129928 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ # Important note -This version of Arduino-lmic does not comply with LoRaWAN™ Specification v1.1 since downlinks can not be disabled. +This version of Arduino-lmic does not comply with LoRaWAN™ Specification v1.1 since downlinks should never be disabled. From LoRaWAN™ Specification v1.1: From fa7768120b812b04a19c51738eb381b04152ec41 Mon Sep 17 00:00:00 2001 From: dberenguer Date: Mon, 21 Oct 2019 12:45:34 +0200 Subject: [PATCH 12/13] LMIC.downlinkEnabled flag --- src/lmic/lmic.c | 16 +++++++++------- src/lmic/lmic.h | 8 ++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/lmic/lmic.c b/src/lmic/lmic.c index b4dcbd22..345f8d19 100644 --- a/src/lmic/lmic.c +++ b/src/lmic/lmic.c @@ -38,7 +38,6 @@ DEFINE_LMIC; - // Fwd decls. static void reportEventNoUpdate(ev_t); static void reportEventAndUpdate(ev_t); @@ -1514,12 +1513,13 @@ static void setupRx1DnData (xref2osjob_t osjob) { static void updataDone (xref2osjob_t osjob) { LMIC_API_PARAMETER(osjob); - #ifdef LMIC_DISABLE_DOWNLINK - LMIC.opmode &= ~(OP_TXDATA|OP_TXRXPEND); - reportEventAndUpdate(EV_TXCOMPLETE); - #else - txDone(sec2osticks(LMIC.rxDelay), FUNC_ADDR(setupRx1DnData)); - #endif + if (LMIC.downlinkEnabled == 0) + { + LMIC.opmode &= ~(OP_TXDATA|OP_TXRXPEND); + reportEventAndUpdate(EV_TXCOMPLETE); + } + else + txDone(sec2osticks(LMIC.rxDelay), FUNC_ADDR(setupRx1DnData)); } // ======================================== @@ -2290,6 +2290,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 faa8a125..57e40960 100644 --- a/src/lmic/lmic.h +++ b/src/lmic/lmic.h @@ -505,6 +505,8 @@ struct lmic_t { u1_t noRXIQinversion; u1_t saveIrqFlags; // last LoRa IRQ flags + + u1_t downlinkEnabled; }; //! \var struct lmic_t LMIC @@ -581,6 +583,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!!! From 9e7dfbdea85a793a3254eb7915ee15687238d8ad Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 25 May 2020 20:17:33 +0200 Subject: [PATCH 13/13] EU 868 MHz by default --- project_config/lmic_project_config.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 */