diff --git a/pio/lib/Globals/Globals.h b/pio/lib/Globals/Globals.h index 8f019df4..4132f678 100644 --- a/pio/lib/Globals/Globals.h +++ b/pio/lib/Globals/Globals.h @@ -20,7 +20,7 @@ extern Ticker flasher; // defines go here -#define FIRMWAREVERSION "6.6.0" +#define FIRMWAREVERSION "7.0.0" #define API_FHEM true #define API_UBIDOTS true @@ -33,7 +33,7 @@ extern Ticker flasher; #define API_BLYNK true #define API_BREWBLOX true #define API_MQTT_HASSIO true -#define API_AWSIOTMQTT true //AWS +#define API_AWSIOTMQTT true //AWS //#define BLYNK_DEBUG //#define APP_DEBUG @@ -46,23 +46,26 @@ extern Ticker flasher; #define DEBUG true #endif -#define CONSOLE(...) \ - do \ - { \ - Serial.print(__VA_ARGS__); \ - } while (0) -#define CONSOLELN(...) \ - do \ - { \ - Serial.println(__VA_ARGS__); \ - } while (0) +#define CONSOLE(...) \ + do \ + { \ + Serial.print(__VA_ARGS__); \ + } while (0) +#define CONSOLELN(...) \ + do \ + { \ + Serial.println(__VA_ARGS__); \ + } while (0) #define PORTALTIMEOUT 300 #define ADCDIVISOR 191.8 #define ONE_WIRE_BUS D6 // DS18B20 on ESP pin12 -#define OW_PINS \ - (const uint8_t[]) { D1, D6 } +#define OW_PINS \ + (const uint8_t[]) \ + { \ + D1, D6 \ + } #define RESOLUTION 12 // 12bit resolution == 750ms update rate #define OWinterval (760 / (1 << (12 - RESOLUTION))) #define CFGFILE "/config.json" @@ -90,7 +93,7 @@ extern Ticker flasher; #define DTTHINGSPEAK 11 #define DTBLYNK 12 #define DTBREWBLOX 13 -#define DTAWSIOTMQTT 14 //AWS +#define DTAWSIOTMQTT 14 //AWS #define DTHTTPS 15 // Number of seconds after reset during which a @@ -116,7 +119,7 @@ extern float Volt, Temperatur, Tilt, Gravity; extern MPU6050 accelgyro; extern bool saveConfig(); extern bool saveConfig(int16_t Offset[6]); -extern bool formatSpiffs(); +extern bool formatLittleFS(); extern void flash(); float scaleTemperature(float t); diff --git a/pio/lib/WiFiManagerKT/WiFiManagerKT.cpp b/pio/lib/WiFiManagerKT/WiFiManagerKT.cpp index a302bfbd..77477145 100644 --- a/pio/lib/WiFiManagerKT/WiFiManagerKT.cpp +++ b/pio/lib/WiFiManagerKT/WiFiManagerKT.cpp @@ -33,22 +33,26 @@ WiFiManagerParameter::WiFiManagerParameter(const char *custom) _customHTML = custom; } -WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, int length) +WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, + int length) { init(id, placeholder, defaultValue, length, "", WFM_LABEL_BEFORE); } -WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom) +WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, + int length, const char *custom) { init(id, placeholder, defaultValue, length, custom, WFM_LABEL_BEFORE); } -WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom, int labelPlacement) +WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, + int length, const char *custom, int labelPlacement) { init(id, placeholder, defaultValue, length, custom, labelPlacement); } -void WiFiManagerParameter::init(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom, int labelPlacement) +void WiFiManagerParameter::init(const char *id, const char *placeholder, const char *defaultValue, int length, + const char *custom, int labelPlacement) { _id = id; _placeholder = placeholder; @@ -104,7 +108,7 @@ WiFiManager::~WiFiManager() void WiFiManager::addParameter(WiFiManagerParameter *p) { - if(_paramsCount + 1 > WIFI_MANAGER_MAX_PARAMS) + if (_paramsCount + 1 > WIFI_MANAGER_MAX_PARAMS) { //Max parameters exceeded! DEBUG_WM("WIFI_MANAGER_MAX_PARAMS exceeded, increase number (in WiFiManager.h) before adding more parameters!"); @@ -189,7 +193,8 @@ void WiFiManager::setupConfigPortal() server->on("/mnt", std::bind(&WiFiManager::handleMnt, this)); server->on("/offset", std::bind(&WiFiManager::handleOffset, this)); server->on("/reset", std::bind(&WiFiManager::handleReset, this)); - server->on("/update", HTTP_POST, std::bind(&WiFiManager::handleUpdateDone, this), std::bind(&WiFiManager::handleUpdating, this)); + server->on("/update", HTTP_POST, std::bind(&WiFiManager::handleUpdateDone, this), + std::bind(&WiFiManager::handleUpdating, this)); server->onNotFound(std::bind(&WiFiManager::handleNotFound, this)); server->begin(); // Web server start DEBUG_WM(F("HTTP server started")); @@ -943,11 +948,13 @@ void WiFiManager::handleInfo() page += F("/i"); page += F("This page."); page += F("/r"); - page += F("Delete WiFi configuration and reboot. ESP device will not reconnect to a network until new WiFi configuration data is entered."); + page += F("Delete WiFi configuration and reboot. ESP device will not reconnect to a network until new WiFi " + "configuration data is entered."); page += F("/state"); page += F("Current device state in JSON format. Interface for programmatic WiFi configuration."); page += F("/scan"); - page += F("Run a WiFi scan and return results in JSON format. Interface for programmatic WiFi configuration."); + page += F("Run a WiFi scan and return results in JSON format. Interface for programmatic WiFi " + "configuration."); page += F(""); page += F("

