From 292a2f49926fb8ec5fea79b8c9af34d90df0c836 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 3 May 2019 15:30:28 -0400 Subject: [PATCH 01/88] Corrected call to sensor power pin in place of sdCardPwrPin --- examples/DRWI_CitSci/DRWI_CitSci.ino | 2 +- examples/DRWI_LTE/DRWI_LTE.ino | 2 +- examples/DRWI_NoCellular/DRWI_NoCellular.ino | 2 +- examples/baro_rho_correction/baro_rho_correction.ino | 2 +- examples/data_saving/data_saving.ino | 2 +- examples/double_logger/double_logger.ino | 4 ++-- examples/logging_to_MMW/logging_to_MMW.ino | 2 +- examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino | 2 +- examples/menu_a_la_carte/menu_a_la_carte.ino | 2 +- examples/simple_logging/simple_logging.ino | 2 +- .../simple_logging_LearnEnviroDIY.ino | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/DRWI_CitSci/DRWI_CitSci.ino b/examples/DRWI_CitSci/DRWI_CitSci.ino index e47455f53..d988d0105 100644 --- a/examples/DRWI_CitSci/DRWI_CitSci.ino +++ b/examples/DRWI_CitSci/DRWI_CitSci.ino @@ -319,7 +319,7 @@ void setup() // Attach the modem and information pins to the logger dataLogger.attachModem(modem); - dataLogger.setLoggerPins(wakePin, sdCardSSPin, sensorPowerPin, buttonPin, greenLED); + dataLogger.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); // Begin the logger dataLogger.begin(); diff --git a/examples/DRWI_LTE/DRWI_LTE.ino b/examples/DRWI_LTE/DRWI_LTE.ino index d7cacd837..0dab4a784 100644 --- a/examples/DRWI_LTE/DRWI_LTE.ino +++ b/examples/DRWI_LTE/DRWI_LTE.ino @@ -386,7 +386,7 @@ void setup() // Attach the modem and information pins to the logger dataLogger.attachModem(modem); - dataLogger.setLoggerPins(wakePin, sdCardSSPin, sensorPowerPin, buttonPin, greenLED); + dataLogger.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); // Begin the logger dataLogger.begin(); diff --git a/examples/DRWI_NoCellular/DRWI_NoCellular.ino b/examples/DRWI_NoCellular/DRWI_NoCellular.ino index 75aa94a27..5177b16b2 100644 --- a/examples/DRWI_NoCellular/DRWI_NoCellular.ino +++ b/examples/DRWI_NoCellular/DRWI_NoCellular.ino @@ -224,7 +224,7 @@ void setup() Logger::setTZOffset(timeZone); // Attach information pins to the logger - dataLogger.setLoggerPins(wakePin, sdCardSSPin, sensorPowerPin, buttonPin, greenLED); + dataLogger.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); dataLogger.setSamplingFeatureUUID(samplingFeature); // Begin the logger diff --git a/examples/baro_rho_correction/baro_rho_correction.ino b/examples/baro_rho_correction/baro_rho_correction.ino index 4a6180aa9..f385d46d2 100644 --- a/examples/baro_rho_correction/baro_rho_correction.ino +++ b/examples/baro_rho_correction/baro_rho_correction.ino @@ -443,7 +443,7 @@ void setup() // Attach the modem and information pins to the logger dataLogger.attachModem(modem); - dataLogger.setLoggerPins(wakePin, sdCardSSPin, sensorPowerPin, buttonPin, greenLED); + dataLogger.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); // Begin the logger dataLogger.begin(); diff --git a/examples/data_saving/data_saving.ino b/examples/data_saving/data_saving.ino index c82b71e15..c43a62ace 100644 --- a/examples/data_saving/data_saving.ino +++ b/examples/data_saving/data_saving.ino @@ -550,7 +550,7 @@ void setup() // attaching it to both allows either logger to control NIST synchronization loggerAllVars.attachModem(modem); loggerToGo.attachModem(modem); - loggerAllVars.setLoggerPins(wakePin, sdCardSSPin, sensorPowerPin, buttonPin, greenLED); + loggerAllVars.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); // Set up the connection information with EnviroDIY for both loggers // Doing this for both loggers ensures that the header of the csv will have the tokens in it diff --git a/examples/double_logger/double_logger.ino b/examples/double_logger/double_logger.ino index 26607124d..59b0926c1 100644 --- a/examples/double_logger/double_logger.ino +++ b/examples/double_logger/double_logger.ino @@ -281,8 +281,8 @@ void setup() array5min.begin(variableCount5min, variableList_at5min); logger1min.begin(LoggerID, 1, &array1min); logger5min.begin(LoggerID, 5, &array5min); - logger1min.setLoggerPins(wakePin, sdCardSSPin, sensorPowerPin, buttonPin, greenLED); - logger5min.setLoggerPins(wakePin, sdCardSSPin, sensorPowerPin, buttonPin, greenLED); + logger1min.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); + logger5min.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); // Turn on the modem diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index 4e2fd68df..7e0a54454 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -766,7 +766,7 @@ void setup() // Attach the modem and information pins to the logger dataLogger.attachModem(modem); - dataLogger.setLoggerPins(wakePin, sdCardSSPin, sensorPowerPin, buttonPin, greenLED); + dataLogger.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); // Begin the logger dataLogger.begin(); diff --git a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino index f36b81862..6b585e4ce 100644 --- a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino +++ b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino @@ -459,7 +459,7 @@ void setup() // Attach the modem and information pins to the logger dataLogger.attachModem(modem); - dataLogger.setLoggerPins(wakePin, sdCardSSPin, sensorPowerPin, buttonPin, greenLED); + dataLogger.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); // Begin the variable array[s], logger[s], and publisher[s] varArray.begin(variableCount, variableList); diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index c91f8277d..68e11a557 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1781,7 +1781,7 @@ void setup() // Attach the modem and information pins to the logger dataLogger.attachModem(modem); - dataLogger.setLoggerPins(wakePin, sdCardSSPin, sensorPowerPin, buttonPin, greenLED); + dataLogger.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); // Begin the logger dataLogger.begin(); diff --git a/examples/simple_logging/simple_logging.ino b/examples/simple_logging/simple_logging.ino index cb8444698..81b8560f7 100644 --- a/examples/simple_logging/simple_logging.ino +++ b/examples/simple_logging/simple_logging.ino @@ -165,7 +165,7 @@ void setup() Logger::setTZOffset(timeZone); // Set information pins - dataLogger.setLoggerPins(wakePin, sdCardSSPin, sensorPowerPin, buttonPin, greenLED); + dataLogger.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); // Begin the variable array[s], logger[s], and publisher[s] varArray.begin(variableCount, variableList); diff --git a/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino b/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino index 63ae52d8e..f8d93a16d 100644 --- a/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino +++ b/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino @@ -202,7 +202,7 @@ void setup() Logger::setTZOffset(timeZone); // Set information pins - dataLogger.setLoggerPins(wakePin, sdCardSSPin, sensorPowerPin, buttonPin, greenLED); + dataLogger.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); // Begin the variable array[s], logger[s], and publisher[s] varArray.begin(variableCount, variableList); From 51c419f3c37f8611a57999102547f74cd1302f9c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 3 May 2019 15:54:19 -0400 Subject: [PATCH 02/88] Extra modem debugging --- src/LoggerModem.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index 2f1f766c8..f1eed47c5 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -359,6 +359,9 @@ bool loggerModem::addSingleMeasurementResult(void) // AT commands bool loggerModem::isStable(bool debug) { + #if defined MS_LOGGERMODEM_DEBUG_DEEP + debug = True; + #endif // If the modem never "woke", then it will never respond and thus it's // essentially already "stable." if (!bitRead(_sensorStatus, 4)) @@ -437,6 +440,9 @@ bool loggerModem::isStable(bool debug) // push data. bool loggerModem::isMeasurementComplete(bool debug) { + #if defined MS_LOGGERMODEM_DEBUG_DEEP + debug = True; + #endif // If a measurement failed to start, the sensor will never return a result, // so the measurement time is essentially already passed // For a cellular modem nothing happens to "start" a measurement so bit 6 @@ -486,6 +492,8 @@ bool loggerModem::isMeasurementComplete(bool debug) else elapsed_in_wait = now - _millisMeasurementRequested; // If we're connected AND receiving valid signal strength, measurement is complete + // In theory these happen at the same time, but in reality one or the other + // may happen first. bool isConnected = _tinyModem->isNetworkConnected(); int signalResponse = _tinyModem->getSignalQuality(); if (isConnected && signalResponse != 0 && signalResponse != 99) From 4b23d16854cfe5d67493671c6ff9b1bb90542be2 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 3 May 2019 16:03:50 -0400 Subject: [PATCH 03/88] wrong case --- src/LoggerModem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index f1eed47c5..cedf8580f 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -360,7 +360,7 @@ bool loggerModem::addSingleMeasurementResult(void) bool loggerModem::isStable(bool debug) { #if defined MS_LOGGERMODEM_DEBUG_DEEP - debug = True; + debug = true; #endif // If the modem never "woke", then it will never respond and thus it's // essentially already "stable." @@ -441,7 +441,7 @@ bool loggerModem::isStable(bool debug) bool loggerModem::isMeasurementComplete(bool debug) { #if defined MS_LOGGERMODEM_DEBUG_DEEP - debug = True; + debug = true; #endif // If a measurement failed to start, the sensor will never return a result, // so the measurement time is essentially already passed From b1f39123e488b512a2290d1ac699eed8bc0fd17f Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 7 May 2019 13:06:08 -0400 Subject: [PATCH 04/88] Fixing compile warning --- src/LoggerModem.cpp | 6 +++--- src/LoggerModem.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index cedf8580f..72f7aec03 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -546,7 +546,7 @@ bool loggerModem::connectInternet(uint32_t waitTime_ms) } // Check that the modem is responding to AT commands. If not, give up. - #if defined DEBUGGING_SERIAL_OUTPUT + #if defined MS_LOGGERMODEM_DEBUG uint32_t start = millis(); #endif MS_DBG(F("\nWaiting for"), getSensorName(), F("to respond to AT commands...")); @@ -601,7 +601,7 @@ bool loggerModem::connectInternet(uint32_t waitTime_ms) void loggerModem::disconnectInternet(void) { - #if defined DEBUGGING_SERIAL_OUTPUT + #if defined MS_LOGGERMODEM_DEBUG uint32_t start = millis(); #endif if (_tinyModem->hasGPRS() && _modemName.indexOf(F("XBee")) < 0) // XBee doesn't like to disconnect @@ -1058,7 +1058,7 @@ void loggerModem::setModemTiming(void) } if (_modemName.indexOf(F("Sequans VZM20Q")) >= 0) { - MS_DBG(F("Resetting warm-up and disconnect timing for a Quectel MC60")); + MS_DBG(F("Resetting warm-up and disconnect timing for a Sequans VZM20Q")); _warmUpTime_ms = 0; // Module automatically boots when power is applied _statusTime_ms = 50; // ?? Undocumented _stabilizationTime_ms = 5000; // ?? Time to UART availability not documented diff --git a/src/LoggerModem.h b/src/LoggerModem.h index 1516f06a4..67c08116d 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -18,6 +18,7 @@ #ifdef MS_LOGGERMODEM_DEBUG #define MS_DEBUGGING_STD +#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif // Included Dependencies From bb47eb1ada188c656148f59954d9c176a1b44e95 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 7 May 2019 13:09:00 -0400 Subject: [PATCH 05/88] unpeg TinyGSM (temporarily?) --- library.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library.json b/library.json index 97ade42f1..36c33ecb2 100644 --- a/library.json +++ b/library.json @@ -295,7 +295,8 @@ }, { "name": "TinyGSM", - "version": "https://github.com/EnviroDIY/TinyGSM.git#84bfb40504f83aa49fd8eb4c3c855e4c00449896", + "version": "https://github.com/EnviroDIY/TinyGSM.git", + "version_commit": "84bfb40504f83aa49fd8eb4c3c855e4c00449896" "version_note": "=0.4.5", "note": "A small Arduino library for GPRS modules.", "authors": [ From fde6488173ac31f89e5aeb7da5026fe55bc94f85 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 7 May 2019 13:11:25 -0400 Subject: [PATCH 06/88] Fix broken json --- library.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library.json b/library.json index 36c33ecb2..73840c8b6 100644 --- a/library.json +++ b/library.json @@ -296,8 +296,8 @@ { "name": "TinyGSM", "version": "https://github.com/EnviroDIY/TinyGSM.git", - "version_commit": "84bfb40504f83aa49fd8eb4c3c855e4c00449896" - "version_note": "=0.4.5", + "version_commit": "84bfb40504f83aa49fd8eb4c3c855e4c00449896", + "version_note": "=0.6.1", "note": "A small Arduino library for GPRS modules.", "authors": [ "Volodymyr Shymanskyy", From 94f41705b383c0f8f06454f40e13284b83f8e28c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 7 May 2019 15:55:13 -0400 Subject: [PATCH 07/88] Removed extraneous define --- src/LoggerModem.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/LoggerModem.h b/src/LoggerModem.h index 67c08116d..1516f06a4 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -18,7 +18,6 @@ #ifdef MS_LOGGERMODEM_DEBUG #define MS_DEBUGGING_STD -#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif // Included Dependencies From f58a2b2057c3f79ef1be55de5b977eee30f8c90b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 8 May 2019 13:09:02 -0400 Subject: [PATCH 08/88] Tiny tweek of power pin array --- src/VariableArray.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 898760595..05d56b145 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -536,12 +536,17 @@ bool VariableArray::completeUpdate(void) { for (uint8_t j = i + 1; j < _variableCount; j++) { - if (powerPins[i] == powerPins[j]) + if (lastSensorVariable[i]) { lastPinVariable[i] = 0; - // MS_DBG(i, F("isn't the last variable on pin, matches"), j); - i++; + // MS_DBG(i, F("isn't the last variable on power pin because not last on sensor.")); } + else if (powerPins[i] == powerPins[j]) + { + lastPinVariable[i] = 0; + // MS_DBG(i, F("isn't the last variable on power pin, matches"), j); + } + i++; } } for (uint8_t i = 0; i < _variableCount; i++) @@ -572,7 +577,8 @@ bool VariableArray::completeUpdate(void) String nameLocation[_variableCount]; for (uint8_t i = 0; i < _variableCount; i++) { - nameLocation[i] = arrayOfVars[i]->getParentSensorNameAndLocation(); + // nameLocation[i] = arrayOfVars[i]->getParentSensorNameAndLocation(); + nameLocation[i] = arrayOfVars[i]->getParentSensorName(); } MS_DEEP_DBG(F("----------------------------------")); MS_DEEP_DBG(F("arrayPositions:\t\t\t")); From c695e41786543b116751c47f5e1dd5ecfd88666a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 8 May 2019 14:11:18 -0400 Subject: [PATCH 09/88] Missing not --- src/VariableArray.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 05d56b145..0f2059e12 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -536,7 +536,7 @@ bool VariableArray::completeUpdate(void) { for (uint8_t j = i + 1; j < _variableCount; j++) { - if (lastSensorVariable[i]) + if (!lastSensorVariable[i]) { lastPinVariable[i] = 0; // MS_DBG(i, F("isn't the last variable on power pin because not last on sensor.")); From 7a5d4c817296e8a114096cbfc6fdcf5ef89f9545 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 13 May 2019 16:16:08 -0400 Subject: [PATCH 10/88] Starting to separate out modems --- src/modems/AdafruitFona2G.h | 106 ++++++++ src/modems/BotleticsSIM7000.h | 0 src/modems/DFRobotWifiBeeESP.h | 223 ++++++++++++++++ src/modems/DigiXBee.cpp | 310 +++++++++++++++++++++++ src/modems/DigiXBee.h | 59 +++++ src/modems/DigiXBeeCellularBypass.h | 175 +++++++++++++ src/modems/DigiXBeeCellularTransparent.h | 164 ++++++++++++ src/modems/DigiXBeeWifi.h | 130 ++++++++++ src/modems/DraginoBG96.h | 106 ++++++++ src/modems/IteadWee.h | 223 ++++++++++++++++ src/modems/NimbelinkLTEMQuectel.h | 110 ++++++++ src/modems/NimbelinkLTEMSequans.h | 111 ++++++++ src/modems/Sodaq2GBeeR6.h | 105 ++++++++ src/modems/SodaqUBeeR410M.h | 103 ++++++++ src/modems/SodaqUBeeU201.h | 121 +++++++++ 15 files changed, 2046 insertions(+) create mode 100644 src/modems/AdafruitFona2G.h create mode 100644 src/modems/BotleticsSIM7000.h create mode 100644 src/modems/DFRobotWifiBeeESP.h create mode 100644 src/modems/DigiXBee.cpp create mode 100644 src/modems/DigiXBee.h create mode 100644 src/modems/DigiXBeeCellularBypass.h create mode 100644 src/modems/DigiXBeeCellularTransparent.h create mode 100644 src/modems/DigiXBeeWifi.h create mode 100644 src/modems/DraginoBG96.h create mode 100644 src/modems/IteadWee.h create mode 100644 src/modems/NimbelinkLTEMQuectel.h create mode 100644 src/modems/NimbelinkLTEMSequans.h create mode 100644 src/modems/Sodaq2GBeeR6.h create mode 100644 src/modems/SodaqUBeeR410M.h create mode 100644 src/modems/SodaqUBeeU201.h diff --git a/src/modems/AdafruitFona2G.h b/src/modems/AdafruitFona2G.h new file mode 100644 index 000000000..eb4069e5c --- /dev/null +++ b/src/modems/AdafruitFona2G.h @@ -0,0 +1,106 @@ +/* + *AdafruitFona2G.h + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module +*/ + +// Header Guards +#ifndef ModularSensorsSpecificModem_h +#define ModularSensorsSpecificModem_h + +// Debugging Statement +// #define MS_ADAFRUITFONA2G_DEBUG + +#ifdef MS_ADAFRUITFONA2G_DEBUG +#define MS_DEBUGGING_STD +#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT +#endif + +#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates + +// Included Dependencies +#include "ModSensorDebugger.h" +#include "LoggerModem.h" + +// ========================================================================== +// Wifi/Cellular Modem Main Chip Selection +// ========================================================================== + +// Select your modem chip - this determines the exact commands sent to it +#define TINY_GSM_MODEM_SIM800 // Select for a SIMCOM SIM800, SIM900, or variant thereof + + +// ========================================================================== +// Modem Pins +// ========================================================================== + +// Declare the existance of modem pin Variables +// Use the "extern" keyword to denote that these will actually be defined in +// the main program rather than in this file. + +extern const int8_t modemVccPin; +extern const int8_t modemSleepRqPin; +extern const int8_t modemStatusPin; +extern const int8_t modemResetPin; +extern const int8_t modemLEDPin; + + +// ========================================================================== +// TinyGSM Client +// ========================================================================== + +// #define TINY_GSM_DEBUG Serial // If you want debugging on the main debug port + +#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates + +// Include TinyGSM for the modem +// This include must be included below the define of the modem name! +#include + +// Create a reference to the serial port for the modem +// Extra hardware and software serial ports are created in the "Settings for Additional Serial Ports" section +HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible +// AltSoftSerial &modemSerial = altSoftSerial; // For software serial if needed +// NeoSWSerial &modemSerial = neoSSerial1; // For software serial if needed + +// Create a new TinyGSM modem to run on that serial port and return a pointer to it +#if defined TINY_GSM_MODEM_XBEE +TinyGsm *tinyModem = new TinyGsm(modemSerial, modemResetPin); +#else +TinyGsm *tinyModem = new TinyGsm(modemSerial); +#endif + +// Create a new TCP client on that modem and return a pointer to it +TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); + + +// ========================================================================== +// Specific Modem On-Off Methods +// ========================================================================== + +bool modemWakeFxn(void) +{ + digitalWrite(modemSleepRqPin, LOW); + delay(1100); // >1s for SIM800, SIM900, Quectel M95, Quectel MC60 + digitalWrite(modemSleepRqPin, HIGH); + return true; +} + + +bool modemSleepFxn(void) +{ + digitalWrite(modemSleepRqPin, LOW); + delay(1100); // 1sec > t > 33sec for SIM800 and clones + digitalWrite(modemSleepRqPin, HIGH); + return true; +} + + +void extraModemSetup(void){} + + + +#endif diff --git a/src/modems/BotleticsSIM7000.h b/src/modems/BotleticsSIM7000.h new file mode 100644 index 000000000..e69de29bb diff --git a/src/modems/DFRobotWifiBeeESP.h b/src/modems/DFRobotWifiBeeESP.h new file mode 100644 index 000000000..f7ec4dd3b --- /dev/null +++ b/src/modems/DFRobotWifiBeeESP.h @@ -0,0 +1,223 @@ +/* + *DFRobotWifiBeeESP.h + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module +*/ + +// Header Guards +#ifndef ModularSensorsSpecificModem_h +#define ModularSensorsSpecificModem_h + +// Debugging Statement +// #define MS_DFROBOTWIFIBEEESP_DEBUG + +#ifdef MS_DFROBOTWIFIBEEESP_DEBUG +#define MS_DEBUGGING_STD +#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT +#endif + +#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates + +// Included Dependencies +#include "ModSensorDebugger.h" +#include "LoggerModem.h" + +// ========================================================================== +// Wifi/Cellular Modem Main Chip Selection +// ========================================================================== + +// Select your modem chip - this determines the exact commands sent to it +#define TINY_GSM_MODEM_ESP8266 // Select for an ESP8266 using the DEFAULT AT COMMAND FIRMWARE + + +// ========================================================================== +// Modem Pins +// ========================================================================== + +// Declare the existance of modem pin Variables +// Use the "extern" keyword to denote that these will actually be defined in +// the main program rather than in this file. + +extern const int8_t modemVccPin; +extern const int8_t modemSleepRqPin; +extern const int8_t modemStatusPin; +extern const int8_t modemResetPin; +extern const int8_t modemLEDPin; +extern Stream &modemSerial; + +extern const int8_t espSleepRqPin; +extern const int8_t espStatusPin; + + +// ========================================================================== +// TinyGSM Client +// ========================================================================== + +// Include TinyGSM for the modem +// This include must be included below the define of the modem name! +#include + +// Create a new TinyGSM modem to run on that serial port and return a pointer to it +TinyGsm *tinyModem = new TinyGsm(modemSerial); + +// Create a new TCP client on that modem and return a pointer to it +TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); + + +// ========================================================================== +// Specific Modem On-Off Methods +// ========================================================================== + +const bool modemStatusLevel = HIGH; // The level of the status pin when the module is active (HIGH or LOW) +// const long modemBaud = 115200; // Communication speed of the modem, 115200 is default for ESP8266 + +// A helper function to wait for the esp to boot and immediately change some settings +// We'll use this in the wake function +bool ESPwaitForBoot(void) +{ + // Wait for boot - finished when characters start coming + // NOTE: After every "hard" reset (either power off or via RST-B), the ESP + // sends out a boot log from the ROM on UART1 at 74880 baud. We're not + // going to worry about the odd baud rate since we're simply throwing the + // characters away. + delay(200); // It will take at least this long + uint32_t start = millis(); + bool success = false; + while (!modemSerial.available() && millis() - start < 1000) {} + if (modemSerial.available()) + { + success = true; + // Read the boot log to empty it from the serial buffer + while (modemSerial.available()) + { + modemSerial.read(); + delay(2); + } + // Have to make sure echo is off or all AT commands will be confused + tinyModem->sendAT(F("E0")); + success &= tinyModem->waitResponse() == 1; + // re-run init to set mux and station mode + success &= tinyModem->init(); + } + return success; +} + +// Create the wake and sleep methods for the modem +// These can be functions of any type and must return a boolean +bool modemSleepFxn(void) +{ + // Use this if you have GPIO16 connected to the reset pin to wake from deep sleep + // but no other MCU pin connected to the reset pin. + // NOTE: This will NOT work nicely with "testingMode" + /*if (loggingInterval > 1) + { + uint32_t sleepSeconds = (((uint32_t)loggingInterval) * 60 * 1000) - 75000L; + String sleepCommand = String(sleepSeconds); + tinyModem->sendAT(F("+GSLP="), sleepCommand); + // Power down for 1 minute less than logging interval + // Better: Calculate length of loop and power down for logging interval - loop time + return tinyModem->waitResponse() == 1; + }*/ + // Use this if you have an MCU pin connected to the ESP's reset pin to wake from deep sleep + if (modemResetPin >= 0) + { + digitalWrite(modemLEDPin, LOW); + return tinyModem->poweroff(); + } + // Use this if you don't have access to the ESP8266's reset pin for deep sleep but you + // do have access to another GPIO pin for light sleep. This also sets up another + // pin to view the sleep status. + else if (modemSleepRqPin >= 0 && modemStatusPin >= 0) + { + tinyModem->sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0,"), + String(espStatusPin), ',', modemStatusLevel); + bool success = tinyModem->waitResponse() == 1; + tinyModem->sendAT(F("+SLEEP=1")); + success &= tinyModem->waitResponse() == 1; + digitalWrite(modemLEDPin, LOW); + return success; + } + // Light sleep without the status pin + else if (modemSleepRqPin >= 0 && modemStatusPin < 0) + { + tinyModem->sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0")); + bool success = tinyModem->waitResponse() == 1; + tinyModem->sendAT(F("+SLEEP=1")); + success &= tinyModem->waitResponse() == 1; + digitalWrite(modemLEDPin, LOW); + return success; + } + else // DON'T go to sleep if we can't wake up! + { + return true; + } +} +bool modemWakeFxn(void) +{ + bool success = true; + if (modemVccPin >= 0) // Turns on when power is applied + { + digitalWrite(modemLEDPin, HIGH); // Because the ESP8266 doesn't have any lights + success &= ESPwaitForBoot(); + if (!success) + { + digitalWrite(modemLEDPin, LOW); // Turn off light if the boot failed + } + return success; + } + else if (modemResetPin >= 0) + { + digitalWrite(modemLEDPin, HIGH); + digitalWrite(modemResetPin, LOW); + delay(1); + digitalWrite(modemResetPin, HIGH); + success &= ESPwaitForBoot(); + if (!success) + { + digitalWrite(modemLEDPin, LOW); // Turn off light if the boot failed + } + return success; + } + else if (modemSleepRqPin >= 0) + { + digitalWrite(modemSleepRqPin, LOW); + delay(1); + digitalWrite(modemSleepRqPin, HIGH); + digitalWrite(modemLEDPin, HIGH); + // Don't have to wait for a boot if using light sleep + return true; + } + else + { + return true; + } +} +// Set up the light-sleep status pin, if applicable +void extraModemSetup(void) +{ + // Slow down the baud rate for slow processors - and save the change to + // the ESP's non-volatile memory so we don't have to do it every time + // #if F_CPU == 8000000L + // if (modemBaud > 57600) + // { + // modemSerial.begin(modemBaud); + // tinyModem->sendAT(F("+UART_DEF=9600,8,1,0,0")); + // tinyModem->waitResponse(); + // modemSerial.end(); + // modemSerial.begin(9600); + // } + // #endif + if (modemVccPin < 0 && modemResetPin < 0 && modemSleepRqPin >= 0 && modemStatusPin >= 0) + { + tinyModem->sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0,"), + String(espStatusPin), ',', modemStatusLevel); + tinyModem->waitResponse(); + } +} + + + +#endif diff --git a/src/modems/DigiXBee.cpp b/src/modems/DigiXBee.cpp new file mode 100644 index 000000000..d0fd5f095 --- /dev/null +++ b/src/modems/DigiXBee.cpp @@ -0,0 +1,310 @@ +/* + *DigiXBee.cpp + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module +*/ + +// Included Dependencies +#include "DigiXBee.h" + + +// Constructor +DigiXBee::DigiXBee(int8_t powerPin, int8_t statusPin, bool useCTSStatus, + int8_t modemResetPin, int8_t modemSleepRqPin, + TinyGsmModem *inModem, Client *inClient, const char *ssid, const char *pwd) + : loggerModem(powerPin, statusPin, !useCTSStatus, + modemResetPin, modemSleepRqPin, + XBEE_STATUS_TIME_MS, XBEE_DISCONNECT_TIME_MS, + XBEE_WARM_UP_TIME_MS, XBEE_ATRESPONSE_TIME_MS, + inModem, inClient, ssid, pwd) +{} + + +bool DigiXBee::setup(void) +{ + bool success = Sensor::setup(); // this will set pin modes and the setup status bit + + // Initialize the modem + MS_DBG(F("Setting up the XBee ...")); + + // Bail if there's no power + if (!checkPowerOn()) + { + MS_DBG(F("XBee doesn't have power and cannot be set-up!")); + return false; + } + + // Check if the modem was awake, wake it if not + // NOTE: We ar NOT powering up the modem! Set up will NOT be successful + // unless the modem is already powered external to this function. + bool wasAwake = ( (_dataPin >= 0 && digitalRead(_dataPin) == _statusLevel) + || bitRead(_sensorStatus, 4) ); + if (!wasAwake) + { + waitForWarmUp(); + MS_DBG(F("Turning on the XBee ...")); + success &= wake(); + } + else MS_DBG(F("XBee was already awake.")); + + if (success) + { + // The begin() generally starts with a 5 second testAT(), that should + // be enough time to allow any modem to be ready to respond + MS_DBG(F("Running XBee's begin function ...")); + success &= _tinyModem->begin(); + _modemName = _tinyModem->getModemName(); + success &= extraXBeeSetup(); + if (success) MS_DBG(F("... Complete! It's a"), getSensorName()); + else MS_DBG(F("... Failed! It's a"), getSensorName()); + } + else MS_DBG(F("... "), getSensorName(), F("did not wake up and cannot be set up!")); + + MS_DBG(_modemName, F("warms up in"), _warmUpTime_ms, F("ms, indicates status in"), + _statusTime_ms, F("ms, is responsive to AT commands in less than"), + _stabilizationTime_ms, F("ms, and takes up to"), _disconnetTime_ms, + F("ms to close connections and shut down.")); + + // XBee saves all configurations to flash, so we can set them here + _tinyModem->networkConnect(_ssid, _pwd); + + // Print out some warnings if things seem to be improperly formatted + if (_tinyModem->hasWifi() && _ssid == NULL) + MS_DBG(F("WARNING: Wifi modem with no SSID given!")); + if (_tinyModem->hasGPRS() && _apn == NULL) + MS_DBG(F("WARNING: Cellular modem with no APN given!")); + + // Set the status bit marking that the modem has been set up (bit 0) + // Only set the bit if setup was successful! + if (success) _sensorStatus |= 0b00000001; + // Otherwise, set the status error bit (bit 7) + else _sensorStatus |= 0b10000000; + + // Put the modem to sleep after finishing setup + // Only go to sleep if it had been asleep and is now awake + bool isAwake = ( (_dataPin >= 0 && digitalRead(_dataPin) == _statusLevel) + || bitRead(_sensorStatus, 4) ); + if (!wasAwake && isAwake) + { + // Run the sleep function + MS_DBG(F("Running given modem sleep function ...")); + success &= _modemSleepFxn(); + } + else MS_DBG(F("Leaving modem on after setup ...")); + // Do NOT power down at the end, because this fxn cannot have powered the + // modem up. + + return success; +} + + +bool DigiXBee::wake(void) +{ + // Sensor::wake() checks if the power pin is on, setup has been successful, + // and sets the wake timestamp and status bits. If it returns false, + // there's no reason to go on. + if (!Sensor::wake()) return false; + // NOTE: This is the ONLY place _millisSensorActivated is set! + // NOTE: This is the ONLY place bit 4 is set! + + bool success = true; + + // Check the status pin and wake bits before running wake function + // Don't want to accidently pulse an already on modem to off + if ( bitRead(_sensorStatus, 4)) + { + MS_DBG(getSensorName(), F("has already been woken up! Will not run wake function.")); + } + // NOTE: It's possible that the status pin is on, but the modem is actually + // mid-shutdown. In that case, we'll mistakenly skip re-waking it. + else if (_dataPin >= 0 && digitalRead(_dataPin) == _statusLevel) + { + MS_DBG(getSensorName(), F("was already on! (status pin level = "), + _statusLevel, F(") Will not run wake function.")); + } + else + { + // Run the input wake function + MS_DBG(F("Running wake function for"), getSensorName()); + success &= XBeeWake(); + } + + // Re-check the status pin + // Only works if the status pin comes on immediately + if (_dataPin > 0 && _statusTime_ms == 0 && digitalRead(_dataPin) != _statusLevel) + { + MS_DBG(F("Status pin level on"), getSensorName(), F("is"), + digitalRead(_dataPin), F("indicating it is off!")); + success = false; + } + + if (success) + { + if (_modemLEDPin >= 0) + { + digitalWrite(_modemLEDPin, HIGH); + } + MS_DBG(getSensorName(), F("should be awake.")); + } + else + { + MS_DBG(getSensorName(), F("failed to wake!")); + // Make sure the activation time is zero and the wake success bit (bit 4) is unset + _millisSensorActivated = 0; + _sensorStatus &= 0b11101111; + } + + return success; +} + + +bool DigiXBee::modemSleepPowerDown(void) +{ + bool success = true; + uint32_t start = millis(); + MS_DBG(F("Turning"), getSensorName(), F("off.")); + + // If there's a status pin available, check before running the sleep function + // NOTE: It's possible that the modem could still be in the process of turning + // on and thus status pin isn't valid yet. In that case, we wouldn't yet + // know it's coming on and so we'd mistakenly assume it's already off and + // not turn it back off. + if (_dataPin >= 0 && digitalRead(_dataPin) != _statusLevel) + MS_DBG(getSensorName(), F("appears to have already been off. Will not run sleep function.")); + // If there's no status pin, check against the status bits + else if (_dataPin < 0 && !bitRead(_sensorStatus, 4)) + MS_DBG(getSensorName(), F("was never sucessfully turned on. Will not run sleep function.")); + else + { + // Run the sleep function + MS_DBG(F("Running given sleep function for"), getSensorName()); + success &= XBeeSleep(); + + if (_modemLEDPin >= 0) + { + digitalWrite(_modemLEDPin, LOW); + } + } + + // Unset the activation time + _millisSensorActivated = 0; + // Unset the measurement request time + _millisMeasurementRequested = 0; + // Unset the status bits for sensor activation (bits 3 & 4) and measurement + // request (bits 5 & 6) + _sensorStatus &= 0b10000111; + + // Now power down + if (_powerPin >= 0) + { + // If there's a status pin available, wait until modem shows it's ready to be powered off + // This allows the modem to shut down gracefully. + if (_dataPin >= 0) + { + MS_DBG(F("Waiting up to"), _disconnetTime_ms, F("milliseconds for graceful shutdown...")); + while (millis() - start < _disconnetTime_ms && digitalRead(_dataPin) == _statusLevel){} + if (digitalRead(_dataPin) == _statusLevel) + MS_DBG(F("... "), getSensorName(), F("did not successfully shut down!")); + else MS_DBG(F("... shutdown complete after"), millis() - start, F("ms.")); + } + else if (_disconnetTime_ms > 0) + { + MS_DBG(F("Waiting"), _disconnetTime_ms, F("ms for graceful shutdown.")); + while (millis() - start < _disconnetTime_ms){} + } + + MS_DBG(F("Turning off power to"), getSensorName(), F("with pin"), _powerPin); + digitalWrite(_powerPin, LOW); + // Unset the power-on time + _millisPowerOn = 0; + // Unset the status bits for sensor power (bits 1 & 2), + // activation (bits 3 & 4), and measurement request (bits 5 & 6) + _sensorStatus &= 0b10000001; + } + else + { + // If we're not going to power the modem down, there's no reason to hold + // up the main processor while waiting for the modem to shut down. + // It can just do its thing unwatched while the main processor sleeps. + MS_DBG(F("Power to"), getSensorName(), F("is not controlled by this library.")); + // Unset the power-on time and bits even if we didn't do anything. + // This prevents the wake from happening on modems with no power pin + // unless modemPowerUp() is called. + _millisPowerOn = 0; + // Unset the status bits for sensor power (bits 1 & 2), + // activation (bits 3 & 4), and measurement request (bits 5 & 6) + _sensorStatus &= 0b10000001; + } + + return success; +} + + +// Create the wake and sleep methods for the modem +// These can be functions of any type and must return a boolean +// After enabling pin sleep, the sleep request pin is held LOW to keep the XBee on +// Enable pin sleep in the setup function or using XCTU prior to connecting the XBee +bool DigiXBee::XBeeWake(void) +{ + if (_modemSleepRqPin >= 0) // Don't go to sleep if there's not a wake pin! + { + digitalWrite(_modemSleepRqPin, HIGH); + return true; + } + else + { + return true; + } +} + + +bool DigiXBee::XBeeSleep(void) +{ + if (_powerPin >= 0) // Turns on when power is applied + return true; + else if (_modemSleepRqPin >= 0) + { + digitalWrite(_modemSleepRqPin, LOW); + digitalWrite(_modemLEDPin, HIGH); // Because the XBee doesn't have any lights + return true; + } + else + { + return true; + } +} + + +bool DigiXBee::extraXBeeSetup(void) +{ + _tinyModem->init(); // initialize + if (_tinyModem->commandMode()) + { + // Set DIO8 to be used for sleep requests + // NOTE: Only pin 9/DIO8/DTR can be used for this function + _tinyModem->sendAT(F("D8"),1); + _tinyModem->waitResponse(); + // Turn on status indication pin - it will be HIGH when the XBee is awake + // NOTE: Only pin 13/ON/SLEEPnot/DIO9 can be used for this function + _tinyModem->sendAT(F("D9"),1); + _tinyModem->waitResponse(); + // Turn on CTS pin - it will be LOW when the XBee is ready to receive commands + // This can be used as proxy for status indication if the true status pin is not accessible + // NOTE: Only pin 12/DIO7/CTS can be used for this function + _tinyModem->sendAT(F("D7"),1); + _tinyModem->waitResponse(); + // Put the XBee in pin sleep mode + _tinyModem->sendAT(F("SM"),1); + _tinyModem->waitResponse(); + // Disassociate from network for lowest power deep sleep + _tinyModem->sendAT(F("SO"),200); + _tinyModem->waitResponse(); + // Write changes to flash and apply them + _tinyModem->writeChanges(); + // Exit command mode + _tinyModem->exitCommand(); + } +} diff --git a/src/modems/DigiXBee.h b/src/modems/DigiXBee.h new file mode 100644 index 000000000..44a18bb68 --- /dev/null +++ b/src/modems/DigiXBee.h @@ -0,0 +1,59 @@ +/* + *DigiXBee.h + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module +*/ + +// Header Guards +#ifndef DigiXBee_h +#define DigiXBee_h + +// Debugging Statement +// #define MS_DIGIXBEEWIFI_DEBUG + +#ifdef MS_DIGIXBEEWIFI_DEBUG +#define MS_DEBUGGING_STD +#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT +#endif + +#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates + +// Included Dependencies +#include "ModSensorDebugger.h" +#include "LoggerModem.h" +#include "TinyGsmClient.h" + +#define TINY_GSM_XBEE_XBEE // Select for Digi brand WiFi or Cellular XBee's + +#define XBEE_STATUS_TIME_MS 15 +#define XBEE_DISCONNECT_TIME_MS 5000L + +#define XBEE_WARM_UP_TIME_MS 50 +#define XBEE_ATRESPONSE_TIME_MS 5000L + + +class DigiXBee : public loggerModem +{ + +public: + // Constructors + DigiXBee(int8_t powerPin, int8_t statusPin, bool useCTSStatus, + int8_t modemResetPin, int8_t modemSleepRqPin, + TinyGsmModem *inModem, Client *inClient, const char *ssid, const char *pwd); + + virtual bool setup(void) override; + virtual bool wake(void) override; + virtual bool modemSleepPowerDown(void); + +protected: + virtual bool XBeeWake(void); + virtual bool XBeeSleep(void); + virtual bool extraXBeeSetup(void) = 0; +}; + + + +#endif diff --git a/src/modems/DigiXBeeCellularBypass.h b/src/modems/DigiXBeeCellularBypass.h new file mode 100644 index 000000000..8ecc9971b --- /dev/null +++ b/src/modems/DigiXBeeCellularBypass.h @@ -0,0 +1,175 @@ +/* + *DigiXBeeCellular.h + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module +*/ + +// Header Guards +#ifndef ModularSensorsSpecificModem_h +#define ModularSensorsSpecificModem_h + +// Debugging Statement +// #define MS_DIGIXBEECELLULAR_DEBUG + +#ifdef MS_DIGIXBEECELLULAR_DEBUG +#define MS_DEBUGGING_STD +#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT +#endif + +#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates + +// Included Dependencies +#include "ModSensorDebugger.h" +#include "LoggerModem.h" + +// ========================================================================== +// Wifi/Cellular Modem Main Chip Selection +// ========================================================================== + +// Select your modem chip - this determines the exact commands sent to it +#define TINY_GSM_MODEM_UBLOX // Select for Digi brand WiFi or Cellular XBee's + + +// ========================================================================== +// Modem Pins +// ========================================================================== + +// Declare the existance of modem pin Variables +// Use the "extern" keyword to denote that these will actually be defined in +// the main program rather than in this file. + +extern const int8_t modemVccPin; +extern const int8_t modemSleepRqPin; +extern const int8_t modemStatusPin; +extern const int8_t modemResetPin; +extern const int8_t modemLEDPin; +extern Stream &modemSerial; + + +// ========================================================================== +// TinyGSM Client +// ========================================================================== + +#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates + +// Include TinyGSM for the modem +// This include must be included below the define of the modem name! +#include + +// Create a new TinyGSM modem to run on that serial port and return a pointer to it +TinyGsm *tinyModem = new TinyGsm(modemSerial); + +// Create a new TCP client on that modem and return a pointer to it +TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); + + +// ========================================================================== +// Specific Modem On-Off Methods +// ========================================================================== +// Describe the physical pin connection of your modem to your board +const bool modemStatusLevel = LOW; // The level of the status pin when the module is active (HIGH or LOW) + +// Create the wake and sleep methods for the modem +// These can be functions of any type and must return a boolean +// After enabling pin sleep, the sleep request pin is held LOW to keep the XBee on +// Enable pin sleep in the setup function or using XCTU prior to connecting the XBee +bool modemSleepFxn(void) +{ + if (modemSleepRqPin >= 0) // Don't go to sleep if there's not a wake pin! + { + digitalWrite(modemSleepRqPin, HIGH); + digitalWrite(modemLEDPin, LOW); + return true; + } + else + { + return true; + } +} + + +bool modemWakeFxn(void) +{ + if (modemVccPin >= 0) // Turns on when power is applied + return true; + else if (modemSleepRqPin >= 0) + { + digitalWrite(modemSleepRqPin, LOW); + digitalWrite(modemLEDPin, HIGH); // Because the XBee doesn't have any lights + return true; + } + else + { + return true; + } +} + + +void extraModemSetup(void) +{ + delay(1010); // Wait the required guard time before entering command mode + tinyModem->streamWrite(GF("+++")); // enter command mode + if (tinyModem->waitResponse(2000, F("OK\r")) == 1); + { + // Set DIO8 to be used for sleep requests + // NOTE: Only pin 9/DIO8/DTR can be used for this function + tinyModem->sendAT(F("D8"),1); + tinyModem->waitResponse(F("OK\r")); + // Turn on status indication pin - it will be HIGH when the XBee is awake + // NOTE: Only pin 13/ON/SLEEPnot/DIO9 can be used for this function + tinyModem->sendAT(F("D9"),1); + tinyModem->waitResponse(F("OK\r")); + // Turn on CTS pin - it will be LOW when the XBee is ready to receive commands + // This can be used as proxy for status indication if the true status pin is not accessible + // NOTE: Only pin 12/DIO7/CTS can be used for this function + tinyModem->sendAT(F("D7"),1); + tinyModem->waitResponse(F("OK\r")); + // Put the XBee in pin sleep mode + tinyModem->sendAT(F("SM"),1); + tinyModem->waitResponse(F("OK\r")); + // Disassociate from network for lowest power deep sleep + tinyModem->sendAT(F("SO"),0); + tinyModem->waitResponse(F("OK\r")); + // Disable remote manager, USB Direct, and LTE PSM + // NOTE: LTE-M's PSM (Power Save Mode) sounds good, but there's no + // easy way on the LTE-M Bee to wake the cell chip itself from PSM, + // so we'll use the Digi pin sleep instead. + tinyModem->sendAT(F("DO"),0); + tinyModem->waitResponse(F("OK\r")); + // Make sure USB direct won't be pin enabled on XBee3 units + tinyModem->sendAT(F("P0"),0); + tinyModem->waitResponse(F("OK\r")); + // Make sure pins 7&8 are not set for USB direct on XBee3 units + tinyModem->sendAT(F("P1"),0); + tinyModem->waitResponse(F("OK\r")); + // Cellular carrier profile - AT&T + // Hologram says they can use any network, but I've never succeeded with anything but AT&T + tinyModem->sendAT(F("CP"),2); + tinyModem->waitResponse(F("OK\r")); + // Cellular network technology - LTE-M Only + // LTE-M XBee connects much faster on AT&T/Hologram when set to LTE-M only (instead of LTE-M/NB IoT) + tinyModem->sendAT(F("N#"),2); + tinyModem->waitResponse(F("OK\r")); + // Turn on bypass mode + tinyModem->sendAT(F("AP5")); + tinyModem->waitResponse(F("OK\r")); + // Write changes to flash + tinyModem->sendAT(F("WR")); + tinyModem->waitResponse(F("OK\r")); + // Apply changes + tinyModem->sendAT(F("AC")); + tinyModem->waitResponse(F("OK\r")); + // Force reset to actually enter bypass mode - this effectively exits bypass mode + tinyModem->sendAT(F("FR")); + tinyModem->waitResponse(F("OK\r")); + // initialize + tinyModem->init(); + } +} + + + +#endif diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h new file mode 100644 index 000000000..92d85682a --- /dev/null +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -0,0 +1,164 @@ +/* + *DigiXBeeCellular.h + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module +*/ + +// Header Guards +#ifndef ModularSensorsSpecificModem_h +#define ModularSensorsSpecificModem_h + +// Debugging Statement +// #define MS_DIGIXBEECELLULAR_DEBUG + +#ifdef MS_DIGIXBEECELLULAR_DEBUG +#define MS_DEBUGGING_STD +#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT +#endif + +#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates + +// Included Dependencies +#include "ModSensorDebugger.h" +#include "LoggerModem.h" + +// ========================================================================== +// Wifi/Cellular Modem Main Chip Selection +// ========================================================================== + +// Select your modem chip - this determines the exact commands sent to it +#define TINY_GSM_MODEM_XBEE // Select for Digi brand WiFi or Cellular XBee's + + +// ========================================================================== +// Modem Pins +// ========================================================================== + +// Declare the existance of modem pin Variables +// Use the "extern" keyword to denote that these will actually be defined in +// the main program rather than in this file. + +extern const int8_t modemVccPin; +extern const int8_t modemSleepRqPin; +extern const int8_t modemStatusPin; +extern const int8_t modemResetPin; +extern const int8_t modemLEDPin; +extern Stream &modemSerial; + + +// ========================================================================== +// TinyGSM Client +// ========================================================================== + +#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates + +// Include TinyGSM for the modem +// This include must be included below the define of the modem name! +#include + +// Create a new TinyGSM modem to run on that serial port and return a pointer to it +TinyGsm *tinyModem = new TinyGsm(modemSerial, modemResetPin); + +// Create a new TCP client on that modem and return a pointer to it +TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); + + +// ========================================================================== +// Specific Modem On-Off Methods +// ========================================================================== +// Describe the physical pin connection of your modem to your board +const bool modemStatusLevel = LOW; // The level of the status pin when the module is active (HIGH or LOW) + +// Create the wake and sleep methods for the modem +// These can be functions of any type and must return a boolean +// After enabling pin sleep, the sleep request pin is held LOW to keep the XBee on +// Enable pin sleep in the setup function or using XCTU prior to connecting the XBee +bool modemSleepFxn(void) +{ + if (modemSleepRqPin >= 0) // Don't go to sleep if there's not a wake pin! + { + digitalWrite(modemSleepRqPin, HIGH); + digitalWrite(modemLEDPin, LOW); + return true; + } + else + { + return true; + } +} + + +bool modemWakeFxn(void) +{ + if (modemVccPin >= 0) // Turns on when power is applied + return true; + else if (modemSleepRqPin >= 0) + { + digitalWrite(modemSleepRqPin, LOW); + digitalWrite(modemLEDPin, HIGH); // Because the XBee doesn't have any lights + return true; + } + else + { + return true; + } +} + + +void extraModemSetup(void) +{ + tinyModem->init(); // initialize + if (tinyModem->commandMode()) + { + // Set DIO8 to be used for sleep requests + // NOTE: Only pin 9/DIO8/DTR can be used for this function + tinyModem->sendAT(F("D8"),1); + tinyModem->waitResponse(); + // Turn on status indication pin - it will be HIGH when the XBee is awake + // NOTE: Only pin 13/ON/SLEEPnot/DIO9 can be used for this function + tinyModem->sendAT(F("D9"),1); + tinyModem->waitResponse(); + // Turn on CTS pin - it will be LOW when the XBee is ready to receive commands + // This can be used as proxy for status indication if the true status pin is not accessible + // NOTE: Only pin 12/DIO7/CTS can be used for this function + tinyModem->sendAT(F("D7"),1); + tinyModem->waitResponse(); + // Put the XBee in pin sleep mode + tinyModem->sendAT(F("SM"),1); + tinyModem->waitResponse(); + // Disassociate from network for lowest power deep sleep + tinyModem->sendAT(F("SO"),0); + tinyModem->waitResponse(); + // Disable remote manager, USB Direct, and LTE PSM + // NOTE: LTE-M's PSM (Power Save Mode) sounds good, but there's no + // easy way on the LTE-M Bee to wake the cell chip itself from PSM, + // so we'll use the Digi pin sleep instead. + tinyModem->sendAT(F("DO"),0); + tinyModem->waitResponse(); + // Make sure USB direct won't be pin enabled on XBee3 units + tinyModem->sendAT(F("P0"),0); + tinyModem->waitResponse(); + // Make sure pins 7&8 are not set for USB direct on XBee3 units + tinyModem->sendAT(F("P1"),0); + tinyModem->waitResponse(); + // Cellular carrier profile - AT&T + // Hologram says they can use any network, but I've never succeeded with anything but AT&T + tinyModem->sendAT(F("CP"),2); + tinyModem->waitResponse(); + // Cellular network technology - LTE-M Only + // LTE-M XBee connects much faster on AT&T/Hologram when set to LTE-M only (instead of LTE-M/NB IoT) + tinyModem->sendAT(F("N#"),2); + tinyModem->waitResponse(); + // Write changes to flash and apply them + tinyModem->writeChanges(); + // Exit command mode + tinyModem->exitCommand(); + } +} + + + +#endif diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h new file mode 100644 index 000000000..201ee1943 --- /dev/null +++ b/src/modems/DigiXBeeWifi.h @@ -0,0 +1,130 @@ +/* + *DigiXBeeWifi.h + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module +*/ + +// Header Guards +#ifndef DigiXBeeWifi_h +#define DigiXBeeWifi_h + +// Debugging Statement +// #define MS_DIGIXBEEWIFI_DEBUG + +#ifdef MS_DIGIXBEEWIFI_DEBUG +#define MS_DEBUGGING_STD +#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT +#endif + +#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates + +// Included Dependencies +#include "ModSensorDebugger.h" +#include "LoggerModem.h" + +#define TINY_GSM_XBEE_XBEE // Select for Digi brand WiFi or Cellular XBee's + +#define XBEE_STATUS_TIME_MS 15 +#define XBEE_DISCONNECT_TIME_MS 5000L + +#define XBEE_WARM_UP_TIME_MS 50 +#define XBEE_ATRESPONSE_TIME_MS 5000L + + +class DigiXBeeWifi : public loggerModem +{ + +public: + // Constructors + DigiXBeeWifi(int8_t powerPin, int8_t statusPin, bool useCTSStatus, + int8_t modemResetPin, int8_t modemSleepRqPin, + TinyGsmModem *inModem, Client *inClient, const char *ssid, const char *pwd); + + virtual bool setup(void) override; + virtual bool wake(void) override; + virtual bool modemSleepPowerDown(void); +} + + +// ========================================================================== +// Specific Modem On-Off Methods +// ========================================================================== + +if (modemCTSPin >= 0 && modemStatusPin < 0) +{ + const bool modemStatusLevel = LOW; // The level of the status pin when the module is active (HIGH or LOW) +} + +// Create the wake and sleep methods for the modem +// These can be functions of any type and must return a boolean +// After enabling pin sleep, the sleep request pin is held LOW to keep the XBee on +// Enable pin sleep in the setup function or using XCTU prior to connecting the XBee +bool modemSleepFxn(void) +{ + if (modemSleepRqPin >= 0) // Don't go to sleep if there's not a wake pin! + { + digitalWrite(modemSleepRqPin, HIGH); + digitalWrite(modemLEDPin, LOW); + return true; + } + else + { + return true; + } +} + + +bool modemWakeFxn(void) +{ + if (modemVccPin >= 0) // Turns on when power is applied + return true; + else if (modemSleepRqPin >= 0) + { + digitalWrite(modemSleepRqPin, LOW); + digitalWrite(modemLEDPin, HIGH); // Because the XBee doesn't have any lights + return true; + } + else + { + return true; + } +} + + +void extraModemSetup(void) +{ + tinyModem->init(); // initialize + if (tinyModem->commandMode()) + { + // Set DIO8 to be used for sleep requests + // NOTE: Only pin 9/DIO8/DTR can be used for this function + tinyModem->sendAT(F("D8"),1); + tinyModem->waitResponse(); + // Turn on status indication pin - it will be HIGH when the XBee is awake + // NOTE: Only pin 13/ON/SLEEPnot/DIO9 can be used for this function + tinyModem->sendAT(F("D9"),1); + tinyModem->waitResponse(); + // Turn on CTS pin - it will be LOW when the XBee is ready to receive commands + // This can be used as proxy for status indication if the true status pin is not accessible + // NOTE: Only pin 12/DIO7/CTS can be used for this function + tinyModem->sendAT(F("D7"),1); + tinyModem->waitResponse(); + // Put the XBee in pin sleep mode + tinyModem->sendAT(F("SM"),1); + tinyModem->waitResponse(); + // Disassociate from network for lowest power deep sleep + tinyModem->sendAT(F("SO"),200); + tinyModem->waitResponse(); + // Write changes to flash and apply them + tinyModem->writeChanges(); + // Exit command mode + tinyModem->exitCommand(); + } +} + + + +#endif diff --git a/src/modems/DraginoBG96.h b/src/modems/DraginoBG96.h new file mode 100644 index 000000000..c9d260a1d --- /dev/null +++ b/src/modems/DraginoBG96.h @@ -0,0 +1,106 @@ +/* + *DraginoBG96.h + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module +*/ + +// Header Guards +#ifndef ModularSensorsSpecificModem_h +#define ModularSensorsSpecificModem_h + +// Debugging Statement +// #define MS_DRAGINOBG96_DEBUG + +#ifdef MS_DRAGINOBG96_DEBUG +#define MS_DEBUGGING_STD +#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT +#endif + +#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates + +// Included Dependencies +#include "ModSensorDebugger.h" +#include "LoggerModem.h" + +// ========================================================================== +// Wifi/Cellular Modem Main Chip Selection +// ========================================================================== + +// Select your modem chip - this determines the exact commands sent to it +#define TINY_GSM_MODEM_BG96 // Select for a Quectel BG96 + + +// ========================================================================== +// Modem Pins +// ========================================================================== + +// Declare the existance of modem pin Variables +// Use the "extern" keyword to denote that these will actually be defined in +// the main program rather than in this file. + +extern const int8_t modemVccPin; +extern const int8_t modemSleepRqPin; +extern const int8_t modemStatusPin; +extern const int8_t modemResetPin; +extern const int8_t modemLEDPin; + + +// ========================================================================== +// TinyGSM Client +// ========================================================================== + +// #define TINY_GSM_DEBUG Serial // If you want debugging on the main debug port + +#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates + +// Include TinyGSM for the modem +// This include must be included below the define of the modem name! +#include + +// Create a reference to the serial port for the modem +// Extra hardware and software serial ports are created in the "Settings for Additional Serial Ports" section +HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible +// AltSoftSerial &modemSerial = altSoftSerial; // For software serial if needed +// NeoSWSerial &modemSerial = neoSSerial1; // For software serial if needed + +// Create a new TinyGSM modem to run on that serial port and return a pointer to it +#if defined TINY_GSM_MODEM_XBEE +TinyGsm *tinyModem = new TinyGsm(modemSerial, modemResetPin); +#else +TinyGsm *tinyModem = new TinyGsm(modemSerial); +#endif + +// Create a new TCP client on that modem and return a pointer to it +TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); + + +// ========================================================================== +// Specific Modem On-Off Methods +// ========================================================================== + +bool modemWakeFxn(void) +{ + digitalWrite(modemSleepRqPin, LOW); + delay(110); // >100ms for Quectel BG96 + digitalWrite(modemSleepRqPin, HIGH); + return true; +} + + +bool modemSleepFxn(void) +{ + digitalWrite(modemSleepRqPin, LOW); + delay(700); // >650ms for Quectel BG96, 0.6sec > pull down > 1sec for Quectel M95, Quectel MC60 + digitalWrite(modemSleepRqPin, HIGH); + return true; +} + + +void extraModemSetup(void){} + + + +#endif diff --git a/src/modems/IteadWee.h b/src/modems/IteadWee.h new file mode 100644 index 000000000..8cf19695a --- /dev/null +++ b/src/modems/IteadWee.h @@ -0,0 +1,223 @@ +/* + *IteadWee.h + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module +*/ + +// Header Guards +#ifndef ModularSensorsSpecificModem_h +#define ModularSensorsSpecificModem_h + +// Debugging Statement +// #define MS_ITEADWEE_DEBUG + +#ifdef MS_ITEADWEE_DEBUG +#define MS_DEBUGGING_STD +#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT +#endif + +#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates + +// Included Dependencies +#include "ModSensorDebugger.h" +#include "LoggerModem.h" + +// ========================================================================== +// Wifi/Cellular Modem Main Chip Selection +// ========================================================================== + +// Select your modem chip - this determines the exact commands sent to it +#define TINY_GSM_MODEM_ESP8266 // Select for an ESP8266 using the DEFAULT AT COMMAND FIRMWARE + + +// ========================================================================== +// Modem Pins +// ========================================================================== + +// Declare the existance of modem pin Variables +// Use the "extern" keyword to denote that these will actually be defined in +// the main program rather than in this file. + +extern const int8_t modemVccPin; +extern const int8_t modemSleepRqPin; +extern const int8_t modemStatusPin; +extern const int8_t modemResetPin; +extern const int8_t modemLEDPin; +extern Stream &modemSerial; + +extern const int8_t espSleepRqPin; +extern const int8_t espStatusPin; + + +// ========================================================================== +// TinyGSM Client +// ========================================================================== + +// Include TinyGSM for the modem +// This include must be included below the define of the modem name! +#include + +// Create a new TinyGSM modem to run on that serial port and return a pointer to it +TinyGsm *tinyModem = new TinyGsm(modemSerial); + +// Create a new TCP client on that modem and return a pointer to it +TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); + + +// ========================================================================== +// Specific Modem On-Off Methods +// ========================================================================== + +const bool modemStatusLevel = HIGH; // The level of the status pin when the module is active (HIGH or LOW) +// const long modemBaud = 115200; // Communication speed of the modem, 115200 is default for ESP8266 + +// A helper function to wait for the esp to boot and immediately change some settings +// We'll use this in the wake function +bool ESPwaitForBoot(void) +{ + // Wait for boot - finished when characters start coming + // NOTE: After every "hard" reset (either power off or via RST-B), the ESP + // sends out a boot log from the ROM on UART1 at 74880 baud. We're not + // going to worry about the odd baud rate since we're simply throwing the + // characters away. + delay(200); // It will take at least this long + uint32_t start = millis(); + bool success = false; + while (!modemSerial.available() && millis() - start < 1000) {} + if (modemSerial.available()) + { + success = true; + // Read the boot log to empty it from the serial buffer + while (modemSerial.available()) + { + modemSerial.read(); + delay(2); + } + // Have to make sure echo is off or all AT commands will be confused + tinyModem->sendAT(F("E0")); + success &= tinyModem->waitResponse() == 1; + // re-run init to set mux and station mode + success &= tinyModem->init(); + } + return success; +} + +// Create the wake and sleep methods for the modem +// These can be functions of any type and must return a boolean +bool modemSleepFxn(void) +{ + // Use this if you have GPIO16 connected to the reset pin to wake from deep sleep + // but no other MCU pin connected to the reset pin. + // NOTE: This will NOT work nicely with "testingMode" + /*if (loggingInterval > 1) + { + uint32_t sleepSeconds = (((uint32_t)loggingInterval) * 60 * 1000) - 75000L; + String sleepCommand = String(sleepSeconds); + tinyModem->sendAT(F("+GSLP="), sleepCommand); + // Power down for 1 minute less than logging interval + // Better: Calculate length of loop and power down for logging interval - loop time + return tinyModem->waitResponse() == 1; + }*/ + // Use this if you have an MCU pin connected to the ESP's reset pin to wake from deep sleep + if (modemResetPin >= 0) + { + digitalWrite(modemLEDPin, LOW); + return tinyModem->poweroff(); + } + // Use this if you don't have access to the ESP8266's reset pin for deep sleep but you + // do have access to another GPIO pin for light sleep. This also sets up another + // pin to view the sleep status. + else if (modemSleepRqPin >= 0 && modemStatusPin >= 0) + { + tinyModem->sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0,"), + String(espStatusPin), ',', modemStatusLevel); + bool success = tinyModem->waitResponse() == 1; + tinyModem->sendAT(F("+SLEEP=1")); + success &= tinyModem->waitResponse() == 1; + digitalWrite(modemLEDPin, LOW); + return success; + } + // Light sleep without the status pin + else if (modemSleepRqPin >= 0 && modemStatusPin < 0) + { + tinyModem->sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0")); + bool success = tinyModem->waitResponse() == 1; + tinyModem->sendAT(F("+SLEEP=1")); + success &= tinyModem->waitResponse() == 1; + digitalWrite(modemLEDPin, LOW); + return success; + } + else // DON'T go to sleep if we can't wake up! + { + return true; + } +} +bool modemWakeFxn(void) +{ + bool success = true; + if (modemVccPin >= 0) // Turns on when power is applied + { + digitalWrite(modemLEDPin, HIGH); // Because the ESP8266 doesn't have any lights + success &= ESPwaitForBoot(); + if (!success) + { + digitalWrite(modemLEDPin, LOW); // Turn off light if the boot failed + } + return success; + } + else if (modemResetPin >= 0) + { + digitalWrite(modemLEDPin, HIGH); + digitalWrite(modemResetPin, LOW); + delay(1); + digitalWrite(modemResetPin, HIGH); + success &= ESPwaitForBoot(); + if (!success) + { + digitalWrite(modemLEDPin, LOW); // Turn off light if the boot failed + } + return success; + } + else if (modemSleepRqPin >= 0) + { + digitalWrite(modemSleepRqPin, LOW); + delay(1); + digitalWrite(modemSleepRqPin, HIGH); + digitalWrite(modemLEDPin, HIGH); + // Don't have to wait for a boot if using light sleep + return true; + } + else + { + return true; + } +} +// Set up the light-sleep status pin, if applicable +void extraModemSetup(void) +{ + // Slow down the baud rate for slow processors - and save the change to + // the ESP's non-volatile memory so we don't have to do it every time + // #if F_CPU == 8000000L + // if (modemBaud > 57600) + // { + // modemSerial.begin(modemBaud); + // tinyModem->sendAT(F("+UART_DEF=9600,8,1,0,0")); + // tinyModem->waitResponse(); + // modemSerial.end(); + // modemSerial.begin(9600); + // } + // #endif + if (modemVccPin < 0 && modemResetPin < 0 && modemSleepRqPin >= 0 && modemStatusPin >= 0) + { + tinyModem->sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0,"), + String(espStatusPin), ',', modemStatusLevel); + tinyModem->waitResponse(); + } +} + + + +#endif diff --git a/src/modems/NimbelinkLTEMQuectel.h b/src/modems/NimbelinkLTEMQuectel.h new file mode 100644 index 000000000..37e14df41 --- /dev/null +++ b/src/modems/NimbelinkLTEMQuectel.h @@ -0,0 +1,110 @@ +/* + *NimbelinkLTEMQuectel.h + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module +*/ + +// Header Guards +#ifndef ModularSensorsSpecificModem_h +#define ModularSensorsSpecificModem_h + +// Debugging Statement +// #define MS_NIMBELINKLTEMQUECTEL_DEBUG + +#ifdef MS_NIMBELINKLTEMQUECTEL_DEBUG +#define MS_DEBUGGING_STD +#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT +#endif + +#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates + +// Included Dependencies +#include "ModSensorDebugger.h" +#include "LoggerModem.h" + +// ========================================================================== +// Wifi/Cellular Modem Main Chip Selection +// ========================================================================== + +// Select your modem chip - this determines the exact commands sent to it +#define TINY_GSM_MODEM_BG96 // Select for a Quectel BG96 + +// ========================================================================== +// Modem Pins +// ========================================================================== + +// Declare the existance of modem pin Variables +// Use the "extern" keyword to denote that these will actually be defined in +// the main program rather than in this file. + +extern const int8_t modemVccPin; +extern const int8_t modemSleepRqPin; +extern const int8_t modemStatusPin; +extern const int8_t modemResetPin; +extern const int8_t modemLEDPin; + + +// ========================================================================== +// TinyGSM Client +// ========================================================================== + +// #define TINY_GSM_DEBUG Serial // If you want debugging on the main debug port + +#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates + +// Include TinyGSM for the modem +// This include must be included below the define of the modem name! +#include + +// Create a reference to the serial port for the modem +// Extra hardware and software serial ports are created in the "Settings for Additional Serial Ports" section +HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible +// AltSoftSerial &modemSerial = altSoftSerial; // For software serial if needed +// NeoSWSerial &modemSerial = neoSSerial1; // For software serial if needed + +// Create a new TinyGSM modem to run on that serial port and return a pointer to it +#if defined TINY_GSM_MODEM_XBEE +TinyGsm *tinyModem = new TinyGsm(modemSerial, modemResetPin); +#else +TinyGsm *tinyModem = new TinyGsm(modemSerial); +#endif + +// Create a new TCP client on that modem and return a pointer to it +TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); + + +// ========================================================================== +// Specific Modem On-Off Methods +// ========================================================================== + +bool modemWakeFxn(void) +{ + digitalWrite(modemSleepRqPin, LOW); + // delay(1100); // >1s for SIM800, SIM900, Quectel M95, Quectel MC60 + // delay(510); // >300ms (>500ms recommended) for Neoway M590 + delay(110); // >100ms for Quectel BG96 + digitalWrite(modemSleepRqPin, HIGH); + return true; +} + + +bool modemSleepFxn(void) +{ + digitalWrite(modemSleepRqPin, LOW); + // delay(1100); // 1sec > t > 33sec for SIM800 and clones + // delay(600); // 0.5sec > pull down > 1sec for SIM900 + // delay(510); // >300ms (>500ms recommended) for Neoway M590 + delay(700); // >650ms for Quectel BG96, 0.6sec > pull down > 1sec for Quectel M95, Quectel MC60 + digitalWrite(modemSleepRqPin, HIGH); + return true; +} + + +void extraModemSetup(void){} + + + +#endif diff --git a/src/modems/NimbelinkLTEMSequans.h b/src/modems/NimbelinkLTEMSequans.h new file mode 100644 index 000000000..51e9a66b0 --- /dev/null +++ b/src/modems/NimbelinkLTEMSequans.h @@ -0,0 +1,111 @@ +/* + *NimbelinkLTEMSequans.h + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module +*/ + +// Header Guards +#ifndef ModularSensorsSpecificModem_h +#define ModularSensorsSpecificModem_h + +// Debugging Statement +// #define MS_NIMBELINKLTEMSEQUANS_DEBUG + +#ifdef MS_NIMBELINKLTEMSEQUANS_DEBUG +#define MS_DEBUGGING_STD +#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT +#endif + +#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates + +// Included Dependencies +#include "ModSensorDebugger.h" +#include "LoggerModem.h" + +// ========================================================================== +// Wifi/Cellular Modem Main Chip Selection +// ========================================================================== + +// Select your modem chip - this determines the exact commands sent to it +#define TINY_GSM_MODEM_SEQUANS_MONARCH // Select for a Sequans Monarch CAT-M1 + + +// ========================================================================== +// Modem Pins +// ========================================================================== + +// Declare the existance of modem pin Variables +// Use the "extern" keyword to denote that these will actually be defined in +// the main program rather than in this file. + +extern const int8_t modemVccPin; +extern const int8_t modemSleepRqPin; +extern const int8_t modemStatusPin; +extern const int8_t modemResetPin; +extern const int8_t modemLEDPin; + + +// ========================================================================== +// TinyGSM Client +// ========================================================================== + +// #define TINY_GSM_DEBUG Serial // If you want debugging on the main debug port + +#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates + +// Include TinyGSM for the modem +// This include must be included below the define of the modem name! +#include + +// Create a reference to the serial port for the modem +// Extra hardware and software serial ports are created in the "Settings for Additional Serial Ports" section +HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible +// AltSoftSerial &modemSerial = altSoftSerial; // For software serial if needed +// NeoSWSerial &modemSerial = neoSSerial1; // For software serial if needed + +// Create a new TinyGSM modem to run on that serial port and return a pointer to it +#if defined TINY_GSM_MODEM_XBEE +TinyGsm *tinyModem = new TinyGsm(modemSerial, modemResetPin); +#else +TinyGsm *tinyModem = new TinyGsm(modemSerial); +#endif + +// Create a new TCP client on that modem and return a pointer to it +TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); + + +// ========================================================================== +// Specific Modem On-Off Methods +// ========================================================================== + +bool modemWakeFxn(void) +{ + digitalWrite(modemSleepRqPin, LOW); + // delay(1100); // >1s for SIM800, SIM900, Quectel M95, Quectel MC60 + // delay(510); // >300ms (>500ms recommended) for Neoway M590 + delay(110); // >100ms for Quectel BG96 + digitalWrite(modemSleepRqPin, HIGH); + return true; +} + + +bool modemSleepFxn(void) +{ + digitalWrite(modemSleepRqPin, LOW); + // delay(1100); // 1sec > t > 33sec for SIM800 and clones + // delay(600); // 0.5sec > pull down > 1sec for SIM900 + // delay(510); // >300ms (>500ms recommended) for Neoway M590 + delay(700); // >650ms for Quectel BG96, 0.6sec > pull down > 1sec for Quectel M95, Quectel MC60 + digitalWrite(modemSleepRqPin, HIGH); + return true; +} + + +void extraModemSetup(void){} + + + +#endif diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h new file mode 100644 index 000000000..359f1f47e --- /dev/null +++ b/src/modems/Sodaq2GBeeR6.h @@ -0,0 +1,105 @@ +/* + *Sodaq2GBeeR6.h + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module +*/ + +// Header Guards +#ifndef ModularSensorsSpecificModem_h +#define ModularSensorsSpecificModem_h + +// Debugging Statement +// #define MS_SODAQ2GBEER6_DEBUG + +#ifdef MS_SODAQ2GBEER6_DEBUG +#define MS_DEBUGGING_STD +#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT +#endif + +#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates + +// Included Dependencies +#include "ModSensorDebugger.h" +#include "LoggerModem.h" + +// ========================================================================== +// Wifi/Cellular Modem Main Chip Selection +// ========================================================================== + +// Select your modem chip - this determines the exact commands sent to it +#define TINY_GSM_MODEM_SIM800 // Select for a SIMCOM SIM800, SIM900, or variant thereof + + +// ========================================================================== +// Modem Pins +// ========================================================================== + +// Declare the existance of modem pin Variables +// Use the "extern" keyword to denote that these will actually be defined in +// the main program rather than in this file. + +extern const int8_t modemVccPin; +extern const int8_t modemSleepRqPin; +extern const int8_t modemStatusPin; +extern const int8_t modemResetPin; +extern const int8_t modemLEDPin; + + +// ========================================================================== +// TinyGSM Client +// ========================================================================== + +// #define TINY_GSM_DEBUG Serial // If you want debugging on the main debug port + +#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates + +// Include TinyGSM for the modem +// This include must be included below the define of the modem name! +#include + +// Create a reference to the serial port for the modem +// Extra hardware and software serial ports are created in the "Settings for Additional Serial Ports" section +HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible +// AltSoftSerial &modemSerial = altSoftSerial; // For software serial if needed +// NeoSWSerial &modemSerial = neoSSerial1; // For software serial if needed + +// Create a new TinyGSM modem to run on that serial port and return a pointer to it +#if defined TINY_GSM_MODEM_XBEE +TinyGsm *tinyModem = new TinyGsm(modemSerial, modemResetPin); +#else +TinyGsm *tinyModem = new TinyGsm(modemSerial); +#endif + +// Create a new TCP client on that modem and return a pointer to it +TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); + + +// ========================================================================== +// Specific Modem On-Off Methods +// ========================================================================== + +// Create the wake and sleep methods for the modem +// These can be functions of any type and must return a boolean +bool modemWakeFxn(void) +{ + digitalWrite(modemSleepRqPin, HIGH); + digitalWrite(modemLEDPin, HIGH); // A light just for show + return true; +} + + +bool modemSleepFxn(void) +{ + digitalWrite(modemSleepRqPin, LOW); + digitalWrite(modemLEDPin, LOW); + return true; +} + + +void extraModemSetup(void){} + + +#endif diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h new file mode 100644 index 000000000..d77995f7d --- /dev/null +++ b/src/modems/SodaqUBeeR410M.h @@ -0,0 +1,103 @@ +/* + *SodaqUBeeR410M.h + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module +*/ + +// Header Guards +#ifndef ModularSensorsSpecificModem_h +#define ModularSensorsSpecificModem_h + +// Debugging Statement +// #define MS_SODAQUBEER410M_DEBUG + +#ifdef MS_SODAQUBEER410M_DEBUG +#define MS_DEBUGGING_STD +#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT +#endif + +#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates + +// Included Dependencies +#include "ModSensorDebugger.h" +#include "LoggerModem.h" + +// ========================================================================== +// Wifi/Cellular Modem Main Chip Selection +// ========================================================================== + +// Select your modem chip - this determines the exact commands sent to it +#define TINY_GSM_MODEM_UBLOX // Select for most u-blox cellular modems + + +// ========================================================================== +// Modem Pins +// ========================================================================== + +// Declare the existance of modem pin Variables +// Use the "extern" keyword to denote that these will actually be defined in +// the main program rather than in this file. + +extern const int8_t modemVccPin; +extern const int8_t modemSleepRqPin; +extern const int8_t modemStatusPin; +extern const int8_t modemResetPin; +extern const int8_t modemLEDPin; + + +// ========================================================================== +// Specific Modem On-Off Methods +// ========================================================================== + +// Create the wake and sleep methods for the modem +// These can be functions of any type and must return a boolean +bool modemSleepFxn(void) +{ + if (modemSleepRqPin >= 0) // R410 must have access to PWR_ON pin to sleep + { + // Easiest to just go to sleep with the AT command rather than using pins + return tinyModem->poweroff(); + } + else // DON'T go to sleep if we can't wake up! + { + return true; + } +} +bool modemWakeFxn(void) +{ + // SARA R4/N4 series must power on and then pulse on + if (modemSleepRqPin >= 0) + { + digitalWrite(modemSleepRqPin, LOW); + digitalWrite(modemLEDPin, HIGH); + delay(200); // 0.15-3.2s pulse for wake on SARA R4/N4 + digitalWrite(modemSleepRqPin, HIGH); + digitalWrite(modemLEDPin, LOW); + // Need to slow down R4/N4's default 115200 baud rate for slow processors + #if F_CPU == 8000000L && defined USE_UBLOX_R410M + delay(4600); // Must wait for UART port to become active + modemSerial.begin(115200); + tinyModem->setBaud(9600); + modemSerial.end(); + modemSerial.begin(9600); + #endif + return true; + } + else + { + return true; + } +} + + +void extraModemSetup(void) +{ + tinyModem->sendAT(F("+URAT=7")); + tinyModem->waitResponse(); +} + + +#endif diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h new file mode 100644 index 000000000..84e142433 --- /dev/null +++ b/src/modems/SodaqUBeeU201.h @@ -0,0 +1,121 @@ +/* + *SodaqUBeeU201.h + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module +*/ + +// Header Guards +#ifndef ModularSensorsSpecificModem_h +#define ModularSensorsSpecificModem_h + +// Debugging Statement +// #define MS_SODAQUBEEU201_DEBUG + +#ifdef MS_SODAQUBEEU201_DEBUG +#define MS_DEBUGGING_STD +#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT +#endif + +#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates + +// Included Dependencies +#include "ModSensorDebugger.h" +#include "LoggerModem.h" + +// ========================================================================== +// Wifi/Cellular Modem Main Chip Selection +// ========================================================================== + +// Select your modem chip - this determines the exact commands sent to it +#define TINY_GSM_MODEM_UBLOX // Select for most u-blox cellular modems + + +// ========================================================================== +// Modem Pins +// ========================================================================== + +// Declare the existance of modem pin Variables +// Use the "extern" keyword to denote that these will actually be defined in +// the main program rather than in this file. + +extern const int8_t modemVccPin; +extern const int8_t modemSleepRqPin; +extern const int8_t modemStatusPin; +extern const int8_t modemResetPin; +extern const int8_t modemLEDPin; + + +// ========================================================================== +// TinyGSM Client +// ========================================================================== + +// #define TINY_GSM_DEBUG Serial // If you want debugging on the main debug port + +#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates + +// Include TinyGSM for the modem +// This include must be included below the define of the modem name! +#include + +// Create a reference to the serial port for the modem +// Extra hardware and software serial ports are created in the "Settings for Additional Serial Ports" section +HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible +// AltSoftSerial &modemSerial = altSoftSerial; // For software serial if needed +// NeoSWSerial &modemSerial = neoSSerial1; // For software serial if needed + +// Create a new TinyGSM modem to run on that serial port and return a pointer to it +TinyGsm *tinyModem = new TinyGsm(modemSerial); + +// Create a new TCP client on that modem and return a pointer to it +TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); + + +// ========================================================================== +// Specific Modem On-Off Methods +// ========================================================================== + +// Create the wake and sleep methods for the modem +// These can be functions of any type and must return a boolean +bool modemSleepFxn(void) +{ + if (modemVccPin >= 0 || modemSleepRqPin >= 0) // others will go on with power on + { + // Easiest to just go to sleep with the AT command rather than using pins + return tinyModem->poweroff(); + } + else // DON'T go to sleep if we can't wake up! + { + return true; + } +} + + +bool modemWakeFxn(void) +{ + // SARA/LISA U2/G2 and SARA G3 series turn on when power is applied + if (modemVccPin >= 0) + return true; + if (modemSleepRqPin >= 0) + { + digitalWrite(modemSleepRqPin, LOW); + digitalWrite(modemLEDPin, HIGH); + // delay(6); // >5ms pulse for wake on SARA G3 + delayMicroseconds(65); // 50-80µs pulse for wake on SARA/LISA U2/G2 + digitalWrite(modemSleepRqPin, HIGH); + digitalWrite(modemLEDPin, LOW); + return true; + } + else + { + return true; + } +} + + +void extraModemSetup(void){} + + +#endif From b93806806e9291f252307d07412b8adad04ccd25 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 13 May 2019 16:16:26 -0400 Subject: [PATCH 11/88] v1 --- src/LoggerModem.cpp | 168 ++++++++++++++++++++++++++++++++++---------- src/LoggerModem.h | 39 +++++++--- 2 files changed, 160 insertions(+), 47 deletions(-) diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index 72f7aec03..c1272e822 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -13,41 +13,130 @@ // Constructors loggerModem::loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, + int8_t modemResetPin, bool (*modemWakeFxn)(), bool (*modemSleepFxn)(), TinyGsmModem *inModem, Client *inClient, const char *APN) : Sensor("Tiny GSM Modem", MODEM_NUM_VARIABLES, MODEM_WARM_UP_TIME_MS, MODEM_ATRESPONSE_TIME_MS, MODEM_MAX_SEARCH_TIME, - powerPin, statusPin, 1), - _tinyModem(inModem), _tinyClient(inClient), - _modemWakeFxn(modemWakeFxn), _modemSleepFxn(modemSleepFxn), - _statusLevel(statusLevel), - _statusTime_ms(MODEM_STATUS_TIME_MS), - _disconnetTime_ms(MODEM_DISCONNECT_TIME_MS), - _apn(APN), _ssid(NULL), _pwd(NULL), _lastNISTrequest(0) + powerPin, statusPin, 1) { _modemName = "unspecified modem"; + _tinyModem = inModem; + _tinyClient = inClient; + + _modemWakeFxn = modemWakeFxn; + _modemSleepFxn = modemSleepFxn; + + _modemResetPin = modemResetPin; + _modemSleepRqPin = -1; + _modemLEDPin = -1; + + _statusLevel = statusLevel; + _statusTime_ms = MODEM_STATUS_TIME_MS, + _disconnetTime_ms = MODEM_DISCONNECT_TIME_MS; + + _apn = APN; + _ssid = NULL; + _pwd = NULL; + + _lastNISTrequest = 0; _lastConnectionCheck = 0; _lastATCheck = 0; - _modemSleepRqPin = -1; } loggerModem::loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, + int8_t modemResetPin, bool (*modemWakeFxn)(), bool (*modemSleepFxn)(), TinyGsmModem *inModem, Client *inClient, const char *ssid, const char *pwd) : Sensor("Tiny GSM Modem", MODEM_NUM_VARIABLES, MODEM_WARM_UP_TIME_MS, MODEM_ATRESPONSE_TIME_MS, MODEM_MAX_SEARCH_TIME, - powerPin, statusPin, 1), - _statusLevel(statusLevel), _statusTime_ms(MODEM_STATUS_TIME_MS), - _disconnetTime_ms(MODEM_DISCONNECT_TIME_MS), - _apn(NULL), _ssid(ssid), _pwd(pwd), _lastNISTrequest(0) + powerPin, statusPin, 1) { + _modemName = "unspecified modem"; _tinyModem = inModem; _tinyClient = inClient; + _modemWakeFxn = modemWakeFxn; _modemSleepFxn = modemSleepFxn; + + _modemResetPin = modemResetPin; + _modemSleepRqPin = -1; + _modemLEDPin = -1; + + _statusLevel = statusLevel; + _statusTime_ms = MODEM_STATUS_TIME_MS, + _disconnetTime_ms = MODEM_DISCONNECT_TIME_MS; + + _apn = NULL; + _ssid = ssid; + _pwd = pwd; + + _lastNISTrequest = 0; + _lastConnectionCheck = 0; + _lastATCheck = 0; +} +loggerModem::loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, + int8_t modemResetPin, int8_t modemSleepRqPin, + uint16_t max_status_time_ms, uint16_t max_disconnetTime_ms, + uint32_t max_warmUpTime_ms, uint32_t max_atresponse_time_ms, + TinyGsmModem *inModem, Client *inClient, const char *APN) + : Sensor("Tiny GSM Modem", MODEM_NUM_VARIABLES, + max_warmUpTime_ms, max_atresponse_time_ms, MODEM_MAX_SEARCH_TIME, + powerPin, statusPin, 1) +{ _modemName = "unspecified modem"; + _tinyModem = inModem; + _tinyClient = inClient; + + _modemWakeFxn = NULL; + _modemSleepFxn = NULL; + + _modemResetPin = modemResetPin; + _modemSleepRqPin = -1; + _modemLEDPin = -1; + + _statusLevel = statusLevel; + _statusTime_ms = max_status_time_ms, + _disconnetTime_ms = max_disconnetTime_ms; + + _apn = APN; + _ssid = NULL; + _pwd = NULL; + + _lastNISTrequest = 0; _lastConnectionCheck = 0; _lastATCheck = 0; +} +loggerModem::loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, + int8_t modemResetPin, int8_t modemSleepRqPin, + uint16_t max_status_time_ms, uint16_t max_disconnetTime_ms, + uint32_t max_warmUpTime_ms, uint32_t max_atresponse_time_ms, + TinyGsmModem *inModem, Client *inClient, const char *ssid, const char *pwd) + : Sensor("Tiny GSM Modem", MODEM_NUM_VARIABLES, + max_warmUpTime_ms, max_atresponse_time_ms, MODEM_MAX_SEARCH_TIME, + powerPin, statusPin, 1) +{ + _modemName = "unspecified modem"; + _tinyModem = inModem; + _tinyClient = inClient; + + _modemWakeFxn = NULL; + _modemSleepFxn = NULL; + + _modemResetPin = modemResetPin; _modemSleepRqPin = -1; + _modemLEDPin = -1; + + _statusLevel = statusLevel; + _statusTime_ms = max_status_time_ms, + _disconnetTime_ms = max_disconnetTime_ms; + + _apn = NULL; + _ssid = ssid; + _pwd = pwd; + + _lastNISTrequest = 0; + _lastConnectionCheck = 0; + _lastATCheck = 0; } @@ -55,6 +144,9 @@ loggerModem::loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, loggerModem::~loggerModem(){} +void loggerModem::setModemLED(int8_t modemLEDPin) { _modemLEDPin = modemLEDPin; }; + + String loggerModem::getSensorName(void) { return _modemName; } @@ -106,6 +198,7 @@ bool loggerModem::setup(void) // NOTE: These are based on documentation for the raw chip! setModemTiming(); + MS_DBG(_modemName, F("warms up in"), _warmUpTime_ms, F("ms, indicates status in"), _statusTime_ms, F("ms, is responsive to AT commands in less than"), _stabilizationTime_ms, F("ms, and takes up to"), _disconnetTime_ms, @@ -153,29 +246,20 @@ bool loggerModem::setup(void) // There are so many ways to wake a modem that we're requiring an input function bool loggerModem::wake(void) { - bool success = true; - - MS_DBG(F("Waking"), getSensorName()); - // Set the status bit for sensor activation attempt (bit 3) - // Setting this bit even if the activation failed, to show the attempt was made - _sensorStatus |= 0b00001000; + // Sensor::wake() checks if the power pin is on, setup has been successful, + // and sets the wake timestamp and status bits. If it returns false, + // there's no reason to go on. + if (!Sensor::wake()) return false; + // NOTE: This is the ONLY place _millisSensorActivated is set! + // NOTE: This is the ONLY place bit 4 is set! - // Check if the sensor was successfully powered - if (!bitRead(_sensorStatus, 2)) - { - MS_DBG(getSensorName(), F("doesn't have power and will never wake up!")); - // Make sure that the wake time and wake success bit (bit 4) are unset - _millisSensorActivated = 0; - _sensorStatus &= 0b11101111; - return false; - } + bool success = true; // Check the status pin and wake bits before running wake function // Don't want to accidently pulse an already on modem to off if ( bitRead(_sensorStatus, 4)) { MS_DBG(getSensorName(), F("has already been woken up! Will not run wake function.")); - success = true; } // NOTE: It's possible that the status pin is on, but the modem is actually // mid-shutdown. In that case, we'll mistakenly skip re-waking it. @@ -183,7 +267,6 @@ bool loggerModem::wake(void) { MS_DBG(getSensorName(), F("was already on! (status pin level = "), _statusLevel, F(") Will not run wake function.")); - success = true; } else { @@ -198,22 +281,24 @@ bool loggerModem::wake(void) { MS_DBG(F("Status pin level on"), getSensorName(), F("is"), digitalRead(_dataPin), F("indicating it is off!")); - // Make sure that the wake time and wake success bit (bit 4) are unset - _millisSensorActivated = 0; - _sensorStatus &= 0b11101111; - return false; + success = false; } if (success) { - // Mark the time that the modem woke up - // NOTE: This is the ONLY place _millisSensorActivated is set! - if (_millisSensorActivated == 0) _millisSensorActivated = millis(); - // Set the status bit for sensor wake/activation success (bit 4) - // NOTE: This is the ONLY place bit 4 is set! - _sensorStatus |= 0b00010000; + if (_modemLEDPin >= 0) + { + digitalWrite(_modemLEDPin, HIGH); + } MS_DBG(getSensorName(), F("should be awake.")); } + else + { + MS_DBG(getSensorName(), F("failed to wake!")); + // Make sure the activation time is zero and the wake success bit (bit 4) is unset + _millisSensorActivated = 0; + _sensorStatus &= 0b11101111; + } return success; } @@ -693,6 +778,11 @@ bool loggerModem::modemSleepPowerDown(void) // Run the sleep function MS_DBG(F("Running given sleep function for"), getSensorName()); success &= _modemSleepFxn(); + + if (_modemLEDPin >= 0) + { + digitalWrite(_modemLEDPin, LOW); + } } // Unset the activation time diff --git a/src/LoggerModem.h b/src/LoggerModem.h index 1516f06a4..f252c0727 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -87,13 +87,27 @@ class loggerModem : public Sensor // typedef's in the TinyGsmClient.h that make this somewhat invisible to // the user. loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, + int8_t modemResetPin, bool (*modemWakeFxn)(), bool (*modemSleepFxn)(), TinyGsmModem *inModem, Client *inClient, const char *APN); loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, + int8_t modemResetPin, bool (*modemWakeFxn)(), bool (*modemSleepFxn)(), TinyGsmModem *inModem, Client *inClient, const char *ssid, const char *pwd); + loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, + int8_t modemResetPin, int8_t modemSleepRqPin, + uint16_t max_status_time_ms, uint16_t max_disconnetTime_ms, + uint32_t max_warmUpTime_ms, uint32_t max_atresponse_time_ms, + TinyGsmModem *inModem, Client *inClient, const char *APN); + + loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, + int8_t modemResetPin, int8_t modemSleepRqPin, + uint16_t max_status_time_ms, uint16_t max_disconnetTime_ms, + uint32_t max_warmUpTime_ms, uint32_t max_atresponse_time_ms, + TinyGsmModem *inModem, Client *inClient, const char *ssid, const char *pwd); + ~loggerModem(); String getSensorName(void) override; @@ -128,13 +142,20 @@ class loggerModem : public Sensor // These are the unique functions for the modem as an internet connected device // ==========================================================================// public: + + // Sets an LED to turn on when the modem is on + void setModemLED(int8_t modemLEDPin); + + // Get values by other names int16_t getSignalRSSI(void) {return sensorValues[RSSI_VAR_NUM];} int16_t getSignalPercent(void) {return sensorValues[PERCENT_SIGNAL_VAR_NUM];} + // Get the client instance in use Client * getClient(void){return _tinyClient;} - bool connectInternet(uint32_t waitTime_ms = 50000L); - void disconnectInternet(void); + // Access the internet + virtual bool connectInternet(uint32_t waitTime_ms = 50000L) = 0; + virtual void disconnectInternet(void) = 0; // This has the same functionality as Client->connect with debugging text // int16_t openTCP(const char *host, uint16_t port); @@ -144,7 +165,7 @@ class loggerModem : public Sensor // void closeTCP(void); // Special sleep and power function for the modem void modemPowerUp(void); - bool modemSleepPowerDown(void); + virtual bool modemSleepPowerDown(void); // Get the time from NIST via TIME protocol (rfc868) // This would be much more efficient if done over UDP, but I'm doing it @@ -156,7 +177,7 @@ class loggerModem : public Sensor TinyGsmModem *_tinyModem; Client *_tinyClient; -private: +protected: // Helper to get approximate RSSI from CSQ (assuming no noise) static int16_t getRSSIFromCSQ(int16_t csq); // Helper to get signal percent from CSQ @@ -166,16 +187,18 @@ class loggerModem : public Sensor // Helper to set the timing for specific cellular chipsets based on their documentation void setModemTiming(void); -private: +protected: bool (*_modemWakeFxn)(void); bool (*_modemSleepFxn)(void); - bool _statusLevel; int8_t _modemSleepRqPin; + int8_t _modemResetPin; + int8_t _modemLEDPin; + + bool _statusLevel; uint16_t _statusTime_ms; uint16_t _disconnetTime_ms; - // uint16_t _on_pull_down_ms; - // uint16_t _off_pull_down_ms; + const char *_apn; const char *_ssid; const char *_pwd; From 9c3fc1fad696a893d4fc0909c8be53164cc441a2 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 13 May 2019 19:21:57 -0400 Subject: [PATCH 12/88] Digi bees --- src/LoggerModem.cpp | 212 +++--------- src/LoggerModem.h | 94 ++---- src/SensorBase.cpp | 3 +- src/modems/DigiXBee.cpp | 265 +-------------- src/modems/DigiXBee.h | 30 +- src/modems/DigiXBeeCellularBypass.cpp | 357 +++++++++++++++++++++ src/modems/DigiXBeeCellularBypass.h | 175 ++-------- src/modems/DigiXBeeCellularTransparent.cpp | 344 ++++++++++++++++++++ src/modems/DigiXBeeCellularTransparent.h | 164 ++-------- src/modems/DigiXBeeWifi.cpp | 342 ++++++++++++++++++++ src/modems/DigiXBeeWifi.h | 119 ++----- 11 files changed, 1207 insertions(+), 898 deletions(-) create mode 100644 src/modems/DigiXBeeCellularBypass.cpp create mode 100644 src/modems/DigiXBeeCellularTransparent.cpp create mode 100644 src/modems/DigiXBeeWifi.cpp diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index c1272e822..9df75baea 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -12,128 +12,26 @@ // Constructors -loggerModem::loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, - int8_t modemResetPin, - bool (*modemWakeFxn)(), bool (*modemSleepFxn)(), - TinyGsmModem *inModem, Client *inClient, const char *APN) - : Sensor("Tiny GSM Modem", MODEM_NUM_VARIABLES, - MODEM_WARM_UP_TIME_MS, MODEM_ATRESPONSE_TIME_MS, MODEM_MAX_SEARCH_TIME, - powerPin, statusPin, 1) -{ - _modemName = "unspecified modem"; - _tinyModem = inModem; - _tinyClient = inClient; - - _modemWakeFxn = modemWakeFxn; - _modemSleepFxn = modemSleepFxn; - - _modemResetPin = modemResetPin; - _modemSleepRqPin = -1; - _modemLEDPin = -1; - - _statusLevel = statusLevel; - _statusTime_ms = MODEM_STATUS_TIME_MS, - _disconnetTime_ms = MODEM_DISCONNECT_TIME_MS; - - _apn = APN; - _ssid = NULL; - _pwd = NULL; - - _lastNISTrequest = 0; - _lastConnectionCheck = 0; - _lastATCheck = 0; -} -loggerModem::loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, - int8_t modemResetPin, - bool (*modemWakeFxn)(), bool (*modemSleepFxn)(), - TinyGsmModem *inModem, Client *inClient, const char *ssid, const char *pwd) - : Sensor("Tiny GSM Modem", MODEM_NUM_VARIABLES, - MODEM_WARM_UP_TIME_MS, MODEM_ATRESPONSE_TIME_MS, MODEM_MAX_SEARCH_TIME, - powerPin, statusPin, 1) -{ - _modemName = "unspecified modem"; - _tinyModem = inModem; - _tinyClient = inClient; - - _modemWakeFxn = modemWakeFxn; - _modemSleepFxn = modemSleepFxn; - - _modemResetPin = modemResetPin; - _modemSleepRqPin = -1; - _modemLEDPin = -1; - - _statusLevel = statusLevel; - _statusTime_ms = MODEM_STATUS_TIME_MS, - _disconnetTime_ms = MODEM_DISCONNECT_TIME_MS; - - _apn = NULL; - _ssid = ssid; - _pwd = pwd; - - _lastNISTrequest = 0; - _lastConnectionCheck = 0; - _lastATCheck = 0; -} -loggerModem::loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, - int8_t modemResetPin, int8_t modemSleepRqPin, - uint16_t max_status_time_ms, uint16_t max_disconnetTime_ms, - uint32_t max_warmUpTime_ms, uint32_t max_atresponse_time_ms, - TinyGsmModem *inModem, Client *inClient, const char *APN) - : Sensor("Tiny GSM Modem", MODEM_NUM_VARIABLES, - max_warmUpTime_ms, max_atresponse_time_ms, MODEM_MAX_SEARCH_TIME, - powerPin, statusPin, 1) -{ - _modemName = "unspecified modem"; - _tinyModem = inModem; - _tinyClient = inClient; - - _modemWakeFxn = NULL; - _modemSleepFxn = NULL; - - _modemResetPin = modemResetPin; - _modemSleepRqPin = -1; - _modemLEDPin = -1; - - _statusLevel = statusLevel; - _statusTime_ms = max_status_time_ms, - _disconnetTime_ms = max_disconnetTime_ms; - - _apn = APN; - _ssid = NULL; - _pwd = NULL; - - _lastNISTrequest = 0; - _lastConnectionCheck = 0; - _lastATCheck = 0; -} loggerModem::loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, int8_t modemResetPin, int8_t modemSleepRqPin, - uint16_t max_status_time_ms, uint16_t max_disconnetTime_ms, + uint32_t max_status_time_ms, uint32_t max_disconnetTime_ms, uint32_t max_warmUpTime_ms, uint32_t max_atresponse_time_ms, - TinyGsmModem *inModem, Client *inClient, const char *ssid, const char *pwd) + uint32_t max_signalQuality_time_ms, + uint8_t measurementsToAverage) : Sensor("Tiny GSM Modem", MODEM_NUM_VARIABLES, - max_warmUpTime_ms, max_atresponse_time_ms, MODEM_MAX_SEARCH_TIME, - powerPin, statusPin, 1) + max_warmUpTime_ms, max_atresponse_time_ms, max_signalQuality_time_ms, + powerPin, statusPin, measurementsToAverage) { _modemName = "unspecified modem"; - _tinyModem = inModem; - _tinyClient = inClient; - - _modemWakeFxn = NULL; - _modemSleepFxn = NULL; _modemResetPin = modemResetPin; - _modemSleepRqPin = -1; + _modemSleepRqPin = modemSleepRqPin; _modemLEDPin = -1; _statusLevel = statusLevel; _statusTime_ms = max_status_time_ms, _disconnetTime_ms = max_disconnetTime_ms; - _apn = NULL; - _ssid = ssid; - _pwd = pwd; - _lastNISTrequest = 0; _lastConnectionCheck = 0; _lastATCheck = 0; @@ -145,6 +43,20 @@ loggerModem::~loggerModem(){} void loggerModem::setModemLED(int8_t modemLEDPin) { _modemLEDPin = modemLEDPin; }; +void loggerModem::modemLEDOn(void) +{ + if (_modemLEDPin >= 0) + { + digitalWrite(_modemLEDPin, HIGH); + } +} +void loggerModem::modemLEDOff(void) +{ + if (_modemLEDPin >= 0) + { + digitalWrite(_modemLEDPin, LOW); + } +} String loggerModem::getSensorName(void) { return _modemName; } @@ -176,7 +88,7 @@ bool loggerModem::setup(void) { waitForWarmUp(); MS_DBG(F("Running given modem wake function ...")); - success &= _modemWakeFxn(); + success &= wake(); // NOTE: not setting wake bits here because we'll go back to sleep // before the end of this function if we weren't awake } @@ -187,8 +99,7 @@ bool loggerModem::setup(void) // The begin() generally starts with a 5 second testAT(), that should // be enough time to allow any modem to be ready to respond MS_DBG(F("Running modem's begin function ...")); - success &= _tinyModem->begin(); - _modemName = _tinyModem->getModemName(); + success &= extraModemSetup(); if (success) MS_DBG(F("... Complete! It's a"), getSensorName()); else MS_DBG(F("... Failed! It's a"), getSensorName()); } @@ -196,7 +107,7 @@ bool loggerModem::setup(void) // Set the timing for modems based on their names // NOTE: These are based on documentation for the raw chip! - setModemTiming(); + // setModemTiming(); MS_DBG(_modemName, F("warms up in"), _warmUpTime_ms, F("ms, indicates status in"), @@ -204,20 +115,6 @@ bool loggerModem::setup(void) _stabilizationTime_ms, F("ms, and takes up to"), _disconnetTime_ms, F("ms to close connections and shut down.")); - // XBee saves all configurations to flash, so we can set them here - if (_modemName.indexOf(F("XBee")) >= 0) - { - MS_DBG(F("Putting connection values into flash memory for the Digi XBee")); - if (_tinyModem->hasWifi()) _tinyModem->networkConnect(_ssid, _pwd); - else _tinyModem->gprsConnect(_apn, "", ""); - } - - // Print out some warnings if things seem to be improperly formatted - if (_tinyModem->hasWifi() && _ssid == NULL) - MS_DBG(F("WARNING: Wifi modem with no SSID given!")); - if (_tinyModem->hasGPRS() && _apn == NULL) - MS_DBG(F("WARNING: Cellular modem with no APN given!")); - // Set the status bit marking that the modem has been set up (bit 0) // Only set the bit if setup was successful! if (success) _sensorStatus |= 0b00000001; @@ -232,7 +129,7 @@ bool loggerModem::setup(void) { // Run the sleep function MS_DBG(F("Running given modem sleep function ...")); - success &= _modemSleepFxn(); + success &= modemSleepFxn(); } else MS_DBG(F("Leaving modem on after setup ...")); // Do NOT power down at the end, because this fxn cannot have powered the @@ -272,7 +169,7 @@ bool loggerModem::wake(void) { // Run the input wake function MS_DBG(F("Running wake function for"), getSensorName()); - success &= _modemWakeFxn(); + success &= modemWakeFxn(); } // Re-check the status pin @@ -286,10 +183,7 @@ bool loggerModem::wake(void) if (success) { - if (_modemLEDPin >= 0) - { - digitalWrite(_modemLEDPin, HIGH); - } + modemLEDOn(); MS_DBG(getSensorName(), F("should be awake.")); } else @@ -382,24 +276,6 @@ bool loggerModem::addSingleMeasurementResult(void) // Only go on to get a result if it was if (bitRead(_sensorStatus, 6)) { - // The WiFi XBee needs to make an actual TCP connection and get some sort - // of response on that connection before it knows the signal quality. - // Connecting to the NIST daytime server, which immediately returns a - // 4 byte response and then closes the connection - if (_modemName.indexOf(F("XBee")) >= 0 && _tinyModem->hasWifi()) - { - MS_DBG(F("Connecting to NIST daytime server to check connection strength...")); - IPAddress ip(129, 6, 15, 30); // This is the IP address of time-c-g.nist.gov - success &= _tinyClient->connect(ip, 37); - _tinyClient->print('!'); // Need to send something before connection is made - delay(100); // Need this delay! Can get away with 50, but 100 is safer. - char junkBuff[5]; - _tinyClient->readBytes(junkBuff, 4); // Dump the returned bytes - // This should ensure we don't wait for more than 4 character time outs - _lastNISTrequest = millis(); - _tinyClient->stop(); // NIST will close on it's side, but need to stop - // because otherwise the Bee won't realize the socket has closed - } // Get signal quality // NOTE: We can't actually distinguish between a bad modem response, no @@ -482,7 +358,7 @@ bool loggerModem::isStable(bool debug) if (now - _lastATCheck < 250) return false; // If the modem is now responding to AT commands, it's "stable" - if (_tinyModem->testAT(10)) + if (didATRespond()) { if (debug) MS_DBG(F("It's been"), (elapsed_since_wake_up), F("ms, and"), getSensorName(), F("is now responding to AT commands!")); @@ -544,17 +420,6 @@ bool loggerModem::isMeasurementComplete(bool debug) // just defining this to not call multiple times below uint32_t now = millis(); - // For Wifi XBee's, we need to open a socket before we get signal strength - // For ease, we will be opening that socket to NIST in addSingleMeasurementResult. - // Because NIST very clearly specifies that we may not ping more frequently - // than once every 4 seconds, we need to wait if it hasn't been that long. - // See: https://tf.nist.gov/tf-cgi/servers.cgi - if (_modemName.indexOf(F("XBee")) >= 0 && _tinyModem->hasWifi() - && now - _lastNISTrequest < 4000) - { - return false; - } - // We don't want to ping any of the modems too fast so they don't get // overwhelmed. Make sure we've waited a little if (now - _lastConnectionCheck < 250) return false; @@ -590,7 +455,7 @@ bool loggerModem::isMeasurementComplete(bool debug) } // If we've exceeded the allowed time to wait for the network, give up - if (elapsed_in_wait > MODEM_MAX_SEARCH_TIME) + if (elapsed_in_wait > XBEE_SIGNALQUALITY_TIME_MS) { if (debug) MS_DBG(F("It's been"), (elapsed_in_wait), F("ms, and"), getSensorName(), F("has maxed out wait for network registration! Ending wait.")); @@ -607,7 +472,7 @@ bool loggerModem::isMeasurementComplete(bool debug) // ==========================================================================// // These are the unique functions for the modem as an internet connected device // ==========================================================================// -bool loggerModem::connectInternet(uint32_t waitTime_ms) +bool loggerModem::connectInternet(uint32_t maxConnectionTime) { bool retVal = true; @@ -649,9 +514,9 @@ bool loggerModem::connectInternet(uint32_t waitTime_ms) { MS_DBG(F("Sending credentials...")); while (!_tinyModem->networkConnect(_ssid, _pwd)) {}; - MS_DBG(F("Waiting up to"), waitTime_ms/1000, + MS_DBG(F("Waiting up to"), maxConnectionTime/1000, F("seconds for connection")); - if (!_tinyModem->waitForNetwork(waitTime_ms)) + if (!_tinyModem->waitForNetwork(maxConnectionTime)) { MS_DBG(F("... WiFi connection failed")); return false; @@ -663,9 +528,9 @@ bool loggerModem::connectInternet(uint32_t waitTime_ms) } else // must be GPRS { - MS_DBG(F("\nWaiting up to"), waitTime_ms/1000, + MS_DBG(F("\nWaiting up to"), maxConnectionTime/1000, F("seconds for cellular network registration...")); - if (_tinyModem->waitForNetwork(waitTime_ms)) + if (_tinyModem->waitForNetwork(maxConnectionTime)) { MS_DBG(F("... Registered after"), millis() - start, F("milliseconds. Connecting to GPRS...")); @@ -777,12 +642,8 @@ bool loggerModem::modemSleepPowerDown(void) { // Run the sleep function MS_DBG(F("Running given sleep function for"), getSensorName()); - success &= _modemSleepFxn(); - - if (_modemLEDPin >= 0) - { - digitalWrite(_modemLEDPin, LOW); - } + success &= modemSleepFxn(); + modemLEDOff(); } // Unset the activation time @@ -977,7 +838,6 @@ Where I could not find it listed, I use 5 seconds. **disconnetTime** - Approximate length of time for unit to gracefully close sockets and disconnect from the network. Most manufactures strongly recommend allowing a graceful shut-down rather than a sudden power-off. -***/ void loggerModem::setModemTiming(void) { if (_modemName.indexOf(F("SIMCom SIM800")) >= 0) @@ -1163,7 +1023,7 @@ void loggerModem::setModemTiming(void) MS_DBG(F("Putting connection values into flash memory for the Digi XBee")); _statusTime_ms = 15; // ??? WAG! // XBee saves all configurations to flash, so we can set them here - if (_tinyModem->hasWifi()) _tinyModem->networkConnect(_ssid, _pwd); else _tinyModem->gprsConnect(_apn, "", ""); } } +***/ diff --git a/src/LoggerModem.h b/src/LoggerModem.h index f252c0727..2970a83e5 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -25,41 +25,11 @@ #include "VariableBase.h" #include "SensorBase.h" #include -#include +#include #define MODEM_NUM_VARIABLES 2 -// Set some default timing variables for the modems. -// Some of these times are reset for specific modems in the modem set-up function -// based on the values in the modem chip's datasheet. - -// Length of time after power is applied to module before the enable pin can be -// called to turn on the module or other wake fxn can be used. If the module -// boots up as soon as power is applied, this value is 0. -// This is used as the sensor variable _warmUpTime_ms. -#define MODEM_WARM_UP_TIME_MS 50 -// Length of time from the completion of wake up function until UART port becomes -// available for AT commands. This is the MAXIMUM amount of time we will wait -// for a response from the modem. -// This is used as the sensor variable _stabilizationTime_ms. -#define MODEM_ATRESPONSE_TIME_MS 5000L -// The maximum amount of time we are willing to wait for a network connection -// before accepting the modem signal strength. Most modems do not give -// real signal strength until they've connected to the network, which takes -// more time in areas of weaker signal. -// This is used as the sensor variable _measurementTime_ms. -#define MODEM_MAX_SEARCH_TIME 15000L -// Length of time from the completion of wake up request until the modem status -// pin begins to show an "on" status. -// This is the modem-only variable _statusTime_ms. -#define MODEM_STATUS_TIME_MS 5000 -// Approximate length of time for unit to gracefully close sockets and disconnect -// from the network. Most manufactures strongly recommend allowing a graceful -// shut-down rather than a sudden power-off. -// This is the modem-only variable _disconnetTime_ms. -#define MODEM_DISCONNECT_TIME_MS 5000 - #define RSSI_VAR_NUM 0 #define RSSI_RESOLUTION 0 @@ -78,35 +48,12 @@ class loggerModem : public Sensor // ==========================================================================// public: // Constructors - // Note: The client for the TinyGSM Modem is needed as an input because - // the tiny GSM client class is a subclass of the unique modem class, not - // of the generalized modem class. That means the client cannot be create - // until the specific modem is defined. So the user must first create the - // specific modem in their sketch, create that modem's client, and then - // feed that client back in here. The TinyGSM library has a bunch of - // typedef's in the TinyGsmClient.h that make this somewhat invisible to - // the user. - loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, - int8_t modemResetPin, - bool (*modemWakeFxn)(), bool (*modemSleepFxn)(), - TinyGsmModem *inModem, Client *inClient, const char *APN); - - loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, - int8_t modemResetPin, - bool (*modemWakeFxn)(), bool (*modemSleepFxn)(), - TinyGsmModem *inModem, Client *inClient, const char *ssid, const char *pwd); - - loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, - int8_t modemResetPin, int8_t modemSleepRqPin, - uint16_t max_status_time_ms, uint16_t max_disconnetTime_ms, - uint32_t max_warmUpTime_ms, uint32_t max_atresponse_time_ms, - TinyGsmModem *inModem, Client *inClient, const char *APN); - loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, int8_t modemResetPin, int8_t modemSleepRqPin, - uint16_t max_status_time_ms, uint16_t max_disconnetTime_ms, + uint32_t max_status_time_ms, uint32_t max_disconnetTime_ms, uint32_t max_warmUpTime_ms, uint32_t max_atresponse_time_ms, - TinyGsmModem *inModem, Client *inClient, const char *ssid, const char *pwd); + uint32_t max_signalQuality_time_ms, + uint8_t measurementsToAverage = 1); ~loggerModem(); @@ -123,8 +70,8 @@ class loggerModem : public Sensor void powerDown(void) override; // Turns modem signal strength into a measurement - bool startSingleMeasurement(void) override; - bool addSingleMeasurementResult(void) override; + virtual bool startSingleMeasurement(void) override; + virtual bool addSingleMeasurementResult(void) = 0; protected: // We override these because the modem can tell us if it's ready or not @@ -133,10 +80,6 @@ class loggerModem : public Sensor // For a WiFi modem, this actually sets the network connection parameters!! bool isStable(bool debug=false) override; - // The a measurement is "complete" when the modem is registered on the network. - // For a cellular modem, this actually sets the GPRS bearer/APN!! - bool isMeasurementComplete(bool debug=false) override; - // ==========================================================================// // These are the unique functions for the modem as an internet connected device @@ -154,7 +97,7 @@ class loggerModem : public Sensor Client * getClient(void){return _tinyClient;} // Access the internet - virtual bool connectInternet(uint32_t waitTime_ms = 50000L) = 0; + virtual bool connectInternet(uint32_t maxConnectionTime = 50000L) = 0; virtual void disconnectInternet(void) = 0; // This has the same functionality as Client->connect with debugging text @@ -170,11 +113,10 @@ class loggerModem : public Sensor // Get the time from NIST via TIME protocol (rfc868) // This would be much more efficient if done over UDP, but I'm doing it // over TCP because I don't have a UDP library for all the modems. - uint32_t getNISTTime(void); + virtual uint32_t getNISTTime(void) = 0; public: // All of these must be pointers - these are all abstract classes! - TinyGsmModem *_tinyModem; Client *_tinyClient; protected: @@ -184,24 +126,28 @@ class loggerModem : public Sensor static int16_t getPctFromCSQ(int16_t csq); // Helper to get signal percent from CSQ static int16_t getPctFromRSSI(int16_t rssi); + + // Other helper functions + void modemLEDOn(void); + void modemLEDOff(void); + virtual bool didATRespond(void) = 0; + virtual bool modemSleepFxn(void) = 0; + virtual bool modemWakeFxn(void) = 0; + virtual bool extraModemSetup(void) = 0; + // Helper to set the timing for specific cellular chipsets based on their documentation - void setModemTiming(void); + // void setModemTiming(void); protected: - bool (*_modemWakeFxn)(void); - bool (*_modemSleepFxn)(void); int8_t _modemSleepRqPin; int8_t _modemResetPin; int8_t _modemLEDPin; bool _statusLevel; - uint16_t _statusTime_ms; - uint16_t _disconnetTime_ms; + uint32_t _statusTime_ms; + uint32_t _disconnetTime_ms; - const char *_apn; - const char *_ssid; - const char *_pwd; uint32_t _lastNISTrequest; uint32_t _lastATCheck; uint32_t _lastConnectionCheck; diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index d0012c753..5a57cfa58 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -313,7 +313,8 @@ void Sensor::notifyVariables(void) variables[i]->getVarName(), F("...")); variables[i]->onSensorUpdate(this); } - else MS_DBG(F("No variable registered for return value"), i, + else MS_DBG(getSensorNameAndLocation(), + F("has no variable registered for return value"), i, F("! No update sent!")); } } diff --git a/src/modems/DigiXBee.cpp b/src/modems/DigiXBee.cpp index d0fd5f095..2c0dc6335 100644 --- a/src/modems/DigiXBee.cpp +++ b/src/modems/DigiXBee.cpp @@ -4,7 +4,7 @@ * *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). * - *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module + *This file is for all Digi XBee's */ // Included Dependencies @@ -13,241 +13,22 @@ // Constructor DigiXBee::DigiXBee(int8_t powerPin, int8_t statusPin, bool useCTSStatus, - int8_t modemResetPin, int8_t modemSleepRqPin, - TinyGsmModem *inModem, Client *inClient, const char *ssid, const char *pwd) + int8_t modemResetPin, int8_t modemSleepRqPin, + uint8_t measurementsToAverage) : loggerModem(powerPin, statusPin, !useCTSStatus, modemResetPin, modemSleepRqPin, XBEE_STATUS_TIME_MS, XBEE_DISCONNECT_TIME_MS, XBEE_WARM_UP_TIME_MS, XBEE_ATRESPONSE_TIME_MS, - inModem, inClient, ssid, pwd) + XBEE_SIGNALQUALITY_TIME_MS, + measurementsToAverage) {} -bool DigiXBee::setup(void) -{ - bool success = Sensor::setup(); // this will set pin modes and the setup status bit - - // Initialize the modem - MS_DBG(F("Setting up the XBee ...")); - - // Bail if there's no power - if (!checkPowerOn()) - { - MS_DBG(F("XBee doesn't have power and cannot be set-up!")); - return false; - } - - // Check if the modem was awake, wake it if not - // NOTE: We ar NOT powering up the modem! Set up will NOT be successful - // unless the modem is already powered external to this function. - bool wasAwake = ( (_dataPin >= 0 && digitalRead(_dataPin) == _statusLevel) - || bitRead(_sensorStatus, 4) ); - if (!wasAwake) - { - waitForWarmUp(); - MS_DBG(F("Turning on the XBee ...")); - success &= wake(); - } - else MS_DBG(F("XBee was already awake.")); - - if (success) - { - // The begin() generally starts with a 5 second testAT(), that should - // be enough time to allow any modem to be ready to respond - MS_DBG(F("Running XBee's begin function ...")); - success &= _tinyModem->begin(); - _modemName = _tinyModem->getModemName(); - success &= extraXBeeSetup(); - if (success) MS_DBG(F("... Complete! It's a"), getSensorName()); - else MS_DBG(F("... Failed! It's a"), getSensorName()); - } - else MS_DBG(F("... "), getSensorName(), F("did not wake up and cannot be set up!")); - - MS_DBG(_modemName, F("warms up in"), _warmUpTime_ms, F("ms, indicates status in"), - _statusTime_ms, F("ms, is responsive to AT commands in less than"), - _stabilizationTime_ms, F("ms, and takes up to"), _disconnetTime_ms, - F("ms to close connections and shut down.")); - - // XBee saves all configurations to flash, so we can set them here - _tinyModem->networkConnect(_ssid, _pwd); - - // Print out some warnings if things seem to be improperly formatted - if (_tinyModem->hasWifi() && _ssid == NULL) - MS_DBG(F("WARNING: Wifi modem with no SSID given!")); - if (_tinyModem->hasGPRS() && _apn == NULL) - MS_DBG(F("WARNING: Cellular modem with no APN given!")); - - // Set the status bit marking that the modem has been set up (bit 0) - // Only set the bit if setup was successful! - if (success) _sensorStatus |= 0b00000001; - // Otherwise, set the status error bit (bit 7) - else _sensorStatus |= 0b10000000; - - // Put the modem to sleep after finishing setup - // Only go to sleep if it had been asleep and is now awake - bool isAwake = ( (_dataPin >= 0 && digitalRead(_dataPin) == _statusLevel) - || bitRead(_sensorStatus, 4) ); - if (!wasAwake && isAwake) - { - // Run the sleep function - MS_DBG(F("Running given modem sleep function ...")); - success &= _modemSleepFxn(); - } - else MS_DBG(F("Leaving modem on after setup ...")); - // Do NOT power down at the end, because this fxn cannot have powered the - // modem up. - - return success; -} - - -bool DigiXBee::wake(void) -{ - // Sensor::wake() checks if the power pin is on, setup has been successful, - // and sets the wake timestamp and status bits. If it returns false, - // there's no reason to go on. - if (!Sensor::wake()) return false; - // NOTE: This is the ONLY place _millisSensorActivated is set! - // NOTE: This is the ONLY place bit 4 is set! - - bool success = true; - - // Check the status pin and wake bits before running wake function - // Don't want to accidently pulse an already on modem to off - if ( bitRead(_sensorStatus, 4)) - { - MS_DBG(getSensorName(), F("has already been woken up! Will not run wake function.")); - } - // NOTE: It's possible that the status pin is on, but the modem is actually - // mid-shutdown. In that case, we'll mistakenly skip re-waking it. - else if (_dataPin >= 0 && digitalRead(_dataPin) == _statusLevel) - { - MS_DBG(getSensorName(), F("was already on! (status pin level = "), - _statusLevel, F(") Will not run wake function.")); - } - else - { - // Run the input wake function - MS_DBG(F("Running wake function for"), getSensorName()); - success &= XBeeWake(); - } - - // Re-check the status pin - // Only works if the status pin comes on immediately - if (_dataPin > 0 && _statusTime_ms == 0 && digitalRead(_dataPin) != _statusLevel) - { - MS_DBG(F("Status pin level on"), getSensorName(), F("is"), - digitalRead(_dataPin), F("indicating it is off!")); - success = false; - } - - if (success) - { - if (_modemLEDPin >= 0) - { - digitalWrite(_modemLEDPin, HIGH); - } - MS_DBG(getSensorName(), F("should be awake.")); - } - else - { - MS_DBG(getSensorName(), F("failed to wake!")); - // Make sure the activation time is zero and the wake success bit (bit 4) is unset - _millisSensorActivated = 0; - _sensorStatus &= 0b11101111; - } - - return success; -} - - -bool DigiXBee::modemSleepPowerDown(void) -{ - bool success = true; - uint32_t start = millis(); - MS_DBG(F("Turning"), getSensorName(), F("off.")); - - // If there's a status pin available, check before running the sleep function - // NOTE: It's possible that the modem could still be in the process of turning - // on and thus status pin isn't valid yet. In that case, we wouldn't yet - // know it's coming on and so we'd mistakenly assume it's already off and - // not turn it back off. - if (_dataPin >= 0 && digitalRead(_dataPin) != _statusLevel) - MS_DBG(getSensorName(), F("appears to have already been off. Will not run sleep function.")); - // If there's no status pin, check against the status bits - else if (_dataPin < 0 && !bitRead(_sensorStatus, 4)) - MS_DBG(getSensorName(), F("was never sucessfully turned on. Will not run sleep function.")); - else - { - // Run the sleep function - MS_DBG(F("Running given sleep function for"), getSensorName()); - success &= XBeeSleep(); - - if (_modemLEDPin >= 0) - { - digitalWrite(_modemLEDPin, LOW); - } - } - - // Unset the activation time - _millisSensorActivated = 0; - // Unset the measurement request time - _millisMeasurementRequested = 0; - // Unset the status bits for sensor activation (bits 3 & 4) and measurement - // request (bits 5 & 6) - _sensorStatus &= 0b10000111; - - // Now power down - if (_powerPin >= 0) - { - // If there's a status pin available, wait until modem shows it's ready to be powered off - // This allows the modem to shut down gracefully. - if (_dataPin >= 0) - { - MS_DBG(F("Waiting up to"), _disconnetTime_ms, F("milliseconds for graceful shutdown...")); - while (millis() - start < _disconnetTime_ms && digitalRead(_dataPin) == _statusLevel){} - if (digitalRead(_dataPin) == _statusLevel) - MS_DBG(F("... "), getSensorName(), F("did not successfully shut down!")); - else MS_DBG(F("... shutdown complete after"), millis() - start, F("ms.")); - } - else if (_disconnetTime_ms > 0) - { - MS_DBG(F("Waiting"), _disconnetTime_ms, F("ms for graceful shutdown.")); - while (millis() - start < _disconnetTime_ms){} - } - - MS_DBG(F("Turning off power to"), getSensorName(), F("with pin"), _powerPin); - digitalWrite(_powerPin, LOW); - // Unset the power-on time - _millisPowerOn = 0; - // Unset the status bits for sensor power (bits 1 & 2), - // activation (bits 3 & 4), and measurement request (bits 5 & 6) - _sensorStatus &= 0b10000001; - } - else - { - // If we're not going to power the modem down, there's no reason to hold - // up the main processor while waiting for the modem to shut down. - // It can just do its thing unwatched while the main processor sleeps. - MS_DBG(F("Power to"), getSensorName(), F("is not controlled by this library.")); - // Unset the power-on time and bits even if we didn't do anything. - // This prevents the wake from happening on modems with no power pin - // unless modemPowerUp() is called. - _millisPowerOn = 0; - // Unset the status bits for sensor power (bits 1 & 2), - // activation (bits 3 & 4), and measurement request (bits 5 & 6) - _sensorStatus &= 0b10000001; - } - - return success; -} - - // Create the wake and sleep methods for the modem // These can be functions of any type and must return a boolean // After enabling pin sleep, the sleep request pin is held LOW to keep the XBee on // Enable pin sleep in the setup function or using XCTU prior to connecting the XBee -bool DigiXBee::XBeeWake(void) +bool DigiXBee::modemWakeFxn(void) { if (_modemSleepRqPin >= 0) // Don't go to sleep if there's not a wake pin! { @@ -261,7 +42,7 @@ bool DigiXBee::XBeeWake(void) } -bool DigiXBee::XBeeSleep(void) +bool DigiXBee::modemSleepFxn(void) { if (_powerPin >= 0) // Turns on when power is applied return true; @@ -276,35 +57,3 @@ bool DigiXBee::XBeeSleep(void) return true; } } - - -bool DigiXBee::extraXBeeSetup(void) -{ - _tinyModem->init(); // initialize - if (_tinyModem->commandMode()) - { - // Set DIO8 to be used for sleep requests - // NOTE: Only pin 9/DIO8/DTR can be used for this function - _tinyModem->sendAT(F("D8"),1); - _tinyModem->waitResponse(); - // Turn on status indication pin - it will be HIGH when the XBee is awake - // NOTE: Only pin 13/ON/SLEEPnot/DIO9 can be used for this function - _tinyModem->sendAT(F("D9"),1); - _tinyModem->waitResponse(); - // Turn on CTS pin - it will be LOW when the XBee is ready to receive commands - // This can be used as proxy for status indication if the true status pin is not accessible - // NOTE: Only pin 12/DIO7/CTS can be used for this function - _tinyModem->sendAT(F("D7"),1); - _tinyModem->waitResponse(); - // Put the XBee in pin sleep mode - _tinyModem->sendAT(F("SM"),1); - _tinyModem->waitResponse(); - // Disassociate from network for lowest power deep sleep - _tinyModem->sendAT(F("SO"),200); - _tinyModem->waitResponse(); - // Write changes to flash and apply them - _tinyModem->writeChanges(); - // Exit command mode - _tinyModem->exitCommand(); - } -} diff --git a/src/modems/DigiXBee.h b/src/modems/DigiXBee.h index 44a18bb68..273999e69 100644 --- a/src/modems/DigiXBee.h +++ b/src/modems/DigiXBee.h @@ -4,7 +4,7 @@ * *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). * - *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module + *This file is for all Digi XBee's */ // Header Guards @@ -19,21 +19,18 @@ #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates - -// Included Dependencies -#include "ModSensorDebugger.h" -#include "LoggerModem.h" -#include "TinyGsmClient.h" - -#define TINY_GSM_XBEE_XBEE // Select for Digi brand WiFi or Cellular XBee's - #define XBEE_STATUS_TIME_MS 15 #define XBEE_DISCONNECT_TIME_MS 5000L #define XBEE_WARM_UP_TIME_MS 50 #define XBEE_ATRESPONSE_TIME_MS 5000L +#define XBEE_SIGNALQUALITY_TIME_MS 45000L + +// Included Dependencies +#include "ModSensorDebugger.h" +#include "LoggerModem.h" + class DigiXBee : public loggerModem { @@ -41,17 +38,12 @@ class DigiXBee : public loggerModem public: // Constructors DigiXBee(int8_t powerPin, int8_t statusPin, bool useCTSStatus, - int8_t modemResetPin, int8_t modemSleepRqPin, - TinyGsmModem *inModem, Client *inClient, const char *ssid, const char *pwd); - - virtual bool setup(void) override; - virtual bool wake(void) override; - virtual bool modemSleepPowerDown(void); + int8_t modemResetPin, int8_t modemSleepRqPin, + uint8_t measurementsToAverage = 1); protected: - virtual bool XBeeWake(void); - virtual bool XBeeSleep(void); - virtual bool extraXBeeSetup(void) = 0; + virtual bool modemSleepFxn(void) override; + virtual bool modemWakeFxn(void) override; }; diff --git a/src/modems/DigiXBeeCellularBypass.cpp b/src/modems/DigiXBeeCellularBypass.cpp new file mode 100644 index 000000000..a6636f224 --- /dev/null +++ b/src/modems/DigiXBeeCellularBypass.cpp @@ -0,0 +1,357 @@ +/* + *DigiXBeeCellularBypass.cpp + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is for Digi Cellular XBee's BASED ON UBLOX CHIPS in bypass mode +*/ + +// Included Dependencies +#include "DigiXBeeCellularBypass.h" + +// Constructors +DigiXBeeCellularBypass::DigiXBeeCellularBypass(Stream* modemStream, + int8_t powerPin, int8_t statusPin, bool useCTSStatus, + int8_t modemResetPin, int8_t modemSleepRqPin, + const char *apn, + uint8_t measurementsToAverage) + : DigiXBee(powerPin, statusPin, useCTSStatus, + modemResetPin, modemSleepRqPin, + measurementsToAverage), + _tinyModem(*modemStream) +{ + _apn = apn; + TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); + _tinyClient = tinyClient; +} + + +bool DigiXBeeCellularBypass::didATRespond(void) +{ + return _tinyModem.testAT(10); +} + + +bool DigiXBeeCellularBypass::extraModemSetup(void) +{ + bool success = true; + delay(1010); // Wait the required guard time before entering command mode + _tinyModem.streamWrite(GF("+++")); // enter command mode + if (success &= _tinyModem.waitResponse(2000, F("OK\r")) == 1) + { + // Set DIO8 to be used for sleep requests + // NOTE: Only pin 9/DIO8/DTR can be used for this function + _tinyModem.sendAT(F("D8"),1); + success &= _tinyModem.waitResponse(F("OK\r")) == 1; + // Turn on status indication pin - it will be HIGH when the XBee is awake + // NOTE: Only pin 13/ON/SLEEPnot/DIO9 can be used for this function + _tinyModem.sendAT(F("D9"),1); + success &= _tinyModem.waitResponse(F("OK\r")) == 1; + // Turn on CTS pin - it will be LOW when the XBee is ready to receive commands + // This can be used as proxy for status indication if the true status pin is not accessible + // NOTE: Only pin 12/DIO7/CTS can be used for this function + _tinyModem.sendAT(F("D7"),1); + success &= _tinyModem.waitResponse(F("OK\r")) == 1; + // Put the XBee in pin sleep mode + _tinyModem.sendAT(F("SM"),1); + success &= _tinyModem.waitResponse(F("OK\r")) == 1; + // Disassociate from network for lowest power deep sleep + _tinyModem.sendAT(F("SO"),0); + success &= _tinyModem.waitResponse(F("OK\r")) == 1; + // Disable remote manager, USB Direct, and LTE PSM + // NOTE: LTE-M's PSM (Power Save Mode) sounds good, but there's no + // easy way on the LTE-M Bee to wake the cell chip itself from PSM, + // so we'll use the Digi pin sleep instead. + _tinyModem.sendAT(F("DO"),0); + success &= _tinyModem.waitResponse(F("OK\r")) == 1; + // Make sure USB direct won't be pin enabled on XBee3 units + _tinyModem.sendAT(F("P0"),0); + success &= _tinyModem.waitResponse(F("OK\r")) == 1; + // Make sure pins 7&8 are not set for USB direct on XBee3 units + _tinyModem.sendAT(F("P1"),0); + success &= _tinyModem.waitResponse(F("OK\r")) == 1; + // Cellular carrier profile - AT&T + // Hologram says they can use any network, but I've never succeeded with anything but AT&T + _tinyModem.sendAT(F("CP"),2); + success &= _tinyModem.waitResponse(F("OK\r")) == 1; + // Cellular network technology - LTE-M Only + // LTE-M XBee connects much faster on AT&T/Hologram when set to LTE-M only (instead of LTE-M/NB IoT) + _tinyModem.sendAT(F("N#"),2); + success &= _tinyModem.waitResponse(F("OK\r")) == 1; + // Turn on bypass mode + _tinyModem.sendAT(F("AP5")); + success &= _tinyModem.waitResponse(F("OK\r")) == 1; + // Write changes to flash + _tinyModem.sendAT(F("WR")); + success &= _tinyModem.waitResponse(F("OK\r")) == 1; + // Apply changes + _tinyModem.sendAT(F("AC")); + success &= _tinyModem.waitResponse(F("OK\r")) == 1; + // Force reset to actually enter bypass mode - this effectively exits bypass mode + _tinyModem.sendAT(F("FR")); + success &= _tinyModem.waitResponse(F("OK\r")) == 1; + // initialize + success &= _tinyModem.init(); + _modemName = _tinyModem.getModemName(); + } + else success = false; + return success; +} + + +// This checks to see if enough time has passed for measurement completion +// In the case of the modem, we consider a measurement to be "complete" when +// the modem has registered on the network *and* returns good signal strength. +// In theory, both of these things happen at the same time - as soon as the +// module detects a network with sufficient signal strength, it connects and +// will respond corretly to requests for its connection status and the signal +// strength. In reality sometimes the modem might respond with successful +// network connection before it responds with a valid signal strength or it +// might be able to return a real measurement of cellular signal strength but +// not be able to register to the network. We'd prefer to wait until it both +// responses are good so we're getting an actual signal strength and it's as +// close as possible to what the antenna is will see when the data publishers +// push data. +bool DigiXBeeCellularBypass::isMeasurementComplete(bool debug) +{ + #if defined MS_DIGIXBEECELLULARBYPASS_DEBUG + debug = true; + #endif + // If a measurement failed to start, the sensor will never return a result, + // so the measurement time is essentially already passed + // For a cellular modem nothing happens to "start" a measurement so bit 6 + // will be set by startSingleMeasurement() as long as bit 4 was set by wake(). + // For a WiFi modem, startSingleMeasurement actually sets the WiFi connection + // parameters. + if (!bitRead(_sensorStatus, 6)) + { + if (debug) {MS_DBG(getSensorName(), + F("is not measuring and will not return a value!"));} + return true; + } + + // just defining this to not call multiple times below + uint32_t now = millis(); + + // We don't want to ping any of the modems too fast so they don't get + // overwhelmed. Make sure we've waited a little + if (now - _lastConnectionCheck < 250) return false; + + // Check how long we've been waiting for the network connection and/or a + // good measurement of signal quality. + uint32_t elapsed_in_wait; + + // Cellular modems and wifi modems with the connection paramters always + // saved to flash (like XBees) begin searching for and attempt to register + // to the network as soon as they are awake - the GPRS paramters that need + // to be set to actually *use* the network don't have to be set until we + // make the attempt to use it. + elapsed_in_wait = now - _millisSensorActivated; + + // If we're connected AND receiving valid signal strength, measurement is complete + // In theory these happen at the same time, but in reality one or the other + // may happen first. + bool isConnected = _tinyModem.isNetworkConnected(); + int signalResponse = _tinyModem.getSignalQuality(); + if (isConnected && signalResponse != 0 && signalResponse != 99) + { + if (debug) MS_DBG(F("It's been"), (elapsed_in_wait), F("ms, and"), + getSensorName(), F("is now registered on the network and reporting valid signal strength!")); + _lastConnectionCheck = now; + return true; + } + + // If we've exceeded the allowed time to wait for the network, give up + if (elapsed_in_wait > XBEE_SIGNALQUALITY_TIME_MS) + { + if (debug) MS_DBG(F("It's been"), (elapsed_in_wait), F("ms, and"), + getSensorName(), F("has maxed out wait for network registration! Ending wait.")); + // Leave status bits and times set - can still get a valid value! + return true; + } + + // If the modem isn't registered yet or doesn't report valid signal, we still need to wait + _lastConnectionCheck = now; + return false; +} + + +bool DigiXBeeCellularBypass::addSingleMeasurementResult(void) +{ + bool success = true; + + // Initialize float variable + int16_t signalQual = -9999; + int16_t percent = -9999; + int16_t rssi = -9999; + + // Check a measurement was *successfully* started (status bit 6 set) + // Only go on to get a result if it was + if (bitRead(_sensorStatus, 6)) + { + + // Get signal quality + // NOTE: We can't actually distinguish between a bad modem response, no + // modem response, and a real response from the modem of no service/signal. + // The TinyGSM getSignalQuality function returns the same "no signal" + // value (99 CSQ or 0 RSSI) in all 3 cases. + MS_DBG(F("Getting signal quality:")); + signalQual = _tinyModem.getSignalQuality(); + MS_DBG(F("Raw signal quality:"), signalQual); + + // Convert signal quality to RSSI, if necessary + rssi = getRSSIFromCSQ(signalQual); + percent = getPctFromCSQ(signalQual); + + MS_DBG(F("RSSI:"), rssi); + MS_DBG(F("Percent signal strength:"), percent); + } + else MS_DBG(getSensorName(), F("is not connected to the network; unable to get signal quality!")); + + verifyAndAddMeasurementResult(RSSI_VAR_NUM, rssi); + verifyAndAddMeasurementResult(PERCENT_SIGNAL_VAR_NUM, percent); + + // Unset the time stamp for the beginning of this measurement + _millisMeasurementRequested = 0; + // Unset the status bits for a measurement request (bits 5 & 6) + _sensorStatus &= 0b10011111; + + return success; +} + + +bool DigiXBeeCellularBypass::connectInternet(uint32_t maxConnectionTime) +{ + bool retVal = true; + + if (bitRead(_sensorStatus, 1) == 0 || bitRead(_sensorStatus, 2) == 0) // NOT yet powered + { + modemPowerUp(); + } + if (bitRead(_sensorStatus, 3) == 0) // No attempts yet to wake the modem + { + waitForWarmUp(); + retVal &= wake(); + } + if (bitRead(_sensorStatus, 0) == 0) // Not yet setup + { + retVal &= setup(); // Set-up if necessary + } + if (!retVal) + { + MS_DBG(F("Modem did't wake up! Cannot connect to the internet!")); + return retVal; + } + + // Check that the modem is responding to AT commands. If not, give up. + #if defined MS_DIGIXBEECELLULARBYPASS_DEBUG + uint32_t start = millis(); + #endif + MS_DBG(F("\nWaiting for"), getSensorName(), F("to respond to AT commands...")); + if (!_tinyModem.testAT(_stabilizationTime_ms + 500)) + { + MS_DBG(F("No response to AT commands! Cannot connect to the internet!")); + return false; + } + else MS_DBG(F("... AT OK after"), millis() - start, F("milliseconds!")); + + MS_DBG(F("\nWaiting up to"), maxConnectionTime/1000, + F("seconds for cellular network registration...")); + if (_tinyModem.waitForNetwork(maxConnectionTime)) + { + MS_DBG(F("... Registered after"), millis() - start, + F("milliseconds. Connecting to GPRS...")); + _tinyModem.gprsConnect(_apn, "", ""); + MS_DBG(F("... Connected after"), millis() - start, + F("milliseconds.")); + retVal = true; + } + else + { + MS_DBG(F("...GPRS connection failed.")); + return false; + } + return retVal; +} + + +void DigiXBeeCellularBypass::disconnectInternet(void) +{ + #if defined MS_DIGIXBEECELLULARBYPASS_DEBUG + uint32_t start = millis(); + #endif + _tinyModem.gprsDisconnect(); + MS_DBG(F("Disconnected from cellular network after"), millis() - start, + F("milliseconds.")); +} + + + +// Get the time from NIST via TIME protocol (rfc868) +// This would be much more efficient if done over UDP, but I'm doing it +// over TCP because I don't have a UDP library for all the modems. +uint32_t DigiXBeeCellularBypass::getNISTTime(void) +{ + // bail if not connected to the internet + if (!_tinyModem.isGprsConnected()) + { + MS_DBG(F("No internet connection, cannot connect to NIST.")); + return 0; + } + + // Must ensure that we do not ping the daylight more than once every 4 seconds + // NIST clearly specifies here that this is a requirement for all software + // that accesses its servers: https://tf.nist.gov/tf-cgi/servers.cgi + while (millis() < _lastNISTrequest + 4000) {} + + // Make TCP connection + MS_DBG(F("Connecting to NIST daytime Server")); + bool connectionMade = false; + connectionMade = _tinyClient->connect("time.nist.gov", 37); + + // Wait up to 5 seconds for a response + if (connectionMade) + { + long start = millis(); + while (_tinyClient && _tinyClient->available() < 4 && millis() - start < 5000L){} + + if (_tinyClient->available() >= 4) + { + MS_DBG(F("\nNIST responded after"), millis() - start, F("ms")); + // Response is returned as 32-bit number as soon as connection is made + // Connection is then immediately closed, so there is no need to close it + uint32_t secFrom1900 = 0; + byte response[4] = {0}; + for (uint8_t i = 0; i < 4; i++) + { + response[i] = _tinyClient->read(); + MS_DBG(F("\nResponse Byte"), i, ':', (char)response[i], + '=', response[i], '=', String(response[i], BIN)); + secFrom1900 += 0x000000FF & response[i]; + // MS_DBG(F("\nseconds from 1900 after byte:"),String(secFrom1900, BIN)); + if (i+1 < 4) {secFrom1900 = secFrom1900 << 8;} + } + MS_DBG(F("\nSeconds from 1900 returned by NIST (UTC):"), + secFrom1900, '=', String(secFrom1900, BIN)); + + // Close the TCP connection, just in case + _tinyClient->stop(); + + // Return the timestamp + uint32_t unixTimeStamp = secFrom1900 - 2208988800; + MS_DBG(F("\nUnix Timestamp returned by NIST (UTC):"), unixTimeStamp); + // If before Jan 1, 2017 or after Jan 1, 2030, most likely an error + if (unixTimeStamp < 1483228800) return 0; + else if (unixTimeStamp > 1893456000) return 0; + else return unixTimeStamp; + } + else + { + MS_DBG(F("NIST Time server did not respond!")); + return 0; + } + } + else MS_DBG(F("Unable to open TCP to NIST!")); + return 0; +} diff --git a/src/modems/DigiXBeeCellularBypass.h b/src/modems/DigiXBeeCellularBypass.h index 8ecc9971b..6e7c62075 100644 --- a/src/modems/DigiXBeeCellularBypass.h +++ b/src/modems/DigiXBeeCellularBypass.h @@ -1,175 +1,62 @@ /* - *DigiXBeeCellular.h + *DigiXBeeCellularBypass.h *This file is part of the EnviroDIY modular sensors library for Arduino * *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). * - *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module + *This file is for Digi Cellular XBee's BASED ON UBLOX CHIPS in bypass mode */ // Header Guards -#ifndef ModularSensorsSpecificModem_h -#define ModularSensorsSpecificModem_h +#ifndef DigiXBeeCellularBypass_h +#define DigiXBeeCellularBypass_h // Debugging Statement -// #define MS_DIGIXBEECELLULAR_DEBUG +// #define MS_DIGIXBEECELLULARBYPASS_DEBUG -#ifdef MS_DIGIXBEECELLULAR_DEBUG +#ifdef MS_DIGIXBEECELLULARBYPASS_DEBUG #define MS_DEBUGGING_STD #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates +#define TINY_GSM_MODEM_UBLOX // Included Dependencies -#include "ModSensorDebugger.h" -#include "LoggerModem.h" +#include "DigiXBee.h" +#include "TinyGsmClient.h" -// ========================================================================== -// Wifi/Cellular Modem Main Chip Selection -// ========================================================================== - -// Select your modem chip - this determines the exact commands sent to it -#define TINY_GSM_MODEM_UBLOX // Select for Digi brand WiFi or Cellular XBee's - - -// ========================================================================== -// Modem Pins -// ========================================================================== - -// Declare the existance of modem pin Variables -// Use the "extern" keyword to denote that these will actually be defined in -// the main program rather than in this file. - -extern const int8_t modemVccPin; -extern const int8_t modemSleepRqPin; -extern const int8_t modemStatusPin; -extern const int8_t modemResetPin; -extern const int8_t modemLEDPin; -extern Stream &modemSerial; +class DigiXBeeCellularBypass : public DigiXBee +{ -// ========================================================================== -// TinyGSM Client -// ========================================================================== +public: + // Constructors + DigiXBeeCellularBypass(Stream* modemStream, + int8_t powerPin, int8_t statusPin, bool useCTSStatus, + int8_t modemResetPin, int8_t modemSleepRqPin, + const char *apn, + uint8_t measurementsToAverage = 1); -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates -// Include TinyGSM for the modem -// This include must be included below the define of the modem name! -#include + // The a measurement is "complete" when the modem is registered on the network. + // For a cellular modem, this actually sets the GPRS bearer/APN!! + bool isMeasurementComplete(bool debug=false) override; + bool addSingleMeasurementResult(void) override; -// Create a new TinyGSM modem to run on that serial port and return a pointer to it -TinyGsm *tinyModem = new TinyGsm(modemSerial); + bool connectInternet(uint32_t maxConnectionTime = 50000L) override; + void disconnectInternet(void) override; -// Create a new TCP client on that modem and return a pointer to it -TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); + uint32_t getNISTTime(void) override; + bool didATRespond(void) override; + bool extraModemSetup(void) override; -// ========================================================================== -// Specific Modem On-Off Methods -// ========================================================================== -// Describe the physical pin connection of your modem to your board -const bool modemStatusLevel = LOW; // The level of the status pin when the module is active (HIGH or LOW) + TinyGsm _tinyModem; -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -// After enabling pin sleep, the sleep request pin is held LOW to keep the XBee on -// Enable pin sleep in the setup function or using XCTU prior to connecting the XBee -bool modemSleepFxn(void) -{ - if (modemSleepRqPin >= 0) // Don't go to sleep if there's not a wake pin! - { - digitalWrite(modemSleepRqPin, HIGH); - digitalWrite(modemLEDPin, LOW); - return true; - } - else - { - return true; - } -} - - -bool modemWakeFxn(void) -{ - if (modemVccPin >= 0) // Turns on when power is applied - return true; - else if (modemSleepRqPin >= 0) - { - digitalWrite(modemSleepRqPin, LOW); - digitalWrite(modemLEDPin, HIGH); // Because the XBee doesn't have any lights - return true; - } - else - { - return true; - } -} - - -void extraModemSetup(void) -{ - delay(1010); // Wait the required guard time before entering command mode - tinyModem->streamWrite(GF("+++")); // enter command mode - if (tinyModem->waitResponse(2000, F("OK\r")) == 1); - { - // Set DIO8 to be used for sleep requests - // NOTE: Only pin 9/DIO8/DTR can be used for this function - tinyModem->sendAT(F("D8"),1); - tinyModem->waitResponse(F("OK\r")); - // Turn on status indication pin - it will be HIGH when the XBee is awake - // NOTE: Only pin 13/ON/SLEEPnot/DIO9 can be used for this function - tinyModem->sendAT(F("D9"),1); - tinyModem->waitResponse(F("OK\r")); - // Turn on CTS pin - it will be LOW when the XBee is ready to receive commands - // This can be used as proxy for status indication if the true status pin is not accessible - // NOTE: Only pin 12/DIO7/CTS can be used for this function - tinyModem->sendAT(F("D7"),1); - tinyModem->waitResponse(F("OK\r")); - // Put the XBee in pin sleep mode - tinyModem->sendAT(F("SM"),1); - tinyModem->waitResponse(F("OK\r")); - // Disassociate from network for lowest power deep sleep - tinyModem->sendAT(F("SO"),0); - tinyModem->waitResponse(F("OK\r")); - // Disable remote manager, USB Direct, and LTE PSM - // NOTE: LTE-M's PSM (Power Save Mode) sounds good, but there's no - // easy way on the LTE-M Bee to wake the cell chip itself from PSM, - // so we'll use the Digi pin sleep instead. - tinyModem->sendAT(F("DO"),0); - tinyModem->waitResponse(F("OK\r")); - // Make sure USB direct won't be pin enabled on XBee3 units - tinyModem->sendAT(F("P0"),0); - tinyModem->waitResponse(F("OK\r")); - // Make sure pins 7&8 are not set for USB direct on XBee3 units - tinyModem->sendAT(F("P1"),0); - tinyModem->waitResponse(F("OK\r")); - // Cellular carrier profile - AT&T - // Hologram says they can use any network, but I've never succeeded with anything but AT&T - tinyModem->sendAT(F("CP"),2); - tinyModem->waitResponse(F("OK\r")); - // Cellular network technology - LTE-M Only - // LTE-M XBee connects much faster on AT&T/Hologram when set to LTE-M only (instead of LTE-M/NB IoT) - tinyModem->sendAT(F("N#"),2); - tinyModem->waitResponse(F("OK\r")); - // Turn on bypass mode - tinyModem->sendAT(F("AP5")); - tinyModem->waitResponse(F("OK\r")); - // Write changes to flash - tinyModem->sendAT(F("WR")); - tinyModem->waitResponse(F("OK\r")); - // Apply changes - tinyModem->sendAT(F("AC")); - tinyModem->waitResponse(F("OK\r")); - // Force reset to actually enter bypass mode - this effectively exits bypass mode - tinyModem->sendAT(F("FR")); - tinyModem->waitResponse(F("OK\r")); - // initialize - tinyModem->init(); - } -} + private: + const char *_apn; +}; #endif diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp new file mode 100644 index 000000000..58395f237 --- /dev/null +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -0,0 +1,344 @@ +/* + *DigiXBeeCellularTransparent.cpp + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is for Digi Cellular XBee's +*/ + +// Included Dependencies +#include "DigiXBeeCellularTransparent.h" + +// Constructors +DigiXBeeCellularTransparent::DigiXBeeCellularTransparent(Stream* modemStream, + int8_t powerPin, int8_t statusPin, bool useCTSStatus, + int8_t modemResetPin, int8_t modemSleepRqPin, + const char *apn, + uint8_t measurementsToAverage) + : DigiXBee(powerPin, statusPin, useCTSStatus, + modemResetPin, modemSleepRqPin, + measurementsToAverage), + _tinyModem(*modemStream, modemResetPin) +{ + _apn = apn; + TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); + _tinyClient = tinyClient; +} + + +bool DigiXBeeCellularTransparent::didATRespond(void) +{ + return _tinyModem.testAT(10); +} + + +bool DigiXBeeCellularTransparent::extraModemSetup(void) +{ + bool success = true; + success &= _tinyModem.init(); // initialize + _modemName = _tinyModem.getModemName(); + if (_tinyModem.commandMode()) + { + // Set DIO8 to be used for sleep requests + // NOTE: Only pin 9/DIO8/DTR can be used for this function + _tinyModem.sendAT(F("D8"),1); + success &= _tinyModem.waitResponse() == 1; + // Turn on status indication pin - it will be HIGH when the XBee is awake + // NOTE: Only pin 13/ON/SLEEPnot/DIO9 can be used for this function + _tinyModem.sendAT(F("D9"),1); + success &= _tinyModem.waitResponse() == 1; + // Turn on CTS pin - it will be LOW when the XBee is ready to receive commands + // This can be used as proxy for status indication if the true status pin is not accessible + // NOTE: Only pin 12/DIO7/CTS can be used for this function + _tinyModem.sendAT(F("D7"),1); + success &= _tinyModem.waitResponse() == 1; + // Put the XBee in pin sleep mode + _tinyModem.sendAT(F("SM"),1); + success &= _tinyModem.waitResponse() == 1; + // Disassociate from network for lowest power deep sleep + _tinyModem.sendAT(F("SO"),0); + success &= _tinyModem.waitResponse() == 1; + // Disable remote manager, USB Direct, and LTE PSM + // NOTE: LTE-M's PSM (Power Save Mode) sounds good, but there's no + // easy way on the LTE-M Bee to wake the cell chip itself from PSM, + // so we'll use the Digi pin sleep instead. + _tinyModem.sendAT(F("DO"),0); + success &= _tinyModem.waitResponse() == 1; + // Make sure USB direct won't be pin enabled on XBee3 units + _tinyModem.sendAT(F("P0"),0); + success &= _tinyModem.waitResponse() == 1; + // Make sure pins 7&8 are not set for USB direct on XBee3 units + _tinyModem.sendAT(F("P1"),0); + success &= _tinyModem.waitResponse() == 1; + // Cellular carrier profile - AT&T + // Hologram says they can use any network, but I've never succeeded with anything but AT&T + _tinyModem.sendAT(F("CP"),2); + success &= _tinyModem.waitResponse() == 1; + // Cellular network technology - LTE-M Only + // LTE-M XBee connects much faster on AT&T/Hologram when set to LTE-M only (instead of LTE-M/NB IoT) + _tinyModem.sendAT(F("N#"),2); + success &= _tinyModem.waitResponse() == 1; + // Put the network connection parameters into flash + success &= _tinyModem.gprsConnect(_apn); + // Write changes to flash and apply them + _tinyModem.writeChanges(); + // Exit command mode + _tinyModem.exitCommand(); + } + else success = false; + return success; +} + + +// This checks to see if enough time has passed for measurement completion +// In the case of the modem, we consider a measurement to be "complete" when +// the modem has registered on the network *and* returns good signal strength. +// In theory, both of these things happen at the same time - as soon as the +// module detects a network with sufficient signal strength, it connects and +// will respond corretly to requests for its connection status and the signal +// strength. In reality sometimes the modem might respond with successful +// network connection before it responds with a valid signal strength or it +// might be able to return a real measurement of cellular signal strength but +// not be able to register to the network. We'd prefer to wait until it both +// responses are good so we're getting an actual signal strength and it's as +// close as possible to what the antenna is will see when the data publishers +// push data. +bool DigiXBeeCellularTransparent::isMeasurementComplete(bool debug) +{ + #if defined MS_DIGIXBEECELLULARTRANSPARENT_DEBUG + debug = true; + #endif + // If a measurement failed to start, the sensor will never return a result, + // so the measurement time is essentially already passed + // For a cellular modem nothing happens to "start" a measurement so bit 6 + // will be set by startSingleMeasurement() as long as bit 4 was set by wake(). + // For a Cellular modem, startSingleMeasurement actually sets the Cellular connection + // parameters. + if (!bitRead(_sensorStatus, 6)) + { + if (debug) {MS_DBG(getSensorName(), + F("is not measuring and will not return a value!"));} + return true; + } + + // just defining this to not call multiple times below + uint32_t now = millis(); + + // We don't want to ping any of the modems too fast so they don't get + // overwhelmed. Make sure we've waited a little + if (now - _lastConnectionCheck < 250) return false; + + // Check how long we've been waiting for the network connection and/or a + // good measurement of signal quality. + uint32_t elapsed_in_wait; + + // Cellular modems and wifi modems with the connection paramters always + // saved to flash (like XBees) begin searching for and attempt to register + // to the network as soon as they are awake - the GPRS paramters that need + // to be set to actually *use* the network don't have to be set until we + // make the attempt to use it. + elapsed_in_wait = now - _millisSensorActivated; + + // If we're connected AND receiving valid signal strength, measurement is complete + // In theory these happen at the same time, but in reality one or the other + // may happen first. + bool isConnected = _tinyModem.isNetworkConnected(); + int signalResponse = _tinyModem.getSignalQuality(); + if (isConnected && signalResponse != 0 && signalResponse != 99) + { + if (debug) MS_DBG(F("It's been"), (elapsed_in_wait), F("ms, and"), + getSensorName(), F("is now registered on the network and reporting valid signal strength!")); + _lastConnectionCheck = now; + return true; + } + + // If we've exceeded the allowed time to wait for the network, give up + if (elapsed_in_wait > XBEE_SIGNALQUALITY_TIME_MS) + { + if (debug) MS_DBG(F("It's been"), (elapsed_in_wait), F("ms, and"), + getSensorName(), F("has maxed out wait for network registration! Ending wait.")); + // Leave status bits and times set - can still get a valid value! + return true; + } + + // If the modem isn't registered yet or doesn't report valid signal, we still need to wait + _lastConnectionCheck = now; + return false; +} + + +bool DigiXBeeCellularTransparent::addSingleMeasurementResult(void) +{ + bool success = true; + + // Initialize float variable + int16_t signalQual = -9999; + int16_t percent = -9999; + int16_t rssi = -9999; + + // Check a measurement was *successfully* started (status bit 6 set) + // Only go on to get a result if it was + if (bitRead(_sensorStatus, 6)) + { + // Get signal quality + // NOTE: We can't actually distinguish between a bad modem response, no + // modem response, and a real response from the modem of no service/signal. + // The TinyGSM getSignalQuality function returns the same "no signal" + // value (99 CSQ or 0 RSSI) in all 3 cases. + MS_DBG(F("Getting signal quality:")); + signalQual = _tinyModem.getSignalQuality(); + MS_DBG(F("Raw signal quality:"), signalQual); + + // Convert signal quality to RSSI + rssi = signalQual; + percent = getPctFromRSSI(signalQual); + + MS_DBG(F("RSSI:"), rssi); + MS_DBG(F("Percent signal strength:"), percent); + } + else MS_DBG(getSensorName(), F("is not connected to the network; unable to get signal quality!")); + + verifyAndAddMeasurementResult(RSSI_VAR_NUM, rssi); + verifyAndAddMeasurementResult(PERCENT_SIGNAL_VAR_NUM, percent); + + // Unset the time stamp for the beginning of this measurement + _millisMeasurementRequested = 0; + // Unset the status bits for a measurement request (bits 5 & 6) + _sensorStatus &= 0b10011111; + + return success; +} + + +bool DigiXBeeCellularTransparent::connectInternet(uint32_t maxConnectionTime) +{ + bool retVal = true; + + if (bitRead(_sensorStatus, 1) == 0 || bitRead(_sensorStatus, 2) == 0) // NOT yet powered + { + modemPowerUp(); + } + if (bitRead(_sensorStatus, 3) == 0) // No attempts yet to wake the modem + { + waitForWarmUp(); + retVal &= wake(); + } + if (bitRead(_sensorStatus, 0) == 0) // Not yet setup + { + retVal &= setup(); // Set-up if necessary + } + if (!retVal) + { + MS_DBG(F("Modem did't wake up! Cannot connect to the internet!")); + return retVal; + } + + // Check that the modem is responding to AT commands. If not, give up. + #if defined MS_DIGIXBEECELLULARTRANSPARENT_DEBUG + uint32_t start = millis(); + #endif + MS_DBG(F("\nWaiting for"), getSensorName(), F("to respond to AT commands...")); + if (!_tinyModem.testAT(_stabilizationTime_ms + 500)) + { + MS_DBG(F("No response to AT commands! Cannot connect to the internet!")); + return false; + } + else MS_DBG(F("... AT OK after"), millis() - start, F("milliseconds!")); + + MS_DBG(F("\nWaiting up to"), maxConnectionTime/1000, + F("seconds for cellular network registration...")); + if (_tinyModem.waitForNetwork(maxConnectionTime)) + { + MS_DBG(F("... Registered after"), millis() - start, + F("milliseconds. Connecting to GPRS...")); + _tinyModem.gprsConnect(_apn, "", ""); + MS_DBG(F("... Connected after"), millis() - start, + F("milliseconds.")); + retVal = true; + } + else + { + MS_DBG(F("...GPRS connection failed.")); + return false; + } +} + + +void DigiXBeeCellularTransparent::disconnectInternet(void) +{ + // XBee doesn't like to disconnect at all, so we're doing nothing +} + + + +// Get the time from NIST via TIME protocol (rfc868) +// This would be much more efficient if done over UDP, but I'm doing it +// over TCP because I don't have a UDP library for all the modems. +uint32_t DigiXBeeCellularTransparent::getNISTTime(void) +{ + // bail if not connected to the internet + if (!_tinyModem.isGprsConnected()) + { + MS_DBG(F("No internet connection, cannot connect to NIST.")); + return 0; + } + + // Must ensure that we do not ping the daylight more than once every 4 seconds + // NIST clearly specifies here that this is a requirement for all software + // that accesses its servers: https://tf.nist.gov/tf-cgi/servers.cgi + while (millis() < _lastNISTrequest + 4000) {} + + // Make TCP connection + MS_DBG(F("Connecting to NIST daytime Server")); + bool connectionMade = false; + IPAddress ip(129, 6, 15, 30); // This is the IP address of time-c-g.nist.gov + connectionMade = _tinyClient->connect(ip, 37); // XBee's address lookup falters on time.nist.gov + _tinyClient->print('!'); // Need to send something before connection is made + delay(100); // Need this delay! Can get away with 50, but 100 is safer. + + // Wait up to 5 seconds for a response + if (connectionMade) + { + long start = millis(); + while (_tinyClient && _tinyClient->available() < 4 && millis() - start < 5000L){} + + if (_tinyClient->available() >= 4) + { + MS_DBG(F("\nNIST responded after"), millis() - start, F("ms")); + // Response is returned as 32-bit number as soon as connection is made + // Connection is then immediately closed, so there is no need to close it + uint32_t secFrom1900 = 0; + byte response[4] = {0}; + for (uint8_t i = 0; i < 4; i++) + { + response[i] = _tinyClient->read(); + MS_DBG(F("\nResponse Byte"), i, ':', (char)response[i], + '=', response[i], '=', String(response[i], BIN)); + secFrom1900 += 0x000000FF & response[i]; + // MS_DBG(F("\nseconds from 1900 after byte:"),String(secFrom1900, BIN)); + if (i+1 < 4) {secFrom1900 = secFrom1900 << 8;} + } + MS_DBG(F("\nSeconds from 1900 returned by NIST (UTC):"), + secFrom1900, '=', String(secFrom1900, BIN)); + + // Close the TCP connection, just in case + _tinyClient->stop(); + + // Return the timestamp + uint32_t unixTimeStamp = secFrom1900 - 2208988800; + MS_DBG(F("\nUnix Timestamp returned by NIST (UTC):"), unixTimeStamp); + // If before Jan 1, 2017 or after Jan 1, 2030, most likely an error + if (unixTimeStamp < 1483228800) return 0; + else if (unixTimeStamp > 1893456000) return 0; + else return unixTimeStamp; + } + else + { + MS_DBG(F("NIST Time server did not respond!")); + return 0; + } + } + else MS_DBG(F("Unable to open TCP to NIST!")); + return 0; +} diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index 92d85682a..371ac9420 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -1,164 +1,62 @@ /* - *DigiXBeeCellular.h + *DigiXBeeCellularTransparent.h *This file is part of the EnviroDIY modular sensors library for Arduino * *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). * - *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module + *This file is for Digi Cellular XBee's */ // Header Guards -#ifndef ModularSensorsSpecificModem_h -#define ModularSensorsSpecificModem_h +#ifndef DigiXBeeCellularTransparent_h +#define DigiXBeeCellularTransparent_h // Debugging Statement -// #define MS_DIGIXBEECELLULAR_DEBUG +// #define MS_DIGIXBEECELLULARTRANSPARENT_DEBUG -#ifdef MS_DIGIXBEECELLULAR_DEBUG +#ifdef MS_DIGIXBEECELLULARTRANSPARENT_DEBUG #define MS_DEBUGGING_STD #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif #define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates - -// Included Dependencies -#include "ModSensorDebugger.h" -#include "LoggerModem.h" - -// ========================================================================== -// Wifi/Cellular Modem Main Chip Selection -// ========================================================================== - -// Select your modem chip - this determines the exact commands sent to it #define TINY_GSM_MODEM_XBEE // Select for Digi brand WiFi or Cellular XBee's - -// ========================================================================== -// Modem Pins -// ========================================================================== - -// Declare the existance of modem pin Variables -// Use the "extern" keyword to denote that these will actually be defined in -// the main program rather than in this file. - -extern const int8_t modemVccPin; -extern const int8_t modemSleepRqPin; -extern const int8_t modemStatusPin; -extern const int8_t modemResetPin; -extern const int8_t modemLEDPin; -extern Stream &modemSerial; +// Included Dependencies +#include "DigiXBee.h" +#include "TinyGsmClient.h" -// ========================================================================== -// TinyGSM Client -// ========================================================================== +class DigiXBeeCellularTransparent : public DigiXBee +{ -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates +public: + // Constructors + DigiXBeeCellularTransparent(Stream* modemStream, + int8_t powerPin, int8_t statusPin, bool useCTSStatus, + int8_t modemResetPin, int8_t modemSleepRqPin, + const char *apn, + uint8_t measurementsToAverage = 1); -// Include TinyGSM for the modem -// This include must be included below the define of the modem name! -#include -// Create a new TinyGSM modem to run on that serial port and return a pointer to it -TinyGsm *tinyModem = new TinyGsm(modemSerial, modemResetPin); + // The a measurement is "complete" when the modem is registered on the network. + // For a cellular modem, this actually sets the GPRS bearer/APN!! + bool isMeasurementComplete(bool debug=false) override; + bool addSingleMeasurementResult(void) override; -// Create a new TCP client on that modem and return a pointer to it -TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); + bool connectInternet(uint32_t maxConnectionTime = 50000L) override; + void disconnectInternet(void) override; + uint32_t getNISTTime(void) override; -// ========================================================================== -// Specific Modem On-Off Methods -// ========================================================================== -// Describe the physical pin connection of your modem to your board -const bool modemStatusLevel = LOW; // The level of the status pin when the module is active (HIGH or LOW) + bool didATRespond(void) override; + bool extraModemSetup(void) override; -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -// After enabling pin sleep, the sleep request pin is held LOW to keep the XBee on -// Enable pin sleep in the setup function or using XCTU prior to connecting the XBee -bool modemSleepFxn(void) -{ - if (modemSleepRqPin >= 0) // Don't go to sleep if there's not a wake pin! - { - digitalWrite(modemSleepRqPin, HIGH); - digitalWrite(modemLEDPin, LOW); - return true; - } - else - { - return true; - } -} - - -bool modemWakeFxn(void) -{ - if (modemVccPin >= 0) // Turns on when power is applied - return true; - else if (modemSleepRqPin >= 0) - { - digitalWrite(modemSleepRqPin, LOW); - digitalWrite(modemLEDPin, HIGH); // Because the XBee doesn't have any lights - return true; - } - else - { - return true; - } -} - - -void extraModemSetup(void) -{ - tinyModem->init(); // initialize - if (tinyModem->commandMode()) - { - // Set DIO8 to be used for sleep requests - // NOTE: Only pin 9/DIO8/DTR can be used for this function - tinyModem->sendAT(F("D8"),1); - tinyModem->waitResponse(); - // Turn on status indication pin - it will be HIGH when the XBee is awake - // NOTE: Only pin 13/ON/SLEEPnot/DIO9 can be used for this function - tinyModem->sendAT(F("D9"),1); - tinyModem->waitResponse(); - // Turn on CTS pin - it will be LOW when the XBee is ready to receive commands - // This can be used as proxy for status indication if the true status pin is not accessible - // NOTE: Only pin 12/DIO7/CTS can be used for this function - tinyModem->sendAT(F("D7"),1); - tinyModem->waitResponse(); - // Put the XBee in pin sleep mode - tinyModem->sendAT(F("SM"),1); - tinyModem->waitResponse(); - // Disassociate from network for lowest power deep sleep - tinyModem->sendAT(F("SO"),0); - tinyModem->waitResponse(); - // Disable remote manager, USB Direct, and LTE PSM - // NOTE: LTE-M's PSM (Power Save Mode) sounds good, but there's no - // easy way on the LTE-M Bee to wake the cell chip itself from PSM, - // so we'll use the Digi pin sleep instead. - tinyModem->sendAT(F("DO"),0); - tinyModem->waitResponse(); - // Make sure USB direct won't be pin enabled on XBee3 units - tinyModem->sendAT(F("P0"),0); - tinyModem->waitResponse(); - // Make sure pins 7&8 are not set for USB direct on XBee3 units - tinyModem->sendAT(F("P1"),0); - tinyModem->waitResponse(); - // Cellular carrier profile - AT&T - // Hologram says they can use any network, but I've never succeeded with anything but AT&T - tinyModem->sendAT(F("CP"),2); - tinyModem->waitResponse(); - // Cellular network technology - LTE-M Only - // LTE-M XBee connects much faster on AT&T/Hologram when set to LTE-M only (instead of LTE-M/NB IoT) - tinyModem->sendAT(F("N#"),2); - tinyModem->waitResponse(); - // Write changes to flash and apply them - tinyModem->writeChanges(); - // Exit command mode - tinyModem->exitCommand(); - } -} + TinyGsm _tinyModem; + private: + const char *_apn; +}; #endif diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp new file mode 100644 index 000000000..e0f977af4 --- /dev/null +++ b/src/modems/DigiXBeeWifi.cpp @@ -0,0 +1,342 @@ +/* + *DigiXBeeWifi.cpp + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is for Digi S6B Wifi XBee's +*/ + +// Included Dependencies +#include "DigiXBeeWifi.h" + +// Constructors +DigiXBeeWifi::DigiXBeeWifi(Stream* modemStream, + int8_t powerPin, int8_t statusPin, bool useCTSStatus, + int8_t modemResetPin, int8_t modemSleepRqPin, + const char *ssid, const char *pwd, + uint8_t measurementsToAverage) + : DigiXBee(powerPin, statusPin, useCTSStatus, + modemResetPin, modemSleepRqPin, + measurementsToAverage), + _tinyModem(*modemStream, modemResetPin) +{ + _ssid = ssid; + _pwd = pwd; + TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); + _tinyClient = tinyClient; +} + + +bool DigiXBeeWifi::didATRespond(void) +{ + return _tinyModem.testAT(10); +} + + +bool DigiXBeeWifi::extraModemSetup(void) +{ + bool success = true; + success &= _tinyModem.init(); // initialize + _modemName = _tinyModem.getModemName(); + if (_tinyModem.commandMode()) + { + // Set DIO8 to be used for sleep requests + // NOTE: Only pin 9/DIO8/DTR can be used for this function + _tinyModem.sendAT(F("D8"),1); + success &= _tinyModem.waitResponse() == 1; + // Turn on status indication pin - it will be HIGH when the XBee is awake + // NOTE: Only pin 13/ON/SLEEPnot/DIO9 can be used for this function + _tinyModem.sendAT(F("D9"),1); + success &= _tinyModem.waitResponse() == 1; + // Turn on CTS pin - it will be LOW when the XBee is ready to receive commands + // This can be used as proxy for status indication if the true status pin is not accessible + // NOTE: Only pin 12/DIO7/CTS can be used for this function + _tinyModem.sendAT(F("D7"),1); + success &= _tinyModem.waitResponse() == 1; + // Put the XBee in pin sleep mode + _tinyModem.sendAT(F("SM"),1); + success &= _tinyModem.waitResponse() == 1; + // Disassociate from network for lowest power deep sleep + _tinyModem.sendAT(F("SO"),200); + success &= _tinyModem.waitResponse() == 1; + // Put the network connection parameters into flash + success &= _tinyModem.networkConnect(_ssid, _pwd); + // Write changes to flash and apply them + _tinyModem.writeChanges(); + // Exit command mode + _tinyModem.exitCommand(); + } + else success = false; + return success; +} + + +// This checks to see if enough time has passed for measurement completion +// In the case of the modem, we consider a measurement to be "complete" when +// the modem has registered on the network *and* returns good signal strength. +// In theory, both of these things happen at the same time - as soon as the +// module detects a network with sufficient signal strength, it connects and +// will respond corretly to requests for its connection status and the signal +// strength. In reality sometimes the modem might respond with successful +// network connection before it responds with a valid signal strength or it +// might be able to return a real measurement of cellular signal strength but +// not be able to register to the network. We'd prefer to wait until it both +// responses are good so we're getting an actual signal strength and it's as +// close as possible to what the antenna is will see when the data publishers +// push data. +bool DigiXBeeWifi::isMeasurementComplete(bool debug) +{ + #if defined MS_DIGIXBEEWIFI_DEBUG + debug = true; + #endif + // If a measurement failed to start, the sensor will never return a result, + // so the measurement time is essentially already passed + // For a cellular modem nothing happens to "start" a measurement so bit 6 + // will be set by startSingleMeasurement() as long as bit 4 was set by wake(). + // For a WiFi modem, startSingleMeasurement actually sets the WiFi connection + // parameters. + if (!bitRead(_sensorStatus, 6)) + { + if (debug) {MS_DBG(getSensorName(), + F("is not measuring and will not return a value!"));} + return true; + } + + // just defining this to not call multiple times below + uint32_t now = millis(); + + // We don't want to ping any of the modems too fast so they don't get + // overwhelmed. Make sure we've waited a little + if (now - _lastConnectionCheck < 250) return false; + + // Check how long we've been waiting for the network connection and/or a + // good measurement of signal quality. + uint32_t elapsed_in_wait; + + // Cellular modems and wifi modems with the connection paramters always + // saved to flash (like XBees) begin searching for and attempt to register + // to the network as soon as they are awake - the GPRS paramters that need + // to be set to actually *use* the network don't have to be set until we + // make the attempt to use it. + elapsed_in_wait = now - _millisSensorActivated; + + // If we're connected AND receiving valid signal strength, measurement is complete + // In theory these happen at the same time, but in reality one or the other + // may happen first. + bool isConnected = _tinyModem.isNetworkConnected(); + int signalResponse = _tinyModem.getSignalQuality(); + if (isConnected && signalResponse != 0 && signalResponse != 99) + { + if (debug) MS_DBG(F("It's been"), (elapsed_in_wait), F("ms, and"), + getSensorName(), F("is now registered on the network and reporting valid signal strength!")); + _lastConnectionCheck = now; + return true; + } + + // If we've exceeded the allowed time to wait for the network, give up + if (elapsed_in_wait > XBEE_SIGNALQUALITY_TIME_MS) + { + if (debug) MS_DBG(F("It's been"), (elapsed_in_wait), F("ms, and"), + getSensorName(), F("has maxed out wait for network registration! Ending wait.")); + // Leave status bits and times set - can still get a valid value! + return true; + } + + // If the modem isn't registered yet or doesn't report valid signal, we still need to wait + _lastConnectionCheck = now; + return false; +} + + +bool DigiXBeeWifi::addSingleMeasurementResult(void) +{ + bool success = true; + + // Initialize float variable + int16_t signalQual = -9999; + int16_t percent = -9999; + int16_t rssi = -9999; + + // Check a measurement was *successfully* started (status bit 6 set) + // Only go on to get a result if it was + if (bitRead(_sensorStatus, 6)) + { + // The WiFi XBee needs to make an actual TCP connection and get some sort + // of response on that connection before it knows the signal quality. + // Connecting to the Google DNS servers for now + MS_DBG(F("Opening connection to check connection strength...")); + bool usedGoogle = false; + if (!_tinyModem.gotIPforSavedHost()) + { + usedGoogle = true; + IPAddress ip(8, 8, 8, 8); // This is the IP address of time-c-g.nist.gov + success &= _tinyClient->connect(ip, 80); + } + _tinyClient->print('!'); // Need to send something before connection is made + delay(100); // Need this delay! Can get away with 50, but 100 is safer. + if (usedGoogle) + { + _tinyClient->stop(); + } + + // Get signal quality + // NOTE: We can't actually distinguish between a bad modem response, no + // modem response, and a real response from the modem of no service/signal. + // The TinyGSM getSignalQuality function returns the same "no signal" + // value (99 CSQ or 0 RSSI) in all 3 cases. + MS_DBG(F("Getting signal quality:")); + signalQual = _tinyModem.getSignalQuality(); + MS_DBG(F("Raw signal quality:"), signalQual); + + // Convert signal quality to RSSI + rssi = signalQual; + percent = getPctFromRSSI(signalQual); + + MS_DBG(F("RSSI:"), rssi); + MS_DBG(F("Percent signal strength:"), percent); + } + else MS_DBG(getSensorName(), F("is not connected to the network; unable to get signal quality!")); + + verifyAndAddMeasurementResult(RSSI_VAR_NUM, rssi); + verifyAndAddMeasurementResult(PERCENT_SIGNAL_VAR_NUM, percent); + + // Unset the time stamp for the beginning of this measurement + _millisMeasurementRequested = 0; + // Unset the status bits for a measurement request (bits 5 & 6) + _sensorStatus &= 0b10011111; + + return success; +} + + +bool DigiXBeeWifi::connectInternet(uint32_t maxConnectionTime) +{ + bool retVal = true; + + if (bitRead(_sensorStatus, 1) == 0 || bitRead(_sensorStatus, 2) == 0) // NOT yet powered + { + modemPowerUp(); + } + if (bitRead(_sensorStatus, 3) == 0) // No attempts yet to wake the modem + { + waitForWarmUp(); + retVal &= wake(); + } + if (bitRead(_sensorStatus, 0) == 0) // Not yet setup + { + retVal &= setup(); // Set-up if necessary + } + if (!retVal) + { + MS_DBG(F("Modem did't wake up! Cannot connect to the internet!")); + return retVal; + } + + // Check that the modem is responding to AT commands. If not, give up. + #if defined MS_DIGIXBEEWIFI_DEBUG + uint32_t start = millis(); + #endif + MS_DBG(F("\nWaiting for"), getSensorName(), F("to respond to AT commands...")); + if (!_tinyModem.testAT(_stabilizationTime_ms + 500)) + { + MS_DBG(F("No response to AT commands! Cannot connect to the internet!")); + return false; + } + else MS_DBG(F("... AT OK after"), millis() - start, F("milliseconds!")); + + MS_DBG(F("\nAttempting to connect to WiFi network...")); + if (!(_tinyModem.isNetworkConnected())) + { + MS_DBG(F("Sending credentials...")); + while (!_tinyModem.networkConnect(_ssid, _pwd)) {}; + MS_DBG(F("Waiting up to"), maxConnectionTime/1000, + F("seconds for connection")); + if (!_tinyModem.waitForNetwork(maxConnectionTime)) + { + MS_DBG(F("... WiFi connection failed")); + return false; + } + } + MS_DBG(F("... WiFi connected after"), millis() - start, + F("milliseconds!")); + return true; +} + + +void DigiXBeeWifi::disconnectInternet(void) +{ + // XBee doesn't like to disconnect at all, so we're doing nothing +} + + +// Get the time from NIST via TIME protocol (rfc868) +// This would be much more efficient if done over UDP, but I'm doing it +// over TCP because I don't have a UDP library for all the modems. +uint32_t DigiXBeeWifi::getNISTTime(void) +{ + // bail if not connected to the internet + if (!_tinyModem.isNetworkConnected()) + { + MS_DBG(F("No internet connection, cannot connect to NIST.")); + return 0; + } + + // Must ensure that we do not ping the daylight more than once every 4 seconds + // NIST clearly specifies here that this is a requirement for all software + // that accesses its servers: https://tf.nist.gov/tf-cgi/servers.cgi + while (millis() < _lastNISTrequest + 4000) {} + + // Make TCP connection + MS_DBG(F("Connecting to NIST daytime Server")); + bool connectionMade = false; + IPAddress ip(129, 6, 15, 30); // This is the IP address of time-c-g.nist.gov + connectionMade = _tinyClient->connect(ip, 37); // XBee's address lookup falters on time.nist.gov + _tinyClient->print('!'); // Need to send something before connection is made + delay(100); // Need this delay! Can get away with 50, but 100 is safer. + + // Wait up to 5 seconds for a response + if (connectionMade) + { + long start = millis(); + while (_tinyClient && _tinyClient->available() < 4 && millis() - start < 5000L){} + + if (_tinyClient->available() >= 4) + { + MS_DBG(F("\nNIST responded after"), millis() - start, F("ms")); + // Response is returned as 32-bit number as soon as connection is made + // Connection is then immediately closed, so there is no need to close it + uint32_t secFrom1900 = 0; + byte response[4] = {0}; + for (uint8_t i = 0; i < 4; i++) + { + response[i] = _tinyClient->read(); + MS_DBG(F("\nResponse Byte"), i, ':', (char)response[i], + '=', response[i], '=', String(response[i], BIN)); + secFrom1900 += 0x000000FF & response[i]; + // MS_DBG(F("\nseconds from 1900 after byte:"),String(secFrom1900, BIN)); + if (i+1 < 4) {secFrom1900 = secFrom1900 << 8;} + } + MS_DBG(F("\nSeconds from 1900 returned by NIST (UTC):"), + secFrom1900, '=', String(secFrom1900, BIN)); + + // Close the TCP connection, just in case + _tinyClient->stop(); + + // Return the timestamp + uint32_t unixTimeStamp = secFrom1900 - 2208988800; + MS_DBG(F("\nUnix Timestamp returned by NIST (UTC):"), unixTimeStamp); + // If before Jan 1, 2017 or after Jan 1, 2030, most likely an error + if (unixTimeStamp < 1483228800) return 0; + else if (unixTimeStamp > 1893456000) return 0; + else return unixTimeStamp; + } + else + { + MS_DBG(F("NIST Time server did not respond!")); + return 0; + } + } + else MS_DBG(F("Unable to open TCP to NIST!")); + return 0; +} diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index 201ee1943..76fcca960 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -4,7 +4,7 @@ * *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). * - *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module + *This file is for Digi S6B Wifi XBee's */ // Header Guards @@ -20,111 +20,44 @@ #endif #define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates +#define TINY_GSM_MODEM_XBEE // Select for Digi brand WiFi or Cellular XBee's // Included Dependencies -#include "ModSensorDebugger.h" -#include "LoggerModem.h" +#include "DigiXBee.h" +#include "TinyGsmClient.h" -#define TINY_GSM_XBEE_XBEE // Select for Digi brand WiFi or Cellular XBee's -#define XBEE_STATUS_TIME_MS 15 -#define XBEE_DISCONNECT_TIME_MS 5000L - -#define XBEE_WARM_UP_TIME_MS 50 -#define XBEE_ATRESPONSE_TIME_MS 5000L - - -class DigiXBeeWifi : public loggerModem +class DigiXBeeWifi : public DigiXBee { public: // Constructors - DigiXBeeWifi(int8_t powerPin, int8_t statusPin, bool useCTSStatus, - int8_t modemResetPin, int8_t modemSleepRqPin, - TinyGsmModem *inModem, Client *inClient, const char *ssid, const char *pwd); + DigiXBeeWifi(Stream* modemStream, + int8_t powerPin, int8_t statusPin, bool useCTSStatus, + int8_t modemResetPin, int8_t modemSleepRqPin, + const char *ssid, const char *pwd, + uint8_t measurementsToAverage = 1); - virtual bool setup(void) override; - virtual bool wake(void) override; - virtual bool modemSleepPowerDown(void); -} + // The a measurement is "complete" when the modem is registered on the network. + // For a cellular modem, this actually sets the GPRS bearer/APN!! + bool isMeasurementComplete(bool debug=false) override; + bool addSingleMeasurementResult(void) override; -// ========================================================================== -// Specific Modem On-Off Methods -// ========================================================================== + bool connectInternet(uint32_t maxConnectionTime = 50000L) override; + void disconnectInternet(void) override; -if (modemCTSPin >= 0 && modemStatusPin < 0) -{ - const bool modemStatusLevel = LOW; // The level of the status pin when the module is active (HIGH or LOW) -} - -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -// After enabling pin sleep, the sleep request pin is held LOW to keep the XBee on -// Enable pin sleep in the setup function or using XCTU prior to connecting the XBee -bool modemSleepFxn(void) -{ - if (modemSleepRqPin >= 0) // Don't go to sleep if there's not a wake pin! - { - digitalWrite(modemSleepRqPin, HIGH); - digitalWrite(modemLEDPin, LOW); - return true; - } - else - { - return true; - } -} - - -bool modemWakeFxn(void) -{ - if (modemVccPin >= 0) // Turns on when power is applied - return true; - else if (modemSleepRqPin >= 0) - { - digitalWrite(modemSleepRqPin, LOW); - digitalWrite(modemLEDPin, HIGH); // Because the XBee doesn't have any lights - return true; - } - else - { - return true; - } -} - - -void extraModemSetup(void) -{ - tinyModem->init(); // initialize - if (tinyModem->commandMode()) - { - // Set DIO8 to be used for sleep requests - // NOTE: Only pin 9/DIO8/DTR can be used for this function - tinyModem->sendAT(F("D8"),1); - tinyModem->waitResponse(); - // Turn on status indication pin - it will be HIGH when the XBee is awake - // NOTE: Only pin 13/ON/SLEEPnot/DIO9 can be used for this function - tinyModem->sendAT(F("D9"),1); - tinyModem->waitResponse(); - // Turn on CTS pin - it will be LOW when the XBee is ready to receive commands - // This can be used as proxy for status indication if the true status pin is not accessible - // NOTE: Only pin 12/DIO7/CTS can be used for this function - tinyModem->sendAT(F("D7"),1); - tinyModem->waitResponse(); - // Put the XBee in pin sleep mode - tinyModem->sendAT(F("SM"),1); - tinyModem->waitResponse(); - // Disassociate from network for lowest power deep sleep - tinyModem->sendAT(F("SO"),200); - tinyModem->waitResponse(); - // Write changes to flash and apply them - tinyModem->writeChanges(); - // Exit command mode - tinyModem->exitCommand(); - } -} + uint32_t getNISTTime(void) override; + + bool didATRespond(void) override; + bool extraModemSetup(void) override; + + TinyGsm _tinyModem; + private: + const char *_ssid; + const char *_pwd; +}; #endif From ae0d7f029a4ab31bb60613608388d6b273144fff Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 14 May 2019 12:54:56 -0400 Subject: [PATCH 13/88] Using pre-processor macros --- src/LoggerModem.cpp | 339 --------------------- src/LoggerModem.h | 18 +- src/modems/DFRobotWifiBeeESP.h | 223 -------------- src/modems/DigiXBee.h | 4 +- src/modems/DigiXBeeCellularBypass.cpp | 224 +------------- src/modems/DigiXBeeCellularBypass.h | 7 +- src/modems/DigiXBeeCellularTransparent.cpp | 215 +------------ src/modems/DigiXBeeCellularTransparent.h | 7 +- src/modems/DigiXBeeWifi.cpp | 217 +------------ src/modems/DigiXBeeWifi.h | 7 +- src/modems/EspressifESP8266.cpp | 281 +++++++++++++++++ src/modems/EspressifESP8266.h | 82 +++++ src/modems/IteadWee.h | 223 -------------- src/modems/LoggerModemMacros.h | 338 ++++++++++++++++++++ 14 files changed, 758 insertions(+), 1427 deletions(-) delete mode 100644 src/modems/DFRobotWifiBeeESP.h create mode 100644 src/modems/EspressifESP8266.cpp create mode 100644 src/modems/EspressifESP8266.h delete mode 100644 src/modems/IteadWee.h create mode 100644 src/modems/LoggerModemMacros.h diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index 9df75baea..9c32e6586 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -230,21 +230,6 @@ bool loggerModem::startSingleMeasurement(void) MS_DBG(getSensorName(), F("was never properly set up, attempting setup now!")); setup(); } - - // For the wifi modems, the SSID and password need to be set before they - // can join a network. - // For **MOST** cellular modems, network registration (should) happen automatically. - // The GPRS bearer (APN) is then set after registration when making the GPRS - // (data) link. - // For XBee models, the SSID, password, and APN are always saved in - // the board's memory, even if power is disconnected, so those values - // are set in the setup function. - if (_ssid && _tinyModem->hasWifi() && !_tinyModem->isNetworkConnected() && - _modemName.indexOf(F("XBee")) < 0 ) - { - success &= _tinyModem->networkConnect(_ssid, _pwd); - } - // Mark the time that a measurement was requested _millisMeasurementRequested = millis(); // Set the status bit for measurement start success (bit 6) @@ -263,58 +248,6 @@ bool loggerModem::startSingleMeasurement(void) } -bool loggerModem::addSingleMeasurementResult(void) -{ - bool success = true; - - // Initialize float variable - int16_t signalQual = -9999; - int16_t percent = -9999; - int16_t rssi = -9999; - - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (bitRead(_sensorStatus, 6)) - { - - // Get signal quality - // NOTE: We can't actually distinguish between a bad modem response, no - // modem response, and a real response from the modem of no service/signal. - // The TinyGSM getSignalQuality function returns the same "no signal" - // value (99 CSQ or 0 RSSI) in all 3 cases. - MS_DBG(F("Getting signal quality:")); - signalQual = _tinyModem->getSignalQuality(); - MS_DBG(F("Raw signal quality:"), signalQual); - - // Convert signal quality to RSSI, if necessary - if ((_modemName.indexOf(F("XBee")) >= 0 || _modemName.indexOf(F("ESP8266")) >= 0)) - { - rssi = signalQual; - percent = getPctFromRSSI(signalQual); - } - else - { - rssi = getRSSIFromCSQ(signalQual); - percent = getPctFromCSQ(signalQual); - } - - MS_DBG(F("RSSI:"), rssi); - MS_DBG(F("Percent signal strength:"), percent); - } - else MS_DBG(getSensorName(), F("is not connected to the network; unable to get signal quality!")); - - verifyAndAddMeasurementResult(RSSI_VAR_NUM, rssi); - verifyAndAddMeasurementResult(PERCENT_SIGNAL_VAR_NUM, percent); - - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - _sensorStatus &= 0b10011111; - - return success; -} - - // This checks to see if enough time has passed for stability // In the case of the modem, we consider it to be "stable" when it responds to // AT commands @@ -386,190 +319,9 @@ bool loggerModem::isStable(bool debug) } -// This checks to see if enough time has passed for measurement completion -// In the case of the modem, we consider a measurement to be "complete" when -// the modem has registered on the network *and* returns good signal strength. -// In theory, both of these things happen at the same time - as soon as the -// module detects a network with sufficient signal strength, it connects and -// will respond corretly to requests for its connection status and the signal -// strength. In reality sometimes the modem might respond with successful -// network connection before it responds with a valid signal strength or it -// might be able to return a real measurement of cellular signal strength but -// not be able to register to the network. We'd prefer to wait until it both -// responses are good so we're getting an actual signal strength and it's as -// close as possible to what the antenna is will see when the data publishers -// push data. -bool loggerModem::isMeasurementComplete(bool debug) -{ - #if defined MS_LOGGERMODEM_DEBUG_DEEP - debug = true; - #endif - // If a measurement failed to start, the sensor will never return a result, - // so the measurement time is essentially already passed - // For a cellular modem nothing happens to "start" a measurement so bit 6 - // will be set by startSingleMeasurement() as long as bit 4 was set by wake(). - // For a WiFi modem, startSingleMeasurement actually sets the WiFi connection - // parameters. - if (!bitRead(_sensorStatus, 6)) - { - if (debug) {MS_DBG(getSensorName(), - F("is not measuring and will not return a value!"));} - return true; - } - - // just defining this to not call multiple times below - uint32_t now = millis(); - - // We don't want to ping any of the modems too fast so they don't get - // overwhelmed. Make sure we've waited a little - if (now - _lastConnectionCheck < 250) return false; - - // Check how long we've been waiting for the network connection and/or a - // good measurement of signal quality. - uint32_t elapsed_in_wait; - - // Cellular modems and wifi modems with the connection paramters always - // saved to flash (like XBees) begin searching for and attempt to register - // to the network as soon as they are awake - the GPRS paramters that need - // to be set to actually *use* the network don't have to be set until we - // make the attempt to use it. - if (_tinyModem->hasGPRS() || _modemName.indexOf(F("XBee")) >= 0) - elapsed_in_wait = now - _millisSensorActivated; - - // For Wifi modems without settings in flash, the connection parameters - // need to set before it can register to the network - that is done in the - // startSingleMeasurement() function and becomes the measurement request time. - else elapsed_in_wait = now - _millisMeasurementRequested; - - // If we're connected AND receiving valid signal strength, measurement is complete - // In theory these happen at the same time, but in reality one or the other - // may happen first. - bool isConnected = _tinyModem->isNetworkConnected(); - int signalResponse = _tinyModem->getSignalQuality(); - if (isConnected && signalResponse != 0 && signalResponse != 99) - { - if (debug) MS_DBG(F("It's been"), (elapsed_in_wait), F("ms, and"), - getSensorName(), F("is now registered on the network and reporting valid signal strength!")); - _lastConnectionCheck = now; - return true; - } - - // If we've exceeded the allowed time to wait for the network, give up - if (elapsed_in_wait > XBEE_SIGNALQUALITY_TIME_MS) - { - if (debug) MS_DBG(F("It's been"), (elapsed_in_wait), F("ms, and"), - getSensorName(), F("has maxed out wait for network registration! Ending wait.")); - // Leave status bits and times set - can still get a valid value! - return true; - } - - // If the modem isn't registered yet or doesn't report valid signal, we still need to wait - _lastConnectionCheck = now; - return false; -} - - // ==========================================================================// // These are the unique functions for the modem as an internet connected device // ==========================================================================// -bool loggerModem::connectInternet(uint32_t maxConnectionTime) -{ - bool retVal = true; - - if (bitRead(_sensorStatus, 1) == 0 || bitRead(_sensorStatus, 2) == 0) // NOT yet powered - { - modemPowerUp(); - } - if (bitRead(_sensorStatus, 3) == 0) // No attempts yet to wake the modem - { - waitForWarmUp(); - retVal &= wake(); - } - if (bitRead(_sensorStatus, 0) == 0) // Not yet setup - { - retVal &= setup(); // Set-up if necessary - } - if (!retVal) - { - MS_DBG(F("Modem did't wake up! Cannot connect to the internet!")); - return retVal; - } - - // Check that the modem is responding to AT commands. If not, give up. - #if defined MS_LOGGERMODEM_DEBUG - uint32_t start = millis(); - #endif - MS_DBG(F("\nWaiting for"), getSensorName(), F("to respond to AT commands...")); - if (!_tinyModem->testAT(_stabilizationTime_ms + 500)) - { - MS_DBG(F("No response to AT commands! Cannot connect to the internet!")); - return false; - } - else MS_DBG(F("... AT OK after"), millis() - start, F("milliseconds!")); - - if (_tinyModem->hasWifi()) - { - MS_DBG(F("\nAttempting to connect to WiFi network...")); - if (!(_tinyModem->isNetworkConnected())) - { - MS_DBG(F("Sending credentials...")); - while (!_tinyModem->networkConnect(_ssid, _pwd)) {}; - MS_DBG(F("Waiting up to"), maxConnectionTime/1000, - F("seconds for connection")); - if (!_tinyModem->waitForNetwork(maxConnectionTime)) - { - MS_DBG(F("... WiFi connection failed")); - return false; - } - } - MS_DBG(F("... WiFi connected after"), millis() - start, - F("milliseconds!")); - return true; - } - else // must be GPRS - { - MS_DBG(F("\nWaiting up to"), maxConnectionTime/1000, - F("seconds for cellular network registration...")); - if (_tinyModem->waitForNetwork(maxConnectionTime)) - { - MS_DBG(F("... Registered after"), millis() - start, - F("milliseconds. Connecting to GPRS...")); - _tinyModem->gprsConnect(_apn, "", ""); - MS_DBG(F("... Connected after"), millis() - start, - F("milliseconds.")); - retVal = true; - } - else - { - MS_DBG(F("...GPRS connection failed.")); - return false; - } - } - return retVal; -} - - -void loggerModem::disconnectInternet(void) -{ - #if defined MS_LOGGERMODEM_DEBUG - uint32_t start = millis(); - #endif - if (_tinyModem->hasGPRS() && _modemName.indexOf(F("XBee")) < 0) // XBee doesn't like to disconnect - { - _tinyModem->gprsDisconnect(); - MS_DBG(F("Disconnected from cellular network after"), millis() - start, - F("milliseconds.")); - } - else if (_modemName.indexOf(F("XBee")) < 0) // XBee doesn't like to disconnect - // If you tell the XBee to disconnect, it will not reconnect to the same - // access point until it has been restarted or powered on and off. - // Since we may not have control of the power off, we just won't disconnect. - { - _tinyModem->networkDisconnect(); - MS_DBG(F("Disconnected from WiFi network after"), millis() - start, - F("milliseconds.")); - } -} /*** @@ -699,81 +451,7 @@ bool loggerModem::modemSleepPowerDown(void) return success; } -// Get the time from NIST via TIME protocol (rfc868) -// This would be much more efficient if done over UDP, but I'm doing it -// over TCP because I don't have a UDP library for all the modems. -uint32_t loggerModem::getNISTTime(void) -{ - // bail if not connected to the internet - if ( (_tinyModem->hasGPRS() && !_tinyModem->isGprsConnected()) || - (_tinyModem->hasWifi() && !_tinyModem->isNetworkConnected()) ) - { - MS_DBG(F("No internet connection, cannot connect to NIST.")); - return 0; - } - - // Must ensure that we do not ping the daylight more than once every 4 seconds - // NIST clearly specifies here that this is a requirement for all software - // that accesses its servers: https://tf.nist.gov/tf-cgi/servers.cgi - while (millis() < _lastNISTrequest + 4000) {} - // Make TCP connection - MS_DBG(F("Connecting to NIST daytime Server")); - bool connectionMade = false; - if (_modemName.indexOf(F("XBee")) >= 0) - { - IPAddress ip(129, 6, 15, 30); // This is the IP address of time-c-g.nist.gov - connectionMade = _tinyClient->connect(ip, 37); // XBee's address lookup falters on time.nist.gov - _tinyClient->print('!'); // Need to send something before connection is made - delay(100); // Need this delay! Can get away with 50, but 100 is safer. - } - else connectionMade = _tinyClient->connect("time.nist.gov", 37); - - // Wait up to 5 seconds for a response - if (connectionMade) - { - long start = millis(); - while (_tinyClient && _tinyClient->available() < 4 && millis() - start < 5000L){} - - if (_tinyClient->available() >= 4) - { - MS_DBG(F("\nNIST responded after"), millis() - start, F("ms")); - // Response is returned as 32-bit number as soon as connection is made - // Connection is then immediately closed, so there is no need to close it - uint32_t secFrom1900 = 0; - byte response[4] = {0}; - for (uint8_t i = 0; i < 4; i++) - { - response[i] = _tinyClient->read(); - MS_DBG(F("\nResponse Byte"), i, ':', (char)response[i], - '=', response[i], '=', String(response[i], BIN)); - secFrom1900 += 0x000000FF & response[i]; - // MS_DBG(F("\nseconds from 1900 after byte:"),String(secFrom1900, BIN)); - if (i+1 < 4) {secFrom1900 = secFrom1900 << 8;} - } - MS_DBG(F("\nSeconds from 1900 returned by NIST (UTC):"), - secFrom1900, '=', String(secFrom1900, BIN)); - - // Close the TCP connection, just in case - _tinyClient->stop(); - - // Return the timestamp - uint32_t unixTimeStamp = secFrom1900 - 2208988800; - MS_DBG(F("\nUnix Timestamp returned by NIST (UTC):"), unixTimeStamp); - // If before Jan 1, 2017 or after Jan 1, 2030, most likely an error - if (unixTimeStamp < 1483228800) return 0; - else if (unixTimeStamp > 1893456000) return 0; - else return unixTimeStamp; - } - else - { - MS_DBG(F("NIST Time server did not respond!")); - return 0; - } - } - else MS_DBG(F("Unable to open TCP to NIST!")); - return 0; -} // Helper to get approximate RSSI from CSQ (assuming no noise) int16_t loggerModem::getRSSIFromCSQ(int16_t csq) @@ -943,16 +621,6 @@ void loggerModem::setModemTiming(void) // _off_pull_down_ms = 0; // N/A - standard chip cannot be powered down with pin _disconnetTime_ms = 10000L; // Wait with 10s time-out for sleep } - if (_modemName.indexOf(F("ESP8266")) >= 0) - { - MS_DBG(F("Resetting warm-up and disconnect timing for a ESP8266")); - _warmUpTime_ms = 0; // Module turns on when power is applied - _statusTime_ms = 350; // N/A? - No status pin - use boot time if using a GPIO pin - _stabilizationTime_ms = 350; // Boot up time 200-300ms - // _on_pull_down_ms = 10; // immediate - // _off_pull_down_ms = 0; // N/A - standard chip cannot be powered down with pin - _disconnetTime_ms = 500; // power down ??? - } if (_modemName.indexOf(F("Neoway M590")) >= 0) { MS_DBG(F("Resetting warm-up and disconnect timing for a Neoway M590")); @@ -1018,12 +686,5 @@ void loggerModem::setModemTiming(void) // use AT+SQNSSHDN command for device shut down _disconnetTime_ms = 15000; // ?? Undocumented (Giving 15sec here in case it is not monitored.) } - if (_modemName.indexOf(F("XBee")) >= 0) - { - MS_DBG(F("Putting connection values into flash memory for the Digi XBee")); - _statusTime_ms = 15; // ??? WAG! - // XBee saves all configurations to flash, so we can set them here - else _tinyModem->gprsConnect(_apn, "", ""); - } } ***/ diff --git a/src/LoggerModem.h b/src/LoggerModem.h index 2970a83e5..a282616b3 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -78,7 +78,22 @@ class loggerModem : public Sensor // The modem is "stable" when it responds to AT commands. // For a WiFi modem, this actually sets the network connection parameters!! - bool isStable(bool debug=false) override; + virtual bool isStable(bool debug=false) override; + + // This checks to see if enough time has passed for measurement completion + // In the case of the modem, we consider a measurement to be "complete" when + // the modem has registered on the network *and* returns good signal strength. + // In theory, both of these things happen at the same time - as soon as the + // module detects a network with sufficient signal strength, it connects and + // will respond corretly to requests for its connection status and the signal + // strength. In reality sometimes the modem might respond with successful + // network connection before it responds with a valid signal strength or it + // might be able to return a real measurement of cellular signal strength but + // not be able to register to the network. We'd prefer to wait until it both + // responses are good so we're getting an actual signal strength and it's as + // close as possible to what the antenna is will see when the data publishers + // push data. + virtual bool isMeasurementComplete(bool debug); // ==========================================================================// @@ -131,6 +146,7 @@ class loggerModem : public Sensor void modemLEDOn(void); void modemLEDOff(void); virtual bool didATRespond(void) = 0; + virtual bool isInternetAvailable(void) = 0; virtual bool modemSleepFxn(void) = 0; virtual bool modemWakeFxn(void) = 0; virtual bool extraModemSetup(void) = 0; diff --git a/src/modems/DFRobotWifiBeeESP.h b/src/modems/DFRobotWifiBeeESP.h deleted file mode 100644 index f7ec4dd3b..000000000 --- a/src/modems/DFRobotWifiBeeESP.h +++ /dev/null @@ -1,223 +0,0 @@ -/* - *DFRobotWifiBeeESP.h - *This file is part of the EnviroDIY modular sensors library for Arduino - * - *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). - * - *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module -*/ - -// Header Guards -#ifndef ModularSensorsSpecificModem_h -#define ModularSensorsSpecificModem_h - -// Debugging Statement -// #define MS_DFROBOTWIFIBEEESP_DEBUG - -#ifdef MS_DFROBOTWIFIBEEESP_DEBUG -#define MS_DEBUGGING_STD -#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT -#endif - -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates - -// Included Dependencies -#include "ModSensorDebugger.h" -#include "LoggerModem.h" - -// ========================================================================== -// Wifi/Cellular Modem Main Chip Selection -// ========================================================================== - -// Select your modem chip - this determines the exact commands sent to it -#define TINY_GSM_MODEM_ESP8266 // Select for an ESP8266 using the DEFAULT AT COMMAND FIRMWARE - - -// ========================================================================== -// Modem Pins -// ========================================================================== - -// Declare the existance of modem pin Variables -// Use the "extern" keyword to denote that these will actually be defined in -// the main program rather than in this file. - -extern const int8_t modemVccPin; -extern const int8_t modemSleepRqPin; -extern const int8_t modemStatusPin; -extern const int8_t modemResetPin; -extern const int8_t modemLEDPin; -extern Stream &modemSerial; - -extern const int8_t espSleepRqPin; -extern const int8_t espStatusPin; - - -// ========================================================================== -// TinyGSM Client -// ========================================================================== - -// Include TinyGSM for the modem -// This include must be included below the define of the modem name! -#include - -// Create a new TinyGSM modem to run on that serial port and return a pointer to it -TinyGsm *tinyModem = new TinyGsm(modemSerial); - -// Create a new TCP client on that modem and return a pointer to it -TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); - - -// ========================================================================== -// Specific Modem On-Off Methods -// ========================================================================== - -const bool modemStatusLevel = HIGH; // The level of the status pin when the module is active (HIGH or LOW) -// const long modemBaud = 115200; // Communication speed of the modem, 115200 is default for ESP8266 - -// A helper function to wait for the esp to boot and immediately change some settings -// We'll use this in the wake function -bool ESPwaitForBoot(void) -{ - // Wait for boot - finished when characters start coming - // NOTE: After every "hard" reset (either power off or via RST-B), the ESP - // sends out a boot log from the ROM on UART1 at 74880 baud. We're not - // going to worry about the odd baud rate since we're simply throwing the - // characters away. - delay(200); // It will take at least this long - uint32_t start = millis(); - bool success = false; - while (!modemSerial.available() && millis() - start < 1000) {} - if (modemSerial.available()) - { - success = true; - // Read the boot log to empty it from the serial buffer - while (modemSerial.available()) - { - modemSerial.read(); - delay(2); - } - // Have to make sure echo is off or all AT commands will be confused - tinyModem->sendAT(F("E0")); - success &= tinyModem->waitResponse() == 1; - // re-run init to set mux and station mode - success &= tinyModem->init(); - } - return success; -} - -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -bool modemSleepFxn(void) -{ - // Use this if you have GPIO16 connected to the reset pin to wake from deep sleep - // but no other MCU pin connected to the reset pin. - // NOTE: This will NOT work nicely with "testingMode" - /*if (loggingInterval > 1) - { - uint32_t sleepSeconds = (((uint32_t)loggingInterval) * 60 * 1000) - 75000L; - String sleepCommand = String(sleepSeconds); - tinyModem->sendAT(F("+GSLP="), sleepCommand); - // Power down for 1 minute less than logging interval - // Better: Calculate length of loop and power down for logging interval - loop time - return tinyModem->waitResponse() == 1; - }*/ - // Use this if you have an MCU pin connected to the ESP's reset pin to wake from deep sleep - if (modemResetPin >= 0) - { - digitalWrite(modemLEDPin, LOW); - return tinyModem->poweroff(); - } - // Use this if you don't have access to the ESP8266's reset pin for deep sleep but you - // do have access to another GPIO pin for light sleep. This also sets up another - // pin to view the sleep status. - else if (modemSleepRqPin >= 0 && modemStatusPin >= 0) - { - tinyModem->sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0,"), - String(espStatusPin), ',', modemStatusLevel); - bool success = tinyModem->waitResponse() == 1; - tinyModem->sendAT(F("+SLEEP=1")); - success &= tinyModem->waitResponse() == 1; - digitalWrite(modemLEDPin, LOW); - return success; - } - // Light sleep without the status pin - else if (modemSleepRqPin >= 0 && modemStatusPin < 0) - { - tinyModem->sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0")); - bool success = tinyModem->waitResponse() == 1; - tinyModem->sendAT(F("+SLEEP=1")); - success &= tinyModem->waitResponse() == 1; - digitalWrite(modemLEDPin, LOW); - return success; - } - else // DON'T go to sleep if we can't wake up! - { - return true; - } -} -bool modemWakeFxn(void) -{ - bool success = true; - if (modemVccPin >= 0) // Turns on when power is applied - { - digitalWrite(modemLEDPin, HIGH); // Because the ESP8266 doesn't have any lights - success &= ESPwaitForBoot(); - if (!success) - { - digitalWrite(modemLEDPin, LOW); // Turn off light if the boot failed - } - return success; - } - else if (modemResetPin >= 0) - { - digitalWrite(modemLEDPin, HIGH); - digitalWrite(modemResetPin, LOW); - delay(1); - digitalWrite(modemResetPin, HIGH); - success &= ESPwaitForBoot(); - if (!success) - { - digitalWrite(modemLEDPin, LOW); // Turn off light if the boot failed - } - return success; - } - else if (modemSleepRqPin >= 0) - { - digitalWrite(modemSleepRqPin, LOW); - delay(1); - digitalWrite(modemSleepRqPin, HIGH); - digitalWrite(modemLEDPin, HIGH); - // Don't have to wait for a boot if using light sleep - return true; - } - else - { - return true; - } -} -// Set up the light-sleep status pin, if applicable -void extraModemSetup(void) -{ - // Slow down the baud rate for slow processors - and save the change to - // the ESP's non-volatile memory so we don't have to do it every time - // #if F_CPU == 8000000L - // if (modemBaud > 57600) - // { - // modemSerial.begin(modemBaud); - // tinyModem->sendAT(F("+UART_DEF=9600,8,1,0,0")); - // tinyModem->waitResponse(); - // modemSerial.end(); - // modemSerial.begin(9600); - // } - // #endif - if (modemVccPin < 0 && modemResetPin < 0 && modemSleepRqPin >= 0 && modemStatusPin >= 0) - { - tinyModem->sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0,"), - String(espStatusPin), ',', modemStatusLevel); - tinyModem->waitResponse(); - } -} - - - -#endif diff --git a/src/modems/DigiXBee.h b/src/modems/DigiXBee.h index 273999e69..145726242 100644 --- a/src/modems/DigiXBee.h +++ b/src/modems/DigiXBee.h @@ -12,9 +12,9 @@ #define DigiXBee_h // Debugging Statement -// #define MS_DIGIXBEEWIFI_DEBUG +// #define MS_DIGIXBEE_DEBUG -#ifdef MS_DIGIXBEEWIFI_DEBUG +#ifdef MS_DIGIXBEE_DEBUG #define MS_DEBUGGING_STD #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif diff --git a/src/modems/DigiXBeeCellularBypass.cpp b/src/modems/DigiXBeeCellularBypass.cpp index a6636f224..c8ac87e61 100644 --- a/src/modems/DigiXBeeCellularBypass.cpp +++ b/src/modems/DigiXBeeCellularBypass.cpp @@ -9,6 +9,7 @@ // Included Dependencies #include "DigiXBeeCellularBypass.h" +#include "modems/LoggerModemMacros.h" // Constructors DigiXBeeCellularBypass::DigiXBeeCellularBypass(Stream* modemStream, @@ -24,13 +25,15 @@ DigiXBeeCellularBypass::DigiXBeeCellularBypass(Stream* modemStream, _apn = apn; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); _tinyClient = tinyClient; + _modemStream = modemStream; } -bool DigiXBeeCellularBypass::didATRespond(void) -{ - return _tinyModem.testAT(10); -} +MS_MODEM_DID_AT_RESPOND(DigiXBeeCellularBypass); +MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeCellularBypass); +MS_MODEM_IS_MEASUREMENT_COMPLETE(DigiXBeeCellularBypass); +MS_MODEM_CONNECT_INTERNET(DigiXBeeCellularBypass); +MS_MODEM_GET_NIST_TIME(DigiXBeeCellularBypass); bool DigiXBeeCellularBypass::extraModemSetup(void) @@ -100,83 +103,6 @@ bool DigiXBeeCellularBypass::extraModemSetup(void) } -// This checks to see if enough time has passed for measurement completion -// In the case of the modem, we consider a measurement to be "complete" when -// the modem has registered on the network *and* returns good signal strength. -// In theory, both of these things happen at the same time - as soon as the -// module detects a network with sufficient signal strength, it connects and -// will respond corretly to requests for its connection status and the signal -// strength. In reality sometimes the modem might respond with successful -// network connection before it responds with a valid signal strength or it -// might be able to return a real measurement of cellular signal strength but -// not be able to register to the network. We'd prefer to wait until it both -// responses are good so we're getting an actual signal strength and it's as -// close as possible to what the antenna is will see when the data publishers -// push data. -bool DigiXBeeCellularBypass::isMeasurementComplete(bool debug) -{ - #if defined MS_DIGIXBEECELLULARBYPASS_DEBUG - debug = true; - #endif - // If a measurement failed to start, the sensor will never return a result, - // so the measurement time is essentially already passed - // For a cellular modem nothing happens to "start" a measurement so bit 6 - // will be set by startSingleMeasurement() as long as bit 4 was set by wake(). - // For a WiFi modem, startSingleMeasurement actually sets the WiFi connection - // parameters. - if (!bitRead(_sensorStatus, 6)) - { - if (debug) {MS_DBG(getSensorName(), - F("is not measuring and will not return a value!"));} - return true; - } - - // just defining this to not call multiple times below - uint32_t now = millis(); - - // We don't want to ping any of the modems too fast so they don't get - // overwhelmed. Make sure we've waited a little - if (now - _lastConnectionCheck < 250) return false; - - // Check how long we've been waiting for the network connection and/or a - // good measurement of signal quality. - uint32_t elapsed_in_wait; - - // Cellular modems and wifi modems with the connection paramters always - // saved to flash (like XBees) begin searching for and attempt to register - // to the network as soon as they are awake - the GPRS paramters that need - // to be set to actually *use* the network don't have to be set until we - // make the attempt to use it. - elapsed_in_wait = now - _millisSensorActivated; - - // If we're connected AND receiving valid signal strength, measurement is complete - // In theory these happen at the same time, but in reality one or the other - // may happen first. - bool isConnected = _tinyModem.isNetworkConnected(); - int signalResponse = _tinyModem.getSignalQuality(); - if (isConnected && signalResponse != 0 && signalResponse != 99) - { - if (debug) MS_DBG(F("It's been"), (elapsed_in_wait), F("ms, and"), - getSensorName(), F("is now registered on the network and reporting valid signal strength!")); - _lastConnectionCheck = now; - return true; - } - - // If we've exceeded the allowed time to wait for the network, give up - if (elapsed_in_wait > XBEE_SIGNALQUALITY_TIME_MS) - { - if (debug) MS_DBG(F("It's been"), (elapsed_in_wait), F("ms, and"), - getSensorName(), F("has maxed out wait for network registration! Ending wait.")); - // Leave status bits and times set - can still get a valid value! - return true; - } - - // If the modem isn't registered yet or doesn't report valid signal, we still need to wait - _lastConnectionCheck = now; - return false; -} - - bool DigiXBeeCellularBypass::addSingleMeasurementResult(void) { bool success = true; @@ -219,139 +145,3 @@ bool DigiXBeeCellularBypass::addSingleMeasurementResult(void) return success; } - - -bool DigiXBeeCellularBypass::connectInternet(uint32_t maxConnectionTime) -{ - bool retVal = true; - - if (bitRead(_sensorStatus, 1) == 0 || bitRead(_sensorStatus, 2) == 0) // NOT yet powered - { - modemPowerUp(); - } - if (bitRead(_sensorStatus, 3) == 0) // No attempts yet to wake the modem - { - waitForWarmUp(); - retVal &= wake(); - } - if (bitRead(_sensorStatus, 0) == 0) // Not yet setup - { - retVal &= setup(); // Set-up if necessary - } - if (!retVal) - { - MS_DBG(F("Modem did't wake up! Cannot connect to the internet!")); - return retVal; - } - - // Check that the modem is responding to AT commands. If not, give up. - #if defined MS_DIGIXBEECELLULARBYPASS_DEBUG - uint32_t start = millis(); - #endif - MS_DBG(F("\nWaiting for"), getSensorName(), F("to respond to AT commands...")); - if (!_tinyModem.testAT(_stabilizationTime_ms + 500)) - { - MS_DBG(F("No response to AT commands! Cannot connect to the internet!")); - return false; - } - else MS_DBG(F("... AT OK after"), millis() - start, F("milliseconds!")); - - MS_DBG(F("\nWaiting up to"), maxConnectionTime/1000, - F("seconds for cellular network registration...")); - if (_tinyModem.waitForNetwork(maxConnectionTime)) - { - MS_DBG(F("... Registered after"), millis() - start, - F("milliseconds. Connecting to GPRS...")); - _tinyModem.gprsConnect(_apn, "", ""); - MS_DBG(F("... Connected after"), millis() - start, - F("milliseconds.")); - retVal = true; - } - else - { - MS_DBG(F("...GPRS connection failed.")); - return false; - } - return retVal; -} - - -void DigiXBeeCellularBypass::disconnectInternet(void) -{ - #if defined MS_DIGIXBEECELLULARBYPASS_DEBUG - uint32_t start = millis(); - #endif - _tinyModem.gprsDisconnect(); - MS_DBG(F("Disconnected from cellular network after"), millis() - start, - F("milliseconds.")); -} - - - -// Get the time from NIST via TIME protocol (rfc868) -// This would be much more efficient if done over UDP, but I'm doing it -// over TCP because I don't have a UDP library for all the modems. -uint32_t DigiXBeeCellularBypass::getNISTTime(void) -{ - // bail if not connected to the internet - if (!_tinyModem.isGprsConnected()) - { - MS_DBG(F("No internet connection, cannot connect to NIST.")); - return 0; - } - - // Must ensure that we do not ping the daylight more than once every 4 seconds - // NIST clearly specifies here that this is a requirement for all software - // that accesses its servers: https://tf.nist.gov/tf-cgi/servers.cgi - while (millis() < _lastNISTrequest + 4000) {} - - // Make TCP connection - MS_DBG(F("Connecting to NIST daytime Server")); - bool connectionMade = false; - connectionMade = _tinyClient->connect("time.nist.gov", 37); - - // Wait up to 5 seconds for a response - if (connectionMade) - { - long start = millis(); - while (_tinyClient && _tinyClient->available() < 4 && millis() - start < 5000L){} - - if (_tinyClient->available() >= 4) - { - MS_DBG(F("\nNIST responded after"), millis() - start, F("ms")); - // Response is returned as 32-bit number as soon as connection is made - // Connection is then immediately closed, so there is no need to close it - uint32_t secFrom1900 = 0; - byte response[4] = {0}; - for (uint8_t i = 0; i < 4; i++) - { - response[i] = _tinyClient->read(); - MS_DBG(F("\nResponse Byte"), i, ':', (char)response[i], - '=', response[i], '=', String(response[i], BIN)); - secFrom1900 += 0x000000FF & response[i]; - // MS_DBG(F("\nseconds from 1900 after byte:"),String(secFrom1900, BIN)); - if (i+1 < 4) {secFrom1900 = secFrom1900 << 8;} - } - MS_DBG(F("\nSeconds from 1900 returned by NIST (UTC):"), - secFrom1900, '=', String(secFrom1900, BIN)); - - // Close the TCP connection, just in case - _tinyClient->stop(); - - // Return the timestamp - uint32_t unixTimeStamp = secFrom1900 - 2208988800; - MS_DBG(F("\nUnix Timestamp returned by NIST (UTC):"), unixTimeStamp); - // If before Jan 1, 2017 or after Jan 1, 2030, most likely an error - if (unixTimeStamp < 1483228800) return 0; - else if (unixTimeStamp > 1893456000) return 0; - else return unixTimeStamp; - } - else - { - MS_DBG(F("NIST Time server did not respond!")); - return 0; - } - } - else MS_DBG(F("Unable to open TCP to NIST!")); - return 0; -} diff --git a/src/modems/DigiXBeeCellularBypass.h b/src/modems/DigiXBeeCellularBypass.h index 6e7c62075..bfd50f94f 100644 --- a/src/modems/DigiXBeeCellularBypass.h +++ b/src/modems/DigiXBeeCellularBypass.h @@ -48,11 +48,14 @@ class DigiXBeeCellularBypass : public DigiXBee uint32_t getNISTTime(void) override; + TinyGsm _tinyModem; + Stream *_modemStream; + +protected: bool didATRespond(void) override; + bool isInternetAvailable(void) override; bool extraModemSetup(void) override; - TinyGsm _tinyModem; - private: const char *_apn; diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index 58395f237..a0a3a03e3 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -9,6 +9,7 @@ // Included Dependencies #include "DigiXBeeCellularTransparent.h" +#include "modems/LoggerModemMacros.h" // Constructors DigiXBeeCellularTransparent::DigiXBeeCellularTransparent(Stream* modemStream, @@ -24,13 +25,15 @@ DigiXBeeCellularTransparent::DigiXBeeCellularTransparent(Stream* modemStream, _apn = apn; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); _tinyClient = tinyClient; + _modemStream = modemStream; } -bool DigiXBeeCellularTransparent::didATRespond(void) -{ - return _tinyModem.testAT(10); -} +MS_MODEM_DID_AT_RESPOND(DigiXBeeCellularTransparent); +MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeCellularTransparent); +MS_MODEM_IS_MEASUREMENT_COMPLETE(DigiXBeeCellularTransparent); +MS_MODEM_CONNECT_INTERNET(DigiXBeeCellularTransparent); +MS_MODEM_GET_NIST_TIME(DigiXBeeCellularTransparent); bool DigiXBeeCellularTransparent::extraModemSetup(void) @@ -91,83 +94,6 @@ bool DigiXBeeCellularTransparent::extraModemSetup(void) } -// This checks to see if enough time has passed for measurement completion -// In the case of the modem, we consider a measurement to be "complete" when -// the modem has registered on the network *and* returns good signal strength. -// In theory, both of these things happen at the same time - as soon as the -// module detects a network with sufficient signal strength, it connects and -// will respond corretly to requests for its connection status and the signal -// strength. In reality sometimes the modem might respond with successful -// network connection before it responds with a valid signal strength or it -// might be able to return a real measurement of cellular signal strength but -// not be able to register to the network. We'd prefer to wait until it both -// responses are good so we're getting an actual signal strength and it's as -// close as possible to what the antenna is will see when the data publishers -// push data. -bool DigiXBeeCellularTransparent::isMeasurementComplete(bool debug) -{ - #if defined MS_DIGIXBEECELLULARTRANSPARENT_DEBUG - debug = true; - #endif - // If a measurement failed to start, the sensor will never return a result, - // so the measurement time is essentially already passed - // For a cellular modem nothing happens to "start" a measurement so bit 6 - // will be set by startSingleMeasurement() as long as bit 4 was set by wake(). - // For a Cellular modem, startSingleMeasurement actually sets the Cellular connection - // parameters. - if (!bitRead(_sensorStatus, 6)) - { - if (debug) {MS_DBG(getSensorName(), - F("is not measuring and will not return a value!"));} - return true; - } - - // just defining this to not call multiple times below - uint32_t now = millis(); - - // We don't want to ping any of the modems too fast so they don't get - // overwhelmed. Make sure we've waited a little - if (now - _lastConnectionCheck < 250) return false; - - // Check how long we've been waiting for the network connection and/or a - // good measurement of signal quality. - uint32_t elapsed_in_wait; - - // Cellular modems and wifi modems with the connection paramters always - // saved to flash (like XBees) begin searching for and attempt to register - // to the network as soon as they are awake - the GPRS paramters that need - // to be set to actually *use* the network don't have to be set until we - // make the attempt to use it. - elapsed_in_wait = now - _millisSensorActivated; - - // If we're connected AND receiving valid signal strength, measurement is complete - // In theory these happen at the same time, but in reality one or the other - // may happen first. - bool isConnected = _tinyModem.isNetworkConnected(); - int signalResponse = _tinyModem.getSignalQuality(); - if (isConnected && signalResponse != 0 && signalResponse != 99) - { - if (debug) MS_DBG(F("It's been"), (elapsed_in_wait), F("ms, and"), - getSensorName(), F("is now registered on the network and reporting valid signal strength!")); - _lastConnectionCheck = now; - return true; - } - - // If we've exceeded the allowed time to wait for the network, give up - if (elapsed_in_wait > XBEE_SIGNALQUALITY_TIME_MS) - { - if (debug) MS_DBG(F("It's been"), (elapsed_in_wait), F("ms, and"), - getSensorName(), F("has maxed out wait for network registration! Ending wait.")); - // Leave status bits and times set - can still get a valid value! - return true; - } - - // If the modem isn't registered yet or doesn't report valid signal, we still need to wait - _lastConnectionCheck = now; - return false; -} - - bool DigiXBeeCellularTransparent::addSingleMeasurementResult(void) { bool success = true; @@ -211,134 +137,7 @@ bool DigiXBeeCellularTransparent::addSingleMeasurementResult(void) } -bool DigiXBeeCellularTransparent::connectInternet(uint32_t maxConnectionTime) -{ - bool retVal = true; - - if (bitRead(_sensorStatus, 1) == 0 || bitRead(_sensorStatus, 2) == 0) // NOT yet powered - { - modemPowerUp(); - } - if (bitRead(_sensorStatus, 3) == 0) // No attempts yet to wake the modem - { - waitForWarmUp(); - retVal &= wake(); - } - if (bitRead(_sensorStatus, 0) == 0) // Not yet setup - { - retVal &= setup(); // Set-up if necessary - } - if (!retVal) - { - MS_DBG(F("Modem did't wake up! Cannot connect to the internet!")); - return retVal; - } - - // Check that the modem is responding to AT commands. If not, give up. - #if defined MS_DIGIXBEECELLULARTRANSPARENT_DEBUG - uint32_t start = millis(); - #endif - MS_DBG(F("\nWaiting for"), getSensorName(), F("to respond to AT commands...")); - if (!_tinyModem.testAT(_stabilizationTime_ms + 500)) - { - MS_DBG(F("No response to AT commands! Cannot connect to the internet!")); - return false; - } - else MS_DBG(F("... AT OK after"), millis() - start, F("milliseconds!")); - - MS_DBG(F("\nWaiting up to"), maxConnectionTime/1000, - F("seconds for cellular network registration...")); - if (_tinyModem.waitForNetwork(maxConnectionTime)) - { - MS_DBG(F("... Registered after"), millis() - start, - F("milliseconds. Connecting to GPRS...")); - _tinyModem.gprsConnect(_apn, "", ""); - MS_DBG(F("... Connected after"), millis() - start, - F("milliseconds.")); - retVal = true; - } - else - { - MS_DBG(F("...GPRS connection failed.")); - return false; - } -} - - void DigiXBeeCellularTransparent::disconnectInternet(void) { // XBee doesn't like to disconnect at all, so we're doing nothing } - - - -// Get the time from NIST via TIME protocol (rfc868) -// This would be much more efficient if done over UDP, but I'm doing it -// over TCP because I don't have a UDP library for all the modems. -uint32_t DigiXBeeCellularTransparent::getNISTTime(void) -{ - // bail if not connected to the internet - if (!_tinyModem.isGprsConnected()) - { - MS_DBG(F("No internet connection, cannot connect to NIST.")); - return 0; - } - - // Must ensure that we do not ping the daylight more than once every 4 seconds - // NIST clearly specifies here that this is a requirement for all software - // that accesses its servers: https://tf.nist.gov/tf-cgi/servers.cgi - while (millis() < _lastNISTrequest + 4000) {} - - // Make TCP connection - MS_DBG(F("Connecting to NIST daytime Server")); - bool connectionMade = false; - IPAddress ip(129, 6, 15, 30); // This is the IP address of time-c-g.nist.gov - connectionMade = _tinyClient->connect(ip, 37); // XBee's address lookup falters on time.nist.gov - _tinyClient->print('!'); // Need to send something before connection is made - delay(100); // Need this delay! Can get away with 50, but 100 is safer. - - // Wait up to 5 seconds for a response - if (connectionMade) - { - long start = millis(); - while (_tinyClient && _tinyClient->available() < 4 && millis() - start < 5000L){} - - if (_tinyClient->available() >= 4) - { - MS_DBG(F("\nNIST responded after"), millis() - start, F("ms")); - // Response is returned as 32-bit number as soon as connection is made - // Connection is then immediately closed, so there is no need to close it - uint32_t secFrom1900 = 0; - byte response[4] = {0}; - for (uint8_t i = 0; i < 4; i++) - { - response[i] = _tinyClient->read(); - MS_DBG(F("\nResponse Byte"), i, ':', (char)response[i], - '=', response[i], '=', String(response[i], BIN)); - secFrom1900 += 0x000000FF & response[i]; - // MS_DBG(F("\nseconds from 1900 after byte:"),String(secFrom1900, BIN)); - if (i+1 < 4) {secFrom1900 = secFrom1900 << 8;} - } - MS_DBG(F("\nSeconds from 1900 returned by NIST (UTC):"), - secFrom1900, '=', String(secFrom1900, BIN)); - - // Close the TCP connection, just in case - _tinyClient->stop(); - - // Return the timestamp - uint32_t unixTimeStamp = secFrom1900 - 2208988800; - MS_DBG(F("\nUnix Timestamp returned by NIST (UTC):"), unixTimeStamp); - // If before Jan 1, 2017 or after Jan 1, 2030, most likely an error - if (unixTimeStamp < 1483228800) return 0; - else if (unixTimeStamp > 1893456000) return 0; - else return unixTimeStamp; - } - else - { - MS_DBG(F("NIST Time server did not respond!")); - return 0; - } - } - else MS_DBG(F("Unable to open TCP to NIST!")); - return 0; -} diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index 371ac9420..db2d71f69 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -49,11 +49,14 @@ class DigiXBeeCellularTransparent : public DigiXBee uint32_t getNISTTime(void) override; + TinyGsm _tinyModem; + Stream *_modemStream; + +protected: bool didATRespond(void) override; + bool isInternetAvailable(void) override; bool extraModemSetup(void) override; - TinyGsm _tinyModem; - private: const char *_apn; diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index e0f977af4..aef08d52b 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -7,8 +7,10 @@ *This file is for Digi S6B Wifi XBee's */ -// Included Dependencies +// Included DependenciesV #include "DigiXBeeWifi.h" +#include "modems/LoggerModemMacros.h" + // Constructors DigiXBeeWifi::DigiXBeeWifi(Stream* modemStream, @@ -25,13 +27,15 @@ DigiXBeeWifi::DigiXBeeWifi(Stream* modemStream, _pwd = pwd; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); _tinyClient = tinyClient; + _modemStream = modemStream; } -bool DigiXBeeWifi::didATRespond(void) -{ - return _tinyModem.testAT(10); -} +MS_MODEM_DID_AT_RESPOND(DigiXBeeWifi); +MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeWifi); +MS_MODEM_IS_MEASUREMENT_COMPLETE(DigiXBeeWifi); +MS_MODEM_CONNECT_INTERNET(DigiXBeeWifi); +MS_MODEM_GET_NIST_TIME(DigiXBeeWifi); bool DigiXBeeWifi::extraModemSetup(void) @@ -72,83 +76,6 @@ bool DigiXBeeWifi::extraModemSetup(void) } -// This checks to see if enough time has passed for measurement completion -// In the case of the modem, we consider a measurement to be "complete" when -// the modem has registered on the network *and* returns good signal strength. -// In theory, both of these things happen at the same time - as soon as the -// module detects a network with sufficient signal strength, it connects and -// will respond corretly to requests for its connection status and the signal -// strength. In reality sometimes the modem might respond with successful -// network connection before it responds with a valid signal strength or it -// might be able to return a real measurement of cellular signal strength but -// not be able to register to the network. We'd prefer to wait until it both -// responses are good so we're getting an actual signal strength and it's as -// close as possible to what the antenna is will see when the data publishers -// push data. -bool DigiXBeeWifi::isMeasurementComplete(bool debug) -{ - #if defined MS_DIGIXBEEWIFI_DEBUG - debug = true; - #endif - // If a measurement failed to start, the sensor will never return a result, - // so the measurement time is essentially already passed - // For a cellular modem nothing happens to "start" a measurement so bit 6 - // will be set by startSingleMeasurement() as long as bit 4 was set by wake(). - // For a WiFi modem, startSingleMeasurement actually sets the WiFi connection - // parameters. - if (!bitRead(_sensorStatus, 6)) - { - if (debug) {MS_DBG(getSensorName(), - F("is not measuring and will not return a value!"));} - return true; - } - - // just defining this to not call multiple times below - uint32_t now = millis(); - - // We don't want to ping any of the modems too fast so they don't get - // overwhelmed. Make sure we've waited a little - if (now - _lastConnectionCheck < 250) return false; - - // Check how long we've been waiting for the network connection and/or a - // good measurement of signal quality. - uint32_t elapsed_in_wait; - - // Cellular modems and wifi modems with the connection paramters always - // saved to flash (like XBees) begin searching for and attempt to register - // to the network as soon as they are awake - the GPRS paramters that need - // to be set to actually *use* the network don't have to be set until we - // make the attempt to use it. - elapsed_in_wait = now - _millisSensorActivated; - - // If we're connected AND receiving valid signal strength, measurement is complete - // In theory these happen at the same time, but in reality one or the other - // may happen first. - bool isConnected = _tinyModem.isNetworkConnected(); - int signalResponse = _tinyModem.getSignalQuality(); - if (isConnected && signalResponse != 0 && signalResponse != 99) - { - if (debug) MS_DBG(F("It's been"), (elapsed_in_wait), F("ms, and"), - getSensorName(), F("is now registered on the network and reporting valid signal strength!")); - _lastConnectionCheck = now; - return true; - } - - // If we've exceeded the allowed time to wait for the network, give up - if (elapsed_in_wait > XBEE_SIGNALQUALITY_TIME_MS) - { - if (debug) MS_DBG(F("It's been"), (elapsed_in_wait), F("ms, and"), - getSensorName(), F("has maxed out wait for network registration! Ending wait.")); - // Leave status bits and times set - can still get a valid value! - return true; - } - - // If the modem isn't registered yet or doesn't report valid signal, we still need to wait - _lastConnectionCheck = now; - return false; -} - - bool DigiXBeeWifi::addSingleMeasurementResult(void) { bool success = true; @@ -210,133 +137,7 @@ bool DigiXBeeWifi::addSingleMeasurementResult(void) } -bool DigiXBeeWifi::connectInternet(uint32_t maxConnectionTime) -{ - bool retVal = true; - - if (bitRead(_sensorStatus, 1) == 0 || bitRead(_sensorStatus, 2) == 0) // NOT yet powered - { - modemPowerUp(); - } - if (bitRead(_sensorStatus, 3) == 0) // No attempts yet to wake the modem - { - waitForWarmUp(); - retVal &= wake(); - } - if (bitRead(_sensorStatus, 0) == 0) // Not yet setup - { - retVal &= setup(); // Set-up if necessary - } - if (!retVal) - { - MS_DBG(F("Modem did't wake up! Cannot connect to the internet!")); - return retVal; - } - - // Check that the modem is responding to AT commands. If not, give up. - #if defined MS_DIGIXBEEWIFI_DEBUG - uint32_t start = millis(); - #endif - MS_DBG(F("\nWaiting for"), getSensorName(), F("to respond to AT commands...")); - if (!_tinyModem.testAT(_stabilizationTime_ms + 500)) - { - MS_DBG(F("No response to AT commands! Cannot connect to the internet!")); - return false; - } - else MS_DBG(F("... AT OK after"), millis() - start, F("milliseconds!")); - - MS_DBG(F("\nAttempting to connect to WiFi network...")); - if (!(_tinyModem.isNetworkConnected())) - { - MS_DBG(F("Sending credentials...")); - while (!_tinyModem.networkConnect(_ssid, _pwd)) {}; - MS_DBG(F("Waiting up to"), maxConnectionTime/1000, - F("seconds for connection")); - if (!_tinyModem.waitForNetwork(maxConnectionTime)) - { - MS_DBG(F("... WiFi connection failed")); - return false; - } - } - MS_DBG(F("... WiFi connected after"), millis() - start, - F("milliseconds!")); - return true; -} - - void DigiXBeeWifi::disconnectInternet(void) { // XBee doesn't like to disconnect at all, so we're doing nothing } - - -// Get the time from NIST via TIME protocol (rfc868) -// This would be much more efficient if done over UDP, but I'm doing it -// over TCP because I don't have a UDP library for all the modems. -uint32_t DigiXBeeWifi::getNISTTime(void) -{ - // bail if not connected to the internet - if (!_tinyModem.isNetworkConnected()) - { - MS_DBG(F("No internet connection, cannot connect to NIST.")); - return 0; - } - - // Must ensure that we do not ping the daylight more than once every 4 seconds - // NIST clearly specifies here that this is a requirement for all software - // that accesses its servers: https://tf.nist.gov/tf-cgi/servers.cgi - while (millis() < _lastNISTrequest + 4000) {} - - // Make TCP connection - MS_DBG(F("Connecting to NIST daytime Server")); - bool connectionMade = false; - IPAddress ip(129, 6, 15, 30); // This is the IP address of time-c-g.nist.gov - connectionMade = _tinyClient->connect(ip, 37); // XBee's address lookup falters on time.nist.gov - _tinyClient->print('!'); // Need to send something before connection is made - delay(100); // Need this delay! Can get away with 50, but 100 is safer. - - // Wait up to 5 seconds for a response - if (connectionMade) - { - long start = millis(); - while (_tinyClient && _tinyClient->available() < 4 && millis() - start < 5000L){} - - if (_tinyClient->available() >= 4) - { - MS_DBG(F("\nNIST responded after"), millis() - start, F("ms")); - // Response is returned as 32-bit number as soon as connection is made - // Connection is then immediately closed, so there is no need to close it - uint32_t secFrom1900 = 0; - byte response[4] = {0}; - for (uint8_t i = 0; i < 4; i++) - { - response[i] = _tinyClient->read(); - MS_DBG(F("\nResponse Byte"), i, ':', (char)response[i], - '=', response[i], '=', String(response[i], BIN)); - secFrom1900 += 0x000000FF & response[i]; - // MS_DBG(F("\nseconds from 1900 after byte:"),String(secFrom1900, BIN)); - if (i+1 < 4) {secFrom1900 = secFrom1900 << 8;} - } - MS_DBG(F("\nSeconds from 1900 returned by NIST (UTC):"), - secFrom1900, '=', String(secFrom1900, BIN)); - - // Close the TCP connection, just in case - _tinyClient->stop(); - - // Return the timestamp - uint32_t unixTimeStamp = secFrom1900 - 2208988800; - MS_DBG(F("\nUnix Timestamp returned by NIST (UTC):"), unixTimeStamp); - // If before Jan 1, 2017 or after Jan 1, 2030, most likely an error - if (unixTimeStamp < 1483228800) return 0; - else if (unixTimeStamp > 1893456000) return 0; - else return unixTimeStamp; - } - else - { - MS_DBG(F("NIST Time server did not respond!")); - return 0; - } - } - else MS_DBG(F("Unable to open TCP to NIST!")); - return 0; -} diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index 76fcca960..e21019129 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -49,11 +49,14 @@ class DigiXBeeWifi : public DigiXBee uint32_t getNISTTime(void) override; + TinyGsm _tinyModem; + Stream *_modemStream; + +protected: bool didATRespond(void) override; + bool isInternetAvailable(void) override; bool extraModemSetup(void) override; - TinyGsm _tinyModem; - private: const char *_ssid; const char *_pwd; diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp new file mode 100644 index 000000000..9746765d9 --- /dev/null +++ b/src/modems/EspressifESP8266.cpp @@ -0,0 +1,281 @@ +/* + *EspressifESP8266.cpp + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file SHOULD work for essentially any breakout of the Espressif ESP8266 + *wifi chip as long as the chip has been flashed with Espressif's AT command + *firmware. +*/ + +// Included Dependencies +#include "EspressifESP8266.h" +#include "modems/LoggerModemMacros.h" + + +// Constructor +EspressifESP8266::EspressifESP8266(Stream* modemStream, + int8_t powerPin, int8_t statusPin, + int8_t modemResetPin, int8_t modemSleepRqPin, + const char *ssid, const char *pwd, + uint8_t measurementsToAverage) + : loggerModem(powerPin, statusPin, HIGH, + modemResetPin, modemSleepRqPin, + ESP8266_STATUS_TIME_MS, ESP8266_DISCONNECT_TIME_MS, + ESP8266_WARM_UP_TIME_MS, ESP8266_ATRESPONSE_TIME_MS, + ESP8266_SIGNALQUALITY_TIME_MS, + measurementsToAverage), + _tinyModem(*modemStream) +{ + _ssid = ssid; + _pwd = pwd; + TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); + _tinyClient = tinyClient; + _modemStream = modemStream; + _statusLevel = HIGH; +} + + +MS_MODEM_DID_AT_RESPOND(EspressifESP8266); +MS_MODEM_IS_INTERNET_AVAILABLE(EspressifESP8266); +MS_MODEM_IS_MEASUREMENT_COMPLETE(EspressifESP8266); +MS_MODEM_CONNECT_INTERNET(EspressifESP8266); +MS_MODEM_DISCONNECT_INTERNET(EspressifESP8266); +MS_MODEM_GET_NIST_TIME(EspressifESP8266); + + +// A helper function to wait for the esp to boot and immediately change some settings +// We'll use this in the wake function +bool EspressifESP8266::ESPwaitForBoot(void) +{ + // Wait for boot - finished when characters start coming + // NOTE: After every "hard" reset (either power off or via RST-B), the ESP + // sends out a boot log from the ROM on UART1 at 74880 baud. We're not + // going to worry about the odd baud rate since we're simply throwing the + // characters away. + delay(200); // It will take at least this long + uint32_t start = millis(); + bool success = false; + while (!_modemStream->available() && millis() - start < 1000) {} + if (_modemStream->available()) + { + success = true; + // Read the boot log to empty it from the serial buffer + while (_modemStream->available()) + { + _modemStream->read(); + delay(2); + } + // Have to make sure echo is off or all AT commands will be confused + _tinyModem.sendAT(F("E0")); + success &= _tinyModem.waitResponse() == 1; + // re-run init to set mux and station mode + success &= _tinyModem.init(); + } + return success; +} + + +// Create the wake and sleep methods for the modem +// These can be functions of any type and must return a boolean +bool EspressifESP8266::modemSleepFxn(void) +{ + // Use this if you have GPIO16 connected to the reset pin to wake from deep sleep + // but no other MCU pin connected to the reset pin. + // NOTE: This will NOT work nicely with "testingMode" + /*if (loggingInterval > 1) + { + uint32_t sleepSeconds = (((uint32_t)loggingInterval) * 60 * 1000) - 75000L; + String sleepCommand = String(sleepSeconds); + _tinyModem.sendAT(F("+GSLP="), sleepCommand); + // Power down for 1 minute less than logging interval + // Better: Calculate length of loop and power down for logging interval - loop time + return _tinyModem.waitResponse() == 1; + }*/ + // Use this if you have an MCU pin connected to the ESP's reset pin to wake from deep sleep + if (_modemResetPin >= 0) + { + digitalWrite(_modemLEDPin, LOW); + return _tinyModem.poweroff(); + } + // Use this if you don't have access to the ESP8266's reset pin for deep sleep but you + // do have access to another GPIO pin for light sleep. This also sets up another + // pin to view the sleep status. + else if (_modemSleepRqPin >= 0 && _dataPin >= 0) + { + _tinyModem.sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0,"), + String(espStatusPin), ',', _statusLevel); + bool success = _tinyModem.waitResponse() == 1; + _tinyModem.sendAT(F("+SLEEP=1")); + success &= _tinyModem.waitResponse() == 1; + digitalWrite(_modemLEDPin, LOW); + return success; + } + // Light sleep without the status pin + else if (_modemSleepRqPin >= 0 && _dataPin < 0) + { + _tinyModem.sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0")); + bool success = _tinyModem.waitResponse() == 1; + _tinyModem.sendAT(F("+SLEEP=1")); + success &= _tinyModem.waitResponse() == 1; + digitalWrite(_modemLEDPin, LOW); + return success; + } + else // DON'T go to sleep if we can't wake up! + { + return true; + } +} + + +bool EspressifESP8266::modemWakeFxn(void) +{ + bool success = true; + if (_powerPin >= 0) // Turns on when power is applied + { + digitalWrite(_modemLEDPin, HIGH); // Because the ESP8266 doesn't have any lights + success &= ESPwaitForBoot(); + if (!success) + { + digitalWrite(_modemLEDPin, LOW); // Turn off light if the boot failed + } + return success; + } + else if (_modemResetPin >= 0) + { + digitalWrite(_modemLEDPin, HIGH); + digitalWrite(_modemResetPin, LOW); + delay(1); + digitalWrite(_modemResetPin, HIGH); + success &= ESPwaitForBoot(); + if (!success) + { + digitalWrite(_modemLEDPin, LOW); // Turn off light if the boot failed + } + return success; + } + else if (_modemSleepRqPin >= 0) + { + digitalWrite(_modemSleepRqPin, LOW); + delay(1); + digitalWrite(_modemSleepRqPin, HIGH); + digitalWrite(_modemLEDPin, HIGH); + // Don't have to wait for a boot if using light sleep + return true; + } + else + { + return true; + } +} + + +// Set up the light-sleep status pin, if applicable +bool EspressifESP8266::extraModemSetup(void) +{ + // Slow down the baud rate for slow processors - and save the change to + // the ESP's non-volatile memory so we don't have to do it every time + // #if F_CPU == 8000000L + // if (modemBaud > 57600) + // { + // _modemStream->begin(modemBaud); + // _tinyModem.sendAT(F("+UART_DEF=9600,8,1,0,0")); + // _tinyModem.waitResponse(); + // _modemStream->end(); + // _modemStream->begin(9600); + // } + // #endif + if (_powerPin < 0 && _modemResetPin < 0 && _modemSleepRqPin >= 0 && _dataPin >= 0) + { + _tinyModem.sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0,"), + String(espStatusPin), ',', _statusLevel); + _tinyModem.waitResponse(); + } + return true; +} + + +bool EspressifESP8266::startSingleMeasurement(void) +{ + bool success = true; + MS_DBG(F("Starting measurement on"), getSensorName()); + // Set the status bits for measurement requested (bit 5) + // Setting this bit even if we failed to start a measurement to show that an attempt was made. + _sensorStatus |= 0b00100000; + + // Check if the modem was successfully awoken (bit 4 set) + // Only mark the measurement request time if it is + if (bitRead(_sensorStatus, 4)) + { + // check if the modem was successfully set up, run set up if not + if (!bitRead(_sensorStatus, 0)) + { + MS_DBG(getSensorName(), F("was never properly set up, attempting setup now!")); + setup(); + } + + // For the wifi modems, the SSID and password need to be set before they + // can join a network. + success &= _tinyModem.networkConnect(_ssid, _pwd); + + // Mark the time that a measurement was requested + _millisMeasurementRequested = millis(); + // Set the status bit for measurement start success (bit 6) + _sensorStatus |= 0b01000000; + } + // Otherwise, make sure that the measurement start time and success bit (bit 6) are unset + else + { + MS_DBG(getSensorNameAndLocation(), + F("isn't awake/active! A measurement cannot be started.")); + _millisMeasurementRequested = 0; + _sensorStatus &= 0b10111111; + success = false; + } + return success; +} + + +bool EspressifESP8266::addSingleMeasurementResult(void) +{ + bool success = true; + + // Initialize float variable + int16_t signalQual = -9999; + int16_t percent = -9999; + int16_t rssi = -9999; + + // Check a measurement was *successfully* started (status bit 6 set) + // Only go on to get a result if it was + if (bitRead(_sensorStatus, 6)) + { + + // Get signal quality + // NOTE: We can't actually distinguish between a bad modem response, no + // modem response, and a real response from the modem of no service/signal. + // The TinyGSM getSignalQuality function returns the same "no signal" + // value (99 CSQ or 0 RSSI) in all 3 cases. + MS_DBG(F("Getting signal quality:")); + signalQual = _tinyModem.getSignalQuality(); + MS_DBG(F("Raw signal quality:"), signalQual); + + // Convert signal quality to RSSI, if necessary + rssi = signalQual; + percent = getPctFromRSSI(signalQual); + + MS_DBG(F("RSSI:"), rssi); + MS_DBG(F("Percent signal strength:"), percent); + } + else MS_DBG(getSensorName(), F("is not connected to the network; unable to get signal quality!")); + + verifyAndAddMeasurementResult(RSSI_VAR_NUM, rssi); + verifyAndAddMeasurementResult(PERCENT_SIGNAL_VAR_NUM, percent); + + // Unset the time stamp for the beginning of this measurement + _millisMeasurementRequested = 0; + // Unset the status bits for a measurement request (bits 5 & 6) + _sensorStatus &= 0b10011111; + + return success; +} diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h new file mode 100644 index 000000000..1f549f39b --- /dev/null +++ b/src/modems/EspressifESP8266.h @@ -0,0 +1,82 @@ +/* + *EspressifESP8266.h + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file SHOULD work for essentially any breakout of the Espressif ESP8266 + *wifi chip as long as the chip has been flashed with Espressif's AT command + *firmware. +*/ + +// Header Guards +#ifndef EspressifESP8266_h +#define EspressifESP8266_h + +// Debugging Statement +// #define MS_ESPRESSIFESP8266_DEBUG + +#ifdef MS_ESPRESSIFESP8266_DEBUG +#define MS_DEBUGGING_STD +#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT +#endif + +#define TINY_GSM_MODEM_ESP8266 + +#define ESP8266_STATUS_TIME_MS 350 // N/A? - No status pin - use boot time if using a GPIO pin +#define ESP8266_DISCONNECT_TIME_MS 500 // power down ??? + +#define ESP8266_WARM_UP_TIME_MS 0 // Module turns on when power is applied +#define ESP8266_ATRESPONSE_TIME_MS 5000L + +#define ESP8266_SIGNALQUALITY_TIME_MS 15000L + +// Included Dependencies +#include "ModSensorDebugger.h" +#include "LoggerModem.h" +#include "TinyGsmClient.h" + + +class EspressifESP8266 : public loggerModem +{ + +public: + // Constructors + EspressifESP8266(Stream* modemStream, + int8_t powerPin, int8_t statusPin, + int8_t modemResetPin, int8_t modemSleepRqPin, + const char *ssid, const char *pwd, + uint8_t measurementsToAverage = 1); + + + // The a measurement is "complete" when the modem is registered on the network. + // For a cellular modem, this actually sets the GPRS bearer/APN!! + bool startSingleMeasurement(void) override; + bool isMeasurementComplete(bool debug=false) override; + bool addSingleMeasurementResult(void) override; + + bool connectInternet(uint32_t maxConnectionTime = 50000L) override; + void disconnectInternet(void) override; + + uint32_t getNISTTime(void) override; + + TinyGsm _tinyModem; + Stream *_modemStream; + +protected: + virtual bool didATRespond(void) override; + virtual bool isInternetAvailable(void) override; + virtual bool modemSleepFxn(void) override; + virtual bool modemWakeFxn(void) override; + virtual bool extraModemSetup(void)override; + +private: + bool ESPwaitForBoot(void); + const char *_ssid; + const char *_pwd; + + int8_t espSleepRqPin; + int8_t espStatusPin; +}; + +#endif diff --git a/src/modems/IteadWee.h b/src/modems/IteadWee.h deleted file mode 100644 index 8cf19695a..000000000 --- a/src/modems/IteadWee.h +++ /dev/null @@ -1,223 +0,0 @@ -/* - *IteadWee.h - *This file is part of the EnviroDIY modular sensors library for Arduino - * - *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). - * - *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module -*/ - -// Header Guards -#ifndef ModularSensorsSpecificModem_h -#define ModularSensorsSpecificModem_h - -// Debugging Statement -// #define MS_ITEADWEE_DEBUG - -#ifdef MS_ITEADWEE_DEBUG -#define MS_DEBUGGING_STD -#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT -#endif - -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates - -// Included Dependencies -#include "ModSensorDebugger.h" -#include "LoggerModem.h" - -// ========================================================================== -// Wifi/Cellular Modem Main Chip Selection -// ========================================================================== - -// Select your modem chip - this determines the exact commands sent to it -#define TINY_GSM_MODEM_ESP8266 // Select for an ESP8266 using the DEFAULT AT COMMAND FIRMWARE - - -// ========================================================================== -// Modem Pins -// ========================================================================== - -// Declare the existance of modem pin Variables -// Use the "extern" keyword to denote that these will actually be defined in -// the main program rather than in this file. - -extern const int8_t modemVccPin; -extern const int8_t modemSleepRqPin; -extern const int8_t modemStatusPin; -extern const int8_t modemResetPin; -extern const int8_t modemLEDPin; -extern Stream &modemSerial; - -extern const int8_t espSleepRqPin; -extern const int8_t espStatusPin; - - -// ========================================================================== -// TinyGSM Client -// ========================================================================== - -// Include TinyGSM for the modem -// This include must be included below the define of the modem name! -#include - -// Create a new TinyGSM modem to run on that serial port and return a pointer to it -TinyGsm *tinyModem = new TinyGsm(modemSerial); - -// Create a new TCP client on that modem and return a pointer to it -TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); - - -// ========================================================================== -// Specific Modem On-Off Methods -// ========================================================================== - -const bool modemStatusLevel = HIGH; // The level of the status pin when the module is active (HIGH or LOW) -// const long modemBaud = 115200; // Communication speed of the modem, 115200 is default for ESP8266 - -// A helper function to wait for the esp to boot and immediately change some settings -// We'll use this in the wake function -bool ESPwaitForBoot(void) -{ - // Wait for boot - finished when characters start coming - // NOTE: After every "hard" reset (either power off or via RST-B), the ESP - // sends out a boot log from the ROM on UART1 at 74880 baud. We're not - // going to worry about the odd baud rate since we're simply throwing the - // characters away. - delay(200); // It will take at least this long - uint32_t start = millis(); - bool success = false; - while (!modemSerial.available() && millis() - start < 1000) {} - if (modemSerial.available()) - { - success = true; - // Read the boot log to empty it from the serial buffer - while (modemSerial.available()) - { - modemSerial.read(); - delay(2); - } - // Have to make sure echo is off or all AT commands will be confused - tinyModem->sendAT(F("E0")); - success &= tinyModem->waitResponse() == 1; - // re-run init to set mux and station mode - success &= tinyModem->init(); - } - return success; -} - -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -bool modemSleepFxn(void) -{ - // Use this if you have GPIO16 connected to the reset pin to wake from deep sleep - // but no other MCU pin connected to the reset pin. - // NOTE: This will NOT work nicely with "testingMode" - /*if (loggingInterval > 1) - { - uint32_t sleepSeconds = (((uint32_t)loggingInterval) * 60 * 1000) - 75000L; - String sleepCommand = String(sleepSeconds); - tinyModem->sendAT(F("+GSLP="), sleepCommand); - // Power down for 1 minute less than logging interval - // Better: Calculate length of loop and power down for logging interval - loop time - return tinyModem->waitResponse() == 1; - }*/ - // Use this if you have an MCU pin connected to the ESP's reset pin to wake from deep sleep - if (modemResetPin >= 0) - { - digitalWrite(modemLEDPin, LOW); - return tinyModem->poweroff(); - } - // Use this if you don't have access to the ESP8266's reset pin for deep sleep but you - // do have access to another GPIO pin for light sleep. This also sets up another - // pin to view the sleep status. - else if (modemSleepRqPin >= 0 && modemStatusPin >= 0) - { - tinyModem->sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0,"), - String(espStatusPin), ',', modemStatusLevel); - bool success = tinyModem->waitResponse() == 1; - tinyModem->sendAT(F("+SLEEP=1")); - success &= tinyModem->waitResponse() == 1; - digitalWrite(modemLEDPin, LOW); - return success; - } - // Light sleep without the status pin - else if (modemSleepRqPin >= 0 && modemStatusPin < 0) - { - tinyModem->sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0")); - bool success = tinyModem->waitResponse() == 1; - tinyModem->sendAT(F("+SLEEP=1")); - success &= tinyModem->waitResponse() == 1; - digitalWrite(modemLEDPin, LOW); - return success; - } - else // DON'T go to sleep if we can't wake up! - { - return true; - } -} -bool modemWakeFxn(void) -{ - bool success = true; - if (modemVccPin >= 0) // Turns on when power is applied - { - digitalWrite(modemLEDPin, HIGH); // Because the ESP8266 doesn't have any lights - success &= ESPwaitForBoot(); - if (!success) - { - digitalWrite(modemLEDPin, LOW); // Turn off light if the boot failed - } - return success; - } - else if (modemResetPin >= 0) - { - digitalWrite(modemLEDPin, HIGH); - digitalWrite(modemResetPin, LOW); - delay(1); - digitalWrite(modemResetPin, HIGH); - success &= ESPwaitForBoot(); - if (!success) - { - digitalWrite(modemLEDPin, LOW); // Turn off light if the boot failed - } - return success; - } - else if (modemSleepRqPin >= 0) - { - digitalWrite(modemSleepRqPin, LOW); - delay(1); - digitalWrite(modemSleepRqPin, HIGH); - digitalWrite(modemLEDPin, HIGH); - // Don't have to wait for a boot if using light sleep - return true; - } - else - { - return true; - } -} -// Set up the light-sleep status pin, if applicable -void extraModemSetup(void) -{ - // Slow down the baud rate for slow processors - and save the change to - // the ESP's non-volatile memory so we don't have to do it every time - // #if F_CPU == 8000000L - // if (modemBaud > 57600) - // { - // modemSerial.begin(modemBaud); - // tinyModem->sendAT(F("+UART_DEF=9600,8,1,0,0")); - // tinyModem->waitResponse(); - // modemSerial.end(); - // modemSerial.begin(9600); - // } - // #endif - if (modemVccPin < 0 && modemResetPin < 0 && modemSleepRqPin >= 0 && modemStatusPin >= 0) - { - tinyModem->sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0,"), - String(espStatusPin), ',', modemStatusLevel); - tinyModem->waitResponse(); - } -} - - - -#endif diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h new file mode 100644 index 000000000..330dd9f2b --- /dev/null +++ b/src/modems/LoggerModemMacros.h @@ -0,0 +1,338 @@ +/* + *LoggerModemMacros.h + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file contains PRE-ROCESSOR MACROS for use with logger modems + * NOTE: These are NOT FUNCTIONS they are pre-processor macros that I'm + * collecting here to avoid writing functions later. +*/ + +// Header Guards +#ifndef LoggerModemMacros_h +#define LoggerModemMacros_h + +#if defined MS_DEBUGGING_STD +#define MS_MODEM_START_TIMER uint32_t start = millis(); +#else +#define MS_MODEM_START_TIMER(...) +#endif + + + +#define MS_MODEM_DID_AT_RESPOND(specificModem) \ +bool specificModem::didATRespond(void) \ +{ \ + return _tinyModem.testAT(10); \ +} + + +#if defined TINY_GSM_MODEM_HAS_GPRS +#define MS_MODEM_IS_INTERNET_AVAILABLE(specificModem) \ +bool specificModem::isInternetAvailable(void) \ +{ \ + return _tinyModem.isGprsConnected(); \ +} +#else +#define MS_MODEM_IS_INTERNET_AVAILABLE(specificModem) \ +bool specificModem::isInternetAvailable(void) \ +{ \ + return _tinyModem.isNetworkConnected(); \ +} +#endif + + +// This checks to see if enough time has passed for measurement completion +// In the case of the modem, we consider a measurement to be "complete" when +// the modem has registered on the network *and* returns good signal strength. +// In theory, both of these things happen at the same time - as soon as the +// module detects a network with sufficient signal strength, it connects and +// will respond corretly to requests for its connection status and the signal +// strength. In reality sometimes the modem might respond with successful +// network connection before it responds with a valid signal strength or it +// might be able to return a real measurement of cellular signal strength but +// not be able to register to the network. We'd prefer to wait until it both +// responses are good so we're getting an actual signal strength and it's as +// close as possible to what the antenna is will see when the data publishers +// push data. +#if defined TINY_GSM_MODEM_XBEE || defined TINY_GSM_MODEM_HAS_GPRS +// Cellular modems and wifi modems with the connection paramters always +// saved to flash (like XBees) begin searching for and attempt to register +// to the network as soon as they are awake - the GPRS paramters that need +// to be set to actually *use* the network don't have to be set until we +// make the attempt to use it. +#define MS_MODEM_IMEC_WAIT_LINE elapsed_in_wait = now - _millisSensorActivated; +#else +// For Wifi modems without settings in flash, the connection parameters +// need to set before it can register to the network - that is done in the +// startSingleMeasurement() function and becomes the measurement request time. +#define MS_MODEM_IMEC_WAIT_LINE elapsed_in_wait = now - _millisMeasurementRequested; +#endif + + +#define MS_MODEM_IS_MEASUREMENT_COMPLETE(specificModem) \ +bool specificModem::isMeasurementComplete(bool debug) \ +{ \ + /* If a measurement failed to start, the sensor will never return a result, */ \ + /* so the measurement time is essentially already passed */ \ + /* For a cellular modem nothing happens to "start" a measurement so bit 6 */ \ + /* will be set by startSingleMeasurement() as long as bit 4 was set by wake(). */ \ + /* For a WiFi modem, startSingleMeasurement actually sets the WiFi connection */ \ + /* parameters. */ \ + if (!bitRead(_sensorStatus, 6)) \ + { \ + if (debug) {MS_DBG(getSensorName(), \ + F("is not measuring and will not return a value!"));} \ + return true; \ + } \ +\ + /* just defining this to not call multiple times below */ \ + uint32_t now = millis(); \ +\ + /* We don't want to ping any of the modems too fast so they don't get */ \ + /* overwhelmed. Make sure we've waited a little */ \ + if (now - _lastConnectionCheck < 250) return false; \ +\ + /* Check how long we've been waiting for the network connection and/or a */ \ + /* good measurement of signal quality. */ \ + uint32_t elapsed_in_wait; \ + MS_MODEM_IMEC_WAIT_LINE \ +\ + /* If we're connected AND receiving valid signal strength, measurement is complete */ \ + /* In theory these happen at the same time, but in reality one or the other */ \ + /* may happen first. */ \ + bool isConnected = _tinyModem.isNetworkConnected(); \ + int signalResponse = _tinyModem.getSignalQuality(); \ + if (isConnected && signalResponse != 0 && signalResponse != 99) \ + { \ + if (debug) MS_DBG(F("It's been"), (elapsed_in_wait), F("ms, and"), \ + getSensorName(), F("is now registered on the network and reporting valid signal strength!")); \ + _lastConnectionCheck = now; \ + return true; \ + } \ +\ + /* If we've exceeded the allowed time to wait for the network, give up */ \ + if (elapsed_in_wait > _measurementTime_ms) \ + { \ + if (debug) MS_DBG(F("It's been"), (elapsed_in_wait), F("ms, and"), \ + getSensorName(), F("has maxed out wait for network registration! Ending wait.")); \ + /* Leave status bits and times set - can still get a valid value! */ \ + return true; \ + } \ +\ + /* If the modem isn't registered yet or doesn't report valid signal, we still need to wait */ \ + _lastConnectionCheck = now; \ + return false; \ +} + + +#define MS_MODEM_CONNECT_INTERNET_FIRST_CHUNK \ + bool retVal = true; \ +\ + /* NOT yet powered */ \ + if (bitRead(_sensorStatus, 1) == 0 || bitRead(_sensorStatus, 2) == 0) \ + { \ + modemPowerUp(); \ + } \ + /* No attempts yet to wake the modem */ \ + if (bitRead(_sensorStatus, 3) == 0) \ + { \ + waitForWarmUp(); \ + retVal &= wake(); \ + } \ + /* Not yet setup */ \ + if (bitRead(_sensorStatus, 0) == 0) \ + { \ + /* Set-up if necessary */ \ + retVal &= setup(); \ + } \ + if (!retVal) \ + { \ + MS_DBG(F("Modem did't wake up! Cannot connect to the internet!")); \ + return retVal; \ + } \ +\ + /* Check that the modem is responding to AT commands. If not, give up. */ \ + MS_MODEM_START_TIMER; \ + MS_DBG(F("\nWaiting for"), getSensorName(), F("to respond to AT commands...")); \ + if (!_tinyModem.testAT(_stabilizationTime_ms + 500)) \ + { \ + MS_DBG(F("No response to AT commands! Cannot connect to the internet!")); \ + return false; \ + } \ + else MS_DBG(F("... AT OK after"), millis() - start, F("milliseconds!")); + + +#if defined TINY_GSM_MODEM_XBEE +#define MS_MODEM_CONNECT_INTERNET(specificModem) \ +bool specificModem::connectInternet(uint32_t maxConnectionTime) \ +{ \ + \ + MS_MODEM_CONNECT_INTERNET_FIRST_CHUNK \ +\ + MS_DBG(F("\nWaiting up to"), maxConnectionTime/1000, \ + F("seconds for internet availability...")); \ + if (_tinyModem.waitForNetwork(maxConnectionTime)) \ + { \ + MS_DBG(F("... Connected after"), millis() - start, \ + F("milliseconds.")); \ + return true; \ + } \ +} + +#elif defined TINY_GSM_MODEM_HAS_GPRS +#define MS_MODEM_CONNECT_INTERNET(specificModem) \ +bool specificModem::connectInternet(uint32_t maxConnectionTime) \ +{ \ + \ + MS_MODEM_CONNECT_INTERNET_FIRST_CHUNK \ +\ + MS_DBG(F("\nWaiting up to"), maxConnectionTime/1000, \ + F("seconds for cellular network registration...")); \ + if (_tinyModem.waitForNetwork(maxConnectionTime)) \ + { \ + MS_DBG(F("... Registered after"), millis() - start, \ + F("milliseconds. Connecting to GPRS...")); \ + _tinyModem.gprsConnect(_apn, "", ""); \ + MS_DBG(F("... Connected after"), millis() - start, \ + F("milliseconds.")); \ + return true; \ + } \ + else \ + { \ + MS_DBG(F("...GPRS connection failed.")); \ + return false; \ + } \ +} + + +#else +#define MS_MODEM_CONNECT_INTERNET(specificModem) \ +bool specificModem::connectInternet(uint32_t maxConnectionTime) \ +{ \ +\ + MS_MODEM_CONNECT_INTERNET_FIRST_CHUNK \ + \ + MS_DBG(F("\nAttempting to connect to WiFi network...")); \ + if (!(_tinyModem.isNetworkConnected())) \ + { \ + MS_DBG(F("Sending credentials...")); \ + while (!_tinyModem.networkConnect(_ssid, _pwd)) {}; \ + MS_DBG(F("Waiting up to"), maxConnectionTime/1000, \ + F("seconds for connection")); \ + if (!_tinyModem.waitForNetwork(maxConnectionTime)) \ + { \ + MS_DBG(F("... WiFi connection failed")); \ + return false; \ + } \ + } \ + MS_DBG(F("... WiFi connected after"), millis() - start, \ + F("milliseconds!")); \ + return true; \ +} +#endif + + +#if defined TINY_GSM_MODEM_HAS_GPRS +#define MS_MODEM_DISCONNECT_INTERNET(specificModem) \ +void specificModem::disconnectInternet(void) \ +{ \ + MS_MODEM_START_TIMER; \ + _tinyModem.gprsDisconnect(); \ + MS_DBG(F("Disconnected from cellular network after"), millis() - start, \ + F("milliseconds.")); \ +} +#else +#define MS_MODEM_DISCONNECT_INTERNET(specificModem) \ +void specificModem::disconnectInternet(void) \ +{ \ + MS_MODEM_START_TIMER; \ + _tinyModem.networkDisconnect(); \ + MS_DBG(F("Disconnected from WiFi network after"), millis() - start, \ + F("milliseconds.")); \ +} +#endif + + +// Get the time from NIST via TIME protocol (rfc868) +// This would be much more efficient if done over UDP, but I'm doing it +// over TCP because I don't have a UDP library for all the modems. +#define MS_MODEM_GET_NIST_TIME(specificModem) \ +uint32_t specificModem::getNISTTime(void) \ +{ \ + /* bail if not connected to the internet */ \ + if (!isInternetAvailable()) \ + { \ + MS_DBG(F("No internet connection, cannot connect to NIST.")); \ + return 0; \ + } \ +\ + /* Must ensure that we do not ping the daylight more than once every 4 seconds */ \ + /* NIST clearly specifies here that this is a requirement for all software */ \ + /* that accesses its servers: https://tf.nist.gov/tf-cgi/servers.cgi */ \ + while (millis() < _lastNISTrequest + 4000) {} \ +\ + /* Make TCP connection */ \ + MS_DBG(F("Connecting to NIST daytime Server")); \ + bool connectionMade = false; \ + if (_modemName.indexOf(F("XBee")) >= 0) \ + { \ + /* This is the IP address of time-c-g.nist.gov */ \ + /* XBee's address lookup falters on time.nist.gov */ \ + IPAddress ip(129, 6, 15, 30); \ + connectionMade = _tinyClient->connect(ip, 37); \ + /* Need to send something before connection is made */ \ + _tinyClient->print('!'); \ + /* Need this delay! Can get away with 50, but 100 is safer. */ \ + delay(100); \ + } \ + else connectionMade = _tinyClient->connect("time.nist.gov", 37); \ +\ + /* Wait up to 5 seconds for a response */ \ + if (connectionMade) \ + { \ + long start = millis(); \ + while (_tinyClient && _tinyClient->available() < 4 && millis() - start < 5000L){} \ +\ + if (_tinyClient->available() >= 4) \ + { \ + MS_DBG(F("\nNIST responded after"), millis() - start, F("ms")); \ + /* Response is returned as 32-bit number as soon as connection is made */ \ + /* Connection is then immediately closed, so there is no need to close it */ \ + uint32_t secFrom1900 = 0; \ + byte response[4] = {0}; \ + for (uint8_t i = 0; i < 4; i++) \ + { \ + response[i] = _tinyClient->read(); \ + MS_DBG(F("\nResponse Byte"), i, ':', (char)response[i], \ + '=', response[i], '=', String(response[i], BIN)); \ + secFrom1900 += 0x000000FF & response[i]; \ + /* MS_DBG(F("\nseconds from 1900 after byte:"),String(secFrom1900, BIN)); */ \ + if (i+1 < 4) {secFrom1900 = secFrom1900 << 8;} \ + } \ + MS_DBG(F("\nSeconds from 1900 returned by NIST (UTC):"), \ + secFrom1900, '=', String(secFrom1900, BIN)); \ +\ + /* Close the TCP connection, just in case */ \ + _tinyClient->stop(); \ +\ + /* Return the timestamp */ \ + uint32_t unixTimeStamp = secFrom1900 - 2208988800; \ + MS_DBG(F("\nUnix Timestamp returned by NIST (UTC):"), unixTimeStamp); \ + /* If before Jan 1, 2017 or after Jan 1, 2030, most likely an error */ \ + if (unixTimeStamp < 1483228800) return 0; \ + else if (unixTimeStamp > 1893456000) return 0; \ + else return unixTimeStamp; \ + } \ + else \ + { \ + MS_DBG(F("NIST Time server did not respond!")); \ + return 0; \ + } \ + } \ + else MS_DBG(F("Unable to open TCP to NIST!")); \ + return 0; \ +} + +#endif From d8f4d19d7a0e0fe12104fdbbc9f669e8277d3839 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 14 May 2019 16:25:52 -0400 Subject: [PATCH 14/88] Added a bunch of modems --- src/LoggerModem.cpp | 76 ----------- src/modems/AdafruitFona2G.h | 106 ---------------- src/modems/BotleticsSIM7000.h | 0 src/modems/DigiXBee.h | 11 +- src/modems/DigiXBeeCellularBypass.cpp | 45 +------ src/modems/DigiXBeeCellularTransparent.cpp | 44 +------ src/modems/DraginoBG96.h | 106 ---------------- src/modems/EspressifESP8266.cpp | 123 +++++------------- src/modems/EspressifESP8266.h | 19 ++- src/modems/LoggerModemMacros.h | 53 ++++++++ src/modems/NimbelinkLTEMQuectel.h | 110 ---------------- src/modems/NimbelinkLTEMSequans.h | 111 ---------------- src/modems/QuectelBG96.cpp | 77 +++++++++++ src/modems/QuectelBG96.h | 81 ++++++++++++ src/modems/SIMComSIM7000.cpp | 77 +++++++++++ src/modems/SIMComSIM7000.h | 80 ++++++++++++ src/modems/SIMComSIM800.cpp | 79 ++++++++++++ src/modems/SIMComSIM800.h | 83 ++++++++++++ src/modems/SequansMonarch.cpp | 84 ++++++++++++ src/modems/SequansMonarch.h | 81 ++++++++++++ src/modems/Sodaq2GBeeR6.cpp | 64 ++++++++++ src/modems/Sodaq2GBeeR6.h | 118 +++++++---------- src/modems/SodaqUBeeR410M.cpp | 117 +++++++++++++++++ src/modems/SodaqUBeeR410M.h | 141 ++++++++++----------- src/modems/SodaqUBeeU201.cpp | 84 ++++++++++++ src/modems/SodaqUBeeU201.h | 139 ++++++++------------ 26 files changed, 1182 insertions(+), 927 deletions(-) delete mode 100644 src/modems/AdafruitFona2G.h delete mode 100644 src/modems/BotleticsSIM7000.h delete mode 100644 src/modems/DraginoBG96.h delete mode 100644 src/modems/NimbelinkLTEMQuectel.h delete mode 100644 src/modems/NimbelinkLTEMSequans.h create mode 100644 src/modems/QuectelBG96.cpp create mode 100644 src/modems/QuectelBG96.h create mode 100644 src/modems/SIMComSIM7000.cpp create mode 100644 src/modems/SIMComSIM7000.h create mode 100644 src/modems/SIMComSIM800.cpp create mode 100644 src/modems/SIMComSIM800.h create mode 100644 src/modems/SequansMonarch.cpp create mode 100644 src/modems/SequansMonarch.h create mode 100644 src/modems/Sodaq2GBeeR6.cpp create mode 100644 src/modems/SodaqUBeeR410M.cpp create mode 100644 src/modems/SodaqUBeeU201.cpp diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index 9c32e6586..ccc404664 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -518,72 +518,6 @@ close sockets and disconnect from the network. Most manufactures strongly recommend allowing a graceful shut-down rather than a sudden power-off. void loggerModem::setModemTiming(void) { - if (_modemName.indexOf(F("SIMCom SIM800")) >= 0) - { - MS_DBG(F("Resetting warm-up and disconnect timing for a SIMCom SIM800")); - _warmUpTime_ms = 450; // Time after power on before "PWRKEY" can be used - >0.4sec - _statusTime_ms = 2000; // Time after end pulse until status pin becomes active (>3sec from start of 1s pulse) - _stabilizationTime_ms = 2000; // Time after end pulse until serial port becomes active (>3sec from start of 1s pulse) - // _on_pull_down_ms = 1100; // >1s - // _off_pull_down_ms = 1100; // 1sec > t > 33sec - _disconnetTime_ms = 1500; // power down (gracefully) takes >3sec - // (Giving 15sec for shutdown in case it is not monitored.) - } - if (_modemName.indexOf(F("SIMCom SIM900")) >= 0) - { - MS_DBG(F("Resetting warm-up and disconnect timing for a SIMCom SIM900")); - _warmUpTime_ms = 1000; // Time after power on before "PWRKEY" can be used (guess - diagram isn't clear) - _statusTime_ms = 2200; // Time after end pulse until status pin becomes active (>2.2sec) - _stabilizationTime_ms = 2200; // Time after end pulse until serial port becomes active (>2.2sec) - // _on_pull_down_ms = 1100; // >1s - // _off_pull_down_ms = 600; // 0.5sec > pull down > 1sec - _disconnetTime_ms = 15000; // power down (gracefully) takes >1.7 sec - // (Giving 15sec for shutdown in case it is not monitored.) - } - if (_modemName.indexOf(F("SIMCom SIM7000")) >= 0) - { - MS_DBG(F("Resetting warm-up and disconnect timing for a SIMCom SIM7000")); - _warmUpTime_ms = 0; // Time after power on before "PWRKEY" can be used - _statusTime_ms = 4500; // Time after end pulse until status pin becomes active (>4.5sec) - _stabilizationTime_ms = 4500; // Time after end pulse until serial port becomes active (>4.5sec) - // _on_pull_down_ms = 1100; // >1s - // _off_pull_down_ms = 1300; // >1.2sec - _disconnetTime_ms = 7000; // power down (gracefully) takes 1.8-6.9 sec - } - if (_modemName.indexOf(F("SARA-R4")) >= 0 || - _modemName.indexOf(F("SARA-N4")) >= 0 || - _modemName.indexOf(F("XBee3™ Cellular LTE-M")) >= 0 || - _modemName.indexOf(F("Digi XBee3™ Cellular NB-IoT")) >= 0) - { - MS_DBG(F("Resetting warm-up and disconnect timing for a u-blox SARA-R4")); - _warmUpTime_ms = 250; // Time after power on before PWR_ON can be used ??? Unclear in documentation! - _statusTime_ms = 12; // V_INT becomes active mid-way through on-pulse - // But using the status time for LTE XBee3 in bypass mode (~11.5ms first wake, ~928µs after) - _stabilizationTime_ms = 4500; // Time until system and digital pins are operational (~4.5s) - // _on_pull_down_ms = 200; // 0.15-3.2s - // _off_pull_down_ms = 1600; // >1.5s - _disconnetTime_ms = 15000; // Power down time "can largely vary depending - // on the application / network settings and the concurrent module - // activities." Vint/status pin should be monitored and power not withdrawn - // until that pin reads low. Giving 15sec here in case it is not monitored. - } - if (_modemName.indexOf(F("SARA-U2")) >= 0 || - _modemName.indexOf(F("XBee® Cellular 3G")) >= 0) - { - MS_DBG(F("Resetting warm-up and disconnect timing for a u-blox SARA-U2")); - _warmUpTime_ms = 0; // Module turns on when power is applied - level of PWR_ON then irrelevant - _statusTime_ms = 35; // Time after end pulse until V_INT becomes active - // Unspecified in documentation! Taking value from Lisa U2 - _stabilizationTime_ms = 6000; // Time until system and digital pins are operational - // (6 sec typical for SARA U201, others 5 sec typical) - // Time for an AT response may be much longer when using a 3G XBee in bypass mode! - // _on_pull_down_ms = 1; // 50-80µs - // _off_pull_down_ms = 1000; // >1s - _disconnetTime_ms = 15000; // Power down time "can largely vary depending - // on the application / network settings and the concurrent module - // activities." Vint/status pin should be monitored and power not withdrawn - // until that pin reads low. Giving 15sec here in case it is not monitored. - } if (_modemName.indexOf(F("SARA-G3")) >= 0) { MS_DBG(F("Resetting warm-up and disconnect timing for a u-blox SARA-G3")); @@ -633,16 +567,6 @@ void loggerModem::setModemTiming(void) // _off_pull_down_ms = 510; // >300ms _disconnetTime_ms = 6000; // power down (gracefully) takes ~5sec } - if (_modemName.indexOf(F("Quectel BG96")) >= 0) - { - MS_DBG(F("Resetting warm-up and disconnect timing for a Quectel BG96")); - _warmUpTime_ms = 30; // Time after VBAT is stable before PWRKEY can be used - _statusTime_ms = 4800; // Time after end pulse until status pin becomes active - _stabilizationTime_ms = 4200; // USB active at >4.2 sec, status at >4.8 sec, URAT at >4.9 - // _on_pull_down_ms = 110; // >100ms - // _off_pull_down_ms = 700; // ≥ 650ms - _disconnetTime_ms = 15000; // > 2 sec (Giving 15sec here in case it is not monitored.) - } if (_modemName.indexOf(F("Quectel BC95")) >= 0) { MS_DBG(F("Resetting warm-up and disconnect timing for a Quectel BC95")); diff --git a/src/modems/AdafruitFona2G.h b/src/modems/AdafruitFona2G.h deleted file mode 100644 index eb4069e5c..000000000 --- a/src/modems/AdafruitFona2G.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - *AdafruitFona2G.h - *This file is part of the EnviroDIY modular sensors library for Arduino - * - *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). - * - *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module -*/ - -// Header Guards -#ifndef ModularSensorsSpecificModem_h -#define ModularSensorsSpecificModem_h - -// Debugging Statement -// #define MS_ADAFRUITFONA2G_DEBUG - -#ifdef MS_ADAFRUITFONA2G_DEBUG -#define MS_DEBUGGING_STD -#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT -#endif - -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates - -// Included Dependencies -#include "ModSensorDebugger.h" -#include "LoggerModem.h" - -// ========================================================================== -// Wifi/Cellular Modem Main Chip Selection -// ========================================================================== - -// Select your modem chip - this determines the exact commands sent to it -#define TINY_GSM_MODEM_SIM800 // Select for a SIMCOM SIM800, SIM900, or variant thereof - - -// ========================================================================== -// Modem Pins -// ========================================================================== - -// Declare the existance of modem pin Variables -// Use the "extern" keyword to denote that these will actually be defined in -// the main program rather than in this file. - -extern const int8_t modemVccPin; -extern const int8_t modemSleepRqPin; -extern const int8_t modemStatusPin; -extern const int8_t modemResetPin; -extern const int8_t modemLEDPin; - - -// ========================================================================== -// TinyGSM Client -// ========================================================================== - -// #define TINY_GSM_DEBUG Serial // If you want debugging on the main debug port - -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates - -// Include TinyGSM for the modem -// This include must be included below the define of the modem name! -#include - -// Create a reference to the serial port for the modem -// Extra hardware and software serial ports are created in the "Settings for Additional Serial Ports" section -HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible -// AltSoftSerial &modemSerial = altSoftSerial; // For software serial if needed -// NeoSWSerial &modemSerial = neoSSerial1; // For software serial if needed - -// Create a new TinyGSM modem to run on that serial port and return a pointer to it -#if defined TINY_GSM_MODEM_XBEE -TinyGsm *tinyModem = new TinyGsm(modemSerial, modemResetPin); -#else -TinyGsm *tinyModem = new TinyGsm(modemSerial); -#endif - -// Create a new TCP client on that modem and return a pointer to it -TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); - - -// ========================================================================== -// Specific Modem On-Off Methods -// ========================================================================== - -bool modemWakeFxn(void) -{ - digitalWrite(modemSleepRqPin, LOW); - delay(1100); // >1s for SIM800, SIM900, Quectel M95, Quectel MC60 - digitalWrite(modemSleepRqPin, HIGH); - return true; -} - - -bool modemSleepFxn(void) -{ - digitalWrite(modemSleepRqPin, LOW); - delay(1100); // 1sec > t > 33sec for SIM800 and clones - digitalWrite(modemSleepRqPin, HIGH); - return true; -} - - -void extraModemSetup(void){} - - - -#endif diff --git a/src/modems/BotleticsSIM7000.h b/src/modems/BotleticsSIM7000.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/modems/DigiXBee.h b/src/modems/DigiXBee.h index 145726242..22bb29f0a 100644 --- a/src/modems/DigiXBee.h +++ b/src/modems/DigiXBee.h @@ -19,12 +19,21 @@ #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif +// Time after turn on until the status pin is active - total WAG #define XBEE_STATUS_TIME_MS 15 +// Power down time "can largely vary depending +// on the application / network settings and the concurrent module +// activities." Vint/status pin should be monitored and power not withdrawn +// until that pin reads low. Giving 15sec here in case it is not monitored. #define XBEE_DISCONNECT_TIME_MS 5000L -#define XBEE_WARM_UP_TIME_MS 50 +// Time after power-up before we can wake the model +#define XBEE_WARM_UP_TIME_MS 0 +// Time we'll get back an AT response. Probably much less than this, except in bypass #define XBEE_ATRESPONSE_TIME_MS 5000L +// How long we're willing to wait to get signal quality +// This can be super slow for cellular modules #define XBEE_SIGNALQUALITY_TIME_MS 45000L // Included Dependencies diff --git a/src/modems/DigiXBeeCellularBypass.cpp b/src/modems/DigiXBeeCellularBypass.cpp index c8ac87e61..dfc1b5f75 100644 --- a/src/modems/DigiXBeeCellularBypass.cpp +++ b/src/modems/DigiXBeeCellularBypass.cpp @@ -32,6 +32,7 @@ DigiXBeeCellularBypass::DigiXBeeCellularBypass(Stream* modemStream, MS_MODEM_DID_AT_RESPOND(DigiXBeeCellularBypass); MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeCellularBypass); MS_MODEM_IS_MEASUREMENT_COMPLETE(DigiXBeeCellularBypass); +MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(DigiXBeeCellularBypass); MS_MODEM_CONNECT_INTERNET(DigiXBeeCellularBypass); MS_MODEM_GET_NIST_TIME(DigiXBeeCellularBypass); @@ -101,47 +102,3 @@ bool DigiXBeeCellularBypass::extraModemSetup(void) else success = false; return success; } - - -bool DigiXBeeCellularBypass::addSingleMeasurementResult(void) -{ - bool success = true; - - // Initialize float variable - int16_t signalQual = -9999; - int16_t percent = -9999; - int16_t rssi = -9999; - - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (bitRead(_sensorStatus, 6)) - { - - // Get signal quality - // NOTE: We can't actually distinguish between a bad modem response, no - // modem response, and a real response from the modem of no service/signal. - // The TinyGSM getSignalQuality function returns the same "no signal" - // value (99 CSQ or 0 RSSI) in all 3 cases. - MS_DBG(F("Getting signal quality:")); - signalQual = _tinyModem.getSignalQuality(); - MS_DBG(F("Raw signal quality:"), signalQual); - - // Convert signal quality to RSSI, if necessary - rssi = getRSSIFromCSQ(signalQual); - percent = getPctFromCSQ(signalQual); - - MS_DBG(F("RSSI:"), rssi); - MS_DBG(F("Percent signal strength:"), percent); - } - else MS_DBG(getSensorName(), F("is not connected to the network; unable to get signal quality!")); - - verifyAndAddMeasurementResult(RSSI_VAR_NUM, rssi); - verifyAndAddMeasurementResult(PERCENT_SIGNAL_VAR_NUM, percent); - - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - _sensorStatus &= 0b10011111; - - return success; -} diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index a0a3a03e3..57066a495 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -32,6 +32,7 @@ DigiXBeeCellularTransparent::DigiXBeeCellularTransparent(Stream* modemStream, MS_MODEM_DID_AT_RESPOND(DigiXBeeCellularTransparent); MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeCellularTransparent); MS_MODEM_IS_MEASUREMENT_COMPLETE(DigiXBeeCellularTransparent); +MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(DigiXBeeCellularTransparent); MS_MODEM_CONNECT_INTERNET(DigiXBeeCellularTransparent); MS_MODEM_GET_NIST_TIME(DigiXBeeCellularTransparent); @@ -94,49 +95,6 @@ bool DigiXBeeCellularTransparent::extraModemSetup(void) } -bool DigiXBeeCellularTransparent::addSingleMeasurementResult(void) -{ - bool success = true; - - // Initialize float variable - int16_t signalQual = -9999; - int16_t percent = -9999; - int16_t rssi = -9999; - - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (bitRead(_sensorStatus, 6)) - { - // Get signal quality - // NOTE: We can't actually distinguish between a bad modem response, no - // modem response, and a real response from the modem of no service/signal. - // The TinyGSM getSignalQuality function returns the same "no signal" - // value (99 CSQ or 0 RSSI) in all 3 cases. - MS_DBG(F("Getting signal quality:")); - signalQual = _tinyModem.getSignalQuality(); - MS_DBG(F("Raw signal quality:"), signalQual); - - // Convert signal quality to RSSI - rssi = signalQual; - percent = getPctFromRSSI(signalQual); - - MS_DBG(F("RSSI:"), rssi); - MS_DBG(F("Percent signal strength:"), percent); - } - else MS_DBG(getSensorName(), F("is not connected to the network; unable to get signal quality!")); - - verifyAndAddMeasurementResult(RSSI_VAR_NUM, rssi); - verifyAndAddMeasurementResult(PERCENT_SIGNAL_VAR_NUM, percent); - - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - _sensorStatus &= 0b10011111; - - return success; -} - - void DigiXBeeCellularTransparent::disconnectInternet(void) { // XBee doesn't like to disconnect at all, so we're doing nothing diff --git a/src/modems/DraginoBG96.h b/src/modems/DraginoBG96.h deleted file mode 100644 index c9d260a1d..000000000 --- a/src/modems/DraginoBG96.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - *DraginoBG96.h - *This file is part of the EnviroDIY modular sensors library for Arduino - * - *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). - * - *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module -*/ - -// Header Guards -#ifndef ModularSensorsSpecificModem_h -#define ModularSensorsSpecificModem_h - -// Debugging Statement -// #define MS_DRAGINOBG96_DEBUG - -#ifdef MS_DRAGINOBG96_DEBUG -#define MS_DEBUGGING_STD -#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT -#endif - -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates - -// Included Dependencies -#include "ModSensorDebugger.h" -#include "LoggerModem.h" - -// ========================================================================== -// Wifi/Cellular Modem Main Chip Selection -// ========================================================================== - -// Select your modem chip - this determines the exact commands sent to it -#define TINY_GSM_MODEM_BG96 // Select for a Quectel BG96 - - -// ========================================================================== -// Modem Pins -// ========================================================================== - -// Declare the existance of modem pin Variables -// Use the "extern" keyword to denote that these will actually be defined in -// the main program rather than in this file. - -extern const int8_t modemVccPin; -extern const int8_t modemSleepRqPin; -extern const int8_t modemStatusPin; -extern const int8_t modemResetPin; -extern const int8_t modemLEDPin; - - -// ========================================================================== -// TinyGSM Client -// ========================================================================== - -// #define TINY_GSM_DEBUG Serial // If you want debugging on the main debug port - -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates - -// Include TinyGSM for the modem -// This include must be included below the define of the modem name! -#include - -// Create a reference to the serial port for the modem -// Extra hardware and software serial ports are created in the "Settings for Additional Serial Ports" section -HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible -// AltSoftSerial &modemSerial = altSoftSerial; // For software serial if needed -// NeoSWSerial &modemSerial = neoSSerial1; // For software serial if needed - -// Create a new TinyGSM modem to run on that serial port and return a pointer to it -#if defined TINY_GSM_MODEM_XBEE -TinyGsm *tinyModem = new TinyGsm(modemSerial, modemResetPin); -#else -TinyGsm *tinyModem = new TinyGsm(modemSerial); -#endif - -// Create a new TCP client on that modem and return a pointer to it -TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); - - -// ========================================================================== -// Specific Modem On-Off Methods -// ========================================================================== - -bool modemWakeFxn(void) -{ - digitalWrite(modemSleepRqPin, LOW); - delay(110); // >100ms for Quectel BG96 - digitalWrite(modemSleepRqPin, HIGH); - return true; -} - - -bool modemSleepFxn(void) -{ - digitalWrite(modemSleepRqPin, LOW); - delay(700); // >650ms for Quectel BG96, 0.6sec > pull down > 1sec for Quectel M95, Quectel MC60 - digitalWrite(modemSleepRqPin, HIGH); - return true; -} - - -void extraModemSetup(void){} - - - -#endif diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index 9746765d9..d0247e573 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -33,13 +33,13 @@ EspressifESP8266::EspressifESP8266(Stream* modemStream, TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); _tinyClient = tinyClient; _modemStream = modemStream; - _statusLevel = HIGH; } MS_MODEM_DID_AT_RESPOND(EspressifESP8266); MS_MODEM_IS_INTERNET_AVAILABLE(EspressifESP8266); MS_MODEM_IS_MEASUREMENT_COMPLETE(EspressifESP8266); +MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(EspressifESP8266); MS_MODEM_CONNECT_INTERNET(EspressifESP8266); MS_MODEM_DISCONNECT_INTERNET(EspressifESP8266); MS_MODEM_GET_NIST_TIME(EspressifESP8266); @@ -79,6 +79,37 @@ bool EspressifESP8266::ESPwaitForBoot(void) // Create the wake and sleep methods for the modem // These can be functions of any type and must return a boolean +bool EspressifESP8266::modemWakeFxn(void) +{ + bool success = true; + if (_powerPin >= 0) // Turns on when power is applied + { + success &= ESPwaitForBoot(); + return success; + } + else if (_modemResetPin >= 0) + { + digitalWrite(_modemResetPin, LOW); + delay(1); + digitalWrite(_modemResetPin, HIGH); + success &= ESPwaitForBoot(); + return success; + } + else if (_modemSleepRqPin >= 0) + { + digitalWrite(_modemSleepRqPin, LOW); + delay(1); + digitalWrite(_modemSleepRqPin, HIGH); + // Don't have to wait for a boot if using light sleep + return true; + } + else + { + return true; + } +} + + bool EspressifESP8266::modemSleepFxn(void) { // Use this if you have GPIO16 connected to the reset pin to wake from deep sleep @@ -96,7 +127,6 @@ bool EspressifESP8266::modemSleepFxn(void) // Use this if you have an MCU pin connected to the ESP's reset pin to wake from deep sleep if (_modemResetPin >= 0) { - digitalWrite(_modemLEDPin, LOW); return _tinyModem.poweroff(); } // Use this if you don't have access to the ESP8266's reset pin for deep sleep but you @@ -109,7 +139,6 @@ bool EspressifESP8266::modemSleepFxn(void) bool success = _tinyModem.waitResponse() == 1; _tinyModem.sendAT(F("+SLEEP=1")); success &= _tinyModem.waitResponse() == 1; - digitalWrite(_modemLEDPin, LOW); return success; } // Light sleep without the status pin @@ -119,7 +148,6 @@ bool EspressifESP8266::modemSleepFxn(void) bool success = _tinyModem.waitResponse() == 1; _tinyModem.sendAT(F("+SLEEP=1")); success &= _tinyModem.waitResponse() == 1; - digitalWrite(_modemLEDPin, LOW); return success; } else // DON'T go to sleep if we can't wake up! @@ -129,51 +157,10 @@ bool EspressifESP8266::modemSleepFxn(void) } -bool EspressifESP8266::modemWakeFxn(void) -{ - bool success = true; - if (_powerPin >= 0) // Turns on when power is applied - { - digitalWrite(_modemLEDPin, HIGH); // Because the ESP8266 doesn't have any lights - success &= ESPwaitForBoot(); - if (!success) - { - digitalWrite(_modemLEDPin, LOW); // Turn off light if the boot failed - } - return success; - } - else if (_modemResetPin >= 0) - { - digitalWrite(_modemLEDPin, HIGH); - digitalWrite(_modemResetPin, LOW); - delay(1); - digitalWrite(_modemResetPin, HIGH); - success &= ESPwaitForBoot(); - if (!success) - { - digitalWrite(_modemLEDPin, LOW); // Turn off light if the boot failed - } - return success; - } - else if (_modemSleepRqPin >= 0) - { - digitalWrite(_modemSleepRqPin, LOW); - delay(1); - digitalWrite(_modemSleepRqPin, HIGH); - digitalWrite(_modemLEDPin, HIGH); - // Don't have to wait for a boot if using light sleep - return true; - } - else - { - return true; - } -} - - // Set up the light-sleep status pin, if applicable bool EspressifESP8266::extraModemSetup(void) { + _modemName = _tinyModem.getModemName(); // Slow down the baud rate for slow processors - and save the change to // the ESP's non-volatile memory so we don't have to do it every time // #if F_CPU == 8000000L @@ -235,47 +222,3 @@ bool EspressifESP8266::startSingleMeasurement(void) } return success; } - - -bool EspressifESP8266::addSingleMeasurementResult(void) -{ - bool success = true; - - // Initialize float variable - int16_t signalQual = -9999; - int16_t percent = -9999; - int16_t rssi = -9999; - - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was - if (bitRead(_sensorStatus, 6)) - { - - // Get signal quality - // NOTE: We can't actually distinguish between a bad modem response, no - // modem response, and a real response from the modem of no service/signal. - // The TinyGSM getSignalQuality function returns the same "no signal" - // value (99 CSQ or 0 RSSI) in all 3 cases. - MS_DBG(F("Getting signal quality:")); - signalQual = _tinyModem.getSignalQuality(); - MS_DBG(F("Raw signal quality:"), signalQual); - - // Convert signal quality to RSSI, if necessary - rssi = signalQual; - percent = getPctFromRSSI(signalQual); - - MS_DBG(F("RSSI:"), rssi); - MS_DBG(F("Percent signal strength:"), percent); - } - else MS_DBG(getSensorName(), F("is not connected to the network; unable to get signal quality!")); - - verifyAndAddMeasurementResult(RSSI_VAR_NUM, rssi); - verifyAndAddMeasurementResult(PERCENT_SIGNAL_VAR_NUM, percent); - - // Unset the time stamp for the beginning of this measurement - _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) - _sensorStatus &= 0b10011111; - - return success; -} diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h index 1f549f39b..b57c3b055 100644 --- a/src/modems/EspressifESP8266.h +++ b/src/modems/EspressifESP8266.h @@ -23,12 +23,19 @@ #define TINY_GSM_MODEM_ESP8266 -#define ESP8266_STATUS_TIME_MS 350 // N/A? - No status pin - use boot time if using a GPIO pin -#define ESP8266_DISCONNECT_TIME_MS 500 // power down ??? - -#define ESP8266_WARM_UP_TIME_MS 0 // Module turns on when power is applied -#define ESP8266_ATRESPONSE_TIME_MS 5000L - +// No possible status pin on the ESP8266 in deep sleep mode +// For cases where a pin is defined for light sleep mode, we'll call this +// the boot time because I have no idea what it would be +#define ESP8266_STATUS_TIME_MS 350 +// power down ??? +#define ESP8266_DISCONNECT_TIME_MS 500 + +// Module turns on when power is applied regardless of pin states +#define ESP8266_WARM_UP_TIME_MS 0 +// Time until system and digital pins are operational +#define ESP8266_ATRESPONSE_TIME_MS 350 + +// How long we're willing to wait to get signal quality #define ESP8266_SIGNALQUALITY_TIME_MS 15000L // Included Dependencies diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 330dd9f2b..500ab241e 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -127,6 +127,59 @@ bool specificModem::isMeasurementComplete(bool debug) \ } +#if defined TINY_GSM_MODEM_XBEE || defined TINY_GSM_MODEM_ESP8266 +#define MS_MODEM_CALC_SIGNAL_RSSI rssi = signalQual; +#define MS_MODEM_CALC_SIGNAL_PERCENT percent = getPctFromRSSI(signalQual); +#else +#define MS_MODEM_CALC_SIGNAL_RSSI rssi = getRSSIFromCSQ(signalQual); +#define MS_MODEM_CALC_SIGNAL_PERCENT percent = getPctFromCSQ(signalQual); +#endif + +#define MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(specificModem) \ +bool specificModem::addSingleMeasurementResult(void) \ +{ \ + bool success = true; \ +\ + /* Initialize float variable */ \ + int16_t signalQual = -9999; \ + int16_t percent = -9999; \ + int16_t rssi = -9999; \ +\ + /* Check a measurement was *successfully* started (status bit 6 set) */ \ + /* Only go on to get a result if it was */ \ + if (bitRead(_sensorStatus, 6)) \ + { \ + /* Get signal quality */ \ + /* NOTE: We can't actually distinguish between a bad modem response, no */ \ + /* modem response, and a real response from the modem of no service/signal. */ \ + /* The TinyGSM getSignalQuality function returns the same "no signal" */ \ + /* value (99 CSQ or 0 RSSI) in all 3 cases. */ \ + MS_DBG(F("Getting signal quality:")); \ + signalQual = _tinyModem->getSignalQuality(); \ + MS_DBG(F("Raw signal quality:"), signalQual); \ +\ + /* Convert signal quality to RSSI, if necessary */ \ + MS_MODEM_CALC_SIGNAL_RSSI; \ + MS_MODEM_CALC_SIGNAL_PERCENT; \ +\ + MS_DBG(F("RSSI:"), rssi); \ + MS_DBG(F("Percent signal strength:"), percent); \ + } \ + else MS_DBG(getSensorName(), F("is not connected to the network; unable to get signal quality!")); \ +\ + verifyAndAddMeasurementResult(RSSI_VAR_NUM, rssi); \ + verifyAndAddMeasurementResult(PERCENT_SIGNAL_VAR_NUM, percent); \ +\ + /* Unset the time stamp for the beginning of this measurement */ \ + _millisMeasurementRequested = 0; \ + /* Unset the status bits for a measurement request (bits 5 & 6) */ \ + _sensorStatus &= 0b10011111; \ +\ + return success; \ +} + + + #define MS_MODEM_CONNECT_INTERNET_FIRST_CHUNK \ bool retVal = true; \ \ diff --git a/src/modems/NimbelinkLTEMQuectel.h b/src/modems/NimbelinkLTEMQuectel.h deleted file mode 100644 index 37e14df41..000000000 --- a/src/modems/NimbelinkLTEMQuectel.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - *NimbelinkLTEMQuectel.h - *This file is part of the EnviroDIY modular sensors library for Arduino - * - *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). - * - *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module -*/ - -// Header Guards -#ifndef ModularSensorsSpecificModem_h -#define ModularSensorsSpecificModem_h - -// Debugging Statement -// #define MS_NIMBELINKLTEMQUECTEL_DEBUG - -#ifdef MS_NIMBELINKLTEMQUECTEL_DEBUG -#define MS_DEBUGGING_STD -#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT -#endif - -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates - -// Included Dependencies -#include "ModSensorDebugger.h" -#include "LoggerModem.h" - -// ========================================================================== -// Wifi/Cellular Modem Main Chip Selection -// ========================================================================== - -// Select your modem chip - this determines the exact commands sent to it -#define TINY_GSM_MODEM_BG96 // Select for a Quectel BG96 - -// ========================================================================== -// Modem Pins -// ========================================================================== - -// Declare the existance of modem pin Variables -// Use the "extern" keyword to denote that these will actually be defined in -// the main program rather than in this file. - -extern const int8_t modemVccPin; -extern const int8_t modemSleepRqPin; -extern const int8_t modemStatusPin; -extern const int8_t modemResetPin; -extern const int8_t modemLEDPin; - - -// ========================================================================== -// TinyGSM Client -// ========================================================================== - -// #define TINY_GSM_DEBUG Serial // If you want debugging on the main debug port - -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates - -// Include TinyGSM for the modem -// This include must be included below the define of the modem name! -#include - -// Create a reference to the serial port for the modem -// Extra hardware and software serial ports are created in the "Settings for Additional Serial Ports" section -HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible -// AltSoftSerial &modemSerial = altSoftSerial; // For software serial if needed -// NeoSWSerial &modemSerial = neoSSerial1; // For software serial if needed - -// Create a new TinyGSM modem to run on that serial port and return a pointer to it -#if defined TINY_GSM_MODEM_XBEE -TinyGsm *tinyModem = new TinyGsm(modemSerial, modemResetPin); -#else -TinyGsm *tinyModem = new TinyGsm(modemSerial); -#endif - -// Create a new TCP client on that modem and return a pointer to it -TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); - - -// ========================================================================== -// Specific Modem On-Off Methods -// ========================================================================== - -bool modemWakeFxn(void) -{ - digitalWrite(modemSleepRqPin, LOW); - // delay(1100); // >1s for SIM800, SIM900, Quectel M95, Quectel MC60 - // delay(510); // >300ms (>500ms recommended) for Neoway M590 - delay(110); // >100ms for Quectel BG96 - digitalWrite(modemSleepRqPin, HIGH); - return true; -} - - -bool modemSleepFxn(void) -{ - digitalWrite(modemSleepRqPin, LOW); - // delay(1100); // 1sec > t > 33sec for SIM800 and clones - // delay(600); // 0.5sec > pull down > 1sec for SIM900 - // delay(510); // >300ms (>500ms recommended) for Neoway M590 - delay(700); // >650ms for Quectel BG96, 0.6sec > pull down > 1sec for Quectel M95, Quectel MC60 - digitalWrite(modemSleepRqPin, HIGH); - return true; -} - - -void extraModemSetup(void){} - - - -#endif diff --git a/src/modems/NimbelinkLTEMSequans.h b/src/modems/NimbelinkLTEMSequans.h deleted file mode 100644 index 51e9a66b0..000000000 --- a/src/modems/NimbelinkLTEMSequans.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - *NimbelinkLTEMSequans.h - *This file is part of the EnviroDIY modular sensors library for Arduino - * - *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). - * - *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module -*/ - -// Header Guards -#ifndef ModularSensorsSpecificModem_h -#define ModularSensorsSpecificModem_h - -// Debugging Statement -// #define MS_NIMBELINKLTEMSEQUANS_DEBUG - -#ifdef MS_NIMBELINKLTEMSEQUANS_DEBUG -#define MS_DEBUGGING_STD -#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT -#endif - -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates - -// Included Dependencies -#include "ModSensorDebugger.h" -#include "LoggerModem.h" - -// ========================================================================== -// Wifi/Cellular Modem Main Chip Selection -// ========================================================================== - -// Select your modem chip - this determines the exact commands sent to it -#define TINY_GSM_MODEM_SEQUANS_MONARCH // Select for a Sequans Monarch CAT-M1 - - -// ========================================================================== -// Modem Pins -// ========================================================================== - -// Declare the existance of modem pin Variables -// Use the "extern" keyword to denote that these will actually be defined in -// the main program rather than in this file. - -extern const int8_t modemVccPin; -extern const int8_t modemSleepRqPin; -extern const int8_t modemStatusPin; -extern const int8_t modemResetPin; -extern const int8_t modemLEDPin; - - -// ========================================================================== -// TinyGSM Client -// ========================================================================== - -// #define TINY_GSM_DEBUG Serial // If you want debugging on the main debug port - -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates - -// Include TinyGSM for the modem -// This include must be included below the define of the modem name! -#include - -// Create a reference to the serial port for the modem -// Extra hardware and software serial ports are created in the "Settings for Additional Serial Ports" section -HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible -// AltSoftSerial &modemSerial = altSoftSerial; // For software serial if needed -// NeoSWSerial &modemSerial = neoSSerial1; // For software serial if needed - -// Create a new TinyGSM modem to run on that serial port and return a pointer to it -#if defined TINY_GSM_MODEM_XBEE -TinyGsm *tinyModem = new TinyGsm(modemSerial, modemResetPin); -#else -TinyGsm *tinyModem = new TinyGsm(modemSerial); -#endif - -// Create a new TCP client on that modem and return a pointer to it -TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); - - -// ========================================================================== -// Specific Modem On-Off Methods -// ========================================================================== - -bool modemWakeFxn(void) -{ - digitalWrite(modemSleepRqPin, LOW); - // delay(1100); // >1s for SIM800, SIM900, Quectel M95, Quectel MC60 - // delay(510); // >300ms (>500ms recommended) for Neoway M590 - delay(110); // >100ms for Quectel BG96 - digitalWrite(modemSleepRqPin, HIGH); - return true; -} - - -bool modemSleepFxn(void) -{ - digitalWrite(modemSleepRqPin, LOW); - // delay(1100); // 1sec > t > 33sec for SIM800 and clones - // delay(600); // 0.5sec > pull down > 1sec for SIM900 - // delay(510); // >300ms (>500ms recommended) for Neoway M590 - delay(700); // >650ms for Quectel BG96, 0.6sec > pull down > 1sec for Quectel M95, Quectel MC60 - digitalWrite(modemSleepRqPin, HIGH); - return true; -} - - -void extraModemSetup(void){} - - - -#endif diff --git a/src/modems/QuectelBG96.cpp b/src/modems/QuectelBG96.cpp new file mode 100644 index 000000000..607517b39 --- /dev/null +++ b/src/modems/QuectelBG96.cpp @@ -0,0 +1,77 @@ +/* + *QuectelBG96.cpp + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is for the Botletics and other modules based on the SIMCOM BG96. +*/ + +// Included Dependencies +#include "QuectelBG96.h" +#include "modems/LoggerModemMacros.h" + + +// Constructor +QuectelBG96::QuectelBG96(Stream* modemStream, + int8_t powerPin, int8_t statusPin, + int8_t modemResetPin, int8_t modemSleepRqPin, + const char *apn, + uint8_t measurementsToAverage) + : loggerModem(powerPin, statusPin, HIGH, + modemResetPin, modemSleepRqPin, + BG96_STATUS_TIME_MS, BG96_DISCONNECT_TIME_MS, + BG96_WARM_UP_TIME_MS, BG96_ATRESPONSE_TIME_MS, + BG96_SIGNALQUALITY_TIME_MS, + measurementsToAverage), + _tinyModem(*modemStream) +{ + _apn = apn; + TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); + _tinyClient = tinyClient; + _modemStream = modemStream; +} + + +MS_MODEM_DID_AT_RESPOND(QuectelBG96); +MS_MODEM_IS_INTERNET_AVAILABLE(QuectelBG96); +MS_MODEM_IS_MEASUREMENT_COMPLETE(QuectelBG96); +MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(QuectelBG96); +MS_MODEM_CONNECT_INTERNET(QuectelBG96); +MS_MODEM_DISCONNECT_INTERNET(QuectelBG96); +MS_MODEM_GET_NIST_TIME(QuectelBG96); + +// Create the wake and sleep methods for the modem +// These can be functions of any type and must return a boolean +bool QuectelBG96::modemWakeFxn(void) +{ + // Must power on and then pulse on + if (_modemSleepRqPin >= 0) + { + digitalWrite(_modemSleepRqPin, LOW); + delay(160); // ≥100ms + digitalWrite(_modemSleepRqPin, LOW); + } + return true; +} + + +bool QuectelBG96::modemSleepFxn(void) +{ + if (_modemSleepRqPin >= 0) // BG96 must have access to PWRKEY pin to sleep + { + // Easiest to just go to sleep with the AT command rather than using pins + return _tinyModem.poweroff(); + } + else // DON'T go to sleep if we can't wake up! + { + return true; + } +} + + +bool QuectelBG96::extraModemSetup(void) +{ + _modemName = _tinyModem.getModemName(); + return true; +} diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h new file mode 100644 index 000000000..00ee4b619 --- /dev/null +++ b/src/modems/QuectelBG96.h @@ -0,0 +1,81 @@ +/* + *QuectelBG96.h + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is for the Dragino BG96, Nimbelink Skywire 4G LTE-M Global, and + *other modules based on the Quectel BG96. +*/ + +// Header Guards +#ifndef QuectelBG96_h +#define QuectelBG96_h + +// Debugging Statement +// #define MS_QUECTELBG96_DEBUG + +#ifdef MS_QUECTELBG96_DEBUG +#define MS_DEBUGGING_STD +#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT +#endif + +#define TINY_GSM_MODEM_BG96 + +// Time after end pulse until status pin becomes active +#define BG96_STATUS_TIME_MS 4800L +// > 2 sec +#define BG96_DISCONNECT_TIME_MS 5000L + +// Time after VBAT is stable before PWRKEY can be used +#define BG96_WARM_UP_TIME_MS 30 +// USB active at >4.2 sec, status at >4.8 sec, URAT at >4.9 +#define BG96_ATRESPONSE_TIME_MS 4200L + +// How long we're willing to wait to get signal quality +#define BG96_SIGNALQUALITY_TIME_MS 15000L + +// Included Dependencies +#include "ModSensorDebugger.h" +#include "LoggerModem.h" +#include "TinyGsmClient.h" + + +class QuectelBG96 : public loggerModem +{ + +public: + // Constructors + QuectelBG96(Stream* modemStream, + int8_t powerPin, int8_t statusPin, + int8_t modemResetPin, int8_t modemSleepRqPin, + const char *apn, + uint8_t measurementsToAverage = 1); + + + // The a measurement is "complete" when the modem is registered on the network. + // For a cellular modem, this actually sets the GPRS bearer/APN!! + bool startSingleMeasurement(void) override; + bool isMeasurementComplete(bool debug=false) override; + bool addSingleMeasurementResult(void) override; + + bool connectInternet(uint32_t maxConnectionTime = 50000L) override; + void disconnectInternet(void) override; + + uint32_t getNISTTime(void) override; + + TinyGsm _tinyModem; + Stream *_modemStream; + +protected: + virtual bool didATRespond(void) override; + virtual bool isInternetAvailable(void) override; + virtual bool modemSleepFxn(void) override; + virtual bool modemWakeFxn(void) override; + virtual bool extraModemSetup(void)override; + +private: + const char *_apn; +}; + +#endif diff --git a/src/modems/SIMComSIM7000.cpp b/src/modems/SIMComSIM7000.cpp new file mode 100644 index 000000000..10e6d0932 --- /dev/null +++ b/src/modems/SIMComSIM7000.cpp @@ -0,0 +1,77 @@ +/* + *SIMComSIM7000.cpp + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is for the Botletics and other modules based on the SIMCOM SIM7000. +*/ + +// Included Dependencies +#include "SIMComSIM7000.h" +#include "modems/LoggerModemMacros.h" + + +// Constructor +SIMComSIM7000::SIMComSIM7000(Stream* modemStream, + int8_t powerPin, int8_t statusPin, + int8_t modemResetPin, int8_t modemSleepRqPin, + const char *apn, + uint8_t measurementsToAverage) + : loggerModem(powerPin, statusPin, HIGH, + modemResetPin, modemSleepRqPin, + SIM7000_STATUS_TIME_MS, SIM7000_DISCONNECT_TIME_MS, + SIM7000_WARM_UP_TIME_MS, SIM7000_ATRESPONSE_TIME_MS, + SIM7000_SIGNALQUALITY_TIME_MS, + measurementsToAverage), + _tinyModem(*modemStream) +{ + _apn = apn; + TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); + _tinyClient = tinyClient; + _modemStream = modemStream; +} + + +MS_MODEM_DID_AT_RESPOND(SIMComSIM7000); +MS_MODEM_IS_INTERNET_AVAILABLE(SIMComSIM7000); +MS_MODEM_IS_MEASUREMENT_COMPLETE(SIMComSIM7000); +MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(SIMComSIM7000); +MS_MODEM_CONNECT_INTERNET(SIMComSIM7000); +MS_MODEM_DISCONNECT_INTERNET(SIMComSIM7000); +MS_MODEM_GET_NIST_TIME(SIMComSIM7000); + +// Create the wake and sleep methods for the modem +// These can be functions of any type and must return a boolean +bool SIMComSIM7000::modemWakeFxn(void) +{ + // Must power on and then pulse on + if (_modemSleepRqPin >= 0) + { + digitalWrite(_modemSleepRqPin, LOW); + delay(1100); // >1s + digitalWrite(_modemSleepRqPin, LOW); + } + return true; +} + + +bool SIMComSIM7000::modemSleepFxn(void) +{ + if (_modemSleepRqPin >= 0) // R410 must have access to PWRKEY pin to sleep + { + // Easiest to just go to sleep with the AT command rather than using pins + return _tinyModem.poweroff(); + } + else // DON'T go to sleep if we can't wake up! + { + return true; + } +} + + +bool SIMComSIM7000::extraModemSetup(void) +{ + _modemName = _tinyModem.getModemName(); + return true; +} diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h new file mode 100644 index 000000000..85cefa8d8 --- /dev/null +++ b/src/modems/SIMComSIM7000.h @@ -0,0 +1,80 @@ +/* + *SIMComSIM7000.h + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is for the Botletics and other modules based on the SIMCOM SIM7000. +*/ + +// Header Guards +#ifndef SIMComSIM7000_h +#define SIMComSIM7000_h + +// Debugging Statement +// #define MS_SIMCOMSIM7000_DEBUG + +#ifdef MS_SIMCOMSIM7000_DEBUG +#define MS_DEBUGGING_STD +#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT +#endif + +#define TINY_GSM_MODEM_SIM7000 + +// Time after end pulse until status pin becomes active (>4.5sec) +#define SIM7000_STATUS_TIME_MS 4500L +// power down (gracefully) takes 1.8-6.9 sec +#define SIM7000_DISCONNECT_TIME_MS 7000L + +// Time after power on before "PWRKEY" can be used (guess - diagram isn't clear) +#define SIM7000_WARM_UP_TIME_MS 1000L +// Time after end pulse until serial port becomes active (>4.5sec) +#define SIM7000_ATRESPONSE_TIME_MS 4500 + +// How long we're willing to wait to get signal quality +#define SIM7000_SIGNALQUALITY_TIME_MS 15000L + +// Included Dependencies +#include "ModSensorDebugger.h" +#include "LoggerModem.h" +#include "TinyGsmClient.h" + + +class SIMComSIM7000 : public loggerModem +{ + +public: + // Constructors + SIMComSIM7000(Stream* modemStream, + int8_t powerPin, int8_t statusPin, + int8_t modemResetPin, int8_t modemSleepRqPin, + const char *apn, + uint8_t measurementsToAverage = 1); + + + // The a measurement is "complete" when the modem is registered on the network. + // For a cellular modem, this actually sets the GPRS bearer/APN!! + bool startSingleMeasurement(void) override; + bool isMeasurementComplete(bool debug=false) override; + bool addSingleMeasurementResult(void) override; + + bool connectInternet(uint32_t maxConnectionTime = 50000L) override; + void disconnectInternet(void) override; + + uint32_t getNISTTime(void) override; + + TinyGsm _tinyModem; + Stream *_modemStream; + +protected: + virtual bool didATRespond(void) override; + virtual bool isInternetAvailable(void) override; + virtual bool modemSleepFxn(void) override; + virtual bool modemWakeFxn(void) override; + virtual bool extraModemSetup(void)override; + +private: + const char *_apn; +}; + +#endif diff --git a/src/modems/SIMComSIM800.cpp b/src/modems/SIMComSIM800.cpp new file mode 100644 index 000000000..006af5cad --- /dev/null +++ b/src/modems/SIMComSIM800.cpp @@ -0,0 +1,79 @@ +/* + *SIMComSIM800.cpp + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is for the Adafruit Fona 2G, the Sodaq GPRSBee R4 and almost any + * other module based on the SIMCOM SIM800 or SIM900 + *the SIMCOM SIM800h. +*/ + +// Included Dependencies +#include "SIMComSIM800.h" +#include "modems/LoggerModemMacros.h" + + +// Constructor +SIMComSIM800::SIMComSIM800(Stream* modemStream, + int8_t powerPin, int8_t statusPin, + int8_t modemResetPin, int8_t modemSleepRqPin, + const char *apn, + uint8_t measurementsToAverage) + : loggerModem(powerPin, statusPin, HIGH, + modemResetPin, modemSleepRqPin, + SIM800_STATUS_TIME_MS, SIM800_DISCONNECT_TIME_MS, + SIM800_WARM_UP_TIME_MS, SIM800_ATRESPONSE_TIME_MS, + SIM800_SIGNALQUALITY_TIME_MS, + measurementsToAverage), + _tinyModem(*modemStream) +{ + _apn = apn; + TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); + _tinyClient = tinyClient; + _modemStream = modemStream; +} + + +MS_MODEM_DID_AT_RESPOND(SIMComSIM800); +MS_MODEM_IS_INTERNET_AVAILABLE(SIMComSIM800); +MS_MODEM_IS_MEASUREMENT_COMPLETE(SIMComSIM800); +MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(SIMComSIM800); +MS_MODEM_CONNECT_INTERNET(SIMComSIM800); +MS_MODEM_DISCONNECT_INTERNET(SIMComSIM800); +MS_MODEM_GET_NIST_TIME(SIMComSIM800); + +// Create the wake and sleep methods for the modem +// These can be functions of any type and must return a boolean +bool SIMComSIM800::modemWakeFxn(void) +{ + // Must power on and then pulse on + if (_modemSleepRqPin >= 0) + { + digitalWrite(_modemSleepRqPin, LOW); + delay(1100); // >1s + digitalWrite(_modemSleepRqPin, LOW); + } + return true; +} + + +bool SIMComSIM800::modemSleepFxn(void) +{ + if (_modemSleepRqPin >= 0) // R410 must have access to PWRKEY pin to sleep + { + // Easiest to just go to sleep with the AT command rather than using pins + return _tinyModem.poweroff(); + } + else // DON'T go to sleep if we can't wake up! + { + return true; + } +} + + +bool SIMComSIM800::extraModemSetup(void) +{ + _modemName = _tinyModem.getModemName(); + return true; +} diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h new file mode 100644 index 000000000..22e604992 --- /dev/null +++ b/src/modems/SIMComSIM800.h @@ -0,0 +1,83 @@ +/* + *SIMComSIM800.h + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is for the Adafruit Fona 2G, the Sodaq GPRSBee R4 and almost any + * other module based on the SIMCOM SIM800 or SIM900 + *the SIMCOM SIM800h. +*/ + +// Header Guards +#ifndef SIMComSIM800_h +#define SIMComSIM800_h + +// Debugging Statement +// #define MS_SIMCOMSIM800_DEBUG + +#ifdef MS_SIMCOMSIM800_DEBUG +#define MS_DEBUGGING_STD +#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT +#endif + +#define TINY_GSM_MODEM_SIM800 + +// Time after end pulse until status pin becomes active (>3sec from start of 1s pulse) +#define SIM800_STATUS_TIME_MS 2000 +// power down (gracefully) takes >3sec +// (Giving 15sec for shutdown in case it is not monitored.) +#define SIM800_DISCONNECT_TIME_MS 15000L + +// Time after power on before "PWRKEY" can be used - >0.4sec +#define SIM800_WARM_UP_TIME_MS 450 +// Time after end pulse until serial port becomes active (>3sec from start of 1s pulse) +#define SIM800_ATRESPONSE_TIME_MS 2000 + +// How long we're willing to wait to get signal quality +#define SIM800_SIGNALQUALITY_TIME_MS 15000L + +// Included Dependencies +#include "ModSensorDebugger.h" +#include "LoggerModem.h" +#include "TinyGsmClient.h" + + +class SIMComSIM800 : public loggerModem +{ + +public: + // Constructors + SIMComSIM800(Stream* modemStream, + int8_t powerPin, int8_t statusPin, + int8_t modemResetPin, int8_t modemSleepRqPin, + const char *apn, + uint8_t measurementsToAverage = 1); + + + // The a measurement is "complete" when the modem is registered on the network. + // For a cellular modem, this actually sets the GPRS bearer/APN!! + bool startSingleMeasurement(void) override; + bool isMeasurementComplete(bool debug=false) override; + bool addSingleMeasurementResult(void) override; + + bool connectInternet(uint32_t maxConnectionTime = 50000L) override; + void disconnectInternet(void) override; + + uint32_t getNISTTime(void) override; + + TinyGsm _tinyModem; + Stream *_modemStream; + +protected: + virtual bool didATRespond(void) override; + virtual bool isInternetAvailable(void) override; + virtual bool modemSleepFxn(void) override; + virtual bool modemWakeFxn(void) override; + virtual bool extraModemSetup(void)override; + +private: + const char *_apn; +}; + +#endif diff --git a/src/modems/SequansMonarch.cpp b/src/modems/SequansMonarch.cpp new file mode 100644 index 000000000..9fc78a1be --- /dev/null +++ b/src/modems/SequansMonarch.cpp @@ -0,0 +1,84 @@ +/* + *SequansMonarch.cpp + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is for the Botletics and other modules based on the SIMCOM BG96. +*/ + +// Included Dependencies +#include "SequansMonarch.h" +#include "modems/LoggerModemMacros.h" + + +// Constructor +SequansMonarch::SequansMonarch(Stream* modemStream, + int8_t powerPin, int8_t statusPin, + int8_t modemResetPin, int8_t modemSleepRqPin, + const char *apn, + uint8_t measurementsToAverage) + : loggerModem(powerPin, statusPin, HIGH, + modemResetPin, modemSleepRqPin, + MONARCH_STATUS_TIME_MS, MONARCH_DISCONNECT_TIME_MS, + MONARCH_WARM_UP_TIME_MS, MONARCH_ATRESPONSE_TIME_MS, + MONARCH_SIGNALQUALITY_TIME_MS, + measurementsToAverage), + _tinyModem(*modemStream) +{ + _apn = apn; + TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); + _tinyClient = tinyClient; + _modemStream = modemStream; +} + + +MS_MODEM_DID_AT_RESPOND(SequansMonarch); +MS_MODEM_IS_INTERNET_AVAILABLE(SequansMonarch); +MS_MODEM_IS_MEASUREMENT_COMPLETE(SequansMonarch); +MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(SequansMonarch); +MS_MODEM_CONNECT_INTERNET(SequansMonarch); +MS_MODEM_DISCONNECT_INTERNET(SequansMonarch); +MS_MODEM_GET_NIST_TIME(SequansMonarch); + +// Create the wake and sleep methods for the modem +// These can be functions of any type and must return a boolean +bool SequansMonarch::modemWakeFxn(void) +{ + // Module turns on when power is applied + // No pulsing required in this case + if (_powerPin >= 0) + return true; + if (_modemSleepRqPin >= 0) + { + digitalWrite(_modemSleepRqPin, LOW); + delayMicroseconds(50); // ?? Time isn't documented + digitalWrite(_modemSleepRqPin, HIGH); + return true; + } + else + { + return true; + } +} + + +bool SequansMonarch::modemSleepFxn(void) +{ + if (_powerPin >= 0 || _modemSleepRqPin >= 0) // will go on with power on + { + // Easiest to just go to sleep with the AT command rather than using pins + return _tinyModem.poweroff(); + } + else // DON'T go to sleep if we can't wake up! + { + return true; + } +} + + +bool SequansMonarch::extraModemSetup(void) +{ + _modemName = _tinyModem.getModemName(); + return true; +} diff --git a/src/modems/SequansMonarch.h b/src/modems/SequansMonarch.h new file mode 100644 index 000000000..9a7261e61 --- /dev/null +++ b/src/modems/SequansMonarch.h @@ -0,0 +1,81 @@ +/* + *SequansMonarch.h + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is for the Dragino BG96, Nimbelink Skywire 4G LTE-M Global, and + *other modules based on the Quectel BG96. +*/ + +// Header Guards +#ifndef SequansMonarch_h +#define SequansMonarch_h + +// Debugging Statement +// #define MS_SEQUANSMONARCH_DEBUG + +#ifdef MS_SEQUANSMONARCH_DEBUG +#define MS_DEBUGGING_STD +#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT +#endif + +#define TINY_GSM_MODEM_SEQUANS_MONARCH + +// ?? Undocumented +#define MONARCH_STATUS_TIME_MS 50 +// ?? Undocumented (Giving 15sec here in case it is not monitored.) +#define MONARCH_DISCONNECT_TIME_MS 15000L + +// Module automatically boots when power is applied +#define MONARCH_WARM_UP_TIME_MS 0 +// ?? Time to UART availability not documented +#define MONARCH_ATRESPONSE_TIME_MS 5000L + +// How long we're willing to wait to get signal quality +#define MONARCH_SIGNALQUALITY_TIME_MS 15000L + +// Included Dependencies +#include "ModSensorDebugger.h" +#include "LoggerModem.h" +#include "TinyGsmClient.h" + + +class SequansMonarch : public loggerModem +{ + +public: + // Constructors + SequansMonarch(Stream* modemStream, + int8_t powerPin, int8_t statusPin, + int8_t modemResetPin, int8_t modemSleepRqPin, + const char *apn, + uint8_t measurementsToAverage = 1); + + + // The a measurement is "complete" when the modem is registered on the network. + // For a cellular modem, this actually sets the GPRS bearer/APN!! + bool startSingleMeasurement(void) override; + bool isMeasurementComplete(bool debug=false) override; + bool addSingleMeasurementResult(void) override; + + bool connectInternet(uint32_t maxConnectionTime = 50000L) override; + void disconnectInternet(void) override; + + uint32_t getNISTTime(void) override; + + TinyGsm _tinyModem; + Stream *_modemStream; + +protected: + virtual bool didATRespond(void) override; + virtual bool isInternetAvailable(void) override; + virtual bool modemSleepFxn(void) override; + virtual bool modemWakeFxn(void) override; + virtual bool extraModemSetup(void)override; + +private: + const char *_apn; +}; + +#endif diff --git a/src/modems/Sodaq2GBeeR6.cpp b/src/modems/Sodaq2GBeeR6.cpp new file mode 100644 index 000000000..a3632e14b --- /dev/null +++ b/src/modems/Sodaq2GBeeR6.cpp @@ -0,0 +1,64 @@ +/* + *Sodaq2GBeeR6.cpp + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is the Sodaq 2GBee revisions 6 and higher - these are based on + *the SIMCOM SIM800h. +*/ + +// Included Dependencies +#include "Sodaq2GBeeR6.h" +#include "modems/LoggerModemMacros.h" + + +// Constructor +Sodaq2GBeeR6::Sodaq2GBeeR6(Stream* modemStream, + int8_t powerPin, int8_t statusPin, int8_t modemSleepRqPin, + const char *apn, + uint8_t measurementsToAverage) + : loggerModem(powerPin, statusPin, HIGH, + -1, modemSleepRqPin, + SIM800_STATUS_TIME_MS, SIM800_DISCONNECT_TIME_MS, + SIM800_WARM_UP_TIME_MS, SIM800_ATRESPONSE_TIME_MS, + SIM800_SIGNALQUALITY_TIME_MS, + measurementsToAverage), + _tinyModem(*modemStream) +{ + _apn = apn; + TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); + _tinyClient = tinyClient; + _modemStream = modemStream; +} + + +MS_MODEM_DID_AT_RESPOND(Sodaq2GBeeR6); +MS_MODEM_IS_INTERNET_AVAILABLE(Sodaq2GBeeR6); +MS_MODEM_IS_MEASUREMENT_COMPLETE(Sodaq2GBeeR6); +MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(Sodaq2GBeeR6); +MS_MODEM_CONNECT_INTERNET(Sodaq2GBeeR6); +MS_MODEM_DISCONNECT_INTERNET(Sodaq2GBeeR6); +MS_MODEM_GET_NIST_TIME(Sodaq2GBeeR6); + +// Create the wake and sleep methods for the modem +// These can be functions of any type and must return a boolean +bool Sodaq2GBeeR6::modemWakeFxn(void) +{ + digitalWrite(_modemSleepRqPin, HIGH); + return true; +} + + +bool Sodaq2GBeeR6::modemSleepFxn(void) +{ + digitalWrite(_modemSleepRqPin, LOW); + return true; +} + + +bool Sodaq2GBeeR6::extraModemSetup(void) +{ + _modemName = _tinyModem.getModemName(); + return true; +} diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h index 359f1f47e..9dcc569a2 100644 --- a/src/modems/Sodaq2GBeeR6.h +++ b/src/modems/Sodaq2GBeeR6.h @@ -4,12 +4,13 @@ * *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). * - *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module + *This file is the Sodaq 2GBee revisions 6 and higher - these are based on + *the SIMCOM SIM800h. */ // Header Guards -#ifndef ModularSensorsSpecificModem_h -#define ModularSensorsSpecificModem_h +#ifndef Sodaq2GBeeR6_h +#define Sodaq2GBeeR6_h // Debugging Statement // #define MS_SODAQ2GBEER6_DEBUG @@ -19,87 +20,62 @@ #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates - -// Included Dependencies -#include "ModSensorDebugger.h" -#include "LoggerModem.h" - -// ========================================================================== -// Wifi/Cellular Modem Main Chip Selection -// ========================================================================== - -// Select your modem chip - this determines the exact commands sent to it -#define TINY_GSM_MODEM_SIM800 // Select for a SIMCOM SIM800, SIM900, or variant thereof - - -// ========================================================================== -// Modem Pins -// ========================================================================== - -// Declare the existance of modem pin Variables -// Use the "extern" keyword to denote that these will actually be defined in -// the main program rather than in this file. - -extern const int8_t modemVccPin; -extern const int8_t modemSleepRqPin; -extern const int8_t modemStatusPin; -extern const int8_t modemResetPin; -extern const int8_t modemLEDPin; +#define TINY_GSM_MODEM_SIM800 +// Time after end pulse until status pin becomes active (>3sec from start of 1s pulse) +#define SIM800_STATUS_TIME_MS 2000 +// power down (gracefully) takes >3sec +// (Giving 15sec for shutdown in case it is not monitored.) +#define SIM800_DISCONNECT_TIME_MS 15000L -// ========================================================================== -// TinyGSM Client -// ========================================================================== +// Time after power on before "PWRKEY" can be used - >0.4sec +#define SIM800_WARM_UP_TIME_MS 450 +// Time after end pulse until serial port becomes active (>3sec from start of 1s pulse) +#define SIM800_ATRESPONSE_TIME_MS 2000 -// #define TINY_GSM_DEBUG Serial // If you want debugging on the main debug port +// How long we're willing to wait to get signal quality +#define SIM800_SIGNALQUALITY_TIME_MS 15000L -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates - -// Include TinyGSM for the modem -// This include must be included below the define of the modem name! -#include +// Included Dependencies +#include "ModSensorDebugger.h" +#include "LoggerModem.h" +#include "TinyGsmClient.h" -// Create a reference to the serial port for the modem -// Extra hardware and software serial ports are created in the "Settings for Additional Serial Ports" section -HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible -// AltSoftSerial &modemSerial = altSoftSerial; // For software serial if needed -// NeoSWSerial &modemSerial = neoSSerial1; // For software serial if needed -// Create a new TinyGSM modem to run on that serial port and return a pointer to it -#if defined TINY_GSM_MODEM_XBEE -TinyGsm *tinyModem = new TinyGsm(modemSerial, modemResetPin); -#else -TinyGsm *tinyModem = new TinyGsm(modemSerial); -#endif - -// Create a new TCP client on that modem and return a pointer to it -TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); +class Sodaq2GBeeR6 : public loggerModem +{ +public: + // Constructors + Sodaq2GBeeR6(Stream* modemStream, + int8_t powerPin, int8_t statusPin, int8_t modemSleepRqPin, + const char *apn, + uint8_t measurementsToAverage = 1); -// ========================================================================== -// Specific Modem On-Off Methods -// ========================================================================== -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -bool modemWakeFxn(void) -{ - digitalWrite(modemSleepRqPin, HIGH); - digitalWrite(modemLEDPin, HIGH); // A light just for show - return true; -} + // The a measurement is "complete" when the modem is registered on the network. + // For a cellular modem, this actually sets the GPRS bearer/APN!! + bool startSingleMeasurement(void) override; + bool isMeasurementComplete(bool debug=false) override; + bool addSingleMeasurementResult(void) override; + bool connectInternet(uint32_t maxConnectionTime = 50000L) override; + void disconnectInternet(void) override; -bool modemSleepFxn(void) -{ - digitalWrite(modemSleepRqPin, LOW); - digitalWrite(modemLEDPin, LOW); - return true; -} + uint32_t getNISTTime(void) override; + TinyGsm _tinyModem; + Stream *_modemStream; -void extraModemSetup(void){} +protected: + virtual bool didATRespond(void) override; + virtual bool isInternetAvailable(void) override; + virtual bool modemSleepFxn(void) override; + virtual bool modemWakeFxn(void) override; + virtual bool extraModemSetup(void)override; +private: + const char *_apn; +}; #endif diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp new file mode 100644 index 000000000..4c748c0d6 --- /dev/null +++ b/src/modems/SodaqUBeeR410M.cpp @@ -0,0 +1,117 @@ +/* + *SodaqUBeeR410M.cpp + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module +*/ + +// Included Dependencies +#include "SodaqUBeeR410M.h" +#include "modems/LoggerModemMacros.h" + + +// Constructor +#if F_CPU == 8000000L +SodaqUBeeR410M::SodaqUBeeR410M(HardwareSerial* modemStream, + int8_t powerPin, int8_t statusPin, int8_t modemSleepRqPin, + const char *apn, + uint8_t measurementsToAverage) + : loggerModem(powerPin, statusPin, HIGH, + -1, modemSleepRqPin, + R410M_STATUS_TIME_MS, R410M_DISCONNECT_TIME_MS, + R410M_WARM_UP_TIME_MS, R410M_ATRESPONSE_TIME_MS, + R410M_SIGNALQUALITY_TIME_MS, + measurementsToAverage), + _tinyModem(*modemStream) +{ + _apn = apn; + TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); + _tinyClient = tinyClient; + _modemStream = modemStream; +} +#else +SodaqUBeeR410M::SodaqUBeeR410M(Stream* modemStream, + int8_t powerPin, int8_t statusPin, int8_t modemSleepRqPin, + const char *apn, + uint8_t measurementsToAverage) + : loggerModem(powerPin, statusPin, HIGH, + -1, modemSleepRqPin, + R410M_STATUS_TIME_MS, R410M_DISCONNECT_TIME_MS, + R410M_WARM_UP_TIME_MS, R410M_ATRESPONSE_TIME_MS, + R410M_SIGNALQUALITY_TIME_MS, + measurementsToAverage), + _tinyModem(*modemStream) +{ + _apn = apn; + TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); + _tinyClient = tinyClient; + _modemStream = modemStream; + _statusLevel = HIGH; +} +#endif + + +MS_MODEM_DID_AT_RESPOND(SodaqUBeeR410M); +MS_MODEM_IS_INTERNET_AVAILABLE(SodaqUBeeR410M); +MS_MODEM_IS_MEASUREMENT_COMPLETE(SodaqUBeeR410M); +MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(SodaqUBeeR410M); +MS_MODEM_CONNECT_INTERNET(SodaqUBeeR410M); +MS_MODEM_DISCONNECT_INTERNET(SodaqUBeeR410M); +MS_MODEM_GET_NIST_TIME(SodaqUBeeR410M); + + +// Create the wake and sleep methods for the modem +// These can be functions of any type and must return a boolean +bool SodaqUBeeR410M::modemWakeFxn(void) +{ + // SARA R4/N4 series must power on and then pulse on + if (_modemSleepRqPin >= 0) + { + digitalWrite(_modemSleepRqPin, LOW); + delay(200); // 0.15-3.2s pulse for wake on SARA R4/N4 + digitalWrite(_modemSleepRqPin, HIGH); + // Need to slow down R4/N4's default 115200 baud rate for slow processors + // The baud rate setting is NOT saved to non-volatile memory, so it must + // be changed every time after loosing power. + #if F_CPU == 8000000L + if (_powerPin >= 0) + { + delay(4600); // Must wait for UART port to become active + _modemStream->begin(115200); + _tinyModem.setBaud(9600); + _modemStream->end(); + _modemStream->begin(9600); + } + #endif + return true; + } + else + { + return true; + } +} + + +bool SodaqUBeeR410M::modemSleepFxn(void) +{ + if (_modemSleepRqPin >= 0) // R410 must have access to PWR_ON pin to sleep + { + // Easiest to just go to sleep with the AT command rather than using pins + return _tinyModem.poweroff(); + } + else // DON'T go to sleep if we can't wake up! + { + return true; + } +} + + +bool SodaqUBeeR410M::extraModemSetup(void) +{ + _modemName = _tinyModem.getModemName(); + // Set to only use LTE-M, which should cause connection more quickly + _tinyModem.sendAT(F("+URAT=7")); + return true; +} diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index d77995f7d..b91e32e0e 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -8,96 +8,87 @@ */ // Header Guards -#ifndef ModularSensorsSpecificModem_h -#define ModularSensorsSpecificModem_h +#ifndef SodaqUBeeR410M_h +#define SodaqUBeeR410M_h // Debugging Statement -// #define MS_SODAQUBEER410M_DEBUG +// #define MS_SodaqUBeeR410M_DEBUG #ifdef MS_SODAQUBEER410M_DEBUG #define MS_DEBUGGING_STD #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates +#define TINY_GSM_MODEM_UBLOX +// V_INT becomes active mid-way through on-pulse +#define R410M_STATUS_TIME_MS 0 +// Power down time "can largely vary depending +// on the application / network settings and the concurrent module +// activities." Vint/status pin should be monitored and power not withdrawn +// until that pin reads low. Giving 15sec here in case it is not monitored. +#define R410M_DISCONNECT_TIME_MS 15000L + +// Time after power on before PWR_ON can be used ??? Unclear in documentation! +#define R410M_WARM_UP_TIME_MS 250 +// Time until system and digital pins are operational (~4.5s) +#define R410M_ATRESPONSE_TIME_MS 4500L + +// How long we're willing to wait to get signal quality +#define R410M_SIGNALQUALITY_TIME_MS 15000L // Included Dependencies #include "ModSensorDebugger.h" #include "LoggerModem.h" +#include "TinyGsmClient.h" -// ========================================================================== -// Wifi/Cellular Modem Main Chip Selection -// ========================================================================== - -// Select your modem chip - this determines the exact commands sent to it -#define TINY_GSM_MODEM_UBLOX // Select for most u-blox cellular modems - - -// ========================================================================== -// Modem Pins -// ========================================================================== - -// Declare the existance of modem pin Variables -// Use the "extern" keyword to denote that these will actually be defined in -// the main program rather than in this file. -extern const int8_t modemVccPin; -extern const int8_t modemSleepRqPin; -extern const int8_t modemStatusPin; -extern const int8_t modemResetPin; -extern const int8_t modemLEDPin; - - -// ========================================================================== -// Specific Modem On-Off Methods -// ========================================================================== - -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -bool modemSleepFxn(void) -{ - if (modemSleepRqPin >= 0) // R410 must have access to PWR_ON pin to sleep - { - // Easiest to just go to sleep with the AT command rather than using pins - return tinyModem->poweroff(); - } - else // DON'T go to sleep if we can't wake up! - { - return true; - } -} -bool modemWakeFxn(void) -{ - // SARA R4/N4 series must power on and then pulse on - if (modemSleepRqPin >= 0) - { - digitalWrite(modemSleepRqPin, LOW); - digitalWrite(modemLEDPin, HIGH); - delay(200); // 0.15-3.2s pulse for wake on SARA R4/N4 - digitalWrite(modemSleepRqPin, HIGH); - digitalWrite(modemLEDPin, LOW); - // Need to slow down R4/N4's default 115200 baud rate for slow processors - #if F_CPU == 8000000L && defined USE_UBLOX_R410M - delay(4600); // Must wait for UART port to become active - modemSerial.begin(115200); - tinyModem->setBaud(9600); - modemSerial.end(); - modemSerial.begin(9600); - #endif - return true; - } - else - { - return true; - } -} - - -void extraModemSetup(void) +class SodaqUBeeR410M : public loggerModem { - tinyModem->sendAT(F("+URAT=7")); - tinyModem->waitResponse(); -} +public: + // Constructors + #if F_CPU == 8000000L + // At this slow baud rate, we need to begin and end serial communication, + // so we need a Serial instance rather than a stream + SodaqUBeeR410M(HardwareSerial* modemStream, + int8_t powerPin, int8_t statusPin, int8_t modemSleepRqPin, + const char *apn, + uint8_t measurementsToAverage = 1); + #else + SodaqUBeeR410M(Stream* modemStream, + int8_t powerPin, int8_t statusPin, int8_t modemSleepRqPin, + const char *apn, + uint8_t measurementsToAverage = 1); + #endif + + + // The a measurement is "complete" when the modem is registered on the network. + // For a cellular modem, this actually sets the GPRS bearer/APN!! + bool startSingleMeasurement(void) override; + bool isMeasurementComplete(bool debug=false) override; + bool addSingleMeasurementResult(void) override; + + bool connectInternet(uint32_t maxConnectionTime = 50000L) override; + void disconnectInternet(void) override; + + uint32_t getNISTTime(void) override; + + TinyGsm _tinyModem; + #if F_CPU == 8000000L + HardwareSerial *_modemStream; + #else + Stream *_modemStream; + #endif + +protected: + virtual bool didATRespond(void) override; + virtual bool isInternetAvailable(void) override; + virtual bool modemSleepFxn(void) override; + virtual bool modemWakeFxn(void) override; + virtual bool extraModemSetup(void)override; + +private: + const char *_apn; +}; #endif diff --git a/src/modems/SodaqUBeeU201.cpp b/src/modems/SodaqUBeeU201.cpp new file mode 100644 index 000000000..284aa6d1f --- /dev/null +++ b/src/modems/SodaqUBeeU201.cpp @@ -0,0 +1,84 @@ +/* + *SodaqUBeeU201.cpp + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is the Sodaq UBee based on the u-blox SARA U201 3G Cellular Module +*/ + +// Included Dependencies +#include "SodaqUBeeU201.h" +#include "modems/LoggerModemMacros.h" + + +// Constructor +SodaqUBeeU201::SodaqUBeeU201(Stream* modemStream, + int8_t powerPin, int8_t statusPin, int8_t modemSleepRqPin, + const char *apn, + uint8_t measurementsToAverage) + : loggerModem(powerPin, statusPin, HIGH, + -1, modemSleepRqPin, + U201_STATUS_TIME_MS, U201_DISCONNECT_TIME_MS, + U201_WARM_UP_TIME_MS, U201_ATRESPONSE_TIME_MS, + U201_SIGNALQUALITY_TIME_MS, + measurementsToAverage), + _tinyModem(*modemStream) +{ + _apn = apn; + TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); + _tinyClient = tinyClient; + _modemStream = modemStream; +} + + +MS_MODEM_DID_AT_RESPOND(SodaqUBeeU201); +MS_MODEM_IS_INTERNET_AVAILABLE(SodaqUBeeU201); +MS_MODEM_IS_MEASUREMENT_COMPLETE(SodaqUBeeU201); +MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(SodaqUBeeU201); +MS_MODEM_CONNECT_INTERNET(SodaqUBeeU201); +MS_MODEM_DISCONNECT_INTERNET(SodaqUBeeU201); +MS_MODEM_GET_NIST_TIME(SodaqUBeeU201); + + +// Create the wake and sleep methods for the modem +// These can be functions of any type and must return a boolean +bool SodaqUBeeU201::modemWakeFxn(void) +{ + // SARA/LISA U2/G2 and SARA G3 series turn on when power is applied + // No pulsing required in this case + if (_powerPin >= 0) + return true; + if (_modemSleepRqPin >= 0) + { + digitalWrite(_modemSleepRqPin, LOW); + delayMicroseconds(65); // 50-80µs pulse for wake on SARA/LISA U2/G2 + digitalWrite(_modemSleepRqPin, HIGH); + return true; + } + else + { + return true; + } +} + + +bool SodaqUBeeU201::modemSleepFxn(void) +{ + if (_powerPin >= 0 || _modemSleepRqPin >= 0) // will go on with power on + { + // Easiest to just go to sleep with the AT command rather than using pins + return _tinyModem.poweroff(); + } + else // DON'T go to sleep if we can't wake up! + { + return true; + } +} + + +bool SodaqUBeeU201::extraModemSetup(void) +{ + _modemName = _tinyModem.getModemName(); + return true; +} diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index 84e142433..dc584cd00 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -4,118 +4,81 @@ * *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). * - *This file is the Sodaq UBee based on the u-blox SARA R410M LTE-M Cellular Module + *This file is the Sodaq UBee based on the u-blox SARA U201 3G Cellular Module */ // Header Guards -#ifndef ModularSensorsSpecificModem_h -#define ModularSensorsSpecificModem_h +#ifndef SodaqUBeeU201_h +#define SodaqUBeeU201_h // Debugging Statement -// #define MS_SODAQUBEEU201_DEBUG +// #define MS_SodaqUBeeU201_DEBUG #ifdef MS_SODAQUBEEU201_DEBUG #define MS_DEBUGGING_STD #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates +#define TINY_GSM_MODEM_UBLOX +// Time after end pulse until V_INT becomes active +// Unspecified in documentation! Taking value from Lisa U2 +#define U201_STATUS_TIME_MS 35 +// Power down time "can largely vary depending +// on the application / network settings and the concurrent module +// activities." Vint/status pin should be monitored and power not withdrawn +// until that pin reads low. Giving 15sec here in case it is not monitored. +#define U201_DISCONNECT_TIME_MS 15000L + +// Module turns on when power is applied - level of PWR_ON then irrelevant +#define U201_WARM_UP_TIME_MS 0 +// Time until system and digital pins are operational +// (6 sec typical for SARA U201) +// Time for an AT response may be even longer when using a 3G XBee in bypass mode! +#define U201_ATRESPONSE_TIME_MS 6000L + +// How long we're willing to wait to get signal quality +#define U201_SIGNALQUALITY_TIME_MS 15000L // Included Dependencies #include "ModSensorDebugger.h" #include "LoggerModem.h" +#include "TinyGsmClient.h" -// ========================================================================== -// Wifi/Cellular Modem Main Chip Selection -// ========================================================================== -// Select your modem chip - this determines the exact commands sent to it -#define TINY_GSM_MODEM_UBLOX // Select for most u-blox cellular modems - - -// ========================================================================== -// Modem Pins -// ========================================================================== - -// Declare the existance of modem pin Variables -// Use the "extern" keyword to denote that these will actually be defined in -// the main program rather than in this file. - -extern const int8_t modemVccPin; -extern const int8_t modemSleepRqPin; -extern const int8_t modemStatusPin; -extern const int8_t modemResetPin; -extern const int8_t modemLEDPin; - - -// ========================================================================== -// TinyGSM Client -// ========================================================================== - -// #define TINY_GSM_DEBUG Serial // If you want debugging on the main debug port - -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates +class SodaqUBeeU201 : public loggerModem +{ -// Include TinyGSM for the modem -// This include must be included below the define of the modem name! -#include +public: + // Constructors + SodaqUBeeU201(Stream* modemStream, + int8_t powerPin, int8_t statusPin, int8_t modemSleepRqPin, + const char *apn, + uint8_t measurementsToAverage = 1); -// Create a reference to the serial port for the modem -// Extra hardware and software serial ports are created in the "Settings for Additional Serial Ports" section -HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible -// AltSoftSerial &modemSerial = altSoftSerial; // For software serial if needed -// NeoSWSerial &modemSerial = neoSSerial1; // For software serial if needed -// Create a new TinyGSM modem to run on that serial port and return a pointer to it -TinyGsm *tinyModem = new TinyGsm(modemSerial); + // The a measurement is "complete" when the modem is registered on the network. + // For a cellular modem, this actually sets the GPRS bearer/APN!! + bool startSingleMeasurement(void) override; + bool isMeasurementComplete(bool debug=false) override; + bool addSingleMeasurementResult(void) override; -// Create a new TCP client on that modem and return a pointer to it -TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); + bool connectInternet(uint32_t maxConnectionTime = 50000L) override; + void disconnectInternet(void) override; + uint32_t getNISTTime(void) override; -// ========================================================================== -// Specific Modem On-Off Methods -// ========================================================================== + TinyGsm _tinyModem; + Stream *_modemStream; -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -bool modemSleepFxn(void) -{ - if (modemVccPin >= 0 || modemSleepRqPin >= 0) // others will go on with power on - { - // Easiest to just go to sleep with the AT command rather than using pins - return tinyModem->poweroff(); - } - else // DON'T go to sleep if we can't wake up! - { - return true; - } -} - - -bool modemWakeFxn(void) -{ - // SARA/LISA U2/G2 and SARA G3 series turn on when power is applied - if (modemVccPin >= 0) - return true; - if (modemSleepRqPin >= 0) - { - digitalWrite(modemSleepRqPin, LOW); - digitalWrite(modemLEDPin, HIGH); - // delay(6); // >5ms pulse for wake on SARA G3 - delayMicroseconds(65); // 50-80µs pulse for wake on SARA/LISA U2/G2 - digitalWrite(modemSleepRqPin, HIGH); - digitalWrite(modemLEDPin, LOW); - return true; - } - else - { - return true; - } -} - - -void extraModemSetup(void){} +protected: + virtual bool didATRespond(void) override; + virtual bool isInternetAvailable(void) override; + virtual bool modemSleepFxn(void) override; + virtual bool modemWakeFxn(void) override; + virtual bool extraModemSetup(void)override; +private: + const char *_apn; +}; #endif From 4c3e554acb425043f9c3fee866f76c3470751414 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 14 May 2019 16:30:59 -0400 Subject: [PATCH 15/88] Setup modem pins in setup --- src/LoggerModem.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index ccc404664..421f10607 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -69,6 +69,24 @@ bool loggerModem::setup(void) { bool success = Sensor::setup(); // this will set pin modes and the setup status bit + // Set-up pin modes + if (_modemSleepRqPin >= 0) + { + pinMode(_modemSleepRqPin, OUTPUT); + // NOTE: Not setting level of sleep request pin + } + int8_t _modemResetPin; + if (_modemResetPin >= 0) + { + pinMode(_modemResetPin, OUTPUT); + digitalWrite(_modemResetPin, HIGH); + } + if (_modemLEDPin >= 0) + { + pinMode(_modemLEDPin, OUTPUT); + digitalWrite(_modemLEDPin, LOW); + } + // Initialize the modem MS_DBG(F("Setting up the modem ...")); From e051526c5c944383f6791329496b3abbec0eeda3 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 14 May 2019 16:58:56 -0400 Subject: [PATCH 16/88] Added forgotten esp light sleep pins --- src/modems/EspressifESP8266.cpp | 15 +++++++++------ src/modems/EspressifESP8266.h | 7 ++++--- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index d0247e573..5fbec975b 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -19,7 +19,8 @@ EspressifESP8266::EspressifESP8266(Stream* modemStream, int8_t powerPin, int8_t statusPin, int8_t modemResetPin, int8_t modemSleepRqPin, const char *ssid, const char *pwd, - uint8_t measurementsToAverage) + uint8_t measurementsToAverage, + int8_t espSleepRqPin, int8_t espStatusPin) : loggerModem(powerPin, statusPin, HIGH, modemResetPin, modemSleepRqPin, ESP8266_STATUS_TIME_MS, ESP8266_DISCONNECT_TIME_MS, @@ -33,6 +34,8 @@ EspressifESP8266::EspressifESP8266(Stream* modemStream, TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); _tinyClient = tinyClient; _modemStream = modemStream; + _espSleepRqPin = espSleepRqPin; + _espStatusPin = espStatusPin; } @@ -134,8 +137,8 @@ bool EspressifESP8266::modemSleepFxn(void) // pin to view the sleep status. else if (_modemSleepRqPin >= 0 && _dataPin >= 0) { - _tinyModem.sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0,"), - String(espStatusPin), ',', _statusLevel); + _tinyModem.sendAT(F("+WAKEUPGPIO=1,"), String(_espSleepRqPin), F(",0,"), + String(_espStatusPin), ',', _statusLevel); bool success = _tinyModem.waitResponse() == 1; _tinyModem.sendAT(F("+SLEEP=1")); success &= _tinyModem.waitResponse() == 1; @@ -144,7 +147,7 @@ bool EspressifESP8266::modemSleepFxn(void) // Light sleep without the status pin else if (_modemSleepRqPin >= 0 && _dataPin < 0) { - _tinyModem.sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0")); + _tinyModem.sendAT(F("+WAKEUPGPIO=1,"), String(_espSleepRqPin), F(",0")); bool success = _tinyModem.waitResponse() == 1; _tinyModem.sendAT(F("+SLEEP=1")); success &= _tinyModem.waitResponse() == 1; @@ -175,8 +178,8 @@ bool EspressifESP8266::extraModemSetup(void) // #endif if (_powerPin < 0 && _modemResetPin < 0 && _modemSleepRqPin >= 0 && _dataPin >= 0) { - _tinyModem.sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0,"), - String(espStatusPin), ',', _statusLevel); + _tinyModem.sendAT(F("+WAKEUPGPIO=1,"), String(_espSleepRqPin), F(",0,"), + String(_espStatusPin), ',', _statusLevel); _tinyModem.waitResponse(); } return true; diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h index b57c3b055..f5c18f717 100644 --- a/src/modems/EspressifESP8266.h +++ b/src/modems/EspressifESP8266.h @@ -53,7 +53,8 @@ class EspressifESP8266 : public loggerModem int8_t powerPin, int8_t statusPin, int8_t modemResetPin, int8_t modemSleepRqPin, const char *ssid, const char *pwd, - uint8_t measurementsToAverage = 1); + uint8_t measurementsToAverage = 1, + int8_t espSleepRqPin = -1, int8_t espStatusPin = -1); // The a measurement is "complete" when the modem is registered on the network. @@ -82,8 +83,8 @@ class EspressifESP8266 : public loggerModem const char *_ssid; const char *_pwd; - int8_t espSleepRqPin; - int8_t espStatusPin; + int8_t _espSleepRqPin; + int8_t _espStatusPin; }; #endif From e830e4cef2878e94aced0764b8ac47309417ce7e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 14 May 2019 17:28:43 -0400 Subject: [PATCH 17/88] Start updating examples --- examples/menu_a_la_carte/menu_a_la_carte.ino | 626 ++++--------------- src/modems/LoggerModemMacros.h | 9 +- 2 files changed, 120 insertions(+), 515 deletions(-) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 68e11a557..45ae72fc8 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -169,47 +169,35 @@ void SERCOM2_Handler() // ========================================================================== -// Wifi/Cellular Modem Main Chip Selection +// Wifi/Cellular Modems // ========================================================================== -// Select your modem chip - this determines the exact commands sent to it -// #define TINY_GSM_MODEM_SIM800 // Select for a SIMCOM SIM800, SIM900, or variant thereof -// #define SIM800_GPRSBEE_R6 // Select with SIM800 for - these use atypical sleep and wake fxns -// #define TINY_GSM_MODEM_SIM808 // Select for a SIMCOM SIM808 or SIM868, or variant thereof -// #define TINY_GSM_MODEM_UBLOX // Select for most u-blox cellular modems -// #define USE_UBLOX_R410M // Select with UBLOX for a non-XBee SARA R4 or N4 model -// #define USE_XBEE_BYPASS // Select with UBLOX for a Digi 3G or LTE-M XBee in bypass mode -// #define TINY_GSM_MODEM_ESP8266 // Select for an ESP8266 using the DEFAULT AT COMMAND FIRMWARE -#define TINY_GSM_MODEM_XBEE // Select for Digi brand WiFi or Cellular XBee's -// #define USE_XBEE_WIFI // Select with XBEE for an S6B wifi XBee -// #define TINY_GSM_MODEM_M590 // Select for a Neoway M590 -// #define TINY_GSM_MODEM_A6 // Select for an AI-Thinker A6, A6C, A7, A20 -// #define TINY_GSM_MODEM_M95 // Select for a Quectel M95 -// #define TINY_GSM_MODEM_BG96 // Select for a Quectel BG96 -// #define TINY_GSM_MODEM_MC60 // Select for a Quectel MC60 or MC60E - - // ========================================================================== // Modem Pins // ========================================================================== +// Describe the physical pin connection of your modem to your board const int8_t modemVccPin = -2; // MCU pin controlling modem power (-1 if not applicable) -const int8_t modemSleepRqPin = 23; // MCU pin used for modem sleep/wake request (-1 if not applicable) const int8_t modemStatusPin = 19; // MCU pin used to read modem status (-1 if not applicable) const int8_t modemResetPin = A4; // MCU pin connected to modem reset pin (-1 if unconnected) +const int8_t modemSleepRqPin = 23; // MCU pin used for modem sleep/wake request (-1 if not applicable) +const bool useCTSforStatus = true; // Flag to use the modem CTS pin for status. Only applies to Digi XBee's +const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem status (-1 if unconnected) // ========================================================================== -// TinyGSM Client +// Network Information // ========================================================================== -// #define TINY_GSM_DEBUG Serial // If you want debugging on the main debug port +// Network connection information +const char *apn = "xxxxx"; // The APN for the gprs connection, unnecessary for WiFi +const char *wifiId = "xxxxx"; // The WiFi access point, unnecessary for gprs +const char *wifiPwd = "xxxxx"; // The password for connecting to WiFi, unnecessary for gprs -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates -// Include TinyGSM for the modem -// This include must be included below the define of the modem name! -#include +// ========================================================================== +// Modem Serial Port and Baud Rate +// ========================================================================== // Create a reference to the serial port for the modem // Extra hardware and software serial ports are created in the "Settings for Additional Serial Ports" section @@ -217,474 +205,109 @@ HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible // AltSoftSerial &modemSerial = altSoftSerial; // For software serial if needed // NeoSWSerial &modemSerial = neoSSerial1; // For software serial if needed -// Create a new TinyGSM modem to run on that serial port and return a pointer to it -#if defined TINY_GSM_MODEM_XBEE -TinyGsm *tinyModem = new TinyGsm(modemSerial, modemResetPin); -#else -TinyGsm *tinyModem = new TinyGsm(modemSerial); -#endif - // Use this to create a modem if you want to spy on modem communication through // a secondary Arduino stream. Make sure you install the StreamDebugger library! // https://github.com/vshymanskyy/StreamDebugger -// Also make sure you comment out the modem creation above to use this. +// Also make sure you comment out the serial port above // #include -// StreamDebugger modemDebugger(modemSerial, Serial); -// #if defined TINY_GSM_MODEM_XBEE -// TinyGsm *tinyModem = new TinyGsm(modemDebugger, modemResetPin); -// #else -// TinyGsm *tinyModem = new TinyGsm(modemDebugger); -// #endif - -// Create a new TCP client on that modem and return a pointer to it -TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); -// The u-blox SARA R410 is very slow to open and close clients, so we can -// iterate through mutiple data senders much more quickly if we have multiple -// clients. The u-blox SARA R410 is the only modem where there's any advantage -// to this. -#if defined USE_UBLOX_R410M -TinyGsmClient *tinyClient2 = new TinyGsmClient(*tinyModem); -TinyGsmClient *tinyClient3 = new TinyGsmClient(*tinyModem); -#endif - - -// ========================================================================== -// Specific Modem On-Off Methods -// ========================================================================== - -// This should apply to all Digi brand XBee modules. -#if defined TINY_GSM_MODEM_XBEE || defined USE_XBEE_BYPASS -// Describe the physical pin connection of your modem to your board -const long modemBaud = 9600; // Communication speed of the modem, 9600 is default for XBee -const bool modemStatusLevel = LOW; // The level of the status pin when the module is active (HIGH or LOW) - -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -// After enabling pin sleep, the sleep request pin is held LOW to keep the XBee on -// Enable pin sleep in the setup function or using XCTU prior to connecting the XBee -bool modemSleepFxn(void) -{ - if (modemSleepRqPin >= 0) // Don't go to sleep if there's not a wake pin! - { - digitalWrite(modemSleepRqPin, HIGH); - digitalWrite(redLED, LOW); - return true; - } - else - { - return true; - } -} -bool modemWakeFxn(void) -{ - if (modemVccPin >= 0) // Turns on when power is applied - return true; - else if (modemSleepRqPin >= 0) - { - digitalWrite(modemSleepRqPin, LOW); - digitalWrite(redLED, HIGH); // Because the XBee doesn't have any lights - return true; - } - else - { - return true; - } -} -// An extra function to set up pin sleep and other preferences on the XBee -// NOTE: This will only succeed if the modem is turned on and awake! -#if defined TINY_GSM_MODEM_XBEE -void extraModemSetup(void) -{ - tinyModem->init(); // initialize - if (tinyModem->commandMode()) - { - tinyModem->sendAT(F("D8"),1); // Set DIO8 to be used for sleep requests - // NOTE: Only pin 9/DIO8/DTR can be used for this function - tinyModem->waitResponse(); - tinyModem->sendAT(F("D9"),1); // Turn on status indication pin - // NOTE: Only pin 13/DIO9 can be used for this function - tinyModem->waitResponse(); - tinyModem->sendAT(F("D7"),1); // Turn on CTS pin - as proxy for status indication - // NOTE: Only pin 12/DIO7/CTS can be used for this function - tinyModem->waitResponse(); - tinyModem->sendAT(F("SM"),1); // Pin sleep - tinyModem->waitResponse(); - tinyModem->sendAT(F("DO"),0); // Disable remote manager, USB Direct, and LTE PSM - // NOTE: LTE-M's PSM (Power Save Mode) sounds good, but there's no - // easy way on the LTE-M Bee to wake the cell chip itself from PSM, - // so we'll use the Digi pin sleep instead. - tinyModem->waitResponse(); - #if defined USE_XBEE_WIFI - tinyModem->sendAT(F("SO"),200); // For WiFi - Disassociate from AP for Deep Sleep - tinyModem->waitResponse(); - #else - tinyModem->sendAT(F("SO"),0); // For Cellular - disconnected sleep - tinyModem->waitResponse(); - tinyModem->sendAT(F("P0"),0); // Make sure USB direct won't be pin enabled - tinyModem->waitResponse(); - tinyModem->sendAT(F("P1"),0); // Make sure pins 7&8 are not set for USB direct - tinyModem->waitResponse(); - tinyModem->sendAT(F("CP"),2); // Cellular carrier profile - AT&T - // Hologram says they can use any network, but I've never succeeded with anything but AT&T - tinyModem->waitResponse(); - tinyModem->sendAT(F("N#"),2); // Cellular network technology - LTE-M Only - // LTE-M XBee connects much faster on AT&T/Hologram when set to LTE-M only (instead of LTE-M/NB IoT) - tinyModem->waitResponse(); - #endif - tinyModem->writeChanges(); - tinyModem->exitCommand(); - } -} -#elif defined USE_XBEE_BYPASS -void extraModemSetup(void) -{ - delay(1000); // Guard time for command mode - tinyModem->streamWrite(GF("+++")); // enter command mode - tinyModem->waitResponse(2000, F("OK\r")); - tinyModem->sendAT(F("D8"),1); // Set DIO8 to be used for sleep requests - // NOTE: Only pin 9/DIO8/DTR can be used for this function - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("D9"),1); // Turn on status indication pin - // NOTE: Only pin 13/DIO9 can be used for this function - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("D7"),1); // Turn on CTS pin - as proxy for status indication - // NOTE: Only pin 12/DIO7/CTS can be used for this function - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("SM"),1); // Pin sleep - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("SO"),0); // For Cellular - disconnected sleep - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("DO"),0); // Disable remote manager, USB Direct, and LTE PSM - // NOTE: LTE-M's PSM (Power Save Mode) sounds good, but there's no - // easy way on the LTE-M Bee to wake the cell chip itself from PSM, - // so we'll use the Digi pin sleep instead. - tinyModem->waitResponse(F("OK\r")); - #if defined USE_UBLOX_R410M - tinyModem->sendAT(F("P0"),0); // Make sure USB direct won't be pin enabled - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("P1"),0); // Make sure pins 7&8 are not set for USB direct - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("CP"),2); // Cellular carrier profile - AT&T - // Hologram says they can use any network, but I've never succeeded with anything but AT&T - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("N#"),2); // Cellular network technology - LTE-M Only - // LTE-M XBee connects much faster on AT&T/Hologram when set to LTE-M only (instead of LTE-M/NB IoT) - tinyModem->waitResponse(F("OK\r")); - #endif - tinyModem->sendAT(F("AP5")); // Turn on bypass mode - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("WR")); // Write changes to flash - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("AC")); // Apply changes - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("FR")); // Force reset to enter bypass mode - tinyModem->waitResponse(F("OK\r")); - tinyModem->init(); // initialize -} -#endif - - -// This should work with most ESP8266 breakouts -#elif defined TINY_GSM_MODEM_ESP8266 -// Describe the physical pin connection of your modem to your board -const long modemBaud = 115200; // Communication speed of the modem, 115200 is default for ESP8266 -const bool modemStatusLevel = HIGH; // The level of the status pin when the module is active (HIGH or LOW) -const int8_t espSleepRqPin = 13; // ESP8266 GPIO pin used for wake from light sleep (-1 if not applicable) -const int8_t espStatusPin = -1; // ESP8266 GPIO pin used to give modem status (-1 if not applicable) - -// A helper function to wait for the esp to boot and immediately change some settings -// We'll use this in the wake function -bool ESPwaitForBoot(void) -{ - // Wait for boot - finished when characters start coming - // NOTE: After every "hard" reset (either power off or via RST-B), the ESP - // sends out a boot log from the ROM on UART1 at 74880 baud. We're not - // going to worry about the odd baud rate since we're simply throwing the - // characters away. - delay(200); // It will take at least this long - uint32_t start = millis(); - bool success = false; - while (!modemSerial.available() && millis() - start < 1000) {} - if (modemSerial.available()) - { - success = true; - // Read the boot log to empty it from the serial buffer - while (modemSerial.available()) - { - modemSerial.read(); - delay(2); - } - // Have to make sure echo is off or all AT commands will be confused - tinyModem->sendAT(F("E0")); - success &= tinyModem->waitResponse() == 1; - // re-run init to set mux and station mode - success &= tinyModem->init(); - } - return success; -} - -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -bool modemSleepFxn(void) -{ - // Use this if you have GPIO16 connected to the reset pin to wake from deep sleep - // but no other MCU pin connected to the reset pin. - // NOTE: This will NOT work nicely with "testingMode" - /*if (loggingInterval > 1) - { - uint32_t sleepSeconds = (((uint32_t)loggingInterval) * 60 * 1000) - 75000L; - String sleepCommand = String(sleepSeconds); - tinyModem->sendAT(F("+GSLP="), sleepCommand); - // Power down for 1 minute less than logging interval - // Better: Calculate length of loop and power down for logging interval - loop time - return tinyModem->waitResponse() == 1; - }*/ - // Use this if you have an MCU pin connected to the ESP's reset pin to wake from deep sleep - if (modemResetPin >= 0) - { - digitalWrite(redLED, LOW); - return tinyModem->poweroff(); - } - // Use this if you don't have access to the ESP8266's reset pin for deep sleep but you - // do have access to another GPIO pin for light sleep. This also sets up another - // pin to view the sleep status. - else if (modemSleepRqPin >= 0 && modemStatusPin >= 0) - { - tinyModem->sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0,"), - String(espStatusPin), ',', modemStatusLevel); - bool success = tinyModem->waitResponse() == 1; - tinyModem->sendAT(F("+SLEEP=1")); - success &= tinyModem->waitResponse() == 1; - digitalWrite(redLED, LOW); - return success; - } - // Light sleep without the status pin - else if (modemSleepRqPin >= 0 && modemStatusPin < 0) - { - tinyModem->sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0")); - bool success = tinyModem->waitResponse() == 1; - tinyModem->sendAT(F("+SLEEP=1")); - success &= tinyModem->waitResponse() == 1; - digitalWrite(redLED, LOW); - return success; - } - else // DON'T go to sleep if we can't wake up! - { - return true; - } -} -bool modemWakeFxn(void) -{ - bool success = true; - if (modemVccPin >= 0) // Turns on when power is applied - { - digitalWrite(redLED, HIGH); // Because the ESP8266 doesn't have any lights - success &= ESPwaitForBoot(); - if (!success) - { - digitalWrite(redLED, LOW); // Turn off light if the boot failed - } - return success; - } - else if (modemResetPin >= 0) - { - digitalWrite(redLED, HIGH); - digitalWrite(modemResetPin, LOW); - delay(1); - digitalWrite(modemResetPin, HIGH); - success &= ESPwaitForBoot(); - if (!success) - { - digitalWrite(redLED, LOW); // Turn off light if the boot failed - } - return success; - } - else if (modemSleepRqPin >= 0) - { - digitalWrite(modemSleepRqPin, LOW); - delay(1); - digitalWrite(modemSleepRqPin, HIGH); - digitalWrite(redLED, HIGH); - // Don't have to wait for a boot if using light sleep - return true; - } - else - { - return true; - } -} -// Set up the light-sleep status pin, if applicable -void extraModemSetup(void) -{ - // Slow down the baud rate for slow processors - and save the change to - // the ESP's non-volatile memory so we don't have to do it every time - #if F_CPU == 8000000L - if (modemBaud > 57600) - { - modemSerial.begin(modemBaud); - tinyModem->sendAT(F("+UART_DEF=9600,8,1,0,0")); - tinyModem->waitResponse(); - modemSerial.end(); - modemSerial.begin(9600); - } - #endif - if (modemVccPin < 0 && modemResetPin < 0 && modemSleepRqPin >= 0 && modemStatusPin >= 0) - { - tinyModem->sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0,"), - String(espStatusPin), ',', modemStatusLevel); - tinyModem->waitResponse(); - } -} - - -// This should work for many u-blox breakouts, but check the timing in wake/sleep functions -#elif defined TINY_GSM_MODEM_UBLOX -// Describe the physical pin connection of your modem to your board -#if defined USE_UBLOX_R410M -const long modemBaud = 115200; // Communication speed of the modem, R4/N4 use 115200 -#else -const long modemBaud = 9600; // Communication speed of the modem, most u-blox use 9600 -#endif -const bool modemStatusLevel = HIGH; // The level of the status pin when the module is active (HIGH or LOW) - -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -bool modemSleepFxn(void) -{ - #if defined USE_UBLOX_R410M - if (modemSleepRqPin >= 0) // R410 must have access to PWR_ON pin to sleep - #else - if (modemVccPin >= 0 || modemSleepRqPin >= 0) // others will go on with power on - #endif - { - // Easiest to just go to sleep with the AT command rather than using pins - return tinyModem->poweroff(); - } - else // DON'T go to sleep if we can't wake up! - { - return true; - } -} -bool modemWakeFxn(void) -{ - // SARA/LISA U2/G2 and SARA G3 series turn on when power is applied - // SARA R4/N4 series must power on and then pulse on - #ifndef USE_UBLOX_R410M - if (modemVccPin >= 0) - return true; - #endif - if (modemSleepRqPin >= 0) - { - digitalWrite(modemSleepRqPin, LOW); - digitalWrite(redLED, HIGH); - #if defined USE_UBLOX_R410M - delay(200); // 0.15-3.2s pulse for wake on SARA R4/N4 - #else - // delay(6); // >5ms pulse for wake on SARA G3 - delayMicroseconds(65); // 50-80µs pulse for wake on SARA/LISA U2/G2 - #endif - digitalWrite(modemSleepRqPin, HIGH); - digitalWrite(redLED, LOW); - // Need to slow down R4/N4's default 115200 baud rate for slow processors - #if F_CPU == 8000000L && defined USE_UBLOX_R410M - delay(4600); // Must wait for UART port to become active - modemSerial.begin(115200); - tinyModem->setBaud(9600); - modemSerial.end(); - modemSerial.begin(9600); - #endif - return true; - } - else - { - return true; - } -} -#if defined USE_UBLOX_R410M -// Set band to only use LTE-M (not NB IoT) - this can speed up connection -void extraModemSetup(void) -{ - tinyModem->sendAT(F("+URAT=7")); - tinyModem->waitResponse(); -} -#else -void extraModemSetup(void){} -#endif - - -// THIS ONLY APPLIES TO A SODAQ GPRSBEE R6!!! -#elif defined TINY_GSM_MODEM_SIM800 && defined SIM800_GPRSBEE_R6 -// Describe the physical pin connection of your modem to your board -const long modemBaud = 9600; // Communication speed of the modem -const bool modemStatusLevel = HIGH; // The level of the status pin when the module is active (HIGH or LOW) - -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -bool modemWakeFxn(void) -{ - digitalWrite(modemSleepRqPin, HIGH); - digitalWrite(redLED, HIGH); // A light just for show - return true; -} -bool modemSleepFxn(void) -{ - digitalWrite(modemSleepRqPin, LOW); - digitalWrite(redLED, LOW); - return true; -} -void extraModemSetup(void){} - - -// Most cellular chips/breakouts respond to a low pulse of some length to power up and down -#else -// Describe the physical pin connection of your modem to your board -const long modemBaud = 9600; // Communication speed of the modem -const bool modemStatusLevel = HIGH; // The level of the status pin when the module is active (HIGH or LOW) - -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -bool modemWakeFxn(void) -{ - digitalWrite(modemSleepRqPin, LOW); - // delay(1100); // >1s for SIM800, SIM900, Quectel M95, Quectel MC60 - // delay(510); // >300ms (>500ms recommended) for Neoway M590 - delay(110); // >100ms for Quectel BG96 - digitalWrite(modemSleepRqPin, HIGH); - return true; -} -bool modemSleepFxn(void) -{ - digitalWrite(modemSleepRqPin, LOW); - // delay(1100); // 1sec > t > 33sec for SIM800 and clones - // delay(600); // 0.5sec > pull down > 1sec for SIM900 - // delay(510); // >300ms (>500ms recommended) for Neoway M590 - delay(700); // >650ms for Quectel BG96, 0.6sec > pull down > 1sec for Quectel M95, Quectel MC60 - digitalWrite(modemSleepRqPin, HIGH); - return true; -} -void extraModemSetup(void){} -#endif - - -// ========================================================================== -// Network Information and LoggerModem Object -// ========================================================================== -#include - -// Network connection information -const char *apn = "xxxxx"; // The APN for the gprs connection, unnecessary for WiFi -const char *wifiId = "xxxxx"; // The WiFi access point, unnecessary for gprs -const char *wifiPwd = "xxxxx"; // The password for connecting to WiFi, unnecessary for gprs - -// Create the loggerModem instance -// A "loggerModem" is a combination of a TinyGSM Modem, a Client, and functions for wake and sleep -#if defined TINY_GSM_MODEM_ESP8266 || defined USE_XBEE_WIFI -loggerModem modem(modemVccPin, modemStatusPin, modemStatusLevel, modemWakeFxn, modemSleepFxn, tinyModem, tinyClient, wifiId, wifiPwd); -// ^^ Use this for WiFi -#else -loggerModem modem(modemVccPin, modemStatusPin, modemStatusLevel, modemWakeFxn, modemSleepFxn, tinyModem, tinyClient, apn); -// ^^ Use this for cellular -#endif +// StreamDebugger modemSerial(Serial1, Serial); + +const long modemBaud = 9600; // Communication speed of the modem + + +// ========================================================================== +// The modem object +// Note: Don't use more than one! +// ========================================================================== + +// For the u-blox based Digi XBee's (3G global and LTE-M global) +// NOTE: According to the manual, this should be less stable than transparent +// mode, but my experience is the complete reverse. +#include +DigiXBeeCellularBypass modem(&modemSerial, + modemVccPin, modemStatusPin, useCTSforStatus, + modemResetPin, modemSleepRqPin, + apn); + +// For any Digi Cellular XBee's +// NOTE: The u-blox based Digi XBee's (3G global and LTE-M global) +// are more stable used in bypass mode (above) +// The Telit based Digi XBees (LTE Cat1) can only use this mode. +// #include +// DigiXBeeCellularTransparent modem(&modemSerial, +// modemVccPin, modemStatusPin, useCTSforStatus, +// modemResetPin, modemSleepRqPin, +// apn); + +// For the Digi Wifi XBee (S6B) +// #include +// DigiXBeeWifi modem(&modemSerial, +// modemVccPin, modemStatusPin, useCTSforStatus, +// modemResetPin, modemSleepRqPin, +// wifiId, wifiPwd); + +// For almost anything based on the Espressif ESP8266 using the AT command firmware +// #include +// // Pins for light sleep on the ESP8266. +// // For power savings, I recommend NOT using these if it's possible to use deep sleep. +// const int8_t espSleepRqPin = -1; // Pin ON THE ESP8266 to assign for light sleep request (-1 if not applicable) +// const int8_t espStatusPin = -1; // Pin ON THE ESP8266 to assign for light sleep status (-1 if not applicable) +// EspressifESP8266 modem(&modemSerial, +// modemVccPin, modemStatusPin, +// modemResetPin, modemSleepRqPin, +// wifiId, wifiPwd, +// 1, // measurements to average, optional +// espSleepRqPin, espStatusPin // Optional arguments +// ); + +// For the Dragino, Nimbelink or other boards based on the Quectel BG96 +// #include +// QuectelBG96 modem(&modemSerial, +// modemVccPin, modemStatusPin, +// modemResetPin, modemSleepRqPin, +// apn); + +// For the Nimbelink LTE-M Verizon/Sequans or other boards based on the Sequans Monarch series +// #include +// SequansMonarch modem(&modemSerial, +// modemVccPin, modemStatusPin, +// modemResetPin, modemSleepRqPin, +// apn); + +// For almost anything based on the SIMCom SIM800 EXCEPT the Sodaq 2GBee R6 and higher +// #include +// SIMComSIM800 modem(&modemSerial, +// modemVccPin, modemStatusPin, +// modemResetPin, modemSleepRqPin, +// apn); + +// For almost anything based on the SIMCom SIM7000 +// #include +// SIMComSIM7000 modem(&modemSerial, +// modemVccPin, modemStatusPin, +// modemResetPin, modemSleepRqPin, +// apn); + +// For the Sodaq 2GBee R6 and R7 based on the SIMCom SIM800 +// #include +// Sodaq2GBeeR6 modem(&modemSerial, +// modemVccPin, modemStatusPin, +// modemResetPin, modemSleepRqPin, +// apn); + +// For the Sodaq UBee based on the 4G LTE-M u-blox SARA R410M +// #include +// SodaqUBeeR410M modem(&modemSerial, +// modemVccPin, modemStatusPin, +// modemResetPin, modemSleepRqPin, +// apn); + +// For the Sodaq UBee based on the 3G u-blox SARA U201 +// #include +// SodaqUBeeU201 modem(&modemSerial, +// modemVccPin, modemStatusPin, +// modemResetPin, modemSleepRqPin, +// apn); // Create RSSI and signal strength variable pointers for the modem // Variable *modemRSSI = new Modem_RSSI(&modem, "12345678-abcd-1234-efgh-1234567890ab"); @@ -1753,26 +1376,6 @@ void setup() digitalWrite(sensorPowerPin, LOW); } - // Set up the sleep/wake pin for the modem and put its inital value as "off" - #if defined TINY_GSM_MODEM_SIM800 && defined SIM800_GPRSBEE_R6 // ONLY FOR GPRSBee R6!!!! - if (modemSleepRqPin >= 0) - { - pinMode(modemSleepRqPin, OUTPUT); - digitalWrite(modemSleepRqPin, LOW); - } - #else - if (modemSleepRqPin >= 0) - { - pinMode(modemSleepRqPin, OUTPUT); - digitalWrite(modemSleepRqPin, HIGH); - } - if (modemResetPin >= 0) - { - pinMode(modemResetPin, OUTPUT); - digitalWrite(modemResetPin, HIGH); - } - #endif - // Set the timezone and offsets // Logging in the given time zone Logger::setTimeZone(timeZone); @@ -1781,6 +1384,7 @@ void setup() // Attach the modem and information pins to the logger dataLogger.attachModem(modem); + modem.setModemLED(modemLEDPin); dataLogger.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); // Begin the logger @@ -1792,10 +1396,6 @@ void setup() { modem.modemPowerUp(); modem.wake(); - - // Run any extra pre-set-up for the modem - Serial.println(F("Running extra modem pre-setup")); - extraModemSetup(); modem.setup(); // At very good battery voltage, or with suspicious time stamp, sync the clock diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 500ab241e..fb03ee4ff 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -16,7 +16,7 @@ #if defined MS_DEBUGGING_STD #define MS_MODEM_START_TIMER uint32_t start = millis(); #else -#define MS_MODEM_START_TIMER(...) +#define MS_MODEM_START_TIMER #endif @@ -155,7 +155,7 @@ bool specificModem::addSingleMeasurementResult(void) \ /* The TinyGSM getSignalQuality function returns the same "no signal" */ \ /* value (99 CSQ or 0 RSSI) in all 3 cases. */ \ MS_DBG(F("Getting signal quality:")); \ - signalQual = _tinyModem->getSignalQuality(); \ + signalQual = _tinyModem.getSignalQuality(); \ MS_DBG(F("Raw signal quality:"), signalQual); \ \ /* Convert signal quality to RSSI, if necessary */ \ @@ -232,6 +232,11 @@ bool specificModem::connectInternet(uint32_t maxConnectionTime) \ F("milliseconds.")); \ return true; \ } \ + else \ + { \ + MS_DBG(F("... connection failed.")); \ + return false; \ + } \ } #elif defined TINY_GSM_MODEM_HAS_GPRS From da97c1895f4ce88880b0f37d5a02f4a6287b9db3 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 15 May 2019 13:36:15 -0400 Subject: [PATCH 18/88] Some cleaning and debug printing --- src/LoggerModem.cpp | 1 - src/LoggerModem.h | 2 +- src/ModSensorDebugger.h | 4 +++ src/modems/DigiXBee.h | 2 -- src/modems/DigiXBeeCellularBypass.cpp | 6 ++++ src/modems/DigiXBeeCellularBypass.h | 17 ++++++++---- src/modems/DigiXBeeCellularTransparent.cpp | 7 ++++- src/modems/DigiXBeeCellularTransparent.h | 15 ++++++---- src/modems/DigiXBeeWifi.cpp | 7 ++++- src/modems/DigiXBeeWifi.h | 15 ++++++---- src/modems/EspressifESP8266.cpp | 5 ++++ src/modems/EspressifESP8266.h | 23 ++++++++++------ src/modems/LoggerModemMacros.h | 30 ++++++++------------ src/modems/QuectelBG96.cpp | 6 ++++ src/modems/QuectelBG96.h | 26 +++++++++++------- src/modems/SIMComSIM7000.cpp | 5 ++++ src/modems/SIMComSIM7000.h | 24 ++++++++++------ src/modems/SIMComSIM800.cpp | 5 ++++ src/modems/SIMComSIM800.h | 26 +++++++++++------- src/modems/SequansMonarch.cpp | 5 ++++ src/modems/SequansMonarch.h | 24 ++++++++++------ src/modems/Sodaq2GBeeR6.cpp | 8 +++++- src/modems/Sodaq2GBeeR6.h | 27 +++++++++++------- src/modems/SodaqUBeeR410M.cpp | 20 +++++++++++--- src/modems/SodaqUBeeR410M.h | 32 ++++++++++++++-------- src/modems/SodaqUBeeU201.cpp | 10 +++++-- src/modems/SodaqUBeeU201.h | 30 ++++++++++++-------- src/publishers/DreamHostPublisher.cpp | 13 +++++---- src/publishers/EnviroDIYPublisher.cpp | 13 +++++---- src/publishers/ThingSpeakPublisher.cpp | 12 +++----- src/sensors/Decagon5TM.cpp | 4 +-- src/sensors/SDI12Sensors.cpp | 4 +-- 32 files changed, 277 insertions(+), 151 deletions(-) diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index 421f10607..c08152b97 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -75,7 +75,6 @@ bool loggerModem::setup(void) pinMode(_modemSleepRqPin, OUTPUT); // NOTE: Not setting level of sleep request pin } - int8_t _modemResetPin; if (_modemResetPin >= 0) { pinMode(_modemResetPin, OUTPUT); diff --git a/src/LoggerModem.h b/src/LoggerModem.h index a282616b3..5460d134e 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -93,7 +93,7 @@ class loggerModem : public Sensor // responses are good so we're getting an actual signal strength and it's as // close as possible to what the antenna is will see when the data publishers // push data. - virtual bool isMeasurementComplete(bool debug); + virtual bool isMeasurementComplete(bool debug) = 0; // ==========================================================================// diff --git a/src/ModSensorDebugger.h b/src/ModSensorDebugger.h index 962f99f6a..17a93ef69 100644 --- a/src/ModSensorDebugger.h +++ b/src/ModSensorDebugger.h @@ -68,8 +68,12 @@ MS_DBG(tail...); } } +#define MS_START_DEBUG_TIMER uint32_t start = millis(); +#define MS_PRINT_DEBUG_TIMER millis() - start #else #define MS_DBG(...) + #define MS_START_DEBUG_TIMER + #define MS_PRINT_DEBUG_TIMER #endif // DEBUGGING_SERIAL_OUTPUT diff --git a/src/modems/DigiXBee.h b/src/modems/DigiXBee.h index 22bb29f0a..bb207ddff 100644 --- a/src/modems/DigiXBee.h +++ b/src/modems/DigiXBee.h @@ -55,6 +55,4 @@ class DigiXBee : public loggerModem virtual bool modemWakeFxn(void) override; }; - - #endif diff --git a/src/modems/DigiXBeeCellularBypass.cpp b/src/modems/DigiXBeeCellularBypass.cpp index dfc1b5f75..462b15ab4 100644 --- a/src/modems/DigiXBeeCellularBypass.cpp +++ b/src/modems/DigiXBeeCellularBypass.cpp @@ -20,7 +20,12 @@ DigiXBeeCellularBypass::DigiXBeeCellularBypass(Stream* modemStream, : DigiXBee(powerPin, statusPin, useCTSStatus, modemResetPin, modemSleepRqPin, measurementsToAverage), + #ifdef MS_DIGIXBEECELLULARBYPASS_DEBUG_DEEP + _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _tinyModem(_modemATDebugger) + #else _tinyModem(*modemStream) + #endif { _apn = apn; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); @@ -34,6 +39,7 @@ MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeCellularBypass); MS_MODEM_IS_MEASUREMENT_COMPLETE(DigiXBeeCellularBypass); MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(DigiXBeeCellularBypass); MS_MODEM_CONNECT_INTERNET(DigiXBeeCellularBypass); +MS_MODEM_DISCONNECT_INTERNET(DigiXBeeCellularBypass); MS_MODEM_GET_NIST_TIME(DigiXBeeCellularBypass); diff --git a/src/modems/DigiXBeeCellularBypass.h b/src/modems/DigiXBeeCellularBypass.h index bfd50f94f..1c6565327 100644 --- a/src/modems/DigiXBeeCellularBypass.h +++ b/src/modems/DigiXBeeCellularBypass.h @@ -12,7 +12,8 @@ #define DigiXBeeCellularBypass_h // Debugging Statement -// #define MS_DIGIXBEECELLULARBYPASS_DEBUG +// #define MS_SODAQUBEEU201_DEBUG +// #define MS_SODAQUBEEU201_DEBUG_DEEP #ifdef MS_DIGIXBEECELLULARBYPASS_DEBUG #define MS_DEBUGGING_STD @@ -22,9 +23,13 @@ #define TINY_GSM_MODEM_UBLOX // Included Dependencies +#include "ModSensorDebugger.h" #include "DigiXBee.h" #include "TinyGsmClient.h" +#ifdef MS_DIGIXBEECELLULARBYPASS_DEBUG_DEEP +#include +#endif class DigiXBeeCellularBypass : public DigiXBee { @@ -37,9 +42,6 @@ class DigiXBeeCellularBypass : public DigiXBee const char *apn, uint8_t measurementsToAverage = 1); - - // The a measurement is "complete" when the modem is registered on the network. - // For a cellular modem, this actually sets the GPRS bearer/APN!! bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; @@ -48,6 +50,10 @@ class DigiXBeeCellularBypass : public DigiXBee uint32_t getNISTTime(void) override; + #ifdef MS_DIGIXBEECELLULARBYPASS_DEBUG_DEEP + StreamDebugger _modemATDebugger; + #endif + TinyGsm _tinyModem; Stream *_modemStream; @@ -56,10 +62,9 @@ class DigiXBeeCellularBypass : public DigiXBee bool isInternetAvailable(void) override; bool extraModemSetup(void) override; - private: +private: const char *_apn; }; - #endif diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index 57066a495..4186f8442 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -20,7 +20,12 @@ DigiXBeeCellularTransparent::DigiXBeeCellularTransparent(Stream* modemStream, : DigiXBee(powerPin, statusPin, useCTSStatus, modemResetPin, modemSleepRqPin, measurementsToAverage), - _tinyModem(*modemStream, modemResetPin) + #ifdef MS_DIGIXBEECELLULARTRANSPARENT_DEBUG_DEEP + _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _tinyModem(_modemATDebugger) + #else + _tinyModem(*modemStream) + #endif { _apn = apn; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index db2d71f69..ea3d5ae1b 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -13,19 +13,23 @@ // Debugging Statement // #define MS_DIGIXBEECELLULARTRANSPARENT_DEBUG +// #define MS_DIGIXBEECELLULARTRANSPARENT_DEBUG_DEEP #ifdef MS_DIGIXBEECELLULARTRANSPARENT_DEBUG #define MS_DEBUGGING_STD #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates #define TINY_GSM_MODEM_XBEE // Select for Digi brand WiFi or Cellular XBee's // Included Dependencies +#include "ModSensorDebugger.h" #include "DigiXBee.h" #include "TinyGsmClient.h" +#ifdef MS_DIGIXBEECELLULARTRANSPARENT_DEBUG_DEEP +#include +#endif class DigiXBeeCellularTransparent : public DigiXBee { @@ -38,9 +42,6 @@ class DigiXBeeCellularTransparent : public DigiXBee const char *apn, uint8_t measurementsToAverage = 1); - - // The a measurement is "complete" when the modem is registered on the network. - // For a cellular modem, this actually sets the GPRS bearer/APN!! bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; @@ -49,6 +50,10 @@ class DigiXBeeCellularTransparent : public DigiXBee uint32_t getNISTTime(void) override; + #ifdef MS_DIGIXBEECELLULARTRANSPARENT_DEBUG_DEEP + StreamDebugger _modemATDebugger; + #endif + TinyGsm _tinyModem; Stream *_modemStream; @@ -57,7 +62,7 @@ class DigiXBeeCellularTransparent : public DigiXBee bool isInternetAvailable(void) override; bool extraModemSetup(void) override; - private: +private: const char *_apn; }; diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index aef08d52b..f6a7c0831 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -21,7 +21,12 @@ DigiXBeeWifi::DigiXBeeWifi(Stream* modemStream, : DigiXBee(powerPin, statusPin, useCTSStatus, modemResetPin, modemSleepRqPin, measurementsToAverage), - _tinyModem(*modemStream, modemResetPin) + #ifdef MS_DIGIXBEEWIFI_DEBUG_DEEP + _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _tinyModem(_modemATDebugger) + #else + _tinyModem(*modemStream) + #endif { _ssid = ssid; _pwd = pwd; diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index e21019129..130844871 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -13,19 +13,23 @@ // Debugging Statement // #define MS_DIGIXBEEWIFI_DEBUG +// #define MS_DIGIXBEEWIFI_DEBUG_DEEP #ifdef MS_DIGIXBEEWIFI_DEBUG #define MS_DEBUGGING_STD #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates #define TINY_GSM_MODEM_XBEE // Select for Digi brand WiFi or Cellular XBee's // Included Dependencies +#include "ModSensorDebugger.h" #include "DigiXBee.h" #include "TinyGsmClient.h" +#ifdef defineMS_DIGIXBEEWIFI_DEBUG_DEEP +#include +#endif class DigiXBeeWifi : public DigiXBee { @@ -38,9 +42,6 @@ class DigiXBeeWifi : public DigiXBee const char *ssid, const char *pwd, uint8_t measurementsToAverage = 1); - - // The a measurement is "complete" when the modem is registered on the network. - // For a cellular modem, this actually sets the GPRS bearer/APN!! bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; @@ -49,6 +50,10 @@ class DigiXBeeWifi : public DigiXBee uint32_t getNISTTime(void) override; + #ifdef MS_DIGIXBEEWIFI_DEBUG_DEEP + StreamDebugger _modemATDebugger; + #endif + TinyGsm _tinyModem; Stream *_modemStream; @@ -57,7 +62,7 @@ class DigiXBeeWifi : public DigiXBee bool isInternetAvailable(void) override; bool extraModemSetup(void) override; - private: +private: const char *_ssid; const char *_pwd; diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index 5fbec975b..99f31f59f 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -27,7 +27,12 @@ EspressifESP8266::EspressifESP8266(Stream* modemStream, ESP8266_WARM_UP_TIME_MS, ESP8266_ATRESPONSE_TIME_MS, ESP8266_SIGNALQUALITY_TIME_MS, measurementsToAverage), + #ifdef MS_ESPRESSIFESP8266_DEBUG_DEEP + _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _tinyModem(_modemATDebugger) + #else _tinyModem(*modemStream) + #endif { _ssid = ssid; _pwd = pwd; diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h index f5c18f717..075d7be93 100644 --- a/src/modems/EspressifESP8266.h +++ b/src/modems/EspressifESP8266.h @@ -15,6 +15,7 @@ // Debugging Statement // #define MS_ESPRESSIFESP8266_DEBUG +// #define MS_ESPRESSIFESP8266_DEBUG_DEEP #ifdef MS_ESPRESSIFESP8266_DEBUG #define MS_DEBUGGING_STD @@ -43,6 +44,10 @@ #include "LoggerModem.h" #include "TinyGsmClient.h" +#ifdef MS_ESPRESSIFESP8266_DEBUG_DEEP +#include +#endif + class EspressifESP8266 : public loggerModem { @@ -56,9 +61,6 @@ class EspressifESP8266 : public loggerModem uint8_t measurementsToAverage = 1, int8_t espSleepRqPin = -1, int8_t espStatusPin = -1); - - // The a measurement is "complete" when the modem is registered on the network. - // For a cellular modem, this actually sets the GPRS bearer/APN!! bool startSingleMeasurement(void) override; bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; @@ -68,15 +70,19 @@ class EspressifESP8266 : public loggerModem uint32_t getNISTTime(void) override; + #ifdef MS_ESPRESSIFESP8266_DEBUG_DEEP + StreamDebugger _modemATDebugger; + #endif + TinyGsm _tinyModem; Stream *_modemStream; protected: - virtual bool didATRespond(void) override; - virtual bool isInternetAvailable(void) override; - virtual bool modemSleepFxn(void) override; - virtual bool modemWakeFxn(void) override; - virtual bool extraModemSetup(void)override; + bool didATRespond(void) override; + bool isInternetAvailable(void) override; + bool modemSleepFxn(void) override; + bool modemWakeFxn(void) override; + bool extraModemSetup(void)override; private: bool ESPwaitForBoot(void); @@ -85,6 +91,7 @@ class EspressifESP8266 : public loggerModem int8_t _espSleepRqPin; int8_t _espStatusPin; + }; #endif diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index fb03ee4ff..82992d9fd 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -13,14 +13,6 @@ #ifndef LoggerModemMacros_h #define LoggerModemMacros_h -#if defined MS_DEBUGGING_STD -#define MS_MODEM_START_TIMER uint32_t start = millis(); -#else -#define MS_MODEM_START_TIMER -#endif - - - #define MS_MODEM_DID_AT_RESPOND(specificModem) \ bool specificModem::didATRespond(void) \ { \ @@ -207,14 +199,14 @@ bool specificModem::addSingleMeasurementResult(void) \ } \ \ /* Check that the modem is responding to AT commands. If not, give up. */ \ - MS_MODEM_START_TIMER; \ + MS_START_DEBUG_TIMER; \ MS_DBG(F("\nWaiting for"), getSensorName(), F("to respond to AT commands...")); \ if (!_tinyModem.testAT(_stabilizationTime_ms + 500)) \ { \ MS_DBG(F("No response to AT commands! Cannot connect to the internet!")); \ return false; \ } \ - else MS_DBG(F("... AT OK after"), millis() - start, F("milliseconds!")); + else MS_DBG(F("... AT OK after"), MS_PRINT_DEBUG_TIMER, F("milliseconds!")); #if defined TINY_GSM_MODEM_XBEE @@ -228,7 +220,7 @@ bool specificModem::connectInternet(uint32_t maxConnectionTime) \ F("seconds for internet availability...")); \ if (_tinyModem.waitForNetwork(maxConnectionTime)) \ { \ - MS_DBG(F("... Connected after"), millis() - start, \ + MS_DBG(F("... Connected after"), MS_PRINT_DEBUG_TIMER, \ F("milliseconds.")); \ return true; \ } \ @@ -250,10 +242,10 @@ bool specificModem::connectInternet(uint32_t maxConnectionTime) \ F("seconds for cellular network registration...")); \ if (_tinyModem.waitForNetwork(maxConnectionTime)) \ { \ - MS_DBG(F("... Registered after"), millis() - start, \ + MS_DBG(F("... Registered after"), MS_PRINT_DEBUG_TIMER, \ F("milliseconds. Connecting to GPRS...")); \ _tinyModem.gprsConnect(_apn, "", ""); \ - MS_DBG(F("... Connected after"), millis() - start, \ + MS_DBG(F("... Connected after"), MS_PRINT_DEBUG_TIMER, \ F("milliseconds.")); \ return true; \ } \ @@ -285,7 +277,7 @@ bool specificModem::connectInternet(uint32_t maxConnectionTime) \ return false; \ } \ } \ - MS_DBG(F("... WiFi connected after"), millis() - start, \ + MS_DBG(F("... WiFi connected after"), MS_PRINT_DEBUG_TIMER, \ F("milliseconds!")); \ return true; \ } @@ -296,18 +288,18 @@ bool specificModem::connectInternet(uint32_t maxConnectionTime) \ #define MS_MODEM_DISCONNECT_INTERNET(specificModem) \ void specificModem::disconnectInternet(void) \ { \ - MS_MODEM_START_TIMER; \ + MS_START_DEBUG_TIMER; \ _tinyModem.gprsDisconnect(); \ - MS_DBG(F("Disconnected from cellular network after"), millis() - start, \ + MS_DBG(F("Disconnected from cellular network after"), MS_PRINT_DEBUG_TIMER, \ F("milliseconds.")); \ } #else #define MS_MODEM_DISCONNECT_INTERNET(specificModem) \ void specificModem::disconnectInternet(void) \ { \ - MS_MODEM_START_TIMER; \ + MS_START_DEBUG_TIMER; \ _tinyModem.networkDisconnect(); \ - MS_DBG(F("Disconnected from WiFi network after"), millis() - start, \ + MS_DBG(F("Disconnected from WiFi network after"), MS_PRINT_DEBUG_TIMER, \ F("milliseconds.")); \ } #endif @@ -350,7 +342,7 @@ uint32_t specificModem::getNISTTime(void) \ /* Wait up to 5 seconds for a response */ \ if (connectionMade) \ { \ - long start = millis(); \ + uint32_t start = millis(); \ while (_tinyClient && _tinyClient->available() < 4 && millis() - start < 5000L){} \ \ if (_tinyClient->available() >= 4) \ diff --git a/src/modems/QuectelBG96.cpp b/src/modems/QuectelBG96.cpp index 607517b39..0bffe6e71 100644 --- a/src/modems/QuectelBG96.cpp +++ b/src/modems/QuectelBG96.cpp @@ -24,7 +24,12 @@ QuectelBG96::QuectelBG96(Stream* modemStream, BG96_WARM_UP_TIME_MS, BG96_ATRESPONSE_TIME_MS, BG96_SIGNALQUALITY_TIME_MS, measurementsToAverage), + #ifdef MS_QUECTELBG96_DEBUG_DEEP + _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _tinyModem(_modemATDebugger) + #else _tinyModem(*modemStream) + #endif { _apn = apn; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); @@ -41,6 +46,7 @@ MS_MODEM_CONNECT_INTERNET(QuectelBG96); MS_MODEM_DISCONNECT_INTERNET(QuectelBG96); MS_MODEM_GET_NIST_TIME(QuectelBG96); + // Create the wake and sleep methods for the modem // These can be functions of any type and must return a boolean bool QuectelBG96::modemWakeFxn(void) diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index 00ee4b619..737dd4b2f 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -13,7 +13,8 @@ #define QuectelBG96_h // Debugging Statement -// #define MS_QUECTELBG96_DEBUG +// #define MS_SODAQUBEEU201_DEBUG +// #define MS_SODAQUBEEU201_DEBUG_DEEP #ifdef MS_QUECTELBG96_DEBUG #define MS_DEBUGGING_STD @@ -40,6 +41,10 @@ #include "LoggerModem.h" #include "TinyGsmClient.h" +#ifdef MS_QUECTELBG96_DEBUG_DEEP +#include +#endif + class QuectelBG96 : public loggerModem { @@ -52,10 +57,6 @@ class QuectelBG96 : public loggerModem const char *apn, uint8_t measurementsToAverage = 1); - - // The a measurement is "complete" when the modem is registered on the network. - // For a cellular modem, this actually sets the GPRS bearer/APN!! - bool startSingleMeasurement(void) override; bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; @@ -64,18 +65,23 @@ class QuectelBG96 : public loggerModem uint32_t getNISTTime(void) override; + #ifdef MS_QUECTELBG96_DEBUG_DEEP + StreamDebugger _modemATDebugger; + #endif + TinyGsm _tinyModem; Stream *_modemStream; protected: - virtual bool didATRespond(void) override; - virtual bool isInternetAvailable(void) override; - virtual bool modemSleepFxn(void) override; - virtual bool modemWakeFxn(void) override; - virtual bool extraModemSetup(void)override; + bool didATRespond(void) override; + bool isInternetAvailable(void) override; + bool modemSleepFxn(void) override; + bool modemWakeFxn(void) override; + bool extraModemSetup(void)override; private: const char *_apn; + }; #endif diff --git a/src/modems/SIMComSIM7000.cpp b/src/modems/SIMComSIM7000.cpp index 10e6d0932..8cc7e5879 100644 --- a/src/modems/SIMComSIM7000.cpp +++ b/src/modems/SIMComSIM7000.cpp @@ -24,7 +24,12 @@ SIMComSIM7000::SIMComSIM7000(Stream* modemStream, SIM7000_WARM_UP_TIME_MS, SIM7000_ATRESPONSE_TIME_MS, SIM7000_SIGNALQUALITY_TIME_MS, measurementsToAverage), + #ifdef MS_SIMCOMSIM7000_DEBUG_DEEP + _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _tinyModem(_modemATDebugger) + #else _tinyModem(*modemStream) + #endif { _apn = apn; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h index 85cefa8d8..63415c119 100644 --- a/src/modems/SIMComSIM7000.h +++ b/src/modems/SIMComSIM7000.h @@ -13,6 +13,7 @@ // Debugging Statement // #define MS_SIMCOMSIM7000_DEBUG +// #define MS_SIMCOMSIM7000_DEBUG_DEEP #ifdef MS_SIMCOMSIM7000_DEBUG #define MS_DEBUGGING_STD @@ -39,6 +40,10 @@ #include "LoggerModem.h" #include "TinyGsmClient.h" +#ifdef MS_SIMCOMSIM7000_DEBUG_DEEP +#include +#endif + class SIMComSIM7000 : public loggerModem { @@ -51,10 +56,6 @@ class SIMComSIM7000 : public loggerModem const char *apn, uint8_t measurementsToAverage = 1); - - // The a measurement is "complete" when the modem is registered on the network. - // For a cellular modem, this actually sets the GPRS bearer/APN!! - bool startSingleMeasurement(void) override; bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; @@ -63,18 +64,23 @@ class SIMComSIM7000 : public loggerModem uint32_t getNISTTime(void) override; + #ifdef MS_SIMCOMSIM7000_DEBUG_DEEP + StreamDebugger _modemATDebugger; + #endif + TinyGsm _tinyModem; Stream *_modemStream; protected: - virtual bool didATRespond(void) override; - virtual bool isInternetAvailable(void) override; - virtual bool modemSleepFxn(void) override; - virtual bool modemWakeFxn(void) override; - virtual bool extraModemSetup(void)override; + bool didATRespond(void) override; + bool isInternetAvailable(void) override; + bool modemSleepFxn(void) override; + bool modemWakeFxn(void) override; + bool extraModemSetup(void)override; private: const char *_apn; + }; #endif diff --git a/src/modems/SIMComSIM800.cpp b/src/modems/SIMComSIM800.cpp index 006af5cad..75858c9ba 100644 --- a/src/modems/SIMComSIM800.cpp +++ b/src/modems/SIMComSIM800.cpp @@ -26,7 +26,12 @@ SIMComSIM800::SIMComSIM800(Stream* modemStream, SIM800_WARM_UP_TIME_MS, SIM800_ATRESPONSE_TIME_MS, SIM800_SIGNALQUALITY_TIME_MS, measurementsToAverage), + #ifdef MS_SIMCOMSIM800_DEBUG_DEEP + _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _tinyModem(_modemATDebugger) + #else _tinyModem(*modemStream) + #endif { _apn = apn; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index 22e604992..8eff9b77b 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -15,6 +15,7 @@ // Debugging Statement // #define MS_SIMCOMSIM800_DEBUG +// #define MS_SIMCOMSIM800_DEBUG_DEEP #ifdef MS_SIMCOMSIM800_DEBUG #define MS_DEBUGGING_STD @@ -42,6 +43,10 @@ #include "LoggerModem.h" #include "TinyGsmClient.h" +#ifdef MS_SIMCOMSIM800_DEBUG_DEEP +#include +#endif + class SIMComSIM800 : public loggerModem { @@ -52,12 +57,8 @@ class SIMComSIM800 : public loggerModem int8_t powerPin, int8_t statusPin, int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, - uint8_t measurementsToAverage = 1); - + uint8_t measurementsToAverage = 1); - // The a measurement is "complete" when the modem is registered on the network. - // For a cellular modem, this actually sets the GPRS bearer/APN!! - bool startSingleMeasurement(void) override; bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; @@ -66,18 +67,23 @@ class SIMComSIM800 : public loggerModem uint32_t getNISTTime(void) override; + #ifdef MS_SIMCOMSIM800_DEBUG_DEEP + StreamDebugger _modemATDebugger; + #endif + TinyGsm _tinyModem; Stream *_modemStream; protected: - virtual bool didATRespond(void) override; - virtual bool isInternetAvailable(void) override; - virtual bool modemSleepFxn(void) override; - virtual bool modemWakeFxn(void) override; - virtual bool extraModemSetup(void)override; + bool didATRespond(void) override; + bool isInternetAvailable(void) override; + bool modemSleepFxn(void) override; + bool modemWakeFxn(void) override; + bool extraModemSetup(void)override; private: const char *_apn; + }; #endif diff --git a/src/modems/SequansMonarch.cpp b/src/modems/SequansMonarch.cpp index 9fc78a1be..9102d5529 100644 --- a/src/modems/SequansMonarch.cpp +++ b/src/modems/SequansMonarch.cpp @@ -24,7 +24,12 @@ SequansMonarch::SequansMonarch(Stream* modemStream, MONARCH_WARM_UP_TIME_MS, MONARCH_ATRESPONSE_TIME_MS, MONARCH_SIGNALQUALITY_TIME_MS, measurementsToAverage), + #ifdef MS_SEQUANSMONARCH_DEBUG_DEEP + _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _tinyModem(_modemATDebugger) + #else _tinyModem(*modemStream) + #endif { _apn = apn; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); diff --git a/src/modems/SequansMonarch.h b/src/modems/SequansMonarch.h index 9a7261e61..39e696c71 100644 --- a/src/modems/SequansMonarch.h +++ b/src/modems/SequansMonarch.h @@ -14,6 +14,7 @@ // Debugging Statement // #define MS_SEQUANSMONARCH_DEBUG +// #define MS_SEQUANSMONARCH_DEBUG_DEEP #ifdef MS_SEQUANSMONARCH_DEBUG #define MS_DEBUGGING_STD @@ -40,6 +41,10 @@ #include "LoggerModem.h" #include "TinyGsmClient.h" +#ifdef MS_SEQUANSMONARCH_DEBUG_DEEP +#include +#endif + class SequansMonarch : public loggerModem { @@ -52,10 +57,6 @@ class SequansMonarch : public loggerModem const char *apn, uint8_t measurementsToAverage = 1); - - // The a measurement is "complete" when the modem is registered on the network. - // For a cellular modem, this actually sets the GPRS bearer/APN!! - bool startSingleMeasurement(void) override; bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; @@ -64,18 +65,23 @@ class SequansMonarch : public loggerModem uint32_t getNISTTime(void) override; + #ifdef MS_SEQUANSMONARCH_DEBUG_DEEP + StreamDebugger _modemATDebugger; + #endif + TinyGsm _tinyModem; Stream *_modemStream; protected: - virtual bool didATRespond(void) override; - virtual bool isInternetAvailable(void) override; - virtual bool modemSleepFxn(void) override; - virtual bool modemWakeFxn(void) override; - virtual bool extraModemSetup(void)override; + bool didATRespond(void) override; + bool isInternetAvailable(void) override; + bool modemSleepFxn(void) override; + bool modemWakeFxn(void) override; + bool extraModemSetup(void)override; private: const char *_apn; + }; #endif diff --git a/src/modems/Sodaq2GBeeR6.cpp b/src/modems/Sodaq2GBeeR6.cpp index a3632e14b..9dcde814c 100644 --- a/src/modems/Sodaq2GBeeR6.cpp +++ b/src/modems/Sodaq2GBeeR6.cpp @@ -15,7 +15,8 @@ // Constructor Sodaq2GBeeR6::Sodaq2GBeeR6(Stream* modemStream, - int8_t powerPin, int8_t statusPin, int8_t modemSleepRqPin, + int8_t powerPin, int8_t statusPin, + int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage) : loggerModem(powerPin, statusPin, HIGH, @@ -24,7 +25,12 @@ Sodaq2GBeeR6::Sodaq2GBeeR6(Stream* modemStream, SIM800_WARM_UP_TIME_MS, SIM800_ATRESPONSE_TIME_MS, SIM800_SIGNALQUALITY_TIME_MS, measurementsToAverage), + #ifdef MS_SODAQ2GBEER6_DEBUG_DEEP + _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _tinyModem(_modemATDebugger) + #else _tinyModem(*modemStream) + #endif { _apn = apn; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h index 9dcc569a2..e5fc06b5d 100644 --- a/src/modems/Sodaq2GBeeR6.h +++ b/src/modems/Sodaq2GBeeR6.h @@ -14,6 +14,7 @@ // Debugging Statement // #define MS_SODAQ2GBEER6_DEBUG +// #define MS_SODAQ2GBEER6_DEBUG_DEEP #ifdef MS_SODAQ2GBEER6_DEBUG #define MS_DEBUGGING_STD @@ -41,21 +42,22 @@ #include "LoggerModem.h" #include "TinyGsmClient.h" +#ifdef MS_SODAQ2GBEER6_DEBUG_DEEP +#include +#endif class Sodaq2GBeeR6 : public loggerModem { public: // Constructors + // NOTE: The Sodaq GPRSBee doesn't expose the SIM800's reset pin Sodaq2GBeeR6(Stream* modemStream, - int8_t powerPin, int8_t statusPin, int8_t modemSleepRqPin, + int8_t powerPin, int8_t statusPin, + int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - - // The a measurement is "complete" when the modem is registered on the network. - // For a cellular modem, this actually sets the GPRS bearer/APN!! - bool startSingleMeasurement(void) override; bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; @@ -64,18 +66,23 @@ class Sodaq2GBeeR6 : public loggerModem uint32_t getNISTTime(void) override; + #ifdef MS_SODAQ2GBEER6_DEBUG_DEEP + StreamDebugger _modemATDebugger; + #endif + TinyGsm _tinyModem; Stream *_modemStream; protected: - virtual bool didATRespond(void) override; - virtual bool isInternetAvailable(void) override; - virtual bool modemSleepFxn(void) override; - virtual bool modemWakeFxn(void) override; - virtual bool extraModemSetup(void)override; + bool didATRespond(void) override; + bool isInternetAvailable(void) override; + bool modemSleepFxn(void) override; + bool modemWakeFxn(void) override; + bool extraModemSetup(void)override; private: const char *_apn; + }; #endif diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp index 4c748c0d6..8f247e542 100644 --- a/src/modems/SodaqUBeeR410M.cpp +++ b/src/modems/SodaqUBeeR410M.cpp @@ -15,16 +15,22 @@ // Constructor #if F_CPU == 8000000L SodaqUBeeR410M::SodaqUBeeR410M(HardwareSerial* modemStream, - int8_t powerPin, int8_t statusPin, int8_t modemSleepRqPin, + int8_t powerPin, int8_t statusPin, + int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage) : loggerModem(powerPin, statusPin, HIGH, - -1, modemSleepRqPin, + modemResetPin, modemSleepRqPin, R410M_STATUS_TIME_MS, R410M_DISCONNECT_TIME_MS, R410M_WARM_UP_TIME_MS, R410M_ATRESPONSE_TIME_MS, R410M_SIGNALQUALITY_TIME_MS, measurementsToAverage), + #ifdef MS_SODAQUBEER410M_DEBUG_DEEP + _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _tinyModem(_modemATDebugger) + #else _tinyModem(*modemStream) + #endif { _apn = apn; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); @@ -33,16 +39,22 @@ SodaqUBeeR410M::SodaqUBeeR410M(HardwareSerial* modemStream, } #else SodaqUBeeR410M::SodaqUBeeR410M(Stream* modemStream, - int8_t powerPin, int8_t statusPin, int8_t modemSleepRqPin, + int8_t powerPin, int8_t statusPin, + int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage) : loggerModem(powerPin, statusPin, HIGH, - -1, modemSleepRqPin, + modemResetPin, modemSleepRqPin, R410M_STATUS_TIME_MS, R410M_DISCONNECT_TIME_MS, R410M_WARM_UP_TIME_MS, R410M_ATRESPONSE_TIME_MS, R410M_SIGNALQUALITY_TIME_MS, measurementsToAverage), + #ifdef MS_SODAQUBEER410M_DEBUG_DEEP + _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _tinyModem(_modemATDebugger) + #else _tinyModem(*modemStream) + #endif { _apn = apn; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index b91e32e0e..c859dbfe5 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -12,7 +12,8 @@ #define SodaqUBeeR410M_h // Debugging Statement -// #define MS_SodaqUBeeR410M_DEBUG +// #define MS_SODAQUBEER410M_DEBUG +// #define MS_SODAQUBEER410M_DEBUG_DEEP #ifdef MS_SODAQUBEER410M_DEBUG #define MS_DEBUGGING_STD @@ -20,6 +21,7 @@ #endif #define TINY_GSM_MODEM_UBLOX + // V_INT becomes active mid-way through on-pulse #define R410M_STATUS_TIME_MS 0 // Power down time "can largely vary depending @@ -41,6 +43,9 @@ #include "LoggerModem.h" #include "TinyGsmClient.h" +#ifdef MS_SODAQUBEER410M_DEBUG_DEEP +#include +#endif class SodaqUBeeR410M : public loggerModem { @@ -51,20 +56,18 @@ class SodaqUBeeR410M : public loggerModem // At this slow baud rate, we need to begin and end serial communication, // so we need a Serial instance rather than a stream SodaqUBeeR410M(HardwareSerial* modemStream, - int8_t powerPin, int8_t statusPin, int8_t modemSleepRqPin, + int8_t powerPin, int8_t statusPin, + int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); #else SodaqUBeeR410M(Stream* modemStream, - int8_t powerPin, int8_t statusPin, int8_t modemSleepRqPin, + int8_t powerPin, int8_t statusPin, + int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); #endif - - // The a measurement is "complete" when the modem is registered on the network. - // For a cellular modem, this actually sets the GPRS bearer/APN!! - bool startSingleMeasurement(void) override; bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; @@ -73,6 +76,10 @@ class SodaqUBeeR410M : public loggerModem uint32_t getNISTTime(void) override; + #ifdef MS_SODAQUBEER410M_DEBUG_DEEP + StreamDebugger _modemATDebugger; + #endif + TinyGsm _tinyModem; #if F_CPU == 8000000L HardwareSerial *_modemStream; @@ -81,14 +88,15 @@ class SodaqUBeeR410M : public loggerModem #endif protected: - virtual bool didATRespond(void) override; - virtual bool isInternetAvailable(void) override; - virtual bool modemSleepFxn(void) override; - virtual bool modemWakeFxn(void) override; - virtual bool extraModemSetup(void)override; + bool didATRespond(void) override; + bool isInternetAvailable(void) override; + bool modemSleepFxn(void) override; + bool modemWakeFxn(void) override; + bool extraModemSetup(void)override; private: const char *_apn; + }; #endif diff --git a/src/modems/SodaqUBeeU201.cpp b/src/modems/SodaqUBeeU201.cpp index 284aa6d1f..4191c2289 100644 --- a/src/modems/SodaqUBeeU201.cpp +++ b/src/modems/SodaqUBeeU201.cpp @@ -14,16 +14,22 @@ // Constructor SodaqUBeeU201::SodaqUBeeU201(Stream* modemStream, - int8_t powerPin, int8_t statusPin, int8_t modemSleepRqPin, + int8_t powerPin, int8_t statusPin, + int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage) : loggerModem(powerPin, statusPin, HIGH, - -1, modemSleepRqPin, + modemResetPin, modemSleepRqPin, U201_STATUS_TIME_MS, U201_DISCONNECT_TIME_MS, U201_WARM_UP_TIME_MS, U201_ATRESPONSE_TIME_MS, U201_SIGNALQUALITY_TIME_MS, measurementsToAverage), + #ifdef MS_SODAQUBEEU201_DEBUG_DEEP + _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _tinyModem(_modemATDebugger) + #else _tinyModem(*modemStream) + #endif { _apn = apn; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index dc584cd00..4903be3ff 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -12,7 +12,8 @@ #define SodaqUBeeU201_h // Debugging Statement -// #define MS_SodaqUBeeU201_DEBUG +// #define MS_SODAQUBEEU201_DEBUG +// #define MS_SODAQUBEEU201_DEBUG_DEEP #ifdef MS_SODAQUBEEU201_DEBUG #define MS_DEBUGGING_STD @@ -20,6 +21,7 @@ #endif #define TINY_GSM_MODEM_UBLOX + // Time after end pulse until V_INT becomes active // Unspecified in documentation! Taking value from Lisa U2 #define U201_STATUS_TIME_MS 35 @@ -44,6 +46,10 @@ #include "LoggerModem.h" #include "TinyGsmClient.h" +#ifdef MS_SODAQUBEEU201_DEBUG_DEEP +#include +#endif + class SodaqUBeeU201 : public loggerModem { @@ -51,14 +57,11 @@ class SodaqUBeeU201 : public loggerModem public: // Constructors SodaqUBeeU201(Stream* modemStream, - int8_t powerPin, int8_t statusPin, int8_t modemSleepRqPin, + int8_t powerPin, int8_t statusPin, + int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - - // The a measurement is "complete" when the modem is registered on the network. - // For a cellular modem, this actually sets the GPRS bearer/APN!! - bool startSingleMeasurement(void) override; bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; @@ -67,18 +70,23 @@ class SodaqUBeeU201 : public loggerModem uint32_t getNISTTime(void) override; + #ifdef MS_SODAQUBEEU201_DEBUG_DEEP + StreamDebugger _modemATDebugger; + #endif + TinyGsm _tinyModem; Stream *_modemStream; protected: - virtual bool didATRespond(void) override; - virtual bool isInternetAvailable(void) override; - virtual bool modemSleepFxn(void) override; - virtual bool modemWakeFxn(void) override; - virtual bool extraModemSetup(void)override; + bool didATRespond(void) override; + bool isInternetAvailable(void) override; + bool modemSleepFxn(void) override; + bool modemWakeFxn(void) override; + bool extraModemSetup(void)override; private: const char *_apn; + }; #endif diff --git a/src/publishers/DreamHostPublisher.cpp b/src/publishers/DreamHostPublisher.cpp index cce8f9d84..a03dd9e49 100644 --- a/src/publishers/DreamHostPublisher.cpp +++ b/src/publishers/DreamHostPublisher.cpp @@ -128,10 +128,10 @@ int16_t DreamHostPublisher::sendData(Client *_outClient) // Open a TCP/IP connection to DreamHost MS_DBG(F("Connecting client")); - uint32_t start_timer = millis(); + MS_START_DEBUG_TIMER ; if (_outClient->connect(dreamhostHost, dreamhostPort)) { - MS_DBG(F("Client connected after"), millis() - start_timer, F("ms\n")); + MS_DBG(F("Client connected after"), MS_PRINT_DEBUG_TIMER, F("ms\n")); // copy the initial post header into the tx buffer strcpy(txBuffer, getHeader); @@ -175,8 +175,9 @@ int16_t DreamHostPublisher::sendData(Client *_outClient) // Send out the finished request (or the last unsent section of it) printTxBuffer(_outClient); - start_timer = millis(); - while ((millis() - start_timer) < 10000L && _outClient->available() < 12) + // Wait 10 seconds for a response from the server + uint32_t start = millis(); + while ((millis() - start) < 10000L && _outClient->available() < 12) {delay(10);} // Read only the first 12 characters of the response @@ -186,9 +187,9 @@ int16_t DreamHostPublisher::sendData(Client *_outClient) // Close the TCP/IP connection MS_DBG(F("Stopping client")); - start_timer = millis(); + MS_START_DEBUG_TIMER; _outClient->stop(); - MS_DBG(F("Client stopped after"), millis() - start_timer, F("ms")); + MS_DBG(F("Client stopped after"), MS_PRINT_DEBUG_TIMER, F("ms")); } else PRINTOUT(F("\n -- Unable to Establish Connection to DreamHost --")); diff --git a/src/publishers/EnviroDIYPublisher.cpp b/src/publishers/EnviroDIYPublisher.cpp index cb8f042ea..4375c6042 100644 --- a/src/publishers/EnviroDIYPublisher.cpp +++ b/src/publishers/EnviroDIYPublisher.cpp @@ -205,10 +205,10 @@ int16_t EnviroDIYPublisher::sendData(Client *_outClient) // Open a TCP/IP connection to the Enviro DIY Data Portal (WebSDL) MS_DBG(F("Connecting client")); - uint32_t start_timer = millis(); + MS_START_DEBUG_TIMER; if (_outClient->connect(enviroDIYHost, enviroDIYPort)) { - MS_DBG(F("Client connected after"), millis() - start_timer, F("ms\n")); + MS_DBG(F("Client connected after"), MS_PRINT_DEBUG_TIMER, F("ms\n")); // copy the initial post header into the tx buffer strcpy(txBuffer, postHeader); @@ -279,8 +279,9 @@ int16_t EnviroDIYPublisher::sendData(Client *_outClient) // Send out the finished request (or the last unsent section of it) printTxBuffer(_outClient); - start_timer = millis(); - while ((millis() - start_timer) < 10000L && _outClient->available() < 12) + // Wait 10 seconds for a response from the server + uint32_t start = millis(); + while ((millis() - start) < 10000L && _outClient->available() < 12) {delay(10);} // Read only the first 12 characters of the response @@ -290,9 +291,9 @@ int16_t EnviroDIYPublisher::sendData(Client *_outClient) // Close the TCP/IP connection MS_DBG(F("Stopping client")); - start_timer = millis(); + MS_START_DEBUG_TIMER; _outClient->stop(); - MS_DBG(F("Client stopped after"), millis() - start_timer, F("ms")); + MS_DBG(F("Client stopped after"), MS_PRINT_DEBUG_TIMER, F("ms")); } else PRINTOUT(F("\n -- Unable to Establish Connection to EnviroDIY Data Portal --")); diff --git a/src/publishers/ThingSpeakPublisher.cpp b/src/publishers/ThingSpeakPublisher.cpp index 81c8a5f1b..bcba2ca7c 100644 --- a/src/publishers/ThingSpeakPublisher.cpp +++ b/src/publishers/ThingSpeakPublisher.cpp @@ -187,12 +187,10 @@ int16_t ThingSpeakPublisher::sendData(Client *_outClient) // Make the MQTT connection // Note: the client id and the user name do not mean anything for ThingSpeak MS_DBG(F("Opening MQTT Connection")); - #if defined(MS_THINGSPEAKPUBLISHER_DEBUG) - uint32_t start_timer = millis(); - #endif + MS_START_DEBUG_TIMER; if (_mqttClient.connect(mqttClient, mqttUser, _thingSpeakMQTTKey)) { - MS_DBG(F("MQTT connected after"), millis() - start_timer, F("ms")); + MS_DBG(F("MQTT connected after"), MS_PRINT_DEBUG_TIMER, F("ms")); if (_mqttClient.publish(topicBuffer, txBuffer)) { @@ -213,10 +211,8 @@ int16_t ThingSpeakPublisher::sendData(Client *_outClient) // Disconnect from MQTT MS_DBG(F("Disconnecting from MQTT")); - #if defined(MS_THINGSPEAKPUBLISHER_DEBUG) - start_timer = millis(); - #endif + MS_START_DEBUG_TIMER _mqttClient.disconnect(); - MS_DBG(F("Disconnected after"), millis() - start_timer, F("ms")); + MS_DBG(F("Disconnected after"), MS_PRINT_DEBUG_TIMER, F("ms")); return retVal; } diff --git a/src/sensors/Decagon5TM.cpp b/src/sensors/Decagon5TM.cpp index 40f9fe8be..fccb42adf 100644 --- a/src/sensors/Decagon5TM.cpp +++ b/src/sensors/Decagon5TM.cpp @@ -60,8 +60,8 @@ bool Decagon5TM::addSingleMeasurementResult(void) delay(30); // It just needs this little delay MS_DBG(F(" >>>"), getDataCommand); - uint32_t startTime = millis(); - while (_SDI12Internal.available() < 3 && (millis() - startTime) < 1500) {} + uint32_t start = millis(); + while (_SDI12Internal.available() < 3 && (millis() - start) < 1500) {} MS_DBG(F(" Receiving results from"), getSensorNameAndLocation()); _SDI12Internal.read(); // ignore the repeated SDI12 address // First variable returned is the Dialectric E diff --git a/src/sensors/SDI12Sensors.cpp b/src/sensors/SDI12Sensors.cpp index ed2f89901..a811ede16 100644 --- a/src/sensors/SDI12Sensors.cpp +++ b/src/sensors/SDI12Sensors.cpp @@ -346,8 +346,8 @@ bool SDI12Sensors::addSingleMeasurementResult(void) delay(30); // It just needs this little delay MS_DBG(F(" >>>"), getDataCommand); - uint32_t startTime = millis(); - while (_SDI12Internal.available() < 3 && (millis() - startTime) < 1500) {} + uint32_t start = millis(); + while (_SDI12Internal.available() < 3 && (millis() - start) < 1500) {} MS_DBG(F(" Receiving results from"), getSensorNameAndLocation()); _SDI12Internal.read(); // ignore the repeated SDI12 address for (uint8_t i = 0; i < _numReturnedVars; i++) From 59c05af95842852728519fe54aed89f451e5bdff Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 15 May 2019 15:27:34 -0400 Subject: [PATCH 19/88] Whew.. updated examples --- examples/DRWI_CitSci/DRWI_CitSci.ino | 97 +--- examples/DRWI_LTE/DRWI_LTE.ino | 169 +----- examples/DRWI_NoCellular/DRWI_NoCellular.ino | 12 +- .../baro_rho_correction.ino | 114 +--- examples/data_saving/data_saving.ino | 105 +--- examples/double_logger/double_logger.ino | 106 +--- examples/logging_to_MMW/logging_to_MMW.ino | 538 +----------------- .../logging_to_ThingSpeak.ino | 251 ++------ examples/menu_a_la_carte/menu_a_la_carte.ino | 260 +++++---- 9 files changed, 336 insertions(+), 1316 deletions(-) diff --git a/examples/DRWI_CitSci/DRWI_CitSci.ino b/examples/DRWI_CitSci/DRWI_CitSci.ino index d988d0105..fe9c7eeac 100644 --- a/examples/DRWI_CitSci/DRWI_CitSci.ino +++ b/examples/DRWI_CitSci/DRWI_CitSci.ino @@ -62,77 +62,31 @@ ProcessorStats mcuBoard(mcuBoardVersion); // ========================================================================== -// Wifi/Cellular Modem Main Chip Selection +// Wifi/Cellular Modem Settings // ========================================================================== -#define TINY_GSM_MODEM_SIM800 // Select for a SIM800, SIM900, or variant thereof - - -// ========================================================================== -// Modem Pins -// ========================================================================== - -const int8_t modemVccPin = -2; // MCU pin controlling modem power (-1 if not applicable) -const int8_t modemSleepRqPin = 23; // MCU pin used for modem sleep/wake request (-1 if not applicable) -const int8_t modemStatusPin = 19; // MCU pin used to read modem status (-1 if not applicable) - - -// ========================================================================== -// TinyGSM Client -// ========================================================================== - -#define TINY_GSM_YIELD() { delay(2); } // Use to counter slow (9600) baud rate - -// Include TinyGSM for the modem -// This include must be included below the define of the modem name! -#include - // Create a reference to the serial port for the modem HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible -// Create a new TinyGSM modem to run on that serial port and return a pointer to it -TinyGsm *tinyModem = new TinyGsm(modemSerial); - -// Create a TCP client on that modem -TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); - - -// ========================================================================== -// Specific Modem On-Off Methods -// ========================================================================== - -// THIS ONLY APPLIES TO A SODAQ GPRSBEE R6!!! -// Describe the physical pin connection of your modem to your board -const long modemBaud = 9600; // Communication speed of the modem -const bool modemStatusLevel = HIGH; // The level of the status pin when the module is active (HIGH or LOW) - -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -bool modemWakeFxn(void) -{ - digitalWrite(modemSleepRqPin, HIGH); - digitalWrite(redLED, HIGH); // A light just for show - return true; -} -bool modemSleepFxn(void) -{ - digitalWrite(modemSleepRqPin, LOW); - digitalWrite(redLED, LOW); - return true; -} -void extraModemSetup(void){} -// ========================================================================== -// Network Information and LoggerModem Object -// ========================================================================== -#include +// Modem Pins - Describe the physical pin connection of your modem to your board +const int8_t modemVccPin = -2; // MCU pin controlling modem power (-1 if not applicable) +const int8_t modemStatusPin = 19; // MCU pin used to read modem status (-1 if not applicable) +const int8_t modemSleepRqPin = 23; // MCU pin used for modem sleep/wake request (-1 if not applicable) +const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem status (-1 if unconnected) // Network connection information -const char *apn = "hologram"; // The APN for the gprs connection, unnecessary for WiFi +const char *apn = "hologram"; // The APN for the gprs connection -// Create the loggerModem instance -// A "loggerModem" is a combination of a TinyGSM Modem, a Client, and functions for wake and sleep -loggerModem modem(modemVccPin, modemStatusPin, modemStatusLevel, modemWakeFxn, modemSleepFxn, tinyModem, tinyClient, apn); -// ^^ Use this for cellular +// For the Sodaq 2GBee R6 and R7 based on the SIMCom SIM800 +// NOTE: The Sodaq GPRSBee doesn't expose the SIM800's reset pin +#include +const long modemBaud = 9600; // SIM800 does auto-bauding by default +Sodaq2GBeeR6 modem2GB(&modemSerial, + modemVccPin, modemStatusPin, + modemSleepRqPin, + apn); +// Create an extra reference to the modem by a generic name (not necessary) +Sodaq2GBeeR6 modem = modem2GB; // ========================================================================== @@ -145,12 +99,12 @@ MaximDS3231 ds3231(1); // ========================================================================== -// CAMPBELL OBS 3 / OBS 3+ Analog Turbidity Sensor +// Campbell OBS 3 / OBS 3+ Analog Turbidity Sensor // ========================================================================== #include const int8_t OBS3Power = sensorPowerPin; // Pin to switch power on and off (-1 if unconnected) -const uint8_t OBS3numberReadings = 10; +const uint8_t OBS3NumberReadings = 10; const uint8_t ADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC // Campbell OBS 3+ Low Range calibration in Volts const int8_t OBSLowADSChannel = 0; // The ADS channel for the low range output @@ -159,7 +113,7 @@ const float OBSLow_B = 1.000E+00; // The "B" value (X) from the low range calib const float OBSLow_C = 0.000E+00; // The "C" value from the low range calibration // Create a Campbell OBS3+ LOW RANGE sensor object -CampbellOBS3 osb3low(OBS3Power, OBSLowADSChannel, OBSLow_A, OBSLow_B, OBSLow_C, ADSi2c_addr, OBS3numberReadings); +CampbellOBS3 osb3low(OBS3Power, OBSLowADSChannel, OBSLow_A, OBSLow_B, OBSLow_C, ADSi2c_addr, OBS3NumberReadings); // Campbell OBS 3+ High Range calibration in Volts @@ -169,7 +123,7 @@ const float OBSHigh_B = 1.000E+00; // The "B" value (X) from the high range cal const float OBSHigh_C = 0.000E+00; // The "C" value from the high range calibration // Create a Campbell OBS3+ HIGH RANGE sensor object -CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHigh_C, ADSi2c_addr, OBS3numberReadings); +CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHigh_C, ADSi2c_addr, OBS3NumberReadings); // ========================================================================== @@ -178,12 +132,12 @@ CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHig #include const char *CTDSDI12address = "1"; // The SDI-12 Address of the CTD -const uint8_t CTDnumberReadings = 6; // The number of readings to average +const uint8_t CTDNumberReadings = 6; // The number of readings to average const int8_t SDI12Power = sensorPowerPin; // Pin to switch power on and off (-1 if unconnected) const int8_t SDI12Data = 7; // The SDI12 data pin // Create a Decagon CTD sensor object -DecagonCTD ctd(*CTDSDI12address, SDI12Power, SDI12Data, CTDnumberReadings); +DecagonCTD ctd(*CTDSDI12address, SDI12Power, SDI12Data, CTDNumberReadings); // ========================================================================== @@ -319,6 +273,7 @@ void setup() // Attach the modem and information pins to the logger dataLogger.attachModem(modem); + modem.setModemLED(modemLEDPin); dataLogger.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); // Begin the logger @@ -330,12 +285,13 @@ void setup() { modem.modemPowerUp(); modem.wake(); + modem.setup(); // At very good battery voltage, or with suspicious time stamp, sync the clock // Note: Please change these battery voltages to match your battery if (getBatteryVoltage() > 3.8 || dataLogger.getNowEpoch() < 1546300800 || /*Before 01/01/2019*/ - dataLogger.getNowEpoch() > 1735689600) /*Before 1/1/2025*/ + dataLogger.getNowEpoch() > 1735689600) /*After 1/1/2025*/ { // Synchronize the RTC with NIST Serial.println(F("Attempting to synchronize RTC with NIST")); @@ -369,6 +325,7 @@ void setup() } // Call the processor sleep + Serial.println(F("Putting processor to sleep")); dataLogger.systemSleep(); } diff --git a/examples/DRWI_LTE/DRWI_LTE.ino b/examples/DRWI_LTE/DRWI_LTE.ino index 0dab4a784..8dcc7206e 100644 --- a/examples/DRWI_LTE/DRWI_LTE.ino +++ b/examples/DRWI_LTE/DRWI_LTE.ino @@ -62,144 +62,34 @@ ProcessorStats mcuBoard(mcuBoardVersion); // ========================================================================== -// Wifi/Cellular Modem Main Chip Selection +// Wifi/Cellular Modem Settings // ========================================================================== -// Select your modem chip - this determines the exact commands sent to it -#define TINY_GSM_MODEM_UBLOX // Select for most u-blox cellular modems -#define USE_UBLOX_R410M // Select with UBLOX for a non-XBee SARA R4 or N4 model -#define USE_XBEE_BYPASS // Select with UBLOX for a Digi 3G or LTE-M XBee in bypass mode - - -// ========================================================================== -// Modem Pins -// ========================================================================== - -const int8_t modemVccPin = -2; // MCU pin controlling modem power (-1 if not applicable) -const int8_t modemSleepRqPin = 23; // MCU pin used for modem sleep/wake request (-1 if not applicable) -const int8_t modemStatusPin = 19; // MCU pin used to read modem status (-1 if not applicable) - - -// ========================================================================== -// TinyGSM Client -// ========================================================================== - -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates - -// Include TinyGSM for the modem -// This include must be included below the define of the modem name! -#include - // Create a reference to the serial port for the modem HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible -// Create a new TinyGSM modem to run on that serial port and return a pointer to it -TinyGsm *tinyModem = new TinyGsm(modemSerial); - -// Create a new TCP client on that modem and return a pointer to it -TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); - - -// ========================================================================== -// Specific Modem On-Off Methods -// ========================================================================== - -// This should apply to all Digi brand XBee modules. -// Describe the physical pin connection of your modem to your board -const long modemBaud = 9600; // Communication speed of the modem, 9600 is default for XBee -const bool modemStatusLevel = LOW; // The level of the status pin when the module is active (HIGH or LOW) - -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -// After enabling pin sleep, the sleep request pin is held LOW to keep the XBee on -// Enable pin sleep in the setup function or using XCTU prior to connecting the XBee -bool modemSleepFxn(void) -{ - if (modemSleepRqPin >= 0) // Don't go to sleep if there's not a wake pin! - { - digitalWrite(modemSleepRqPin, HIGH); - digitalWrite(redLED, LOW); - return true; - } - else - { - return true; - } -} -bool modemWakeFxn(void) -{ - if (modemVccPin >= 0) // Turns on when power is applied - return true; - else if (modemSleepRqPin >= 0) - { - digitalWrite(modemSleepRqPin, LOW); - digitalWrite(redLED, HIGH); // Because the XBee doesn't have any lights - return true; - } - else - { - return true; - } -} -// An extra function to set up pin sleep and other preferences on the XBee -// NOTE: This will only succeed if the modem is turned on and awake! -void extraModemSetup(void) -{ - delay(1000); // Guard time for command mode - tinyModem->streamWrite(GF("+++")); // enter command mode - tinyModem->waitResponse(2000, F("OK\r")); - tinyModem->sendAT(F("D8"),1); // Set DIO8 to be used for sleep requests - // NOTE: Only pin 9/DIO8/DTR can be used for this function - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("D9"),1); // Turn on status indication pin - // NOTE: Only pin 13/DIO9 can be used for this function - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("D7"),1); // Turn on CTS pin - as proxy for status indication - // NOTE: Only pin 12/DIO7/CTS can be used for this function - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("SM"),1); // Pin sleep - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("SO"),0); // For Cellular - disconnected sleep - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("DO"),0); // Disable remote manager, USB Direct, and LTE PSM - // NOTE: LTE-M's PSM (Power Save Mode) sounds good, but there's no - // easy way on the LTE-M Bee to wake the cell chip itself from PSM, - // so we'll use the Digi pin sleep instead. - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("P0"),0); // Make sure USB direct won't be pin enabled - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("P1"),0); // Make sure pins 7&8 are not set for USB direct - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("CP"),2); // Cellular carrier profile - AT&T - // Hologram says they can use any network, but I've never succeeded with anything but AT&T - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("N#"),2); // Cellular network technology - LTE-M Only - // LTE-M XBee connects much faster on AT&T/Hologram when set to LTE-M only (instead of LTE-M/NB IoT) - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("AP5")); // Turn on bypass mode - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("WR")); // Write changes to flash - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("AC")); // Apply changes - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("FR")); // Force reset to enter bypass mode - tinyModem->waitResponse(F("OK\r")); - tinyModem->init(); // initialize -} - - -// ========================================================================== -// Network Information and LoggerModem Object -// ========================================================================== -#include +// Modem Pins - Describe the physical pin connection of your modem to your board +const int8_t modemVccPin = -2; // MCU pin controlling modem power (-1 if not applicable) +const int8_t modemStatusPin = 19; // MCU pin used to read modem status (-1 if not applicable) +const int8_t modemResetPin = 20; // MCU pin connected to modem reset pin (-1 if unconnected) +const int8_t modemSleepRqPin = 23; // MCU pin used for modem sleep/wake request (-1 if not applicable) +const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem status (-1 if unconnected) // Network connection information -const char *apn = "hologram"; // The APN for the gprs connection, unnecessary for WiFi +const char *apn = "hologram"; // The APN for the gprs connection -// Create the loggerModem instance -// A "loggerModem" is a combination of a TinyGSM Modem, a Client, and functions for wake and sleep -loggerModem modem(modemVccPin, modemStatusPin, modemStatusLevel, modemWakeFxn, modemSleepFxn, tinyModem, tinyClient, apn); -// ^^ Use this for cellular +// For the u-blox based Digi XBee's (3G global and LTE-M global) +// NOTE: According to the manual, this should be less stable than transparent +// mode, but my experience is the complete reverse. +#include +const long modemBaud = 9600; // All XBee's use 9600 by default +const bool useCTSforStatus = true; // Flag to use the modem CTS pin for status +DigiXBeeCellularBypass modemXBCB(&modemSerial, + modemVccPin, modemStatusPin, useCTSforStatus, + modemResetPin, modemSleepRqPin, + apn); +// Create an extra reference to the modem by a generic name (not necessary) +DigiXBeeCellularBypass modem = modemXBCB; // ========================================================================== @@ -212,12 +102,12 @@ MaximDS3231 ds3231(1); // ========================================================================== -// CAMPBELL OBS 3 / OBS 3+ Analog Turbidity Sensor +// Campbell OBS 3 / OBS 3+ Analog Turbidity Sensor // ========================================================================== #include const int8_t OBS3Power = sensorPowerPin; // Pin to switch power on and off (-1 if unconnected) -const uint8_t OBS3numberReadings = 10; +const uint8_t OBS3NumberReadings = 10; const uint8_t ADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC // Campbell OBS 3+ Low Range calibration in Volts const int8_t OBSLowADSChannel = 0; // The ADS channel for the low range output @@ -226,7 +116,7 @@ const float OBSLow_B = 1.000E+00; // The "B" value (X) from the low range calib const float OBSLow_C = 0.000E+00; // The "C" value from the low range calibration // Create a Campbell OBS3+ LOW RANGE sensor object -CampbellOBS3 osb3low(OBS3Power, OBSLowADSChannel, OBSLow_A, OBSLow_B, OBSLow_C, ADSi2c_addr, OBS3numberReadings); +CampbellOBS3 osb3low(OBS3Power, OBSLowADSChannel, OBSLow_A, OBSLow_B, OBSLow_C, ADSi2c_addr, OBS3NumberReadings); // Campbell OBS 3+ High Range calibration in Volts @@ -236,7 +126,7 @@ const float OBSHigh_B = 1.000E+00; // The "B" value (X) from the high range cal const float OBSHigh_C = 0.000E+00; // The "C" value from the high range calibration // Create a Campbell OBS3+ HIGH RANGE sensor object -CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHigh_C, ADSi2c_addr, OBS3numberReadings); +CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHigh_C, ADSi2c_addr, OBS3NumberReadings); // ========================================================================== @@ -245,12 +135,12 @@ CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHig #include const char *CTDSDI12address = "1"; // The SDI-12 Address of the CTD -const uint8_t CTDnumberReadings = 6; // The number of readings to average +const uint8_t CTDNumberReadings = 6; // The number of readings to average const int8_t SDI12Power = sensorPowerPin; // Pin to switch power on and off (-1 if unconnected) const int8_t SDI12Data = 7; // The SDI12 data pin // Create a Decagon CTD sensor object -DecagonCTD ctd(*CTDSDI12address, SDI12Power, SDI12Data, CTDnumberReadings); +DecagonCTD ctd(*CTDSDI12address, SDI12Power, SDI12Data, CTDNumberReadings); // ========================================================================== @@ -386,6 +276,7 @@ void setup() // Attach the modem and information pins to the logger dataLogger.attachModem(modem); + modem.setModemLED(modemLEDPin); dataLogger.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); // Begin the logger @@ -397,17 +288,13 @@ void setup() { modem.modemPowerUp(); modem.wake(); - - // Run any extra pre-set-up for the modem - Serial.println(F("Running extra modem pre-setup")); - extraModemSetup(); modem.setup(); // At very good battery voltage, or with suspicious time stamp, sync the clock // Note: Please change these battery voltages to match your battery if (getBatteryVoltage() > 3.8 || dataLogger.getNowEpoch() < 1546300800 || /*Before 01/01/2019*/ - dataLogger.getNowEpoch() > 1735689600) /*Before 1/1/2025*/ + dataLogger.getNowEpoch() > 1735689600) /*After 1/1/2025*/ { // Synchronize the RTC with NIST Serial.println(F("Attempting to synchronize RTC with NIST")); diff --git a/examples/DRWI_NoCellular/DRWI_NoCellular.ino b/examples/DRWI_NoCellular/DRWI_NoCellular.ino index 5177b16b2..85aa1b974 100644 --- a/examples/DRWI_NoCellular/DRWI_NoCellular.ino +++ b/examples/DRWI_NoCellular/DRWI_NoCellular.ino @@ -71,12 +71,12 @@ MaximDS3231 ds3231(1); // ========================================================================== -// CAMPBELL OBS 3 / OBS 3+ Analog Turbidity Sensor +// Campbell OBS 3 / OBS 3+ Analog Turbidity Sensor // ========================================================================== #include const int8_t OBS3Power = sensorPowerPin; // Pin to switch power on and off (-1 if unconnected) -const uint8_t OBS3numberReadings = 10; +const uint8_t OBS3NumberReadings = 10; const uint8_t ADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC // Campbell OBS 3+ Low Range calibration in Volts const int8_t OBSLowADSChannel = 0; // The ADS channel for the low range output @@ -85,7 +85,7 @@ const float OBSLow_B = 1.000E+00; // The "B" value (X) from the low range calib const float OBSLow_C = 0.000E+00; // The "C" value from the low range calibration // Create a Campbell OBS3+ LOW RANGE sensor object -CampbellOBS3 osb3low(OBS3Power, OBSLowADSChannel, OBSLow_A, OBSLow_B, OBSLow_C, ADSi2c_addr, OBS3numberReadings); +CampbellOBS3 osb3low(OBS3Power, OBSLowADSChannel, OBSLow_A, OBSLow_B, OBSLow_C, ADSi2c_addr, OBS3NumberReadings); // Campbell OBS 3+ High Range calibration in Volts @@ -95,7 +95,7 @@ const float OBSHigh_B = 1.000E+00; // The "B" value (X) from the high range cal const float OBSHigh_C = 0.000E+00; // The "C" value from the high range calibration // Create a Campbell OBS3+ HIGH RANGE sensor object -CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHigh_C, ADSi2c_addr, OBS3numberReadings); +CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHigh_C, ADSi2c_addr, OBS3NumberReadings); // ========================================================================== @@ -104,12 +104,12 @@ CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHig #include const char *CTDSDI12address = "1"; // The SDI-12 Address of the CTD -const uint8_t CTDnumberReadings = 6; // The number of readings to average +const uint8_t CTDNumberReadings = 6; // The number of readings to average const int8_t SDI12Power = sensorPowerPin; // Pin to switch power on and off (-1 if unconnected) const int8_t SDI12Data = 7; // The SDI12 data pin // Create a Decagon CTD sensor object -DecagonCTD ctd(*CTDSDI12address, SDI12Power, SDI12Data, CTDnumberReadings); +DecagonCTD ctd(*CTDSDI12address, SDI12Power, SDI12Data, CTDNumberReadings); // ========================================================================== diff --git a/examples/baro_rho_correction/baro_rho_correction.ino b/examples/baro_rho_correction/baro_rho_correction.ino index f385d46d2..43133572a 100644 --- a/examples/baro_rho_correction/baro_rho_correction.ino +++ b/examples/baro_rho_correction/baro_rho_correction.ino @@ -66,91 +66,31 @@ Variable *mcuBoardSampNo = new ProcessorStats_SampleNumber(&mcuBoard, "12345678- // ========================================================================== -// Wifi/Cellular Modem Main Chip Selection +// Wifi/Cellular Modem Settings // ========================================================================== -// Select your modem chip - this determines the exact commands sent to it -#define TINY_GSM_MODEM_SIM800 // Select for a SIMCOM SIM800, SIM900, or variant thereof - - -// ========================================================================== -// Modem Pins -// ========================================================================== - -const int8_t modemVccPin = -2; // MCU pin controlling modem power (-1 if not applicable) -const int8_t modemSleepRqPin = 23; // MCU pin used for modem sleep/wake request (-1 if not applicable) -const int8_t modemStatusPin = 19; // MCU pin used to read modem status (-1 if not applicable) - - -// ========================================================================== -// TinyGSM Client -// ========================================================================== - -// #define TINY_GSM_DEBUG Serial // If you want debugging on the main debug port - -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates - -// Include TinyGSM for the modem -// This include must be included below the define of the modem name! -#include - // Create a reference to the serial port for the modem HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible -// Create a new TinyGSM modem to run on that serial port and return a pointer to it -TinyGsm *tinyModem = new TinyGsm(modemSerial); - -// Use this to create a modem if you want to spy on modem communication through -// a secondary Arduino stream. Make sure you install the StreamDebugger library! -// https://github.com/vshymanskyy/StreamDebugger -// Also make sure you comment out the modem creation above to use this. -// #include -// StreamDebugger modemDebugger(modemSerial, Serial); -// TinyGsm tinyModem(modemDebugger); - -// Create a new TCP client on that modem and return a pointer to it -TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); - - -// ========================================================================== -// Specific Modem On-Off Methods -// ========================================================================== - -// THIS ONLY APPLIES TO A SODAQ GPRSBEE R6!!! -// Describe the physical pin connection of your modem to your board -const long modemBaud = 9600; // Communication speed of the modem -const bool modemStatusLevel = HIGH; // The level of the status pin when the module is active (HIGH or LOW) - -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -bool modemWakeFxn(void) -{ - digitalWrite(modemSleepRqPin, HIGH); - digitalWrite(redLED, HIGH); // A light just for show - return true; -} -bool modemSleepFxn(void) -{ - digitalWrite(modemSleepRqPin, LOW); - digitalWrite(redLED, LOW); - return true; -} -void extraModemSetup(void){} - - -// ========================================================================== -// Network Information and LoggerModem Object -// ========================================================================== -#include +// Modem Pins - Describe the physical pin connection of your modem to your board +const int8_t modemVccPin = -2; // MCU pin controlling modem power (-1 if not applicable) +const int8_t modemStatusPin = 19; // MCU pin used to read modem status (-1 if not applicable) +const int8_t modemSleepRqPin = 23; // MCU pin used for modem sleep/wake request (-1 if not applicable) +const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem status (-1 if unconnected) // Network connection information -const char *apn = "xxxxx"; // The APN for the gprs connection, unnecessary for WiFi -const char *wifiId = "xxxxx"; // The WiFi access point, unnecessary for gprs -const char *wifiPwd = "xxxxx"; // The password for connecting to WiFi, unnecessary for gprs - -// Create the loggerModem instance -// A "loggerModem" is a combination of a TinyGSM Modem, a Client, and functions for wake and sleep -loggerModem modem(modemVccPin, modemStatusPin, modemStatusLevel, modemWakeFxn, modemSleepFxn, tinyModem, tinyClient, apn); +const char *apn = "xxxxx"; // The APN for the gprs connection + +// For the Sodaq 2GBee R6 and R7 based on the SIMCom SIM800 +// NOTE: The Sodaq GPRSBee doesn't expose the SIM800's reset pin +#include +const long modemBaud = 9600; // SIM800 does auto-bauding by default +Sodaq2GBeeR6 modem2GB(&modemSerial, + modemVccPin, modemStatusPin, + modemSleepRqPin, + apn); +// Create an extra reference to the modem by a generic name (not necessary) +Sodaq2GBeeR6 modem = modem2GB; // Create RSSI and signal strength variable pointers for the modem Variable *modemRSSI = new Modem_RSSI(&modem, "12345678-abcd-1234-efgh-1234567890ab"); @@ -358,10 +298,10 @@ Logger dataLogger(LoggerID, loggingInterval, &varArray); // ========================================================================== -// A Publisher to WikiWatershed +// A Publisher to Monitor My Watershed / EnviroDIY Data Sharing Portal // ========================================================================== // Device registration and sampling feature information can be obtained after -// registration at http://data.WikiWatershed.org +// registration at https://monitormywatershed.org or https://data.envirodiy.org const char *registrationToken = "12345678-abcd-1234-efgh-1234567890ab"; // Device registration token const char *samplingFeature = "12345678-abcd-1234-efgh-1234567890ab"; // Sampling feature UUID @@ -431,10 +371,6 @@ void setup() // Blink the LEDs to show the board is on and starting up greenredflash(); - // Set up the sleep/wake pin for the modem and put its inital value as "off" - pinMode(modemSleepRqPin, OUTPUT); - digitalWrite(modemSleepRqPin, LOW); - // Set the timezone and offsets // Logging in the given time zone Logger::setTimeZone(timeZone); @@ -443,6 +379,7 @@ void setup() // Attach the modem and information pins to the logger dataLogger.attachModem(modem); + modem.setModemLED(modemLEDPin); dataLogger.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); // Begin the logger @@ -454,12 +391,13 @@ void setup() { modem.modemPowerUp(); modem.wake(); + modem.setup(); // At very good battery voltage, or with suspicious time stamp, sync the clock // Note: Please change these battery voltages to match your battery if (getBatteryVoltage() > 3.8 || dataLogger.getNowEpoch() < 1546300800 || /*Before 01/01/2019*/ - dataLogger.getNowEpoch() > 1735689600) /*Before 1/1/2025*/ + dataLogger.getNowEpoch() > 1735689600) /*After 1/1/2025*/ { // Synchronize the RTC with NIST Serial.println(F("Attempting to synchronize RTC with NIST")); @@ -477,8 +415,10 @@ void setup() varArray.setupSensors(); } - // Power down the modem - modem.modemSleepPowerDown(); + // Power down the modem - but only if there will be more than 15 seconds before + // the first logging interval - it can take the modem that long to shut down + if (Logger::getNowEpoch() % (loggingInterval*60) > 15) + modem.modemSleepPowerDown(); // Create the log file, adding the default header to it // Do this last so we have the best chance of getting the time correct and diff --git a/examples/data_saving/data_saving.ino b/examples/data_saving/data_saving.ino index c43a62ace..7ae031618 100644 --- a/examples/data_saving/data_saving.ino +++ b/examples/data_saving/data_saving.ino @@ -170,88 +170,31 @@ void SERCOM2_Handler() // ========================================================================== -// Wifi/Cellular Modem Main Chip Selection +// Wifi/Cellular Modem Settings // ========================================================================== -// Select your modem chip - this determines the exact commands sent to it -#define TINY_GSM_MODEM_SIM800 // Select for a SIMCOM SIM800, SIM900, or variant thereof - - -// ========================================================================== -// Modem Pins -// ========================================================================== - -const int8_t modemVccPin = -2; // MCU pin controlling modem power (-1 if not applicable) -const int8_t modemSleepRqPin = 23; // MCU pin used for modem sleep/wake request (-1 if not applicable) -const int8_t modemStatusPin = 19; // MCU pin used to read modem status (-1 if not applicable) - - -// ========================================================================== -// TinyGSM Client -// ========================================================================== - -// Include TinyGSM for the modem -// This include must be included below the define of the modem name! -#include - // Create a reference to the serial port for the modem -// Extra hardware and software serial ports are created in the "Settings for Additional Serial Ports" section HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible -// Create a new TinyGSM modem to run on that serial port and return a pointer to it -TinyGsm *tinyModem = new TinyGsm(modemSerial); - -// Use this to create a modem if you want to spy on modem communication through -// a secondary Arduino stream. Make sure you install the StreamDebugger library! -// https://github.com/vshymanskyy/StreamDebugger -// Also make sure you comment out the modem creation above to use this. -// #include -// StreamDebugger modemDebugger(modemSerial, Serial); -// TinyGsm *tinyModem = new TinyGsm(modemDebugger); - -// Create a new TCP client on that modem and return a pointer to it -TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); - - -// ========================================================================== -// Specific Modem On-Off Methods -// ========================================================================== - -// THIS ONLY APPLIES TO A SODAQ GPRSBEE R6!!! -// Describe the physical pin connection of your modem to your board -const long modemBaud = 9600; // Communication speed of the modem -const bool modemStatusLevel = HIGH; // The level of the status pin when the module is active (HIGH or LOW) - -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -bool modemWakeFxn(void) -{ - digitalWrite(modemSleepRqPin, HIGH); - digitalWrite(redLED, HIGH); // A light just for show - return true; -} -bool modemSleepFxn(void) -{ - digitalWrite(modemSleepRqPin, LOW); - digitalWrite(redLED, LOW); - return true; -} -void extraModemSetup(void){} - - -// ========================================================================== -// Network Information and LoggerModem Object -// ========================================================================== -#include +// Modem Pins - Describe the physical pin connection of your modem to your board +const int8_t modemVccPin = -2; // MCU pin controlling modem power (-1 if not applicable) +const int8_t modemStatusPin = 19; // MCU pin used to read modem status (-1 if not applicable) +const int8_t modemSleepRqPin = 23; // MCU pin used for modem sleep/wake request (-1 if not applicable) +const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem status (-1 if unconnected) // Network connection information -const char *apn = "xxxxx"; // The APN for the gprs connection, unnecessary for WiFi -const char *wifiId = "xxxxx"; // The WiFi access point, unnecessary for gprs -const char *wifiPwd = "xxxxx"; // The password for connecting to WiFi, unnecessary for gprs - -// Create the loggerModem instance -// A "loggerModem" is a combination of a TinyGSM Modem, a Client, and functions for wake and sleep -loggerModem modem(modemVccPin, modemStatusPin, modemStatusLevel, modemWakeFxn, modemSleepFxn, tinyModem, tinyClient, apn); +const char *apn = "xxxxx"; // The APN for the gprs connection + +// For the Sodaq 2GBee R6 and R7 based on the SIMCom SIM800 +// NOTE: The Sodaq GPRSBee doesn't expose the SIM800's reset pin +#include +const long modemBaud = 9600; // SIM800 does auto-bauding by default +Sodaq2GBeeR6 modem2GB(&modemSerial, + modemVccPin, modemStatusPin, + modemSleepRqPin, + apn); +// Create an extra reference to the modem by a generic name (not necessary) +Sodaq2GBeeR6 modem = modem2GB; // Create RSSI and signal strength variable pointers for the modem Variable *modemRSSI = new Modem_RSSI(&modem, "12345678-abcd-1234-efgh-1234567890ab"); @@ -512,7 +455,6 @@ void setup() Serial.println(F( "WARNING: THIS EXAMPLE WAS WRITTEN FOR A DIFFERENT VERSION OF MODULAR SENSORS!!")); - // Start the serial connection with the modem modemSerial.begin(modemBaud); @@ -535,10 +477,6 @@ void setup() // Blink the LEDs to show the board is on and starting up greenredflash(); - // Set up the sleep/wake pin for the modem and put its inital value as "off" - pinMode(modemSleepRqPin, OUTPUT); - digitalWrite(modemSleepRqPin, LOW); - // Set the timezone and offsets // Logging in the given time zone Logger::setTimeZone(timeZone); @@ -550,6 +488,7 @@ void setup() // attaching it to both allows either logger to control NIST synchronization loggerAllVars.attachModem(modem); loggerToGo.attachModem(modem); + modem.setModemLED(modemLEDPin); loggerAllVars.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); // Set up the connection information with EnviroDIY for both loggers @@ -563,17 +502,13 @@ void setup() { modem.modemPowerUp(); modem.wake(); - - // Run any extra pre-set-up for the modem - Serial.println(F("Running extra modem pre-setup")); - extraModemSetup(); modem.setup(); // At very good battery voltage, or with suspicious time stamp, sync the clock // Note: Please change these battery voltages to match your battery if (getBatteryVoltage() > 3.8 || loggerAllVars.getNowEpoch() < 1546300800 || /*Before 01/01/2019*/ - loggerAllVars.getNowEpoch() > 1735689600) /*Before 1/1/2025*/ + loggerAllVars.getNowEpoch() > 1735689600) /*After 1/1/2025*/ { // Synchronize the RTC with NIST Serial.println(F("Attempting to synchronize RTC with NIST")); diff --git a/examples/double_logger/double_logger.ino b/examples/double_logger/double_logger.ino index 59b0926c1..b294cc8d7 100644 --- a/examples/double_logger/double_logger.ino +++ b/examples/double_logger/double_logger.ino @@ -63,97 +63,36 @@ ProcessorStats mcuBoard(mcuBoardVersion); // ========================================================================== -// Wifi/Cellular Modem Main Chip Selection +// Wifi/Cellular Modem Settings // ========================================================================== -// Select your modem chip - this determines the exact commands sent to it -#define TINY_GSM_MODEM_XBEE // Select for Digi brand WiFi or Cellular XBee's - - -// ========================================================================== -// Modem Pins -// ========================================================================== - -const int8_t modemVccPin = -2; // MCU pin controlling modem power (-1 if not applicable) -const int8_t modemSleepRqPin = 23; // MCU pin used for modem sleep/wake request (-1 if not applicable) -const int8_t modemStatusPin = 19; // MCU pin used to read modem status (-1 if not applicable) -const int8_t modemResetPin = A4; // MCU pin connected to modem reset pin (-1 if unconnected) - - -// ========================================================================== -// TinyGSM Client -// ========================================================================== - -#if defined(TINY_GSM_MODEM_XBEE) - #define TINY_GSM_YIELD() { delay(2); } // Use to counter slow (9600) baud rate -#endif - -// Include TinyGSM for the modem -// This include must be included below the define of the modem name! -#include - // Create a reference to the serial port for the modem +// Extra hardware and software serial ports are created in the "Settings for Additional Serial Ports" section HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible +// AltSoftSerial &modemSerial = altSoftSerial; // For software serial if needed +// NeoSWSerial &modemSerial = neoSSerial1; // For software serial if needed -// Create a TinyGSM modem to run on that serial port -TinyGsm tinyModem(modemSerial, modemResetPin); - -// Create a TCP client on that modem -TinyGsmClient tinyClient(tinyModem); - - -// ========================================================================== -// Specific Modem On-Off Methods -// ========================================================================== - -// This should apply to all Digi brand XBee modules. -// Describe the physical pin connection of your modem to your board -const long modemBaud = 9600; // Communication speed of the modem -const bool modemStatusLevel = LOW; // The level of the status pin when the module is active (HIGH or LOW) - -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -// After enabling pin sleep, the sleep request pin is held LOW to keep the XBee on -// Enable pin sleep in the setup function or using XCTU prior to connecting the XBee -bool modemSleepFxn(void) -{ - if (modemSleepRqPin >= 0) // Don't go to sleep if there's not a wake pin! - { - digitalWrite(modemSleepRqPin, HIGH); - digitalWrite(redLED, LOW); - return true; - } - else return true; -} -bool modemWakeFxn(void) -{ - if (modemVccPin >= 0) // Turns on when power is applied - return true; - else if (modemSleepRqPin >= 0) - { - digitalWrite(modemSleepRqPin, LOW); - digitalWrite(redLED, HIGH); // Because the XBee doesn't have any lights - return true; - } - else return true; -} - - -// ========================================================================== -// Network Information and LoggerModem Object -// ========================================================================== -#include +// Modem Pins - Describe the physical pin connection of your modem to your board +const int8_t modemVccPin = -2; // MCU pin controlling modem power (-1 if not applicable) +const int8_t modemStatusPin = 19; // MCU pin used to read modem status (-1 if not applicable) +const int8_t modemResetPin = 20; // MCU pin connected to modem reset pin (-1 if unconnected) +const int8_t modemSleepRqPin = 23; // MCU pin used for modem sleep/wake request (-1 if not applicable) +const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem status (-1 if unconnected) // Network connection information -const char *apn = "xxxxx"; // The APN for the gprs connection, unnecessary for WiFi const char *wifiId = "xxxxx"; // The WiFi access point, unnecessary for gprs const char *wifiPwd = "xxxxx"; // The password for connecting to WiFi, unnecessary for gprs -// Create the loggerModem instance -// A "loggerModem" is a combination of a TinyGSM Modem, a Client, and functions for wake and sleep -// loggerModem modem(modemVccPin, modemStatusPin, modemStatusLevel, modemWakeFxn, modemSleepFxn, &tinyModem, &tinyClient, wifiId, wifiPwd); -loggerModem modem(modemVccPin, modemStatusPin, modemStatusLevel, modemWakeFxn, modemSleepFxn, &tinyModem, &tinyClient, apn); - +// For the Digi Wifi XBee (S6B) +#include +const long modemBaud = 9600; // All XBee's use 9600 by default +const bool useCTSforStatus = true; // Flag to use the modem CTS pin for status +DigiXBeeWifi modemXBWF(&modemSerial, + modemVccPin, modemStatusPin, useCTSforStatus, + modemResetPin, modemSleepRqPin, + wifiId, wifiPwd); +// Create an extra reference to the modem by a generic name (not necessary) +DigiXBeeWifi modem = modemXBWF; // ========================================================================== @@ -267,9 +206,6 @@ void setup() // Blink the LEDs to show the board is on and starting up greenredflash(); - // Set up pin for the modem - pinMode(modemSleepRqPin, OUTPUT); - // Set the timezone and offsets // Logging in the given time zone Logger::setTimeZone(timeZone); @@ -284,8 +220,8 @@ void setup() logger1min.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); logger5min.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); - // Turn on the modem + modem.setModemLED(modemLEDPin); modem.modemPowerUp(); modem.wake(); diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index 7e0a54454..09d533495 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -60,502 +60,37 @@ ProcessorStats mcuBoard(mcuBoardVersion); // ========================================================================== -// Wifi/Cellular Modem Main Chip Selection +// Wifi/Cellular Modem Settings // ========================================================================== -// Select your modem chip - this determines the exact commands sent to it -// #define TINY_GSM_MODEM_SIM800 // Select for a SIMCOM SIM800, SIM900, or variant thereof -// #define SIM800_GPRSBEE_R6 // Select with SIM800 for - these use atypical sleep and wake fxns -// #define TINY_GSM_MODEM_SIM808 // Select for a SIMCOM SIM808 or SIM868, or variant thereof -// #define TINY_GSM_MODEM_UBLOX // Select for most u-blox cellular modems -// #define USE_UBLOX_R410M // Select with UBLOX for a non-XBee SARA R4 or N4 model -// #define USE_XBEE_BYPASS // Select with UBLOX for a Digi 3G or LTE-M XBee in bypass mode -// #define TINY_GSM_MODEM_ESP8266 // Select for an ESP8266 using the DEFAULT AT COMMAND FIRMWARE -#define TINY_GSM_MODEM_XBEE // Select for Digi brand WiFi or Cellular XBee's -// #define USE_XBEE_WIFI // Select with XBEE for an S6B wifi XBee -// #define TINY_GSM_MODEM_M590 // Select for a Neoway M590 -// #define TINY_GSM_MODEM_A6 // Select for an AI-Thinker A6, A6C, A7, A20 -// #define TINY_GSM_MODEM_M95 // Select for a Quectel M95 -// #define TINY_GSM_MODEM_BG96 // Select for a Quectel BG96 -// #define TINY_GSM_MODEM_MC60 // Select for a Quectel MC60 or MC60E - - -// ========================================================================== -// Modem Pins -// ========================================================================== - -const int8_t modemVccPin = -2; // MCU pin controlling modem power (-1 if not applicable) -const int8_t modemSleepRqPin = 23; // MCU pin used for modem sleep/wake request (-1 if not applicable) -const int8_t modemStatusPin = 19; // MCU pin used to read modem status (-1 if not applicable) -const int8_t modemResetPin = A4; // MCU pin connected to modem reset pin (-1 if unconnected) - - -// ========================================================================== -// TinyGSM Client -// ========================================================================== - -// #define TINY_GSM_DEBUG Serial // If you want debugging on the main debug port - -#define TINY_GSM_YIELD() { delay(2); } // Can help with slow (9600) baud rates - -// Include TinyGSM for the modem -// This include must be included below the define of the modem name! -#include - // Create a reference to the serial port for the modem +// Extra hardware and software serial ports are created in the "Settings for Additional Serial Ports" section HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible +// AltSoftSerial &modemSerial = altSoftSerial; // For software serial if needed +// NeoSWSerial &modemSerial = neoSSerial1; // For software serial if needed -// Create a new TinyGSM modem to run on that serial port and return a pointer to it -#if defined TINY_GSM_MODEM_XBEE -TinyGsm *tinyModem = new TinyGsm(modemSerial, modemResetPin); -#else -TinyGsm *tinyModem = new TinyGsm(modemSerial); -#endif - - -// Create a new TCP client on that modem and return a pointer to it -TinyGsmClient *tinyClient = new TinyGsmClient(*tinyModem); -// The u-blox SARA R410 is very slow to open and close clients, so we can -// iterate through mutiple data senders much more quickly if we have multiple -// clients. The u-blox SARA R410 is the only modem where there's any advantage -// to this. -#if defined USE_UBLOX_R410M -TinyGsmClient *tinyClient2 = new TinyGsmClient(*tinyModem); -TinyGsmClient *tinyClient3 = new TinyGsmClient(*tinyModem); -#endif - - -// ========================================================================== -// Specific Modem On-Off Methods -// ========================================================================== - -// This should apply to all Digi brand XBee modules. -#if defined TINY_GSM_MODEM_XBEE || defined USE_XBEE_BYPASS -// Describe the physical pin connection of your modem to your board -const long modemBaud = 9600; // Communication speed of the modem, 9600 is default for XBee -const bool modemStatusLevel = LOW; // The level of the status pin when the module is active (HIGH or LOW) - -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -// After enabling pin sleep, the sleep request pin is held LOW to keep the XBee on -// Enable pin sleep in the setup function or using XCTU prior to connecting the XBee -bool modemSleepFxn(void) -{ - if (modemSleepRqPin >= 0) // Don't go to sleep if there's not a wake pin! - { - digitalWrite(modemSleepRqPin, HIGH); - digitalWrite(redLED, LOW); - return true; - } - else - { - return true; - } -} -bool modemWakeFxn(void) -{ - if (modemVccPin >= 0) // Turns on when power is applied - return true; - else if (modemSleepRqPin >= 0) - { - digitalWrite(modemSleepRqPin, LOW); - digitalWrite(redLED, HIGH); // Because the XBee doesn't have any lights - return true; - } - else - { - return true; - } -} -// An extra function to set up pin sleep and other preferences on the XBee -// NOTE: This will only succeed if the modem is turned on and awake! -#if defined TINY_GSM_MODEM_XBEE -void extraModemSetup(void) -{ - tinyModem->init(); // initialize - if (tinyModem->commandMode()) - { - tinyModem->sendAT(F("D8"),1); // Set DIO8 to be used for sleep requests - // NOTE: Only pin 9/DIO8/DTR can be used for this function - tinyModem->waitResponse(); - tinyModem->sendAT(F("D9"),1); // Turn on status indication pin - // NOTE: Only pin 13/DIO9 can be used for this function - tinyModem->waitResponse(); - tinyModem->sendAT(F("D7"),1); // Turn on CTS pin - as proxy for status indication - // NOTE: Only pin 12/DIO7/CTS can be used for this function - tinyModem->waitResponse(); - tinyModem->sendAT(F("SM"),1); // Pin sleep - tinyModem->waitResponse(); - tinyModem->sendAT(F("DO"),0); // Disable remote manager, USB Direct, and LTE PSM - // NOTE: LTE-M's PSM (Power Save Mode) sounds good, but there's no - // easy way on the LTE-M Bee to wake the cell chip itself from PSM, - // so we'll use the Digi pin sleep instead. - tinyModem->waitResponse(); - #if defined USE_XBEE_WIFI - tinyModem->sendAT(F("SO"),200); // For WiFi - Disassociate from AP for Deep Sleep - tinyModem->waitResponse(); - #else - tinyModem->sendAT(F("SO"),0); // For Cellular - disconnected sleep - tinyModem->waitResponse(); - tinyModem->sendAT(F("P0"),0); // Make sure USB direct won't be pin enabled - tinyModem->waitResponse(); - tinyModem->sendAT(F("P1"),0); // Make sure pins 7&8 are not set for USB direct - tinyModem->waitResponse(); - tinyModem->sendAT(F("N#"),2); // Cellular network technology - LTE-M Only - // LTE-M XBee connects much faster on AT&T/Hologram when set to LTE-M only (instead of LTE-M/NB IoT) - tinyModem->waitResponse(); - #endif - tinyModem->writeChanges(); - tinyModem->exitCommand(); - } -} -#elif defined USE_XBEE_BYPASS -void extraModemSetup(void) -{ - delay(1000); // Guard time for command mode - tinyModem->streamWrite(GF("+++")); // enter command mode - tinyModem->waitResponse(2000, F("OK\r")); - tinyModem->sendAT(F("D8"),1); // Set DIO8 to be used for sleep requests - // NOTE: Only pin 9/DIO8/DTR can be used for this function - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("D9"),1); // Turn on status indication pin - // NOTE: Only pin 13/DIO9 can be used for this function - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("D7"),1); // Turn on CTS pin - as proxy for status indication - // NOTE: Only pin 12/DIO7/CTS can be used for this function - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("SM"),1); // Pin sleep - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("SO"),0); // For Cellular - disconnected sleep - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("DO"),0); // Disable remote manager, USB Direct, and LTE PSM - // NOTE: LTE-M's PSM (Power Save Mode) sounds good, but there's no - // easy way on the LTE-M Bee to wake the cell chip itself from PSM, - // so we'll use the Digi pin sleep instead. - tinyModem->waitResponse(F("OK\r")); - #if defined USE_UBLOX_R410M - tinyModem->sendAT(F("P0"),0); // Make sure USB direct won't be pin enabled - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("P1"),0); // Make sure pins 7&8 are not set for USB direct - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("N#"),2); // Cellular network technology - LTE-M Only - // LTE-M XBee connects much faster on AT&T/Hologram when set to LTE-M only (instead of LTE-M/NB IoT) - tinyModem->waitResponse(F("OK\r")); - #endif - tinyModem->sendAT(F("AP5")); // Turn on bypass mode - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("WR")); // Write changes to flash - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("AC")); // Apply changes - tinyModem->waitResponse(F("OK\r")); - tinyModem->sendAT(F("FR")); // Force reset to enter bypass mode - tinyModem->waitResponse(F("OK\r")); - tinyModem->init(); // initialize -} -#endif - - -// This should work with most ESP8266 breakouts -#elif defined TINY_GSM_MODEM_ESP8266 -// Describe the physical pin connection of your modem to your board -const long modemBaud = 115200; // Communication speed of the modem, 115200 is default for ESP8266 -const bool modemStatusLevel = HIGH; // The level of the status pin when the module is active (HIGH or LOW) -const int8_t espSleepRqPin = 13; // ESP8266 GPIO pin used for wake from light sleep (-1 if not applicable) -const int8_t espStatusPin = -1; // ESP8266 GPIO pin used to give modem status (-1 if not applicable) - -// A helper function to wait for the esp to boot and immediately change some settings -// We'll use this in the wake function -bool ESPwaitForBoot(void) -{ - // Wait for boot - finished when characters start coming - // NOTE: After every "hard" reset (either power off or via RST-B), the ESP - // sends out a boot log from the ROM on UART1 at 74880 baud. We're not - // going to worry about the odd baud rate since we're simply throwing the - // characters away. - delay(200); // It will take at least this long - uint32_t start = millis(); - bool success = false; - while (!modemSerial.available() && millis() - start < 1000) {} - if (modemSerial.available()) - { - success = true; - // Read the boot log to empty it from the serial buffer - while (modemSerial.available()) - { - modemSerial.read(); - delay(2); - } - // Have to make sure echo is off or all AT commands will be confused - tinyModem->sendAT(F("E0")); - success &= tinyModem->waitResponse() == 1; - // re-run init to set mux and station mode - success &= tinyModem->init(); - } - return success; -} - -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -bool modemSleepFxn(void) -{ - // Use this if you have GPIO16 connected to the reset pin to wake from deep sleep - // but no other MCU pin connected to the reset pin. - // NOTE: This will NOT work nicely with "testingMode" - /*if (loggingInterval > 1) - { - uint32_t sleepSeconds = (((uint32_t)loggingInterval) * 60 * 1000) - 75000L; - String sleepCommand = String(sleepSeconds); - tinyModem->sendAT(F("+GSLP="), sleepCommand); - // Power down for 1 minute less than logging interval - // Better: Calculate length of loop and power down for logging interval - loop time - return tinyModem->waitResponse() == 1; - }*/ - // Use this if you have an MCU pin connected to the ESP's reset pin to wake from deep sleep - if (modemResetPin >= 0) - { - digitalWrite(redLED, LOW); - return tinyModem->poweroff(); - } - // Use this if you don't have access to the ESP8266's reset pin for deep sleep but you - // do have access to another GPIO pin for light sleep. This also sets up another - // pin to view the sleep status. - else if (modemSleepRqPin >= 0 && modemStatusPin >= 0) - { - tinyModem->sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0,"), - String(espStatusPin), ',', modemStatusLevel); - bool success = tinyModem->waitResponse() == 1; - tinyModem->sendAT(F("+SLEEP=1")); - success &= tinyModem->waitResponse() == 1; - digitalWrite(redLED, LOW); - return success; - } - // Light sleep without the status pin - else if (modemSleepRqPin >= 0 && modemStatusPin < 0) - { - tinyModem->sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0")); - bool success = tinyModem->waitResponse() == 1; - tinyModem->sendAT(F("+SLEEP=1")); - success &= tinyModem->waitResponse() == 1; - digitalWrite(redLED, LOW); - return success; - } - else // DON'T go to sleep if we can't wake up! - { - return true; - } -} -bool modemWakeFxn(void) -{ - bool success = true; - if (modemVccPin >= 0) // Turns on when power is applied - { - digitalWrite(redLED, HIGH); // Because the ESP8266 doesn't have any lights - success &= ESPwaitForBoot(); - if (!success) - { - digitalWrite(redLED, LOW); // Turn off light if the boot failed - } - return success; - } - else if (modemResetPin >= 0) - { - digitalWrite(redLED, HIGH); - digitalWrite(modemResetPin, LOW); - delay(1); - digitalWrite(modemResetPin, HIGH); - success &= ESPwaitForBoot(); - if (!success) - { - digitalWrite(redLED, LOW); // Turn off light if the boot failed - } - return success; - } - else if (modemSleepRqPin >= 0) - { - digitalWrite(modemSleepRqPin, LOW); - delay(1); - digitalWrite(modemSleepRqPin, HIGH); - digitalWrite(redLED, HIGH); - // Don't have to wait for a boot if using light sleep - return true; - } - else - { - return true; - } -} -// Set up the light-sleep status pin, if applicable -void extraModemSetup(void) -{ - // Slow down the baud rate for slow processors - and save the change to - // the ESP's non-volatile memory so we don't have to do it every time - #if F_CPU == 8000000L - if (modemBaud > 57600) - { - modemSerial.begin(modemBaud); - tinyModem->sendAT(F("+UART_DEF=9600,8,1,0,0")); - tinyModem->waitResponse(); - modemSerial.end(); - modemSerial.begin(9600); - } - #endif - if (modemVccPin < 0 && modemResetPin < 0 && modemSleepRqPin >= 0 && modemStatusPin >= 0) - { - tinyModem->sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0,"), - String(espStatusPin), ',', modemStatusLevel); - tinyModem->waitResponse(); - } -} - - -// This should work for many u-blox breakouts, but check the timing in wake/sleep functions -#elif defined TINY_GSM_MODEM_UBLOX -// Describe the physical pin connection of your modem to your board -#if defined USE_UBLOX_R410M -const long modemBaud = 115200; // Communication speed of the modem, R4/N4 use 115200 -#else -const long modemBaud = 9600; // Communication speed of the modem, most u-blox use 9600 -#endif -const bool modemStatusLevel = HIGH; // The level of the status pin when the module is active (HIGH or LOW) - -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -bool modemSleepFxn(void) -{ - #if defined USE_UBLOX_R410M - if (modemSleepRqPin >= 0) // R410 must have access to PWR_ON pin to sleep - #else - if (modemVccPin >= 0 || modemSleepRqPin >= 0) // others will go on with power on - #endif - { - // Easiest to just go to sleep with the AT command rather than using pins - return tinyModem->poweroff(); - } - else // DON'T go to sleep if we can't wake up! - { - return true; - } -} -bool modemWakeFxn(void) -{ - // SARA/LISA U2/G2 and SARA G3 series turn on when power is applied - // SARA R4/N4 series must power on and then pulse on - #ifndef USE_UBLOX_R410M - if (modemVccPin >= 0) - return true; - #endif - if (modemSleepRqPin >= 0) - { - digitalWrite(modemSleepRqPin, LOW); - digitalWrite(redLED, HIGH); - #if defined USE_UBLOX_R410M - delay(200); // 0.15-3.2s pulse for wake on SARA R4/N4 - #else - // delay(6); // >5ms pulse for wake on SARA G3 - delayMicroseconds(65); // 50-80µs pulse for wake on SARA/LISA U2/G2 - #endif - digitalWrite(modemSleepRqPin, HIGH); - digitalWrite(redLED, LOW); - // Need to slow down R4/N4's default 115200 baud rate for slow processors - #if F_CPU == 8000000L && defined USE_UBLOX_R410M - delay(4600); // Must wait for UART port to become active - modemSerial.begin(115200); - tinyModem->setBaud(9600); - modemSerial.end(); - modemSerial.begin(9600); - #endif - return true; - } - else - { - return true; - } -} -#if defined USE_UBLOX_R410M -// Set band to only use LTE-M (not NB IoT) - this can speed up connection -void extraModemSetup(void) -{ - tinyModem->sendAT(F("+URAT=7")); - tinyModem->waitResponse(); -} -#else -void extraModemSetup(void){} -#endif - - -// THIS ONLY APPLIES TO A SODAQ GPRSBEE R6!!! -#elif defined TINY_GSM_MODEM_SIM800 && defined SIM800_GPRSBEE_R6 -// Describe the physical pin connection of your modem to your board -const long modemBaud = 9600; // Communication speed of the modem -const bool modemStatusLevel = HIGH; // The level of the status pin when the module is active (HIGH or LOW) - -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -bool modemWakeFxn(void) -{ - digitalWrite(modemSleepRqPin, HIGH); - digitalWrite(redLED, HIGH); // A light just for show - return true; -} -bool modemSleepFxn(void) -{ - digitalWrite(modemSleepRqPin, LOW); - digitalWrite(redLED, LOW); - return true; -} -void extraModemSetup(void){} - - -// Most cellular chips/breakouts respond to a low pulse of some length to power up and down -#else -// Describe the physical pin connection of your modem to your board -const long modemBaud = 9600; // Communication speed of the modem -const bool modemStatusLevel = HIGH; // The level of the status pin when the module is active (HIGH or LOW) - -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -bool modemWakeFxn(void) -{ - digitalWrite(modemSleepRqPin, LOW); - // delay(1100); // >1s for SIM800, SIM900, Quectel M95, Quectel MC60 - // delay(510); // >300ms (>500ms recommended) for Neoway M590 - delay(110); // >100ms for Quectel BG96 - digitalWrite(modemSleepRqPin, HIGH); - return true; -} -bool modemSleepFxn(void) -{ - digitalWrite(modemSleepRqPin, LOW); - // delay(1100); // 1sec > t > 33sec for SIM800 and clones - // delay(600); // 0.5sec > pull down > 1sec for SIM900 - // delay(510); // >300ms (>500ms recommended) for Neoway M590 - delay(700); // >650ms for Quectel BG96, 0.6sec > pull down > 1sec for Quectel M95, Quectel MC60 - digitalWrite(modemSleepRqPin, HIGH); - return true; -} -void extraModemSetup(void){} -#endif - - -// ========================================================================== -// Network Information and LoggerModem Object -// ========================================================================== -#include +// Modem Pins - Describe the physical pin connection of your modem to your board +const int8_t modemVccPin = -2; // MCU pin controlling modem power (-1 if not applicable) +const int8_t modemStatusPin = 19; // MCU pin used to read modem status (-1 if not applicable) +const int8_t modemResetPin = 20; // MCU pin connected to modem reset pin (-1 if unconnected) +const int8_t modemSleepRqPin = 23; // MCU pin used for modem sleep/wake request (-1 if not applicable) +const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem status (-1 if unconnected) // Network connection information -const char *apn = "xxxxx"; // The APN for the gprs connection, unnecessary for WiFi -const char *wifiId = "xxxxx"; // The WiFi access point, unnecessary for gprs -const char *wifiPwd = "xxxxx"; // The password for connecting to WiFi, unnecessary for gprs +const char *apn = "xxxxx"; // The APN for the gprs connection -// Create the loggerModem instance -// A "loggerModem" is a combination of a TinyGSM Modem, a Client, and functions for wake and sleep -#if defined TINY_GSM_MODEM_ESP8266 || defined USE_XBEE_WIFI -loggerModem modem(modemVccPin, modemStatusPin, modemStatusLevel, modemWakeFxn, modemSleepFxn, tinyModem, tinyClient, wifiId, wifiPwd); -// ^^ Use this for WiFi -#else -loggerModem modem(modemVccPin, modemStatusPin, modemStatusLevel, modemWakeFxn, modemSleepFxn, tinyModem, tinyClient, apn); -// ^^ Use this for cellular -#endif +// For the u-blox based Digi XBee's (3G global and LTE-M global) +// NOTE: According to the manual, this should be less stable than transparent +// mode, but my experience is the complete reverse. +#include +const long modemBaud = 9600; // All XBee's use 9600 by default +const bool useCTSforStatus = true; // Flag to use the modem CTS pin for status. Only applies to Digi XBee's +DigiXBeeCellularBypass modemXBCB(&modemSerial, + modemVccPin, modemStatusPin, useCTSforStatus, + modemResetPin, modemSleepRqPin, + apn); +// Create an extra reference to the modem by a generic name (not necessary) +DigiXBeeCellularBypass modem = modemXBCB; // ========================================================================== @@ -738,26 +273,6 @@ void setup() digitalWrite(sensorPowerPin, LOW); } - // Set up the sleep/wake pin for the modem and put its inital value as "off" - #if defined TINY_GSM_MODEM_SIM800 && defined SIM800_GPRSBEE_R6 // ONLY FOR GPRSBee R6!!!! - if (modemSleepRqPin >= 0) - { - pinMode(modemSleepRqPin, OUTPUT); - digitalWrite(modemSleepRqPin, LOW); - } - #else - if (modemSleepRqPin >= 0) - { - pinMode(modemSleepRqPin, OUTPUT); - digitalWrite(modemSleepRqPin, HIGH); - } - if (modemResetPin >= 0) - { - pinMode(modemResetPin, OUTPUT); - digitalWrite(modemResetPin, HIGH); - } - #endif - // Set the timezone and offsets // Logging in the given time zone Logger::setTimeZone(timeZone); @@ -766,6 +281,7 @@ void setup() // Attach the modem and information pins to the logger dataLogger.attachModem(modem); + modem.setModemLED(modemLEDPin); dataLogger.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); // Begin the logger @@ -777,17 +293,13 @@ void setup() { modem.modemPowerUp(); modem.wake(); - - // Run any extra pre-set-up for the modem - Serial.println(F("Running extra modem pre-setup")); - extraModemSetup(); modem.setup(); // At very good battery voltage, or with suspicious time stamp, sync the clock // Note: Please change these battery voltages to match your battery if (getBatteryVoltage() > 3.8 || dataLogger.getNowEpoch() < 1546300800 || /*Before 01/01/2019*/ - dataLogger.getNowEpoch() > 1735689600) /*Before 1/1/2025*/ + dataLogger.getNowEpoch() > 1735689600) /*After 1/1/2025*/ { // Synchronize the RTC with NIST Serial.println(F("Attempting to synchronize RTC with NIST")); diff --git a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino index 6b585e4ce..a9d13c0d2 100644 --- a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino +++ b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino @@ -61,210 +61,42 @@ ProcessorStats mcuBoard(mcuBoardVersion); // ========================================================================== -// Wifi/Cellular Modem Main Chip Selection +// Wifi/Cellular Modem Settings // ========================================================================== -// Select your modem chip - this determines the exact commands sent to it -#define TINY_GSM_MODEM_ESP8266 // Select for an ESP8266 using the DEFAULT AT COMMAND FIRMWARE - - -// ========================================================================== -// Modem Pins -// ========================================================================== - -const int8_t modemVccPin = -2; // MCU pin controlling modem power (-1 if not applicable) -const int8_t modemSleepRqPin = 19; // MCU pin used for wake from light sleep (-1 if not applicable) -const int8_t modemStatusPin = -1; // MCU pin used to read modem status (-1 if not applicable) -const int8_t modemResetPin = A4; // MCU pin connected to ESP8266's RSTB/GPIO16 pin (-1 if unconnected) - - -// ========================================================================== -// TinyGSM Client -// ========================================================================== - -// Include TinyGSM for the modem -// This include must be included below the define of the modem name! -#include - // Create a reference to the serial port for the modem HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible -// Create a TinyGSM modem to run on that serial port -TinyGsm tinyModem(modemSerial); - -// Create a TCP client on that modem -TinyGsmClient tinyClient(tinyModem); - - -// ========================================================================== -// Specific Modem On-Off Methods -// ========================================================================== - -// This should work with most ESP8266 breakouts -// Describe the physical pin connection of your modem to your board -const long modemBaud = 115200; // Communication speed of the modem, 115200 is default for ESP8266 -const bool modemStatusLevel = HIGH; // The level of the status pin when the module is active (HIGH or LOW) -const int8_t espSleepRqPin = 13; // ESP8266 GPIO pin used for wake from light sleep (-1 if not applicable) -const int8_t espStatusPin = -1; // ESP8266 GPIO pin used to give modem status (-1 if not applicable) - -// A helper function to wait for the esp to boot and immediately change some settings -// We'll use this in the wake function -bool ESPwaitForBoot(void) -{ - // Wait for boot - finished when characters start coming - // NOTE: After every "hard" reset (either power off or via RST-B), the ESP - // sends out a boot log from the ROM on UART1 at 74880 baud. We're not - // going to worry about the odd baud rate since we're simply throwing the - // characters away. - delay(200); // It will take at least this long - uint32_t start = millis(); - bool success = false; - while (!modemSerial.available() && millis() - start < 1000) {} - if (modemSerial.available()) - { - success = true; - // Read the boot log to empty it from the serial buffer - while (modemSerial.available()) - { - modemSerial.read(); - delay(2); - } - // Have to make sure echo is off or all AT commands will be confused - tinyModem.sendAT(F("E0")); - success &= tinyModem.waitResponse() == 1; - // re-run init to set mux and station mode - success &= tinyModem.init(); - } - return success; -} - -// Create the wake and sleep methods for the modem -// These can be functions of any type and must return a boolean -bool modemSleepFxn(void) -{ - // Use this if you have GPIO16 connected to the reset pin to wake from deep sleep - // but no other MCU pin connected to the reset pin. - // NOTE: This will NOT work nicely with "testingMode" - /*if (loggingInterval > 1) - { - uint32_t sleepSeconds = (((uint32_t)loggingInterval) * 60 * 1000) - 75000L; - String sleepCommand = String(sleepSeconds); - tinyModem.sendAT(F("+GSLP="), sleepCommand); - // Power down for 1 minute less than logging interval - // Better: Calculate length of loop and power down for logging interval - loop time - return tinyModem.waitResponse() == 1; - }*/ - // Use this if you have an MCU pin connected to the ESP's reset pin to wake from deep sleep - if (modemResetPin >= 0) - { - digitalWrite(redLED, LOW); - return tinyModem.poweroff(); - } - // Use this if you don't have access to the ESP8266's reset pin for deep sleep but you - // do have access to another GPIO pin for light sleep. This also sets up another - // pin to view the sleep status. - else if (modemSleepRqPin >= 0 && modemStatusPin >= 0) - { - tinyModem.sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0,"), - String(espStatusPin), ',', modemStatusLevel); - bool success = tinyModem.waitResponse() == 1; - tinyModem.sendAT(F("+SLEEP=1")); - success &= tinyModem.waitResponse() == 1; - digitalWrite(redLED, LOW); - return success; - } - // Light sleep without the status pin - else if (modemSleepRqPin >= 0 && modemStatusPin < 0) - { - tinyModem.sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0")); - bool success = tinyModem.waitResponse() == 1; - tinyModem.sendAT(F("+SLEEP=1")); - success &= tinyModem.waitResponse() == 1; - digitalWrite(redLED, LOW); - return success; - } - else // DON'T go to sleep if we can't wake up! - { - return true; - } -} -bool modemWakeFxn(void) -{ - bool success = true; - if (modemVccPin >= 0) // Turns on when power is applied - { - digitalWrite(redLED, HIGH); // Because the ESP8266 doesn't have any lights - success &= ESPwaitForBoot(); - if (!success) - { - digitalWrite(redLED, LOW); // Turn off light if the boot failed - } - return success; - } - else if (modemResetPin >= 0) - { - digitalWrite(redLED, HIGH); - digitalWrite(modemResetPin, LOW); - delay(1); - digitalWrite(modemResetPin, HIGH); - success &= ESPwaitForBoot(); - if (!success) - { - digitalWrite(redLED, LOW); // Turn off light if the boot failed - } - return success; - } - else if (modemSleepRqPin >= 0) - { - digitalWrite(modemSleepRqPin, LOW); - delay(1); - digitalWrite(modemSleepRqPin, HIGH); - digitalWrite(redLED, HIGH); - // Don't have to wait for a boot if using light sleep - return true; - } - else - { - return true; - } -} -// Set up the light-sleep status pin, if applicable -void extraModemSetup(void) -{ - // Slow down the baud rate for slow processors - and save the change to - // the ESP's non-volatile memory so we don't have to do it every time - #if F_CPU == 8000000L - if (modemBaud > 57600) - { - modemSerial.begin(modemBaud); - tinyModem.sendAT(F("+UART_DEF=9600,8,1,0,0")); - tinyModem.waitResponse(); - modemSerial.end(); - modemSerial.begin(9600); - } - #endif - if (modemVccPin < 0 && modemResetPin < 0 && modemSleepRqPin >= 0 && modemStatusPin >= 0) - { - tinyModem.sendAT(F("+WAKEUPGPIO=1,"), String(espSleepRqPin), F(",0,"), - String(espStatusPin), ',', modemStatusLevel); - tinyModem.waitResponse(); - } -} - - -// ========================================================================== -// Network Information and LoggerModem Object -// ========================================================================== -#include +// Modem Pins - Describe the physical pin connection of your modem to your board +const int8_t modemVccPin = -2; // MCU pin controlling modem power (-1 if not applicable) +const int8_t modemStatusPin = 19; // MCU pin used to read modem status (-1 if not applicable) +const int8_t modemResetPin = 20; // MCU pin connected to modem reset pin (-1 if unconnected) +const int8_t modemSleepRqPin = 23; // MCU pin used for modem sleep/wake request (-1 if not applicable) +const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem status (-1 if unconnected) // Network connection information -const char *apn = "xxxxx"; // The APN for the gprs connection, unnecessary for WiFi -const char *wifiId = "xxxxx"; // The WiFi access point, unnecessary for gprs -const char *wifiPwd = "xxxxx"; // The password for connecting to WiFi, unnecessary for gprs - -// Create the loggerModem instance -// A "loggerModem" is a combination of a TinyGSM Modem, a Client, and functions for wake and sleep -loggerModem modem(modemVccPin, modemStatusPin, modemStatusLevel, modemWakeFxn, modemSleepFxn, &tinyModem, &tinyClient, wifiId, wifiPwd); +const char *wifiId = "xxxxx"; // The WiFi access point +const char *wifiPwd = "xxxxx"; // The password for connecting to WiFi + +// For almost anything based on the Espressif ESP8266 using the AT command firmware +#include +const long modemBaud = 115200; // Communication speed of the modem +// NOTE: This baud rate too fast for an 8MHz board, like the Mayfly! The module +// should be programmed to a slower baud rate or set to auto-baud using the +// AT+UART_CUR or AT+UART_DEF command. +// Pins for light sleep on the ESP8266. +// For power savings, I recommend NOT using these if it's possible to use deep sleep. +const int8_t espSleepRqPin = -1; // Pin ON THE ESP8266 to assign for light sleep request (-1 if not applicable) +const int8_t espStatusPin = -1; // Pin ON THE ESP8266 to assign for light sleep status (-1 if not applicable) +EspressifESP8266 modemESP(&modemSerial, + modemVccPin, modemStatusPin, + modemResetPin, modemSleepRqPin, + wifiId, wifiPwd, + 1, // measurements to average, optional + espSleepRqPin, espStatusPin // Optional arguments + ); +// Create an extra reference to the modem by a generic name (not necessary) +EspressifESP8266 modem = modemESP; // ========================================================================== @@ -277,12 +109,12 @@ MaximDS3231 ds3231(1); // ========================================================================== -// CAMPBELL OBS 3 / OBS 3+ Analog Turbidity Sensor +// Campbell OBS 3 / OBS 3+ Analog Turbidity Sensor // ========================================================================== #include const int8_t OBS3Power = sensorPowerPin; // Pin to switch power on and off (-1 if unconnected) -const uint8_t OBS3numberReadings = 10; +const uint8_t OBS3NumberReadings = 10; const uint8_t ADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC // Campbell OBS 3+ Low Range calibration in Volts const int8_t OBSLowADSChannel = 0; // The ADS channel for the low range output @@ -291,7 +123,7 @@ const float OBSLow_B = 1.000E+00; // The "B" value (X) from the low range calib const float OBSLow_C = 0.000E+00; // The "C" value from the low range calibration // Create a Campbell OBS3+ LOW RANGE sensor object -CampbellOBS3 osb3low(OBS3Power, OBSLowADSChannel, OBSLow_A, OBSLow_B, OBSLow_C, ADSi2c_addr, OBS3numberReadings); +CampbellOBS3 osb3low(OBS3Power, OBSLowADSChannel, OBSLow_A, OBSLow_B, OBSLow_C, ADSi2c_addr, OBS3NumberReadings); // Campbell OBS 3+ High Range calibration in Volts @@ -301,7 +133,7 @@ const float OBSHigh_B = 1.000E+00; // The "B" value (X) from the high range cal const float OBSHigh_C = 0.000E+00; // The "C" value from the high range calibration // Create a Campbell OBS3+ HIGH RANGE sensor object -CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHigh_C, ADSi2c_addr, OBS3numberReadings); +CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHigh_C, ADSi2c_addr, OBS3NumberReadings); // ========================================================================== @@ -310,12 +142,12 @@ CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHig #include const char *CTDSDI12address = "1"; // The SDI-12 Address of the CTD -const uint8_t CTDnumberReadings = 6; // The number of readings to average +const uint8_t CTDNumberReadings = 6; // The number of readings to average const int8_t SDI12Power = sensorPowerPin; // Pin to switch power on and off (-1 if unconnected) const int8_t SDI12Data = 7; // The SDI12 data pin // Create a Decagon CTD sensor object -DecagonCTD ctd(*CTDSDI12address, SDI12Power, SDI12Data, CTDnumberReadings); +DecagonCTD ctd(*CTDSDI12address, SDI12Power, SDI12Data, CTDNumberReadings); // ========================================================================== @@ -440,16 +272,6 @@ void setup() pinMode(sensorPowerPin, OUTPUT); digitalWrite(sensorPowerPin, LOW); } - if (modemSleepRqPin >= 0) - { - pinMode(modemSleepRqPin, OUTPUT); - digitalWrite(modemSleepRqPin, HIGH); - } - if (modemResetPin >= 0) - { - pinMode(modemResetPin, OUTPUT); - digitalWrite(modemResetPin, HIGH); - } // Set the timezone and offsets // Logging in the given time zone @@ -459,6 +281,7 @@ void setup() // Attach the modem and information pins to the logger dataLogger.attachModem(modem); + modem.setModemLED(modemLEDPin); dataLogger.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); // Begin the variable array[s], logger[s], and publisher[s] @@ -477,7 +300,7 @@ void setup() // Note: Please change these battery voltages to match your battery if (getBatteryVoltage() > 3.8 || dataLogger.getNowEpoch() < 1546300800 || /*Before 01/01/2019*/ - dataLogger.getNowEpoch() > 1735689600) /*Before 1/1/2025*/ + dataLogger.getNowEpoch() > 1735689600) /*After 1/1/2025*/ { // Synchronize the RTC with NIST Serial.println(F("Attempting to synchronize RTC with NIST")); diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 45ae72fc8..c241ed837 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -169,52 +169,29 @@ void SERCOM2_Handler() // ========================================================================== -// Wifi/Cellular Modems +// Wifi/Cellular Modem Settings // ========================================================================== -// ========================================================================== -// Modem Pins -// ========================================================================== +// Create a reference to the serial port for the modem +// Extra hardware and software serial ports are created in the "Settings for Additional Serial Ports" section +HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible +// AltSoftSerial &modemSerial = altSoftSerial; // For software serial if needed +// NeoSWSerial &modemSerial = neoSSerial1; // For software serial if needed + -// Describe the physical pin connection of your modem to your board +// Modem Pins - Describe the physical pin connection of your modem to your board const int8_t modemVccPin = -2; // MCU pin controlling modem power (-1 if not applicable) const int8_t modemStatusPin = 19; // MCU pin used to read modem status (-1 if not applicable) -const int8_t modemResetPin = A4; // MCU pin connected to modem reset pin (-1 if unconnected) +const int8_t modemResetPin = 20; // MCU pin connected to modem reset pin (-1 if unconnected) const int8_t modemSleepRqPin = 23; // MCU pin used for modem sleep/wake request (-1 if not applicable) -const bool useCTSforStatus = true; // Flag to use the modem CTS pin for status. Only applies to Digi XBee's const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem status (-1 if unconnected) - -// ========================================================================== -// Network Information -// ========================================================================== - // Network connection information const char *apn = "xxxxx"; // The APN for the gprs connection, unnecessary for WiFi const char *wifiId = "xxxxx"; // The WiFi access point, unnecessary for gprs const char *wifiPwd = "xxxxx"; // The password for connecting to WiFi, unnecessary for gprs -// ========================================================================== -// Modem Serial Port and Baud Rate -// ========================================================================== - -// Create a reference to the serial port for the modem -// Extra hardware and software serial ports are created in the "Settings for Additional Serial Ports" section -HardwareSerial &modemSerial = Serial1; // Use hardware serial if possible -// AltSoftSerial &modemSerial = altSoftSerial; // For software serial if needed -// NeoSWSerial &modemSerial = neoSSerial1; // For software serial if needed - -// Use this to create a modem if you want to spy on modem communication through -// a secondary Arduino stream. Make sure you install the StreamDebugger library! -// https://github.com/vshymanskyy/StreamDebugger -// Also make sure you comment out the serial port above -// #include -// StreamDebugger modemSerial(Serial1, Serial); - -const long modemBaud = 9600; // Communication speed of the modem - - // ========================================================================== // The modem object // Note: Don't use more than one! @@ -224,90 +201,149 @@ const long modemBaud = 9600; // Communication speed of the modem // NOTE: According to the manual, this should be less stable than transparent // mode, but my experience is the complete reverse. #include -DigiXBeeCellularBypass modem(&modemSerial, - modemVccPin, modemStatusPin, useCTSforStatus, - modemResetPin, modemSleepRqPin, - apn); - -// For any Digi Cellular XBee's -// NOTE: The u-blox based Digi XBee's (3G global and LTE-M global) -// are more stable used in bypass mode (above) -// The Telit based Digi XBees (LTE Cat1) can only use this mode. +const long modemBaud = 9600; // All XBee's use 9600 by default +const bool useCTSforStatus = true; // Flag to use the modem CTS pin for status +DigiXBeeCellularBypass modemXBCB(&modemSerial, + modemVccPin, modemStatusPin, useCTSforStatus, + modemResetPin, modemSleepRqPin, + apn); +// Create an extra reference to the modem by a generic name (not necessary) +DigiXBeeCellularBypass modem = modemXBCB; +// ========================================================================== + +// // For any Digi Cellular XBee's +// // NOTE: The u-blox based Digi XBee's (3G global and LTE-M global) +// // are more stable used in bypass mode (above) +// // The Telit based Digi XBees (LTE Cat1) can only use this mode. // #include -// DigiXBeeCellularTransparent modem(&modemSerial, -// modemVccPin, modemStatusPin, useCTSforStatus, -// modemResetPin, modemSleepRqPin, -// apn); - -// For the Digi Wifi XBee (S6B) +// const long modemBaud = 9600; // All XBee's use 9600 by default +// const bool useCTSforStatus = true; // Flag to use the modem CTS pin for status +// DigiXBeeCellularTransparent modemXBCT(&modemSerial, +// modemVccPin, modemStatusPin, useCTSforStatus, +// modemResetPin, modemSleepRqPin, +// apn); +// // Create an extra reference to the modem by a generic name (not necessary) +// DigiXBeeCellularTransparent modem = modemXBCT; +// // ========================================================================== + +// // For the Digi Wifi XBee (S6B) // #include -// DigiXBeeWifi modem(&modemSerial, -// modemVccPin, modemStatusPin, useCTSforStatus, -// modemResetPin, modemSleepRqPin, -// wifiId, wifiPwd); +// const long modemBaud = 9600; // All XBee's use 9600 by default +// const bool useCTSforStatus = true; // Flag to use the modem CTS pin for status +// DigiXBeeWifi modemXBWF(&modemSerial, +// modemVccPin, modemStatusPin, useCTSforStatus, +// modemResetPin, modemSleepRqPin, +// wifiId, wifiPwd); +// // Create an extra reference to the modem by a generic name (not necessary) +// DigiXBeeWifi modem = modemXBWF; +// // ========================================================================== -// For almost anything based on the Espressif ESP8266 using the AT command firmware +// // For almost anything based on the Espressif ESP8266 using the AT command firmware // #include +// const long modemBaud = 115200; // Communication speed of the modem +// // NOTE: This baud rate too fast for an 8MHz board, like the Mayfly! The module +// // should be programmed to a slower baud rate or set to auto-baud using the +// // AT+UART_CUR or AT+UART_DEF command. // // Pins for light sleep on the ESP8266. // // For power savings, I recommend NOT using these if it's possible to use deep sleep. // const int8_t espSleepRqPin = -1; // Pin ON THE ESP8266 to assign for light sleep request (-1 if not applicable) // const int8_t espStatusPin = -1; // Pin ON THE ESP8266 to assign for light sleep status (-1 if not applicable) -// EspressifESP8266 modem(&modemSerial, -// modemVccPin, modemStatusPin, -// modemResetPin, modemSleepRqPin, -// wifiId, wifiPwd, -// 1, // measurements to average, optional -// espSleepRqPin, espStatusPin // Optional arguments -// ); - -// For the Dragino, Nimbelink or other boards based on the Quectel BG96 +// EspressifESP8266 modemESP(&modemSerial, +// modemVccPin, modemStatusPin, +// modemResetPin, modemSleepRqPin, +// wifiId, wifiPwd, +// 1, // measurements to average, optional +// espSleepRqPin, espStatusPin // Optional arguments +// ); +// // Create an extra reference to the modem by a generic name (not necessary) +// EspressifESP8266 modem = modemESP; +// // ========================================================================== + +// // For the Dragino, Nimbelink or other boards based on the Quectel BG96 // #include -// QuectelBG96 modem(&modemSerial, -// modemVccPin, modemStatusPin, -// modemResetPin, modemSleepRqPin, -// apn); - -// For the Nimbelink LTE-M Verizon/Sequans or other boards based on the Sequans Monarch series +// const long modemBaud = 115200; // Communication speed of the modem +// QuectelBG96 modemBG96(&modemSerial, +// modemVccPin, modemStatusPin, +// modemResetPin, modemSleepRqPin, +// apn); +// // Create an extra reference to the modem by a generic name (not necessary) +// QuectelBG96 modem = modemBG96; +// // ========================================================================== + +// // For the Nimbelink LTE-M Verizon/Sequans or other boards based on the Sequans Monarch series // #include -// SequansMonarch modem(&modemSerial, -// modemVccPin, modemStatusPin, -// modemResetPin, modemSleepRqPin, -// apn); - -// For almost anything based on the SIMCom SIM800 EXCEPT the Sodaq 2GBee R6 and higher +// const long modemBaud = 921600; // Default baud rate of SVZM20 is 921600 +// // NOTE: This baud rate is much too fast for many Arduinos! The module should +// // be programmed to a slower baud rate or set to auto-baud using the AT+IPR command. +// SequansMonarch modemSVZM(&modemSerial, +// modemVccPin, modemStatusPin, +// modemResetPin, modemSleepRqPin, +// apn); +// // Create an extra reference to the modem by a generic name (not necessary) +// SequansMonarch modem = modemSVZM; +// // ========================================================================== + +// // For almost anything based on the SIMCom SIM800 EXCEPT the Sodaq 2GBee R6 and higher // #include -// SIMComSIM800 modem(&modemSerial, -// modemVccPin, modemStatusPin, -// modemResetPin, modemSleepRqPin, -// apn); +// const long modemBaud = 9600; // SIM800 does auto-bauding by default +// SIMComSIM800 modemS800(&modemSerial, +// modemVccPin, modemStatusPin, +// modemResetPin, modemSleepRqPin, +// apn); +// // Create an extra reference to the modem by a generic name (not necessary) +// SIMComSIM800 modem = modemS800; +// // ========================================================================== -// For almost anything based on the SIMCom SIM7000 +// // For almost anything based on the SIMCom SIM7000 // #include -// SIMComSIM7000 modem(&modemSerial, -// modemVccPin, modemStatusPin, -// modemResetPin, modemSleepRqPin, -// apn); - -// For the Sodaq 2GBee R6 and R7 based on the SIMCom SIM800 +// const long modemBaud = 9600; // SIM7000 does auto-bauding by default +// SIMComSIM7000 modem7000(&modemSerial, +// modemVccPin, modemStatusPin, +// modemResetPin, modemSleepRqPin, +// apn); +// // Create an extra reference to the modem by a generic name (not necessary) +// SIMComSIM7000 modem = modem7000; +// // ========================================================================== + +// // For the Sodaq 2GBee R6 and R7 based on the SIMCom SIM800 +// // NOTE: The Sodaq GPRSBee doesn't expose the SIM800's reset pin // #include -// Sodaq2GBeeR6 modem(&modemSerial, -// modemVccPin, modemStatusPin, -// modemResetPin, modemSleepRqPin, -// apn); +// const long modemBaud = 9600; // SIM800 does auto-bauding by default +// Sodaq2GBeeR6 modem2GB(&modemSerial, +// modemVccPin, modemStatusPin, +// modemSleepRqPin, +// apn); +// // Create an extra reference to the modem by a generic name (not necessary) +// Sodaq2GBeeR6 modem = modem2GB; +// // ========================================================================== // For the Sodaq UBee based on the 4G LTE-M u-blox SARA R410M // #include -// SodaqUBeeR410M modem(&modemSerial, -// modemVccPin, modemStatusPin, -// modemResetPin, modemSleepRqPin, -// apn); - -// For the Sodaq UBee based on the 3G u-blox SARA U201 +// const long modemBaud = 115200; // Default baud rate of the SARA R410M is 115200 +// // NOTE: The SARA R410N DOES NOT save baud rate to non-volatile memory. After +// // every power loss, the module will return to the default baud rate of 115200. +// // NOTE: 115200 is TOO FAST for an 8MHz Arduino. This library attempts to +// // compensate by sending a baud rate change command in the wake function. +// // YMMV! +// SodaqUBeeR410M modemR410(&modemSerial, +// modemVccPin, modemStatusPin, +// modemResetPin, modemSleepRqPin, +// apn); +// // Create an extra reference to the modem by a generic name (not necessary) +// SodaqUBeeR410M modem = modemR410; +// // ========================================================================== + +// // For the Sodaq UBee based on the 3G u-blox SARA U201 // #include -// SodaqUBeeU201 modem(&modemSerial, -// modemVccPin, modemStatusPin, -// modemResetPin, modemSleepRqPin, -// apn); +// const long modemBaud = 9600; // SARA U2xx module does auto-bauding by default +// SodaqUBeeU201 modemU201(&modemSerial, +// modemVccPin, modemStatusPin, +// modemResetPin, modemSleepRqPin, +// apn); +// // Create an extra reference to the modem by a generic name (not necessary) +// SodaqUBeeU201 modem = modemU201; +// // ========================================================================== + // Create RSSI and signal strength variable pointers for the modem // Variable *modemRSSI = new Modem_RSSI(&modem, "12345678-abcd-1234-efgh-1234567890ab"); @@ -515,12 +551,12 @@ BoschBME280 bme280(I2CPower, BMEi2c_addr); // ========================================================================== -// CAMPBELL OBS 3 / OBS 3+ Analog Turbidity Sensor +// Campbell OBS 3 / OBS 3+ Analog Turbidity Sensor // ========================================================================== #include const int8_t OBS3Power = sensorPowerPin; // Pin to switch power on and off (-1 if unconnected) -const uint8_t OBS3numberReadings = 10; +const uint8_t OBS3NumberReadings = 10; // const uint8_t ADSi2c_addr = 0x48; // The I2C address of the ADS1115 ADC // Campbell OBS 3+ Low Range calibration in Volts const int8_t OBSLowADSChannel = 0; // The ADS channel for the low range output @@ -529,7 +565,7 @@ const float OBSLow_B = 1.000E+00; // The "B" value (X) from the low range calib const float OBSLow_C = 0.000E+00; // The "C" value from the low range calibration // Create a Campbell OBS3+ LOW RANGE sensor object -CampbellOBS3 osb3low(OBS3Power, OBSLowADSChannel, OBSLow_A, OBSLow_B, OBSLow_C, ADSi2c_addr, OBS3numberReadings); +CampbellOBS3 osb3low(OBS3Power, OBSLowADSChannel, OBSLow_A, OBSLow_B, OBSLow_C, ADSi2c_addr, OBS3NumberReadings); // Create turbidity and voltage variable pointers for the low range of the OBS3 // Variable *obs3TurbLow = new CampbellOBS3_Turbidity(&osb3low, "12345678-abcd-1234-efgh-1234567890ab"); @@ -543,7 +579,7 @@ const float OBSHigh_B = 1.000E+00; // The "B" value (X) from the high range cal const float OBSHigh_C = 0.000E+00; // The "C" value from the high range calibration // Create a Campbell OBS3+ HIGH RANGE sensor object -CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHigh_C, ADSi2c_addr, OBS3numberReadings); +CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHigh_C, ADSi2c_addr, OBS3NumberReadings); // Create turbidity and voltage variable pointers for the high range of the OBS3 // Variable *obs3TurbHigh = new CampbellOBS3_Turbidity(&osb3high, "12345678-abcd-1234-efgh-1234567890ab"); @@ -575,12 +611,12 @@ Decagon5TM fivetm(*TMSDI12address, SDI12Power, SDI12Data); #include const char *CTDSDI12address = "1"; // The SDI-12 Address of the CTD -const uint8_t CTDnumberReadings = 6; // The number of readings to average +const uint8_t CTDNumberReadings = 6; // The number of readings to average // const int8_t SDI12Power = sensorPowerPin; // Pin to switch power on and off (-1 if unconnected) // const int8_t SDI12Data = 7; // The SDI12 data pin // Create a Decagon CTD sensor object -DecagonCTD ctd(*CTDSDI12address, SDI12Power, SDI12Data, CTDnumberReadings); +DecagonCTD ctd(*CTDSDI12address, SDI12Power, SDI12Data, CTDNumberReadings); // Create conductivity, temperature, and depth variable pointers for the CTD // Variable *ctdCond = new DecagonCTD_Cond(&ctd, "12345678-abcd-1234-efgh-1234567890ab"); @@ -1233,17 +1269,13 @@ EnviroDIYPublisher EnviroDIYPOST(dataLogger, registrationToken, samplingFeature) // A Publisher to DreamHost // ========================================================================== // NOTE: This is an outdated data collection tool used by the Stroud Center. -// It us unlikely that you will use this. +// It very, very unlikely that you will use this. const char * DreamHostPortalRX = "xxxx"; // Create a data publisher to DreamHost #include -#if defined USE_UBLOX_R410M -DreamHostPublisher DreamHostGET(dataLogger, tinyClient2, DreamHostPortalRX); -#else DreamHostPublisher DreamHostGET(dataLogger, DreamHostPortalRX); -#endif // ========================================================================== @@ -1260,11 +1292,7 @@ const char *thingSpeakChannelKey = "XXXXXXXXXXXXXXXX"; // The Write API Key for // Create a data publisher for ThingSpeak #include -#if defined USE_UBLOX_R410M -ThingSpeakPublisher TsMqtt(dataLogger, tinyClient3, thingSpeakMQTTKey, thingSpeakChannelID, thingSpeakChannelKey); -#else ThingSpeakPublisher TsMqtt(dataLogger, thingSpeakMQTTKey, thingSpeakChannelID, thingSpeakChannelKey); -#endif // ========================================================================== @@ -1420,8 +1448,10 @@ void setup() varArray.setupSensors(); } - // Power down the modem - modem.modemSleepPowerDown(); + // Power down the modem - but only if there will be more than 15 seconds before + // the first logging interval - it can take the modem that long to shut down + if (Logger::getNowEpoch() % (loggingInterval*60) > 15) + modem.modemSleepPowerDown(); // Create the log file, adding the default header to it // Do this last so we have the best chance of getting the time correct and From 08ca9f1daa97942ee48ddc293a17ecfe2d02e632 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 16 May 2019 10:39:43 -0400 Subject: [PATCH 20/88] Renamed processor battery var --- examples/DRWI_CitSci/DRWI_CitSci.ino | 2 +- examples/DRWI_CitSci/ReadMe.md | 4 ++-- examples/DRWI_LTE/DRWI_LTE.ino | 2 +- examples/DRWI_LTE/ReadMe.md | 4 ++-- examples/DRWI_NoCellular/DRWI_NoCellular.ino | 2 +- examples/DRWI_NoCellular/ReadMe.md | 4 ++-- examples/baro_rho_correction/baro_rho_correction.ino | 2 +- examples/data_saving/data_saving.ino | 2 +- examples/double_logger/double_logger.ino | 2 +- examples/logging_to_MMW/logging_to_MMW.ino | 2 +- examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino | 2 +- examples/menu_a_la_carte/menu_a_la_carte.ino | 4 ++-- examples/simple_logging/simple_logging.ino | 2 +- .../simple_logging_LearnEnviroDIY.ino | 2 +- src/sensors/ProcessorStats.h | 8 ++++---- 15 files changed, 22 insertions(+), 22 deletions(-) diff --git a/examples/DRWI_CitSci/DRWI_CitSci.ino b/examples/DRWI_CitSci/DRWI_CitSci.ino index fe9c7eeac..e0a4a1411 100644 --- a/examples/DRWI_CitSci/DRWI_CitSci.ino +++ b/examples/DRWI_CitSci/DRWI_CitSci.ino @@ -151,7 +151,7 @@ Variable *variableList[] = { new DecagonCTD_Depth(&ctd, "12345678-abcd-1234-efgh-1234567890ab"), new CampbellOBS3_Turbidity(&osb3low, "12345678-abcd-1234-efgh-1234567890ab", "TurbLow"), new CampbellOBS3_Turbidity(&osb3high, "12345678-abcd-1234-efgh-1234567890ab", "TurbHigh"), - new ProcessorStats_Batt(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"), + new ProcessorStats_Battery(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"), new MaximDS3231_Temp(&ds3231, "12345678-abcd-1234-efgh-1234567890ab"), new Modem_RSSI(&modem, "12345678-abcd-1234-efgh-1234567890ab"), new Modem_SignalPercent(&modem, "12345678-abcd-1234-efgh-1234567890ab"), diff --git a/examples/DRWI_CitSci/ReadMe.md b/examples/DRWI_CitSci/ReadMe.md index a766822ac..8b7642673 100644 --- a/examples/DRWI_CitSci/ReadMe.md +++ b/examples/DRWI_CitSci/ReadMe.md @@ -55,14 +55,14 @@ CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHig - Change _**all**_ of the the ```"12345678-abcd-1234-efgh-1234567890ab"``` values in this section of code to the values shown on the EnviroDIY data portal for your variables. - After you register your site and variables, you should see a group of empty plots on the page for your site. The plots have titles like "Temperature" and below the plot will be a list of the "Medium", "Sensor", and "UUID" for that variable. - Copy the appropriate UUID from below each plot to its proper place in this section of the code. - - For example, the ```"12345678-abcd-1234-efgh-1234567890ab"``` in the first line (```new ProcessorStats_Batt(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab")```) should be replaced by the UUID listed under the plot titled "Battery Voltage" with the sensor listed below as "EnviroDIY_Mayfly Data Logger". + - For example, the ```"12345678-abcd-1234-efgh-1234567890ab"``` in the first line (```new ProcessorStats_Battery(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab")```) should be replaced by the UUID listed under the plot titled "Battery Voltage" with the sensor listed below as "EnviroDIY_Mayfly Data Logger". ```cpp // ========================================================================== // Creating the Variable Array[s] and Filling with Variable Objects // ========================================================================== Variable *variableList[] = { - new ProcessorStats_Batt(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"), + new ProcessorStats_Battery(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"), new MaximDS3231_Temp(&ds3231, "12345678-abcd-1234-efgh-1234567890ab"), new DecagonCTD_Cond(&ctd, "12345678-abcd-1234-efgh-1234567890ab"), new DecagonCTD_Temp(&ctd, "12345678-abcd-1234-efgh-1234567890ab"), diff --git a/examples/DRWI_LTE/DRWI_LTE.ino b/examples/DRWI_LTE/DRWI_LTE.ino index 8dcc7206e..aedd86c81 100644 --- a/examples/DRWI_LTE/DRWI_LTE.ino +++ b/examples/DRWI_LTE/DRWI_LTE.ino @@ -154,7 +154,7 @@ Variable *variableList[] = { new DecagonCTD_Depth(&ctd, "12345678-abcd-1234-efgh-1234567890ab"), new CampbellOBS3_Turbidity(&osb3low, "12345678-abcd-1234-efgh-1234567890ab", "TurbLow"), new CampbellOBS3_Turbidity(&osb3high, "12345678-abcd-1234-efgh-1234567890ab", "TurbHigh"), - new ProcessorStats_Batt(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"), + new ProcessorStats_Battery(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"), new MaximDS3231_Temp(&ds3231, "12345678-abcd-1234-efgh-1234567890ab"), new Modem_RSSI(&modem, "12345678-abcd-1234-efgh-1234567890ab"), new Modem_SignalPercent(&modem, "12345678-abcd-1234-efgh-1234567890ab"), diff --git a/examples/DRWI_LTE/ReadMe.md b/examples/DRWI_LTE/ReadMe.md index 696eca55e..d8923366c 100644 --- a/examples/DRWI_LTE/ReadMe.md +++ b/examples/DRWI_LTE/ReadMe.md @@ -55,14 +55,14 @@ CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHig - Change _**all**_ of the the ```"12345678-abcd-1234-efgh-1234567890ab"``` values in this section of code to the values shown on the EnviroDIY data portal for your variables. - After you register your site and variables, you should see a group of empty plots on the page for your site. The plots have titles like "Temperature" and below the plot will be a list of the "Medium", "Sensor", and "UUID" for that variable. - Copy the appropriate UUID from below each plot to its proper place in this section of the code. - - For example, the ```"12345678-abcd-1234-efgh-1234567890ab"``` in the first line (```new ProcessorStats_Batt(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab")```) should be replaced by the UUID listed under the plot titled "Battery Voltage" with the sensor listed below as "EnviroDIY_Mayfly Data Logger". + - For example, the ```"12345678-abcd-1234-efgh-1234567890ab"``` in the first line (```new ProcessorStats_Battery(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab")```) should be replaced by the UUID listed under the plot titled "Battery Voltage" with the sensor listed below as "EnviroDIY_Mayfly Data Logger". ```cpp // ========================================================================== // Creating the Variable Array[s] and Filling with Variable Objects // ========================================================================== Variable *variableList[] = { - new ProcessorStats_Batt(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"), + new ProcessorStats_Battery(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"), new MaximDS3231_Temp(&ds3231, "12345678-abcd-1234-efgh-1234567890ab"), new DecagonCTD_Cond(&ctd, "12345678-abcd-1234-efgh-1234567890ab"), new DecagonCTD_Temp(&ctd, "12345678-abcd-1234-efgh-1234567890ab"), diff --git a/examples/DRWI_NoCellular/DRWI_NoCellular.ino b/examples/DRWI_NoCellular/DRWI_NoCellular.ino index 85aa1b974..f80a6463d 100644 --- a/examples/DRWI_NoCellular/DRWI_NoCellular.ino +++ b/examples/DRWI_NoCellular/DRWI_NoCellular.ino @@ -123,7 +123,7 @@ Variable *variableList[] = { new DecagonCTD_Depth(&ctd, "12345678-abcd-1234-efgh-1234567890ab"), new CampbellOBS3_Turbidity(&osb3low, "12345678-abcd-1234-efgh-1234567890ab", "TurbLow"), new CampbellOBS3_Turbidity(&osb3high, "12345678-abcd-1234-efgh-1234567890ab", "TurbHigh"), - new ProcessorStats_Batt(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"), + new ProcessorStats_Battery(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"), new MaximDS3231_Temp(&ds3231, "12345678-abcd-1234-efgh-1234567890ab") }; // Count up the number of pointers in the array diff --git a/examples/DRWI_NoCellular/ReadMe.md b/examples/DRWI_NoCellular/ReadMe.md index f42a684a5..4d8bbb682 100644 --- a/examples/DRWI_NoCellular/ReadMe.md +++ b/examples/DRWI_NoCellular/ReadMe.md @@ -55,14 +55,14 @@ CampbellOBS3 osb3high(OBS3Power, OBSHighADSChannel, OBSHigh_A, OBSHigh_B, OBSHig - Change _**all**_ of the the ```"12345678-abcd-1234-efgh-1234567890ab"``` values in this section of code to the values shown on the EnviroDIY data portal for your variables. - After you register your site and variables, you should see a group of empty plots on the page for your site. The plots have titles like "Temperature" and below the plot will be a list of the "Medium", "Sensor", and "UUID" for that variable. - Copy the appropriate UUID from below each plot to its proper place in this section of the code. - - For example, the ```"12345678-abcd-1234-efgh-1234567890ab"``` in the first line (```new ProcessorStats_Batt(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab")```) should be replaced by the UUID listed under the plot titled "Battery Voltage" with the sensor listed below as "EnviroDIY_Mayfly Data Logger". + - For example, the ```"12345678-abcd-1234-efgh-1234567890ab"``` in the first line (```new ProcessorStats_Battery(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab")```) should be replaced by the UUID listed under the plot titled "Battery Voltage" with the sensor listed below as "EnviroDIY_Mayfly Data Logger". ```cpp // ========================================================================== // Creating the Variable Array[s] and Filling with Variable Objects // ========================================================================== Variable *variableList[] = { - new ProcessorStats_Batt(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"), + new ProcessorStats_Battery(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"), new MaximDS3231_Temp(&ds3231, "12345678-abcd-1234-efgh-1234567890ab"), new DecagonCTD_Cond(&ctd, "12345678-abcd-1234-efgh-1234567890ab"), new DecagonCTD_Temp(&ctd, "12345678-abcd-1234-efgh-1234567890ab"), diff --git a/examples/baro_rho_correction/baro_rho_correction.ino b/examples/baro_rho_correction/baro_rho_correction.ino index 43133572a..d6ec9a26c 100644 --- a/examples/baro_rho_correction/baro_rho_correction.ino +++ b/examples/baro_rho_correction/baro_rho_correction.ino @@ -60,7 +60,7 @@ const char *mcuBoardVersion = "v0.5b"; ProcessorStats mcuBoard(mcuBoardVersion); // Create sample number, battery voltage, and free RAM variable pointers for the processor -Variable *mcuBoardBatt = new ProcessorStats_Batt(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"); +Variable *mcuBoardBatt = new ProcessorStats_Battery(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"); Variable *mcuBoardAvailableRAM = new ProcessorStats_FreeRam(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"); Variable *mcuBoardSampNo = new ProcessorStats_SampleNumber(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"); diff --git a/examples/data_saving/data_saving.ino b/examples/data_saving/data_saving.ino index 7ae031618..c59ef0c8b 100644 --- a/examples/data_saving/data_saving.ino +++ b/examples/data_saving/data_saving.ino @@ -60,7 +60,7 @@ const char *mcuBoardVersion = "v0.5b"; ProcessorStats mcuBoard(mcuBoardVersion); // Create sample number, battery voltage, and free RAM variable pointers for the processor -Variable *mcuBoardBatt = new ProcessorStats_Batt(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"); +Variable *mcuBoardBatt = new ProcessorStats_Battery(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"); Variable *mcuBoardAvailableRAM = new ProcessorStats_FreeRam(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"); Variable *mcuBoardSampNo = new ProcessorStats_SampleNumber(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"); diff --git a/examples/double_logger/double_logger.ino b/examples/double_logger/double_logger.ino index b294cc8d7..11380b47a 100644 --- a/examples/double_logger/double_logger.ino +++ b/examples/double_logger/double_logger.ino @@ -133,7 +133,7 @@ VariableArray array1min; // The variables to record at 5 minute intervals Variable *variableList_at5min[] = { new MaximDS3231_Temp(&ds3231), - new ProcessorStats_Batt(&mcuBoard), + new ProcessorStats_Battery(&mcuBoard), new ProcessorStats_FreeRam(&mcuBoard) }; // Count up the number of pointers in the 5-minute array diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index 09d533495..413b82421 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -146,7 +146,7 @@ Variable *variableList[] = { new BoschBME280_Pressure(&bme280, "12345678-abcd-1234-efgh-1234567890ab"), new BoschBME280_Altitude(&bme280, "12345678-abcd-1234-efgh-1234567890ab"), new MaximDS18_Temp(&ds18, "12345678-abcd-1234-efgh-1234567890ab"), - new ProcessorStats_Batt(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"), + new ProcessorStats_Battery(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"), new MaximDS3231_Temp(&ds3231, "12345678-abcd-1234-efgh-1234567890ab"), new Modem_RSSI(&modem, "12345678-abcd-1234-efgh-1234567890ab"), new Modem_SignalPercent(&modem, "12345678-abcd-1234-efgh-1234567890ab"), diff --git a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino index a9d13c0d2..087188c2b 100644 --- a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino +++ b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino @@ -161,7 +161,7 @@ Variable *variableList[] = { new DecagonCTD_Depth(&ctd, "12345678-abcd-1234-efgh-1234567890ab"), new CampbellOBS3_Turbidity(&osb3low, "12345678-abcd-1234-efgh-1234567890ab", "TurbLow"), new CampbellOBS3_Turbidity(&osb3high, "12345678-abcd-1234-efgh-1234567890ab", "TurbHigh"), - new ProcessorStats_Batt(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"), + new ProcessorStats_Battery(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"), new MaximDS3231_Temp(&ds3231, "12345678-abcd-1234-efgh-1234567890ab"), new Modem_RSSI(&modem, "12345678-abcd-1234-efgh-1234567890ab") }; diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index c241ed837..6fb77b127 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -59,7 +59,7 @@ const char *mcuBoardVersion = "v0.5b"; ProcessorStats mcuBoard(mcuBoardVersion); // Create sample number, battery voltage, and free RAM variable pointers for the processor -// Variable *mcuBoardBatt = new ProcessorStats_Batt(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"); +// Variable *mcuBoardBatt = new ProcessorStats_Battery(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"); // Variable *mcuBoardAvailableRAM = new ProcessorStats_FreeRam(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"); // Variable *mcuBoardSampNo = new ProcessorStats_SampleNumber(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"); @@ -1214,7 +1214,7 @@ Variable *variableList[] = { new ZebraTechDOpto_DOpct(&dopto, "12345678-abcd-1234-efgh-1234567890ab"), new ZebraTechDOpto_DOmgL(&dopto, "12345678-abcd-1234-efgh-1234567890ab"), new ProcessorStats_FreeRam(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"), - new ProcessorStats_Batt(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"), + new ProcessorStats_Battery(&mcuBoard, "12345678-abcd-1234-efgh-1234567890ab"), new MaximDS3231_Temp(&ds3231, "12345678-abcd-1234-efgh-1234567890ab"), new Modem_RSSI(&modem, "12345678-abcd-1234-efgh-1234567890ab"), new Modem_SignalPercent(&modem, "12345678-abcd-1234-efgh-1234567890ab"), diff --git a/examples/simple_logging/simple_logging.ino b/examples/simple_logging/simple_logging.ino index 81b8560f7..71a676cef 100644 --- a/examples/simple_logging/simple_logging.ino +++ b/examples/simple_logging/simple_logging.ino @@ -87,7 +87,7 @@ MaximDS3231 ds3231(1); Variable *variableList[] = { new ProcessorStats_SampleNumber(&mcuBoard), new ProcessorStats_FreeRam(&mcuBoard), - new ProcessorStats_Batt(&mcuBoard), + new ProcessorStats_Battery(&mcuBoard), new MaximDS3231_Temp(&ds3231) // Additional sensor variables can be added here, by copying the syntax // for creating the variable pointer (FORM1) from the `menu_a_la_carte.ino` example diff --git a/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino b/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino index f8d93a16d..af8f817aa 100644 --- a/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino +++ b/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino @@ -119,7 +119,7 @@ MaximDS18 ds18(OneWirePower, OneWireBus); Variable *variableList[] = { new ProcessorStats_SampleNumber(&mcuBoard), new ProcessorStats_FreeRam(&mcuBoard), - new ProcessorStats_Batt(&mcuBoard), + new ProcessorStats_Battery(&mcuBoard), new MaximDS3231_Temp(&ds3231), new BoschBME280_Temp(&bme280), new BoschBME280_Humidity(&bme280), diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index eb9b3a564..e6966ba54 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -65,10 +65,10 @@ class ProcessorStats : public Sensor // For the battery supplying power to the processor -class ProcessorStats_Batt : public Variable +class ProcessorStats_Battery : public Variable { public: - ProcessorStats_Batt(Sensor *parentSense, + ProcessorStats_Battery(Sensor *parentSense, const char *uuid = "", const char *varCode = "Battery") : Variable(parentSense, @@ -77,12 +77,12 @@ class ProcessorStats_Batt : public Variable "batteryVoltage", "volt", varCode, uuid) {} - ProcessorStats_Batt() + ProcessorStats_Battery() : Variable((const uint8_t)PROCESSOR_BATTERY_VAR_NUM, (uint8_t)PROCESSOR_BATTERY_RESOLUTION, "batteryVoltage", "volt", "Battery") {} - ~ProcessorStats_Batt(){} + ~ProcessorStats_Battery(){} }; From 4f14b0dab1218643d16db0bde6b2cc93d4bd3c7a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 16 May 2019 10:41:59 -0400 Subject: [PATCH 21/88] Removed modemStream internal pointer --- src/modems/DigiXBeeCellularBypass.cpp | 14 ++++++++++++-- src/modems/DigiXBeeCellularBypass.h | 5 ++--- src/modems/DigiXBeeCellularTransparent.cpp | 9 ++++++++- src/modems/DigiXBeeCellularTransparent.h | 1 - src/modems/DigiXBeeWifi.cpp | 12 +++++++++--- src/modems/DigiXBeeWifi.h | 1 - src/modems/QuectelBG96.cpp | 2 +- src/modems/QuectelBG96.h | 5 ++--- src/modems/SIMComSIM7000.cpp | 2 +- src/modems/SIMComSIM7000.h | 1 - src/modems/SIMComSIM800.cpp | 2 +- src/modems/SIMComSIM800.h | 1 - src/modems/SequansMonarch.cpp | 2 +- src/modems/SequansMonarch.h | 1 - src/modems/Sodaq2GBeeR6.cpp | 2 +- src/modems/Sodaq2GBeeR6.h | 1 - src/modems/SodaqUBeeR410M.cpp | 11 ++++++----- src/modems/SodaqUBeeR410M.h | 4 +--- src/modems/SodaqUBeeU201.cpp | 2 +- src/modems/SodaqUBeeU201.h | 1 - 20 files changed, 46 insertions(+), 33 deletions(-) diff --git a/src/modems/DigiXBeeCellularBypass.cpp b/src/modems/DigiXBeeCellularBypass.cpp index 462b15ab4..0fd74da53 100644 --- a/src/modems/DigiXBeeCellularBypass.cpp +++ b/src/modems/DigiXBeeCellularBypass.cpp @@ -30,7 +30,6 @@ DigiXBeeCellularBypass::DigiXBeeCellularBypass(Stream* modemStream, _apn = apn; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); _tinyClient = tinyClient; - _modemStream = modemStream; } @@ -47,9 +46,11 @@ bool DigiXBeeCellularBypass::extraModemSetup(void) { bool success = true; delay(1010); // Wait the required guard time before entering command mode + MS_DBG(F("Putting XBee into command mode...")); _tinyModem.streamWrite(GF("+++")); // enter command mode if (success &= _tinyModem.waitResponse(2000, F("OK\r")) == 1) { + MS_DBG(F("Setting I/O Pins...")); // Set DIO8 to be used for sleep requests // NOTE: Only pin 9/DIO8/DTR can be used for this function _tinyModem.sendAT(F("D8"),1); @@ -64,11 +65,13 @@ bool DigiXBeeCellularBypass::extraModemSetup(void) _tinyModem.sendAT(F("D7"),1); success &= _tinyModem.waitResponse(F("OK\r")) == 1; // Put the XBee in pin sleep mode + MS_DBG(F("Setting Sleep Options...")); _tinyModem.sendAT(F("SM"),1); success &= _tinyModem.waitResponse(F("OK\r")) == 1; // Disassociate from network for lowest power deep sleep _tinyModem.sendAT(F("SO"),0); success &= _tinyModem.waitResponse(F("OK\r")) == 1; + MS_DBG(F("Setting Other Options...")); // Disable remote manager, USB Direct, and LTE PSM // NOTE: LTE-M's PSM (Power Save Mode) sounds good, but there's no // easy way on the LTE-M Bee to wake the cell chip itself from PSM, @@ -81,6 +84,7 @@ bool DigiXBeeCellularBypass::extraModemSetup(void) // Make sure pins 7&8 are not set for USB direct on XBee3 units _tinyModem.sendAT(F("P1"),0); success &= _tinyModem.waitResponse(F("OK\r")) == 1; + MS_DBG(F("Setting Cellular Carrier Options...")); // Cellular carrier profile - AT&T // Hologram says they can use any network, but I've never succeeded with anything but AT&T _tinyModem.sendAT(F("CP"),2); @@ -89,6 +93,7 @@ bool DigiXBeeCellularBypass::extraModemSetup(void) // LTE-M XBee connects much faster on AT&T/Hologram when set to LTE-M only (instead of LTE-M/NB IoT) _tinyModem.sendAT(F("N#"),2); success &= _tinyModem.waitResponse(F("OK\r")) == 1; + MS_DBG(F("Turning on Bypass Mode...")); // Turn on bypass mode _tinyModem.sendAT(F("AP5")); success &= _tinyModem.waitResponse(F("OK\r")) == 1; @@ -99,12 +104,17 @@ bool DigiXBeeCellularBypass::extraModemSetup(void) _tinyModem.sendAT(F("AC")); success &= _tinyModem.waitResponse(F("OK\r")) == 1; // Force reset to actually enter bypass mode - this effectively exits bypass mode + MS_DBG(F("Resetting the module to reboot in bypass mode...")); _tinyModem.sendAT(F("FR")); success &= _tinyModem.waitResponse(F("OK\r")) == 1; - // initialize + delay(200); // Allow the unit to reset + // re-initialize + MS_DBG(F("Attempting to reconnect to the u-blox module...")); success &= _tinyModem.init(); _modemName = _tinyModem.getModemName(); } else success = false; + if (success) MS_DBG(F("... Setup successful!")); + else MS_DBG(F("... failed!")); return success; } diff --git a/src/modems/DigiXBeeCellularBypass.h b/src/modems/DigiXBeeCellularBypass.h index 1c6565327..17ab78a5c 100644 --- a/src/modems/DigiXBeeCellularBypass.h +++ b/src/modems/DigiXBeeCellularBypass.h @@ -12,8 +12,8 @@ #define DigiXBeeCellularBypass_h // Debugging Statement -// #define MS_SODAQUBEEU201_DEBUG -// #define MS_SODAQUBEEU201_DEBUG_DEEP +// #define MS_DIGIXBEECELLULARBYPASS_DEBUG +// #define MS_DIGIXBEECELLULARBYPASS_DEBUG_DEEP #ifdef MS_DIGIXBEECELLULARBYPASS_DEBUG #define MS_DEBUGGING_STD @@ -55,7 +55,6 @@ class DigiXBeeCellularBypass : public DigiXBee #endif TinyGsm _tinyModem; - Stream *_modemStream; protected: bool didATRespond(void) override; diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index 4186f8442..04e7c2630 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -30,7 +30,6 @@ DigiXBeeCellularTransparent::DigiXBeeCellularTransparent(Stream* modemStream, _apn = apn; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); _tinyClient = tinyClient; - _modemStream = modemStream; } @@ -45,10 +44,13 @@ MS_MODEM_GET_NIST_TIME(DigiXBeeCellularTransparent); bool DigiXBeeCellularTransparent::extraModemSetup(void) { bool success = true; + MS_DBG(F("Initializing the XBee...")); success &= _tinyModem.init(); // initialize _modemName = _tinyModem.getModemName(); + MS_DBG(F("Putting XBee into command mode...")); if (_tinyModem.commandMode()) { + MS_DBG(F("Setting I/O Pins...")); // Set DIO8 to be used for sleep requests // NOTE: Only pin 9/DIO8/DTR can be used for this function _tinyModem.sendAT(F("D8"),1); @@ -63,11 +65,13 @@ bool DigiXBeeCellularTransparent::extraModemSetup(void) _tinyModem.sendAT(F("D7"),1); success &= _tinyModem.waitResponse() == 1; // Put the XBee in pin sleep mode + MS_DBG(F("Setting Sleep Options...")); _tinyModem.sendAT(F("SM"),1); success &= _tinyModem.waitResponse() == 1; // Disassociate from network for lowest power deep sleep _tinyModem.sendAT(F("SO"),0); success &= _tinyModem.waitResponse() == 1; + MS_DBG(F("Setting Other Options...")); // Disable remote manager, USB Direct, and LTE PSM // NOTE: LTE-M's PSM (Power Save Mode) sounds good, but there's no // easy way on the LTE-M Bee to wake the cell chip itself from PSM, @@ -80,6 +84,7 @@ bool DigiXBeeCellularTransparent::extraModemSetup(void) // Make sure pins 7&8 are not set for USB direct on XBee3 units _tinyModem.sendAT(F("P1"),0); success &= _tinyModem.waitResponse() == 1; + MS_DBG(F("Setting Cellular Carrier Options...")); // Cellular carrier profile - AT&T // Hologram says they can use any network, but I've never succeeded with anything but AT&T _tinyModem.sendAT(F("CP"),2); @@ -96,6 +101,8 @@ bool DigiXBeeCellularTransparent::extraModemSetup(void) _tinyModem.exitCommand(); } else success = false; + if (success) MS_DBG(F("... Setup successful!")); + else MS_DBG(F("... failed!")); return success; } diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index ea3d5ae1b..db8371eef 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -55,7 +55,6 @@ class DigiXBeeCellularTransparent : public DigiXBee #endif TinyGsm _tinyModem; - Stream *_modemStream; protected: bool didATRespond(void) override; diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index f6a7c0831..4aa1990ea 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -32,7 +32,6 @@ DigiXBeeWifi::DigiXBeeWifi(Stream* modemStream, _pwd = pwd; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); _tinyClient = tinyClient; - _modemStream = modemStream; } @@ -46,10 +45,13 @@ MS_MODEM_GET_NIST_TIME(DigiXBeeWifi); bool DigiXBeeWifi::extraModemSetup(void) { bool success = true; + MS_DBG(F("Initializing the XBee...")); success &= _tinyModem.init(); // initialize _modemName = _tinyModem.getModemName(); + MS_DBG(F("Putting XBee into command mode...")); if (_tinyModem.commandMode()) { + MS_DBG(F("Setting I/O Pins...")); // Set DIO8 to be used for sleep requests // NOTE: Only pin 9/DIO8/DTR can be used for this function _tinyModem.sendAT(F("D8"),1); @@ -64,11 +66,13 @@ bool DigiXBeeWifi::extraModemSetup(void) _tinyModem.sendAT(F("D7"),1); success &= _tinyModem.waitResponse() == 1; // Put the XBee in pin sleep mode + MS_DBG(F("Setting Sleep Options...")); _tinyModem.sendAT(F("SM"),1); success &= _tinyModem.waitResponse() == 1; // Disassociate from network for lowest power deep sleep _tinyModem.sendAT(F("SO"),200); success &= _tinyModem.waitResponse() == 1; + MS_DBG(F("Setting Wifi Network Options...")); // Put the network connection parameters into flash success &= _tinyModem.networkConnect(_ssid, _pwd); // Write changes to flash and apply them @@ -77,6 +81,8 @@ bool DigiXBeeWifi::extraModemSetup(void) _tinyModem.exitCommand(); } else success = false; + if (success) MS_DBG(F("... Setup successful!")); + else MS_DBG(F("... failed!")); return success; } @@ -130,8 +136,8 @@ bool DigiXBeeWifi::addSingleMeasurementResult(void) } else MS_DBG(getSensorName(), F("is not connected to the network; unable to get signal quality!")); - verifyAndAddMeasurementResult(RSSI_VAR_NUM, rssi); - verifyAndAddMeasurementResult(PERCENT_SIGNAL_VAR_NUM, percent); + verifyAndAddMeasurementResult(MODEM_RSSI_VAR_NUM, rssi); + verifyAndAddMeasurementResult(MODEM_PERCENT_SIGNAL_VAR_NUM, percent); // Unset the time stamp for the beginning of this measurement _millisMeasurementRequested = 0; diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index 130844871..f79ef0988 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -55,7 +55,6 @@ class DigiXBeeWifi : public DigiXBee #endif TinyGsm _tinyModem; - Stream *_modemStream; protected: bool didATRespond(void) override; diff --git a/src/modems/QuectelBG96.cpp b/src/modems/QuectelBG96.cpp index 0bffe6e71..ae5a74203 100644 --- a/src/modems/QuectelBG96.cpp +++ b/src/modems/QuectelBG96.cpp @@ -34,7 +34,6 @@ QuectelBG96::QuectelBG96(Stream* modemStream, _apn = apn; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); _tinyClient = tinyClient; - _modemStream = modemStream; } @@ -78,6 +77,7 @@ bool QuectelBG96::modemSleepFxn(void) bool QuectelBG96::extraModemSetup(void) { + _tinyModem.init(); _modemName = _tinyModem.getModemName(); return true; } diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index 737dd4b2f..7e1478420 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -13,8 +13,8 @@ #define QuectelBG96_h // Debugging Statement -// #define MS_SODAQUBEEU201_DEBUG -// #define MS_SODAQUBEEU201_DEBUG_DEEP +// #define MS_QUECTELBG96_DEBUG +// #define MS_QUECTELBG96_DEBUG_DEEP #ifdef MS_QUECTELBG96_DEBUG #define MS_DEBUGGING_STD @@ -70,7 +70,6 @@ class QuectelBG96 : public loggerModem #endif TinyGsm _tinyModem; - Stream *_modemStream; protected: bool didATRespond(void) override; diff --git a/src/modems/SIMComSIM7000.cpp b/src/modems/SIMComSIM7000.cpp index 8cc7e5879..155e2dfba 100644 --- a/src/modems/SIMComSIM7000.cpp +++ b/src/modems/SIMComSIM7000.cpp @@ -34,7 +34,6 @@ SIMComSIM7000::SIMComSIM7000(Stream* modemStream, _apn = apn; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); _tinyClient = tinyClient; - _modemStream = modemStream; } @@ -77,6 +76,7 @@ bool SIMComSIM7000::modemSleepFxn(void) bool SIMComSIM7000::extraModemSetup(void) { + _tinyModem.init(); _modemName = _tinyModem.getModemName(); return true; } diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h index 63415c119..b4c0df09a 100644 --- a/src/modems/SIMComSIM7000.h +++ b/src/modems/SIMComSIM7000.h @@ -69,7 +69,6 @@ class SIMComSIM7000 : public loggerModem #endif TinyGsm _tinyModem; - Stream *_modemStream; protected: bool didATRespond(void) override; diff --git a/src/modems/SIMComSIM800.cpp b/src/modems/SIMComSIM800.cpp index 75858c9ba..e770cd27c 100644 --- a/src/modems/SIMComSIM800.cpp +++ b/src/modems/SIMComSIM800.cpp @@ -36,7 +36,6 @@ SIMComSIM800::SIMComSIM800(Stream* modemStream, _apn = apn; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); _tinyClient = tinyClient; - _modemStream = modemStream; } @@ -79,6 +78,7 @@ bool SIMComSIM800::modemSleepFxn(void) bool SIMComSIM800::extraModemSetup(void) { + _tinyModem.init(); _modemName = _tinyModem.getModemName(); return true; } diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index 8eff9b77b..b83db94f8 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -72,7 +72,6 @@ class SIMComSIM800 : public loggerModem #endif TinyGsm _tinyModem; - Stream *_modemStream; protected: bool didATRespond(void) override; diff --git a/src/modems/SequansMonarch.cpp b/src/modems/SequansMonarch.cpp index 9102d5529..908a23f3a 100644 --- a/src/modems/SequansMonarch.cpp +++ b/src/modems/SequansMonarch.cpp @@ -34,7 +34,6 @@ SequansMonarch::SequansMonarch(Stream* modemStream, _apn = apn; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); _tinyClient = tinyClient; - _modemStream = modemStream; } @@ -84,6 +83,7 @@ bool SequansMonarch::modemSleepFxn(void) bool SequansMonarch::extraModemSetup(void) { + _tinyModem.init(); _modemName = _tinyModem.getModemName(); return true; } diff --git a/src/modems/SequansMonarch.h b/src/modems/SequansMonarch.h index 39e696c71..59922b6eb 100644 --- a/src/modems/SequansMonarch.h +++ b/src/modems/SequansMonarch.h @@ -70,7 +70,6 @@ class SequansMonarch : public loggerModem #endif TinyGsm _tinyModem; - Stream *_modemStream; protected: bool didATRespond(void) override; diff --git a/src/modems/Sodaq2GBeeR6.cpp b/src/modems/Sodaq2GBeeR6.cpp index 9dcde814c..9a4562c0e 100644 --- a/src/modems/Sodaq2GBeeR6.cpp +++ b/src/modems/Sodaq2GBeeR6.cpp @@ -35,7 +35,6 @@ Sodaq2GBeeR6::Sodaq2GBeeR6(Stream* modemStream, _apn = apn; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); _tinyClient = tinyClient; - _modemStream = modemStream; } @@ -65,6 +64,7 @@ bool Sodaq2GBeeR6::modemSleepFxn(void) bool Sodaq2GBeeR6::extraModemSetup(void) { + _tinyModem.init(); _modemName = _tinyModem.getModemName(); return true; } diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h index e5fc06b5d..3503b45dc 100644 --- a/src/modems/Sodaq2GBeeR6.h +++ b/src/modems/Sodaq2GBeeR6.h @@ -71,7 +71,6 @@ class Sodaq2GBeeR6 : public loggerModem #endif TinyGsm _tinyModem; - Stream *_modemStream; protected: bool didATRespond(void) override; diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp index 8f247e542..0fbc23931 100644 --- a/src/modems/SodaqUBeeR410M.cpp +++ b/src/modems/SodaqUBeeR410M.cpp @@ -35,7 +35,6 @@ SodaqUBeeR410M::SodaqUBeeR410M(HardwareSerial* modemStream, _apn = apn; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); _tinyClient = tinyClient; - _modemStream = modemStream; } #else SodaqUBeeR410M::SodaqUBeeR410M(Stream* modemStream, @@ -59,7 +58,7 @@ SodaqUBeeR410M::SodaqUBeeR410M(Stream* modemStream, _apn = apn; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); _tinyClient = tinyClient; - _modemStream = modemStream; + _modemSerial = modemStream; _statusLevel = HIGH; } #endif @@ -91,10 +90,10 @@ bool SodaqUBeeR410M::modemWakeFxn(void) if (_powerPin >= 0) { delay(4600); // Must wait for UART port to become active - _modemStream->begin(115200); + _modemSerial->begin(115200); _tinyModem.setBaud(9600); - _modemStream->end(); - _modemStream->begin(9600); + _modemSerial->end(); + _modemSerial->begin(9600); } #endif return true; @@ -122,8 +121,10 @@ bool SodaqUBeeR410M::modemSleepFxn(void) bool SodaqUBeeR410M::extraModemSetup(void) { + _tinyModem.init(); _modemName = _tinyModem.getModemName(); // Set to only use LTE-M, which should cause connection more quickly _tinyModem.sendAT(F("+URAT=7")); + _tinyModem.waitResponse(); return true; } diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index c859dbfe5..b29f392a3 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -82,9 +82,7 @@ class SodaqUBeeR410M : public loggerModem TinyGsm _tinyModem; #if F_CPU == 8000000L - HardwareSerial *_modemStream; - #else - Stream *_modemStream; + HardwareSerial *_modemSerial; #endif protected: diff --git a/src/modems/SodaqUBeeU201.cpp b/src/modems/SodaqUBeeU201.cpp index 4191c2289..5f691bc25 100644 --- a/src/modems/SodaqUBeeU201.cpp +++ b/src/modems/SodaqUBeeU201.cpp @@ -34,7 +34,6 @@ SodaqUBeeU201::SodaqUBeeU201(Stream* modemStream, _apn = apn; TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); _tinyClient = tinyClient; - _modemStream = modemStream; } @@ -85,6 +84,7 @@ bool SodaqUBeeU201::modemSleepFxn(void) bool SodaqUBeeU201::extraModemSetup(void) { + _tinyModem.init(); _modemName = _tinyModem.getModemName(); return true; } diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index 4903be3ff..83fd6e827 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -75,7 +75,6 @@ class SodaqUBeeU201 : public loggerModem #endif TinyGsm _tinyModem; - Stream *_modemStream; protected: bool didATRespond(void) override; From e4c94bbe71c1c93168f6267644e3de0d83b56cb1 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 16 May 2019 10:43:26 -0400 Subject: [PATCH 22/88] Renamed modem vars and added modem battery and temp --- src/LoggerModem.h | 84 +++++++++++++++++++++++++++------- src/modems/LoggerModemMacros.h | 4 +- 2 files changed, 69 insertions(+), 19 deletions(-) diff --git a/src/LoggerModem.h b/src/LoggerModem.h index 5460d134e..4957c6b58 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -13,7 +13,7 @@ #define LoggerModem_h // FOR DEBUGGING -// #define MS_LOGGERMODEM_DEBUG +#define MS_LOGGERMODEM_DEBUG // #define MS_LOGGERMODEM_DEBUG_DEEP #ifdef MS_LOGGERMODEM_DEBUG @@ -28,13 +28,19 @@ #include -#define MODEM_NUM_VARIABLES 2 +#define MODEM_NUM_VARIABLES 4 -#define RSSI_VAR_NUM 0 -#define RSSI_RESOLUTION 0 +#define MODEM_RSSI_VAR_NUM 0 +#define MODEM_RSSI_RESOLUTION 0 -#define PERCENT_SIGNAL_VAR_NUM 1 -#define PERCENT_SIGNAL_RESOLUTION 0 +#define MODEM_PERCENT_SIGNAL_VAR_NUM 1 +#define MODEM_PERCENT_SIGNAL_RESOLUTION 0 + +#define MODEM_BATTERY_VAR_NUM 2 +#define MODEM_BATTERY_RESOLUTION 2 + +#define MODEM_TEMPERATURE_VAR_NUM 3 +#define MODEM_TEMPERATURE_RESOLUTION 1 /* =========================================================================== * Functions for the modem class @@ -55,7 +61,7 @@ class loggerModem : public Sensor uint32_t max_signalQuality_time_ms, uint8_t measurementsToAverage = 1); - ~loggerModem(); + virtual ~loggerModem(); String getSensorName(void) override; @@ -105,11 +111,11 @@ class loggerModem : public Sensor void setModemLED(int8_t modemLEDPin); // Get values by other names - int16_t getSignalRSSI(void) {return sensorValues[RSSI_VAR_NUM];} - int16_t getSignalPercent(void) {return sensorValues[PERCENT_SIGNAL_VAR_NUM];} // Get the client instance in use Client * getClient(void){return _tinyClient;} + int16_t getSignalRSSI(void) {return sensorValues[MODEM_RSSI_VAR_NUM];} + int16_t getSignalPercent(void) {return sensorValues[MODEM_PERCENT_SIGNAL_VAR_NUM];} // Access the internet virtual bool connectInternet(uint32_t maxConnectionTime = 50000L) = 0; @@ -182,14 +188,14 @@ class Modem_RSSI : public Variable const char *uuid = "", const char *varCode = "RSSI") : Variable(parentSense, - (const uint8_t)RSSI_VAR_NUM, - (uint8_t)RSSI_RESOLUTION, + (const uint8_t)MODEM_RSSI_VAR_NUM, + (uint8_t)MODEM_RSSI_RESOLUTION, "RSSI", "decibelMiliWatt", varCode, uuid) {} Modem_RSSI() - : Variable((const uint8_t)RSSI_VAR_NUM, - (uint8_t)RSSI_RESOLUTION, + : Variable((const uint8_t)MODEM_RSSI_VAR_NUM, + (uint8_t)MODEM_RSSI_RESOLUTION, "RSSI", "decibelMiliWatt", "RSSI") {} ~Modem_RSSI(){} @@ -204,17 +210,61 @@ class Modem_SignalPercent : public Variable const char *uuid = "", const char *varCode = "signalPercent") : Variable(parentSense, - (const uint8_t)PERCENT_SIGNAL_VAR_NUM, - (uint8_t)PERCENT_SIGNAL_RESOLUTION, + (const uint8_t)MODEM_BATTERY_VAR_NUM, + (uint8_t)MODEM_BATTERY_RESOLUTION, "signalPercent", "percent", varCode, uuid) {} Modem_SignalPercent() - : Variable((const uint8_t)PERCENT_SIGNAL_VAR_NUM, - (uint8_t)PERCENT_SIGNAL_RESOLUTION, + : Variable((const uint8_t)MODEM_BATTERY_VAR_NUM, + (uint8_t)MODEM_BATTERY_RESOLUTION, "signalPercent", "percent", "signalPercent") {} ~Modem_SignalPercent(){} }; + +// Defines the Signal Percentage +class Modem_Battery : public Variable +{ +public: + Modem_Battery(Sensor *parentSense, + const char *uuid = "", + const char *varCode = "modemBattery") + : Variable(parentSense, + (const uint8_t)MODEM_PERCENT_SIGNAL_VAR_NUM, + (uint8_t)MODEM_PERCENT_SIGNAL_RESOLUTION, + "batteryVoltage", "volt", + varCode, uuid) + {} + Modem_Battery() + : Variable((const uint8_t)MODEM_PERCENT_SIGNAL_VAR_NUM, + (uint8_t)MODEM_PERCENT_SIGNAL_RESOLUTION, + "batteryVoltage", "volt", "modemBattery") + {} + ~Modem_Battery(){} +}; + + +// Defines the Temperature Sensor on the modem (not all modems have one) +class Modem_Temp : public Variable +{ +public: + Modem_Temp(Sensor *parentSense, + const char *uuid = "", + const char *varCode = "modemTemp") + : Variable(parentSense, + (const uint8_t)MODEM_TEMPERATURE_VAR_NUM, + (uint8_t)MODEM_TEMPERATURE_RESOLUTION, + "temperature", "degreeCelsius", + varCode, uuid) + {} + Modem_Temp() + : Variable((const uint8_t)MODEM_TEMPERATURE_VAR_NUM, + (uint8_t)MODEM_TEMPERATURE_RESOLUTION, + "temperature", "degreeCelsius", "modemTemp") + {} + ~Modem_Temp(){} +}; + #endif // Header Guard diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 82992d9fd..1d53ed7b0 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -159,8 +159,8 @@ bool specificModem::addSingleMeasurementResult(void) \ } \ else MS_DBG(getSensorName(), F("is not connected to the network; unable to get signal quality!")); \ \ - verifyAndAddMeasurementResult(RSSI_VAR_NUM, rssi); \ - verifyAndAddMeasurementResult(PERCENT_SIGNAL_VAR_NUM, percent); \ + verifyAndAddMeasurementResult(MODEM_RSSI_VAR_NUM, rssi); \ + verifyAndAddMeasurementResult(MODEM_PERCENT_SIGNAL_VAR_NUM, percent); \ \ /* Unset the time stamp for the beginning of this measurement */ \ _millisMeasurementRequested = 0; \ From 819edbb62c96152ecc8daaa06f1b5dab4012ef5f Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 16 May 2019 11:04:27 -0400 Subject: [PATCH 23/88] esp --- src/modems/EspressifESP8266.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index 99f31f59f..597664d9c 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -168,17 +168,18 @@ bool EspressifESP8266::modemSleepFxn(void) // Set up the light-sleep status pin, if applicable bool EspressifESP8266::extraModemSetup(void) { + _tinyModem.init(); _modemName = _tinyModem.getModemName(); // Slow down the baud rate for slow processors - and save the change to // the ESP's non-volatile memory so we don't have to do it every time // #if F_CPU == 8000000L // if (modemBaud > 57600) // { - // _modemStream->begin(modemBaud); + // _modemSerial->begin(modemBaud); // _tinyModem.sendAT(F("+UART_DEF=9600,8,1,0,0")); // _tinyModem.waitResponse(); - // _modemStream->end(); - // _modemStream->begin(9600); + // _modemSerial->end(); + // _modemSerial->begin(9600); // } // #endif if (_powerPin < 0 && _modemResetPin < 0 && _modemSleepRqPin >= 0 && _dataPin >= 0) From dc826d83ee03b80656099a5290eaa9e887b33072 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 16 May 2019 11:10:03 -0400 Subject: [PATCH 24/88] Removed client from loggerModem parent class --- src/LoggerModem.h | 8 -------- src/dataPublisherBase.cpp | 5 ----- src/dataPublisherBase.h | 1 - src/modems/DigiXBeeCellularBypass.cpp | 8 ++++---- src/modems/DigiXBeeCellularBypass.h | 1 + src/modems/DigiXBeeCellularTransparent.cpp | 8 ++++---- src/modems/DigiXBeeCellularTransparent.h | 1 + src/modems/DigiXBeeWifi.cpp | 8 ++++---- src/modems/DigiXBeeWifi.h | 1 + src/modems/EspressifESP8266.cpp | 13 +++++++------ src/modems/EspressifESP8266.h | 3 +++ src/modems/LoggerModemMacros.h | 14 +++++++------- src/modems/QuectelBG96.cpp | 8 ++++---- src/modems/QuectelBG96.h | 1 + src/modems/SIMComSIM7000.cpp | 8 ++++---- src/modems/SIMComSIM7000.h | 1 + src/modems/SIMComSIM800.cpp | 8 ++++---- src/modems/SIMComSIM800.h | 1 + src/modems/SequansMonarch.cpp | 8 ++++---- src/modems/SequansMonarch.h | 1 + src/modems/Sodaq2GBeeR6.cpp | 8 ++++---- src/modems/Sodaq2GBeeR6.h | 1 + src/modems/SodaqUBeeR410M.cpp | 18 +++++++++--------- src/modems/SodaqUBeeR410M.h | 2 ++ src/modems/SodaqUBeeU201.cpp | 8 ++++---- src/modems/SodaqUBeeU201.h | 1 + 26 files changed, 73 insertions(+), 72 deletions(-) diff --git a/src/LoggerModem.h b/src/LoggerModem.h index 4957c6b58..633b66d1b 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -25,7 +25,6 @@ #include "VariableBase.h" #include "SensorBase.h" #include -#include #define MODEM_NUM_VARIABLES 4 @@ -111,9 +110,6 @@ class loggerModem : public Sensor void setModemLED(int8_t modemLEDPin); // Get values by other names - - // Get the client instance in use - Client * getClient(void){return _tinyClient;} int16_t getSignalRSSI(void) {return sensorValues[MODEM_RSSI_VAR_NUM];} int16_t getSignalPercent(void) {return sensorValues[MODEM_PERCENT_SIGNAL_VAR_NUM];} @@ -136,10 +132,6 @@ class loggerModem : public Sensor // over TCP because I don't have a UDP library for all the modems. virtual uint32_t getNISTTime(void) = 0; -public: - // All of these must be pointers - these are all abstract classes! - Client *_tinyClient; - protected: // Helper to get approximate RSSI from CSQ (assuming no noise) static int16_t getRSSIFromCSQ(int16_t csq); diff --git a/src/dataPublisherBase.cpp b/src/dataPublisherBase.cpp index 8cfa83ba7..2428ecd12 100644 --- a/src/dataPublisherBase.cpp +++ b/src/dataPublisherBase.cpp @@ -119,11 +119,6 @@ void dataPublisher::printTxBuffer(Stream *stream) // This sends data on the "default" client of the modem int16_t dataPublisher::sendData() { - if (_inClient == NULL && _baseLogger->_logModem != NULL) - { - _inClient = _baseLogger->_logModem->getClient(); - } - if (_inClient == NULL) return 0; else return sendData(_inClient); } diff --git a/src/dataPublisherBase.h b/src/dataPublisherBase.h index 32b72095f..3ee0bb793 100644 --- a/src/dataPublisherBase.h +++ b/src/dataPublisherBase.h @@ -73,7 +73,6 @@ class dataPublisher // This depends on an internet connection already being made and a client // being available virtual int16_t sendData(Client *_outClient) = 0; - // This sends data on the "default" client of the modem attached to the logger virtual int16_t sendData(); protected: diff --git a/src/modems/DigiXBeeCellularBypass.cpp b/src/modems/DigiXBeeCellularBypass.cpp index 0fd74da53..00f61bb23 100644 --- a/src/modems/DigiXBeeCellularBypass.cpp +++ b/src/modems/DigiXBeeCellularBypass.cpp @@ -22,14 +22,14 @@ DigiXBeeCellularBypass::DigiXBeeCellularBypass(Stream* modemStream, measurementsToAverage), #ifdef MS_DIGIXBEECELLULARBYPASS_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger) + _tinyModem(_modemATDebugger), + _tinyClient(_tinyModem) #else - _tinyModem(*modemStream) + _tinyModem(*modemStream), + _tinyClient(_tinyModem) #endif { _apn = apn; - TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); - _tinyClient = tinyClient; } diff --git a/src/modems/DigiXBeeCellularBypass.h b/src/modems/DigiXBeeCellularBypass.h index 17ab78a5c..9e4ea3f15 100644 --- a/src/modems/DigiXBeeCellularBypass.h +++ b/src/modems/DigiXBeeCellularBypass.h @@ -55,6 +55,7 @@ class DigiXBeeCellularBypass : public DigiXBee #endif TinyGsm _tinyModem; + TinyGsmClient _tinyClient; protected: bool didATRespond(void) override; diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index 04e7c2630..3c5b66b89 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -22,14 +22,14 @@ DigiXBeeCellularTransparent::DigiXBeeCellularTransparent(Stream* modemStream, measurementsToAverage), #ifdef MS_DIGIXBEECELLULARTRANSPARENT_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger) + _tinyModem(_modemATDebugger), + _tinyClient(_tinyModem) #else - _tinyModem(*modemStream) + _tinyModem(*modemStream), + _tinyClient(_tinyModem) #endif { _apn = apn; - TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); - _tinyClient = tinyClient; } diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index db8371eef..a792849d4 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -55,6 +55,7 @@ class DigiXBeeCellularTransparent : public DigiXBee #endif TinyGsm _tinyModem; + TinyGsmClient _tinyClient; protected: bool didATRespond(void) override; diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index 4aa1990ea..a9674f0c9 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -23,15 +23,15 @@ DigiXBeeWifi::DigiXBeeWifi(Stream* modemStream, measurementsToAverage), #ifdef MS_DIGIXBEEWIFI_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger) + _tinyModem(_modemATDebugger), + _tinyClient(_tinyModem) #else - _tinyModem(*modemStream) + _tinyModem(*modemStream), + _tinyClient(_tinyModem) #endif { _ssid = ssid; _pwd = pwd; - TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); - _tinyClient = tinyClient; } diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index f79ef0988..aa51eef55 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -55,6 +55,7 @@ class DigiXBeeWifi : public DigiXBee #endif TinyGsm _tinyModem; + TinyGsmClient _tinyClient; protected: bool didATRespond(void) override; diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index 597664d9c..1ee795f5f 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -29,20 +29,21 @@ EspressifESP8266::EspressifESP8266(Stream* modemStream, measurementsToAverage), #ifdef MS_ESPRESSIFESP8266_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger) + _tinyModem(_modemATDebugger), + _tinyClient(_tinyModem) #else - _tinyModem(*modemStream) + _tinyModem(*modemStream), + _tinyClient(_tinyModem) #endif { _ssid = ssid; _pwd = pwd; - TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); - _tinyClient = tinyClient; - _modemStream = modemStream; + _espSleepRqPin = espSleepRqPin; _espStatusPin = espStatusPin; -} + _modemStream = modemStream; +} MS_MODEM_DID_AT_RESPOND(EspressifESP8266); MS_MODEM_IS_INTERNET_AVAILABLE(EspressifESP8266); diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h index 075d7be93..da36a6687 100644 --- a/src/modems/EspressifESP8266.h +++ b/src/modems/EspressifESP8266.h @@ -75,6 +75,9 @@ class EspressifESP8266 : public loggerModem #endif TinyGsm _tinyModem; + TinyGsmClient _tinyClient; + + // Need the stream for tossing junk on boot Stream *_modemStream; protected: diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 1d53ed7b0..81baa5994 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -331,21 +331,21 @@ uint32_t specificModem::getNISTTime(void) \ /* This is the IP address of time-c-g.nist.gov */ \ /* XBee's address lookup falters on time.nist.gov */ \ IPAddress ip(129, 6, 15, 30); \ - connectionMade = _tinyClient->connect(ip, 37); \ + connectionMade = _tinyClient.connect(ip, 37); \ /* Need to send something before connection is made */ \ - _tinyClient->print('!'); \ + _tinyClient.print('!'); \ /* Need this delay! Can get away with 50, but 100 is safer. */ \ delay(100); \ } \ - else connectionMade = _tinyClient->connect("time.nist.gov", 37); \ + else connectionMade = _tinyClient.connect("time.nist.gov", 37); \ \ /* Wait up to 5 seconds for a response */ \ if (connectionMade) \ { \ uint32_t start = millis(); \ - while (_tinyClient && _tinyClient->available() < 4 && millis() - start < 5000L){} \ + while (_tinyClient && _tinyClient.available() < 4 && millis() - start < 5000L){} \ \ - if (_tinyClient->available() >= 4) \ + if (_tinyClient.available() >= 4) \ { \ MS_DBG(F("\nNIST responded after"), millis() - start, F("ms")); \ /* Response is returned as 32-bit number as soon as connection is made */ \ @@ -354,7 +354,7 @@ uint32_t specificModem::getNISTTime(void) \ byte response[4] = {0}; \ for (uint8_t i = 0; i < 4; i++) \ { \ - response[i] = _tinyClient->read(); \ + response[i] = _tinyClient.read(); \ MS_DBG(F("\nResponse Byte"), i, ':', (char)response[i], \ '=', response[i], '=', String(response[i], BIN)); \ secFrom1900 += 0x000000FF & response[i]; \ @@ -365,7 +365,7 @@ uint32_t specificModem::getNISTTime(void) \ secFrom1900, '=', String(secFrom1900, BIN)); \ \ /* Close the TCP connection, just in case */ \ - _tinyClient->stop(); \ + _tinyClient.stop(); \ \ /* Return the timestamp */ \ uint32_t unixTimeStamp = secFrom1900 - 2208988800; \ diff --git a/src/modems/QuectelBG96.cpp b/src/modems/QuectelBG96.cpp index ae5a74203..16406a99f 100644 --- a/src/modems/QuectelBG96.cpp +++ b/src/modems/QuectelBG96.cpp @@ -26,14 +26,14 @@ QuectelBG96::QuectelBG96(Stream* modemStream, measurementsToAverage), #ifdef MS_QUECTELBG96_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger) + _tinyModem(_modemATDebugger), + _tinyClient(_tinyModem) #else - _tinyModem(*modemStream) + _tinyModem(*modemStream), + _tinyClient(_tinyModem) #endif { _apn = apn; - TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); - _tinyClient = tinyClient; } diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index 7e1478420..5096dfe78 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -70,6 +70,7 @@ class QuectelBG96 : public loggerModem #endif TinyGsm _tinyModem; + TinyGsmClient _tinyClient; protected: bool didATRespond(void) override; diff --git a/src/modems/SIMComSIM7000.cpp b/src/modems/SIMComSIM7000.cpp index 155e2dfba..39a01a868 100644 --- a/src/modems/SIMComSIM7000.cpp +++ b/src/modems/SIMComSIM7000.cpp @@ -26,14 +26,14 @@ SIMComSIM7000::SIMComSIM7000(Stream* modemStream, measurementsToAverage), #ifdef MS_SIMCOMSIM7000_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger) + _tinyModem(_modemATDebugger), + _tinyClient(_tinyModem) #else - _tinyModem(*modemStream) + _tinyModem(*modemStream), + _tinyClient(_tinyModem) #endif { _apn = apn; - TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); - _tinyClient = tinyClient; } diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h index b4c0df09a..49efa9960 100644 --- a/src/modems/SIMComSIM7000.h +++ b/src/modems/SIMComSIM7000.h @@ -69,6 +69,7 @@ class SIMComSIM7000 : public loggerModem #endif TinyGsm _tinyModem; + TinyGsmClient _tinyClient; protected: bool didATRespond(void) override; diff --git a/src/modems/SIMComSIM800.cpp b/src/modems/SIMComSIM800.cpp index e770cd27c..2f4873852 100644 --- a/src/modems/SIMComSIM800.cpp +++ b/src/modems/SIMComSIM800.cpp @@ -28,14 +28,14 @@ SIMComSIM800::SIMComSIM800(Stream* modemStream, measurementsToAverage), #ifdef MS_SIMCOMSIM800_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger) + _tinyModem(_modemATDebugger), + _tinyClient(_tinyModem) #else - _tinyModem(*modemStream) + _tinyModem(*modemStream), + _tinyClient(_tinyModem) #endif { _apn = apn; - TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); - _tinyClient = tinyClient; } diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index b83db94f8..74000c8ab 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -72,6 +72,7 @@ class SIMComSIM800 : public loggerModem #endif TinyGsm _tinyModem; + TinyGsmClient _tinyClient; protected: bool didATRespond(void) override; diff --git a/src/modems/SequansMonarch.cpp b/src/modems/SequansMonarch.cpp index 908a23f3a..06b1fc4ae 100644 --- a/src/modems/SequansMonarch.cpp +++ b/src/modems/SequansMonarch.cpp @@ -26,14 +26,14 @@ SequansMonarch::SequansMonarch(Stream* modemStream, measurementsToAverage), #ifdef MS_SEQUANSMONARCH_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger) + _tinyModem(_modemATDebugger), + _tinyClient(_tinyModem) #else - _tinyModem(*modemStream) + _tinyModem(*modemStream), + _tinyClient(_tinyModem) #endif { _apn = apn; - TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); - _tinyClient = tinyClient; } diff --git a/src/modems/SequansMonarch.h b/src/modems/SequansMonarch.h index 59922b6eb..c2b9a0fa4 100644 --- a/src/modems/SequansMonarch.h +++ b/src/modems/SequansMonarch.h @@ -70,6 +70,7 @@ class SequansMonarch : public loggerModem #endif TinyGsm _tinyModem; + TinyGsmClient _tinyClient; protected: bool didATRespond(void) override; diff --git a/src/modems/Sodaq2GBeeR6.cpp b/src/modems/Sodaq2GBeeR6.cpp index 9a4562c0e..e5ec3957f 100644 --- a/src/modems/Sodaq2GBeeR6.cpp +++ b/src/modems/Sodaq2GBeeR6.cpp @@ -27,14 +27,14 @@ Sodaq2GBeeR6::Sodaq2GBeeR6(Stream* modemStream, measurementsToAverage), #ifdef MS_SODAQ2GBEER6_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger) + _tinyModem(_modemATDebugger), + _tinyClient(_tinyModem) #else - _tinyModem(*modemStream) + _tinyModem(*modemStream), + _tinyClient(_tinyModem) #endif { _apn = apn; - TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); - _tinyClient = tinyClient; } diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h index 3503b45dc..3070ac8da 100644 --- a/src/modems/Sodaq2GBeeR6.h +++ b/src/modems/Sodaq2GBeeR6.h @@ -71,6 +71,7 @@ class Sodaq2GBeeR6 : public loggerModem #endif TinyGsm _tinyModem; + TinyGsmClient _tinyClient; protected: bool didATRespond(void) override; diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp index 0fbc23931..faf4a0fff 100644 --- a/src/modems/SodaqUBeeR410M.cpp +++ b/src/modems/SodaqUBeeR410M.cpp @@ -27,14 +27,14 @@ SodaqUBeeR410M::SodaqUBeeR410M(HardwareSerial* modemStream, measurementsToAverage), #ifdef MS_SODAQUBEER410M_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger) + _tinyModem(_modemATDebugger), + _tinyClient(_tinyModem) #else - _tinyModem(*modemStream) + _tinyModem(*modemStream), + _tinyClient(_tinyModem) #endif { _apn = apn; - TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); - _tinyClient = tinyClient; } #else SodaqUBeeR410M::SodaqUBeeR410M(Stream* modemStream, @@ -50,16 +50,16 @@ SodaqUBeeR410M::SodaqUBeeR410M(Stream* modemStream, measurementsToAverage), #ifdef MS_SODAQUBEER410M_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger) + _tinyModem(_modemATDebugger), + _tinyClient(_tinyModem) #else - _tinyModem(*modemStream) + _tinyModem(*modemStream), + _tinyClient(_tinyModem) #endif { _apn = apn; - TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); - _tinyClient = tinyClient; + _modemSerial = modemStream; - _statusLevel = HIGH; } #endif diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index b29f392a3..6bb9fe0d8 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -81,6 +81,8 @@ class SodaqUBeeR410M : public loggerModem #endif TinyGsm _tinyModem; + TinyGsmClient _tinyClient; + #if F_CPU == 8000000L HardwareSerial *_modemSerial; #endif diff --git a/src/modems/SodaqUBeeU201.cpp b/src/modems/SodaqUBeeU201.cpp index 5f691bc25..d0a49a460 100644 --- a/src/modems/SodaqUBeeU201.cpp +++ b/src/modems/SodaqUBeeU201.cpp @@ -26,14 +26,14 @@ SodaqUBeeU201::SodaqUBeeU201(Stream* modemStream, measurementsToAverage), #ifdef MS_SODAQUBEEU201_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger) + _tinyModem(_modemATDebugger), + _tinyClient(_tinyModem) #else - _tinyModem(*modemStream) + _tinyModem(*modemStream), + _tinyClient(_tinyModem) #endif { _apn = apn; - TinyGsmClient *tinyClient = new TinyGsmClient(_tinyModem); - _tinyClient = tinyClient; } diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index 83fd6e827..3668625e9 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -75,6 +75,7 @@ class SodaqUBeeU201 : public loggerModem #endif TinyGsm _tinyModem; + TinyGsmClient _tinyClient; protected: bool didATRespond(void) override; From d9ed6087fc019fed49a7c68116825001fd7ee77b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 16 May 2019 11:20:04 -0400 Subject: [PATCH 25/88] shortened macro if, fix xbee pointer --- src/modems/DigiXBeeCellularBypass.cpp | 3 +-- src/modems/DigiXBeeCellularTransparent.cpp | 3 +-- src/modems/DigiXBeeWifi.cpp | 9 ++++----- src/modems/EspressifESP8266.cpp | 3 +-- src/modems/QuectelBG96.cpp | 3 +-- src/modems/SIMComSIM7000.cpp | 3 +-- src/modems/SIMComSIM800.cpp | 3 +-- src/modems/SequansMonarch.cpp | 3 +-- src/modems/Sodaq2GBeeR6.cpp | 3 +-- src/modems/SodaqUBeeR410M.cpp | 6 ++---- src/modems/SodaqUBeeU201.cpp | 3 +-- 11 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/modems/DigiXBeeCellularBypass.cpp b/src/modems/DigiXBeeCellularBypass.cpp index 00f61bb23..ca12adc69 100644 --- a/src/modems/DigiXBeeCellularBypass.cpp +++ b/src/modems/DigiXBeeCellularBypass.cpp @@ -23,11 +23,10 @@ DigiXBeeCellularBypass::DigiXBeeCellularBypass(Stream* modemStream, #ifdef MS_DIGIXBEECELLULARBYPASS_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), _tinyModem(_modemATDebugger), - _tinyClient(_tinyModem) #else _tinyModem(*modemStream), - _tinyClient(_tinyModem) #endif + _tinyClient(_tinyModem) { _apn = apn; } diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index 3c5b66b89..e31e02c5b 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -23,11 +23,10 @@ DigiXBeeCellularTransparent::DigiXBeeCellularTransparent(Stream* modemStream, #ifdef MS_DIGIXBEECELLULARTRANSPARENT_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), _tinyModem(_modemATDebugger), - _tinyClient(_tinyModem) #else _tinyModem(*modemStream), - _tinyClient(_tinyModem) #endif + _tinyClient(_tinyModem) { _apn = apn; } diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index a9674f0c9..4986b4e65 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -24,11 +24,10 @@ DigiXBeeWifi::DigiXBeeWifi(Stream* modemStream, #ifdef MS_DIGIXBEEWIFI_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), _tinyModem(_modemATDebugger), - _tinyClient(_tinyModem) #else _tinyModem(*modemStream), - _tinyClient(_tinyModem) #endif + _tinyClient(_tinyModem) { _ssid = ssid; _pwd = pwd; @@ -109,13 +108,13 @@ bool DigiXBeeWifi::addSingleMeasurementResult(void) { usedGoogle = true; IPAddress ip(8, 8, 8, 8); // This is the IP address of time-c-g.nist.gov - success &= _tinyClient->connect(ip, 80); + success &= _tinyClient.connect(ip, 80); } - _tinyClient->print('!'); // Need to send something before connection is made + _tinyClient.print('!'); // Need to send something before connection is made delay(100); // Need this delay! Can get away with 50, but 100 is safer. if (usedGoogle) { - _tinyClient->stop(); + _tinyClient.stop(); } // Get signal quality diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index 1ee795f5f..f5f4a5123 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -30,11 +30,10 @@ EspressifESP8266::EspressifESP8266(Stream* modemStream, #ifdef MS_ESPRESSIFESP8266_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), _tinyModem(_modemATDebugger), - _tinyClient(_tinyModem) #else _tinyModem(*modemStream), - _tinyClient(_tinyModem) #endif + _tinyClient(_tinyModem) { _ssid = ssid; _pwd = pwd; diff --git a/src/modems/QuectelBG96.cpp b/src/modems/QuectelBG96.cpp index 16406a99f..67e63c1c7 100644 --- a/src/modems/QuectelBG96.cpp +++ b/src/modems/QuectelBG96.cpp @@ -27,11 +27,10 @@ QuectelBG96::QuectelBG96(Stream* modemStream, #ifdef MS_QUECTELBG96_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), _tinyModem(_modemATDebugger), - _tinyClient(_tinyModem) #else _tinyModem(*modemStream), - _tinyClient(_tinyModem) #endif + _tinyClient(_tinyModem) { _apn = apn; } diff --git a/src/modems/SIMComSIM7000.cpp b/src/modems/SIMComSIM7000.cpp index 39a01a868..81e5da913 100644 --- a/src/modems/SIMComSIM7000.cpp +++ b/src/modems/SIMComSIM7000.cpp @@ -27,11 +27,10 @@ SIMComSIM7000::SIMComSIM7000(Stream* modemStream, #ifdef MS_SIMCOMSIM7000_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), _tinyModem(_modemATDebugger), - _tinyClient(_tinyModem) #else _tinyModem(*modemStream), - _tinyClient(_tinyModem) #endif + _tinyClient(_tinyModem) { _apn = apn; } diff --git a/src/modems/SIMComSIM800.cpp b/src/modems/SIMComSIM800.cpp index 2f4873852..962739d3f 100644 --- a/src/modems/SIMComSIM800.cpp +++ b/src/modems/SIMComSIM800.cpp @@ -29,11 +29,10 @@ SIMComSIM800::SIMComSIM800(Stream* modemStream, #ifdef MS_SIMCOMSIM800_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), _tinyModem(_modemATDebugger), - _tinyClient(_tinyModem) #else _tinyModem(*modemStream), - _tinyClient(_tinyModem) #endif + _tinyClient(_tinyModem) { _apn = apn; } diff --git a/src/modems/SequansMonarch.cpp b/src/modems/SequansMonarch.cpp index 06b1fc4ae..93031399b 100644 --- a/src/modems/SequansMonarch.cpp +++ b/src/modems/SequansMonarch.cpp @@ -27,11 +27,10 @@ SequansMonarch::SequansMonarch(Stream* modemStream, #ifdef MS_SEQUANSMONARCH_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), _tinyModem(_modemATDebugger), - _tinyClient(_tinyModem) #else _tinyModem(*modemStream), - _tinyClient(_tinyModem) #endif + _tinyClient(_tinyModem) { _apn = apn; } diff --git a/src/modems/Sodaq2GBeeR6.cpp b/src/modems/Sodaq2GBeeR6.cpp index e5ec3957f..ce7430e64 100644 --- a/src/modems/Sodaq2GBeeR6.cpp +++ b/src/modems/Sodaq2GBeeR6.cpp @@ -28,11 +28,10 @@ Sodaq2GBeeR6::Sodaq2GBeeR6(Stream* modemStream, #ifdef MS_SODAQ2GBEER6_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), _tinyModem(_modemATDebugger), - _tinyClient(_tinyModem) #else _tinyModem(*modemStream), - _tinyClient(_tinyModem) #endif + _tinyClient(_tinyModem) { _apn = apn; } diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp index faf4a0fff..02c0a7e48 100644 --- a/src/modems/SodaqUBeeR410M.cpp +++ b/src/modems/SodaqUBeeR410M.cpp @@ -28,11 +28,10 @@ SodaqUBeeR410M::SodaqUBeeR410M(HardwareSerial* modemStream, #ifdef MS_SODAQUBEER410M_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), _tinyModem(_modemATDebugger), - _tinyClient(_tinyModem) #else _tinyModem(*modemStream), - _tinyClient(_tinyModem) #endif + _tinyClient(_tinyModem) { _apn = apn; } @@ -51,11 +50,10 @@ SodaqUBeeR410M::SodaqUBeeR410M(Stream* modemStream, #ifdef MS_SODAQUBEER410M_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), _tinyModem(_modemATDebugger), - _tinyClient(_tinyModem) #else _tinyModem(*modemStream), - _tinyClient(_tinyModem) #endif + _tinyClient(_tinyModem) { _apn = apn; diff --git a/src/modems/SodaqUBeeU201.cpp b/src/modems/SodaqUBeeU201.cpp index d0a49a460..4d9481427 100644 --- a/src/modems/SodaqUBeeU201.cpp +++ b/src/modems/SodaqUBeeU201.cpp @@ -27,11 +27,10 @@ SodaqUBeeU201::SodaqUBeeU201(Stream* modemStream, #ifdef MS_SODAQUBEEU201_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), _tinyModem(_modemATDebugger), - _tinyClient(_tinyModem) #else _tinyModem(*modemStream), - _tinyClient(_tinyModem) #endif + _tinyClient(_tinyModem) { _apn = apn; } From 89b80512d53056ebc8bab1f605129eefebbec045 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 16 May 2019 11:31:14 -0400 Subject: [PATCH 26/88] All examples have explicit client --- examples/DRWI_CitSci/DRWI_CitSci.ino | 2 +- examples/DRWI_LTE/DRWI_LTE.ino | 2 +- examples/baro_rho_correction/baro_rho_correction.ino | 2 +- examples/logging_to_MMW/logging_to_MMW.ino | 2 +- examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino | 2 +- examples/menu_a_la_carte/menu_a_la_carte.ino | 6 +++--- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/DRWI_CitSci/DRWI_CitSci.ino b/examples/DRWI_CitSci/DRWI_CitSci.ino index e0a4a1411..207bff83c 100644 --- a/examples/DRWI_CitSci/DRWI_CitSci.ino +++ b/examples/DRWI_CitSci/DRWI_CitSci.ino @@ -182,7 +182,7 @@ const char *samplingFeature = "12345678-abcd-1234-efgh-1234567890ab"; // Sam // Create a data publisher for the EnviroDIY/WikiWatershed POST endpoint #include -EnviroDIYPublisher EnviroDIYPOST(dataLogger, registrationToken, samplingFeature); +EnviroDIYPublisher EnviroDIYPOST(dataLogger, modem._tinyClient, registrationToken, samplingFeature); // ========================================================================== diff --git a/examples/DRWI_LTE/DRWI_LTE.ino b/examples/DRWI_LTE/DRWI_LTE.ino index aedd86c81..fdd571496 100644 --- a/examples/DRWI_LTE/DRWI_LTE.ino +++ b/examples/DRWI_LTE/DRWI_LTE.ino @@ -185,7 +185,7 @@ const char *samplingFeature = "12345678-abcd-1234-efgh-1234567890ab"; // Sam // Create a data publisher for the EnviroDIY/WikiWatershed POST endpoint #include -EnviroDIYPublisher EnviroDIYPOST(dataLogger, registrationToken, samplingFeature); +EnviroDIYPublisher EnviroDIYPOST(dataLogger, modem._tinyClient, registrationToken, samplingFeature); // ========================================================================== diff --git a/examples/baro_rho_correction/baro_rho_correction.ino b/examples/baro_rho_correction/baro_rho_correction.ino index d6ec9a26c..d1a2dd169 100644 --- a/examples/baro_rho_correction/baro_rho_correction.ino +++ b/examples/baro_rho_correction/baro_rho_correction.ino @@ -307,7 +307,7 @@ const char *samplingFeature = "12345678-abcd-1234-efgh-1234567890ab"; // Sam // Create a data publisher for the EnviroDIY/WikiWatershed POST endpoint #include -EnviroDIYPublisher EnviroDIYPOST(dataLogger, registrationToken, samplingFeature); +EnviroDIYPublisher EnviroDIYPOST(dataLogger, modem._tinyClient, registrationToken, samplingFeature); // ========================================================================== diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index 413b82421..82c1ca3d3 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -179,7 +179,7 @@ const char *samplingFeature = "12345678-abcd-1234-efgh-1234567890ab"; // Sam // Create a data publisher for the EnviroDIY/WikiWatershed POST endpoint #include -EnviroDIYPublisher EnviroDIYPOST(dataLogger, registrationToken, samplingFeature); +EnviroDIYPublisher EnviroDIYPOST(dataLogger, modem._tinyClient, registrationToken, samplingFeature); // ========================================================================== diff --git a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino index 087188c2b..00d3b45bf 100644 --- a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino +++ b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino @@ -287,7 +287,7 @@ void setup() // Begin the variable array[s], logger[s], and publisher[s] varArray.begin(variableCount, variableList); dataLogger.begin(LoggerID, loggingInterval, &varArray); - TsMqtt.begin(dataLogger, thingSpeakMQTTKey, thingSpeakChannelID, thingSpeakChannelKey); + TsMqtt.begin(dataLogger, modem._tinyClient, thingSpeakMQTTKey, thingSpeakChannelID, thingSpeakChannelKey); // Note: Please change these battery voltages to match your battery // Check that the battery is OK before powering the modem diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 6fb77b127..751b4b597 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1262,7 +1262,7 @@ const char *samplingFeature = "12345678-abcd-1234-efgh-1234567890ab"; // Sam // Create a data publisher for the EnviroDIY/WikiWatershed POST endpoint #include -EnviroDIYPublisher EnviroDIYPOST(dataLogger, registrationToken, samplingFeature); +EnviroDIYPublisher EnviroDIYPOST(dataLogger, modem._tinyClient, registrationToken, samplingFeature); // ========================================================================== @@ -1275,7 +1275,7 @@ const char * DreamHostPortalRX = "xxxx"; // Create a data publisher to DreamHost #include -DreamHostPublisher DreamHostGET(dataLogger, DreamHostPortalRX); +DreamHostPublisher DreamHostGET(dataLogger, modem._tinyClient, DreamHostPortalRX); // ========================================================================== @@ -1292,7 +1292,7 @@ const char *thingSpeakChannelKey = "XXXXXXXXXXXXXXXX"; // The Write API Key for // Create a data publisher for ThingSpeak #include -ThingSpeakPublisher TsMqtt(dataLogger, thingSpeakMQTTKey, thingSpeakChannelID, thingSpeakChannelKey); +ThingSpeakPublisher TsMqtt(dataLogger, modem._tinyClient, thingSpeakMQTTKey, thingSpeakChannelID, thingSpeakChannelKey); // ========================================================================== From 29e73ad9c135ef4c6a10af4a510c12481aa5a550 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 16 May 2019 11:37:32 -0400 Subject: [PATCH 27/88] Rename to make it look more different --- examples/DRWI_CitSci/DRWI_CitSci.ino | 2 +- examples/DRWI_LTE/DRWI_LTE.ino | 2 +- .../baro_rho_correction.ino | 2 +- examples/data_saving/data_saving.ino | 2 +- examples/logging_to_MMW/logging_to_MMW.ino | 2 +- .../logging_to_ThingSpeak.ino | 2 +- examples/menu_a_la_carte/menu_a_la_carte.ino | 6 +- src/LoggerModem.cpp | 8 +-- src/dataPublisherBase.cpp | 6 +- src/modems/DigiXBeeCellularBypass.cpp | 70 +++++++++---------- src/modems/DigiXBeeCellularBypass.h | 4 +- src/modems/DigiXBeeCellularTransparent.cpp | 58 +++++++-------- src/modems/DigiXBeeCellularTransparent.h | 4 +- src/modems/DigiXBeeWifi.cpp | 48 ++++++------- src/modems/DigiXBeeWifi.h | 4 +- src/modems/EspressifESP8266.cpp | 48 ++++++------- src/modems/EspressifESP8266.h | 4 +- src/modems/LoggerModemMacros.h | 44 ++++++------ src/modems/QuectelBG96.cpp | 12 ++-- src/modems/QuectelBG96.h | 4 +- src/modems/SIMComSIM7000.cpp | 12 ++-- src/modems/SIMComSIM7000.h | 4 +- src/modems/SIMComSIM800.cpp | 12 ++-- src/modems/SIMComSIM800.h | 4 +- src/modems/SequansMonarch.cpp | 12 ++-- src/modems/SequansMonarch.h | 4 +- src/modems/Sodaq2GBeeR6.cpp | 10 +-- src/modems/Sodaq2GBeeR6.h | 4 +- src/modems/SodaqUBeeR410M.cpp | 24 +++---- src/modems/SodaqUBeeR410M.h | 4 +- src/modems/SodaqUBeeU201.cpp | 12 ++-- src/modems/SodaqUBeeU201.h | 4 +- 32 files changed, 221 insertions(+), 217 deletions(-) diff --git a/examples/DRWI_CitSci/DRWI_CitSci.ino b/examples/DRWI_CitSci/DRWI_CitSci.ino index 207bff83c..ee8bf4a87 100644 --- a/examples/DRWI_CitSci/DRWI_CitSci.ino +++ b/examples/DRWI_CitSci/DRWI_CitSci.ino @@ -182,7 +182,7 @@ const char *samplingFeature = "12345678-abcd-1234-efgh-1234567890ab"; // Sam // Create a data publisher for the EnviroDIY/WikiWatershed POST endpoint #include -EnviroDIYPublisher EnviroDIYPOST(dataLogger, modem._tinyClient, registrationToken, samplingFeature); +EnviroDIYPublisher EnviroDIYPOST(dataLogger, &modem.gsmClient, registrationToken, samplingFeature); // ========================================================================== diff --git a/examples/DRWI_LTE/DRWI_LTE.ino b/examples/DRWI_LTE/DRWI_LTE.ino index fdd571496..d12a0134a 100644 --- a/examples/DRWI_LTE/DRWI_LTE.ino +++ b/examples/DRWI_LTE/DRWI_LTE.ino @@ -185,7 +185,7 @@ const char *samplingFeature = "12345678-abcd-1234-efgh-1234567890ab"; // Sam // Create a data publisher for the EnviroDIY/WikiWatershed POST endpoint #include -EnviroDIYPublisher EnviroDIYPOST(dataLogger, modem._tinyClient, registrationToken, samplingFeature); +EnviroDIYPublisher EnviroDIYPOST(dataLogger, &modem.gsmClient, registrationToken, samplingFeature); // ========================================================================== diff --git a/examples/baro_rho_correction/baro_rho_correction.ino b/examples/baro_rho_correction/baro_rho_correction.ino index d1a2dd169..e4608aca4 100644 --- a/examples/baro_rho_correction/baro_rho_correction.ino +++ b/examples/baro_rho_correction/baro_rho_correction.ino @@ -307,7 +307,7 @@ const char *samplingFeature = "12345678-abcd-1234-efgh-1234567890ab"; // Sam // Create a data publisher for the EnviroDIY/WikiWatershed POST endpoint #include -EnviroDIYPublisher EnviroDIYPOST(dataLogger, modem._tinyClient, registrationToken, samplingFeature); +EnviroDIYPublisher EnviroDIYPOST(dataLogger, &modem.gsmClient, registrationToken, samplingFeature); // ========================================================================== diff --git a/examples/data_saving/data_saving.ino b/examples/data_saving/data_saving.ino index c59ef0c8b..9ed422616 100644 --- a/examples/data_saving/data_saving.ino +++ b/examples/data_saving/data_saving.ino @@ -395,7 +395,7 @@ const char *samplingFeature = "12345678-abcd-1234-efgh-1234567890ab"; // Sam // Create a data publisher for the EnviroDIY/WikiWatershed POST endpoint // This is only attached to the logger with the shorter variable array #include -EnviroDIYPublisher EnviroDIYPOST(loggerToGo, registrationToken, samplingFeature); +EnviroDIYPublisher EnviroDIYPOST(loggerToGo, &modem.gsmClient, registrationToken, samplingFeature); // ========================================================================== diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index 82c1ca3d3..48f915aaa 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -179,7 +179,7 @@ const char *samplingFeature = "12345678-abcd-1234-efgh-1234567890ab"; // Sam // Create a data publisher for the EnviroDIY/WikiWatershed POST endpoint #include -EnviroDIYPublisher EnviroDIYPOST(dataLogger, modem._tinyClient, registrationToken, samplingFeature); +EnviroDIYPublisher EnviroDIYPOST(dataLogger, &modem.gsmClient, registrationToken, samplingFeature); // ========================================================================== diff --git a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino index 00d3b45bf..1a6dcf230 100644 --- a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino +++ b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino @@ -287,7 +287,7 @@ void setup() // Begin the variable array[s], logger[s], and publisher[s] varArray.begin(variableCount, variableList); dataLogger.begin(LoggerID, loggingInterval, &varArray); - TsMqtt.begin(dataLogger, modem._tinyClient, thingSpeakMQTTKey, thingSpeakChannelID, thingSpeakChannelKey); + TsMqtt.begin(dataLogger, &modem.gsmClient, thingSpeakMQTTKey, thingSpeakChannelID, thingSpeakChannelKey); // Note: Please change these battery voltages to match your battery // Check that the battery is OK before powering the modem diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 751b4b597..ca06b84a5 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1262,7 +1262,7 @@ const char *samplingFeature = "12345678-abcd-1234-efgh-1234567890ab"; // Sam // Create a data publisher for the EnviroDIY/WikiWatershed POST endpoint #include -EnviroDIYPublisher EnviroDIYPOST(dataLogger, modem._tinyClient, registrationToken, samplingFeature); +EnviroDIYPublisher EnviroDIYPOST(dataLogger, &modem.gsmClient, registrationToken, samplingFeature); // ========================================================================== @@ -1275,7 +1275,7 @@ const char * DreamHostPortalRX = "xxxx"; // Create a data publisher to DreamHost #include -DreamHostPublisher DreamHostGET(dataLogger, modem._tinyClient, DreamHostPortalRX); +DreamHostPublisher DreamHostGET(dataLogger, &modem.gsmClient, DreamHostPortalRX); // ========================================================================== @@ -1292,7 +1292,7 @@ const char *thingSpeakChannelKey = "XXXXXXXXXXXXXXXX"; // The Write API Key for // Create a data publisher for ThingSpeak #include -ThingSpeakPublisher TsMqtt(dataLogger, modem._tinyClient, thingSpeakMQTTKey, thingSpeakChannelID, thingSpeakChannelKey); +ThingSpeakPublisher TsMqtt(dataLogger, &modem.gsmClient, thingSpeakMQTTKey, thingSpeakChannelID, thingSpeakChannelKey); // ========================================================================== diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index c08152b97..9e1f40a80 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -345,7 +345,7 @@ bool loggerModem::isStable(bool debug) int16_t loggerModem::openTCP(const char *host, uint16_t port) { MS_DBG(F("Connecting to"), host, F("...")); - int16_t ret_val = _tinyClient->connect(host, port); + int16_t ret_val = gsmClient->connect(host, port); if (ret_val) MS_DBG(F("...Success!")); else MS_DBG(F("...Connection failed.")); return ret_val; @@ -355,7 +355,7 @@ int16_t loggerModem::openTCP(const char *host, uint16_t port) int16_t loggerModem::openTCP(IPAddress ip, uint16_t port) { MS_DBG(F("Connecting to"), ip, F("...")); - int16_t ret_val = _tinyClient->connect(ip, port); + int16_t ret_val = gsmClient->connect(ip, port); if (ret_val) MS_DBG(F("...Success!")); else MS_DBG(F("...Connection failed.")); return ret_val; @@ -364,8 +364,8 @@ int16_t loggerModem::openTCP(IPAddress ip, uint16_t port) void loggerModem::closeTCP(void) { - if (_tinyClient) - _tinyClient->stop(); + if (gsmClient) + gsmClient->stop(); MS_DBG(F("Closed TCP/IP.")); } ***/ diff --git a/src/dataPublisherBase.cpp b/src/dataPublisherBase.cpp index 2428ecd12..c1fbe8c36 100644 --- a/src/dataPublisherBase.cpp +++ b/src/dataPublisherBase.cpp @@ -119,6 +119,10 @@ void dataPublisher::printTxBuffer(Stream *stream) // This sends data on the "default" client of the modem int16_t dataPublisher::sendData() { - if (_inClient == NULL) return 0; + if (_inClient == NULL) + { + PRINTOUT(F("ERROR! No web client assigned to publish data!")); + return 0; + } else return sendData(_inClient); } diff --git a/src/modems/DigiXBeeCellularBypass.cpp b/src/modems/DigiXBeeCellularBypass.cpp index ca12adc69..1a489e458 100644 --- a/src/modems/DigiXBeeCellularBypass.cpp +++ b/src/modems/DigiXBeeCellularBypass.cpp @@ -22,11 +22,11 @@ DigiXBeeCellularBypass::DigiXBeeCellularBypass(Stream* modemStream, measurementsToAverage), #ifdef MS_DIGIXBEECELLULARBYPASS_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger), + gsmModem(_modemATDebugger), #else - _tinyModem(*modemStream), + gsmModem(*modemStream), #endif - _tinyClient(_tinyModem) + gsmClient(gsmModem) { _apn = apn; } @@ -46,71 +46,71 @@ bool DigiXBeeCellularBypass::extraModemSetup(void) bool success = true; delay(1010); // Wait the required guard time before entering command mode MS_DBG(F("Putting XBee into command mode...")); - _tinyModem.streamWrite(GF("+++")); // enter command mode - if (success &= _tinyModem.waitResponse(2000, F("OK\r")) == 1) + gsmModem.streamWrite(GF("+++")); // enter command mode + if (success &= gsmModem.waitResponse(2000, F("OK\r")) == 1) { MS_DBG(F("Setting I/O Pins...")); // Set DIO8 to be used for sleep requests // NOTE: Only pin 9/DIO8/DTR can be used for this function - _tinyModem.sendAT(F("D8"),1); - success &= _tinyModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(F("D8"),1); + success &= gsmModem.waitResponse(F("OK\r")) == 1; // Turn on status indication pin - it will be HIGH when the XBee is awake // NOTE: Only pin 13/ON/SLEEPnot/DIO9 can be used for this function - _tinyModem.sendAT(F("D9"),1); - success &= _tinyModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(F("D9"),1); + success &= gsmModem.waitResponse(F("OK\r")) == 1; // Turn on CTS pin - it will be LOW when the XBee is ready to receive commands // This can be used as proxy for status indication if the true status pin is not accessible // NOTE: Only pin 12/DIO7/CTS can be used for this function - _tinyModem.sendAT(F("D7"),1); - success &= _tinyModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(F("D7"),1); + success &= gsmModem.waitResponse(F("OK\r")) == 1; // Put the XBee in pin sleep mode MS_DBG(F("Setting Sleep Options...")); - _tinyModem.sendAT(F("SM"),1); - success &= _tinyModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(F("SM"),1); + success &= gsmModem.waitResponse(F("OK\r")) == 1; // Disassociate from network for lowest power deep sleep - _tinyModem.sendAT(F("SO"),0); - success &= _tinyModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(F("SO"),0); + success &= gsmModem.waitResponse(F("OK\r")) == 1; MS_DBG(F("Setting Other Options...")); // Disable remote manager, USB Direct, and LTE PSM // NOTE: LTE-M's PSM (Power Save Mode) sounds good, but there's no // easy way on the LTE-M Bee to wake the cell chip itself from PSM, // so we'll use the Digi pin sleep instead. - _tinyModem.sendAT(F("DO"),0); - success &= _tinyModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(F("DO"),0); + success &= gsmModem.waitResponse(F("OK\r")) == 1; // Make sure USB direct won't be pin enabled on XBee3 units - _tinyModem.sendAT(F("P0"),0); - success &= _tinyModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(F("P0"),0); + success &= gsmModem.waitResponse(F("OK\r")) == 1; // Make sure pins 7&8 are not set for USB direct on XBee3 units - _tinyModem.sendAT(F("P1"),0); - success &= _tinyModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(F("P1"),0); + success &= gsmModem.waitResponse(F("OK\r")) == 1; MS_DBG(F("Setting Cellular Carrier Options...")); // Cellular carrier profile - AT&T // Hologram says they can use any network, but I've never succeeded with anything but AT&T - _tinyModem.sendAT(F("CP"),2); - success &= _tinyModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(F("CP"),2); + success &= gsmModem.waitResponse(F("OK\r")) == 1; // Cellular network technology - LTE-M Only // LTE-M XBee connects much faster on AT&T/Hologram when set to LTE-M only (instead of LTE-M/NB IoT) - _tinyModem.sendAT(F("N#"),2); - success &= _tinyModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(F("N#"),2); + success &= gsmModem.waitResponse(F("OK\r")) == 1; MS_DBG(F("Turning on Bypass Mode...")); // Turn on bypass mode - _tinyModem.sendAT(F("AP5")); - success &= _tinyModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(F("AP5")); + success &= gsmModem.waitResponse(F("OK\r")) == 1; // Write changes to flash - _tinyModem.sendAT(F("WR")); - success &= _tinyModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(F("WR")); + success &= gsmModem.waitResponse(F("OK\r")) == 1; // Apply changes - _tinyModem.sendAT(F("AC")); - success &= _tinyModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(F("AC")); + success &= gsmModem.waitResponse(F("OK\r")) == 1; // Force reset to actually enter bypass mode - this effectively exits bypass mode MS_DBG(F("Resetting the module to reboot in bypass mode...")); - _tinyModem.sendAT(F("FR")); - success &= _tinyModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(F("FR")); + success &= gsmModem.waitResponse(F("OK\r")) == 1; delay(200); // Allow the unit to reset // re-initialize MS_DBG(F("Attempting to reconnect to the u-blox module...")); - success &= _tinyModem.init(); - _modemName = _tinyModem.getModemName(); + success &= gsmModem.init(); + _modemName = gsmModem.getModemName(); } else success = false; if (success) MS_DBG(F("... Setup successful!")); diff --git a/src/modems/DigiXBeeCellularBypass.h b/src/modems/DigiXBeeCellularBypass.h index 9e4ea3f15..645fe793f 100644 --- a/src/modems/DigiXBeeCellularBypass.h +++ b/src/modems/DigiXBeeCellularBypass.h @@ -54,8 +54,8 @@ class DigiXBeeCellularBypass : public DigiXBee StreamDebugger _modemATDebugger; #endif - TinyGsm _tinyModem; - TinyGsmClient _tinyClient; + TinyGsm gsmModem; + TinyGsmClient gsmClient; protected: bool didATRespond(void) override; diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index e31e02c5b..933a41e23 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -22,11 +22,11 @@ DigiXBeeCellularTransparent::DigiXBeeCellularTransparent(Stream* modemStream, measurementsToAverage), #ifdef MS_DIGIXBEECELLULARTRANSPARENT_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger), + gsmModem(_modemATDebugger), #else - _tinyModem(*modemStream), + gsmModem(*modemStream), #endif - _tinyClient(_tinyModem) + gsmClient(gsmModem) { _apn = apn; } @@ -44,60 +44,60 @@ bool DigiXBeeCellularTransparent::extraModemSetup(void) { bool success = true; MS_DBG(F("Initializing the XBee...")); - success &= _tinyModem.init(); // initialize - _modemName = _tinyModem.getModemName(); + success &= gsmModem.init(); // initialize + _modemName = gsmModem.getModemName(); MS_DBG(F("Putting XBee into command mode...")); - if (_tinyModem.commandMode()) + if (gsmModem.commandMode()) { MS_DBG(F("Setting I/O Pins...")); // Set DIO8 to be used for sleep requests // NOTE: Only pin 9/DIO8/DTR can be used for this function - _tinyModem.sendAT(F("D8"),1); - success &= _tinyModem.waitResponse() == 1; + gsmModem.sendAT(F("D8"),1); + success &= gsmModem.waitResponse() == 1; // Turn on status indication pin - it will be HIGH when the XBee is awake // NOTE: Only pin 13/ON/SLEEPnot/DIO9 can be used for this function - _tinyModem.sendAT(F("D9"),1); - success &= _tinyModem.waitResponse() == 1; + gsmModem.sendAT(F("D9"),1); + success &= gsmModem.waitResponse() == 1; // Turn on CTS pin - it will be LOW when the XBee is ready to receive commands // This can be used as proxy for status indication if the true status pin is not accessible // NOTE: Only pin 12/DIO7/CTS can be used for this function - _tinyModem.sendAT(F("D7"),1); - success &= _tinyModem.waitResponse() == 1; + gsmModem.sendAT(F("D7"),1); + success &= gsmModem.waitResponse() == 1; // Put the XBee in pin sleep mode MS_DBG(F("Setting Sleep Options...")); - _tinyModem.sendAT(F("SM"),1); - success &= _tinyModem.waitResponse() == 1; + gsmModem.sendAT(F("SM"),1); + success &= gsmModem.waitResponse() == 1; // Disassociate from network for lowest power deep sleep - _tinyModem.sendAT(F("SO"),0); - success &= _tinyModem.waitResponse() == 1; + gsmModem.sendAT(F("SO"),0); + success &= gsmModem.waitResponse() == 1; MS_DBG(F("Setting Other Options...")); // Disable remote manager, USB Direct, and LTE PSM // NOTE: LTE-M's PSM (Power Save Mode) sounds good, but there's no // easy way on the LTE-M Bee to wake the cell chip itself from PSM, // so we'll use the Digi pin sleep instead. - _tinyModem.sendAT(F("DO"),0); - success &= _tinyModem.waitResponse() == 1; + gsmModem.sendAT(F("DO"),0); + success &= gsmModem.waitResponse() == 1; // Make sure USB direct won't be pin enabled on XBee3 units - _tinyModem.sendAT(F("P0"),0); - success &= _tinyModem.waitResponse() == 1; + gsmModem.sendAT(F("P0"),0); + success &= gsmModem.waitResponse() == 1; // Make sure pins 7&8 are not set for USB direct on XBee3 units - _tinyModem.sendAT(F("P1"),0); - success &= _tinyModem.waitResponse() == 1; + gsmModem.sendAT(F("P1"),0); + success &= gsmModem.waitResponse() == 1; MS_DBG(F("Setting Cellular Carrier Options...")); // Cellular carrier profile - AT&T // Hologram says they can use any network, but I've never succeeded with anything but AT&T - _tinyModem.sendAT(F("CP"),2); - success &= _tinyModem.waitResponse() == 1; + gsmModem.sendAT(F("CP"),2); + success &= gsmModem.waitResponse() == 1; // Cellular network technology - LTE-M Only // LTE-M XBee connects much faster on AT&T/Hologram when set to LTE-M only (instead of LTE-M/NB IoT) - _tinyModem.sendAT(F("N#"),2); - success &= _tinyModem.waitResponse() == 1; + gsmModem.sendAT(F("N#"),2); + success &= gsmModem.waitResponse() == 1; // Put the network connection parameters into flash - success &= _tinyModem.gprsConnect(_apn); + success &= gsmModem.gprsConnect(_apn); // Write changes to flash and apply them - _tinyModem.writeChanges(); + gsmModem.writeChanges(); // Exit command mode - _tinyModem.exitCommand(); + gsmModem.exitCommand(); } else success = false; if (success) MS_DBG(F("... Setup successful!")); diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index a792849d4..7949f46f9 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -54,8 +54,8 @@ class DigiXBeeCellularTransparent : public DigiXBee StreamDebugger _modemATDebugger; #endif - TinyGsm _tinyModem; - TinyGsmClient _tinyClient; + TinyGsm gsmModem; + TinyGsmClient gsmClient; protected: bool didATRespond(void) override; diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index 4986b4e65..1e44dd3cd 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -23,11 +23,11 @@ DigiXBeeWifi::DigiXBeeWifi(Stream* modemStream, measurementsToAverage), #ifdef MS_DIGIXBEEWIFI_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger), + gsmModem(_modemATDebugger), #else - _tinyModem(*modemStream), + gsmModem(*modemStream), #endif - _tinyClient(_tinyModem) + gsmClient(gsmModem) { _ssid = ssid; _pwd = pwd; @@ -45,39 +45,39 @@ bool DigiXBeeWifi::extraModemSetup(void) { bool success = true; MS_DBG(F("Initializing the XBee...")); - success &= _tinyModem.init(); // initialize - _modemName = _tinyModem.getModemName(); + success &= gsmModem.init(); // initialize + _modemName = gsmModem.getModemName(); MS_DBG(F("Putting XBee into command mode...")); - if (_tinyModem.commandMode()) + if (gsmModem.commandMode()) { MS_DBG(F("Setting I/O Pins...")); // Set DIO8 to be used for sleep requests // NOTE: Only pin 9/DIO8/DTR can be used for this function - _tinyModem.sendAT(F("D8"),1); - success &= _tinyModem.waitResponse() == 1; + gsmModem.sendAT(F("D8"),1); + success &= gsmModem.waitResponse() == 1; // Turn on status indication pin - it will be HIGH when the XBee is awake // NOTE: Only pin 13/ON/SLEEPnot/DIO9 can be used for this function - _tinyModem.sendAT(F("D9"),1); - success &= _tinyModem.waitResponse() == 1; + gsmModem.sendAT(F("D9"),1); + success &= gsmModem.waitResponse() == 1; // Turn on CTS pin - it will be LOW when the XBee is ready to receive commands // This can be used as proxy for status indication if the true status pin is not accessible // NOTE: Only pin 12/DIO7/CTS can be used for this function - _tinyModem.sendAT(F("D7"),1); - success &= _tinyModem.waitResponse() == 1; + gsmModem.sendAT(F("D7"),1); + success &= gsmModem.waitResponse() == 1; // Put the XBee in pin sleep mode MS_DBG(F("Setting Sleep Options...")); - _tinyModem.sendAT(F("SM"),1); - success &= _tinyModem.waitResponse() == 1; + gsmModem.sendAT(F("SM"),1); + success &= gsmModem.waitResponse() == 1; // Disassociate from network for lowest power deep sleep - _tinyModem.sendAT(F("SO"),200); - success &= _tinyModem.waitResponse() == 1; + gsmModem.sendAT(F("SO"),200); + success &= gsmModem.waitResponse() == 1; MS_DBG(F("Setting Wifi Network Options...")); // Put the network connection parameters into flash - success &= _tinyModem.networkConnect(_ssid, _pwd); + success &= gsmModem.networkConnect(_ssid, _pwd); // Write changes to flash and apply them - _tinyModem.writeChanges(); + gsmModem.writeChanges(); // Exit command mode - _tinyModem.exitCommand(); + gsmModem.exitCommand(); } else success = false; if (success) MS_DBG(F("... Setup successful!")); @@ -104,17 +104,17 @@ bool DigiXBeeWifi::addSingleMeasurementResult(void) // Connecting to the Google DNS servers for now MS_DBG(F("Opening connection to check connection strength...")); bool usedGoogle = false; - if (!_tinyModem.gotIPforSavedHost()) + if (!gsmModem.gotIPforSavedHost()) { usedGoogle = true; IPAddress ip(8, 8, 8, 8); // This is the IP address of time-c-g.nist.gov - success &= _tinyClient.connect(ip, 80); + success &= gsmClient.connect(ip, 80); } - _tinyClient.print('!'); // Need to send something before connection is made + gsmClient.print('!'); // Need to send something before connection is made delay(100); // Need this delay! Can get away with 50, but 100 is safer. if (usedGoogle) { - _tinyClient.stop(); + gsmClient.stop(); } // Get signal quality @@ -123,7 +123,7 @@ bool DigiXBeeWifi::addSingleMeasurementResult(void) // The TinyGSM getSignalQuality function returns the same "no signal" // value (99 CSQ or 0 RSSI) in all 3 cases. MS_DBG(F("Getting signal quality:")); - signalQual = _tinyModem.getSignalQuality(); + signalQual = gsmModem.getSignalQuality(); MS_DBG(F("Raw signal quality:"), signalQual); // Convert signal quality to RSSI diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index aa51eef55..aea12ef10 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -54,8 +54,8 @@ class DigiXBeeWifi : public DigiXBee StreamDebugger _modemATDebugger; #endif - TinyGsm _tinyModem; - TinyGsmClient _tinyClient; + TinyGsm gsmModem; + TinyGsmClient gsmClient; protected: bool didATRespond(void) override; diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index f5f4a5123..129d15b10 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -29,11 +29,11 @@ EspressifESP8266::EspressifESP8266(Stream* modemStream, measurementsToAverage), #ifdef MS_ESPRESSIFESP8266_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger), + gsmModem(_modemATDebugger), #else - _tinyModem(*modemStream), + gsmModem(*modemStream), #endif - _tinyClient(_tinyModem) + gsmClient(gsmModem) { _ssid = ssid; _pwd = pwd; @@ -76,10 +76,10 @@ bool EspressifESP8266::ESPwaitForBoot(void) delay(2); } // Have to make sure echo is off or all AT commands will be confused - _tinyModem.sendAT(F("E0")); - success &= _tinyModem.waitResponse() == 1; + gsmModem.sendAT(F("E0")); + success &= gsmModem.waitResponse() == 1; // re-run init to set mux and station mode - success &= _tinyModem.init(); + success &= gsmModem.init(); } return success; } @@ -127,35 +127,35 @@ bool EspressifESP8266::modemSleepFxn(void) { uint32_t sleepSeconds = (((uint32_t)loggingInterval) * 60 * 1000) - 75000L; String sleepCommand = String(sleepSeconds); - _tinyModem.sendAT(F("+GSLP="), sleepCommand); + gsmModem.sendAT(F("+GSLP="), sleepCommand); // Power down for 1 minute less than logging interval // Better: Calculate length of loop and power down for logging interval - loop time - return _tinyModem.waitResponse() == 1; + return gsmModem.waitResponse() == 1; }*/ // Use this if you have an MCU pin connected to the ESP's reset pin to wake from deep sleep if (_modemResetPin >= 0) { - return _tinyModem.poweroff(); + return gsmModem.poweroff(); } // Use this if you don't have access to the ESP8266's reset pin for deep sleep but you // do have access to another GPIO pin for light sleep. This also sets up another // pin to view the sleep status. else if (_modemSleepRqPin >= 0 && _dataPin >= 0) { - _tinyModem.sendAT(F("+WAKEUPGPIO=1,"), String(_espSleepRqPin), F(",0,"), + gsmModem.sendAT(F("+WAKEUPGPIO=1,"), String(_espSleepRqPin), F(",0,"), String(_espStatusPin), ',', _statusLevel); - bool success = _tinyModem.waitResponse() == 1; - _tinyModem.sendAT(F("+SLEEP=1")); - success &= _tinyModem.waitResponse() == 1; + bool success = gsmModem.waitResponse() == 1; + gsmModem.sendAT(F("+SLEEP=1")); + success &= gsmModem.waitResponse() == 1; return success; } // Light sleep without the status pin else if (_modemSleepRqPin >= 0 && _dataPin < 0) { - _tinyModem.sendAT(F("+WAKEUPGPIO=1,"), String(_espSleepRqPin), F(",0")); - bool success = _tinyModem.waitResponse() == 1; - _tinyModem.sendAT(F("+SLEEP=1")); - success &= _tinyModem.waitResponse() == 1; + gsmModem.sendAT(F("+WAKEUPGPIO=1,"), String(_espSleepRqPin), F(",0")); + bool success = gsmModem.waitResponse() == 1; + gsmModem.sendAT(F("+SLEEP=1")); + success &= gsmModem.waitResponse() == 1; return success; } else // DON'T go to sleep if we can't wake up! @@ -168,25 +168,25 @@ bool EspressifESP8266::modemSleepFxn(void) // Set up the light-sleep status pin, if applicable bool EspressifESP8266::extraModemSetup(void) { - _tinyModem.init(); - _modemName = _tinyModem.getModemName(); + gsmModem.init(); + _modemName = gsmModem.getModemName(); // Slow down the baud rate for slow processors - and save the change to // the ESP's non-volatile memory so we don't have to do it every time // #if F_CPU == 8000000L // if (modemBaud > 57600) // { // _modemSerial->begin(modemBaud); - // _tinyModem.sendAT(F("+UART_DEF=9600,8,1,0,0")); - // _tinyModem.waitResponse(); + // gsmModem.sendAT(F("+UART_DEF=9600,8,1,0,0")); + // gsmModem.waitResponse(); // _modemSerial->end(); // _modemSerial->begin(9600); // } // #endif if (_powerPin < 0 && _modemResetPin < 0 && _modemSleepRqPin >= 0 && _dataPin >= 0) { - _tinyModem.sendAT(F("+WAKEUPGPIO=1,"), String(_espSleepRqPin), F(",0,"), + gsmModem.sendAT(F("+WAKEUPGPIO=1,"), String(_espSleepRqPin), F(",0,"), String(_espStatusPin), ',', _statusLevel); - _tinyModem.waitResponse(); + gsmModem.waitResponse(); } return true; } @@ -213,7 +213,7 @@ bool EspressifESP8266::startSingleMeasurement(void) // For the wifi modems, the SSID and password need to be set before they // can join a network. - success &= _tinyModem.networkConnect(_ssid, _pwd); + success &= gsmModem.networkConnect(_ssid, _pwd); // Mark the time that a measurement was requested _millisMeasurementRequested = millis(); diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h index da36a6687..1081a93f2 100644 --- a/src/modems/EspressifESP8266.h +++ b/src/modems/EspressifESP8266.h @@ -74,8 +74,8 @@ class EspressifESP8266 : public loggerModem StreamDebugger _modemATDebugger; #endif - TinyGsm _tinyModem; - TinyGsmClient _tinyClient; + TinyGsm gsmModem; + TinyGsmClient gsmClient; // Need the stream for tossing junk on boot Stream *_modemStream; diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 81baa5994..3c9e7920d 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -16,7 +16,7 @@ #define MS_MODEM_DID_AT_RESPOND(specificModem) \ bool specificModem::didATRespond(void) \ { \ - return _tinyModem.testAT(10); \ + return gsmModem.testAT(10); \ } @@ -24,13 +24,13 @@ bool specificModem::didATRespond(void) \ #define MS_MODEM_IS_INTERNET_AVAILABLE(specificModem) \ bool specificModem::isInternetAvailable(void) \ { \ - return _tinyModem.isGprsConnected(); \ + return gsmModem.isGprsConnected(); \ } #else #define MS_MODEM_IS_INTERNET_AVAILABLE(specificModem) \ bool specificModem::isInternetAvailable(void) \ { \ - return _tinyModem.isNetworkConnected(); \ + return gsmModem.isNetworkConnected(); \ } #endif @@ -94,8 +94,8 @@ bool specificModem::isMeasurementComplete(bool debug) \ /* If we're connected AND receiving valid signal strength, measurement is complete */ \ /* In theory these happen at the same time, but in reality one or the other */ \ /* may happen first. */ \ - bool isConnected = _tinyModem.isNetworkConnected(); \ - int signalResponse = _tinyModem.getSignalQuality(); \ + bool isConnected = gsmModem.isNetworkConnected(); \ + int signalResponse = gsmModem.getSignalQuality(); \ if (isConnected && signalResponse != 0 && signalResponse != 99) \ { \ if (debug) MS_DBG(F("It's been"), (elapsed_in_wait), F("ms, and"), \ @@ -147,7 +147,7 @@ bool specificModem::addSingleMeasurementResult(void) \ /* The TinyGSM getSignalQuality function returns the same "no signal" */ \ /* value (99 CSQ or 0 RSSI) in all 3 cases. */ \ MS_DBG(F("Getting signal quality:")); \ - signalQual = _tinyModem.getSignalQuality(); \ + signalQual = gsmModem.getSignalQuality(); \ MS_DBG(F("Raw signal quality:"), signalQual); \ \ /* Convert signal quality to RSSI, if necessary */ \ @@ -201,7 +201,7 @@ bool specificModem::addSingleMeasurementResult(void) \ /* Check that the modem is responding to AT commands. If not, give up. */ \ MS_START_DEBUG_TIMER; \ MS_DBG(F("\nWaiting for"), getSensorName(), F("to respond to AT commands...")); \ - if (!_tinyModem.testAT(_stabilizationTime_ms + 500)) \ + if (!gsmModem.testAT(_stabilizationTime_ms + 500)) \ { \ MS_DBG(F("No response to AT commands! Cannot connect to the internet!")); \ return false; \ @@ -218,7 +218,7 @@ bool specificModem::connectInternet(uint32_t maxConnectionTime) \ \ MS_DBG(F("\nWaiting up to"), maxConnectionTime/1000, \ F("seconds for internet availability...")); \ - if (_tinyModem.waitForNetwork(maxConnectionTime)) \ + if (gsmModem.waitForNetwork(maxConnectionTime)) \ { \ MS_DBG(F("... Connected after"), MS_PRINT_DEBUG_TIMER, \ F("milliseconds.")); \ @@ -240,11 +240,11 @@ bool specificModem::connectInternet(uint32_t maxConnectionTime) \ \ MS_DBG(F("\nWaiting up to"), maxConnectionTime/1000, \ F("seconds for cellular network registration...")); \ - if (_tinyModem.waitForNetwork(maxConnectionTime)) \ + if (gsmModem.waitForNetwork(maxConnectionTime)) \ { \ MS_DBG(F("... Registered after"), MS_PRINT_DEBUG_TIMER, \ F("milliseconds. Connecting to GPRS...")); \ - _tinyModem.gprsConnect(_apn, "", ""); \ + gsmModem.gprsConnect(_apn, "", ""); \ MS_DBG(F("... Connected after"), MS_PRINT_DEBUG_TIMER, \ F("milliseconds.")); \ return true; \ @@ -265,13 +265,13 @@ bool specificModem::connectInternet(uint32_t maxConnectionTime) \ MS_MODEM_CONNECT_INTERNET_FIRST_CHUNK \ \ MS_DBG(F("\nAttempting to connect to WiFi network...")); \ - if (!(_tinyModem.isNetworkConnected())) \ + if (!(gsmModem.isNetworkConnected())) \ { \ MS_DBG(F("Sending credentials...")); \ - while (!_tinyModem.networkConnect(_ssid, _pwd)) {}; \ + while (!gsmModem.networkConnect(_ssid, _pwd)) {}; \ MS_DBG(F("Waiting up to"), maxConnectionTime/1000, \ F("seconds for connection")); \ - if (!_tinyModem.waitForNetwork(maxConnectionTime)) \ + if (!gsmModem.waitForNetwork(maxConnectionTime)) \ { \ MS_DBG(F("... WiFi connection failed")); \ return false; \ @@ -289,7 +289,7 @@ bool specificModem::connectInternet(uint32_t maxConnectionTime) \ void specificModem::disconnectInternet(void) \ { \ MS_START_DEBUG_TIMER; \ - _tinyModem.gprsDisconnect(); \ + gsmModem.gprsDisconnect(); \ MS_DBG(F("Disconnected from cellular network after"), MS_PRINT_DEBUG_TIMER, \ F("milliseconds.")); \ } @@ -298,7 +298,7 @@ void specificModem::disconnectInternet(void) \ void specificModem::disconnectInternet(void) \ { \ MS_START_DEBUG_TIMER; \ - _tinyModem.networkDisconnect(); \ + gsmModem.networkDisconnect(); \ MS_DBG(F("Disconnected from WiFi network after"), MS_PRINT_DEBUG_TIMER, \ F("milliseconds.")); \ } @@ -331,21 +331,21 @@ uint32_t specificModem::getNISTTime(void) \ /* This is the IP address of time-c-g.nist.gov */ \ /* XBee's address lookup falters on time.nist.gov */ \ IPAddress ip(129, 6, 15, 30); \ - connectionMade = _tinyClient.connect(ip, 37); \ + connectionMade = gsmClient.connect(ip, 37); \ /* Need to send something before connection is made */ \ - _tinyClient.print('!'); \ + gsmClient.print('!'); \ /* Need this delay! Can get away with 50, but 100 is safer. */ \ delay(100); \ } \ - else connectionMade = _tinyClient.connect("time.nist.gov", 37); \ + else connectionMade = gsmClient.connect("time.nist.gov", 37); \ \ /* Wait up to 5 seconds for a response */ \ if (connectionMade) \ { \ uint32_t start = millis(); \ - while (_tinyClient && _tinyClient.available() < 4 && millis() - start < 5000L){} \ + while (gsmClient && gsmClient.available() < 4 && millis() - start < 5000L){} \ \ - if (_tinyClient.available() >= 4) \ + if (gsmClient.available() >= 4) \ { \ MS_DBG(F("\nNIST responded after"), millis() - start, F("ms")); \ /* Response is returned as 32-bit number as soon as connection is made */ \ @@ -354,7 +354,7 @@ uint32_t specificModem::getNISTTime(void) \ byte response[4] = {0}; \ for (uint8_t i = 0; i < 4; i++) \ { \ - response[i] = _tinyClient.read(); \ + response[i] = gsmClient.read(); \ MS_DBG(F("\nResponse Byte"), i, ':', (char)response[i], \ '=', response[i], '=', String(response[i], BIN)); \ secFrom1900 += 0x000000FF & response[i]; \ @@ -365,7 +365,7 @@ uint32_t specificModem::getNISTTime(void) \ secFrom1900, '=', String(secFrom1900, BIN)); \ \ /* Close the TCP connection, just in case */ \ - _tinyClient.stop(); \ + gsmClient.stop(); \ \ /* Return the timestamp */ \ uint32_t unixTimeStamp = secFrom1900 - 2208988800; \ diff --git a/src/modems/QuectelBG96.cpp b/src/modems/QuectelBG96.cpp index 67e63c1c7..357f97ce9 100644 --- a/src/modems/QuectelBG96.cpp +++ b/src/modems/QuectelBG96.cpp @@ -26,11 +26,11 @@ QuectelBG96::QuectelBG96(Stream* modemStream, measurementsToAverage), #ifdef MS_QUECTELBG96_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger), + gsmModem(_modemATDebugger), #else - _tinyModem(*modemStream), + gsmModem(*modemStream), #endif - _tinyClient(_tinyModem) + gsmClient(gsmModem) { _apn = apn; } @@ -65,7 +65,7 @@ bool QuectelBG96::modemSleepFxn(void) if (_modemSleepRqPin >= 0) // BG96 must have access to PWRKEY pin to sleep { // Easiest to just go to sleep with the AT command rather than using pins - return _tinyModem.poweroff(); + return gsmModem.poweroff(); } else // DON'T go to sleep if we can't wake up! { @@ -76,7 +76,7 @@ bool QuectelBG96::modemSleepFxn(void) bool QuectelBG96::extraModemSetup(void) { - _tinyModem.init(); - _modemName = _tinyModem.getModemName(); + gsmModem.init(); + _modemName = gsmModem.getModemName(); return true; } diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index 5096dfe78..bcb795f33 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -69,8 +69,8 @@ class QuectelBG96 : public loggerModem StreamDebugger _modemATDebugger; #endif - TinyGsm _tinyModem; - TinyGsmClient _tinyClient; + TinyGsm gsmModem; + TinyGsmClient gsmClient; protected: bool didATRespond(void) override; diff --git a/src/modems/SIMComSIM7000.cpp b/src/modems/SIMComSIM7000.cpp index 81e5da913..cebe8e219 100644 --- a/src/modems/SIMComSIM7000.cpp +++ b/src/modems/SIMComSIM7000.cpp @@ -26,11 +26,11 @@ SIMComSIM7000::SIMComSIM7000(Stream* modemStream, measurementsToAverage), #ifdef MS_SIMCOMSIM7000_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger), + gsmModem(_modemATDebugger), #else - _tinyModem(*modemStream), + gsmModem(*modemStream), #endif - _tinyClient(_tinyModem) + gsmClient(gsmModem) { _apn = apn; } @@ -64,7 +64,7 @@ bool SIMComSIM7000::modemSleepFxn(void) if (_modemSleepRqPin >= 0) // R410 must have access to PWRKEY pin to sleep { // Easiest to just go to sleep with the AT command rather than using pins - return _tinyModem.poweroff(); + return gsmModem.poweroff(); } else // DON'T go to sleep if we can't wake up! { @@ -75,7 +75,7 @@ bool SIMComSIM7000::modemSleepFxn(void) bool SIMComSIM7000::extraModemSetup(void) { - _tinyModem.init(); - _modemName = _tinyModem.getModemName(); + gsmModem.init(); + _modemName = gsmModem.getModemName(); return true; } diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h index 49efa9960..94183fbd6 100644 --- a/src/modems/SIMComSIM7000.h +++ b/src/modems/SIMComSIM7000.h @@ -68,8 +68,8 @@ class SIMComSIM7000 : public loggerModem StreamDebugger _modemATDebugger; #endif - TinyGsm _tinyModem; - TinyGsmClient _tinyClient; + TinyGsm gsmModem; + TinyGsmClient gsmClient; protected: bool didATRespond(void) override; diff --git a/src/modems/SIMComSIM800.cpp b/src/modems/SIMComSIM800.cpp index 962739d3f..4d3ee4069 100644 --- a/src/modems/SIMComSIM800.cpp +++ b/src/modems/SIMComSIM800.cpp @@ -28,11 +28,11 @@ SIMComSIM800::SIMComSIM800(Stream* modemStream, measurementsToAverage), #ifdef MS_SIMCOMSIM800_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger), + gsmModem(_modemATDebugger), #else - _tinyModem(*modemStream), + gsmModem(*modemStream), #endif - _tinyClient(_tinyModem) + gsmClient(gsmModem) { _apn = apn; } @@ -66,7 +66,7 @@ bool SIMComSIM800::modemSleepFxn(void) if (_modemSleepRqPin >= 0) // R410 must have access to PWRKEY pin to sleep { // Easiest to just go to sleep with the AT command rather than using pins - return _tinyModem.poweroff(); + return gsmModem.poweroff(); } else // DON'T go to sleep if we can't wake up! { @@ -77,7 +77,7 @@ bool SIMComSIM800::modemSleepFxn(void) bool SIMComSIM800::extraModemSetup(void) { - _tinyModem.init(); - _modemName = _tinyModem.getModemName(); + gsmModem.init(); + _modemName = gsmModem.getModemName(); return true; } diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index 74000c8ab..831de3a96 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -71,8 +71,8 @@ class SIMComSIM800 : public loggerModem StreamDebugger _modemATDebugger; #endif - TinyGsm _tinyModem; - TinyGsmClient _tinyClient; + TinyGsm gsmModem; + TinyGsmClient gsmClient; protected: bool didATRespond(void) override; diff --git a/src/modems/SequansMonarch.cpp b/src/modems/SequansMonarch.cpp index 93031399b..72d2c58ac 100644 --- a/src/modems/SequansMonarch.cpp +++ b/src/modems/SequansMonarch.cpp @@ -26,11 +26,11 @@ SequansMonarch::SequansMonarch(Stream* modemStream, measurementsToAverage), #ifdef MS_SEQUANSMONARCH_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger), + gsmModem(_modemATDebugger), #else - _tinyModem(*modemStream), + gsmModem(*modemStream), #endif - _tinyClient(_tinyModem) + gsmClient(gsmModem) { _apn = apn; } @@ -71,7 +71,7 @@ bool SequansMonarch::modemSleepFxn(void) if (_powerPin >= 0 || _modemSleepRqPin >= 0) // will go on with power on { // Easiest to just go to sleep with the AT command rather than using pins - return _tinyModem.poweroff(); + return gsmModem.poweroff(); } else // DON'T go to sleep if we can't wake up! { @@ -82,7 +82,7 @@ bool SequansMonarch::modemSleepFxn(void) bool SequansMonarch::extraModemSetup(void) { - _tinyModem.init(); - _modemName = _tinyModem.getModemName(); + gsmModem.init(); + _modemName = gsmModem.getModemName(); return true; } diff --git a/src/modems/SequansMonarch.h b/src/modems/SequansMonarch.h index c2b9a0fa4..82aec967a 100644 --- a/src/modems/SequansMonarch.h +++ b/src/modems/SequansMonarch.h @@ -69,8 +69,8 @@ class SequansMonarch : public loggerModem StreamDebugger _modemATDebugger; #endif - TinyGsm _tinyModem; - TinyGsmClient _tinyClient; + TinyGsm gsmModem; + TinyGsmClient gsmClient; protected: bool didATRespond(void) override; diff --git a/src/modems/Sodaq2GBeeR6.cpp b/src/modems/Sodaq2GBeeR6.cpp index ce7430e64..f7849d727 100644 --- a/src/modems/Sodaq2GBeeR6.cpp +++ b/src/modems/Sodaq2GBeeR6.cpp @@ -27,11 +27,11 @@ Sodaq2GBeeR6::Sodaq2GBeeR6(Stream* modemStream, measurementsToAverage), #ifdef MS_SODAQ2GBEER6_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger), + gsmModem(_modemATDebugger), #else - _tinyModem(*modemStream), + gsmModem(*modemStream), #endif - _tinyClient(_tinyModem) + gsmClient(gsmModem) { _apn = apn; } @@ -63,7 +63,7 @@ bool Sodaq2GBeeR6::modemSleepFxn(void) bool Sodaq2GBeeR6::extraModemSetup(void) { - _tinyModem.init(); - _modemName = _tinyModem.getModemName(); + gsmModem.init(); + _modemName = gsmModem.getModemName(); return true; } diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h index 3070ac8da..b3cc5e5cf 100644 --- a/src/modems/Sodaq2GBeeR6.h +++ b/src/modems/Sodaq2GBeeR6.h @@ -70,8 +70,8 @@ class Sodaq2GBeeR6 : public loggerModem StreamDebugger _modemATDebugger; #endif - TinyGsm _tinyModem; - TinyGsmClient _tinyClient; + TinyGsm gsmModem; + TinyGsmClient gsmClient; protected: bool didATRespond(void) override; diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp index 02c0a7e48..808873733 100644 --- a/src/modems/SodaqUBeeR410M.cpp +++ b/src/modems/SodaqUBeeR410M.cpp @@ -27,11 +27,11 @@ SodaqUBeeR410M::SodaqUBeeR410M(HardwareSerial* modemStream, measurementsToAverage), #ifdef MS_SODAQUBEER410M_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger), + gsmModem(_modemATDebugger), #else - _tinyModem(*modemStream), + gsmModem(*modemStream), #endif - _tinyClient(_tinyModem) + gsmClient(gsmModem) { _apn = apn; } @@ -49,11 +49,11 @@ SodaqUBeeR410M::SodaqUBeeR410M(Stream* modemStream, measurementsToAverage), #ifdef MS_SODAQUBEER410M_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger), + gsmModem(_modemATDebugger), #else - _tinyModem(*modemStream), + gsmModem(*modemStream), #endif - _tinyClient(_tinyModem) + gsmClient(gsmModem) { _apn = apn; @@ -89,7 +89,7 @@ bool SodaqUBeeR410M::modemWakeFxn(void) { delay(4600); // Must wait for UART port to become active _modemSerial->begin(115200); - _tinyModem.setBaud(9600); + gsmModem.setBaud(9600); _modemSerial->end(); _modemSerial->begin(9600); } @@ -108,7 +108,7 @@ bool SodaqUBeeR410M::modemSleepFxn(void) if (_modemSleepRqPin >= 0) // R410 must have access to PWR_ON pin to sleep { // Easiest to just go to sleep with the AT command rather than using pins - return _tinyModem.poweroff(); + return gsmModem.poweroff(); } else // DON'T go to sleep if we can't wake up! { @@ -119,10 +119,10 @@ bool SodaqUBeeR410M::modemSleepFxn(void) bool SodaqUBeeR410M::extraModemSetup(void) { - _tinyModem.init(); - _modemName = _tinyModem.getModemName(); + gsmModem.init(); + _modemName = gsmModem.getModemName(); // Set to only use LTE-M, which should cause connection more quickly - _tinyModem.sendAT(F("+URAT=7")); - _tinyModem.waitResponse(); + gsmModem.sendAT(F("+URAT=7")); + gsmModem.waitResponse(); return true; } diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index 6bb9fe0d8..bb8129741 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -80,8 +80,8 @@ class SodaqUBeeR410M : public loggerModem StreamDebugger _modemATDebugger; #endif - TinyGsm _tinyModem; - TinyGsmClient _tinyClient; + TinyGsm gsmModem; + TinyGsmClient gsmClient; #if F_CPU == 8000000L HardwareSerial *_modemSerial; diff --git a/src/modems/SodaqUBeeU201.cpp b/src/modems/SodaqUBeeU201.cpp index 4d9481427..187af694c 100644 --- a/src/modems/SodaqUBeeU201.cpp +++ b/src/modems/SodaqUBeeU201.cpp @@ -26,11 +26,11 @@ SodaqUBeeU201::SodaqUBeeU201(Stream* modemStream, measurementsToAverage), #ifdef MS_SODAQUBEEU201_DEBUG_DEEP _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), - _tinyModem(_modemATDebugger), + gsmModem(_modemATDebugger), #else - _tinyModem(*modemStream), + gsmModem(*modemStream), #endif - _tinyClient(_tinyModem) + gsmClient(gsmModem) { _apn = apn; } @@ -72,7 +72,7 @@ bool SodaqUBeeU201::modemSleepFxn(void) if (_powerPin >= 0 || _modemSleepRqPin >= 0) // will go on with power on { // Easiest to just go to sleep with the AT command rather than using pins - return _tinyModem.poweroff(); + return gsmModem.poweroff(); } else // DON'T go to sleep if we can't wake up! { @@ -83,7 +83,7 @@ bool SodaqUBeeU201::modemSleepFxn(void) bool SodaqUBeeU201::extraModemSetup(void) { - _tinyModem.init(); - _modemName = _tinyModem.getModemName(); + gsmModem.init(); + _modemName = gsmModem.getModemName(); return true; } diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index 3668625e9..9cb5e3ad6 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -74,8 +74,8 @@ class SodaqUBeeU201 : public loggerModem StreamDebugger _modemATDebugger; #endif - TinyGsm _tinyModem; - TinyGsmClient _tinyClient; + TinyGsm gsmModem; + TinyGsmClient gsmClient; protected: bool didATRespond(void) override; From 250649bfe0ec3dfcc7da1e1cf349e44721d3558d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 16 May 2019 13:13:17 -0400 Subject: [PATCH 28/88] Never let XBee disconnect, even in bypass --- src/LoggerModem.h | 2 +- src/modems/DigiXBee.h | 2 +- src/modems/DigiXBeeCellularBypass.cpp | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/LoggerModem.h b/src/LoggerModem.h index 633b66d1b..9984b6e34 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -13,7 +13,7 @@ #define LoggerModem_h // FOR DEBUGGING -#define MS_LOGGERMODEM_DEBUG +// #define MS_LOGGERMODEM_DEBUG // #define MS_LOGGERMODEM_DEBUG_DEEP #ifdef MS_LOGGERMODEM_DEBUG diff --git a/src/modems/DigiXBee.h b/src/modems/DigiXBee.h index bb207ddff..3ee0d0afc 100644 --- a/src/modems/DigiXBee.h +++ b/src/modems/DigiXBee.h @@ -25,7 +25,7 @@ // on the application / network settings and the concurrent module // activities." Vint/status pin should be monitored and power not withdrawn // until that pin reads low. Giving 15sec here in case it is not monitored. -#define XBEE_DISCONNECT_TIME_MS 5000L +#define XBEE_DISCONNECT_TIME_MS 15000L // Time after power-up before we can wake the model #define XBEE_WARM_UP_TIME_MS 0 diff --git a/src/modems/DigiXBeeCellularBypass.cpp b/src/modems/DigiXBeeCellularBypass.cpp index 1a489e458..760a9b9cc 100644 --- a/src/modems/DigiXBeeCellularBypass.cpp +++ b/src/modems/DigiXBeeCellularBypass.cpp @@ -37,7 +37,6 @@ MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeCellularBypass); MS_MODEM_IS_MEASUREMENT_COMPLETE(DigiXBeeCellularBypass); MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(DigiXBeeCellularBypass); MS_MODEM_CONNECT_INTERNET(DigiXBeeCellularBypass); -MS_MODEM_DISCONNECT_INTERNET(DigiXBeeCellularBypass); MS_MODEM_GET_NIST_TIME(DigiXBeeCellularBypass); @@ -117,3 +116,9 @@ bool DigiXBeeCellularBypass::extraModemSetup(void) else MS_DBG(F("... failed!")); return success; } + + +void DigiXBeeCellularBypass::disconnectInternet(void) +{ + // XBee doesn't like to disconnect at all, so we're doing nothing +} From c6842e68abc98e0515a0addabc2c3875bb193885 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 16 May 2019 13:28:50 -0400 Subject: [PATCH 29/88] Moved setup check to startMeasurement instead of wake --- src/SensorBase.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 5a57cfa58..1a1d2b23c 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -210,15 +210,6 @@ bool Sensor::wake(void) // Set the status bit for sensor wake/activation success (bit 4) _sensorStatus |= 0b00010000; - // check if the sensor was successfully set up, run set up if not - // NOTE: we're setting the wake status bits and time regardless of the - // result of this setup attempt! - if (!bitRead(_sensorStatus, 0)) - { - MS_DBG(getSensorNameAndLocation(), F("was never properly set up, attempting setup now!")); - setup(); - } - return true; } @@ -250,6 +241,15 @@ bool Sensor::sleep(void) bool Sensor::startSingleMeasurement(void) { bool success = true; + + // check if the sensor was successfully set up, run set up if not + // NOTE: We continue regardless of the success of this attempt + if (!bitRead(_sensorStatus, 0)) + { + MS_DBG(getSensorNameAndLocation(), F("was never properly set up, attempting setup now!")); + setup(); + } + MS_DBG(F("Starting measurement on"), getSensorNameAndLocation()); // Set the status bits for measurement requested (bit 5) // Setting this bit even if we failed to start a measurement to show that an attempt was made. From c4e6c8e8bd80c50b95c9e1128bc3344f59c4ad97 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 16 May 2019 14:02:22 -0400 Subject: [PATCH 30/88] Setup/wake cleaning --- src/LoggerModem.cpp | 41 ++------------------------------ src/LoggerModem.h | 4 ---- src/modems/EspressifESP8266.cpp | 32 ++++++++++--------------- src/sensors/BoschBME280.cpp | 5 ++-- src/sensors/MaxBotixSonar.cpp | 5 ++-- src/sensors/TIINA219.cpp | 5 ++-- src/sensors/YosemitechParent.cpp | 5 ++-- 7 files changed, 22 insertions(+), 75 deletions(-) diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index 9e1f40a80..351160b9a 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -160,9 +160,8 @@ bool loggerModem::setup(void) // There are so many ways to wake a modem that we're requiring an input function bool loggerModem::wake(void) { - // Sensor::wake() checks if the power pin is on, setup has been successful, - // and sets the wake timestamp and status bits. If it returns false, - // there's no reason to go on. + // Sensor::wake() checks if the power pin is on and sets the wake timestamp + // and status bits. If it returns false, there's no reason to go on. if (!Sensor::wake()) return false; // NOTE: This is the ONLY place _millisSensorActivated is set! // NOTE: This is the ONLY place bit 4 is set! @@ -229,42 +228,6 @@ void loggerModem::powerDown(void) } -bool loggerModem::startSingleMeasurement(void) -{ - bool success = true; - MS_DBG(F("Starting measurement on"), getSensorName()); - // Set the status bits for measurement requested (bit 5) - // Setting this bit even if we failed to start a measurement to show that an attempt was made. - _sensorStatus |= 0b00100000; - - // Check if the modem was successfully awoken (bit 4 set) - // Only mark the measurement request time if it is - if (bitRead(_sensorStatus, 4)) - { - // check if the modem was successfully set up, run set up if not - if (!bitRead(_sensorStatus, 0)) - { - MS_DBG(getSensorName(), F("was never properly set up, attempting setup now!")); - setup(); - } - // Mark the time that a measurement was requested - _millisMeasurementRequested = millis(); - // Set the status bit for measurement start success (bit 6) - _sensorStatus |= 0b01000000; - } - // Otherwise, make sure that the measurement start time and success bit (bit 6) are unset - else - { - MS_DBG(getSensorNameAndLocation(), - F("isn't awake/active! A measurement cannot be started.")); - _millisMeasurementRequested = 0; - _sensorStatus &= 0b10111111; - success = false; - } - return success; -} - - // This checks to see if enough time has passed for stability // In the case of the modem, we consider it to be "stable" when it responds to // AT commands diff --git a/src/LoggerModem.h b/src/LoggerModem.h index 9984b6e34..16ab07af2 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -74,10 +74,6 @@ class loggerModem : public Sensor void powerUp(void) override; void powerDown(void) override; - // Turns modem signal strength into a measurement - virtual bool startSingleMeasurement(void) override; - virtual bool addSingleMeasurementResult(void) = 0; - protected: // We override these because the modem can tell us if it's ready or not diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index 129d15b10..d27f6c590 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -194,40 +194,32 @@ bool EspressifESP8266::extraModemSetup(void) bool EspressifESP8266::startSingleMeasurement(void) { + // Sensor::startSingleMeasurement() checks that if it's awake/active and sets + // the timestamp and status bits. If it returns false, there's no reason to go on. + if (!Sensor::startSingleMeasurement()) return false; + bool success = true; MS_DBG(F("Starting measurement on"), getSensorName()); // Set the status bits for measurement requested (bit 5) // Setting this bit even if we failed to start a measurement to show that an attempt was made. _sensorStatus |= 0b00100000; - // Check if the modem was successfully awoken (bit 4 set) - // Only mark the measurement request time if it is - if (bitRead(_sensorStatus, 4)) - { - // check if the modem was successfully set up, run set up if not - if (!bitRead(_sensorStatus, 0)) - { - MS_DBG(getSensorName(), F("was never properly set up, attempting setup now!")); - setup(); - } - - // For the wifi modems, the SSID and password need to be set before they - // can join a network. - success &= gsmModem.networkConnect(_ssid, _pwd); + // The SSID and password need to be set before the ESP8266m can join a + //network and get signal strength + success &= gsmModem.networkConnect(_ssid, _pwd); - // Mark the time that a measurement was requested + if (success) + { + // Update the time that a measurement was requested _millisMeasurementRequested = millis(); - // Set the status bit for measurement start success (bit 6) - _sensorStatus |= 0b01000000; } // Otherwise, make sure that the measurement start time and success bit (bit 6) are unset else { - MS_DBG(getSensorNameAndLocation(), - F("isn't awake/active! A measurement cannot be started.")); + MS_DBG(getSensorNameAndLocation(), F("did not successfully start a measurement.")); _millisMeasurementRequested = 0; _sensorStatus &= 0b10111111; - success = false; } + return success; } diff --git a/src/sensors/BoschBME280.cpp b/src/sensors/BoschBME280.cpp index 4f296bb88..c479e6318 100644 --- a/src/sensors/BoschBME280.cpp +++ b/src/sensors/BoschBME280.cpp @@ -88,9 +88,8 @@ bool BoschBME280::setup(void) bool BoschBME280::wake(void) { - // Sensor::wake() checks if the power pin is on, setup has been successful, - // and sets the wake timestamp and status bits. If it returns false, - // there's no reason to go on. + // Sensor::wake() checks if the power pin is on and sets the wake timestamp + // and status bits. If it returns false, there's no reason to go on. if (!Sensor::wake()) return false; // Restart always needed after power-up to set sampling modes diff --git a/src/sensors/MaxBotixSonar.cpp b/src/sensors/MaxBotixSonar.cpp index a116363a3..63de7de5c 100644 --- a/src/sensors/MaxBotixSonar.cpp +++ b/src/sensors/MaxBotixSonar.cpp @@ -63,9 +63,8 @@ bool MaxBotixSonar::setup(void) // Parsing and tossing the header lines in the wake-up bool MaxBotixSonar::wake(void) { - // Sensor::wake() checks if the power pin is on, setup has been successful, - // and sets the wake timestamp and status bits. If it returns false, - // there's no reason to go on. + // Sensor::wake() checks if the power pin is on and sets the wake timestamp + // and status bits. If it returns false, there's no reason to go on. if (!Sensor::wake()) return false; // NOTE: After the power is turned on to the MaxBotix, it sends several lines diff --git a/src/sensors/TIINA219.cpp b/src/sensors/TIINA219.cpp index f6f989b25..16463a0b6 100644 --- a/src/sensors/TIINA219.cpp +++ b/src/sensors/TIINA219.cpp @@ -50,9 +50,8 @@ bool TIINA219::setup(void) bool TIINA219::wake(void) { - // Sensor::wake() checks if the power pin is on, setup has been successful, - // and sets the wake timestamp and status bits. If it returns false, - // there's no reason to go on. + // Sensor::wake() checks if the power pin is on and sets the wake timestamp + // and status bits. If it returns false, there's no reason to go on. if (!Sensor::wake()) return false; // Begin/Init needs to be rerun after every power-up to set the calibration diff --git a/src/sensors/YosemitechParent.cpp b/src/sensors/YosemitechParent.cpp index a29ca0172..bf366120a 100644 --- a/src/sensors/YosemitechParent.cpp +++ b/src/sensors/YosemitechParent.cpp @@ -80,9 +80,8 @@ bool YosemitechParent::setup(void) // Different from the standard in that it waits for warm up and starts measurements bool YosemitechParent::wake(void) { - // Sensor::wake() checks if the power pin is on, setup has been successful, - // and sets the wake timestamp and status bits. If it returns false, - // there's no reason to go on. + // Sensor::wake() checks if the power pin is on and sets the wake timestamp + // and status bits. If it returns false, there's no reason to go on. if (!Sensor::wake()) return false; // Send the command to begin taking readings, trying up to 5 times From b89c686996d5c9eebe2778f1a467c0a8f8a903a7 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 16 May 2019 14:13:40 -0400 Subject: [PATCH 31/88] Oops! Mixed up modem battery --- src/LoggerModem.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/LoggerModem.h b/src/LoggerModem.h index 16ab07af2..f53318003 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -198,14 +198,14 @@ class Modem_SignalPercent : public Variable const char *uuid = "", const char *varCode = "signalPercent") : Variable(parentSense, - (const uint8_t)MODEM_BATTERY_VAR_NUM, - (uint8_t)MODEM_BATTERY_RESOLUTION, + (const uint8_t)MODEM_PERCENT_SIGNAL_VAR_NUM, + (uint8_t)MODEM_PERCENT_SIGNAL_RESOLUTION, "signalPercent", "percent", varCode, uuid) {} Modem_SignalPercent() - : Variable((const uint8_t)MODEM_BATTERY_VAR_NUM, - (uint8_t)MODEM_BATTERY_RESOLUTION, + : Variable((const uint8_t)MODEM_PERCENT_SIGNAL_VAR_NUM, + (uint8_t)MODEM_PERCENT_SIGNAL_RESOLUTION, "signalPercent", "percent", "signalPercent") {} ~Modem_SignalPercent(){} @@ -220,14 +220,14 @@ class Modem_Battery : public Variable const char *uuid = "", const char *varCode = "modemBattery") : Variable(parentSense, - (const uint8_t)MODEM_PERCENT_SIGNAL_VAR_NUM, - (uint8_t)MODEM_PERCENT_SIGNAL_RESOLUTION, + (const uint8_t)MODEM_BATTERY_VAR_NUM, + (uint8_t)MODEM_BATTERY_RESOLUTION, "batteryVoltage", "volt", varCode, uuid) {} Modem_Battery() - : Variable((const uint8_t)MODEM_PERCENT_SIGNAL_VAR_NUM, - (uint8_t)MODEM_PERCENT_SIGNAL_RESOLUTION, + : Variable((const uint8_t)MODEM_BATTERY_VAR_NUM, + (uint8_t)MODEM_BATTERY_RESOLUTION, "batteryVoltage", "volt", "modemBattery") {} ~Modem_Battery(){} From c9cf5db2030ac0c342bbb047408683725b3623fa Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 16 May 2019 14:41:29 -0400 Subject: [PATCH 32/88] Debug print out filenames --- src/LoggerBase.h | 2 +- src/LoggerModem.h | 2 +- src/SensorBase.h | 2 +- src/VariableArray.h | 4 ++-- src/VariableBase.h | 2 +- src/dataPublisherBase.h | 2 +- src/modems/DigiXBee.h | 2 +- src/modems/DigiXBeeCellularBypass.h | 2 +- src/modems/DigiXBeeCellularTransparent.h | 2 +- src/modems/DigiXBeeWifi.h | 2 +- src/modems/EspressifESP8266.h | 2 +- src/modems/QuectelBG96.h | 2 +- src/modems/SIMComSIM7000.h | 2 +- src/modems/SIMComSIM800.h | 2 +- src/modems/SequansMonarch.h | 2 +- src/modems/Sodaq2GBeeR6.h | 2 +- src/modems/SodaqUBeeR410M.h | 4 ++-- src/modems/SodaqUBeeU201.h | 2 +- src/publishers/DreamHostPublisher.h | 2 +- src/publishers/EnviroDIYPublisher.h | 2 +- src/publishers/ThingSpeakPublisher.h | 2 +- src/sensors/AOSongAM2315.h | 2 +- src/sensors/AOSongDHT.h | 2 +- src/sensors/ApogeeSQ212.h | 2 +- src/sensors/AtlasParent.h | 2 +- src/sensors/AtlasScientificCO2.h | 2 +- src/sensors/AtlasScientificDO.h | 2 +- src/sensors/AtlasScientificEC.h | 2 +- src/sensors/AtlasScientificORP.h | 2 +- src/sensors/AtlasScientificRTD.h | 2 +- src/sensors/AtlasScientificpH.h | 2 +- src/sensors/BoschBME280.h | 2 +- src/sensors/CampbellOBS3.h | 2 +- src/sensors/Decagon5TM.h | 2 +- src/sensors/DecagonCTD.h | 2 +- src/sensors/DecagonES2.h | 2 +- src/sensors/ExternalVoltage.h | 2 +- src/sensors/FreescaleMPL115A2.h | 2 +- src/sensors/KellerAcculevel.h | 4 ++-- src/sensors/KellerNanolevel.h | 4 ++-- src/sensors/KellerParent.h | 4 ++-- src/sensors/MaxBotixSonar.h | 2 +- src/sensors/MaximDS18.h | 2 +- src/sensors/MaximDS3231.h | 2 +- src/sensors/MeaSpecMS5803.h | 2 +- src/sensors/ProcessorStats.h | 2 +- src/sensors/RainCounterI2C.h | 2 +- src/sensors/SDI12Sensors.h | 2 +- src/sensors/TIINA219.h | 2 +- src/sensors/YosemitechParent.h | 4 ++-- src/sensors/YosemitechY4000.h | 4 ++-- src/sensors/YosemitechY504.h | 4 ++-- src/sensors/YosemitechY510.h | 4 ++-- src/sensors/YosemitechY511.h | 4 ++-- src/sensors/YosemitechY514.h | 4 ++-- src/sensors/YosemitechY520.h | 4 ++-- src/sensors/YosemitechY532.h | 4 ++-- src/sensors/YosemitechY533.h | 4 ++-- src/sensors/YosemitechY550.h | 4 ++-- src/sensors/ZebraTechDOpto.h | 2 +- 60 files changed, 75 insertions(+), 75 deletions(-) diff --git a/src/LoggerBase.h b/src/LoggerBase.h index fcf33af9a..be0578a2a 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -16,7 +16,7 @@ // #define MS_LOGGERBASE_DEBUG #ifdef MS_LOGGERBASE_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "LoggerBase" #endif // Included Dependencies diff --git a/src/LoggerModem.h b/src/LoggerModem.h index f53318003..0129335ba 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -17,7 +17,7 @@ // #define MS_LOGGERMODEM_DEBUG_DEEP #ifdef MS_LOGGERMODEM_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "LoggerModem" #endif // Included Dependencies diff --git a/src/SensorBase.h b/src/SensorBase.h index f73d7975b..31b862f20 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -15,7 +15,7 @@ // #define MS_SENSORBASE_DEBUG #ifdef MS_SENSORBASE_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "SensorBase" #endif // Included Dependencies diff --git a/src/VariableArray.h b/src/VariableArray.h index db1de75ec..aa5c67d7b 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -16,11 +16,11 @@ // #define MS_VARIABLEARRAY_DEBUG_DEEP #ifdef MS_VARIABLEARRAY_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "VariableArray" #endif #ifdef MS_VARIABLEARRAY_DEBUG_DEEP -#define MS_DEBUGGING_DEEP +#define MS_DEBUGGING_DEEP "VariableArray" #endif // Included Dependencies diff --git a/src/VariableBase.h b/src/VariableBase.h index 4e8a8624e..f376d0975 100644 --- a/src/VariableBase.h +++ b/src/VariableBase.h @@ -15,7 +15,7 @@ // #define MS_VARIABLEBASE_DEBUG #ifdef MS_VARIABLEBASE_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "VariableBase" #endif // Forward Declared Dependences diff --git a/src/dataPublisherBase.h b/src/dataPublisherBase.h index 3ee0bb793..733d2eb4c 100644 --- a/src/dataPublisherBase.h +++ b/src/dataPublisherBase.h @@ -15,7 +15,7 @@ // #define MS_DATAPUBLISHERBASE_DEBUG #ifdef MS_DATAPUBLISHERBASE_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "dataPublisherBase" #endif // Send Buffer diff --git a/src/modems/DigiXBee.h b/src/modems/DigiXBee.h index 3ee0d0afc..d24a7f807 100644 --- a/src/modems/DigiXBee.h +++ b/src/modems/DigiXBee.h @@ -15,7 +15,7 @@ // #define MS_DIGIXBEE_DEBUG #ifdef MS_DIGIXBEE_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "DigiXBee" #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif diff --git a/src/modems/DigiXBeeCellularBypass.h b/src/modems/DigiXBeeCellularBypass.h index 645fe793f..3e7d1b0cc 100644 --- a/src/modems/DigiXBeeCellularBypass.h +++ b/src/modems/DigiXBeeCellularBypass.h @@ -16,7 +16,7 @@ // #define MS_DIGIXBEECELLULARBYPASS_DEBUG_DEEP #ifdef MS_DIGIXBEECELLULARBYPASS_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "DigiXBeeCellularBypass" #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index 7949f46f9..c769849a2 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -16,7 +16,7 @@ // #define MS_DIGIXBEECELLULARTRANSPARENT_DEBUG_DEEP #ifdef MS_DIGIXBEECELLULARTRANSPARENT_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "DigiXBeeCellularTransparent" #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index aea12ef10..f215c567a 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -16,7 +16,7 @@ // #define MS_DIGIXBEEWIFI_DEBUG_DEEP #ifdef MS_DIGIXBEEWIFI_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "DigiXBeeWifi" #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h index 1081a93f2..588f0c8b6 100644 --- a/src/modems/EspressifESP8266.h +++ b/src/modems/EspressifESP8266.h @@ -18,7 +18,7 @@ // #define MS_ESPRESSIFESP8266_DEBUG_DEEP #ifdef MS_ESPRESSIFESP8266_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "EspressifESP8266" #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index bcb795f33..f51d2a67c 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -17,7 +17,7 @@ // #define MS_QUECTELBG96_DEBUG_DEEP #ifdef MS_QUECTELBG96_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "QuectelBG96" #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h index 94183fbd6..23d1bbe75 100644 --- a/src/modems/SIMComSIM7000.h +++ b/src/modems/SIMComSIM7000.h @@ -16,7 +16,7 @@ // #define MS_SIMCOMSIM7000_DEBUG_DEEP #ifdef MS_SIMCOMSIM7000_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "SIMComSIM7000" #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index 831de3a96..9a6dc2cc1 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -18,7 +18,7 @@ // #define MS_SIMCOMSIM800_DEBUG_DEEP #ifdef MS_SIMCOMSIM800_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "SIMComSIM800" #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif diff --git a/src/modems/SequansMonarch.h b/src/modems/SequansMonarch.h index 82aec967a..ceaad307c 100644 --- a/src/modems/SequansMonarch.h +++ b/src/modems/SequansMonarch.h @@ -17,7 +17,7 @@ // #define MS_SEQUANSMONARCH_DEBUG_DEEP #ifdef MS_SEQUANSMONARCH_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "SequansMonarch" #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h index b3cc5e5cf..f82272b5c 100644 --- a/src/modems/Sodaq2GBeeR6.h +++ b/src/modems/Sodaq2GBeeR6.h @@ -17,7 +17,7 @@ // #define MS_SODAQ2GBEER6_DEBUG_DEEP #ifdef MS_SODAQ2GBEER6_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "Sodaq2GBeeR6" #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index bb8129741..7104386eb 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -16,7 +16,7 @@ // #define MS_SODAQUBEER410M_DEBUG_DEEP #ifdef MS_SODAQUBEER410M_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "SodaqUBeeR410M" #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif @@ -82,7 +82,7 @@ class SodaqUBeeR410M : public loggerModem TinyGsm gsmModem; TinyGsmClient gsmClient; - + #if F_CPU == 8000000L HardwareSerial *_modemSerial; #endif diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index 9cb5e3ad6..dcd93a0b3 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -16,7 +16,7 @@ // #define MS_SODAQUBEEU201_DEBUG_DEEP #ifdef MS_SODAQUBEEU201_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "SodaqUBeeU201" #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif diff --git a/src/publishers/DreamHostPublisher.h b/src/publishers/DreamHostPublisher.h index 9eb5c7b6e..2ca80512b 100644 --- a/src/publishers/DreamHostPublisher.h +++ b/src/publishers/DreamHostPublisher.h @@ -15,7 +15,7 @@ // #define MS_DREAMHOSTPUBLISHER_DEBUG #ifdef MS_DREAMHOSTPUBLISHER_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "DreamHostPublisher" #endif // Included Dependencies diff --git a/src/publishers/EnviroDIYPublisher.h b/src/publishers/EnviroDIYPublisher.h index 197d29317..9c98247c0 100644 --- a/src/publishers/EnviroDIYPublisher.h +++ b/src/publishers/EnviroDIYPublisher.h @@ -16,7 +16,7 @@ // #define MS_ENVIRODIYPUBLISHER_DEBUG #ifdef MS_ENVIRODIYPUBLISHER_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "EnviroDIYPublisher" #endif // Included Dependencies diff --git a/src/publishers/ThingSpeakPublisher.h b/src/publishers/ThingSpeakPublisher.h index 7fcd0d298..64c598d2b 100644 --- a/src/publishers/ThingSpeakPublisher.h +++ b/src/publishers/ThingSpeakPublisher.h @@ -15,7 +15,7 @@ // #define MS_THINGSPEAKPUBLISHER_DEBUG #ifdef MS_THINGSPEAKPUBLISHER_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "ThingSpeakPublisher" #endif // MQTT User Name diff --git a/src/sensors/AOSongAM2315.h b/src/sensors/AOSongAM2315.h index ec7318ec5..63906279d 100644 --- a/src/sensors/AOSongAM2315.h +++ b/src/sensors/AOSongAM2315.h @@ -30,7 +30,7 @@ // #define MS_AOSONGAM2315_DEBUG #ifdef MS_AOSONGAM2315_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "AOSongAM2315" #endif // Included Dependencies diff --git a/src/sensors/AOSongDHT.h b/src/sensors/AOSongDHT.h index a25082f4d..a9105ce7d 100644 --- a/src/sensors/AOSongDHT.h +++ b/src/sensors/AOSongDHT.h @@ -32,7 +32,7 @@ // #define MS_AOSONGDHT_DEBUG #ifdef MS_AOSONGDHT_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "AOSongDHT" #endif // Included Dependencies diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index 0ba774a20..525803135 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -37,7 +37,7 @@ // #define MS_APOGEESQ212_DEBUG #ifdef MS_APOGEESQ212_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "ApogeeSQ212" #endif // Included Dependencies diff --git a/src/sensors/AtlasParent.h b/src/sensors/AtlasParent.h index 0c1be3067..54230366d 100644 --- a/src/sensors/AtlasParent.h +++ b/src/sensors/AtlasParent.h @@ -20,7 +20,7 @@ // #define MS_ATLASPARENT_DEBUG #ifdef MS_ATLASPARENT_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "AtlasParent" #endif // Included Dependencies diff --git a/src/sensors/AtlasScientificCO2.h b/src/sensors/AtlasScientificCO2.h index 4fa70e73e..34b2684b5 100644 --- a/src/sensors/AtlasScientificCO2.h +++ b/src/sensors/AtlasScientificCO2.h @@ -19,7 +19,7 @@ // #define MS_ATLASSCIENTIFICCO2_DEBUG #ifdef MS_ATLASSCIENTIFICCO2_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "AtlasScientificCO2" #endif // Included Dependencies diff --git a/src/sensors/AtlasScientificDO.h b/src/sensors/AtlasScientificDO.h index 07f520ede..41db5c938 100644 --- a/src/sensors/AtlasScientificDO.h +++ b/src/sensors/AtlasScientificDO.h @@ -19,7 +19,7 @@ // #define MS_ATLASSCIENTIFICDO_DEBUG #ifdef MS_ATLASSCIENTIFICDO_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "AtlasScientificDO" #endif // Included Dependencies diff --git a/src/sensors/AtlasScientificEC.h b/src/sensors/AtlasScientificEC.h index c665d000e..1d5727327 100644 --- a/src/sensors/AtlasScientificEC.h +++ b/src/sensors/AtlasScientificEC.h @@ -20,7 +20,7 @@ // #define MS_ATLASSCIENTIFICEC_DEBUG #ifdef MS_ATLASSCIENTIFICEC_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "AtlasScientificEC" #endif // Included Dependencies diff --git a/src/sensors/AtlasScientificORP.h b/src/sensors/AtlasScientificORP.h index fbd2fdcdf..f24f59418 100644 --- a/src/sensors/AtlasScientificORP.h +++ b/src/sensors/AtlasScientificORP.h @@ -19,7 +19,7 @@ // #define MS_ATLASORP_DEBUG #ifdef MS_ATLASORP_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "AtlasScientificORP" #endif // Included Dependencies diff --git a/src/sensors/AtlasScientificRTD.h b/src/sensors/AtlasScientificRTD.h index 361031760..7f492a9f8 100644 --- a/src/sensors/AtlasScientificRTD.h +++ b/src/sensors/AtlasScientificRTD.h @@ -19,7 +19,7 @@ // #define MS_ATLASSCIENTIFICRTD_DEBUG #ifdef MS_ATLASSCIENTIFICRTD_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "AtlasScientificRTD" #endif // Included Dependencies diff --git a/src/sensors/AtlasScientificpH.h b/src/sensors/AtlasScientificpH.h index 6ef44fd41..a31ad9c99 100644 --- a/src/sensors/AtlasScientificpH.h +++ b/src/sensors/AtlasScientificpH.h @@ -19,7 +19,7 @@ // #define MS_ATLASSCIENTIFICPH_DEBUG #ifdef MS_ATLASSCIENTIFICPH_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "AtlasScientificpH" #endif // Included Dependencies diff --git a/src/sensors/BoschBME280.h b/src/sensors/BoschBME280.h index 634eaa61b..e23564da5 100644 --- a/src/sensors/BoschBME280.h +++ b/src/sensors/BoschBME280.h @@ -38,7 +38,7 @@ // #define MS_BOSCHBME280_DEBUG #ifdef MS_BOSCHBME280_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "BoschBME280" #endif // Included Dependencies diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 8956e751f..34c05414c 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -33,7 +33,7 @@ // #define MS_CAMPBELLOBS3_DEBUG #ifdef MS_CAMPBELLOBS3_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "CampbellOBS3" #endif // Included Dependencies diff --git a/src/sensors/Decagon5TM.h b/src/sensors/Decagon5TM.h index e3b4d3985..689c74917 100644 --- a/src/sensors/Decagon5TM.h +++ b/src/sensors/Decagon5TM.h @@ -34,7 +34,7 @@ // #define MS_DECAGON5TM_DEBUG #ifdef MS_DECAGON5TM_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "Decagon5TM" #endif // Included Dependencies diff --git a/src/sensors/DecagonCTD.h b/src/sensors/DecagonCTD.h index de5bf657f..01bbccc8c 100644 --- a/src/sensors/DecagonCTD.h +++ b/src/sensors/DecagonCTD.h @@ -38,7 +38,7 @@ // #define MS_DECAGONCTD_DEBUG #ifdef MS_DECAGONCTD_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "DecagonCTD" #endif // Included Dependencies diff --git a/src/sensors/DecagonES2.h b/src/sensors/DecagonES2.h index a148e0f60..5e5e20b5e 100644 --- a/src/sensors/DecagonES2.h +++ b/src/sensors/DecagonES2.h @@ -33,7 +33,7 @@ // #define MS_DECAGONES2_DEBUG #ifdef MS_DECAGONES2_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "DecagonES2" #endif // Included Dependencies diff --git a/src/sensors/ExternalVoltage.h b/src/sensors/ExternalVoltage.h index f374ffe62..956f9cfbe 100644 --- a/src/sensors/ExternalVoltage.h +++ b/src/sensors/ExternalVoltage.h @@ -58,7 +58,7 @@ // #define MS_EXTERNALVOLTAGE_DEBUG #ifdef MS_EXTERNALVOLTAGE_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "ExternalVoltage" #endif // Included Dependencies diff --git a/src/sensors/FreescaleMPL115A2.h b/src/sensors/FreescaleMPL115A2.h index d5f9fba85..b3ae7dc3f 100644 --- a/src/sensors/FreescaleMPL115A2.h +++ b/src/sensors/FreescaleMPL115A2.h @@ -29,7 +29,7 @@ // #define MS_FREESCALEMPL115A2_DEBUG #ifdef MS_FREESCALEMPL115A2_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "FreescaleMPL115A2" #endif // Included Dependencies diff --git a/src/sensors/KellerAcculevel.h b/src/sensors/KellerAcculevel.h index 0dc5b3d35..30b542714 100644 --- a/src/sensors/KellerAcculevel.h +++ b/src/sensors/KellerAcculevel.h @@ -23,11 +23,11 @@ // #define MS_KELLERACCULEVEL_DEBUG_DEEP #ifdef MS_KELLERACCULEVEL_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "KellerAcculevel" #endif #ifdef MS_KELLERACCULEVEL_DEBUG_DEEP -#define MS_DEBUGGING_DEEP +#define MS_DEBUGGING_DEEP "KellerAcculevel" #endif // Included Dependencies diff --git a/src/sensors/KellerNanolevel.h b/src/sensors/KellerNanolevel.h index 0b2fc0088..aecd6f6a1 100644 --- a/src/sensors/KellerNanolevel.h +++ b/src/sensors/KellerNanolevel.h @@ -23,11 +23,11 @@ // #define MS_KELLERNANOLEVEL_DEBUG_DEEP #ifdef MS_KELLERNANOLEVEL_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "KellerNanolevel" #endif #ifdef MS_KELLERNANOLEVEL_DEBUG_DEEP -#define MS_DEBUGGING_DEEP +#define MS_DEBUGGING_DEEP "KellerNanolevel" #endif // Included Dependencies diff --git a/src/sensors/KellerParent.h b/src/sensors/KellerParent.h index ad62d6b7f..484d53d64 100644 --- a/src/sensors/KellerParent.h +++ b/src/sensors/KellerParent.h @@ -24,11 +24,11 @@ // #define MS_KELLERPARENT_DEBUG_DEEP #ifdef MS_KELLERPARENT_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "KellerParent" #endif #ifdef MS_KELLERPARENT_DEBUG_DEEP -#define MS_DEBUGGING_DEEP +#define MS_DEBUGGING_DEEP "KellerParent" #endif // Included Dependencies diff --git a/src/sensors/MaxBotixSonar.h b/src/sensors/MaxBotixSonar.h index 0e4c55b50..ec4fec9bd 100644 --- a/src/sensors/MaxBotixSonar.h +++ b/src/sensors/MaxBotixSonar.h @@ -21,7 +21,7 @@ // #define MS_MAXBOTIXSONAR_DEBUG #ifdef MS_MAXBOTIXSONAR_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "MaxBotixSonar" #endif // Included Dependencies diff --git a/src/sensors/MaximDS18.h b/src/sensors/MaximDS18.h index e7220d562..10c39be01 100644 --- a/src/sensors/MaximDS18.h +++ b/src/sensors/MaximDS18.h @@ -29,7 +29,7 @@ // #define MS_MAXIMDS18_DEBUG #ifdef MS_MAXIMDS18_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "MaximDS18" #endif // Included Dependencies diff --git a/src/sensors/MaximDS3231.h b/src/sensors/MaximDS3231.h index c3bbe78fe..703fe222d 100644 --- a/src/sensors/MaximDS3231.h +++ b/src/sensors/MaximDS3231.h @@ -25,7 +25,7 @@ // #define MS_MAXIMDS3231_DEBUG #ifdef MS_MAXIMDS3231_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "MaximDS3231" #endif // Included Dependencies diff --git a/src/sensors/MeaSpecMS5803.h b/src/sensors/MeaSpecMS5803.h index 826645a35..632b5bffe 100644 --- a/src/sensors/MeaSpecMS5803.h +++ b/src/sensors/MeaSpecMS5803.h @@ -49,7 +49,7 @@ // #define MS_MEASSPECMS5803_DEBUG #ifdef MS_MEASSPECMS5803_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "MeaSpecMS5803" #endif // Included Dependencies diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index e6966ba54..10261e8b3 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -20,7 +20,7 @@ // #define MS_PROCESSORSTATS_DEBUG #ifdef MS_PROCESSORSTATS_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "ProcessorStats" #endif // Included Dependencies diff --git a/src/sensors/RainCounterI2C.h b/src/sensors/RainCounterI2C.h index 4d0a33100..7a66a7b53 100644 --- a/src/sensors/RainCounterI2C.h +++ b/src/sensors/RainCounterI2C.h @@ -25,7 +25,7 @@ // #define MS_RAINCOUNTERI2C_DEBUG #ifdef MS_RAINCOUNTERI2C_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "RainCounterI2C" #endif // Included Dependencies diff --git a/src/sensors/SDI12Sensors.h b/src/sensors/SDI12Sensors.h index d601fdb06..323109595 100644 --- a/src/sensors/SDI12Sensors.h +++ b/src/sensors/SDI12Sensors.h @@ -19,7 +19,7 @@ // #define MS_SDI12SENSORS_DEBUG #ifdef MS_SDI12SENSORS_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "SDI12Sensors" #endif // Included Dependencies diff --git a/src/sensors/TIINA219.h b/src/sensors/TIINA219.h index 3e61de480..2546cb585 100644 --- a/src/sensors/TIINA219.h +++ b/src/sensors/TIINA219.h @@ -33,7 +33,7 @@ // #define MS_TIINA219_DEBUG #ifdef MS_TIINA219_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "TIINA219" #endif // Included Dependencies diff --git a/src/sensors/YosemitechParent.h b/src/sensors/YosemitechParent.h index d2985f491..bc7386fbe 100644 --- a/src/sensors/YosemitechParent.h +++ b/src/sensors/YosemitechParent.h @@ -22,11 +22,11 @@ // #define MS_YOSEMITECHPARENT_DEBUG_DEEP #ifdef MS_YOSEMITECHPARENT_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "YosemitechParent" #endif #ifdef MS_YOSEMITECHPARENT_DEBUG_DEEP -#define MS_DEBUGGING_DEEP +#define MS_DEBUGGING_DEEP "YosemitechParent" #endif // Included Dependencies diff --git a/src/sensors/YosemitechY4000.h b/src/sensors/YosemitechY4000.h index 58e76c96e..1912e55f6 100644 --- a/src/sensors/YosemitechY4000.h +++ b/src/sensors/YosemitechY4000.h @@ -69,11 +69,11 @@ // #define MS_YOSEMITECHY4000_DEBUG_DEEP #ifdef MS_YOSEMITECHY4000_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "YosemitechY4000" #endif #ifdef MS_YOSEMITECHY4000_DEBUG_DEEP -#define MS_DEBUGGING_DEEP +#define MS_DEBUGGING_DEEP "YosemitechY4000" #endif // Included Dependencies diff --git a/src/sensors/YosemitechY504.h b/src/sensors/YosemitechY504.h index fb2b5dec0..d2ddf390c 100644 --- a/src/sensors/YosemitechY504.h +++ b/src/sensors/YosemitechY504.h @@ -36,11 +36,11 @@ // #define MS_YOSEMITECHY504_DEBUG_DEEP #ifdef MS_YOSEMITECHY504_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "YosemitechY504" #endif #ifdef MS_YOSEMITECHY504_DEBUG_DEEP -#define MS_DEBUGGING_DEEP +#define MS_DEBUGGING_DEEP "YosemitechY504" #endif // Included Dependencies diff --git a/src/sensors/YosemitechY510.h b/src/sensors/YosemitechY510.h index 0856b1786..dd3d20da0 100644 --- a/src/sensors/YosemitechY510.h +++ b/src/sensors/YosemitechY510.h @@ -36,11 +36,11 @@ // #define MS_YOSEMITECHY510B_DEBUG_DEEP #ifdef MS_YOSEMITECHY510B_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "YosemitechY510" #endif #ifdef MS_YOSEMITECHY510B_DEBUG_DEEP -#define MS_DEBUGGING_DEEP +#define MS_DEBUGGING_DEEP "YosemitechY510" #endif // Included Dependencies diff --git a/src/sensors/YosemitechY511.h b/src/sensors/YosemitechY511.h index 8e1c22a0c..5058bdb31 100644 --- a/src/sensors/YosemitechY511.h +++ b/src/sensors/YosemitechY511.h @@ -36,11 +36,11 @@ // #define MS_YOSEMITECHY511_DEBUG_DEEP #ifdef MS_YOSEMITECHY511_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "YosemitechY511" #endif #ifdef MS_YOSEMITECHY511_DEBUG_DEEP -#define MS_DEBUGGING_DEEP +#define MS_DEBUGGING_DEEP "YosemitechY511" #endif // Included Dependencies diff --git a/src/sensors/YosemitechY514.h b/src/sensors/YosemitechY514.h index afa360afe..906419b69 100644 --- a/src/sensors/YosemitechY514.h +++ b/src/sensors/YosemitechY514.h @@ -37,11 +37,11 @@ // #define MS_YOSEMITECHY514_DEBUG_DEEP #ifdef MS_YOSEMITECHY514_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "YosemitechY514" #endif #ifdef MS_YOSEMITECHY514_DEBUG_DEEP -#define MS_DEBUGGING_DEEP +#define MS_DEBUGGING_DEEP "YosemitechY514" #endif // Included Dependencies diff --git a/src/sensors/YosemitechY520.h b/src/sensors/YosemitechY520.h index 52b8ae94f..6e702b4c9 100644 --- a/src/sensors/YosemitechY520.h +++ b/src/sensors/YosemitechY520.h @@ -37,11 +37,11 @@ // #define MS_YOSEMITECHY520_DEBUG_DEEP #ifdef MS_YOSEMITECHY520_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "YosemitechY520" #endif #ifdef MS_YOSEMITECHY520_DEBUG_DEEP -#define MS_DEBUGGING_DEEP +#define MS_DEBUGGING_DEEP "YosemitechY520" #endif // Included Dependencies diff --git a/src/sensors/YosemitechY532.h b/src/sensors/YosemitechY532.h index faee581fb..fd2d53d13 100644 --- a/src/sensors/YosemitechY532.h +++ b/src/sensors/YosemitechY532.h @@ -37,11 +37,11 @@ // #define MS_YOSEMITECHY532_DEBUG_DEEP #ifdef MS_YOSEMITECHY532_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "YosemitechY532" #endif #ifdef MS_YOSEMITECHY532_DEBUG_DEEP -#define MS_DEBUGGING_DEEP +#define MS_DEBUGGING_DEEP "YosemitechY532" #endif // Included Dependencies diff --git a/src/sensors/YosemitechY533.h b/src/sensors/YosemitechY533.h index 221b8ce1d..01b35dc8d 100644 --- a/src/sensors/YosemitechY533.h +++ b/src/sensors/YosemitechY533.h @@ -42,11 +42,11 @@ // #define MS_YOSEMITECHY533_DEBUG_DEEP #ifdef MS_YOSEMITECHY533_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "YosemitechY533" #endif #ifdef MS_YOSEMITECHY533_DEBUG_DEEP -#define MS_DEBUGGING_DEEP +#define MS_DEBUGGING_DEEP "YosemitechY533" #endif // Included Dependencies diff --git a/src/sensors/YosemitechY550.h b/src/sensors/YosemitechY550.h index 3f0a64fa4..c43ed25a6 100644 --- a/src/sensors/YosemitechY550.h +++ b/src/sensors/YosemitechY550.h @@ -40,11 +40,11 @@ // #define MS_YOSEMITECHY550_DEBUG_DEEP #ifdef MS_YOSEMITECHY550_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "YosemitechY550" #endif #ifdef MS_YOSEMITECHY550_DEBUG_DEEP -#define MS_DEBUGGING_DEEP +#define MS_DEBUGGING_DEEP "YosemitechY550" #endif // Included Dependencies diff --git a/src/sensors/ZebraTechDOpto.h b/src/sensors/ZebraTechDOpto.h index d38d1b5b9..e485e65e1 100644 --- a/src/sensors/ZebraTechDOpto.h +++ b/src/sensors/ZebraTechDOpto.h @@ -40,7 +40,7 @@ // #define MS_ZEBRATECHDOPTO_DEBUG #ifdef MS_ZEBRATECHDOPTO_DEBUG -#define MS_DEBUGGING_STD +#define MS_DEBUGGING_STD "ZebraTechDOpto" #endif // Included Dependencies From 2f03efe97ffbe343bd76aa42a2b79db4d4e4949a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 16 May 2019 15:03:27 -0400 Subject: [PATCH 33/88] Mark header guard --- src/dataPublisherBase.h | 1 - src/modems/DigiXBee.h | 2 +- src/modems/DigiXBeeCellularBypass.h | 2 +- src/modems/DigiXBeeCellularTransparent.h | 2 +- src/modems/DigiXBeeWifi.h | 2 +- src/modems/EspressifESP8266.h | 2 +- src/modems/QuectelBG96.h | 2 +- src/modems/SIMComSIM7000.h | 2 +- src/modems/SIMComSIM800.h | 2 +- src/modems/SequansMonarch.h | 2 +- src/modems/Sodaq2GBeeR6.h | 2 +- src/modems/SodaqUBeeR410M.h | 2 +- src/modems/SodaqUBeeU201.h | 2 +- src/sensors/AtlasScientificCO2.h | 1 + src/sensors/AtlasScientificDO.h | 1 + src/sensors/AtlasScientificEC.h | 1 + src/sensors/AtlasScientificORP.h | 1 + src/sensors/AtlasScientificRTD.h | 1 + src/sensors/AtlasScientificpH.h | 1 + src/sensors/Decagon5TM.h | 1 + src/sensors/DecagonCTD.h | 1 + src/sensors/DecagonES2.h | 1 + src/sensors/KellerAcculevel.h | 1 + src/sensors/KellerNanolevel.h | 1 + src/sensors/YosemitechY4000.h | 1 + src/sensors/YosemitechY504.h | 1 + src/sensors/YosemitechY510.h | 1 + src/sensors/YosemitechY511.h | 1 + src/sensors/YosemitechY514.h | 1 + src/sensors/YosemitechY520.h | 1 + src/sensors/YosemitechY532.h | 1 + src/sensors/YosemitechY533.h | 1 + src/sensors/YosemitechY550.h | 1 + src/sensors/ZebraTechDOpto.h | 1 + 34 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/dataPublisherBase.h b/src/dataPublisherBase.h index 733d2eb4c..77d16e037 100644 --- a/src/dataPublisherBase.h +++ b/src/dataPublisherBase.h @@ -27,7 +27,6 @@ #define MS_SEND_BUFFER_SIZE 750 // Included Dependencies -//#include #include "ModSensorDebugger.h" #include "LoggerBase.h" #include "Client.h" diff --git a/src/modems/DigiXBee.h b/src/modems/DigiXBee.h index d24a7f807..a6336c689 100644 --- a/src/modems/DigiXBee.h +++ b/src/modems/DigiXBee.h @@ -55,4 +55,4 @@ class DigiXBee : public loggerModem virtual bool modemWakeFxn(void) override; }; -#endif +#endif // Header Guard diff --git a/src/modems/DigiXBeeCellularBypass.h b/src/modems/DigiXBeeCellularBypass.h index 3e7d1b0cc..1c9897ba9 100644 --- a/src/modems/DigiXBeeCellularBypass.h +++ b/src/modems/DigiXBeeCellularBypass.h @@ -67,4 +67,4 @@ class DigiXBeeCellularBypass : public DigiXBee }; -#endif +#endif // Header Guard diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index c769849a2..25759583d 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -67,4 +67,4 @@ class DigiXBeeCellularTransparent : public DigiXBee }; -#endif +#endif // Header Guard diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index f215c567a..bf7caaad4 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -68,4 +68,4 @@ class DigiXBeeWifi : public DigiXBee }; -#endif +#endif // Header Guard diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h index 588f0c8b6..c8b577748 100644 --- a/src/modems/EspressifESP8266.h +++ b/src/modems/EspressifESP8266.h @@ -97,4 +97,4 @@ class EspressifESP8266 : public loggerModem }; -#endif +#endif // Header Guard diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index f51d2a67c..dcf825fde 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -84,4 +84,4 @@ class QuectelBG96 : public loggerModem }; -#endif +#endif // Header Guard diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h index 23d1bbe75..cfb979f1e 100644 --- a/src/modems/SIMComSIM7000.h +++ b/src/modems/SIMComSIM7000.h @@ -83,4 +83,4 @@ class SIMComSIM7000 : public loggerModem }; -#endif +#endif // Header Guard diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index 9a6dc2cc1..422f1de5e 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -86,4 +86,4 @@ class SIMComSIM800 : public loggerModem }; -#endif +#endif // Header Guard diff --git a/src/modems/SequansMonarch.h b/src/modems/SequansMonarch.h index ceaad307c..148cb038d 100644 --- a/src/modems/SequansMonarch.h +++ b/src/modems/SequansMonarch.h @@ -84,4 +84,4 @@ class SequansMonarch : public loggerModem }; -#endif +#endif // Header Guard diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h index f82272b5c..f082f266a 100644 --- a/src/modems/Sodaq2GBeeR6.h +++ b/src/modems/Sodaq2GBeeR6.h @@ -85,4 +85,4 @@ class Sodaq2GBeeR6 : public loggerModem }; -#endif +#endif // Header Guard diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index 7104386eb..0f1f89036 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -99,4 +99,4 @@ class SodaqUBeeR410M : public loggerModem }; -#endif +#endif // Header Guard diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index dcd93a0b3..08501706b 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -89,4 +89,4 @@ class SodaqUBeeU201 : public loggerModem }; -#endif +#endif // Header Guard diff --git a/src/sensors/AtlasScientificCO2.h b/src/sensors/AtlasScientificCO2.h index 34b2684b5..752dcbb9a 100644 --- a/src/sensors/AtlasScientificCO2.h +++ b/src/sensors/AtlasScientificCO2.h @@ -23,6 +23,7 @@ #endif // Included Dependencies +#include "ModSensorDebugger.h" #include "VariableBase.h" #include "sensors/AtlasParent.h" diff --git a/src/sensors/AtlasScientificDO.h b/src/sensors/AtlasScientificDO.h index 41db5c938..1ae562487 100644 --- a/src/sensors/AtlasScientificDO.h +++ b/src/sensors/AtlasScientificDO.h @@ -23,6 +23,7 @@ #endif // Included Dependencies +#include "ModSensorDebugger.h" #include "VariableBase.h" #include "sensors/AtlasParent.h" diff --git a/src/sensors/AtlasScientificEC.h b/src/sensors/AtlasScientificEC.h index 1d5727327..fa0856dcf 100644 --- a/src/sensors/AtlasScientificEC.h +++ b/src/sensors/AtlasScientificEC.h @@ -24,6 +24,7 @@ #endif // Included Dependencies +#include "ModSensorDebugger.h" #include "VariableBase.h" #include "sensors/AtlasParent.h" diff --git a/src/sensors/AtlasScientificORP.h b/src/sensors/AtlasScientificORP.h index f24f59418..8b4fd26b9 100644 --- a/src/sensors/AtlasScientificORP.h +++ b/src/sensors/AtlasScientificORP.h @@ -23,6 +23,7 @@ #endif // Included Dependencies +#include "ModSensorDebugger.h" #include "VariableBase.h" #include "sensors/AtlasParent.h" diff --git a/src/sensors/AtlasScientificRTD.h b/src/sensors/AtlasScientificRTD.h index 7f492a9f8..a9f94cd8a 100644 --- a/src/sensors/AtlasScientificRTD.h +++ b/src/sensors/AtlasScientificRTD.h @@ -23,6 +23,7 @@ #endif // Included Dependencies +#include "ModSensorDebugger.h" #include "VariableBase.h" #include "sensors/AtlasParent.h" diff --git a/src/sensors/AtlasScientificpH.h b/src/sensors/AtlasScientificpH.h index a31ad9c99..a2573e6b8 100644 --- a/src/sensors/AtlasScientificpH.h +++ b/src/sensors/AtlasScientificpH.h @@ -23,6 +23,7 @@ #endif // Included Dependencies +#include "ModSensorDebugger.h" #include "VariableBase.h" #include "sensors/AtlasParent.h" diff --git a/src/sensors/Decagon5TM.h b/src/sensors/Decagon5TM.h index 689c74917..89359a40a 100644 --- a/src/sensors/Decagon5TM.h +++ b/src/sensors/Decagon5TM.h @@ -38,6 +38,7 @@ #endif // Included Dependencies +#include "ModSensorDebugger.h" #include "VariableBase.h" #include "sensors/SDI12Sensors.h" diff --git a/src/sensors/DecagonCTD.h b/src/sensors/DecagonCTD.h index 01bbccc8c..94059b738 100644 --- a/src/sensors/DecagonCTD.h +++ b/src/sensors/DecagonCTD.h @@ -42,6 +42,7 @@ #endif // Included Dependencies +#include "ModSensorDebugger.h" #include "VariableBase.h" #include "sensors/SDI12Sensors.h" diff --git a/src/sensors/DecagonES2.h b/src/sensors/DecagonES2.h index 5e5e20b5e..348c1900d 100644 --- a/src/sensors/DecagonES2.h +++ b/src/sensors/DecagonES2.h @@ -37,6 +37,7 @@ #endif // Included Dependencies +#include "ModSensorDebugger.h" #include "VariableBase.h" #include "sensors/SDI12Sensors.h" diff --git a/src/sensors/KellerAcculevel.h b/src/sensors/KellerAcculevel.h index 30b542714..5c3fdcf6f 100644 --- a/src/sensors/KellerAcculevel.h +++ b/src/sensors/KellerAcculevel.h @@ -31,6 +31,7 @@ #endif // Included Dependencies +#include "ModSensorDebugger.h" #include "VariableBase.h" #include "sensors/KellerParent.h" diff --git a/src/sensors/KellerNanolevel.h b/src/sensors/KellerNanolevel.h index aecd6f6a1..9372c56a1 100644 --- a/src/sensors/KellerNanolevel.h +++ b/src/sensors/KellerNanolevel.h @@ -31,6 +31,7 @@ #endif // Included Dependencies +#include "ModSensorDebugger.h" #include "VariableBase.h" #include "sensors/KellerParent.h" diff --git a/src/sensors/YosemitechY4000.h b/src/sensors/YosemitechY4000.h index 1912e55f6..7598d9cc6 100644 --- a/src/sensors/YosemitechY4000.h +++ b/src/sensors/YosemitechY4000.h @@ -77,6 +77,7 @@ #endif // Included Dependencies +#include "ModSensorDebugger.h" #include "VariableBase.h" #include "sensors/YosemitechParent.h" diff --git a/src/sensors/YosemitechY504.h b/src/sensors/YosemitechY504.h index d2ddf390c..65c24cfb6 100644 --- a/src/sensors/YosemitechY504.h +++ b/src/sensors/YosemitechY504.h @@ -44,6 +44,7 @@ #endif // Included Dependencies +#include "ModSensorDebugger.h" #include "VariableBase.h" #include "sensors/YosemitechParent.h" diff --git a/src/sensors/YosemitechY510.h b/src/sensors/YosemitechY510.h index dd3d20da0..03b4ccf73 100644 --- a/src/sensors/YosemitechY510.h +++ b/src/sensors/YosemitechY510.h @@ -44,6 +44,7 @@ #endif // Included Dependencies +#include "ModSensorDebugger.h" #include "VariableBase.h" #include "sensors/YosemitechParent.h" diff --git a/src/sensors/YosemitechY511.h b/src/sensors/YosemitechY511.h index 5058bdb31..e08cae580 100644 --- a/src/sensors/YosemitechY511.h +++ b/src/sensors/YosemitechY511.h @@ -44,6 +44,7 @@ #endif // Included Dependencies +#include "ModSensorDebugger.h" #include "VariableBase.h" #include "sensors/YosemitechParent.h" diff --git a/src/sensors/YosemitechY514.h b/src/sensors/YosemitechY514.h index 906419b69..7f0feb51b 100644 --- a/src/sensors/YosemitechY514.h +++ b/src/sensors/YosemitechY514.h @@ -45,6 +45,7 @@ #endif // Included Dependencies +#include "ModSensorDebugger.h" #include "VariableBase.h" #include "sensors/YosemitechParent.h" diff --git a/src/sensors/YosemitechY520.h b/src/sensors/YosemitechY520.h index 6e702b4c9..ed45f524e 100644 --- a/src/sensors/YosemitechY520.h +++ b/src/sensors/YosemitechY520.h @@ -45,6 +45,7 @@ #endif // Included Dependencies +#include "ModSensorDebugger.h" #include "VariableBase.h" #include "sensors/YosemitechParent.h" diff --git a/src/sensors/YosemitechY532.h b/src/sensors/YosemitechY532.h index fd2d53d13..d05ddfc05 100644 --- a/src/sensors/YosemitechY532.h +++ b/src/sensors/YosemitechY532.h @@ -45,6 +45,7 @@ #endif // Included Dependencies +#include "ModSensorDebugger.h" #include "VariableBase.h" #include "sensors/YosemitechParent.h" diff --git a/src/sensors/YosemitechY533.h b/src/sensors/YosemitechY533.h index 01b35dc8d..4974eb60a 100644 --- a/src/sensors/YosemitechY533.h +++ b/src/sensors/YosemitechY533.h @@ -50,6 +50,7 @@ #endif // Included Dependencies +#include "ModSensorDebugger.h" #include "VariableBase.h" #include "sensors/YosemitechParent.h" diff --git a/src/sensors/YosemitechY550.h b/src/sensors/YosemitechY550.h index c43ed25a6..ef9ab5474 100644 --- a/src/sensors/YosemitechY550.h +++ b/src/sensors/YosemitechY550.h @@ -48,6 +48,7 @@ #endif // Included Dependencies +#include "ModSensorDebugger.h" #include "VariableBase.h" #include "sensors/YosemitechParent.h" diff --git a/src/sensors/ZebraTechDOpto.h b/src/sensors/ZebraTechDOpto.h index e485e65e1..6697550f1 100644 --- a/src/sensors/ZebraTechDOpto.h +++ b/src/sensors/ZebraTechDOpto.h @@ -44,6 +44,7 @@ #endif // Included Dependencies +#include "ModSensorDebugger.h" #include "VariableBase.h" #include "sensors/SDI12Sensors.h" From 11137d11538794fa51cb16d9f9d85eb404d66ecb Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 16 May 2019 15:36:09 -0400 Subject: [PATCH 34/88] corrected deep debugging --- src/LoggerBase.h | 1 - src/ModSensorDebugger.h | 11 ++++++++++- src/modems/DigiXBeeCellularBypass.cpp | 2 +- src/modems/DigiXBeeCellularTransparent.cpp | 2 +- src/modems/DigiXBeeWifi.cpp | 2 +- src/modems/EspressifESP8266.cpp | 2 +- src/modems/QuectelBG96.cpp | 2 +- src/modems/SIMComSIM7000.cpp | 2 +- src/modems/SIMComSIM800.cpp | 2 +- src/modems/SequansMonarch.cpp | 2 +- src/modems/Sodaq2GBeeR6.cpp | 2 +- src/modems/SodaqUBeeR410M.cpp | 4 ++-- src/modems/SodaqUBeeU201.cpp | 2 +- 13 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/LoggerBase.h b/src/LoggerBase.h index be0578a2a..2a7e10b57 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -20,7 +20,6 @@ #endif // Included Dependencies -//#include #include "ModSensorDebugger.h" #include "VariableArray.h" #include "LoggerModem.h" diff --git a/src/ModSensorDebugger.h b/src/ModSensorDebugger.h index 17a93ef69..f243cd366 100644 --- a/src/ModSensorDebugger.h +++ b/src/ModSensorDebugger.h @@ -59,6 +59,9 @@ template static void MS_DBG(T last) { DEBUGGING_SERIAL_OUTPUT.println(last); + // DEBUGGING_SERIAL_OUTPUT.print(" ("); + // DEBUGGING_SERIAL_OUTPUT.print(MS_DEBUGGING_STD); + // DEBUGGING_SERIAL_OUTPUT.println(')'); } template @@ -78,7 +81,13 @@ #ifndef DEEP_DEBUGGING_SERIAL_OUTPUT - #define DEEP_DEBUGGING_SERIAL_OUTPUT DEBUGGING_SERIAL_OUTPUT + // #if defined(ARDUINO_SAMD_ZERO) && defined(SERIAL_PORT_USBVIRTUAL) + #if defined(SERIAL_PORT_USBVIRTUAL) + // #define Serial SERIAL_PORT_USBVIRTUAL + #define DEEP_DEBUGGING_SERIAL_OUTPUT SERIAL_PORT_USBVIRTUAL + #elif defined __AVR__ + #define DEEP_DEBUGGING_SERIAL_OUTPUT Serial + #endif #endif // ifndef DEEP_DEBUGGING_SERIAL_OUTPUT #if defined DEEP_DEBUGGING_SERIAL_OUTPUT && defined MS_DEBUGGING_DEEP diff --git a/src/modems/DigiXBeeCellularBypass.cpp b/src/modems/DigiXBeeCellularBypass.cpp index 760a9b9cc..1fec554a3 100644 --- a/src/modems/DigiXBeeCellularBypass.cpp +++ b/src/modems/DigiXBeeCellularBypass.cpp @@ -21,7 +21,7 @@ DigiXBeeCellularBypass::DigiXBeeCellularBypass(Stream* modemStream, modemResetPin, modemSleepRqPin, measurementsToAverage), #ifdef MS_DIGIXBEECELLULARBYPASS_DEBUG_DEEP - _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _modemATDebugger(*modemStream, DEEP_DEBUGGING_SERIAL_OUTPUT), gsmModem(_modemATDebugger), #else gsmModem(*modemStream), diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index 933a41e23..a812e318d 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -21,7 +21,7 @@ DigiXBeeCellularTransparent::DigiXBeeCellularTransparent(Stream* modemStream, modemResetPin, modemSleepRqPin, measurementsToAverage), #ifdef MS_DIGIXBEECELLULARTRANSPARENT_DEBUG_DEEP - _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _modemATDebugger(*modemStream, DEEP_DEBUGGING_SERIAL_OUTPUT), gsmModem(_modemATDebugger), #else gsmModem(*modemStream), diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index 1e44dd3cd..7d239180d 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -22,7 +22,7 @@ DigiXBeeWifi::DigiXBeeWifi(Stream* modemStream, modemResetPin, modemSleepRqPin, measurementsToAverage), #ifdef MS_DIGIXBEEWIFI_DEBUG_DEEP - _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _modemATDebugger(*modemStream, DEEP_DEBUGGING_SERIAL_OUTPUT), gsmModem(_modemATDebugger), #else gsmModem(*modemStream), diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index d27f6c590..12d7ef567 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -28,7 +28,7 @@ EspressifESP8266::EspressifESP8266(Stream* modemStream, ESP8266_SIGNALQUALITY_TIME_MS, measurementsToAverage), #ifdef MS_ESPRESSIFESP8266_DEBUG_DEEP - _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _modemATDebugger(*modemStream, DEEP_DEBUGGING_SERIAL_OUTPUT), gsmModem(_modemATDebugger), #else gsmModem(*modemStream), diff --git a/src/modems/QuectelBG96.cpp b/src/modems/QuectelBG96.cpp index 357f97ce9..ba03b16bf 100644 --- a/src/modems/QuectelBG96.cpp +++ b/src/modems/QuectelBG96.cpp @@ -25,7 +25,7 @@ QuectelBG96::QuectelBG96(Stream* modemStream, BG96_SIGNALQUALITY_TIME_MS, measurementsToAverage), #ifdef MS_QUECTELBG96_DEBUG_DEEP - _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _modemATDebugger(*modemStream, DEEP_DEBUGGING_SERIAL_OUTPUT), gsmModem(_modemATDebugger), #else gsmModem(*modemStream), diff --git a/src/modems/SIMComSIM7000.cpp b/src/modems/SIMComSIM7000.cpp index cebe8e219..a6ca70d9f 100644 --- a/src/modems/SIMComSIM7000.cpp +++ b/src/modems/SIMComSIM7000.cpp @@ -25,7 +25,7 @@ SIMComSIM7000::SIMComSIM7000(Stream* modemStream, SIM7000_SIGNALQUALITY_TIME_MS, measurementsToAverage), #ifdef MS_SIMCOMSIM7000_DEBUG_DEEP - _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _modemATDebugger(*modemStream, DEEP_DEBUGGING_SERIAL_OUTPUT), gsmModem(_modemATDebugger), #else gsmModem(*modemStream), diff --git a/src/modems/SIMComSIM800.cpp b/src/modems/SIMComSIM800.cpp index 4d3ee4069..fa56e8ba7 100644 --- a/src/modems/SIMComSIM800.cpp +++ b/src/modems/SIMComSIM800.cpp @@ -27,7 +27,7 @@ SIMComSIM800::SIMComSIM800(Stream* modemStream, SIM800_SIGNALQUALITY_TIME_MS, measurementsToAverage), #ifdef MS_SIMCOMSIM800_DEBUG_DEEP - _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _modemATDebugger(*modemStream, DEEP_DEBUGGING_SERIAL_OUTPUT), gsmModem(_modemATDebugger), #else gsmModem(*modemStream), diff --git a/src/modems/SequansMonarch.cpp b/src/modems/SequansMonarch.cpp index 72d2c58ac..a660be813 100644 --- a/src/modems/SequansMonarch.cpp +++ b/src/modems/SequansMonarch.cpp @@ -25,7 +25,7 @@ SequansMonarch::SequansMonarch(Stream* modemStream, MONARCH_SIGNALQUALITY_TIME_MS, measurementsToAverage), #ifdef MS_SEQUANSMONARCH_DEBUG_DEEP - _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _modemATDebugger(*modemStream, DEEP_DEBUGGING_SERIAL_OUTPUT), gsmModem(_modemATDebugger), #else gsmModem(*modemStream), diff --git a/src/modems/Sodaq2GBeeR6.cpp b/src/modems/Sodaq2GBeeR6.cpp index f7849d727..615352523 100644 --- a/src/modems/Sodaq2GBeeR6.cpp +++ b/src/modems/Sodaq2GBeeR6.cpp @@ -26,7 +26,7 @@ Sodaq2GBeeR6::Sodaq2GBeeR6(Stream* modemStream, SIM800_SIGNALQUALITY_TIME_MS, measurementsToAverage), #ifdef MS_SODAQ2GBEER6_DEBUG_DEEP - _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _modemATDebugger(*modemStream, DEEP_DEBUGGING_SERIAL_OUTPUT), gsmModem(_modemATDebugger), #else gsmModem(*modemStream), diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp index 808873733..5d2b1013c 100644 --- a/src/modems/SodaqUBeeR410M.cpp +++ b/src/modems/SodaqUBeeR410M.cpp @@ -26,7 +26,7 @@ SodaqUBeeR410M::SodaqUBeeR410M(HardwareSerial* modemStream, R410M_SIGNALQUALITY_TIME_MS, measurementsToAverage), #ifdef MS_SODAQUBEER410M_DEBUG_DEEP - _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _modemATDebugger(*modemStream, DEEP_DEBUGGING_SERIAL_OUTPUT), gsmModem(_modemATDebugger), #else gsmModem(*modemStream), @@ -48,7 +48,7 @@ SodaqUBeeR410M::SodaqUBeeR410M(Stream* modemStream, R410M_SIGNALQUALITY_TIME_MS, measurementsToAverage), #ifdef MS_SODAQUBEER410M_DEBUG_DEEP - _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _modemATDebugger(*modemStream, DEEP_DEBUGGING_SERIAL_OUTPUT), gsmModem(_modemATDebugger), #else gsmModem(*modemStream), diff --git a/src/modems/SodaqUBeeU201.cpp b/src/modems/SodaqUBeeU201.cpp index 187af694c..af773688d 100644 --- a/src/modems/SodaqUBeeU201.cpp +++ b/src/modems/SodaqUBeeU201.cpp @@ -25,7 +25,7 @@ SodaqUBeeU201::SodaqUBeeU201(Stream* modemStream, U201_SIGNALQUALITY_TIME_MS, measurementsToAverage), #ifdef MS_SODAQUBEEU201_DEBUG_DEEP - _modemATDebugger(*modemStream, DEBUGGING_SERIAL_OUTPUT), + _modemATDebugger(*modemStream, DEEP_DEBUGGING_SERIAL_OUTPUT), gsmModem(_modemATDebugger), #else gsmModem(*modemStream), From 325c073c6f4882a05a3826c3e807a4db9dee902d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 16 May 2019 16:37:36 -0400 Subject: [PATCH 35/88] Let the modem decide if its wake and sleep should always be run --- src/LoggerModem.cpp | 11 ++++++----- src/LoggerModem.h | 6 +++++- src/ModSensorDebugger.h | 11 ++++++----- src/modems/DigiXBee.cpp | 2 +- src/modems/EspressifESP8266.cpp | 10 ++-------- src/modems/QuectelBG96.cpp | 2 +- src/modems/SIMComSIM7000.cpp | 2 +- src/modems/SIMComSIM800.cpp | 2 +- src/modems/SequansMonarch.cpp | 2 +- src/modems/Sodaq2GBeeR6.cpp | 2 +- src/modems/SodaqUBeeR410M.cpp | 2 +- src/modems/SodaqUBeeU201.cpp | 2 +- 12 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index 351160b9a..b9fb0522a 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -13,7 +13,7 @@ // Constructors loggerModem::loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, - int8_t modemResetPin, int8_t modemSleepRqPin, + int8_t modemResetPin, int8_t modemSleepRqPin, bool alwaysRunWake, uint32_t max_status_time_ms, uint32_t max_disconnetTime_ms, uint32_t max_warmUpTime_ms, uint32_t max_atresponse_time_ms, uint32_t max_signalQuality_time_ms, @@ -27,6 +27,7 @@ loggerModem::loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, _modemResetPin = modemResetPin; _modemSleepRqPin = modemSleepRqPin; _modemLEDPin = -1; + _alwaysRunWake = alwaysRunWake; _statusLevel = statusLevel; _statusTime_ms = max_status_time_ms, @@ -170,13 +171,13 @@ bool loggerModem::wake(void) // Check the status pin and wake bits before running wake function // Don't want to accidently pulse an already on modem to off - if ( bitRead(_sensorStatus, 4)) + if ( bitRead(_sensorStatus, 4) && !_alwaysRunWake) { MS_DBG(getSensorName(), F("has already been woken up! Will not run wake function.")); } // NOTE: It's possible that the status pin is on, but the modem is actually // mid-shutdown. In that case, we'll mistakenly skip re-waking it. - else if (_dataPin >= 0 && digitalRead(_dataPin) == _statusLevel) + else if (_dataPin >= 0 && digitalRead(_dataPin) == _statusLevel && !_alwaysRunWake) { MS_DBG(getSensorName(), F("was already on! (status pin level = "), _statusLevel, F(") Will not run wake function.")); @@ -365,10 +366,10 @@ bool loggerModem::modemSleepPowerDown(void) // on and thus status pin isn't valid yet. In that case, we wouldn't yet // know it's coming on and so we'd mistakenly assume it's already off and // not turn it back off. - if (_dataPin >= 0 && digitalRead(_dataPin) != _statusLevel) + if (_dataPin >= 0 && digitalRead(_dataPin) != _statusLevel && !_alwaysRunWake) MS_DBG(getSensorName(), F("appears to have already been off. Will not run sleep function.")); // If there's no status pin, check against the status bits - else if (_dataPin < 0 && !bitRead(_sensorStatus, 4)) + else if (_dataPin < 0 && !bitRead(_sensorStatus, 4) && !_alwaysRunWake) MS_DBG(getSensorName(), F("was never sucessfully turned on. Will not run sleep function.")); else { diff --git a/src/LoggerModem.h b/src/LoggerModem.h index 0129335ba..e04c78b7e 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -54,7 +54,7 @@ class loggerModem : public Sensor public: // Constructors loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, - int8_t modemResetPin, int8_t modemSleepRqPin, + int8_t modemResetPin, int8_t modemSleepRqPin, bool alwaysRunWake, uint32_t max_status_time_ms, uint32_t max_disconnetTime_ms, uint32_t max_warmUpTime_ms, uint32_t max_atresponse_time_ms, uint32_t max_signalQuality_time_ms, @@ -154,6 +154,10 @@ class loggerModem : public Sensor int8_t _modemResetPin; int8_t _modemLEDPin; + // THis denotes whether we should run the wake/sleep functions regardless + // of the state of the status pins or if we should check the status pin first. + bool _alwaysRunWake; + bool _statusLevel; uint32_t _statusTime_ms; uint32_t _disconnetTime_ms; diff --git a/src/ModSensorDebugger.h b/src/ModSensorDebugger.h index f243cd366..b9d58ca6e 100644 --- a/src/ModSensorDebugger.h +++ b/src/ModSensorDebugger.h @@ -58,10 +58,9 @@ namespace { template static void MS_DBG(T last) { - DEBUGGING_SERIAL_OUTPUT.println(last); - // DEBUGGING_SERIAL_OUTPUT.print(" ("); - // DEBUGGING_SERIAL_OUTPUT.print(MS_DEBUGGING_STD); - // DEBUGGING_SERIAL_OUTPUT.println(')'); + DEBUGGING_SERIAL_OUTPUT.print(last); + DEBUGGING_SERIAL_OUTPUT.print(" --"); + DEBUGGING_SERIAL_OUTPUT.println(MS_DEBUGGING_STD); } template @@ -94,7 +93,9 @@ namespace { template static void MS_DEEP_DBG(T last) { - DEEP_DEBUGGING_SERIAL_OUTPUT.println(last); + DEEP_DEBUGGING_SERIAL_OUTPUT.print(last); + DEEP_DEBUGGING_SERIAL_OUTPUT.print(" --"); + DEEP_DEBUGGING_SERIAL_OUTPUT.println(MS_DEBUGGING_STD); } template diff --git a/src/modems/DigiXBee.cpp b/src/modems/DigiXBee.cpp index 2c0dc6335..2376e78db 100644 --- a/src/modems/DigiXBee.cpp +++ b/src/modems/DigiXBee.cpp @@ -16,7 +16,7 @@ DigiXBee::DigiXBee(int8_t powerPin, int8_t statusPin, bool useCTSStatus, int8_t modemResetPin, int8_t modemSleepRqPin, uint8_t measurementsToAverage) : loggerModem(powerPin, statusPin, !useCTSStatus, - modemResetPin, modemSleepRqPin, + modemResetPin, modemSleepRqPin, true, XBEE_STATUS_TIME_MS, XBEE_DISCONNECT_TIME_MS, XBEE_WARM_UP_TIME_MS, XBEE_ATRESPONSE_TIME_MS, XBEE_SIGNALQUALITY_TIME_MS, diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index 12d7ef567..f7c02d90c 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -22,7 +22,7 @@ EspressifESP8266::EspressifESP8266(Stream* modemStream, uint8_t measurementsToAverage, int8_t espSleepRqPin, int8_t espStatusPin) : loggerModem(powerPin, statusPin, HIGH, - modemResetPin, modemSleepRqPin, + modemResetPin, modemSleepRqPin, true, ESP8266_STATUS_TIME_MS, ESP8266_DISCONNECT_TIME_MS, ESP8266_WARM_UP_TIME_MS, ESP8266_ATRESPONSE_TIME_MS, ESP8266_SIGNALQUALITY_TIME_MS, @@ -182,12 +182,6 @@ bool EspressifESP8266::extraModemSetup(void) // _modemSerial->begin(9600); // } // #endif - if (_powerPin < 0 && _modemResetPin < 0 && _modemSleepRqPin >= 0 && _dataPin >= 0) - { - gsmModem.sendAT(F("+WAKEUPGPIO=1,"), String(_espSleepRqPin), F(",0,"), - String(_espStatusPin), ',', _statusLevel); - gsmModem.waitResponse(); - } return true; } @@ -220,6 +214,6 @@ bool EspressifESP8266::startSingleMeasurement(void) _millisMeasurementRequested = 0; _sensorStatus &= 0b10111111; } - + return success; } diff --git a/src/modems/QuectelBG96.cpp b/src/modems/QuectelBG96.cpp index ba03b16bf..07eb5a53e 100644 --- a/src/modems/QuectelBG96.cpp +++ b/src/modems/QuectelBG96.cpp @@ -19,7 +19,7 @@ QuectelBG96::QuectelBG96(Stream* modemStream, const char *apn, uint8_t measurementsToAverage) : loggerModem(powerPin, statusPin, HIGH, - modemResetPin, modemSleepRqPin, + modemResetPin, modemSleepRqPin, false, BG96_STATUS_TIME_MS, BG96_DISCONNECT_TIME_MS, BG96_WARM_UP_TIME_MS, BG96_ATRESPONSE_TIME_MS, BG96_SIGNALQUALITY_TIME_MS, diff --git a/src/modems/SIMComSIM7000.cpp b/src/modems/SIMComSIM7000.cpp index a6ca70d9f..282ddf65a 100644 --- a/src/modems/SIMComSIM7000.cpp +++ b/src/modems/SIMComSIM7000.cpp @@ -19,7 +19,7 @@ SIMComSIM7000::SIMComSIM7000(Stream* modemStream, const char *apn, uint8_t measurementsToAverage) : loggerModem(powerPin, statusPin, HIGH, - modemResetPin, modemSleepRqPin, + modemResetPin, modemSleepRqPin, false, SIM7000_STATUS_TIME_MS, SIM7000_DISCONNECT_TIME_MS, SIM7000_WARM_UP_TIME_MS, SIM7000_ATRESPONSE_TIME_MS, SIM7000_SIGNALQUALITY_TIME_MS, diff --git a/src/modems/SIMComSIM800.cpp b/src/modems/SIMComSIM800.cpp index fa56e8ba7..e6797a140 100644 --- a/src/modems/SIMComSIM800.cpp +++ b/src/modems/SIMComSIM800.cpp @@ -21,7 +21,7 @@ SIMComSIM800::SIMComSIM800(Stream* modemStream, const char *apn, uint8_t measurementsToAverage) : loggerModem(powerPin, statusPin, HIGH, - modemResetPin, modemSleepRqPin, + modemResetPin, modemSleepRqPin, false, SIM800_STATUS_TIME_MS, SIM800_DISCONNECT_TIME_MS, SIM800_WARM_UP_TIME_MS, SIM800_ATRESPONSE_TIME_MS, SIM800_SIGNALQUALITY_TIME_MS, diff --git a/src/modems/SequansMonarch.cpp b/src/modems/SequansMonarch.cpp index a660be813..938bdcfb6 100644 --- a/src/modems/SequansMonarch.cpp +++ b/src/modems/SequansMonarch.cpp @@ -19,7 +19,7 @@ SequansMonarch::SequansMonarch(Stream* modemStream, const char *apn, uint8_t measurementsToAverage) : loggerModem(powerPin, statusPin, HIGH, - modemResetPin, modemSleepRqPin, + modemResetPin, modemSleepRqPin, true, MONARCH_STATUS_TIME_MS, MONARCH_DISCONNECT_TIME_MS, MONARCH_WARM_UP_TIME_MS, MONARCH_ATRESPONSE_TIME_MS, MONARCH_SIGNALQUALITY_TIME_MS, diff --git a/src/modems/Sodaq2GBeeR6.cpp b/src/modems/Sodaq2GBeeR6.cpp index 615352523..9bb80f461 100644 --- a/src/modems/Sodaq2GBeeR6.cpp +++ b/src/modems/Sodaq2GBeeR6.cpp @@ -20,7 +20,7 @@ Sodaq2GBeeR6::Sodaq2GBeeR6(Stream* modemStream, const char *apn, uint8_t measurementsToAverage) : loggerModem(powerPin, statusPin, HIGH, - -1, modemSleepRqPin, + -1, modemSleepRqPin, true, SIM800_STATUS_TIME_MS, SIM800_DISCONNECT_TIME_MS, SIM800_WARM_UP_TIME_MS, SIM800_ATRESPONSE_TIME_MS, SIM800_SIGNALQUALITY_TIME_MS, diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp index 5d2b1013c..0527ed2ad 100644 --- a/src/modems/SodaqUBeeR410M.cpp +++ b/src/modems/SodaqUBeeR410M.cpp @@ -20,7 +20,7 @@ SodaqUBeeR410M::SodaqUBeeR410M(HardwareSerial* modemStream, const char *apn, uint8_t measurementsToAverage) : loggerModem(powerPin, statusPin, HIGH, - modemResetPin, modemSleepRqPin, + modemResetPin, modemSleepRqPin, true, R410M_STATUS_TIME_MS, R410M_DISCONNECT_TIME_MS, R410M_WARM_UP_TIME_MS, R410M_ATRESPONSE_TIME_MS, R410M_SIGNALQUALITY_TIME_MS, diff --git a/src/modems/SodaqUBeeU201.cpp b/src/modems/SodaqUBeeU201.cpp index af773688d..c1d2e33dd 100644 --- a/src/modems/SodaqUBeeU201.cpp +++ b/src/modems/SodaqUBeeU201.cpp @@ -19,7 +19,7 @@ SodaqUBeeU201::SodaqUBeeU201(Stream* modemStream, const char *apn, uint8_t measurementsToAverage) : loggerModem(powerPin, statusPin, HIGH, - modemResetPin, modemSleepRqPin, + modemResetPin, modemSleepRqPin, true, U201_STATUS_TIME_MS, U201_DISCONNECT_TIME_MS, U201_WARM_UP_TIME_MS, U201_ATRESPONSE_TIME_MS, U201_SIGNALQUALITY_TIME_MS, From d97caaf7ad3d5767bf0fce5260c9310245814c95 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 16 May 2019 17:28:51 -0400 Subject: [PATCH 36/88] Fix XBee sleep, and added a debug print --- src/ModSensorDebugger.h | 4 ++-- src/modems/DigiXBee.cpp | 7 ++++--- src/modems/EspressifESP8266.cpp | 8 ++++++++ src/modems/SIMComSIM7000.cpp | 2 ++ src/modems/SIMComSIM800.cpp | 2 ++ src/modems/SequansMonarch.cpp | 2 ++ src/modems/Sodaq2GBeeR6.cpp | 2 ++ src/modems/SodaqUBeeR410M.cpp | 2 ++ src/modems/SodaqUBeeU201.cpp | 2 ++ 9 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/ModSensorDebugger.h b/src/ModSensorDebugger.h index b9d58ca6e..fc351b65f 100644 --- a/src/ModSensorDebugger.h +++ b/src/ModSensorDebugger.h @@ -59,7 +59,7 @@ template static void MS_DBG(T last) { DEBUGGING_SERIAL_OUTPUT.print(last); - DEBUGGING_SERIAL_OUTPUT.print(" --"); + DEBUGGING_SERIAL_OUTPUT.print(" <--"); DEBUGGING_SERIAL_OUTPUT.println(MS_DEBUGGING_STD); } @@ -94,7 +94,7 @@ template static void MS_DEEP_DBG(T last) { DEEP_DEBUGGING_SERIAL_OUTPUT.print(last); - DEEP_DEBUGGING_SERIAL_OUTPUT.print(" --"); + DEEP_DEBUGGING_SERIAL_OUTPUT.print(" <--"); DEEP_DEBUGGING_SERIAL_OUTPUT.println(MS_DEBUGGING_STD); } diff --git a/src/modems/DigiXBee.cpp b/src/modems/DigiXBee.cpp index 2376e78db..724e43ae1 100644 --- a/src/modems/DigiXBee.cpp +++ b/src/modems/DigiXBee.cpp @@ -32,7 +32,8 @@ bool DigiXBee::modemWakeFxn(void) { if (_modemSleepRqPin >= 0) // Don't go to sleep if there's not a wake pin! { - digitalWrite(_modemSleepRqPin, HIGH); + MS_DBG(F("Setting pin"), _modemSleepRqPin, F("LOW to wake XBee")); + digitalWrite(_modemSleepRqPin, LOW); return true; } else @@ -48,8 +49,8 @@ bool DigiXBee::modemSleepFxn(void) return true; else if (_modemSleepRqPin >= 0) { - digitalWrite(_modemSleepRqPin, LOW); - digitalWrite(_modemLEDPin, HIGH); // Because the XBee doesn't have any lights + MS_DBG(F("Setting pin"), _modemSleepRqPin, F("HIGH to put XBee to sleep")); + digitalWrite(_modemSleepRqPin, HIGH); return true; } else diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index f7c02d90c..730998f28 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -62,6 +62,7 @@ bool EspressifESP8266::ESPwaitForBoot(void) // sends out a boot log from the ROM on UART1 at 74880 baud. We're not // going to worry about the odd baud rate since we're simply throwing the // characters away. + MS_DBG(F("Waiting for boot-up message from ESP8266")); delay(200); // It will take at least this long uint32_t start = millis(); bool success = false; @@ -97,6 +98,8 @@ bool EspressifESP8266::modemWakeFxn(void) } else if (_modemResetPin >= 0) { + MS_DBG(F("Sending a reset pulse to pin"), _modemResetPin, + F("to wake ESP8266 from deep sleep")) digitalWrite(_modemResetPin, LOW); delay(1); digitalWrite(_modemResetPin, HIGH); @@ -105,6 +108,8 @@ bool EspressifESP8266::modemWakeFxn(void) } else if (_modemSleepRqPin >= 0) { + MS_DBG(F("Sending a pulse to pin"), _modemSleepRqPin, + F("to wake ESP8266 from light sleep")) digitalWrite(_modemSleepRqPin, LOW); delay(1); digitalWrite(_modemSleepRqPin, HIGH); @@ -135,6 +140,7 @@ bool EspressifESP8266::modemSleepFxn(void) // Use this if you have an MCU pin connected to the ESP's reset pin to wake from deep sleep if (_modemResetPin >= 0) { + MS_DBG(F("Requesting deep sleep for ESP8266")); return gsmModem.poweroff(); } // Use this if you don't have access to the ESP8266's reset pin for deep sleep but you @@ -142,6 +148,7 @@ bool EspressifESP8266::modemSleepFxn(void) // pin to view the sleep status. else if (_modemSleepRqPin >= 0 && _dataPin >= 0) { + MS_DBG(F("Requesting light sleep for ESP8266 with status indication")); gsmModem.sendAT(F("+WAKEUPGPIO=1,"), String(_espSleepRqPin), F(",0,"), String(_espStatusPin), ',', _statusLevel); bool success = gsmModem.waitResponse() == 1; @@ -152,6 +159,7 @@ bool EspressifESP8266::modemSleepFxn(void) // Light sleep without the status pin else if (_modemSleepRqPin >= 0 && _dataPin < 0) { + MS_DBG(F("Requesting light sleep for ESP8266")); gsmModem.sendAT(F("+WAKEUPGPIO=1,"), String(_espSleepRqPin), F(",0")); bool success = gsmModem.waitResponse() == 1; gsmModem.sendAT(F("+SLEEP=1")); diff --git a/src/modems/SIMComSIM7000.cpp b/src/modems/SIMComSIM7000.cpp index 282ddf65a..e3087fcd5 100644 --- a/src/modems/SIMComSIM7000.cpp +++ b/src/modems/SIMComSIM7000.cpp @@ -51,6 +51,7 @@ bool SIMComSIM7000::modemWakeFxn(void) // Must power on and then pulse on if (_modemSleepRqPin >= 0) { + MS_DBG(F("Sending a wake-up pulse on pin"), _modemSleepRqPin, F("for SIM7000")); digitalWrite(_modemSleepRqPin, LOW); delay(1100); // >1s digitalWrite(_modemSleepRqPin, LOW); @@ -64,6 +65,7 @@ bool SIMComSIM7000::modemSleepFxn(void) if (_modemSleepRqPin >= 0) // R410 must have access to PWRKEY pin to sleep { // Easiest to just go to sleep with the AT command rather than using pins + MS_DBG(F("Asking SIM7000 to power down")); return gsmModem.poweroff(); } else // DON'T go to sleep if we can't wake up! diff --git a/src/modems/SIMComSIM800.cpp b/src/modems/SIMComSIM800.cpp index e6797a140..94f7ac7cd 100644 --- a/src/modems/SIMComSIM800.cpp +++ b/src/modems/SIMComSIM800.cpp @@ -53,6 +53,7 @@ bool SIMComSIM800::modemWakeFxn(void) // Must power on and then pulse on if (_modemSleepRqPin >= 0) { + MS_DBG(F("Sending a wake-up pulse on pin"), _modemSleepRqPin, F("for SIM800")); digitalWrite(_modemSleepRqPin, LOW); delay(1100); // >1s digitalWrite(_modemSleepRqPin, LOW); @@ -66,6 +67,7 @@ bool SIMComSIM800::modemSleepFxn(void) if (_modemSleepRqPin >= 0) // R410 must have access to PWRKEY pin to sleep { // Easiest to just go to sleep with the AT command rather than using pins + MS_DBG(F("Asking SIM800 to power down")); return gsmModem.poweroff(); } else // DON'T go to sleep if we can't wake up! diff --git a/src/modems/SequansMonarch.cpp b/src/modems/SequansMonarch.cpp index 938bdcfb6..aee720bb3 100644 --- a/src/modems/SequansMonarch.cpp +++ b/src/modems/SequansMonarch.cpp @@ -54,6 +54,7 @@ bool SequansMonarch::modemWakeFxn(void) return true; if (_modemSleepRqPin >= 0) { + MS_DBG(F("Sending a wake-up pulse on pin"), _modemSleepRqPin, F("for Sequans Monarch")); digitalWrite(_modemSleepRqPin, LOW); delayMicroseconds(50); // ?? Time isn't documented digitalWrite(_modemSleepRqPin, HIGH); @@ -71,6 +72,7 @@ bool SequansMonarch::modemSleepFxn(void) if (_powerPin >= 0 || _modemSleepRqPin >= 0) // will go on with power on { // Easiest to just go to sleep with the AT command rather than using pins + MS_DBG(F("Asking Sequans Monarch to power down")); return gsmModem.poweroff(); } else // DON'T go to sleep if we can't wake up! diff --git a/src/modems/Sodaq2GBeeR6.cpp b/src/modems/Sodaq2GBeeR6.cpp index 9bb80f461..cf7ce8986 100644 --- a/src/modems/Sodaq2GBeeR6.cpp +++ b/src/modems/Sodaq2GBeeR6.cpp @@ -49,6 +49,7 @@ MS_MODEM_GET_NIST_TIME(Sodaq2GBeeR6); // These can be functions of any type and must return a boolean bool Sodaq2GBeeR6::modemWakeFxn(void) { + MS_DBG(F("Setting pin"), _modemSleepRqPin, F("high to wake GPRSBeeR6")); digitalWrite(_modemSleepRqPin, HIGH); return true; } @@ -56,6 +57,7 @@ bool Sodaq2GBeeR6::modemWakeFxn(void) bool Sodaq2GBeeR6::modemSleepFxn(void) { + MS_DBG(F("Sending pin"), _modemSleepRqPin, F("low to stop GPRSBeeR6")); digitalWrite(_modemSleepRqPin, LOW); return true; } diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp index 0527ed2ad..26629f675 100644 --- a/src/modems/SodaqUBeeR410M.cpp +++ b/src/modems/SodaqUBeeR410M.cpp @@ -78,6 +78,7 @@ bool SodaqUBeeR410M::modemWakeFxn(void) // SARA R4/N4 series must power on and then pulse on if (_modemSleepRqPin >= 0) { + MS_DBG(F("Sending a wake-up pulse on pin"), _modemSleepRqPin, F("for Sodaq UBee R410M")); digitalWrite(_modemSleepRqPin, LOW); delay(200); // 0.15-3.2s pulse for wake on SARA R4/N4 digitalWrite(_modemSleepRqPin, HIGH); @@ -108,6 +109,7 @@ bool SodaqUBeeR410M::modemSleepFxn(void) if (_modemSleepRqPin >= 0) // R410 must have access to PWR_ON pin to sleep { // Easiest to just go to sleep with the AT command rather than using pins + MS_DBG(F("Asking u-blox R410M to power down")); return gsmModem.poweroff(); } else // DON'T go to sleep if we can't wake up! diff --git a/src/modems/SodaqUBeeU201.cpp b/src/modems/SodaqUBeeU201.cpp index c1d2e33dd..d41773396 100644 --- a/src/modems/SodaqUBeeU201.cpp +++ b/src/modems/SodaqUBeeU201.cpp @@ -55,6 +55,7 @@ bool SodaqUBeeU201::modemWakeFxn(void) return true; if (_modemSleepRqPin >= 0) { + MS_DBG(F("Sending a wake-up pulse on pin"), _modemSleepRqPin, F("for Sodaq UBee U201")); digitalWrite(_modemSleepRqPin, LOW); delayMicroseconds(65); // 50-80µs pulse for wake on SARA/LISA U2/G2 digitalWrite(_modemSleepRqPin, HIGH); @@ -72,6 +73,7 @@ bool SodaqUBeeU201::modemSleepFxn(void) if (_powerPin >= 0 || _modemSleepRqPin >= 0) // will go on with power on { // Easiest to just go to sleep with the AT command rather than using pins + MS_DBG(F("Asking u-blox SARA U201 to power down")); return gsmModem.poweroff(); } else // DON'T go to sleep if we can't wake up! From 4cffdf69ed4914179a43c81de75f2f2899e944f3 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 16 May 2019 17:40:22 -0400 Subject: [PATCH 37/88] Fixed redefinition warning --- src/LoggerBase.h | 1 + src/LoggerModem.h | 1 + src/SensorBase.h | 1 + src/VariableArray.h | 1 + src/VariableBase.h | 1 + src/dataPublisherBase.h | 1 + src/modems/DigiXBee.h | 1 + src/modems/DigiXBeeCellularBypass.h | 1 + src/modems/DigiXBeeCellularTransparent.h | 1 + src/modems/DigiXBeeWifi.h | 1 + src/modems/EspressifESP8266.h | 1 + src/modems/QuectelBG96.h | 1 + src/modems/SIMComSIM7000.h | 1 + src/modems/SIMComSIM800.h | 1 + src/modems/SequansMonarch.h | 1 + src/modems/Sodaq2GBeeR6.h | 1 + src/modems/SodaqUBeeR410M.h | 1 + src/modems/SodaqUBeeU201.h | 1 + src/publishers/DreamHostPublisher.h | 1 + src/publishers/EnviroDIYPublisher.h | 1 + src/publishers/ThingSpeakPublisher.h | 1 + src/sensors/AOSongAM2315.h | 1 + src/sensors/AOSongDHT.h | 1 + src/sensors/ApogeeSQ212.h | 1 + src/sensors/AtlasParent.h | 1 + src/sensors/AtlasScientificCO2.h | 1 + src/sensors/AtlasScientificDO.h | 1 + src/sensors/AtlasScientificEC.h | 1 + src/sensors/AtlasScientificORP.h | 1 + src/sensors/AtlasScientificRTD.h | 1 + src/sensors/AtlasScientificpH.h | 1 + src/sensors/BoschBME280.h | 1 + src/sensors/CampbellOBS3.h | 1 + src/sensors/Decagon5TM.h | 1 + src/sensors/DecagonCTD.h | 1 + src/sensors/DecagonES2.h | 1 + src/sensors/ExternalVoltage.h | 1 + src/sensors/FreescaleMPL115A2.h | 1 + src/sensors/KellerAcculevel.h | 1 + src/sensors/KellerNanolevel.h | 1 + src/sensors/KellerParent.h | 1 + src/sensors/MaxBotixSonar.h | 1 + src/sensors/MaximDS18.h | 1 + src/sensors/MaximDS3231.h | 1 + src/sensors/MeaSpecMS5803.h | 1 + src/sensors/ProcessorStats.h | 1 + src/sensors/RainCounterI2C.h | 1 + src/sensors/SDI12Sensors.h | 1 + src/sensors/TIINA219.h | 1 + src/sensors/YosemitechParent.h | 1 + src/sensors/YosemitechY4000.h | 1 + src/sensors/YosemitechY504.h | 1 + src/sensors/YosemitechY510.h | 1 + src/sensors/YosemitechY511.h | 1 + src/sensors/YosemitechY514.h | 1 + src/sensors/YosemitechY520.h | 1 + src/sensors/YosemitechY532.h | 1 + src/sensors/YosemitechY533.h | 1 + src/sensors/YosemitechY550.h | 1 + src/sensors/ZebraTechDOpto.h | 1 + 60 files changed, 60 insertions(+) diff --git a/src/LoggerBase.h b/src/LoggerBase.h index 2a7e10b57..8ac2eeec2 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -21,6 +21,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableArray.h" #include "LoggerModem.h" diff --git a/src/LoggerModem.h b/src/LoggerModem.h index e04c78b7e..d56185cc7 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -22,6 +22,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "SensorBase.h" #include diff --git a/src/SensorBase.h b/src/SensorBase.h index 31b862f20..6fef777df 100644 --- a/src/SensorBase.h +++ b/src/SensorBase.h @@ -20,6 +20,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include // The largest number of variables from a single sensor diff --git a/src/VariableArray.h b/src/VariableArray.h index aa5c67d7b..73e1a665c 100644 --- a/src/VariableArray.h +++ b/src/VariableArray.h @@ -25,6 +25,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "SensorBase.h" diff --git a/src/VariableBase.h b/src/VariableBase.h index f376d0975..e2f0ea609 100644 --- a/src/VariableBase.h +++ b/src/VariableBase.h @@ -23,6 +23,7 @@ class Sensor; // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD class Variable { diff --git a/src/dataPublisherBase.h b/src/dataPublisherBase.h index 77d16e037..5eb9fb660 100644 --- a/src/dataPublisherBase.h +++ b/src/dataPublisherBase.h @@ -28,6 +28,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "LoggerBase.h" #include "Client.h" diff --git a/src/modems/DigiXBee.h b/src/modems/DigiXBee.h index a6336c689..c5e3150d5 100644 --- a/src/modems/DigiXBee.h +++ b/src/modems/DigiXBee.h @@ -38,6 +38,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "LoggerModem.h" diff --git a/src/modems/DigiXBeeCellularBypass.h b/src/modems/DigiXBeeCellularBypass.h index 1c9897ba9..02d93fb5b 100644 --- a/src/modems/DigiXBeeCellularBypass.h +++ b/src/modems/DigiXBeeCellularBypass.h @@ -24,6 +24,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "DigiXBee.h" #include "TinyGsmClient.h" diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index 25759583d..8aa0ea071 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -24,6 +24,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "DigiXBee.h" #include "TinyGsmClient.h" diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index bf7caaad4..5ee42ad0c 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -24,6 +24,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "DigiXBee.h" #include "TinyGsmClient.h" diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h index c8b577748..0c9b57bee 100644 --- a/src/modems/EspressifESP8266.h +++ b/src/modems/EspressifESP8266.h @@ -41,6 +41,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "LoggerModem.h" #include "TinyGsmClient.h" diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index dcf825fde..f8551435d 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -38,6 +38,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "LoggerModem.h" #include "TinyGsmClient.h" diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h index cfb979f1e..19b83d7f7 100644 --- a/src/modems/SIMComSIM7000.h +++ b/src/modems/SIMComSIM7000.h @@ -37,6 +37,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "LoggerModem.h" #include "TinyGsmClient.h" diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index 422f1de5e..88e2ea48c 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -40,6 +40,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "LoggerModem.h" #include "TinyGsmClient.h" diff --git a/src/modems/SequansMonarch.h b/src/modems/SequansMonarch.h index 148cb038d..4ef968576 100644 --- a/src/modems/SequansMonarch.h +++ b/src/modems/SequansMonarch.h @@ -38,6 +38,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "LoggerModem.h" #include "TinyGsmClient.h" diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h index f082f266a..ae4b5bea3 100644 --- a/src/modems/Sodaq2GBeeR6.h +++ b/src/modems/Sodaq2GBeeR6.h @@ -39,6 +39,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "LoggerModem.h" #include "TinyGsmClient.h" diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index 0f1f89036..24aa95df6 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -40,6 +40,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "LoggerModem.h" #include "TinyGsmClient.h" diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index 08501706b..08ac4f85a 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -43,6 +43,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "LoggerModem.h" #include "TinyGsmClient.h" diff --git a/src/publishers/DreamHostPublisher.h b/src/publishers/DreamHostPublisher.h index 2ca80512b..75e55aea5 100644 --- a/src/publishers/DreamHostPublisher.h +++ b/src/publishers/DreamHostPublisher.h @@ -20,6 +20,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "dataPublisherBase.h" diff --git a/src/publishers/EnviroDIYPublisher.h b/src/publishers/EnviroDIYPublisher.h index 9c98247c0..a83d511bf 100644 --- a/src/publishers/EnviroDIYPublisher.h +++ b/src/publishers/EnviroDIYPublisher.h @@ -21,6 +21,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "dataPublisherBase.h" diff --git a/src/publishers/ThingSpeakPublisher.h b/src/publishers/ThingSpeakPublisher.h index 64c598d2b..320b6eb5a 100644 --- a/src/publishers/ThingSpeakPublisher.h +++ b/src/publishers/ThingSpeakPublisher.h @@ -28,6 +28,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "dataPublisherBase.h" #include diff --git a/src/sensors/AOSongAM2315.h b/src/sensors/AOSongAM2315.h index 63906279d..ba977cc10 100644 --- a/src/sensors/AOSongAM2315.h +++ b/src/sensors/AOSongAM2315.h @@ -35,6 +35,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "SensorBase.h" diff --git a/src/sensors/AOSongDHT.h b/src/sensors/AOSongDHT.h index a9105ce7d..2de64350c 100644 --- a/src/sensors/AOSongDHT.h +++ b/src/sensors/AOSongDHT.h @@ -37,6 +37,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "SensorBase.h" #include diff --git a/src/sensors/ApogeeSQ212.h b/src/sensors/ApogeeSQ212.h index 525803135..ac7da3264 100644 --- a/src/sensors/ApogeeSQ212.h +++ b/src/sensors/ApogeeSQ212.h @@ -42,6 +42,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "SensorBase.h" diff --git a/src/sensors/AtlasParent.h b/src/sensors/AtlasParent.h index 54230366d..5c7676d01 100644 --- a/src/sensors/AtlasParent.h +++ b/src/sensors/AtlasParent.h @@ -25,6 +25,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "SensorBase.h" #include diff --git a/src/sensors/AtlasScientificCO2.h b/src/sensors/AtlasScientificCO2.h index 752dcbb9a..5355f0650 100644 --- a/src/sensors/AtlasScientificCO2.h +++ b/src/sensors/AtlasScientificCO2.h @@ -24,6 +24,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "sensors/AtlasParent.h" diff --git a/src/sensors/AtlasScientificDO.h b/src/sensors/AtlasScientificDO.h index 1ae562487..082f006ac 100644 --- a/src/sensors/AtlasScientificDO.h +++ b/src/sensors/AtlasScientificDO.h @@ -24,6 +24,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "sensors/AtlasParent.h" diff --git a/src/sensors/AtlasScientificEC.h b/src/sensors/AtlasScientificEC.h index fa0856dcf..333c5fe6d 100644 --- a/src/sensors/AtlasScientificEC.h +++ b/src/sensors/AtlasScientificEC.h @@ -25,6 +25,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "sensors/AtlasParent.h" diff --git a/src/sensors/AtlasScientificORP.h b/src/sensors/AtlasScientificORP.h index 8b4fd26b9..9638f2314 100644 --- a/src/sensors/AtlasScientificORP.h +++ b/src/sensors/AtlasScientificORP.h @@ -24,6 +24,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "sensors/AtlasParent.h" diff --git a/src/sensors/AtlasScientificRTD.h b/src/sensors/AtlasScientificRTD.h index a9f94cd8a..cc67ab91c 100644 --- a/src/sensors/AtlasScientificRTD.h +++ b/src/sensors/AtlasScientificRTD.h @@ -24,6 +24,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "sensors/AtlasParent.h" diff --git a/src/sensors/AtlasScientificpH.h b/src/sensors/AtlasScientificpH.h index a2573e6b8..4b7167268 100644 --- a/src/sensors/AtlasScientificpH.h +++ b/src/sensors/AtlasScientificpH.h @@ -24,6 +24,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "sensors/AtlasParent.h" diff --git a/src/sensors/BoschBME280.h b/src/sensors/BoschBME280.h index e23564da5..a1c82bad3 100644 --- a/src/sensors/BoschBME280.h +++ b/src/sensors/BoschBME280.h @@ -43,6 +43,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "SensorBase.h" #include diff --git a/src/sensors/CampbellOBS3.h b/src/sensors/CampbellOBS3.h index 34c05414c..e80449749 100644 --- a/src/sensors/CampbellOBS3.h +++ b/src/sensors/CampbellOBS3.h @@ -38,6 +38,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "SensorBase.h" diff --git a/src/sensors/Decagon5TM.h b/src/sensors/Decagon5TM.h index 89359a40a..8c6f9e1c5 100644 --- a/src/sensors/Decagon5TM.h +++ b/src/sensors/Decagon5TM.h @@ -39,6 +39,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "sensors/SDI12Sensors.h" diff --git a/src/sensors/DecagonCTD.h b/src/sensors/DecagonCTD.h index 94059b738..5928df2bc 100644 --- a/src/sensors/DecagonCTD.h +++ b/src/sensors/DecagonCTD.h @@ -43,6 +43,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "sensors/SDI12Sensors.h" diff --git a/src/sensors/DecagonES2.h b/src/sensors/DecagonES2.h index 348c1900d..f54c6b40c 100644 --- a/src/sensors/DecagonES2.h +++ b/src/sensors/DecagonES2.h @@ -38,6 +38,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "sensors/SDI12Sensors.h" diff --git a/src/sensors/ExternalVoltage.h b/src/sensors/ExternalVoltage.h index 956f9cfbe..a65b3b65d 100644 --- a/src/sensors/ExternalVoltage.h +++ b/src/sensors/ExternalVoltage.h @@ -63,6 +63,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "SensorBase.h" diff --git a/src/sensors/FreescaleMPL115A2.h b/src/sensors/FreescaleMPL115A2.h index b3ae7dc3f..e9ef96d82 100644 --- a/src/sensors/FreescaleMPL115A2.h +++ b/src/sensors/FreescaleMPL115A2.h @@ -34,6 +34,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "SensorBase.h" #include diff --git a/src/sensors/KellerAcculevel.h b/src/sensors/KellerAcculevel.h index 5c3fdcf6f..cae584934 100644 --- a/src/sensors/KellerAcculevel.h +++ b/src/sensors/KellerAcculevel.h @@ -32,6 +32,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "sensors/KellerParent.h" diff --git a/src/sensors/KellerNanolevel.h b/src/sensors/KellerNanolevel.h index 9372c56a1..e3996b4b1 100644 --- a/src/sensors/KellerNanolevel.h +++ b/src/sensors/KellerNanolevel.h @@ -32,6 +32,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "sensors/KellerParent.h" diff --git a/src/sensors/KellerParent.h b/src/sensors/KellerParent.h index 484d53d64..4b4d50436 100644 --- a/src/sensors/KellerParent.h +++ b/src/sensors/KellerParent.h @@ -33,6 +33,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "SensorBase.h" #include diff --git a/src/sensors/MaxBotixSonar.h b/src/sensors/MaxBotixSonar.h index ec4fec9bd..63823db80 100644 --- a/src/sensors/MaxBotixSonar.h +++ b/src/sensors/MaxBotixSonar.h @@ -26,6 +26,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "SensorBase.h" diff --git a/src/sensors/MaximDS18.h b/src/sensors/MaximDS18.h index 10c39be01..084661843 100644 --- a/src/sensors/MaximDS18.h +++ b/src/sensors/MaximDS18.h @@ -34,6 +34,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "SensorBase.h" #include diff --git a/src/sensors/MaximDS3231.h b/src/sensors/MaximDS3231.h index 703fe222d..3df6a8150 100644 --- a/src/sensors/MaximDS3231.h +++ b/src/sensors/MaximDS3231.h @@ -30,6 +30,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "SensorBase.h" diff --git a/src/sensors/MeaSpecMS5803.h b/src/sensors/MeaSpecMS5803.h index 632b5bffe..eb851eab9 100644 --- a/src/sensors/MeaSpecMS5803.h +++ b/src/sensors/MeaSpecMS5803.h @@ -54,6 +54,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "SensorBase.h" #include diff --git a/src/sensors/ProcessorStats.h b/src/sensors/ProcessorStats.h index 10261e8b3..7b1c4bf39 100644 --- a/src/sensors/ProcessorStats.h +++ b/src/sensors/ProcessorStats.h @@ -25,6 +25,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "SensorBase.h" diff --git a/src/sensors/RainCounterI2C.h b/src/sensors/RainCounterI2C.h index 7a66a7b53..9bc554e45 100644 --- a/src/sensors/RainCounterI2C.h +++ b/src/sensors/RainCounterI2C.h @@ -30,6 +30,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "SensorBase.h" #include diff --git a/src/sensors/SDI12Sensors.h b/src/sensors/SDI12Sensors.h index 323109595..97ed65a79 100644 --- a/src/sensors/SDI12Sensors.h +++ b/src/sensors/SDI12Sensors.h @@ -24,6 +24,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "SensorBase.h" #ifdef SDI12_EXTERNAL_PCINT diff --git a/src/sensors/TIINA219.h b/src/sensors/TIINA219.h index 2546cb585..fde29d5d2 100644 --- a/src/sensors/TIINA219.h +++ b/src/sensors/TIINA219.h @@ -38,6 +38,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "SensorBase.h" #include diff --git a/src/sensors/YosemitechParent.h b/src/sensors/YosemitechParent.h index bc7386fbe..9952ea185 100644 --- a/src/sensors/YosemitechParent.h +++ b/src/sensors/YosemitechParent.h @@ -31,6 +31,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "SensorBase.h" #include diff --git a/src/sensors/YosemitechY4000.h b/src/sensors/YosemitechY4000.h index 7598d9cc6..dca9c2ece 100644 --- a/src/sensors/YosemitechY4000.h +++ b/src/sensors/YosemitechY4000.h @@ -78,6 +78,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "sensors/YosemitechParent.h" diff --git a/src/sensors/YosemitechY504.h b/src/sensors/YosemitechY504.h index 65c24cfb6..e6d731203 100644 --- a/src/sensors/YosemitechY504.h +++ b/src/sensors/YosemitechY504.h @@ -45,6 +45,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "sensors/YosemitechParent.h" diff --git a/src/sensors/YosemitechY510.h b/src/sensors/YosemitechY510.h index 03b4ccf73..9ea02cacf 100644 --- a/src/sensors/YosemitechY510.h +++ b/src/sensors/YosemitechY510.h @@ -45,6 +45,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "sensors/YosemitechParent.h" diff --git a/src/sensors/YosemitechY511.h b/src/sensors/YosemitechY511.h index e08cae580..d8b25e616 100644 --- a/src/sensors/YosemitechY511.h +++ b/src/sensors/YosemitechY511.h @@ -45,6 +45,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "sensors/YosemitechParent.h" diff --git a/src/sensors/YosemitechY514.h b/src/sensors/YosemitechY514.h index 7f0feb51b..4dde6c175 100644 --- a/src/sensors/YosemitechY514.h +++ b/src/sensors/YosemitechY514.h @@ -46,6 +46,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "sensors/YosemitechParent.h" diff --git a/src/sensors/YosemitechY520.h b/src/sensors/YosemitechY520.h index ed45f524e..a27b61c1b 100644 --- a/src/sensors/YosemitechY520.h +++ b/src/sensors/YosemitechY520.h @@ -46,6 +46,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "sensors/YosemitechParent.h" diff --git a/src/sensors/YosemitechY532.h b/src/sensors/YosemitechY532.h index d05ddfc05..7776b8cd6 100644 --- a/src/sensors/YosemitechY532.h +++ b/src/sensors/YosemitechY532.h @@ -46,6 +46,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "sensors/YosemitechParent.h" diff --git a/src/sensors/YosemitechY533.h b/src/sensors/YosemitechY533.h index 4974eb60a..4bde54f85 100644 --- a/src/sensors/YosemitechY533.h +++ b/src/sensors/YosemitechY533.h @@ -51,6 +51,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "sensors/YosemitechParent.h" diff --git a/src/sensors/YosemitechY550.h b/src/sensors/YosemitechY550.h index ef9ab5474..f77c2559c 100644 --- a/src/sensors/YosemitechY550.h +++ b/src/sensors/YosemitechY550.h @@ -49,6 +49,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "sensors/YosemitechParent.h" diff --git a/src/sensors/ZebraTechDOpto.h b/src/sensors/ZebraTechDOpto.h index 6697550f1..352925a96 100644 --- a/src/sensors/ZebraTechDOpto.h +++ b/src/sensors/ZebraTechDOpto.h @@ -45,6 +45,7 @@ // Included Dependencies #include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD #include "VariableBase.h" #include "sensors/SDI12Sensors.h" From 13b4cb85c08944dba653014bd6c359ce2e170bbe Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 21 May 2019 15:01:35 -0400 Subject: [PATCH 38/88] Added missing destructors --- src/modems/DigiXBee.h | 1 + src/modems/DigiXBeeCellularBypass.h | 1 + src/modems/DigiXBeeCellularTransparent.h | 1 + src/modems/DigiXBeeWifi.h | 1 + src/modems/EspressifESP8266.h | 1 + src/modems/QuectelBG96.h | 1 + src/modems/SIMComSIM7000.h | 2 +- src/modems/SIMComSIM800.h | 1 + src/modems/SequansMonarch.h | 1 + src/modems/Sodaq2GBeeR6.h | 1 + src/modems/SodaqUBeeR410M.h | 1 + src/modems/SodaqUBeeU201.h | 1 + 12 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/modems/DigiXBee.h b/src/modems/DigiXBee.h index c5e3150d5..b3cb29e22 100644 --- a/src/modems/DigiXBee.h +++ b/src/modems/DigiXBee.h @@ -50,6 +50,7 @@ class DigiXBee : public loggerModem DigiXBee(int8_t powerPin, int8_t statusPin, bool useCTSStatus, int8_t modemResetPin, int8_t modemSleepRqPin, uint8_t measurementsToAverage = 1); + virtual ~DigiXBee(); protected: virtual bool modemSleepFxn(void) override; diff --git a/src/modems/DigiXBeeCellularBypass.h b/src/modems/DigiXBeeCellularBypass.h index 02d93fb5b..c35277214 100644 --- a/src/modems/DigiXBeeCellularBypass.h +++ b/src/modems/DigiXBeeCellularBypass.h @@ -42,6 +42,7 @@ class DigiXBeeCellularBypass : public DigiXBee int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); + virtual ~DigiXBeeCellularBypass(); bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index 8aa0ea071..36936b8c9 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -42,6 +42,7 @@ class DigiXBeeCellularTransparent : public DigiXBee int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); + virtual ~DigiXBeeCellularTransparent(); bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index 5ee42ad0c..b7d8ab938 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -42,6 +42,7 @@ class DigiXBeeWifi : public DigiXBee int8_t modemResetPin, int8_t modemSleepRqPin, const char *ssid, const char *pwd, uint8_t measurementsToAverage = 1); + virtual ~DigiXBeeWifi(); bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h index 0c9b57bee..9e411b484 100644 --- a/src/modems/EspressifESP8266.h +++ b/src/modems/EspressifESP8266.h @@ -61,6 +61,7 @@ class EspressifESP8266 : public loggerModem const char *ssid, const char *pwd, uint8_t measurementsToAverage = 1, int8_t espSleepRqPin = -1, int8_t espStatusPin = -1); + virtual ~EspressifESP8266(); bool startSingleMeasurement(void) override; bool isMeasurementComplete(bool debug=false) override; diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index f8551435d..00731bf51 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -57,6 +57,7 @@ class QuectelBG96 : public loggerModem int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); + virtual ~QuectelBG96(); bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h index 19b83d7f7..d00d707c9 100644 --- a/src/modems/SIMComSIM7000.h +++ b/src/modems/SIMComSIM7000.h @@ -56,7 +56,7 @@ class SIMComSIM7000 : public loggerModem int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - + virtual ~SIMComSIM7000(); bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index 88e2ea48c..4b0553cf0 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -59,6 +59,7 @@ class SIMComSIM800 : public loggerModem int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); + virtual ~SIMComSIM800(){} bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; diff --git a/src/modems/SequansMonarch.h b/src/modems/SequansMonarch.h index 4ef968576..af87e2ec2 100644 --- a/src/modems/SequansMonarch.h +++ b/src/modems/SequansMonarch.h @@ -57,6 +57,7 @@ class SequansMonarch : public loggerModem int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); + virtual ~SequansMonarch(); bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h index ae4b5bea3..07859da2e 100644 --- a/src/modems/Sodaq2GBeeR6.h +++ b/src/modems/Sodaq2GBeeR6.h @@ -58,6 +58,7 @@ class Sodaq2GBeeR6 : public loggerModem int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); + virtual ~Sodaq2GBeeR6(){} bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index 24aa95df6..c2705594d 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -68,6 +68,7 @@ class SodaqUBeeR410M : public loggerModem const char *apn, uint8_t measurementsToAverage = 1); #endif + virtual ~SodaqUBeeR410M(){} bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index 08ac4f85a..05c2b18cc 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -62,6 +62,7 @@ class SodaqUBeeU201 : public loggerModem int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); + virtual ~SodaqUBeeU201(){} bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; From 81975f81112e9907b65c048f89d3f2cef67d3126 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 21 May 2019 16:34:21 -0400 Subject: [PATCH 39/88] Changed isMeasurementComplete to verifyMeasurementComplete in modems --- src/LoggerModem.cpp | 5 +++++ src/LoggerModem.h | 9 +++++---- src/modems/DigiXBee.h | 2 +- src/modems/DigiXBeeCellularBypass.cpp | 4 ++-- src/modems/DigiXBeeCellularBypass.h | 4 ++-- src/modems/DigiXBeeCellularTransparent.cpp | 4 ++-- src/modems/DigiXBeeCellularTransparent.h | 4 ++-- src/modems/DigiXBeeWifi.cpp | 4 ++-- src/modems/DigiXBeeWifi.h | 4 ++-- src/modems/EspressifESP8266.cpp | 2 +- src/modems/EspressifESP8266.h | 4 ++-- src/modems/LoggerModemMacros.h | 4 ++-- src/modems/QuectelBG96.cpp | 2 +- src/modems/QuectelBG96.h | 4 ++-- src/modems/SIMComSIM7000.cpp | 2 +- src/modems/SIMComSIM7000.h | 5 +++-- src/modems/SIMComSIM800.cpp | 2 +- src/modems/SIMComSIM800.h | 6 +++--- src/modems/SequansMonarch.cpp | 2 +- src/modems/SequansMonarch.h | 6 +++--- src/modems/Sodaq2GBeeR6.cpp | 2 +- src/modems/Sodaq2GBeeR6.h | 4 ++-- src/modems/SodaqUBeeR410M.cpp | 2 +- src/modems/SodaqUBeeR410M.h | 4 ++-- src/modems/SodaqUBeeU201.cpp | 2 +- src/modems/SodaqUBeeU201.h | 4 ++-- 26 files changed, 52 insertions(+), 45 deletions(-) diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index b9fb0522a..57e88eb15 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -299,6 +299,11 @@ bool loggerModem::isStable(bool debug) return false; } +bool loggerModem::isMeasurementComplete(bool debug) +{ + return verifyMeasurementComplete(debug); +} + // ==========================================================================// // These are the unique functions for the modem as an internet connected device diff --git a/src/LoggerModem.h b/src/LoggerModem.h index d56185cc7..0ef5f6af1 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -53,20 +53,20 @@ class loggerModem : public Sensor // These are the functions that set the modem up as a sensor // ==========================================================================// public: - // Constructors + // Constructor/Destructor loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, int8_t modemResetPin, int8_t modemSleepRqPin, bool alwaysRunWake, uint32_t max_status_time_ms, uint32_t max_disconnetTime_ms, uint32_t max_warmUpTime_ms, uint32_t max_atresponse_time_ms, uint32_t max_signalQuality_time_ms, uint8_t measurementsToAverage = 1); - virtual ~loggerModem(); String getSensorName(void) override; virtual bool setup(void) override; virtual bool wake(void) override; + virtual bool addSingleMeasurementResult(void) = 0; // Do NOT turn the modem on and off with the regular power up and down! // This is because when it is run in an array with other sensors, we will @@ -95,7 +95,7 @@ class loggerModem : public Sensor // responses are good so we're getting an actual signal strength and it's as // close as possible to what the antenna is will see when the data publishers // push data. - virtual bool isMeasurementComplete(bool debug) = 0; + virtual bool isMeasurementComplete(bool debug = false) override; // ==========================================================================// @@ -122,7 +122,7 @@ class loggerModem : public Sensor // void closeTCP(void); // Special sleep and power function for the modem void modemPowerUp(void); - virtual bool modemSleepPowerDown(void); + bool modemSleepPowerDown(void); // Get the time from NIST via TIME protocol (rfc868) // This would be much more efficient if done over UDP, but I'm doing it @@ -142,6 +142,7 @@ class loggerModem : public Sensor void modemLEDOff(void); virtual bool didATRespond(void) = 0; virtual bool isInternetAvailable(void) = 0; + virtual bool verifyMeasurementComplete(bool debug = false) = 0; virtual bool modemSleepFxn(void) = 0; virtual bool modemWakeFxn(void) = 0; virtual bool extraModemSetup(void) = 0; diff --git a/src/modems/DigiXBee.h b/src/modems/DigiXBee.h index b3cb29e22..f3db0030d 100644 --- a/src/modems/DigiXBee.h +++ b/src/modems/DigiXBee.h @@ -46,7 +46,7 @@ class DigiXBee : public loggerModem { public: - // Constructors + // Constructor/Destructor DigiXBee(int8_t powerPin, int8_t statusPin, bool useCTSStatus, int8_t modemResetPin, int8_t modemSleepRqPin, uint8_t measurementsToAverage = 1); diff --git a/src/modems/DigiXBeeCellularBypass.cpp b/src/modems/DigiXBeeCellularBypass.cpp index 1fec554a3..053c6fcd9 100644 --- a/src/modems/DigiXBeeCellularBypass.cpp +++ b/src/modems/DigiXBeeCellularBypass.cpp @@ -11,7 +11,7 @@ #include "DigiXBeeCellularBypass.h" #include "modems/LoggerModemMacros.h" -// Constructors +// Constructor/Destructor DigiXBeeCellularBypass::DigiXBeeCellularBypass(Stream* modemStream, int8_t powerPin, int8_t statusPin, bool useCTSStatus, int8_t modemResetPin, int8_t modemSleepRqPin, @@ -34,7 +34,7 @@ DigiXBeeCellularBypass::DigiXBeeCellularBypass(Stream* modemStream, MS_MODEM_DID_AT_RESPOND(DigiXBeeCellularBypass); MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeCellularBypass); -MS_MODEM_IS_MEASUREMENT_COMPLETE(DigiXBeeCellularBypass); +MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(DigiXBeeCellularBypass); MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(DigiXBeeCellularBypass); MS_MODEM_CONNECT_INTERNET(DigiXBeeCellularBypass); MS_MODEM_GET_NIST_TIME(DigiXBeeCellularBypass); diff --git a/src/modems/DigiXBeeCellularBypass.h b/src/modems/DigiXBeeCellularBypass.h index c35277214..d16cd2085 100644 --- a/src/modems/DigiXBeeCellularBypass.h +++ b/src/modems/DigiXBeeCellularBypass.h @@ -36,7 +36,7 @@ class DigiXBeeCellularBypass : public DigiXBee { public: - // Constructors + // Constructor/Destructor DigiXBeeCellularBypass(Stream* modemStream, int8_t powerPin, int8_t statusPin, bool useCTSStatus, int8_t modemResetPin, int8_t modemSleepRqPin, @@ -44,7 +44,6 @@ class DigiXBeeCellularBypass : public DigiXBee uint8_t measurementsToAverage = 1); virtual ~DigiXBeeCellularBypass(); - bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; @@ -62,6 +61,7 @@ class DigiXBeeCellularBypass : public DigiXBee protected: bool didATRespond(void) override; bool isInternetAvailable(void) override; + bool verifyMeasurementComplete(bool debug=false) override; bool extraModemSetup(void) override; private: diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index a812e318d..301eee2ec 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -11,7 +11,7 @@ #include "DigiXBeeCellularTransparent.h" #include "modems/LoggerModemMacros.h" -// Constructors +// Constructor/Destructor DigiXBeeCellularTransparent::DigiXBeeCellularTransparent(Stream* modemStream, int8_t powerPin, int8_t statusPin, bool useCTSStatus, int8_t modemResetPin, int8_t modemSleepRqPin, @@ -34,7 +34,7 @@ DigiXBeeCellularTransparent::DigiXBeeCellularTransparent(Stream* modemStream, MS_MODEM_DID_AT_RESPOND(DigiXBeeCellularTransparent); MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeCellularTransparent); -MS_MODEM_IS_MEASUREMENT_COMPLETE(DigiXBeeCellularTransparent); +MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(DigiXBeeCellularTransparent); MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(DigiXBeeCellularTransparent); MS_MODEM_CONNECT_INTERNET(DigiXBeeCellularTransparent); MS_MODEM_GET_NIST_TIME(DigiXBeeCellularTransparent); diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index 36936b8c9..62226212e 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -36,7 +36,7 @@ class DigiXBeeCellularTransparent : public DigiXBee { public: - // Constructors + // Constructor/Destructor DigiXBeeCellularTransparent(Stream* modemStream, int8_t powerPin, int8_t statusPin, bool useCTSStatus, int8_t modemResetPin, int8_t modemSleepRqPin, @@ -44,7 +44,6 @@ class DigiXBeeCellularTransparent : public DigiXBee uint8_t measurementsToAverage = 1); virtual ~DigiXBeeCellularTransparent(); - bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; @@ -62,6 +61,7 @@ class DigiXBeeCellularTransparent : public DigiXBee protected: bool didATRespond(void) override; bool isInternetAvailable(void) override; + bool verifyMeasurementComplete(bool debug=false) override; bool extraModemSetup(void) override; private: diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index 7d239180d..feb64f927 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -12,7 +12,7 @@ #include "modems/LoggerModemMacros.h" -// Constructors +// Constructor/Destructor DigiXBeeWifi::DigiXBeeWifi(Stream* modemStream, int8_t powerPin, int8_t statusPin, bool useCTSStatus, int8_t modemResetPin, int8_t modemSleepRqPin, @@ -36,7 +36,7 @@ DigiXBeeWifi::DigiXBeeWifi(Stream* modemStream, MS_MODEM_DID_AT_RESPOND(DigiXBeeWifi); MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeWifi); -MS_MODEM_IS_MEASUREMENT_COMPLETE(DigiXBeeWifi); +MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(DigiXBeeWifi); MS_MODEM_CONNECT_INTERNET(DigiXBeeWifi); MS_MODEM_GET_NIST_TIME(DigiXBeeWifi); diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index b7d8ab938..a726b6afa 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -36,7 +36,7 @@ class DigiXBeeWifi : public DigiXBee { public: - // Constructors + // Constructor/Destructor DigiXBeeWifi(Stream* modemStream, int8_t powerPin, int8_t statusPin, bool useCTSStatus, int8_t modemResetPin, int8_t modemSleepRqPin, @@ -44,7 +44,6 @@ class DigiXBeeWifi : public DigiXBee uint8_t measurementsToAverage = 1); virtual ~DigiXBeeWifi(); - bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; @@ -62,6 +61,7 @@ class DigiXBeeWifi : public DigiXBee protected: bool didATRespond(void) override; bool isInternetAvailable(void) override; + bool verifyMeasurementComplete(bool debug=false) override; bool extraModemSetup(void) override; private: diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index 730998f28..c8732b521 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -46,7 +46,7 @@ EspressifESP8266::EspressifESP8266(Stream* modemStream, MS_MODEM_DID_AT_RESPOND(EspressifESP8266); MS_MODEM_IS_INTERNET_AVAILABLE(EspressifESP8266); -MS_MODEM_IS_MEASUREMENT_COMPLETE(EspressifESP8266); +MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(EspressifESP8266); MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(EspressifESP8266); MS_MODEM_CONNECT_INTERNET(EspressifESP8266); MS_MODEM_DISCONNECT_INTERNET(EspressifESP8266); diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h index 9e411b484..c3cf18e28 100644 --- a/src/modems/EspressifESP8266.h +++ b/src/modems/EspressifESP8266.h @@ -54,7 +54,7 @@ class EspressifESP8266 : public loggerModem { public: - // Constructors + // Constructor/Destructor EspressifESP8266(Stream* modemStream, int8_t powerPin, int8_t statusPin, int8_t modemResetPin, int8_t modemSleepRqPin, @@ -64,7 +64,6 @@ class EspressifESP8266 : public loggerModem virtual ~EspressifESP8266(); bool startSingleMeasurement(void) override; - bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; @@ -85,6 +84,7 @@ class EspressifESP8266 : public loggerModem protected: bool didATRespond(void) override; bool isInternetAvailable(void) override; + bool verifyMeasurementComplete(bool debug=false) override; bool modemSleepFxn(void) override; bool modemWakeFxn(void) override; bool extraModemSetup(void)override; diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 3c9e7920d..a88311894 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -63,8 +63,8 @@ bool specificModem::isInternetAvailable(void) \ #endif -#define MS_MODEM_IS_MEASUREMENT_COMPLETE(specificModem) \ -bool specificModem::isMeasurementComplete(bool debug) \ +#define MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(specificModem) \ +bool specificModem::verifyMeasurementComplete(bool debug) \ { \ /* If a measurement failed to start, the sensor will never return a result, */ \ /* so the measurement time is essentially already passed */ \ diff --git a/src/modems/QuectelBG96.cpp b/src/modems/QuectelBG96.cpp index 07eb5a53e..6d30f26e4 100644 --- a/src/modems/QuectelBG96.cpp +++ b/src/modems/QuectelBG96.cpp @@ -38,7 +38,7 @@ QuectelBG96::QuectelBG96(Stream* modemStream, MS_MODEM_DID_AT_RESPOND(QuectelBG96); MS_MODEM_IS_INTERNET_AVAILABLE(QuectelBG96); -MS_MODEM_IS_MEASUREMENT_COMPLETE(QuectelBG96); +MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(QuectelBG96); MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(QuectelBG96); MS_MODEM_CONNECT_INTERNET(QuectelBG96); MS_MODEM_DISCONNECT_INTERNET(QuectelBG96); diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index 00731bf51..89f60eae3 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -51,7 +51,7 @@ class QuectelBG96 : public loggerModem { public: - // Constructors + // Constructor/Destructor QuectelBG96(Stream* modemStream, int8_t powerPin, int8_t statusPin, int8_t modemResetPin, int8_t modemSleepRqPin, @@ -59,7 +59,6 @@ class QuectelBG96 : public loggerModem uint8_t measurementsToAverage = 1); virtual ~QuectelBG96(); - bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; @@ -77,6 +76,7 @@ class QuectelBG96 : public loggerModem protected: bool didATRespond(void) override; bool isInternetAvailable(void) override; + bool verifyMeasurementComplete(bool debug=false) override; bool modemSleepFxn(void) override; bool modemWakeFxn(void) override; bool extraModemSetup(void)override; diff --git a/src/modems/SIMComSIM7000.cpp b/src/modems/SIMComSIM7000.cpp index e3087fcd5..b7cde3d3d 100644 --- a/src/modems/SIMComSIM7000.cpp +++ b/src/modems/SIMComSIM7000.cpp @@ -38,7 +38,7 @@ SIMComSIM7000::SIMComSIM7000(Stream* modemStream, MS_MODEM_DID_AT_RESPOND(SIMComSIM7000); MS_MODEM_IS_INTERNET_AVAILABLE(SIMComSIM7000); -MS_MODEM_IS_MEASUREMENT_COMPLETE(SIMComSIM7000); +MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(SIMComSIM7000); MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(SIMComSIM7000); MS_MODEM_CONNECT_INTERNET(SIMComSIM7000); MS_MODEM_DISCONNECT_INTERNET(SIMComSIM7000); diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h index d00d707c9..679a16b9e 100644 --- a/src/modems/SIMComSIM7000.h +++ b/src/modems/SIMComSIM7000.h @@ -50,14 +50,14 @@ class SIMComSIM7000 : public loggerModem { public: - // Constructors + // Constructor/Destructor SIMComSIM7000(Stream* modemStream, int8_t powerPin, int8_t statusPin, int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); virtual ~SIMComSIM7000(); - bool isMeasurementComplete(bool debug=false) override; + bool addSingleMeasurementResult(void) override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; @@ -75,6 +75,7 @@ class SIMComSIM7000 : public loggerModem protected: bool didATRespond(void) override; bool isInternetAvailable(void) override; + bool verifyMeasurementComplete(bool debug=false) override; bool modemSleepFxn(void) override; bool modemWakeFxn(void) override; bool extraModemSetup(void)override; diff --git a/src/modems/SIMComSIM800.cpp b/src/modems/SIMComSIM800.cpp index 94f7ac7cd..26be2d126 100644 --- a/src/modems/SIMComSIM800.cpp +++ b/src/modems/SIMComSIM800.cpp @@ -40,7 +40,7 @@ SIMComSIM800::SIMComSIM800(Stream* modemStream, MS_MODEM_DID_AT_RESPOND(SIMComSIM800); MS_MODEM_IS_INTERNET_AVAILABLE(SIMComSIM800); -MS_MODEM_IS_MEASUREMENT_COMPLETE(SIMComSIM800); +MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(SIMComSIM800); MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(SIMComSIM800); MS_MODEM_CONNECT_INTERNET(SIMComSIM800); MS_MODEM_DISCONNECT_INTERNET(SIMComSIM800); diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index 4b0553cf0..84c794fa0 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -53,15 +53,14 @@ class SIMComSIM800 : public loggerModem { public: - // Constructors + // Constructor/Destructor SIMComSIM800(Stream* modemStream, int8_t powerPin, int8_t statusPin, int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~SIMComSIM800(){} + virtual ~SIMComSIM800(){} - bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; @@ -79,6 +78,7 @@ class SIMComSIM800 : public loggerModem protected: bool didATRespond(void) override; bool isInternetAvailable(void) override; + bool verifyMeasurementComplete(bool debug=false) override; bool modemSleepFxn(void) override; bool modemWakeFxn(void) override; bool extraModemSetup(void)override; diff --git a/src/modems/SequansMonarch.cpp b/src/modems/SequansMonarch.cpp index aee720bb3..c3d07e908 100644 --- a/src/modems/SequansMonarch.cpp +++ b/src/modems/SequansMonarch.cpp @@ -38,7 +38,7 @@ SequansMonarch::SequansMonarch(Stream* modemStream, MS_MODEM_DID_AT_RESPOND(SequansMonarch); MS_MODEM_IS_INTERNET_AVAILABLE(SequansMonarch); -MS_MODEM_IS_MEASUREMENT_COMPLETE(SequansMonarch); +MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(SequansMonarch); MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(SequansMonarch); MS_MODEM_CONNECT_INTERNET(SequansMonarch); MS_MODEM_DISCONNECT_INTERNET(SequansMonarch); diff --git a/src/modems/SequansMonarch.h b/src/modems/SequansMonarch.h index af87e2ec2..a7f5c6bd0 100644 --- a/src/modems/SequansMonarch.h +++ b/src/modems/SequansMonarch.h @@ -51,15 +51,14 @@ class SequansMonarch : public loggerModem { public: - // Constructors + // Constructor/Destructor SequansMonarch(Stream* modemStream, int8_t powerPin, int8_t statusPin, int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~SequansMonarch(); + virtual ~SequansMonarch(); - bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; @@ -77,6 +76,7 @@ class SequansMonarch : public loggerModem protected: bool didATRespond(void) override; bool isInternetAvailable(void) override; + bool verifyMeasurementComplete(bool debug=false) override; bool modemSleepFxn(void) override; bool modemWakeFxn(void) override; bool extraModemSetup(void)override; diff --git a/src/modems/Sodaq2GBeeR6.cpp b/src/modems/Sodaq2GBeeR6.cpp index cf7ce8986..09fc48fc4 100644 --- a/src/modems/Sodaq2GBeeR6.cpp +++ b/src/modems/Sodaq2GBeeR6.cpp @@ -39,7 +39,7 @@ Sodaq2GBeeR6::Sodaq2GBeeR6(Stream* modemStream, MS_MODEM_DID_AT_RESPOND(Sodaq2GBeeR6); MS_MODEM_IS_INTERNET_AVAILABLE(Sodaq2GBeeR6); -MS_MODEM_IS_MEASUREMENT_COMPLETE(Sodaq2GBeeR6); +MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(Sodaq2GBeeR6); MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(Sodaq2GBeeR6); MS_MODEM_CONNECT_INTERNET(Sodaq2GBeeR6); MS_MODEM_DISCONNECT_INTERNET(Sodaq2GBeeR6); diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h index 07859da2e..674c8a028 100644 --- a/src/modems/Sodaq2GBeeR6.h +++ b/src/modems/Sodaq2GBeeR6.h @@ -51,7 +51,7 @@ class Sodaq2GBeeR6 : public loggerModem { public: - // Constructors + // Constructor/Destructor // NOTE: The Sodaq GPRSBee doesn't expose the SIM800's reset pin Sodaq2GBeeR6(Stream* modemStream, int8_t powerPin, int8_t statusPin, @@ -60,7 +60,6 @@ class Sodaq2GBeeR6 : public loggerModem uint8_t measurementsToAverage = 1); virtual ~Sodaq2GBeeR6(){} - bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; @@ -78,6 +77,7 @@ class Sodaq2GBeeR6 : public loggerModem protected: bool didATRespond(void) override; bool isInternetAvailable(void) override; + bool verifyMeasurementComplete(bool debug=false) override; bool modemSleepFxn(void) override; bool modemWakeFxn(void) override; bool extraModemSetup(void)override; diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp index 26629f675..93ae666cd 100644 --- a/src/modems/SodaqUBeeR410M.cpp +++ b/src/modems/SodaqUBeeR410M.cpp @@ -64,7 +64,7 @@ SodaqUBeeR410M::SodaqUBeeR410M(Stream* modemStream, MS_MODEM_DID_AT_RESPOND(SodaqUBeeR410M); MS_MODEM_IS_INTERNET_AVAILABLE(SodaqUBeeR410M); -MS_MODEM_IS_MEASUREMENT_COMPLETE(SodaqUBeeR410M); +MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(SodaqUBeeR410M); MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(SodaqUBeeR410M); MS_MODEM_CONNECT_INTERNET(SodaqUBeeR410M); MS_MODEM_DISCONNECT_INTERNET(SodaqUBeeR410M); diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index c2705594d..e056514c3 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -52,7 +52,7 @@ class SodaqUBeeR410M : public loggerModem { public: - // Constructors + // Constructor/Destructor #if F_CPU == 8000000L // At this slow baud rate, we need to begin and end serial communication, // so we need a Serial instance rather than a stream @@ -70,7 +70,6 @@ class SodaqUBeeR410M : public loggerModem #endif virtual ~SodaqUBeeR410M(){} - bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; @@ -92,6 +91,7 @@ class SodaqUBeeR410M : public loggerModem protected: bool didATRespond(void) override; bool isInternetAvailable(void) override; + bool verifyMeasurementComplete(bool debug=false) override; bool modemSleepFxn(void) override; bool modemWakeFxn(void) override; bool extraModemSetup(void)override; diff --git a/src/modems/SodaqUBeeU201.cpp b/src/modems/SodaqUBeeU201.cpp index d41773396..bfbb67ce0 100644 --- a/src/modems/SodaqUBeeU201.cpp +++ b/src/modems/SodaqUBeeU201.cpp @@ -38,7 +38,7 @@ SodaqUBeeU201::SodaqUBeeU201(Stream* modemStream, MS_MODEM_DID_AT_RESPOND(SodaqUBeeU201); MS_MODEM_IS_INTERNET_AVAILABLE(SodaqUBeeU201); -MS_MODEM_IS_MEASUREMENT_COMPLETE(SodaqUBeeU201); +MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(SodaqUBeeU201); MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(SodaqUBeeU201); MS_MODEM_CONNECT_INTERNET(SodaqUBeeU201); MS_MODEM_DISCONNECT_INTERNET(SodaqUBeeU201); diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index 05c2b18cc..306d2c121 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -56,7 +56,7 @@ class SodaqUBeeU201 : public loggerModem { public: - // Constructors + // Constructor/Destructor SodaqUBeeU201(Stream* modemStream, int8_t powerPin, int8_t statusPin, int8_t modemResetPin, int8_t modemSleepRqPin, @@ -64,7 +64,6 @@ class SodaqUBeeU201 : public loggerModem uint8_t measurementsToAverage = 1); virtual ~SodaqUBeeU201(){} - bool isMeasurementComplete(bool debug=false) override; bool addSingleMeasurementResult(void) override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; @@ -82,6 +81,7 @@ class SodaqUBeeU201 : public loggerModem protected: bool didATRespond(void) override; bool isInternetAvailable(void) override; + bool verifyMeasurementComplete(bool debug=false) override; bool modemSleepFxn(void) override; bool modemWakeFxn(void) override; bool extraModemSetup(void)override; From 881b3b201ee87f8d23eb6201576f37abe1972c61 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 21 May 2019 17:00:54 -0400 Subject: [PATCH 40/88] Still hunting missing virtual functions crashing linker --- src/modems/DigiXBee.h | 17 ++++++++++++++++- src/modems/DigiXBeeCellularBypass.h | 2 +- src/modems/DigiXBeeCellularTransparent.h | 2 +- src/modems/DigiXBeeWifi.h | 2 +- src/modems/EspressifESP8266.h | 2 +- src/modems/QuectelBG96.h | 2 +- src/modems/SIMComSIM7000.h | 2 +- 7 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/modems/DigiXBee.h b/src/modems/DigiXBee.h index f3db0030d..fca3a4740 100644 --- a/src/modems/DigiXBee.h +++ b/src/modems/DigiXBee.h @@ -50,11 +50,26 @@ class DigiXBee : public loggerModem DigiXBee(int8_t powerPin, int8_t statusPin, bool useCTSStatus, int8_t modemResetPin, int8_t modemSleepRqPin, uint8_t measurementsToAverage = 1); - virtual ~DigiXBee(); + virtual ~DigiXBee(){} + + virtual bool addSingleMeasurementResult(void) = 0; + + // Access the internet + virtual bool connectInternet(uint32_t maxConnectionTime = 50000L) = 0; + virtual void disconnectInternet(void) = 0; + + // Get the time from NIST via TIME protocol (rfc868) + // This would be much more efficient if done over UDP, but I'm doing it + // over TCP because I don't have a UDP library for all the modems. + virtual uint32_t getNISTTime(void) = 0; protected: + virtual bool didATRespond(void) = 0; + virtual bool isInternetAvailable(void) = 0; + virtual bool verifyMeasurementComplete(bool debug = false) = 0; virtual bool modemSleepFxn(void) override; virtual bool modemWakeFxn(void) override; + virtual bool extraModemSetup(void) = 0; }; #endif // Header Guard diff --git a/src/modems/DigiXBeeCellularBypass.h b/src/modems/DigiXBeeCellularBypass.h index d16cd2085..8ee6237da 100644 --- a/src/modems/DigiXBeeCellularBypass.h +++ b/src/modems/DigiXBeeCellularBypass.h @@ -42,7 +42,7 @@ class DigiXBeeCellularBypass : public DigiXBee int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~DigiXBeeCellularBypass(); + virtual ~DigiXBeeCellularBypass(){} bool addSingleMeasurementResult(void) override; diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index 62226212e..a4321f43f 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -42,7 +42,7 @@ class DigiXBeeCellularTransparent : public DigiXBee int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~DigiXBeeCellularTransparent(); + virtual ~DigiXBeeCellularTransparent(){} bool addSingleMeasurementResult(void) override; diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index a726b6afa..27605fae6 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -42,7 +42,7 @@ class DigiXBeeWifi : public DigiXBee int8_t modemResetPin, int8_t modemSleepRqPin, const char *ssid, const char *pwd, uint8_t measurementsToAverage = 1); - virtual ~DigiXBeeWifi(); + virtual ~DigiXBeeWifi(){} bool addSingleMeasurementResult(void) override; diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h index c3cf18e28..4634ea0c3 100644 --- a/src/modems/EspressifESP8266.h +++ b/src/modems/EspressifESP8266.h @@ -61,7 +61,7 @@ class EspressifESP8266 : public loggerModem const char *ssid, const char *pwd, uint8_t measurementsToAverage = 1, int8_t espSleepRqPin = -1, int8_t espStatusPin = -1); - virtual ~EspressifESP8266(); + virtual ~EspressifESP8266(){} bool startSingleMeasurement(void) override; bool addSingleMeasurementResult(void) override; diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index 89f60eae3..ce5c7e943 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -57,7 +57,7 @@ class QuectelBG96 : public loggerModem int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~QuectelBG96(); + virtual ~QuectelBG96(){} bool addSingleMeasurementResult(void) override; diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h index 679a16b9e..5f036e273 100644 --- a/src/modems/SIMComSIM7000.h +++ b/src/modems/SIMComSIM7000.h @@ -56,7 +56,7 @@ class SIMComSIM7000 : public loggerModem int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~SIMComSIM7000(); + virtual ~SIMComSIM7000(){} bool addSingleMeasurementResult(void) override; From a743ad19ad7fe225c0cd6b317294b527e8cffa40 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 21 May 2019 17:35:26 -0400 Subject: [PATCH 41/88] Still the destructor? --- src/modems/DigiXBee.cpp | 4 ++++ src/modems/DigiXBee.h | 2 +- src/modems/DigiXBeeCellularBypass.cpp | 4 ++++ src/modems/DigiXBeeCellularBypass.h | 2 +- src/modems/DigiXBeeCellularTransparent.cpp | 4 ++++ src/modems/DigiXBeeCellularTransparent.h | 2 +- src/modems/DigiXBeeWifi.cpp | 4 ++++ src/modems/DigiXBeeWifi.h | 2 +- src/modems/EspressifESP8266.cpp | 5 +++++ src/modems/EspressifESP8266.h | 2 +- src/modems/QuectelBG96.cpp | 4 ++++ src/modems/QuectelBG96.h | 2 +- src/modems/SIMComSIM7000.cpp | 4 ++++ src/modems/SIMComSIM7000.h | 2 +- src/modems/SIMComSIM800.cpp | 4 ++++ src/modems/SIMComSIM800.h | 2 +- src/modems/SequansMonarch.cpp | 4 ++++ src/modems/Sodaq2GBeeR6.cpp | 4 ++++ src/modems/Sodaq2GBeeR6.h | 2 +- src/modems/SodaqUBeeR410M.cpp | 4 ++++ src/modems/SodaqUBeeR410M.h | 2 +- src/modems/SodaqUBeeU201.cpp | 4 ++++ src/modems/SodaqUBeeU201.h | 2 +- 23 files changed, 60 insertions(+), 11 deletions(-) diff --git a/src/modems/DigiXBee.cpp b/src/modems/DigiXBee.cpp index 724e43ae1..9d2535f56 100644 --- a/src/modems/DigiXBee.cpp +++ b/src/modems/DigiXBee.cpp @@ -24,6 +24,10 @@ DigiXBee::DigiXBee(int8_t powerPin, int8_t statusPin, bool useCTSStatus, {} +// Destructor +DigiXBee::~DigiXBee(){} + + // Create the wake and sleep methods for the modem // These can be functions of any type and must return a boolean // After enabling pin sleep, the sleep request pin is held LOW to keep the XBee on diff --git a/src/modems/DigiXBee.h b/src/modems/DigiXBee.h index fca3a4740..2fda1e1d0 100644 --- a/src/modems/DigiXBee.h +++ b/src/modems/DigiXBee.h @@ -50,7 +50,7 @@ class DigiXBee : public loggerModem DigiXBee(int8_t powerPin, int8_t statusPin, bool useCTSStatus, int8_t modemResetPin, int8_t modemSleepRqPin, uint8_t measurementsToAverage = 1); - virtual ~DigiXBee(){} + virtual ~DigiXBee(); virtual bool addSingleMeasurementResult(void) = 0; diff --git a/src/modems/DigiXBeeCellularBypass.cpp b/src/modems/DigiXBeeCellularBypass.cpp index 053c6fcd9..2d521a39f 100644 --- a/src/modems/DigiXBeeCellularBypass.cpp +++ b/src/modems/DigiXBeeCellularBypass.cpp @@ -32,6 +32,10 @@ DigiXBeeCellularBypass::DigiXBeeCellularBypass(Stream* modemStream, } +// Destructor +DigiXBeeCellularBypass::~DigiXBeeCellularBypass(){} + + MS_MODEM_DID_AT_RESPOND(DigiXBeeCellularBypass); MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeCellularBypass); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(DigiXBeeCellularBypass); diff --git a/src/modems/DigiXBeeCellularBypass.h b/src/modems/DigiXBeeCellularBypass.h index 8ee6237da..d16cd2085 100644 --- a/src/modems/DigiXBeeCellularBypass.h +++ b/src/modems/DigiXBeeCellularBypass.h @@ -42,7 +42,7 @@ class DigiXBeeCellularBypass : public DigiXBee int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~DigiXBeeCellularBypass(){} + virtual ~DigiXBeeCellularBypass(); bool addSingleMeasurementResult(void) override; diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index 301eee2ec..ee72361a4 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -32,6 +32,10 @@ DigiXBeeCellularTransparent::DigiXBeeCellularTransparent(Stream* modemStream, } +// Destructor +DigiXBeeCellularTransparent::~DigiXBeeCellularTransparent(){} + + MS_MODEM_DID_AT_RESPOND(DigiXBeeCellularTransparent); MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeCellularTransparent); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(DigiXBeeCellularTransparent); diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index a4321f43f..62226212e 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -42,7 +42,7 @@ class DigiXBeeCellularTransparent : public DigiXBee int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~DigiXBeeCellularTransparent(){} + virtual ~DigiXBeeCellularTransparent(); bool addSingleMeasurementResult(void) override; diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index feb64f927..e0b65bc4f 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -34,6 +34,10 @@ DigiXBeeWifi::DigiXBeeWifi(Stream* modemStream, } +// Destructor +DigiXBeeWifi::~DigiXBeeWifi(){} + + MS_MODEM_DID_AT_RESPOND(DigiXBeeWifi); MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeWifi); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(DigiXBeeWifi); diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index 27605fae6..a726b6afa 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -42,7 +42,7 @@ class DigiXBeeWifi : public DigiXBee int8_t modemResetPin, int8_t modemSleepRqPin, const char *ssid, const char *pwd, uint8_t measurementsToAverage = 1); - virtual ~DigiXBeeWifi(){} + virtual ~DigiXBeeWifi(); bool addSingleMeasurementResult(void) override; diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index c8732b521..82bbe472f 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -44,6 +44,11 @@ EspressifESP8266::EspressifESP8266(Stream* modemStream, _modemStream = modemStream; } + +// Destructor +EspressifESP8266::~EspressifESP8266(){} + + MS_MODEM_DID_AT_RESPOND(EspressifESP8266); MS_MODEM_IS_INTERNET_AVAILABLE(EspressifESP8266); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(EspressifESP8266); diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h index 4634ea0c3..c3cf18e28 100644 --- a/src/modems/EspressifESP8266.h +++ b/src/modems/EspressifESP8266.h @@ -61,7 +61,7 @@ class EspressifESP8266 : public loggerModem const char *ssid, const char *pwd, uint8_t measurementsToAverage = 1, int8_t espSleepRqPin = -1, int8_t espStatusPin = -1); - virtual ~EspressifESP8266(){} + virtual ~EspressifESP8266(); bool startSingleMeasurement(void) override; bool addSingleMeasurementResult(void) override; diff --git a/src/modems/QuectelBG96.cpp b/src/modems/QuectelBG96.cpp index 6d30f26e4..9a52f6df7 100644 --- a/src/modems/QuectelBG96.cpp +++ b/src/modems/QuectelBG96.cpp @@ -36,6 +36,10 @@ QuectelBG96::QuectelBG96(Stream* modemStream, } +// Destructor +QuectelBG96::~QuectelBG96(){} + + MS_MODEM_DID_AT_RESPOND(QuectelBG96); MS_MODEM_IS_INTERNET_AVAILABLE(QuectelBG96); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(QuectelBG96); diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index ce5c7e943..89f60eae3 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -57,7 +57,7 @@ class QuectelBG96 : public loggerModem int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~QuectelBG96(){} + virtual ~QuectelBG96(); bool addSingleMeasurementResult(void) override; diff --git a/src/modems/SIMComSIM7000.cpp b/src/modems/SIMComSIM7000.cpp index b7cde3d3d..49b6b7bf0 100644 --- a/src/modems/SIMComSIM7000.cpp +++ b/src/modems/SIMComSIM7000.cpp @@ -36,6 +36,10 @@ SIMComSIM7000::SIMComSIM7000(Stream* modemStream, } +// Destructor +SIMComSIM7000::~SIMComSIM7000(){} + + MS_MODEM_DID_AT_RESPOND(SIMComSIM7000); MS_MODEM_IS_INTERNET_AVAILABLE(SIMComSIM7000); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(SIMComSIM7000); diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h index 5f036e273..679a16b9e 100644 --- a/src/modems/SIMComSIM7000.h +++ b/src/modems/SIMComSIM7000.h @@ -56,7 +56,7 @@ class SIMComSIM7000 : public loggerModem int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~SIMComSIM7000(){} + virtual ~SIMComSIM7000(); bool addSingleMeasurementResult(void) override; diff --git a/src/modems/SIMComSIM800.cpp b/src/modems/SIMComSIM800.cpp index 26be2d126..4542b6391 100644 --- a/src/modems/SIMComSIM800.cpp +++ b/src/modems/SIMComSIM800.cpp @@ -38,6 +38,10 @@ SIMComSIM800::SIMComSIM800(Stream* modemStream, } +// Destructor +SIMComSIM800::~SIMComSIM800(){} + + MS_MODEM_DID_AT_RESPOND(SIMComSIM800); MS_MODEM_IS_INTERNET_AVAILABLE(SIMComSIM800); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(SIMComSIM800); diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index 84c794fa0..f2c7c20ee 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -59,7 +59,7 @@ class SIMComSIM800 : public loggerModem int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~SIMComSIM800(){} + virtual ~SIMComSIM800(); bool addSingleMeasurementResult(void) override; diff --git a/src/modems/SequansMonarch.cpp b/src/modems/SequansMonarch.cpp index c3d07e908..bbcd275a7 100644 --- a/src/modems/SequansMonarch.cpp +++ b/src/modems/SequansMonarch.cpp @@ -36,6 +36,10 @@ SequansMonarch::SequansMonarch(Stream* modemStream, } +// Destructor +SequansMonarch::~SequansMonarch(){} + + MS_MODEM_DID_AT_RESPOND(SequansMonarch); MS_MODEM_IS_INTERNET_AVAILABLE(SequansMonarch); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(SequansMonarch); diff --git a/src/modems/Sodaq2GBeeR6.cpp b/src/modems/Sodaq2GBeeR6.cpp index 09fc48fc4..976e27ffc 100644 --- a/src/modems/Sodaq2GBeeR6.cpp +++ b/src/modems/Sodaq2GBeeR6.cpp @@ -37,6 +37,10 @@ Sodaq2GBeeR6::Sodaq2GBeeR6(Stream* modemStream, } +// Destructor +Sodaq2GBeeR6::~Sodaq2GBeeR6(){} + + MS_MODEM_DID_AT_RESPOND(Sodaq2GBeeR6); MS_MODEM_IS_INTERNET_AVAILABLE(Sodaq2GBeeR6); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(Sodaq2GBeeR6); diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h index 674c8a028..946c8fd7e 100644 --- a/src/modems/Sodaq2GBeeR6.h +++ b/src/modems/Sodaq2GBeeR6.h @@ -58,7 +58,7 @@ class Sodaq2GBeeR6 : public loggerModem int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~Sodaq2GBeeR6(){} + virtual ~Sodaq2GBeeR6(); bool addSingleMeasurementResult(void) override; diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp index 93ae666cd..25cab6e30 100644 --- a/src/modems/SodaqUBeeR410M.cpp +++ b/src/modems/SodaqUBeeR410M.cpp @@ -62,6 +62,10 @@ SodaqUBeeR410M::SodaqUBeeR410M(Stream* modemStream, #endif +// Destructor +SodaqUBeeR410M::~SodaqUBeeR410M(){} + + MS_MODEM_DID_AT_RESPOND(SodaqUBeeR410M); MS_MODEM_IS_INTERNET_AVAILABLE(SodaqUBeeR410M); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(SodaqUBeeR410M); diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index e056514c3..fccb6fed6 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -68,7 +68,7 @@ class SodaqUBeeR410M : public loggerModem const char *apn, uint8_t measurementsToAverage = 1); #endif - virtual ~SodaqUBeeR410M(){} + virtual ~SodaqUBeeR410M(); bool addSingleMeasurementResult(void) override; diff --git a/src/modems/SodaqUBeeU201.cpp b/src/modems/SodaqUBeeU201.cpp index bfbb67ce0..7fab3b4e6 100644 --- a/src/modems/SodaqUBeeU201.cpp +++ b/src/modems/SodaqUBeeU201.cpp @@ -36,6 +36,10 @@ SodaqUBeeU201::SodaqUBeeU201(Stream* modemStream, } +// Destructor +SodaqUBeeU201::~SodaqUBeeU201(){} + + MS_MODEM_DID_AT_RESPOND(SodaqUBeeU201); MS_MODEM_IS_INTERNET_AVAILABLE(SodaqUBeeU201); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(SodaqUBeeU201); diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index 306d2c121..f84bba20d 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -62,7 +62,7 @@ class SodaqUBeeU201 : public loggerModem int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~SodaqUBeeU201(){} + virtual ~SodaqUBeeU201(); bool addSingleMeasurementResult(void) override; From 891ee176a80d59d37afac71cfa5f1a0f71b3e6db Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 21 May 2019 18:59:49 -0400 Subject: [PATCH 42/88] Re-implement modem results --- src/LoggerModem.cpp | 49 ++++++++++++ src/LoggerModem.h | 11 +-- src/modems/DigiXBee.h | 7 +- src/modems/DigiXBeeCellularBypass.cpp | 4 +- src/modems/DigiXBeeCellularBypass.h | 7 +- src/modems/DigiXBeeCellularTransparent.cpp | 4 +- src/modems/DigiXBeeCellularTransparent.h | 7 +- src/modems/DigiXBeeWifi.cpp | 2 + src/modems/DigiXBeeWifi.h | 5 ++ src/modems/EspressifESP8266.cpp | 4 +- src/modems/EspressifESP8266.h | 6 +- src/modems/LoggerModemMacros.h | 88 +++++++++++++--------- src/modems/QuectelBG96.cpp | 4 +- src/modems/QuectelBG96.h | 7 +- src/modems/SIMComSIM7000.cpp | 4 +- src/modems/SIMComSIM7000.h | 7 +- src/modems/SIMComSIM800.cpp | 4 +- src/modems/SIMComSIM800.h | 7 +- src/modems/SequansMonarch.cpp | 4 +- src/modems/SequansMonarch.h | 7 +- src/modems/Sodaq2GBeeR6.cpp | 4 +- src/modems/Sodaq2GBeeR6.h | 7 +- src/modems/SodaqUBeeR410M.cpp | 4 +- src/modems/SodaqUBeeR410M.h | 7 +- src/modems/SodaqUBeeU201.cpp | 4 +- src/modems/SodaqUBeeU201.h | 7 +- 26 files changed, 200 insertions(+), 71 deletions(-) diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index 57e88eb15..5c2e5a67e 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -299,12 +299,61 @@ bool loggerModem::isStable(bool debug) return false; } + bool loggerModem::isMeasurementComplete(bool debug) { return verifyMeasurementComplete(debug); } +bool loggerModem::addSingleMeasurementResult(void) +{ + bool success = true; + + /* Initialize float variable */ + int16_t percent = -9999; + int16_t rssi = -9999; + float volt = -9999; + float temp = -9999; + + /* Check a measurement was *successfully* started (status bit 6 set) */ + /* Only go on to get a result if it was */ + if (bitRead(_sensorStatus, 6)) + { + /* Get signal quality */ + /* NOTE: We can't actually distinguish between a bad modem response, no */ + /* modem response, and a real response from the modem of no service/signal. */ + /* The TinyGSM getSignalQuality function returns the same "no signal" */ + /* value (99 CSQ or 0 RSSI) in all 3 cases. */ + MS_DBG(F("Getting signal quality:")); + success &= getModemSignalQuality(rssi, percent); + MS_DBG(F("RSSI:"), rssi); + MS_DBG(F("Percent signal strength:"), percent); + + MS_DBG(F("Getting battery, if possible:")); + volt = getModemBatteryVoltage(); + MS_DBG(F("Battery voltage:"), volt); + + MS_DBG(F("Getting chip temperature, if possible:")); + temp = getModemTemperature(); + MS_DBG(F("Battery voltage:"), temp); + } + else MS_DBG(getSensorName(), F("is not connected to the network; unable to get signal quality!")); + + verifyAndAddMeasurementResult(MODEM_RSSI_VAR_NUM, rssi); + verifyAndAddMeasurementResult(MODEM_PERCENT_SIGNAL_VAR_NUM, percent); + verifyAndAddMeasurementResult(MODEM_BATTERY_VAR_NUM, volt); + verifyAndAddMeasurementResult(MODEM_TEMPERATURE_VAR_NUM, temp); + + /* Unset the time stamp for the beginning of this measurement */ + _millisMeasurementRequested = 0; + /* Unset the status bits for a measurement request (bits 5 & 6) */ + _sensorStatus &= 0b10011111; + + return success; +} + + // ==========================================================================// // These are the unique functions for the modem as an internet connected device // ==========================================================================// diff --git a/src/LoggerModem.h b/src/LoggerModem.h index 0ef5f6af1..42c7af815 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -66,7 +66,7 @@ class loggerModem : public Sensor virtual bool setup(void) override; virtual bool wake(void) override; - virtual bool addSingleMeasurementResult(void) = 0; + virtual bool addSingleMeasurementResult(void); // Do NOT turn the modem on and off with the regular power up and down! // This is because when it is run in an array with other sensors, we will @@ -106,14 +106,15 @@ class loggerModem : public Sensor // Sets an LED to turn on when the modem is on void setModemLED(int8_t modemLEDPin); - // Get values by other names - int16_t getSignalRSSI(void) {return sensorValues[MODEM_RSSI_VAR_NUM];} - int16_t getSignalPercent(void) {return sensorValues[MODEM_PERCENT_SIGNAL_VAR_NUM];} - // Access the internet virtual bool connectInternet(uint32_t maxConnectionTime = 50000L) = 0; virtual void disconnectInternet(void) = 0; + // Get values by other names + virtual bool getModemSignalQuality(int16_t &rssi, int16_t &percent) = 0; + virtual float getModemBatteryVoltage(void) = 0; + virtual float getModemTemperature(void) = 0; + // This has the same functionality as Client->connect with debugging text // int16_t openTCP(const char *host, uint16_t port); // This has the same functionality as Client->connect with debugging text diff --git a/src/modems/DigiXBee.h b/src/modems/DigiXBee.h index 2fda1e1d0..c5b0bbd4f 100644 --- a/src/modems/DigiXBee.h +++ b/src/modems/DigiXBee.h @@ -52,12 +52,15 @@ class DigiXBee : public loggerModem uint8_t measurementsToAverage = 1); virtual ~DigiXBee(); - virtual bool addSingleMeasurementResult(void) = 0; - // Access the internet virtual bool connectInternet(uint32_t maxConnectionTime = 50000L) = 0; virtual void disconnectInternet(void) = 0; + // Get values by other names + virtual bool getModemSignalQuality(int16_t &rssi, int16_t &percent) = 0; + virtual float getModemBatteryVoltage(void) = 0; + virtual float getModemTemperature(void) = 0; + // Get the time from NIST via TIME protocol (rfc868) // This would be much more efficient if done over UDP, but I'm doing it // over TCP because I don't have a UDP library for all the modems. diff --git a/src/modems/DigiXBeeCellularBypass.cpp b/src/modems/DigiXBeeCellularBypass.cpp index 2d521a39f..9da3e2113 100644 --- a/src/modems/DigiXBeeCellularBypass.cpp +++ b/src/modems/DigiXBeeCellularBypass.cpp @@ -39,7 +39,9 @@ DigiXBeeCellularBypass::~DigiXBeeCellularBypass(){} MS_MODEM_DID_AT_RESPOND(DigiXBeeCellularBypass); MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeCellularBypass); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(DigiXBeeCellularBypass); -MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(DigiXBeeCellularBypass); +MS_MODEM_GET_MODEM_SIGNAL_QUALITY(DigiXBeeCellularBypass); +MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_NA(DigiXBeeCellularBypass); +MS_MODEM_GET_MODEM_TEMPERATURE_NA(DigiXBeeCellularBypass); MS_MODEM_CONNECT_INTERNET(DigiXBeeCellularBypass); MS_MODEM_GET_NIST_TIME(DigiXBeeCellularBypass); diff --git a/src/modems/DigiXBeeCellularBypass.h b/src/modems/DigiXBeeCellularBypass.h index d16cd2085..454226f7d 100644 --- a/src/modems/DigiXBeeCellularBypass.h +++ b/src/modems/DigiXBeeCellularBypass.h @@ -44,11 +44,14 @@ class DigiXBeeCellularBypass : public DigiXBee uint8_t measurementsToAverage = 1); virtual ~DigiXBeeCellularBypass(); - bool addSingleMeasurementResult(void) override; - bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet(void) override; + // Get values by other names + bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; + float getModemBatteryVoltage(void) override; + float getModemTemperature(void) override; + uint32_t getNISTTime(void) override; #ifdef MS_DIGIXBEECELLULARBYPASS_DEBUG_DEEP diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index ee72361a4..956788644 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -39,7 +39,9 @@ DigiXBeeCellularTransparent::~DigiXBeeCellularTransparent(){} MS_MODEM_DID_AT_RESPOND(DigiXBeeCellularTransparent); MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeCellularTransparent); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(DigiXBeeCellularTransparent); -MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(DigiXBeeCellularTransparent); +MS_MODEM_GET_MODEM_SIGNAL_QUALITY(DigiXBeeCellularTransparent); +MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_NA(DigiXBeeCellularTransparent); +MS_MODEM_GET_MODEM_TEMPERATURE_NA(DigiXBeeCellularTransparent); MS_MODEM_CONNECT_INTERNET(DigiXBeeCellularTransparent); MS_MODEM_GET_NIST_TIME(DigiXBeeCellularTransparent); diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index 62226212e..a99b37f8a 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -44,11 +44,14 @@ class DigiXBeeCellularTransparent : public DigiXBee uint8_t measurementsToAverage = 1); virtual ~DigiXBeeCellularTransparent(); - bool addSingleMeasurementResult(void) override; - bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet(void) override; + // Get values by other names + bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; + float getModemBatteryVoltage(void) override; + float getModemTemperature(void) override; + uint32_t getNISTTime(void) override; #ifdef MS_DIGIXBEECELLULARTRANSPARENT_DEBUG_DEEP diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index e0b65bc4f..d3c852f00 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -41,6 +41,8 @@ DigiXBeeWifi::~DigiXBeeWifi(){} MS_MODEM_DID_AT_RESPOND(DigiXBeeWifi); MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeWifi); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(DigiXBeeWifi); +MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_NA(DigiXBeeWifi); +MS_MODEM_GET_MODEM_TEMPERATURE_NA(DigiXBeeWifi); MS_MODEM_CONNECT_INTERNET(DigiXBeeWifi); MS_MODEM_GET_NIST_TIME(DigiXBeeWifi); diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index a726b6afa..ff7aa1455 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -49,6 +49,11 @@ class DigiXBeeWifi : public DigiXBee bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet(void) override; + // Get values by other names + bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; + float getModemBatteryVoltage(void) override; + float getModemTemperature(void) override; + uint32_t getNISTTime(void) override; #ifdef MS_DIGIXBEEWIFI_DEBUG_DEEP diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index 82bbe472f..3f5e58bb6 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -52,7 +52,9 @@ EspressifESP8266::~EspressifESP8266(){} MS_MODEM_DID_AT_RESPOND(EspressifESP8266); MS_MODEM_IS_INTERNET_AVAILABLE(EspressifESP8266); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(EspressifESP8266); -MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(EspressifESP8266); +MS_MODEM_GET_MODEM_SIGNAL_QUALITY(EspressifESP8266); +MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_NA(EspressifESP8266); +MS_MODEM_GET_MODEM_TEMPERATURE_NA(EspressifESP8266); MS_MODEM_CONNECT_INTERNET(EspressifESP8266); MS_MODEM_DISCONNECT_INTERNET(EspressifESP8266); MS_MODEM_GET_NIST_TIME(EspressifESP8266); diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h index c3cf18e28..8dcba3cce 100644 --- a/src/modems/EspressifESP8266.h +++ b/src/modems/EspressifESP8266.h @@ -64,11 +64,15 @@ class EspressifESP8266 : public loggerModem virtual ~EspressifESP8266(); bool startSingleMeasurement(void) override; - bool addSingleMeasurementResult(void) override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet(void) override; + // Get values by other names + bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; + float getModemBatteryVoltage(void) override; + float getModemTemperature(void) override; + uint32_t getNISTTime(void) override; #ifdef MS_ESPRESSIFESP8266_DEBUG_DEEP diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index a88311894..5d3d7bc9a 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -127,47 +127,65 @@ bool specificModem::verifyMeasurementComplete(bool debug) \ #define MS_MODEM_CALC_SIGNAL_PERCENT percent = getPctFromCSQ(signalQual); #endif -#define MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(specificModem) \ -bool specificModem::addSingleMeasurementResult(void) \ +#define MS_MODEM_GET_MODEM_SIGNAL_QUALITY(specificModem) \ +bool specificModem::getModemSignalQuality(int16_t &rssi, int16_t &percent) \ { \ - bool success = true; \ + /* Get signal quality */ \ + /* NOTE: We can't actually distinguish between a bad modem response, no */ \ + /* modem response, and a real response from the modem of no service/signal. */ \ + /* The TinyGSM getSignalQuality function returns the same "no signal" */ \ + /* value (99 CSQ or 0 RSSI) in all 3 cases. */ \ + MS_DBG(F("Getting signal quality:")); \ + uint16_t signalQual = gsmModem.getSignalQuality(); \ + MS_DBG(F("Raw signal quality:"), signalQual); \ \ - /* Initialize float variable */ \ - int16_t signalQual = -9999; \ - int16_t percent = -9999; \ - int16_t rssi = -9999; \ + /* Convert signal quality to RSSI, if necessary */ \ + MS_MODEM_CALC_SIGNAL_RSSI; \ + MS_MODEM_CALC_SIGNAL_PERCENT; \ \ - /* Check a measurement was *successfully* started (status bit 6 set) */ \ - /* Only go on to get a result if it was */ \ - if (bitRead(_sensorStatus, 6)) \ - { \ - /* Get signal quality */ \ - /* NOTE: We can't actually distinguish between a bad modem response, no */ \ - /* modem response, and a real response from the modem of no service/signal. */ \ - /* The TinyGSM getSignalQuality function returns the same "no signal" */ \ - /* value (99 CSQ or 0 RSSI) in all 3 cases. */ \ - MS_DBG(F("Getting signal quality:")); \ - signalQual = gsmModem.getSignalQuality(); \ - MS_DBG(F("Raw signal quality:"), signalQual); \ -\ - /* Convert signal quality to RSSI, if necessary */ \ - MS_MODEM_CALC_SIGNAL_RSSI; \ - MS_MODEM_CALC_SIGNAL_PERCENT; \ -\ - MS_DBG(F("RSSI:"), rssi); \ - MS_DBG(F("Percent signal strength:"), percent); \ - } \ - else MS_DBG(getSensorName(), F("is not connected to the network; unable to get signal quality!")); \ + MS_DBG(F("RSSI:"), rssi); \ + MS_DBG(F("Percent signal strength:"), percent); \ \ - verifyAndAddMeasurementResult(MODEM_RSSI_VAR_NUM, rssi); \ - verifyAndAddMeasurementResult(MODEM_PERCENT_SIGNAL_VAR_NUM, percent); \ + return true; \ +} + + +#define MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_AVAILABLE(specificModem) \ +float specificModem::getModemBatteryVoltage(void) \ +{ \ + MS_DBG(F("Getting battery voltage:")); \ + float volt = gsmModem.getBattVoltage(); \ + MS_DBG(F("Voltage:"), volt); \ \ - /* Unset the time stamp for the beginning of this measurement */ \ - _millisMeasurementRequested = 0; \ - /* Unset the status bits for a measurement request (bits 5 & 6) */ \ - _sensorStatus &= 0b10011111; \ + return volt; \ +} + + +#define MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_NA(specificModem) \ +float specificModem::getModemBatteryVoltage(void) \ +{ \ + MS_DBG(F("This modem doesn't return battery voltage!")); \ + return (float)-9999; \ +} + + +#define MS_MODEM_GET_MODEM_TEMPERATURE_AVAILABLE(specificModem) \ +float specificModem::getModemBatteryVoltage(void) \ +{ \ + MS_DBG(F("Getting temperature:")); \ + float temp = gsmModem.getBattVoltage(); \ + MS_DBG(F("Temperature:"), temp); \ \ - return success; \ + return temp; \ +} + + +// NOTE: Most modems don't give this +#define MS_MODEM_GET_MODEM_TEMPERATURE_NA(specificModem) \ +float specificModem::getModemTemperature(void) \ +{ \ + MS_DBG(F("This modem doesn't return temperature!")); \ + return (float)-9999; \ } diff --git a/src/modems/QuectelBG96.cpp b/src/modems/QuectelBG96.cpp index 9a52f6df7..52046571d 100644 --- a/src/modems/QuectelBG96.cpp +++ b/src/modems/QuectelBG96.cpp @@ -43,7 +43,9 @@ QuectelBG96::~QuectelBG96(){} MS_MODEM_DID_AT_RESPOND(QuectelBG96); MS_MODEM_IS_INTERNET_AVAILABLE(QuectelBG96); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(QuectelBG96); -MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(QuectelBG96); +MS_MODEM_GET_MODEM_SIGNAL_QUALITY(QuectelBG96); +MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_AVAILABLE(QuectelBG96); +MS_MODEM_GET_MODEM_TEMPERATURE_NA(QuectelBG96); MS_MODEM_CONNECT_INTERNET(QuectelBG96); MS_MODEM_DISCONNECT_INTERNET(QuectelBG96); MS_MODEM_GET_NIST_TIME(QuectelBG96); diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index 89f60eae3..d8ba13c5c 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -59,11 +59,14 @@ class QuectelBG96 : public loggerModem uint8_t measurementsToAverage = 1); virtual ~QuectelBG96(); - bool addSingleMeasurementResult(void) override; - bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet(void) override; + // Get values by other names + bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; + float getModemBatteryVoltage(void) override; + float getModemTemperature(void) override; + uint32_t getNISTTime(void) override; #ifdef MS_QUECTELBG96_DEBUG_DEEP diff --git a/src/modems/SIMComSIM7000.cpp b/src/modems/SIMComSIM7000.cpp index 49b6b7bf0..78debed58 100644 --- a/src/modems/SIMComSIM7000.cpp +++ b/src/modems/SIMComSIM7000.cpp @@ -43,7 +43,9 @@ SIMComSIM7000::~SIMComSIM7000(){} MS_MODEM_DID_AT_RESPOND(SIMComSIM7000); MS_MODEM_IS_INTERNET_AVAILABLE(SIMComSIM7000); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(SIMComSIM7000); -MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(SIMComSIM7000); +MS_MODEM_GET_MODEM_SIGNAL_QUALITY(SIMComSIM7000); +MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_AVAILABLE(SIMComSIM7000); +MS_MODEM_GET_MODEM_TEMPERATURE_NA(SIMComSIM7000); MS_MODEM_CONNECT_INTERNET(SIMComSIM7000); MS_MODEM_DISCONNECT_INTERNET(SIMComSIM7000); MS_MODEM_GET_NIST_TIME(SIMComSIM7000); diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h index 679a16b9e..4b8428e37 100644 --- a/src/modems/SIMComSIM7000.h +++ b/src/modems/SIMComSIM7000.h @@ -58,11 +58,14 @@ class SIMComSIM7000 : public loggerModem uint8_t measurementsToAverage = 1); virtual ~SIMComSIM7000(); - bool addSingleMeasurementResult(void) override; - bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet(void) override; + // Get values by other names + bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; + float getModemBatteryVoltage(void) override; + float getModemTemperature(void) override; + uint32_t getNISTTime(void) override; #ifdef MS_SIMCOMSIM7000_DEBUG_DEEP diff --git a/src/modems/SIMComSIM800.cpp b/src/modems/SIMComSIM800.cpp index 4542b6391..f47f26774 100644 --- a/src/modems/SIMComSIM800.cpp +++ b/src/modems/SIMComSIM800.cpp @@ -45,7 +45,9 @@ SIMComSIM800::~SIMComSIM800(){} MS_MODEM_DID_AT_RESPOND(SIMComSIM800); MS_MODEM_IS_INTERNET_AVAILABLE(SIMComSIM800); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(SIMComSIM800); -MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(SIMComSIM800); +MS_MODEM_GET_MODEM_SIGNAL_QUALITY(SIMComSIM800); +MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_AVAILABLE(SIMComSIM800); +MS_MODEM_GET_MODEM_TEMPERATURE_NA(SIMComSIM800); MS_MODEM_CONNECT_INTERNET(SIMComSIM800); MS_MODEM_DISCONNECT_INTERNET(SIMComSIM800); MS_MODEM_GET_NIST_TIME(SIMComSIM800); diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index f2c7c20ee..1f8c0ba60 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -61,11 +61,14 @@ class SIMComSIM800 : public loggerModem uint8_t measurementsToAverage = 1); virtual ~SIMComSIM800(); - bool addSingleMeasurementResult(void) override; - bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet(void) override; + // Get values by other names + bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; + float getModemBatteryVoltage(void) override; + float getModemTemperature(void) override; + uint32_t getNISTTime(void) override; #ifdef MS_SIMCOMSIM800_DEBUG_DEEP diff --git a/src/modems/SequansMonarch.cpp b/src/modems/SequansMonarch.cpp index bbcd275a7..fafd653fb 100644 --- a/src/modems/SequansMonarch.cpp +++ b/src/modems/SequansMonarch.cpp @@ -43,7 +43,9 @@ SequansMonarch::~SequansMonarch(){} MS_MODEM_DID_AT_RESPOND(SequansMonarch); MS_MODEM_IS_INTERNET_AVAILABLE(SequansMonarch); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(SequansMonarch); -MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(SequansMonarch); +MS_MODEM_GET_MODEM_SIGNAL_QUALITY(SequansMonarch); +MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_NA(SequansMonarch); +MS_MODEM_GET_MODEM_TEMPERATURE_NA(SequansMonarch); MS_MODEM_CONNECT_INTERNET(SequansMonarch); MS_MODEM_DISCONNECT_INTERNET(SequansMonarch); MS_MODEM_GET_NIST_TIME(SequansMonarch); diff --git a/src/modems/SequansMonarch.h b/src/modems/SequansMonarch.h index a7f5c6bd0..c02c0e3d7 100644 --- a/src/modems/SequansMonarch.h +++ b/src/modems/SequansMonarch.h @@ -59,11 +59,14 @@ class SequansMonarch : public loggerModem uint8_t measurementsToAverage = 1); virtual ~SequansMonarch(); - bool addSingleMeasurementResult(void) override; - bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet(void) override; + // Get values by other names + bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; + float getModemBatteryVoltage(void) override; + float getModemTemperature(void) override; + uint32_t getNISTTime(void) override; #ifdef MS_SEQUANSMONARCH_DEBUG_DEEP diff --git a/src/modems/Sodaq2GBeeR6.cpp b/src/modems/Sodaq2GBeeR6.cpp index 976e27ffc..e5fb4cc3e 100644 --- a/src/modems/Sodaq2GBeeR6.cpp +++ b/src/modems/Sodaq2GBeeR6.cpp @@ -44,7 +44,9 @@ Sodaq2GBeeR6::~Sodaq2GBeeR6(){} MS_MODEM_DID_AT_RESPOND(Sodaq2GBeeR6); MS_MODEM_IS_INTERNET_AVAILABLE(Sodaq2GBeeR6); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(Sodaq2GBeeR6); -MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(Sodaq2GBeeR6); +MS_MODEM_GET_MODEM_SIGNAL_QUALITY(Sodaq2GBeeR6); +MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_AVAILABLE(Sodaq2GBeeR6); +MS_MODEM_GET_MODEM_TEMPERATURE_NA(Sodaq2GBeeR6); MS_MODEM_CONNECT_INTERNET(Sodaq2GBeeR6); MS_MODEM_DISCONNECT_INTERNET(Sodaq2GBeeR6); MS_MODEM_GET_NIST_TIME(Sodaq2GBeeR6); diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h index 946c8fd7e..200798c4a 100644 --- a/src/modems/Sodaq2GBeeR6.h +++ b/src/modems/Sodaq2GBeeR6.h @@ -60,11 +60,14 @@ class Sodaq2GBeeR6 : public loggerModem uint8_t measurementsToAverage = 1); virtual ~Sodaq2GBeeR6(); - bool addSingleMeasurementResult(void) override; - bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet(void) override; + // Get values by other names + bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; + float getModemBatteryVoltage(void) override; + float getModemTemperature(void) override; + uint32_t getNISTTime(void) override; #ifdef MS_SODAQ2GBEER6_DEBUG_DEEP diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp index 25cab6e30..61e4d3d9f 100644 --- a/src/modems/SodaqUBeeR410M.cpp +++ b/src/modems/SodaqUBeeR410M.cpp @@ -69,7 +69,9 @@ SodaqUBeeR410M::~SodaqUBeeR410M(){} MS_MODEM_DID_AT_RESPOND(SodaqUBeeR410M); MS_MODEM_IS_INTERNET_AVAILABLE(SodaqUBeeR410M); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(SodaqUBeeR410M); -MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(SodaqUBeeR410M); +MS_MODEM_GET_MODEM_SIGNAL_QUALITY(SodaqUBeeR410M); +MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_NA(SodaqUBeeR410M); +MS_MODEM_GET_MODEM_TEMPERATURE_NA(SodaqUBeeR410M); MS_MODEM_CONNECT_INTERNET(SodaqUBeeR410M); MS_MODEM_DISCONNECT_INTERNET(SodaqUBeeR410M); MS_MODEM_GET_NIST_TIME(SodaqUBeeR410M); diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index fccb6fed6..43227a36c 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -70,11 +70,14 @@ class SodaqUBeeR410M : public loggerModem #endif virtual ~SodaqUBeeR410M(); - bool addSingleMeasurementResult(void) override; - bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet(void) override; + // Get values by other names + bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; + float getModemBatteryVoltage(void) override; + float getModemTemperature(void) override; + uint32_t getNISTTime(void) override; #ifdef MS_SODAQUBEER410M_DEBUG_DEEP diff --git a/src/modems/SodaqUBeeU201.cpp b/src/modems/SodaqUBeeU201.cpp index 7fab3b4e6..ef01cdccd 100644 --- a/src/modems/SodaqUBeeU201.cpp +++ b/src/modems/SodaqUBeeU201.cpp @@ -43,7 +43,9 @@ SodaqUBeeU201::~SodaqUBeeU201(){} MS_MODEM_DID_AT_RESPOND(SodaqUBeeU201); MS_MODEM_IS_INTERNET_AVAILABLE(SodaqUBeeU201); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(SodaqUBeeU201); -MS_MODEM_ADD_SINGLE_MEASUREMENT_RESULT(SodaqUBeeU201); +MS_MODEM_GET_MODEM_SIGNAL_QUALITY(SodaqUBeeU201); +MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_NA(SodaqUBeeU201); +MS_MODEM_GET_MODEM_TEMPERATURE_NA(SodaqUBeeU201); MS_MODEM_CONNECT_INTERNET(SodaqUBeeU201); MS_MODEM_DISCONNECT_INTERNET(SodaqUBeeU201); MS_MODEM_GET_NIST_TIME(SodaqUBeeU201); diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index f84bba20d..b26cb7212 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -64,11 +64,14 @@ class SodaqUBeeU201 : public loggerModem uint8_t measurementsToAverage = 1); virtual ~SodaqUBeeU201(); - bool addSingleMeasurementResult(void) override; - bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet(void) override; + // Get values by other names + bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; + float getModemBatteryVoltage(void) override; + float getModemTemperature(void) override; + uint32_t getNISTTime(void) override; #ifdef MS_SODAQUBEEU201_DEBUG_DEEP From d4bb1a75ada1e6ffb223a5ce143732a2ce4deebb Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 22 May 2019 14:12:23 -0400 Subject: [PATCH 43/88] Add additional battery stats from modem --- examples/DRWI_LTE/DRWI_LTE.ino | 14 +-- examples/logging_to_MMW/logging_to_MMW.ino | 14 +-- examples/menu_a_la_carte/menu_a_la_carte.ino | 41 ++++--- src/LoggerModem.cpp | 23 +++- src/LoggerModem.h | 84 ++++++++++--- src/modems/DigiXBee.h | 2 +- src/modems/DigiXBee3GBypass.cpp | 116 ++++++++++++++++++ ...BeeCellularBypass.h => DigiXBee3GBypass.h} | 26 ++-- src/modems/DigiXBeeCellularTransparent.cpp | 64 +++++++++- src/modems/DigiXBeeCellularTransparent.h | 4 +- ...llularBypass.cpp => DigiXBeeLTEBypass.cpp} | 33 +++-- src/modems/DigiXBeeLTEBypass.h | 75 +++++++++++ src/modems/DigiXBeeWifi.cpp | 77 ++++++++++-- src/modems/DigiXBeeWifi.h | 2 +- src/modems/EspressifESP8266.cpp | 2 +- src/modems/EspressifESP8266.h | 2 +- src/modems/LoggerModemMacros.h | 21 ++-- src/modems/QuectelBG96.cpp | 2 +- src/modems/QuectelBG96.h | 2 +- src/modems/SIMComSIM7000.cpp | 2 +- src/modems/SIMComSIM7000.h | 2 +- src/modems/SIMComSIM800.cpp | 2 +- src/modems/SIMComSIM800.h | 2 +- src/modems/SequansMonarch.cpp | 4 +- src/modems/SequansMonarch.h | 2 +- src/modems/Sodaq2GBeeR6.cpp | 2 +- src/modems/Sodaq2GBeeR6.h | 2 +- src/modems/SodaqUBeeR410M.cpp | 4 +- src/modems/SodaqUBeeR410M.h | 2 +- src/modems/SodaqUBeeU201.cpp | 2 +- src/modems/SodaqUBeeU201.h | 2 +- 31 files changed, 509 insertions(+), 123 deletions(-) create mode 100644 src/modems/DigiXBee3GBypass.cpp rename src/modems/{DigiXBeeCellularBypass.h => DigiXBee3GBypass.h} (73%) rename src/modems/{DigiXBeeCellularBypass.cpp => DigiXBeeLTEBypass.cpp} (83%) create mode 100644 src/modems/DigiXBeeLTEBypass.h diff --git a/examples/DRWI_LTE/DRWI_LTE.ino b/examples/DRWI_LTE/DRWI_LTE.ino index d12a0134a..0d9c72b6e 100644 --- a/examples/DRWI_LTE/DRWI_LTE.ino +++ b/examples/DRWI_LTE/DRWI_LTE.ino @@ -78,18 +78,18 @@ const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem st // Network connection information const char *apn = "hologram"; // The APN for the gprs connection -// For the u-blox based Digi XBee's (3G global and LTE-M global) +// For the u-blox SARA R410M based Digi LTE-M XBee3 // NOTE: According to the manual, this should be less stable than transparent // mode, but my experience is the complete reverse. -#include +#include const long modemBaud = 9600; // All XBee's use 9600 by default const bool useCTSforStatus = true; // Flag to use the modem CTS pin for status -DigiXBeeCellularBypass modemXBCB(&modemSerial, - modemVccPin, modemStatusPin, useCTSforStatus, - modemResetPin, modemSleepRqPin, - apn); +DigiXBeeLTEBypass modemXBLTEB(&modemSerial, + modemVccPin, modemStatusPin, useCTSforStatus, + modemResetPin, modemSleepRqPin, + apn); // Create an extra reference to the modem by a generic name (not necessary) -DigiXBeeCellularBypass modem = modemXBCB; +DigiXBeeLTEBypass modem = modemXBLTEB; // ========================================================================== diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index 48f915aaa..7f24687a0 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -79,18 +79,18 @@ const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem st // Network connection information const char *apn = "xxxxx"; // The APN for the gprs connection -// For the u-blox based Digi XBee's (3G global and LTE-M global) +// For the u-blox SARA R410M based Digi LTE-M XBee3 // NOTE: According to the manual, this should be less stable than transparent // mode, but my experience is the complete reverse. -#include +#include const long modemBaud = 9600; // All XBee's use 9600 by default const bool useCTSforStatus = true; // Flag to use the modem CTS pin for status. Only applies to Digi XBee's -DigiXBeeCellularBypass modemXBCB(&modemSerial, - modemVccPin, modemStatusPin, useCTSforStatus, - modemResetPin, modemSleepRqPin, - apn); +DigiXBeeLTEBypass modemXBLTEB(&modemSerial, + modemVccPin, modemStatusPin, useCTSforStatus, + modemResetPin, modemSleepRqPin, + apn); // Create an extra reference to the modem by a generic name (not necessary) -DigiXBeeCellularBypass modem = modemXBCB; +DigiXBeeLTEBypass modem = modemXBLTEB; // ========================================================================== diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index ca06b84a5..d614b536d 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -197,20 +197,6 @@ const char *wifiPwd = "xxxxx"; // The password for connecting to WiFi, unnecess // Note: Don't use more than one! // ========================================================================== -// For the u-blox based Digi XBee's (3G global and LTE-M global) -// NOTE: According to the manual, this should be less stable than transparent -// mode, but my experience is the complete reverse. -#include -const long modemBaud = 9600; // All XBee's use 9600 by default -const bool useCTSforStatus = true; // Flag to use the modem CTS pin for status -DigiXBeeCellularBypass modemXBCB(&modemSerial, - modemVccPin, modemStatusPin, useCTSforStatus, - modemResetPin, modemSleepRqPin, - apn); -// Create an extra reference to the modem by a generic name (not necessary) -DigiXBeeCellularBypass modem = modemXBCB; -// ========================================================================== - // // For any Digi Cellular XBee's // // NOTE: The u-blox based Digi XBee's (3G global and LTE-M global) // // are more stable used in bypass mode (above) @@ -226,6 +212,33 @@ DigiXBeeCellularBypass modem = modemXBCB; // DigiXBeeCellularTransparent modem = modemXBCT; // // ========================================================================== +// For the u-blox SARA R410M based Digi LTE-M XBee3 +// NOTE: According to the manual, this should be less stable than transparent +// mode, but my experience is the complete reverse. +#include +const long modemBaud = 9600; // All XBee's use 9600 by default +const bool useCTSforStatus = true; // Flag to use the modem CTS pin for status +DigiXBeeLTEBypass modemXBLTEB(&modemSerial, + modemVccPin, modemStatusPin, useCTSforStatus, + modemResetPin, modemSleepRqPin, + apn); +// Create an extra reference to the modem by a generic name (not necessary) +DigiXBeeLTEBypass modem = modemXBLTEB; +// ========================================================================== + +// // For the u-blox SARA U201 based Digi 3G XBee with 2G fallback +// // NOTE: According to the manual, this should be less stable than transparent +// // mode, but my experience is the complete reverse. +// #include +// const long modemBaud = 9600; // All XBee's use 9600 by default +// DigiXBeeLTEBypass modemXB3GB(&modemSerial, +// modemVccPin, modemStatusPin, useCTSforStatus, +// modemResetPin, modemSleepRqPin, +// apn); +// // Create an extra reference to the modem by a generic name (not necessary) +// DigiXBee3GBypass modem = modemXB3GB; +// // ========================================================================== + // // For the Digi Wifi XBee (S6B) // #include // const long modemBaud = 9600; // All XBee's use 9600 by default diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index 5c2e5a67e..617b7a212 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -313,8 +313,13 @@ bool loggerModem::addSingleMeasurementResult(void) /* Initialize float variable */ int16_t percent = -9999; int16_t rssi = -9999; - float volt = -9999; + uint8_t state = -99; + int8_t bpercent = -99; + uint16_t volt = -9999; float temp = -9999; + float fstate = -9999; + float fbpercent = -9999; + float fvolt = -9999; /* Check a measurement was *successfully* started (status bit 6 set) */ /* Only go on to get a result if it was */ @@ -330,19 +335,27 @@ bool loggerModem::addSingleMeasurementResult(void) MS_DBG(F("RSSI:"), rssi); MS_DBG(F("Percent signal strength:"), percent); - MS_DBG(F("Getting battery, if possible:")); - volt = getModemBatteryVoltage(); + MS_DBG(F("Getting battery info, if possible:")); + success &= getModemBatteryStats(state, bpercent, volt); + MS_DBG(F("Battery charge state:"), state); + MS_DBG(F("Battery percentage:"), bpercent); MS_DBG(F("Battery voltage:"), volt); + // convert responses to floats + if (state != 99) fstate = (float)state; + if (bpercent != 99) fbpercent = (float)bpercent; + if (volt != 9999) fvolt = (float)volt; MS_DBG(F("Getting chip temperature, if possible:")); temp = getModemTemperature(); - MS_DBG(F("Battery voltage:"), temp); + MS_DBG(F("Modem temperature:"), temp); } else MS_DBG(getSensorName(), F("is not connected to the network; unable to get signal quality!")); verifyAndAddMeasurementResult(MODEM_RSSI_VAR_NUM, rssi); verifyAndAddMeasurementResult(MODEM_PERCENT_SIGNAL_VAR_NUM, percent); - verifyAndAddMeasurementResult(MODEM_BATTERY_VAR_NUM, volt); + verifyAndAddMeasurementResult(MODEM_BATTERY_STATE_VAR_NUM, fstate); + verifyAndAddMeasurementResult(MODEM_BATTERY_PERCENT_VAR_NUM, fbpercent); + verifyAndAddMeasurementResult(MODEM_BATTERY_VOLT_VAR_NUM, fvolt); verifyAndAddMeasurementResult(MODEM_TEMPERATURE_VAR_NUM, temp); /* Unset the time stamp for the beginning of this measurement */ diff --git a/src/LoggerModem.h b/src/LoggerModem.h index 42c7af815..300b4f312 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -28,7 +28,7 @@ #include -#define MODEM_NUM_VARIABLES 4 +#define MODEM_NUM_VARIABLES 6 #define MODEM_RSSI_VAR_NUM 0 #define MODEM_RSSI_RESOLUTION 0 @@ -36,10 +36,16 @@ #define MODEM_PERCENT_SIGNAL_VAR_NUM 1 #define MODEM_PERCENT_SIGNAL_RESOLUTION 0 -#define MODEM_BATTERY_VAR_NUM 2 -#define MODEM_BATTERY_RESOLUTION 2 +#define MODEM_BATTERY_STATE_VAR_NUM 2 +#define MODEM_BATTERY_STATE_RESOLUTION 0 -#define MODEM_TEMPERATURE_VAR_NUM 3 +#define MODEM_BATTERY_PERCENT_VAR_NUM 3 +#define MODEM_BATTERY_PERCENT_RESOLUTION 0 + +#define MODEM_BATTERY_VOLT_VAR_NUM 4 +#define MODEM_BATTERY_VOLT_RESOLUTION 3 + +#define MODEM_TEMPERATURE_VAR_NUM 5 #define MODEM_TEMPERATURE_RESOLUTION 1 /* =========================================================================== @@ -112,7 +118,7 @@ class loggerModem : public Sensor // Get values by other names virtual bool getModemSignalQuality(int16_t &rssi, int16_t &percent) = 0; - virtual float getModemBatteryVoltage(void) = 0; + virtual bool getModemBatteryStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) = 0; virtual float getModemTemperature(void) = 0; // This has the same functionality as Client->connect with debugging text @@ -219,25 +225,69 @@ class Modem_SignalPercent : public Variable }; -// Defines the Signal Percentage -class Modem_Battery : public Variable +// Defines the Battery Charge State +class Modem_BatteryState : public Variable { public: - Modem_Battery(Sensor *parentSense, - const char *uuid = "", - const char *varCode = "modemBattery") + Modem_BatteryState(Sensor *parentSense, + const char *uuid = "", + const char *varCode = "modemBatteryCS") + : Variable(parentSense, + (const uint8_t)MODEM_BATTERY_STATE_VAR_NUM, + (uint8_t)MODEM_BATTERY_STATE_RESOLUTION, + "batteryChargeState", "number", + varCode, uuid) + {} + Modem_BatteryState() + : Variable((const uint8_t)MODEM_BATTERY_STATE_VAR_NUM, + (uint8_t)MODEM_BATTERY_STATE_RESOLUTION, + "batteryChargeState", "number", "modemBatteryCS") + {} + ~Modem_BatteryState(){} +}; + + +// Defines the Battery Charge Percent +class Modem_BatteryPercent : public Variable +{ +public: + Modem_BatteryPercent(Sensor *parentSense, + const char *uuid = "", + const char *varCode = "modemBatteryPct") + : Variable(parentSense, + (const uint8_t)MODEM_BATTERY_PERCENT_VAR_NUM, + (uint8_t)MODEM_BATTERY_PERCENT_RESOLUTION, + "batteryVoltage", "percent", + varCode, uuid) + {} + Modem_BatteryPercent() + : Variable((const uint8_t)MODEM_BATTERY_PERCENT_VAR_NUM, + (uint8_t)MODEM_BATTERY_PERCENT_RESOLUTION, + "batteryVoltage", "percent", "modemBatteryPct") + {} + ~Modem_BatteryPercent(){} +}; + + +// Defines the Battery Voltage +class Modem_BatteryVoltage : public Variable +{ +public: + Modem_BatteryVoltage(Sensor *parentSense, + const char *uuid = "", + const char *varCode = "modemBatteryVolt") : Variable(parentSense, - (const uint8_t)MODEM_BATTERY_VAR_NUM, - (uint8_t)MODEM_BATTERY_RESOLUTION, + (const uint8_t)MODEM_BATTERY_VOLT_VAR_NUM, + (uint8_t)MODEM_BATTERY_VOLT_RESOLUTION, "batteryVoltage", "volt", varCode, uuid) {} - Modem_Battery() - : Variable((const uint8_t)MODEM_BATTERY_VAR_NUM, - (uint8_t)MODEM_BATTERY_RESOLUTION, - "batteryVoltage", "volt", "modemBattery") + Modem_BatteryVoltage() + : Variable((const uint8_t)MODEM_BATTERY_VOLT_VAR_NUM, + (uint8_t)MODEM_BATTERY_VOLT_RESOLUTION, + "batteryVoltage", "volt", "modemBatteryVolt") {} - ~Modem_Battery(){} + ~Modem_BatteryVoltage(){} }; diff --git a/src/modems/DigiXBee.h b/src/modems/DigiXBee.h index c5b0bbd4f..0125a6222 100644 --- a/src/modems/DigiXBee.h +++ b/src/modems/DigiXBee.h @@ -58,7 +58,7 @@ class DigiXBee : public loggerModem // Get values by other names virtual bool getModemSignalQuality(int16_t &rssi, int16_t &percent) = 0; - virtual float getModemBatteryVoltage(void) = 0; + virtual bool getModemBatteryStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) = 0; virtual float getModemTemperature(void) = 0; // Get the time from NIST via TIME protocol (rfc868) diff --git a/src/modems/DigiXBee3GBypass.cpp b/src/modems/DigiXBee3GBypass.cpp new file mode 100644 index 000000000..43aedd84c --- /dev/null +++ b/src/modems/DigiXBee3GBypass.cpp @@ -0,0 +1,116 @@ +/* + *DigiXBee3GBypass.cpp + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is for Digi Cellular XBee's BASED ON UBLOX CHIPS in bypass mode +*/ + +// Included Dependencies +#include "DigiXBee3GBypass.h" +#include "modems/LoggerModemMacros.h" + +// Constructor/Destructor +DigiXBee3GBypass::DigiXBee3GBypass(Stream* modemStream, + int8_t powerPin, int8_t statusPin, bool useCTSStatus, + int8_t modemResetPin, int8_t modemSleepRqPin, + const char *apn, + uint8_t measurementsToAverage) + : DigiXBee(powerPin, statusPin, useCTSStatus, + modemResetPin, modemSleepRqPin, + measurementsToAverage), + #ifdef MS_DIGIXBEELTEBYPASS_DEBUG_DEEP + _modemATDebugger(*modemStream, DEEP_DEBUGGING_SERIAL_OUTPUT), + gsmModem(_modemATDebugger), + #else + gsmModem(*modemStream), + #endif + gsmClient(gsmModem) +{ + _apn = apn; +} + + +// Destructor +DigiXBee3GBypass::~DigiXBee3GBypass(){} + + +MS_MODEM_DID_AT_RESPOND(DigiXBee3GBypass); +MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBee3GBypass); +MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(DigiXBee3GBypass); +MS_MODEM_GET_MODEM_SIGNAL_QUALITY(DigiXBee3GBypass); +MS_MODEM_GET_MODEM_BATTERY_AVAILABLE(DigiXBee3GBypass); +// NOTE: Could actually get temperature from the Digi chip by entering bypass mode +MS_MODEM_GET_MODEM_TEMPERATURE_NA(DigiXBee3GBypass); +MS_MODEM_CONNECT_INTERNET(DigiXBee3GBypass); +MS_MODEM_GET_NIST_TIME(DigiXBee3GBypass); + + +bool DigiXBee3GBypass::extraModemSetup(void) +{ + bool success = true; + delay(1010); // Wait the required guard time before entering command mode + MS_DBG(F("Putting XBee into command mode...")); + gsmModem.streamWrite(GF("+++")); // enter command mode + if (success &= gsmModem.waitResponse(2000, F("OK\r")) == 1) + { + MS_DBG(F("Setting I/O Pins...")); + // Set DIO8 to be used for sleep requests + // NOTE: Only pin 9/DIO8/DTR can be used for this function + gsmModem.sendAT(F("D8"),1); + success &= gsmModem.waitResponse(F("OK\r")) == 1; + // Turn on status indication pin - it will be HIGH when the XBee is awake + // NOTE: Only pin 13/ON/SLEEPnot/DIO9 can be used for this function + gsmModem.sendAT(F("D9"),1); + success &= gsmModem.waitResponse(F("OK\r")) == 1; + // Turn on CTS pin - it will be LOW when the XBee is ready to receive commands + // This can be used as proxy for status indication if the true status pin is not accessible + // NOTE: Only pin 12/DIO7/CTS can be used for this function + gsmModem.sendAT(F("D7"),1); + success &= gsmModem.waitResponse(F("OK\r")) == 1; + // Put the XBee in pin sleep mode + MS_DBG(F("Setting Sleep Options...")); + gsmModem.sendAT(F("SM"),1); + success &= gsmModem.waitResponse(F("OK\r")) == 1; + // Disassociate from network for lowest power deep sleep + MS_DBG(F("Setting Other Options...")); + // Disable remote manager, enable 2G fallback + gsmModem.sendAT(F("DO"),02); + success &= gsmModem.waitResponse(F("OK\r")) == 1; + MS_DBG(F("Setting Cellular Carrier Options...")); + // Cellular carrier profile - AT&T + // Hologram says they can use any network, but I've never succeeded with anything but AT&T + gsmModem.sendAT(F("CP"),2); + success &= gsmModem.waitResponse(F("OK\r")) == 1; + MS_DBG(F("Turning on Bypass Mode...")); + // Turn on bypass mode + gsmModem.sendAT(F("AP5")); + success &= gsmModem.waitResponse(F("OK\r")) == 1; + // Write changes to flash + gsmModem.sendAT(F("WR")); + success &= gsmModem.waitResponse(F("OK\r")) == 1; + // Apply changes + gsmModem.sendAT(F("AC")); + success &= gsmModem.waitResponse(F("OK\r")) == 1; + // Force reset to actually enter bypass mode - this effectively exits bypass mode + MS_DBG(F("Resetting the module to reboot in bypass mode...")); + gsmModem.sendAT(F("FR")); + success &= gsmModem.waitResponse(F("OK\r")) == 1; + delay(200); // Allow the unit to reset + // re-initialize + MS_DBG(F("Attempting to reconnect to the u-blox module...")); + success &= gsmModem.init(); + _modemName = gsmModem.getModemName(); + } + else success = false; + if (success) MS_DBG(F("... Setup successful!")); + else MS_DBG(F("... failed!")); + return success; +} + + +void DigiXBee3GBypass::disconnectInternet(void) +{ + // XBee doesn't like to disconnect at all, so we're doing nothing +} diff --git a/src/modems/DigiXBeeCellularBypass.h b/src/modems/DigiXBee3GBypass.h similarity index 73% rename from src/modems/DigiXBeeCellularBypass.h rename to src/modems/DigiXBee3GBypass.h index 454226f7d..c4cdd6a13 100644 --- a/src/modems/DigiXBeeCellularBypass.h +++ b/src/modems/DigiXBee3GBypass.h @@ -1,5 +1,5 @@ /* - *DigiXBeeCellularBypass.h + *DigiXBee3GBypass.h *This file is part of the EnviroDIY modular sensors library for Arduino * *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). @@ -8,15 +8,15 @@ */ // Header Guards -#ifndef DigiXBeeCellularBypass_h -#define DigiXBeeCellularBypass_h +#ifndef DigiXBee3GBypass_h +#define DigiXBee3GBypass_h // Debugging Statement -// #define MS_DIGIXBEECELLULARBYPASS_DEBUG -// #define MS_DIGIXBEECELLULARBYPASS_DEBUG_DEEP +// #define MS_DIGIXBEE3GBYPASS_DEBUG +// #define MS_DIGIXBEE3GBYPASS_DEBUG_DEEP -#ifdef MS_DIGIXBEECELLULARBYPASS_DEBUG -#define MS_DEBUGGING_STD "DigiXBeeCellularBypass" +#ifdef MS_DIGIXBEE3GBYPASS_DEBUG +#define MS_DEBUGGING_STD "DigiXBee3GBypass" #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif @@ -28,33 +28,33 @@ #include "DigiXBee.h" #include "TinyGsmClient.h" -#ifdef MS_DIGIXBEECELLULARBYPASS_DEBUG_DEEP +#ifdef MS_DIGIXBEE3GBYPASS_DEBUG_DEEP #include #endif -class DigiXBeeCellularBypass : public DigiXBee +class DigiXBee3GBypass : public DigiXBee { public: // Constructor/Destructor - DigiXBeeCellularBypass(Stream* modemStream, + DigiXBee3GBypass(Stream* modemStream, int8_t powerPin, int8_t statusPin, bool useCTSStatus, int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~DigiXBeeCellularBypass(); + virtual ~DigiXBee3GBypass(); bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet(void) override; // Get values by other names bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; - float getModemBatteryVoltage(void) override; + bool getModemBatteryStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) override; float getModemTemperature(void) override; uint32_t getNISTTime(void) override; - #ifdef MS_DIGIXBEECELLULARBYPASS_DEBUG_DEEP + #ifdef MS_DIGIXBEE3GBYPASS_DEBUG_DEEP StreamDebugger _modemATDebugger; #endif diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index 956788644..651df0aa1 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -40,8 +40,8 @@ MS_MODEM_DID_AT_RESPOND(DigiXBeeCellularTransparent); MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeCellularTransparent); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(DigiXBeeCellularTransparent); MS_MODEM_GET_MODEM_SIGNAL_QUALITY(DigiXBeeCellularTransparent); -MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_NA(DigiXBeeCellularTransparent); -MS_MODEM_GET_MODEM_TEMPERATURE_NA(DigiXBeeCellularTransparent); +MS_MODEM_GET_MODEM_BATTERY_NA(DigiXBeeCellularTransparent); +MS_MODEM_GET_MODEM_TEMPERATURE_AVAILABLE(DigiXBeeCellularTransparent); MS_MODEM_CONNECT_INTERNET(DigiXBeeCellularTransparent); MS_MODEM_GET_NIST_TIME(DigiXBeeCellularTransparent); @@ -112,6 +112,66 @@ bool DigiXBeeCellularTransparent::extraModemSetup(void) } +bool DigiXBeeCellularTransparent::addSingleMeasurementResult(void) +{ + bool success = true; + + /* Initialize float variable */ + int16_t signalQual = -9999; + int16_t percent = -9999; + int16_t rssi = -9999; + float temp = -9999; + + /* Check a measurement was *successfully* started (status bit 6 set) */ + /* Only go on to get a result if it was */ + if (bitRead(_sensorStatus, 6)) + { + // Enter command mode only once + MS_DBG(F("Entering Command Mode:")); + gsmModem.commandMode(); + + // Get signal quality + // NOTE: We can't actually distinguish between a bad modem response, no + // modem response, and a real response from the modem of no service/signal. + // The TinyGSM getSignalQuality function returns the same "no signal" + // value (99 CSQ or 0 RSSI) in all 3 cases. + MS_DBG(F("Getting signal quality:")); + signalQual = gsmModem.getSignalQuality(); + MS_DBG(F("Raw signal quality:"), signalQual); + + // Convert signal quality to RSSI + rssi = signalQual; + percent = getPctFromRSSI(signalQual); + + MS_DBG(F("RSSI:"), rssi); + MS_DBG(F("Percent signal strength:"), percent); + + MS_DBG(F("Getting chip temperature:")); + temp = getModemTemperature(); + MS_DBG(F("Modem temperature:"), temp); + + // Exit command modem + MS_DBG(F("Leaving Command Mode:")); + gsmModem.exitCommand(); + } + else MS_DBG(getSensorName(), F("is not connected to the network; unable to get signal quality!")); + + verifyAndAddMeasurementResult(MODEM_RSSI_VAR_NUM, rssi); + verifyAndAddMeasurementResult(MODEM_PERCENT_SIGNAL_VAR_NUM, percent); + verifyAndAddMeasurementResult(MODEM_BATTERY_STATE_VAR_NUM, (float)-9999); + verifyAndAddMeasurementResult(MODEM_BATTERY_PERCENT_VAR_NUM, (float)-9999); + verifyAndAddMeasurementResult(MODEM_BATTERY_VOLT_VAR_NUM, (float)-9999); + verifyAndAddMeasurementResult(MODEM_TEMPERATURE_VAR_NUM, temp); + + /* Unset the time stamp for the beginning of this measurement */ + _millisMeasurementRequested = 0; + /* Unset the status bits for a measurement request (bits 5 & 6) */ + _sensorStatus &= 0b10011111; + + return success; +} + + void DigiXBeeCellularTransparent::disconnectInternet(void) { // XBee doesn't like to disconnect at all, so we're doing nothing diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index a99b37f8a..679c545b8 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -44,12 +44,14 @@ class DigiXBeeCellularTransparent : public DigiXBee uint8_t measurementsToAverage = 1); virtual ~DigiXBeeCellularTransparent(); + bool addSingleMeasurementResult(void) override; + bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet(void) override; // Get values by other names bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; - float getModemBatteryVoltage(void) override; + bool getModemBatteryStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) override; float getModemTemperature(void) override; uint32_t getNISTTime(void) override; diff --git a/src/modems/DigiXBeeCellularBypass.cpp b/src/modems/DigiXBeeLTEBypass.cpp similarity index 83% rename from src/modems/DigiXBeeCellularBypass.cpp rename to src/modems/DigiXBeeLTEBypass.cpp index 9da3e2113..2f34db68c 100644 --- a/src/modems/DigiXBeeCellularBypass.cpp +++ b/src/modems/DigiXBeeLTEBypass.cpp @@ -1,5 +1,5 @@ /* - *DigiXBeeCellularBypass.cpp + *DigiXBeeLTEBypass.cpp *This file is part of the EnviroDIY modular sensors library for Arduino * *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). @@ -8,11 +8,11 @@ */ // Included Dependencies -#include "DigiXBeeCellularBypass.h" +#include "DigiXBeeLTEBypass.h" #include "modems/LoggerModemMacros.h" // Constructor/Destructor -DigiXBeeCellularBypass::DigiXBeeCellularBypass(Stream* modemStream, +DigiXBeeLTEBypass::DigiXBeeLTEBypass(Stream* modemStream, int8_t powerPin, int8_t statusPin, bool useCTSStatus, int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, @@ -20,7 +20,7 @@ DigiXBeeCellularBypass::DigiXBeeCellularBypass(Stream* modemStream, : DigiXBee(powerPin, statusPin, useCTSStatus, modemResetPin, modemSleepRqPin, measurementsToAverage), - #ifdef MS_DIGIXBEECELLULARBYPASS_DEBUG_DEEP + #ifdef MS_DIGIXBEELTEBYPASS_DEBUG_DEEP _modemATDebugger(*modemStream, DEEP_DEBUGGING_SERIAL_OUTPUT), gsmModem(_modemATDebugger), #else @@ -33,20 +33,20 @@ DigiXBeeCellularBypass::DigiXBeeCellularBypass(Stream* modemStream, // Destructor -DigiXBeeCellularBypass::~DigiXBeeCellularBypass(){} +DigiXBeeLTEBypass::~DigiXBeeLTEBypass(){} -MS_MODEM_DID_AT_RESPOND(DigiXBeeCellularBypass); -MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeCellularBypass); -MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(DigiXBeeCellularBypass); -MS_MODEM_GET_MODEM_SIGNAL_QUALITY(DigiXBeeCellularBypass); -MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_NA(DigiXBeeCellularBypass); -MS_MODEM_GET_MODEM_TEMPERATURE_NA(DigiXBeeCellularBypass); -MS_MODEM_CONNECT_INTERNET(DigiXBeeCellularBypass); -MS_MODEM_GET_NIST_TIME(DigiXBeeCellularBypass); +MS_MODEM_DID_AT_RESPOND(DigiXBeeLTEBypass); +MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeLTEBypass); +MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(DigiXBeeLTEBypass); +MS_MODEM_GET_MODEM_SIGNAL_QUALITY(DigiXBeeLTEBypass); +MS_MODEM_GET_MODEM_BATTERY_AVAILABLE(DigiXBeeLTEBypass); +MS_MODEM_GET_MODEM_TEMPERATURE_AVAILABLE(DigiXBeeLTEBypass); +MS_MODEM_CONNECT_INTERNET(DigiXBeeLTEBypass); +MS_MODEM_GET_NIST_TIME(DigiXBeeLTEBypass); -bool DigiXBeeCellularBypass::extraModemSetup(void) +bool DigiXBeeLTEBypass::extraModemSetup(void) { bool success = true; delay(1010); // Wait the required guard time before entering command mode @@ -72,9 +72,6 @@ bool DigiXBeeCellularBypass::extraModemSetup(void) MS_DBG(F("Setting Sleep Options...")); gsmModem.sendAT(F("SM"),1); success &= gsmModem.waitResponse(F("OK\r")) == 1; - // Disassociate from network for lowest power deep sleep - gsmModem.sendAT(F("SO"),0); - success &= gsmModem.waitResponse(F("OK\r")) == 1; MS_DBG(F("Setting Other Options...")); // Disable remote manager, USB Direct, and LTE PSM // NOTE: LTE-M's PSM (Power Save Mode) sounds good, but there's no @@ -124,7 +121,7 @@ bool DigiXBeeCellularBypass::extraModemSetup(void) } -void DigiXBeeCellularBypass::disconnectInternet(void) +void DigiXBeeLTEBypass::disconnectInternet(void) { // XBee doesn't like to disconnect at all, so we're doing nothing } diff --git a/src/modems/DigiXBeeLTEBypass.h b/src/modems/DigiXBeeLTEBypass.h new file mode 100644 index 000000000..59efe68c6 --- /dev/null +++ b/src/modems/DigiXBeeLTEBypass.h @@ -0,0 +1,75 @@ +/* + *DigiXBeeLTEBypass.h + *This file is part of the EnviroDIY modular sensors library for Arduino + * + *Initial library developement done by Sara Damiano (sdamiano@stroudcenter.org). + * + *This file is for Digi Cellular XBee's BASED ON UBLOX CHIPS in bypass mode +*/ + +// Header Guards +#ifndef DigiXBeeLTEBypass_h +#define DigiXBeeLTEBypass_h + +// Debugging Statement +// #define MS_DIGIXBEELTEBYPASS_DEBUG +// #define MS_DIGIXBEELTEBYPASS_DEBUG_DEEP + +#ifdef MS_DIGIXBEELTEBYPASS_DEBUG +#define MS_DEBUGGING_STD "DigiXBeeLTEBypass" +#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT +#endif + +#define TINY_GSM_MODEM_SARAR4 + +// Included Dependencies +#include "ModSensorDebugger.h" +#undef MS_DEBUGGING_STD +#include "DigiXBee.h" +#include "TinyGsmClient.h" + +#ifdef MS_DIGIXBEELTEBYPASS_DEBUG_DEEP +#include +#endif + +class DigiXBeeLTEBypass : public DigiXBee +{ + +public: + // Constructor/Destructor + DigiXBeeLTEBypass(Stream* modemStream, + int8_t powerPin, int8_t statusPin, bool useCTSStatus, + int8_t modemResetPin, int8_t modemSleepRqPin, + const char *apn, + uint8_t measurementsToAverage = 1); + virtual ~DigiXBeeLTEBypass(); + + bool connectInternet(uint32_t maxConnectionTime = 50000L) override; + void disconnectInternet(void) override; + + // Get values by other names + bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; + bool getModemBatteryStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) override; + float getModemTemperature(void) override; + + uint32_t getNISTTime(void) override; + + #ifdef MS_DIGIXBEELTEBYPASS_DEBUG_DEEP + StreamDebugger _modemATDebugger; + #endif + + TinyGsm gsmModem; + TinyGsmClient gsmClient; + +protected: + bool didATRespond(void) override; + bool isInternetAvailable(void) override; + bool verifyMeasurementComplete(bool debug=false) override; + bool extraModemSetup(void) override; + +private: + const char *_apn; + +}; + +#endif // Header Guard diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index d3c852f00..4a80ee250 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -41,8 +41,8 @@ DigiXBeeWifi::~DigiXBeeWifi(){} MS_MODEM_DID_AT_RESPOND(DigiXBeeWifi); MS_MODEM_IS_INTERNET_AVAILABLE(DigiXBeeWifi); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(DigiXBeeWifi); -MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_NA(DigiXBeeWifi); -MS_MODEM_GET_MODEM_TEMPERATURE_NA(DigiXBeeWifi); +MS_MODEM_GET_MODEM_BATTERY_NA(DigiXBeeWifi); +MS_MODEM_GET_MODEM_TEMPERATURE_AVAILABLE(DigiXBeeWifi); MS_MODEM_CONNECT_INTERNET(DigiXBeeWifi); MS_MODEM_GET_NIST_TIME(DigiXBeeWifi); @@ -92,17 +92,64 @@ bool DigiXBeeWifi::extraModemSetup(void) } +bool DigiXBeeWifi::getModemSignalQuality(int16_t &rssi, int16_t &percent) +{ + // Initialize float variable + bool success = true; + int16_t signalQual = -9999; + percent = -9999; + rssi = -9999; + + // The WiFi XBee needs to make an actual TCP connection and get some sort + // of response on that connection before it knows the signal quality. + // Connecting to the Google DNS servers for now + MS_DBG(F("Opening connection to check connection strength...")); + bool usedGoogle = false; + if (!gsmModem.gotIPforSavedHost()) + { + usedGoogle = true; + IPAddress ip(8, 8, 8, 8); // This is the IP address of time-c-g.nist.gov + success &= gsmClient.connect(ip, 80); + } + gsmClient.print('!'); // Need to send something before connection is made + delay(100); // Need this delay! Can get away with 50, but 100 is safer. + if (usedGoogle) + { + gsmClient.stop(); + } + + // Get signal quality + // NOTE: We can't actually distinguish between a bad modem response, no + // modem response, and a real response from the modem of no service/signal. + // The TinyGSM getSignalQuality function returns the same "no signal" + // value (99 CSQ or 0 RSSI) in all 3 cases. + MS_DBG(F("Getting signal quality:")); + signalQual = gsmModem.getSignalQuality(); + MS_DBG(F("Raw signal quality:"), signalQual); + + // Convert signal quality to RSSI + rssi = signalQual; + percent = getPctFromRSSI(signalQual); + + MS_DBG(F("RSSI:"), rssi); + MS_DBG(F("Percent signal strength:"), percent); + + return success; +} + + bool DigiXBeeWifi::addSingleMeasurementResult(void) { bool success = true; - // Initialize float variable + /* Initialize float variable */ int16_t signalQual = -9999; int16_t percent = -9999; int16_t rssi = -9999; + float temp = -9999; - // Check a measurement was *successfully* started (status bit 6 set) - // Only go on to get a result if it was + /* Check a measurement was *successfully* started (status bit 6 set) */ + /* Only go on to get a result if it was */ if (bitRead(_sensorStatus, 6)) { // The WiFi XBee needs to make an actual TCP connection and get some sort @@ -123,6 +170,10 @@ bool DigiXBeeWifi::addSingleMeasurementResult(void) gsmClient.stop(); } + // Enter command mode only once + MS_DBG(F("Entering Command Mode:")); + gsmModem.commandMode(); + // Get signal quality // NOTE: We can't actually distinguish between a bad modem response, no // modem response, and a real response from the modem of no service/signal. @@ -138,15 +189,27 @@ bool DigiXBeeWifi::addSingleMeasurementResult(void) MS_DBG(F("RSSI:"), rssi); MS_DBG(F("Percent signal strength:"), percent); + + MS_DBG(F("Getting chip temperature:")); + temp = getModemTemperature(); + MS_DBG(F("Modem temperature:"), temp); + + // Exit command modem + MS_DBG(F("Leaving Command Mode:")); + gsmModem.exitCommand(); } else MS_DBG(getSensorName(), F("is not connected to the network; unable to get signal quality!")); verifyAndAddMeasurementResult(MODEM_RSSI_VAR_NUM, rssi); verifyAndAddMeasurementResult(MODEM_PERCENT_SIGNAL_VAR_NUM, percent); + verifyAndAddMeasurementResult(MODEM_BATTERY_STATE_VAR_NUM, (float)-9999); + verifyAndAddMeasurementResult(MODEM_BATTERY_PERCENT_VAR_NUM, (float)-9999); + verifyAndAddMeasurementResult(MODEM_BATTERY_VOLT_VAR_NUM, (float)-9999); + verifyAndAddMeasurementResult(MODEM_TEMPERATURE_VAR_NUM, temp); - // Unset the time stamp for the beginning of this measurement + /* Unset the time stamp for the beginning of this measurement */ _millisMeasurementRequested = 0; - // Unset the status bits for a measurement request (bits 5 & 6) + /* Unset the status bits for a measurement request (bits 5 & 6) */ _sensorStatus &= 0b10011111; return success; diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index ff7aa1455..dd79f001c 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -51,7 +51,7 @@ class DigiXBeeWifi : public DigiXBee // Get values by other names bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; - float getModemBatteryVoltage(void) override; + bool getModemBatteryStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) override; float getModemTemperature(void) override; uint32_t getNISTTime(void) override; diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index 3f5e58bb6..bc1215cad 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -53,7 +53,7 @@ MS_MODEM_DID_AT_RESPOND(EspressifESP8266); MS_MODEM_IS_INTERNET_AVAILABLE(EspressifESP8266); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(EspressifESP8266); MS_MODEM_GET_MODEM_SIGNAL_QUALITY(EspressifESP8266); -MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_NA(EspressifESP8266); +MS_MODEM_GET_MODEM_BATTERY_NA(EspressifESP8266); MS_MODEM_GET_MODEM_TEMPERATURE_NA(EspressifESP8266); MS_MODEM_CONNECT_INTERNET(EspressifESP8266); MS_MODEM_DISCONNECT_INTERNET(EspressifESP8266); diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h index 8dcba3cce..658f923c5 100644 --- a/src/modems/EspressifESP8266.h +++ b/src/modems/EspressifESP8266.h @@ -70,7 +70,7 @@ class EspressifESP8266 : public loggerModem // Get values by other names bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; - float getModemBatteryVoltage(void) override; + bool getModemBatteryStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) override; float getModemTemperature(void) override; uint32_t getNISTTime(void) override; diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 5d3d7bc9a..bba9e0a6f 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -150,30 +150,27 @@ bool specificModem::getModemSignalQuality(int16_t &rssi, int16_t &percent) \ } -#define MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_AVAILABLE(specificModem) \ -float specificModem::getModemBatteryVoltage(void) \ +#define MS_MODEM_GET_MODEM_BATTERY_AVAILABLE(specificModem) \ +bool specificModem::getModemBatteryStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) \ { \ MS_DBG(F("Getting battery voltage:")); \ - float volt = gsmModem.getBattVoltage(); \ - MS_DBG(F("Voltage:"), volt); \ -\ - return volt; \ + return gsmModem.getBattStats(chargeState, percent, milliVolts); \ } -#define MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_NA(specificModem) \ -float specificModem::getModemBatteryVoltage(void) \ +#define MS_MODEM_GET_MODEM_BATTERY_NA(specificModem) \ +bool specificModem::getModemBatteryStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) \ { \ - MS_DBG(F("This modem doesn't return battery voltage!")); \ - return (float)-9999; \ + MS_DBG(F("This modem doesn't return battery infromation!")); \ + return false; \ } #define MS_MODEM_GET_MODEM_TEMPERATURE_AVAILABLE(specificModem) \ -float specificModem::getModemBatteryVoltage(void) \ +float specificModem::getModemTemperature(void) \ { \ MS_DBG(F("Getting temperature:")); \ - float temp = gsmModem.getBattVoltage(); \ + float temp = gsmModem.getTemperature(); \ MS_DBG(F("Temperature:"), temp); \ \ return temp; \ diff --git a/src/modems/QuectelBG96.cpp b/src/modems/QuectelBG96.cpp index 52046571d..0e0668532 100644 --- a/src/modems/QuectelBG96.cpp +++ b/src/modems/QuectelBG96.cpp @@ -44,7 +44,7 @@ MS_MODEM_DID_AT_RESPOND(QuectelBG96); MS_MODEM_IS_INTERNET_AVAILABLE(QuectelBG96); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(QuectelBG96); MS_MODEM_GET_MODEM_SIGNAL_QUALITY(QuectelBG96); -MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_AVAILABLE(QuectelBG96); +MS_MODEM_GET_MODEM_BATTERY_AVAILABLE(QuectelBG96); MS_MODEM_GET_MODEM_TEMPERATURE_NA(QuectelBG96); MS_MODEM_CONNECT_INTERNET(QuectelBG96); MS_MODEM_DISCONNECT_INTERNET(QuectelBG96); diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index d8ba13c5c..a9f2ab2c1 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -64,7 +64,7 @@ class QuectelBG96 : public loggerModem // Get values by other names bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; - float getModemBatteryVoltage(void) override; + bool getModemBatteryStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) override; float getModemTemperature(void) override; uint32_t getNISTTime(void) override; diff --git a/src/modems/SIMComSIM7000.cpp b/src/modems/SIMComSIM7000.cpp index 78debed58..ba5d12074 100644 --- a/src/modems/SIMComSIM7000.cpp +++ b/src/modems/SIMComSIM7000.cpp @@ -44,7 +44,7 @@ MS_MODEM_DID_AT_RESPOND(SIMComSIM7000); MS_MODEM_IS_INTERNET_AVAILABLE(SIMComSIM7000); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(SIMComSIM7000); MS_MODEM_GET_MODEM_SIGNAL_QUALITY(SIMComSIM7000); -MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_AVAILABLE(SIMComSIM7000); +MS_MODEM_GET_MODEM_BATTERY_AVAILABLE(SIMComSIM7000); MS_MODEM_GET_MODEM_TEMPERATURE_NA(SIMComSIM7000); MS_MODEM_CONNECT_INTERNET(SIMComSIM7000); MS_MODEM_DISCONNECT_INTERNET(SIMComSIM7000); diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h index 4b8428e37..d36ec9d7a 100644 --- a/src/modems/SIMComSIM7000.h +++ b/src/modems/SIMComSIM7000.h @@ -63,7 +63,7 @@ class SIMComSIM7000 : public loggerModem // Get values by other names bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; - float getModemBatteryVoltage(void) override; + bool getModemBatteryStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) override; float getModemTemperature(void) override; uint32_t getNISTTime(void) override; diff --git a/src/modems/SIMComSIM800.cpp b/src/modems/SIMComSIM800.cpp index f47f26774..bd6ab5408 100644 --- a/src/modems/SIMComSIM800.cpp +++ b/src/modems/SIMComSIM800.cpp @@ -46,7 +46,7 @@ MS_MODEM_DID_AT_RESPOND(SIMComSIM800); MS_MODEM_IS_INTERNET_AVAILABLE(SIMComSIM800); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(SIMComSIM800); MS_MODEM_GET_MODEM_SIGNAL_QUALITY(SIMComSIM800); -MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_AVAILABLE(SIMComSIM800); +MS_MODEM_GET_MODEM_BATTERY_AVAILABLE(SIMComSIM800); MS_MODEM_GET_MODEM_TEMPERATURE_NA(SIMComSIM800); MS_MODEM_CONNECT_INTERNET(SIMComSIM800); MS_MODEM_DISCONNECT_INTERNET(SIMComSIM800); diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index 1f8c0ba60..175a4216d 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -66,7 +66,7 @@ class SIMComSIM800 : public loggerModem // Get values by other names bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; - float getModemBatteryVoltage(void) override; + bool getModemBatteryStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) override; float getModemTemperature(void) override; uint32_t getNISTTime(void) override; diff --git a/src/modems/SequansMonarch.cpp b/src/modems/SequansMonarch.cpp index fafd653fb..09a74b053 100644 --- a/src/modems/SequansMonarch.cpp +++ b/src/modems/SequansMonarch.cpp @@ -44,8 +44,8 @@ MS_MODEM_DID_AT_RESPOND(SequansMonarch); MS_MODEM_IS_INTERNET_AVAILABLE(SequansMonarch); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(SequansMonarch); MS_MODEM_GET_MODEM_SIGNAL_QUALITY(SequansMonarch); -MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_NA(SequansMonarch); -MS_MODEM_GET_MODEM_TEMPERATURE_NA(SequansMonarch); +MS_MODEM_GET_MODEM_BATTERY_NA(SequansMonarch); +MS_MODEM_GET_MODEM_TEMPERATURE_AVAILABLE(SequansMonarch); MS_MODEM_CONNECT_INTERNET(SequansMonarch); MS_MODEM_DISCONNECT_INTERNET(SequansMonarch); MS_MODEM_GET_NIST_TIME(SequansMonarch); diff --git a/src/modems/SequansMonarch.h b/src/modems/SequansMonarch.h index c02c0e3d7..4b2555fa1 100644 --- a/src/modems/SequansMonarch.h +++ b/src/modems/SequansMonarch.h @@ -64,7 +64,7 @@ class SequansMonarch : public loggerModem // Get values by other names bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; - float getModemBatteryVoltage(void) override; + bool getModemBatteryStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) override; float getModemTemperature(void) override; uint32_t getNISTTime(void) override; diff --git a/src/modems/Sodaq2GBeeR6.cpp b/src/modems/Sodaq2GBeeR6.cpp index e5fb4cc3e..1afa755e7 100644 --- a/src/modems/Sodaq2GBeeR6.cpp +++ b/src/modems/Sodaq2GBeeR6.cpp @@ -45,7 +45,7 @@ MS_MODEM_DID_AT_RESPOND(Sodaq2GBeeR6); MS_MODEM_IS_INTERNET_AVAILABLE(Sodaq2GBeeR6); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(Sodaq2GBeeR6); MS_MODEM_GET_MODEM_SIGNAL_QUALITY(Sodaq2GBeeR6); -MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_AVAILABLE(Sodaq2GBeeR6); +MS_MODEM_GET_MODEM_BATTERY_AVAILABLE(Sodaq2GBeeR6); MS_MODEM_GET_MODEM_TEMPERATURE_NA(Sodaq2GBeeR6); MS_MODEM_CONNECT_INTERNET(Sodaq2GBeeR6); MS_MODEM_DISCONNECT_INTERNET(Sodaq2GBeeR6); diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h index 200798c4a..b42dde2a8 100644 --- a/src/modems/Sodaq2GBeeR6.h +++ b/src/modems/Sodaq2GBeeR6.h @@ -65,7 +65,7 @@ class Sodaq2GBeeR6 : public loggerModem // Get values by other names bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; - float getModemBatteryVoltage(void) override; + bool getModemBatteryStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) override; float getModemTemperature(void) override; uint32_t getNISTTime(void) override; diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp index 61e4d3d9f..7dc52a7c2 100644 --- a/src/modems/SodaqUBeeR410M.cpp +++ b/src/modems/SodaqUBeeR410M.cpp @@ -70,8 +70,8 @@ MS_MODEM_DID_AT_RESPOND(SodaqUBeeR410M); MS_MODEM_IS_INTERNET_AVAILABLE(SodaqUBeeR410M); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(SodaqUBeeR410M); MS_MODEM_GET_MODEM_SIGNAL_QUALITY(SodaqUBeeR410M); -MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_NA(SodaqUBeeR410M); -MS_MODEM_GET_MODEM_TEMPERATURE_NA(SodaqUBeeR410M); +MS_MODEM_GET_MODEM_BATTERY_AVAILABLE(SodaqUBeeR410M); +MS_MODEM_GET_MODEM_TEMPERATURE_AVAILABLE(SodaqUBeeR410M); MS_MODEM_CONNECT_INTERNET(SodaqUBeeR410M); MS_MODEM_DISCONNECT_INTERNET(SodaqUBeeR410M); MS_MODEM_GET_NIST_TIME(SodaqUBeeR410M); diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index 43227a36c..31696976a 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -75,7 +75,7 @@ class SodaqUBeeR410M : public loggerModem // Get values by other names bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; - float getModemBatteryVoltage(void) override; + bool getModemBatteryStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) override; float getModemTemperature(void) override; uint32_t getNISTTime(void) override; diff --git a/src/modems/SodaqUBeeU201.cpp b/src/modems/SodaqUBeeU201.cpp index ef01cdccd..e2e76507c 100644 --- a/src/modems/SodaqUBeeU201.cpp +++ b/src/modems/SodaqUBeeU201.cpp @@ -44,7 +44,7 @@ MS_MODEM_DID_AT_RESPOND(SodaqUBeeU201); MS_MODEM_IS_INTERNET_AVAILABLE(SodaqUBeeU201); MS_MODEM_VERIFY_MEASUREMENT_COMPLETE(SodaqUBeeU201); MS_MODEM_GET_MODEM_SIGNAL_QUALITY(SodaqUBeeU201); -MS_MODEM_GET_MODEM_BATTERY_VOLTAGE_NA(SodaqUBeeU201); +MS_MODEM_GET_MODEM_BATTERY_AVAILABLE(SodaqUBeeU201); MS_MODEM_GET_MODEM_TEMPERATURE_NA(SodaqUBeeU201); MS_MODEM_CONNECT_INTERNET(SodaqUBeeU201); MS_MODEM_DISCONNECT_INTERNET(SodaqUBeeU201); diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index b26cb7212..2e70c4e8f 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -69,7 +69,7 @@ class SodaqUBeeU201 : public loggerModem // Get values by other names bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; - float getModemBatteryVoltage(void) override; + bool getModemBatteryStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) override; float getModemTemperature(void) override; uint32_t getNISTTime(void) override; From 993dd2991b13e1146660d21d1df467ed88a3f66e Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 22 May 2019 14:57:09 -0400 Subject: [PATCH 44/88] Need to compile the modems folder! --- library.json | 3 +++ src/modems/DigiXBee.cpp | 7 +++++++ src/modems/DigiXBee.h | 6 +++--- src/modems/DigiXBee3GBypass.cpp | 6 ------ src/modems/DigiXBee3GBypass.h | 3 +-- src/modems/DigiXBeeCellularTransparent.cpp | 6 ------ src/modems/DigiXBeeCellularTransparent.h | 3 +-- src/modems/DigiXBeeLTEBypass.cpp | 6 ------ src/modems/DigiXBeeLTEBypass.h | 3 +-- src/modems/DigiXBeeWifi.cpp | 6 ------ src/modems/DigiXBeeWifi.h | 3 +-- src/modems/EspressifESP8266.h | 2 +- src/modems/LoggerModemMacros.h | 2 +- src/modems/QuectelBG96.h | 2 +- src/modems/SIMComSIM7000.h | 2 +- src/modems/SIMComSIM800.h | 2 +- src/modems/SequansMonarch.h | 2 +- src/modems/Sodaq2GBeeR6.h | 2 +- src/modems/SodaqUBeeR410M.h | 2 +- src/modems/SodaqUBeeU201.h | 2 +- 20 files changed, 26 insertions(+), 44 deletions(-) diff --git a/library.json b/library.json index 73840c8b6..60f600fcc 100644 --- a/library.json +++ b/library.json @@ -55,6 +55,9 @@ "+", "+", "+", + "+", + "+", + "+", "+", "+", "+" diff --git a/src/modems/DigiXBee.cpp b/src/modems/DigiXBee.cpp index 9d2535f56..d7eaa001a 100644 --- a/src/modems/DigiXBee.cpp +++ b/src/modems/DigiXBee.cpp @@ -62,3 +62,10 @@ bool DigiXBee::modemSleepFxn(void) return true; } } + + +void DigiXBee::disconnectInternet(void) +{ + // XBee doesn't like to disconnect AT ALL, so we're doing nothing + // If you do disconnect, you must power cycle before you can reconnecte +} diff --git a/src/modems/DigiXBee.h b/src/modems/DigiXBee.h index 0125a6222..42519ac1d 100644 --- a/src/modems/DigiXBee.h +++ b/src/modems/DigiXBee.h @@ -54,7 +54,7 @@ class DigiXBee : public loggerModem // Access the internet virtual bool connectInternet(uint32_t maxConnectionTime = 50000L) = 0; - virtual void disconnectInternet(void) = 0; + void disconnectInternet(void); // Get values by other names virtual bool getModemSignalQuality(int16_t &rssi, int16_t &percent) = 0; @@ -70,8 +70,8 @@ class DigiXBee : public loggerModem virtual bool didATRespond(void) = 0; virtual bool isInternetAvailable(void) = 0; virtual bool verifyMeasurementComplete(bool debug = false) = 0; - virtual bool modemSleepFxn(void) override; - virtual bool modemWakeFxn(void) override; + bool modemSleepFxn(void) override; + bool modemWakeFxn(void) override; virtual bool extraModemSetup(void) = 0; }; diff --git a/src/modems/DigiXBee3GBypass.cpp b/src/modems/DigiXBee3GBypass.cpp index 43aedd84c..1fd5afb03 100644 --- a/src/modems/DigiXBee3GBypass.cpp +++ b/src/modems/DigiXBee3GBypass.cpp @@ -108,9 +108,3 @@ bool DigiXBee3GBypass::extraModemSetup(void) else MS_DBG(F("... failed!")); return success; } - - -void DigiXBee3GBypass::disconnectInternet(void) -{ - // XBee doesn't like to disconnect at all, so we're doing nothing -} diff --git a/src/modems/DigiXBee3GBypass.h b/src/modems/DigiXBee3GBypass.h index c4cdd6a13..58db914f7 100644 --- a/src/modems/DigiXBee3GBypass.h +++ b/src/modems/DigiXBee3GBypass.h @@ -42,10 +42,9 @@ class DigiXBee3GBypass : public DigiXBee int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~DigiXBee3GBypass(); + ~DigiXBee3GBypass(); bool connectInternet(uint32_t maxConnectionTime = 50000L) override; - void disconnectInternet(void) override; // Get values by other names bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index 651df0aa1..578add1bf 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -170,9 +170,3 @@ bool DigiXBeeCellularTransparent::addSingleMeasurementResult(void) return success; } - - -void DigiXBeeCellularTransparent::disconnectInternet(void) -{ - // XBee doesn't like to disconnect at all, so we're doing nothing -} diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index 679c545b8..94ec971bb 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -42,12 +42,11 @@ class DigiXBeeCellularTransparent : public DigiXBee int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~DigiXBeeCellularTransparent(); + ~DigiXBeeCellularTransparent(); bool addSingleMeasurementResult(void) override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; - void disconnectInternet(void) override; // Get values by other names bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; diff --git a/src/modems/DigiXBeeLTEBypass.cpp b/src/modems/DigiXBeeLTEBypass.cpp index 2f34db68c..db47f566a 100644 --- a/src/modems/DigiXBeeLTEBypass.cpp +++ b/src/modems/DigiXBeeLTEBypass.cpp @@ -119,9 +119,3 @@ bool DigiXBeeLTEBypass::extraModemSetup(void) else MS_DBG(F("... failed!")); return success; } - - -void DigiXBeeLTEBypass::disconnectInternet(void) -{ - // XBee doesn't like to disconnect at all, so we're doing nothing -} diff --git a/src/modems/DigiXBeeLTEBypass.h b/src/modems/DigiXBeeLTEBypass.h index 59efe68c6..d9cf9100a 100644 --- a/src/modems/DigiXBeeLTEBypass.h +++ b/src/modems/DigiXBeeLTEBypass.h @@ -42,10 +42,9 @@ class DigiXBeeLTEBypass : public DigiXBee int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~DigiXBeeLTEBypass(); + ~DigiXBeeLTEBypass(); bool connectInternet(uint32_t maxConnectionTime = 50000L) override; - void disconnectInternet(void) override; // Get values by other names bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index 4a80ee250..0834444cb 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -214,9 +214,3 @@ bool DigiXBeeWifi::addSingleMeasurementResult(void) return success; } - - -void DigiXBeeWifi::disconnectInternet(void) -{ - // XBee doesn't like to disconnect at all, so we're doing nothing -} diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index dd79f001c..484dd3d5e 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -42,12 +42,11 @@ class DigiXBeeWifi : public DigiXBee int8_t modemResetPin, int8_t modemSleepRqPin, const char *ssid, const char *pwd, uint8_t measurementsToAverage = 1); - virtual ~DigiXBeeWifi(); + ~DigiXBeeWifi(); bool addSingleMeasurementResult(void) override; bool connectInternet(uint32_t maxConnectionTime = 50000L) override; - void disconnectInternet(void) override; // Get values by other names bool getModemSignalQuality(int16_t &rssi, int16_t &percent) override; diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h index 658f923c5..3c4095a74 100644 --- a/src/modems/EspressifESP8266.h +++ b/src/modems/EspressifESP8266.h @@ -61,7 +61,7 @@ class EspressifESP8266 : public loggerModem const char *ssid, const char *pwd, uint8_t measurementsToAverage = 1, int8_t espSleepRqPin = -1, int8_t espStatusPin = -1); - virtual ~EspressifESP8266(); + ~EspressifESP8266(); bool startSingleMeasurement(void) override; diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index bba9e0a6f..3d97d36a1 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -166,6 +166,7 @@ bool specificModem::getModemBatteryStats(uint8_t &chargeState, int8_t &percent, } +// NOTE: Most modems don't give this #define MS_MODEM_GET_MODEM_TEMPERATURE_AVAILABLE(specificModem) \ float specificModem::getModemTemperature(void) \ { \ @@ -177,7 +178,6 @@ float specificModem::getModemTemperature(void) \ } -// NOTE: Most modems don't give this #define MS_MODEM_GET_MODEM_TEMPERATURE_NA(specificModem) \ float specificModem::getModemTemperature(void) \ { \ diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index a9f2ab2c1..906f6f209 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -57,7 +57,7 @@ class QuectelBG96 : public loggerModem int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~QuectelBG96(); + ~QuectelBG96(); bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet(void) override; diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h index d36ec9d7a..f6d37c251 100644 --- a/src/modems/SIMComSIM7000.h +++ b/src/modems/SIMComSIM7000.h @@ -56,7 +56,7 @@ class SIMComSIM7000 : public loggerModem int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~SIMComSIM7000(); + ~SIMComSIM7000(); bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet(void) override; diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index 175a4216d..23477d914 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -59,7 +59,7 @@ class SIMComSIM800 : public loggerModem int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~SIMComSIM800(); + ~SIMComSIM800(); bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet(void) override; diff --git a/src/modems/SequansMonarch.h b/src/modems/SequansMonarch.h index 4b2555fa1..f8a3b63eb 100644 --- a/src/modems/SequansMonarch.h +++ b/src/modems/SequansMonarch.h @@ -57,7 +57,7 @@ class SequansMonarch : public loggerModem int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~SequansMonarch(); + ~SequansMonarch(); bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet(void) override; diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h index b42dde2a8..271797e3b 100644 --- a/src/modems/Sodaq2GBeeR6.h +++ b/src/modems/Sodaq2GBeeR6.h @@ -58,7 +58,7 @@ class Sodaq2GBeeR6 : public loggerModem int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~Sodaq2GBeeR6(); + ~Sodaq2GBeeR6(); bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet(void) override; diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index 31696976a..669e38774 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -68,7 +68,7 @@ class SodaqUBeeR410M : public loggerModem const char *apn, uint8_t measurementsToAverage = 1); #endif - virtual ~SodaqUBeeR410M(); + ~SodaqUBeeR410M(); bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet(void) override; diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index 2e70c4e8f..72ab28965 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -62,7 +62,7 @@ class SodaqUBeeU201 : public loggerModem int8_t modemResetPin, int8_t modemSleepRqPin, const char *apn, uint8_t measurementsToAverage = 1); - virtual ~SodaqUBeeU201(); + ~SodaqUBeeU201(); bool connectInternet(uint32_t maxConnectionTime = 50000L) override; void disconnectInternet(void) override; From 1b36cbc19326ded0cc4e1a78a6c866b789ae33bf Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 22 May 2019 15:36:12 -0400 Subject: [PATCH 45/88] Version bump --- examples/DRWI_CitSci/DRWI_CitSci.ino | 4 ++-- examples/DRWI_LTE/DRWI_LTE.ino | 4 ++-- examples/DRWI_NoCellular/DRWI_NoCellular.ino | 4 ++-- examples/baro_rho_correction/baro_rho_correction.ino | 4 ++-- examples/data_saving/data_saving.ino | 4 ++-- examples/double_logger/double_logger.ino | 4 ++-- examples/logging_to_MMW/logging_to_MMW.ino | 4 ++-- examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino | 4 ++-- examples/menu_a_la_carte/menu_a_la_carte.ino | 4 ++-- examples/simple_logging/simple_logging.ino | 4 ++-- .../simple_logging_LearnEnviroDIY.ino | 4 ++-- examples/single_sensor/single_sensor.ino | 4 ++-- library.json | 2 +- library.properties | 2 +- src/ModSensorDebugger.h | 2 +- 15 files changed, 27 insertions(+), 27 deletions(-) diff --git a/examples/DRWI_CitSci/DRWI_CitSci.ino b/examples/DRWI_CitSci/DRWI_CitSci.ino index ee8bf4a87..6460b2f8b 100644 --- a/examples/DRWI_CitSci/DRWI_CitSci.ino +++ b/examples/DRWI_CitSci/DRWI_CitSci.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.21.4 +This example sketch is written for ModularSensors library version 0.22.0 This sketch is an example of logging data to an SD card and sending the data to both the EnviroDIY data portal as should be used by groups involved with @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.21.4"; +const char *libraryVersion = "0.22.0"; // The name of this file const char *sketchName = "DWRI_CitSci.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/DRWI_LTE/DRWI_LTE.ino b/examples/DRWI_LTE/DRWI_LTE.ino index 0d9c72b6e..a8aa3bffa 100644 --- a/examples/DRWI_LTE/DRWI_LTE.ino +++ b/examples/DRWI_LTE/DRWI_LTE.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.21.4 +This example sketch is written for ModularSensors library version 0.22.0 This sketch is an example of logging data to an SD card and sending the data to both the EnviroDIY data portal as should be used by groups involved with @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.21.4"; +const char *libraryVersion = "0.22.0"; // The name of this file const char *sketchName = "DRWI_LTE.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/DRWI_NoCellular/DRWI_NoCellular.ino b/examples/DRWI_NoCellular/DRWI_NoCellular.ino index f80a6463d..54ea0b628 100644 --- a/examples/DRWI_NoCellular/DRWI_NoCellular.ino +++ b/examples/DRWI_NoCellular/DRWI_NoCellular.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.21.4 +This example sketch is written for ModularSensors library version 0.22.0 This sketch is an example of logging data to an SD card as should be used by groups involved with The William Penn Foundation's Delaware River Watershed @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.21.4"; +const char *libraryVersion = "0.22.0"; // The name of this file const char *sketchName = "DRWI_NoCellular.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/baro_rho_correction/baro_rho_correction.ino b/examples/baro_rho_correction/baro_rho_correction.ino index e4608aca4..99b41e1b6 100644 --- a/examples/baro_rho_correction/baro_rho_correction.ino +++ b/examples/baro_rho_correction/baro_rho_correction.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.21.4 +This example sketch is written for ModularSensors library version 0.22.0 This sketch is an example of logging data to an SD card and sending the data to the EnviroDIY data portal. @@ -27,7 +27,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.21.4"; +const char *libraryVersion = "0.22.0"; // The name of this file const char *sketchName = "baro_rho_correction.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/data_saving/data_saving.ino b/examples/data_saving/data_saving.ino index 9ed422616..1b4e7a486 100644 --- a/examples/data_saving/data_saving.ino +++ b/examples/data_saving/data_saving.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.21.4 +This example sketch is written for ModularSensors library version 0.22.0 This sketch is an example of logging data to an SD card and sending only a portion of that data to the EnviroDIY data portal. @@ -27,7 +27,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.21.4"; +const char *libraryVersion = "0.22.0"; // The name of this file const char *sketchName = "data_saving.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/double_logger/double_logger.ino b/examples/double_logger/double_logger.ino index 11380b47a..dffb73e52 100644 --- a/examples/double_logger/double_logger.ino +++ b/examples/double_logger/double_logger.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.21.4 +This example sketch is written for ModularSensors library version 0.22.0 This sketch is an example of logging data from different variables at two different logging intervals. This example uses more of the manual functions @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.21.4"; +const char *libraryVersion = "0.22.0"; // The name of this file const char *sketchName = "double_logger.ino"; // Logger ID - we're only using one logger ID for both "loggers" diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index 7f24687a0..34dc4dff6 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.21.4 +This example sketch is written for ModularSensors library version 0.22.0 This shows most of the standard functions of the library at once. @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.21.4"; +const char *libraryVersion = "0.22.0"; // The name of this file const char *sketchName = "logging_to MMW.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino index 1a6dcf230..510c2a7be 100644 --- a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino +++ b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.21.4 +This example sketch is written for ModularSensors library version 0.22.0 This sketch is an example of logging data to an SD card and sending the data to ThingSpeak. @@ -27,7 +27,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.21.4"; +const char *libraryVersion = "0.22.0"; // The name of this file const char *sketchName = "logging_to_ThingSpeak.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index d614b536d..d1c606fe7 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.21.4 +This example sketch is written for ModularSensors library version 0.22.0 This shows most of the standard functions of the library at once. @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.21.4"; +const char *libraryVersion = "0.22.0"; // The name of this file const char *sketchName = "menu_a_la_carte.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/simple_logging/simple_logging.ino b/examples/simple_logging/simple_logging.ino index 71a676cef..afe9003dd 100644 --- a/examples/simple_logging/simple_logging.ino +++ b/examples/simple_logging/simple_logging.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.21.4 +This example sketch is written for ModularSensors library version 0.22.0 This sketch is an example of logging data to an SD card @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.21.4"; +const char *libraryVersion = "0.22.0"; // The name of this file const char *sketchName = "simple_logging.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino b/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino index af8f817aa..399dcd8f6 100644 --- a/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino +++ b/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.21.4 +This example sketch is written for ModularSensors library version 0.22.0 This sketch is an example of logging data to an SD card @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.21.4"; +const char *libraryVersion = "0.22.0"; // The name of this file const char *sketchName = "simple_logging.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/single_sensor/single_sensor.ino b/examples/single_sensor/single_sensor.ino index 4f0e2ebce..3faa69492 100644 --- a/examples/single_sensor/single_sensor.ino +++ b/examples/single_sensor/single_sensor.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.21.4 +This example sketch is written for ModularSensors library version 0.22.0 This sketch is an example of getting data from a single sensor, in this case, a MaxBotix Ultrasonic Range Finder @@ -24,7 +24,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. #include // The library version this example was written for -const char *libraryVersion = "0.21.4"; +const char *libraryVersion = "0.22.0"; // The name of this file const char *sketchName = "single_sensor.ino"; diff --git a/library.json b/library.json index 60f600fcc..90db4275d 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "EnviroDIY_ModularSensors", - "version": "0.21.4", + "version": "0.22.0", "description": "A library that allows access to multiple sensors through a unified interface. This allows the user to simply access many sensors to log the data or send the data to data repositories like the EnviroDIY data portal.", "keywords": "modular, sensor, sensors, datalogger, logger, low power, sleeping, EnviroDIY, ModularSensors, Mayfly, WikiWatershed, ThingSpeak", "platforms": "atmelavr, atmelsam", diff --git a/library.properties b/library.properties index 7d9179093..b8046c356 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=EnviroDIY_ModularSensors -version=0.21.4 +version=0.22.0 author=Sara Damiano , Shannon Hicks maintainer=Sara Damiano sentence=A library that allows access to multiple sensors through a unified interface. diff --git a/src/ModSensorDebugger.h b/src/ModSensorDebugger.h index fc351b65f..2e6baa5f6 100644 --- a/src/ModSensorDebugger.h +++ b/src/ModSensorDebugger.h @@ -15,7 +15,7 @@ #include // The current library version number -#define MODULAR_SENSORS_VERSION "0.21.4" +#define MODULAR_SENSORS_VERSION "0.22.0" #ifndef STANDARD_SERIAL_OUTPUT // #if defined(ARDUINO_SAMD_ZERO) && defined(SERIAL_PORT_USBVIRTUAL) From ac9f611061e2d01c9c3e87e36e21b8b280d1a72b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 22 May 2019 16:11:37 -0400 Subject: [PATCH 46/88] Correct modem battery units, flash strings --- src/LoggerModem.h | 8 ++-- src/modems/DigiXBee3GBypass.cpp | 40 ++++++++--------- src/modems/DigiXBeeCellularTransparent.cpp | 20 ++++----- src/modems/DigiXBeeLTEBypass.cpp | 52 +++++++++++----------- src/modems/DigiXBeeWifi.cpp | 10 ++--- src/modems/EspressifESP8266.cpp | 14 +++--- src/modems/SodaqUBeeR410M.cpp | 2 +- 7 files changed, 73 insertions(+), 73 deletions(-) diff --git a/src/LoggerModem.h b/src/LoggerModem.h index 300b4f312..8642dafdc 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -43,7 +43,7 @@ #define MODEM_BATTERY_PERCENT_RESOLUTION 0 #define MODEM_BATTERY_VOLT_VAR_NUM 4 -#define MODEM_BATTERY_VOLT_RESOLUTION 3 +#define MODEM_BATTERY_VOLT_RESOLUTION 0 #define MODEM_TEMPERATURE_VAR_NUM 5 #define MODEM_TEMPERATURE_RESOLUTION 1 @@ -275,17 +275,17 @@ class Modem_BatteryVoltage : public Variable public: Modem_BatteryVoltage(Sensor *parentSense, const char *uuid = "", - const char *varCode = "modemBatteryVolt") + const char *varCode = "modemBatterymVolt") : Variable(parentSense, (const uint8_t)MODEM_BATTERY_VOLT_VAR_NUM, (uint8_t)MODEM_BATTERY_VOLT_RESOLUTION, - "batteryVoltage", "volt", + "batteryVoltage", "milliVolt", varCode, uuid) {} Modem_BatteryVoltage() : Variable((const uint8_t)MODEM_BATTERY_VOLT_VAR_NUM, (uint8_t)MODEM_BATTERY_VOLT_RESOLUTION, - "batteryVoltage", "volt", "modemBatteryVolt") + "batteryVoltage", "milliVolt", "modemBatterymVolt") {} ~Modem_BatteryVoltage(){} }; diff --git a/src/modems/DigiXBee3GBypass.cpp b/src/modems/DigiXBee3GBypass.cpp index 1fd5afb03..2a813a249 100644 --- a/src/modems/DigiXBee3GBypass.cpp +++ b/src/modems/DigiXBee3GBypass.cpp @@ -58,45 +58,45 @@ bool DigiXBee3GBypass::extraModemSetup(void) MS_DBG(F("Setting I/O Pins...")); // Set DIO8 to be used for sleep requests // NOTE: Only pin 9/DIO8/DTR can be used for this function - gsmModem.sendAT(F("D8"),1); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("D8"),1); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; // Turn on status indication pin - it will be HIGH when the XBee is awake // NOTE: Only pin 13/ON/SLEEPnot/DIO9 can be used for this function - gsmModem.sendAT(F("D9"),1); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("D9"),1); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; // Turn on CTS pin - it will be LOW when the XBee is ready to receive commands // This can be used as proxy for status indication if the true status pin is not accessible // NOTE: Only pin 12/DIO7/CTS can be used for this function - gsmModem.sendAT(F("D7"),1); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("D7"),1); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; // Put the XBee in pin sleep mode MS_DBG(F("Setting Sleep Options...")); - gsmModem.sendAT(F("SM"),1); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("SM"),1); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; // Disassociate from network for lowest power deep sleep MS_DBG(F("Setting Other Options...")); // Disable remote manager, enable 2G fallback - gsmModem.sendAT(F("DO"),02); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("DO"),02); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; MS_DBG(F("Setting Cellular Carrier Options...")); // Cellular carrier profile - AT&T // Hologram says they can use any network, but I've never succeeded with anything but AT&T - gsmModem.sendAT(F("CP"),2); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("CP"),2); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; MS_DBG(F("Turning on Bypass Mode...")); // Turn on bypass mode - gsmModem.sendAT(F("AP5")); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("AP5")); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; // Write changes to flash - gsmModem.sendAT(F("WR")); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("WR")); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; // Apply changes - gsmModem.sendAT(F("AC")); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("AC")); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; // Force reset to actually enter bypass mode - this effectively exits bypass mode MS_DBG(F("Resetting the module to reboot in bypass mode...")); - gsmModem.sendAT(F("FR")); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("FR")); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; delay(200); // Allow the unit to reset // re-initialize MS_DBG(F("Attempting to reconnect to the u-blox module...")); diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index 578add1bf..e67d73cd3 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -58,45 +58,45 @@ bool DigiXBeeCellularTransparent::extraModemSetup(void) MS_DBG(F("Setting I/O Pins...")); // Set DIO8 to be used for sleep requests // NOTE: Only pin 9/DIO8/DTR can be used for this function - gsmModem.sendAT(F("D8"),1); + gsmModem.sendAT(GF("D8"),1); success &= gsmModem.waitResponse() == 1; // Turn on status indication pin - it will be HIGH when the XBee is awake // NOTE: Only pin 13/ON/SLEEPnot/DIO9 can be used for this function - gsmModem.sendAT(F("D9"),1); + gsmModem.sendAT(GF("D9"),1); success &= gsmModem.waitResponse() == 1; // Turn on CTS pin - it will be LOW when the XBee is ready to receive commands // This can be used as proxy for status indication if the true status pin is not accessible // NOTE: Only pin 12/DIO7/CTS can be used for this function - gsmModem.sendAT(F("D7"),1); + gsmModem.sendAT(GF("D7"),1); success &= gsmModem.waitResponse() == 1; // Put the XBee in pin sleep mode MS_DBG(F("Setting Sleep Options...")); - gsmModem.sendAT(F("SM"),1); + gsmModem.sendAT(GF("SM"),1); success &= gsmModem.waitResponse() == 1; // Disassociate from network for lowest power deep sleep - gsmModem.sendAT(F("SO"),0); + gsmModem.sendAT(GF("SO"),0); success &= gsmModem.waitResponse() == 1; MS_DBG(F("Setting Other Options...")); // Disable remote manager, USB Direct, and LTE PSM // NOTE: LTE-M's PSM (Power Save Mode) sounds good, but there's no // easy way on the LTE-M Bee to wake the cell chip itself from PSM, // so we'll use the Digi pin sleep instead. - gsmModem.sendAT(F("DO"),0); + gsmModem.sendAT(GF("DO"),0); success &= gsmModem.waitResponse() == 1; // Make sure USB direct won't be pin enabled on XBee3 units - gsmModem.sendAT(F("P0"),0); + gsmModem.sendAT(GF("P0"),0); success &= gsmModem.waitResponse() == 1; // Make sure pins 7&8 are not set for USB direct on XBee3 units - gsmModem.sendAT(F("P1"),0); + gsmModem.sendAT(GF("P1"),0); success &= gsmModem.waitResponse() == 1; MS_DBG(F("Setting Cellular Carrier Options...")); // Cellular carrier profile - AT&T // Hologram says they can use any network, but I've never succeeded with anything but AT&T - gsmModem.sendAT(F("CP"),2); + gsmModem.sendAT(GF("CP"),2); success &= gsmModem.waitResponse() == 1; // Cellular network technology - LTE-M Only // LTE-M XBee connects much faster on AT&T/Hologram when set to LTE-M only (instead of LTE-M/NB IoT) - gsmModem.sendAT(F("N#"),2); + gsmModem.sendAT(GF("N#"),2); success &= gsmModem.waitResponse() == 1; // Put the network connection parameters into flash success &= gsmModem.gprsConnect(_apn); diff --git a/src/modems/DigiXBeeLTEBypass.cpp b/src/modems/DigiXBeeLTEBypass.cpp index db47f566a..3f390d8f0 100644 --- a/src/modems/DigiXBeeLTEBypass.cpp +++ b/src/modems/DigiXBeeLTEBypass.cpp @@ -57,57 +57,57 @@ bool DigiXBeeLTEBypass::extraModemSetup(void) MS_DBG(F("Setting I/O Pins...")); // Set DIO8 to be used for sleep requests // NOTE: Only pin 9/DIO8/DTR can be used for this function - gsmModem.sendAT(F("D8"),1); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("D8"),1); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; // Turn on status indication pin - it will be HIGH when the XBee is awake // NOTE: Only pin 13/ON/SLEEPnot/DIO9 can be used for this function - gsmModem.sendAT(F("D9"),1); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("D9"),1); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; // Turn on CTS pin - it will be LOW when the XBee is ready to receive commands // This can be used as proxy for status indication if the true status pin is not accessible // NOTE: Only pin 12/DIO7/CTS can be used for this function - gsmModem.sendAT(F("D7"),1); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("D7"),1); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; // Put the XBee in pin sleep mode MS_DBG(F("Setting Sleep Options...")); - gsmModem.sendAT(F("SM"),1); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("SM"),1); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; MS_DBG(F("Setting Other Options...")); // Disable remote manager, USB Direct, and LTE PSM // NOTE: LTE-M's PSM (Power Save Mode) sounds good, but there's no // easy way on the LTE-M Bee to wake the cell chip itself from PSM, // so we'll use the Digi pin sleep instead. - gsmModem.sendAT(F("DO"),0); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("DO"),0); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; // Make sure USB direct won't be pin enabled on XBee3 units - gsmModem.sendAT(F("P0"),0); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("P0"),0); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; // Make sure pins 7&8 are not set for USB direct on XBee3 units - gsmModem.sendAT(F("P1"),0); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("P1"),0); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; MS_DBG(F("Setting Cellular Carrier Options...")); // Cellular carrier profile - AT&T // Hologram says they can use any network, but I've never succeeded with anything but AT&T - gsmModem.sendAT(F("CP"),2); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("CP"),2); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; // Cellular network technology - LTE-M Only // LTE-M XBee connects much faster on AT&T/Hologram when set to LTE-M only (instead of LTE-M/NB IoT) - gsmModem.sendAT(F("N#"),2); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("N#"),2); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; MS_DBG(F("Turning on Bypass Mode...")); // Turn on bypass mode - gsmModem.sendAT(F("AP5")); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("AP5")); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; // Write changes to flash - gsmModem.sendAT(F("WR")); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("WR")); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; // Apply changes - gsmModem.sendAT(F("AC")); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("AC")); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; // Force reset to actually enter bypass mode - this effectively exits bypass mode MS_DBG(F("Resetting the module to reboot in bypass mode...")); - gsmModem.sendAT(F("FR")); - success &= gsmModem.waitResponse(F("OK\r")) == 1; + gsmModem.sendAT(GF("FR")); + success &= gsmModem.waitResponse(GF("OK\r")) == 1; delay(200); // Allow the unit to reset // re-initialize MS_DBG(F("Attempting to reconnect to the u-blox module...")); diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index 0834444cb..bf8b1cf00 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -59,23 +59,23 @@ bool DigiXBeeWifi::extraModemSetup(void) MS_DBG(F("Setting I/O Pins...")); // Set DIO8 to be used for sleep requests // NOTE: Only pin 9/DIO8/DTR can be used for this function - gsmModem.sendAT(F("D8"),1); + gsmModem.sendAT(GF("D8"),1); success &= gsmModem.waitResponse() == 1; // Turn on status indication pin - it will be HIGH when the XBee is awake // NOTE: Only pin 13/ON/SLEEPnot/DIO9 can be used for this function - gsmModem.sendAT(F("D9"),1); + gsmModem.sendAT(GF("D9"),1); success &= gsmModem.waitResponse() == 1; // Turn on CTS pin - it will be LOW when the XBee is ready to receive commands // This can be used as proxy for status indication if the true status pin is not accessible // NOTE: Only pin 12/DIO7/CTS can be used for this function - gsmModem.sendAT(F("D7"),1); + gsmModem.sendAT(GF("D7"),1); success &= gsmModem.waitResponse() == 1; // Put the XBee in pin sleep mode MS_DBG(F("Setting Sleep Options...")); - gsmModem.sendAT(F("SM"),1); + gsmModem.sendAT(GF("SM"),1); success &= gsmModem.waitResponse() == 1; // Disassociate from network for lowest power deep sleep - gsmModem.sendAT(F("SO"),200); + gsmModem.sendAT(GF("SO"),200); success &= gsmModem.waitResponse() == 1; MS_DBG(F("Setting Wifi Network Options...")); // Put the network connection parameters into flash diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index bc1215cad..0196dc222 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -84,7 +84,7 @@ bool EspressifESP8266::ESPwaitForBoot(void) delay(2); } // Have to make sure echo is off or all AT commands will be confused - gsmModem.sendAT(F("E0")); + gsmModem.sendAT(GF("E0")); success &= gsmModem.waitResponse() == 1; // re-run init to set mux and station mode success &= gsmModem.init(); @@ -139,7 +139,7 @@ bool EspressifESP8266::modemSleepFxn(void) { uint32_t sleepSeconds = (((uint32_t)loggingInterval) * 60 * 1000) - 75000L; String sleepCommand = String(sleepSeconds); - gsmModem.sendAT(F("+GSLP="), sleepCommand); + gsmModem.sendAT(GF("+GSLP="), sleepCommand); // Power down for 1 minute less than logging interval // Better: Calculate length of loop and power down for logging interval - loop time return gsmModem.waitResponse() == 1; @@ -156,10 +156,10 @@ bool EspressifESP8266::modemSleepFxn(void) else if (_modemSleepRqPin >= 0 && _dataPin >= 0) { MS_DBG(F("Requesting light sleep for ESP8266 with status indication")); - gsmModem.sendAT(F("+WAKEUPGPIO=1,"), String(_espSleepRqPin), F(",0,"), + gsmModem.sendAT(GF("+WAKEUPGPIO=1,"), String(_espSleepRqPin), F(",0,"), String(_espStatusPin), ',', _statusLevel); bool success = gsmModem.waitResponse() == 1; - gsmModem.sendAT(F("+SLEEP=1")); + gsmModem.sendAT(GF("+SLEEP=1")); success &= gsmModem.waitResponse() == 1; return success; } @@ -167,9 +167,9 @@ bool EspressifESP8266::modemSleepFxn(void) else if (_modemSleepRqPin >= 0 && _dataPin < 0) { MS_DBG(F("Requesting light sleep for ESP8266")); - gsmModem.sendAT(F("+WAKEUPGPIO=1,"), String(_espSleepRqPin), F(",0")); + gsmModem.sendAT(GF("+WAKEUPGPIO=1,"), String(_espSleepRqPin), F(",0")); bool success = gsmModem.waitResponse() == 1; - gsmModem.sendAT(F("+SLEEP=1")); + gsmModem.sendAT(GF("+SLEEP=1")); success &= gsmModem.waitResponse() == 1; return success; } @@ -191,7 +191,7 @@ bool EspressifESP8266::extraModemSetup(void) // if (modemBaud > 57600) // { // _modemSerial->begin(modemBaud); - // gsmModem.sendAT(F("+UART_DEF=9600,8,1,0,0")); + // gsmModem.sendAT(GF("+UART_DEF=9600,8,1,0,0")); // gsmModem.waitResponse(); // _modemSerial->end(); // _modemSerial->begin(9600); diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp index 7dc52a7c2..e1c822379 100644 --- a/src/modems/SodaqUBeeR410M.cpp +++ b/src/modems/SodaqUBeeR410M.cpp @@ -130,7 +130,7 @@ bool SodaqUBeeR410M::extraModemSetup(void) gsmModem.init(); _modemName = gsmModem.getModemName(); // Set to only use LTE-M, which should cause connection more quickly - gsmModem.sendAT(F("+URAT=7")); + gsmModem.sendAT(GF("+URAT=7")); gsmModem.waitResponse(); return true; } From 9766266133472d34d190651d1bc7cbd9d4586d19 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 22 May 2019 16:14:50 -0400 Subject: [PATCH 47/88] case correction --- src/LoggerModem.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/LoggerModem.h b/src/LoggerModem.h index 8642dafdc..ef3388d00 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -275,17 +275,17 @@ class Modem_BatteryVoltage : public Variable public: Modem_BatteryVoltage(Sensor *parentSense, const char *uuid = "", - const char *varCode = "modemBatterymVolt") + const char *varCode = "modemBatterymV") : Variable(parentSense, (const uint8_t)MODEM_BATTERY_VOLT_VAR_NUM, (uint8_t)MODEM_BATTERY_VOLT_RESOLUTION, - "batteryVoltage", "milliVolt", + "batteryVoltage", "millivolt", varCode, uuid) {} Modem_BatteryVoltage() : Variable((const uint8_t)MODEM_BATTERY_VOLT_VAR_NUM, (uint8_t)MODEM_BATTERY_VOLT_RESOLUTION, - "batteryVoltage", "milliVolt", "modemBatterymVolt") + "batteryVoltage", "millivolt", "modemBatterymV") {} ~Modem_BatteryVoltage(){} }; From 72192f2d46daea0807a4f15880beb91442be7d10 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 22 May 2019 16:34:04 -0400 Subject: [PATCH 48/88] Missed flash strings --- examples/menu_a_la_carte/menu_a_la_carte.ino | 2 +- src/modems/DigiXBee3GBypass.cpp | 2 +- src/modems/DigiXBeeLTEBypass.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index d1c606fe7..0b142c8c5 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -199,7 +199,7 @@ const char *wifiPwd = "xxxxx"; // The password for connecting to WiFi, unnecess // // For any Digi Cellular XBee's // // NOTE: The u-blox based Digi XBee's (3G global and LTE-M global) -// // are more stable used in bypass mode (above) +// // are more stable used in bypass mode (below) // // The Telit based Digi XBees (LTE Cat1) can only use this mode. // #include // const long modemBaud = 9600; // All XBee's use 9600 by default diff --git a/src/modems/DigiXBee3GBypass.cpp b/src/modems/DigiXBee3GBypass.cpp index 2a813a249..0e2bbdf88 100644 --- a/src/modems/DigiXBee3GBypass.cpp +++ b/src/modems/DigiXBee3GBypass.cpp @@ -53,7 +53,7 @@ bool DigiXBee3GBypass::extraModemSetup(void) delay(1010); // Wait the required guard time before entering command mode MS_DBG(F("Putting XBee into command mode...")); gsmModem.streamWrite(GF("+++")); // enter command mode - if (success &= gsmModem.waitResponse(2000, F("OK\r")) == 1) + if (success &= gsmModem.waitResponse(2000, GF("OK\r")) == 1) { MS_DBG(F("Setting I/O Pins...")); // Set DIO8 to be used for sleep requests diff --git a/src/modems/DigiXBeeLTEBypass.cpp b/src/modems/DigiXBeeLTEBypass.cpp index 3f390d8f0..a35e62481 100644 --- a/src/modems/DigiXBeeLTEBypass.cpp +++ b/src/modems/DigiXBeeLTEBypass.cpp @@ -52,7 +52,7 @@ bool DigiXBeeLTEBypass::extraModemSetup(void) delay(1010); // Wait the required guard time before entering command mode MS_DBG(F("Putting XBee into command mode...")); gsmModem.streamWrite(GF("+++")); // enter command mode - if (success &= gsmModem.waitResponse(2000, F("OK\r")) == 1) + if (success &= gsmModem.waitResponse(2000, GF("OK\r")) == 1) { MS_DBG(F("Setting I/O Pins...")); // Set DIO8 to be used for sleep requests From aec109b4d8180bc26a5e1d72857b541b53aed41b Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 23 May 2019 13:06:29 -0400 Subject: [PATCH 49/88] Fixed UBeeR410, update gitignore --- .gitignore | 1 + src/modems/SodaqUBeeR410M.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index c2439a879..d3c9a2afa 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,7 @@ Temporary Items # Atom / PlatformIO .pioenvs .piolibdeps +.pio/* .clang_complete .gcc-flags.json lib/readme.txt diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp index e1c822379..c4b89198f 100644 --- a/src/modems/SodaqUBeeR410M.cpp +++ b/src/modems/SodaqUBeeR410M.cpp @@ -34,6 +34,8 @@ SodaqUBeeR410M::SodaqUBeeR410M(HardwareSerial* modemStream, gsmClient(gsmModem) { _apn = apn; + + _modemSerial = modemStream; } #else SodaqUBeeR410M::SodaqUBeeR410M(Stream* modemStream, @@ -56,8 +58,6 @@ SodaqUBeeR410M::SodaqUBeeR410M(Stream* modemStream, gsmClient(gsmModem) { _apn = apn; - - _modemSerial = modemStream; } #endif From 93123e3f951d601f952fef8dba1c52ce0580d4d5 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 23 May 2019 14:26:55 -0400 Subject: [PATCH 50/88] Fixed R410 to have right modem defined --- examples/menu_a_la_carte/menu_a_la_carte.ino | 15 ++++++++------- src/LoggerBase.cpp | 2 +- src/modems/SodaqUBeeR410M.h | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 0b142c8c5..e7410dc34 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -50,8 +50,8 @@ const int8_t buttonPin = 21; // MCU pin for a button to use to enter debugg const int8_t wakePin = A7; // MCU interrupt/alarm pin to wake from sleep // Set the wake pin to -1 if you do not want the main processor to sleep. // In a SAMD system where you are using the built-in rtc, set wakePin to 1 -const int8_t sdCardPwrPin = -1; // MCU SD card power pin (-1 if not applicable) -const int8_t sdCardSSPin = 12; // MCU SD card chip select/slave select pin (must be given!) +const int8_t sdCardPwrPin = -1; // MCU SD card power pin (-1 if not applicable) +const int8_t sdCardSSPin = 12; // MCU SD card chip select/slave select pin (must be given!) const int8_t sensorPowerPin = 22; // MCU pin controlling main sensor power (-1 if not applicable) // Create the main processor chip "sensor" - for general metadata @@ -219,9 +219,9 @@ const char *wifiPwd = "xxxxx"; // The password for connecting to WiFi, unnecess const long modemBaud = 9600; // All XBee's use 9600 by default const bool useCTSforStatus = true; // Flag to use the modem CTS pin for status DigiXBeeLTEBypass modemXBLTEB(&modemSerial, - modemVccPin, modemStatusPin, useCTSforStatus, - modemResetPin, modemSleepRqPin, - apn); + modemVccPin, modemStatusPin, useCTSforStatus, + modemResetPin, modemSleepRqPin, + apn); // Create an extra reference to the modem by a generic name (not necessary) DigiXBeeLTEBypass modem = modemXBLTEB; // ========================================================================== @@ -256,7 +256,7 @@ DigiXBeeLTEBypass modem = modemXBLTEB; // const long modemBaud = 115200; // Communication speed of the modem // // NOTE: This baud rate too fast for an 8MHz board, like the Mayfly! The module // // should be programmed to a slower baud rate or set to auto-baud using the -// // AT+UART_CUR or AT+UART_DEF command. +// // AT+UART_CUR or AT+UART_DEF command *before* attempting conrrol with this library. // // Pins for light sleep on the ESP8266. // // For power savings, I recommend NOT using these if it's possible to use deep sleep. // const int8_t espSleepRqPin = -1; // Pin ON THE ESP8266 to assign for light sleep request (-1 if not applicable) @@ -337,7 +337,8 @@ DigiXBeeLTEBypass modem = modemXBLTEB; // // every power loss, the module will return to the default baud rate of 115200. // // NOTE: 115200 is TOO FAST for an 8MHz Arduino. This library attempts to // // compensate by sending a baud rate change command in the wake function. -// // YMMV! +// // Because of this, 8MHz boards, LIKE THE MAYFLY, *MUST* use a HardwareSerial +// // instance as modemSerial. // SodaqUBeeR410M modemR410(&modemSerial, // modemVccPin, modemStatusPin, // modemResetPin, modemSleepRqPin, diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index 6ab10106f..64d4b2562 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -974,7 +974,7 @@ bool Logger::initializeSDCard(void) } else // skip everything else if there's no SD card, otherwise it might hang { - PRINTOUT(F("Successfully connected to SD Card with card/slave select on pin"), + MS_DBG(F("Successfully connected to SD Card with card/slave select on pin"), _SDCardSSPin); return true; } diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index 669e38774..e6d3d5559 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -20,7 +20,7 @@ #define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif -#define TINY_GSM_MODEM_UBLOX +#define TINY_GSM_MODEM_SARAR4 // V_INT becomes active mid-way through on-pulse #define R410M_STATUS_TIME_MS 0 From 80fa4c795275a286bf12bdf1b89d9e4024a379d1 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 23 May 2019 16:55:38 -0400 Subject: [PATCH 51/88] Slightly longer wait when rebooting to bypass --- src/modems/DigiXBee3GBypass.cpp | 6 +++--- src/modems/DigiXBeeLTEBypass.cpp | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modems/DigiXBee3GBypass.cpp b/src/modems/DigiXBee3GBypass.cpp index 0e2bbdf88..db83fc558 100644 --- a/src/modems/DigiXBee3GBypass.cpp +++ b/src/modems/DigiXBee3GBypass.cpp @@ -93,11 +93,11 @@ bool DigiXBee3GBypass::extraModemSetup(void) // Apply changes gsmModem.sendAT(GF("AC")); success &= gsmModem.waitResponse(GF("OK\r")) == 1; - // Force reset to actually enter bypass mode - this effectively exits bypass mode + // Force reset to actually enter bypass mode - this effectively exits command mode MS_DBG(F("Resetting the module to reboot in bypass mode...")); gsmModem.sendAT(GF("FR")); - success &= gsmModem.waitResponse(GF("OK\r")) == 1; - delay(200); // Allow the unit to reset + success &= gsmModem.waitResponse(5000L, GF("OK\r")) == 1; + delay(500); // Allow the unit to reset // re-initialize MS_DBG(F("Attempting to reconnect to the u-blox module...")); success &= gsmModem.init(); diff --git a/src/modems/DigiXBeeLTEBypass.cpp b/src/modems/DigiXBeeLTEBypass.cpp index a35e62481..d29867ea1 100644 --- a/src/modems/DigiXBeeLTEBypass.cpp +++ b/src/modems/DigiXBeeLTEBypass.cpp @@ -104,11 +104,11 @@ bool DigiXBeeLTEBypass::extraModemSetup(void) // Apply changes gsmModem.sendAT(GF("AC")); success &= gsmModem.waitResponse(GF("OK\r")) == 1; - // Force reset to actually enter bypass mode - this effectively exits bypass mode + // Force reset to actually enter bypass mode - this effectively exits command mode MS_DBG(F("Resetting the module to reboot in bypass mode...")); gsmModem.sendAT(GF("FR")); - success &= gsmModem.waitResponse(GF("OK\r")) == 1; - delay(200); // Allow the unit to reset + success &= gsmModem.waitResponse(5000L, GF("OK\r")) == 1; + delay(500); // Allow the unit to reset // re-initialize MS_DBG(F("Attempting to reconnect to the u-blox module...")); success &= gsmModem.init(); From 454425091757921352ac760a33277a380b64a359 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 23 May 2019 18:43:15 -0400 Subject: [PATCH 52/88] Longer wait to get NIST for XBee --- .gitignore | 3 +++ src/modems/DigiXBeeWifi.h | 2 +- src/modems/LoggerModemMacros.h | 6 ++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index d3c9a2afa..f56844074 100644 --- a/.gitignore +++ b/.gitignore @@ -52,6 +52,9 @@ Temporary Items # Atom / PlatformIO .pioenvs .piolibdeps +.pio +.pio/libdeps +.pio/build .pio/* .clang_complete .gcc-flags.json diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index 484dd3d5e..031b156fd 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -28,7 +28,7 @@ #include "DigiXBee.h" #include "TinyGsmClient.h" -#ifdef defineMS_DIGIXBEEWIFI_DEBUG_DEEP +#ifdef MS_DIGIXBEEWIFI_DEBUG_DEEP #include #endif diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 3d97d36a1..44ad34eaf 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -347,10 +347,12 @@ uint32_t specificModem::getNISTTime(void) \ /* XBee's address lookup falters on time.nist.gov */ \ IPAddress ip(129, 6, 15, 30); \ connectionMade = gsmClient.connect(ip, 37); \ + /* Wait again so NIST doesn't refuse us! */ \ + delay(4000L); \ /* Need to send something before connection is made */ \ - gsmClient.print('!'); \ + gsmClient.println('!'); \ /* Need this delay! Can get away with 50, but 100 is safer. */ \ - delay(100); \ + /*delay(100);*/ \ } \ else connectionMade = gsmClient.connect("time.nist.gov", 37); \ \ From 9bc76d2cd9b370703d4e94fca933850a63e35933 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 23 May 2019 18:48:31 -0400 Subject: [PATCH 53/88] One less space, one less byte of data --- src/dataPublisherBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dataPublisherBase.cpp b/src/dataPublisherBase.cpp index c1fbe8c36..0cde30006 100644 --- a/src/dataPublisherBase.cpp +++ b/src/dataPublisherBase.cpp @@ -13,7 +13,7 @@ char dataPublisher::txBuffer[MS_SEND_BUFFER_SIZE] = {'\0'}; // Basic chunks of HTTP const char *dataPublisher::getHeader = "GET "; const char *dataPublisher::postHeader = "POST "; -const char *dataPublisher::HTTPtag = " HTTP/1.1"; +const char *dataPublisher::HTTPtag = " HTTP/1.1"; const char *dataPublisher::hostHeader = "\r\nHost: "; // Constructors From cf0520c3c839521ffa0199e84106f01498ca89f1 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 23 May 2019 19:03:50 -0400 Subject: [PATCH 54/88] Added function for a modem hard reset - TBD when and where to use --- src/LoggerModem.cpp | 16 +++++++++++++++- src/LoggerModem.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index 617b7a212..d13a748b5 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -60,6 +60,18 @@ void loggerModem::modemLEDOff(void) } +void loggerModem::modemHardReset(void) +{ + if (_modemResetPin >= 0) + { + MS_DBG(F("Doing a hard reset!")); + digitalWrite(_modemResetPin, LOW); + delay(1); + digitalWrite(_modemResetPin, LOW); + } +} + + String loggerModem::getSensorName(void) { return _modemName; } @@ -191,11 +203,13 @@ bool loggerModem::wake(void) // Re-check the status pin // Only works if the status pin comes on immediately - if (_dataPin > 0 && _statusTime_ms == 0 && digitalRead(_dataPin) != _statusLevel) + if (_dataPin >= 0 && _statusTime_ms == 0 && digitalRead(_dataPin) != _statusLevel) { MS_DBG(F("Status pin level on"), getSensorName(), F("is"), digitalRead(_dataPin), F("indicating it is off!")); success = false; + modemHardReset(); + success = digitalRead(_dataPin) == _statusLevel; } if (success) diff --git a/src/LoggerModem.h b/src/LoggerModem.h index ef3388d00..3c0985b07 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -147,6 +147,7 @@ class loggerModem : public Sensor // Other helper functions void modemLEDOn(void); void modemLEDOff(void); + void modemHardReset(void); virtual bool didATRespond(void) = 0; virtual bool isInternetAvailable(void) = 0; virtual bool verifyMeasurementComplete(bool debug = false) = 0; From 86352baa17c91ec114c82cdb58efbcda05393c7a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 May 2019 11:30:22 -0400 Subject: [PATCH 55/88] Fixed hard reset --- src/LoggerModem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index d13a748b5..986861db1 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -66,8 +66,8 @@ void loggerModem::modemHardReset(void) { MS_DBG(F("Doing a hard reset!")); digitalWrite(_modemResetPin, LOW); - delay(1); - digitalWrite(_modemResetPin, LOW); + delay(200); + digitalWrite(_modemResetPin, HIGH); } } From 479362f62c6f849d9c5316b0b7eb396bc4e85709 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 May 2019 16:18:35 -0400 Subject: [PATCH 56/88] Remembered to initialize client after modem --- src/modems/DigiXBee.h | 1 - src/modems/DigiXBee3GBypass.cpp | 1 + src/modems/DigiXBee3GBypass.h | 1 - src/modems/DigiXBeeCellularTransparent.cpp | 3 ++- src/modems/DigiXBeeCellularTransparent.h | 1 - src/modems/DigiXBeeLTEBypass.cpp | 1 + src/modems/DigiXBeeLTEBypass.h | 1 - src/modems/DigiXBeeWifi.cpp | 3 ++- src/modems/DigiXBeeWifi.h | 1 - src/modems/EspressifESP8266.cpp | 2 ++ src/modems/EspressifESP8266.h | 1 - src/modems/QuectelBG96.cpp | 1 + src/modems/QuectelBG96.h | 1 - src/modems/SIMComSIM7000.cpp | 1 + src/modems/SIMComSIM7000.h | 1 - src/modems/SIMComSIM800.cpp | 1 + src/modems/SIMComSIM800.h | 1 - src/modems/SequansMonarch.cpp | 1 + src/modems/SequansMonarch.h | 1 - src/modems/Sodaq2GBeeR6.cpp | 1 + src/modems/Sodaq2GBeeR6.h | 1 - src/modems/SodaqUBeeR410M.cpp | 1 + src/modems/SodaqUBeeR410M.h | 1 - src/modems/SodaqUBeeU201.cpp | 1 + src/modems/SodaqUBeeU201.h | 1 - 25 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/modems/DigiXBee.h b/src/modems/DigiXBee.h index 42519ac1d..8196fbf61 100644 --- a/src/modems/DigiXBee.h +++ b/src/modems/DigiXBee.h @@ -16,7 +16,6 @@ #ifdef MS_DIGIXBEE_DEBUG #define MS_DEBUGGING_STD "DigiXBee" -#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif // Time after turn on until the status pin is active - total WAG diff --git a/src/modems/DigiXBee3GBypass.cpp b/src/modems/DigiXBee3GBypass.cpp index db83fc558..43d5fb1e1 100644 --- a/src/modems/DigiXBee3GBypass.cpp +++ b/src/modems/DigiXBee3GBypass.cpp @@ -101,6 +101,7 @@ bool DigiXBee3GBypass::extraModemSetup(void) // re-initialize MS_DBG(F("Attempting to reconnect to the u-blox module...")); success &= gsmModem.init(); + gsmClient.init(&gsmModem); _modemName = gsmModem.getModemName(); } else success = false; diff --git a/src/modems/DigiXBee3GBypass.h b/src/modems/DigiXBee3GBypass.h index 58db914f7..fe8a830f9 100644 --- a/src/modems/DigiXBee3GBypass.h +++ b/src/modems/DigiXBee3GBypass.h @@ -17,7 +17,6 @@ #ifdef MS_DIGIXBEE3GBYPASS_DEBUG #define MS_DEBUGGING_STD "DigiXBee3GBypass" -#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif #define TINY_GSM_MODEM_UBLOX diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index e67d73cd3..eb5cfa07d 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -50,7 +50,8 @@ bool DigiXBeeCellularTransparent::extraModemSetup(void) { bool success = true; MS_DBG(F("Initializing the XBee...")); - success &= gsmModem.init(); // initialize + success &= gsmModem.init(); + gsmClient.init(&gsmModem); _modemName = gsmModem.getModemName(); MS_DBG(F("Putting XBee into command mode...")); if (gsmModem.commandMode()) diff --git a/src/modems/DigiXBeeCellularTransparent.h b/src/modems/DigiXBeeCellularTransparent.h index 94ec971bb..b7b76aeaa 100644 --- a/src/modems/DigiXBeeCellularTransparent.h +++ b/src/modems/DigiXBeeCellularTransparent.h @@ -17,7 +17,6 @@ #ifdef MS_DIGIXBEECELLULARTRANSPARENT_DEBUG #define MS_DEBUGGING_STD "DigiXBeeCellularTransparent" -#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif #define TINY_GSM_MODEM_XBEE // Select for Digi brand WiFi or Cellular XBee's diff --git a/src/modems/DigiXBeeLTEBypass.cpp b/src/modems/DigiXBeeLTEBypass.cpp index d29867ea1..ed7cd5a42 100644 --- a/src/modems/DigiXBeeLTEBypass.cpp +++ b/src/modems/DigiXBeeLTEBypass.cpp @@ -112,6 +112,7 @@ bool DigiXBeeLTEBypass::extraModemSetup(void) // re-initialize MS_DBG(F("Attempting to reconnect to the u-blox module...")); success &= gsmModem.init(); + gsmClient.init(&gsmModem); _modemName = gsmModem.getModemName(); } else success = false; diff --git a/src/modems/DigiXBeeLTEBypass.h b/src/modems/DigiXBeeLTEBypass.h index d9cf9100a..d5513cd36 100644 --- a/src/modems/DigiXBeeLTEBypass.h +++ b/src/modems/DigiXBeeLTEBypass.h @@ -17,7 +17,6 @@ #ifdef MS_DIGIXBEELTEBYPASS_DEBUG #define MS_DEBUGGING_STD "DigiXBeeLTEBypass" -#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif #define TINY_GSM_MODEM_SARAR4 diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index bf8b1cf00..e9b810111 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -51,7 +51,8 @@ bool DigiXBeeWifi::extraModemSetup(void) { bool success = true; MS_DBG(F("Initializing the XBee...")); - success &= gsmModem.init(); // initialize + success &= gsmModem.init(); + gsmClient.init(&gsmModem); _modemName = gsmModem.getModemName(); MS_DBG(F("Putting XBee into command mode...")); if (gsmModem.commandMode()) diff --git a/src/modems/DigiXBeeWifi.h b/src/modems/DigiXBeeWifi.h index 031b156fd..aa156da4e 100644 --- a/src/modems/DigiXBeeWifi.h +++ b/src/modems/DigiXBeeWifi.h @@ -17,7 +17,6 @@ #ifdef MS_DIGIXBEEWIFI_DEBUG #define MS_DEBUGGING_STD "DigiXBeeWifi" -#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif #define TINY_GSM_MODEM_XBEE // Select for Digi brand WiFi or Cellular XBee's diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index 0196dc222..63a45daa3 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -88,6 +88,7 @@ bool EspressifESP8266::ESPwaitForBoot(void) success &= gsmModem.waitResponse() == 1; // re-run init to set mux and station mode success &= gsmModem.init(); + gsmClient.init(&gsmModem); } return success; } @@ -184,6 +185,7 @@ bool EspressifESP8266::modemSleepFxn(void) bool EspressifESP8266::extraModemSetup(void) { gsmModem.init(); + gsmClient.init(&gsmModem); _modemName = gsmModem.getModemName(); // Slow down the baud rate for slow processors - and save the change to // the ESP's non-volatile memory so we don't have to do it every time diff --git a/src/modems/EspressifESP8266.h b/src/modems/EspressifESP8266.h index 3c4095a74..76085cedc 100644 --- a/src/modems/EspressifESP8266.h +++ b/src/modems/EspressifESP8266.h @@ -19,7 +19,6 @@ #ifdef MS_ESPRESSIFESP8266_DEBUG #define MS_DEBUGGING_STD "EspressifESP8266" -#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif #define TINY_GSM_MODEM_ESP8266 diff --git a/src/modems/QuectelBG96.cpp b/src/modems/QuectelBG96.cpp index 0e0668532..e8f4f825e 100644 --- a/src/modems/QuectelBG96.cpp +++ b/src/modems/QuectelBG96.cpp @@ -83,6 +83,7 @@ bool QuectelBG96::modemSleepFxn(void) bool QuectelBG96::extraModemSetup(void) { gsmModem.init(); + gsmClient.init(&gsmModem); _modemName = gsmModem.getModemName(); return true; } diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index 906f6f209..e8174d42b 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -18,7 +18,6 @@ #ifdef MS_QUECTELBG96_DEBUG #define MS_DEBUGGING_STD "QuectelBG96" -#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif #define TINY_GSM_MODEM_BG96 diff --git a/src/modems/SIMComSIM7000.cpp b/src/modems/SIMComSIM7000.cpp index ba5d12074..071795669 100644 --- a/src/modems/SIMComSIM7000.cpp +++ b/src/modems/SIMComSIM7000.cpp @@ -84,6 +84,7 @@ bool SIMComSIM7000::modemSleepFxn(void) bool SIMComSIM7000::extraModemSetup(void) { gsmModem.init(); + gsmClient.init(&gsmModem); _modemName = gsmModem.getModemName(); return true; } diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h index f6d37c251..a73bea8de 100644 --- a/src/modems/SIMComSIM7000.h +++ b/src/modems/SIMComSIM7000.h @@ -17,7 +17,6 @@ #ifdef MS_SIMCOMSIM7000_DEBUG #define MS_DEBUGGING_STD "SIMComSIM7000" -#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif #define TINY_GSM_MODEM_SIM7000 diff --git a/src/modems/SIMComSIM800.cpp b/src/modems/SIMComSIM800.cpp index bd6ab5408..0bdeb9cc0 100644 --- a/src/modems/SIMComSIM800.cpp +++ b/src/modems/SIMComSIM800.cpp @@ -86,6 +86,7 @@ bool SIMComSIM800::modemSleepFxn(void) bool SIMComSIM800::extraModemSetup(void) { gsmModem.init(); + gsmClient.init(&gsmModem); _modemName = gsmModem.getModemName(); return true; } diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index 23477d914..37501ed81 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -19,7 +19,6 @@ #ifdef MS_SIMCOMSIM800_DEBUG #define MS_DEBUGGING_STD "SIMComSIM800" -#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif #define TINY_GSM_MODEM_SIM800 diff --git a/src/modems/SequansMonarch.cpp b/src/modems/SequansMonarch.cpp index 09a74b053..b8feba849 100644 --- a/src/modems/SequansMonarch.cpp +++ b/src/modems/SequansMonarch.cpp @@ -91,6 +91,7 @@ bool SequansMonarch::modemSleepFxn(void) bool SequansMonarch::extraModemSetup(void) { gsmModem.init(); + gsmClient.init(&gsmModem); _modemName = gsmModem.getModemName(); return true; } diff --git a/src/modems/SequansMonarch.h b/src/modems/SequansMonarch.h index f8a3b63eb..4ed8f7627 100644 --- a/src/modems/SequansMonarch.h +++ b/src/modems/SequansMonarch.h @@ -18,7 +18,6 @@ #ifdef MS_SEQUANSMONARCH_DEBUG #define MS_DEBUGGING_STD "SequansMonarch" -#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif #define TINY_GSM_MODEM_SEQUANS_MONARCH diff --git a/src/modems/Sodaq2GBeeR6.cpp b/src/modems/Sodaq2GBeeR6.cpp index 1afa755e7..f6f5cbe89 100644 --- a/src/modems/Sodaq2GBeeR6.cpp +++ b/src/modems/Sodaq2GBeeR6.cpp @@ -72,6 +72,7 @@ bool Sodaq2GBeeR6::modemSleepFxn(void) bool Sodaq2GBeeR6::extraModemSetup(void) { gsmModem.init(); + gsmClient.init(&gsmModem); _modemName = gsmModem.getModemName(); return true; } diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h index 271797e3b..25c9ea501 100644 --- a/src/modems/Sodaq2GBeeR6.h +++ b/src/modems/Sodaq2GBeeR6.h @@ -18,7 +18,6 @@ #ifdef MS_SODAQ2GBEER6_DEBUG #define MS_DEBUGGING_STD "Sodaq2GBeeR6" -#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif #define TINY_GSM_MODEM_SIM800 diff --git a/src/modems/SodaqUBeeR410M.cpp b/src/modems/SodaqUBeeR410M.cpp index c4b89198f..c4d2fe22e 100644 --- a/src/modems/SodaqUBeeR410M.cpp +++ b/src/modems/SodaqUBeeR410M.cpp @@ -128,6 +128,7 @@ bool SodaqUBeeR410M::modemSleepFxn(void) bool SodaqUBeeR410M::extraModemSetup(void) { gsmModem.init(); + gsmClient.init(&gsmModem); _modemName = gsmModem.getModemName(); // Set to only use LTE-M, which should cause connection more quickly gsmModem.sendAT(GF("+URAT=7")); diff --git a/src/modems/SodaqUBeeR410M.h b/src/modems/SodaqUBeeR410M.h index e6d3d5559..61f71de44 100644 --- a/src/modems/SodaqUBeeR410M.h +++ b/src/modems/SodaqUBeeR410M.h @@ -17,7 +17,6 @@ #ifdef MS_SODAQUBEER410M_DEBUG #define MS_DEBUGGING_STD "SodaqUBeeR410M" -#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif #define TINY_GSM_MODEM_SARAR4 diff --git a/src/modems/SodaqUBeeU201.cpp b/src/modems/SodaqUBeeU201.cpp index e2e76507c..81d3edf8d 100644 --- a/src/modems/SodaqUBeeU201.cpp +++ b/src/modems/SodaqUBeeU201.cpp @@ -92,6 +92,7 @@ bool SodaqUBeeU201::modemSleepFxn(void) bool SodaqUBeeU201::extraModemSetup(void) { gsmModem.init(); + gsmClient.init(&gsmModem); _modemName = gsmModem.getModemName(); return true; } diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index 72ab28965..6971faa12 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -17,7 +17,6 @@ #ifdef MS_SODAQUBEEU201_DEBUG #define MS_DEBUGGING_STD "SodaqUBeeU201" -#define TINY_GSM_DEBUG DEBUGGING_SERIAL_OUTPUT #endif #define TINY_GSM_MODEM_UBLOX From 32c36ab47b715ec1ecf5c83c826c649f7af4dbd1 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 May 2019 19:24:46 -0400 Subject: [PATCH 57/88] Fix other high low high pulses --- src/modems/QuectelBG96.cpp | 2 +- src/modems/SIMComSIM7000.cpp | 2 +- src/modems/SIMComSIM800.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modems/QuectelBG96.cpp b/src/modems/QuectelBG96.cpp index e8f4f825e..1f41bd3a7 100644 --- a/src/modems/QuectelBG96.cpp +++ b/src/modems/QuectelBG96.cpp @@ -60,7 +60,7 @@ bool QuectelBG96::modemWakeFxn(void) { digitalWrite(_modemSleepRqPin, LOW); delay(160); // ≥100ms - digitalWrite(_modemSleepRqPin, LOW); + digitalWrite(_modemSleepRqPin, HIGH); } return true; } diff --git a/src/modems/SIMComSIM7000.cpp b/src/modems/SIMComSIM7000.cpp index 071795669..a933010f0 100644 --- a/src/modems/SIMComSIM7000.cpp +++ b/src/modems/SIMComSIM7000.cpp @@ -60,7 +60,7 @@ bool SIMComSIM7000::modemWakeFxn(void) MS_DBG(F("Sending a wake-up pulse on pin"), _modemSleepRqPin, F("for SIM7000")); digitalWrite(_modemSleepRqPin, LOW); delay(1100); // >1s - digitalWrite(_modemSleepRqPin, LOW); + digitalWrite(_modemSleepRqPin, HIGH); } return true; } diff --git a/src/modems/SIMComSIM800.cpp b/src/modems/SIMComSIM800.cpp index 0bdeb9cc0..7a25f94bc 100644 --- a/src/modems/SIMComSIM800.cpp +++ b/src/modems/SIMComSIM800.cpp @@ -62,7 +62,7 @@ bool SIMComSIM800::modemWakeFxn(void) MS_DBG(F("Sending a wake-up pulse on pin"), _modemSleepRqPin, F("for SIM800")); digitalWrite(_modemSleepRqPin, LOW); delay(1100); // >1s - digitalWrite(_modemSleepRqPin, LOW); + digitalWrite(_modemSleepRqPin, HIGH); } return true; } From 9f7bee773e5a2bfdca8ace4acba8188ec002a202 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 May 2019 19:24:56 -0400 Subject: [PATCH 58/88] Fix when to run wake --- src/LoggerModem.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index 986861db1..5cfb118df 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -183,13 +183,9 @@ bool loggerModem::wake(void) // Check the status pin and wake bits before running wake function // Don't want to accidently pulse an already on modem to off - if ( bitRead(_sensorStatus, 4) && !_alwaysRunWake) - { - MS_DBG(getSensorName(), F("has already been woken up! Will not run wake function.")); - } // NOTE: It's possible that the status pin is on, but the modem is actually // mid-shutdown. In that case, we'll mistakenly skip re-waking it. - else if (_dataPin >= 0 && digitalRead(_dataPin) == _statusLevel && !_alwaysRunWake) + if (_dataPin >= 0 && digitalRead(_dataPin) == _statusLevel && !_alwaysRunWake) { MS_DBG(getSensorName(), F("was already on! (status pin level = "), _statusLevel, F(") Will not run wake function.")); From 2d92f6d8d18f738b99757075f848437d8dab02c3 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 May 2019 22:39:41 -0400 Subject: [PATCH 59/88] Slightly longer waits for status --- library.json | 3 +-- src/LoggerModem.cpp | 28 ++++++++++++++++------------ src/LoggerModem.h | 4 ++-- src/modems/LoggerModemMacros.h | 7 ++----- src/modems/QuectelBG96.h | 4 ++-- src/modems/SIMComSIM7000.h | 2 +- src/modems/SIMComSIM800.h | 8 +++++--- src/modems/SequansMonarch.h | 2 +- src/modems/Sodaq2GBeeR6.h | 2 +- src/modems/SodaqUBeeU201.h | 2 +- 10 files changed, 32 insertions(+), 30 deletions(-) diff --git a/library.json b/library.json index 90db4275d..8e6505c75 100644 --- a/library.json +++ b/library.json @@ -299,8 +299,7 @@ { "name": "TinyGSM", "version": "https://github.com/EnviroDIY/TinyGSM.git", - "version_commit": "84bfb40504f83aa49fd8eb4c3c855e4c00449896", - "version_note": "=0.6.1", + "version_note": "=0.7.8", "note": "A small Arduino library for GPRS modules.", "authors": [ "Volodymyr Shymanskyy", diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index 5cfb118df..241e3f857 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -323,9 +323,9 @@ bool loggerModem::addSingleMeasurementResult(void) /* Initialize float variable */ int16_t percent = -9999; int16_t rssi = -9999; - uint8_t state = -99; + uint8_t state = 99; int8_t bpercent = -99; - uint16_t volt = -9999; + uint16_t volt = 9999; float temp = -9999; float fstate = -9999; float fbpercent = -9999; @@ -340,20 +340,24 @@ bool loggerModem::addSingleMeasurementResult(void) /* modem response, and a real response from the modem of no service/signal. */ /* The TinyGSM getSignalQuality function returns the same "no signal" */ /* value (99 CSQ or 0 RSSI) in all 3 cases. */ - MS_DBG(F("Getting signal quality:")); + MS_DBG(F("Asking modem to give signal quality:")); success &= getModemSignalQuality(rssi, percent); - MS_DBG(F("RSSI:"), rssi); - MS_DBG(F("Percent signal strength:"), percent); + // MS_DBG(F("RSSI:"), rssi); + // MS_DBG(F("Percent signal strength:"), percent); MS_DBG(F("Getting battery info, if possible:")); success &= getModemBatteryStats(state, bpercent, volt); - MS_DBG(F("Battery charge state:"), state); - MS_DBG(F("Battery percentage:"), bpercent); - MS_DBG(F("Battery voltage:"), volt); // convert responses to floats - if (state != 99) fstate = (float)state; - if (bpercent != 99) fbpercent = (float)bpercent; - if (volt != 9999) fvolt = (float)volt; + if (success) + { + if (state != 99) fstate = (float)state; + if (bpercent != -99) fbpercent = (float)bpercent; + if (volt != 9999) fvolt = (float)volt; + MS_DBG(F("Modem battery charge state:"), fstate); + MS_DBG(F("Modem battery percentage:"), fbpercent); + MS_DBG(F("Modem battery voltage:"), fvolt); + } + else MS_DBG(F("Battery information not returned!")); MS_DBG(F("Getting chip temperature, if possible:")); temp = getModemTemperature(); @@ -424,7 +428,7 @@ void loggerModem::modemPowerUp(void) else { MS_DBG(F("Power to"), getSensorName(), F("is not controlled by this library.")); - // Mark the power-on time, just in case it had not been marked + // Mark the power-on time, just in case it had not been marked if (_millisPowerOn == 0) _millisPowerOn = millis(); } // Set the status bit for sensor power attempt (bit 1) and success (bit 2) diff --git a/src/LoggerModem.h b/src/LoggerModem.h index 3c0985b07..26c5ecf8a 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -297,8 +297,8 @@ class Modem_Temp : public Variable { public: Modem_Temp(Sensor *parentSense, - const char *uuid = "", - const char *varCode = "modemTemp") + const char *uuid = "", + const char *varCode = "modemTemp") : Variable(parentSense, (const uint8_t)MODEM_TEMPERATURE_VAR_NUM, (uint8_t)MODEM_TEMPERATURE_RESOLUTION, diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 44ad34eaf..051d354d2 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -142,9 +142,6 @@ bool specificModem::getModemSignalQuality(int16_t &rssi, int16_t &percent) \ /* Convert signal quality to RSSI, if necessary */ \ MS_MODEM_CALC_SIGNAL_RSSI; \ MS_MODEM_CALC_SIGNAL_PERCENT; \ -\ - MS_DBG(F("RSSI:"), rssi); \ - MS_DBG(F("Percent signal strength:"), percent); \ \ return true; \ } @@ -153,7 +150,7 @@ bool specificModem::getModemSignalQuality(int16_t &rssi, int16_t &percent) \ #define MS_MODEM_GET_MODEM_BATTERY_AVAILABLE(specificModem) \ bool specificModem::getModemBatteryStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) \ { \ - MS_DBG(F("Getting battery voltage:")); \ + MS_DBG(F("Getting modem battery data:")); \ return gsmModem.getBattStats(chargeState, percent, milliVolts); \ } @@ -161,7 +158,7 @@ bool specificModem::getModemBatteryStats(uint8_t &chargeState, int8_t &percent, #define MS_MODEM_GET_MODEM_BATTERY_NA(specificModem) \ bool specificModem::getModemBatteryStats(uint8_t &chargeState, int8_t &percent, uint16_t &milliVolts) \ { \ - MS_DBG(F("This modem doesn't return battery infromation!")); \ + MS_DBG(F("This modem doesn't return battery information!")); \ return false; \ } diff --git a/src/modems/QuectelBG96.h b/src/modems/QuectelBG96.h index e8174d42b..ad92ed498 100644 --- a/src/modems/QuectelBG96.h +++ b/src/modems/QuectelBG96.h @@ -22,8 +22,8 @@ #define TINY_GSM_MODEM_BG96 -// Time after end pulse until status pin becomes active -#define BG96_STATUS_TIME_MS 4800L +// Time after end pulse until status pin becomes active - 4.8s +#define BG96_STATUS_TIME_MS 5000L // > 2 sec #define BG96_DISCONNECT_TIME_MS 5000L diff --git a/src/modems/SIMComSIM7000.h b/src/modems/SIMComSIM7000.h index a73bea8de..ecec1a39e 100644 --- a/src/modems/SIMComSIM7000.h +++ b/src/modems/SIMComSIM7000.h @@ -22,7 +22,7 @@ #define TINY_GSM_MODEM_SIM7000 // Time after end pulse until status pin becomes active (>4.5sec) -#define SIM7000_STATUS_TIME_MS 4500L +#define SIM7000_STATUS_TIME_MS 5000L // power down (gracefully) takes 1.8-6.9 sec #define SIM7000_DISCONNECT_TIME_MS 7000L diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index 37501ed81..6be7030ed 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -14,7 +14,7 @@ #define SIMComSIM800_h // Debugging Statement -// #define MS_SIMCOMSIM800_DEBUG +#define MS_SIMCOMSIM800_DEBUG // #define MS_SIMCOMSIM800_DEBUG_DEEP #ifdef MS_SIMCOMSIM800_DEBUG @@ -23,8 +23,10 @@ #define TINY_GSM_MODEM_SIM800 -// Time after end pulse until status pin becomes active (>3sec from start of 1s pulse) -#define SIM800_STATUS_TIME_MS 2000 +// Time after end pulse until status pin becomes active +// SIM800 - >3sec from start of 1s pulse +// SIM900 - >2.2sec from end of pulse +#define SIM800_STATUS_TIME_MS 2500 // power down (gracefully) takes >3sec // (Giving 15sec for shutdown in case it is not monitored.) #define SIM800_DISCONNECT_TIME_MS 15000L diff --git a/src/modems/SequansMonarch.h b/src/modems/SequansMonarch.h index 4ed8f7627..573e28fd1 100644 --- a/src/modems/SequansMonarch.h +++ b/src/modems/SequansMonarch.h @@ -23,7 +23,7 @@ #define TINY_GSM_MODEM_SEQUANS_MONARCH // ?? Undocumented -#define MONARCH_STATUS_TIME_MS 50 +#define MONARCH_STATUS_TIME_MS 500 // ?? Undocumented (Giving 15sec here in case it is not monitored.) #define MONARCH_DISCONNECT_TIME_MS 15000L diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h index 25c9ea501..862efefcd 100644 --- a/src/modems/Sodaq2GBeeR6.h +++ b/src/modems/Sodaq2GBeeR6.h @@ -23,7 +23,7 @@ #define TINY_GSM_MODEM_SIM800 // Time after end pulse until status pin becomes active (>3sec from start of 1s pulse) -#define SIM800_STATUS_TIME_MS 2000 +#define SIM800_STATUS_TIME_MS 2500 // power down (gracefully) takes >3sec // (Giving 15sec for shutdown in case it is not monitored.) #define SIM800_DISCONNECT_TIME_MS 15000L diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index 6971faa12..42a151b8b 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -23,7 +23,7 @@ // Time after end pulse until V_INT becomes active // Unspecified in documentation! Taking value from Lisa U2 -#define U201_STATUS_TIME_MS 35 +#define U201_STATUS_TIME_MS 100 // Power down time "can largely vary depending // on the application / network settings and the concurrent module // activities." Vint/status pin should be monitored and power not withdrawn From bf667dc33ef7e48a38fd55a9adc9579331c344c4 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Fri, 24 May 2019 22:44:39 -0400 Subject: [PATCH 60/88] Version bump --- examples/DRWI_CitSci/DRWI_CitSci.ino | 4 ++-- examples/DRWI_LTE/DRWI_LTE.ino | 4 ++-- examples/DRWI_NoCellular/DRWI_NoCellular.ino | 4 ++-- examples/baro_rho_correction/baro_rho_correction.ino | 4 ++-- examples/data_saving/data_saving.ino | 4 ++-- examples/double_logger/double_logger.ino | 4 ++-- examples/logging_to_MMW/logging_to_MMW.ino | 4 ++-- examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino | 4 ++-- examples/menu_a_la_carte/menu_a_la_carte.ino | 4 ++-- examples/simple_logging/simple_logging.ino | 4 ++-- .../simple_logging_LearnEnviroDIY.ino | 4 ++-- examples/single_sensor/single_sensor.ino | 4 ++-- library.json | 2 +- library.properties | 2 +- src/ModSensorDebugger.h | 2 +- 15 files changed, 27 insertions(+), 27 deletions(-) diff --git a/examples/DRWI_CitSci/DRWI_CitSci.ino b/examples/DRWI_CitSci/DRWI_CitSci.ino index 6460b2f8b..18e785e49 100644 --- a/examples/DRWI_CitSci/DRWI_CitSci.ino +++ b/examples/DRWI_CitSci/DRWI_CitSci.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.0 +This example sketch is written for ModularSensors library version 0.22.1 This sketch is an example of logging data to an SD card and sending the data to both the EnviroDIY data portal as should be used by groups involved with @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.0"; +const char *libraryVersion = "0.22.1"; // The name of this file const char *sketchName = "DWRI_CitSci.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/DRWI_LTE/DRWI_LTE.ino b/examples/DRWI_LTE/DRWI_LTE.ino index a8aa3bffa..11b544140 100644 --- a/examples/DRWI_LTE/DRWI_LTE.ino +++ b/examples/DRWI_LTE/DRWI_LTE.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.0 +This example sketch is written for ModularSensors library version 0.22.1 This sketch is an example of logging data to an SD card and sending the data to both the EnviroDIY data portal as should be used by groups involved with @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.0"; +const char *libraryVersion = "0.22.1"; // The name of this file const char *sketchName = "DRWI_LTE.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/DRWI_NoCellular/DRWI_NoCellular.ino b/examples/DRWI_NoCellular/DRWI_NoCellular.ino index 54ea0b628..fd469cb80 100644 --- a/examples/DRWI_NoCellular/DRWI_NoCellular.ino +++ b/examples/DRWI_NoCellular/DRWI_NoCellular.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.0 +This example sketch is written for ModularSensors library version 0.22.1 This sketch is an example of logging data to an SD card as should be used by groups involved with The William Penn Foundation's Delaware River Watershed @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.0"; +const char *libraryVersion = "0.22.1"; // The name of this file const char *sketchName = "DRWI_NoCellular.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/baro_rho_correction/baro_rho_correction.ino b/examples/baro_rho_correction/baro_rho_correction.ino index 99b41e1b6..45154704f 100644 --- a/examples/baro_rho_correction/baro_rho_correction.ino +++ b/examples/baro_rho_correction/baro_rho_correction.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.0 +This example sketch is written for ModularSensors library version 0.22.1 This sketch is an example of logging data to an SD card and sending the data to the EnviroDIY data portal. @@ -27,7 +27,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.0"; +const char *libraryVersion = "0.22.1"; // The name of this file const char *sketchName = "baro_rho_correction.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/data_saving/data_saving.ino b/examples/data_saving/data_saving.ino index 1b4e7a486..837bbf4f7 100644 --- a/examples/data_saving/data_saving.ino +++ b/examples/data_saving/data_saving.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.0 +This example sketch is written for ModularSensors library version 0.22.1 This sketch is an example of logging data to an SD card and sending only a portion of that data to the EnviroDIY data portal. @@ -27,7 +27,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.0"; +const char *libraryVersion = "0.22.1"; // The name of this file const char *sketchName = "data_saving.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/double_logger/double_logger.ino b/examples/double_logger/double_logger.ino index dffb73e52..5a22e39b7 100644 --- a/examples/double_logger/double_logger.ino +++ b/examples/double_logger/double_logger.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.0 +This example sketch is written for ModularSensors library version 0.22.1 This sketch is an example of logging data from different variables at two different logging intervals. This example uses more of the manual functions @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.0"; +const char *libraryVersion = "0.22.1"; // The name of this file const char *sketchName = "double_logger.ino"; // Logger ID - we're only using one logger ID for both "loggers" diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index 34dc4dff6..a0b82d8fb 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.0 +This example sketch is written for ModularSensors library version 0.22.1 This shows most of the standard functions of the library at once. @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.0"; +const char *libraryVersion = "0.22.1"; // The name of this file const char *sketchName = "logging_to MMW.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino index 510c2a7be..d1ba179a0 100644 --- a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino +++ b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.0 +This example sketch is written for ModularSensors library version 0.22.1 This sketch is an example of logging data to an SD card and sending the data to ThingSpeak. @@ -27,7 +27,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.0"; +const char *libraryVersion = "0.22.1"; // The name of this file const char *sketchName = "logging_to_ThingSpeak.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index e7410dc34..47106e8aa 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.0 +This example sketch is written for ModularSensors library version 0.22.1 This shows most of the standard functions of the library at once. @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.0"; +const char *libraryVersion = "0.22.1"; // The name of this file const char *sketchName = "menu_a_la_carte.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/simple_logging/simple_logging.ino b/examples/simple_logging/simple_logging.ino index afe9003dd..f2b1fa254 100644 --- a/examples/simple_logging/simple_logging.ino +++ b/examples/simple_logging/simple_logging.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.0 +This example sketch is written for ModularSensors library version 0.22.1 This sketch is an example of logging data to an SD card @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.0"; +const char *libraryVersion = "0.22.1"; // The name of this file const char *sketchName = "simple_logging.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino b/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino index 399dcd8f6..58e22b384 100644 --- a/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino +++ b/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.0 +This example sketch is written for ModularSensors library version 0.22.1 This sketch is an example of logging data to an SD card @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.0"; +const char *libraryVersion = "0.22.1"; // The name of this file const char *sketchName = "simple_logging.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/single_sensor/single_sensor.ino b/examples/single_sensor/single_sensor.ino index 3faa69492..909ea6169 100644 --- a/examples/single_sensor/single_sensor.ino +++ b/examples/single_sensor/single_sensor.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.0 +This example sketch is written for ModularSensors library version 0.22.1 This sketch is an example of getting data from a single sensor, in this case, a MaxBotix Ultrasonic Range Finder @@ -24,7 +24,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. #include // The library version this example was written for -const char *libraryVersion = "0.22.0"; +const char *libraryVersion = "0.22.1"; // The name of this file const char *sketchName = "single_sensor.ino"; diff --git a/library.json b/library.json index 8e6505c75..ec9e07dd0 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "EnviroDIY_ModularSensors", - "version": "0.22.0", + "version": "0.22.1", "description": "A library that allows access to multiple sensors through a unified interface. This allows the user to simply access many sensors to log the data or send the data to data repositories like the EnviroDIY data portal.", "keywords": "modular, sensor, sensors, datalogger, logger, low power, sleeping, EnviroDIY, ModularSensors, Mayfly, WikiWatershed, ThingSpeak", "platforms": "atmelavr, atmelsam", diff --git a/library.properties b/library.properties index b8046c356..847cb1e68 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=EnviroDIY_ModularSensors -version=0.22.0 +version=0.22.1 author=Sara Damiano , Shannon Hicks maintainer=Sara Damiano sentence=A library that allows access to multiple sensors through a unified interface. diff --git a/src/ModSensorDebugger.h b/src/ModSensorDebugger.h index 2e6baa5f6..2715d83e6 100644 --- a/src/ModSensorDebugger.h +++ b/src/ModSensorDebugger.h @@ -15,7 +15,7 @@ #include // The current library version number -#define MODULAR_SENSORS_VERSION "0.22.0" +#define MODULAR_SENSORS_VERSION "0.22.1" #ifndef STANDARD_SERIAL_OUTPUT // #if defined(ARDUINO_SAMD_ZERO) && defined(SERIAL_PORT_USBVIRTUAL) From a06ce9ffde657dc46cd9e72bd164c79d915ad6b7 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Sat, 25 May 2019 00:28:27 -0400 Subject: [PATCH 61/88] Missing semicolon --- library.json | 2 +- src/modems/EspressifESP8266.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library.json b/library.json index ec9e07dd0..caf1592e7 100644 --- a/library.json +++ b/library.json @@ -299,7 +299,7 @@ { "name": "TinyGSM", "version": "https://github.com/EnviroDIY/TinyGSM.git", - "version_note": "=0.7.8", + "version_note": "=0.7.9", "note": "A small Arduino library for GPRS modules.", "authors": [ "Volodymyr Shymanskyy", diff --git a/src/modems/EspressifESP8266.cpp b/src/modems/EspressifESP8266.cpp index 63a45daa3..8e879e818 100644 --- a/src/modems/EspressifESP8266.cpp +++ b/src/modems/EspressifESP8266.cpp @@ -107,7 +107,7 @@ bool EspressifESP8266::modemWakeFxn(void) else if (_modemResetPin >= 0) { MS_DBG(F("Sending a reset pulse to pin"), _modemResetPin, - F("to wake ESP8266 from deep sleep")) + F("to wake ESP8266 from deep sleep")); digitalWrite(_modemResetPin, LOW); delay(1); digitalWrite(_modemResetPin, HIGH); @@ -117,7 +117,7 @@ bool EspressifESP8266::modemWakeFxn(void) else if (_modemSleepRqPin >= 0) { MS_DBG(F("Sending a pulse to pin"), _modemSleepRqPin, - F("to wake ESP8266 from light sleep")) + F("to wake ESP8266 from light sleep")); digitalWrite(_modemSleepRqPin, LOW); delay(1); digitalWrite(_modemSleepRqPin, HIGH); From abf34e6233da858c33db147eeb96825df5a3570a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 28 May 2019 15:26:46 -0400 Subject: [PATCH 62/88] Force restart XBee --- src/modems/DigiXBeeCellularTransparent.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index eb5cfa07d..08453598e 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -101,10 +101,18 @@ bool DigiXBeeCellularTransparent::extraModemSetup(void) success &= gsmModem.waitResponse() == 1; // Put the network connection parameters into flash success &= gsmModem.gprsConnect(_apn); + MS_DBG(F("Ensuring XBee is in transparent mode...")); + // Make sure we're really in transparent mode + gsmModem.sendAT(GF("AP1")); + success &= gsmModem.waitResponse() == 1; // Write changes to flash and apply them + MS_DBG(F("Applying chages...")); gsmModem.writeChanges(); // Exit command mode gsmModem.exitCommand(); + // Force restart the modem, just for good measure + MS_DBG(F("Restarting XBee...")); + success &= gsmModem.restart(); } else success = false; if (success) MS_DBG(F("... Setup successful!")); From 4d7bd7f0acf0a687064052c50d77dcac98b27e99 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Tue, 28 May 2019 15:35:55 -0400 Subject: [PATCH 63/88] Typo --- src/modems/DigiXBeeCellularTransparent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index 08453598e..b9339e3a4 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -106,7 +106,7 @@ bool DigiXBeeCellularTransparent::extraModemSetup(void) gsmModem.sendAT(GF("AP1")); success &= gsmModem.waitResponse() == 1; // Write changes to flash and apply them - MS_DBG(F("Applying chages...")); + MS_DBG(F("Applying changes...")); gsmModem.writeChanges(); // Exit command mode gsmModem.exitCommand(); From 82f0c5569057890e0c0ab28e315207f6c8056eab Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 29 May 2019 11:38:57 -0400 Subject: [PATCH 64/88] SIM800 debug off by default --- src/modems/SIMComSIM800.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index 6be7030ed..af7dda5af 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -14,7 +14,7 @@ #define SIMComSIM800_h // Debugging Statement -#define MS_SIMCOMSIM800_DEBUG +// #define MS_SIMCOMSIM800_DEBUG // #define MS_SIMCOMSIM800_DEBUG_DEEP #ifdef MS_SIMCOMSIM800_DEBUG From 33e64d04d23c4388b3c9c7c0dd8d2dd167c9730a Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 29 May 2019 11:58:31 -0400 Subject: [PATCH 65/88] Always room for debugging --- src/modems/LoggerModemMacros.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 051d354d2..cc4c043ef 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -120,11 +120,19 @@ bool specificModem::verifyMeasurementComplete(bool debug) \ #if defined TINY_GSM_MODEM_XBEE || defined TINY_GSM_MODEM_ESP8266 -#define MS_MODEM_CALC_SIGNAL_RSSI rssi = signalQual; -#define MS_MODEM_CALC_SIGNAL_PERCENT percent = getPctFromRSSI(signalQual); +#define MS_MODEM_CALC_SIGNAL_RSSI \ +rssi = signalQual; \ +MS_DBG(F("Raw signal is already in units of RSSI:"), rssi); +#define MS_MODEM_CALC_SIGNAL_PERCENT \ +percent = getPctFromRSSI(signalQual); +MS_DBG(F("Signal percent calcuated from RSSI:"), percent); #else -#define MS_MODEM_CALC_SIGNAL_RSSI rssi = getRSSIFromCSQ(signalQual); -#define MS_MODEM_CALC_SIGNAL_PERCENT percent = getPctFromCSQ(signalQual); +#define MS_MODEM_CALC_SIGNAL_RSSI \ +rssi = getRSSIFromCSQ(signalQual); \ +MS_DBG(F("RSSI Estimated from CSQ:"), rssi); +#define MS_MODEM_CALC_SIGNAL_PERCENT \ +percent = getPctFromCSQ(signalQual); \ +MS_DBG(F("ignal percent calcuated from CSQ:"), percent); #endif #define MS_MODEM_GET_MODEM_SIGNAL_QUALITY(specificModem) \ From d85596787212562de7813fdb33d73c599e2e33a6 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 29 May 2019 12:06:28 -0400 Subject: [PATCH 66/88] Typo --- src/LoggerModem.cpp | 6 +++--- src/modems/LoggerModemMacros.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index 241e3f857..a6b6a5afc 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -342,8 +342,8 @@ bool loggerModem::addSingleMeasurementResult(void) /* value (99 CSQ or 0 RSSI) in all 3 cases. */ MS_DBG(F("Asking modem to give signal quality:")); success &= getModemSignalQuality(rssi, percent); - // MS_DBG(F("RSSI:"), rssi); - // MS_DBG(F("Percent signal strength:"), percent); + MS_DBG(F("RSSI:"), rssi); + MS_DBG(F("Percent signal strength:"), percent); MS_DBG(F("Getting battery info, if possible:")); success &= getModemBatteryStats(state, bpercent, volt); @@ -363,7 +363,7 @@ bool loggerModem::addSingleMeasurementResult(void) temp = getModemTemperature(); MS_DBG(F("Modem temperature:"), temp); } - else MS_DBG(getSensorName(), F("is not connected to the network; unable to get signal quality!")); + else MS_DBG(getSensorName(), F("is not expected to return measurement results!")); verifyAndAddMeasurementResult(MODEM_RSSI_VAR_NUM, rssi); verifyAndAddMeasurementResult(MODEM_PERCENT_SIGNAL_VAR_NUM, percent); diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index cc4c043ef..0d5077c1b 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -132,7 +132,7 @@ rssi = getRSSIFromCSQ(signalQual); \ MS_DBG(F("RSSI Estimated from CSQ:"), rssi); #define MS_MODEM_CALC_SIGNAL_PERCENT \ percent = getPctFromCSQ(signalQual); \ -MS_DBG(F("ignal percent calcuated from CSQ:"), percent); +MS_DBG(F("Signal percent calcuated from CSQ:"), percent); #endif #define MS_MODEM_GET_MODEM_SIGNAL_QUALITY(specificModem) \ From ab869748b9ab751806893576e3be7948bf14afa3 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 29 May 2019 12:45:46 -0400 Subject: [PATCH 67/88] Very minor example changes --- examples/DRWI_LTE/DRWI_LTE.ino | 17 +++++++++++--- .../baro_rho_correction.ino | 14 +++++------ examples/data_saving/data_saving.ino | 10 ++++---- examples/menu_a_la_carte/menu_a_la_carte.ino | 23 +++++++++++++++---- 4 files changed, 44 insertions(+), 20 deletions(-) diff --git a/examples/DRWI_LTE/DRWI_LTE.ino b/examples/DRWI_LTE/DRWI_LTE.ino index 11b544140..1e835f2e5 100644 --- a/examples/DRWI_LTE/DRWI_LTE.ino +++ b/examples/DRWI_LTE/DRWI_LTE.ino @@ -312,9 +312,6 @@ void setup() varArray.setupSensors(); } - // Power down the modem - modem.modemSleepPowerDown(); - // Create the log file, adding the default header to it // Do this last so we have the best chance of getting the time correct and // all sensor names correct @@ -322,11 +319,25 @@ void setup() // the sensor setup we'll skip this too. if (getBatteryVoltage() > 3.4) { + Serial.println(F("Setting up file on SD card")); dataLogger.turnOnSDcard(true); // true = wait for card to settle after power up dataLogger.createLogFile(true); // true = write a new header dataLogger.turnOffSDcard(true); // true = wait for internal housekeeping after write } + // Power down the modem - but only if there will be more than 15 seconds before + // the first logging interval - it can take the LTE modem that long to shut down + if (Logger::getNowEpoch() % (loggingInterval*60) > 15 || + Logger::getNowEpoch() % (loggingInterval*60) < 6) + { + Serial.println(F("Putting modem to sleep")); + modem.modemSleepPowerDown(); + } + else + { + Serial.println(F("Leaving modem on until after first measurement")); + } + // Call the processor sleep Serial.println(F("Putting processor to sleep")); dataLogger.systemSleep(); diff --git a/examples/baro_rho_correction/baro_rho_correction.ino b/examples/baro_rho_correction/baro_rho_correction.ino index 45154704f..5adffae6c 100644 --- a/examples/baro_rho_correction/baro_rho_correction.ino +++ b/examples/baro_rho_correction/baro_rho_correction.ino @@ -51,8 +51,8 @@ const int8_t buttonPin = 21; // MCU pin for a button to use to enter debugg const int8_t wakePin = A7; // MCU interrupt/alarm pin to wake from sleep // Set the wake pin to -1 if you do not want the main processor to sleep. // In a SAMD system where you are using the built-in rtc, set wakePin to 1 -const int8_t sdCardPwrPin = -1; // MCU SD card power pin (-1 if not applicable) -const int8_t sdCardSSPin = 12; // MCU SD card chip select/slave select pin (must be given!) +const int8_t sdCardPwrPin = -1; // MCU SD card power pin (-1 if not applicable) +const int8_t sdCardSSPin = 12; // MCU SD card chip select/slave select pin (must be given!) const int8_t sensorPowerPin = 22; // MCU pin controlling main sensor power (-1 if not applicable) // Create the main processor chip "sensor" - for general metadata @@ -415,11 +415,6 @@ void setup() varArray.setupSensors(); } - // Power down the modem - but only if there will be more than 15 seconds before - // the first logging interval - it can take the modem that long to shut down - if (Logger::getNowEpoch() % (loggingInterval*60) > 15) - modem.modemSleepPowerDown(); - // Create the log file, adding the default header to it // Do this last so we have the best chance of getting the time correct and // all sensor names correct @@ -427,11 +422,16 @@ void setup() // the sensor setup we'll skip this too. if (getBatteryVoltage() > 3.4) { + Serial.println(F("Setting up file on SD card")); dataLogger.turnOnSDcard(true); // true = wait for card to settle after power up dataLogger.createLogFile(true); // true = write a new header dataLogger.turnOffSDcard(true); // true = wait for internal housekeeping after write } + // Power down the modem + Serial.println(F("Putting modem to sleep")); + modem.modemSleepPowerDown(); + // Call the processor sleep Serial.println(F("Putting processor to sleep")); dataLogger.systemSleep(); diff --git a/examples/data_saving/data_saving.ino b/examples/data_saving/data_saving.ino index 837bbf4f7..50339cf1d 100644 --- a/examples/data_saving/data_saving.ino +++ b/examples/data_saving/data_saving.ino @@ -51,8 +51,8 @@ const int8_t buttonPin = 21; // MCU pin for a button to use to enter debugg const int8_t wakePin = A7; // MCU interrupt/alarm pin to wake from sleep // Set the wake pin to -1 if you do not want the main processor to sleep. // In a SAMD system where you are using the built-in rtc, set wakePin to 1 -const int8_t sdCardPwrPin = -1; // MCU SD card power pin (-1 if not applicable) -const int8_t sdCardSSPin = 12; // MCU SD card chip select/slave select pin (must be given!) +const int8_t sdCardPwrPin = -1; // MCU SD card power pin (-1 if not applicable) +const int8_t sdCardSSPin = 12; // MCU SD card chip select/slave select pin (must be given!) const int8_t sensorPowerPin = 22; // MCU pin controlling main sensor power (-1 if not applicable) // Create the main processor chip "sensor" - for general metadata @@ -385,10 +385,10 @@ Logger loggerAllVars(LoggerID, loggingInterval, &arrayComplete); Logger loggerToGo(LoggerID, loggingInterval, &arrayToGo); // ========================================================================== -// A Publisher to WikiWatershed +// A Publisher to Monitor My Watershed / EnviroDIY Data Sharing Portal // ========================================================================== // Device registration and sampling feature information can be obtained after -// registration at http://data.WikiWatershed.org +// registration at https://monitormywatershed.org or https://data.envirodiy.org const char *registrationToken = "12345678-abcd-1234-efgh-1234567890ab"; // Device registration token const char *samplingFeature = "12345678-abcd-1234-efgh-1234567890ab"; // Sampling feature UUID @@ -462,7 +462,7 @@ void setup() modbusSerial.begin(9600); // Assign pins SERCOM functionality for SAMD boards - // NOTE: This must happen *after* the begin + // NOTE: This must happen *after* the various serial.begin statements #if defined ARDUINO_ARCH_SAMD #ifndef ENABLE_SERIAL2 pinPeripheral(10, PIO_SERCOM); // Serial2 Tx/Dout = SERCOM1 Pad #2 diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 47106e8aa..8090b6750 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1232,6 +1232,10 @@ Variable *variableList[] = { new MaximDS3231_Temp(&ds3231, "12345678-abcd-1234-efgh-1234567890ab"), new Modem_RSSI(&modem, "12345678-abcd-1234-efgh-1234567890ab"), new Modem_SignalPercent(&modem, "12345678-abcd-1234-efgh-1234567890ab"), + new Modem_BatteryState(&modem, "12345678-abcd-1234-efgh-1234567890ab"), + new Modem_BatteryPercent(&modem, "12345678-abcd-1234-efgh-1234567890ab"), + new Modem_BatteryVoltage(&modem, "12345678-abcd-1234-efgh-1234567890ab"), + new Modem_Temp(&modem, "12345678-abcd-1234-efgh-1234567890ab"), calculatedVar, }; @@ -1462,11 +1466,6 @@ void setup() varArray.setupSensors(); } - // Power down the modem - but only if there will be more than 15 seconds before - // the first logging interval - it can take the modem that long to shut down - if (Logger::getNowEpoch() % (loggingInterval*60) > 15) - modem.modemSleepPowerDown(); - // Create the log file, adding the default header to it // Do this last so we have the best chance of getting the time correct and // all sensor names correct @@ -1474,11 +1473,25 @@ void setup() // the sensor setup we'll skip this too. if (getBatteryVoltage() > 3.4) { + Serial.println(F("Setting up file on SD card")); dataLogger.turnOnSDcard(true); // true = wait for card to settle after power up dataLogger.createLogFile(true); // true = write a new header dataLogger.turnOffSDcard(true); // true = wait for internal housekeeping after write } + // Power down the modem - but only if there will be more than 15 seconds before + // the first logging interval - it can take the LTE modem that long to shut down + if (Logger::getNowEpoch() % (loggingInterval*60) > 15 || + Logger::getNowEpoch() % (loggingInterval*60) < 6) + { + Serial.println(F("Putting modem to sleep")); + modem.modemSleepPowerDown(); + } + else + { + Serial.println(F("Leaving modem on until after first measurement")); + } + // Call the processor sleep Serial.println(F("Putting processor to sleep")); dataLogger.systemSleep(); From 628fc03c731ab80a923a50b480f1963b68af51f2 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 29 May 2019 13:36:26 -0400 Subject: [PATCH 68/88] Fixed maxbotix debugging --- src/sensors/MaxBotixSonar.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sensors/MaxBotixSonar.cpp b/src/sensors/MaxBotixSonar.cpp index 63de7de5c..65276b84f 100644 --- a/src/sensors/MaxBotixSonar.cpp +++ b/src/sensors/MaxBotixSonar.cpp @@ -63,7 +63,7 @@ bool MaxBotixSonar::setup(void) // Parsing and tossing the header lines in the wake-up bool MaxBotixSonar::wake(void) { - // Sensor::wake() checks if the power pin is on and sets the wake timestamp + // Sensor::wake() checks if the power pin is on and sets the wake timestamp // and status bits. If it returns false, there's no reason to go on. if (!Sensor::wake()) return false; @@ -95,13 +95,13 @@ bool MaxBotixSonar::wake(void) MS_DBG(F("Dumping"), junkChars, F("characters from MaxBotix stream buffer")); for (uint8_t i = 0; i < junkChars; i++) { - #ifdef DEBUGGING_SERIAL_OUTPUT + #ifdef MS_MAXBOTIXSONAR_DEBUG DEBUGGING_SERIAL_OUTPUT.print(_stream->read()); #else _stream->read(); #endif } - #ifdef DEBUGGING_SERIAL_OUTPUT + #ifdef MS_MAXBOTIXSONAR_DEBUG DEBUGGING_SERIAL_OUTPUT.println(); #endif } @@ -124,13 +124,13 @@ bool MaxBotixSonar::addSingleMeasurementResult(void) MS_DBG(F("Dumping"), junkChars, F("characters from MaxBotix stream buffer:")); for (uint8_t i = 0; i < junkChars; i++) { - #ifdef DEBUGGING_SERIAL_OUTPUT + #ifdef MS_MAXBOTIXSONAR_DEBUG DEBUGGING_SERIAL_OUTPUT.print(_stream->read()); #else _stream->read(); #endif } - #ifdef DEBUGGING_SERIAL_OUTPUT + #ifdef MS_MAXBOTIXSONAR_DEBUG DEBUGGING_SERIAL_OUTPUT.println(); #endif } From 7c87f7380dd4c757bc12cd33864ffc821187dccb Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 29 May 2019 21:48:45 -0400 Subject: [PATCH 69/88] Increased AT response time for SIM800, also increase wait padding --- src/LoggerModem.cpp | 18 +++--------------- src/modems/SIMComSIM800.h | 2 +- src/modems/Sodaq2GBeeR6.h | 7 ++++--- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index a6b6a5afc..2f1d2f101 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -261,7 +261,7 @@ bool loggerModem::isStable(bool debug) uint32_t elapsed_since_wake_up = now - _millisSensorActivated; // If the modem has a status pin and it's off, give up - if ( (_dataPin >= 0 && elapsed_since_wake_up > _statusTime_ms && + if ( (_dataPin >= 0 && elapsed_since_wake_up > (_statusTime_ms + 250) && digitalRead(_dataPin) != _statusLevel)) { if (debug) MS_DBG(F("It's been"), (elapsed_since_wake_up), F("ms, and status pin on"), @@ -290,8 +290,8 @@ bool loggerModem::isStable(bool debug) return true; } - // If we've exceeded the documented time until UART should respond (plus 500ms buffer), give up - if (elapsed_since_wake_up > (_stabilizationTime_ms + 500)) + // If we've exceeded the documented time until UART should respond (plus 750ms buffer), give up + if (elapsed_since_wake_up > (_stabilizationTime_ms + 750)) { if (debug) MS_DBG(F("It's been"), (elapsed_since_wake_up), F("ms, and"), getSensorName(), F("has maxed out wait for AT command reply! Ending wait.")); @@ -660,17 +660,5 @@ void loggerModem::setModemTiming(void) // _off_pull_down_ms = 700; // 0.6s= 0) - { - MS_DBG(F("Resetting warm-up and disconnect timing for a Sequans VZM20Q")); - _warmUpTime_ms = 0; // Module automatically boots when power is applied - _statusTime_ms = 50; // ?? Undocumented - _stabilizationTime_ms = 5000; // ?? Time to UART availability not documented - // _on_pull_down_ms = 50; // ?? Undocumented - // _off_pull_down_ms = 0; // N/A - standard chip cannot be powered down with pin - // use AT+CPSMS command for LTE-M power saving - // use AT+SQNSSHDN command for device shut down - _disconnetTime_ms = 15000; // ?? Undocumented (Giving 15sec here in case it is not monitored.) - } } ***/ diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index af7dda5af..5973cb9c7 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -34,7 +34,7 @@ // Time after power on before "PWRKEY" can be used - >0.4sec #define SIM800_WARM_UP_TIME_MS 450 // Time after end pulse until serial port becomes active (>3sec from start of 1s pulse) -#define SIM800_ATRESPONSE_TIME_MS 2000 +#define SIM800_ATRESPONSE_TIME_MS 2500 // How long we're willing to wait to get signal quality #define SIM800_SIGNALQUALITY_TIME_MS 15000L diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h index 862efefcd..e3a09688a 100644 --- a/src/modems/Sodaq2GBeeR6.h +++ b/src/modems/Sodaq2GBeeR6.h @@ -28,10 +28,11 @@ // (Giving 15sec for shutdown in case it is not monitored.) #define SIM800_DISCONNECT_TIME_MS 15000L -// Time after power on before "PWRKEY" can be used - >0.4sec -#define SIM800_WARM_UP_TIME_MS 450 +// NOTE: The GPRSBee R6+ has the PWR_KEY tied to the input voltage, so there is +// no warm-up time needed +#define SIM800_WARM_UP_TIME_MS 0 // Time after end pulse until serial port becomes active (>3sec from start of 1s pulse) -#define SIM800_ATRESPONSE_TIME_MS 2000 +#define SIM800_ATRESPONSE_TIME_MS 2500 // How long we're willing to wait to get signal quality #define SIM800_SIGNALQUALITY_TIME_MS 15000L From 340647815c26a1403d2810201541101b76832418 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 30 May 2019 13:35:17 -0400 Subject: [PATCH 70/88] Missing slash --- src/modems/LoggerModemMacros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 0d5077c1b..b565ebf7c 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -124,7 +124,7 @@ bool specificModem::verifyMeasurementComplete(bool debug) \ rssi = signalQual; \ MS_DBG(F("Raw signal is already in units of RSSI:"), rssi); #define MS_MODEM_CALC_SIGNAL_PERCENT \ -percent = getPctFromRSSI(signalQual); +percent = getPctFromRSSI(signalQual); \ MS_DBG(F("Signal percent calcuated from RSSI:"), percent); #else #define MS_MODEM_CALC_SIGNAL_RSSI \ From c7cf82255ad3bba162a81534a472959cdca6d2c0 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 30 May 2019 13:47:54 -0400 Subject: [PATCH 71/88] Increased buffer on status pin reading --- src/LoggerModem.cpp | 2 +- src/modems/SIMComSIM800.h | 4 ++-- src/modems/Sodaq2GBeeR6.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index 2f1d2f101..c83177031 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -261,7 +261,7 @@ bool loggerModem::isStable(bool debug) uint32_t elapsed_since_wake_up = now - _millisSensorActivated; // If the modem has a status pin and it's off, give up - if ( (_dataPin >= 0 && elapsed_since_wake_up > (_statusTime_ms + 250) && + if ( (_dataPin >= 0 && elapsed_since_wake_up > (_statusTime_ms + 500) && digitalRead(_dataPin) != _statusLevel)) { if (debug) MS_DBG(F("It's been"), (elapsed_since_wake_up), F("ms, and status pin on"), diff --git a/src/modems/SIMComSIM800.h b/src/modems/SIMComSIM800.h index 5973cb9c7..e1c96a094 100644 --- a/src/modems/SIMComSIM800.h +++ b/src/modems/SIMComSIM800.h @@ -26,7 +26,7 @@ // Time after end pulse until status pin becomes active // SIM800 - >3sec from start of 1s pulse // SIM900 - >2.2sec from end of pulse -#define SIM800_STATUS_TIME_MS 2500 +#define SIM800_STATUS_TIME_MS 3000 // power down (gracefully) takes >3sec // (Giving 15sec for shutdown in case it is not monitored.) #define SIM800_DISCONNECT_TIME_MS 15000L @@ -34,7 +34,7 @@ // Time after power on before "PWRKEY" can be used - >0.4sec #define SIM800_WARM_UP_TIME_MS 450 // Time after end pulse until serial port becomes active (>3sec from start of 1s pulse) -#define SIM800_ATRESPONSE_TIME_MS 2500 +#define SIM800_ATRESPONSE_TIME_MS 3000 // How long we're willing to wait to get signal quality #define SIM800_SIGNALQUALITY_TIME_MS 15000L diff --git a/src/modems/Sodaq2GBeeR6.h b/src/modems/Sodaq2GBeeR6.h index e3a09688a..4f3198492 100644 --- a/src/modems/Sodaq2GBeeR6.h +++ b/src/modems/Sodaq2GBeeR6.h @@ -23,7 +23,7 @@ #define TINY_GSM_MODEM_SIM800 // Time after end pulse until status pin becomes active (>3sec from start of 1s pulse) -#define SIM800_STATUS_TIME_MS 2500 +#define SIM800_STATUS_TIME_MS 3000 // power down (gracefully) takes >3sec // (Giving 15sec for shutdown in case it is not monitored.) #define SIM800_DISCONNECT_TIME_MS 15000L @@ -32,7 +32,7 @@ // no warm-up time needed #define SIM800_WARM_UP_TIME_MS 0 // Time after end pulse until serial port becomes active (>3sec from start of 1s pulse) -#define SIM800_ATRESPONSE_TIME_MS 2500 +#define SIM800_ATRESPONSE_TIME_MS 3000 // How long we're willing to wait to get signal quality #define SIM800_SIGNALQUALITY_TIME_MS 15000L From 8e6571b501476e9cf84590f0180c6a37f0d6e5d2 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 30 May 2019 16:10:41 -0400 Subject: [PATCH 72/88] remove some \n's --- src/modems/LoggerModemMacros.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index b565ebf7c..298de81ec 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -144,7 +144,7 @@ bool specificModem::getModemSignalQuality(int16_t &rssi, int16_t &percent) \ /* The TinyGSM getSignalQuality function returns the same "no signal" */ \ /* value (99 CSQ or 0 RSSI) in all 3 cases. */ \ MS_DBG(F("Getting signal quality:")); \ - uint16_t signalQual = gsmModem.getSignalQuality(); \ + int16_t signalQual = gsmModem.getSignalQuality(); \ MS_DBG(F("Raw signal quality:"), signalQual); \ \ /* Convert signal quality to RSSI, if necessary */ \ @@ -369,7 +369,7 @@ uint32_t specificModem::getNISTTime(void) \ \ if (gsmClient.available() >= 4) \ { \ - MS_DBG(F("\nNIST responded after"), millis() - start, F("ms")); \ + MS_DBG(F("NIST responded after"), millis() - start, F("ms")); \ /* Response is returned as 32-bit number as soon as connection is made */ \ /* Connection is then immediately closed, so there is no need to close it */ \ uint32_t secFrom1900 = 0; \ @@ -377,13 +377,13 @@ uint32_t specificModem::getNISTTime(void) \ for (uint8_t i = 0; i < 4; i++) \ { \ response[i] = gsmClient.read(); \ - MS_DBG(F("\nResponse Byte"), i, ':', (char)response[i], \ + MS_DBG(F("Response Byte"), i, ':', (char)response[i], \ '=', response[i], '=', String(response[i], BIN)); \ secFrom1900 += 0x000000FF & response[i]; \ /* MS_DBG(F("\nseconds from 1900 after byte:"),String(secFrom1900, BIN)); */ \ if (i+1 < 4) {secFrom1900 = secFrom1900 << 8;} \ } \ - MS_DBG(F("\nSeconds from 1900 returned by NIST (UTC):"), \ + MS_DBG(F("Seconds from 1900 returned by NIST (UTC):"), \ secFrom1900, '=', String(secFrom1900, BIN)); \ \ /* Close the TCP connection, just in case */ \ @@ -391,7 +391,7 @@ uint32_t specificModem::getNISTTime(void) \ \ /* Return the timestamp */ \ uint32_t unixTimeStamp = secFrom1900 - 2208988800; \ - MS_DBG(F("\nUnix Timestamp returned by NIST (UTC):"), unixTimeStamp); \ + MS_DBG(F("Unix Timestamp returned by NIST (UTC):"), unixTimeStamp); \ /* If before Jan 1, 2017 or after Jan 1, 2030, most likely an error */ \ if (unixTimeStamp < 1483228800) return 0; \ else if (unixTimeStamp > 1893456000) return 0; \ From 13a646ea856b42112f5fb6eb1097833a2559cc94 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 30 May 2019 17:29:34 -0400 Subject: [PATCH 73/88] Version bump, dependency bump --- examples/DRWI_CitSci/DRWI_CitSci.ino | 4 ++-- examples/DRWI_LTE/DRWI_LTE.ino | 4 ++-- examples/DRWI_NoCellular/DRWI_NoCellular.ino | 4 ++-- examples/baro_rho_correction/baro_rho_correction.ino | 4 ++-- examples/data_saving/data_saving.ino | 4 ++-- examples/double_logger/double_logger.ino | 4 ++-- examples/logging_to_MMW/logging_to_MMW.ino | 4 ++-- examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino | 4 ++-- examples/menu_a_la_carte/menu_a_la_carte.ino | 4 ++-- examples/simple_logging/simple_logging.ino | 4 ++-- .../simple_logging_LearnEnviroDIY.ino | 4 ++-- examples/single_sensor/single_sensor.ino | 4 ++-- library.json | 4 ++-- library.properties | 2 +- src/ModSensorDebugger.h | 2 +- src/modems/LoggerModemMacros.h | 4 ++-- 16 files changed, 30 insertions(+), 30 deletions(-) diff --git a/examples/DRWI_CitSci/DRWI_CitSci.ino b/examples/DRWI_CitSci/DRWI_CitSci.ino index 18e785e49..a654350e8 100644 --- a/examples/DRWI_CitSci/DRWI_CitSci.ino +++ b/examples/DRWI_CitSci/DRWI_CitSci.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.1 +This example sketch is written for ModularSensors library version 0.22.2 This sketch is an example of logging data to an SD card and sending the data to both the EnviroDIY data portal as should be used by groups involved with @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.1"; +const char *libraryVersion = "0.22.2"; // The name of this file const char *sketchName = "DWRI_CitSci.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/DRWI_LTE/DRWI_LTE.ino b/examples/DRWI_LTE/DRWI_LTE.ino index 1e835f2e5..0a9d06944 100644 --- a/examples/DRWI_LTE/DRWI_LTE.ino +++ b/examples/DRWI_LTE/DRWI_LTE.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.1 +This example sketch is written for ModularSensors library version 0.22.2 This sketch is an example of logging data to an SD card and sending the data to both the EnviroDIY data portal as should be used by groups involved with @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.1"; +const char *libraryVersion = "0.22.2"; // The name of this file const char *sketchName = "DRWI_LTE.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/DRWI_NoCellular/DRWI_NoCellular.ino b/examples/DRWI_NoCellular/DRWI_NoCellular.ino index fd469cb80..340e25d39 100644 --- a/examples/DRWI_NoCellular/DRWI_NoCellular.ino +++ b/examples/DRWI_NoCellular/DRWI_NoCellular.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.1 +This example sketch is written for ModularSensors library version 0.22.2 This sketch is an example of logging data to an SD card as should be used by groups involved with The William Penn Foundation's Delaware River Watershed @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.1"; +const char *libraryVersion = "0.22.2"; // The name of this file const char *sketchName = "DRWI_NoCellular.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/baro_rho_correction/baro_rho_correction.ino b/examples/baro_rho_correction/baro_rho_correction.ino index 5adffae6c..22837593c 100644 --- a/examples/baro_rho_correction/baro_rho_correction.ino +++ b/examples/baro_rho_correction/baro_rho_correction.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.1 +This example sketch is written for ModularSensors library version 0.22.2 This sketch is an example of logging data to an SD card and sending the data to the EnviroDIY data portal. @@ -27,7 +27,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.1"; +const char *libraryVersion = "0.22.2"; // The name of this file const char *sketchName = "baro_rho_correction.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/data_saving/data_saving.ino b/examples/data_saving/data_saving.ino index 50339cf1d..c04998824 100644 --- a/examples/data_saving/data_saving.ino +++ b/examples/data_saving/data_saving.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.1 +This example sketch is written for ModularSensors library version 0.22.2 This sketch is an example of logging data to an SD card and sending only a portion of that data to the EnviroDIY data portal. @@ -27,7 +27,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.1"; +const char *libraryVersion = "0.22.2"; // The name of this file const char *sketchName = "data_saving.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/double_logger/double_logger.ino b/examples/double_logger/double_logger.ino index 5a22e39b7..f0853ed27 100644 --- a/examples/double_logger/double_logger.ino +++ b/examples/double_logger/double_logger.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.1 +This example sketch is written for ModularSensors library version 0.22.2 This sketch is an example of logging data from different variables at two different logging intervals. This example uses more of the manual functions @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.1"; +const char *libraryVersion = "0.22.2"; // The name of this file const char *sketchName = "double_logger.ino"; // Logger ID - we're only using one logger ID for both "loggers" diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index a0b82d8fb..6ffd74c72 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.1 +This example sketch is written for ModularSensors library version 0.22.2 This shows most of the standard functions of the library at once. @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.1"; +const char *libraryVersion = "0.22.2"; // The name of this file const char *sketchName = "logging_to MMW.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino index d1ba179a0..d7b3ba999 100644 --- a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino +++ b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.1 +This example sketch is written for ModularSensors library version 0.22.2 This sketch is an example of logging data to an SD card and sending the data to ThingSpeak. @@ -27,7 +27,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.1"; +const char *libraryVersion = "0.22.2"; // The name of this file const char *sketchName = "logging_to_ThingSpeak.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 8090b6750..4a26952a2 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.1 +This example sketch is written for ModularSensors library version 0.22.2 This shows most of the standard functions of the library at once. @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.1"; +const char *libraryVersion = "0.22.2"; // The name of this file const char *sketchName = "menu_a_la_carte.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/simple_logging/simple_logging.ino b/examples/simple_logging/simple_logging.ino index f2b1fa254..9c8d3d5c3 100644 --- a/examples/simple_logging/simple_logging.ino +++ b/examples/simple_logging/simple_logging.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.1 +This example sketch is written for ModularSensors library version 0.22.2 This sketch is an example of logging data to an SD card @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.1"; +const char *libraryVersion = "0.22.2"; // The name of this file const char *sketchName = "simple_logging.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino b/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino index 58e22b384..037cc397c 100644 --- a/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino +++ b/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.1 +This example sketch is written for ModularSensors library version 0.22.2 This sketch is an example of logging data to an SD card @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.1"; +const char *libraryVersion = "0.22.2"; // The name of this file const char *sketchName = "simple_logging.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/single_sensor/single_sensor.ino b/examples/single_sensor/single_sensor.ino index 909ea6169..7325db664 100644 --- a/examples/single_sensor/single_sensor.ino +++ b/examples/single_sensor/single_sensor.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.1 +This example sketch is written for ModularSensors library version 0.22.2 This sketch is an example of getting data from a single sensor, in this case, a MaxBotix Ultrasonic Range Finder @@ -24,7 +24,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. #include // The library version this example was written for -const char *libraryVersion = "0.22.1"; +const char *libraryVersion = "0.22.2"; // The name of this file const char *sketchName = "single_sensor.ino"; diff --git a/library.json b/library.json index caf1592e7..d5d5b5417 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "EnviroDIY_ModularSensors", - "version": "0.22.1", + "version": "0.22.2", "description": "A library that allows access to multiple sensors through a unified interface. This allows the user to simply access many sensors to log the data or send the data to data repositories like the EnviroDIY data portal.", "keywords": "modular, sensor, sensors, datalogger, logger, low power, sleeping, EnviroDIY, ModularSensors, Mayfly, WikiWatershed, ThingSpeak", "platforms": "atmelavr, atmelsam", @@ -299,7 +299,7 @@ { "name": "TinyGSM", "version": "https://github.com/EnviroDIY/TinyGSM.git", - "version_note": "=0.7.9", + "version_note": "=0.7.10", "note": "A small Arduino library for GPRS modules.", "authors": [ "Volodymyr Shymanskyy", diff --git a/library.properties b/library.properties index 847cb1e68..4cc8f6ebc 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=EnviroDIY_ModularSensors -version=0.22.1 +version=0.22.2 author=Sara Damiano , Shannon Hicks maintainer=Sara Damiano sentence=A library that allows access to multiple sensors through a unified interface. diff --git a/src/ModSensorDebugger.h b/src/ModSensorDebugger.h index 2715d83e6..cf4f0cdbe 100644 --- a/src/ModSensorDebugger.h +++ b/src/ModSensorDebugger.h @@ -15,7 +15,7 @@ #include // The current library version number -#define MODULAR_SENSORS_VERSION "0.22.1" +#define MODULAR_SENSORS_VERSION "0.22.2" #ifndef STANDARD_SERIAL_OUTPUT // #if defined(ARDUINO_SAMD_ZERO) && defined(SERIAL_PORT_USBVIRTUAL) diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 298de81ec..38816948a 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -344,7 +344,7 @@ uint32_t specificModem::getNISTTime(void) \ while (millis() < _lastNISTrequest + 4000) {} \ \ /* Make TCP connection */ \ - MS_DBG(F("Connecting to NIST daytime Server")); \ + MS_DBG(F("\nConnecting to NIST daytime Server")); \ bool connectionMade = false; \ if (_modemName.indexOf(F("XBee")) >= 0) \ { \ @@ -391,7 +391,7 @@ uint32_t specificModem::getNISTTime(void) \ \ /* Return the timestamp */ \ uint32_t unixTimeStamp = secFrom1900 - 2208988800; \ - MS_DBG(F("Unix Timestamp returned by NIST (UTC):"), unixTimeStamp); \ + MS_DBG(F("Unix Timestamp returned by NIST (UTC):"), unixTimeStamp, '\n'); \ /* If before Jan 1, 2017 or after Jan 1, 2030, most likely an error */ \ if (unixTimeStamp < 1483228800) return 0; \ else if (unixTimeStamp > 1893456000) return 0; \ From efde16cee73beb99eb46bbaacfd0bebf633b8227 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 30 May 2019 18:10:45 -0400 Subject: [PATCH 74/88] Status pin check --- src/LoggerModem.cpp | 22 ++++++++++++++-------- src/modems/LoggerModemMacros.h | 1 + src/modems/SodaqUBeeU201.h | 1 - 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index c83177031..b09022281 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -187,8 +187,8 @@ bool loggerModem::wake(void) // mid-shutdown. In that case, we'll mistakenly skip re-waking it. if (_dataPin >= 0 && digitalRead(_dataPin) == _statusLevel && !_alwaysRunWake) { - MS_DBG(getSensorName(), F("was already on! (status pin level = "), - _statusLevel, F(") Will not run wake function.")); + MS_DBG(getSensorName(), F("was already on! (status pin"), _dataPin, + F("level = "), _statusLevel, F(") Will not run wake function.")); } else { @@ -201,7 +201,7 @@ bool loggerModem::wake(void) // Only works if the status pin comes on immediately if (_dataPin >= 0 && _statusTime_ms == 0 && digitalRead(_dataPin) != _statusLevel) { - MS_DBG(F("Status pin level on"), getSensorName(), F("is"), + MS_DBG(F("Status pin"), _dataPin, F("on"), getSensorName(), F("is"), digitalRead(_dataPin), F("indicating it is off!")); success = false; modemHardReset(); @@ -264,9 +264,9 @@ bool loggerModem::isStable(bool debug) if ( (_dataPin >= 0 && elapsed_since_wake_up > (_statusTime_ms + 500) && digitalRead(_dataPin) != _statusLevel)) { - if (debug) MS_DBG(F("It's been"), (elapsed_since_wake_up), F("ms, and status pin on"), - getSensorName(), F("is"), digitalRead(_dataPin), - F("indicating it is off. AT commands will not be attempted!")); + if (debug) MS_DBG(F("It's been"), (elapsed_since_wake_up), F("ms, and status pin"), + _dataPin, F("on"), getSensorName(), F("is"), digitalRead(_dataPin), + F("indicating it is off. Will not continue to attempt communication!")); // Unset status bit 4 (wake up success) and _millisSensorActivated // We unset these bits here because it's possible that a modem "passed" // the wake command, but never really woke. For sensors that take time @@ -448,10 +448,15 @@ bool loggerModem::modemSleepPowerDown(void) // know it's coming on and so we'd mistakenly assume it's already off and // not turn it back off. if (_dataPin >= 0 && digitalRead(_dataPin) != _statusLevel && !_alwaysRunWake) - MS_DBG(getSensorName(), F("appears to have already been off. Will not run sleep function.")); + { + MS_DBG(F("Status pin"), _dataPin, F("on"), getSensorName(), F("is"), + digitalRead(_dataPin), F("indicating it is already off! Will not run sleep function.")); + } // If there's no status pin, check against the status bits else if (_dataPin < 0 && !bitRead(_sensorStatus, 4) && !_alwaysRunWake) + { MS_DBG(getSensorName(), F("was never sucessfully turned on. Will not run sleep function.")); + } else { // Run the sleep function @@ -475,7 +480,8 @@ bool loggerModem::modemSleepPowerDown(void) // This allows the modem to shut down gracefully. if (_dataPin >= 0) { - MS_DBG(F("Waiting up to"), _disconnetTime_ms, F("milliseconds for graceful shutdown...")); + MS_DBG(F("Waiting up to"), _disconnetTime_ms, F("milliseconds for graceful shutdown as indicated by pin"), + _dataPin, F("going"), !_statusLevel, F("...")); while (millis() - start < _disconnetTime_ms && digitalRead(_dataPin) == _statusLevel){} if (digitalRead(_dataPin) == _statusLevel) MS_DBG(F("... "), getSensorName(), F("did not successfully shut down!")); diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index 38816948a..eb9918a19 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -219,6 +219,7 @@ float specificModem::getModemTemperature(void) \ } \ \ /* Check that the modem is responding to AT commands. If not, give up. */ \ + /* TODO: Check status pin? */ \ MS_START_DEBUG_TIMER; \ MS_DBG(F("\nWaiting for"), getSensorName(), F("to respond to AT commands...")); \ if (!gsmModem.testAT(_stabilizationTime_ms + 500)) \ diff --git a/src/modems/SodaqUBeeU201.h b/src/modems/SodaqUBeeU201.h index 42a151b8b..cad00b02c 100644 --- a/src/modems/SodaqUBeeU201.h +++ b/src/modems/SodaqUBeeU201.h @@ -34,7 +34,6 @@ #define U201_WARM_UP_TIME_MS 0 // Time until system and digital pins are operational // (6 sec typical for SARA U201) -// Time for an AT response may be even longer when using a 3G XBee in bypass mode! #define U201_ATRESPONSE_TIME_MS 6000L // How long we're willing to wait to get signal quality From a6e0270d63ba1d5ff056bdbea0596e23a574c29d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 5 Jun 2019 11:08:53 -0400 Subject: [PATCH 75/88] Use mask array in VariableArray::updateAllSensors to reduce fxn calls --- src/VariableArray.cpp | 55 +++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 15 deletions(-) diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 0f2059e12..07abb99bb 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -299,6 +299,7 @@ void VariableArray::sensorsPowerDown(void) bool VariableArray::updateAllSensors(void) { bool success = true; + uint8_t nSensorsCompleted = 0; #ifdef MS_VARIABLEARRAY_DEBUG_DEEP bool deepDebugTiming = true; @@ -306,27 +307,51 @@ bool VariableArray::updateAllSensors(void) bool deepDebugTiming = false; #endif + // Create an array with the unique-ness value (so we can skip the function calls later) + MS_DBG(F("Creating a mask array with the uniqueness for each sensor..")); + bool lastSensorVariable[_variableCount]; + for (uint8_t i = 0; i < _variableCount; i++) + { + lastSensorVariable[i] = isLastVarFromSensor(i); + } + + // Create an array for the number of measurements already completed and set all to zero + MS_DBG(F("Creating an array for the number of completed measurements..")); + uint8_t nMeasurementsCompleted[_variableCount]; + for (uint8_t i = 0; i < _variableCount; i++) + { + nMeasurementsCompleted[i] = 0; + } + + // Create an array for the number of measurements to average (another short cut) + MS_DBG(F("Creating an array with the number of measurements to average..")); + uint8_t nMeasurementsToAverage[_variableCount]; + for (uint8_t i = 0; i < _variableCount; i++) + { + if (lastSensorVariable[i]) + { + nMeasurementsToAverage[i] = + arrayOfVars[i]->parentSensor->getNumberMeasurementsToAverage(); + } + else nMeasurementsToAverage[i] = 0; + } + // Clear the initial variable arrays MS_DBG(F("----->> Clearing all results arrays before taking new measurements. ...")); for (uint8_t i = 0; i < _variableCount; i++) { - if (isLastVarFromSensor(i)) + if (lastSensorVariable[i]) { arrayOfVars[i]->parentSensor->clearValues(); } } MS_DBG(F(" ... Complete. <<-----")); - uint8_t nSensorsCompleted = 0; - uint8_t nMeasurementsCompleted[_variableCount]; - for (uint8_t i = 0; i < _variableCount; i++) - nMeasurementsCompleted[i] = 0; - // Check for any sensors that didn't wake up and mark them as "complete" so // they will be skipped in further looping. for (uint8_t i = 0; i < _variableCount; i++) { - if (isLastVarFromSensor(i)) // Skip non-unique sensors + if (lastSensorVariable[i]) // Skip non-unique sensors { if (bitRead(arrayOfVars[i]->parentSensor->getStatus(), 3) == 0 || // No attempt made to wake the sensor up bitRead(arrayOfVars[i]->parentSensor->getStatus(), 4) == 0 ) // OR Wake up failed @@ -336,7 +361,7 @@ bool VariableArray::updateAllSensors(void) // Set the number of measurements already equal to whatever total // number requested to ensure the sensor is skipped in further loops. - nMeasurementsCompleted[i] = arrayOfVars[i]->parentSensor->getNumberMeasurementsToAverage(); + nMeasurementsCompleted[i] = nMeasurementsToAverage[i]; // Bump up the finished count. nSensorsCompleted++; } @@ -352,8 +377,8 @@ bool VariableArray::updateAllSensors(void) // THIS IS PURELY FOR DEEP DEBUGGING OF THE TIMING! // Leave this whole section commented out unless you want excessive // printouts (ie, thousands of lines) of the timing information!! - if (isLastVarFromSensor(i) and - arrayOfVars[i]->parentSensor->getNumberMeasurementsToAverage() > nMeasurementsCompleted[i]) + if (lastSensorVariable[i] and + nMeasurementsToAverage[i] > nMeasurementsCompleted[i]) { MS_DEEP_DBG(i), '-', arrayOfVars[i]->getParentSensorNameAndLocation(), F("- millis:"), millis(), @@ -372,8 +397,8 @@ bool VariableArray::updateAllSensors(void) ***/ // Only do checks on sensors that still have measurements to finish - if (isLastVarFromSensor(i) and - arrayOfVars[i]->parentSensor->getNumberMeasurementsToAverage() > nMeasurementsCompleted[i]) + if (lastSensorVariable[i] and + nMeasurementsToAverage[i] > nMeasurementsCompleted[i]) { // first, make sure the sensor is stable if ( arrayOfVars[i]->parentSensor->isStable(deepDebugTiming)) @@ -427,7 +452,7 @@ bool VariableArray::updateAllSensors(void) } // if all the measurements are done, mark the whole sensor as done - if (nMeasurementsCompleted[i] == arrayOfVars[i]->parentSensor->getNumberMeasurementsToAverage()) + if (nMeasurementsCompleted[i] == nMeasurementsToAverage[i]) { MS_DBG(F("--- Finished all measurements from"), arrayOfVars[i]->getParentSensorNameAndLocation(), F("---")); @@ -443,7 +468,7 @@ bool VariableArray::updateAllSensors(void) MS_DBG(F("----->> Averaging results and notifying all variables. ...")); for (uint8_t i = 0; i < _variableCount; i++) { - if (isLastVarFromSensor(i)) + if (lastSensorVariable[i]) { // MS_DBG(F("--- Averaging results from"), arrayOfVars[i]->getParentSensorNameAndLocation(), F("---")); arrayOfVars[i]->parentSensor->averageMeasurements(); @@ -630,7 +655,7 @@ bool VariableArray::completeUpdate(void) // THIS IS PURELY FOR DEEP DEBUGGING OF THE TIMING! // Leave this whole section commented out unless you want excessive // printouts (ie, thousands of lines) of the timing information!! - if (isLastVarFromSensor(i) and + if (lastSensorVariable[i] and nMeasurementsToAverage[i] > nMeasurementsCompleted[i]) { MS_DEEP_DBG(i), '-', From daf7f6d1b4c91002dfbe0065310eb3aa0c8f8112 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 12 Jun 2019 12:24:46 -0400 Subject: [PATCH 76/88] Additional conditions for a modem hard reset --- src/LoggerModem.cpp | 82 ++++++++++++++++++++++++++++++++------------- src/LoggerModem.h | 6 +++- 2 files changed, 64 insertions(+), 24 deletions(-) diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index b09022281..ff8447b58 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -36,6 +36,8 @@ loggerModem::loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, _lastNISTrequest = 0; _lastConnectionCheck = 0; _lastATCheck = 0; + + previousCommunicationFailed = false; } @@ -68,6 +70,10 @@ void loggerModem::modemHardReset(void) digitalWrite(_modemResetPin, LOW); delay(200); digitalWrite(_modemResetPin, HIGH); + // Re-set _millisSensorActivated - the hard reset is a new activation + _millisSensorActivated = millis(); + // Unset the flag for prior communication failure + previousCommunicationFailed = false; } } @@ -176,9 +182,8 @@ bool loggerModem::wake(void) // Sensor::wake() checks if the power pin is on and sets the wake timestamp // and status bits. If it returns false, there's no reason to go on. if (!Sensor::wake()) return false; - // NOTE: This is the ONLY place _millisSensorActivated is set! - // NOTE: This is the ONLY place bit 4 is set! - + // NOTE: _millisSensorActivated can be set here or by modemHardReset + // NOTE: This is the ONLY place status bit 4 is set! bool success = true; // Check the status pin and wake bits before running wake function @@ -198,7 +203,7 @@ bool loggerModem::wake(void) } // Re-check the status pin - // Only works if the status pin comes on immediately + // Only works if the status pin comes on immediately - most don't if (_dataPin >= 0 && _statusTime_ms == 0 && digitalRead(_dataPin) != _statusLevel) { MS_DBG(F("Status pin"), _dataPin, F("on"), getSensorName(), F("is"), @@ -247,6 +252,7 @@ bool loggerModem::isStable(bool debug) #if defined MS_LOGGERMODEM_DEBUG_DEEP debug = true; #endif + // If the modem never "woke", then it will never respond and thus it's // essentially already "stable." if (!bitRead(_sensorStatus, 4)) @@ -260,21 +266,36 @@ bool loggerModem::isStable(bool debug) uint32_t now = millis(); uint32_t elapsed_since_wake_up = now - _millisSensorActivated; - // If the modem has a status pin and it's off, give up + // If the modem has a status pin and it's still off after the specified time + // plus a 500ms buffer, then, if it's the first time this happened give up + // and move on. If it's happened twice in a row, try a hard reset and + // keep waiting. if ( (_dataPin >= 0 && elapsed_since_wake_up > (_statusTime_ms + 500) && digitalRead(_dataPin) != _statusLevel)) { - if (debug) MS_DBG(F("It's been"), (elapsed_since_wake_up), F("ms, and status pin"), + // if we maxed out the wait for the status pin after the previous wake + // and we've maxed it again after the most recent wake, do a hard reset + // and continue waiting + if (previousCommunicationFailed) + { + modemHardReset(); + return false; + } + else + { + if (debug) MS_DBG(F("It's been"), (elapsed_since_wake_up), F("ms, and status pin"), _dataPin, F("on"), getSensorName(), F("is"), digitalRead(_dataPin), F("indicating it is off. Will not continue to attempt communication!")); - // Unset status bit 4 (wake up success) and _millisSensorActivated - // We unset these bits here because it's possible that a modem "passed" - // the wake command, but never really woke. For sensors that take time - // before their status pin becomes active, (_statusTime_ms > 0) we - // don't know immediately that they failed to wake - _millisSensorActivated = 0; - _sensorStatus &= 0b11101111; - return true; + // Unset status bit 4 (wake up success) and _millisSensorActivated + // We unset these bits here because it's possible that a modem "passed" + // the wake command, but never really woke. For sensors that take time + // before their status pin becomes active, (_statusTime_ms > 0) we + // don't know that they failed to wake until we check here + _millisSensorActivated = 0; + _sensorStatus &= 0b11101111; + previousCommunicationFailed = true; + return true; + } } // We don't want to ping any of the modems too fast so they don't get @@ -287,20 +308,35 @@ bool loggerModem::isStable(bool debug) if (debug) MS_DBG(F("It's been"), (elapsed_since_wake_up), F("ms, and"), getSensorName(), F("is now responding to AT commands!")); _lastATCheck = now; + previousCommunicationFailed = false; return true; } - // If we've exceeded the documented time until UART should respond (plus 750ms buffer), give up + // If we've exceeded the documented time until UART should respond (plus + // 750ms buffer), then, if it's the first time this happened give up + // and move on. If it's happened twice in a row, try a hard reset and + // keep waiting. if (elapsed_since_wake_up > (_stabilizationTime_ms + 750)) { - if (debug) MS_DBG(F("It's been"), (elapsed_since_wake_up), F("ms, and"), - getSensorName(), F("has maxed out wait for AT command reply! Ending wait.")); - // Unset status bit 4 (wake up success) and _millisSensorActivated - // It's safe to unset these here because we've already tested and failed - // to respond to AT commands. - _millisSensorActivated = 0; - _sensorStatus &= 0b11101111; - return true; + if (previousCommunicationFailed) + { + // if we maxed out the wait last time and we've maxed it again, + // do a hard reset and continue waiting + modemHardReset(); + return false; + } + else + { + if (debug) MS_DBG(F("It's been"), (elapsed_since_wake_up), F("ms, and"), + getSensorName(), F("has maxed out wait for AT command reply! Ending wait.")); + // Unset status bit 4 (wake up success) and _millisSensorActivated + // It's safe to unset these here because we've already tested and failed + // to respond to AT commands. + _millisSensorActivated = 0; + _sensorStatus &= 0b11101111; + previousCommunicationFailed = true; + return true; + } } // If the modem isn't responding to AT commands yet, but its status pin shows diff --git a/src/LoggerModem.h b/src/LoggerModem.h index 26c5ecf8a..ab0c7fb40 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -164,7 +164,7 @@ class loggerModem : public Sensor int8_t _modemResetPin; int8_t _modemLEDPin; - // THis denotes whether we should run the wake/sleep functions regardless + // This denotes whether we should run the wake/sleep functions regardless // of the state of the status pins or if we should check the status pin first. bool _alwaysRunWake; @@ -172,9 +172,13 @@ class loggerModem : public Sensor uint32_t _statusTime_ms; uint32_t _disconnetTime_ms; + // A flag noting if the last wait for AT command responses failed + bool previousCommunicationFailed; + uint32_t _lastNISTrequest; uint32_t _lastATCheck; uint32_t _lastConnectionCheck; + String _modemName; }; From 3ba7de1e24593dec30bc76883b8ca1e5c1d38442 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Wed, 12 Jun 2019 13:06:07 -0400 Subject: [PATCH 77/88] Version bump --- examples/DRWI_CitSci/DRWI_CitSci.ino | 4 ++-- examples/DRWI_LTE/DRWI_LTE.ino | 4 ++-- examples/DRWI_NoCellular/DRWI_NoCellular.ino | 4 ++-- examples/baro_rho_correction/baro_rho_correction.ino | 4 ++-- examples/data_saving/data_saving.ino | 4 ++-- examples/double_logger/double_logger.ino | 4 ++-- examples/logging_to_MMW/logging_to_MMW.ino | 4 ++-- examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino | 4 ++-- examples/menu_a_la_carte/menu_a_la_carte.ino | 4 ++-- examples/simple_logging/simple_logging.ino | 4 ++-- .../simple_logging_LearnEnviroDIY.ino | 4 ++-- examples/single_sensor/single_sensor.ino | 4 ++-- library.json | 2 +- library.properties | 2 +- src/ModSensorDebugger.h | 2 +- 15 files changed, 27 insertions(+), 27 deletions(-) diff --git a/examples/DRWI_CitSci/DRWI_CitSci.ino b/examples/DRWI_CitSci/DRWI_CitSci.ino index a654350e8..8f089b756 100644 --- a/examples/DRWI_CitSci/DRWI_CitSci.ino +++ b/examples/DRWI_CitSci/DRWI_CitSci.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.2 +This example sketch is written for ModularSensors library version 0.22.3 This sketch is an example of logging data to an SD card and sending the data to both the EnviroDIY data portal as should be used by groups involved with @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.2"; +const char *libraryVersion = "0.22.3"; // The name of this file const char *sketchName = "DWRI_CitSci.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/DRWI_LTE/DRWI_LTE.ino b/examples/DRWI_LTE/DRWI_LTE.ino index 0a9d06944..608a43791 100644 --- a/examples/DRWI_LTE/DRWI_LTE.ino +++ b/examples/DRWI_LTE/DRWI_LTE.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.2 +This example sketch is written for ModularSensors library version 0.22.3 This sketch is an example of logging data to an SD card and sending the data to both the EnviroDIY data portal as should be used by groups involved with @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.2"; +const char *libraryVersion = "0.22.3"; // The name of this file const char *sketchName = "DRWI_LTE.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/DRWI_NoCellular/DRWI_NoCellular.ino b/examples/DRWI_NoCellular/DRWI_NoCellular.ino index 340e25d39..526c6880c 100644 --- a/examples/DRWI_NoCellular/DRWI_NoCellular.ino +++ b/examples/DRWI_NoCellular/DRWI_NoCellular.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.2 +This example sketch is written for ModularSensors library version 0.22.3 This sketch is an example of logging data to an SD card as should be used by groups involved with The William Penn Foundation's Delaware River Watershed @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.2"; +const char *libraryVersion = "0.22.3"; // The name of this file const char *sketchName = "DRWI_NoCellular.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/baro_rho_correction/baro_rho_correction.ino b/examples/baro_rho_correction/baro_rho_correction.ino index 22837593c..440ac3b4d 100644 --- a/examples/baro_rho_correction/baro_rho_correction.ino +++ b/examples/baro_rho_correction/baro_rho_correction.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.2 +This example sketch is written for ModularSensors library version 0.22.3 This sketch is an example of logging data to an SD card and sending the data to the EnviroDIY data portal. @@ -27,7 +27,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.2"; +const char *libraryVersion = "0.22.3"; // The name of this file const char *sketchName = "baro_rho_correction.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/data_saving/data_saving.ino b/examples/data_saving/data_saving.ino index c04998824..87b6f4be7 100644 --- a/examples/data_saving/data_saving.ino +++ b/examples/data_saving/data_saving.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.2 +This example sketch is written for ModularSensors library version 0.22.3 This sketch is an example of logging data to an SD card and sending only a portion of that data to the EnviroDIY data portal. @@ -27,7 +27,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.2"; +const char *libraryVersion = "0.22.3"; // The name of this file const char *sketchName = "data_saving.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/double_logger/double_logger.ino b/examples/double_logger/double_logger.ino index f0853ed27..4abcb9d29 100644 --- a/examples/double_logger/double_logger.ino +++ b/examples/double_logger/double_logger.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.2 +This example sketch is written for ModularSensors library version 0.22.3 This sketch is an example of logging data from different variables at two different logging intervals. This example uses more of the manual functions @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.2"; +const char *libraryVersion = "0.22.3"; // The name of this file const char *sketchName = "double_logger.ino"; // Logger ID - we're only using one logger ID for both "loggers" diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index 6ffd74c72..7c3cd6d40 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.2 +This example sketch is written for ModularSensors library version 0.22.3 This shows most of the standard functions of the library at once. @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.2"; +const char *libraryVersion = "0.22.3"; // The name of this file const char *sketchName = "logging_to MMW.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino index d7b3ba999..5bc9dfd53 100644 --- a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino +++ b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.2 +This example sketch is written for ModularSensors library version 0.22.3 This sketch is an example of logging data to an SD card and sending the data to ThingSpeak. @@ -27,7 +27,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.2"; +const char *libraryVersion = "0.22.3"; // The name of this file const char *sketchName = "logging_to_ThingSpeak.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 4a26952a2..7b0a4bbff 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.2 +This example sketch is written for ModularSensors library version 0.22.3 This shows most of the standard functions of the library at once. @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.2"; +const char *libraryVersion = "0.22.3"; // The name of this file const char *sketchName = "menu_a_la_carte.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/simple_logging/simple_logging.ino b/examples/simple_logging/simple_logging.ino index 9c8d3d5c3..f4251fce7 100644 --- a/examples/simple_logging/simple_logging.ino +++ b/examples/simple_logging/simple_logging.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.2 +This example sketch is written for ModularSensors library version 0.22.3 This sketch is an example of logging data to an SD card @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.2"; +const char *libraryVersion = "0.22.3"; // The name of this file const char *sketchName = "simple_logging.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino b/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino index 037cc397c..02d820cde 100644 --- a/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino +++ b/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.2 +This example sketch is written for ModularSensors library version 0.22.3 This sketch is an example of logging data to an SD card @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.2"; +const char *libraryVersion = "0.22.3"; // The name of this file const char *sketchName = "simple_logging.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/single_sensor/single_sensor.ino b/examples/single_sensor/single_sensor.ino index 7325db664..6e93e5ffe 100644 --- a/examples/single_sensor/single_sensor.ino +++ b/examples/single_sensor/single_sensor.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.2 +This example sketch is written for ModularSensors library version 0.22.3 This sketch is an example of getting data from a single sensor, in this case, a MaxBotix Ultrasonic Range Finder @@ -24,7 +24,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. #include // The library version this example was written for -const char *libraryVersion = "0.22.2"; +const char *libraryVersion = "0.22.3"; // The name of this file const char *sketchName = "single_sensor.ino"; diff --git a/library.json b/library.json index d5d5b5417..9e27f98bf 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "EnviroDIY_ModularSensors", - "version": "0.22.2", + "version": "0.22.3", "description": "A library that allows access to multiple sensors through a unified interface. This allows the user to simply access many sensors to log the data or send the data to data repositories like the EnviroDIY data portal.", "keywords": "modular, sensor, sensors, datalogger, logger, low power, sleeping, EnviroDIY, ModularSensors, Mayfly, WikiWatershed, ThingSpeak", "platforms": "atmelavr, atmelsam", diff --git a/library.properties b/library.properties index 4cc8f6ebc..d75f8554a 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=EnviroDIY_ModularSensors -version=0.22.2 +version=0.22.3 author=Sara Damiano , Shannon Hicks maintainer=Sara Damiano sentence=A library that allows access to multiple sensors through a unified interface. diff --git a/src/ModSensorDebugger.h b/src/ModSensorDebugger.h index cf4f0cdbe..2932e16b6 100644 --- a/src/ModSensorDebugger.h +++ b/src/ModSensorDebugger.h @@ -15,7 +15,7 @@ #include // The current library version number -#define MODULAR_SENSORS_VERSION "0.22.2" +#define MODULAR_SENSORS_VERSION "0.22.3" #ifndef STANDARD_SERIAL_OUTPUT // #if defined(ARDUINO_SAMD_ZERO) && defined(SERIAL_PORT_USBVIRTUAL) From 88f501f4a09aa59cbbe25a904d92d745df412376 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Thu, 20 Jun 2019 14:22:53 -0400 Subject: [PATCH 78/88] Turned off extra modbus deep debugging - remnant of debug change --- src/sensors/KellerParent.cpp | 2 +- src/sensors/YosemitechParent.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/sensors/KellerParent.cpp b/src/sensors/KellerParent.cpp index 1ecf50a5d..dd3813a37 100644 --- a/src/sensors/KellerParent.cpp +++ b/src/sensors/KellerParent.cpp @@ -66,7 +66,7 @@ bool KellerParent::setup(void) if (_RS485EnablePin >= 0) pinMode(_RS485EnablePin, OUTPUT); if (_powerPin2 >= 0) pinMode(_powerPin2, OUTPUT); - #if defined(DEEP_DEBUGGING_SERIAL_OUTPUT) + #ifdef MS_KELLERPARENT_DEBUG_DEEP sensor.setDebugStream(&DEEP_DEBUGGING_SERIAL_OUTPUT); #endif diff --git a/src/sensors/YosemitechParent.cpp b/src/sensors/YosemitechParent.cpp index bf366120a..a0c398db5 100644 --- a/src/sensors/YosemitechParent.cpp +++ b/src/sensors/YosemitechParent.cpp @@ -64,7 +64,7 @@ bool YosemitechParent::setup(void) if (_RS485EnablePin >= 0) pinMode(_RS485EnablePin, OUTPUT); if (_powerPin2 >= 0) pinMode(_powerPin2, OUTPUT); - #if defined(DEEP_DEBUGGING_SERIAL_OUTPUT) + #ifdef MS_YOSEMITECHPARENT_DEBUG_DEEP sensor.setDebugStream(&DEEP_DEBUGGING_SERIAL_OUTPUT); #endif @@ -80,7 +80,7 @@ bool YosemitechParent::setup(void) // Different from the standard in that it waits for warm up and starts measurements bool YosemitechParent::wake(void) { - // Sensor::wake() checks if the power pin is on and sets the wake timestamp + // Sensor::wake() checks if the power pin is on and sets the wake timestamp // and status bits. If it returns false, there's no reason to go on. if (!Sensor::wake()) return false; From c2e2e71f793a3a61adfa9f1a4ad6ba6a255a6e18 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 24 Jun 2019 11:35:02 -0400 Subject: [PATCH 79/88] Fix for most current version of AM2315 --- library.json | 4 ++-- src/sensors/AOSongAM2315.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library.json b/library.json index 9e27f98bf..6b543cb95 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "EnviroDIY_ModularSensors", - "version": "0.22.3", + "version": "0.22.4", "description": "A library that allows access to multiple sensors through a unified interface. This allows the user to simply access many sensors to log the data or send the data to data repositories like the EnviroDIY data portal.", "keywords": "modular, sensor, sensors, datalogger, logger, low power, sleeping, EnviroDIY, ModularSensors, Mayfly, WikiWatershed, ThingSpeak", "platforms": "atmelavr, atmelsam", @@ -119,7 +119,7 @@ "name": "Adafruit AM2315", "library id": "773", "url": "https://github.com/adafruit/Adafruit_AM2315.git", - "version": "=1.0.1", + "version": "=2.0.0", "note": "AOSong AM2315 I2C Temp/Humidity Sensor Library by Adafruit", "authors": [ "Adafruit" diff --git a/src/sensors/AOSongAM2315.cpp b/src/sensors/AOSongAM2315.cpp index c11dc472f..acb71a0ba 100644 --- a/src/sensors/AOSongAM2315.cpp +++ b/src/sensors/AOSongAM2315.cpp @@ -66,7 +66,7 @@ bool AOSongAM2315::addSingleMeasurementResult(void) MS_DBG(getSensorNameAndLocation(), F("is reporting:")); Adafruit_AM2315 am2315; // create a sensor object - ret_val = am2315.readTemperatureAndHumidity(temp_val, humid_val); + ret_val = am2315.readTemperatureAndHumidity(&temp_val, &humid_val); if (!ret_val or isnan(temp_val)) temp_val = -9999; if (!ret_val or isnan(humid_val)) humid_val = -9999; From bd35e40cf34cd794587a8819427bb6994a6c4a1d Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 24 Jun 2019 11:37:50 -0400 Subject: [PATCH 80/88] Rename from "sendData" to "publishData" --- examples/DRWI_CitSci/DRWI_CitSci.ino | 2 +- examples/DRWI_LTE/DRWI_LTE.ino | 2 +- examples/baro_rho_correction/baro_rho_correction.ino | 2 +- examples/data_saving/data_saving.ino | 2 +- examples/logging_to_MMW/logging_to_MMW.ino | 2 +- .../logging_to_ThingSpeak/logging_to_ThingSpeak.ino | 2 +- examples/menu_a_la_carte/menu_a_la_carte.ino | 4 ++-- src/LoggerBase.cpp | 10 +++++----- src/LoggerBase.h | 4 ++-- src/dataPublisherBase.cpp | 4 ++-- src/dataPublisherBase.h | 4 ++-- src/publishers/DreamHostPublisher.cpp | 2 +- src/publishers/DreamHostPublisher.h | 2 +- src/publishers/EnviroDIYPublisher.cpp | 2 +- src/publishers/EnviroDIYPublisher.h | 2 +- src/publishers/ThingSpeakPublisher.cpp | 2 +- src/publishers/ThingSpeakPublisher.h | 2 +- 17 files changed, 25 insertions(+), 25 deletions(-) diff --git a/examples/DRWI_CitSci/DRWI_CitSci.ino b/examples/DRWI_CitSci/DRWI_CitSci.ino index 8f089b756..694950c71 100644 --- a/examples/DRWI_CitSci/DRWI_CitSci.ino +++ b/examples/DRWI_CitSci/DRWI_CitSci.ino @@ -351,6 +351,6 @@ void loop() // If the battery is good, send the data to the world else { - dataLogger.logDataAndSend(); + dataLogger.logDataAndPublish(); } } diff --git a/examples/DRWI_LTE/DRWI_LTE.ino b/examples/DRWI_LTE/DRWI_LTE.ino index 608a43791..fd7876882 100644 --- a/examples/DRWI_LTE/DRWI_LTE.ino +++ b/examples/DRWI_LTE/DRWI_LTE.ino @@ -365,6 +365,6 @@ void loop() // If the battery is good, send the data to the world else { - dataLogger.logDataAndSend(); + dataLogger.logDataAndPublish(); } } diff --git a/examples/baro_rho_correction/baro_rho_correction.ino b/examples/baro_rho_correction/baro_rho_correction.ino index 440ac3b4d..f3acfa3b4 100644 --- a/examples/baro_rho_correction/baro_rho_correction.ino +++ b/examples/baro_rho_correction/baro_rho_correction.ino @@ -459,6 +459,6 @@ void loop() // If the battery is good, send the data to the world else { - dataLogger.logDataAndSend(); + dataLogger.logDataAndPublish(); } } diff --git a/examples/data_saving/data_saving.ino b/examples/data_saving/data_saving.ino index 87b6f4be7..05d6a2aa3 100644 --- a/examples/data_saving/data_saving.ino +++ b/examples/data_saving/data_saving.ino @@ -624,7 +624,7 @@ void loop() if (modem.connectInternet()) { // Publish data to remotes - loggerToGo.sendDataToRemotes(); + loggerToGo.publishDataToRemotes(); // Sync the clock at midnight // NOTE: All loggers have the same clock, pick one diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index 7c3cd6d40..bbb728f27 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -360,6 +360,6 @@ void loop() // If the battery is good, send the data to the world else { - dataLogger.logDataAndSend(); + dataLogger.logDataAndPublish(); } } diff --git a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino index 5bc9dfd53..3b34ec97f 100644 --- a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino +++ b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino @@ -359,6 +359,6 @@ void loop() // If the battery is good, send the data to the world else { - dataLogger.logDataAndSend(); + dataLogger.logDataAndPublish(); } } diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 7b0a4bbff..40c65e59e 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -1520,7 +1520,7 @@ void loop() // If the battery is good, send the data to the world else { - dataLogger.logDataAndSend(); + dataLogger.logDataAndPublish(); } } // */ @@ -1576,7 +1576,7 @@ void loop() if (modem.connectInternet()) { // Publish data to remotes - dataLogger.sendDataToRemotes(); + dataLogger.publishDataToRemotes(); // Sync the clock at midnight if (Logger::markedEpochTime != 0 && Logger::markedEpochTime % 86400 == 0) diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index 64d4b2562..8a588cfd2 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -414,7 +414,7 @@ void Logger::registerDataPublisher(dataPublisher* publisher) } -void Logger::sendDataToRemotes(void) +void Logger::publishDataToRemotes(void) { MS_DBG(F("Sending out remote data.")); @@ -423,8 +423,8 @@ void Logger::sendDataToRemotes(void) if (dataPublishers[i] != NULL) { PRINTOUT(F("\nSending data to"), dataPublishers[i]->getEndpoint()); - // dataPublishers[i]->sendData(_logModem->getClient()); - dataPublishers[i]->sendData(); + // dataPublishers[i]->publishData(_logModem->getClient()); + dataPublishers[i]->publishData(); } } } @@ -1378,7 +1378,7 @@ void Logger::logData(void) systemSleep(); } // This is a one-and-done to log data -void Logger::logDataAndSend(void) +void Logger::logDataAndPublish(void) { // Assuming we were woken up by the clock, check if the current time is an // even interval of the logging interval @@ -1417,7 +1417,7 @@ void Logger::logDataAndSend(void) if (_logModem->connectInternet()) { // Publish data to remotes - sendDataToRemotes(); + publishDataToRemotes(); // Sync the clock at midnight if (Logger::markedEpochTime != 0 && Logger::markedEpochTime % 86400 == 0) diff --git a/src/LoggerBase.h b/src/LoggerBase.h index 8ac2eeec2..2d2838434 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -172,7 +172,7 @@ class Logger // These tie the variables to their parent sensor void registerDataPublisher(dataPublisher* publisher); // Notifies attached variables of new values - void sendDataToRemotes(void); + void publishDataToRemotes(void); protected: // The internal modem instance @@ -353,7 +353,7 @@ class Logger // This is a one-and-done to log data virtual void logData(void); - void logDataAndSend(void); + void logDataAndPublish(void); // Public variables // Time stamps - want to set them at a single time and carry them forward diff --git a/src/dataPublisherBase.cpp b/src/dataPublisherBase.cpp index 0cde30006..394d4c63a 100644 --- a/src/dataPublisherBase.cpp +++ b/src/dataPublisherBase.cpp @@ -117,12 +117,12 @@ void dataPublisher::printTxBuffer(Stream *stream) // This sends data on the "default" client of the modem -int16_t dataPublisher::sendData() +int16_t dataPublisher::publishData() { if (_inClient == NULL) { PRINTOUT(F("ERROR! No web client assigned to publish data!")); return 0; } - else return sendData(_inClient); + else return publishData(_inClient); } diff --git a/src/dataPublisherBase.h b/src/dataPublisherBase.h index 5eb9fb660..c183bf6a4 100644 --- a/src/dataPublisherBase.h +++ b/src/dataPublisherBase.h @@ -72,8 +72,8 @@ class dataPublisher // This opens a socket to the correct receiver and sends out the formatted data // This depends on an internet connection already being made and a client // being available - virtual int16_t sendData(Client *_outClient) = 0; - virtual int16_t sendData(); + virtual int16_t publishData(Client *_outClient) = 0; + virtual int16_t publishData(); protected: // The internal logger instance diff --git a/src/publishers/DreamHostPublisher.cpp b/src/publishers/DreamHostPublisher.cpp index a03dd9e49..74a5baa02 100644 --- a/src/publishers/DreamHostPublisher.cpp +++ b/src/publishers/DreamHostPublisher.cpp @@ -120,7 +120,7 @@ void DreamHostPublisher::begin(Logger& baseLogger, // Post the data to dream host. // int16_t DreamHostPublisher::postDataDreamHost(void) -int16_t DreamHostPublisher::sendData(Client *_outClient) +int16_t DreamHostPublisher::publishData(Client *_outClient) { // Create a buffer for the portions of the request and response char tempBuffer[37] = ""; diff --git a/src/publishers/DreamHostPublisher.h b/src/publishers/DreamHostPublisher.h index 75e55aea5..21cb5e1cb 100644 --- a/src/publishers/DreamHostPublisher.h +++ b/src/publishers/DreamHostPublisher.h @@ -71,7 +71,7 @@ class DreamHostPublisher : public dataPublisher // over that connection. // The return is the http status code of the response. // int16_t postDataDreamHost(void); - int16_t sendData(Client *_outClient); + int16_t publishData(Client *_outClient); protected: // portions of the GET request diff --git a/src/publishers/EnviroDIYPublisher.cpp b/src/publishers/EnviroDIYPublisher.cpp index 4375c6042..294c4bd9d 100644 --- a/src/publishers/EnviroDIYPublisher.cpp +++ b/src/publishers/EnviroDIYPublisher.cpp @@ -195,7 +195,7 @@ void EnviroDIYPublisher::begin(Logger& baseLogger, // over that connection. // The return is the http status code of the response. // int16_t EnviroDIYPublisher::postDataEnviroDIY(void) -int16_t EnviroDIYPublisher::sendData(Client *_outClient) +int16_t EnviroDIYPublisher::publishData(Client *_outClient) { // Create a buffer for the portions of the request and response char tempBuffer[37] = ""; diff --git a/src/publishers/EnviroDIYPublisher.h b/src/publishers/EnviroDIYPublisher.h index a83d511bf..15f609886 100644 --- a/src/publishers/EnviroDIYPublisher.h +++ b/src/publishers/EnviroDIYPublisher.h @@ -79,7 +79,7 @@ class EnviroDIYPublisher : public dataPublisher // over that connection. // The return is the http status code of the response. // int16_t postDataEnviroDIY(void); - virtual int16_t sendData(Client *_outClient); + virtual int16_t publishData(Client *_outClient); protected: diff --git a/src/publishers/ThingSpeakPublisher.cpp b/src/publishers/ThingSpeakPublisher.cpp index bcba2ca7c..8b8ee2008 100644 --- a/src/publishers/ThingSpeakPublisher.cpp +++ b/src/publishers/ThingSpeakPublisher.cpp @@ -125,7 +125,7 @@ void ThingSpeakPublisher::begin(Logger& baseLogger, // This sends the data to ThingSpeak // bool ThingSpeakPublisher::mqttThingSpeak(void) -int16_t ThingSpeakPublisher::sendData(Client *_outClient) +int16_t ThingSpeakPublisher::publishData(Client *_outClient) { bool retVal = false; diff --git a/src/publishers/ThingSpeakPublisher.h b/src/publishers/ThingSpeakPublisher.h index 320b6eb5a..0ddaace9f 100644 --- a/src/publishers/ThingSpeakPublisher.h +++ b/src/publishers/ThingSpeakPublisher.h @@ -86,7 +86,7 @@ class ThingSpeakPublisher : public dataPublisher // This sends the data to ThingSpeak // bool mqttThingSpeak(void); - virtual int16_t sendData(Client *_outClient); + virtual int16_t publishData(Client *_outClient); protected: static const char *mqttServer; From 1ea5593e8cd1f8c275c85ced7bc1cab2ad6ec5bc Mon Sep 17 00:00:00 2001 From: Anthony Aufdenkampe Date: Mon, 24 Jun 2019 10:58:20 -0500 Subject: [PATCH 81/88] Create Maxbotix_MaxSonar_MB7954_Datasheet_ConnectWire.pdf --- ...ix_MaxSonar_MB7954_Datasheet_ConnectWire.pdf | Bin 0 -> 50839 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 doc/Maxbotix_MaxSonar_MB7954_Datasheet_ConnectWire.pdf diff --git a/doc/Maxbotix_MaxSonar_MB7954_Datasheet_ConnectWire.pdf b/doc/Maxbotix_MaxSonar_MB7954_Datasheet_ConnectWire.pdf new file mode 100644 index 0000000000000000000000000000000000000000..1eb1330e2ff93eb9344ae85f4a4e322c7fe1ab07 GIT binary patch literal 50839 zcmbrl1yo#1wm*yn2oNL?2o~s|!D-w*xVyW%y9I~f!8JI+-QC^Y-QAt9$=v(y+?jdv z*82XvRt~3jRqfi|C%?0sNQz&85=cdl07taGF*1PwM+cw*Sn8M{z_GI09XiW(@d$`5?eK+2|X*ib)G%OY_GE$OQO(2e9}b8Vl{e(SSgDkan-1zt#ci z>6!nH#>hnbZ!{K~f1@$d)Bf9DMkYFzf8EQ-!p!imG$vZQf0YGD%Ru|@G-gJcf7uJ9 zWnp0aR~jA7zw@I5(gXi(9WCv@(rD@Ef&VHWEfWLCv46J}9Xx=;m>;0ZPET(@!=$gx$f!?epwFz!qOD7>N2jC1prfbFOv|86%lUt= z00r}Fu-e*b+t~dh)M!AtLG)Ep00Hj*C2;@$>_vck)$XrslykPy2T=2A+i9Cw8oruF z+fd&Y0P@qTIsQ4tXhHt`r+u;jx>rjI7@OJY+W@Eq%(U(F`So=z_4GkhF?|a|J0k$o zA6aT^XQQue4ob6RT`etSZ7r?lZm>5G*%+nZh=kQ|KhV+K(w+h(SLvnT#q>1V7s1?&JmUI# z#@f7=PM`tUO|y)m|yTBkFbe>n>v(TRT1@ZJU48dhI_4 zuZgEFr`&#rt^^%eC^&bm>iIEn-$jk(w2h}4wdRhPrBmM8c4D^fuCXk^SKy`rb zk1q&WdmX#qhsoL4>%SiR_lSKJ@h|=U66-H5UIhfnDWPo+%7On~ZQegkNeKj1Y!(`N z022et@8|)Ay`e1t^i4<2W2^h>0MGm#} z{Uh*X?extR06@CeFFA2zTU%ob!{4?6MH|g)V7|%-N;G|1z#s1ZXD_~z{?hUvnFj?^N7Q^_fLirLsnPCj<0Is1A`o+w5xkMKlZLmr(hy*vVqQ=*3q2(j`vvfExJU>4lBLo;e#tGYtQ`oNE>joQc|2v# zQFyHd-=~F{YRlkKGJJ47cHjGP^CQ!Sti*XuK+(^~KB19&1ZGROLvuM?=eJIytyLU~d+PXcA&NA;gcLw33@;y6GZu<3O?n|czdjX3ZkJN|5i3Dh z#3M0vs0C)I0|$K!O2P8Rc>+Axkk*|z?$%hjbIc!CP_G&`oC@ilw-}0d64Bj?hA};R zopW|Q*{GZ&7A5b6ueZKDKGgBPHCi9r;ZM=kyxs@CM@{Z3M;VZIf`C8<)Ma^1Mz#1z zmfe_5E+P3?VcBc&BzgLT)A(YQ$D0vKmxlvsE8@HI3`s)uNNgc(6KuaFF7_$)iCinw zipX^esGU+gqIh(WopD9*ow8N?vVbSiEL%qHb@p&}N$7vwX21C0RZ?7(Q=f0+^3_@S zm!pbsnW2faHc#^c(GCj{kcnggNHma|pe-s{q4K7p&uH|Z600hBN6DWXD18|Et&O6p zXU&e)hltdrKc=$1-ftuYPN_u7MomB39WBKcErpF|C6Bv)oPvpQEDR?7jsR->LsT)? zC%>#EFM{ll$CLv77c!!PGCCZA@5IUx(c7ZSlX58TNc;AoHo9@eSs2jvF8o)4=@xns z^qPVwZzm2*u=TigDM%Fxas8|xNDCF*8rlPU#b;4P#-9l>gON^BDIn;vd&Z+Mq~$_` zS%JlsB4<_PrJ`6AxM9b*C|b_5y1UVA3vn4c^VVTLt@Te!=9A$baBCLAYo!3vAd?O-y9X)%=j=-ywsbG7b{GNfkuEiPU&eEZ|sw3|l1N8D*jV zSV+R@E0wfrCq<-v+~5rw)?#${DfB4{;sTO3e|j{(06OCnL(rx*G^|S1bDzlCk~hWI zmN$OBTan)tZRTZhVpMNYzRXiF1!RsHD4T@&XCCpLHE)#@_Kvm1#u|0vbxW&48ZmtE zbco|KUj8KKYsK`7Z)M`0Q7T@ZBQs^2b-8`=8!=Kb3U?irU8u()35H#LBY0*ayUBL$ z(Qh7bQjG{_dZMVXs5Q{K$u`(m(uzaAu2`~p6T%g?GZ9F!1nHMU@Px*&v20;JBL{6x zzQ6RG)O1vZh}<`#U@uBTGTBpZQ7cFjAA{1Adxb6>XGjS*THZSnZHcJpdfC&o5q2{x z1@E!fP8gCU;C8}uNWW`8D93mDz)5o$j~V?2J{64K1%5Nu`8#A37i%Pxu!KoAJrd2- z*7dQG3Hex7Pv%c;DPp#5g!|qwsPB-uP>;DQW9ZDo$T`48WE{J63M-ZNOoldn;@aq_ zFHn^9;Nf(MzP;A-Fr#r1Hn0NT#~An#tH#~VZ&>}~2_=P2PumKR_&#MpqiN8T3Ug)a zF#lZTxH+!lmsi-YWTvzzd~5P#h=&ws3?Dek)<$}m;d{t$8ZgrSnAm#2ZGm4Cfjchh zw2lz!<(O4i8K{&jCQK3R$-}lMWO(LJo)KuE%~XL$VzfykKOIMZ%k=8 z3%&I0?oQ9`PzUulkGd2~M=35NN5u)E_lpzR`cnu*;nXGr9yT{22}GMQ41%UuCbt*Y z_#++Z43gp#o5_SFbvsH>jMwG;Q7o>9p~_5Im?)69*%>tb z9GVWgcdL%S*l)bYtjD}hs;sbAy?mO_^GLe}E`htd#8BlO=({*e1SBoSnU^bExI?EW zrlXDQDiy^Q?6j--ZZPL-2{PuwgvpyKS7{8;HCc_nA-*(oyNyN{ug*^c!fA#&@hT~s zn6{}}4i#Rx@G8Z{xUi=p!}_t~su5W0Y%3+Jtjjf_E?_laJYcO!+o0PX3fROxS((vQ zJgLHXdJJ|yzQ<7d@Pc&wp$1{lNm6|+Nx%A{OZj^4@$e9UH`pAbso%`tn(3-8oz*GC zi3<9!$+r=sVyZ6@NUm=-)bu)AlHqYy^ z^?Vf{j)@t$DLMv2X^*Y?9KIJ9RYelg$F1$8EXY5!BBrVJPn#O*#jv;) zrX>|56r?0gZ5q9g3#l!|-e$sv&@1pBx(XYMO`CcxUKS=lwB1kX=Im0a| z_k#~cSuhjOow0bJUEX|(U9^}&Lr2wao_*+AUp<=9X&j|3NN=QZ7*QYAOP(1qmjLSDynz1=x zw4!iuXA=)5=4X^#AshzX8X_;3CvqS+#&|x0DS-;Qp}Y1WM0X`;G;4M~Z~?>A%**aT z=V{ZTcmug?w8`#+BnA0BBczENZCUo5feJoj*js@i0%Pw!Gs36S!lp^wYC7-c6(`mo z#PCBF^GvuxmlQUvluo0YB;((RtBUgB)O9wB$^^w@FR>r>)#-L?*V-6JMu0@(3q+2o zgr2V74r&{+uZozg?Z4eNxN$mirDD@EyDKbsDOe$vVs4wCHZFWiw_0<;KzPT;QSASA zHM%t_PZ(`^tfxmodd1K{>gM9EjIL}&hlTHvFnsgJfv$(LgYfwJ-o#E_3Y61#r0H0w zgz{NDUFs+oH@aTJnJ)hxkBvDu)1D{4ug-I_@D7D)^-X!LTUi?Com|>XXIv04gJ)<5 zPB0_!SMND8KZfjgxTMUj^|B8d#P6oP-;B2n?EZ3jK+j>4(S7)u#Ir$U6}P@T zUdDXON$5U&##U+>m@1|NahD)mExUma1l}jW5Zp^vjV{wkEQy5-qInrngDQuBu&MX{ zihB$uMr}}tU79z_Qa_i|W!{G(Vo2z3YkhfshCPImoVszB;Fkj>OSbG8SxRb$qDAIR zV97E>kChX2y63L&URTpr+hj%$(HvEXv&9N0JHf z=|3GiRe6w%O(~lKvZ9+lCmPUK2=IPxy~M}euh2dfTc$oFR68Q1eacO#<^GUW3}3x@ zmz|2aq5DvFx=E}2ZR>n)_ETAS*&>g_nnxdD!*D0(cXf?R^n|L->U_+pf{(F!tmVbj zCWU#)NeKyU?96kq*M7uEJuWEfmk|LqkqKpSvk{~{b%oAzv5k^AM8rSt;VY(OQg1K4 zS_?eu$D9s#DYp|ey*clmHb_j--S`$1aXt332OfH^vBHh6Gm6nABPU7V!9qD1@ml44 z&KE)jiQN%II2-7Dv0%2HZ`0bKn6GNy#C#g|_-Hk-THN>3!0vDCk>^2aU_N}yyc=iA#s?Znhm^(v{<#ifnD|StEIkm!m%Xni!156JRr~g>ITUT zM-qXAEyD~+Je$_8T#Fc%Wrb+ZDYC|{hs+13$ivy^!-!*zRtQ5XUqevngnG3r#C;+Csvj;jSI2^IIOAz@6Ap%^E$y4I` zs1N1l_$(0V#5%Y%VDww;@ff`P_Dk2|5F}6HkAkl}nF~x0<4w56uRy zErjiP^!-9<)gJv$)YF=cd-$sN4x8rNooBpfx3J%LIix-D3;CmaRUZRBs;$GkU52;w zLgni48~wH}NpLQ3LVw2Ie$W(kt5Wh6N5Bbut*zp$BINE}P}*mo9txdJjQ3$eg7NBX zqFuWZCAAebyo+O&A8QB}SGZIgOIGkL4oXlT%92tu1H#AzsXuMGNg`|is+_Eeeu8ja zoHza0GQ%c#*m13abB60Xy=-Nf6^Aw`0qkIumn%rtiFMEKEt3EavC30W0VS{E;m&Yn zv~22zoXdr65^cZ!AYkh;8cEct)Yro*GTsxY&;nwF5c??PGUZKTK@OZj144LcZW1ul z@+G@&XE|emd>o5!npzXuzUNWr!UTO>WeD`?2J#Uk9?;{f7Q9avAgESA?wW_7G)EA@ zYIET6ky$gw9B*~YUYy7g5f?T!L zdYw;(iTWaDd zI_{o+c0XOQ;(EGssoSp1e{Q0B{-J;-ix`7DP~jp&w(u-KrhN%8r{MQ&{c9@|H2s}8H@jXC@m@(Lpa-l% z0yvsaN(gXT^at>8S_B1O!HGLq)4{HLUAVz<%5bH@5DF2YXeik;!K(c@;Iss%y&#NC zM2{Cvo7EPVf1Hn~kd_oJP2<+Y(muI!E5k|t3O$CIFmmDgk7oM~yZ&Xjf5IvyRfKqi z{s*i42eS4DWcC-%2LPe9|G-KAf-8Z4!mED)gRlGk7rc@QH1|JvB|QlJ1HFI&(1YFw zF|aTK7-@h2Iu;OO%R~=g1idq11fjTe3?QtM1qfgOfxC<}Ouxs!=jcGt=PQHPH(dV* zfcabMzqI~K(7!bML)AYJ%>QDHzc5T%8b$y!69WiorT;POYc81O=ddg{}a<>0J4A(*1u=X zkuriE>P$?tr2+kT?>%NH;Xt)nxbLG6CH7qGiyltlY%D4bY&S*^gq&VP+ap_B4mTK^ zm${A*1mUA^mN4kaE17X21eTPTxsyda$(NDTS1&2bHws-y_>6dnk)^@h>?9@93}WH9 zykV)LVdpU9IO*Zo-SfuvX6eS@%^R@GQ7HP!p~MZ++m5x7b?I|(nT>V%A@i5p+nrBf zS;!ZTR2nnKwb=$am=_C?RMf_*_4}jYSgv5ZF<|*C)arHGeXDfgE8wjR+L-|=s)+=6 z7HkinxgYV$Jgmv#oJe-wlx}Hp7TL=`xXgq!MAS@yOIenvRn*ok&pBap%V1Tv*vMbp zGrADBonJ30Etl0h%MTD9OfAV-B5S1hlNu?SB4%! zqZzGk7i0Ik3vkk@lK?a~qCI$E-pQ^1Xv3~bOX%+2bg>C`hMw5@47uHYB!%GECKiuC zS89Nam5!UkM@io%4K@v-(s}YOaAR+Vn)pLZh`XITD;DO%I`L6GX@@0x*4g*u^m2;` ziYFvTH)s#I5&$&q69)7e#xj>LiPSSzqc3g3{HnbZG-9S55<9$PM~xPjn_{0i$%knO zCqxI$nf<3-alAH_O)PD+$`1EZcwB#yGW2`&OK#5ScIae3fEylkX$kcjsS}PvtBaBk zdHP3OUqR_}h-5$V&UXa-01X)lBH5|QAB2AAQb=Q_*6e~-gd@`Mq$JLXAzDR(R%U|Q zpQ=m0#{y7$E-{Ftb(x2IthVvMPve-P??gm{zr!^_-8rX{*0CHP7WO4z?im*gO9aFx zMwv;9h?RD!QW~^%Vk5YyC&y0YDWmbpzOf06mYSMO%X3&rkuaoTij}PAq#oOQ+>wCw zJ%F3D%!_v8Lh%j=5f0W~Myg&-W=*Ta?0GaH84@aq&1R*jeFCTv>9YUO5f8Rl8e zfFXTvw@~jyGuH6xW!S)Y_$Gl=$=J&btp``bN(hauh{7g<^G!i8P1K)Y6svnuKD6pN z1E)((Ube)xmkRdwoe*)29d>N3`NmharH?{N+YuG+?oEh$zvjd>XIQuBG2RicdObi; znIU7tQd^XL{2Y2?B*|n$kYBHUdy^0;;pW_B1eQYIHhJDF7ef=gLh6ZmG zJPRWIz@|fRhAVM2hg?$T)FSK=i24t#3duT%8D1@WWiT1<5X2>5AQ);$jRcbu^_s!& zc4Zw1?G|N{H!#d-1t_yoPvyFla%HcFQy@K*d@+BSI>^$WczwMlSiPyW=4>xFFjCV^ zAvdk>WjEB8|-67TLD>Fr5^EYe2_dSRNRly1^1Hpw`Wqv@A+P}#1uP}|#z z8VY^XbHtNqH;(IUAd;VmXky=86~_SIoJ-osPvI!(d%v4>>YYbu@aqs}cfWXhx_MS6 zDg}4RXZ6ipfrX>_vll;psiM>z}yYP9fKc(kR@YxJ*9{R#qE)v5oobYGI zM(up@<>YH=XVd)ab2bp)bp%HzM)b1;B>Sk$$%ji}ebwhWhS`;=48fN={|@u^3++&C zNb5Q{8QBIJrbb;Yc%M}Mw=SQzoD@Au!Qct(mL9h`QJXs~;u5l~#BW5Oeu+YP#-@3N zxH;_NHe}r^*`wV=HatP)Gm9oCi5MEnROLYB_`$+YC?+c8IwrE3Cru!5?_I?<;rxh= zE&n)ZY;5NjwmaJJXsy!BpF1EjFNT*i_+mY~c~#5jJpzf=p%E@7k09>BhpuO(FVzY3 za8F5v^YgxQ{u~1-=Eo~+omc}{&T$a`oFE%$ic(-eT0pd{Dy2pn8tpVi!S`fvIlkK` zeq<`VM19=Q_<3fxFrSR2R%?bN6k)A}tLhYnp{6OGD?Yg7s1|S_ z%!!uI==Tu$NN7f@L?_Pw&@}2Bp{BS-Q`r6(_aRPSziX#OsomoH4SW#MnH3G&T#{Oh z7zxQvqM?3dVc{iYo!jS{5uEV1U%-6D-U=EqhdV8HJnH`#*-*InxYXoNYB6Q-Jf*?s zT(>`^cyR&Xf5&eQ0B%f)bTg1<<{`U^^U(yu(doRcqY3z_Oj(%dFgAeX?y_^}|5bFS zMJ~+%Y0J50($TX<_h>0=eW#GPV+$^3m_xBh{KkFM=AOQX)6u)$$DSp{k!g|Bw)(`{ zBY%pRv%2m^(BkB!n9Nn;U5NE<+Jmpgk0XtDmb+1>%i=sD>Z^d+^lRTNnb2Rv zgcz`#)nKM-y^70!MSv|lh91cIPId0N3_>>vw-5*2*0C0cX0k{i2`ul@u%euYIKv_l z<)Mba3U?Fgh+QU-(OrJMPq>e0<|`Q|Ats95I}>yFszMLjvpkl*)lavNHjaMS&OoB$VOW8;wW; z+i`(3F2{2OVfu5O?S!Mwz`Ti=mbTpW3^R3$mba4 z=(zJlgIdE6i(Be_)ndk(tW%$IhJ6`#h-<)w!pVnB(TQRGnuTL9c_WdLvHa}4MZQpw zQEWg#Ku{OHXZ54fu4#qimCjAfo2px=G@^=e%Am1r>Gc6xYBmaFE{qWJL8zvb|q2M6lC2u>68 z{fO`x2}qM&IC(OCP0^r`x>(&hQs(b(Q!^oh9bN^iA81e&@~EVqZ)S9DP* zh<~)kzd6S*{us51N=7I4HOK4M*rc{hLe!zKe$Iw)y*r}@SPU%t@)wo3ObowUYS#dl z+*+VW9>Z3m%{xq3kwNa!#a*KQb0*0`^!cximEIq1y(ZY{Zc8P&47Ub#9h+!{Vi7IW zt#!_pJ1&_}_PgFQRsAwjFz8tHFE5cOkBww9J;06K(7_~zmpdV66HaMCZvG0)$A#M{ z>&`76)cQUPw$STPN~X|Z+#iyhcA&?`;-8)N^UWB5l!-occ1Tn zR~!g$6{-f4yFQ3+i|M!+GSM(%6hddSOMoWwF4;?S8T4es6s-yGMSBR$Grtr*+T?y_ z3LD{Yu{qQexH+r4W0|`Ir(~*mEC^2+b>yunm}J(Om?a`cym7!gJk7OIkmre-Qjyv$ zI;X0fM)PgDIsa5=9nIGh7YM2Q@v*MAuz6=}Lj9q2vBqDw^jV&w zaxQuoeW~+|#PUFTp!k!!)v}ogk8=wha=GP&Bw0n(bUyEhe=DTq)JkMser0A+egDe@ zLgWk?vFV*E{Gw^Dxrf_!${jh}JX;Qo1)F|a?6rSHnwD*K^@qDRRLi@I>?gyYn%DEa zFF(774J9|4dGN$28%|}Lsaf@ObaCEk%`sfVHhsN%lhy9?48{6cx%YklkYl3Hc8q~N zSr-lI^&3^Vj?397N=DW4U0ae7$>xtp>@kdEpJRu-mBVN%d2%5oqg|Q^#-P!c*GorZ ztM#J9vWaoTsu#<03+u$Tx> z@!v!kJIvmr{2{aeuk5H=Sv)@c$f*|2#zta4jW|u4?n6M3K>2IJQgoW#9GTI~ zR!%G@5iv?tP%}1jNI=c+B;Amt{pRs|D3u zhhx^|C%dDL%%j+(2b_#9%$NNz;3YOVa@XC<>Bz;9K5k@k+Hc!){d=5z;URc&tYg&p zT3rz^=q_;mC!*1M;*LEMC)_MgwZmFW=R)EPk$~x3c+2!n9wWoT&lLMhkw*!U(cRtM zGW94&T;2m`wv}mqXdZ^>)&)5gmBG?wO?k4w1!Jrg`Tji2NjDRqbX)6e$&&&OhgWyr zXYxGp$*0NBZkp-4-^#)tRVGJ&W*8CpnPSIzn|;7F+VuODo*##Yx$Y`R&&OZ=?K%wmk)R_SF_=%ajLi&50PBBm}sIN!r;lp zt%{VvEC>|Z9R0s|HS9SxJ#eiXwyyOvn9STy_jfJCc15ENH{WfwUBB>a>ZAr$o!m4C z<1&f_*$mM3^y3udcnCu#hhAHwD{-mzjL+QHVIA}w3CKn#IU7_Kh3m0rXVoU82HC@m zoz#+DAzeVbxWR{RX>zMwF6^uzAQs1_m7F+VU6r&GAoU0*D&Twy`0&sgMAH*G4Y^Az z_0qr$ds%kUx-lb-fR077Pybl*dCFt=ISsH)+1nVV;YW-k$#5~EC4VL*g2p`uf*=xZ zJ~K;P+6*?d@f)rW0Fkg0KCbn?On7pQjkGtMl5~}HwX8kudOj21l|9htXQgIO?Dcj& z;nIDrbCs8v(k)CezvFT`(Or?#nSd`vCs>1%(%xKKQ;6USWA5pundavr8~Txn*ztJ< z5qSevkIywEw-rpX(+P`gZ4P5ZE5S4Hj4Y4@7MSX1Mhk`Y6D?MIBur^Or1H<BKhR z_=;TRci^X)8b0{K_KPm8T9|=lpYfPdp0Q#9ceZ|o^(Bb+@!sPm6g%8QSlLyG6k`w) zmFDOwwrrf1Fii9rhqx3gAzO)`VRCv@A|Hwbmt+cSWcCUW7Yf>LGLlL(p`D#}Hk8hz zAGS>e>`f!%%B(u)Ywzx@I&jZQsJLcM8^Te$2JlFN&W-gJOshNBR~|X}8t)%)#?HuJ zO7fJsG;eM94RhaE50Rd4{@Rg{wmh5)EWr^+#p9C0=XA*9cKfh5nhJ5Y`pkaT`n=HP zF7$A-9UT7iaE(K@lf%`N-@3$*y2>$}FS*Ka4R^nfqtkP(9V(dXgjur9`PpsR`Q@(u z!hA>h1@KXkB0TfhH;j5)lkgcljM`uK5!eG{edJw$pR}Z|>--*vga2*^As}F{-ZAJU zrQUIVIi0Izgv`UClKb()USH;H-({>qDHGVB`UV?kmdS}1T9S_%?ACJUT82391f3ns_{-7l2BT~k=&E} zGZS}xJ)To5XB(8y@dr{Fwp?KoQCJZu+6p$Jx96lL<`45#rc0h%`#YP<1XnRniWqk% zzYO+*3+i8fkoRlKkCPOe;D5#WHoadp9?M-&*(HDUTp(Uo@=H%(@53*3Oz=W;M@Kcy z+9eK73NKIa3)uDj|BOq&g2;a%mH!>jX8`qg{vDZAk8A_s`S1KsoZ*%M{=}mqG1N=h z0pb(Y9|2nVI3oCoxYySmPIKA;NPCc~<(~HgS6hiY;#Vj7uxXXQ=y#NM%h*K$3}fcQ zDU4*p+7DF@{tcQ9&*%FyB_}a*ls^fdw@)TLvhug*20!d&%>YxVQ2EgM3gMTMOcTIq1zq_`FhuEI6g` zJD>K*AsPu9NqFY8R985bi8+R0E$|=z&j$T_cluvIzmUF}gT9@yt~Ll?{tE~P4Zd1{ zx{pB}vw+th9Q^Ku{tHzHwFHCk=)XbB|EWv-PZl6<{Kf_b`k+?o*Di2X01yP|Q`_hp z8ry=J+(Exr`J<8l&yMroP2Ycc|33&z`Pw`!sbgkrZU5Sb{{JHQ-@BRrI!n&jT;G;b z#?o9H^h1@upYUG|@%O&r{~EbK8X)lB-bEd8%thhUM4nurT`^NOh}I&(=;D8oR_HA| znCicLe=r;H-jbSyFDNU#Wo58aS$?j^%0(=gg7iZ_4}mqIS7Su){hnBe3pGmNCt9b+%I3)*dIS3jE9at&+WV>MD|i+md0^u)p0FDlTu|noE|eO{DEi~TpB^PeyK&@h82=n7JYFzg^P>QsV5e;nR|zDFK|{DNhKoi{s<2fsTKfPlci>fp8XatdyD z#dokO%y<6)9s3D@I;?3{O$&f}x=RWT;l>4$Hd-htBH%EpGN=^z9Oqiqf%6Iw4BahU zyUrY0su<6BY31H-3AoHoaual+Y!6I>Y4S|Br3P=~!qo=@r7L%CoM9_!fL^jmN~ zZ|+q#nQ@5`*x2svDz!6uNxe*4$6%)ScbVJ2p>?l~X8V7QD6@h&^6fSjVkfgvxnG5- z$zoEGNQ5p1N38&&%zUBb0)sAznJkmw)^=6j@)&I~AF`L#QzeG}Ts06PC^V~(9f7sm zU>e%TzexYG5%1p_BW+Q+ztTpB>rr+doYDwkhYH(}BC(Es&5je=hP|k5XE*#}>tp46 zOwIHKrV9D|F%26Y0W*8#rBvGLHr??jQuN&0PT`jpejEPuLiQKuOunq=2$EF|?60~mQ?-$o&`REpWdG_QD5$Qu|URu)xWFL zl2F7JNcThNsI~)3%CKzF%+$^-gmhT$w0gllOagi@TRmSvJEaO3aW0&{keE-0Ga@nv zDj*^T1rZ1#!|Wi`)`W1^IzvL1zg?ZWe;gUbGxmVXca2BL19J0fv9r4DwyFr~z9G%v zCOXbNlMc14mgUMX17bgAVrX(|ryq8BaVdE&Dhxd&N$?PQkWdQoz{0>L+Na|f(fDvX z+U#hWuNrD+aouz>`<(5R@mBNZ@CGGdOUy zhx=suGaGUXR;1+Mq-c91l<$Z)>B6z(z~orf!5a00i+dI_sD2+XH_ScPR*yic0@!nO)}!OO zP|mL@jdTa7A(g)kAwB=fO5-OU{~f@RU#j_rhznZeb7_AOln+A$DwL{I>72=zAEn9E zj94N1G+55iLh{7F42=FD+Y66uBN_%$qY9?I|dR;t;~kLfeKJ(_2kB`A!#4z0E1ctu|7m zaVThdPreMH`*HjmEV!9^%1;h7!GorZYkEV)l|l}`V*3+`DK$RUF*}AttNs-$H<&^? z^<;m}`a}9?o(&teMbS-$WCzr(O6*w|rxN>42a#ss9m6Lf8sP+wWmDD+VHY+L@ofV+ zQ5C;A!e~5%h*hv6n~fsaOB%ef+Dj+RnwGN&_pi?9PP_3$(-)cVjI138)OG2vdp5xZ z9LuklzeO26?Pi1qDSB6xjA+i3AHX%uVIaNx0$7oi+MK+zWK=nT4NrY{G?_BV*{LqM ze!P7;)KT%m`Jd%rTW$pXm zm%48oaO)^yh5Rm*ZQcDCWnk4{{$P^r>>)hqp%bAcRNzXAnK2>&vt-bY!Ex?*mRJ(mUq9v+!{t6$2{w>CvR3OH_#=VfN*!L(9mz zkDh)`+t|`Ka7JI>_E9PFd|z~Iq};T5X!jGJ@AQ@|Vs;U;7y@H7;_&I_?#E=zu7>&1 z)D)7?!x~vmK=&1-$ASm-F0+=@#Hv&$E&OBM*wy#1`GJinsP|z%?}A_dih_z z>y%FMg#9#1-{8|fdGMCSpRq`8e7LJer&7YQIdXYq)99nQQ7J0h=-1bzSuFkux3b?v z-l`h5My+Bjmq6QCye|LAq{f;|BI#tJsfE$lL4NKf^DZYbES+|TCbsf; zxnA@+&5;wPjWRmVjfzKxDYwkk##9`4N4k^C-Q zfEC=S{3CgOV!9ezb%td|V&-mxH3KpCDA{n3xNdWZ!eE7=p(J$u#P$MuFt6+=2i!8{ zlg6U~=U#7!&R~+L#Siv0)LC&R4yNk3Asf{~qzq~tx}`fIAu-YLhFESV$h~qlX*Rbq zvG8&U(Lyo6n79Vy$Qw7M$*jzS}U8CES?2}+J|FY5j zb86kt9XIy40SBW{^9RS2t>i>xa~bMGaMbr=v!v`6Z8D4e zoSy>P1;F947t$X4j|#5kVVEj4cOEm;V6qoqtJpQ{nPB;Fqc9W67GPuv^BdN#qvs(QY~7OPC~8t@C};&ygyd zBl%hV*^fA}!WZi0=smnPlFs|>H>^(ybg;NXj!Rvw3$_fJd4_atXC?oT$YVI&SB%y4P)TgLzKErH5hg9l!=hKEXa;$&SLJzbkFPtL(X|z z;R$KONFnJ?pGs=6xk|xZsWs0we?qK%>6Z)b_g0ASfJ-j2rdpADS1Zo17;)&~~!YHXR~ArYdQuAr-Lg@e2rppJ?LEa)pBJ{$`76S~WS~kP_=x`bCuOpw2<< z#Hem*ploQq_uL~kh}ifc3so{DF5t@8#ya$6{oS+ZaB(qvd4&wKqs7IXM$NN`(E0*Y zgD4Y$ea@UBym%*bQ`#PBdysdRc~5bNHOoqf`CHlRKF$0ZwuHKDQH6VOPwIofn5!K> zvBY5fF^1vJ9ftQDWrV8Xhg+Bgl&Q8qn32PK;p*#%qqb`=S5NTmf8z1o`8;-4xrXy{nbJ&+t!WY z;DBje$*`{!S*V$9fosal33V**H4PZM=22zxO6f$hY~= zet|fyw)}Nf^RyP<`dFvagbaz=RG+s*iFj@_l-Tf)Bv>len0e%%^3w9He$0zP?A=#BisW!Q&9fXHU?Nk6KMvJaGMP3I@}j>6fP zbowg1gHqHr@ zW5U5iK7;*g;(;w_QhLH1bOpC@&xq^9@Dr1v(;X zU)DL8h?HClh#PgbO1%D19S}YNaq@jNvEsgRQ+45huGSmzgJgAM?(%S&s;jE*>CtxI zEc~+=Zu12F3_DpA=Y6h3bbzxUm8z(5N!Wn?!8MbH+KcLC7QDF))dIuKVQ!SGf(y&? z8YC7hy3JkhR-%i8I7dTHs=Dk*@h?NqyI+PwiOvo~>5CX)zbgDtbJ>JrRVbipS-=(UmJDJHT4P9i zfts6IRJd-@*xELYoyu@=_@{X0DJ8!dnr_d5sBWN|RQKmuC(IXSy7#8*bNXCtm-~Jn zlu$=#bu7f$8;Dam+BH@ z$BPUtL^(2!tJ9bPT{6QJX;!?i_fL5V9PW&ZWye2`JAFwI%`?`q6Gx@1gEO3fNzOZR zF38onct&-w);FZl0w+$hjLL!|Jo7%(#Icqlwa83`L)QIG&8l*O0hPqf=n#RJ{SQD`?6>K+_vFW!bNPyfmjCU_!)=y0D1bt=A z+%Ys#Fv(GF&kvCd|3BW|DM**-{n9Mkw#~0>>y&NVt~zDwlup^UZQHhO+nV$HchB^6 zbl=Qe^xck~5j$@(GBVd%@3ZRFig6I+T&n|!mVXI1E#J;3<3Jtb6u{1DL`lunLaOKs zG`FVM!{d;5StL}OB z>$}+c#a5m^Q#Np&Sm@wF2u7D0y=JYNz_m)Rfwk30;=^Laq8*y$VsNG zo;!Y}e`GUWub#)zV9a5tsonVvVX9awa*6)S->z&G{1VWS#a3%xqU}H8I@q%<^Z=T1 zX?~cv9;qAl5Rb1;`tvu-*~1~(p2CE_@iO`Ke0Ta(?Hc`jLp-F`8G0T06l%_u!w`P* zvVBj-na62_m6BFtw!Qg#JFlyBvw)P%4`S_2uTJ}G%IRnLPa755Df;-;HrAFE3z^R= zc&5|V!?dGmgj(^fS|69-_Z<8FMo6W$1Xqlu;5}#+CW|Y#hp0jfaVpcIOn$uIf9Kzasfw4~Gqp{6!5t;ty%@NfE5Q z5y%h7Fkef9AF#-A)LV@Es9yUe%w<7hw~K^{_5>+q*SC(x0fhE*dH%s8Ww zRJ(^&P2mKU{ck^zP?!8FalSowjH;*0qLzHq?L*=#Iy|04?-!j)pdt`-oPo>QF&7vw zyoa3&Gs>5L15xI2a8n5N}esm0g42Kw~+IP3DS5&9>ay5w8SN}Tq3i$X#A=tiMe z@_rQtlql`6%#pUuRxo295$p7I>RJm|sOhW3ZVT`AeSQ8auYNf`g|>OhxFVX}iP^q^ zGg^!}`*6@8elwoyECh^7vpw6?5GF!XLzlQdgH$;&<*JWDjNkBdH&Zfr@Hjr&EM{ph zx(Ari#GPX=#?=QWbPGNkp{+S_+He+B2xlUfCZTfTPb;cMIyXn*HyQ!6(G7VoS>0(n zQ18f(>V%M=tbbkEjGAYy+KFtjW3-TrYPglKCgKTNVV~zkq&m$KYX4LtTz%N_`kn8J zHka-Pr|z&h;WeFd{{B7J0nM0f+U(zRk!;+v$lkppt7|_op;aMqDEQh%qRJS1;kKV% zbZ6nKZwZLSA(db?C1;w=Seev4IXrNO>{fX3akE_K_jGH5N=Z%aBfN1qS-u(JQJOye zdKIs@%T6nYmwSR0%sv5xqACJH2#G>C^!Db?ZKnTs7dBRZu;REMPt}~I=eJ`V* z_NA+rX-D2K|1dh3Z?_-tQ0y69^>eCkT=~F3I~{(IZ;?e9qhud>8+#ut9>E`xH;5Qh zFRBoOF4sk>tgzB2)A~_Wgrxy0eb$bmpeJnkj(OMY7O>5H=m>)Rh){xn6*Z3gKidzy=b1WAGbFg`=qMu4RaL?|91ZKv*{iZ0cRx%Lkdq- zA$8s6Gg9jlSqn~D=EyXs%q|cU#cR5u!+J=)uKrr(vYO<9ELa66H-=l85K-{Lp6RFD z@kxl3Wl@HfUSTj9y!Wh1?&|@IvlFuYvb?f}18Y&foj<5(^Svp+om=`Az9Nvq|CFs{jO_2Q6Q*#TvHt0V}WMwU`Ax^J4c6 zwfDAdOGwRYzxl1?KAdY;FIRb6I3(~>?`!$SUmjkIPohHWxdL3)-U5#o}85P`l#?Vs$KjCLp#ljnDP&|Y<^>_1WQ`G@PcoTT>n6#721y=2LFI(yzfokZlhEq>(GYW2fZY^#Em!qxZ%l^3ZR zFz-Kyi}hlFHWcmd5yd+5r=L~S@c9fLy6-G>_fc;|SlHi;Ht;E*zd%Q>U+Gk)n)*>C zPD&My8o4Z@Olq(&;`)7|sYkmVIv-mE3$6H4y&}8r9J?a>PVxeKffo^D9mq0b?Gje| zM};(v60zuv8Cipu@2~8Gp1ybuW5LWy%G|}o>67W>JF}+`c2{@Qx3`|SJZZIH09Y1| zK3mikzv)zk+k2-cu!=&X^Gc^@j)Pv8rav5ihUzUMc|kpN=E+Gv4)G#Ro?iLVr;dWi zhKAK?X0?HvFGHz)Bh^#%HZEww`9VX8jzE_`H-!M^KDitIo~r#;z^9IXC>&)0vAc|K zHDGq2JnOA(*G(cNq3L{rC49OC`to!-{@&T+Q@ZF=2k0QOCdHhfa*)8~vGH2`t?iyC z>d@V}+v@^rGB>H_O?m~-^Jf^(Q(5AVOYb}rl9-fBm>lE6N>oaYOA=z6{>4${Mhtfk@feR(zJ{gFL8aN#E4lXzE zlO!)th^Q1gv4|lcaNAlLTnKRuT2{dUxs0@Eak(Ap7^4(++%cYen&?^lOfECV)dZ?s zO-NA%Ij@Y@WkX80?Bf$of0|YZT5EoFKGBAOZ>+%@06&mhwB<rDFdHS#Yph4brNI=?Cf(7{?QktYLO|Ceo|wA;_p$h zXGvI3)lgv?KZF#f5li}ZF+)qOX71&W2Esy2U#_;GA?>#)yUw$q*_26$=*TZiOjoU( zQ)%IoH}D~~S5P!EP#x(8*SK@TS7L*eZ@2x0ZUH5g4Jf2(dXYvb(|Yu6k1f9rNDjyf z@6JWjE%FYGiKrG9ebm7ay?XpUr4d!ABPQzPXpcZrv4JXYZ#A1!)llYEwU**=E-j)7 z)JrR($?sy$P?034S0V2hEq+Tgfg>7z<2l6k;hPJ9^I)ofa)#L6<^KGFt} zZArSQ?v}e+RW_Li*^+Fg&>*>DlEqP)ypdW-RJlh?t1dI~c$HaT<6<*9Rt_gL z{nA)?tXxZ9wvn}NE@snSNUu7>w+V*XDLa}BrX?VU;nyOlLeSAU^%vX@q zL~J}nDA&QPUR%jI6IhWOk7eh zRe>wG;_&;>DQFuy{P+krdEmwrq23zT*_|^cD}_1Uu}o0~c^F}2{29&go_c|F+Ymq& zr478e0!wNmSs-r@5M96u&C!%IQRmZ6W%V_`6kTxBEt;M?5EBA)SBBwxD9Y{gP=R~g z5u~-7jh9(iV~b?{*3JJ#XCK-qZyy16n=l(@Gpcl+#s{6aI4aLV-qbgfPIhkj35GQ( zixibcE7evA*VIibVP%1T4*3hHnvjC}s>DftaY5H3pUl7jBqLQt^eQesz_ZuhWgJh|OI|5KcvsBuW^r#>lhg#oZJ)E3U0N+MT}e`7=9#s?cF=*DMF=p702Q9})^% zhn$MX03MONgHZMl+p=HU$TLlCb9%fH5xx1d^GGCh;tBhudKB!`3*BVwYX*(t^O$KU zl}3hPwUIi8UPt1Y>otHas}HU0-*|Q6i?ye&3dbi5(fx)dm_wMG_kysVOErMGZF~o@ z*)Ee@Ajm4xeza@gT5(RY)!zW*71yKiiMB=VnKI=C~ua{+fBm{8}wRh;0$OG2oW$Y&a}3n5OVUtU@@_xqbAit)4clp{BjB_1-{n2xV*yp zvL#s`X^jiIHf zt@Fh4^wQMUz{13b9e|mPm5!H$nVO57jsDA5e0xCR4Ll|X4MUZ;qS8}OS6Tbz+|^my zTH8zFWaK(~yZbw!FK?{u414qPr0wkpz5jguz2ydXuq)>SGOWj!5I^DDDGu1* z3D&7k3;_gKNX4&hbaddGLQoJ5#3@mR`&h*dgb{X}Qi0{-IGMvI7gs8?%;%3Aq5BR zL!snQkBum_yaw_edJ)Qz-W^v7N-AnxFK9~yNX6PHyuB;}x0!{;mi7iFI#~Kq+D!(J zl%_|q92RRZdoqDkpa5GXo^$J2Sx%8A#B)95D(A26;MrqTMskx+xJ}e9wy)?q2`W8O z(UX>d95<0(`zMnf95y5mQefLvSetj?wzpb&PFl%742q_9v?by-5C4Vc4NKk>{D!?#;Ilu-@pYULDe`N3JMhHh*!sMbW(c z=D&7aT*1`e2p%pL)$vzn!|o0(w_6JE5CW%pWp*L_e;0Jha9TxPVn+`gNA2OwYPThcfhPj3()0`Nom?qrGLO|6Mq zml7o*98D`7ko^!Wuv$b<|H#t&jlHb{vlNHy1a4Y#C>qeGnK@1=YL8@xW+(>pES9vO z!)e?_lZ?r@MIti&B4BEvu!pd((Sj0^?(!Mtz+sZ~_V{Yl&?%_s?7_F7Lqk}junj)la;ZvSrTN^quZLEXoiN2*%AyN5T|s?XU{`XjDx z#roRJd6q&!avR_j!LixR`-Sy_sxy~_`w)rz7&1k;LAlb-?RjJ8T{f*mdo6K?us2ZAA3 z^Mz6S5^HsleR03?s?k&RGX}1=$LKo|%fih;_3-XokDn z(W{hJ9igUd6o&=N0>vOwq4ID^d+G|6$KL!pw4W8RZ3b8~+vp01*G!Dj-Ig29(k!jZMr!f5skBCLT zZ-MfRNSO93KWxm{th4{t6A*zDu#R)g?=X25lIseFXBHGt9KYlp@R~orHZ*7T${Sq?Yz2}F?k0g--7%T)S-8s-xDN9} zPDX?*9n&K-$u|jq#vg{#+?cO004=?rg*B(A45=zil&RkDb($ig>8sK%N%uKC(O;9S?2pL%0V8b-s^!=2Y z0V`^+iLjp=P!ablJT~qm@4ZG+?o#0q6ruKBG?N(OBn~pCB)+kt+G^_(w4+wCWs!|6t_V=-q_3Z zZ~C!}!QpCceujP2$31h){U0xI_R}dno|HGXT6_RXw%zv+cDXePLatA8Qu(bez8!U% zl7Y6B(S4)ks?Dx(i^0uw-c2P#ld(>|5mfD{U*}|j*JCebqrLOfz*rR+zd5&C%bPx@ zP3j|4T58;OBS0hV+g7gqWr_X};HCsQ9>!hX#21DeKNT;%{d&9laJD&Ln5e`yO8P{{ zHuCSehUbI?h_mFr=~wJF;#Pc?cQqQ$)lR1>k3CBfi;cf2nd-L8$Ho&s{b?BgiH-CyVZ_|SWzufIJ>sQS|O&RKiUIqp?oVGSw03^jXH0NvK|hNC9k@~O;= zeNz7RUifY*dEc)l_!_YKfe7(06JZWd5URfV=AIT+dqCJzRnKu2Y=AI7zXu8Cx|(wY zC=Lw6@DE>LGOR>eG}XCO2DVtQf|;qI%9NciP7kr#jNIN#Uc< z{cF2$L!6$A3BFwAE^iW5d zzcFx~q%qUT(csSX{OyuJ_GmPG)82KJEL)1&H?v(f(#}h%g+NU57uLtSI<(g5^4n*^ zeX4Q>N-KAc%7oXVUTMW2+&D0U-;qp;$L14+=iQf^BKyNYL`%J6?a8Z#<8rRQhuqD0 zb;i=0tX`AvRAbo?6g*(Nj1b)Z4SqHpHnw@LWHsQLd9MXFr#XmCPI3#8;Z(=3 zz}?5(MgVE|d{XT(dKeR@6muH|B=X5?n40LwuXmR#yO2xoC1LM67ksNje9O>Zr4fQY zkNc|DhEr^pOw!o2goB%v^cu2;>>OZE>z$TX1KSos3cwS24jU2fO&?EE^Q;#7cX8V| z(IlCAmZU24`w(^&A$8Yh4Vjb1KZukHgv$5Dv7EJf(VwpAIr*MkBK0~M=E7qBZxIMJ z$)#f1=9bCf)rkQ+PM2R50%ZjbSvo6_)i77mH5*!!n~x+ns_Dro5|kZ@y}&|sFdc-? zq6E-IjSRl5QbKoSo!0%cm`)>$jtU6vug~MAY*FU1QR!&>1@(b3t1Sm@LwP!3GZ|^pJFUL=6ME90?J*FHJjJ{()6Ot04PqC=0`>d9p9fv> zDXAczDEZ2C&Vu#CgMW}rmG)$B+Z6pJ+8c(8h0;&UsAE6+2j_v#-Y z7L6n`qDkj@or`+9XQ(~?Uf`U%-KJziE5M>Y|YDuSna=8b?L7`5USShpO+B` zSSXUG#_J~?X~=ib)njCTAhKwuO7uDD{@OmKQi^jzw$0N)ysqRxcrM6$Sri^r_woOx z9b&xWWka~Y+QBGJ=$Xr;_`S@BU32O7rV=}Uq1^tLR1h6UrhebiTb`~Sr);L`NpLYh z77BaG<_uBK=T87@4-?RPrkuEzd7l1j7=OwNo1EPKKD+?!F)MIN=%57`)S9gHSS?d+ znb617KH2=RIIK?^Uzfc-NmBF;_T!$=OmSMQe za`u7w;hCp?ofCv7-Z!b{DAHoRp*r=IIMJBiZsALI)9lY`n`s_qiSPtGG;jV?m*6#i zjtRSuzpQm?`$qMhMNP&4k-%QmCfWkZnXZ0PUz4TE4wT~pzHA$MtC(=-VUkYV=G=Q* z)!1t5A$Y{3w})-}D@}Ls|6|jF*42TG^J= zL!85h%fK?~_3>U#q0wd#PYp*diFZv`5+lTQYPknq&tN)AFN{AJGb$=o>QvLuQX&er zDOCf|vjqv}2XvRQPq-}9b0ydtf@S0S_e6}9at7{lMIJ>Wr$_9@K5?E5iO!{Ki^n;o zXgQztW58n4vT?KlTh!F{XhD7>s~?}EA93-Cinn&3wC*yYy6ZO@Gt?1+x3zILfb6Xd zaQ3j-D7C~@*~~7xR!k^uyIm`5Bnvf9eB05u$jp>60Q_T>97ZcH=8kVe%%a`AOVLhw zDT$b%dY04b-dkRP3-X3*G@%$Wu{3cnETvumxG^YpQR}! zt<#hizdN)$#9kXNhknQ@FlIb1xRdDG=aXBdKD$Uj>-erjw4V0-^fi=#g+sV1kg8o4I?+xvsg#&ExJYTtf^Q zlIgGBxG{~^yZRs=3ZStl$Z<%> z@$pCru?cbUpqixtiHU*?;uKmKz;;3a0S>~P+SdB0Thb5-Z*L@gO>j0>S$bI^OCMA| zcw^Jj;`bgAhtbiofJ8w#D=RryWPaqQpOZ~L2%vDFHGeQ2JceFSA_NAclWxLZ1fbpB zgHLmyAM{MfR`*x1V9`OcLO)!sQXoVJ2S>u)z5RoOy|1d!&nnPc|JTJ#BN{MPh~L3F z4qA7A7D-5At&AD7_70I-g1g+vn8rjrA;c*N^!R;&YYP(_;Y6S7)=^#ION*161Do%zvH5|fkERn&ZJtn4hs znws3a&n|wr0i3}E+3DG7L*6+bOg;7O&E0ivOIl)^%$0UWq9y4=Frkf854Bl@UsUloApW4Mz1<%$iO@j%0nm+fsZsr9r} zR773uhkp~Z8SyE{EG>g{Ska}-PUg!0x`j|t8T#6MklL$S1)VJ+62fJ^wg4MU~}E6vW_3e3dH&a@s=`cEbJ8#Y0` zGtTn1loQtwYD#*jwtu^d(WofvM+|2hR@KHDBkIq$LgQ6T(9w+?+M#6rmi~uC48Gm; z{hBlykssuL@4I`y_Zp7OVhW2xLaYxW8`)fhI31N)HE&s%F!DKA$p2FqFl2;KkEDAe z0<8-@C6xE{*f2g_B3>5*(S5(e-!f^MGxOQ^B5mE@{6H}KW6Mv`vQ*Ep8~7!@B9uSe zS5iRJMixVMN9{&xtYRrW#79Kifmvd{=W!)_q^@$X?DB)tsyx816uMSQ{I0s*N~S#p z*pr0DU1{Vbo_`=f>UTrTWy&dxRwt}}zqfnZPn$ZOX>c6suhNnQV@anKblO2_s55IQ zG{gRiud3N7?)Jfrpyy-#=Ev5$_J0BBo-Z`7xU69(huhuq=z3~|T(s$@qpx=l8yX?U zVz$yrrCfIwr#;S{({5?3FuuNfs|NXKn8SGYS2e6oO+4+ZY$5uwzw>k-oY6wZvIiv3 z5lQFni67+q%Zm*G%X0NI_L3X8Qdw^ z*igKwR=I1D^}*F0QuKFr_h8S;WKHPc=>5LlCfx<^a*X(^Z3H;KOPuV78RJ+Pyub}s zk?aQq>Ro9q;fkVgpb*#rZr@;h3Nsz)9A9<5m#?_)O9|ipsjNvs60=#_8rpm_Xhwq~ zj$2x~C=}Seaoay;ae;u;C|ie_V_vtX=KeA&L%TSwtV^ zN(y;+%V{H^Q^bX0sD+zcMB_5|cNvddXFOWJIm1x?3#e{-jz6~vqZq?ZE^~=s*_nv z$Owt^6qEc_;KyLdD@w7mD>eHe1&bOlLD(9BqPvwFtooG>xw>z?=hu87W}RS4r@j-W zmkOX69u7oa!px9l0}*@ktpK1OeLXn93ll_}YOx~+!$ zqn8&Xc4zml6kUjpbl!CJuL-T5dwoU*}xv=C1?@mzFh^z^SbCAR;wx4BP%Dqa@ z!y(xNK~0gS^-2dMk*i+gAxvI-RX%-dCvxYMOnU z-(q4ArTgu(J7q?V#WT}X5p1U(vtH0sGwv}}T32m4WknQ%gZOhb8dEGKt-tF{+lZ1w z-Xzn;yynq%!|YCu4J`%LNgeEW1D0|FD^ywi6X@Hv=&QU=cR_mqeHUB>Q?pUdgAOo* ze4An@A+m>klRQG%A>HS|9K**XPU8?rS8!wGYz_WFQuRsgdCYUJY&=O1662bbyW8&u zA^}1cUs)8HKjY*1h~017DOv^Mer&U^t<8n5Bk13`>X$_mBxsex*-nVJFI!SwMxO3$ z*x@NE)+y-(2`JNon)aI1oiB;nC)h;_@7SI)LNO{gn;6cBoFpw3u~w%}!cCrq|?2CW8xVKk+M=niYEc>=;Pt&$}A&kv(?{1^z>UeYomnLzIBx zN^cBZGg(L@vt;=O)B@=@0HEwkqHtPy&}LimoR6q`8RmFZ>d#8B*8P@ilAM^;%`t7) zWm%8O3`INpzwyWDLD2jkMP$GEn^`iEksv$4IHrh1y0pnVZ%a=o4bn&Nqo6XBD5!WK z^CG74eeP|ue7$jzMLkMs zeJtN52}7=sHMqI8xBs|^$#D8AYb>J>eHHoV)#Hiq@z%ePIa2X9(6H#O(6HsaqZ_X23`^Lw_;wWM-h=GV781x^l;XJQUG2JxOR4CiW`u zQYq!I#D*9kH;py76qs}Huo`taETh1NEw;xzxox%}!(bO2T`EobpD_>akly6UQu3Ln$_c-K7EB&)iRvpCFH*vqSL zT_eItQZ@EKvq+bRPvE-+tW=27$P6v9u*X7~uc6tz{aBqSyWJw%Oub+|IoMJ@ z@8RNc7h)q^q<*Vv(~$1S&x|(z9)86)%WqYux|~L8>h@HOkusYwoeo1R8_2TjLpc;L zGgdJs7*h$JO>TmwOV1=9crfdO#`F7w+VI_OZp+%z$nNQshY|}!djRk&KKkHfR9&bQ z7M5)xg_}U@7A62)^zmeJG0AG(3%f_~(oavUZu2rnsZr1tO}Ywg6q&D))Lma9=gIcB z%JXlIXHLRBR1<-=3+shq>tt?5W1-TdkYH*R^~215u}tVxM43uGK89<*@t%wlxE&;ew4>;7W;bD|$( z?L30nN1$xED!nI8paQ(lP=+xqynvxux}x8udh_mPd{2k1qvDgb4wzQDs9ep))|M~L zq-3&Z$C1Qi@vI7eV)gb6TkfWAF|dGURR~8}%`c{mq)qua_w_D0yYC&!6h1UI`CQZJEouIsS*tutx zjVc<;R9E6-A~rm%)_2#s^wh$gzoZIdNj*x#!2#vcZ6t*H&Bocz^>@J1*1lG>`mO!k zW=z<05v7X9+9p>FoT3B(uVZ>2En88^Xa+pl9nfW*9fB1ec2?F$nRY~SK1?qKF?3JC zQhHXls|C?YskYR1^l`2uYRjkiVwkl3Jn(onX8Qq2gPY674#-|;R(qGP)nJuOHSVfE zYd&azi$fMX)RdjEgug3mbcvI^G5n)*8sZP~CNPS)?C2Z_-g{3T9p!?pMj{uu?t0^_ z=X-yE?jDXa2D5PAQ)d=%G(LV##F11$$7eoY?vdhvH3j*PV1xq{FR6}l3H z0}=??2rc~@8%cz+%bmKLEHahNNa`NTLRT^pmww>>)NFyOoN)``jqZ60W~<$yVFkrR3%s&$}{aiT1PmktaiK`uqT9I4tBs5NkZ z*&pBgG)2-z=R<68rZyuRMpc`|P@v^6xCC8+m1ZodW|2P8LK@VUM8Gg&gIZ zEy|bohj(++XJOuU)K+K?7l*VOFZ2JAKhHJFYnEJbHc(!G?KB}7%L5fDZ#8nj8b(%( z^mobOenG$Weg8cwK5oG)u=q0)=6z@rtsvRa1;L)PiS0Hz*s~*ThABJbkoC9P8TW1w zLB{2;^d*@AjdPop4kV^4O7n{E7U;Cu7We#2c=u6&i*b$KGSkQJrlv-+;X-g3NiG>H z>Q>wQh@NC?G7nEK4!3ZxKg?EwIc{}RCeQLI4`=4E3%5T=buQ1m6MXVp6e>&`H=bI1 z<=@?PB5)CNW$tqYc)@e@ecW*&wuu@?*TTcOa1qJ#oCqZon9q7B=k!+~vDi1y^RYxZ zG`1suWnd+cl)AI%-&+Ep^{UDEzW*!id7zO!#_^`*^LF-`1VzJUY6qzBMi~^HCQHgT#PfiMGip z>mRH%-C#p}*b&|DLc&)iKvY!EiZGzxzUAvZgD(8+uKQtud|ih&QeKJ62zfs_zl^Ps z<$Z|Jr==e<#=Df8=Cm>2X`^>$s=2&36C`K5W3xXBZWW&L8qIu)n7P@`_ye;SL^%(6 z^B^H`6V&VDp{O-01>o`=UKmYmyw8Q1{1N z`4z$5VQi_PESl_u`MXU7!Uf(6eZu7!zebA(kSgtz7$XXdzo_uyF`}5bgvgrjow68~ zF~|fDrcxy4-`e7fSz&DD*Hd&Y-1Q?;&`lhckb@~noPyNk!H#vlI zPfWv@U`U2E;=MUK+nzuVVFZRaj1gRC9+ZKz4FO2Mjhwmc(Is59mBA%Tu;)#y(??Ij zfO(ON^fFqf>R&Nw1p6#rBvmp?HGksf4;&0`L>%2H?IUgwi54AI5`>*;% z)hA7g=<*V<8-m7xTC;q`>UVNC@4!`bsK_W$2r}245xAYTq_=q7AB?wpP~v?pJF%A; zBRA6YcNP9vrOKARwLYy7CuU+xQ&IVMMf>cprA6j|e_(i7{pgyYx~CrBkrn`V>Y!s% zG`-udul4GTG)Az3*nu2PR>mf%1)X#KK8M+6!ghg?!%zcjT$CHVWAiS*CV7pp zGXJ&(*5Sm~Unt43O*cwmcCqqQm;2~cbPDVYW$R~W4vg&+s4Nt$|vj3MC{OHH)-h=(o1OtS*1J0 z1OCSwVOL1(XGkX1RyCB>q3ifzlpZ3eJvvG3~9IhE;#%2}0B3rH_kl*TI9NmTEL_OU9n> zj}`cNW?G68=2UpLR&9A(zvWZ}u3~C|evTXN^e!|)$Zu0&o3E})24 zF2>~AA+y7`E_woPuY z^l?(w%9%YZCuXy;U1y-5zL|JC;6A3>px+<62y|v_u<_lTExFKUmrd)`+ashmn=~~VYpJ;iO z;D7*3rq|k=tgKz*Vf5Q=Bi3t*rk0;w2k#z(X6f8fHxR?EGDo>y zb;4HsM!P4tk&9GWR(#P|glCwE=5BKFJXP`h*4x|QbF^EJ>Tg}P19)$prLu7Qm&^}3 zd7bKdCqn3iE=yhk<115%_GAed9x`Sa%*%7I7-*lTH(72Ut%em5en!pVO2)6FS}TQH zfY8oY)NLaL<3yvWz6ChJwM(I_~5hTUp>~D9LxtPFIzj&t><8-;{m%e@@F*mh9@Wg z zRWo!^nQ?DwApCGoSssJ- z)^?*DBXepD#kGtN#;0k@Y5g~TM3P}uSL8Tkt+ut@1FWZqsh$XEwn!@HaUJ6SE)2J_ z(K;4GmC;5jykR6fR&368`~M%GWux~E7{ zG|NuP+I%vQG0i{t+>%^FYSi44zz}d zvri+N&n=h_5_A$I>21%w_~(|@6CEe%s|JD>d5oPi{?pm^T8%FE`v!;)F_;|=2YLF_ zG~1@XRnCHZ!(_r{*zDRrBf+P1AocPwkMhYU`JquqD_% z^0~{+T*KF%!a1N&2v`q>>-C5vI?X8Xn5Pk&&nNV-NRONN`nmd!UZuV&EOAN{*e(mB zs&QrFNMdAIQ5Q6p1RL*;ROg5B|9W;gdb?Hn8KDJYh$LZwpDSZRR{zgOM4zo(v{--;7q4c>ty)^|NP3+wx%@A|xD`k--IvgU081Q8q)>aj{ z_{ugH2Ip*qiScaO{sl)Rp^%QZ@}{l!s}~*k2Eu&6(#<|Z=(XP`Wb*nQ-~Zmn`cJ#p z|9>BgmFxfIW3l|F-0J^a@|A;&`QP3DXDV#gim3wH?F!>9d0_`wVPa7ckGi0iU@THH zlBJr{S#12@BrP!Lv)F(1GTgC{qBxzxj*GjW$!Lz3p{|#Y=ghY$@8iidmY$Kd5paJJ ze> z+j4mkivEIM!>ZHd?FQrVs)dxxS#5=r=H5!QAbEqNmo&OO+Fasg>THta8||aSD@D{K zC90|{E$*D1;bL`jFgG{WH`g^axcRqxxqEtiyoUNh!^ZrHijb3$k_#yDm6o2Fnqd6b zKfypCTGg|`GeTKneu9~zzQXb2 zXb4mb_%{EJVYv5Wkg>6$v)TM<1pvCf7X<%)9kvl6gmfZQhtM9u<{9wPgal`n%XzCA zZjqkH*r9^43dX56AN#7I0Kkj2DH-mMqlB2R~I zWBOqi%OU-`^mao)r=a3 z4%QkL&*bcjq)~~?4V6Q#i}JXZZVP$IH3ouBW;u4~F8`!CA?CQ8K$K5U)8IJ2eb37i z9Ze$q30m46rVa*syA~+ zgt}^5Z{XjKjgsx=UN=&SZ}hdEl1In}o59+InZ)$+*JLMHjYFdYS%ob(Da7Xr;}b)^ ztzQOz$MK%XDy=13mS3~gWwTuDCy48OSxNlruy@Gu=i(g>@Th+U2bmEBbK0g{#W)i$ zo??u8Y1Cyj1nMXz-M3K;gaD%lBT2c@&086;rlKp{m5b!(T;Db=sjZD5do@`m+$o5b zkySS5_~mVje&Am5Z!A%2&nobn&J^`lsO-_ar0@~7znS~HqHQYnU2Fu#gS*P6vK1_xU@}U9xu70Zg-bIR3Bd-Z4nirdbef+qP}n zwr$(CHO*<;wr#t6+L*R&_jLF6JnwtHIQyLwu|IZWBeo(c>aMJ;MAh{pxpRRAh6LH zk>n}14vSsaGYz?Ut9jNh)M%~S81aG41KjJvTZ<~E!{32SEIcTneNN_}IXNfhEkAHj zaxwgTK|L}<=W#g*IxhUBK5Kj(dYj9s%fcOBKe{8Y7-fy22HXZMhoJ3wz1@ybQ& z7KyxP-R8*1&>CS2NfI;~VfxM6Pv3}2Ky=5R)A7#!gp(s}eHIjFOj)u}(%oT4s{^C2 z@C~y}HqAH@`z>}K8ZX;<;51rS!-{-|k~wi_yarzj7|tkDWwgbb=cn8vct@@Om@1M3 z&DL6Ac_@evmE);aH@B12M51j^?D&P0n@Ov z;JkL##)9`0_4#?O<$P#rFz}Ko@&eNY)zft&^O&&ZLK9q%P(M3C-w}`&!@FNLiL-eg zjLKlapTy4bIH^;RiB@5|PPTP;qicmETrm^UVEa`AD}7^g9r0P(M?n^M z$h2-K1}GtbPmdUfmHW5L-8+(nno!zODUDOGg~~W50EF7I6NIP8+q@pvmqzBY*(=DN zT`6@eYfhAurs4o|h5;a+hv+X>gY&k2azk1#;`tILT+cbb^ z|8(Q^8Y~2$0TybyW|(5B!Zy570Z?vQ2^h4y^X<*gEv+rJFKQ?@jc|U(1f0WB-nT}A z`6ruUK?5k2Z;N-qawe`_yc1{%B;JRN7$@_|OZL;hGXF9WEcR$I=#kO5PfY(~%0Y-& z5((1`VzD$NVzCTT#7$CofmJ7O7TxX~j!>(*-%t0}<22mA&hki01N9f(n`^oy~k zJFZ`tyB`TnP82rW5S~veE`T7GJNy~#QD3=BJ=G`*)Y7t%z7KLO#eSC655`>asLS2lO|jwa(iQV)Btl@}Sjn3o)RhNyH#T7Q^NARonu#h1o^eErBQ z4p@0L^g)XB|;3U$D`h>CK$f-VlMdBC+T#w`Vw2)->fd z6&gY<(YuSfu)Zt{$*ao9;Uh)uXF(ry*`zV!lwHp)FM{(4UN;6jc1S0JafRHEwaO7i zs_G(0^iF*UM?~76W+~hdLJ@KN;Hy)zR&B#Ru9*V3)UyUB-2 zae-l}ybjN7$@${&CtSY!ivB?UT3&R@WHRH+`#)hS_;B22@F#nk<+V<1l3TM(H3KW+ z`pvt`c=#dL@UnmSN@Xl$m1{juhqzqM0uR|Xs)CVAR;pV~pBrpGHF}dlLc42W#eeHk zt#wK{6s@tX!ZQ04sOCnVO4Xs)9z-v?9N{~g@iI>3nb9Wkv)HN5vTf1CZQRfszR}32 z^6;nwkZLMqIvpu|1T4_()HH1>4F z#5tCXEv-3FJr+K=Inh~1!-L(pT9?N%vr#3oMx5puCKMMwZ|v7Vwdeg#!k&p6A-)!5 z3M4V*7oT`Oxj>uQv;MB$*{@$O5CaidUsG*r+O{u`VXDR*L!%;|c4+AywpDJ!AjFg{ zuYyqk+GP$Zq0-4ysmaa&hXb|ToyJ?tFS4n|9h)79pO4JzF|cU`j-No)F{!^SnSZ%O zXv0R;kAEn+bg)!#v4L`TkIzo-^i64w&1ODNDto6OW0}t__W#=bL}U{C^NFjEGT8Mr zY{3_qN*wPSIh19mM?*YVNhEoWLjI2Y9zgx^dS$Yo7rt8rj@w(jwQ_|7whWVHzP_rg z+Y$S!HI;NdR!H{@eKw0O>uN4r;{(q!MTzb{c9C5`*R_X~v@%E%sLfg2<2_UZy2Ot* zcU%z{u){aMkZWec+|eatfVY4yj9icelNh{enb1a)BB6okT|OA-6n!J#04m<1sBh+X zW@T%-&9#4^Dkols2I2pUYg^{v^p@#5E`B;=#fyZm(V4qpYq(1ewQPU=`ibKlFPgR^ zqck_7aUDx4ON(XLDN-iJ+!GmV{UP^mzgUP?y5{!-d?HKbnPG>lGWOu=6J-18Ks`_! zrPD$>Ru+UIn1fx#*aL}CCF7{-3w>jZ%Bs$OQTS#9fxl9-RmL*`0d!PXZ(07L!G_?( zDfzz3f>3o68va}y-m7?k?#^_qSmnl#p!5UbkAA*Huj5Cf`r}QuOi%j)3oo8n@NdZjdsXe|4#KzE;wD z9ShQ=^(S#hPBqC;%Veq@A@*IyGIc@D-cqw&x=67Wd8`AgssTU%kWdpPzunBV4690% z`+KQD(uSRu10D`D&|uk!3iqUV4v$WpvN~37C?SAO1k>Z)l(3PNu8||2i35iNS=c(p z!Vh7_`VN>owe$D5`&1g+%4BpLQW(d!4NfO92{xfaZ>J$9Bl*nrt&JK zh~f}K`OI>0#Covc&)wv%ib58y$d)-Mv0l-*Kgysly<(HD(kRKTP+esiXysY>wMjI& z<JUbCo+Lo8YQN%nmh9F@Rk@517Y~WwP^F7P`fDBp()v9u0=KDefR^9J z-;15l{ArKibP+&@8D?^m<=q<(>6H`=$1+5gg#B;U>o`B38s6byDZnu?O7G8aS;f>g z-(=k$vPagnAJ#oRH9z~t*I6+yU?E>TL{?p}d@oRkM`y#~J&&HW$oaTzhuzL_K&b0< z=ihjfTJyy_H~U$5;TLM{);~d|sb4UVndbW~1BD~iO*5amQBSV z9=}NK#%r5;m89Wuze)FtF~|?;Zm%NYs~NFo%tIK^-4OrO_THaF!Wxix z0XF8zaJq-BX+on^<~JZ)?1Z(?XII@?86{!`#`1yRtzBZ!TU20d&;S!9^JBAZ*NFma z#1;{S)?xu+UnbBl=N44dYG&@4vxs_?yNMao*9mWpQxxzTHn~H zUz(>(6%T7tQPHE*;smcNy$`gS%P~Pb@RjF@@Do3(e`SMpDq)479kq9 zbAjz8KybHwPn%iW90MRQ$G+m2`~#+Yg4gqy;lqX!QR;r#m_GH>$+?0UQq6(XeS37q zL1@XEV#rjYU3w{*fc>>>Ed|oHRzk3le>CK_Cy?`FKBWH*k7Q93W;0v|}Xr zCv43K`*_;wt@&?K%9LF{S9*nyK7)_I0>>Dzqk6~g%gsYMfZ7S&(ECesS}id5JnF^O zjZMZRwvHV9=Yr5_@KzXeBau_w!u7^O31p_nmOpv3(*CURrz9h&9>hoQM-@h`(b^7Ck6o4mTMqu)`qfL zv$d@Ps5z#3?&o$1Utz+%v$l>jbdMvL8@{P2C7p)iRzF25$IB^QAu`;n3vlT|N>BD? zo_7SG+f6G1!ftgt@(=iXGEPrZzq~<7(DJR;xp)W^XC70HzK8kbc}Ee4R%#A{5>mz?C&^>S1ZgLC9%kE z;D6LS^4{0C2Ob5DoM=G2fmf6B$cyxQt*I_S&- z-%Lp4ZO;AZ&=8&%zh{P=>5cWJk6ij}>5_UvGvrVi9eBx(EyrVmT^iIZv$LOaLp`Q6j( z*=mX=OB{XA>cC#V1Kj0H2=ZmwpBBwNE=GLf1>pLttkOt$@dRlZb&fIO0$lZnTEE<0 zEoT-+*vKe3yq*|vo*4p zOu3k@I_yPfXq7*1Y(1EwLf`csC-p?)eiinBkJAEhje0y%!&w`9p?k2OIJCRhR2{x) z9cAn6kT$Nkv(TSm$}dVL{_N0HZCSikl~>a8)9-jlN-W-Muz`drGpI$MRw$lKZZBMN zIr6-yHY?{rkZipK*Q_xoy@2mF%2?g2nIJCZ1KoXp-WJ`bv+`X1?5Xqc+shgSNHlNf zeAQte?5a}1@IP5Qz$|pU|JB2_ZURz)tlI(EGW($lPdPgUk-wLS8l+b^6+FXAHGXvv z^TKYEJgBb;^bCnOs}m2ia1EdR{L9s0k*5tzd^`6a1D2k%Ys6-wp3fT!9ET0p9IbGatx+#HiS6&JhNou zd(bClfyv$|s6{b_2rl1sWGH@vMML#{n2?@(%wrO}M}@xi?@{ZdoNydB$TZ7yHrQQO zc32II^~W6H?CYG^QxXUE*7)zJW{;?8x{b+N7kuItw7T8rl%zlM1mQNptnmXV=U|zt z|KM7Fy|4H+$wDiWc7>F;634F+hSWf1>+!*`OHRg|2BvYM&!i2R#8kx2TG2pzM%yG^ zCq6yHiTuF&D|Qc}JjrDuU%SsY6`{5npUd;WnOBu2Cp%$KyEHJddd*&5En`o;((;uo zU%7?Ty>pW(((mbcx@UPM7;lzm1u!<;e6e0r)}>GjJ(37m7Z>^rbFDH~+3Owwb#8tg zV2S{}ACO8IEW|deevNjNQ9021(+*}4koFZt!f(b)$+6NQS=XSWZ!JYZ?^peL1opOY zhbfrmtm=%dwkHTgCd%)w^9xt;uxSX|oR0*oI7Lix9w3T8rqzr*86nu8WJxevmdb_p zEd@}q`myc$RpkTK`<$}adn(r?q;9gSD_0 zFrp3`^ZOzXhirEBB@~B|29o~vVoo&aVQ8_EGi8dCrYtap3~5ddj1>JTOEiuXd!3pl z2R`7m!TYNDunDEKSVtRWU((IHr=n8&;r@Y;1f?xPLUp<5J%Y38C^XrtI!B#B$B9Wl znX!2QXW0tBAU|@_EvpSeEqcFsLbE}c)Ji4cgP+8Vk@^HN?}|Gq{Hg&CWSAs%5Q%S`2&CSA{# z^*H}Tz|v!AY(4k$F|97jfmHyo*JmN;xlh`_Qp=V9d`qw2q$v@gq8Z+r_j6U7$Y_mL zbW!ob$F(DVmBZ````g>ZcMW_K<|5BE3KhgR(NWH@fu#fX?z}73-ITSb4x*+w-^y{y z3Lw$T3<|10_r+s&N%9qy;lLn)bOj9G*=hOVX{=37wRtg44k3S7*8X;74p~n!6NLIm zYS`l!g-qUC1!O=VS+A+@Kd=2q?O=J->Sx$!%EzY@-s0P-PTI=*Ult}<1s&$N7ivjJ+p)+2t} zB_81NLGVxW$fmAL9$#;9=1GazqrkBVFLz=6QW z5)fW}IZWKd@u}kashl~>bKK@;w}eAn`Y2QlgdCE~{PDARbH0G_KDt&N`ZZm>!*aWZ zo}n#t&W7?uaAGhNqCFe@DvpoB%We+Zi`J??P&O19(!Bh-D0HfD3wB&|Xi=^%2X*!% zzQ6%6{Nj;R`FqZBxQXCZXpYI^`76j$wYF=_=8Z*uawez@qoEkXx)J*?o$d%`>MvLW z?#H}Q69fw2ZfInOqSu{!8z$h7ztcAFwKN@*_je-L33*zdx_R9eA44PYc^s|@jA`9Y z%N6lFa~@miA8t<@{eJQR$&|Y^-BF7e7Qg?xBi11CYG8BHe@KVlwXR1h28;?dcG)Km zupGarK=?2x;6Q{g93&EvWmCv*46u8_E=vi|IUR3Oj;h)$9mJmzhy=uCXZ-<~uALB& zV7hh+?4MkqXDwZ7$TX_xu#cG>ThakpK{z=eu|Bh&NhVPLTLIl4*CbP_Xy!E@4Y`os zUg+u*%xF(=Co@I2#=-TF8Tb)`K?xOX9X#<99O1DqaUZ@ z^(jh2sBku`cI)5;RE5c>{L{*W()lYy%6@Tr`jqV%QQtBqYD_ zqJSL>dSc1Cg5OB4dz|wZDCtF_+kfxcXZqiA?Q{Gm*FNiaimCsLo_!`3&VSb)b#`$w zHME6=^2o}bbLaRSg#~`29}*IQxCGTKeu-sCArwuNRl!^E{aV_nX+%+bYJSloOKGtJ zuTajFAjt~8LZ}>7wXhnISPb_afmnUk`KtSCga4{~+rRhvzGwE>QD6j8X6*sYLcp&($C~n^(B@?HPsdM)Kq?NJ@M@!6!Spk?ikK92kK!mISvKug%1h7>E0tTQVD{vA3fFZy) z>b`Bj`oJ|#0tGobjORIkP<#X6zcPlu2IL_>2Z)?X4^UB(XY!hxX3tJCvY1(!M>RFpxjDEvJ9l(> zYjvORo(NyU{@{2~|IKQ}Ncrj}b%v|7O#j^IjCXK!n9BFrT-8-@C#foHi(A~Yt7@$L zyYuN8cX6f$KDa4gelS;DY_z20^sl2oI&`@CF=o2@lHc7eonMCl0Orm7vk=C;w1=Fa@m*nRwGIHD<-=y~(f)xpz4w08-%XSpd$OGKnyLAm@A z10^1kT!P5vu*LA{6{LpM z`a_z$fNP9}t-qfvc~0cqdmI_&i?>NWSySfGbBq>vs@U$|twG%zJ%d8DB%#R=tU0?f z(o4bwf0QJ&7ez_i2}~8fha)fW2q)1mbiGr)95%#eJJusq*wT~e9Em>S|8fYP1gcKM zsz$_mS@s(f$~ZC1*Z(|L=oXS6&3fctrO}&OkSc>F5o;p)IB>?R&}j^tPyye%-wcll;>{hFdI^5SHBMp05w_9-} z*yJ9<<`tGg7rsdew8nDFo2e!ZLv*=Z+hlX!Qnxm8?d|IE0)y%01B-nic_4huWTM!N zntGoaw0e-?e%Jz@_3LqUJ#1LodoahqoqG#(G<-wd+6~xl2CPnVttuWvB$Rr%X&#*e z?VO{(Ar@Z$BeFNJ9a1FR{u>16cY4Y~Fra|qo>ae~;evU#mA?5(GSgCZ%4WNFWyekm z8W~Ot0-l)dj_K`u5`E$z-2*Amp!pQ#!A z=HPIRp$RGCmSj-O0myV;({bZ;8m&r`1^u7H~QIR4*4WKbZ zxzNRQO*F1b55jSZb6kJI1+$7NlvF0mLp2zucer&C=%3f?q%cshiUZa}HBKf2X| zsvK28Baq7vV}g+G3sU_wT&3_`xY>@_e#VeOprsU7)~v@a1WBZlDW=g-)s z`uj8NcAW&oq`v&CrEO}IU->Z~8gJC2w=wrz0dt#mhECa$DFL)?>yD~y?xp0Fp!pp` zm7~dczN{bR6ZOBf(3DBx;8m*HntoP0hLlFB+^ql`RmnXLd(>Vam! zPt!QK9t=~`%*LYE_&p$xN340nGQ{7Rb?fjo>r9AsmeZ26Qb!&0HG6M5*CIxWvJ}uB zlRE(GBhjqE^fVS)G?&~v%1P(kDtdc4PYfq_T=}>?x;G`AZHqbNPz}kx@zc=ciJo?m z!Dcn=Ozc$%r25fIhgUL}HVdG)x;s3x>gc0u8KY$9

?TXSy= zDN#CjxnZ5@760@r#7TIN&~;A<%Hy%p61y3JQfr64u?*w)J1gFFnT4+UiJnVT$BU17 z*{4ETzlFW~jZ`#wv<2n}?Nw_`t6niZ63iRc=dbA^BmOSVM(2fr@=^_7=Tr@)y}=M; zIHsn$ZP1A0(#GFq@cv5$vxp|#>QqbhWzu)!lU73Csq_w@dKbfUYD}nnDZpGIjaB)m z*s=z<89f;i!M3tzIu5*pZNPp^xT7($Tffll9nxb})Ursw?kp==qh;~ENFger;U+Pm z-2glR}URn9 zbBqaLPz{ABcW^ApIMKGMkg*a?kfsuTmv^LvDUOLTwB>)>{CxemegEL|=dC?{^4h9B z_T+6)T+#T1+&d=S1<3irJwU!lNP*rW?^11JD&Ac`Hc1C^CXhH+1gR}t8_7V6B zz`+3x3O2X_fC3PB{(=YmLXd!iiB}JxqN1#%^FuN6w&IgT?5?aqJ>~6Vuj4_@E-9*N_6u&AK@*NfbgNu~JI`ioajWUP zwF7zP_4b9s_*VpykTzb4VS;ug&@I1NSVuz0$_~Ybd?n+8Po$rO_1`0eZ zJ!7Cj0tCMn{SSg_oyG+T3?N)$ph?`_XaV8kw{7z4W`?1?n52~by(@@})cLAwR3U9o zr^Rz3@f4Ps>Wu6WtMWex-mm-SKj|C%13xmOK>PagmJS1V1CR;MIR8unFTt_NSvpY< zQ{8AI<(u8aGp^T`?~I}Ieav5`9clcCcSh)$cs^ZHz`#y#h2-gj%A13uS%u-<0%OWcL^iAwJB1ni>6E%R$c^ z5%sm)sCO-qj8NNN-PXj+vdvGmjJ#S%kr@vlm>n$3da=AsBu2^m?ehxyDk|A0zi`!3 zrfs(pIWr@&A*xxiFtKNAv)I;kqr$thxx8a|#?W468@>?pJ1+Y4Z=BZWsyBnN^aZGTQ}( z{t>VXdqmIdC~!HDRFw9YhK>&zOKR|75MA`Oa%ebJyT=0O)t#r$BuDmDOS+8Ypm&7! z{{4gWK)suoMR}O$E%Tp6N<(9ej29U8t}^x%ENZ6=dp5@9gnPfpUrJPjZ7@xTTTnpj;{nAdHgVmsG`ovpY%oiT z95^x-LnD*76^vSx&6<-}-#U-28(Lr_>Y(FK-j}%2pVB4(e){3X554}m3Cn0z;+dBvkpLL@XfHvh9`alzX_yknfA@$DymoDj zBR3v!?7Ij2qh;x4d5L&zPI5MaL$UYPnjAdy3b6liLh=#2+^Fm1YD|$LoC25*Ar|cE zDepCm6J-6wSj+PGvh_%bq{^WMfYfq?jyjIJJ~{kPukS{aO=OfZF()hh=|n&YSm?v- zY%3G1W&h-a?_w-y?JQVNHfl1n52Z{8gRcmZTSl#_L`ba8}B@sQ(XLhSb?{tIC`VAx$>qk3r5v>Bb78MMQ=Lu@kQtURZnhb zGLWnX!f-lcMX#9Au^PcO>hz+yeqJu8(3WXxh$sn8ui_20_PtuF*a1^%(;vZdf47aH z`r6l;y5uTr%g!?q`@&`yXb6Rh*(CnErw={c?Mg@VD^|mHAS?@_d>Y=MVY+I29^7{O z)xNnpwF*^%2w3BJ(08a{J^dVC@gL^qA&f$toM!q4c(Bxi>Qr?34I*oETE~0L6`uDA z6Zs|^=_x`WE-;$ere7+OZ_U{|8d@CF~+9 zjVkmENMNw00#eJOkWV?p?Y$liUjdAy0^Scc8OKo9JFjq^i94d#I`v|l!PRUhe2g*% zW}$b%we3xVIFv(LvS(qGBR=W^aqMT;BUZ4Hxp)~N)Vi^C1$Xpvmtp>5)i-Y|g$$gq zKKEMWaHSQQ+J_e>f>+tGZ;Mg!WWy2ZnCMkd3PF%oW{#PMXn{kse!}38#$5-zbdbF@7sRF&a;#sF+B|4KJ*kHH3tlOf%VyDHvZ;39n5o zYf!O(6^|js9F8*(g?W0+=zg~QZ+LI}`_8;}%|2(Xyk^}W#@&qqU<;r?p$001i|^02-qR2BJ^UfFoiXk^m5Z1mgQ|M1CM7 z0AY}4NWoB15qIbZ-~a#!7_@)@P*B33o3;;EcmaK&q)7^D?y9n)j|=H}|u zWA5uBvic@vE}`v$5eE2*7ZX`x;00QX>rj1SlNx zq(cy>?G4Hyq5#<}KQJLW_S{j_pa-Ke!L@H_n^_mxbKdYUj2%qGQ~{P4>FMYx0Fl z^Yk4g1pQ>cA}#;}v(Af$0hbrp++ueMz69|nv*XXlH2iGu4lq&t{YtLDb(76rt)g%( z;HRDzPFQ~cPjIOfi62eMrVd@m;>W-Q(F+nSnr{CF)I{PCsjv#OtsU|4^_bg4_T6kM zkyj`~s)HP4m!o7!237Z-B=P8_Lgrku?FRE>f9vP^&;Z{$)fHL}{MaF4)C?;D)ONOb zBlP&QB2)PKgMl^T?cycDNEx>IP$ z!Cjo=UX#o*NKFntmguo%4w4St=7^|hX@}yM-q@4ajfF{;>*yJQo2J7bz+AkP+Jkr& zs*mjQhp%{A;q{zg^Jz;TxJjYxDo)91@>fEu;J;G&xw}o0|D}i}@OyMl-qVrU}=IXD4{hIx>wc zP-s@dHBQ~5hxl^xi4qK?+qFm)gcFHQh_#`g!C)g|4>9WXOPR&YkvB^PF8i0#kWdM$W{s>!kGZ=yfi=Bozu@Q!xP( zCQpM=ESIIveX+voDuLXr?CqQ*2eB|RDK*dmt^$|wE4B&AdtAh3`wS_T?gDQk(Jd=q zrjcK&ple3d)a|wd8(lRCTBv03Y6KpXx?)@!LQ)x?jJAC=H`^m;W_-HAHU^{UBw>{PJoAYYt(NlDIc*5YW8G&qggpacWz8Df{KZ%yX0`ZruX!G83yXQvnO3@X_LQ zAlSR-v;`jmJnsn}mtc5^WrWTWAdCXp$n+`hXp?b_dXXo?_B1j+fa!6nF0SdqOSem0 zG{3UDz-5Bf`Picb415j!k%?-z%aupk)iq9HlSb{DanCMeG0~1>{EHV1kNp+NqD+_E z0~EjyR_bc1&O!S~0B_-wGZTfMR_1)sr0d5`F?`IgkCX$FOt#h79$d6D&D2i3`< zjv(KW{)o-r2QE&=CPU-F|GqEI{wT@Nky;g7=R9^o-7?DLV8ZNqP7FcJSCFl5 zuT*@CU-5_Zuh=f!x7A3Y74E9^7VW3ptMXh`nMhD|F5Zre)KrNw{zV~H`7w^zV07wj zdoc($IlJygMiO_hC0`tiR#&)Vh2Lmp(XbteU$UdtP*44YEeC=Isb^d z_(hMt`_i<%K{dNJLT2$9X0mg;Ac)=vF@?mY;f&*@>vVs!3yQm>Ut^>q*@R`pN$040 zd&8(zlr6%*?0yVnZ6a-GnTOi?rYdq|CAL}7hw#?Whae1TK$(eDv#oNxL7lSCygg$h zp7d-cte+uDI`uhrA2^TdA?&gCgZ%jCdK#K(QKuwg~Xr3#cyk%(ZTY@t`!S3N)E*|%-DAwQebxHMhgZEyM6NLJK-vp$CC_B zm?vhvzD61oF8$XKHx#CMerp{%8yBLm-C$t|o|k%xf6H04J36ZGRo29haJ6mY314} zim1;MgA!FAil@VO1t5j*qCn2y4pC`KlfN~3Sig-VrGHBD2-~}Um-_j)>(bQD7A{x!0Fk4z%p>)#7(-?(g||L)&7->H5X*uVF& zaenuIuYIF4u(JOP#{NBF`^IDX-t!G&VE?;^iSL{LKZ4pj{TB&X*#5=oKX$TxOY{$i zZ|Z+x|4{$N`AhZhoc*s<|3B`3wfM{NuLl2&jDI-_y1H1{I}!XRjsHsX51+p@IKKN| zUjISwua@k8_eq<2y4yQ_Uj@(K*>@&pD^p{ae@$fVP5#qCvoo+Ua5Azmv$Ak%{XJp@ zCwmiDW7BUPDVS;hm5kY0heAbGhmt@+M2tY*!Ntx}}%FIgecj0gQd+Ohx(cea3_y55dnZLij|A4tT8Cu%>m6eC*ua=fxrhh5YONtO^ z^RTd(F|eB&vay*mo0)PLa~c}6m@pd|u^O2eaxk$PGV%SdF}^EG{VS5*(8=Xr5;L-Y O=cpzn6_po*h58?}&pdnp literal 0 HcmV?d00001 From 1577d6d60f284997aef9f6bb9130027423e283bc Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 24 Jun 2019 13:44:32 -0400 Subject: [PATCH 82/88] Removing debug/printout from fxns called by logger ctor --- src/LoggerBase.cpp | 99 +++++++++++++++++++++++++++++++--------------- 1 file changed, 67 insertions(+), 32 deletions(-) diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index 8a588cfd2..2a893e373 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -147,15 +147,12 @@ Logger::~Logger(){} void Logger::setLoggerID(const char *loggerID) { _loggerID = loggerID; - MS_DBG(F("Logger ID is:"), _loggerID); } // Sets/Gets the logging interval void Logger::setLoggingInterval(uint16_t loggingIntervalMinutes) { _loggingIntervalMinutes = loggingIntervalMinutes; - MS_DBG(F("Setting logger to record at"), - _loggingIntervalMinutes, F("minute intervals.")); } @@ -163,16 +160,17 @@ void Logger::setLoggingInterval(uint16_t loggingIntervalMinutes) void Logger::setSamplingFeatureUUID(const char *samplingFeatureUUID) { _samplingFeatureUUID = samplingFeatureUUID; - MS_DBG(F("Sampling feature UUID is:"), _samplingFeatureUUID); } // Sets up a pin controlling the power to the SD card void Logger::setSDCardPwr(int8_t SDCardPowerPin) { _SDCardPowerPin = SDCardPowerPin; - pinMode(_SDCardPowerPin, OUTPUT); - digitalWrite(_SDCardPowerPin, LOW); - MS_DBG(F("Pin"), _SDCardPowerPin, F("set as SD Card Power Pin")); + if (_SDCardPowerPin >= 0) + { + pinMode(_SDCardPowerPin, OUTPUT); + digitalWrite(_SDCardPowerPin, LOW); + } } // NOTE: Structure of power switching on SD card taken from: // https://thecavepearlproject.org/2017/05/21/switching-off-sd-cards-for-low-power-data-logging/ @@ -208,8 +206,10 @@ void Logger::turnOffSDcard(bool waitForHousekeeping) void Logger::setSDCardSS(int8_t SDCardSSPin) { _SDCardSSPin = SDCardSSPin; - pinMode(_SDCardSSPin, OUTPUT); - MS_DBG(F("Pin"), _SDCardSSPin, F("set as SD Card Slave/Chip Select")); + if (_SDCardSSPin >= 0) + { + pinMode(_SDCardSSPin, OUTPUT); + } } @@ -225,21 +225,10 @@ void Logger::setSDCardPins(int8_t SDCardSSPin, int8_t SDCardPowerPin) void Logger::setRTCWakePin(int8_t mcuWakePin) { _mcuWakePin = mcuWakePin; - if (_mcuWakePin < 0) - { - MS_DBG(F("Logger mcu will not sleep between readings!")); - return; - } - - #if defined MS_SAMD_DS3231 || not defined ARDUINO_ARCH_SAMD if (_mcuWakePin >= 0) { pinMode(_mcuWakePin, INPUT_PULLUP); } - MS_DBG(F("Pin"), _mcuWakePin, F("set as RTC wake up pin")); - #elif defined ARDUINO_ARCH_SAMD - MS_DBG(F("MCU's internal clock will be used for wake up")); - #endif } @@ -247,8 +236,10 @@ void Logger::setRTCWakePin(int8_t mcuWakePin) void Logger::setAlertPin(int8_t ledPin) { _ledPin = ledPin; - pinMode(_ledPin, OUTPUT); - MS_DBG(F("Pin"), _ledPin, F("set as LED alert pin")); + if (_ledPin >= 0 ) + { + pinMode(_ledPin, OUTPUT); + } } void Logger::alertOn() { @@ -261,7 +252,7 @@ void Logger::alertOff() { if (_ledPin >= 0) { - digitalWrite(_ledPin, LOW); + digitalWrite(_ledPin, LOW); } } @@ -278,8 +269,6 @@ void Logger::setTestingModePin(int8_t buttonPin) { pinMode(_buttonPin, INPUT_PULLUP); enableInterrupt(_buttonPin, Logger::testingISR, CHANGE); - PRINTOUT(F("Push button on pin"), _buttonPin, - F("at any time to enter sensor testing mode.")); } } @@ -308,19 +297,16 @@ void Logger::setLoggerPins(int8_t mcuWakePin, void Logger::setVariableArray(VariableArray *inputArray) { _internalArray = inputArray; - PRINTOUT(F("This logger has a variable array with"), - getArrayVarCount(), F("variables, of which"), - getArrayVarCount() - _internalArray->getCalculatedVariableCount(), - F("come from"), _internalArray->getSensorCount(), F("sensors and"), - _internalArray->getCalculatedVariableCount(), F("are calculated.")); } + // Returns the number of variables in the internal array uint8_t Logger::getArrayVarCount() { return _internalArray->getVariableCount(); } + // This gets the name of the parent sensor, if applicable String Logger::getParentSensorNameAtI(uint8_t position_i) { @@ -370,8 +356,6 @@ String Logger::getValueStringAtI(uint8_t position_i) void Logger::attachModem(loggerModem& modem) { _logModem = &modem; - // Print out the modem info - PRINTOUT(F("A modem has been tied to this logger!")); } @@ -1298,6 +1282,48 @@ void Logger::begin(VariableArray *inputArray) } void Logger::begin() { + MS_DBG(F("Logger ID is:"), _loggerID); + MS_DBG(F("Logger is set to record at"), + _loggingIntervalMinutes, F("minute intervals.")); + + PRINTOUT(F("This logger has a variable array with"), + getArrayVarCount(), F("variables, of which"), + getArrayVarCount() - _internalArray->getCalculatedVariableCount(), + F("come from"), _internalArray->getSensorCount(), F("sensors and"), + _internalArray->getCalculatedVariableCount(), F("are calculated.")); + + if (_samplingFeatureUUID != NULL) + { + MS_DBG(F("Sampling feature UUID is:"), _samplingFeatureUUID); + } + + // Set pin modes for sd card power + if (_SDCardPowerPin >= 0) + { + pinMode(_SDCardPowerPin, OUTPUT); + digitalWrite(_SDCardPowerPin, LOW); + MS_DBG(F("Pin"), _SDCardPowerPin, F("set as SD Card Power Pin")); + } + // Set pin modes for sd card slave select (aka chip select) + if (_SDCardSSPin >= 0) + { + pinMode(_SDCardSSPin, OUTPUT); + MS_DBG(F("Pin"), _SDCardSSPin, F("set as SD Card Slave/Chip Select")); + } + // Set pin mode for LED pin + if (_ledPin >= 0 ) + { + pinMode(_ledPin, OUTPUT); + MS_DBG(F("Pin"), _ledPin, F("set as LED alert pin")); + } + if (_buttonPin >= 0) + { + pinMode(_buttonPin, INPUT_PULLUP); + enableInterrupt(_buttonPin, Logger::testingISR, CHANGE); + MS_DBG(F("Button on pin"), _buttonPin, + F("can be used to enter sensor testing mode.")); + } + #if defined ARDUINO_ARCH_SAMD MS_DBG(F("Beginning internal real time clock")); zero_sleep_rtc.begin(); @@ -1323,6 +1349,15 @@ void Logger::begin() Wire.setTimeout(0); #if defined MS_SAMD_DS3231 || not defined ARDUINO_ARCH_SAMD + if (_mcuWakePin < 0) + { + MS_DBG(F("Logger mcu will not sleep between readings!")); + } + else + { + pinMode(_mcuWakePin, INPUT_PULLUP); + MS_DBG(F("Pin"), _mcuWakePin, F("set as RTC wake up pin")); + } MS_DBG(F("Beginning DS3231 real time clock")); rtc.begin(); #endif From 02cd9b796cd082f3a211a1ee8dbab377030a5dbe Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 24 Jun 2019 13:57:28 -0400 Subject: [PATCH 83/88] Cleared a few more prints from ctors --- src/LoggerModem.cpp | 2 +- src/VariableArray.cpp | 4 ++-- src/VariableBase.cpp | 22 +++++++++++----------- src/publishers/DreamHostPublisher.cpp | 2 +- src/publishers/EnviroDIYPublisher.cpp | 2 +- src/publishers/ThingSpeakPublisher.cpp | 6 +++--- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index ff8447b58..02a2f58fd 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -123,7 +123,7 @@ bool loggerModem::setup(void) if (!wasAwake) { waitForWarmUp(); - MS_DBG(F("Running given modem wake function ...")); + MS_DBG(F("Running modem wake function ...")); success &= wake(); // NOTE: not setting wake bits here because we'll go back to sleep // before the end of this function if we weren't awake diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 07abb99bb..1792ce3f4 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -55,7 +55,7 @@ uint8_t VariableArray::getSensorCount(void) { if (isLastVarFromSensor(i)) numSensors++; } - MS_DBG(F("There are"), numSensors, F("unique sensors in the group.")); + // MS_DBG(F("There are"), numSensors, F("unique sensors in the group.")); return numSensors; } @@ -902,6 +902,6 @@ uint8_t VariableArray::countMaxToAverage(void) numReps = max(numReps, arrayOfVars[i]->parentSensor->getNumberMeasurementsToAverage()); } } - MS_DBG(F("The largest number of measurements to average will be"), numReps); + // MS_DBG(F("The largest number of measurements to average will be"), numReps); return numReps; } diff --git a/src/VariableBase.cpp b/src/VariableBase.cpp index af3ae5d85..fbc64773e 100644 --- a/src/VariableBase.cpp +++ b/src/VariableBase.cpp @@ -170,13 +170,13 @@ void Variable::attachSensor(Sensor *parentSense) if (!isCalculated) { parentSensor = parentSense; - MS_DBG(F("Attempting to register"), getVarName(), + /*MS_DBG(F("Attempting to register"), getVarName(), F("as variable number"), _sensorVarNum, F("to"), parentSensor->getSensorName(), F("attached at"), - parentSensor->getSensorLocation(), F("...")); + parentSensor->getSensorLocation(), F("..."));*/ parentSensor->registerVariable(_sensorVarNum, this); } - else MS_DBG(F("This is a calculated variable. It cannot have a parent sensor!")); + // else MS_DBG(F("This is a calculated variable. It cannot have a parent sensor!")); } @@ -237,10 +237,10 @@ void Variable::setCalculation(float (*calcFxn)()) { if (isCalculated) { - MS_DBG(F("Calculation function set")); + // MS_DBG(F("Calculation function set")); _calcFxn = calcFxn; } - else MS_DBG(F("This is a measured variable. It cannot have a calculation function!")); + // else MS_DBG(F("This is a measured variable. It cannot have a calculation function!")); } @@ -257,7 +257,7 @@ uint8_t Variable::getResolution(void){return _decimalResolution;} void Variable::setResolution(uint8_t decimalResolution) { _decimalResolution = decimalResolution; - MS_DBG(F("Variable resolution is"), _decimalResolution, F("decimal places")); + // MS_DBG(F("Variable resolution is"), _decimalResolution, F("decimal places")); } // This gets/sets the variable's name using http://vocabulary.odm2.org/variablename/ @@ -265,7 +265,7 @@ String Variable::getVarName(void){return _varName;} void Variable::setVarName(const char *varName) { _varName = varName; - MS_DBG(F("Variable name is"), _varName); + // MS_DBG(F("Variable name is"), _varName); } // This gets/sets the variable's unit using http://vocabulary.odm2.org/units/ @@ -273,7 +273,7 @@ String Variable::getVarUnit(void){return _varUnit;} void Variable::setVarUnit(const char *varUnit) { _varUnit = varUnit; - MS_DBG(F("Variable unit is"), _varUnit); + // MS_DBG(F("Variable unit is"), _varUnit); } // This returns a customized code for the variable @@ -282,7 +282,7 @@ String Variable::getVarCode(void){return _varCode;} void Variable::setVarCode(const char *varCode) { _varCode = varCode; - MS_DBG(F("Variable code is"), _varCode); + // MS_DBG(F("Variable code is"), _varCode); } // This returns the variable UUID, if one has been assigned @@ -291,8 +291,8 @@ String Variable::getVarUUID(void){return _uuid;} void Variable::setVarUUID(const char *uuid) { _uuid = uuid; - if (strlen(_uuid) == 0) MS_DBG(F("No UUID assigned")); - else MS_DBG(F("Variable UUID is"), _uuid); + // if (strlen(_uuid) == 0) MS_DBG(F("No UUID assigned")); + // else MS_DBG(F("Variable UUID is"), _uuid); } diff --git a/src/publishers/DreamHostPublisher.cpp b/src/publishers/DreamHostPublisher.cpp index 74a5baa02..a07e6f10a 100644 --- a/src/publishers/DreamHostPublisher.cpp +++ b/src/publishers/DreamHostPublisher.cpp @@ -62,7 +62,7 @@ DreamHostPublisher::~DreamHostPublisher(){} void DreamHostPublisher::setDreamHostPortalRX(const char *dhUrl) { _DreamHostPortalRX = dhUrl; - MS_DBG(F("Dreamhost portal URL set!")); + // MS_DBG(F("Dreamhost portal URL set!")); } diff --git a/src/publishers/EnviroDIYPublisher.cpp b/src/publishers/EnviroDIYPublisher.cpp index 294c4bd9d..ea85000cb 100644 --- a/src/publishers/EnviroDIYPublisher.cpp +++ b/src/publishers/EnviroDIYPublisher.cpp @@ -75,7 +75,7 @@ EnviroDIYPublisher::~EnviroDIYPublisher(){} void EnviroDIYPublisher::setToken(const char *registrationToken) { _registrationToken = registrationToken; - MS_DBG(F("Registration token set!")); + // MS_DBG(F("Registration token set!")); } diff --git a/src/publishers/ThingSpeakPublisher.cpp b/src/publishers/ThingSpeakPublisher.cpp index 8b8ee2008..29e03d01d 100644 --- a/src/publishers/ThingSpeakPublisher.cpp +++ b/src/publishers/ThingSpeakPublisher.cpp @@ -72,21 +72,21 @@ ThingSpeakPublisher::~ThingSpeakPublisher(){} void ThingSpeakPublisher::setMQTTKey(const char *thingSpeakMQTTKey) { _thingSpeakMQTTKey = thingSpeakMQTTKey; - MS_DBG(F("MQTT Key set!")); + // MS_DBG(F("MQTT Key set!")); } void ThingSpeakPublisher::setChannelID(const char *thingSpeakChannelID) { _thingSpeakChannelID = thingSpeakChannelID; - MS_DBG(F("Channel ID set!")); + // MS_DBG(F("Channel ID set!")); } void ThingSpeakPublisher::setChannelKey(const char *thingSpeakChannelKey) { _thingSpeakChannelKey = thingSpeakChannelKey; - MS_DBG(F("Channel Key set!")); + // MS_DBG(F("Channel Key set!")); } // Sets all 3 ThingSpeak parameters From ed6ee06f4cd4af6fd05a0ca96b58f91ad65b3607 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 24 Jun 2019 15:16:59 -0400 Subject: [PATCH 84/88] Cleaning up stragglers causing debugging to fail on samd --- src/LoggerModem.cpp | 10 +++++++++- src/SensorBase.cpp | 4 ++-- src/VariableArray.cpp | 10 +++++----- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/LoggerModem.cpp b/src/LoggerModem.cpp index 02a2f58fd..039305a65 100644 --- a/src/LoggerModem.cpp +++ b/src/LoggerModem.cpp @@ -45,7 +45,15 @@ loggerModem::loggerModem(int8_t powerPin, int8_t statusPin, bool statusLevel, loggerModem::~loggerModem(){} -void loggerModem::setModemLED(int8_t modemLEDPin) { _modemLEDPin = modemLEDPin; }; +void loggerModem::setModemLED(int8_t modemLEDPin) +{ + _modemLEDPin = modemLEDPin; + if (_modemLEDPin >= 0) + { + pinMode(_modemLEDPin, OUTPUT); + digitalWrite(_modemLEDPin, LOW); + } +}; void loggerModem::modemLEDOn(void) { if (_modemLEDPin >= 0) diff --git a/src/SensorBase.cpp b/src/SensorBase.cpp index 1a1d2b23c..48d008b22 100644 --- a/src/SensorBase.cpp +++ b/src/SensorBase.cpp @@ -279,8 +279,8 @@ bool Sensor::startSingleMeasurement(void) void Sensor::registerVariable(int sensorVarNum, Variable* var) { variables[sensorVarNum] = var; - MS_DBG(F("... Registration from"), getSensorNameAndLocation(), F("for"), - var->getVarName(), F("accepted.")); + /*MS_DBG(F("... Registration from"), getSensorNameAndLocation(), F("for"), + var->getVarName(), F("accepted."));*/ } diff --git a/src/VariableArray.cpp b/src/VariableArray.cpp index 1792ce3f4..466e32765 100644 --- a/src/VariableArray.cpp +++ b/src/VariableArray.cpp @@ -860,14 +860,14 @@ void VariableArray::printSensorData(Stream *stream) // Check for unique sensors bool VariableArray::isLastVarFromSensor(int arrayIndex) { - MS_DEEP_DBG(F("Checking if"), arrayOfVars[arrayIndex]->getVarName(), '(', - arrayIndex, F(") is the last variable from a sensor...")); + /*MS_DEEP_DBG(F("Checking if"), arrayOfVars[arrayIndex]->getVarName(), '(', + arrayIndex, F(") is the last variable from a sensor..."));*/ // Calculated variables are never the last variable from a sensor, simply // because the don't come from a sensor at all. if (arrayOfVars[arrayIndex]->isCalculated) { - MS_DEEP_DBG(F(" ... Nope, it's calculated!")); + // MS_DEEP_DBG(F(" ... Nope, it's calculated!")); return false; } @@ -880,11 +880,11 @@ bool VariableArray::isLastVarFromSensor(int arrayIndex) if (sensNameLoc == arrayOfVars[j]->getParentSensorNameAndLocation()) { unique = false; - MS_DEEP_DBG(F(" ... Nope, there are others after it!")); + // MS_DEEP_DBG(F(" ... Nope, there are others after it!")); break; } } - if (unique) MS_DEEP_DBG(F(" ... Yes, it is!")); + // if (unique) MS_DEEP_DBG(F(" ... Yes, it is!")); return unique; } } From a89acf0640a22e169c35dec8876f74dd1ffeb797 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 24 Jun 2019 15:50:51 -0400 Subject: [PATCH 85/88] Moved daily clock sync to noon --- src/LoggerBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index 2a893e373..697b2920c 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -1455,7 +1455,7 @@ void Logger::logDataAndPublish(void) publishDataToRemotes(); // Sync the clock at midnight - if (Logger::markedEpochTime != 0 && Logger::markedEpochTime % 86400 == 0) + if (Logger::markedEpochTime != 0 && Logger::markedEpochTime % 86400 == 43200) { MS_DBG(F("Running a daily clock sync...")); setRTClock(_logModem->getNISTTime()); From dfb7106c0a71d3a7d5fc2cc0a8dde2555a41b88c Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 24 Jun 2019 17:09:33 -0400 Subject: [PATCH 86/88] Rename timezone fxns, add explicit fxn to set rtc timezone --- examples/DRWI_CitSci/DRWI_CitSci.ino | 18 ++-- examples/DRWI_LTE/DRWI_LTE.ino | 18 ++-- examples/DRWI_NoCellular/DRWI_NoCellular.ino | 12 +-- .../baro_rho_correction.ino | 18 ++-- examples/data_saving/data_saving.ino | 14 +-- examples/double_logger/double_logger.ino | 12 +-- examples/logging_to_MMW/logging_to_MMW.ino | 18 ++-- .../logging_to_ThingSpeak.ino | 18 ++-- examples/menu_a_la_carte/menu_a_la_carte.ino | 14 +-- examples/simple_logging/simple_logging.ino | 12 +-- .../simple_logging_LearnEnviroDIY.ino | 12 +-- examples/single_sensor/single_sensor.ino | 4 +- library.properties | 2 +- src/LoggerBase.cpp | 88 +++++++++++++------ src/LoggerBase.h | 17 ++-- src/ModSensorDebugger.h | 2 +- 16 files changed, 170 insertions(+), 109 deletions(-) diff --git a/examples/DRWI_CitSci/DRWI_CitSci.ino b/examples/DRWI_CitSci/DRWI_CitSci.ino index 694950c71..e0bf26309 100644 --- a/examples/DRWI_CitSci/DRWI_CitSci.ino +++ b/examples/DRWI_CitSci/DRWI_CitSci.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.3 +This example sketch is written for ModularSensors library version 0.22.4 This sketch is an example of logging data to an SD card and sending the data to both the EnviroDIY data portal as should be used by groups involved with @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.3"; +const char *libraryVersion = "0.22.4"; // The name of this file const char *sketchName = "DWRI_CitSci.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card @@ -265,11 +265,11 @@ void setup() digitalWrite(modemSleepRqPin, LOW); } - // Set the timezone and offsets + // Set the timezones for the logger/data and the RTC // Logging in the given time zone - Logger::setTimeZone(timeZone); - // Offset is the same as the time zone because the RTC is in UTC - Logger::setTZOffset(timeZone); + Logger::setLoggerTimeZone(timeZone); + // It is STRONGLY RECOMMENDED that you set the RTC to be in UTC (UTC+0) + Logger::setRTCTimeZone(0); // Attach the modem and information pins to the logger dataLogger.attachModem(modem); @@ -294,11 +294,15 @@ void setup() dataLogger.getNowEpoch() > 1735689600) /*After 1/1/2025*/ { // Synchronize the RTC with NIST - Serial.println(F("Attempting to synchronize RTC with NIST")); + Serial.println(F("Attempting to connect to the internet and synchronize RTC with NIST")); if (modem.connectInternet(120000L)) { dataLogger.setRTClock(modem.getNISTTime()); } + else + { + Serial.println(F("Could not connect to internet for clock sync.")); + } } } diff --git a/examples/DRWI_LTE/DRWI_LTE.ino b/examples/DRWI_LTE/DRWI_LTE.ino index fd7876882..851eb3cef 100644 --- a/examples/DRWI_LTE/DRWI_LTE.ino +++ b/examples/DRWI_LTE/DRWI_LTE.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.3 +This example sketch is written for ModularSensors library version 0.22.4 This sketch is an example of logging data to an SD card and sending the data to both the EnviroDIY data portal as should be used by groups involved with @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.3"; +const char *libraryVersion = "0.22.4"; // The name of this file const char *sketchName = "DRWI_LTE.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card @@ -268,11 +268,11 @@ void setup() digitalWrite(modemSleepRqPin, HIGH); } - // Set the timezone and offsets + // Set the timezones for the logger/data and the RTC // Logging in the given time zone - Logger::setTimeZone(timeZone); - // Offset is the same as the time zone because the RTC is in UTC - Logger::setTZOffset(timeZone); + Logger::setLoggerTimeZone(timeZone); + // It is STRONGLY RECOMMENDED that you set the RTC to be in UTC (UTC+0) + Logger::setRTCTimeZone(0); // Attach the modem and information pins to the logger dataLogger.attachModem(modem); @@ -297,11 +297,15 @@ void setup() dataLogger.getNowEpoch() > 1735689600) /*After 1/1/2025*/ { // Synchronize the RTC with NIST - Serial.println(F("Attempting to synchronize RTC with NIST")); + Serial.println(F("Attempting to connect to the internet and synchronize RTC with NIST")); if (modem.connectInternet(120000L)) { dataLogger.setRTClock(modem.getNISTTime()); } + else + { + Serial.println(F("Could not connect to internet for clock sync.")); + } } } diff --git a/examples/DRWI_NoCellular/DRWI_NoCellular.ino b/examples/DRWI_NoCellular/DRWI_NoCellular.ino index 526c6880c..56ac1d4c4 100644 --- a/examples/DRWI_NoCellular/DRWI_NoCellular.ino +++ b/examples/DRWI_NoCellular/DRWI_NoCellular.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.3 +This example sketch is written for ModularSensors library version 0.22.4 This sketch is an example of logging data to an SD card as should be used by groups involved with The William Penn Foundation's Delaware River Watershed @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.3"; +const char *libraryVersion = "0.22.4"; // The name of this file const char *sketchName = "DRWI_NoCellular.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card @@ -217,11 +217,11 @@ void setup() digitalWrite(sensorPowerPin, LOW); } - // Set the timezone and offsets + // Set the timezones for the logger/data and the RTC // Logging in the given time zone - Logger::setTimeZone(timeZone); - // Offset is the same as the time zone because the RTC is in UTC - Logger::setTZOffset(timeZone); + Logger::setLoggerTimeZone(timeZone); + // It is STRONGLY RECOMMENDED that you set the RTC to be in UTC (UTC+0) + Logger::setRTCTimeZone(0); // Attach information pins to the logger dataLogger.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); diff --git a/examples/baro_rho_correction/baro_rho_correction.ino b/examples/baro_rho_correction/baro_rho_correction.ino index f3acfa3b4..cde838956 100644 --- a/examples/baro_rho_correction/baro_rho_correction.ino +++ b/examples/baro_rho_correction/baro_rho_correction.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.3 +This example sketch is written for ModularSensors library version 0.22.4 This sketch is an example of logging data to an SD card and sending the data to the EnviroDIY data portal. @@ -27,7 +27,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.3"; +const char *libraryVersion = "0.22.4"; // The name of this file const char *sketchName = "baro_rho_correction.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card @@ -371,11 +371,11 @@ void setup() // Blink the LEDs to show the board is on and starting up greenredflash(); - // Set the timezone and offsets + // Set the timezones for the logger/data and the RTC // Logging in the given time zone - Logger::setTimeZone(timeZone); - // Offset is the same as the time zone because the RTC is in UTC - Logger::setTZOffset(timeZone); + Logger::setLoggerTimeZone(timeZone); + // It is STRONGLY RECOMMENDED that you set the RTC to be in UTC (UTC+0) + Logger::setRTCTimeZone(0); // Attach the modem and information pins to the logger dataLogger.attachModem(modem); @@ -400,11 +400,15 @@ void setup() dataLogger.getNowEpoch() > 1735689600) /*After 1/1/2025*/ { // Synchronize the RTC with NIST - Serial.println(F("Attempting to synchronize RTC with NIST")); + Serial.println(F("Attempting to connect to the internet and synchronize RTC with NIST")); if (modem.connectInternet(120000L)) { dataLogger.setRTClock(modem.getNISTTime()); } + else + { + Serial.println(F("Could not connect to internet for clock sync.")); + } } } diff --git a/examples/data_saving/data_saving.ino b/examples/data_saving/data_saving.ino index 05d6a2aa3..7be9bcafc 100644 --- a/examples/data_saving/data_saving.ino +++ b/examples/data_saving/data_saving.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.3 +This example sketch is written for ModularSensors library version 0.22.4 This sketch is an example of logging data to an SD card and sending only a portion of that data to the EnviroDIY data portal. @@ -27,7 +27,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.3"; +const char *libraryVersion = "0.22.4"; // The name of this file const char *sketchName = "data_saving.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card @@ -477,11 +477,11 @@ void setup() // Blink the LEDs to show the board is on and starting up greenredflash(); - // Set the timezone and offsets + // Set the timezones for the logger/data and the RTC // Logging in the given time zone - Logger::setTimeZone(timeZone); - // Offset is the same as the time zone because the RTC is in UTC - Logger::setTZOffset(timeZone); + Logger::setLoggerTimeZone(timeZone); + // It is STRONGLY RECOMMENDED that you set the RTC to be in UTC (UTC+0) + Logger::setRTCTimeZone(0); // Attach the same modem to both loggers // It is only needed for the logger that will be sending out data, but @@ -511,7 +511,7 @@ void setup() loggerAllVars.getNowEpoch() > 1735689600) /*After 1/1/2025*/ { // Synchronize the RTC with NIST - Serial.println(F("Attempting to synchronize RTC with NIST")); + Serial.println(F("Attempting to connect to the internet and synchronize RTC with NIST")); if (modem.connectInternet(120000L)) { loggerAllVars.setRTClock(modem.getNISTTime()); diff --git a/examples/double_logger/double_logger.ino b/examples/double_logger/double_logger.ino index 4abcb9d29..f6d2c14bc 100644 --- a/examples/double_logger/double_logger.ino +++ b/examples/double_logger/double_logger.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.3 +This example sketch is written for ModularSensors library version 0.22.4 This sketch is an example of logging data from different variables at two different logging intervals. This example uses more of the manual functions @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.3"; +const char *libraryVersion = "0.22.4"; // The name of this file const char *sketchName = "double_logger.ino"; // Logger ID - we're only using one logger ID for both "loggers" @@ -206,11 +206,11 @@ void setup() // Blink the LEDs to show the board is on and starting up greenredflash(); - // Set the timezone and offsets + // Set the timezones for the logger/data and the RTC // Logging in the given time zone - Logger::setTimeZone(timeZone); - // Offset is the same as the time zone because the RTC is in UTC - Logger::setTZOffset(timeZone); + Logger::setLoggerTimeZone(timeZone); + // It is STRONGLY RECOMMENDED that you set the RTC to be in UTC (UTC+0) + Logger::setRTCTimeZone(0); // Begin the variable array[s], logger[s], and publisher[s] array1min.begin(variableCount1min, variableList_at1min); diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index bbb728f27..4169a7cd2 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.3 +This example sketch is written for ModularSensors library version 0.22.4 This shows most of the standard functions of the library at once. @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.3"; +const char *libraryVersion = "0.22.4"; // The name of this file const char *sketchName = "logging_to MMW.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card @@ -273,11 +273,11 @@ void setup() digitalWrite(sensorPowerPin, LOW); } - // Set the timezone and offsets + // Set the timezones for the logger/data and the RTC // Logging in the given time zone - Logger::setTimeZone(timeZone); - // Offset is the same as the time zone because the RTC is in UTC - Logger::setTZOffset(timeZone); + Logger::setLoggerTimeZone(timeZone); + // It is STRONGLY RECOMMENDED that you set the RTC to be in UTC (UTC+0) + Logger::setRTCTimeZone(0); // Attach the modem and information pins to the logger dataLogger.attachModem(modem); @@ -302,11 +302,15 @@ void setup() dataLogger.getNowEpoch() > 1735689600) /*After 1/1/2025*/ { // Synchronize the RTC with NIST - Serial.println(F("Attempting to synchronize RTC with NIST")); + Serial.println(F("Attempting to connect to the internet and synchronize RTC with NIST")); if (modem.connectInternet(120000L)) { dataLogger.setRTClock(modem.getNISTTime()); } + else + { + Serial.println(F("Could not connect to internet for clock sync.")); + } } } diff --git a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino index 3b34ec97f..f9167b890 100644 --- a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino +++ b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.3 +This example sketch is written for ModularSensors library version 0.22.4 This sketch is an example of logging data to an SD card and sending the data to ThingSpeak. @@ -27,7 +27,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.3"; +const char *libraryVersion = "0.22.4"; // The name of this file const char *sketchName = "logging_to_ThingSpeak.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card @@ -273,11 +273,11 @@ void setup() digitalWrite(sensorPowerPin, LOW); } - // Set the timezone and offsets + // Set the timezones for the logger/data and the RTC // Logging in the given time zone - Logger::setTimeZone(timeZone); - // Offset is the same as the time zone because the RTC is in UTC - Logger::setTZOffset(timeZone); + Logger::setLoggerTimeZone(timeZone); + // It is STRONGLY RECOMMENDED that you set the RTC to be in UTC (UTC+0) + Logger::setRTCTimeZone(0); // Attach the modem and information pins to the logger dataLogger.attachModem(modem); @@ -303,11 +303,15 @@ void setup() dataLogger.getNowEpoch() > 1735689600) /*After 1/1/2025*/ { // Synchronize the RTC with NIST - Serial.println(F("Attempting to synchronize RTC with NIST")); + Serial.println(F("Attempting to connect to the internet and synchronize RTC with NIST")); if (modem.connectInternet(120000L)) { dataLogger.setRTClock(modem.getNISTTime()); } + else + { + Serial.println(F("Could not connect to internet for clock sync.")); + } } } diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index 40c65e59e..ebb4820eb 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.3 +This example sketch is written for ModularSensors library version 0.22.4 This shows most of the standard functions of the library at once. @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.3"; +const char *libraryVersion = "0.22.4"; // The name of this file const char *sketchName = "menu_a_la_carte.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card @@ -1422,11 +1422,11 @@ void setup() digitalWrite(sensorPowerPin, LOW); } - // Set the timezone and offsets + // Set the timezones for the logger/data and the RTC // Logging in the given time zone - Logger::setTimeZone(timeZone); - // Offset is the same as the time zone because the RTC is in UTC - Logger::setTZOffset(timeZone); + Logger::setLoggerTimeZone(timeZone); + // It is STRONGLY RECOMMENDED that you set the RTC to be in UTC (UTC+0) + Logger::setRTCTimeZone(0); // Attach the modem and information pins to the logger dataLogger.attachModem(modem); @@ -1451,7 +1451,7 @@ void setup() dataLogger.getNowEpoch() > 1735689600) /*After 1/1/2025*/ { // Synchronize the RTC with NIST - Serial.println(F("Attempting to synchronize RTC with NIST")); + Serial.println(F("Attempting to connect to the internet and synchronize RTC with NIST")); if (modem.connectInternet(120000L)) { dataLogger.setRTClock(modem.getNISTTime()); diff --git a/examples/simple_logging/simple_logging.ino b/examples/simple_logging/simple_logging.ino index f4251fce7..0e5645534 100644 --- a/examples/simple_logging/simple_logging.ino +++ b/examples/simple_logging/simple_logging.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.3 +This example sketch is written for ModularSensors library version 0.22.4 This sketch is an example of logging data to an SD card @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.3"; +const char *libraryVersion = "0.22.4"; // The name of this file const char *sketchName = "simple_logging.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card @@ -158,11 +158,11 @@ void setup() // Blink the LEDs to show the board is on and starting up greenredflash(); - // Set the timezone and offsets + // Set the timezones for the logger/data and the RTC // Logging in the given time zone - Logger::setTimeZone(timeZone); - // Offset is the same as the time zone because the RTC is in UTC - Logger::setTZOffset(timeZone); + Logger::setLoggerTimeZone(timeZone); + // It is STRONGLY RECOMMENDED that you set the RTC to be in UTC (UTC+0) + Logger::setRTCTimeZone(0); // Set information pins dataLogger.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); diff --git a/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino b/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino index 02d820cde..86bb06d88 100644 --- a/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino +++ b/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.3 +This example sketch is written for ModularSensors library version 0.22.4 This sketch is an example of logging data to an SD card @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.3"; +const char *libraryVersion = "0.22.4"; // The name of this file const char *sketchName = "simple_logging.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card @@ -195,11 +195,11 @@ void setup() // Blink the LEDs to show the board is on and starting up greenredflash(); - // Set the timezone and offsets + // Set the timezones for the logger/data and the RTC // Logging in the given time zone - Logger::setTimeZone(timeZone); - // Offset is the same as the time zone because the RTC is in UTC - Logger::setTZOffset(timeZone); + Logger::setLoggerTimeZone(timeZone); + // It is STRONGLY RECOMMENDED that you set the RTC to be in UTC (UTC+0) + Logger::setRTCTimeZone(0); // Set information pins dataLogger.setLoggerPins(wakePin, sdCardSSPin, sdCardPwrPin, buttonPin, greenLED); diff --git a/examples/single_sensor/single_sensor.ino b/examples/single_sensor/single_sensor.ino index 6e93e5ffe..b86297d01 100644 --- a/examples/single_sensor/single_sensor.ino +++ b/examples/single_sensor/single_sensor.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.3 +This example sketch is written for ModularSensors library version 0.22.4 This sketch is an example of getting data from a single sensor, in this case, a MaxBotix Ultrasonic Range Finder @@ -24,7 +24,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. #include // The library version this example was written for -const char *libraryVersion = "0.22.3"; +const char *libraryVersion = "0.22.4"; // The name of this file const char *sketchName = "single_sensor.ino"; diff --git a/library.properties b/library.properties index d75f8554a..a0bf17d5e 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=EnviroDIY_ModularSensors -version=0.22.3 +version=0.22.4 author=Sara Damiano , Shannon Hicks maintainer=Sara Damiano sentence=A library that allows access to multiple sensors through a unified interface. diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index 697b2920c..5f479520b 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -20,9 +20,9 @@ // Initialize the static timezone -int8_t Logger::_timeZone = 0; +int8_t Logger::_loggerTimeZone = 0; // Initialize the static time adjustment -int8_t Logger::_offset = 0; +int8_t Logger::_loggerRTCOffset = 0; // Initialize the static timestamps uint32_t Logger::markedEpochTime = 0; // Initialize the testing/logging flags @@ -419,34 +419,70 @@ void Logger::publishDataToRemotes(void) // Public functions to access the clock in proper format and time zone // ===================================================================== // -// Sets the static timezone - this must be set -void Logger::setTimeZone(int8_t timeZone) +// Sets the static timezone that the data will be logged in - this must be set +void Logger::setLoggerTimeZone(int8_t timeZone) { - _timeZone = timeZone; + _loggerTimeZone = timeZone; // Some helpful prints for debugging #ifdef STANDARD_SERIAL_OUTPUT const char* prtout1 = "Logger timezone is set to UTC"; - if (_timeZone == 0) PRINTOUT(prtout1); - else if (_timeZone > 0) PRINTOUT(prtout1, '+', _timeZone); - else PRINTOUT(prtout1, _timeZone); + if (_loggerTimeZone == 0) + PRINTOUT(prtout1); + else if (_loggerTimeZone > 0) + PRINTOUT(prtout1, '+', _loggerTimeZone); + else + PRINTOUT(prtout1, _loggerTimeZone); #endif } +int8_t Logger::getLoggerTimeZone(void) +{ + return Logger::_loggerTimeZone; +} + +// Sets the static timezone that the RTC is programmed in +// I VERY VERY STRONGLY RECOMMEND SETTING THE RTC IN UTC +// You can either set the RTC offset directly or set the offset between the +// RTC and the logger +void Logger::setRTCTimeZone(int8_t timeZone) +{ + _loggerRTCOffset = _loggerTimeZone - timeZone; + // Some helpful prints for debugging + #ifdef STANDARD_SERIAL_OUTPUT + const char* prtout1 = "RTC timezone is set to UTC"; + if ((_loggerTimeZone - _loggerRTCOffset) == 0) + PRINTOUT(prtout1); + else if ((_loggerTimeZone - _loggerRTCOffset) > 0) + PRINTOUT(prtout1, '+', (_loggerTimeZone - _loggerRTCOffset)); + else + PRINTOUT(prtout1, (_loggerTimeZone - _loggerRTCOffset)); + #endif +} +int8_t Logger::getRTCTimeZone(void) +{ + return Logger::_loggerTimeZone - Logger::_loggerRTCOffset; +} // This set the offset between the built-in clock and the time zone where // the data is being recorded. If your RTC is set in UTC and your logging // timezone is EST, this should be -5. If your RTC is set in EST and your // timezone is EST this does not need to be called. +// You can either set the RTC offset directly or set the offset between the +// RTC and the logger void Logger::setTZOffset(int8_t offset) { - _offset = offset; + _loggerRTCOffset = offset; // Some helpful prints for debugging - #ifdef STANDARD_SERIAL_OUTPUT - const char* prtout1 = "RTC timezone is set to UTC"; - if ((_timeZone - _offset) == 0) PRINTOUT(prtout1); - else if ((_timeZone - _offset) > 0) PRINTOUT(prtout1, '+', (_timeZone - _offset)); - else PRINTOUT(prtout1, (_timeZone - _offset)); - #endif + if (_loggerRTCOffset == 0) + PRINTOUT(F("RTC and Logger are set in the same timezone.")); + else if (_loggerRTCOffset < 0) + PRINTOUT(F("RTC is set"), -1*_loggerRTCOffset, F("hours ahead of logging timezone")); + else + PRINTOUT(F("RTC is set"), _loggerRTCOffset, F("hours behind the logging timezone")); +} +int8_t Logger::getTZOffset(void) +{ + return Logger::_loggerRTCOffset; } // This gets the current epoch time (unix time, ie, the number of seconds @@ -456,7 +492,7 @@ void Logger::setTZOffset(int8_t offset) uint32_t Logger::getNowEpoch(void) { uint32_t currentEpochTime = rtc.now().getEpoch(); - currentEpochTime += _offset*3600; + currentEpochTime += _loggerRTCOffset*3600; return currentEpochTime; } void Logger::setNowEpoch(uint32_t ts){rtc.setEpoch(ts);} @@ -466,7 +502,7 @@ void Logger::setNowEpoch(uint32_t ts){rtc.setEpoch(ts);} uint32_t Logger::getNowEpoch(void) { uint32_t currentEpochTime = zero_sleep_rtc.getEpoch(); - currentEpochTime += _offset*3600; + currentEpochTime += _loggerRTCOffset*3600; return currentEpochTime; } void Logger::setNowEpoch(uint32_t ts){zero_sleep_rtc.setEpoch(ts);} @@ -489,24 +525,24 @@ String Logger::formatDateTime_ISO8601(DateTime& dt) // Convert the DateTime object to a String dt.addToString(dateTimeStr); dateTimeStr.replace(" ", "T"); - String tzString = String(_timeZone); - if (-24 <= _timeZone && _timeZone <= -10) + String tzString = String(_loggerTimeZone); + if (-24 <= _loggerTimeZone && _loggerTimeZone <= -10) { tzString += F(":00"); } - else if (-10 < _timeZone && _timeZone < 0) + else if (-10 < _loggerTimeZone && _loggerTimeZone < 0) { tzString = tzString.substring(0,1) + '0' + tzString.substring(1,2) + F(":00"); } - else if (_timeZone == 0) + else if (_loggerTimeZone == 0) { tzString = 'Z'; } - else if (0 < _timeZone && _timeZone < 10) + else if (0 < _loggerTimeZone && _loggerTimeZone < 10) { tzString = "+0" + tzString + F(":00"); } - else if (10 <= _timeZone && _timeZone <= 24) + else if (10 <= _loggerTimeZone && _loggerTimeZone <= 24) { tzString = "+" + tzString + F(":00"); } @@ -534,7 +570,7 @@ bool Logger::setRTClock(uint32_t setTime) return false; } - uint32_t set_logTZ = setTime + getTimeZone()*3600; + uint32_t set_logTZ = setTime + getLoggerTimeZone()*3600; uint32_t set_rtcTZ = set_logTZ - getTZOffset()*3600; MS_DBG(F(" Correct Time for Logger:"), set_logTZ, F("->"), \ formatDateTime_ISO8601(set_logTZ)); @@ -914,8 +950,8 @@ void Logger::printFileHeader(Stream *stream) // We'll finish up the the custom variable codes String dtRowHeader = F("Date and Time in UTC"); - if (_timeZone > 0) dtRowHeader += '+' + _timeZone; - else if (_timeZone < 0) dtRowHeader += _timeZone; + if (_loggerTimeZone > 0) dtRowHeader += '+' + _loggerTimeZone; + else if (_loggerTimeZone < 0) dtRowHeader += _loggerTimeZone; STREAM_CSV_ROW(dtRowHeader, getVarCodeAtI(i)); } diff --git a/src/LoggerBase.h b/src/LoggerBase.h index 2d2838434..946ab8fac 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -189,16 +189,21 @@ class Logger // ===================================================================== // public: - // Sets the static timezone - this must be set - static void setTimeZone(int8_t timeZone); - static int8_t getTimeZone(void) { return Logger::_timeZone; } + // Sets the static timezone that the data will be logged in - this must be set + static void setLoggerTimeZone(int8_t timeZone); + static int8_t getLoggerTimeZone(void); + + // Sets the static timezone that the RTC is programmed in + // I VERY VERY STRONGLY RECOMMEND SETTING THE RTC IN UTC + static void setRTCTimeZone(int8_t timeZone); + static int8_t getRTCTimeZone(void); // This set the offset between the built-in clock and the time zone where // the data is being recorded. If your RTC is set in UTC and your logging // timezone is EST, this should be -5. If your RTC is set in EST and your // timezone is EST this does not need to be called. static void setTZOffset(int8_t offset); - static int8_t getTZOffset(void) { return Logger::_offset; } + static int8_t getTZOffset(void); // This gets the current epoch time (unix time, ie, the number of seconds // from January 1, 1970 00:00:00 UTC) and corrects it for the specified time zone @@ -237,8 +242,8 @@ class Logger protected: // Static variables - identical for EVERY logger - static int8_t _timeZone; - static int8_t _offset; + static int8_t _loggerTimeZone; + static int8_t _loggerRTCOffset; // ============================================================================ // Public Functions for sleeping the logger diff --git a/src/ModSensorDebugger.h b/src/ModSensorDebugger.h index 2932e16b6..df6d44d7c 100644 --- a/src/ModSensorDebugger.h +++ b/src/ModSensorDebugger.h @@ -15,7 +15,7 @@ #include // The current library version number -#define MODULAR_SENSORS_VERSION "0.22.3" +#define MODULAR_SENSORS_VERSION "0.22.4" #ifndef STANDARD_SERIAL_OUTPUT // #if defined(ARDUINO_SAMD_ZERO) && defined(SERIAL_PORT_USBVIRTUAL) From 9ce918f26d1a13f8b799ad65629a3a9349d1a101 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 24 Jun 2019 17:59:42 -0400 Subject: [PATCH 87/88] Explicit cast to uint32_t before multiplication, fixes #259. Version bump --- examples/DRWI_CitSci/DRWI_CitSci.ino | 4 +-- examples/DRWI_LTE/DRWI_LTE.ino | 4 +-- examples/DRWI_NoCellular/DRWI_NoCellular.ino | 4 +-- .../baro_rho_correction.ino | 4 +-- examples/data_saving/data_saving.ino | 4 +-- examples/double_logger/double_logger.ino | 4 +-- examples/logging_to_MMW/logging_to_MMW.ino | 4 +-- .../logging_to_ThingSpeak.ino | 4 +-- examples/menu_a_la_carte/menu_a_la_carte.ino | 4 +-- examples/simple_logging/simple_logging.ino | 4 +-- .../simple_logging_LearnEnviroDIY.ino | 4 +-- examples/single_sensor/single_sensor.ino | 4 +-- library.json | 2 +- library.properties | 2 +- src/LoggerBase.cpp | 34 ++++++++++++------- src/LoggerBase.h | 6 +++- src/LoggerModem.h | 1 + src/ModSensorDebugger.h | 2 +- 18 files changed, 55 insertions(+), 40 deletions(-) diff --git a/examples/DRWI_CitSci/DRWI_CitSci.ino b/examples/DRWI_CitSci/DRWI_CitSci.ino index e0bf26309..22e5cccfa 100644 --- a/examples/DRWI_CitSci/DRWI_CitSci.ino +++ b/examples/DRWI_CitSci/DRWI_CitSci.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.4 +This example sketch is written for ModularSensors library version 0.22.5 This sketch is an example of logging data to an SD card and sending the data to both the EnviroDIY data portal as should be used by groups involved with @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.4"; +const char *libraryVersion = "0.22.5"; // The name of this file const char *sketchName = "DWRI_CitSci.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/DRWI_LTE/DRWI_LTE.ino b/examples/DRWI_LTE/DRWI_LTE.ino index 851eb3cef..ec5a6dc1f 100644 --- a/examples/DRWI_LTE/DRWI_LTE.ino +++ b/examples/DRWI_LTE/DRWI_LTE.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.4 +This example sketch is written for ModularSensors library version 0.22.5 This sketch is an example of logging data to an SD card and sending the data to both the EnviroDIY data portal as should be used by groups involved with @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.4"; +const char *libraryVersion = "0.22.5"; // The name of this file const char *sketchName = "DRWI_LTE.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/DRWI_NoCellular/DRWI_NoCellular.ino b/examples/DRWI_NoCellular/DRWI_NoCellular.ino index 56ac1d4c4..236db8447 100644 --- a/examples/DRWI_NoCellular/DRWI_NoCellular.ino +++ b/examples/DRWI_NoCellular/DRWI_NoCellular.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.4 +This example sketch is written for ModularSensors library version 0.22.5 This sketch is an example of logging data to an SD card as should be used by groups involved with The William Penn Foundation's Delaware River Watershed @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.4"; +const char *libraryVersion = "0.22.5"; // The name of this file const char *sketchName = "DRWI_NoCellular.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/baro_rho_correction/baro_rho_correction.ino b/examples/baro_rho_correction/baro_rho_correction.ino index cde838956..9051e3121 100644 --- a/examples/baro_rho_correction/baro_rho_correction.ino +++ b/examples/baro_rho_correction/baro_rho_correction.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.4 +This example sketch is written for ModularSensors library version 0.22.5 This sketch is an example of logging data to an SD card and sending the data to the EnviroDIY data portal. @@ -27,7 +27,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.4"; +const char *libraryVersion = "0.22.5"; // The name of this file const char *sketchName = "baro_rho_correction.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/data_saving/data_saving.ino b/examples/data_saving/data_saving.ino index 7be9bcafc..259560b74 100644 --- a/examples/data_saving/data_saving.ino +++ b/examples/data_saving/data_saving.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.4 +This example sketch is written for ModularSensors library version 0.22.5 This sketch is an example of logging data to an SD card and sending only a portion of that data to the EnviroDIY data portal. @@ -27,7 +27,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.4"; +const char *libraryVersion = "0.22.5"; // The name of this file const char *sketchName = "data_saving.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/double_logger/double_logger.ino b/examples/double_logger/double_logger.ino index f6d2c14bc..b5aade2a1 100644 --- a/examples/double_logger/double_logger.ino +++ b/examples/double_logger/double_logger.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.4 +This example sketch is written for ModularSensors library version 0.22.5 This sketch is an example of logging data from different variables at two different logging intervals. This example uses more of the manual functions @@ -28,7 +28,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.4"; +const char *libraryVersion = "0.22.5"; // The name of this file const char *sketchName = "double_logger.ino"; // Logger ID - we're only using one logger ID for both "loggers" diff --git a/examples/logging_to_MMW/logging_to_MMW.ino b/examples/logging_to_MMW/logging_to_MMW.ino index 4169a7cd2..5a506c472 100644 --- a/examples/logging_to_MMW/logging_to_MMW.ino +++ b/examples/logging_to_MMW/logging_to_MMW.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.4 +This example sketch is written for ModularSensors library version 0.22.5 This shows most of the standard functions of the library at once. @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.4"; +const char *libraryVersion = "0.22.5"; // The name of this file const char *sketchName = "logging_to MMW.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino index f9167b890..f539a0fae 100644 --- a/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino +++ b/examples/logging_to_ThingSpeak/logging_to_ThingSpeak.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.4 +This example sketch is written for ModularSensors library version 0.22.5 This sketch is an example of logging data to an SD card and sending the data to ThingSpeak. @@ -27,7 +27,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.4"; +const char *libraryVersion = "0.22.5"; // The name of this file const char *sketchName = "logging_to_ThingSpeak.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/menu_a_la_carte/menu_a_la_carte.ino b/examples/menu_a_la_carte/menu_a_la_carte.ino index ebb4820eb..fa10e61fd 100644 --- a/examples/menu_a_la_carte/menu_a_la_carte.ino +++ b/examples/menu_a_la_carte/menu_a_la_carte.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.4 +This example sketch is written for ModularSensors library version 0.22.5 This shows most of the standard functions of the library at once. @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.4"; +const char *libraryVersion = "0.22.5"; // The name of this file const char *sketchName = "menu_a_la_carte.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/simple_logging/simple_logging.ino b/examples/simple_logging/simple_logging.ino index 0e5645534..3f5823686 100644 --- a/examples/simple_logging/simple_logging.ino +++ b/examples/simple_logging/simple_logging.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.4 +This example sketch is written for ModularSensors library version 0.22.5 This sketch is an example of logging data to an SD card @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.4"; +const char *libraryVersion = "0.22.5"; // The name of this file const char *sketchName = "simple_logging.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino b/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino index 86bb06d88..a236b5020 100644 --- a/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino +++ b/examples/simple_logging_LearnEnviroDIY/simple_logging_LearnEnviroDIY.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.4 +This example sketch is written for ModularSensors library version 0.22.5 This sketch is an example of logging data to an SD card @@ -26,7 +26,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // Data Logger Settings // ========================================================================== // The library version this example was written for -const char *libraryVersion = "0.22.4"; +const char *libraryVersion = "0.22.5"; // The name of this file const char *sketchName = "simple_logging.ino"; // Logger ID, also becomes the prefix for the name of the data file on SD card diff --git a/examples/single_sensor/single_sensor.ino b/examples/single_sensor/single_sensor.ino index b86297d01..33fde8a55 100644 --- a/examples/single_sensor/single_sensor.ino +++ b/examples/single_sensor/single_sensor.ino @@ -7,7 +7,7 @@ Software License: BSD-3. Copyright (c) 2017, Stroud Water Research Center (SWRC) and the EnviroDIY Development Team -This example sketch is written for ModularSensors library version 0.22.4 +This example sketch is written for ModularSensors library version 0.22.5 This sketch is an example of getting data from a single sensor, in this case, a MaxBotix Ultrasonic Range Finder @@ -24,7 +24,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. #include // The library version this example was written for -const char *libraryVersion = "0.22.4"; +const char *libraryVersion = "0.22.5"; // The name of this file const char *sketchName = "single_sensor.ino"; diff --git a/library.json b/library.json index 6b543cb95..8a2945b0f 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "EnviroDIY_ModularSensors", - "version": "0.22.4", + "version": "0.22.5", "description": "A library that allows access to multiple sensors through a unified interface. This allows the user to simply access many sensors to log the data or send the data to data repositories like the EnviroDIY data portal.", "keywords": "modular, sensor, sensors, datalogger, logger, low power, sleeping, EnviroDIY, ModularSensors, Mayfly, WikiWatershed, ThingSpeak", "platforms": "atmelavr, atmelsam", diff --git a/library.properties b/library.properties index a0bf17d5e..2d46c193f 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=EnviroDIY_ModularSensors -version=0.22.4 +version=0.22.5 author=Sara Damiano , Shannon Hicks maintainer=Sara Damiano sentence=A library that allows access to multiple sensors through a unified interface. diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index 5f479520b..a6abec767 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -492,7 +492,7 @@ int8_t Logger::getTZOffset(void) uint32_t Logger::getNowEpoch(void) { uint32_t currentEpochTime = rtc.now().getEpoch(); - currentEpochTime += _loggerRTCOffset*3600; + currentEpochTime += ((uint32_t)_loggerRTCOffset)*3600; return currentEpochTime; } void Logger::setNowEpoch(uint32_t ts){rtc.setEpoch(ts);} @@ -502,7 +502,7 @@ void Logger::setNowEpoch(uint32_t ts){rtc.setEpoch(ts);} uint32_t Logger::getNowEpoch(void) { uint32_t currentEpochTime = zero_sleep_rtc.getEpoch(); - currentEpochTime += _loggerRTCOffset*3600; + currentEpochTime += ((uint32_t)_loggerRTCOffset)*3600; return currentEpochTime; } void Logger::setNowEpoch(uint32_t ts){zero_sleep_rtc.setEpoch(ts);} @@ -518,6 +518,8 @@ DateTime Logger::dtFromEpoch(uint32_t epochTime) } // This converts a date-time object into a ISO8601 formatted string +// It assumes the supplied date/time is in the LOGGER's timezone and adds +// the LOGGER's offset as the time zone offset in the string. String Logger::formatDateTime_ISO8601(DateTime& dt) { // Set up an inital string @@ -552,6 +554,8 @@ String Logger::formatDateTime_ISO8601(DateTime& dt) // This converts an epoch time (unix time) into a ISO8601 formatted string +// It assumes the supplied date/time is in the LOGGER's timezone and adds +// the LOGGER's offset as the time zone offset in the string. String Logger::formatDateTime_ISO8601(uint32_t epochTime) { // Create a DateTime object from the epochTime @@ -561,28 +565,32 @@ String Logger::formatDateTime_ISO8601(uint32_t epochTime) // This sets the real time clock to the given time -bool Logger::setRTClock(uint32_t setTime) +bool Logger::setRTClock(uint32_t UTCEpochSeconds) { // If the timestamp is zero, just exit - if (setTime == 0) + if (UTCEpochSeconds == 0) { PRINTOUT(F("Bad timestamp, not setting clock.")); return false; } - uint32_t set_logTZ = setTime + getLoggerTimeZone()*3600; - uint32_t set_rtcTZ = set_logTZ - getTZOffset()*3600; - MS_DBG(F(" Correct Time for Logger:"), set_logTZ, F("->"), \ - formatDateTime_ISO8601(set_logTZ)); + // The "setTime" is the number of seconds since Jan 1, 1970 in UTC + // We're interested in the setTime in the logger's and RTC's timezone + // The RTC's timezone is equal to the logger's timezone minus the offset + // between the logger and the RTC. + uint32_t set_logTZ = UTCEpochSeconds + ((uint32_t)getLoggerTimeZone())*3600; + uint32_t set_rtcTZ = set_logTZ - ((uint32_t)getTZOffset())*3600; + MS_DBG(F(" Time for Logger supplied by NIST:"), set_logTZ, \ + F("->"), formatDateTime_ISO8601(set_logTZ)); // Check the current RTC time uint32_t cur_logTZ = getNowEpoch(); - MS_DBG(F(" Time Returned by RTC:"), cur_logTZ, F("->"), \ + MS_DBG(F(" Current Time on RTC:"), cur_logTZ, F("->"), \ formatDateTime_ISO8601(cur_logTZ)); - MS_DBG(F("Offset:"), abs(set_logTZ - cur_logTZ)); + MS_DBG(F(" Offset between NIST and RTC:"), abs(set_logTZ - cur_logTZ)); // If the RTC and NIST disagree by more than 5 seconds, set the clock - if ((abs(set_logTZ - cur_logTZ) > 5) && (setTime != 0)) + if ((abs(set_logTZ - cur_logTZ) > 5) && (UTCEpochSeconds != 0)) { setNowEpoch(set_rtcTZ); PRINTOUT(F("Clock set!")); @@ -615,7 +623,8 @@ bool Logger::checkInterval(void) { bool retval; uint32_t checkTime = getNowEpoch(); - MS_DBG(F("Current Unix Timestamp:"), checkTime); + MS_DBG(F("Current Unix Timestamp:"), checkTime, F("->"), \ + formatDateTime_ISO8601(checkTime)); MS_DBG(F("Logging interval in seconds:"), (_loggingIntervalMinutes*60)); MS_DBG(F("Mod of Logging Interval:"), checkTime % (_loggingIntervalMinutes*60)); @@ -669,6 +678,7 @@ bool Logger::checkMarkedInterval(void) // This must be a static function (which means it can only call other static funcions.) void Logger::wakeISR(void) { + Logger::markTime(); // MS_DBG(F("Clock interrupt!")); } diff --git a/src/LoggerBase.h b/src/LoggerBase.h index 946ab8fac..84a40e659 100644 --- a/src/LoggerBase.h +++ b/src/LoggerBase.h @@ -217,13 +217,17 @@ class Logger static DateTime dtFromEpoch(uint32_t epochTime); // This converts a date-time object into a ISO8601 formatted string + // It assumes the supplied date/time is in the LOGGER's timezone and adds + // the LOGGER's offset as the time zone offset in the string. static String formatDateTime_ISO8601(DateTime& dt); // This converts an epoch time (unix time) into a ISO8601 formatted string + // It assumes the supplied date/time is in the LOGGER's timezone and adds + // the LOGGER's offset as the time zone offset in the string. static String formatDateTime_ISO8601(uint32_t epochTime); // This sets the real time clock to the given time - bool setRTClock(uint32_t setTime); + bool setRTClock(uint32_t UTCEpochSeconds); // This sets static variables for the date/time - this is needed so that all // data outputs (SD, EnviroDIY, serial printing, etc) print the same time diff --git a/src/LoggerModem.h b/src/LoggerModem.h index ab0c7fb40..af0fbc81e 100644 --- a/src/LoggerModem.h +++ b/src/LoggerModem.h @@ -134,6 +134,7 @@ class loggerModem : public Sensor // Get the time from NIST via TIME protocol (rfc868) // This would be much more efficient if done over UDP, but I'm doing it // over TCP because I don't have a UDP library for all the modems. + // NOTE: The return is the number of seconds since Jan 1, 1970 IN UTC virtual uint32_t getNISTTime(void) = 0; protected: diff --git a/src/ModSensorDebugger.h b/src/ModSensorDebugger.h index df6d44d7c..65cdc3ca6 100644 --- a/src/ModSensorDebugger.h +++ b/src/ModSensorDebugger.h @@ -15,7 +15,7 @@ #include // The current library version number -#define MODULAR_SENSORS_VERSION "0.22.4" +#define MODULAR_SENSORS_VERSION "0.22.5" #ifndef STANDARD_SERIAL_OUTPUT // #if defined(ARDUINO_SAMD_ZERO) && defined(SERIAL_PORT_USBVIRTUAL) From 9c87c2e77e5e6ae00cd3ab482e17ef1a1b084bd0 Mon Sep 17 00:00:00 2001 From: Sara Damiano Date: Mon, 24 Jun 2019 18:05:00 -0400 Subject: [PATCH 88/88] Revert markTime in ISR. Need to think more on the implications of it. --- src/LoggerBase.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/LoggerBase.cpp b/src/LoggerBase.cpp index a6abec767..5374ab51d 100644 --- a/src/LoggerBase.cpp +++ b/src/LoggerBase.cpp @@ -678,7 +678,6 @@ bool Logger::checkMarkedInterval(void) // This must be a static function (which means it can only call other static funcions.) void Logger::wakeISR(void) { - Logger::markTime(); // MS_DBG(F("Clock interrupt!")); }