From 4629038364b748452bad617d008442f15e948238 Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Fri, 17 Aug 2018 16:42:49 +0200 Subject: [PATCH 01/24] Adding attempts to readLine and state marker if radio module is unresponsive --- src/TheThingsNetwork.cpp | 25 ++++++++++++++++--------- src/TheThingsNetwork.h | 1 + 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/TheThingsNetwork.cpp b/src/TheThingsNetwork.cpp index c6b4b42c..66d4c156 100644 --- a/src/TheThingsNetwork.cpp +++ b/src/TheThingsNetwork.cpp @@ -357,15 +357,21 @@ void TheThingsNetwork::clearReadBuffer() } } -size_t TheThingsNetwork::readLine(char *buffer, size_t size) +size_t TheThingsNetwork::readLine(char *buffer, size_t size, uint8_t attempts = 3) // Default timeout value 10s and is set in class initiator { size_t read = 0; - while (read == 0) + while (read == 0 && attempts>0) { read = modemStream->readBytesUntil('\n', buffer, size); } - buffer[read - 1] = '\0'; // set \r to \0 - return read; + if(attempts<=0){ // If attempts is activated return 0 and set RN state marker + this->radioModuleInvalidState = true; // Inform the application about the radio module is not responsive. + return 0; + } + else{ + buffer[read - 1] = '\0'; // set \r to \0 + return read; + } } size_t TheThingsNetwork::readResponse(uint8_t prefixTable, uint8_t index, char *buffer, size_t size) @@ -417,7 +423,7 @@ void TheThingsNetwork::reset(bool adr) size_t length = readResponse(SYS_TABLE, SYS_RESET, buffer, sizeof(buffer)); autoBaud(); - length = readResponse(SYS_TABLE, SYS_TABLE, SYS_GET_VER, buffer, sizeof(buffer)); + length = readResponse(SYS_TABLE, SYS_TABLE, SYS_GET_VER, buffer, sizeof(buffer)); // buffer contains "RN2xx3[xx] x.x.x ...", splitting model from version char *model = strtok(buffer, " "); @@ -436,6 +442,7 @@ void TheThingsNetwork::reset(bool adr) sendMacSet(MAC_ADR, "off"); } this->adr = adr; + this->radioModuleInvalidState = false; } void TheThingsNetwork::saveState() @@ -776,8 +783,8 @@ void TheThingsNetwork::configureKR920_923() void TheThingsNetwork::configureIN865_867() { sendMacSet(MAC_ADR, "off"); // TODO: remove when ADR is implemented for this plan - sendMacSet(MAC_RX2, "2 866550000"); // SF10 - + sendMacSet(MAC_RX2, "2 866550000"); // SF10 + // Disable the three default LoRaWAN channels sendChSet(MAC_CHANNEL_STATUS, 0, "off"); sendChSet(MAC_CHANNEL_STATUS, 1, "off"); @@ -1035,7 +1042,7 @@ void TheThingsNetwork::sleep(uint32_t mseconds) } void TheThingsNetwork::wake() -{ +{ autoBaud(); } @@ -1051,7 +1058,7 @@ void TheThingsNetwork::linkCheck(uint16_t seconds) modemStream->write(buffer); modemStream->write(SEND_MSG); debugPrintLn(buffer); - waitForOk(); + waitForOk(); } uint8_t TheThingsNetwork::getLinkCheckGateways() diff --git a/src/TheThingsNetwork.h b/src/TheThingsNetwork.h index 92f84e13..8f33d35c 100644 --- a/src/TheThingsNetwork.h +++ b/src/TheThingsNetwork.h @@ -54,6 +54,7 @@ class TheThingsNetwork bool adr; char buffer[512]; bool baudDetermined = false; + bool radioModuleInvalidState = false; void (*messageCallback)(const uint8_t *payload, size_t size, port_t port); void clearReadBuffer(); From 0653d8d730270d0dea89d62449fa3a461fbb33a1 Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Fri, 24 Aug 2018 11:05:21 +0200 Subject: [PATCH 02/24] Fix spacing around brackets --- src/TheThingsNetwork.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/TheThingsNetwork.cpp b/src/TheThingsNetwork.cpp index 66d4c156..48f49f76 100644 --- a/src/TheThingsNetwork.cpp +++ b/src/TheThingsNetwork.cpp @@ -364,11 +364,13 @@ size_t TheThingsNetwork::readLine(char *buffer, size_t size, uint8_t attempts = { read = modemStream->readBytesUntil('\n', buffer, size); } - if(attempts<=0){ // If attempts is activated return 0 and set RN state marker + if(attempts<=0) + { // If attempts is activated return 0 and set RN state marker this->radioModuleInvalidState = true; // Inform the application about the radio module is not responsive. return 0; } - else{ + else + { buffer[read - 1] = '\0'; // set \r to \0 return read; } From 012e6511281617deff3f88c08b76a78c3ca0034d Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Fri, 24 Aug 2018 11:09:25 +0200 Subject: [PATCH 03/24] Adding attempts to TheTHingsNetwork.h --- src/TheThingsNetwork.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/TheThingsNetwork.h b/src/TheThingsNetwork.h index 8f33d35c..7cfac0b4 100644 --- a/src/TheThingsNetwork.h +++ b/src/TheThingsNetwork.h @@ -54,11 +54,11 @@ class TheThingsNetwork bool adr; char buffer[512]; bool baudDetermined = false; - bool radioModuleInvalidState = false; + bool radioModuleInvalidState = false; void (*messageCallback)(const uint8_t *payload, size_t size, port_t port); void clearReadBuffer(); - size_t readLine(char *buffer, size_t size); + size_t readLine(char *buffer, size_t size, uint8_t attempts); size_t readResponse(uint8_t prefixTable, uint8_t indexTable, uint8_t index, char *buffer, size_t size); size_t readResponse(uint8_t table, uint8_t index, char *buffer, size_t size); @@ -103,7 +103,7 @@ class TheThingsNetwork void wake(); void saveState(); void linkCheck(uint16_t seconds); - uint8_t getLinkCheckGateways(); + uint8_t getLinkCheckGateways(); uint8_t getLinkCheckMargin(); }; From 969373288df6b74c779a58c470008a385e7382f9 Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Fri, 24 Aug 2018 11:19:12 +0200 Subject: [PATCH 04/24] No need for else when if has return --- src/TheThingsNetwork.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/TheThingsNetwork.cpp b/src/TheThingsNetwork.cpp index 48f49f76..3008e029 100644 --- a/src/TheThingsNetwork.cpp +++ b/src/TheThingsNetwork.cpp @@ -369,11 +369,8 @@ size_t TheThingsNetwork::readLine(char *buffer, size_t size, uint8_t attempts = this->radioModuleInvalidState = true; // Inform the application about the radio module is not responsive. return 0; } - else - { - buffer[read - 1] = '\0'; // set \r to \0 - return read; - } + buffer[read - 1] = '\0'; // set \r to \0 + return read; } size_t TheThingsNetwork::readResponse(uint8_t prefixTable, uint8_t index, char *buffer, size_t size) From 77403c652ceba7608f8d19709ebf06a15dae8e69 Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Wed, 3 Oct 2018 13:40:30 +0200 Subject: [PATCH 05/24] Set default in header file --- src/TheThingsNetwork.cpp | 2 +- src/TheThingsNetwork.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/TheThingsNetwork.cpp b/src/TheThingsNetwork.cpp index 3008e029..7ecf9b0e 100644 --- a/src/TheThingsNetwork.cpp +++ b/src/TheThingsNetwork.cpp @@ -357,7 +357,7 @@ void TheThingsNetwork::clearReadBuffer() } } -size_t TheThingsNetwork::readLine(char *buffer, size_t size, uint8_t attempts = 3) // Default timeout value 10s and is set in class initiator +size_t TheThingsNetwork::readLine(char *buffer, size_t size, uint8_t attempts) // Default timeout value 10s and is set in class initiator { size_t read = 0; while (read == 0 && attempts>0) diff --git a/src/TheThingsNetwork.h b/src/TheThingsNetwork.h index 7cfac0b4..5ff698da 100644 --- a/src/TheThingsNetwork.h +++ b/src/TheThingsNetwork.h @@ -58,7 +58,7 @@ class TheThingsNetwork void (*messageCallback)(const uint8_t *payload, size_t size, port_t port); void clearReadBuffer(); - size_t readLine(char *buffer, size_t size, uint8_t attempts); + size_t readLine(char *buffer, size_t size, uint8_t attempts = 3); size_t readResponse(uint8_t prefixTable, uint8_t indexTable, uint8_t index, char *buffer, size_t size); size_t readResponse(uint8_t table, uint8_t index, char *buffer, size_t size); From 2a1968eed6fc6b589318cb5a39d7ec776a839ec6 Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Wed, 3 Oct 2018 13:44:57 +0200 Subject: [PATCH 06/24] decrement attempts --- src/TheThingsNetwork.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TheThingsNetwork.cpp b/src/TheThingsNetwork.cpp index 7ecf9b0e..0758b83e 100644 --- a/src/TheThingsNetwork.cpp +++ b/src/TheThingsNetwork.cpp @@ -360,7 +360,7 @@ void TheThingsNetwork::clearReadBuffer() size_t TheThingsNetwork::readLine(char *buffer, size_t size, uint8_t attempts) // Default timeout value 10s and is set in class initiator { size_t read = 0; - while (read == 0 && attempts>0) + while (!read && attempts--) { read = modemStream->readBytesUntil('\n', buffer, size); } From 91d5b8b5747ed781b4faf005223f33a422242b0d Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Wed, 3 Oct 2018 14:42:19 +0200 Subject: [PATCH 07/24] Proposal to handle exception when RN module does not respond --- src/TheThingsNetwork.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/TheThingsNetwork.cpp b/src/TheThingsNetwork.cpp index 0758b83e..9896f35a 100644 --- a/src/TheThingsNetwork.cpp +++ b/src/TheThingsNetwork.cpp @@ -367,6 +367,8 @@ size_t TheThingsNetwork::readLine(char *buffer, size_t size, uint8_t attempts) / if(attempts<=0) { // If attempts is activated return 0 and set RN state marker this->radioModuleInvalidState = true; // Inform the application about the radio module is not responsive. + debugPrintLn('No response from RN module. Soft resetting RN Module'); + this->reset(true); return 0; } buffer[read - 1] = '\0'; // set \r to \0 From 2df5307aa3a1cd9a76109aeb5ad272c3161e05b9 Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Fri, 26 Oct 2018 14:39:33 +0200 Subject: [PATCH 08/24] Changed variable name from radioModuleInvalidState to needsHardReset --- src/TheThingsNetwork.cpp | 6 +++--- src/TheThingsNetwork.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/TheThingsNetwork.cpp b/src/TheThingsNetwork.cpp index 9896f35a..d1e864cf 100644 --- a/src/TheThingsNetwork.cpp +++ b/src/TheThingsNetwork.cpp @@ -366,9 +366,9 @@ size_t TheThingsNetwork::readLine(char *buffer, size_t size, uint8_t attempts) / } if(attempts<=0) { // If attempts is activated return 0 and set RN state marker - this->radioModuleInvalidState = true; // Inform the application about the radio module is not responsive. + this->needsHardReset = true; // Inform the application about the radio module is not responsive. debugPrintLn('No response from RN module. Soft resetting RN Module'); - this->reset(true); + return 0; } buffer[read - 1] = '\0'; // set \r to \0 @@ -443,7 +443,7 @@ void TheThingsNetwork::reset(bool adr) sendMacSet(MAC_ADR, "off"); } this->adr = adr; - this->radioModuleInvalidState = false; + this->needsHardReset = false; } void TheThingsNetwork::saveState() diff --git a/src/TheThingsNetwork.h b/src/TheThingsNetwork.h index 5ff698da..8beb4735 100644 --- a/src/TheThingsNetwork.h +++ b/src/TheThingsNetwork.h @@ -54,7 +54,7 @@ class TheThingsNetwork bool adr; char buffer[512]; bool baudDetermined = false; - bool radioModuleInvalidState = false; + bool needsHardReset = false; void (*messageCallback)(const uint8_t *payload, size_t size, port_t port); void clearReadBuffer(); From d4a6ce5bd0611baae930993b748b43f16df4ba4e Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Fri, 26 Oct 2018 14:52:53 +0200 Subject: [PATCH 09/24] Added hardReset function with non-blocking delay. made needsHardReset a public variable --- src/TheThingsNetwork.cpp | 10 ++++++++++ src/TheThingsNetwork.h | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/TheThingsNetwork.cpp b/src/TheThingsNetwork.cpp index d1e864cf..7cc1a5f6 100644 --- a/src/TheThingsNetwork.cpp +++ b/src/TheThingsNetwork.cpp @@ -446,6 +446,16 @@ void TheThingsNetwork::reset(bool adr) this->needsHardReset = false; } +void TheThingsNetwork::resetHard(uint8_t resetPin){ + digitalWrite(resetPin, LOW); + unsigned long time_now = milis(); + int period = 1000; + while(millis() < time_now + period){ + // wait + } + digitalWrite(resetPin, HIGH); +} + void TheThingsNetwork::saveState() { debugPrint(SENDING); diff --git a/src/TheThingsNetwork.h b/src/TheThingsNetwork.h index 8beb4735..f961ff51 100644 --- a/src/TheThingsNetwork.h +++ b/src/TheThingsNetwork.h @@ -54,7 +54,6 @@ class TheThingsNetwork bool adr; char buffer[512]; bool baudDetermined = false; - bool needsHardReset = false; void (*messageCallback)(const uint8_t *payload, size_t size, port_t port); void clearReadBuffer(); @@ -85,8 +84,11 @@ class TheThingsNetwork void sendGetValue(uint8_t table, uint8_t prefix, uint8_t index); public: + bool needsHardReset = false; + TheThingsNetwork(Stream &modemStream, Stream &debugStream, ttn_fp_t fp, uint8_t sf = TTN_DEFAULT_SF, uint8_t fsb = TTN_DEFAULT_FSB); void reset(bool adr = true); + void resetHard(uint8_t resetPin); void showStatus(); size_t getHardwareEui(char *buffer, size_t size); size_t getAppEui(char *buffer, size_t size); From 72fc4f2e51b71825f5dcf865728f6fe80940b47f Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Fri, 26 Oct 2018 14:57:36 +0200 Subject: [PATCH 10/24] Updating documentation for hardreset --- docs/TheThingsNetwork.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/TheThingsNetwork.md b/docs/TheThingsNetwork.md index 94130b80..176fcaba 100644 --- a/docs/TheThingsNetwork.md +++ b/docs/TheThingsNetwork.md @@ -26,6 +26,14 @@ Performs a software reset of the RN module. This does not clear saved state, e.g void reset(bool adr); ``` +## Method: `hardReset` + +Performs a hardware reset of the RN module. Input parameter is the pin which the reset pin from the module is connected to. This does clear saved state, e.g. provisioned keys. + +```c +void hardResetuint8_t resetPin); +``` + - `bool adr`: Enable/disable Adaptive Data Rate. ## Method: `getHardwareEui` From 71e3d0af9dff3a4040a2049a23d5b833594d415b Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Sat, 1 Dec 2018 03:52:56 +0100 Subject: [PATCH 11/24] Changed wording of unresponsive rn module in readline function --- src/TheThingsNetwork.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TheThingsNetwork.cpp b/src/TheThingsNetwork.cpp index 7cc1a5f6..1e9c6b75 100644 --- a/src/TheThingsNetwork.cpp +++ b/src/TheThingsNetwork.cpp @@ -367,7 +367,7 @@ size_t TheThingsNetwork::readLine(char *buffer, size_t size, uint8_t attempts) / if(attempts<=0) { // If attempts is activated return 0 and set RN state marker this->needsHardReset = true; // Inform the application about the radio module is not responsive. - debugPrintLn('No response from RN module. Soft resetting RN Module'); + debugPrintLn('No response from RN module.'); return 0; } From 833ec1e77908d87222f7c9fd1ce5caee2df9d875 Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Sat, 1 Dec 2018 03:53:41 +0100 Subject: [PATCH 12/24] Spacing in if statement in readline function --- src/TheThingsNetwork.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TheThingsNetwork.cpp b/src/TheThingsNetwork.cpp index 1e9c6b75..a70a0712 100644 --- a/src/TheThingsNetwork.cpp +++ b/src/TheThingsNetwork.cpp @@ -364,7 +364,7 @@ size_t TheThingsNetwork::readLine(char *buffer, size_t size, uint8_t attempts) / { read = modemStream->readBytesUntil('\n', buffer, size); } - if(attempts<=0) + if (attempts<=0) { // If attempts is activated return 0 and set RN state marker this->needsHardReset = true; // Inform the application about the radio module is not responsive. debugPrintLn('No response from RN module.'); From 0fc3bc2ea128fe442871f8bc8ceac7606f225458 Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Sat, 1 Dec 2018 03:54:27 +0100 Subject: [PATCH 13/24] Removing comment at readline function --- src/TheThingsNetwork.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TheThingsNetwork.cpp b/src/TheThingsNetwork.cpp index a70a0712..6d229101 100644 --- a/src/TheThingsNetwork.cpp +++ b/src/TheThingsNetwork.cpp @@ -357,7 +357,7 @@ void TheThingsNetwork::clearReadBuffer() } } -size_t TheThingsNetwork::readLine(char *buffer, size_t size, uint8_t attempts) // Default timeout value 10s and is set in class initiator +size_t TheThingsNetwork::readLine(char *buffer, size_t size, uint8_t attempts) { size_t read = 0; while (!read && attempts--) From d74d17db070b8e6c9ac8d286cd99d91b4e9390c8 Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Sat, 1 Dec 2018 04:06:56 +0100 Subject: [PATCH 14/24] Fixed spelling mistake of millis in resetHard --- src/TheThingsNetwork.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TheThingsNetwork.cpp b/src/TheThingsNetwork.cpp index 6d229101..423147cb 100644 --- a/src/TheThingsNetwork.cpp +++ b/src/TheThingsNetwork.cpp @@ -448,7 +448,7 @@ void TheThingsNetwork::reset(bool adr) void TheThingsNetwork::resetHard(uint8_t resetPin){ digitalWrite(resetPin, LOW); - unsigned long time_now = milis(); + unsigned long time_now = millis(); int period = 1000; while(millis() < time_now + period){ // wait From fe0c8ab94508f51ac00d8a388149ef39dc7d7a1f Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Sat, 1 Dec 2018 04:12:09 +0100 Subject: [PATCH 15/24] Replacing single qoute with double qoute to fix warning: character constant too long for its type --- src/TheThingsNetwork.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TheThingsNetwork.cpp b/src/TheThingsNetwork.cpp index 423147cb..00a339fd 100644 --- a/src/TheThingsNetwork.cpp +++ b/src/TheThingsNetwork.cpp @@ -367,7 +367,7 @@ size_t TheThingsNetwork::readLine(char *buffer, size_t size, uint8_t attempts) if (attempts<=0) { // If attempts is activated return 0 and set RN state marker this->needsHardReset = true; // Inform the application about the radio module is not responsive. - debugPrintLn('No response from RN module.'); + debugPrintLn("No response from RN module."); return 0; } From a0afabf0bd533ffa70ec9cbcea988c40dcbefd4c Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Sat, 1 Dec 2018 04:19:46 +0100 Subject: [PATCH 16/24] remove empty line --- src/TheThingsNetwork.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/TheThingsNetwork.cpp b/src/TheThingsNetwork.cpp index 00a339fd..31279b62 100644 --- a/src/TheThingsNetwork.cpp +++ b/src/TheThingsNetwork.cpp @@ -368,7 +368,6 @@ size_t TheThingsNetwork::readLine(char *buffer, size_t size, uint8_t attempts) { // If attempts is activated return 0 and set RN state marker this->needsHardReset = true; // Inform the application about the radio module is not responsive. debugPrintLn("No response from RN module."); - return 0; } buffer[read - 1] = '\0'; // set \r to \0 From 69ef4438d544ff9afdaa1d0a4dc2f6d3c847f80d Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Wed, 5 Dec 2018 21:40:29 +0100 Subject: [PATCH 17/24] Fixed missing ( --- docs/TheThingsNetwork.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/TheThingsNetwork.md b/docs/TheThingsNetwork.md index 176fcaba..bee73841 100644 --- a/docs/TheThingsNetwork.md +++ b/docs/TheThingsNetwork.md @@ -31,7 +31,7 @@ void reset(bool adr); Performs a hardware reset of the RN module. Input parameter is the pin which the reset pin from the module is connected to. This does clear saved state, e.g. provisioned keys. ```c -void hardResetuint8_t resetPin); +void hardReset(uint8_t resetPin); ``` - `bool adr`: Enable/disable Adaptive Data Rate. From 896a8aa723efb53a796a0d550bcab4f24b490bb5 Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Wed, 5 Dec 2018 21:43:39 +0100 Subject: [PATCH 18/24] moved adr parameter to reset and added parameter description for hardreset --- docs/TheThingsNetwork.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/TheThingsNetwork.md b/docs/TheThingsNetwork.md index bee73841..de54af11 100644 --- a/docs/TheThingsNetwork.md +++ b/docs/TheThingsNetwork.md @@ -26,6 +26,8 @@ Performs a software reset of the RN module. This does not clear saved state, e.g void reset(bool adr); ``` +- `bool adr`: Enable/disable Adaptive Data Rate. + ## Method: `hardReset` Performs a hardware reset of the RN module. Input parameter is the pin which the reset pin from the module is connected to. This does clear saved state, e.g. provisioned keys. @@ -34,7 +36,7 @@ Performs a hardware reset of the RN module. Input parameter is the pin which the void hardReset(uint8_t resetPin); ``` -- `bool adr`: Enable/disable Adaptive Data Rate. +- `uint8_t resetPin`: The output pin that is connection to the module's reset pin. ## Method: `getHardwareEui` From 88c81a05457f104332ac35829505b1e8dfbac08f Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Wed, 5 Dec 2018 21:44:30 +0100 Subject: [PATCH 19/24] Spelling mistake --- docs/TheThingsNetwork.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/TheThingsNetwork.md b/docs/TheThingsNetwork.md index de54af11..02ade956 100644 --- a/docs/TheThingsNetwork.md +++ b/docs/TheThingsNetwork.md @@ -36,7 +36,7 @@ Performs a hardware reset of the RN module. Input parameter is the pin which the void hardReset(uint8_t resetPin); ``` -- `uint8_t resetPin`: The output pin that is connection to the module's reset pin. +- `uint8_t resetPin`: The output pin that is connected to the module's reset pin. ## Method: `getHardwareEui` From 13b554fc5eaabde5265b67251d7c881c3106e91a Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Wed, 5 Dec 2018 21:52:16 +0100 Subject: [PATCH 20/24] Reformulated the non i/o blocking wait function to make it more understandable --- src/TheThingsNetwork.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/TheThingsNetwork.cpp b/src/TheThingsNetwork.cpp index 31279b62..f8bf6c64 100644 --- a/src/TheThingsNetwork.cpp +++ b/src/TheThingsNetwork.cpp @@ -449,8 +449,8 @@ void TheThingsNetwork::resetHard(uint8_t resetPin){ digitalWrite(resetPin, LOW); unsigned long time_now = millis(); int period = 1000; + // Non I/O blocking wait function while(millis() < time_now + period){ - // wait } digitalWrite(resetPin, HIGH); } From 8c8cb8c256084914ef7da199a923549c8e51b8a1 Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Wed, 5 Dec 2018 21:54:38 +0100 Subject: [PATCH 21/24] Updated the way while brackets are placed in resetHard --- src/TheThingsNetwork.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/TheThingsNetwork.cpp b/src/TheThingsNetwork.cpp index f8bf6c64..553021c8 100644 --- a/src/TheThingsNetwork.cpp +++ b/src/TheThingsNetwork.cpp @@ -450,7 +450,8 @@ void TheThingsNetwork::resetHard(uint8_t resetPin){ unsigned long time_now = millis(); int period = 1000; // Non I/O blocking wait function - while(millis() < time_now + period){ + while(millis() < time_now + period) + { } digitalWrite(resetPin, HIGH); } From 8ec0a258450007c2ebd3dce9403d4233ef5216d7 Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Sat, 22 Dec 2018 18:08:13 +0100 Subject: [PATCH 22/24] Updated hardreset documentation to include initial pinmode setup --- docs/TheThingsNetwork.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/TheThingsNetwork.md b/docs/TheThingsNetwork.md index 02ade956..f8429252 100644 --- a/docs/TheThingsNetwork.md +++ b/docs/TheThingsNetwork.md @@ -31,6 +31,7 @@ void reset(bool adr); ## Method: `hardReset` Performs a hardware reset of the RN module. Input parameter is the pin which the reset pin from the module is connected to. This does clear saved state, e.g. provisioned keys. +The `resetPin` should be configured as output and set to high. ```c void hardReset(uint8_t resetPin); From a17f5e494e5b1f9f8b55168aefcfcfa3f774fa6d Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Sat, 22 Dec 2018 18:10:25 +0100 Subject: [PATCH 23/24] rewording of hardreset output pin config --- docs/TheThingsNetwork.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/TheThingsNetwork.md b/docs/TheThingsNetwork.md index f8429252..c23384b7 100644 --- a/docs/TheThingsNetwork.md +++ b/docs/TheThingsNetwork.md @@ -31,13 +31,12 @@ void reset(bool adr); ## Method: `hardReset` Performs a hardware reset of the RN module. Input parameter is the pin which the reset pin from the module is connected to. This does clear saved state, e.g. provisioned keys. -The `resetPin` should be configured as output and set to high. ```c void hardReset(uint8_t resetPin); ``` -- `uint8_t resetPin`: The output pin that is connected to the module's reset pin. +- `uint8_t resetPin`: The output pin that is connected to the module's reset pin. The output pin should be configured as output and set to high by the user. ## Method: `getHardwareEui` From 87dacf4da494b481f124ae5ce72b8663d3f74758 Mon Sep 17 00:00:00 2001 From: Peter Savnik Date: Fri, 28 Dec 2018 12:36:17 +0100 Subject: [PATCH 24/24] Using delay(1000) instead of custom delay function to ensure that ESP8266 background operations will work --- src/TheThingsNetwork.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/TheThingsNetwork.cpp b/src/TheThingsNetwork.cpp index 553021c8..7b06eb11 100644 --- a/src/TheThingsNetwork.cpp +++ b/src/TheThingsNetwork.cpp @@ -447,12 +447,7 @@ void TheThingsNetwork::reset(bool adr) void TheThingsNetwork::resetHard(uint8_t resetPin){ digitalWrite(resetPin, LOW); - unsigned long time_now = millis(); - int period = 1000; - // Non I/O blocking wait function - while(millis() < time_now + period) - { - } + delay(1000); digitalWrite(resetPin, HIGH); }