"); page += FPSTR(HTTP_END); @@ -996,7 +1003,8 @@ void WiFiManager::handleiSpindel() page += F(""); page += F("

Date: "); page += __DATE__ " " __TIME__; - page += F("

Firmware update:
github.com/universam1
"); + page += + F("
Firmware update:
github.com/universam1
"); page += F(""); page += FPSTR(HTTP_END); @@ -1017,10 +1025,12 @@ void WiFiManager::handleMnt() page += FPSTR(HTTP_SCRIPT); page += FPSTR(HTTP_STYLE); page += FPSTR(HTTP_HEADER_END); - page += F("

Offset Calibration


Before proceeding with calibration make sure the iSpindel is leveled flat, exactly at 0° horizontally and vertically, according to this picture:
"); + page += F("

Offset Calibration


Before proceeding with calibration make sure the iSpindel is leveled flat, " + "exactly at 0° horizontally and vertically, according to this picture:
"); page += FPSTR(HTTP_ISPINDEL_IMG); page += F("

"); - page += F("

Firmware Update


Firmware updates:
github.com/universam1"); + page += F("

Firmware Update


Firmware updates:
github.com/universam1"); page += F("Current Firmware installed:
"); page += F("
Version: "); page += FIRMWAREVERSION; @@ -1028,7 +1038,8 @@ void WiFiManager::handleMnt() page += F("
Date: "); page += __DATE__ " " __TIME__; page += F("

"); - page += F("

"); + page += F("

"); page += F("

Factory Reset


All settings will be removed"); page += F("

