Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Build] Add short compressed build description (#3262) #3263

Open
wants to merge 32 commits into
base: mega
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
abd5757
[Build] Add short compressed build description (#3262)
TD-er Oct 22, 2020
7fa97b5
Merge branch 'mega' into feature/build_description
TD-er Oct 30, 2020
5fdbbd8
Merge branch 'mega' into feature/build_description
TD-er Dec 6, 2020
ca6fe16
Merge branch 'mega' into feature/build_description
TD-er Dec 19, 2020
0300f55
Merge branch 'mega' into feature/build_description
TD-er Dec 27, 2020
868c17a
Merge branch 'mega' into feature/build_description
TD-er Jan 4, 2021
f383bfc
Merge branch 'mega' into feature/build_description
TD-er Jan 14, 2021
d0b31f5
Merge branch 'mega' into feature/build_description
TD-er Feb 1, 2021
812d534
Merge branch 'mega' into feature/build_description
TD-er Mar 7, 2021
7da9ea6
Merge branch 'mega' into feature/build_description
TD-er May 2, 2021
bb5330e
Merge branch 'mega' into feature/build_description
TD-er May 13, 2021
bb84bf7
Merge branch 'mega' into feature/build_description
TD-er May 28, 2021
1926ec7
Merge branch 'mega' into feature/build_description
TD-er May 31, 2021
fd8172a
Merge branch 'mega' into feature/build_description
TD-er Jun 5, 2021
613d7b8
Merge branch 'mega' into feature/build_description
TD-er Jul 25, 2021
7b6c49c
Merge branch 'mega' into feature/build_description
TD-er Jul 26, 2021
11895ca
Fix build issues due to changes in ESPEasy core.
TD-er Jul 26, 2021
9ab17ec
Merge branch 'mega' into feature/build_description
TD-er Aug 2, 2021
b40dc95
Merge branch 'mega' into feature/build_description
TD-er Sep 19, 2021
5d5a2b2
Merge branch 'mega' into feature/build_description
TD-er Oct 16, 2021
fe829e1
Merge branch 'mega' into feature/build_description
TD-er Oct 22, 2021
6316c00
Merge branch 'mega' into feature/build_description
TD-er Oct 24, 2021
49a6601
Fix missing relative path in include
TD-er Oct 24, 2021
c9f9676
Merge branch 'mega' into feature/build_description
TD-er Oct 24, 2021
cdf2139
Merge branch 'mega' into feature/build_description
TD-er Apr 23, 2022
3c60178
Merge branch 'mega' into feature/build_description
TD-er Jun 12, 2022
6be7d6e
[Build descriptop] Fix merge issue
TD-er Jun 12, 2022
6655cb4
Merge branch 'mega' into feature/build_description
TD-er Jul 18, 2022
0de7c9c
Merge branch 'mega' into feature/build_description
TD-er Jul 18, 2022
caee99b
Merge branch 'mega' into feature/build_description
TD-er Jul 27, 2022
a3a45d3
Merge branch 'mega' into feature/build_description
TD-er Jan 18, 2023
f4d8ff0
Merge branch 'mega' into feature/build_description
TD-er Apr 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions src/src/Helpers/ESPEasy_Build_Description.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#include "../Helpers/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 = CPLUGIN_MAX;
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 = PLUGIN_MAX;
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;
}
26 changes: 26 additions & 0 deletions src/src/Helpers/ESPEasy_Build_Description.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef HELPERS_ESPEASY_BUILD_DESCRIPTION_H
#define HELPERS_ESPEASY_BUILD_DESCRIPTION_H

#include <Arduino.h>
#include <vector>

struct xPluginEnumerator {
public:

xPluginEnumerator();

void setSize(unsigned int maxID);

void add(unsigned int ID);

String getString(char separator) const;

private:

std::vector<uint16_t>_bitmap;
};

String CreateBuildDescription(char separator);


#endif // HELPERS_ESPEASY_BUILD_DESCRIPTION_H
3 changes: 3 additions & 0 deletions src/src/Helpers/StringProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "../Globals/WiFi_AP_Candidates.h"

#include "../Helpers/Convert.h"
#include "../Helpers/ESPEasy_Build_Description.h"
#include "../Helpers/ESPEasy_Storage.h"
#include "../Helpers/Memory.h"
#include "../Helpers/Misc.h"
Expand Down Expand Up @@ -175,6 +176,7 @@ const __FlashStringHelper * 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::I2C_BUS_STATE: return F("I2C Bus State");
Expand Down Expand Up @@ -443,6 +445,7 @@ String getValue(LabelType::Enum label) {
case LabelType::BUILD_TIME: return String(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::I2C_BUS_STATE: return toString(I2C_state);
case LabelType::I2C_BUS_CLEARED_COUNT: return String(I2C_bus_cleared_count);
Expand Down
1 change: 1 addition & 0 deletions src/src/Helpers/StringProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ struct LabelType {
BUILD_TIME,
BINARY_FILENAME,
BUILD_PLATFORM,
BUILD_DESCRIPTION,
GIT_HEAD,


Expand Down
2 changes: 2 additions & 0 deletions src/src/WebServer/SysInfoPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,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();

Expand Down Expand Up @@ -515,6 +516,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);
}

Expand Down