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); }