Skip to content

Commit

Permalink
0.8.55
Browse files Browse the repository at this point in the history
* merge PR: fix reboot problem with deactivated power graph #1360
* changed scope of variables and member functions inside display classes
* removed automatically "minimal" builds
* fix include of "settings.h" (was already done in #1360)
* merge PR: Enhancement: Add info about compiled modules to version string #1357
* add info about installed binary to `/update` #1353
* fix lang in `/system` #1346
  • Loading branch information
lumapu committed Jan 14, 2024
1 parent 201c96e commit 6c4e6f9
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 40 deletions.
30 changes: 23 additions & 7 deletions scripts/convertHtml.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,33 @@ def readVersion(path):

today = date.today()
search = ["_MAJOR", "_MINOR", "_PATCH"]
version = today.strftime("%y%m%d") + "_ahoy_"
ver = ""
for line in lines:
if(line.find("VERSION_") != -1):
for s in search:
p = line.find(s)
if(p != -1):
version += line[p+13:].rstrip() + "."
ver += line[p+13:].rstrip() + "."
return ver[:-1]

def htmlParts(file, header, nav, footer, version, lang):
def readVersionFull(path):
f = open(path, "r")
lines = f.readlines()
f.close()

today = date.today()
search = ["_MAJOR", "_MINOR", "_PATCH"]
version = today.strftime("%y%m%d") + "_ahoy_"
for line in lines:
if(line.find("VERSION_") != -1):
for s in search:
p = line.find(s)
if(p != -1):
version += line[p+13:].rstrip() + "."
version = version[:-1] + "_" + get_git_sha()
return version

def htmlParts(file, header, nav, footer, versionPath, lang):
p = "";
f = open(file, "r")
lines = f.readlines()
Expand All @@ -59,8 +74,10 @@ def htmlParts(file, header, nav, footer, version, lang):
p += line

#placeholders
version = readVersion(versionPath);
link = '<a target="_blank" href="https://github.com/lumapu/ahoy/commits/' + get_git_sha() + '">GIT SHA: ' + get_git_sha() + ' :: ' + version + '</a>'
p = p.replace("{#VERSION}", version)
p = p.replace("{#VERSION_FULL}", readVersionFull(versionPath))
p = p.replace("{#VERSION_GIT}", link)

# remove if - endif ESP32
Expand Down Expand Up @@ -120,7 +137,7 @@ def translate(file, data, lang="de"):
return data


def convert2Header(inFile, version, lang):
def convert2Header(inFile, versionPath, lang):
fileType = inFile.split(".")[1]
define = inFile.split(".")[0].upper()
define2 = inFile.split(".")[1].upper()
Expand All @@ -140,7 +157,7 @@ def convert2Header(inFile, version, lang):
f.close()
else:
if fileType == "html":
data = htmlParts(inFile, "includes/header.html", "includes/nav.html", "includes/footer.html", version, lang)
data = htmlParts(inFile, "includes/header.html", "includes/nav.html", "includes/footer.html", versionPath, lang)
else:
f = open(inFile, "r")
data = f.read()
Expand Down Expand Up @@ -193,7 +210,6 @@ def convert2Header(inFile, version, lang):
Path("h").mkdir(exist_ok=True)
Path("tmp").mkdir(exist_ok=True) # created to check if webpages are valid with all replacements
shutil.copyfile("style.css", "tmp/style.css")
version = readVersion("../../defines.h")

# get language from environment
lang = "en"
Expand All @@ -202,4 +218,4 @@ def convert2Header(inFile, version, lang):

# go throw the array
for val in files_grabbed:
convert2Header(val, version, lang)
convert2Header(val, "../../defines.h", lang)
3 changes: 3 additions & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* changed scope of variables and member functions inside display classes
* removed automatically "minimal" builds
* fix include of "settings.h" (was already done in #1360)
* merge PR: Enhancement: Add info about compiled modules to version string #1357
* add info about installed binary to `/update` #1353
* fix lang in `/system` #1346

## 0.8.54 - 2024-01-13
* added minimal version (without: MqTT, Display, History), WebUI is not changed!
Expand Down
58 changes: 29 additions & 29 deletions src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,42 +465,42 @@ void app:: zeroIvValues(bool checkAvail, bool skipYieldDay) {

//-----------------------------------------------------------------------------
void app::resetSystem(void) {
snprintf(mVersion, sizeof(mVersion), "%d.%d.%d%s", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH,
"-"
#ifdef ENABLE_PROMETHEUS_EP
"P"
#endif
snprintf(mVersion, sizeof(mVersion), "%d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
snprintf(mVersionModules, sizeof(mVersionModules), "%s",
#ifdef ENABLE_PROMETHEUS_EP
"P"
#endif

#ifdef ENABLE_MQTT
"M"
#endif
#ifdef ENABLE_MQTT
"M"
#endif

#ifdef PLUGIN_DISPLAY
"D"
#endif
#ifdef PLUGIN_DISPLAY
"D"
#endif

#ifdef ENABLE_HISTORY
"H"
#endif
#ifdef ENABLE_HISTORY
"H"
#endif

#ifdef AP_ONLY
"A"
#endif
#ifdef AP_ONLY
"A"
#endif

#ifdef ENABLE_SYSLOG
"Y"
#endif
#ifdef ENABLE_SYSLOG
"Y"
#endif

#ifdef ENABLE_SIMULATOR
"S"
#endif
#ifdef ENABLE_SIMULATOR
"S"
#endif

"-"
#ifdef LANG_DE
"de"
#else
"en"
#endif
"-"
#ifdef LANG_DE
"de"
#else
"en"
#endif
);

#ifdef AP_ONLY
Expand Down
7 changes: 6 additions & 1 deletion src/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ class app : public IApp, public ah::Scheduler {
return mVersion;
}

const char *getVersionModules() {
return mVersionModules;
}

uint32_t getSunrise() {
return mSunrise;
}
Expand Down Expand Up @@ -386,7 +390,8 @@ class app : public IApp, public ah::Scheduler {
CmtRadio<> mCmtRadio;
#endif

char mVersion[23];
char mVersion[12];
char mVersionModules[12];
settings mSettings;
settings_t *mConfig;
bool mSavePending;
Expand Down
1 change: 1 addition & 0 deletions src/appInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class IApp {
virtual bool getShouldReboot() = 0;
virtual void setRebootFlag() = 0;
virtual const char *getVersion() = 0;
virtual const char *getVersionModules() = 0;

#if !defined(ETHERNET)
virtual void scanAvailNetworks() = 0;
Expand Down
5 changes: 4 additions & 1 deletion src/web/RestApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ class RestApi {
obj[F("ts_uptime")] = mApp->getUptime();
obj[F("ts_now")] = mApp->getTimestamp();
obj[F("version")] = String(mApp->getVersion());
obj[F("modules")] = String(mApp->getVersionModules());
obj[F("build")] = String(AUTO_GIT_HASH);
obj[F("env")] = String(ENV_NAME);
obj[F("menu_prot")] = mApp->getProtection(request);
Expand Down Expand Up @@ -325,7 +326,9 @@ class RestApi {
void getHtmlSystem(AsyncWebServerRequest *request, JsonObject obj) {
getSysInfo(request, obj.createNestedObject(F("system")));
getGeneric(request, obj.createNestedObject(F("generic")));
obj[F("html")] = F("<a href=\"/factory\" class=\"btn\">AhoyFactory Reset</a><br/><br/><a href=\"/reboot\" class=\"btn\">Reboot</a>");
char tmp[100];
snprintf(tmp, 100, "<a href=\"/factory\" class=\"btn\">%s</a><br/><br/><a href=\"/reboot\" class=\"btn\">%s</a>", FACTORY_RESET, BTN_REBOOT);
obj[F("html")] = String(tmp);
}

void getHtmlLogout(AsyncWebServerRequest *request, JsonObject obj) {
Expand Down
2 changes: 1 addition & 1 deletion src/web/html/system.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
const data = ["sdk", "cpu_freq", "chip_revision",
"chip_model", "chip_cores", "esp_type", "mac", "wifi_rssi", "ts_uptime",
"flash_size", "sketch_used", "heap_total", "heap_free", "heap_frag",
"max_free_blk", "version", "core_version", "reboot_reason"];
"max_free_blk", "version", "modules", "env", "core_version", "reboot_reason"];

lines = [];
for (const [key, value] of Object.entries(obj)) {
Expand Down
2 changes: 2 additions & 0 deletions src/web/html/update.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<div id="content">
<fieldset>
<legend class="des">{#SELECT_FILE} (*.bin)</legend>
<p>{#INSTALLED_VERSION}: <span id="version" style="background-color: var(--input-bg); padding: 7px;"></span></p>
<form id="form" method="POST" action="/update" enctype="multipart/form-data" accept-charset="utf-8">
<input type="file" name="update">
<input type="button" class="btn my-4" value="{#BTN_UPDATE}" onclick="hide()">
Expand All @@ -26,6 +27,7 @@
parseNav(obj);
parseESP(obj);
parseRssi(obj);
document.getElementById("version").innerHTML = "{#VERSION_FULL}_" + obj.env + ".bin"
}

function hide() {
Expand Down
12 changes: 12 additions & 0 deletions src/web/lang.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,16 @@
#define INV_NOT_FOUND "inverter not found!"
#endif

#ifdef LANG_DE
#define FACTORY_RESET "Ahoy Factory Reset"
#else /*LANG_EN*/
#define FACTORY_RESET "Ahoy auf Werkseinstellungen zurücksetzen"
#endif

#ifdef LANG_DE
#define BTN_REBOOT "Reboot"
#else /*LANG_EN*/
#define BTN_REBOOT "Ahoy neustarten"
#endif

#endif /*__LANG_H__*/
7 changes: 6 additions & 1 deletion src/web/lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
{
"token": "WELCOME",
"en": "Welcome to AhoyDTU",
"de": "Willkommen zu AhoyDTU"
"de": "Willkommen bei AhoyDTU"
},
{
"token": "NETWORK_SETUP",
Expand Down Expand Up @@ -1043,6 +1043,11 @@
"en": "Download latest Release and Development versions (without login)",
"de": "Lade die letzte Releaseversion oder Entwicklerversion herunter (ohne Login)"
},
{
"token": "INSTALLED_VERSION",
"en": "installed version (original filename)",
"de": "aktuell installierte Version"
},
{
"token": "UPDATE_STARTED",
"en": "update started",
Expand Down

0 comments on commit 6c4e6f9

Please sign in to comment.