Skip to content

Commit

Permalink
embrace upstream __compiled_constants.h approach
Browse files Browse the repository at this point in the history
  • Loading branch information
schlimmchen committed May 7, 2024
1 parent 255e81e commit 841523f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions include/__compiled_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@


extern const char *__COMPILED_GIT_HASH__;
extern const char *__COMPILED_GIT_BRANCH__;
// extern const char *__COMPILED_DATE_TIME_UTC_STR__;
2 changes: 2 additions & 0 deletions pio-scripts/auto_firmware_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def do_main():
if 1:
# Add the description of the current git revision
lines += 'const char *__COMPILED_GIT_HASH__ = "%s";\n' % (get_build_version())
# ... and git branch
lines += 'const char *__COMPILED_GIT_BRANCH__ = "%s";\n' % (get_build_branch())

updateFileIfChanged(targetfile, bytes(lines, "utf-8"))

Expand Down
3 changes: 2 additions & 1 deletion src/MqttHandlVedirectHass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "MessageOutput.h"
#include "VictronMppt.h"
#include "Utils.h"
#include "__compiled_constants.h"

MqttHandleVedirectHassClass MqttHandleVedirectHass;

Expand Down Expand Up @@ -214,7 +215,7 @@ void MqttHandleVedirectHassClass::createDeviceInfo(JsonObject &object,
object["cu"] = String("http://") + NetworkSettings.localIP().toString();
object["mf"] = "OpenDTU";
object["mdl"] = mpptData.getPidAsString();
object["sw"] = AUTO_GIT_HASH;
object["sw"] = __COMPILED_GIT_HASH__;
}

void MqttHandleVedirectHassClass::publish(const String& subtopic, const String& payload)
Expand Down
3 changes: 2 additions & 1 deletion src/MqttHandleBatteryHass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "Configuration.h"
#include "MqttSettings.h"
#include "Utils.h"
#include "__compiled_constants.h"

MqttHandleBatteryHassClass MqttHandleBatteryHass;

Expand Down Expand Up @@ -237,7 +238,7 @@ void MqttHandleBatteryHassClass::createDeviceInfo(JsonObject& object)
object["cu"] = String("http://") + NetworkSettings.localIP().toString();
object["mf"] = "OpenDTU";
object["mdl"] = Battery.getStats()->getManufacturer();
object["sw"] = AUTO_GIT_HASH;
object["sw"] = __COMPILED_GIT_HASH__;
}

void MqttHandleBatteryHassClass::publish(const String& subtopic, const String& payload)
Expand Down
3 changes: 2 additions & 1 deletion src/MqttHandlePowerLimiterHass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "NetworkSettings.h"
#include "MessageOutput.h"
#include "Utils.h"
#include "__compiled_constants.h"

MqttHandlePowerLimiterHassClass MqttHandlePowerLimiterHass;

Expand Down Expand Up @@ -193,7 +194,7 @@ void MqttHandlePowerLimiterHassClass::createDeviceInfo(JsonObject& object)
object["cu"] = String("http://") + NetworkSettings.localIP().toString();
object["mf"] = "OpenDTU";
object["mdl"] = "Dynamic Power Limiter";
object["sw"] = AUTO_GIT_HASH;
object["sw"] = __COMPILED_GIT_HASH__;
}

void MqttHandlePowerLimiterHassClass::publish(const String& subtopic, const String& payload)
Expand Down
6 changes: 1 addition & 5 deletions src/WebApi_sysstatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
#include <ResetReason.h>
#include "__compiled_constants.h"

#ifndef AUTO_GIT_BRANCH
#define AUTO_GIT_BRANCH ""
#endif

void WebApiSysstatusClass::init(AsyncWebServer& server, Scheduler& scheduler)
{
using std::placeholders::_1;
Expand Down Expand Up @@ -66,7 +62,7 @@ void WebApiSysstatusClass::onSystemStatus(AsyncWebServerRequest* request)
snprintf(version, sizeof(version), "%d.%d.%d", CONFIG_VERSION >> 24 & 0xff, CONFIG_VERSION >> 16 & 0xff, CONFIG_VERSION >> 8 & 0xff);
root["config_version"] = version;
root["git_hash"] = __COMPILED_GIT_HASH__;
root["git_branch"] = AUTO_GIT_BRANCH;
root["git_branch"] = __COMPILED_GIT_BRANCH__;
root["pioenv"] = PIOENV;

root["uptime"] = esp_timer_get_time() / 1000000;
Expand Down

0 comments on commit 841523f

Please sign in to comment.