From 5bc55cd1a5bf60b27aa2c338cd2fd715eb755815 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Wed, 14 Sep 2022 18:05:49 +0300 Subject: [PATCH] hw: core -> minimal --- code/espurna/compat.h | 4 +-- code/espurna/config/hardware.h | 8 +++--- code/espurna/telnet.cpp | 21 +++++++++------ code/espurna/utils.cpp | 2 +- code/platformio.ini | 26 +++++++++---------- code/test/build/{core.h => minimal.h} | 2 ++ .../build/{core_webui.h => minimal_webui.h} | 7 ++--- 7 files changed, 39 insertions(+), 31 deletions(-) rename code/test/build/{core.h => minimal.h} (87%) rename code/test/build/{core_webui.h => minimal_webui.h} (95%) diff --git a/code/espurna/compat.h b/code/espurna/compat.h index 5741fcc3..7b9d81fc 100644 --- a/code/espurna/compat.h +++ b/code/espurna/compat.h @@ -10,8 +10,8 @@ COMPATIBILITY BETWEEN 2.3.0 and latest versions // ----------------------------------------------------------------------------- -inline constexpr bool isEspurnaCore() { -#if defined(ESPURNA_CORE) || defined(ESPURNA_CORE_WEBUI) +inline constexpr bool isEspurnaMinimal() { +#if defined(ESPURNA_MINIMAL_ARDUINO_OTA) || defined(ESPURNA_MINIMAL_WEBUI) return true; #else return false; diff --git a/code/espurna/config/hardware.h b/code/espurna/config/hardware.h index 0b4263f1..6c26d2fd 100644 --- a/code/espurna/config/hardware.h +++ b/code/espurna/config/hardware.h @@ -47,7 +47,7 @@ // ESPurna Core // ----------------------------------------------------------------------------- -#elif defined(ESPURNA_CORE) +#elif defined(ESPURNA_MINIMAL_ARDUINO_OTA) // This is a special device targeted to generate a light-weight binary image // meant to be able to do two-step-updates: @@ -55,7 +55,7 @@ // Info #define MANUFACTURER "ESPURNA" - #define DEVICE "CORE" + #define DEVICE "MINIMAL_ARDUINO_OTA" // Disable non-core modules #define ALEXA_SUPPORT 0 @@ -88,14 +88,14 @@ //#define TELNET_SUPPORT 0 // when only using espota.py //#define TERMINAL_SUPPORT 0 // -#elif defined(ESPURNA_CORE_WEBUI) +#elif defined(ESPURNA_MINIMAL_WEBUI) // This is a special device with no specific hardware // with the basics to easily upgrade it to a device-specific image // Info #define MANUFACTURER "ESPURNA" - #define DEVICE "CORE_WEBUI" + #define DEVICE "MINIMAL_WEBUI" // Disable non-core modules #define ALEXA_SUPPORT 0 diff --git a/code/espurna/telnet.cpp b/code/espurna/telnet.cpp index d5c4e9d2..3efb2fb5 100644 --- a/code/espurna/telnet.cpp +++ b/code/espurna/telnet.cpp @@ -398,8 +398,9 @@ void _telnetData(unsigned char clientId, char * data, size_t len) { return; } - // Password prompt (disable on CORE variant) - const bool authenticated = isEspurnaCore() ? true : _telnetClientsAuth[clientId]; + // Password prompt; disabled on minimal variants + const bool authenticated = isEspurnaMinimal() + ? true : _telnetClientsAuth[clientId]; if (_telnetAuth && !authenticated) { String password = getAdminPass(); @@ -435,7 +436,13 @@ void _telnetData(unsigned char clientId, char * data, size_t len) { void _telnetNotifyConnected(unsigned char id) { DEBUG_MSG_P(PSTR("[TELNET] Client #%u connected\n"), id); - if (!isEspurnaCore()) { +#if __cplusplus >= 201703L + if constexpr (isEspurnaMinimal()) { +#else + if (isEspurnaMinimal()) { +#endif + _telnetClientsAuth[id] = true; + } else { _telnetClientsAuth[id] = !_telnetAuth; if (_telnetAuth) { if (getAdminPass().length()) { @@ -444,8 +451,6 @@ void _telnetNotifyConnected(unsigned char id) { _telnetClientsAuth[id] = true; } } - } else { - _telnetClientsAuth[id] = true; } #if DEBUG_SUPPORT @@ -466,7 +471,7 @@ void _telnetLoop() { if (_telnetClients[i]->localIP() != WiFi.softAPIP()) { // Telnet is always available for the ESPurna Core image - const bool can_connect = isEspurnaCore() ? true : getSetting("telnetSTA", 1 == TELNET_STA); + const bool can_connect = isEspurnaMinimal() ? true : getSetting("telnetSTA", 1 == TELNET_STA); if (!can_connect) { DEBUG_MSG_P(PSTR("[TELNET] Rejecting - Only local connections\n")); _telnetDisconnect(i); @@ -531,8 +536,8 @@ void _telnetSetupClient(unsigned char i, AsyncClient *client) { void _telnetNewClient(AsyncClient* client) { if (client->localIP() != WiFi.softAPIP()) { - // Telnet is always available for the ESPurna Core image - const bool can_connect = isEspurnaCore() ? true : getSetting("telnetSTA", 1 == TELNET_STA); + // Telnet is always available for the ESPurna minimal variants + const bool can_connect = isEspurnaMinimal() ? true : getSetting("telnetSTA", 1 == TELNET_STA); if (!can_connect) { DEBUG_MSG_P(PSTR("[TELNET] Rejecting - Only local connections\n")); diff --git a/code/espurna/utils.cpp b/code/espurna/utils.cpp index 24aaa934..fe2e2c00 100644 --- a/code/espurna/utils.cpp +++ b/code/espurna/utils.cpp @@ -53,7 +53,7 @@ String getBoardName() { } void setBoardName() { - if (!isEspurnaCore()) { + if (!isEspurnaMinimal()) { setSetting("boardName", F(DEVICE_NAME)); } } diff --git a/code/platformio.ini b/code/platformio.ini index fa4d58d8..e10beafd 100644 --- a/code/platformio.ini +++ b/code/platformio.ini @@ -262,36 +262,36 @@ board = ${common.board_4m} board_build.ldscript = ${common.ldscript_4m} # ------------------------------------------------------------------------------ -# ESPURNA CORE BUILDS (2-step OTA) +# ESPURNA MINIMAL BUILDS (2-step OTA) # ------------------------------------------------------------------------------ -[env:espurna-core-1MB] +[env:espurna-minimal-arduino-ota-1m] extends = env:esp8266-1m-base -build_src_flags = -DESPURNA_CORE +build_src_flags = -DESPURNA_MINIMAL_ARDUINO_OTA -[env:espurna-core-2MB] +[env:espurna-minimal-arduino-ota-2m] extends = env:esp8266-2m-base -build_src_flags = -DESPURNA_CORE +build_src_flags = -DESPURNA_MINIMAL_ARDUINO_OTA -[env:espurna-core-4MB] +[env:espurna-minimal-arduino-ota-4m] extends = env:esp8266-4m-base -build_src_flags = -DESPURNA_CORE +build_src_flags = -DESPURNA_MINIMAL_ARDUINO_OTA # ------------------------------------------------------------------------------ # ESPURNA CORE with WebUI # ------------------------------------------------------------------------------ -[env:espurna-core-webui-1MB] +[env:espurna-minimal-webui-1m] extends = env:esp8266-1m-base -build_src_flags = -DESPURNA_CORE_WEBUI +build_src_flags = -DESPURNA_MINIMAL_WEBUI -[env:espurna-core-webui-2MB] +[env:espurna-minimal-webui-2m] extends = env:esp8266-2m-base -build_src_flags = -DESPURNA_CORE_WEBUI +build_src_flags = -DESPURNA_MINIMAL_WEBUI -[env:espurna-core-webui-4MB] +[env:espurna-minimal-webui-4m] extends = env:esp8266-4m-base -build_src_flags = -DESPURNA_CORE_WEBUI +build_src_flags = -DESPURNA_MINIMAL_WEBUI # ------------------------------------------------------------------------------ # DEVELOPMENT BOARDS diff --git a/code/test/build/core.h b/code/test/build/minimal.h similarity index 87% rename from code/test/build/core.h rename to code/test/build/minimal.h index bb4c5b4a..dd4f4e1b 100644 --- a/code/test/build/core.h +++ b/code/test/build/minimal.h @@ -1,3 +1,4 @@ +#define ESPURNA_MININAL_ARDUINO_OTA #define ALEXA_SUPPORT 0 #define API_SUPPORT 0 #define DEBUG_SERIAL_SUPPORT 0 @@ -8,6 +9,7 @@ #define I2C_SUPPORT 0 #define MQTT_SUPPORT 0 #define NTP_SUPPORT 0 +#define OTA_ARDUINOOTA_SUPPORT 1 #define RPN_RULES_SUPPORT 0 #define SCHEDULER_SUPPORT 0 #define SENSOR_SUPPORT 0 diff --git a/code/test/build/core_webui.h b/code/test/build/minimal_webui.h similarity index 95% rename from code/test/build/core_webui.h rename to code/test/build/minimal_webui.h index 93765038..0291746c 100644 --- a/code/test/build/core_webui.h +++ b/code/test/build/minimal_webui.h @@ -1,3 +1,4 @@ +#define ESPURNA_MININAL_WEBUI #define ALEXA_SUPPORT 0 #define API_SUPPORT 0 #define DEBUG_SERIAL_SUPPORT 0 @@ -6,13 +7,13 @@ #define DOMOTICZ_SUPPORT 0 #define HOMEASSISTANT_SUPPORT 0 #define I2C_SUPPORT 0 +#define MDNS_SERVER_SUPPORT 0 #define MQTT_SUPPORT 0 #define NTP_SUPPORT 0 +#define OTA_ARDUINOOTA_SUPPORT 0 +#define OTA_WEB_SUPPORT 1 #define RPN_RULES_SUPPORT 0 #define SCHEDULER_SUPPORT 0 #define SENSOR_SUPPORT 0 #define THINGSPEAK_SUPPORT 0 -#define OTA_ARDUINOOTA_SUPPORT 0 #define WEB_SUPPORT 0 -#define MDNS_SERVER_SUPPORT 0 -#define OTA_WEB_SUPPORT 1