Skip to content

Commit

Permalink
[Build] Add short compressed build description (#3262)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
TD-er committed Oct 22, 2020
1 parent e1e8adb commit abd5757
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 1 deletion.
91 changes: 91 additions & 0 deletions src/src/Helpers/ESPEasy_Build_Description.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
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 @@ -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"
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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());
Expand Down
3 changes: 2 additions & 1 deletion src/src/Helpers/StringProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ struct LabelType {
BUILD_TIME,
BINARY_FILENAME,
BUILD_PLATFORM,
BUILD_DESCRIPTION,
GIT_HEAD,


Expand Down Expand Up @@ -173,4 +174,4 @@ bool tryDownloadFileType(const String & url,
unsigned int filenr = 0);


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

Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit abd5757

Please sign in to comment.