From cc7602539f2504d2b3e60638f400ae59ed6ebd1d Mon Sep 17 00:00:00 2001 From: TD-er Date: Wed, 10 May 2023 23:00:33 +0200 Subject: [PATCH] [Build] Fix building ESPEasy in PlatformIO 6.1.7 (#4656) * [PIO build] Update build scripts for scons 4.5.x * [Build] Fix build error due to strange cast of double type in rules * [Build] Work-around for new ESP8266 macro of round() Whoever thought it would be a good idea to make round() an explicit cast to `long`.... * [Build ESP8266] Replace calls to round() * [Build] Use HWrandom to overcome build issues * [Build] Fix missing include * [Build] Remove extern "C" to allow for (C++) function overloading * [Build] include ESPEasy_common.h instead of Arduino.h where possible * [Cleanup] Moving not commonly needed code out of ESPEasy_common.h * [Build] Remove "Helpers" folder from concat script * [Build] Include ESPEasy_common.h instead of ESPEasy_config.h * [Build] Add Helpers folder to concat .cpp for ESP8266 * [Build] Add ESPEasyCore to concat cpp & split global RulesCalculate obj * [Build test] Disable lots of plugins + not concat Helpers/*.cpp * [Build test] Disable P037 to test build failures * [Build test] Undef round right after include * [Build] Revert disabling plugins + concat Helpers/*.cpp * [Build] Include cmath after Arduino.h to redefine round() * [Build] Fix ESP32 build error * [Build] Add ESP32_CLASSIC define for ESP32 IR build --- platformio.ini | 2 +- platformio_core_defs.ini | 2 +- platformio_esp32_envs.ini | 11 +- platformio_esp82xx_base.ini | 4 +- src/ESPEasy-Globals.cpp | 2 - src/ESPEasy.ino | 2 - src/ESPEasy_common.h | 61 ++++++----- src/_C009.cpp | 1 + src/_C014.cpp | 1 + src/_P021_Level.ino | 2 +- src/_Plugin_Helper.h | 4 +- src/src/Commands/Common.h | 1 - src/src/Commands/Controller.h | 2 +- src/src/Commands/GPIO.h | 2 +- src/src/Commands/HTTP.h | 2 +- src/src/Commands/InternalCommands.h | 4 +- src/src/Commands/MQTT.h | 2 - src/src/Commands/RTC.h | 2 +- src/src/Commands/Rules.cpp | 2 +- src/src/Commands/Rules.h | 2 +- src/src/Commands/Servo.h | 1 - src/src/Commands/Settings.h | 2 +- src/src/Commands/System.h | 2 +- src/src/Commands/Tasks.cpp | 2 +- src/src/Commands/Timer.h | 2 +- src/src/Commands/UPD.h | 1 - src/src/Commands/i2c.h | 2 +- src/src/Commands/wd.cpp | 2 + src/src/ControllerQueue/C011_queue_element.h | 5 +- src/src/ControllerQueue/C015_queue_element.h | 4 +- .../ControllerDelayHandlerStruct.h | 2 +- src/src/CustomBuild/CompiletimeDefines.h | 4 + src/src/CustomBuild/define_plugin_sets.h | 2 +- src/src/DataStructs/C013_p2p_dataStructs.h | 1 - src/src/DataStructs/Caches.h | 3 +- .../DataStructs/ControllerSettingsStruct.h | 4 +- src/src/DataStructs/DeviceStruct.h | 3 +- src/src/DataStructs/ESPEasyControllerCache.h | 1 - src/src/DataStructs/ESPEasy_EventStruct.cpp | 2 + src/src/DataStructs/ESPEasy_EventStruct.h | 2 - src/src/DataStructs/EthernetEventData.h | 1 + .../DataStructs/EventStructCommandWrapper.h | 3 +- src/src/DataStructs/ExtraTaskSettingsStruct.h | 2 +- src/src/DataStructs/I2CTypes.h | 3 +- src/src/DataStructs/LogStruct.h | 1 - src/src/DataStructs/NodesHandler.cpp | 2 + .../DataStructs/NotificationSettingsStruct.h | 1 - src/src/DataStructs/ProvisioningStruct.h | 2 + src/src/DataStructs/TimeChangeRule.h | 2 +- src/src/DataStructs/TimingStats.h | 1 - src/src/DataStructs_templ/SettingsStruct.cpp | 2 +- src/src/DataTypes/CPluginID.h | 3 +- src/src/DataTypes/ControllerIndex.h | 2 +- src/src/DataTypes/DeviceIndex.h | 2 +- src/src/DataTypes/DeviceModel.h | 2 +- src/src/DataTypes/ESPEasyFileType.h | 2 +- src/src/DataTypes/ESPEasyTimeSource.cpp | 2 - src/src/DataTypes/ESPEasyTimeSource.h | 4 +- src/src/DataTypes/EthernetParameters.h | 2 +- src/src/DataTypes/EventValueSource.h | 2 +- src/src/DataTypes/NPluginID.h | 2 +- src/src/DataTypes/NetworkMedium.h | 2 - src/src/DataTypes/NodeTypeID.h | 26 ++++- src/src/DataTypes/NotifierIndex.h | 2 +- src/src/DataTypes/PluginID.h | 2 +- src/src/DataTypes/ProtocolIndex.h | 2 +- src/src/DataTypes/SPI_options.h | 2 +- src/src/DataTypes/TaskIndex.h | 2 +- src/src/DataTypes/TimeSource.h | 2 +- src/src/DataTypes/WiFiConnectionProtocol.h | 2 +- src/src/ESPEasyCore/Controller.cpp | 2 +- src/src/ESPEasyCore/ESPEasyEthEvent.h | 10 +- src/src/ESPEasyCore/ESPEasyNetwork.h | 2 + src/src/ESPEasyCore/ESPEasyRules.cpp | 7 +- src/src/ESPEasyCore/ESPEasyWiFiEvent.h | 2 + src/src/ESPEasyCore/ESPEasyWifi.cpp | 1 + src/src/Globals/C016_ControllerCache.h | 1 - src/src/Globals/ESPEasyWiFiEvent.h | 2 +- src/src/Globals/MainLoopCommand.h | 2 +- src/src/Globals/NPlugins.h | 2 +- src/src/Globals/NetworkState.h | 2 +- src/src/Globals/Plugins.h | 4 +- src/src/Globals/Plugins_other.h | 2 +- src/src/Globals/Protocol.h | 2 + src/src/Globals/RamTracker.h | 2 +- src/src/Globals/RulesCalculate.cpp | 90 ++++++++++++++++ src/src/Globals/RulesCalculate.h | 27 +++++ src/src/Globals/RuntimeData.h | 2 + src/src/Globals/Statistics.cpp | 1 - src/src/Helpers/AdafruitGFX_helper.cpp | 8 +- src/src/Helpers/AdafruitGFX_helper.h | 11 +- src/src/Helpers/Audio.h | 1 - src/src/Helpers/CRC_functions.h | 2 +- src/src/Helpers/Convert.h | 2 +- src/src/Helpers/ESPEasyMutex.cpp | 12 +++ src/src/Helpers/ESPEasyMutex.h | 4 +- src/src/Helpers/ESPEasy_math.cpp | 3 + src/src/Helpers/ESPEasy_time.cpp | 12 +-- src/src/Helpers/ESPEasy_time.h | 2 - src/src/Helpers/ESPEasy_time_calc.cpp | 2 +- src/src/Helpers/ESPEasy_time_calc.h | 3 +- src/src/Helpers/ESPEasy_time_zone.h | 2 +- src/src/Helpers/FS_Helper.h | 1 - src/src/Helpers/Hardware.cpp | 38 ++++++- src/src/Helpers/Hardware.h | 6 +- src/src/Helpers/I2C_Plugin_Helper.h | 1 - src/src/Helpers/LongTermTimer.h | 2 +- src/src/Helpers/Memory.h | 1 - src/src/Helpers/Misc.h | 2 - src/src/Helpers/Modbus_RTU.h | 2 +- src/src/Helpers/Networking.cpp | 13 ++- src/src/Helpers/Networking.h | 2 +- src/src/Helpers/Numerical.h | 2 +- src/src/Helpers/OTA.cpp | 14 +++ src/src/Helpers/PortStatus.h | 2 +- src/src/Helpers/Rules_calculate.cpp | 102 +----------------- src/src/Helpers/Rules_calculate.h | 15 +-- src/src/Helpers/StringConverter.h | 2 - src/src/Helpers/StringConverter_Numerical.h | 2 +- src/src/Helpers/StringGenerator_GPIO.h | 1 - src/src/Helpers/StringGenerator_Plugin.h | 2 +- src/src/Helpers/StringGenerator_System.cpp | 20 ++++ src/src/Helpers/StringGenerator_WiFi.cpp | 4 + src/src/Helpers/StringParser.cpp | 6 +- src/src/Helpers/StringParser.h | 2 - src/src/Helpers/SystemVariables.h | 2 - src/src/Helpers/_CPlugin_Helper_webform.h | 2 +- src/src/Helpers/_CPlugin_init.h | 1 - .../Helpers/_Internal_GPIO_pulseHelper.cpp | 1 - src/src/Helpers/_NPlugin_init.h | 2 - src/src/Helpers/_Plugin_Helper_serial.cpp | 4 +- src/src/Helpers/_Plugin_Helper_webform.h | 2 +- src/src/Helpers/_Plugin_SensorTypeHelper.h | 2 +- src/src/Helpers/_Plugin_init.h | 2 - src/src/Helpers/msecTimerHandlerStruct.cpp | 1 - src/src/Helpers/msecTimerHandlerStruct.h | 2 +- src/src/PluginStructs/P002_data_struct.cpp | 2 +- src/src/PluginStructs/P036_data_struct.cpp | 2 - src/src/PluginStructs/P042_data_struct.cpp | 10 +- src/src/PluginStructs/P079_data_struct.h | 6 -- src/src/PluginStructs/P089_data_struct.cpp | 2 +- src/src/PluginStructs/P092_data_struct.h | 2 - src/src/PluginStructs/P103_data_struct.h | 2 +- src/src/PluginStructs/P118_data_struct.h | 1 - src/src/PluginStructs/P128_data_struct.cpp | 18 ++-- src/src/WebServer/I2C_Scanner.cpp | 1 + src/src/WebServer/WebTemplateParser.h | 3 - src/src/WebServer/common.h | 14 +-- tools/pio/concat_cpp_files.py | 1 + tools/pio/generate-compiletime-defines.py | 21 ++-- 150 files changed, 470 insertions(+), 348 deletions(-) create mode 100644 src/src/Globals/RulesCalculate.cpp create mode 100644 src/src/Globals/RulesCalculate.h create mode 100644 src/src/Helpers/ESPEasyMutex.cpp diff --git a/platformio.ini b/platformio.ini index 3de4b4eaa..eeec7d378 100644 --- a/platformio.ini +++ b/platformio.ini @@ -91,7 +91,7 @@ upload_speed = 115200 monitor_speed = 115200 ;targets = size, checkprogsize targets = -src_filter = +<*> -<.git/> -<.svn/> - - - - -<*/Commands_tmp/> -<*/ControllerQueue_tmp/> -<*/DataStructs_tmp/> -<*/DataTypes_tmp/> -<*/Globals_tmp/> -<*/Helpers_tmp/> -<*/PluginStructs_tmp/> -<*/WebServer_tmp/> +src_filter = +<*> -<.git/> -<.svn/> - - - - -<*/Commands_tmp/> -<*/ControllerQueue_tmp/> -<*/DataStructs_tmp/> -<*/DataTypes_tmp/> -<*/ESPEasyCore_tmp/> -<*/Globals_tmp/> -<*/Helpers_tmp/> -<*/PluginStructs_tmp/> -<*/WebServer_tmp/> ; Backwards compatibility: https://github.com/platformio/platformio-core/issues/4270 ;build_src_filter = +<*> -<.git/> -<.svn/> - - - - -<*/Commands/> -<*/ControllerQueue/> -<*/DataStructs/> -<*/DataTypes/> -<*/Globals/> -<*/Helpers/> -<*/PluginStructs/> -<*/WebServer/> diff --git a/platformio_core_defs.ini b/platformio_core_defs.ini index ec3363f2e..1af8a90bd 100644 --- a/platformio_core_defs.ini +++ b/platformio_core_defs.ini @@ -74,6 +74,7 @@ build_flags = ${esp82xx_2_5_x.build_flags} -DCORE_POST_2_6_0 ; remove the 4-bytes alignment for PSTR() -DPSTR_ALIGN=1 + -Werror=return-type lib_ignore = ${esp82xx_defaults.lib_ignore} @@ -81,7 +82,6 @@ lib_ignore = ${esp82xx_defaults.lib_ignore} build_flags = ${esp82xx_2_6_x.build_flags} -DCORE_POST_3_0_0 -Wno-deprecated-declarations - -Werror=return-type lib_ignore = ${esp82xx_defaults.lib_ignore} diff --git a/platformio_esp32_envs.ini b/platformio_esp32_envs.ini index e9e62ace2..1d11c13ea 100644 --- a/platformio_esp32_envs.ini +++ b/platformio_esp32_envs.ini @@ -60,6 +60,7 @@ lib_ignore = ${esp32_always.lib_ignore} HeatpumpIR ESP32 BLE Arduino build_flags = ${esp32_base.build_flags} + -DESP32_CLASSIC extra_scripts = ${esp32_base.extra_scripts} build_unflags = ${esp32_base.build_unflags} -fexceptions @@ -76,7 +77,7 @@ board_build.filesystem = littlefs extends = esp32_base lib_ignore = ${esp32_always.lib_ignore} ESP32_ping -build_flags = ${esp32_base.build_flags} +build_flags = ${esp32_common.build_flags} -DFEATURE_ARDUINO_OTA=1 -DPLUGIN_BUILD_NORMAL_IRext -DCOLLECTION_USE_RTTTL @@ -115,7 +116,7 @@ board_upload.flash_size = 16MB [env:custom_IR_ESP32_4M316k] extends = esp32_base board = esp32_4M -build_flags = ${esp32_base.build_flags} +build_flags = ${esp32_common.build_flags} -DPLUGIN_BUILD_CUSTOM -DPLUGIN_BUILD_IR lib_ignore = ${esp32_always.lib_ignore} @@ -272,7 +273,7 @@ extra_scripts = ${env:custom_ESP32_4M316k.extra_scripts} extends = esp32_base board = esp32_16M8M board_upload.flash_size = 16MB -build_flags = ${esp32_base.build_flags} +build_flags = ${esp32_common.build_flags} -DPLUGIN_BUILD_CUSTOM -DPLUGIN_BUILD_IR -DFEATURE_ETHERNET=1 @@ -429,7 +430,7 @@ board = esp32_16M1M board_upload.flash_size = 16MB lib_ignore = ${esp32_always.lib_ignore} ESP32_ping -build_flags = ${esp32_base.build_flags} +build_flags = ${esp32_common.build_flags} -DFEATURE_ARDUINO_OTA=1 -DPLUGIN_BUILD_MAX_ESP32 -DPLUGIN_BUILD_IR_EXTENDED @@ -447,7 +448,7 @@ board = esp32_16M8M board_upload.flash_size = 16MB lib_ignore = ${esp32_always.lib_ignore} ESP32_ping -build_flags = ${esp32_base.build_flags} +build_flags = ${esp32_common.build_flags} -DUSE_LITTLEFS -DFEATURE_ARDUINO_OTA=1 -DPLUGIN_BUILD_MAX_ESP32 diff --git a/platformio_esp82xx_base.ini b/platformio_esp82xx_base.ini index 3b3c74d0f..4f4d59aaa 100644 --- a/platformio_esp82xx_base.ini +++ b/platformio_esp82xx_base.ini @@ -61,7 +61,7 @@ framework = ${common.framework} upload_speed = ${common.upload_speed} monitor_speed = ${common.monitor_speed} targets = ${common.targets} -build_flags = ${debug_flags.build_flags} +build_flags = ${minimal_size.build_flags} ${mqtt_flags.build_flags} -DHTTPCLIENT_1_1_COMPATIBLE=0 build_unflags = -DDEBUG_ESP_PORT @@ -80,7 +80,7 @@ lib_ignore = ${esp82xx_defaults.lib_ignore} monitor_filters = esp8266_exception_decoder extra_scripts = pre:tools/pio/pre_default_check.py ${extra_scripts_esp8266.extra_scripts} -src_filter = +<*> -<.git/> -<.svn/> - - - - -<*/Commands/> -<*/ControllerQueue/> -<*/DataStructs/> -<*/DataTypes/> -<*/Globals/> -<*/Helpers/> -<*/PluginStructs/> -<*/WebServer/> +src_filter = +<*> -<.git/> -<.svn/> - - - - -<*/Commands/> -<*/ControllerQueue/> -<*/DataStructs/> -<*/DataTypes/> -<*/ESPEasyCore/> -<*/Globals/> -<*/Helpers/> -<*/PluginStructs/> -<*/WebServer/> diff --git a/src/ESPEasy-Globals.cpp b/src/ESPEasy-Globals.cpp index dd03cf830..74bf20a96 100644 --- a/src/ESPEasy-Globals.cpp +++ b/src/ESPEasy-Globals.cpp @@ -1,5 +1,3 @@ -#include - #include "ESPEasy-Globals.h" diff --git a/src/ESPEasy.ino b/src/ESPEasy.ino index 60e80cbf8..f6e2e3906 100644 --- a/src/ESPEasy.ino +++ b/src/ESPEasy.ino @@ -1,6 +1,4 @@ -#include - #ifdef CONTINUOUS_INTEGRATION # pragma GCC diagnostic error "-Wall" #else // ifdef CONTINUOUS_INTEGRATION diff --git a/src/ESPEasy_common.h b/src/ESPEasy_common.h index 8499eff5e..5d644055e 100644 --- a/src/ESPEasy_common.h +++ b/src/ESPEasy_common.h @@ -1,6 +1,8 @@ #ifndef ESPEASY_COMMON_H #define ESPEASY_COMMON_H +#ifdef __cplusplus + // ***************************************************************************************** // For Arduino IDE users: // When building using Custom.h, uncomment the next line: @@ -14,7 +16,10 @@ */ -#include +#include // See: https://github.com/esp8266/Arduino/issues/8922#issuecomment-1542301697 +#include + + // User configuration #include "include/ESPEasy_config.h" #include "./src/CustomBuild/ESPEasyDefaults.h" @@ -39,7 +44,7 @@ #endif //#include "src/DataStructs/NodeStruct.h" -#include "src/DataTypes/NodeTypeID.h" +//#include "src/DataTypes/NodeTypeID.h" #include "src/Globals/RamTracker.h" #include "src/ESPEasyCore/ESPEasy_Log.h" #include "src/Helpers/ESPEasy_math.h" @@ -47,7 +52,6 @@ #if defined(ESP8266) #include - #define NODE_TYPE_ID NODE_TYPE_ID_ESP_EASYM_STD #include #ifndef LWIP_VERSION_MAJOR #error @@ -57,32 +61,43 @@ #else #include #endif - #include +// #include //#include #ifndef LWIP_OPEN_SRC #define LWIP_OPEN_SRC #endif - #include - #include - #include - #include +// #include +// #include +// #include +// #include #include + /* extern "C" { #include } + */ - #define SMALLEST_OTA_IMAGE 276848 // smallest known 2-step OTA image - #define MAX_SKETCH_SIZE 1044464 // 1020 kB - 16 bytes #endif +/* #if defined(ESP32) #include #ifdef ESP32S2 - #define NODE_TYPE_ID NODE_TYPE_ID_ESP_EASY32S2_STD + #include + #elif defined(ESP32S3) + #include #elif defined(ESP32C3) - #define NODE_TYPE_ID NODE_TYPE_ID_ESP_EASY32C3_STD - #else - #define NODE_TYPE_ID NODE_TYPE_ID_ESP_EASY32_STD + #include + # elif defined(ESP32_CLASSIC) + #if ESP_IDF_VERSION_MAJOR > 3 + #include + #else + #include + #endif + # else + + static_assert(false, "Implement processor architecture"); + #endif // #include // #include "esp32_ping.h" @@ -99,27 +114,18 @@ #include // Needed to call ESP-IDF functions like esp_wifi_.... #endif +*/ - -#include -#include -#include +//#include +//#include +//#include extern const String EMPTY_STRING; -#ifndef ARDUINO_OTA_PORT - #if defined(ESP32) - #define ARDUINO_OTA_PORT 3232 - #else - // Do not use port 8266 for OTA, since that's used for ESPeasy p2p - #define ARDUINO_OTA_PORT 18266 - #endif -#endif - #if defined(ESP8266) //enable Arduino OTA updating. //Note: This adds around 10kb to the firmware size, and 1kb extra ram. @@ -133,5 +139,6 @@ extern const String EMPTY_STRING; //#define FEATURE_MDNS #endif +#endif #endif // ESPEASY_COMMON_H \ No newline at end of file diff --git a/src/_C009.cpp b/src/_C009.cpp index 7eb057947..0dc9a361e 100644 --- a/src/_C009.cpp +++ b/src/_C009.cpp @@ -1,6 +1,7 @@ #include "src/Helpers/_CPlugin_Helper.h" #ifdef USES_C009 +#include "src/DataTypes/NodeTypeID.h" #include "src/Helpers/StringProvider.h" #include "src/CustomBuild/ESPEasy_buildinfo.h" diff --git a/src/_C014.cpp b/src/_C014.cpp index 8294e3097..0ece7b5d2 100644 --- a/src/_C014.cpp +++ b/src/_C014.cpp @@ -2,6 +2,7 @@ #ifdef USES_C014 # include "src/Commands/InternalCommands.h" +# include "src/DataTypes/NodeTypeID.h" # include "src/Globals/Device.h" # include "src/Globals/MQTT.h" # include "src/Globals/Plugins.h" diff --git a/src/_P021_Level.ino b/src/_P021_Level.ino index 7602c6c58..d34eb1b1e 100644 --- a/src/_P021_Level.ino +++ b/src/_P021_Level.ino @@ -15,7 +15,7 @@ // apply float/double math compare functions instead of regular comparisons # include "src/Helpers/ESPEasy_math.h" -# include "src/Helpers/Rules_calculate.h" +# include "src/Globals/RulesCalculate.h" # include "src/WebServer/ESPEasy_WebServer.h" # define PLUGIN_021 diff --git a/src/_Plugin_Helper.h b/src/_Plugin_Helper.h index 7dbcf1304..84d8e305f 100644 --- a/src/_Plugin_Helper.h +++ b/src/_Plugin_Helper.h @@ -1,9 +1,7 @@ #ifndef PLUGIN_HELPER_H #define PLUGIN_HELPER_H -#include - -#include "include/ESPEasy_config.h" +#include "ESPEasy_common.h" #include "src/CustomBuild/ESPEasyLimits.h" diff --git a/src/src/Commands/Common.h b/src/src/Commands/Common.h index 25cc86296..2f13624f5 100644 --- a/src/src/Commands/Common.h +++ b/src/src/Commands/Common.h @@ -2,7 +2,6 @@ #define COMMAND_COMMON_H #include -#include #include "../../ESPEasy_common.h" diff --git a/src/src/Commands/Controller.h b/src/src/Commands/Controller.h index e16fca029..02f3fecd6 100644 --- a/src/src/Commands/Controller.h +++ b/src/src/Commands/Controller.h @@ -1,7 +1,7 @@ #ifndef COMMAND_CONTROLLR_H #define COMMAND_CONTROLLR_H -#include +#include "../../ESPEasy_common.h" const __FlashStringHelper * Command_Controller_Disable(struct EventStruct *event, const char* Line); const __FlashStringHelper * Command_Controller_Enable(struct EventStruct *event, const char* Line); diff --git a/src/src/Commands/GPIO.h b/src/src/Commands/GPIO.h index 5dedb7d04..805ffccaa 100644 --- a/src/src/Commands/GPIO.h +++ b/src/src/Commands/GPIO.h @@ -1,7 +1,7 @@ #ifndef COMMAND_GPIO_H #define COMMAND_GPIO_H -#include +#include "../../ESPEasy_common.h" // FIXME TD-er: This fwd declaration should not be in .h file. diff --git a/src/src/Commands/HTTP.h b/src/src/Commands/HTTP.h index 42d383523..ea1dfdc75 100644 --- a/src/src/Commands/HTTP.h +++ b/src/src/Commands/HTTP.h @@ -1,7 +1,7 @@ #ifndef COMMAND_HTTP_H #define COMMAND_HTTP_H -#include +#include "../../ESPEasy_common.h" #if FEATURE_SEND_TO_HTTP || FEATURE_POST_TO_HTTP || FEATURE_PUT_TO_HTTP const __FlashStringHelper* httpEmitToHTTP(struct EventStruct *event, diff --git a/src/src/Commands/InternalCommands.h b/src/src/Commands/InternalCommands.h index ece220516..75308f858 100644 --- a/src/src/Commands/InternalCommands.h +++ b/src/src/Commands/InternalCommands.h @@ -1,11 +1,11 @@ #ifndef COMMANDS_INTERNALCOMMANDS_H #define COMMANDS_INTERNALCOMMANDS_H +#include "../../ESPEasy_common.h" + #include "../DataStructs/ESPEasy_EventStruct.h" #include "../Globals/Plugins.h" -#include - bool checkSourceFlags(EventValueSource::Enum source, EventValueSourceGroup::Enum group); diff --git a/src/src/Commands/MQTT.h b/src/src/Commands/MQTT.h index c3c4566ef..a1af7ecec 100644 --- a/src/src/Commands/MQTT.h +++ b/src/src/Commands/MQTT.h @@ -5,8 +5,6 @@ #if FEATURE_MQTT -#include - const __FlashStringHelper * Command_MQTT_Publish(struct EventStruct *event, const char *Line); diff --git a/src/src/Commands/RTC.h b/src/src/Commands/RTC.h index be41df993..2444766e6 100644 --- a/src/src/Commands/RTC.h +++ b/src/src/Commands/RTC.h @@ -1,7 +1,7 @@ #ifndef COMMAND_RTC_H #define COMMAND_RTC_H -#include +#include "../../ESPEasy_common.h" const __FlashStringHelper * Command_RTC_Clear(struct EventStruct *event, const char* Line); const __FlashStringHelper * Command_RTC_resetFlashWriteCounter(struct EventStruct *event, const char* Line); diff --git a/src/src/Commands/Rules.cpp b/src/src/Commands/Rules.cpp index a6854ceb5..8a331896a 100644 --- a/src/src/Commands/Rules.cpp +++ b/src/src/Commands/Rules.cpp @@ -12,11 +12,11 @@ #include "../ESPEasyCore/ESPEasyRules.h" #include "../Globals/EventQueue.h" +#include "../Globals/RulesCalculate.h" #include "../Globals/RuntimeData.h" #include "../Globals/Settings.h" #include "../Helpers/Misc.h" -#include "../Helpers/Rules_calculate.h" #include "../Helpers/StringConverter.h" const __FlashStringHelper * Command_Rules_Execute(struct EventStruct *event, const char *Line) diff --git a/src/src/Commands/Rules.h b/src/src/Commands/Rules.h index f24b5d89b..03ca32187 100644 --- a/src/src/Commands/Rules.h +++ b/src/src/Commands/Rules.h @@ -1,7 +1,7 @@ #ifndef COMMAND_RULES_H #define COMMAND_RULES_H -#include +#include "../../ESPEasy_common.h" const __FlashStringHelper * Command_Rules_Execute(struct EventStruct *event, const char *Line); String Command_Rules_UseRules(struct EventStruct *event, const char *Line); diff --git a/src/src/Commands/Servo.h b/src/src/Commands/Servo.h index 502c66092..4a1b2f4e6 100644 --- a/src/src/Commands/Servo.h +++ b/src/src/Commands/Servo.h @@ -5,7 +5,6 @@ #if FEATURE_SERVO -# include # include # include diff --git a/src/src/Commands/Settings.h b/src/src/Commands/Settings.h index d5bdd5ce6..07262bca4 100644 --- a/src/src/Commands/Settings.h +++ b/src/src/Commands/Settings.h @@ -1,7 +1,7 @@ #ifndef COMMAND_SETTINGS_H #define COMMAND_SETTINGS_H -#include +#include "../../ESPEasy_common.h" String Command_Settings_Build(struct EventStruct *event, const char* Line); String Command_Settings_Unit(struct EventStruct *event, const char* Line); diff --git a/src/src/Commands/System.h b/src/src/Commands/System.h index 887e8ba6b..1f8690b87 100644 --- a/src/src/Commands/System.h +++ b/src/src/Commands/System.h @@ -1,7 +1,7 @@ #ifndef COMMAND_SYSTEM_H #define COMMAND_SYSTEM_H -#include +#include "../../ESPEasy_common.h" const __FlashStringHelper * Command_System_NoSleep(struct EventStruct *event, const char* Line); const __FlashStringHelper * Command_System_deepSleep(struct EventStruct *event, const char* Line); diff --git a/src/src/Commands/Tasks.cpp b/src/src/Commands/Tasks.cpp index 06eb37371..8a70d2b58 100644 --- a/src/src/Commands/Tasks.cpp +++ b/src/src/Commands/Tasks.cpp @@ -12,12 +12,12 @@ #include "../ESPEasyCore/Serial.h" #include "../Globals/ESPEasy_Scheduler.h" +#include "../Globals/RulesCalculate.h" #include "../Globals/RuntimeData.h" #include "../Globals/Settings.h" #include "../Helpers/Misc.h" #include "../Helpers/Numerical.h" -#include "../Helpers/Rules_calculate.h" #include "../Helpers/StringConverter.h" #include "../Helpers/StringParser.h" diff --git a/src/src/Commands/Timer.h b/src/src/Commands/Timer.h index cd367748b..bf470c049 100644 --- a/src/src/Commands/Timer.h +++ b/src/src/Commands/Timer.h @@ -1,7 +1,7 @@ #ifndef COMMAND_TIMER_H #define COMMAND_TIMER_H -#include +#include "../../ESPEasy_common.h" const __FlashStringHelper * Command_Timer_Set (struct EventStruct *event, const char* Line); const __FlashStringHelper * Command_Timer_Set_ms (struct EventStruct *event, const char* Line); diff --git a/src/src/Commands/UPD.h b/src/src/Commands/UPD.h index 8fac3b7f6..6dcd6ba9f 100644 --- a/src/src/Commands/UPD.h +++ b/src/src/Commands/UPD.h @@ -3,7 +3,6 @@ #include "../../ESPEasy_common.h" -#include String Command_UDP_Port(struct EventStruct *event, const char* Line); #if FEATURE_ESPEASY_P2P diff --git a/src/src/Commands/i2c.h b/src/src/Commands/i2c.h index f4133eeb3..27a8c2fc3 100644 --- a/src/src/Commands/i2c.h +++ b/src/src/Commands/i2c.h @@ -1,7 +1,7 @@ #ifndef COMMAND_I2C_H #define COMMAND_I2C_H -#include +#include "../../ESPEasy_common.h" const __FlashStringHelper * Command_i2c_Scanner(struct EventStruct *event, const char* Line); diff --git a/src/src/Commands/wd.cpp b/src/src/Commands/wd.cpp index 39a508a0e..03a2cc4dd 100644 --- a/src/src/Commands/wd.cpp +++ b/src/src/Commands/wd.cpp @@ -11,6 +11,8 @@ #include "../Helpers/StringConverter.h" +#include + const __FlashStringHelper * Command_WD_Config(EventStruct *event, const char* Line) { Wire.beginTransmission(event->Par1); // address diff --git a/src/src/ControllerQueue/C011_queue_element.h b/src/src/ControllerQueue/C011_queue_element.h index 1874fb43a..782dce058 100644 --- a/src/src/ControllerQueue/C011_queue_element.h +++ b/src/src/ControllerQueue/C011_queue_element.h @@ -2,6 +2,9 @@ #define CONTROLLERQUEUE_C011_QUEUE_ELEMENT_H #include "../../ESPEasy_common.h" + +#ifdef USES_C011 + #include "../ControllerQueue/Queue_element_base.h" #include "../CustomBuild/ESPEasyLimits.h" #include "../DataStructs/DeviceStruct.h" @@ -12,8 +15,6 @@ struct EventStruct; -#ifdef USES_C011 - /*********************************************************************************************\ * C011_queue_element for queueing requests for C011: Generic HTTP Advanced. \*********************************************************************************************/ diff --git a/src/src/ControllerQueue/C015_queue_element.h b/src/src/ControllerQueue/C015_queue_element.h index 08e6592e6..a08814358 100644 --- a/src/src/ControllerQueue/C015_queue_element.h +++ b/src/src/ControllerQueue/C015_queue_element.h @@ -2,6 +2,9 @@ #define CONTROLLERQUEUE_C015_QUEUE_ELEMENT_H #include "../../ESPEasy_common.h" + +#ifdef USES_C015 + #include "../ControllerQueue/Queue_element_base.h" #include "../CustomBuild/ESPEasyLimits.h" #include "../DataStructs/UnitMessageCount.h" @@ -10,7 +13,6 @@ struct EventStruct; -#ifdef USES_C015 /*********************************************************************************************\ * C015_queue_element for queueing requests for 015: Blynk diff --git a/src/src/ControllerQueue/ControllerDelayHandlerStruct.h b/src/src/ControllerQueue/ControllerDelayHandlerStruct.h index 4049ee7f3..0419e4b40 100644 --- a/src/src/ControllerQueue/ControllerDelayHandlerStruct.h +++ b/src/src/ControllerQueue/ControllerDelayHandlerStruct.h @@ -20,7 +20,7 @@ #include "../Helpers/Scheduler.h" #include "../Helpers/StringConverter.h" -#include + #include #include // For std::shared_ptr #include // std::nothrow diff --git a/src/src/CustomBuild/CompiletimeDefines.h b/src/src/CustomBuild/CompiletimeDefines.h index d1d5550ea..4accfedca 100644 --- a/src/src/CustomBuild/CompiletimeDefines.h +++ b/src/src/CustomBuild/CompiletimeDefines.h @@ -1,7 +1,11 @@ #ifndef CUSTOMBUILD_COMPILETIMEDEFINES_H #define CUSTOMBUILD_COMPILETIMEDEFINES_H + #include +#ifdef ESP8266 +#undef round //see https://github.com/esp8266/Arduino/issues/5787#issuecomment-465852231 +#endif // Build NR is used as a "revision" nr for settings diff --git a/src/src/CustomBuild/define_plugin_sets.h b/src/src/CustomBuild/define_plugin_sets.h index 230bd8648..aeab8a7fe 100644 --- a/src/src/CustomBuild/define_plugin_sets.h +++ b/src/src/CustomBuild/define_plugin_sets.h @@ -2904,4 +2904,4 @@ To create/register a plugin, you have to : #endif #endif -#endif // CUSTOMBUILD_DEFINE_PLUGIN_SETS_H +#endif // CUSTOMBUILD_DEFINE_PLUGIN_SETS_H \ No newline at end of file diff --git a/src/src/DataStructs/C013_p2p_dataStructs.h b/src/src/DataStructs/C013_p2p_dataStructs.h index 491d7b457..f90748093 100644 --- a/src/src/DataStructs/C013_p2p_dataStructs.h +++ b/src/src/DataStructs/C013_p2p_dataStructs.h @@ -5,7 +5,6 @@ #ifdef USES_C013 -# include # include "../CustomBuild/ESPEasyLimits.h" # include "../DataStructs/DeviceStruct.h" diff --git a/src/src/DataStructs/Caches.h b/src/src/DataStructs/Caches.h index dca04e79f..ed5aef56a 100644 --- a/src/src/DataStructs/Caches.h +++ b/src/src/DataStructs/Caches.h @@ -1,7 +1,6 @@ #ifndef DATASTRUCTS_CACHES_H #define DATASTRUCTS_CACHES_H -#include #include "../../ESPEasy_common.h" #include "../CustomBuild/ESPEasyLimits.h" @@ -14,6 +13,8 @@ #include "../Helpers/RulesHelper.h" +#include + // Key is combination of array index + some offset reflecting the used array // Store those sparingly used TaskDevicePluginConfigLong and TaskDevicePluginConfig // from the ExtraTaskSettings diff --git a/src/src/DataStructs/ControllerSettingsStruct.h b/src/src/DataStructs/ControllerSettingsStruct.h index baf898524..a25fa211b 100644 --- a/src/src/DataStructs/ControllerSettingsStruct.h +++ b/src/src/DataStructs/ControllerSettingsStruct.h @@ -4,7 +4,8 @@ /*********************************************************************************************\ * ControllerSettingsStruct definition \*********************************************************************************************/ -#include +#include "../../ESPEasy_common.h" + #include // For std::shared_ptr #include // for std::nothrow @@ -12,7 +13,6 @@ #include #include -#include "../../ESPEasy_common.h" #include "../DataStructs/ChecksumType.h" #include "../Globals/Plugins.h" diff --git a/src/src/DataStructs/DeviceStruct.h b/src/src/DataStructs/DeviceStruct.h index 2a6d51848..2afa6276e 100644 --- a/src/src/DataStructs/DeviceStruct.h +++ b/src/src/DataStructs/DeviceStruct.h @@ -2,7 +2,8 @@ #define DATASTRUCTS_DEVICESTRUCTS_H -#include +#include "../../ESPEasy_common.h" + #include #include "../DataTypes/SensorVType.h" diff --git a/src/src/DataStructs/ESPEasyControllerCache.h b/src/src/DataStructs/ESPEasyControllerCache.h index fd7acdc5e..f27b99d49 100644 --- a/src/src/DataStructs/ESPEasyControllerCache.h +++ b/src/src/DataStructs/ESPEasyControllerCache.h @@ -5,7 +5,6 @@ #if FEATURE_RTC_CACHE_STORAGE -#include #include "../DataStructs/RTC_cache_handler_struct.h" diff --git a/src/src/DataStructs/ESPEasy_EventStruct.cpp b/src/src/DataStructs/ESPEasy_EventStruct.cpp index ebc068998..4e36d79f3 100644 --- a/src/src/DataStructs/ESPEasy_EventStruct.cpp +++ b/src/src/DataStructs/ESPEasy_EventStruct.cpp @@ -1,5 +1,7 @@ #include "../DataStructs/ESPEasy_EventStruct.h" +#include "../../ESPEasy_common.h" + #include "../CustomBuild/ESPEasyLimits.h" #include "../DataTypes/EventValueSource.h" #include "../Globals/Plugins.h" diff --git a/src/src/DataStructs/ESPEasy_EventStruct.h b/src/src/DataStructs/ESPEasy_EventStruct.h index e3b2bdcde..6197d007d 100644 --- a/src/src/DataStructs/ESPEasy_EventStruct.h +++ b/src/src/DataStructs/ESPEasy_EventStruct.h @@ -3,8 +3,6 @@ #include "../../ESPEasy_common.h" -#include - #include "../DataTypes/ControllerIndex.h" #include "../DataTypes/EventValueSource.h" #include "../DataTypes/TaskIndex.h" diff --git a/src/src/DataStructs/EthernetEventData.h b/src/src/DataStructs/EthernetEventData.h index 349bf824c..1aa88bbda 100644 --- a/src/src/DataStructs/EthernetEventData.h +++ b/src/src/DataStructs/EthernetEventData.h @@ -12,6 +12,7 @@ #ifdef ESP32 # include +# include #endif // ifdef ESP32 diff --git a/src/src/DataStructs/EventStructCommandWrapper.h b/src/src/DataStructs/EventStructCommandWrapper.h index 86ae05fc6..92b24087c 100644 --- a/src/src/DataStructs/EventStructCommandWrapper.h +++ b/src/src/DataStructs/EventStructCommandWrapper.h @@ -1,7 +1,8 @@ #ifndef DATASTRUCTS_EVENTSTRUCTCOMMANDWRAPPER_H #define DATASTRUCTS_EVENTSTRUCTCOMMANDWRAPPER_H -#include +#include "../../ESPEasy_common.h" + #include "../DataStructs/ESPEasy_EventStruct.h" struct EventStructCommandWrapper { diff --git a/src/src/DataStructs/ExtraTaskSettingsStruct.h b/src/src/DataStructs/ExtraTaskSettingsStruct.h index 95a21ff2e..c6c3c55b0 100644 --- a/src/src/DataStructs/ExtraTaskSettingsStruct.h +++ b/src/src/DataStructs/ExtraTaskSettingsStruct.h @@ -5,7 +5,7 @@ * ExtraTaskSettingsStruct \*********************************************************************************************/ -#include +#include "../../ESPEasy_common.h" #include "../CustomBuild/ESPEasyLimits.h" #include "../DataStructs/ChecksumType.h" diff --git a/src/src/DataStructs/I2CTypes.h b/src/src/DataStructs/I2CTypes.h index ee9760cd7..565b74283 100644 --- a/src/src/DataStructs/I2CTypes.h +++ b/src/src/DataStructs/I2CTypes.h @@ -1,7 +1,8 @@ #ifndef DATASTRUCTS_I2C_TYPES_H #define DATASTRUCTS_I2C_TYPES_H -#include +#include "../../ESPEasy_common.h" + #include // **************************************************************************/ diff --git a/src/src/DataStructs/LogStruct.h b/src/src/DataStructs/LogStruct.h index 258ca3eb6..01928d07d 100644 --- a/src/src/DataStructs/LogStruct.h +++ b/src/src/DataStructs/LogStruct.h @@ -1,7 +1,6 @@ #ifndef DATASTRUCTS_LOGSTRUCT_H #define DATASTRUCTS_LOGSTRUCT_H -#include #include "../../ESPEasy_common.h" diff --git a/src/src/DataStructs/NodesHandler.cpp b/src/src/DataStructs/NodesHandler.cpp index 749713aea..2666aa786 100644 --- a/src/src/DataStructs/NodesHandler.cpp +++ b/src/src/DataStructs/NodesHandler.cpp @@ -10,6 +10,8 @@ #include "../Globals/ESPEasy_now_state.h" #endif +#include "../DataTypes/NodeTypeID.h" + #if FEATURE_MQTT #include "../ESPEasyCore/Controller.h" #endif diff --git a/src/src/DataStructs/NotificationSettingsStruct.h b/src/src/DataStructs/NotificationSettingsStruct.h index ee5e59e6b..73b353f2e 100644 --- a/src/src/DataStructs/NotificationSettingsStruct.h +++ b/src/src/DataStructs/NotificationSettingsStruct.h @@ -5,7 +5,6 @@ #if FEATURE_NOTIFIER -#include #include // For std::shared_ptr /*********************************************************************************************\ diff --git a/src/src/DataStructs/ProvisioningStruct.h b/src/src/DataStructs/ProvisioningStruct.h index 27c04a50b..5f5ad5642 100644 --- a/src/src/DataStructs/ProvisioningStruct.h +++ b/src/src/DataStructs/ProvisioningStruct.h @@ -8,6 +8,8 @@ # include "../DataStructs/FactoryDefaultPref.h" # include "../DataTypes/ESPEasyFileType.h" +# include // for std::shared_ptr + /*********************************************************************************************\ * ProvisioningStruct \*********************************************************************************************/ diff --git a/src/src/DataStructs/TimeChangeRule.h b/src/src/DataStructs/TimeChangeRule.h index 33d13962c..7bdb5a2de 100644 --- a/src/src/DataStructs/TimeChangeRule.h +++ b/src/src/DataStructs/TimeChangeRule.h @@ -1,7 +1,7 @@ #ifndef DATASTRUCTS_TIMECHANGERULE_H #define DATASTRUCTS_TIMECHANGERULE_H -#include +#include "../../ESPEasy_common.h" // structure to describe rules for when daylight/summer time begins, // or when standard time begins. diff --git a/src/src/DataStructs/TimingStats.h b/src/src/DataStructs/TimingStats.h index 12bf4f28e..141bca841 100644 --- a/src/src/DataStructs/TimingStats.h +++ b/src/src/DataStructs/TimingStats.h @@ -11,7 +11,6 @@ # include "../Globals/Settings.h" # include "../Helpers/ESPEasy_time_calc.h" -# include # include #endif // if FEATURE_TIMING_STATS diff --git a/src/src/DataStructs_templ/SettingsStruct.cpp b/src/src/DataStructs_templ/SettingsStruct.cpp index c971e5161..6662a11c3 100644 --- a/src/src/DataStructs_templ/SettingsStruct.cpp +++ b/src/src/DataStructs_templ/SettingsStruct.cpp @@ -425,7 +425,7 @@ void SettingsStruct_tmpl::validate() { if ((Longitude < -180.0f) || (Longitude > 180.0f)) { Longitude = 0.0f; } - if (VariousBits1 > (1 << 31)) { VariousBits1 = 0; } // FIXME: Check really needed/useful? + if (VariousBits1 > (1u << 31)) { VariousBits1 = 0; } // FIXME: Check really needed/useful? ZERO_TERMINATE(Name); ZERO_TERMINATE(NTPHost); diff --git a/src/src/DataTypes/CPluginID.h b/src/src/DataTypes/CPluginID.h index b9fc144df..1afeade14 100644 --- a/src/src/DataTypes/CPluginID.h +++ b/src/src/DataTypes/CPluginID.h @@ -1,8 +1,7 @@ #ifndef DATATYPES_CPLUGINID_H #define DATATYPES_CPLUGINID_H -#include - +#include "../../ESPEasy_common.h" typedef uint8_t cpluginID_t; diff --git a/src/src/DataTypes/ControllerIndex.h b/src/src/DataTypes/ControllerIndex.h index dc219a6fa..045a93976 100644 --- a/src/src/DataTypes/ControllerIndex.h +++ b/src/src/DataTypes/ControllerIndex.h @@ -1,7 +1,7 @@ #ifndef DATATYPES_CONTROLLERINDEX_H #define DATATYPES_CONTROLLERINDEX_H -#include +#include "../../ESPEasy_common.h" typedef uint8_t controllerIndex_t; diff --git a/src/src/DataTypes/DeviceIndex.h b/src/src/DataTypes/DeviceIndex.h index d3d693613..fbad479cc 100644 --- a/src/src/DataTypes/DeviceIndex.h +++ b/src/src/DataTypes/DeviceIndex.h @@ -1,7 +1,7 @@ #ifndef DATATYPES_DEVICEINDEX_H #define DATATYPES_DEVICEINDEX_H -#include +#include "../../ESPEasy_common.h" typedef uint8_t deviceIndex_t; diff --git a/src/src/DataTypes/DeviceModel.h b/src/src/DataTypes/DeviceModel.h index a55fb8df5..18c994d55 100644 --- a/src/src/DataTypes/DeviceModel.h +++ b/src/src/DataTypes/DeviceModel.h @@ -5,7 +5,7 @@ Pre defined settings for off-the-shelf hardware \*********************************************************************************************/ -#include +#include "../../ESPEasy_common.h" // This enum will be stored, so do not change order or at least the values. enum class DeviceModel : uint8_t { diff --git a/src/src/DataTypes/ESPEasyFileType.h b/src/src/DataTypes/ESPEasyFileType.h index 273f1b7e7..c80be67fc 100644 --- a/src/src/DataTypes/ESPEasyFileType.h +++ b/src/src/DataTypes/ESPEasyFileType.h @@ -1,7 +1,7 @@ #ifndef DATATYPES_ESPEASYFILETYPE_H #define DATATYPES_ESPEASYFILETYPE_H -#include +#include "../../ESPEasy_common.h" struct FileType { enum Enum : short { diff --git a/src/src/DataTypes/ESPEasyTimeSource.cpp b/src/src/DataTypes/ESPEasyTimeSource.cpp index 52f482914..faa9f4c04 100644 --- a/src/src/DataTypes/ESPEasyTimeSource.cpp +++ b/src/src/DataTypes/ESPEasyTimeSource.cpp @@ -1,7 +1,5 @@ #include "../DataTypes/ESPEasyTimeSource.h" -#include - #include "../../ESPEasy_common.h" const __FlashStringHelper* toString(timeSource_t timeSource) diff --git a/src/src/DataTypes/ESPEasyTimeSource.h b/src/src/DataTypes/ESPEasyTimeSource.h index ac868f8e2..c660f2f26 100644 --- a/src/src/DataTypes/ESPEasyTimeSource.h +++ b/src/src/DataTypes/ESPEasyTimeSource.h @@ -2,8 +2,10 @@ #define DATATYPES_ESPEASYTIMESOURCE_H +#include "../../ESPEasy_common.h" + #include -#include + class String; diff --git a/src/src/DataTypes/EthernetParameters.h b/src/src/DataTypes/EthernetParameters.h index 07f97f42a..08441fb87 100644 --- a/src/src/DataTypes/EthernetParameters.h +++ b/src/src/DataTypes/EthernetParameters.h @@ -1,7 +1,7 @@ #ifndef DATASTRUCTS_ETHERNETPARAMETERS_H #define DATASTRUCTS_ETHERNETPARAMETERS_H -#include +#include "../../ESPEasy_common.h" // Is stored in settings enum class EthClockMode_t : uint8_t { diff --git a/src/src/DataTypes/EventValueSource.h b/src/src/DataTypes/EventValueSource.h index 3a1d17920..8b60bd236 100644 --- a/src/src/DataTypes/EventValueSource.h +++ b/src/src/DataTypes/EventValueSource.h @@ -1,7 +1,7 @@ #ifndef DATATYPES_EVENT_VALUE_SOURCE_H #define DATATYPES_EVENT_VALUE_SOURCE_H -#include +#include "../../ESPEasy_common.h" struct EventValueSourceGroup { enum class Enum : uint8_t { diff --git a/src/src/DataTypes/NPluginID.h b/src/src/DataTypes/NPluginID.h index 9dc6abd74..d6f64c57e 100644 --- a/src/src/DataTypes/NPluginID.h +++ b/src/src/DataTypes/NPluginID.h @@ -1,7 +1,7 @@ #ifndef DATATYPES_NPLUGINID_H #define DATATYPES_NPLUGINID_H -#include +#include "../../ESPEasy_common.h" typedef uint8_t npluginID_t; diff --git a/src/src/DataTypes/NetworkMedium.h b/src/src/DataTypes/NetworkMedium.h index 462380b9a..c516d9229 100644 --- a/src/src/DataTypes/NetworkMedium.h +++ b/src/src/DataTypes/NetworkMedium.h @@ -1,8 +1,6 @@ #ifndef DATATYPES_NETWORKMEDIUM_H #define DATATYPES_NETWORKMEDIUM_H -#include - #include "../../ESPEasy_common.h" // Is stored in settings diff --git a/src/src/DataTypes/NodeTypeID.h b/src/src/DataTypes/NodeTypeID.h index 3f6e86ece..5df96c97b 100644 --- a/src/src/DataTypes/NodeTypeID.h +++ b/src/src/DataTypes/NodeTypeID.h @@ -1,7 +1,7 @@ #ifndef DATATYPES_NODETYPEID_H #define DATATYPES_NODETYPEID_H -#include +#include "../../ESPEasy_common.h" #define NODE_TYPE_ID_ESP_EASY_STD 1 #define NODE_TYPE_ID_RPI_EASY_STD 5 // https://github.com/enesbcs/rpieasy @@ -12,6 +12,30 @@ #define NODE_TYPE_ID_ARDUINO_EASY_STD 65 #define NODE_TYPE_ID_NANO_EASY_STD 81 + +#if defined(ESP8266) + #define NODE_TYPE_ID NODE_TYPE_ID_ESP_EASYM_STD +#endif + + +#if defined(ESP32) + #ifdef ESP32S2 + #define NODE_TYPE_ID NODE_TYPE_ID_ESP_EASY32S2_STD + #elif defined(ESP32S3) + #define NODE_TYPE_ID NODE_TYPE_ID_ESP_EASY32S3_STD + #elif defined(ESP32C3) + #define NODE_TYPE_ID NODE_TYPE_ID_ESP_EASY32C3_STD + # elif defined(ESP32_CLASSIC) + #define NODE_TYPE_ID NODE_TYPE_ID_ESP_EASY32_STD + # else + + static_assert(false, "Implement processor architecture"); + + #endif +#endif + + + const __FlashStringHelper* toNodeTypeDisplayString(uint8_t nodeType); #endif // ifndef DATATYPES_NODETYPEID_H \ No newline at end of file diff --git a/src/src/DataTypes/NotifierIndex.h b/src/src/DataTypes/NotifierIndex.h index c747ac453..2d3a00830 100644 --- a/src/src/DataTypes/NotifierIndex.h +++ b/src/src/DataTypes/NotifierIndex.h @@ -1,7 +1,7 @@ #ifndef DATATYPES_NOTIFIERINDEX_H #define DATATYPES_NOTIFIERINDEX_H -#include +#include "../../ESPEasy_common.h" typedef uint8_t notifierIndex_t; diff --git a/src/src/DataTypes/PluginID.h b/src/src/DataTypes/PluginID.h index 7e66733c7..a7372ba3a 100644 --- a/src/src/DataTypes/PluginID.h +++ b/src/src/DataTypes/PluginID.h @@ -1,7 +1,7 @@ #ifndef DATATYPES_PLUGINID_H #define DATATYPES_PLUGINID_H -#include +#include "../../ESPEasy_common.h" typedef uint8_t pluginID_t; diff --git a/src/src/DataTypes/ProtocolIndex.h b/src/src/DataTypes/ProtocolIndex.h index accbd429b..d660d5950 100644 --- a/src/src/DataTypes/ProtocolIndex.h +++ b/src/src/DataTypes/ProtocolIndex.h @@ -1,7 +1,7 @@ #ifndef DATATYPES_PROTOCOLINDEX_H #define DATATYPES_PROTOCOLINDEX_H -#include +#include "../../ESPEasy_common.h" typedef uint8_t protocolIndex_t; diff --git a/src/src/DataTypes/SPI_options.h b/src/src/DataTypes/SPI_options.h index 71b767e29..e5d7c31cd 100644 --- a/src/src/DataTypes/SPI_options.h +++ b/src/src/DataTypes/SPI_options.h @@ -1,7 +1,7 @@ #ifndef DATATYPES_SPI_OPTIONS_H #define DATATYPES_SPI_OPTIONS_H -#include +#include "../../ESPEasy_common.h" enum class SPI_Options_e { // Do not change values as this is stored in the settings! None = 0, diff --git a/src/src/DataTypes/TaskIndex.h b/src/src/DataTypes/TaskIndex.h index cefc8f73c..874b5c48e 100644 --- a/src/src/DataTypes/TaskIndex.h +++ b/src/src/DataTypes/TaskIndex.h @@ -1,7 +1,7 @@ #ifndef DATATYPES_TASKINDEX_H #define DATATYPES_TASKINDEX_H -#include +#include "../../ESPEasy_common.h" typedef uint8_t taskIndex_t; typedef uint16_t userVarIndex_t; diff --git a/src/src/DataTypes/TimeSource.h b/src/src/DataTypes/TimeSource.h index 87deaec79..37ea3b1ed 100644 --- a/src/src/DataTypes/TimeSource.h +++ b/src/src/DataTypes/TimeSource.h @@ -1,7 +1,7 @@ #ifndef DATATYPES_TIMESOURCE_H #define DATATYPES_TIMESOURCE_H -#include +#include "../../ESPEasy_common.h" // Do not change order as values are stored in settings enum class ExtTimeSource_e { diff --git a/src/src/DataTypes/WiFiConnectionProtocol.h b/src/src/DataTypes/WiFiConnectionProtocol.h index e73b93bd2..88f715f2b 100644 --- a/src/src/DataTypes/WiFiConnectionProtocol.h +++ b/src/src/DataTypes/WiFiConnectionProtocol.h @@ -1,7 +1,7 @@ #ifndef DATATYPES_WIFICONNECTIONPROTOCOL_H #define DATATYPES_WIFICONNECTIONPROTOCOL_H -#include +#include "../../ESPEasy_common.h" enum class WiFiConnectionProtocol { Unknown, diff --git a/src/src/ESPEasyCore/Controller.cpp b/src/src/ESPEasyCore/Controller.cpp index a3514ca5e..f1960eb44 100644 --- a/src/src/ESPEasyCore/Controller.cpp +++ b/src/src/ESPEasyCore/Controller.cpp @@ -23,13 +23,13 @@ #include "../Globals/MQTT.h" #include "../Globals/Plugins.h" #include "../Globals/Protocol.h" +#include "../Globals/RulesCalculate.h" #include "../Helpers/_CPlugin_Helper.h" #include "../Helpers/Misc.h" #include "../Helpers/Network.h" #include "../Helpers/PeriodicalActions.h" #include "../Helpers/PortStatus.h" -#include "../Helpers/Rules_calculate.h" #define PLUGIN_ID_MQTT_IMPORT 37 diff --git a/src/src/ESPEasyCore/ESPEasyEthEvent.h b/src/src/ESPEasyCore/ESPEasyEthEvent.h index bdecf597f..620f672b1 100644 --- a/src/src/ESPEasyCore/ESPEasyEthEvent.h +++ b/src/src/ESPEasyCore/ESPEasyEthEvent.h @@ -9,9 +9,13 @@ // Make sure not to call anything in these functions that result in delay() or yield() // ******************************************************************************** #ifdef ESP32 - #if ESP_IDF_VERSION_MAJOR > 3 - void EthEvent(WiFiEvent_t event, arduino_event_info_t info); - #endif +#if FEATURE_ETHERNET +#if ESP_IDF_VERSION_MAJOR > 3 +#include +#include +void EthEvent(WiFiEvent_t event, arduino_event_info_t info); +#endif +#endif #endif diff --git a/src/src/ESPEasyCore/ESPEasyNetwork.h b/src/src/ESPEasyCore/ESPEasyNetwork.h index 24b8b5389..0da1e4b61 100644 --- a/src/src/ESPEasyCore/ESPEasyNetwork.h +++ b/src/src/ESPEasyCore/ESPEasyNetwork.h @@ -5,6 +5,8 @@ #include "../DataStructs/MAC_address.h" +#include + void setNetworkMedium(NetworkMedium_t medium); void NetworkConnectRelaxed(); diff --git a/src/src/ESPEasyCore/ESPEasyRules.cpp b/src/src/ESPEasyCore/ESPEasyRules.cpp index 7e4a5247c..b5cc095ed 100644 --- a/src/src/ESPEasyCore/ESPEasyRules.cpp +++ b/src/src/ESPEasyCore/ESPEasyRules.cpp @@ -1,5 +1,7 @@ #include "../ESPEasyCore/ESPEasyRules.h" +#include "../../_Plugin_Helper.h" + #include "../Commands/InternalCommands.h" #include "../DataStructs/TimingStats.h" #include "../DataTypes/EventValueSource.h" @@ -10,21 +12,18 @@ #include "../Globals/EventQueue.h" #include "../Globals/Plugins.h" #include "../Globals/Plugins_other.h" +#include "../Globals/RulesCalculate.h" #include "../Globals/Settings.h" #include "../Helpers/ESPEasy_Storage.h" #include "../Helpers/ESPEasy_time_calc.h" #include "../Helpers/FS_Helper.h" #include "../Helpers/Misc.h" #include "../Helpers/Numerical.h" -#include "../Helpers/Rules_calculate.h" #include "../Helpers/RulesHelper.h" #include "../Helpers/RulesMatcher.h" #include "../Helpers/StringConverter.h" #include "../Helpers/StringParser.h" -#include "../../_Plugin_Helper.h" - - #include #include diff --git a/src/src/ESPEasyCore/ESPEasyWiFiEvent.h b/src/src/ESPEasyCore/ESPEasyWiFiEvent.h index a8c1dc795..3625b215b 100644 --- a/src/src/ESPEasyCore/ESPEasyWiFiEvent.h +++ b/src/src/ESPEasyCore/ESPEasyWiFiEvent.h @@ -13,6 +13,7 @@ #ifdef ESP32 #include #include +#include class WiFi_Access_Static_IP : public WiFiSTAClass { public: @@ -40,6 +41,7 @@ void setUseStaticIP(bool enabled); // ******************************************************************************** #ifdef ESP32 #if ESP_IDF_VERSION_MAJOR > 3 + #include void WiFiEvent(WiFiEvent_t event, arduino_event_info_t info); #else void WiFiEvent(system_event_id_t event, system_event_info_t info); diff --git a/src/src/ESPEasyCore/ESPEasyWifi.cpp b/src/src/ESPEasyCore/ESPEasyWifi.cpp index 99a5432ee..e7e1d43cd 100644 --- a/src/src/ESPEasyCore/ESPEasyWifi.cpp +++ b/src/src/ESPEasyCore/ESPEasyWifi.cpp @@ -25,6 +25,7 @@ #ifdef ESP32 #include +#include // Needed to call ESP-IDF functions like esp_wifi_.... #endif // FIXME TD-er: Cleanup of WiFi code diff --git a/src/src/Globals/C016_ControllerCache.h b/src/src/Globals/C016_ControllerCache.h index 9c74619de..4a51359a4 100644 --- a/src/src/Globals/C016_ControllerCache.h +++ b/src/src/Globals/C016_ControllerCache.h @@ -5,7 +5,6 @@ #ifdef USES_C016 -# include # include "../DataStructs/ESPEasyControllerCache.h" # include "../DataStructs/ESPEasy_EventStruct.h" # include "../DataStructs/DeviceStruct.h" diff --git a/src/src/Globals/ESPEasyWiFiEvent.h b/src/src/Globals/ESPEasyWiFiEvent.h index 157051110..8d83519b8 100644 --- a/src/src/Globals/ESPEasyWiFiEvent.h +++ b/src/src/Globals/ESPEasyWiFiEvent.h @@ -6,7 +6,7 @@ #include "../DataStructs/WiFiEventData.h" -#include + #include #include diff --git a/src/src/Globals/MainLoopCommand.h b/src/src/Globals/MainLoopCommand.h index 1d2caa715..917e26483 100644 --- a/src/src/Globals/MainLoopCommand.h +++ b/src/src/Globals/MainLoopCommand.h @@ -1,7 +1,7 @@ #ifndef GLOBALS_MAINLOOPCOMMAND_H #define GLOBALS_MAINLOOPCOMMAND_H -#include +#include "../../ESPEasy_common.h" extern uint8_t cmd_within_mainloop; diff --git a/src/src/Globals/NPlugins.h b/src/src/Globals/NPlugins.h index 266a684bb..7fe8e1e4d 100644 --- a/src/src/Globals/NPlugins.h +++ b/src/src/Globals/NPlugins.h @@ -14,7 +14,7 @@ #include #include -#include + typedef uint8_t nprotocolIndex_t; diff --git a/src/src/Globals/NetworkState.h b/src/src/Globals/NetworkState.h index ec8aa2174..81101add8 100644 --- a/src/src/Globals/NetworkState.h +++ b/src/src/Globals/NetworkState.h @@ -1,7 +1,7 @@ #ifndef GLOBALS_NETWORKSTATE_H #define GLOBALS_NETWORKSTATE_H -#include +#include "../../ESPEasy_common.h" #include #include diff --git a/src/src/Globals/Plugins.h b/src/src/Globals/Plugins.h index aeae9a3c5..c849d67ec 100644 --- a/src/src/Globals/Plugins.h +++ b/src/src/Globals/Plugins.h @@ -3,14 +3,14 @@ #include "../../ESPEasy_common.h" -#include -#include #include "../CustomBuild/ESPEasyLimits.h" #include "../DataTypes/PluginID.h" #include "../DataTypes/DeviceIndex.h" #include "../DataTypes/TaskIndex.h" +#include +#include /********************************************************************************************\ diff --git a/src/src/Globals/Plugins_other.h b/src/src/Globals/Plugins_other.h index f81949db0..0ef944999 100644 --- a/src/src/Globals/Plugins_other.h +++ b/src/src/Globals/Plugins_other.h @@ -1,7 +1,7 @@ #ifndef GLOBALS_PLUGIN_OTHER_H #define GLOBALS_PLUGIN_OTHER_H -#include +#include "../../ESPEasy_common.h" #include "../CustomBuild/ESPEasyLimits.h" diff --git a/src/src/Globals/Protocol.h b/src/src/Globals/Protocol.h index 87c67582d..807010ee6 100644 --- a/src/src/Globals/Protocol.h +++ b/src/src/Globals/Protocol.h @@ -1,6 +1,8 @@ #ifndef GLOBALS_PROTOCOL_H #define GLOBALS_PROTOCOL_H +#include "../../ESPEasy_common.h" + #include "../DataStructs/ProtocolStruct.h" #include "../CustomBuild/ESPEasyLimits.h" diff --git a/src/src/Globals/RamTracker.h b/src/src/Globals/RamTracker.h index a9dc40f24..1b8223fe2 100644 --- a/src/src/Globals/RamTracker.h +++ b/src/src/Globals/RamTracker.h @@ -5,7 +5,7 @@ #define TRACES 3 // number of memory traces #define TRACEENTRIES 15 // entries per trace -#include + #include "../../ESPEasy_common.h" /********************************************************************************************\ diff --git a/src/src/Globals/RulesCalculate.cpp b/src/src/Globals/RulesCalculate.cpp new file mode 100644 index 000000000..500b378ff --- /dev/null +++ b/src/src/Globals/RulesCalculate.cpp @@ -0,0 +1,90 @@ +#include "../Globals/RulesCalculate.h" + +#include "../DataStructs/TimingStats.h" +#include "../Helpers/Numerical.h" +#include "../Helpers/StringConverter_Numerical.h" + +RulesCalculate_t RulesCalculate{}; + +/******************************************************************************************* +* Helper functions to actually interact with the rules calculation functions. +* *****************************************************************************************/ +int CalculateParam(const String& TmpStr) { + int returnValue = 0; + + // Minimize calls to the Calulate function. + // Only if TmpStr starts with '=' then call Calculate(). Otherwise do not call it + if (TmpStr[0] != '=') { + validIntFromString(TmpStr, returnValue); + } else { + double param = 0; + + // Starts with an '=', so Calculate starting at next position + CalculateReturnCode returnCode = Calculate(TmpStr.substring(1), param); + + if (!isError(returnCode)) { +#ifndef BUILD_NO_DEBUG + + if (loglevelActiveFor(LOG_LEVEL_DEBUG)) { + String log = F("CALCULATE PARAM: "); + log += TmpStr; + log += F(" = "); + log += roundf(param); + addLogMove(LOG_LEVEL_DEBUG, log); + } +#endif // ifndef BUILD_NO_DEBUG + } + returnValue = roundf(param); // return integer only as it's valid only for device and task id + } + return returnValue; +} + +CalculateReturnCode Calculate(const String& input, + double & result) +{ + START_TIMER; + CalculateReturnCode returnCode = RulesCalculate.doCalculate( + RulesCalculate_t::preProces(input).c_str(), + &result); + + if (isError(returnCode)) { + if (loglevelActiveFor(LOG_LEVEL_ERROR)) { + String log = F("Calculate: "); + + switch (returnCode) { + case CalculateReturnCode::ERROR_STACK_OVERFLOW: + log += F("Stack Overflow"); + break; + case CalculateReturnCode::ERROR_BAD_OPERATOR: + log += F("Bad Operator"); + break; + case CalculateReturnCode::ERROR_PARENTHESES_MISMATCHED: + log += F("Parenthesis mismatch"); + break; + case CalculateReturnCode::ERROR_UNKNOWN_TOKEN: + log += F("Unknown token"); + break; + case CalculateReturnCode::ERROR_TOKEN_LENGTH_EXCEEDED: + log += String(F("Exceeded token length (")) + TOKEN_LENGTH + ')'; + break; + case CalculateReturnCode::OK: + // Already handled, but need to have all cases here so the compiler can warn if we're missing one. + break; + } + + #ifndef BUILD_NO_DEBUG + log += F(" input: "); + log += input; + log += F(" = "); + + const bool trimTrailingZeros = true; + log += doubleToString(result, 6, trimTrailingZeros); + #endif // ifndef BUILD_NO_DEBUG + + addLogMove(LOG_LEVEL_ERROR, log); + } + } + STOP_TIMER(COMPUTE_STATS); + return returnCode; +} + diff --git a/src/src/Globals/RulesCalculate.h b/src/src/Globals/RulesCalculate.h new file mode 100644 index 000000000..c802a09bb --- /dev/null +++ b/src/src/Globals/RulesCalculate.h @@ -0,0 +1,27 @@ +#ifndef GLOBALS_RULESCALCULATE_H +#define GLOBALS_RULESCALCULATE_H + +#include "../Helpers/Rules_calculate.h" + +/********************************************************************************************\ + Instance of the RulesCalculate to perform calculations + These functions are wrapped in a class to + - make it more clear what external functions to use + - Make sure generic function names will not cause conflicts + - Prevent external access to calculate only variables. + \*********************************************************************************************/ + +extern RulesCalculate_t RulesCalculate; + +/******************************************************************************************* +* Helper functions to actually interact with the rules calculation functions. +* *****************************************************************************************/ + +int CalculateParam(const String& TmpStr); + +CalculateReturnCode Calculate(const String& input, + double & result); + + + +#endif \ No newline at end of file diff --git a/src/src/Globals/RuntimeData.h b/src/src/Globals/RuntimeData.h index 071e99440..b219db265 100644 --- a/src/src/Globals/RuntimeData.h +++ b/src/src/Globals/RuntimeData.h @@ -1,6 +1,8 @@ #ifndef GLOBALS_RUNTIMEDATA_H #define GLOBALS_RUNTIMEDATA_H +#include "../../ESPEasy_common.h" + #include "../CustomBuild/ESPEasyLimits.h" #include "../DataStructs/UserVarStruct.h" diff --git a/src/src/Globals/Statistics.cpp b/src/src/Globals/Statistics.cpp index 0e1339b0d..54f41fbec 100644 --- a/src/src/Globals/Statistics.cpp +++ b/src/src/Globals/Statistics.cpp @@ -1,6 +1,5 @@ #include "../Globals/Statistics.h" -#include #ifndef BUILD_NO_RAM_TRACKER uint32_t lowestRAM = 0; diff --git a/src/src/Helpers/AdafruitGFX_helper.cpp b/src/src/Helpers/AdafruitGFX_helper.cpp index 7073e1a54..ca8308aef 100644 --- a/src/src/Helpers/AdafruitGFX_helper.cpp +++ b/src/src/Helpers/AdafruitGFX_helper.cpp @@ -5,9 +5,6 @@ # include "../Helpers/StringConverter.h" # include "../WebServer/Markup_Forms.h" -# if FEATURE_SD && defined(ADAGFX_ENABLE_BMP_DISPLAY) -# include -# endif // if FEATURE_SD && defined(ADAGFX_ENABLE_BMP_DISPLAY) # if ADAGFX_FONTS_INCLUDED # include "../Static/Fonts/Seven_Segment24pt7b.h" @@ -67,6 +64,11 @@ # endif // ifdef ADAGFX_FONTS_EXTRA_20PT_INCLUDED # endif // if ADAGFX_FONTS_INCLUDED +# if FEATURE_SD && defined(ADAGFX_ENABLE_BMP_DISPLAY) +# include +# endif // if FEATURE_SD && defined(ADAGFX_ENABLE_BMP_DISPLAY) + + /****************************************************************************************** * get the display text for a 'text print mode' enum value *****************************************************************************************/ diff --git a/src/src/Helpers/AdafruitGFX_helper.h b/src/src/Helpers/AdafruitGFX_helper.h index 88aaa6f2e..0d2ab46ab 100644 --- a/src/src/Helpers/AdafruitGFX_helper.h +++ b/src/src/Helpers/AdafruitGFX_helper.h @@ -38,7 +38,12 @@ * Make 8 and 16 color support optional to squeeze a few bytes from size limited builds * 2022-05-23 tonhuisman: Add changelog, older changes have not been logged. ***************************************************************************/ -# include + +# include "../Helpers/Numerical.h" +# include "../Helpers/ESPEasy_Storage.h" +# include "../ESPEasyCore/ESPEasy_Log.h" + + # include # include # include @@ -47,10 +52,6 @@ // Used for bmp support # define BUFPIXELS 200 ///< 200 * 5 = 1000 bytes -# include "../Helpers/Numerical.h" -# include "../Helpers/ESPEasy_Storage.h" -# include "../ESPEasyCore/ESPEasy_Log.h" - # define ADAGFX_PARSE_MAX_ARGS 7 // Maximum number of arguments needed and supported (corrected) # ifndef ADAGFX_ARGUMENT_VALIDATION # define ADAGFX_ARGUMENT_VALIDATION 1 // Validate command arguments diff --git a/src/src/Helpers/Audio.h b/src/src/Helpers/Audio.h index 5e2cd63a8..297179d3d 100644 --- a/src/src/Helpers/Audio.h +++ b/src/src/Helpers/Audio.h @@ -1,7 +1,6 @@ #ifndef HELPERS_AUDIO_H #define HELPERS_AUDIO_H -#include #include "../../ESPEasy_common.h" diff --git a/src/src/Helpers/CRC_functions.h b/src/src/Helpers/CRC_functions.h index d28287dbe..76a7bebb6 100644 --- a/src/src/Helpers/CRC_functions.h +++ b/src/src/Helpers/CRC_functions.h @@ -1,7 +1,7 @@ #ifndef HELPERS_CRC_FUNCTIONS_H #define HELPERS_CRC_FUNCTIONS_H -#include +#include "../../ESPEasy_common.h" int calc_CRC16(const String& text); diff --git a/src/src/Helpers/Convert.h b/src/src/Helpers/Convert.h index c448c71af..445d9044a 100644 --- a/src/src/Helpers/Convert.h +++ b/src/src/Helpers/Convert.h @@ -1,7 +1,7 @@ #ifndef HELPERS_CONVERT_H #define HELPERS_CONVERT_H -#include +#include "../../ESPEasy_common.h" /*********************************************************************************************\ Convert bearing in degree to bearing string diff --git a/src/src/Helpers/ESPEasyMutex.cpp b/src/src/Helpers/ESPEasyMutex.cpp new file mode 100644 index 000000000..9a1582140 --- /dev/null +++ b/src/src/Helpers/ESPEasyMutex.cpp @@ -0,0 +1,12 @@ +#include "../Helpers/ESPEasyMutex.h" + +#ifdef ESP8266 + + // ESP8266 doesn't have a proper mutex system. + // This is by no means a perfect implementation, but the assembly implementation was causing lots of issues with esp8266/Arduino 3.0.0 + // See: https://github.com/letscontrolit/ESPEasy/issues/3693#issuecomment-868847669 + ESPEasy_Mutex::ESPEasy_Mutex() { + _mutex = 1; + } + +#endif \ No newline at end of file diff --git a/src/src/Helpers/ESPEasyMutex.h b/src/src/Helpers/ESPEasyMutex.h index 927976f72..3f6939a28 100644 --- a/src/src/Helpers/ESPEasyMutex.h +++ b/src/src/Helpers/ESPEasyMutex.h @@ -30,9 +30,7 @@ struct ESPEasy_Mutex { // ESP8266 doesn't have a proper mutex system. // This is by no means a perfect implementation, but the assembly implementation was causing lots of issues with esp8266/Arduino 3.0.0 // See: https://github.com/letscontrolit/ESPEasy/issues/3693#issuecomment-868847669 - ESPEasy_Mutex() { - _mutex = 1; - } + ESPEasy_Mutex(); // May cause deadlock, perhaps add a timeout? void lock() { diff --git a/src/src/Helpers/ESPEasy_math.cpp b/src/src/Helpers/ESPEasy_math.cpp index dc2f27e97..1e87f7594 100644 --- a/src/src/Helpers/ESPEasy_math.cpp +++ b/src/src/Helpers/ESPEasy_math.cpp @@ -1,5 +1,8 @@ #include "../Helpers/ESPEasy_math.h" +#include +// Need to include Arduino.h first, then cmath +// See: https://github.com/esp8266/Arduino/issues/8922#issuecomment-1542301697 #include diff --git a/src/src/Helpers/ESPEasy_time.cpp b/src/src/Helpers/ESPEasy_time.cpp index 1e873e054..f43e9442a 100644 --- a/src/src/Helpers/ESPEasy_time.cpp +++ b/src/src/Helpers/ESPEasy_time.cpp @@ -231,7 +231,7 @@ unsigned long ESPEasy_time::now() { #if FEATURE_EXT_RTC // External RTC only stores with second resolution. // Thus to limit the error to +/- 500 ms, round the sysTime instead of just casting it. - ExtRTC_set(round(sysTime)); + ExtRTC_set(static_cast(sysTime + 0.5)); #endif { const unsigned long abs_time_offset_ms = std::abs(time_offset) * 1000; @@ -242,7 +242,7 @@ unsigned long ESPEasy_time::now() { // offset is less than 1 second, so we consider it a regular time sync. if (abs_time_offset_ms < 100) { // Good clock stability, use 5 - 6 hour interval - syncInterval = random(18000, 21600); + syncInterval = HwRandom(18000, 21600); } else { // Dynamic interval between 30 minutes ... 5 hours. syncInterval = 1800000 / abs_time_offset_ms; @@ -252,7 +252,7 @@ unsigned long ESPEasy_time::now() { } if (syncInterval <= 3600) { - syncInterval = random(3600, 4000); + syncInterval = HwRandom(3600, 4000); } } else if (timeSource == timeSource_t::No_time_source) { syncInterval = 60; @@ -380,16 +380,16 @@ bool ESPEasy_time::getNtpTime(double& unixTime_d) log += Settings.NTPHost; // When single set host fails, retry again in 20 seconds - nextSyncTime = sysTime + random(20, 60); + nextSyncTime = sysTime + HwRandom(20, 60); } else { // Have to do a lookup each time, since the NTP pool always returns another IP - String ntpServerName = String(random(0, 3)); + String ntpServerName = String(HwRandom(0, 3)); ntpServerName += F(".pool.ntp.org"); resolveHostByName(ntpServerName.c_str(), timeServerIP); log += ntpServerName; // When pool host fails, retry can be much sooner - nextSyncTime = sysTime + random(5, 20); + nextSyncTime = sysTime + HwRandom(5, 20); useNTPpool = true; } diff --git a/src/src/Helpers/ESPEasy_time.h b/src/src/Helpers/ESPEasy_time.h index b66ba21c7..e2f32376b 100644 --- a/src/src/Helpers/ESPEasy_time.h +++ b/src/src/Helpers/ESPEasy_time.h @@ -3,8 +3,6 @@ #include "../../ESPEasy_common.h" -#include - #include "../DataTypes/ESPEasyTimeSource.h" #include diff --git a/src/src/Helpers/ESPEasy_time_calc.cpp b/src/src/Helpers/ESPEasy_time_calc.cpp index ecd81a7ef..c6c2e4840 100644 --- a/src/src/Helpers/ESPEasy_time_calc.cpp +++ b/src/src/Helpers/ESPEasy_time_calc.cpp @@ -1,6 +1,6 @@ #include "../Helpers/ESPEasy_time_calc.h" -#include + #include #include "../Globals/ESPEasy_time.h" diff --git a/src/src/Helpers/ESPEasy_time_calc.h b/src/src/Helpers/ESPEasy_time_calc.h index d71fbfc46..03cad2433 100644 --- a/src/src/Helpers/ESPEasy_time_calc.h +++ b/src/src/Helpers/ESPEasy_time_calc.h @@ -1,8 +1,7 @@ #ifndef HELPERS_ESPEASY_TIME_CALC_H #define HELPERS_ESPEASY_TIME_CALC_H -#include - +#include "../../ESPEasy_common.h" inline uint64_t getMicros64() { #ifdef ESP8266 diff --git a/src/src/Helpers/ESPEasy_time_zone.h b/src/src/Helpers/ESPEasy_time_zone.h index 237c7366f..3ff835bec 100644 --- a/src/src/Helpers/ESPEasy_time_zone.h +++ b/src/src/Helpers/ESPEasy_time_zone.h @@ -1,7 +1,7 @@ #ifndef HELPERS_ESPEASY_TIME_ZONE_H #define HELPERS_ESPEASY_TIME_ZONE_H -#include +#include "../../ESPEasy_common.h" #include "../DataStructs/TimeChangeRule.h" diff --git a/src/src/Helpers/FS_Helper.h b/src/src/Helpers/FS_Helper.h index 4d491ae63..f6d227802 100644 --- a/src/src/Helpers/FS_Helper.h +++ b/src/src/Helpers/FS_Helper.h @@ -1,7 +1,6 @@ #ifndef HELPERS_SPIFFS_HELPER_H #define HELPERS_SPIFFS_HELPER_H -#include #include "../../ESPEasy_common.h" diff --git a/src/src/Helpers/Hardware.cpp b/src/src/Helpers/Hardware.cpp index 8fe6d4109..b55beee92 100644 --- a/src/src/Helpers/Hardware.cpp +++ b/src/src/Helpers/Hardware.cpp @@ -37,20 +37,35 @@ # include # if ESP_IDF_VERSION_MAJOR > 3 // IDF 4+ - # if CONFIG_IDF_TARGET_ESP32S2 // ESP32-S2 + # if CONFIG_IDF_TARGET_ESP32S3 // ESP32-S3 + # include + # include + # include + + # define HAS_HALL_EFFECT_SENSOR 0 + # elif CONFIG_IDF_TARGET_ESP32S2 // ESP32-S2 # include # include + # include + + # define HAS_HALL_EFFECT_SENSOR 0 # elif CONFIG_IDF_TARGET_ESP32C3 // ESP32-C3 # include - # include + # include + + # define HAS_HALL_EFFECT_SENSOR 0 + # define HAS_TOUCH_GPIO 0 # elif CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4 # include # include - # else // if CONFIG_IDF_TARGET_ESP32S2 + # include + + # else # error Target CONFIG_IDF_TARGET is not supported - # endif // if CONFIG_IDF_TARGET_ESP32S2 + # endif # else // ESP32 Before IDF 4.0 # include + # include # endif // if ESP_IDF_VERSION_MAJOR > 3 #endif // ifdef ESP32 @@ -1116,6 +1131,21 @@ uint32_t HwRandom() { #undef _RAND_ADDR } +long HwRandom(long howbig) { + if(howbig == 0) { + return 0; + } + return HwRandom() % howbig; +} + +long HwRandom(long howsmall, long howbig) { + if(howsmall >= howbig) { + return howsmall; + } + long diff = howbig - howsmall; + return HwRandom(diff) + howsmall; +} + #ifdef ESP8266 void readBootCause() { lastBootCause = BOOT_CAUSE_MANUAL_REBOOT; diff --git a/src/src/Helpers/Hardware.h b/src/src/Helpers/Hardware.h index 47fd0af65..bdab0bb9d 100644 --- a/src/src/Helpers/Hardware.h +++ b/src/src/Helpers/Hardware.h @@ -3,8 +3,6 @@ #include "../../ESPEasy_common.h" -#include - #include "../DataStructs/GpioFactorySettingsStruct.h" #include "../DataStructs/PinMode.h" #include "../DataTypes/DeviceModel.h" @@ -169,6 +167,10 @@ bool CanUsePSRAM(); // Based on code from https://raw.githubusercontent.com/espressif/esp-idf/master/components/esp32/hw_random.c uint32_t HwRandom(); +long HwRandom(long howbig); + +long HwRandom(long howsmall, long howbig); + /********************************************************************************************\ Boot information diff --git a/src/src/Helpers/I2C_Plugin_Helper.h b/src/src/Helpers/I2C_Plugin_Helper.h index 601e84c4b..55b3a81e4 100644 --- a/src/src/Helpers/I2C_Plugin_Helper.h +++ b/src/src/Helpers/I2C_Plugin_Helper.h @@ -1,7 +1,6 @@ #ifndef _SRC_HELPERS_I2C_PLUGIN_HELPER_H #define _SRC_HELPERS_I2C_PLUGIN_HELPER_H -#include #include "../../ESPEasy_common.h" diff --git a/src/src/Helpers/LongTermTimer.h b/src/src/Helpers/LongTermTimer.h index ca8842592..9922881e7 100644 --- a/src/src/Helpers/LongTermTimer.h +++ b/src/src/Helpers/LongTermTimer.h @@ -1,7 +1,7 @@ #ifndef HELPERS_LONGTERMTIMER_H #define HELPERS_LONGTERMTIMER_H -#include +#include "../../ESPEasy_common.h" #include "../Helpers/ESPEasy_time_calc.h" diff --git a/src/src/Helpers/Memory.h b/src/src/Helpers/Memory.h index c01a75de7..6bc37e03a 100644 --- a/src/src/Helpers/Memory.h +++ b/src/src/Helpers/Memory.h @@ -1,7 +1,6 @@ #ifndef HELPERS_MEMORY_H #define HELPERS_MEMORY_H -#include #include "../../ESPEasy_common.h" diff --git a/src/src/Helpers/Misc.h b/src/src/Helpers/Misc.h index c11b38570..2b997272c 100644 --- a/src/src/Helpers/Misc.h +++ b/src/src/Helpers/Misc.h @@ -3,8 +3,6 @@ #include "../../ESPEasy_common.h" -#include - #include "../DataStructs/PinMode.h" #include "../DataTypes/ControllerIndex.h" #include "../DataTypes/TaskIndex.h" diff --git a/src/src/Helpers/Modbus_RTU.h b/src/src/Helpers/Modbus_RTU.h index eb727f75e..f60fdfd97 100644 --- a/src/src/Helpers/Modbus_RTU.h +++ b/src/src/Helpers/Modbus_RTU.h @@ -2,7 +2,7 @@ #define HELPERS_MODBUS_RTU_H -#include +#include "../../ESPEasy_common.h" #include diff --git a/src/src/Helpers/Networking.cpp b/src/src/Helpers/Networking.cpp index 958f06390..12a6489fb 100644 --- a/src/src/Helpers/Networking.cpp +++ b/src/src/Helpers/Networking.cpp @@ -25,6 +25,7 @@ #include "../Globals/Settings.h" #include "../Helpers/ESPEasy_Storage.h" #include "../Helpers/ESPEasy_time_calc.h" +#include "../Helpers/Hardware.h" #include "../Helpers/Misc.h" #include "../Helpers/Network.h" #include "../Helpers/Numerical.h" @@ -37,6 +38,8 @@ #include #include // for getDigestAuth +#include + #include // Generic Networking routines @@ -52,6 +55,12 @@ #include +#ifdef ESP8266 +#include +#include +#include +#include +#endif #ifdef SUPPORT_ARP # include @@ -813,7 +822,7 @@ void SSDP_update() { } break; case MX: - _delay = random(0, atoi(buffer)) * 1000L; + _delay = HwRandom(0, atoi(buffer)) * 1000L; break; } @@ -1144,7 +1153,7 @@ bool beginWiFiUDP_randomPort(WiFiUDP& udp) { while (attempts > 0) { --attempts; - long port = random(1025, 65535); + long port = HwRandom(1025, 65535); if (udp.begin(port) != 0) { return true; diff --git a/src/src/Helpers/Networking.h b/src/src/Helpers/Networking.h index 4002edcc5..e7c644bb4 100644 --- a/src/src/Helpers/Networking.h +++ b/src/src/Helpers/Networking.h @@ -3,7 +3,7 @@ #include "../../ESPEasy_common.h" -#include + #include #include diff --git a/src/src/Helpers/Numerical.h b/src/src/Helpers/Numerical.h index f9b65abe4..72182da8c 100644 --- a/src/src/Helpers/Numerical.h +++ b/src/src/Helpers/Numerical.h @@ -1,7 +1,7 @@ #ifndef HELPERS_NUMERICAL_H #define HELPERS_NUMERICAL_H -#include +#include "../../ESPEasy_common.h" /********************************************************************************************\ Check if string is valid float diff --git a/src/src/Helpers/OTA.cpp b/src/src/Helpers/OTA.cpp index 3f26b404b..e28e0101d 100644 --- a/src/src/Helpers/OTA.cpp +++ b/src/src/Helpers/OTA.cpp @@ -16,9 +16,23 @@ #endif +#ifndef ARDUINO_OTA_PORT + #if defined(ESP32) + #define ARDUINO_OTA_PORT 3232 + #else + // Do not use port 8266 for OTA, since that's used for ESPeasy p2p + #define ARDUINO_OTA_PORT 18266 + #endif +#endif + + bool OTA_possible(uint32_t& maxSketchSize, bool& use2step) { #if defined(ESP8266) + #define SMALLEST_OTA_IMAGE 276848 // smallest known 2-step OTA image + #define MAX_SKETCH_SIZE 1044464 // 1020 kB - 16 bytes + + // Compute the current free space and sketch size, rounded to 4k blocks. // These block bounaries are needed for erasing a full block on flash. const uint32_t freeSketchSpace = (getFreeSketchSpace() - 0x1000) & 0xFFFFF000; diff --git a/src/src/Helpers/PortStatus.h b/src/src/Helpers/PortStatus.h index eeba29743..7daebcedf 100644 --- a/src/src/Helpers/PortStatus.h +++ b/src/src/Helpers/PortStatus.h @@ -1,7 +1,7 @@ #ifndef HELPERS_PORTSTATUS_H #define HELPERS_PORTSTATUS_H -#include +#include "../../ESPEasy_common.h" #include "../DataStructs/PortStatusStruct.h" #include "../Globals/Plugins.h" diff --git a/src/src/Helpers/Rules_calculate.cpp b/src/src/Helpers/Rules_calculate.cpp index c7342d571..290d249d0 100644 --- a/src/src/Helpers/Rules_calculate.cpp +++ b/src/src/Helpers/Rules_calculate.cpp @@ -1,7 +1,5 @@ #include "../Helpers/Rules_calculate.h" -#include - #include "../DataStructs/TimingStats.h" #include "../ESPEasyCore/ESPEasy_Log.h" #include "../Globals/RamTracker.h" @@ -16,16 +14,6 @@ RulesCalculate_t::RulesCalculate_t() { } } -/********************************************************************************************\ - Instance of the RulesCalculate to perform calculations - These functions are wrapped in a class to - - make it more clear what external functions to use - - Make sure generic function names will not cause conflicts - - Prevent external access to calculate only variables. - \*********************************************************************************************/ -RulesCalculate_t RulesCalculate; - - /********************************************************************************************\ Calculate function for simple expressions \*********************************************************************************************/ @@ -116,7 +104,7 @@ double RulesCalculate_t::apply_operator(char op, double first, double second) case '/': return first / second; case '%': - return static_cast(round(first)) % static_cast(round(second)); + return static_cast(roundf(first)) % static_cast(roundf(second)); case '^': return pow(first, second); default: @@ -131,7 +119,7 @@ double RulesCalculate_t::apply_unary_operator(char op, double first) switch (un_op) { case UnaryOperator::Not: - return (approximatelyEqual(round(first), 0)) ? 1 : 0; + return essentiallyZero(roundf(first)) ? 1.0 : 0.0; case UnaryOperator::Log: return log10(first); case UnaryOperator::Ln: @@ -145,7 +133,7 @@ double RulesCalculate_t::apply_unary_operator(char op, double first) case UnaryOperator::Sq: return first * first; case UnaryOperator::Round: - return round(first); + return roundf(first); default: break; } @@ -309,8 +297,7 @@ unsigned int RulesCalculate_t::op_arg_count(const char c) CalculateReturnCode RulesCalculate_t::doCalculate(const char *input, double *result) { - #define TOKEN_LENGTH 25 - #define OPERATOR_STACK_SIZE 32 + #ifndef BUILD_NO_RAM_TRACKER checkRAM(F("Calculate")); #endif // ifndef BUILD_NO_RAM_TRACKER @@ -614,84 +601,3 @@ String RulesCalculate_t::preProces(const String& input) return preprocessed; } -/******************************************************************************************* -* Helper functions to actually interact with the rules calculation functions. -* *****************************************************************************************/ -int CalculateParam(const String& TmpStr) { - int returnValue = 0; - - // Minimize calls to the Calulate function. - // Only if TmpStr starts with '=' then call Calculate(). Otherwise do not call it - if (TmpStr[0] != '=') { - validIntFromString(TmpStr, returnValue); - } else { - double param = 0; - - // Starts with an '=', so Calculate starting at next position - CalculateReturnCode returnCode = Calculate(TmpStr.substring(1), param); - - if (!isError(returnCode)) { -#ifndef BUILD_NO_DEBUG - - if (loglevelActiveFor(LOG_LEVEL_DEBUG)) { - String log = F("CALCULATE PARAM: "); - log += TmpStr; - log += F(" = "); - log += round(param); - addLogMove(LOG_LEVEL_DEBUG, log); - } -#endif // ifndef BUILD_NO_DEBUG - } - returnValue = round(param); // return integer only as it's valid only for device and task id - } - return returnValue; -} - -CalculateReturnCode Calculate(const String& input, - double & result) -{ - START_TIMER; - CalculateReturnCode returnCode = RulesCalculate.doCalculate( - RulesCalculate_t::preProces(input).c_str(), - &result); - - if (isError(returnCode)) { - if (loglevelActiveFor(LOG_LEVEL_ERROR)) { - String log = F("Calculate: "); - - switch (returnCode) { - case CalculateReturnCode::ERROR_STACK_OVERFLOW: - log += F("Stack Overflow"); - break; - case CalculateReturnCode::ERROR_BAD_OPERATOR: - log += F("Bad Operator"); - break; - case CalculateReturnCode::ERROR_PARENTHESES_MISMATCHED: - log += F("Parenthesis mismatch"); - break; - case CalculateReturnCode::ERROR_UNKNOWN_TOKEN: - log += F("Unknown token"); - break; - case CalculateReturnCode::ERROR_TOKEN_LENGTH_EXCEEDED: - log += String(F("Exceeded token length (")) + TOKEN_LENGTH + ')'; - break; - case CalculateReturnCode::OK: - // Already handled, but need to have all cases here so the compiler can warn if we're missing one. - break; - } - - #ifndef BUILD_NO_DEBUG - log += F(" input: "); - log += input; - log += F(" = "); - - const bool trimTrailingZeros = true; - log += doubleToString(result, 6, trimTrailingZeros); - #endif // ifndef BUILD_NO_DEBUG - - addLogMove(LOG_LEVEL_ERROR, log); - } - } - STOP_TIMER(COMPUTE_STATS); - return returnCode; -} diff --git a/src/src/Helpers/Rules_calculate.h b/src/src/Helpers/Rules_calculate.h index 1a6482dcd..1ac7a7a40 100644 --- a/src/src/Helpers/Rules_calculate.h +++ b/src/src/Helpers/Rules_calculate.h @@ -10,6 +10,9 @@ #define STACK_SIZE 10 // was 50 #define TOKEN_MAX 20 +#define TOKEN_LENGTH 25 +#define OPERATOR_STACK_SIZE 32 + enum class CalculateReturnCode : uint8_t{ OK = 0u, ERROR_STACK_OVERFLOW = 1u, @@ -57,7 +60,7 @@ const __FlashStringHelper* toString(UnaryOperator op); class RulesCalculate_t { private: - double globalstack[STACK_SIZE]; + double globalstack[STACK_SIZE]{}; double *sp = globalstack - 1; const double *sp_max = &globalstack[STACK_SIZE - 1]; @@ -109,16 +112,6 @@ public: static String preProces(const String& input); }; -extern RulesCalculate_t RulesCalculate; - -/******************************************************************************************* -* Helper functions to actually interact with the rules calculation functions. -* *****************************************************************************************/ - -int CalculateParam(const String& TmpStr); - -CalculateReturnCode Calculate(const String& input, - double & result); #endif // ifndef HELPERS_RULES_CALCULATE_H diff --git a/src/src/Helpers/StringConverter.h b/src/src/Helpers/StringConverter.h index 0522ffe3b..cfef169f9 100644 --- a/src/src/Helpers/StringConverter.h +++ b/src/src/Helpers/StringConverter.h @@ -3,8 +3,6 @@ #include "../../ESPEasy_common.h" -#include - #include "../Globals/Plugins.h" #include "../Globals/CPlugins.h" diff --git a/src/src/Helpers/StringConverter_Numerical.h b/src/src/Helpers/StringConverter_Numerical.h index 4713a076d..8d2bd4eb6 100644 --- a/src/src/Helpers/StringConverter_Numerical.h +++ b/src/src/Helpers/StringConverter_Numerical.h @@ -1,7 +1,7 @@ #ifndef HELPERS_STRINGCONVERTER_NUMERICAL_H #define HELPERS_STRINGCONVERTER_NUMERICAL_H -#include +#include "../../ESPEasy_common.h" /********************************************************************************************\ Convert a char string to integer diff --git a/src/src/Helpers/StringGenerator_GPIO.h b/src/src/Helpers/StringGenerator_GPIO.h index 5e3f5b088..dc5955b7a 100644 --- a/src/src/Helpers/StringGenerator_GPIO.h +++ b/src/src/Helpers/StringGenerator_GPIO.h @@ -1,7 +1,6 @@ #ifndef HELPERS_STRINGGENERATOR_GPIO_H #define HELPERS_STRINGGENERATOR_GPIO_H -#include #include "../../ESPEasy_common.h" diff --git a/src/src/Helpers/StringGenerator_Plugin.h b/src/src/Helpers/StringGenerator_Plugin.h index 129bac6de..481af214c 100644 --- a/src/src/Helpers/StringGenerator_Plugin.h +++ b/src/src/Helpers/StringGenerator_Plugin.h @@ -1,7 +1,7 @@ #ifndef HELPERS_STRINGGENERATOR_PLUGIN_H #define HELPERS_STRINGGENERATOR_PLUGIN_H -#include +#include "../../ESPEasy_common.h" // Generate string with appending nr (when > 0) diff --git a/src/src/Helpers/StringGenerator_System.cpp b/src/src/Helpers/StringGenerator_System.cpp index 3b30003e8..dbdf9cf36 100644 --- a/src/src/Helpers/StringGenerator_System.cpp +++ b/src/src/Helpers/StringGenerator_System.cpp @@ -9,6 +9,26 @@ #include "../CustomBuild/CompiletimeDefines.h" +#if defined(ESP32) + #ifdef ESP32S2 + #include + #elif defined(ESP32S3) + #include + #elif defined(ESP32C3) + #include + # elif defined(ESP32_CLASSIC) + #if ESP_IDF_VERSION_MAJOR > 3 + #include + #else + #include + #endif + # else + + static_assert(false, "Implement processor architecture"); + + #endif +#endif + #if FEATURE_MQTT //#include diff --git a/src/src/Helpers/StringGenerator_WiFi.cpp b/src/src/Helpers/StringGenerator_WiFi.cpp index 4b67089fa..f4a3afe80 100644 --- a/src/src/Helpers/StringGenerator_WiFi.cpp +++ b/src/src/Helpers/StringGenerator_WiFi.cpp @@ -4,6 +4,10 @@ #include "../Globals/ESPEasyWiFiEvent.h" +#ifdef ESP8266 +#include +#endif + const __FlashStringHelper * WiFi_encryptionType(uint8_t encryptionType) { switch (encryptionType) { #ifdef ESP32 diff --git a/src/src/Helpers/StringParser.cpp b/src/src/Helpers/StringParser.cpp index 890c58863..35f60723d 100644 --- a/src/src/Helpers/StringParser.cpp +++ b/src/src/Helpers/StringParser.cpp @@ -1,7 +1,5 @@ #include "../Helpers/StringParser.h" -#include "../../ESPEasy_common.h" - #include "../../_Plugin_Helper.h" #include "../Commands/GPIO.h" @@ -13,17 +11,17 @@ #include "../Globals/Cache.h" #include "../Globals/Plugins_other.h" #include "../Globals/Protocol.h" +#include "../Globals/RulesCalculate.h" #include "../Globals/RuntimeData.h" #include "../Helpers/ESPEasy_math.h" #include "../Helpers/ESPEasy_Storage.h" #include "../Helpers/Misc.h" #include "../Helpers/Numerical.h" -#include "../Helpers/Rules_calculate.h" #include "../Helpers/StringConverter.h" #include "../Helpers/StringGenerator_GPIO.h" -#include + /********************************************************************************************\ Parse string template diff --git a/src/src/Helpers/StringParser.h b/src/src/Helpers/StringParser.h index ce6e39635..4334d9f49 100644 --- a/src/src/Helpers/StringParser.h +++ b/src/src/Helpers/StringParser.h @@ -3,8 +3,6 @@ #include "../../ESPEasy_common.h" -#include - #include "../Globals/Plugins.h" /********************************************************************************************\ diff --git a/src/src/Helpers/SystemVariables.h b/src/src/Helpers/SystemVariables.h index 12d57bb95..d1965a78a 100644 --- a/src/src/Helpers/SystemVariables.h +++ b/src/src/Helpers/SystemVariables.h @@ -1,8 +1,6 @@ #ifndef HELPERS_SYSTEMVARIABLES_H #define HELPERS_SYSTEMVARIABLES_H -#include - #include "../../ESPEasy_common.h" class SystemVariables { diff --git a/src/src/Helpers/_CPlugin_Helper_webform.h b/src/src/Helpers/_CPlugin_Helper_webform.h index faa17ad86..76bb5398a 100644 --- a/src/src/Helpers/_CPlugin_Helper_webform.h +++ b/src/src/Helpers/_CPlugin_Helper_webform.h @@ -1,7 +1,7 @@ #ifndef HELPERS__CPLUGIN_HELPER_WEBFORM_H #define HELPERS__CPLUGIN_HELPER_WEBFORM_H -#include +#include "../../ESPEasy_common.h" #include "../DataStructs/ControllerSettingsStruct.h" #include "../Globals/CPlugins.h" diff --git a/src/src/Helpers/_CPlugin_init.h b/src/src/Helpers/_CPlugin_init.h index bf7b1d6f9..200a6ddf1 100644 --- a/src/src/Helpers/_CPlugin_init.h +++ b/src/src/Helpers/_CPlugin_init.h @@ -5,7 +5,6 @@ #include "../DataTypes/ESPEasy_plugin_functions.h" -#include struct EventStruct; diff --git a/src/src/Helpers/_Internal_GPIO_pulseHelper.cpp b/src/src/Helpers/_Internal_GPIO_pulseHelper.cpp index 9383283b0..864c370a3 100644 --- a/src/src/Helpers/_Internal_GPIO_pulseHelper.cpp +++ b/src/src/Helpers/_Internal_GPIO_pulseHelper.cpp @@ -9,7 +9,6 @@ #include "../../ESPEasy_common.h" -#include #include diff --git a/src/src/Helpers/_NPlugin_init.h b/src/src/Helpers/_NPlugin_init.h index 2fc641384..12fbf442c 100644 --- a/src/src/Helpers/_NPlugin_init.h +++ b/src/src/Helpers/_NPlugin_init.h @@ -7,8 +7,6 @@ #include "../DataTypes/ESPEasy_plugin_functions.h" -#include - struct EventStruct; diff --git a/src/src/Helpers/_Plugin_Helper_serial.cpp b/src/src/Helpers/_Plugin_Helper_serial.cpp index 0a2864adb..10336e2bc 100644 --- a/src/src/Helpers/_Plugin_Helper_serial.cpp +++ b/src/src/Helpers/_Plugin_Helper_serial.cpp @@ -191,7 +191,7 @@ void serialHelper_webformLoad(ESPEasySerialPort port, int rxPinDef, int txPinDef String options[NR_ESPEASY_SERIAL_TYPES]; int ids[NR_ESPEASY_SERIAL_TYPES]; - String attr[NR_ESPEASY_SERIAL_TYPES]; +// String attr[NR_ESPEASY_SERIAL_TYPES]; #ifndef DISABLE_SC16IS752_Serial int index = NR_ESPEASY_SERIAL_TYPES - 1; // Place I2C Serial at the end @@ -212,9 +212,11 @@ void serialHelper_webformLoad(ESPEasySerialPort port, int rxPinDef, int txPinDef #ifndef DISABLE_SOFTWARE_SERIAL case ESPEasySerialPort::software: { + /* if (!allowSoftwareSerial) { attr[index] = F("disabled"); } + */ break; } #endif // ifndef DISABLE_SOFTWARE_SERIAL diff --git a/src/src/Helpers/_Plugin_Helper_webform.h b/src/src/Helpers/_Plugin_Helper_webform.h index bcb081a90..4ee3ea7c1 100644 --- a/src/src/Helpers/_Plugin_Helper_webform.h +++ b/src/src/Helpers/_Plugin_Helper_webform.h @@ -3,7 +3,7 @@ #include "../Globals/Plugins.h" -#include +#include "../../ESPEasy_common.h" #define SWITCH_DOUBLECLICK_MIN_INTERVAL 1000 #define SWITCH_LONGPRESS_MIN_INTERVAL 500 diff --git a/src/src/Helpers/_Plugin_SensorTypeHelper.h b/src/src/Helpers/_Plugin_SensorTypeHelper.h index b4a1add1e..165322c26 100644 --- a/src/src/Helpers/_Plugin_SensorTypeHelper.h +++ b/src/src/Helpers/_Plugin_SensorTypeHelper.h @@ -1,7 +1,7 @@ #ifndef HELPER_CPLUGIN_SENSORTYPEHELPER_H #define HELPER_CPLUGIN_SENSORTYPEHELPER_H -#include +#include "../../ESPEasy_common.h" #include "../DataStructs/DeviceStruct.h" diff --git a/src/src/Helpers/_Plugin_init.h b/src/src/Helpers/_Plugin_init.h index aafc3b31c..739d0a5b0 100644 --- a/src/src/Helpers/_Plugin_init.h +++ b/src/src/Helpers/_Plugin_init.h @@ -6,8 +6,6 @@ #include "../DataTypes/ESPEasy_plugin_functions.h" -#include - struct EventStruct; diff --git a/src/src/Helpers/msecTimerHandlerStruct.cpp b/src/src/Helpers/msecTimerHandlerStruct.cpp index 4e2d501b5..e3f6ce1d5 100644 --- a/src/src/Helpers/msecTimerHandlerStruct.cpp +++ b/src/src/Helpers/msecTimerHandlerStruct.cpp @@ -1,6 +1,5 @@ #include "../Helpers/msecTimerHandlerStruct.h" -#include #include "../Helpers/ESPEasy_time_calc.h" diff --git a/src/src/Helpers/msecTimerHandlerStruct.h b/src/src/Helpers/msecTimerHandlerStruct.h index 67e3326fb..6897a7110 100644 --- a/src/src/Helpers/msecTimerHandlerStruct.h +++ b/src/src/Helpers/msecTimerHandlerStruct.h @@ -2,7 +2,7 @@ #define HELPERS_MSECTIMERHANDLERSTRUCT_H -#include +#include "../../ESPEasy_common.h" #include #include "../DataStructs/timer_id_couple.h" diff --git a/src/src/PluginStructs/P002_data_struct.cpp b/src/src/PluginStructs/P002_data_struct.cpp index 47195d7c7..8af936bc0 100644 --- a/src/src/PluginStructs/P002_data_struct.cpp +++ b/src/src/PluginStructs/P002_data_struct.cpp @@ -2,7 +2,7 @@ #ifdef USES_P002 -# include "../Helpers/Rules_calculate.h" +# include "../Globals/RulesCalculate.h" # ifndef DEFAULT_VREF diff --git a/src/src/PluginStructs/P036_data_struct.cpp b/src/src/PluginStructs/P036_data_struct.cpp index 7a9ed74c5..418b76ac1 100644 --- a/src/src/PluginStructs/P036_data_struct.cpp +++ b/src/src/PluginStructs/P036_data_struct.cpp @@ -2,8 +2,6 @@ #ifdef USES_P036 -# include - # include "../ESPEasyCore/ESPEasyNetwork.h" # include "../Globals/RTC.h" # include "../Helpers/ESPEasy_Storage.h" diff --git a/src/src/PluginStructs/P042_data_struct.cpp b/src/src/PluginStructs/P042_data_struct.cpp index 7152d6343..d44f168dd 100644 --- a/src/src/PluginStructs/P042_data_struct.cpp +++ b/src/src/PluginStructs/P042_data_struct.cpp @@ -98,7 +98,7 @@ bool P042_data_struct::plugin_fifty_per_second(struct EventStruct *event) { if (Candle_type == P042_SimType::TypeStaticLight) { type_Advanced_Candle(); } - Candle_Update = millis() + random(25, 150); + Candle_Update = millis() + HwRandom(25, 150); } break; } @@ -273,7 +273,7 @@ void P042_data_struct::type_Simple_Candle() { // Flicker, based on our initial RGB values for (int i = 0; i < Candle_pxlcnt; i++) { - int flicker = random(0, P042_RANDOM_PIXEL); + int flicker = HwRandom(0, P042_RANDOM_PIXEL); int r1 = r - flicker; int g1 = g - flicker; int b1 = b - flicker; @@ -288,9 +288,9 @@ void P042_data_struct::type_Simple_Candle() { } void P042_data_struct::type_Advanced_Candle() { - Candle_Temp[0] = random(1, 4); // 1..4 LEDs in RED - Candle_Temp[1] = random(1, 4) + Candle_Temp[0]; // 1..3 LEDs in Yellow / Orange - Candle_Temp[2] = random(0, 2); // 0..1 Choose Yellow = 0 / Orange = 1 + Candle_Temp[0] = HwRandom(1, 4); // 1..4 LEDs in RED + Candle_Temp[1] = HwRandom(1, 4) + Candle_Temp[0]; // 1..3 LEDs in Yellow / Orange + Candle_Temp[2] = HwRandom(0, 2); // 0..1 Choose Yellow = 0 / Orange = 1 int colorbase[3]; int color1[3]; diff --git a/src/src/PluginStructs/P079_data_struct.h b/src/src/PluginStructs/P079_data_struct.h index b0bd05313..1589876a8 100644 --- a/src/src/PluginStructs/P079_data_struct.h +++ b/src/src/PluginStructs/P079_data_struct.h @@ -9,12 +9,6 @@ # define PRODUCT_ID_I2C_LOLIN 0x02 -# if (ARDUINO >= 100) - # include "Arduino.h" -# else // if (ARDUINO >= 100) - # include "WProgram.h" -# endif // if (ARDUINO >= 100) - # include "Wire.h" # define P079_MOTOR_A 0 diff --git a/src/src/PluginStructs/P089_data_struct.cpp b/src/src/PluginStructs/P089_data_struct.cpp index b5e282326..940d0cd03 100644 --- a/src/src/PluginStructs/P089_data_struct.cpp +++ b/src/src/PluginStructs/P089_data_struct.cpp @@ -59,7 +59,7 @@ bool P089_data_struct::send_ping(struct EventStruct *event) { destIPAddress.addr = ip; /* Generate random ID & seq */ - idseq = random(UINT32_MAX); + idseq = HwRandom(); u16_t ping_len = ICMP_PAYLOAD_LEN + sizeof(struct icmp_echo_hdr); struct pbuf *packetBuffer = pbuf_alloc(PBUF_IP, ping_len, PBUF_RAM); diff --git a/src/src/PluginStructs/P092_data_struct.h b/src/src/PluginStructs/P092_data_struct.h index 371bf50a0..81030b660 100644 --- a/src/src/PluginStructs/P092_data_struct.h +++ b/src/src/PluginStructs/P092_data_struct.h @@ -5,8 +5,6 @@ #ifdef USES_P092 -#include - # ifdef LIMIT_BUILD_SIZE # define P092_LIMIT_BUILD_SIZE # endif // ifdef LIMIT_BUILD_SIZE diff --git a/src/src/PluginStructs/P103_data_struct.h b/src/src/PluginStructs/P103_data_struct.h index 82fe037ff..f615e3896 100644 --- a/src/src/PluginStructs/P103_data_struct.h +++ b/src/src/PluginStructs/P103_data_struct.h @@ -6,7 +6,7 @@ #ifdef USES_P103 -# include "src/Helpers/Rules_calculate.h" +# include "../Globals/RulesCalculate.h" enum class AtlasEZO_Sensors_e : uint8_t { UNKNOWN = 0u, diff --git a/src/src/PluginStructs/P118_data_struct.h b/src/src/PluginStructs/P118_data_struct.h index 6bf1da730..ea2b9ddd6 100644 --- a/src/src/PluginStructs/P118_data_struct.h +++ b/src/src/PluginStructs/P118_data_struct.h @@ -6,7 +6,6 @@ # include "../../ESPEasy-Globals.h" -# include # include "IthoCC1101.h" # include "IthoPacket.h" diff --git a/src/src/PluginStructs/P128_data_struct.cpp b/src/src/PluginStructs/P128_data_struct.cpp index 58f6ac73e..e90f97cf3 100644 --- a/src/src/PluginStructs/P128_data_struct.cpp +++ b/src/src/PluginStructs/P128_data_struct.cpp @@ -476,7 +476,7 @@ bool P128_data_struct::plugin_write(struct EventStruct *event, _counter_mode_step = 0; randomSeed(analogRead(A0)); - pixelNum = random(NUMPixels); // Begin at random point + pixelNum = HwRandom(NUMPixels); // Begin at random point startpixel = str3.isEmpty() ? 0 @@ -914,10 +914,10 @@ void P128_data_struct::faketv(void) { ftv_ng = (uint8_t)pgm_read_byte(&ftv_gamma8[ftv_g8]) * 257; ftv_nb = (uint8_t)pgm_read_byte(&ftv_gamma8[ftv_b8]) * 257; - ftv_totalTime = random(12, 125); // Semi-random pixel-to-pixel time - ftv_fadeTime = random(0, ftv_totalTime); // Pixel-to-pixel transition time + ftv_totalTime = HwRandom(12, 125); // Semi-random pixel-to-pixel time + ftv_fadeTime = HwRandom(0, ftv_totalTime); // Pixel-to-pixel transition time - if (random(10) < 3) { ftv_fadeTime = 0; } // Force scene cut 30% of time + if (HwRandom(10) < 3) { ftv_fadeTime = 0; } // Force scene cut 30% of time ftv_holdTime = counter20ms + ftv_totalTime - ftv_fadeTime; // Non-transition time ftv_startTime = counter20ms; } @@ -1164,10 +1164,10 @@ void P128_data_struct::twinkle(void) { } uint16_t min_leds = _max(1, pixelCount / 5); // make sure, at least one LED is on uint16_t max_leds = _max(1, pixelCount / 2); // make sure, at least one LED is on - _counter_mode_step = random(min_leds, max_leds); + _counter_mode_step = HwRandom(min_leds, max_leds); } - Plugin_128_pixels->SetPixelColor(random(pixelCount), rgb); + Plugin_128_pixels->SetPixelColor(HwRandom(pixelCount), rgb); _counter_mode_step--; } @@ -1201,8 +1201,8 @@ void P128_data_struct::twinklefade(void) { Plugin_128_pixels->SetPixelColor(i, px_rgb); } - if (random(count) < 50) { - Plugin_128_pixels->SetPixelColor(random(pixelCount), rgb); + if (HwRandom(count) < 50) { + Plugin_128_pixels->SetPixelColor(HwRandom(pixelCount), rgb); } } } @@ -1217,7 +1217,7 @@ void P128_data_struct::sparkle(void) { for (int i = 0; i < pixelCount; i++) { Plugin_128_pixels->SetPixelColor(i, rrggbb); } - Plugin_128_pixels->SetPixelColor(random(pixelCount), rgb); + Plugin_128_pixels->SetPixelColor(HwRandom(pixelCount), rgb); } } diff --git a/src/src/WebServer/I2C_Scanner.cpp b/src/src/WebServer/I2C_Scanner.cpp index 0510b2e88..c96cda2fb 100644 --- a/src/src/WebServer/I2C_Scanner.cpp +++ b/src/src/WebServer/I2C_Scanner.cpp @@ -12,6 +12,7 @@ #include "../Helpers/StringConverter.h" +#include #ifdef WEBSERVER_NEW_UI diff --git a/src/src/WebServer/WebTemplateParser.h b/src/src/WebServer/WebTemplateParser.h index e0becbe53..91152ea8b 100644 --- a/src/src/WebServer/WebTemplateParser.h +++ b/src/src/WebServer/WebTemplateParser.h @@ -3,9 +3,6 @@ #include "../../ESPEasy_common.h" -#include - - #define _HEAD false #define _TAIL true diff --git a/src/src/WebServer/common.h b/src/src/WebServer/common.h index 7de1c3aa7..dfd73f1ac 100644 --- a/src/src/WebServer/common.h +++ b/src/src/WebServer/common.h @@ -2,7 +2,13 @@ #define WEBSERVER_WEBSERVER_COMMON_H -#include +#include "../../ESPEasy_common.h" +#include "../ESPEasyCore/ESPEasy_Log.h" +#include "../Globals/Services.h" +#include "../Globals/TXBuffer.h" +#include "../Helpers/StringProvider.h" + + #include #ifdef ESP32 @@ -15,12 +21,6 @@ #include #endif -#include "../../ESPEasy_common.h" -#include "../ESPEasyCore/ESPEasy_Log.h" -#include "../Globals/Services.h" -#include "../Globals/TXBuffer.h" -#include "../Helpers/StringProvider.h" - void sendHeader(const String& name, const String& value, bool first = false); void sendHeader(const __FlashStringHelper * name, const String& value, bool first = false); void sendHeader(const __FlashStringHelper * name, const __FlashStringHelper * value, bool first = false); diff --git a/tools/pio/concat_cpp_files.py b/tools/pio/concat_cpp_files.py index 2f2a32e3e..f9ddd7a61 100644 --- a/tools/pio/concat_cpp_files.py +++ b/tools/pio/concat_cpp_files.py @@ -54,6 +54,7 @@ concat_cpp_files('./src/src/Commands') concat_cpp_files('./src/src/ControllerQueue') concat_cpp_files('./src/src/DataStructs') concat_cpp_files('./src/src/DataTypes') +concat_cpp_files('./src/src/ESPEasyCore') concat_cpp_files('./src/src/Globals') concat_cpp_files('./src/src/Helpers') concat_cpp_files('./src/src/PluginStructs') diff --git a/tools/pio/generate-compiletime-defines.py b/tools/pio/generate-compiletime-defines.py index 279e4ca21..9a5a710d2 100644 --- a/tools/pio/generate-compiletime-defines.py +++ b/tools/pio/generate-compiletime-defines.py @@ -7,6 +7,7 @@ from datetime import date import datetime import time import json +import collections def compute_version_date(): @@ -102,17 +103,19 @@ def gen_compiletime_defines(node): # pass SCons variables as extra keyword arguments to `env.Object()` function # p.s: run `pio run -t envdump` to see a list with SCons variables + defines = env["CPPDEFINES"] + defines.append(("SET_BUILD_BINARY_FILENAME", '\\"%s\\"' % create_binary_filename())) + defines.append(("SET_BOARD_NAME", '\\"%s\\"' % get_board_name())) + defines.append(("SET_BUILD_PLATFORM", '\\"%s\\"' % platform.platform())) + defines.append(("SET_BUILD_GIT_HEAD", '\\"%s\\"' % get_git_description())) + defines.append(("SET_BUILD_CDN_URL", '\\"%s\\"' % get_cdn_url_prefix())) + defines.append(("SET_BUILD_VERSION", compute_version_date())) + defines.append(("SET_BUILD_UNIXTIME", create_build_unixtime())) + defines.append(("SET_BUILD_TIME_RFC1123", '\\"%s\\"' % create_RFC1123_build_date())) + return env.Object( node, - CPPDEFINES=env["CPPDEFINES"] - + [("SET_BUILD_BINARY_FILENAME", '\\"%s\\"' % create_binary_filename())] - + [("SET_BOARD_NAME", '\\"%s\\"' % get_board_name())] - + [("SET_BUILD_PLATFORM", '\\"%s\\"' % platform.platform())] - + [("SET_BUILD_GIT_HEAD", '\\"%s\\"' % get_git_description())] - + [("SET_BUILD_CDN_URL", '\\"%s\\"' % get_cdn_url_prefix())] - + [("SET_BUILD_VERSION", compute_version_date())] - + [("SET_BUILD_UNIXTIME", create_build_unixtime())] - + [("SET_BUILD_TIME_RFC1123", '\\"%s\\"' % create_RFC1123_build_date())], + CPPDEFINES=defines, CCFLAGS=env["CCFLAGS"] )