Show current git hash in web gui
This commit is contained in:
parent
8d2b71cd04
commit
3b9d117b4d
22
auto_firmware_version.py
Normal file
22
auto_firmware_version.py
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
import pkg_resources
|
||||||
|
|
||||||
|
Import("env")
|
||||||
|
|
||||||
|
required_pkgs = {'dulwich'}
|
||||||
|
installed_pkgs = {pkg.key for pkg in pkg_resources.working_set}
|
||||||
|
missing_pkgs = required_pkgs - installed_pkgs
|
||||||
|
|
||||||
|
if missing_pkgs:
|
||||||
|
env.Execute('$PYTHONEXE -m pip install dulwich --global-option="--pure"')
|
||||||
|
|
||||||
|
from dulwich import porcelain
|
||||||
|
|
||||||
|
def get_firmware_specifier_build_flag():
|
||||||
|
build_version = porcelain.describe('.') # '.' refers to the repository root dir
|
||||||
|
build_flag = "-D AUTO_GIT_HASH=\\\"" + build_version + "\\\""
|
||||||
|
print ("Firmware Revision: " + build_version)
|
||||||
|
return (build_flag)
|
||||||
|
|
||||||
|
env.Append(
|
||||||
|
BUILD_FLAGS=[get_firmware_specifier_build_flag()]
|
||||||
|
)
|
||||||
@ -28,6 +28,9 @@ lib_deps =
|
|||||||
https://github.com/marvinroger/async-mqtt-client.git
|
https://github.com/marvinroger/async-mqtt-client.git
|
||||||
nrf24/RF24 @ ^1.4.2
|
nrf24/RF24 @ ^1.4.2
|
||||||
|
|
||||||
|
extra_scripts =
|
||||||
|
pre:auto_firmware_version.py
|
||||||
|
|
||||||
board = esp32dev
|
board = esp32dev
|
||||||
board_build.partitions = partitions_custom.csv
|
board_build.partitions = partitions_custom.csv
|
||||||
board_build.filesystem = littlefs
|
board_build.filesystem = littlefs
|
||||||
|
|||||||
@ -5,6 +5,10 @@
|
|||||||
#include <LittleFS.h>
|
#include <LittleFS.h>
|
||||||
#include <ResetReason.h>
|
#include <ResetReason.h>
|
||||||
|
|
||||||
|
#ifndef AUTO_GIT_HASH
|
||||||
|
#define AUTO_GIT_HASH ""
|
||||||
|
#endif
|
||||||
|
|
||||||
void WebApiSysstatusClass::init(AsyncWebServer* server)
|
void WebApiSysstatusClass::init(AsyncWebServer* server)
|
||||||
{
|
{
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
@ -51,6 +55,7 @@ void WebApiSysstatusClass::onSystemStatus(AsyncWebServerRequest* request)
|
|||||||
char version[16];
|
char version[16];
|
||||||
sprintf(version, "%d.%d.%d", CONFIG_VERSION >> 24 & 0xff, CONFIG_VERSION >> 16 & 0xff, CONFIG_VERSION >> 8 & 0xff);
|
sprintf(version, "%d.%d.%d", CONFIG_VERSION >> 24 & 0xff, CONFIG_VERSION >> 16 & 0xff, CONFIG_VERSION >> 8 & 0xff);
|
||||||
root[F("firmware_version")] = version;
|
root[F("firmware_version")] = version;
|
||||||
|
root[F("git_hash")] = AUTO_GIT_HASH;
|
||||||
|
|
||||||
root[F("uptime")] = esp_timer_get_time() / 1000000;
|
root[F("uptime")] = esp_timer_get_time() / 1000000;
|
||||||
|
|
||||||
|
|||||||
@ -19,6 +19,10 @@
|
|||||||
<th>Firmware Version</th>
|
<th>Firmware Version</th>
|
||||||
<td>{{ systemDataList.firmware_version }}</td>
|
<td>{{ systemDataList.firmware_version }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Git Hash</th>
|
||||||
|
<td>{{ systemDataList.git_hash }}</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Reset Reason CPU 0</th>
|
<th>Reset Reason CPU 0</th>
|
||||||
<td>{{ systemDataList.resetreason_0 }}</td>
|
<td>{{ systemDataList.resetreason_0 }}</td>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user