From e86fda14a2a36545336b8716612a5e939b64ace7 Mon Sep 17 00:00:00 2001 From: "neilh20.gitk" Date: Thu, 7 Oct 2021 12:54:03 -0700 Subject: [PATCH] WiFi S6B changes #21 - remove SSID writes and add S6B restart --- a/tu_xx01/lib/SDI-12nh | 1 - a/tu_xx01/lib/TinyGSMnh | 1 + a/tu_xx01/platformio.ini | 29 ++- a/tu_xx01/src/ms_cfg.h | 19 +- a/tu_xx01/src/ms_cfg.h_LT5_wifi | 287 +++++++++++++++++++++ a/tu_xx01/src/tu_xx01.cpp | 2 +- src/LoggerBaseSDcpp.h | 4 +- src/modems/DigiXBeeCellularTransparent.cpp | 44 ++-- src/modems/DigiXBeeWifi.cpp | 56 ++-- src/modems/LoggerModemMacros.h | 4 - 10 files changed, 372 insertions(+), 75 deletions(-) delete mode 160000 a/tu_xx01/lib/SDI-12nh create mode 160000 a/tu_xx01/lib/TinyGSMnh create mode 100644 a/tu_xx01/src/ms_cfg.h_LT5_wifi diff --git a/a/tu_xx01/lib/SDI-12nh b/a/tu_xx01/lib/SDI-12nh deleted file mode 160000 index 1234e7f8e..000000000 --- a/a/tu_xx01/lib/SDI-12nh +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1234e7f8efa595dd32505e385fc674e08dbc0782 diff --git a/a/tu_xx01/lib/TinyGSMnh b/a/tu_xx01/lib/TinyGSMnh new file mode 160000 index 000000000..b2696a715 --- /dev/null +++ b/a/tu_xx01/lib/TinyGSMnh @@ -0,0 +1 @@ +Subproject commit b2696a7157377783026445f2864255f7f284489d diff --git a/a/tu_xx01/platformio.ini b/a/tu_xx01/platformio.ini index 16d071f80..e441e104a 100644 --- a/a/tu_xx01/platformio.ini +++ b/a/tu_xx01/platformio.ini @@ -17,10 +17,11 @@ default_envs = mayfly ; Ignore these folders or PlatformIO will double count all the dependencies ; Development: ModularSensors Release1: src ? ; ?? .pioenvs, .piolibdeps, .vscode, include, doc, examples, sensor_tests, compile_tests, pioScripts -lib_ignore = .git, doc, examples, arduino_update, sensor_tests, ModularSensors +lib_ignore = .git, doc, examples, arduino_update, sensor_tests, + ModularSensors EnviroDIY_DS3231 - Arduino-SDI-12 TinyGSM ;see below + ;Arduino-SDI-12 lib_cmn_deps = ; These are latest beyond EnviroDIY releases @@ -60,9 +61,9 @@ lib_cmn_deps = ;https://github.com/PaulStoffregen/OneWire ;https://github.com/knolleary/pubsubclient.git ;bug https://github.com/EnviroDIY/TinyGSM.git ; bug EnviroDIY/ModularSensors/issues 311 - https://github.com/neilh10/TinyGSM.git ;Bug fixes over Envirodiy + ;https://github.com/neilh10/TinyGSM.git ;Bug fixes over Envirodiy ;https://github.com/EnviroDIY/YosemitechModbus - ;https://github.com/neilh10/Arduino-SDI-12#release1 + https://github.com/neilh10/Arduino-SDI-12#release1 ;https://github.com/EnviroDIY/Arduino-SDI-12.git bug with extraWakeTime=10 ;https://github.com/EnviroDIY/Tally_Library.git#Dev_I2C ; @@ -87,11 +88,11 @@ cmn_build_flags = -DMQTT_MAX_PACKET_SIZE=240 -DTINY_GSM_YIELD_MS=2 ;-DTINY_GSM_RX_BUFFER=64 ;is this needed? - -DNO_FIRST_SYNC_WITH_NIST + ;-DNO_FIRST_SYNC_WITH_NIST -DNIST_SYNC_HOURLY ;-DMS_TU_XX_DEBUG ;-DMS_TU_XX_DEBUG_DEEP - ;-DSTREAMDEBUGGER_DBG + -DSTREAMDEBUGGER_DBG ;-DMS_DUMP_FREE_RAM ;-DMS_TTY_USER_INPUT -DSerialCommand_inFlash ;requires MS_TTY_USER_INPUT @@ -99,25 +100,26 @@ cmn_build_flags = ;-DSERIALCOMMAND_DEBUG ;-DMS_LOGGERBASE_POSTS ;-DMS_LOGGERBASE_SLEEP_DEBUG ;Need or below - ;-DMS_LOGGERBASE_DEBUG + -DMS_LOGGERBASE_DEBUG ;-DMS_LOGGERBASE_DEEP_DEBUG ;-DMS_LOGGERMODEM_DEBUG - ;-DMS_LOGGERMODEM_DEBUG_DEEP + -DMS_LOGGERMODEM_DEBUG_DEEP ;-DMS_SENSORBASE_DEBUG ;-DMS_VARIABLEARRAY_DEBUG ;-DMS_VARIABLEARRAY_DEBUG_DEEP ;-DMS_VARIABLEBASE_DEBUG ;-DMS_VARIABLEBASE_DEBUG_DEEP ;-DMS_DATAPUBLISHERBASE_DEBUG - ;-DMS_ENVIRODIYPUBLISHER_DEBUG + -DMS_ENVIRODIYPUBLISHER_DEBUG ;-DMS_THINGSPEAKPUBLISHER_DEBUG ;-DMS_UBIDOTSPUBLISHER_DEBUG - ;-DMS_DIGIXBEEWIFI_DEBUG + -DDIGIXBEEWIFI_NO_IP_SAV + -DMS_DIGIXBEEWIFI_DEBUG ;-DMS_DIGIXBEEWIFI_DEBUG_DEEP ;-DMS_DIGIXBEECELLULARTRANSPARENT_DEBUG ;-DMS_DIGIXBEECELLULARTRANSPARENT_DEBUG_DEEP ;-DMS_DIGIXBEE_DEBUG - ;-DTINY_GSM_DEBUG=Serial + -DTINY_GSM_DEBUG=Serial ;-DTinyGsmClientXbee_DBG=Serial ;-DMS_STSTC3100SENSOR_DEBUG ;-DSTC3100DM_DEBUG ; device manager @@ -134,13 +136,12 @@ cmn_build_flags = ;-DMS_MODBUS_DEBUG ;-DMS_ANALOGELECCONDUCTIVITY_DEBUG ;-DMS_ANALOGELECCONDUCTIVITY_DEBUG_DEEP - -DMS_SDI12SENSORS_DEBUG ;LT500 sometimes responding - -DMS_SDI12SENSORS_DEBUG_DEEP + ;-DMS_SDI12SENSORS_DEBUG ;LT500 sometimes responding + ;-DMS_SDI12SENSORS_DEBUG_DEEP ;For -DMS_SDI12 options: NONE or MS_SDI12_SINGLE_LINE_RESPONSE OR MS_SDI12_NON_CONCURRENT not BOTH ;-DMS_SDI12_SINGLE_LINE_RESPONSE ;-DMS_SDI12_NON_CONCURRENT ;-DENVIRODIY_SDI12_USE_CRC - -DMS_SDI12_USE_CRC ;-DMS_ENVIRODIYPUBLISHER_DEBUG ;-DMS_ENVIRODIYPUBLISHER_DEBUG_DEEP -DSodaq_DS3231_DEBUG diff --git a/a/tu_xx01/src/ms_cfg.h b/a/tu_xx01/src/ms_cfg.h index 5e8ee5011..a68fecc66 100644 --- a/a/tu_xx01/src/ms_cfg.h +++ b/a/tu_xx01/src/ms_cfg.h @@ -1,6 +1,5 @@ /***************************************************************************** -ms_cfg.h_LT5_wifi - ModularSensors Configuration - tgt _LT5 Acculevel / WiFi -Status 210326: 0.28.3 updated cc, not tested +ms_cfg.h_LT5_lte - ModularSensors Configuration - tgt _LT5 /WiFi Written By: Neil Hancock www.envirodiy.org/members/neilh20/ Development Environment: PlatformIO Hardware Platform(s): EnviroDIY Mayfly Arduino Datalogger+RS485 Wingboard @@ -31,8 +30,8 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. // MAYFLY_BAT_DIGI Digi Modem LTE with onboard battery measurement // Choices applied to define MAYFLY_BAT_xx 1) Stc3100 2) ExternVolage_ACT 3) Digi Mode 4) MAYFLY_BAT_A6 -//#define MAYFLY_BAT_A6 4 -#define MAYFLY_BAT_AA0 2 +#define MAYFLY_BAT_A6 4 +//#define MAYFLY_BAT_AA0 2 //FUT #define MAYFLY_BAT_DIGI 3 @@ -46,9 +45,9 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. //#define USE_STC3100_DD 1 #define MAYFLY_BAT_STC3100 1 // Only one of NOT both KellerAcculevel and KellerNanolevel as share same ADDR -#define KellerAcculevel_ACT 1 +//#define KellerAcculevel_ACT 1 // KellerAcculevel units can be 1 (meter) 2 (feet) -#define KellerAcculevel_DepthUnits 2 +//#define KellerAcculevel_DepthUnits 2 //#define KellerNanolevel_ACT 1 #endif //WINGBOARD_KNH002 @@ -62,7 +61,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. //#define ASONG_AM23XX_UUID 1 //Two heavy sensors with power useage -#define BM_PWR_SENSOR_CONFIG_BUILD_SPECIFIC BM_PWR_MEDIUM_REQ +#define BM_PWR_SENSOR_CONFIG_BUILD_SPECIFIC BM_PWR_LOW_REQ // Mayfly configuration // Carrier board for Digi XBEE LTE CAT-M1 and jumper from battery @@ -72,7 +71,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. #define MFName_DEF "Mayfly" #define HwVersion_DEF MFVersion_DEF #define HwName_DEF MFName_DEF -#define CONFIGURATION_DESCRIPTION_STR "tu_LT5KA_wifi LT500,Acculevel" +#define CONFIGURATION_DESCRIPTION_STR "tu_LT5_wifi LT500" #define USE_MS_SD_INI 1 #define USE_PS_EEPROM 1 @@ -147,7 +146,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. #define WIFIID_CDEF "xxx" // NULL for none, or password for connecting to WiFi, #define WIFIPWD_CDEF "yyy" -#define MMW_TIMER_POST_TIMEOUT_MS_DEF 7000L +#define MMW_TIMER_POST_TIMEOUT_MS_DEF 9000L //POST PACING ms 0-15000 #define MMW_TIMER_POST_PACING_MS_DEF 100L //Post MAX Num - is num of MAX num at one go. 0 no limit @@ -251,7 +250,7 @@ THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. #if defined UseModem_Module // This seems to be de-stabilizing Digi S6B -//#define DIGI_RSSI_UUID "DIGI_RSSI_UUID" +#define DIGI_RSSI_UUID "DIGI_RSSI_UUID" //#define Modem_SignalPercent_UUID "SignalPercent_UUID" #endif // UseModem_Module diff --git a/a/tu_xx01/src/ms_cfg.h_LT5_wifi b/a/tu_xx01/src/ms_cfg.h_LT5_wifi new file mode 100644 index 000000000..a68fecc66 --- /dev/null +++ b/a/tu_xx01/src/ms_cfg.h_LT5_wifi @@ -0,0 +1,287 @@ +/***************************************************************************** +ms_cfg.h_LT5_lte - ModularSensors Configuration - tgt _LT5 /WiFi +Written By: Neil Hancock www.envirodiy.org/members/neilh20/ +Development Environment: PlatformIO +Hardware Platform(s): EnviroDIY Mayfly Arduino Datalogger+RS485 Wingboard + +Software License: BSD-3. + Copyright (c) 2018, Neil Hancock - all rights assigned to Stroud Water +Research Center (SWRC) and they may change this title to Stroud Water Research +Center as required and the EnviroDIY Development Team + + +DISCLAIMER: +THIS CODE IS PROVIDED "AS IS" - NO WARRANTY IS GIVEN. +*****************************************************************************/ +#ifndef ms_cfg_h +#define ms_cfg_h +#include // The base Arduino library +// Local default defitions here + +//************************************************************************** +// This configuration is for a standard Mayfly0.5b +// Sensors Used - two std to begin then +//#define AnalogProcEC_ACT 1 +// Power Availability monitoring decisions use LiIon Voltge, +// Battery Voltage measurements can be derived from a number of sources +// MAYFLY_BAT_A6 - standard measures Solar Charging or LiIon battry V which ever is greated +// MAYFLY_BAT_AA0 - ExternalVolt/ADS1115 requires external R - ECO4 +// MAYFLY_BAT_STC3100 sensor IC on RS485 WINGBOARD_KNH002 +// MAYFLY_BAT_DIGI Digi Modem LTE with onboard battery measurement +// Choices applied to define MAYFLY_BAT_xx 1) Stc3100 2) ExternVolage_ACT 3) Digi Mode 4) MAYFLY_BAT_A6 + +#define MAYFLY_BAT_A6 4 +//#define MAYFLY_BAT_AA0 2 +//FUT #define MAYFLY_BAT_DIGI 3 + + +//#define ENVIRODIY_MAYFLY_TEMPERATURE 1 +//#define Decagon_CTD_UUID 1 +#define Insitu_TrollSdi12_UUID 1 + +#define WINGBOARD_KNH002 1 +#if defined WINGBOARD_KNH002 +//This supports RS485 1.9W and STC3100 +//#define USE_STC3100_DD 1 +#define MAYFLY_BAT_STC3100 1 +// Only one of NOT both KellerAcculevel and KellerNanolevel as share same ADDR +//#define KellerAcculevel_ACT 1 +// KellerAcculevel units can be 1 (meter) 2 (feet) +//#define KellerAcculevel_DepthUnits 2 + +//#define KellerNanolevel_ACT 1 +#endif //WINGBOARD_KNH002 + +//Select one of following MAYFLY_BAT_xx as the source for BatterManagement Analysis +//#define MAYFLY_BAT_CHOICE MAYFLY_BAT_A6 +//#define MAYFLY_BAT_CHOICE MAYFLY_BAT_AA0 +#define MAYFLY_BAT_CHOICE MAYFLY_BAT_STC3100 +// FUT #define MAYFLY_BAT_CHOICE MAYFLY_BAT_DIGI + +//#define ASONG_AM23XX_UUID 1 + +//Two heavy sensors with power useage +#define BM_PWR_SENSOR_CONFIG_BUILD_SPECIFIC BM_PWR_LOW_REQ + +// Mayfly configuration +// Carrier board for Digi XBEE LTE CAT-M1 and jumper from battery +// Digi WiFi S6 plugged in directly +// For debug: C4 removed, strap for AA2/Vbat AA3/SolarV, +#define MFVersion_DEF "v0.5b" +#define MFName_DEF "Mayfly" +#define HwVersion_DEF MFVersion_DEF +#define HwName_DEF MFName_DEF +#define CONFIGURATION_DESCRIPTION_STR "tu_LT5_wifi LT500" + +#define USE_MS_SD_INI 1 +#define USE_PS_EEPROM 1 +#define USE_PS_HW_BOOT 1 + +//#define USE_PS_modularSensorsCommon 1 + +#define greenLEDPin 8 // MCU pin for the green LED (-1 if not applicable) +#define redLEDPin 9 // MCU pin for the red LED (-1 if not applicable) + +#define sensorPowerPin_DEF 22 +#define modemSleepRqPin_DEF 23 +#define modemStatusPin_DEF \ + 19 // MCU pin used to read modem status (-1 if not applicable) +#define modemResetPin_DEF \ + 20 // MCU pin connected to modem reset pin (-1 if unconnected) + +#define LOGGERID_DEF_STR "msLog01" +#define NEW_LOGGERID_MAX_SIZE 40 +#define configIniID_DEF_STR "ms_cfg.ini" +#define CONFIG_TIME_ZONE_DEF -8 + +// ** How frequently (in minutes) to log data ** +// For two Loggers defined logger2Mult with the faster loggers timeout and the +// multiplier to the slower loggger +// #define loggingInterval_Fast_MIN (1) +// #define logger2Mult 5 ~Not working for mayfly + +// How frequently (in minutes) to log data +#if defined logger2Mult +#define loggingInterval_CDEF_MIN (loggingInterval_Fast_MIN * logger2Mult) +#else +#define loggingInterval_CDEF_MIN 15 +#endif // logger2Mult +// Maximum logging setting allowed +#define loggingInterval_MAX_CDEF_MIN 6 * 60 + +// Maximum logging setting allowed +#define loggingInterval_MAX_CDEF_MIN 6 * 60 + + +// Instructions: define only one _Module +#define DigiXBeeWifi_Module 1 +//#warning infoMayflyWithDigiXBeeWiFi +//#define DigiXBeeCellularTransparent_Module 1 +//#warning infoMayflyWithDigiXBeeCellTransparent +// #define DigiXBeeLTE_Module 1 - unstable +// #define TINY_GSM_MODEM_SIM800 // Select for a SIM800, SIM900, or variant +// thereof #define TINY_GSM_MODEM_UBLOX // Select for most u-blox cellular +// modems #define TINY_GSM_MODEM_ESP8266 // Select for an ESP8266 using the +// DEFAULT AT COMMAND FIRMWARE End TinyGsmClient.h options +#if defined(DigiXBeeWifi_Module) || defined(DigiXBeeCellularTransparent_Module) +// The Modem is used to push data and also sync Time +// In standalong logger, no internet, Modem can be required at factor to do a +// sync Time Normally enable both of the following. In standalone, disable +// UseModem_PushData. +#define UseModem_Module 1 +#define UseModem_PushData 1 +//Select buildtime Publishers supported. +// The persisten resources (EEPROM) are allocated as a baselevel no matter what options +#define USE_PUB_MMW 1 +//#define USE_PUB_TSMQTT 1 +//#define USE_PUB_UBIDOTS 1 + +// Required for TinyGsmClient.h +#define TINY_GSM_MODEM_XBEE + +// The APN for the gprs connection, unnecessary for WiFi +#define APN_CDEF "hologram" + +// The WiFi access point +#define WIFIID_CDEF "xxx" +// NULL for none, or password for connecting to WiFi, +#define WIFIPWD_CDEF "yyy" +#define MMW_TIMER_POST_TIMEOUT_MS_DEF 9000L +//POST PACING ms 0-15000 +#define MMW_TIMER_POST_PACING_MS_DEF 100L +//Post MAX Num - is num of MAX num at one go. 0 no limit +#define MMW_TIMER_POST_MAX_MUM_DEF 100 +//Manage Internet - common for all providers +#define MNGI_COLLECT_READINGS_DEF 1 +#define MNGI_SEND_OFFSET_MIN_DEF 0 +#endif // Modules + +// end of _Module + +// This might need revisiting +#define ARD_ANLAOG_MULTIPLEX_PIN A6 + +//#define SENSOR_CONFIG_GENERAL 1 +//#define KellerAcculevel_ACT 1 +// Defaults for data.envirodiy.org +#define registrationToken_UUID "registrationToken_UUID" +#define samplingFeature_UUID "samplingFeature_UUID" + + +#ifdef Decagon_CTD_UUID +// Mayfly definitions +#define CTD10_DEPTH_UUID "CTD10_DEPTH_UUID" +#define CTD10_TEMP_UUID "CTD10_TEMP_UUID" +#define CTD10_COND_UUID "CTD10_COND_UUID" +#endif // Decagon_CTD_UUID + + +#ifdef Insitu_TrollSdi12_UUID +// Mayfly definitions +#define ITROLL_DEPTH_UUID "ITROLL_DEPTH_UUID" +#define ITROLL_TEMP_UUID "ITROLL_TEMP_UUID" +//#define ITROLL_PRESSURE_UUID "ITROLL_PRESSURE_UUID" +#endif // Insitu_Troll_UUID + + +#ifdef KellerAcculevel_ACT +#define KellerXxlevel_Height_UUID "KellerXxlevel_Height_UUID" +#define KellerXxlevel_Temp_UUID "KellerXxlevel_Temp_UUID" +#define CONFIG_SENSOR_RS485_PHY 1 +#define KellerAcculevelModbusAddress_DEF 0x01 +#endif // KellerAcculevel_ACT + +#ifdef KellerNanolevel_ACT +#define KellerXxlevel_Height_UUID "KellerXxlevel_Height_UUID" +#define KellerXxlevel_Temp_UUID "KellerXxlevel_Temp_UUID" +#define CONFIG_SENSOR_RS485_PHY 1 +#define KellerNanolevelModbusAddress_DEF 0x01 +#endif // KellerNanolevel_ACT + +//#define InsituLTrs485_ACT 1 -not working +#ifdef InsituLTrs485_ACT +#define CONFIG_SENSOR_RS485_PHY 1 +#define InsituLTrs485_Height_UUID "KellerNanolevel_Height_UUID" +#define InsituLTrs485_Temp_UUID "KellerNanolevel_Temp_UUID" +#define InsituLTrs485ModbusAddress_DEF 0x01 +// Default is 19200 lets hope serial works with it. +#define MODBUS_BAUD_RATE 19200 +#endif // InsituLTrs485_ACT + +#ifdef CONFIG_SENSOR_RS485_PHY +// Mayfly definitions +#define CONFIG_HW_RS485PHY_TX_PIN 5 // Mayfly OCRA1 map AltSoftSerial Tx pin +#define CONFIG_HW_RS485PHY_RX_PIN 6 // Mayfly ICES1 map AltSoftSerial Rx pin +#define CONFIG_HW_RS485PHY_DIR_PIN -1 +#define max485EnablePin_DEF -1 +#define rs485AdapterPower_DEF \ + 22 // Pin to switch RS485 adapter power on and off (-1 if unconnected) +#define modbusSensorPower_DEF \ + 22; // Pin to switch power on and off (-1 if unconnected) +#ifndef MODBUS_BAUD_RATE +#define MODBUS_BAUD_RATE 9600 +#endif // MODBUS_BAUD_RATE +#endif // CONFIG_SENSOR_RS485_PHY + + +#ifdef AnalogProcEC_ACT +#define EC1_UUID "EC1_UUID" +#define ECpwrPin_DEF A4 +#define ECdataPin1_DEF A0 +#endif // AnalogProcEC_ACT + +//#define INA219M_PHY_ACT 1 +#ifdef INA219M_PHY_ACT +#define INA219M_MA_UUID "INA219_MA_UUID" +#define INA219M_VOLT_UUID "INA219_VOLT_UUID" +#endif // INA219_PHY_ACT + +#if defined ASONG_AM23XX_UUID +#define ASONG_AM23_Air_Temperature_UUID "Air_Temperature_UUID" +#define ASONG_AM23_Air_TemperatureF_UUID "Air_TemperatureF_UUID" +#define ASONG_AM23_Air_Humidity_UUID "Air_Humidity_UUID" +#endif // ASONG_AM23XX_UUID + + +#ifdef ENVIRODIY_MAYFLY_TEMPERATURE +#define MaximDS3231_TEMP_UUID "MaximDS3231_TEMP_UUID" +//#define MaximDS3231_TEMPF_UUID "MaximDS3231_TEMPF_UUID" +#endif // ENVIRODIY_MAYFLY_TEMPERATURE + +#if defined UseModem_Module +// This seems to be de-stabilizing Digi S6B +#define DIGI_RSSI_UUID "DIGI_RSSI_UUID" +//#define Modem_SignalPercent_UUID "SignalPercent_UUID" +#endif // UseModem_Module + +#define ProcessorStats_ACT 1 +#if defined ProcessorStats_ACT +#define ProcessorStats_SampleNumber_UUID "SampleNumber_UUID" +#endif // ProcessorStats_ACT +#if defined MAYFLY_BAT_A6 +#define ProcessorStats_Batt_UUID "Batt_UUID" +#endif // MAYFLY_BAT_A6 + +#if defined MAYFLY_BAT_STC3100 +#define STC3100_Volt_UUID "STC3100Volt_UUID" +#define STC3100_USED1_mAhr_UUID "STC3100used1_mAhr_UUID" +#define STC3100_AVLBL_mAhr_UUID "STC3100avlbl_mAhr_UUID" +#endif // MAYFLY_BAT_STC3100 + +#ifdef MAYFLY_BAT_AA0 +// AA0(AIN0) is 1/10 of Vbat using R+R divider. Requires Mayfly ECO 04 +//#define ExternalVoltage_Volt0_UUID "Batt_UUID" +#define ExternalVoltage_Volt0_UUID "Volt0_UUID" +//#define ExternalVoltage_Volt1_UUID "Volt1_UUID" +//#else // MAYFLY_BAT_AA0 +#endif // MAYFLY_BAT_AA0 +#if 0// defined MAYFLY_BAT_A6 +#define ProcVolt_ACT 1 +#if defined ProcVolt_ACT +#define ProcVolt0_UUID "Batt_UUID" +//#define ProcVolt0_UUID "Volt0_UUID" +//#define ProcVolt1_UUID "Volt1_UUID" +#endif // ProcVolt_ACT +#endif // MAYFLY_BAT_A6 + +#endif // ms_cfg_h diff --git a/a/tu_xx01/src/tu_xx01.cpp b/a/tu_xx01/src/tu_xx01.cpp index 218dbdaea..fab41289b 100644 --- a/a/tu_xx01/src/tu_xx01.cpp +++ b/a/tu_xx01/src/tu_xx01.cpp @@ -301,7 +301,7 @@ DecagonCTD ctdPhy(*CTDSDI12address, SDI12Power, SDI12Data, CTDNumberReadings); #if defined Insitu_TrollSdi12_UUID // ========================================================================== -// Insitu Aqua/Level Troll Conductivity, Temperature, and Depth Sensor +// Insitu Aqua/Level Troll Pressure, Temperature, and Depth Sensor // ========================================================================== #include diff --git a/src/LoggerBaseSDcpp.h b/src/LoggerBaseSDcpp.h index 4041bd193..7fc36102a 100644 --- a/src/LoggerBaseSDcpp.h +++ b/src/LoggerBaseSDcpp.h @@ -64,7 +64,7 @@ void Logger::SD1_ListReadings() { _fileName.toCharArray(charFileName, fileNameLength); if (logFile.open(charFileName, O_RDONLY)) { - MS_DBG(F("Opened existing file:"), _filename); + MS_DBG(F("Opened existing file:"), _fileName); //Need to have watchdog not print while listing while (logFile.available()) { Serial.write(logFile.read()); @@ -73,7 +73,7 @@ void Logger::SD1_ListReadings() { logFile.close(); Serial.println(); } else { - MS_DBG(F("Unable to to find file:"), _filename); + MS_DBG(F("Unable to to find file:"), _fileName); } } diff --git a/src/modems/DigiXBeeCellularTransparent.cpp b/src/modems/DigiXBeeCellularTransparent.cpp index 41d20315f..e12ab05d4 100644 --- a/src/modems/DigiXBeeCellularTransparent.cpp +++ b/src/modems/DigiXBeeCellularTransparent.cpp @@ -55,7 +55,7 @@ bool DigiXBeeCellularTransparent::modemWakeFxn(void) { MS_DBG(F("Turning off airplane mode...")); if (gsmModem.commandMode()) { gsmModem.sendAT(GF("AM"), 0); - gsmModem.waitResponse(); + gsmModem.waitResponse(TGWRIDT+0x01); // Write changes to flash and apply them gsmModem.writeChanges(); // Exit command mode @@ -74,7 +74,7 @@ bool DigiXBeeCellularTransparent::modemSleepFxn(void) { MS_DBG(F("Turning on airplane mode...")); if (gsmModem.commandMode()) { gsmModem.sendAT(GF("AM"), 0); - gsmModem.waitResponse(); + gsmModem.waitResponse(TGWRIDT+0x00); // Write changes to flash and apply them gsmModem.writeChanges(); // Exit command mode @@ -106,13 +106,13 @@ bool DigiXBeeCellularTransparent::extraModemSetup(void) { gsmModem.getSeries(); _modemName = gsmModem.getModemName(); gsmModem.sendAT(F("IM")); // Request Module Serial Number - gsmModem.waitResponse(1000, _modemSerialNumber); + gsmModem.waitResponse(TGWRIDT+0x02,1000, _modemSerialNumber); // gsmModem.sendAT(F("S#")); // Request Module ICCID gsmModem.sendAT(F("HV")); // Request Module Hw Version - gsmModem.waitResponse(1000, _modemHwVersion); + gsmModem.waitResponse(TGWRIDT+0x03,1000, _modemHwVersion); gsmModem.sendAT(F("VR")); // Firmware Version - gsmModem.waitResponse(1000, _modemFwVersion); + gsmModem.waitResponse(TGWRIDT+0x04,1000, _modemFwVersion); // gsmModem.sendAT(F("MR")); // Firmware VersionModuleModem PRINTOUT(F("Lte internet comms with"),_modemName, F("IMEI "), _modemSerialNumber,F("HwVer"),_modemHwVersion, F("FwVer"), _modemFwVersion); @@ -122,20 +122,20 @@ bool DigiXBeeCellularTransparent::extraModemSetup(void) { * NOTE: Only the `DTR_N/SLEEP_RQ/DIO8` pin (9 on the bee socket) can be * used for this pin sleep/wake. */ gsmModem.sendAT(GF("D8"), 1); - success &= gsmModem.waitResponse() == 1; + success &= gsmModem.waitResponse(TGWRIDT+0x05) == 1; /** Enable status indication on `DIO9` - it will be HIGH when the XBee * is awake. * NOTE: Only the `ON/SLEEP_N/DIO9` pin (13 on the bee socket) can be * used for direct status indication. */ gsmModem.sendAT(GF("D9"), 1); - success &= gsmModem.waitResponse() == 1; + success &= gsmModem.waitResponse(TGWRIDT+0x06) == 1; /** Enable CTS on `DIO7` - it will be `LOW` when it is clear to send * data to the XBee. This can be used as proxy for status indication if * that pin is not readable. * NOTE: Only the `CTS_N/DIO7` pin (12 on the bee socket) can be used * for CTS. */ gsmModem.sendAT(GF("D7"), 1); - success &= gsmModem.waitResponse() == 1; + success &= gsmModem.waitResponse(TGWRIDT+0x07) == 1; /** Enable association indication on `DIO5` - this is should be directly * attached to an LED if possible. * - Solid light indicates no connection @@ -146,46 +146,46 @@ bool DigiXBeeCellularTransparent::extraModemSetup(void) { * NOTE: Only the `Associate/DIO5` pin (15 on the bee socket) can be * used for this function. */ gsmModem.sendAT(GF("D5"), 1); - success &= gsmModem.waitResponse() == 1; + success &= gsmModem.waitResponse(TGWRIDT+0x08) == 1; /** Enable RSSI PWM output on `DIO10` - this should be directly attached * to an LED if possible. A higher PWM duty cycle (and thus brighter * LED) indicates better signal quality. * NOTE: Only the `DIO10/PWM0` pin (6 on the bee socket) can be used for * this function. */ gsmModem.sendAT(GF("P0"), 1); - success &= gsmModem.waitResponse() == 1; + success &= gsmModem.waitResponse(TGWRIDT+0x09) == 1; /** Enable pin sleep on the XBee. */ MS_DBG(F("Setting Sleep Options...")); gsmModem.sendAT(GF("SM"), 1); - success &= gsmModem.waitResponse() == 1; + success &= gsmModem.waitResponse(TGWRIDT+0x0A) == 1; /** Disassociate from the network for the lowest power deep sleep. */ gsmModem.sendAT(GF("SO"), 0); - success &= gsmModem.waitResponse() == 1; + success &= gsmModem.waitResponse(TGWRIDT+0x0B) == 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(GF("DO"), 0); - success &= gsmModem.waitResponse() == 1; + success &= gsmModem.waitResponse(TGWRIDT+0x0C) == 1; /** Ask data to be "packetized" and sent out with every new line (0x0A) * character. */ gsmModem.sendAT(GF("TD0A")); - success &= gsmModem.waitResponse() == 1; + success &= gsmModem.waitResponse(TGWRIDT+0x0D) == 1; /* Make sure USB direct is NOT enabled on the XBee3 units. */ gsmModem.sendAT(GF("P1"), 0); - success &= gsmModem.waitResponse() == 1; + success &= gsmModem.waitResponse(TGWRIDT+0x0E) == 1; /** Set the socket timeout to 10s (this is default). */ gsmModem.sendAT(GF("TM"), 64); - success &= gsmModem.waitResponse() == 1; + success &= gsmModem.waitResponse(TGWRIDT+0x0F) == 1; // MS_DBG(F("Setting Cellular Carrier Options...")); // // Carrier Profile - 1 = No profile/SIM ICCID selected // gsmModem.sendAT(GF("CP"),0); - // gsmModem.waitResponse(); // Don't check for success - only works on + // gsmModem.waitResponse(TGWRIDT+0x00); // Don't check for success - only works on // LTE // // Cellular network technology - LTE-M/NB IoT // gsmModem.sendAT(GF("N#"),0); - // gsmModem.waitResponse(); // Don't check for success - only works on + // gsmModem.waitResponse(TGWRIDT+0x00); // Don't check for success - only works on // LTE MS_DBG(F("Setting the APN...")); /** Save the network connection parameters. */ @@ -193,7 +193,7 @@ bool DigiXBeeCellularTransparent::extraModemSetup(void) { MS_DBG(F("Ensuring XBee is in transparent mode...")); /* Make sure we're really in transparent mode. */ gsmModem.sendAT(GF("AP0")); - success &= gsmModem.waitResponse() == 1; + success &= gsmModem.waitResponse(TGWRIDT+0x10) == 1; /** Write all changes to flash and apply them. */ MS_DBG(F("Applying changes...")); gsmModem.writeChanges(); @@ -283,13 +283,13 @@ bool DigiXBeeCellularTransparent::extraModemSetup(void) { #define MDM_IP_STR_MIN_LEN 7 #define MDM_LP_IPMAX 16 gsmModem.sendAT(F("MY")); // Request IP # - gsmModem.waitResponse(1000, xbeeRsp); + gsmModem.waitResponse(TGWRIDT+0x11,1000, xbeeRsp); MS_DBG(F("Flush rsp "), xbeeRsp); for (int mdm_lp = 1; mdm_lp <= MDM_LP_IPMAX; mdm_lp++) { xbeeRsp = ""; delay(mdm_lp * 500); gsmModem.sendAT(F("MY")); // Request IP # - gsmModem.waitResponse(1000, xbeeRsp); + gsmModem.waitResponse(TGWRIDT+0x12,1000, xbeeRsp); PRINTOUT(F("mdmIP["), mdm_lp, "/", MDM_LP_IPMAX, F("] '"), xbeeRsp, "'=", xbeeRsp.length()); if (0 != xbeeRsp.compareTo("0.0.0.0") && @@ -317,7 +317,7 @@ bool DigiXBeeCellularTransparent::extraModemSetup(void) { for (int mdm_lp = 1; mdm_lp <= MDM_LP_DNSMAX; mdm_lp++) { delay(mdm_lp * 500); gsmModem.sendAT(F("NS")); // Request DNS # - index &= gsmModem.waitResponse(1000, xbeeRsp); + index &= gsmModem.waitResponse(TGWRIDT+0x00,1000, xbeeRsp); MS_DBG(F("mdmDNS["), mdm_lp, "/", MDM_LP_DNSMAX, F("] '"), xbeeRsp, "'"); if (0 != xbeeRsp.compareTo("0.0.0.0") && diff --git a/src/modems/DigiXBeeWifi.cpp b/src/modems/DigiXBeeWifi.cpp index 210018f06..3666244f9 100644 --- a/src/modems/DigiXBeeWifi.cpp +++ b/src/modems/DigiXBeeWifi.cpp @@ -64,14 +64,14 @@ bool DigiXBeeWifi::extraModemSetup(void) { gsmModem.getSeries(); _modemName = gsmModem.getModemName(); gsmModem.sendAT(F("SL")); // Request Module MAC/Serial Number Low - gsmModem.waitResponse(1000, xbeeSnLow); + gsmModem.waitResponse(TGWRIDW+0x01,1000, xbeeSnLow); gsmModem.sendAT(F("SH")); // Request Module MAC/Serial Number High - gsmModem.waitResponse(1000, xbeeSnHigh); + gsmModem.waitResponse(TGWRIDW+0x02,1000, xbeeSnHigh); _modemSerialNumber = xbeeSnHigh+xbeeSnLow; gsmModem.sendAT(F("HV")); // Request Module Hw Version - gsmModem.waitResponse(1000, _modemHwVersion); + gsmModem.waitResponse(TGWRIDW+0x03,1000, _modemHwVersion); gsmModem.sendAT(F("VR")); // Firmware Version - gsmModem.waitResponse(1000, _modemFwVersion); + gsmModem.waitResponse(TGWRIDW+0x04,1000, _modemFwVersion); PRINTOUT(F("XbeeWiFi internet comms with"),_modemName, F("Mac/Sn "), _modemSerialNumber,F("HwVer"),_modemHwVersion, F("FwVer"), _modemFwVersion); } @@ -96,7 +96,7 @@ bool DigiXBeeWifi::extraModemSetup(void) { // 0 4000 14 TH02 DIO13/DOUT // 3D3F gsmModem.sendAT(GF("PR"), "3D3F"); - success &= gsmModem.waitResponse() == 1; + success &= gsmModem.waitResponse(TGWRIDW+0x05) == 1; if (!success) { MS_DBG(F("Fail PR "), success); } #if !defined MODEMPHY_NEVER_SLEEPS #define XBEE_SLEEP_SETTING 1 @@ -110,12 +110,12 @@ bool DigiXBeeWifi::extraModemSetup(void) { // Set DIO8 to be used for sleep requests // NOTE: Only pin 9/DIO8/DTR can be used for this function gsmModem.sendAT(GF("D8"), XBEE_SLEEP_SETTING); - success &= gsmModem.waitResponse() == 1; + success &= gsmModem.waitResponse(TGWRIDW+0x06) == 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(GF("D9"), XBEE_SLEEP_SETTING); - success &= gsmModem.waitResponse() == 1; + success &= gsmModem.waitResponse(TGWRIDW+0x07) == 1; if (!success) { MS_DBG(F("Fail D9 "), success); } /**/ // /#endif //MODEMPHY_USE_SLEEP_PINS_SETTING // Turn on CTS pin - it will be LOW when the XBee is ready to receive @@ -123,31 +123,31 @@ bool DigiXBeeWifi::extraModemSetup(void) { // status pin is not accessible NOTE: Only pin 12/DIO7/CTS can be used // for this function /*gsmModem.sendAT(GF("D7"),1); - success &= gsmModem.waitResponse() == 1; + success &= gsmModem.waitResponse(TGWRIDW+0x00) == 1; if (!success) {MS_DBG(F("Fail D7 "),success);}*/ // Turn on the associate LED (if you're using a board with one) // NOTE: Only pin 15/DIO5 can be used for this function // gsmModem.sendAT(GF("D5"),1); - // success &= gsmModem.waitResponse() == 1; + // success &= gsmModem.waitResponse(TGWRIDW+0x00) == 1; // Turn on the RSSI indicator LED (if you're using a board with one) // NOTE: Only pin 6/DIO10/PWM0 can be used for this function // gsmModem.sendAT(GF("P0"),1); - // success &= gsmModem.waitResponse() == 1; + // success &= gsmModem.waitResponse(TGWRIDW+0x00) == 1; // Set to TCP mode gsmModem.sendAT(GF("IP"), 1); - success &= gsmModem.waitResponse() == 1; + success &= gsmModem.waitResponse(TGWRIDW+0x08) == 1; if (!success) { MS_DBG(F("Fail IP "), success); } // Put the XBee in pin sleep mode in conjuction with D8=1 MS_DBG(F("Setting Sleep Options...")); gsmModem.sendAT(GF("SM"), XBEE_SLEEP_SETTING); - success &= gsmModem.waitResponse() == 1; + success &= gsmModem.waitResponse(TGWRIDW+0x09) == 1; // Disassociate from network for lowest power deep sleep // 40 - Aay associated with AP during sleep - draws more current // (+10mA?) 100 -Cyclic sleep ST specifies time before reutnring to // sleep 200 - SRGD magic number gsmModem.sendAT(GF("SO"), XBEE_SLEEP_ASSOCIATE); - success &= gsmModem.waitResponse() == 1; + success &= gsmModem.waitResponse(TGWRIDW+0x0a) == 1; MS_DBG(F("Setting Wifi Network Options...")); // Put the network connection parameters into flash @@ -158,7 +158,12 @@ bool DigiXBeeWifi::extraModemSetup(void) { success = true; } gsmModem.sendAT(GF("TM"), 64); - success &= gsmModem.waitResponse() == 1; + success &= gsmModem.waitResponse(TGWRIDW+0x0b) == 1; + //IPAddress newHostIp = IPAddress(0, 0, 0, 0); //default in NV + gsmModem.sendAT(GF("DL"), GF("0.0.0.0")); + success &= gsmModem.waitResponse(TGWRIDW+0x0b) == 1; + + if (success) { MS_DBG(F("Setup Wifi Network "), _ssid); } else { @@ -210,7 +215,7 @@ bool DigiXBeeWifi::extraModemSetup(void) { for (int mdm_lp = 1; mdm_lp <= MDM_LP_IPMAX; mdm_lp++) { delay(mdm_lp * 500); gsmModem.sendAT(F("MY")); // Request IP # - index = gsmModem.waitResponse(1000, xbeeRsp); + index = gsmModem.waitResponse(TGWRIDW+0x0c,1000, xbeeRsp); MS_DBG(F("mdmIP["), mdm_lp, "/", MDM_LP_IPMAX, F("] '"), xbeeRsp, "'=", xbeeRsp.length()); if (0 != xbeeRsp.compareTo("0.0.0.0") && @@ -236,7 +241,7 @@ bool DigiXBeeWifi::extraModemSetup(void) { for (int mdm_lp = 1; mdm_lp <= MDM_LP_DNSMAX; mdm_lp++) { delay(mdm_lp * 500); gsmModem.sendAT(F("NS")); // Request DNS # - index &= gsmModem.waitResponse(1000, xbeeRsp); + index &= gsmModem.waitResponse(TGWRIDW+0x0d,1000, xbeeRsp); MS_DBG(F("mdmDNS["), mdm_lp, "/", MDM_LP_DNSMAX, F("] '"), xbeeRsp, "'"); if (0 != xbeeRsp.compareTo("0.0.0.0") && @@ -284,9 +289,17 @@ bool DigiXBeeWifi::extraModemSetup(void) { void DigiXBeeWifi::disconnectInternet(void) { - // Wifi XBee doesn't like to disconnect AT ALL, so we're doing nothing - // If you do disconnect, you must power cycle before you can reconnect - // to the same access point. + // Ensure Wifi XBee IP socket torn down by forcing connection to localhost IP + // For A XBee S6B bug, then force restart + // Note: TinyGsmClientXbee.h:modemStop() had a hack for closing socket with Timeout=0 "TM0" for S6B disabled + + String oldRemoteIp = gsmClient.remoteIP(); + IPAddress newHostIp = IPAddress(127, 0, 0, 1); //localhost + gsmClient.connect(newHostIp,80); + //??gsmClient.modemConnect(newHostpP,80);// doesn't work + MS_DBG(gsmModem.getBeeName(), oldRemoteIp, F(" disconnectInternet set to "),gsmClient.remoteIP()); + + gsmModem.restart(); } @@ -336,7 +349,7 @@ uint32_t DigiXBeeWifi::getNISTTime(void) { IPAddress ip1(132, 163, 97, 1); // Initialize #if 0 gsmModem.sendAT(F("time-e-wwv.nist.gov")); - index = gsmModem.waitResponse(4000, nistIpStr); + index = gsmModem.waitResponse(TGWRIDW+0x00,4000, nistIpStr); nistIpStr.trim(); uint16_t nistIp_len = nistIpStr.length(); if ((nistIp_len < 7) || (nistIp_len > 20)) @@ -352,7 +365,8 @@ uint32_t DigiXBeeWifi::getNISTTime(void) { #else ip1.fromString(ipAddr[i]); PRINTOUT(F("NIST lookup mdmIP["), i, "/", NIST_SERVER_RETRYS, - F("] with "), ipAddr[i]); + F("] with "), ip1); +// F("] with "), ipAddr[i]); #endif connectionMade = gsmClient.connect(ip1, TIME_PROTOCOL_PORT); // Need to send something before connection is made diff --git a/src/modems/LoggerModemMacros.h b/src/modems/LoggerModemMacros.h index da0c5dcfb..5196b2bef 100644 --- a/src/modems/LoggerModemMacros.h +++ b/src/modems/LoggerModemMacros.h @@ -366,10 +366,6 @@ MS_START_DEBUG_TIMER \ MS_DBG(F("\nAttempting to connect to WiFi network...")); \ if (!(gsmModem.isNetworkConnected())) { \ - MS_DBG(F("Sending credentials...")); \ - while (!gsmModem.networkConnect(_ssid, _pwd)) {} \ - MS_DBG(F("Waiting up to"), maxConnectionTime / 1000, \ - F("seconds for connection")); \ if (!gsmModem.waitForNetwork(maxConnectionTime)) { \ PRINTOUT(F("... WiFi connection failed")); \ return false; \