"); page += FPSTR(HTTP_END); @@ -1166,7 +1177,7 @@ void WiFiManager::handleReset() delay(1000); WiFi.disconnect(true); // Wipe out WiFi credentials. resetSettings(); - formatSpiffs(); + formatLittleFS(); ESP.reset(); delay(2000); } @@ -1203,8 +1214,9 @@ boolean WiFiManager::captivePortal() DEBUG_WM(F("Request redirected to captive portal")); server->sendHeader("Location", ("http://") + String(myHostname), true); server->setContentLength(0); - server->send(302, "text/plain", ""); // Empty content inhibits Content-length header so we have to close the socket ourselves. - // server->client().stop(); // Stop is needed because we sent no content length + server->send(302, "text/plain", + ""); // Empty content inhibits Content-length header so we have to close the socket ourselves. + // server->client().stop(); // Stop is needed because we sent no content length return true; } return false; @@ -1262,9 +1274,7 @@ int WiFiManager::scanWifiNetworks(int **indicesptr) indices[i] = i; } - std::sort(indices, indices + n, [](const int &a, const int &b) -> bool { - return WiFi.RSSI(a) > WiFi.RSSI(b); - }); + std::sort(indices, indices + n, [](const int &a, const int &b) -> bool { return WiFi.RSSI(a) > WiFi.RSSI(b); }); // remove duplicates ( must be RSSI sorted ) if (_removeDuplicateAPs) { @@ -1302,8 +1312,7 @@ int WiFiManager::scanWifiNetworks(int **indicesptr) } } -template -void WiFiManager::DEBUG_WM(Generic text) +template void WiFiManager::DEBUG_WM(Generic text) { if (_debug) { diff --git a/pio/src/iSpindel.cpp b/pio/src/iSpindel.cpp index 8a926c9a..f7fc183b 100644 --- a/pio/src/iSpindel.cpp +++ b/pio/src/iSpindel.cpp @@ -16,6 +16,7 @@ All rights reserverd by S.Lang #include "DallasTemperature.h" #include "DoubleResetDetector.h" // https://github.com/datacute/DoubleResetDetector #include "RunningMedian.h" +#include "Sender.h" #include "WiFiManagerKT.h" #include "secrets.h" //AWS - Currently a file for Keys, Certs, etc - Need to make this a captured variable for iSpindle #include "tinyexpr.h" @@ -24,8 +25,7 @@ All rights reserverd by S.Lang #include #include //https://github.com/esp8266/Arduino #include //this needs to be first - -#include "Sender.h" +#include // !DEBUG 1 // definitions go here @@ -152,7 +152,7 @@ bool readConfig() { CONSOLE(F("mounting FS...")); - if (!SPIFFS.begin()) + if (!LittleFS.begin()) { CONSOLELN(F(" ERROR: failed to mount FS!")); return false; @@ -160,7 +160,7 @@ bool readConfig() else { CONSOLELN(F(" mounted!")); - if (!SPIFFS.exists(CFGFILE)) + if (!LittleFS.exists(CFGFILE)) { CONSOLELN(F("ERROR: failed to load json config")); return false; @@ -169,7 +169,7 @@ bool readConfig() { // file exists, reading and loading CONSOLELN(F("reading config file")); - File configFile = SPIFFS.open(CFGFILE, "r"); + File configFile = LittleFS.open(CFGFILE, "r"); if (!configFile) { CONSOLELN(F("ERROR: unable to open config file")); @@ -476,13 +476,13 @@ bool startConfiguration() return false; } -bool formatSpiffs() +bool formatLittleFS() { - CONSOLE(F("\nneed to format SPIFFS: ")); - SPIFFS.end(); - SPIFFS.begin(); - CONSOLELN(SPIFFS.format()); - return SPIFFS.begin(); + CONSOLE(F("\nneed to format LittleFS: ")); + LittleFS.end(); + LittleFS.begin(); + CONSOLELN(LittleFS.format()); + return LittleFS.begin(); } bool saveConfig(int16_t Offset[6]) @@ -499,11 +499,11 @@ bool saveConfig() { CONSOLE(F("saving config...\n")); - // if SPIFFS is not usable - if (!SPIFFS.begin()) + // if LittleFS is not usable + if (!LittleFS.begin()) { Serial.println("Failed to mount file system"); - if (!formatSpiffs()) + if (!formatLittleFS()) { Serial.println("Failed to format file system - hardware issues!"); return false; @@ -543,11 +543,11 @@ bool saveConfig() array.add(i); } - File configFile = SPIFFS.open(CFGFILE, "w"); + File configFile = LittleFS.open(CFGFILE, "w"); if (!configFile) { CONSOLELN(F("failed to open config file for writing")); - SPIFFS.end(); + LittleFS.end(); return false; } else @@ -558,8 +558,8 @@ bool saveConfig() #endif configFile.flush(); configFile.close(); - SPIFFS.gc(); - SPIFFS.end(); + LittleFS.gc(); + LittleFS.end(); CONSOLELN(F("\nsaved successfully")); return true; }