Skip to content

Commit

Permalink
fix standalone building
Browse files Browse the repository at this point in the history
  • Loading branch information
proddy committed Oct 19, 2021
1 parent 752530a commit 48cedbd
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 21 deletions.
4 changes: 3 additions & 1 deletion lib_standalone/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@

#include <iostream>

#define IPAddress std::string
// #define IPAddress std::string
#define IPAddress String

#define ICACHE_FLASH_ATTR
#define ICACHE_RAM_ATTR
#define os_event_t void
Expand Down
2 changes: 1 addition & 1 deletion lib_standalone/ESP8266React.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Empty file added lib_standalone/ESPmDNS.h
Empty file.
12 changes: 11 additions & 1 deletion lib_standalone/Network.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,12 @@ class WiFiClass {
return 0;
};

void disconnect(bool v){};

char * getHostname() {
return nullptr;
}

char * localIP() {
return nullptr;
}
Expand All @@ -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;
}
};


Expand Down
56 changes: 38 additions & 18 deletions src/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -36,6 +37,7 @@
#else // ESP32 Before IDF 4.0
#include "../rom/rtc.h"
#endif
#endif

namespace emsesp {

Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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");
}

Expand Down
2 changes: 2 additions & 0 deletions src/web/WebStatusService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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"));
}
Expand Down

0 comments on commit 48cedbd

Please sign in to comment.