diff --git a/docs/source/Plugin/_plugin_substitutions_p15x.repl b/docs/source/Plugin/_plugin_substitutions_p15x.repl index cd1964efe..a9c88d141 100644 --- a/docs/source/Plugin/_plugin_substitutions_p15x.repl +++ b/docs/source/Plugin/_plugin_substitutions_p15x.repl @@ -72,7 +72,7 @@ .. |P157_type| replace:: :cyan:`Display` .. |P157_typename| replace:: :cyan:`Display - HT16K33 14-/7-segment` .. |P157_porttype| replace:: `.` -.. |P157_status| replace:: :green:`DISPLAY` :yellow:`COLLECTION` +.. |P157_status| replace:: :yellow:`DISPLAY` :yellow:`COLLECTION` .. |P157_status_lb| replace:: `.` .. |P157_github| replace:: P157_14DGT.ino .. _P157_github: https://github.com/letscontrolit/ESPEasy/blob/mega/src/_P157_14DGT.ino diff --git a/docs/source/Tools/Tools.rst b/docs/source/Tools/Tools.rst index 7145a6c9c..d499d1bd4 100644 --- a/docs/source/Tools/Tools.rst +++ b/docs/source/Tools/Tools.rst @@ -411,18 +411,6 @@ See for more detailed information "Controller - ESPEasy P2P Networking" Special and Experimental Settings --------------------------------- -Fixed IP Octet -^^^^^^^^^^^^^^ - -Sets the last byte(octet) of the IP address to this value, regardless of what IP is given using DHCP (all other settings received via DHCP will be used) - -So if you receive 192.168.1.234 from your DHCP server and this value is set to "10", -then the used IP in your node is 192.168.1.10. -But since you're receiving more information from the DHCP server, -like subnet mask / gateway / DNS, it may still be useful. -This allows a somewhat static IP in your network (N.B. use it with an 'octet' outside the range of the DHCP IPs) while still having set to DHCP. -So if you take the node to another network which does use 192.168.52.x then you will know it will be on 192.168.52.10 (when setting this value to "10") - WD I2C Address ^^^^^^^^^^^^^^ diff --git a/platformio.ini b/platformio.ini index 8b85a1147..02c285521 100644 --- a/platformio.ini +++ b/platformio.ini @@ -34,15 +34,15 @@ extra_configs = platformio_esp32p4r3_envs.ini -;default_envs = normal_ESP32_4M +;default_envs = normal_ESP32_4M316k default_envs = max_ESP32_16M8M ;default_envs = max_ESP32c5_8M1M -;default_envs = normal_ESP32c6_4M316k_LittleFS_CDC -; default_envs = custom_ESP8266_4M1M +;default_envs = normal_ESP32c6_4M316k +; default_envs = custom_274_ESP8266_4M1M ;default_envs = normal_ESP8266_4M1M -;default_envs = test_beta_ESP8266_4M1M +;default_envs = custom_beta_2ndheap_ESP8266_4M1M ; ..etc ;build_cache_dir = $PROJECT_DIR\.buildcache diff --git a/src/src/CustomBuild/ESPEasyDefaults.h b/src/src/CustomBuild/ESPEasyDefaults.h index 3cc809d56..d385cf73d 100644 --- a/src/src/CustomBuild/ESPEasyDefaults.h +++ b/src/src/CustomBuild/ESPEasyDefaults.h @@ -634,7 +634,6 @@ #define DEFAULT_USE_GLOBAL_SYNC false // (true|false) -#define DEFAULT_IP_OCTET 0 // #define DEFAULT_WD_IC2_ADDRESS 0 // #define DEFAULT_USE_SSDP false // (true|false) #define DEFAULT_CON_FAIL_THRES 0 // diff --git a/src/src/DataStructs/LogBuffer.cpp b/src/src/DataStructs/LogBuffer.cpp index 065db1c90..f96b0b8ad 100644 --- a/src/src/DataStructs/LogBuffer.cpp +++ b/src/src/DataStructs/LogBuffer.cpp @@ -34,20 +34,23 @@ bool LogBuffer::getNext(LogDestination logDestination, uint32_t& timestamp, Stri return false; } -uint32_t LogBuffer::getNrMessages(LogDestination logDestination) const +bool LogBuffer::hasMessages(LogDestination logDestination) { - uint32_t res{}; + if (logDestination >= NR_LOG_TO_DESTINATIONS) { return false; } - if (logDestination >= NR_LOG_TO_DESTINATIONS) { return res; } + clearExpiredEntries(); // Cleanup the old stuff first uint32_t pos = cache_iterator_pos[logDestination]; for (; pos < LogEntries.size(); ++pos) { if (LogEntries[pos].validForSubscriber(logDestination)) { - ++res; + cache_iterator_pos[logDestination] = pos; + return true; } } - return res; + + lastReadTimeStamp[logDestination] = millis(); // Reset if we aren't going to fetch a next message + return false; } bool LogBuffer::logActiveRead(LogDestination logDestination) { diff --git a/src/src/DataStructs/LogBuffer.h b/src/src/DataStructs/LogBuffer.h index 8df20ab07..f55cc6f3b 100644 --- a/src/src/DataStructs/LogBuffer.h +++ b/src/src/DataStructs/LogBuffer.h @@ -52,8 +52,8 @@ struct LogBuffer { String & message, uint8_t & loglevel); - // Return the number of messages left for given log destination. - uint32_t getNrMessages(LogDestination logDestination) const; + // Return true if messages available for given log destination. + bool hasMessages(LogDestination logDestination); bool logActiveRead(LogDestination logDestination); diff --git a/src/src/DataStructs/SettingsStruct.h b/src/src/DataStructs/SettingsStruct.h index 570a1503d..7d912abd3 100644 --- a/src/src/DataStructs/SettingsStruct.h +++ b/src/src/DataStructs/SettingsStruct.h @@ -550,7 +550,7 @@ public: uint8_t Gateway[4] = {0}; uint8_t Subnet[4] = {0}; uint8_t DNS[4] = {0}; - uint8_t IP_Octet = 0; + uint8_t IP_Octet_unused = 0; // No longer applicable after 2026-Network rewrite-merged uint8_t Unit = 0; char Name[26] = {0}; char NTPHost[64] = {0}; diff --git a/src/src/DataStructs_templ/SettingsStruct.cpp b/src/src/DataStructs_templ/SettingsStruct.cpp index d12ad749f..040986039 100644 --- a/src/src/DataStructs_templ/SettingsStruct.cpp +++ b/src/src/DataStructs_templ/SettingsStruct.cpp @@ -693,7 +693,6 @@ void SettingsStruct_tmpl::clearMisc() { PID = ESP_PROJECT_PID; Version = VERSION; Build = get_build_nr(); - IP_Octet = 0; Delay = DEFAULT_DELAY; Pin_i2c_sda = DEFAULT_PIN_I2C_SDA; Pin_i2c_scl = DEFAULT_PIN_I2C_SCL; diff --git a/src/src/ESPEasyCore/ESPEasy_Console_Port.cpp b/src/src/ESPEasyCore/ESPEasy_Console_Port.cpp index e8d6e077f..01354863b 100644 --- a/src/src/ESPEasyCore/ESPEasy_Console_Port.cpp +++ b/src/src/ESPEasyCore/ESPEasy_Console_Port.cpp @@ -220,9 +220,9 @@ ESPEasySerialPort EspEasy_Console_Port::getPortType() const bool EspEasy_Console_Port::process_serialWriteBuffer() { - if (_serialWriteBuffer.getNrMessages() == 0) { return false; } - - if (_serial == nullptr) { return false; } + if ((_serial == nullptr) || !_serialWriteBuffer.hasMessages()) { + return false; + } #ifdef ESP32 if (!xPortCanYield()) { return false; } diff --git a/src/src/Helpers/ESPEasy_FactoryDefault.cpp b/src/src/Helpers/ESPEasy_FactoryDefault.cpp index 6c9e69c2d..0ee05c130 100644 --- a/src/src/Helpers/ESPEasy_FactoryDefault.cpp +++ b/src/src/Helpers/ESPEasy_FactoryDefault.cpp @@ -277,7 +277,6 @@ void ResetFactory(bool formatFS) Settings.Version = VERSION; Settings.Build = get_build_nr(); - // Settings.IP_Octet = DEFAULT_IP_OCTET; // Settings.Delay = DEFAULT_DELAY; Settings.Pin_i2c_sda = gpio_settings.i2c_sda; Settings.Pin_i2c_scl = gpio_settings.i2c_scl; @@ -324,7 +323,6 @@ void ResetFactory(bool formatFS) /* Settings.GlobalSync_unused = DEFAULT_USE_GLOBAL_SYNC; - Settings.IP_Octet = DEFAULT_IP_OCTET; Settings.WDI2CAddress = DEFAULT_WD_IC2_ADDRESS; Settings.UseSSDP = DEFAULT_USE_SSDP; Settings.ConnectionFailuresThreshold = DEFAULT_CON_FAIL_THRES; diff --git a/src/src/Helpers/LogStreamWriter.cpp b/src/src/Helpers/LogStreamWriter.cpp index 5ee13c1d5..2b5646a19 100644 --- a/src/src/Helpers/LogStreamWriter.cpp +++ b/src/src/Helpers/LogStreamWriter.cpp @@ -20,11 +20,11 @@ bool LogStreamWriter::process(Print*stream, size_t availableForWrite) return write(*stream, availableForWrite) != 0; } -bool LogStreamWriter::process() { return false; } +bool LogStreamWriter::process() { return false; } -uint32_t LogStreamWriter::getNrMessages() const +bool LogStreamWriter::hasMessages() const { - return Logging.getNrMessages(_log_destination); + return Logging.hasMessages(_log_destination); } size_t LogStreamWriter::write(Print& stream, size_t nrBytesToWrite) @@ -84,9 +84,9 @@ size_t LogStreamWriter::write_item(Print& stream, bool done = false; - while (!done && bytesWritten < nrBytesToWrite) { const size_t bytesWritten_startLoop = bytesWritten; + if (!_prefix.isEmpty()) { bytesWritten += write_part(_prefix, stream, nrBytesToWrite - bytesWritten); } @@ -101,10 +101,11 @@ size_t LogStreamWriter::write_item(Print& stream, clear(); done = true; } + if (bytesWritten_startLoop == bytesWritten) - { + { // Nothing written in this loop, retry later. - return bytesWritten; + return bytesWritten; } } return bytesWritten; @@ -119,6 +120,7 @@ size_t LogStreamWriter::write_part(String& str, Print& stream, size_t nrBytesTo bytesWritten = stream.write(&str[_readpos], bytesLeft); _readpos += bytesWritten; } + if (_readpos >= str.length()) { // Clear str str.clear(); diff --git a/src/src/Helpers/LogStreamWriter.h b/src/src/Helpers/LogStreamWriter.h index 40df86e20..712c981e8 100644 --- a/src/src/Helpers/LogStreamWriter.h +++ b/src/src/Helpers/LogStreamWriter.h @@ -11,32 +11,35 @@ public: virtual ~LogStreamWriter() {} - virtual bool process(Print* stream, size_t availableForWrite); - + virtual bool process(Print *stream, + size_t availableForWrite); + // Only use this from derived classes, as we need a Stream to further process - virtual bool process(); + virtual bool process(); - virtual uint32_t getNrMessages() const; + virtual bool hasMessages() const; - virtual void clear(); + virtual void clear(); protected: // Write continuously until either nrBytesToWrite was reached or no new messages were available to process. // @retval Number of bytes written. Zero when no new message was available to process. virtual size_t write(Print& stream, - size_t nrBytesToWrite); + size_t nrBytesToWrite); // Write single item and clear() on return. // This way each call starts with a new item and long messages may get truncated based on nrBytesToWrite // @retval Number of bytes written. Zero when no new message was available to process. virtual size_t write_single_item(Print& stream, - size_t nrBytesToWrite); + size_t nrBytesToWrite); virtual size_t write_item(Print& stream, - size_t nrBytesToWrite); + size_t nrBytesToWrite); - size_t write_part(String& str, Print& stream, size_t nrBytesToWrite); + size_t write_part(String& str, + Print & stream, + size_t nrBytesToWrite); virtual size_t write_skipping(Print& stream); diff --git a/src/src/Helpers/Log_Helper.cpp b/src/src/Helpers/Log_Helper.cpp index 2254f6e48..1871ce0a2 100644 --- a/src/src/Helpers/Log_Helper.cpp +++ b/src/src/Helpers/Log_Helper.cpp @@ -14,6 +14,7 @@ #endif // if FEATURE_SD #if FEATURE_SD + void addToSDLog(uint8_t logLevel, const String& str) { if (!str.isEmpty() && loglevelActiveFor(LOG_TO_SDCARD, logLevel)) { @@ -31,6 +32,7 @@ void addToSDLog(uint8_t logLevel, const String& str) logFile.close(); } } + #endif // if FEATURE_SD void LogHelper::addLogEntry(LogEntry_t&& logEntry) @@ -60,14 +62,12 @@ bool LogHelper::getNext(LogDestination logDestination, uint32_t& timestamp, Stri return _logBuffer.getNext(logDestination, timestamp, message, loglevel); } -uint32_t LogHelper::getNrMessages(LogDestination logDestination) const -{ - return _logBuffer.getNrMessages(logDestination); -} +bool LogHelper::hasMessages(LogDestination logDestination) { return _logBuffer.hasMessages(logDestination); } void LogHelper::loop(bool serialOnly) { #if FEATURE_SD + if (!serialOnly) { String message; uint32_t timestamp{}; @@ -78,14 +78,11 @@ void LogHelper::loop(bool serialOnly) addToSDLog(loglevel, message); } } -#endif +#endif // if FEATURE_SD _logBuffer.clearExpiredEntries(); } -bool LogHelper::logActiveRead(LogDestination logDestination) -{ - return _logBuffer.logActiveRead(logDestination); -} +bool LogHelper::logActiveRead(LogDestination logDestination) { return _logBuffer.logActiveRead(logDestination); } void LogHelper::consolePrint(const __FlashStringHelper *text) { _tmpConsoleOutput += text; } diff --git a/src/src/Helpers/Log_Helper.h b/src/src/Helpers/Log_Helper.h index b0ea29fc4..7ba705a1c 100644 --- a/src/src/Helpers/Log_Helper.h +++ b/src/src/Helpers/Log_Helper.h @@ -14,16 +14,16 @@ public: void addLogEntry(LogEntry_t&& logEntry); - bool getNext(LogDestination logDestination, - uint32_t& timestamp, - String & message, - uint8_t & loglevel); + bool getNext(LogDestination logDestination, + uint32_t & timestamp, + String & message, + uint8_t & loglevel); - uint32_t getNrMessages(LogDestination logDestination) const; + bool hasMessages(LogDestination logDestination); - void loop(bool serialOnly); + void loop(bool serialOnly); - bool logActiveRead(LogDestination logDestination); + bool logActiveRead(LogDestination logDestination); // Append to internal buffer, which will only be flushed on consolePrintln diff --git a/src/src/Helpers/SyslogWriter.cpp b/src/src/Helpers/SyslogWriter.cpp index def302801..0752db75e 100644 --- a/src/src/Helpers/SyslogWriter.cpp +++ b/src/src/Helpers/SyslogWriter.cpp @@ -3,19 +3,19 @@ #if FEATURE_SYSLOG -#include "../../ESPEasy/net/ESPEasyNetwork.h" -#include "../../ESPEasy/net/Globals/NetworkState.h" -#include "../Globals/ESPEasy_time.h" -#include "../Globals/Settings.h" -#include "../Helpers/ESPEasy_time_calc.h" -#include "../Helpers/Networking.h" -#include "../Helpers/StringConverter.h" +# include "../../ESPEasy/net/ESPEasyNetwork.h" +# include "../../ESPEasy/net/Globals/NetworkState.h" +# include "../Globals/ESPEasy_time.h" +# include "../Globals/Settings.h" +# include "../Helpers/ESPEasy_time_calc.h" +# include "../Helpers/Networking.h" +# include "../Helpers/StringConverter.h" -#define MAX_LENGTH_SYSLOG_MESSAGE 1000 +# define MAX_LENGTH_SYSLOG_MESSAGE 1000 bool SyslogWriter::process() { - if ((Settings.SyslogLevel == 0) || (getNrMessages() == 0)) { + if ((Settings.SyslogLevel == 0) || !hasMessages()) { return false; } @@ -136,4 +136,5 @@ void SyslogWriter::prepare_prefix() formattedTimestamp.c_str(), hostname.c_str()); } -#endif \ No newline at end of file + +#endif // if FEATURE_SYSLOG diff --git a/src/src/WebServer/AdvancedConfigPage.cpp b/src/src/WebServer/AdvancedConfigPage.cpp index cb3a355b1..e541fc26f 100644 --- a/src/src/WebServer/AdvancedConfigPage.cpp +++ b/src/src/WebServer/AdvancedConfigPage.cpp @@ -44,7 +44,7 @@ void handle_advanced() { if (!webArg(F("edit")).isEmpty()) { - Settings.IP_Octet = webArg(F("ip")).toInt(); + // Settings.IP_Octet_unused = webArg(F("ip")).toInt(); // No longer applicable after 2026-Network rewrite-merged strncpy_webserver_arg(Settings.NTPHost, F("ntphost")); Settings.TimeZone = getFormItemInt(F("timezone")); TimeChangeRule dst_start(getFormItemInt(F("dststartweek")), getFormItemInt(F("dststartdow")), getFormItemInt(F("dststartmonth")), getFormItemInt(F("dststarthour")), Settings.TimeZone); @@ -298,7 +298,7 @@ void handle_advanced() { addFormNumericBox(F("Webserver port"), F("webport"), Settings.WebserverPort, 0, 65535); addFormNote(F("Requires reboot to activate")); - addFormNumericBox(F("Fixed IP Octet"), F("ip"), Settings.IP_Octet, 0, 255); + // addFormNumericBox(F("Fixed IP Octet"), F("ip"), Settings.IP_Octet_unused, 0, 255); // No longer applicable after 2026-Network rewrite-merged addFormNumericBox(F("WD I2C Address"), F("wdi2caddress"), Settings.WDI2CAddress, 0, 127); addHtml(F(" (decimal)")); diff --git a/src/src/WebServer/Log.cpp b/src/src/WebServer/Log.cpp index 54f6996fb..1b9a01c0e 100644 --- a/src/src/WebServer/Log.cpp +++ b/src/src/WebServer/Log.cpp @@ -111,10 +111,10 @@ void handle_log_JSON() { } } } - const uint32_t nrEntriesLeft = Logging.getNrMessages(LOG_TO_WEBLOG); - int32_t logTimeSpan = timeDiff(firstTimeStamp, lastTimeStamp); - int32_t refreshSuggestion = (nrEntriesLeft > 0) ? 200 : 1000; - int32_t newOptimum = 1000; + const bool entriesAvailable = Logging.hasMessages(LOG_TO_WEBLOG); + const int32_t logTimeSpan = timeDiff(firstTimeStamp, lastTimeStamp); + int32_t refreshSuggestion = entriesAvailable ? 200 : 1000; + int32_t newOptimum = 1000; if ((nrEntries > 2) && (logTimeSpan > 1)) { diff --git a/src/src/WebServer/SysInfoPage.cpp b/src/src/WebServer/SysInfoPage.cpp index c240d74b8..3169b5168 100644 --- a/src/src/WebServer/SysInfoPage.cpp +++ b/src/src/WebServer/SysInfoPage.cpp @@ -41,6 +41,10 @@ # include "../Helpers/Hardware_temperature_sensor.h" # endif +#if FEATURE_EEPROM_EXTERNAL +#include "../../ESPEasy/eeprom/Helpers/EEPROMExternal.h" +#endif // if FEATURE_EEPROM_EXTERNAL + # ifdef ESP32 # include # endif // ifdef ESP32 @@ -718,6 +722,27 @@ void handle_sysinfo_Storage() { getPartitionTableSVG(); # endif // ifdef ESP8266 # endif // if FEATURE_CHART_STORAGE_LAYOUT + + #ifndef LIMIT_BUILD_SIZE + + #if FEATURE_EEPROM_EXTERNAL + { + const bool eepromChecked = ESPEasy::eeprom::checkEEPROMEnabled() > 0; + if (eepromChecked) { + addFormSubHeader(F("External I2C EEPROM")); + addRowLabel(F("EEPROM Model/size")); + addHtml(getEEPROMName(static_cast(Settings.EEPROMExternalType()))); + addRowLabel(F("EEPROM Enabled")); + addEnabled(eepromChecked); + if (ESPEasy::eeprom::isEEPROMExternalWriteProtected()) { + addHtml(F(" Write-protected!")); + } + addRowLabel(F("'WriteEE' slots available")); + addHtmlInt(ESPEasy::eeprom::getEEPROMMaxSlots()); + } + } + #endif // if FEATURE_EEPROM_EXTERNAL + #endif // ifndef LIMIT_BUILD_SIZE } # endif // ifndef WEBSERVER_SYSINFO_MINIMAL