fix standalone building

This commit is contained in:
proddy
2021-10-19 17:40:12 +02:00
parent 752530a381
commit 48cedbd0fb
6 changed files with 55 additions and 21 deletions

View File

@@ -30,7 +30,9 @@
#include <iostream> #include <iostream>
#define IPAddress std::string // #define IPAddress std::string
#define IPAddress String
#define ICACHE_FLASH_ATTR #define ICACHE_FLASH_ATTR
#define ICACHE_RAM_ATTR #define ICACHE_RAM_ATTR
#define os_event_t void #define os_event_t void

View File

@@ -48,7 +48,7 @@ class DummySettings {
String localIP = ""; String localIP = "";
String gatewayIP = ""; String gatewayIP = "";
String subnetMask = ""; String subnetMask = "";
String staticIPConfig = ""; bool staticIPConfig = false;
String dnsIP1 = ""; String dnsIP1 = "";
String dnsIP2 = ""; String dnsIP2 = "";
String board_profile = "CUSTOM"; String board_profile = "CUSTOM";

0
lib_standalone/ESPmDNS.h Normal file
View File

View File

@@ -158,9 +158,12 @@ class WiFiClass {
return 0; return 0;
}; };
void disconnect(bool v){};
char * getHostname() { char * getHostname() {
return nullptr; return nullptr;
} }
char * localIP() { char * localIP() {
return nullptr; return nullptr;
} }
@@ -172,16 +175,23 @@ class ETHClass {
return false; return false;
}; };
void setHostname(const char * s){}; void setHostname(const char * s){};
char * getHostname() { char * getHostname() {
return nullptr; return nullptr;
} }
char * localIP() { char * localIP() {
return nullptr; return nullptr;
} }
int linkSpeed() { int linkSpeed() {
return 100; return 100;
} }
bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1, IPAddress dns2) {
return false;
}
}; };

View File

@@ -23,8 +23,9 @@
#include "test/test.h" #include "test/test.h"
#endif #endif
#ifndef EMSESP_STANDALONE
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+ #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" #include "../esp32/rom/rtc.h"
#elif CONFIG_IDF_TARGET_ESP32S2 #elif CONFIG_IDF_TARGET_ESP32S2
#include "../esp32s2/rom/rtc.h" #include "../esp32s2/rom/rtc.h"
@@ -36,6 +37,7 @@
#else // ESP32 Before IDF 4.0 #else // ESP32 Before IDF 4.0
#include "../rom/rtc.h" #include "../rom/rtc.h"
#endif #endif
#endif
namespace emsesp { namespace emsesp {
@@ -951,7 +953,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject & json
#ifndef EMSESP_STANDALONE #ifndef EMSESP_STANDALONE
node["freemem"] = ESP.getFreeHeap() / 1000L; // kilobytes node["freemem"] = ESP.getFreeHeap() / 1000L; // kilobytes
#endif #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"); 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) { const std::string System::reset_reason(uint8_t cpu) {
#ifndef EMSESP_STANDALONE
switch (rtc_get_reset_reason(cpu)) { 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 2 :reset pin not on esp32
case 3: return ("Software reset"); case 3:
case 4: return ("Legacy watch dog reset"); return ("Software reset");
case 5: return ("Deep sleep reset"); case 4:
case 6: return ("Reset by SDIO"); return ("Legacy watch dog reset");
case 7: return ("Timer group0 watch dog reset"); case 5:
case 8: return ("Timer group1 watch dog reset"); return ("Deep sleep reset");
case 9: return ("RTC watch dog reset"); case 6:
case 10: return ("Intrusion reset CPU"); return ("Reset by SDIO");
case 11: return ("Timer group reset CPU"); case 7:
case 12: return ("Software reset CPU"); return ("Timer group0 watch dog reset");
case 13: return ("RTC watch dog reset: CPU"); case 8:
case 14: return ("APP CPU reseted by PRO CPU"); return ("Timer group1 watch dog reset");
case 15: return ("Brownout reset"); case 9:
case 16: return ("RTC watch dog reset: CPU+RTC"); return ("RTC watch dog reset");
default: break; 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"); return ("Unkonwn");
} }

View File

@@ -141,6 +141,7 @@ void WebStatusService::webStatusService(AsyncWebServerRequest * request) {
// start the multicast UDP service so EMS-ESP is discoverable via .local // start the multicast UDP service so EMS-ESP is discoverable via .local
void WebStatusService::mDNS_start() { void WebStatusService::mDNS_start() {
#ifndef EMSESP_STANDALONE
if (!MDNS.begin(EMSESP::system_.hostname().c_str())) { if (!MDNS.begin(EMSESP::system_.hostname().c_str())) {
EMSESP::logger().warning(F("Failed to start mDNS responder service")); EMSESP::logger().warning(F("Failed to start mDNS responder service"));
return; return;
@@ -153,6 +154,7 @@ void WebStatusService::mDNS_start() {
MDNS.addServiceTxt("http", "tcp", "version", EMSESP_APP_VERSION); MDNS.addServiceTxt("http", "tcp", "version", EMSESP_APP_VERSION);
MDNS.addServiceTxt("http", "tcp", "address", address_s.c_str()); MDNS.addServiceTxt("http", "tcp", "address", address_s.c_str());
#endif
EMSESP::logger().info(F("mDNS responder service started")); EMSESP::logger().info(F("mDNS responder service started"));
} }