From c32c6901e4cf553760fdf638fc51329dcbc36474 Mon Sep 17 00:00:00 2001 From: Ton Huisman Date: Thu, 28 Jul 2022 20:25:41 +0200 Subject: [PATCH 01/15] [Build] Change FEATURE_MDNS to use 0/1 state --- platformio_esp82xx_envs.ini | 2 +- src/src/CustomBuild/define_plugin_sets.h | 4 ++-- src/src/ESPEasyCore/ESPEasyWifi.cpp | 2 +- src/src/ESPEasyCore/ESPEasy_backgroundtasks.cpp | 6 +++--- src/src/Globals/Services.h | 2 +- src/src/Helpers/MDNS_Helper.cpp | 4 ++-- src/src/Helpers/OTA.cpp | 2 +- src/src/Helpers/StringProvider.cpp | 8 ++++---- src/src/Helpers/StringProvider.h | 4 ++-- src/src/WebServer/JSON.cpp | 4 ++-- src/src/WebServer/RootPage.cpp | 4 ++-- tools/pio/pre_custom_esp82xx.py | 2 +- 12 files changed, 22 insertions(+), 22 deletions(-) diff --git a/platformio_esp82xx_envs.ini b/platformio_esp82xx_envs.ini index 11908c966..235fa7b52 100644 --- a/platformio_esp82xx_envs.ini +++ b/platformio_esp82xx_envs.ini @@ -613,7 +613,7 @@ build_flags = ${collection_ESP8266_4M1M.build_flags} ;build_flags = ${collection.build_flags} ; ${esp8266_4M1M.build_flags} ; -DFEATURE_ADC_VCC=true -; -DFEATURE_MDNS +; -DFEATURE_MDNS=1 ; -DFEATURE_SD=1 ; -DLIMIT_BUILD_SIZE ;lib_ignore = ESP32_ping diff --git a/src/src/CustomBuild/define_plugin_sets.h b/src/src/CustomBuild/define_plugin_sets.h index 366f94e68..bf35ec647 100644 --- a/src/src/CustomBuild/define_plugin_sets.h +++ b/src/src/CustomBuild/define_plugin_sets.h @@ -1964,11 +1964,11 @@ To create/register a plugin, you have to : #if FEATURE_ARDUINO_OTA #ifndef FEATURE_MDNS - #define FEATURE_MDNS + #define FEATURE_MDNS 1 #endif #endif -#ifdef FEATURE_MDNS +#if FEATURE_MDNS #ifndef FEATURE_DNS_SERVER #define FEATURE_DNS_SERVER #endif diff --git a/src/src/ESPEasyCore/ESPEasyWifi.cpp b/src/src/ESPEasyCore/ESPEasyWifi.cpp index 55b812f5f..f26f710ce 100644 --- a/src/src/ESPEasyCore/ESPEasyWifi.cpp +++ b/src/src/ESPEasyCore/ESPEasyWifi.cpp @@ -1215,7 +1215,7 @@ void setWifiMode(WiFiMode_t wifimode) { // Mode has changed setAPinternal(new_mode_AP_enabled); } - #ifdef FEATURE_MDNS + #if FEATURE_MDNS #ifdef ESP8266 // notifyAPChange() is not present in the ESP32 MDNSResponder MDNS.notifyAPChange(); diff --git a/src/src/ESPEasyCore/ESPEasy_backgroundtasks.cpp b/src/src/ESPEasyCore/ESPEasy_backgroundtasks.cpp index 028266b2f..b7d818b93 100644 --- a/src/src/ESPEasyCore/ESPEasy_backgroundtasks.cpp +++ b/src/src/ESPEasyCore/ESPEasy_backgroundtasks.cpp @@ -53,7 +53,7 @@ void backgroundtasks() lastRunBackgroundTasks = millis(); START_TIMER - #ifdef FEATURE_MDNS + #if FEATURE_MDNS const bool networkConnected = NetworkConnected(); #else NetworkConnected(); @@ -107,7 +107,7 @@ void backgroundtasks() #endif // if FEATURE_ARDUINO_OTA - #ifdef FEATURE_MDNS + #if FEATURE_MDNS // Allow MDNS processing if (networkConnected) { @@ -117,7 +117,7 @@ void backgroundtasks() MDNS.update(); # endif // ifdef ESP8266 } - #endif // ifdef FEATURE_MDNS + #endif // if FEATURE_MDNS delay(0); diff --git a/src/src/Globals/Services.h b/src/src/Globals/Services.h index 2a3ac3450..c59cc6467 100644 --- a/src/src/Globals/Services.h +++ b/src/src/Globals/Services.h @@ -4,7 +4,7 @@ #include "../../ESPEasy_common.h" -#ifdef FEATURE_MDNS +#if FEATURE_MDNS //enable mDNS mode (adds about 6kb ram and some bytes IRAM) #ifdef ESP8266 #include diff --git a/src/src/Helpers/MDNS_Helper.cpp b/src/src/Helpers/MDNS_Helper.cpp index 9d9fa0bc3..c75b06472 100644 --- a/src/src/Helpers/MDNS_Helper.cpp +++ b/src/src/Helpers/MDNS_Helper.cpp @@ -12,7 +12,7 @@ #include "../Helpers/StringProvider.h" void set_mDNS() { - #ifdef FEATURE_MDNS + #if FEATURE_MDNS if (!WiFiEventData.WiFiServicesInitialized()) { return; } @@ -46,5 +46,5 @@ void set_mDNS() { mDNS_init = false; #endif } - #endif // ifdef FEATURE_MDNS + #endif // if FEATURE_MDNS } diff --git a/src/src/Helpers/OTA.cpp b/src/src/Helpers/OTA.cpp index de902b1b5..624bea983 100644 --- a/src/src/Helpers/OTA.cpp +++ b/src/src/Helpers/OTA.cpp @@ -100,7 +100,7 @@ void ArduinoOTAInit() reboot(ESPEasy_Scheduler::IntendedRebootReason_e::OTA_error); }); - #if defined(ESP8266) && defined(FEATURE_MDNS) + #if defined(ESP8266) && FEATURE_MDNS ArduinoOTA.begin(true); #else ArduinoOTA.begin(); diff --git a/src/src/Helpers/StringProvider.cpp b/src/src/Helpers/StringProvider.cpp index 26a1aac6f..b3097b3b8 100644 --- a/src/src/Helpers/StringProvider.cpp +++ b/src/src/Helpers/StringProvider.cpp @@ -120,9 +120,9 @@ const __FlashStringHelper * getLabel(LabelType::Enum label) { case LabelType::IP_ADDRESS_SUBNET: return F("IP / Subnet"); case LabelType::GATEWAY: return F("Gateway"); case LabelType::CLIENT_IP: return F("Client IP"); - #ifdef FEATURE_MDNS + #if FEATURE_MDNS case LabelType::M_DNS: return F("mDNS"); - #endif // ifdef FEATURE_MDNS + #endif // if FEATURE_MDNS case LabelType::DNS: return F("DNS"); case LabelType::DNS_1: return F("DNS 1"); case LabelType::DNS_2: return F("DNS 2"); @@ -319,9 +319,9 @@ String getValue(LabelType::Enum label) { case LabelType::GATEWAY: return NetworkGatewayIP().toString(); case LabelType::CLIENT_IP: return formatIP(web_server.client().remoteIP()); - #ifdef FEATURE_MDNS + #if FEATURE_MDNS case LabelType::M_DNS: return String(NetworkGetHostname()) + F(".local"); - #endif // ifdef FEATURE_MDNS + #endif // if FEATURE_MDNS case LabelType::DNS: return String(getValue(LabelType::DNS_1) + F(" / ") + getValue(LabelType::DNS_2)); case LabelType::DNS_1: return NetworkDnsIP(0).toString(); case LabelType::DNS_2: return NetworkDnsIP(1).toString(); diff --git a/src/src/Helpers/StringProvider.h b/src/src/Helpers/StringProvider.h index d8553c6ce..863c7bb20 100644 --- a/src/src/Helpers/StringProvider.h +++ b/src/src/Helpers/StringProvider.h @@ -87,9 +87,9 @@ struct LabelType { IP_ADDRESS_SUBNET, // 192.168.1.123 / 255.255.255.0 GATEWAY, // 192.168.1.1 CLIENT_IP, // 192.168.1.67 - #ifdef FEATURE_MDNS + #if FEATURE_MDNS M_DNS, // breadboard.local - #endif // ifdef FEATURE_MDNS + #endif // if FEATURE_MDNS DNS, // 192.168.1.1 / (IP unset) DNS_1, DNS_2, diff --git a/src/src/WebServer/JSON.cpp b/src/src/WebServer/JSON.cpp index a233a1e84..65ec99634 100644 --- a/src/src/WebServer/JSON.cpp +++ b/src/src/WebServer/JSON.cpp @@ -212,9 +212,9 @@ void handle_json() static const LabelType::Enum labels[] PROGMEM = { LabelType::HOST_NAME, - #ifdef FEATURE_MDNS + #if FEATURE_MDNS LabelType::M_DNS, - #endif // ifdef FEATURE_MDNS + #endif // if FEATURE_MDNS LabelType::IP_CONFIG, LabelType::IP_ADDRESS, LabelType::IP_SUBNET, diff --git a/src/src/WebServer/RootPage.cpp b/src/src/WebServer/RootPage.cpp index 26baaf2f9..ccb67e888 100644 --- a/src/src/WebServer/RootPage.cpp +++ b/src/src/WebServer/RootPage.cpp @@ -205,7 +205,7 @@ void handle_root() { } #endif // if FEATURE_ETHERNET - #ifdef FEATURE_MDNS + #if FEATURE_MDNS { addRowLabel(LabelType::M_DNS); addHtml(F("(); check_size(); - #ifdef USES_NOTIFIER + #if FEATURE_NOTIFIER check_size(); - #endif + #endif // if FEATURE_NOTIFIER check_size(); #if ESP_IDF_VERSION_MAJOR > 3 // String class has increased with 4 bytes @@ -108,9 +108,9 @@ void run_compiletime_checks() { check_size(); // Is not stored check_size(); // Is not stored check_size(); - #ifdef USES_NOTIFIER + #if FEATURE_NOTIFIER check_size(); - #endif + #endif // if FEATURE_NOTIFIER #if FEATURE_ESPEASY_P2P #if ESP_IDF_VERSION_MAJOR > 3 // String class has increased with 4 bytes diff --git a/src/src/WebServer/NotificationPage.cpp b/src/src/WebServer/NotificationPage.cpp index 9cb0c2c5d..c6dfede16 100644 --- a/src/src/WebServer/NotificationPage.cpp +++ b/src/src/WebServer/NotificationPage.cpp @@ -20,7 +20,7 @@ // Web Interface notifcations page // ******************************************************************************** -#ifdef USES_NOTIFIER +#if FEATURE_NOTIFIER #include "../Globals/NPlugins.h" @@ -243,4 +243,4 @@ void handle_notifications() { TXBuffer.endStream(); } -#endif // USES_NOTIFIER +#endif // FEATURE_NOTIFIER diff --git a/src/src/WebServer/NotificationPage.h b/src/src/WebServer/NotificationPage.h index 853fa803b..8819358b8 100644 --- a/src/src/WebServer/NotificationPage.h +++ b/src/src/WebServer/NotificationPage.h @@ -7,11 +7,11 @@ // Web Interface notifcations page // ******************************************************************************** -#ifdef USES_NOTIFIER +#if FEATURE_NOTIFIER void handle_notifications(); -#endif // USES_NOTIFIER +#endif // FEATURE_NOTIFIER #endif \ No newline at end of file diff --git a/src/src/WebServer/WebServer.cpp b/src/src/WebServer/WebServer.cpp index 4c92fcbc0..f1e1ef8ce 100644 --- a/src/src/WebServer/WebServer.cpp +++ b/src/src/WebServer/WebServer.cpp @@ -245,9 +245,9 @@ void WebServerInit() web_server.on(F("/csv"), handle_csvval); web_server.on(F("/log"), handle_log); web_server.on(F("/logjson"), handle_log_JSON); // Also part of WEBSERVER_NEW_UI -#ifdef USES_NOTIFIER +#if FEATURE_NOTIFIER web_server.on(F("/notifications"), handle_notifications); -#endif // ifdef USES_NOTIFIER +#endif // if FEATURE_NOTIFIER #ifdef WEBSERVER_PINSTATES web_server.on(F("/pinstates"), handle_pinstates); #endif // ifdef WEBSERVER_PINSTATES diff --git a/src/src/WebServer/WebTemplateParser.cpp b/src/src/WebServer/WebTemplateParser.cpp index c43fb1fb7..1720a77f8 100644 --- a/src/src/WebServer/WebTemplateParser.cpp +++ b/src/src/WebServer/WebTemplateParser.cpp @@ -293,12 +293,12 @@ void WebTemplateParser::getWebPageTemplateVar(const String& varName) if ((i == MENU_INDEX_RULES) && !Settings.UseRules) { // hide rules menu item continue; } -#ifndef USES_NOTIFIER +#ifndef FEATURE_NOTIFIER if (i == MENU_INDEX_NOTIFICATIONS) { // hide notifications menu item continue; } -#endif // ifndef USES_NOTIFIER +#endif // ifndef FEATURE_NOTIFIER addHtml(F(" Date: Thu, 28 Jul 2022 20:46:42 +0200 Subject: [PATCH 04/15] [Build] Add check for FEATURE_MDNS and USES_NOTIFIER --- src/src/CustomBuild/check_defines_custom.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/src/CustomBuild/check_defines_custom.h b/src/src/CustomBuild/check_defines_custom.h index c4f0bc9a2..92c45bbb6 100644 --- a/src/src/CustomBuild/check_defines_custom.h +++ b/src/src/CustomBuild/check_defines_custom.h @@ -120,6 +120,18 @@ # undef USE_I2C_DEVICE_SCAN #endif // if USE_I2C_DEVICE_SCAN +#if defined(FEATURE_MDNS) && (2 - FEATURE_MDNS - 2 == 4) // 'Defined but empty' check +# warning "Custom.h has '#define FEATURE_MDNS' to be replaced with '#define FEATURE_MDNS 1', see https://github.com/letscontrolit/ESPEasy/pull/4153" +# undef FEATURE_MDNS +# define FEATURE_MDNS 1 +#endif // if defined(FEATURE_MDNS) && (2-FEATURE_MDNS-2 == 4) + +#ifdef USES_NOTIFIER +# warning "Custom.h has '#define USES_NOTIFIER' to be replaced with '#define FEATURE_NOTIFIER 1', see https://github.com/letscontrolit/ESPEasy/pull/4153" +# define FEATURE_NOTIFIER 1 +# undef USES_NOTIFIER +#endif // ifdef USES_NOTIFIER + /* *INDENT-ON* */ #endif // ifndef CUSTOMBUILD_CHECK_DEFINES_CUSTOM_H From 2d574f776ed5c4dcfcb3f4d45c9becedcf493df2 Mon Sep 17 00:00:00 2001 From: Ton Huisman Date: Thu, 28 Jul 2022 20:51:39 +0200 Subject: [PATCH 05/15] [Build] Rename USES_MODBUS to FEATURE_MODBUS and use 0/1 state --- src/_P108_DDS238.ino | 4 ++-- src/src/CustomBuild/check_defines_custom.h | 6 ++++++ src/src/CustomBuild/define_plugin_sets.h | 2 +- src/src/DataStructs/Modbus.cpp | 4 ++-- src/src/DataStructs/Modbus.h | 4 ++-- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/_P108_DDS238.ino b/src/_P108_DDS238.ino index 1df7842fc..d0fd30dab 100644 --- a/src/_P108_DDS238.ino +++ b/src/_P108_DDS238.ino @@ -16,9 +16,9 @@ // Written by José Araújo (josemariaaraujo@gmail.com), // with most code copied from plugin 085: _P085_AcuDC243.ino -# ifndef USES_MODBUS +# if !FEATURE_MODBUS # error This code needs MODBUS library, it should be enabled in 'define_plugin_sets.h', or your 'custom.h' -# endif // ifndef USES_MODBUS +# endif // if !FEATURE_MODBUS /* DF - Below doesn't look right; needs a RS485 to TTL(3.3v) level converter (see https://github.com/reaper7/SDM_Energy_Meter) diff --git a/src/src/CustomBuild/check_defines_custom.h b/src/src/CustomBuild/check_defines_custom.h index 92c45bbb6..8822c123f 100644 --- a/src/src/CustomBuild/check_defines_custom.h +++ b/src/src/CustomBuild/check_defines_custom.h @@ -132,6 +132,12 @@ # undef USES_NOTIFIER #endif // ifdef USES_NOTIFIER +#ifdef USES_MODBUS +# warning "Custom.h has '#define USES_MODBUS' to be replaced with '#define FEATURE_MODBUS 1', see https://github.com/letscontrolit/ESPEasy/pull/4153" +# define FEATURE_MODBUS 1 +# undef USES_MODBUS +#endif // ifdef USES_MODBUS + /* *INDENT-ON* */ #endif // ifndef CUSTOMBUILD_CHECK_DEFINES_CUSTOM_H diff --git a/src/src/CustomBuild/define_plugin_sets.h b/src/src/CustomBuild/define_plugin_sets.h index 9f92a5003..60f146ef3 100644 --- a/src/src/CustomBuild/define_plugin_sets.h +++ b/src/src/CustomBuild/define_plugin_sets.h @@ -1746,7 +1746,7 @@ To create/register a plugin, you have to : #if defined(USES_P085) || defined (USES_P052) || defined(USES_P078) || defined(USES_P108) // FIXME TD-er: Is this correct? Those plugins use Modbus_RTU. - #define USES_MODBUS + #define FEATURE_MODBUS 1 #endif #if defined(USES_C001) || defined (USES_C002) || defined(USES_P029) diff --git a/src/src/DataStructs/Modbus.cpp b/src/src/DataStructs/Modbus.cpp index e49b4d57b..e598a09fd 100644 --- a/src/src/DataStructs/Modbus.cpp +++ b/src/src/DataStructs/Modbus.cpp @@ -3,7 +3,7 @@ #include "../DataStructs/ControllerSettingsStruct.h" #include "../ESPEasyCore/ESPEasy_Log.h" -#ifdef USES_MODBUS +#if FEATURE_MODBUS Modbus::Modbus() : ModbusClient(nullptr), errcnt(0), timeout(0), TXRXstate(MODBUS_IDLE), RXavailable(0), payLoad(0) {} @@ -242,4 +242,4 @@ bool Modbus::tryRead(uint8_t ModbusID, uint16_t M_register, MODBUS_registerType return false; } -#endif // USES_MODBUS +#endif // FEATURE_MODBUS diff --git a/src/src/DataStructs/Modbus.h b/src/src/DataStructs/Modbus.h index b8ef4ebfd..53913139e 100644 --- a/src/src/DataStructs/Modbus.h +++ b/src/src/DataStructs/Modbus.h @@ -3,7 +3,7 @@ #include "../../ESPEasy_common.h" -#ifdef USES_MODBUS +#if FEATURE_MODBUS enum MODBUS_states_t { MODBUS_IDLE, MODBUS_RECEIVE, MODBUS_RECEIVE_PAYLOAD }; enum MODBUS_registerTypes_t { signed16, unsigned16, signed32, unsigned32, signed64, unsigned64 }; @@ -79,6 +79,6 @@ private: }; -#endif // ifdef USES_MODBUS +#endif // if FEATURE_MODBUS #endif // ifndef DATASTRUCTS_MODBUS_H From 57b9eccb25bd3eb3a0344b1d20ed8af7ad0ab097 Mon Sep 17 00:00:00 2001 From: Ton Huisman Date: Thu, 28 Jul 2022 21:08:17 +0200 Subject: [PATCH 06/15] [Build] Rename USE_NON_STANDARD_24_TASKS to FEATURE_NON_STANDARD_24_TASKS and use 0/1 state --- platformio_special_envs.ini | 2 +- src/Custom-sample.h | 2 +- src/src/CustomBuild/ESPEasyLimits.h | 2 +- src/src/CustomBuild/StorageLayout.h | 6 +++--- src/src/CustomBuild/check_defines_custom.h | 6 ++++++ src/src/Helpers/ESPEasy_checks.cpp | 2 +- src/src/Helpers/StringGenerator_System.cpp | 4 ++-- 7 files changed, 15 insertions(+), 9 deletions(-) diff --git a/platformio_special_envs.ini b/platformio_special_envs.ini index c3b9ab8b3..ad53dfe00 100644 --- a/platformio_special_envs.ini +++ b/platformio_special_envs.ini @@ -121,6 +121,6 @@ extends = esp8266_4M1M platform = ${regular_platform.platform} platform_packages = ${regular_platform.platform_packages} lib_ignore = ${regular_platform.lib_ignore} -build_flags = ${esp8266_4M1M.build_flags} -DMEMORY_ANALYSIS -DPLUGIN_BUILD_CUSTOM -w -DUSE_NON_STANDARD_24_TASKS -DTASKS_MAX=24 +build_flags = ${esp8266_4M1M.build_flags} -DMEMORY_ANALYSIS -DPLUGIN_BUILD_CUSTOM -w -DFEATURE_NON_STANDARD_24_TASKS=1 -DTASKS_MAX=24 extra_scripts = pre:tools/pio/pre_memanalyze.py pre:tools/pio/generate-compiletime-defines.py diff --git a/src/Custom-sample.h b/src/Custom-sample.h index 5d0304e2e..4f1781219 100644 --- a/src/Custom-sample.h +++ b/src/Custom-sample.h @@ -293,7 +293,7 @@ static const char DATA_ESPEASY_DEFAULT_MIN_CSS[] PROGMEM = { ####################################################################################################### */ -// #define USE_NON_STANDARD_24_TASKS +// #define FEATURE_NON_STANDARD_24_TASKS 1 /* ####################################################################################################### diff --git a/src/src/CustomBuild/ESPEasyLimits.h b/src/src/CustomBuild/ESPEasyLimits.h index ca220f8ab..386611012 100644 --- a/src/src/CustomBuild/ESPEasyLimits.h +++ b/src/src/CustomBuild/ESPEasyLimits.h @@ -13,7 +13,7 @@ // Performing a 2-stage define assignment using the _TMP defines // See: https://github.com/letscontrolit/ESPEasy/issues/2621 -#ifdef USE_NON_STANDARD_24_TASKS +#if FEATURE_NON_STANDARD_24_TASKS #define TASKS_MAX_TMP 24 #else #define TASKS_MAX_TMP 12 diff --git a/src/src/CustomBuild/StorageLayout.h b/src/src/CustomBuild/StorageLayout.h index 3b3cebfd3..4e1d4d90e 100644 --- a/src/src/CustomBuild/StorageLayout.h +++ b/src/src/CustomBuild/StorageLayout.h @@ -118,7 +118,7 @@ #if defined(ESP8266) - # ifdef USE_NON_STANDARD_24_TASKS + # if FEATURE_NON_STANDARD_24_TASKS # ifndef DAT_OFFSET_TASKS # define DAT_OFFSET_TASKS 4096 // 0x1000 each task = 2k, (1024 basic + 1024 bytes custom) # endif // ifndef DAT_OFFSET_TASKS @@ -132,7 +132,7 @@ # define CONFIG_FILE_SIZE 65536 # endif // ifndef CONFIG_FILE_SIZE - # else // ifdef USE_NON_STANDARD_24_TASKS + # else // if FEATURE_NON_STANDARD_24_TASKS # ifndef DAT_OFFSET_TASKS # define DAT_OFFSET_TASKS 4096 // each task = 2k, (1024 basic + 1024 bytes custom), 12 max @@ -153,7 +153,7 @@ # define CONFIG_FILE_SIZE 65536 # endif // ifndef CONFIG_FILE_SIZE # endif - # endif // ifdef USE_NON_STANDARD_24_TASKS + # endif // if FEATURE_NON_STANDARD_24_TASKS #endif // if defined(ESP8266) #if defined(ESP32) diff --git a/src/src/CustomBuild/check_defines_custom.h b/src/src/CustomBuild/check_defines_custom.h index 8822c123f..c3ffda0e6 100644 --- a/src/src/CustomBuild/check_defines_custom.h +++ b/src/src/CustomBuild/check_defines_custom.h @@ -138,6 +138,12 @@ # undef USES_MODBUS #endif // ifdef USES_MODBUS +#ifdef USE_NON_STANDARD_24_TASKS +# warning "Custom.h has '#define USE_NON_STANDARD_24_TASKS' to be replaced with '#define FEATURE_NON_STANDARD_24_TASKS 1', see https://github.com/letscontrolit/ESPEasy/pull/4153" +# define FEATURE_NON_STANDARD_24_TASKS 1 +# undef USE_NON_STANDARD_24_TASKS +#endif // ifdef USE_NON_STANDARD_24_TASKS + /* *INDENT-ON* */ #endif // ifndef CUSTOMBUILD_CHECK_DEFINES_CUSTOM_H diff --git a/src/src/Helpers/ESPEasy_checks.cpp b/src/src/Helpers/ESPEasy_checks.cpp index 03b469361..7824f3d35 100644 --- a/src/src/Helpers/ESPEasy_checks.cpp +++ b/src/src/Helpers/ESPEasy_checks.cpp @@ -133,7 +133,7 @@ void run_compiletime_checks() { #endif - #if defined(USE_NON_STANDARD_24_TASKS) && defined(ESP8266) + #if FEATURE_NON_STANDARD_24_TASKS && defined(ESP8266) static_assert(TASKS_MAX == 24, "TASKS_MAX invalid size"); #endif diff --git a/src/src/Helpers/StringGenerator_System.cpp b/src/src/Helpers/StringGenerator_System.cpp index d3d4a9f56..7f4fa88ba 100644 --- a/src/src/Helpers/StringGenerator_System.cpp +++ b/src/src/Helpers/StringGenerator_System.cpp @@ -186,9 +186,9 @@ String getPluginDescriptionString() { result += F(PLUGIN_DESCR); result += ']'; #endif // ifdef PLUGIN_DESCR - #ifdef USE_NON_STANDARD_24_TASKS + #if FEATURE_NON_STANDARD_24_TASKS && defined(ESP8266) result += F(" 24tasks"); - #endif // ifdef USE_NON_STANDARD_24_TASKS + #endif // if FEATURE_NON_STANDARD_24_TASKS && defined(ESP8266) result.trim(); return result; } From d6d7a73ec58e8105db7058c7a64b3da1eeda44b1 Mon Sep 17 00:00:00 2001 From: Ton Huisman Date: Thu, 28 Jul 2022 21:15:09 +0200 Subject: [PATCH 07/15] [Build] Rename USES_PACKED_RAW_DATA to FEATURE_PACKED_RAW_DATA and use 0/1 state --- src/_P026_Sysinfo.ino | 4 ++-- src/_P082_GPS.ino | 4 ++-- src/_P085_AcuDC243.ino | 4 ++-- src/_P102_PZEM004Tv3.ino | 4 ++-- src/_P108_DDS238.ino | 4 ++-- src/src/ControllerQueue/C018_queue_element.cpp | 4 ++-- src/src/CustomBuild/check_defines_custom.h | 6 ++++++ src/src/CustomBuild/define_plugin_sets.h | 2 +- src/src/DataTypes/ESPEasy_plugin_functions.h | 2 +- src/src/Helpers/_CPlugin_LoRa_TTN_helper.cpp | 4 ++-- src/src/Helpers/_CPlugin_LoRa_TTN_helper.h | 4 ++-- 11 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/_P026_Sysinfo.ino b/src/_P026_Sysinfo.ino index dafad0d72..06bb39476 100644 --- a/src/_P026_Sysinfo.ino +++ b/src/_P026_Sysinfo.ino @@ -182,7 +182,7 @@ boolean Plugin_026(uint8_t function, struct EventStruct *event, String& string) success = true; break; } -#ifdef USES_PACKED_RAW_DATA +#if FEATURE_PACKED_RAW_DATA case PLUGIN_GET_PACKED_RAW_DATA: { // Matching JS code: @@ -205,7 +205,7 @@ boolean Plugin_026(uint8_t function, struct EventStruct *event, String& string) success = true; break; } -#endif // USES_PACKED_RAW_DATA +#endif // if FEATURE_PACKED_RAW_DATA } return success; } diff --git a/src/_P082_GPS.ino b/src/_P082_GPS.ino index f58949230..362fa4dba 100644 --- a/src/_P082_GPS.ino +++ b/src/_P082_GPS.ino @@ -521,7 +521,7 @@ boolean Plugin_082(uint8_t function, struct EventStruct *event, String& string) break; } -# ifdef USES_PACKED_RAW_DATA +# if FEATURE_PACKED_RAW_DATA case PLUGIN_GET_PACKED_RAW_DATA: { P082_data_struct *P082_data = @@ -550,7 +550,7 @@ boolean Plugin_082(uint8_t function, struct EventStruct *event, String& string) } break; } -# endif // USES_PACKED_RAW_DATA +# endif // if FEATURE_PACKED_RAW_DATA } return success; } diff --git a/src/_P085_AcuDC243.ino b/src/_P085_AcuDC243.ino index ccebfbe3f..8e8216e47 100644 --- a/src/_P085_AcuDC243.ino +++ b/src/_P085_AcuDC243.ino @@ -295,7 +295,7 @@ boolean Plugin_085(uint8_t function, struct EventStruct *event, String& string) } break; } -# ifdef USES_PACKED_RAW_DATA +# if FEATURE_PACKED_RAW_DATA case PLUGIN_GET_PACKED_RAW_DATA: { // FIXME TD-er: Same code as in P102, share in LoRa code. @@ -318,7 +318,7 @@ boolean Plugin_085(uint8_t function, struct EventStruct *event, String& string) } break; } -# endif // USES_PACKED_RAW_DATA +# endif // if FEATURE_PACKED_RAW_DATA } return success; } diff --git a/src/_P102_PZEM004Tv3.ino b/src/_P102_PZEM004Tv3.ino index 9a0358ade..87123e40a 100644 --- a/src/_P102_PZEM004Tv3.ino +++ b/src/_P102_PZEM004Tv3.ino @@ -309,7 +309,7 @@ boolean Plugin_102(uint8_t function, struct EventStruct *event, String& string) break; } -#ifdef USES_PACKED_RAW_DATA +#if FEATURE_PACKED_RAW_DATA case PLUGIN_GET_PACKED_RAW_DATA: { // Matching JS code: @@ -337,7 +337,7 @@ boolean Plugin_102(uint8_t function, struct EventStruct *event, String& string) success = true; break; } -#endif // USES_PACKED_RAW_DATA +#endif // if FEATURE_PACKED_RAW_DATA diff --git a/src/_P108_DDS238.ino b/src/_P108_DDS238.ino index d0fd30dab..33fe527af 100644 --- a/src/_P108_DDS238.ino +++ b/src/_P108_DDS238.ino @@ -255,7 +255,7 @@ boolean Plugin_108(uint8_t function, struct EventStruct *event, String& string) break; } -# ifdef USES_PACKED_RAW_DATA +# if FEATURE_PACKED_RAW_DATA case PLUGIN_GET_PACKED_RAW_DATA: { // FIXME TD-er: Same code as in P102, share in LoRa code. @@ -278,7 +278,7 @@ boolean Plugin_108(uint8_t function, struct EventStruct *event, String& string) } break; } -# endif // USES_PACKED_RAW_DATA +# endif // if FEATURE_PACKED_RAW_DATA } return success; } diff --git a/src/src/ControllerQueue/C018_queue_element.cpp b/src/src/ControllerQueue/C018_queue_element.cpp index 8fecf3f6e..0ac1fb5cd 100644 --- a/src/src/ControllerQueue/C018_queue_element.cpp +++ b/src/src/ControllerQueue/C018_queue_element.cpp @@ -12,7 +12,7 @@ C018_queue_element::C018_queue_element(struct EventStruct *event, uint8_t sample TaskIndex(event->TaskIndex), controller_idx(event->ControllerIndex) { - # ifdef USES_PACKED_RAW_DATA + # if FEATURE_PACKED_RAW_DATA #ifdef USE_SECOND_HEAP // HeapSelectIram ephemeral; #endif @@ -24,7 +24,7 @@ C018_queue_element::C018_queue_element(struct EventStruct *event, uint8_t sample log += packed; addLogMove(LOG_LEVEL_INFO, log); } - # endif // USES_PACKED_RAW_DATA + # endif // if FEATURE_PACKED_RAW_DATA } size_t C018_queue_element::getSize() const { diff --git a/src/src/CustomBuild/check_defines_custom.h b/src/src/CustomBuild/check_defines_custom.h index c3ffda0e6..7ba1ce627 100644 --- a/src/src/CustomBuild/check_defines_custom.h +++ b/src/src/CustomBuild/check_defines_custom.h @@ -144,6 +144,12 @@ # undef USE_NON_STANDARD_24_TASKS #endif // ifdef USE_NON_STANDARD_24_TASKS +#ifdef USES_PACKED_RAW_DATA +# warning "Custom.h has '#define USES_PACKED_RAW_DATA' to be replaced with '#define FEATURE_PACKED_RAW_DATA 1', see https://github.com/letscontrolit/ESPEasy/pull/4153" +# define FEATURE_PACKED_RAW_DATA 1 +# undef USES_PACKED_RAW_DATA +#endif // ifdef USES_PACKED_RAW_DATA + /* *INDENT-ON* */ #endif // ifndef CUSTOMBUILD_CHECK_DEFINES_CUSTOM_H diff --git a/src/src/CustomBuild/define_plugin_sets.h b/src/src/CustomBuild/define_plugin_sets.h index 60f146ef3..1e4ce3f8e 100644 --- a/src/src/CustomBuild/define_plugin_sets.h +++ b/src/src/CustomBuild/define_plugin_sets.h @@ -1741,7 +1741,7 @@ To create/register a plugin, you have to : #if defined(USES_C018) - #define USES_PACKED_RAW_DATA + #define FEATURE_PACKED_RAW_DATA 1 #endif #if defined(USES_P085) || defined (USES_P052) || defined(USES_P078) || defined(USES_P108) diff --git a/src/src/DataTypes/ESPEasy_plugin_functions.h b/src/src/DataTypes/ESPEasy_plugin_functions.h index 5a5639a7c..eb8b05757 100644 --- a/src/src/DataTypes/ESPEasy_plugin_functions.h +++ b/src/src/DataTypes/ESPEasy_plugin_functions.h @@ -37,7 +37,7 @@ #define PLUGIN_MONITOR 30 // Replaces PLUGIN_UNCONDITIONAL_POLL #define PLUGIN_SET_DEFAULTS 31 // Called when assigning a plugin to a task, to set some default config. #define PLUGIN_GET_PACKED_RAW_DATA 32 // Return all data in a compact binary format specific for that plugin. - // Needs USES_PACKED_RAW_DATA + // Needs FEATURE_PACKED_RAW_DATA #define PLUGIN_ONLY_TIMER_IN 33 // Similar to PLUGIN_TIMER_IN, addressed to a plugin instead of a task. #define PLUGIN_WEBFORM_SHOW_I2C_PARAMS 34 // Show I2C parameters like address. #define PLUGIN_WEBFORM_SHOW_SERIAL_PARAMS 35 // When needed, show additional parameters like baudrate or specific serial config diff --git a/src/src/Helpers/_CPlugin_LoRa_TTN_helper.cpp b/src/src/Helpers/_CPlugin_LoRa_TTN_helper.cpp index d76348a08..916860cef 100644 --- a/src/src/Helpers/_CPlugin_LoRa_TTN_helper.cpp +++ b/src/src/Helpers/_CPlugin_LoRa_TTN_helper.cpp @@ -10,7 +10,7 @@ // # Helper functions to encode data for use on LoRa/TTN network. // ####################################################################################################### -#if defined(USES_PACKED_RAW_DATA) +#if FEATURE_PACKED_RAW_DATA String getPackedFromPlugin(struct EventStruct *event, uint8_t sampleSetCount) @@ -104,4 +104,4 @@ float getLoRaAirTime(uint8_t pl, uint8_t sf, uint16_t bw, uint8_t cr, uint8_t n_ return t_air; } -#endif // USES_PACKED_RAW_DATA +#endif // if FEATURE_PACKED_RAW_DATA diff --git a/src/src/Helpers/_CPlugin_LoRa_TTN_helper.h b/src/src/Helpers/_CPlugin_LoRa_TTN_helper.h index e280a75eb..018314905 100644 --- a/src/src/Helpers/_CPlugin_LoRa_TTN_helper.h +++ b/src/src/Helpers/_CPlugin_LoRa_TTN_helper.h @@ -8,7 +8,7 @@ // # Helper functions to encode data for use on LoRa/TTN network. // ####################################################################################################### -#if defined(USES_PACKED_RAW_DATA) +#if FEATURE_PACKED_RAW_DATA #include "../DataStructs/ESPEasy_packed_raw_data.h" @@ -32,7 +32,7 @@ float getLoRaAirTime(uint8_t pl, bool header = true, bool crc = true); -#endif // USES_PACKED_RAW_DATA +#endif // if FEATURE_PACKED_RAW_DATA From 1ca18b8a1b7c92609a8845a05f2c7fda047e9530 Mon Sep 17 00:00:00 2001 From: Ton Huisman Date: Thu, 28 Jul 2022 22:06:15 +0200 Subject: [PATCH 08/15] [Build] Rename USES_BLYNK to FEATURE_BLYNK and use 0/1 state --- src/src/Commands/InternalCommands.cpp | 4 ++-- src/src/CustomBuild/check_defines_custom.h | 6 ++++++ src/src/CustomBuild/define_plugin_sets.h | 9 +++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/src/Commands/InternalCommands.cpp b/src/src/Commands/InternalCommands.cpp index 45c61b7ed..9b3dae2f8 100644 --- a/src/src/Commands/InternalCommands.cpp +++ b/src/src/Commands/InternalCommands.cpp @@ -5,10 +5,10 @@ #include "../../_Plugin_Helper.h" #include "../Globals/Settings.h" -#ifdef USES_BLYNK +#if FEATURE_BLYNK # include "../Commands/Blynk.h" # include "../Commands/Blynk_c015.h" -#endif // ifdef USES_BLYNK +#endif // if FEATURE_BLYNK #include "../Commands/Common.h" #include "../Commands/Controller.h" diff --git a/src/src/CustomBuild/check_defines_custom.h b/src/src/CustomBuild/check_defines_custom.h index f3862224f..ff7f3ffd9 100644 --- a/src/src/CustomBuild/check_defines_custom.h +++ b/src/src/CustomBuild/check_defines_custom.h @@ -150,6 +150,12 @@ # undef USES_PACKED_RAW_DATA #endif // ifdef USES_PACKED_RAW_DATA +#ifdef USES_BLYNK +# warning "Custom.h has '#define USES_BLYNK' to be replaced with '#define FEATURE_BLYNK 1', see https://github.com/letscontrolit/ESPEasy/pull/4153" +# define FEATURE_BLYNK 1 +# undef USES_BLYNK +#endif // ifdef USES_BLYNK + /* *INDENT-ON* */ #endif // ifndef CUSTOMBUILD_CHECK_DEFINES_CUSTOM_H diff --git a/src/src/CustomBuild/define_plugin_sets.h b/src/src/CustomBuild/define_plugin_sets.h index fcfb74d65..a25ea0cab 100644 --- a/src/src/CustomBuild/define_plugin_sets.h +++ b/src/src/CustomBuild/define_plugin_sets.h @@ -1852,8 +1852,9 @@ To create/register a plugin, you have to : #undef FEATURE_TOOLTIPS #define FEATURE_TOOLTIPS 0 #endif - #ifdef USES_BLYNK - #undef USES_BLYNK + #if FEATURE_BLYNK + #undef FEATURE_BLYNK + #define FEATURE_BLYNK 0 #endif #if !defined(PLUGIN_SET_COLLECTION) && !defined(PLUGIN_SET_SONOFF_POW) #ifdef USES_P076 @@ -1940,7 +1941,7 @@ To create/register a plugin, you have to : #endif #if defined(USES_C012) || defined (USES_C015) - #define USES_BLYNK + #define FEATURE_BLYNK 1 #endif // Specific notifier plugins may be enabled via Custom.h, regardless @@ -1968,7 +1969,7 @@ To create/register a plugin, you have to : // It may have gotten undefined to fit a build. Make sure the Blynk controllers are not defined -#ifndef USES_BLYNK +#ifndef FEATURE_BLYNK #ifdef USES_C012 #undef USES_C012 #endif From d42ab378811992190f811aeb57a3287ecd089f78 Mon Sep 17 00:00:00 2001 From: Ton Huisman Date: Thu, 28 Jul 2022 22:20:15 +0200 Subject: [PATCH 09/15] [Build] Fix typo in USES_BLYNK to FEATURE_BLYNK --- src/src/CustomBuild/define_plugin_sets.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/src/CustomBuild/define_plugin_sets.h b/src/src/CustomBuild/define_plugin_sets.h index a25ea0cab..19813463b 100644 --- a/src/src/CustomBuild/define_plugin_sets.h +++ b/src/src/CustomBuild/define_plugin_sets.h @@ -1969,7 +1969,7 @@ To create/register a plugin, you have to : // It may have gotten undefined to fit a build. Make sure the Blynk controllers are not defined -#ifndef FEATURE_BLYNK +#if !FEATURE_BLYNK #ifdef USES_C012 #undef USES_C012 #endif From 93ee95cb606fff702d0b8a15796fbf5847ec7797 Mon Sep 17 00:00:00 2001 From: Ton Huisman Date: Thu, 28 Jul 2022 23:10:54 +0200 Subject: [PATCH 10/15] [Build] Change FEATURE_ADC_VCC to use 1/0 instead of true/false, fix issues with test for FEATURE_ADC_VCC active --- platformio_core_defs.ini | 2 +- platformio_esp82xx_envs.ini | 28 ++++++++++++------------ src/ESPEasy_common.h | 2 +- src/src/CustomBuild/define_plugin_sets.h | 2 +- src/src/PluginStructs/P037_data_struct.h | 4 ++-- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/platformio_core_defs.ini b/platformio_core_defs.ini index 06368fc79..7ca97a767 100644 --- a/platformio_core_defs.ini +++ b/platformio_core_defs.ini @@ -6,7 +6,7 @@ ; **** Frequently used build flags: ; Use custom.h file to override default settings for ESPeasy: -D USE_CUSTOM_H -; Set VCC mode to measure Vcc of ESP chip : -D FEATURE_ADC_VCC=true +; Set VCC mode to measure Vcc of ESP chip : -D FEATURE_ADC_VCC=1 ; Build Flags: ; -DUSE_CONFIG_OVERRIDE diff --git a/platformio_esp82xx_envs.ini b/platformio_esp82xx_envs.ini index 235fa7b52..a14911222 100644 --- a/platformio_esp82xx_envs.ini +++ b/platformio_esp82xx_envs.ini @@ -252,7 +252,7 @@ platform = ${regular_platform.platform} platform_packages = ${regular_platform.platform_packages} build_flags = ${regular_platform.build_flags} ${esp8266_1M.build_flags} - -D FEATURE_ADC_VCC=true + -D FEATURE_ADC_VCC=1 lib_ignore = ${regular_platform.lib_ignore} SD(esp8266) SD @@ -265,7 +265,7 @@ platform = ${regular_platform_alt_wifi.platform} platform_packages = ${regular_platform_alt_wifi.platform_packages} build_flags = ${regular_platform_alt_wifi.build_flags} ${esp8266_1M.build_flags} - -D FEATURE_ADC_VCC=true + -D FEATURE_ADC_VCC=1 lib_ignore = ${regular_platform_alt_wifi.lib_ignore} SD(esp8266) SD @@ -306,7 +306,7 @@ platform = ${regular_platform.platform} platform_packages = ${regular_platform.platform_packages} build_flags = ${regular_platform.build_flags} ${esp8266_4M1M.build_flags} - -D FEATURE_ADC_VCC=true + -D FEATURE_ADC_VCC=1 [env:normal_alt_wifi_ESP8266_4M1M] extends = esp8266_4M1M @@ -544,63 +544,63 @@ build_flags = ${collection_ESP8266_4M1M.build_flags} [env:collection_A_ESP8266_4M1M_VCC] extends = collection_ESP8266_4M1M build_flags = ${collection_ESP8266_4M1M.build_flags} - -DFEATURE_ADC_VCC=true + -DFEATURE_ADC_VCC=1 -DCOLLECTION_USE_RTTTL [env:collection_B_ESP8266_4M1M_VCC] extends = collection_ESP8266_4M1M build_flags = ${collection_ESP8266_4M1M.build_flags} - -DFEATURE_ADC_VCC=true + -DFEATURE_ADC_VCC=1 -DPLUGIN_BUILD_COLLECTION_B [env:collection_C_ESP8266_4M1M_VCC] extends = collection_ESP8266_4M1M build_flags = ${collection_ESP8266_4M1M.build_flags} - -DFEATURE_ADC_VCC=true + -DFEATURE_ADC_VCC=1 -DPLUGIN_BUILD_COLLECTION_C -DCOLLECTION_USE_RTTTL [env:collection_D_ESP8266_4M1M_VCC] extends = collection_ESP8266_4M1M build_flags = ${collection_ESP8266_4M1M.build_flags} - -DFEATURE_ADC_VCC=true + -DFEATURE_ADC_VCC=1 -DPLUGIN_BUILD_COLLECTION_D -DCOLLECTION_USE_RTTTL [env:collection_E_ESP8266_4M1M_VCC] extends = collection_ESP8266_4M1M build_flags = ${collection_ESP8266_4M1M.build_flags} - -DFEATURE_ADC_VCC=true + -DFEATURE_ADC_VCC=1 -DPLUGIN_BUILD_COLLECTION_E -DCOLLECTION_USE_RTTTL ;[env:collection_A_alt_wifi_ESP8266_4M1M_VCC] ;extends = collection_alt_wifi_ESP8266_4M1M ;build_flags = ${collection_alt_wifi_ESP8266_4M1M.build_flags} -; -DFEATURE_ADC_VCC=true +; -DFEATURE_ADC_VCC=1 ;[env:collection_B_alt_wifi_ESP8266_4M1M_VCC] ;extends = collection_alt_wifi_ESP8266_4M1M ;build_flags = ${collection_alt_wifi_ESP8266_4M1M.build_flags} -; -DFEATURE_ADC_VCC=true +; -DFEATURE_ADC_VCC=1 ; -DPLUGIN_BUILD_COLLECTION_B ;[env:collection_C_alt_wifi_ESP8266_4M1M_VCC] ;extends = collection_alt_wifi_ESP8266_4M1M ;build_flags = ${collection_alt_wifi_ESP8266_4M1M.build_flags} -; -DFEATURE_ADC_VCC=true +; -DFEATURE_ADC_VCC=1 ; -DPLUGIN_BUILD_COLLECTION_C ;[env:collection_D_alt_wifi_ESP8266_4M1M_VCC] ;extends = collection_alt_wifi_ESP8266_4M1M ;build_flags = ${collection_alt_wifi_ESP8266_4M1M.build_flags} -; -DFEATURE_ADC_VCC=true +; -DFEATURE_ADC_VCC=1 ; -DPLUGIN_BUILD_COLLECTION_D ;[env:collection_E_alt_wifi_ESP8266_4M1M_VCC] ;extends = collection_alt_wifi_ESP8266_4M1M ;build_flags = ${collection_alt_wifi_ESP8266_4M1M.build_flags} -; -DFEATURE_ADC_VCC=true +; -DFEATURE_ADC_VCC=1 ; -DPLUGIN_BUILD_COLLECTION_E @@ -612,7 +612,7 @@ build_flags = ${collection_ESP8266_4M1M.build_flags} ;platform_packages = ${collection.platform_packages} ;build_flags = ${collection.build_flags} ; ${esp8266_4M1M.build_flags} -; -DFEATURE_ADC_VCC=true +; -DFEATURE_ADC_VCC=1 ; -DFEATURE_MDNS=1 ; -DFEATURE_SD=1 ; -DLIMIT_BUILD_SIZE diff --git a/src/ESPEasy_common.h b/src/ESPEasy_common.h index 2a93ad5cd..6c6b36706 100644 --- a/src/ESPEasy_common.h +++ b/src/ESPEasy_common.h @@ -237,7 +237,7 @@ extern const String EMPTY_STRING; // Please note that the TOUT pin has to be disconnected in this mode // Use the "System Info" device to read the VCC value #ifndef FEATURE_ADC_VCC - #define FEATURE_ADC_VCC false + #define FEATURE_ADC_VCC 0 #endif #ifndef ARDUINO_OTA_PORT diff --git a/src/src/CustomBuild/define_plugin_sets.h b/src/src/CustomBuild/define_plugin_sets.h index 19813463b..4b493433b 100644 --- a/src/src/CustomBuild/define_plugin_sets.h +++ b/src/src/CustomBuild/define_plugin_sets.h @@ -1781,7 +1781,7 @@ To create/register a plugin, you have to : // VCC builds need a bit more, disable timing stats to make it fit. #ifndef PLUGIN_BUILD_CUSTOM - #if defined(FEATURE_ADC_VCC) && !defined(PLUGIN_SET_MAX) + #if FEATURE_ADC_VCC && !defined(PLUGIN_SET_MAX) #ifndef LIMIT_BUILD_SIZE #define LIMIT_BUILD_SIZE #endif diff --git a/src/src/PluginStructs/P037_data_struct.h b/src/src/PluginStructs/P037_data_struct.h index 8b5ef6c8b..3c6760afd 100644 --- a/src/src/PluginStructs/P037_data_struct.h +++ b/src/src/PluginStructs/P037_data_struct.h @@ -40,9 +40,9 @@ # if P037_MAPPING_SUPPORT # undef P037_MAPPING_SUPPORT # endif // if P037_MAPPING_SUPPORT -# if defined(FEATURE_ADC_VCC) && P037_FILTER_SUPPORT +# if FEATURE_ADC_VCC && P037_FILTER_SUPPORT # undef P037_FILTER_SUPPORT -# endif // if defined(FEATURE_ADC_VCC) && P037_FILTER_SUPPORT +# endif // if FEATURE_ADC_VCC && P037_FILTER_SUPPORT // #if P037_JSON_SUPPORT // #undef P037_JSON_SUPPORT From 5487bc461040e48778ab5db36de99f44ec040590 Mon Sep 17 00:00:00 2001 From: Ton Huisman Date: Fri, 29 Jul 2022 14:28:08 +0200 Subject: [PATCH 11/15] [P037] Fix build errors on more/less limited builds, apply uncrustify improvements --- src/src/PluginStructs/P037_data_struct.cpp | 34 ++++++++++++---------- src/src/PluginStructs/P037_data_struct.h | 5 ++++ 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/src/PluginStructs/P037_data_struct.cpp b/src/src/PluginStructs/P037_data_struct.cpp index f80a408be..3b3258170 100644 --- a/src/src/PluginStructs/P037_data_struct.cpp +++ b/src/src/PluginStructs/P037_data_struct.cpp @@ -36,9 +36,9 @@ bool P037_data_struct::loadSettings() { String tmp[1]; LoadCustomTaskSettings(_taskIndex, tmp, - 1, 41, offset); - globalTopicPrefix = std::move(tmp[0]); - offset += 41; + 1, 41, offset); + globalTopicPrefix = std::move(tmp[0]); + offset += 41; } @@ -51,34 +51,36 @@ bool P037_data_struct::loadSettings() { String P037_data_struct::saveSettings() { String res; + if (_taskIndex < TASKS_MAX) { size_t offset = 0; res += SaveCustomTaskSettings(_taskIndex, mqttTopics, - VARS_PER_TASK, 41, offset); + VARS_PER_TASK, 41, offset); offset += VARS_PER_TASK * 41; res += SaveCustomTaskSettings(_taskIndex, jsonAttributes, - VARS_PER_TASK, 21, offset); + VARS_PER_TASK, 21, offset); offset += VARS_PER_TASK * 21; { String tmp[1]; tmp[0] = globalTopicPrefix; - res += SaveCustomTaskSettings(_taskIndex, tmp, - 1, 41, offset); + res += SaveCustomTaskSettings(_taskIndex, tmp, + 1, 41, offset); offset += 41; } res += SaveCustomTaskSettings(_taskIndex, valueArray, - P037_ARRAY_SIZE, 0, offset + 1); + P037_ARRAY_SIZE, 0, offset + 1); } return res; } String P037_data_struct::getFullMQTTTopic(uint8_t taskValueIndex) const { String topic; - if (taskValueIndex < VARS_PER_TASK && mqttTopics[taskValueIndex].length() > 0) { + + if ((taskValueIndex < VARS_PER_TASK) && (mqttTopics[taskValueIndex].length() > 0)) { topic.reserve(globalTopicPrefix.length() + mqttTopics[taskValueIndex].length()); topic = globalTopicPrefix; topic.trim(); @@ -88,9 +90,9 @@ String P037_data_struct::getFullMQTTTopic(uint8_t taskValueIndex) const { return topic; } - bool P037_data_struct::shouldSubscribeToMQTTtopic(const String& topic) const { - if (topic.length() == 0) return false; + if (topic.length() == 0) { return false; } + for (uint8_t x = 0; x < VARS_PER_TASK; x++) { if (topic.equalsIgnoreCase(getFullMQTTTopic(x))) { @@ -124,6 +126,9 @@ void P037_data_struct::parseMappings() { _maxFilter = 0; // Initialize to empty # endif // if P037_FILTER_SUPPORT + # if P037_MAPPING_SUPPORT || P037_FILTER_SUPPORT + int8_t idx; + # endif // if P037_MAPPING_SUPPORT || P037_FILTER_SUPPORT # if P037_MAPPING_SUPPORT int8_t idx = P037_MAX_MAPPINGS; @@ -475,7 +480,6 @@ bool P037_data_struct::webform_load( return success; } // webform_load - bool P037_data_struct::webform_save( # if P037_FILTER_SUPPORT bool filterEnabled @@ -503,8 +507,8 @@ bool P037_data_struct::webform_save( # ifdef P037_JSON_SUPPORT if (jsonEnabled) { - argName = F("attribute"); - argName += (varNr + 1); + argName = F("attribute"); + argName += (varNr + 1); jsonAttributes[varNr] = web_server.arg(argName); } # endif // P037_JSON_SUPPORT @@ -515,6 +519,7 @@ bool P037_data_struct::webform_save( # if P037_MAPPING_SUPPORT || P037_FILTER_SUPPORT String left, right; bool firstError; + int8_t idx = 0; # endif // if P037_MAPPING_SUPPORT || P037_FILTER_SUPPORT // Mappings are processed first @@ -522,7 +527,6 @@ bool P037_data_struct::webform_save( firstError = true; String operands = P037_OPERAND_LIST; uint8_t mapNr = 1; - int8_t idx = 0; left.reserve(32); right.reserve(32); diff --git a/src/src/PluginStructs/P037_data_struct.h b/src/src/PluginStructs/P037_data_struct.h index 3c6760afd..4e813ba4b 100644 --- a/src/src/PluginStructs/P037_data_struct.h +++ b/src/src/PluginStructs/P037_data_struct.h @@ -39,22 +39,27 @@ # endif // ifdef PLUGIN_037_DEBUG # if P037_MAPPING_SUPPORT # undef P037_MAPPING_SUPPORT +# define P037_MAPPING_SUPPORT 0 # endif // if P037_MAPPING_SUPPORT # if FEATURE_ADC_VCC && P037_FILTER_SUPPORT # undef P037_FILTER_SUPPORT +# define P037_FILTER_SUPPORT 0 # endif // if FEATURE_ADC_VCC && P037_FILTER_SUPPORT // #if P037_JSON_SUPPORT // #undef P037_JSON_SUPPORT +// #define P037_JSON_SUPPORT 0 // #endif # endif // if defined(LIMIT_BUILD_SIZE) && !defined(P037_OVERRIDE) # ifdef PLUGIN_DISPLAY_COLLECTION # if P037_FILTER_SUPPORT # undef P037_FILTER_SUPPORT +# define P037_FILTER_SUPPORT 0 # endif // if P037_FILTER_SUPPORT # if P037_REPLACE_BY_COMMA_SUPPORT # undef P037_REPLACE_BY_COMMA_SUPPORT +# define P037_REPLACE_BY_COMMA_SUPPORT 0 # endif // if P037_REPLACE_BY_COMMA_SUPPORT # endif // ifdef PLUGIN_DISPLAY_COLLECTION # endif // ifndef PLUGIN_BUILD_MAX_ESP32 From 7c7d4869554814fa2e438db5ba76434923d6ce8f Mon Sep 17 00:00:00 2001 From: Ton Huisman Date: Fri, 29 Jul 2022 15:03:18 +0200 Subject: [PATCH 12/15] [P037] Fix typo --- src/src/PluginStructs/P037_data_struct.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/src/PluginStructs/P037_data_struct.cpp b/src/src/PluginStructs/P037_data_struct.cpp index 3b3258170..e2b509311 100644 --- a/src/src/PluginStructs/P037_data_struct.cpp +++ b/src/src/PluginStructs/P037_data_struct.cpp @@ -130,7 +130,7 @@ void P037_data_struct::parseMappings() { int8_t idx; # endif // if P037_MAPPING_SUPPORT || P037_FILTER_SUPPORT # if P037_MAPPING_SUPPORT - int8_t idx = P037_MAX_MAPPINGS; + idx = P037_MAX_MAPPINGS; for (uint8_t mappingOffset = P037_END_MAPPINGS; mappingOffset >= P037_START_MAPPINGS && _maxIdx == 0; mappingOffset--) { if (!valueArray[mappingOffset].isEmpty()) { From 6b0e6f10f79d3ef894f9d85e4f05f107a799e3c4 Mon Sep 17 00:00:00 2001 From: Ton Huisman Date: Fri, 29 Jul 2022 20:52:39 +0200 Subject: [PATCH 13/15] [Build] Change FEATURE_REPORTING to use 1/0 --- src/ESPEasy-Globals.h | 2 +- src/_Reporting.ino | 6 +++--- src/src/CustomBuild/check_defines_custom.h | 6 ++++++ src/src/ESPEasyCore/ESPEasy_setup.cpp | 4 ++-- src/src/Helpers/PeriodicalActions.cpp | 4 ++-- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/ESPEasy-Globals.h b/src/ESPEasy-Globals.h index 5cfe99b12..344e5563a 100644 --- a/src/ESPEasy-Globals.h +++ b/src/ESPEasy-Globals.h @@ -13,7 +13,7 @@ //enable reporting status to ESPEasy developers. //this informs us of crashes and stability issues. // not finished yet! -// #define FEATURE_REPORTING +// #define FEATURE_REPORTING 1 //Select which plugin sets you want to build. //These are normally automaticly set via the Platformio build environment. diff --git a/src/_Reporting.ino b/src/_Reporting.ino index fd35235bb..0b713fef8 100644 --- a/src/_Reporting.ino +++ b/src/_Reporting.ino @@ -1,6 +1,6 @@ // not finished yet -#ifdef FEATURE_REPORTING +#if defined(FEATURE_REPORTING) && FEATURE_REPORTING #include @@ -8,7 +8,7 @@ // NO, too big: #include #define REPORT_HOST "espeasy.datux.nl" -#define FEATURE_REPORTING +#define FEATURE_REPORTING 1 void ReportStatus() { @@ -94,4 +94,4 @@ void ReportStatus() } */ -#endif // ifdef FEATURE_REPORTING +#endif // if defined(FEATURE_REPORTING) && FEATURE_REPORTING diff --git a/src/src/CustomBuild/check_defines_custom.h b/src/src/CustomBuild/check_defines_custom.h index ff7f3ffd9..ab9c1f5a9 100644 --- a/src/src/CustomBuild/check_defines_custom.h +++ b/src/src/CustomBuild/check_defines_custom.h @@ -156,6 +156,12 @@ # undef USES_BLYNK #endif // ifdef USES_BLYNK +#if defined(FEATURE_REPORTING) && (2 - FEATURE_REPORTING - 2 == 4) // 'Defined but empty' check +# warning "Custom.h has '#define FEATURE_REPORTING' to be replaced with '#define FEATURE_REPORTING 1', see https://github.com/letscontrolit/ESPEasy/pull/4153" +# undef FEATURE_REPORTING +# define FEATURE_REPORTING 1 +#endif // if defined(FEATURE_REPORTING) && (2-FEATURE_REPORTING-2 == 4) + /* *INDENT-ON* */ #endif // ifndef CUSTOMBUILD_CHECK_DEFINES_CUSTOM_H diff --git a/src/src/ESPEasyCore/ESPEasy_setup.cpp b/src/src/ESPEasyCore/ESPEasy_setup.cpp index cc6d7ab2e..0d3c93b27 100644 --- a/src/src/ESPEasyCore/ESPEasy_setup.cpp +++ b/src/src/ESPEasyCore/ESPEasy_setup.cpp @@ -453,9 +453,9 @@ void ESPEasy_setup() #endif - #ifdef FEATURE_REPORTING + #if FEATURE_REPORTING ReportStatus(); - #endif // ifdef FEATURE_REPORTING + #endif // if FEATURE_REPORTING #if FEATURE_ARDUINO_OTA ArduinoOTAInit(); diff --git a/src/src/Helpers/PeriodicalActions.cpp b/src/src/Helpers/PeriodicalActions.cpp index 76022a760..31543222b 100644 --- a/src/src/Helpers/PeriodicalActions.cpp +++ b/src/src/Helpers/PeriodicalActions.cpp @@ -245,9 +245,9 @@ void runEach30Seconds() } #endif - #ifdef FEATURE_REPORTING + #if FEATURE_REPORTING ReportStatus(); - #endif + #endif // if FEATURE_REPORTING } From 80b32e737183ec43eeb2d498abced31de16b1584 Mon Sep 17 00:00:00 2001 From: Ton Huisman Date: Fri, 29 Jul 2022 21:02:09 +0200 Subject: [PATCH 14/15] [Build] Change FEATURE_DNS_SERVER to use 1/0 state --- src/src/CustomBuild/check_defines_custom.h | 6 ++++++ src/src/CustomBuild/define_plugin_sets.h | 4 ++-- src/src/ESPEasyCore/ESPEasyWifi.cpp | 4 ++-- src/src/ESPEasyCore/ESPEasyWifi_ProcessEvent.cpp | 4 ++-- src/src/ESPEasyCore/ESPEasy_backgroundtasks.cpp | 4 ++-- src/src/Globals/Services.cpp | 4 ++-- src/src/Globals/Services.h | 4 ++-- 7 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/src/CustomBuild/check_defines_custom.h b/src/src/CustomBuild/check_defines_custom.h index ab9c1f5a9..a626d6f93 100644 --- a/src/src/CustomBuild/check_defines_custom.h +++ b/src/src/CustomBuild/check_defines_custom.h @@ -162,6 +162,12 @@ # define FEATURE_REPORTING 1 #endif // if defined(FEATURE_REPORTING) && (2-FEATURE_REPORTING-2 == 4) +#if defined(FEATURE_DNS_SERVER) && (2 - FEATURE_DNS_SERVER - 2 == 4) // 'Defined but empty' check +# warning "Custom.h has '#define FEATURE_DNS_SERVER' to be replaced with '#define FEATURE_DNS_SERVER 1', see https://github.com/letscontrolit/ESPEasy/pull/4153" +# undef FEATURE_DNS_SERVER +# define FEATURE_DNS_SERVER 1 +#endif // if defined(FEATURE_DNS_SERVER) && (2-FEATURE_DNS_SERVER-2 == 4) + /* *INDENT-ON* */ #endif // ifndef CUSTOMBUILD_CHECK_DEFINES_CUSTOM_H diff --git a/src/src/CustomBuild/define_plugin_sets.h b/src/src/CustomBuild/define_plugin_sets.h index 4b493433b..bde1ff0c7 100644 --- a/src/src/CustomBuild/define_plugin_sets.h +++ b/src/src/CustomBuild/define_plugin_sets.h @@ -1986,14 +1986,14 @@ To create/register a plugin, you have to : #if FEATURE_MDNS #ifndef FEATURE_DNS_SERVER - #define FEATURE_DNS_SERVER + #define FEATURE_DNS_SERVER 1 #endif #endif #ifdef WEBSERVER_SETUP #ifndef PLUGIN_BUILD_MINIMAL_OTA #ifndef FEATURE_DNS_SERVER - #define FEATURE_DNS_SERVER + #define FEATURE_DNS_SERVER 1 #endif #endif #endif diff --git a/src/src/ESPEasyCore/ESPEasyWifi.cpp b/src/src/ESPEasyCore/ESPEasyWifi.cpp index f26f710ce..66e21c8ba 100644 --- a/src/src/ESPEasyCore/ESPEasyWifi.cpp +++ b/src/src/ESPEasyCore/ESPEasyWifi.cpp @@ -1086,12 +1086,12 @@ void setAPinternal(bool enable) #endif // ifdef ESP32 WiFiEventData.timerAPoff.setMillisFromNow(WIFI_AP_OFF_TIMER_DURATION); } else { - #ifdef FEATURE_DNS_SERVER + #if FEATURE_DNS_SERVER if (dnsServerActive) { dnsServerActive = false; dnsServer.stop(); } - #endif + #endif // if FEATURE_DNS_SERVER } } diff --git a/src/src/ESPEasyCore/ESPEasyWifi_ProcessEvent.cpp b/src/src/ESPEasyCore/ESPEasyWifi_ProcessEvent.cpp index e7f43b69f..1dc9d76c3 100644 --- a/src/src/ESPEasyCore/ESPEasyWifi_ProcessEvent.cpp +++ b/src/src/ESPEasyCore/ESPEasyWifi_ProcessEvent.cpp @@ -491,7 +491,7 @@ void processConnectAPmode() { addLogMove(LOG_LEVEL_INFO, log); } - #ifdef FEATURE_DNS_SERVER + #if FEATURE_DNS_SERVER // Start DNS, only used if the ESP has no valid WiFi config // It will reply with it's own address on all DNS requests // (captive portal concept) @@ -499,7 +499,7 @@ void processConnectAPmode() { dnsServerActive = true; dnsServer.start(DNS_PORT, "*", apIP); } - #endif + #endif // if FEATURE_DNS_SERVER } // Switch of AP mode when timeout reached and no client connected anymore. diff --git a/src/src/ESPEasyCore/ESPEasy_backgroundtasks.cpp b/src/src/ESPEasyCore/ESPEasy_backgroundtasks.cpp index 3708e862d..46712664c 100644 --- a/src/src/ESPEasyCore/ESPEasy_backgroundtasks.cpp +++ b/src/src/ESPEasyCore/ESPEasy_backgroundtasks.cpp @@ -83,13 +83,13 @@ void backgroundtasks() #endif } - #ifdef FEATURE_DNS_SERVER + #if FEATURE_DNS_SERVER // process DNS, only used if the ESP has no valid WiFi config if (dnsServerActive) { dnsServer.processNextRequest(); } - #endif // ifdef FEATURE_DNS_SERVER + #endif // if FEATURE_DNS_SERVER #if FEATURE_ARDUINO_OTA diff --git a/src/src/Globals/Services.cpp b/src/src/Globals/Services.cpp index 52f65b832..f3971e2a4 100644 --- a/src/src/Globals/Services.cpp +++ b/src/src/Globals/Services.cpp @@ -22,8 +22,8 @@ #endif -#ifdef FEATURE_DNS_SERVER +#if FEATURE_DNS_SERVER #include DNSServer dnsServer; bool dnsServerActive = false; -#endif +#endif // if FEATURE_DNS_SERVER diff --git a/src/src/Globals/Services.h b/src/src/Globals/Services.h index c59cc6467..7d4197e51 100644 --- a/src/src/Globals/Services.h +++ b/src/src/Globals/Services.h @@ -49,11 +49,11 @@ #endif -#ifdef FEATURE_DNS_SERVER +#if FEATURE_DNS_SERVER #include extern DNSServer dnsServer; extern bool dnsServerActive; -#endif +#endif // if FEATURE_DNS_SERVER #endif // GLOBALS_SERVICES_H From d18cde81ba191aeeb8f6e7dad90d7496bbf76680 Mon Sep 17 00:00:00 2001 From: Ton Huisman Date: Fri, 29 Jul 2022 21:13:14 +0200 Subject: [PATCH 15/15] [Build] Correct a few FEATURE_flag checks --- src/src/CustomBuild/define_plugin_sets.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/src/CustomBuild/define_plugin_sets.h b/src/src/CustomBuild/define_plugin_sets.h index bde1ff0c7..eac3cae24 100644 --- a/src/src/CustomBuild/define_plugin_sets.h +++ b/src/src/CustomBuild/define_plugin_sets.h @@ -318,17 +318,17 @@ To create/register a plugin, you have to : #endif #endif -#ifdef FEATURE_FHEM +#if FEATURE_FHEM #define USES_C009 // FHEM HTTP #endif -#ifdef FEATURE_HOMEASSISTANT_OPENHAB +#if FEATURE_HOMEASSISTANT_OPENHAB #define USES_C005 // Home Assistant (openHAB) MQTT #endif #ifdef PLUGIN_BUILD_MINIMAL_OTA // Disable ESPEasy p2p for minimal OTA builds. - #ifdef FEATURE_ESPEASY_P2P + #if FEATURE_ESPEASY_P2P #undef FEATURE_ESPEASY_P2P #define FEATURE_ESPEASY_P2P 0 #endif