Browse Source

0.8.57

* added protection to prevent update to wrong firmware (environment check)
pull/1367/head
lumapu 1 year ago
parent
commit
f503516c9f
  1. 45
      ahoy.code-workspace
  2. 1
      src/CHANGES.md
  3. 2
      src/app.cpp
  4. 4
      src/web/RestApi.h
  5. 29
      src/web/html/update.html
  6. 20
      src/web/lang.json

45
ahoy.code-workspace

@ -0,0 +1,45 @@
{
"folders": [
{
"path": "."
},
{
"path": "src"
}
],
"settings": {
"files.associations": {
"algorithm": "cpp",
"array": "cpp",
"chrono": "cpp",
"deque": "cpp",
"format": "cpp",
"forward_list": "cpp",
"functional": "cpp",
"initializer_list": "cpp",
"iterator": "cpp",
"list": "cpp",
"memory": "cpp",
"queue": "cpp",
"random": "cpp",
"regex": "cpp",
"vector": "cpp",
"xhash": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xmemory": "cpp",
"xstring": "cpp",
"xtree": "cpp",
"xutility": "cpp",
"*.tcc": "cpp",
"string": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"string_view": "cpp",
"sstream": "cpp",
"istream": "cpp",
"ostream": "cpp"
},
"editor.formatOnSave": false
}
}

1
src/CHANGES.md

@ -5,6 +5,7 @@
* merge PR: MI-MQTT and last retransmit #1363
* fixed DTU-ID, now built from the unique part of the MAC
* fix lang in `/system` #1346
* added protection to prevent update to wrong firmware (environment check)
## 0.8.56 - 2024-01-15
* potential fix of update problems and random reboots #1359 #1354

2
src/app.cpp

@ -35,7 +35,7 @@ void app::setup() {
}
#if defined(ESP32)
if(mConfig->cmt.enabled) {
mCmtRadio.setup(&mConfig->serial.debug, &mConfig->serial.privacyLog, &mConfig->serial.printWholeTrace, mConfig->cmt.pinSclk, mConfig->cmt.pinSdio, mConfig->cmt.pinCsb, mConfig->cmt.pinFcsb, false);
mCmtRadio.setup(&mConfig->serial.debug, &mConfig->serial.privacyLog, &mConfig->serial.printWholeTrace, mConfig->cmt.pinSclk, mConfig->cmt.pinSdio, mConfig->cmt.pinCsb, mConfig->cmt.pinFcsb);
}
#endif
#ifdef ETHERNET

4
src/web/RestApi.h

@ -326,8 +326,8 @@ class RestApi {
void getHtmlSystem(AsyncWebServerRequest *request, JsonObject obj) {
getSysInfo(request, obj.createNestedObject(F("system")));
getGeneric(request, obj.createNestedObject(F("generic")));
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);
char tmp[200];
snprintf(tmp, 200, "<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);
}

29
src/web/html/update.html

@ -23,17 +23,34 @@
</div>
{#HTML_FOOTER}
<script type="text/javascript">
var env;
function parseGeneric(obj) {
parseNav(obj);
parseESP(obj);
parseRssi(obj);
parseNav(obj)
parseESP(obj)
parseRssi(obj)
env = obj.env
document.getElementById("version").innerHTML = "{#VERSION_FULL}_" + obj.env + ".bin"
}
function hide() {
document.getElementById("form").submit();
var e = document.getElementById("content");
e.replaceChildren(span("{#UPDATE_STARTED}"));
var bin = document.getElementsByName("update")[0].value.slice(-env.length-4, -4)
if (bin !== env) {
var html = ml("div", {class: "row"}, [
ml("div", {class: "row my-3"}, "{#WARN_DIFF_ENV}"),
ml("div", {class: "row"}, [
ml("div", {class: "col-6"}, ml("input", {type: "button", class: "btn", value: "{#CANCEL}", onclick: function() { modalClose(); }}, null)),
ml("div", {class: "col-6"}, ml("input", {type: "button", class: "btn", value: "{#CONTIUE}", onclick: function() { start(); modalClose(); }}, null))
])
])
modal("{#UPDATE_MODAL}", html)
} else
start()
}
function start() {
document.getElementById("form").submit()
var e = document.getElementById("content")
e.replaceChildren(span("{#UPDATE_STARTED}"))
}
getAjax("/api/generic", parseGeneric);

20
src/web/lang.json

@ -1052,6 +1052,26 @@
"token": "UPDATE_STARTED",
"en": "update started",
"de": "Aktualisierung gestartet"
},
{
"token": "UPDATE_MODAL",
"en": "Warning",
"de": "Warnung"
},
{
"token": "WARN_DIFF_ENV",
"en": "your environment does not match the update file!",
"de": "Die ausgew&auml;hlte Firmware passt uU. nicht zum Chipsatz!"
},
{
"token": "CONTIUE",
"en": "continue",
"de": "fortfahren"
},
{
"token": "CANCEL",
"en": "cancel",
"de": "abbrechen"
}
]
},

Loading…
Cancel
Save