From abd5757803c6b1d03891cbb30ada9fdaf79fce86 Mon Sep 17 00:00:00 2001 From: TD-er Date: Thu, 22 Oct 2020 21:54:29 +0200 Subject: [PATCH 1/4] [Build] Add short compressed build description (#3262) See #3262 Outputs `Tffff:7:P17:2400:22:(3):10:` Equivalent to: ``` "CONTROLLER_SET_ALL", "NOTIFIER_SET_NONE", "PLUGIN_SET_ONLY_SWITCH", "USES_P001", # Switch "USES_P002", # ADC "USES_P004", # Dallas DS18b20 "USES_P100", # Pulse Counter - DS2423 "USES_C016", # Cache Controller "USES_C018", # TTN/RN2483 "USES_C015", # TTN/RN2483 ``` Still missing Notifier, CPU, flash size. [Build] Fix bit order in build description Fix build issues after merge --- src/src/Helpers/ESPEasy_Build_Description.cpp | 91 +++++++++++++++++++ src/src/Helpers/ESPEasy_Build_Description.h | 26 ++++++ src/src/Helpers/StringProvider.cpp | 3 + src/src/Helpers/StringProvider.h | 3 +- src/src/WebServer/SysInfoPage.cpp | 2 + 5 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 src/src/Helpers/ESPEasy_Build_Description.cpp create mode 100644 src/src/Helpers/ESPEasy_Build_Description.h diff --git a/src/src/Helpers/ESPEasy_Build_Description.cpp b/src/src/Helpers/ESPEasy_Build_Description.cpp new file mode 100644 index 0000000000..4e23987701 --- /dev/null +++ b/src/src/Helpers/ESPEasy_Build_Description.cpp @@ -0,0 +1,91 @@ +#include "ESPEasy_Build_Description.h" + + +#include "../Globals/CPlugins.h" +#include "../Globals/NPlugins.h" +#include "../Globals/Plugins.h" + +xPluginEnumerator::xPluginEnumerator() {} + +void xPluginEnumerator::setSize(unsigned int maxID) { + const unsigned int wordSize = (maxID / 16) + 1; + + if (_bitmap.size() < wordSize) { + _bitmap.resize(wordSize, 0); + } +} + +void xPluginEnumerator::add(unsigned int ID) { + setSize(ID); + unsigned int wordIndex = ID / 16; + unsigned int bitIndex = 15 - (ID % 16); + + bitSet(_bitmap[wordIndex], bitIndex); +} + +String xPluginEnumerator::getString(char separator) const { + String result; + + result.reserve(_bitmap.size() * 5); // 4 HEX characters per 16 bit value + separator + size_t zeroCount = 0; + + for (size_t i = 0; i < _bitmap.size(); ++i) { + if (_bitmap[i] == 0) { + ++zeroCount; + } else if (zeroCount > 0) { + result += '('; + result += zeroCount; + result += ')'; + result += separator; + zeroCount = 0; + } + + if (zeroCount == 0) { + result += String(_bitmap[i], HEX); + result += separator; + } + } + return result; +} + +String CreateBuildDescription(char separator) { + String result; + + { + result += 'T'; + xPluginEnumerator cplugins; + const unsigned int size = ProtocolIndex_to_CPlugin_id.size(); + cplugins.setSize(size); + + for (size_t i = 0; i < size; ++i) { + cplugins.add(ProtocolIndex_to_CPlugin_id[i]); + } + result += cplugins.getString(separator); + } + { + result += 'P'; + xPluginEnumerator plugins; + const unsigned int size = DeviceIndex_to_Plugin_id.size(); + plugins.setSize(size); + + for (size_t i = 0; i < size; ++i) { + plugins.add(DeviceIndex_to_Plugin_id[i]); + } + result += plugins.getString(separator); + } + { + // FIXME TD-er: Right now we don't have a notifierindex to ID vector + + /* + result += 'N'; + xPluginEnumerator plugins; + const unsigned int size = DeviceIndex_to_Plugin_id.size(); + plugins.setSize(size); + for (size_t i = 0; i < size; ++i) { + plugins.add(DeviceIndex_to_Plugin_id[i]); + } + result += plugins.getString(separator); + */ + } + return result; +} diff --git a/src/src/Helpers/ESPEasy_Build_Description.h b/src/src/Helpers/ESPEasy_Build_Description.h new file mode 100644 index 0000000000..2543cdc64f --- /dev/null +++ b/src/src/Helpers/ESPEasy_Build_Description.h @@ -0,0 +1,26 @@ +#ifndef HELPERS_ESPEASY_BUILD_DESCRIPTION_H +#define HELPERS_ESPEASY_BUILD_DESCRIPTION_H + +#include +#include + +struct xPluginEnumerator { +public: + + xPluginEnumerator(); + + void setSize(unsigned int maxID); + + void add(unsigned int ID); + + String getString(char separator) const; + +private: + + std::vector_bitmap; +}; + +String CreateBuildDescription(char separator); + + +#endif // HELPERS_ESPEASY_BUILD_DESCRIPTION_H diff --git a/src/src/Helpers/StringProvider.cpp b/src/src/Helpers/StringProvider.cpp index eeeea8d8ee..f1a1fa0bc1 100644 --- a/src/src/Helpers/StringProvider.cpp +++ b/src/src/Helpers/StringProvider.cpp @@ -16,6 +16,7 @@ #include "../Globals/Settings.h" #include "../Helpers/CompiletimeDefines.h" +#include "../Helpers/ESPEasy_Build_Description.h" #include "../Helpers/Memory.h" #include "../Helpers/Scheduler.h" #include "../Helpers/StringConverter.h" @@ -108,6 +109,7 @@ String getLabel(LabelType::Enum label) { case LabelType::BUILD_TIME: return F("Build Time"); case LabelType::BINARY_FILENAME: return F("Binary Filename"); case LabelType::BUILD_PLATFORM: return F("Build Platform"); + case LabelType::BUILD_DESCRIPTION: return F("Build Description"); case LabelType::GIT_HEAD: return F("Git HEAD"); case LabelType::SYSLOG_LOG_LEVEL: return F("Syslog Log Level"); @@ -248,6 +250,7 @@ String getValue(LabelType::Enum label) { case LabelType::BUILD_TIME: return get_build_date() + " " + get_build_time(); case LabelType::BINARY_FILENAME: return get_binary_filename(); case LabelType::BUILD_PLATFORM: return get_build_platform(); + case LabelType::BUILD_DESCRIPTION: return CreateBuildDescription(':'); case LabelType::GIT_HEAD: return get_git_head(); case LabelType::SYSLOG_LOG_LEVEL: return getLogLevelDisplayString(Settings.SyslogLevel); case LabelType::SERIAL_LOG_LEVEL: return getLogLevelDisplayString(getSerialLogLevel()); diff --git a/src/src/Helpers/StringProvider.h b/src/src/Helpers/StringProvider.h index 6ec70eb62d..84f0282fa7 100644 --- a/src/src/Helpers/StringProvider.h +++ b/src/src/Helpers/StringProvider.h @@ -85,6 +85,7 @@ struct LabelType { BUILD_TIME, BINARY_FILENAME, BUILD_PLATFORM, + BUILD_DESCRIPTION, GIT_HEAD, @@ -173,4 +174,4 @@ bool tryDownloadFileType(const String & url, unsigned int filenr = 0); -#endif // STRING_PROVIDER_TYPES_H +#endif // STRING_PROVIDER_TYPES_H \ No newline at end of file diff --git a/src/src/WebServer/SysInfoPage.cpp b/src/src/WebServer/SysInfoPage.cpp index 18fc61fb97..c7f8971f5e 100644 --- a/src/src/WebServer/SysInfoPage.cpp +++ b/src/src/WebServer/SysInfoPage.cpp @@ -130,6 +130,7 @@ void handle_sysinfo_json() { json_prop(F("build_time"), get_build_time()); json_prop(F("filename"), getValue(LabelType::BINARY_FILENAME)); json_prop(F("build_platform"), getValue(LabelType::BUILD_PLATFORM)); + json_prop(F("build_description"), getValue(LabelType::BUILD_DESCRIPTION)); json_prop(F("git_head"), getValue(LabelType::GIT_HEAD)); json_close(); @@ -497,6 +498,7 @@ void handle_sysinfo_Firmware() { addRowLabelValue_copy(LabelType::BUILD_TIME); addRowLabelValue_copy(LabelType::BINARY_FILENAME); addRowLabelValue_copy(LabelType::BUILD_PLATFORM); + addRowLabelValue_copy(LabelType::BUILD_DESCRIPTION); addRowLabelValue_copy(LabelType::GIT_HEAD); } From 11895ca26d604720685ece0d0329bbcbb7c81f6d Mon Sep 17 00:00:00 2001 From: TD-er Date: Mon, 26 Jul 2021 14:52:02 +0200 Subject: [PATCH 2/4] Fix build issues due to changes in ESPEasy core. --- src/src/Helpers/ESPEasy_Build_Description.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/src/Helpers/ESPEasy_Build_Description.cpp b/src/src/Helpers/ESPEasy_Build_Description.cpp index 4e23987701..deabf6d82d 100644 --- a/src/src/Helpers/ESPEasy_Build_Description.cpp +++ b/src/src/Helpers/ESPEasy_Build_Description.cpp @@ -54,7 +54,7 @@ String CreateBuildDescription(char separator) { { result += 'T'; xPluginEnumerator cplugins; - const unsigned int size = ProtocolIndex_to_CPlugin_id.size(); + const unsigned int size = CPLUGIN_MAX; cplugins.setSize(size); for (size_t i = 0; i < size; ++i) { @@ -65,7 +65,7 @@ String CreateBuildDescription(char separator) { { result += 'P'; xPluginEnumerator plugins; - const unsigned int size = DeviceIndex_to_Plugin_id.size(); + const unsigned int size = PLUGIN_MAX; plugins.setSize(size); for (size_t i = 0; i < size; ++i) { From 49a6601749c82f36ca334ef262b2e957f19b801a Mon Sep 17 00:00:00 2001 From: TD-er Date: Sun, 24 Oct 2021 15:37:42 +0200 Subject: [PATCH 3/4] Fix missing relative path in include --- src/src/Helpers/ESPEasy_Build_Description.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/src/Helpers/ESPEasy_Build_Description.cpp b/src/src/Helpers/ESPEasy_Build_Description.cpp index deabf6d82d..31f0a7b0f2 100644 --- a/src/src/Helpers/ESPEasy_Build_Description.cpp +++ b/src/src/Helpers/ESPEasy_Build_Description.cpp @@ -1,5 +1,4 @@ -#include "ESPEasy_Build_Description.h" - +#include "../Helpers/ESPEasy_Build_Description.h" #include "../Globals/CPlugins.h" #include "../Globals/NPlugins.h" From 6be7d6e89f249b702c09fea6351ac7a70ba99ce9 Mon Sep 17 00:00:00 2001 From: TD-er Date: Sun, 12 Jun 2022 11:53:55 +0200 Subject: [PATCH 4/4] [Build descriptop] Fix merge issue --- src/src/Helpers/StringProvider.h | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/src/src/Helpers/StringProvider.h b/src/src/Helpers/StringProvider.h index 14cfd51f35..a38e8920f1 100644 --- a/src/src/Helpers/StringProvider.h +++ b/src/src/Helpers/StringProvider.h @@ -204,32 +204,4 @@ String getValue(LabelType::Enum label); String getExtendedValue(LabelType::Enum label); -struct FileType { - enum Enum : short { - CONFIG_DAT, - SECURITY_DAT, - RULES_TXT, - NOTIFICATION_DAT - }; -}; - - -const __FlashStringHelper * getFileName(FileType::Enum filetype); -String getFileName(FileType::Enum filetype, - unsigned int filenr); - -// filenr = 0...3 for files rules1.txt ... rules4.txt -String getRulesFileName(unsigned int filenr); - -void addDownloadFiletypeCheckbox(FileType::Enum filetype, - unsigned int filenr = 0); -void storeDownloadFiletypeCheckbox(FileType::Enum filetype, - unsigned int filenr = 0); -bool tryDownloadFileType(const String & url, - const String & user, - const String & pass, - FileType::Enum filetype, - unsigned int filenr = 0); - - #endif // STRING_PROVIDER_TYPES_H