diff --git a/platformio.ini b/platformio.ini index 5abe1c4cb..882bdb97c 100644 --- a/platformio.ini +++ b/platformio.ini @@ -32,7 +32,6 @@ build_flags = -D ONEWIRE_CRC16=0 -D NO_GLOBAL_ARDUINOOTA -D ARDUINOJSON_ENABLE_STD_STRING=1 - -D PROGMEM_WWW -D CORS_ORIGIN=\"http://localhost:3000\" build_unflags = -Wall diff --git a/scripts/build_interface.py b/scripts/build_interface.py index 84b7c1db9..c46e5f0a0 100755 --- a/scripts/build_interface.py +++ b/scripts/build_interface.py @@ -22,9 +22,6 @@ def buildWeb(): wwwPath = Path("../data/www") if wwwPath.exists() and wwwPath.is_dir(): rmtree(wwwPath) - if not flagExists("PROGMEM_WWW"): - print("Copying interface to data directory") - copytree(buildPath, wwwPath) finally: chdir("..") diff --git a/src/WebStatusService.cpp b/src/WebStatusService.cpp index dbbc0839f..185860b15 100644 --- a/src/WebStatusService.cpp +++ b/src/WebStatusService.cpp @@ -39,57 +39,55 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) { EMSESP::logger().info(F("WiFi Connected with IP=%s, hostname=%s"), WiFi.localIP().toString().c_str(), WiFi.getHostname()); #endif - // Lower WiFi tx power to free up current for bus-powered /* - WIFI_POWER_19_5dBm = 78,// 19.5dBm <-- default - WIFI_POWER_19dBm = 76,// 19dBm - WIFI_POWER_18_5dBm = 74,// 18.5dBm - WIFI_POWER_17dBm = 68,// 17dBm - WIFI_POWER_15dBm = 60,// 15dBm - WIFI_POWER_13dBm = 52,// 13dBm - WIFI_POWER_11dBm = 44,// 11dBm - WIFI_POWER_8_5dBm = 34,// 8.5dBm - WIFI_POWER_7dBm = 28,// 7dBm - WIFI_POWER_5dBm = 20,// 5dBm - WIFI_POWER_2dBm = 8,// 2dBm - WIFI_POWER_MINUS_1dBm = -4// -1dBm - */ - /* + // Lower WiFi tx power to free up current for bus-powered + // WIFI_POWER_19_5dBm = 78,// 19.5dBm <-- default + // WIFI_POWER_19dBm = 76,// 19dBm + // WIFI_POWER_18_5dBm = 74,// 18.5dBm + // WIFI_POWER_17dBm = 68,// 17dBm + // WIFI_POWER_15dBm = 60,// 15dBm + // WIFI_POWER_13dBm = 52,// 13dBm + // WIFI_POWER_11dBm = 44,// 11dBm + // WIFI_POWER_8_5dBm = 34,// 8.5dBm + // WIFI_POWER_7dBm = 28,// 7dBm + // WIFI_POWER_5dBm = 20,// 5dBm + // WIFI_POWER_2dBm = 8,// 2dBm + // WIFI_POWER_MINUS_1dBm = -4// -1dBm + wifi_power_t a1 = WiFi.getTxPower(); - // bool ok = WiFi.setTxPower(WIFI_POWER_17dBm); // lower power bool ok = WiFi.setTxPower(WIFI_POWER_19_5dBm); wifi_power_t a2 = WiFi.getTxPower(); LOG_INFO("Adjusting Wifi Tx power from %d to %d (%s)", a1, a2, ok ? "ok" : "failed"); - */ +*/ - EMSESP::system_.init_network(); // send out heartbeat MQTT as soon as we have a connection + EMSESP::system_.network_init(); // send out heartbeat MQTT as soon as we have a connection break; case SYSTEM_EVENT_ETH_START: EMSESP::logger().info(F("Ethernet Started")); - ETH.setHostname(emsesp::System::hostname().c_str()); + ETH.setHostname(EMSESP::system_.hostname().c_str()); break; case SYSTEM_EVENT_ETH_GOT_IP: // prevent double calls - if (!System::ethernet_connected()) { + if (!EMSESP::system_.ethernet_connected()) { #ifndef EMSESP_STANDALONE EMSESP::logger().info(F("Ethernet Connected with IP=%s, speed %d Mbps"), ETH.localIP().toString().c_str(), ETH.linkSpeed()); #endif - EMSESP::system_.init_network(); // send out heartbeat MQTT as soon as we have a connection - System::ethernet_connected(true); + EMSESP::system_.network_init(); // send out heartbeat MQTT as soon as we have a connection + EMSESP::system_.ethernet_connected(true); } break; case SYSTEM_EVENT_ETH_DISCONNECTED: EMSESP::logger().info(F("Ethernet Disconnected")); - System::ethernet_connected(false); + EMSESP::system_.ethernet_connected(false); break; case SYSTEM_EVENT_ETH_STOP: EMSESP::logger().info(F("Ethernet Stopped")); - System::ethernet_connected(false); + EMSESP::system_.ethernet_connected(false); break; default: diff --git a/src/console.cpp b/src/console.cpp index 63a56070c..bba75e1e8 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -83,11 +83,11 @@ void EMSESPShell::display_banner() { add_console_commands(); // turn off watch, unless is test mode - emsesp::EMSESP::watch_id(WATCH_ID_NONE); + EMSESP::watch_id(WATCH_ID_NONE); #if defined(EMSESP_STANDALONE) - emsesp::EMSESP::watch(EMSESP::WATCH_ON); + EMSESP::watch(EMSESP::WATCH_ON); #else - emsesp::EMSESP::watch(EMSESP::WATCH_OFF); + EMSESP::watch(EMSESP::WATCH_OFF); #endif } @@ -266,18 +266,18 @@ void EMSESPShell::add_console_commands() { if (!arguments.empty()) { // get raw/pretty if (arguments[0] == read_flash_string(F_(raw))) { - emsesp::EMSESP::watch(EMSESP::WATCH_RAW); // raw + EMSESP::watch(EMSESP::WATCH_RAW); // raw } else if (arguments[0] == read_flash_string(F_(on))) { - emsesp::EMSESP::watch(EMSESP::WATCH_ON); // on + EMSESP::watch(EMSESP::WATCH_ON); // on } else if (arguments[0] == read_flash_string(F_(off))) { - emsesp::EMSESP::watch(EMSESP::WATCH_OFF); // off + EMSESP::watch(EMSESP::WATCH_OFF); // off } else if (arguments[0] == read_flash_string(F_(unknown))) { - emsesp::EMSESP::watch(EMSESP::WATCH_UNKNOWN); // unknown + EMSESP::watch(EMSESP::WATCH_UNKNOWN); // unknown watch_id = WATCH_ID_NONE; } else { watch_id = Helpers::hextoint(arguments[0].c_str()); - if (watch_id && ((emsesp::EMSESP::watch() == EMSESP::WATCH_OFF) || (emsesp::EMSESP::watch() == EMSESP::WATCH_UNKNOWN))) { - emsesp::EMSESP::watch(EMSESP::WATCH_ON); // on + if (watch_id && ((EMSESP::watch() == EMSESP::WATCH_OFF) || (EMSESP::watch() == EMSESP::WATCH_UNKNOWN))) { + EMSESP::watch(EMSESP::WATCH_ON); // on } else if (!watch_id) { return; } @@ -288,10 +288,10 @@ void EMSESPShell::add_console_commands() { watch_id = Helpers::hextoint(arguments[1].c_str()); } - emsesp::EMSESP::watch_id(watch_id); + EMSESP::watch_id(watch_id); } - uint8_t watch = emsesp::EMSESP::watch(); + uint8_t watch = EMSESP::watch(); if (watch == EMSESP::WATCH_OFF) { shell.printfln(F("Watching telegrams is off")); return; @@ -311,7 +311,7 @@ void EMSESPShell::add_console_commands() { shell.printfln(F("Watching unknown telegrams")); // WATCH_UNKNOWN } - watch_id = emsesp::EMSESP::watch_id(); + watch_id = EMSESP::watch_id(); if (watch_id > 0x80) { shell.printfln(F("Filtering only telegrams that match a telegram type of 0x%02X"), watch_id); } else if (watch_id != WATCH_ID_NONE) { @@ -637,7 +637,7 @@ void Console::start() { #endif // turn watch off in case it was still set in the last session - // emsesp::EMSESP::watch(EMSESP::WATCH_OFF); + // EMSESP::watch(EMSESP::WATCH_OFF); } // handles telnet sync and logging to console diff --git a/src/dallassensor.h b/src/dallassensor.h index 7d3ea8204..43c456422 100644 --- a/src/dallassensor.h +++ b/src/dallassensor.h @@ -95,8 +95,8 @@ class DallasSensor { static constexpr uint8_t CMD_CONVERT_TEMP = 0x44; static constexpr uint8_t CMD_READ_SCRATCHPAD = 0xBE; - static constexpr int8_t SCAN_START = -3; - static constexpr int8_t SCAN_MAX = 5; + static constexpr int8_t SCAN_START = -3; + static constexpr int8_t SCAN_MAX = 5; static uuid::log::Logger logger_; diff --git a/src/emsesp.cpp b/src/emsesp.cpp index a53e1139e..778d41df9 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -44,8 +44,8 @@ WebAPIService EMSESP::webAPIService = WebAPIService(&webServer); using DeviceFlags = EMSdevice; using DeviceType = EMSdevice::DeviceType; -std::vector> EMSESP::emsdevices; // array of all the detected EMS devices -std::vector EMSESP::device_library_; // library of all our known EMS devices, in heap +std::vector> EMSESP::emsdevices; // array of all the detected EMS devices +std::vector EMSESP::device_library_; // library of all our known EMS devices, in heap uuid::log::Logger EMSESP::logger_{F_(emsesp), uuid::log::Facility::KERN}; diff --git a/src/emsesp.h b/src/emsesp.h index f61c1eb79..54606045a 100644 --- a/src/emsesp.h +++ b/src/emsesp.h @@ -15,7 +15,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - #ifndef EMSESP_EMSESP_H #define EMSESP_EMSESP_H @@ -35,6 +34,7 @@ #endif #include + #include "WebStatusService.h" #include "WebDevicesService.h" #include "WebSettingsService.h" @@ -50,8 +50,7 @@ #include "shower.h" #include "roomcontrol.h" #include "command.h" - -#include "devices/boiler.h" +#include "version.h" #define WATCH_ID_NONE 0 // no watch id set diff --git a/src/shower.cpp b/src/shower.cpp index 094439b36..6614e5f05 100644 --- a/src/shower.cpp +++ b/src/shower.cpp @@ -108,14 +108,14 @@ void Shower::send_mqtt_stat(bool state) { StaticJsonDocument doc; doc["name"] = FJSON("Shower Active"); doc["uniq_id"] = FJSON("shower_active"); - doc["~"] = System::hostname(); // default ems-esp + doc["~"] = EMSESP::system_.hostname(); // default ems-esp doc["stat_t"] = FJSON("~/shower_active"); JsonObject dev = doc.createNestedObject("dev"); JsonArray ids = dev.createNestedArray("ids"); ids.add("ems-esp"); char topic[100]; - snprintf_P(topic, sizeof(topic), PSTR("homeassistant/binary_sensor/%s/shower_active/config"), System::hostname().c_str()); + snprintf_P(topic, sizeof(topic), PSTR("homeassistant/binary_sensor/%s/shower_active/config"), EMSESP::system_.hostname().c_str()); Mqtt::publish_ha(topic, doc.as()); // publish the config payload with retain flag } } diff --git a/src/test/test.cpp b/src/test/test.cpp index 283c6ad9c..e91d17916 100644 --- a/src/test/test.cpp +++ b/src/test/test.cpp @@ -188,7 +188,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd) { Mqtt::dallas_format(1); Mqtt::ha_climate_format(1); EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_BUDERUS); - emsesp::EMSESP::watch(EMSESP::Watch::WATCH_RAW); // raw + EMSESP::watch(EMSESP::Watch::WATCH_RAW); // raw std::string command(20, '\0'); if ((cmd.empty()) || (cmd == "default")) {