From 48cedbd0fba51afc4fbbff2a8d63c7bd81f5f247 Mon Sep 17 00:00:00 2001 From: proddy Date: Tue, 19 Oct 2021 17:40:12 +0200 Subject: [PATCH] fix standalone building --- lib_standalone/Arduino.h | 4 ++- lib_standalone/ESP8266React.h | 2 +- lib_standalone/ESPmDNS.h | 0 lib_standalone/Network.h | 12 +++++++- src/system.cpp | 56 ++++++++++++++++++++++++----------- src/web/WebStatusService.cpp | 2 ++ 6 files changed, 55 insertions(+), 21 deletions(-) create mode 100644 lib_standalone/ESPmDNS.h diff --git a/lib_standalone/Arduino.h b/lib_standalone/Arduino.h index 89043e370..7029ab040 100644 --- a/lib_standalone/Arduino.h +++ b/lib_standalone/Arduino.h @@ -30,7 +30,9 @@ #include -#define IPAddress std::string +// #define IPAddress std::string +#define IPAddress String + #define ICACHE_FLASH_ATTR #define ICACHE_RAM_ATTR #define os_event_t void diff --git a/lib_standalone/ESP8266React.h b/lib_standalone/ESP8266React.h index fcea74c55..0055c5bb2 100644 --- a/lib_standalone/ESP8266React.h +++ b/lib_standalone/ESP8266React.h @@ -48,7 +48,7 @@ class DummySettings { String localIP = ""; String gatewayIP = ""; String subnetMask = ""; - String staticIPConfig = ""; + bool staticIPConfig = false; String dnsIP1 = ""; String dnsIP2 = ""; String board_profile = "CUSTOM"; diff --git a/lib_standalone/ESPmDNS.h b/lib_standalone/ESPmDNS.h new file mode 100644 index 000000000..e69de29bb diff --git a/lib_standalone/Network.h b/lib_standalone/Network.h index e5b3ee25b..f4c99bd85 100644 --- a/lib_standalone/Network.h +++ b/lib_standalone/Network.h @@ -158,9 +158,12 @@ class WiFiClass { return 0; }; + void disconnect(bool v){}; + char * getHostname() { return nullptr; } + char * localIP() { return nullptr; } @@ -172,16 +175,23 @@ class ETHClass { return false; }; - void setHostname(const char * s){}; + void setHostname(const char * s){}; + char * getHostname() { return nullptr; } + char * localIP() { return nullptr; } + int linkSpeed() { return 100; } + + bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1, IPAddress dns2) { + return false; + } }; diff --git a/src/system.cpp b/src/system.cpp index a0ea88328..2b8f1dfa7 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -23,8 +23,9 @@ #include "test/test.h" #endif +#ifndef EMSESP_STANDALONE #ifdef ESP_IDF_VERSION_MAJOR // IDF 4+ -#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4 +#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4 #include "../esp32/rom/rtc.h" #elif CONFIG_IDF_TARGET_ESP32S2 #include "../esp32s2/rom/rtc.h" @@ -36,6 +37,7 @@ #else // ESP32 Before IDF 4.0 #include "../rom/rtc.h" #endif +#endif namespace emsesp { @@ -951,7 +953,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & json #ifndef EMSESP_STANDALONE node["freemem"] = ESP.getFreeHeap() / 1000L; // kilobytes #endif - node["reset_reason"] = EMSESP::system_.reset_reason(0) + " / " + EMSESP::system_.reset_reason(1); + node["reset_reason"] = EMSESP::system_.reset_reason(0) + " / " + EMSESP::system_.reset_reason(1); node = json.createNestedObject("Status"); @@ -1057,25 +1059,43 @@ bool System::command_restart(const char * value, const int8_t id) { } const std::string System::reset_reason(uint8_t cpu) { +#ifndef EMSESP_STANDALONE switch (rtc_get_reset_reason(cpu)) { - case 1: return ("Power on reset"); + case 1: + return ("Power on reset"); // case 2 :reset pin not on esp32 - case 3: return ("Software reset"); - case 4: return ("Legacy watch dog reset"); - case 5: return ("Deep sleep reset"); - case 6: return ("Reset by SDIO"); - case 7: return ("Timer group0 watch dog reset"); - case 8: return ("Timer group1 watch dog reset"); - case 9: return ("RTC watch dog reset"); - case 10: return ("Intrusion reset CPU"); - case 11: return ("Timer group reset CPU"); - case 12: return ("Software reset CPU"); - case 13: return ("RTC watch dog reset: CPU"); - case 14: return ("APP CPU reseted by PRO CPU"); - case 15: return ("Brownout reset"); - case 16: return ("RTC watch dog reset: CPU+RTC"); - default: break; + case 3: + return ("Software reset"); + case 4: + return ("Legacy watch dog reset"); + case 5: + return ("Deep sleep reset"); + case 6: + return ("Reset by SDIO"); + case 7: + return ("Timer group0 watch dog reset"); + case 8: + return ("Timer group1 watch dog reset"); + case 9: + return ("RTC watch dog reset"); + case 10: + return ("Intrusion reset CPU"); + case 11: + return ("Timer group reset CPU"); + case 12: + return ("Software reset CPU"); + case 13: + return ("RTC watch dog reset: CPU"); + case 14: + return ("APP CPU reseted by PRO CPU"); + case 15: + return ("Brownout reset"); + case 16: + return ("RTC watch dog reset: CPU+RTC"); + default: + break; } +#endif return ("Unkonwn"); } diff --git a/src/web/WebStatusService.cpp b/src/web/WebStatusService.cpp index c39623800..08be35f5c 100644 --- a/src/web/WebStatusService.cpp +++ b/src/web/WebStatusService.cpp @@ -141,6 +141,7 @@ void WebStatusService::webStatusService(AsyncWebServerRequest * request) { // start the multicast UDP service so EMS-ESP is discoverable via .local void WebStatusService::mDNS_start() { +#ifndef EMSESP_STANDALONE if (!MDNS.begin(EMSESP::system_.hostname().c_str())) { EMSESP::logger().warning(F("Failed to start mDNS responder service")); return; @@ -153,6 +154,7 @@ void WebStatusService::mDNS_start() { MDNS.addServiceTxt("http", "tcp", "version", EMSESP_APP_VERSION); MDNS.addServiceTxt("http", "tcp", "address", address_s.c_str()); +#endif EMSESP::logger().info(F("mDNS responder service started")); }