Skip to content

Commit 1c0b1b9

Browse files
committed
- Add visualization of progress ESP32 flashing from Github
- Add display of release information by clicking a button on the update page. #### v0.1.9 - Merge pull request #2 from skrue/iss9 - Fix random " in root page - Fix z2m/zha page - Change update check repo to mercenaruss/uzg-firmware - Specify PIO, EspSoftwareSerial, bblanchon/ArduinoJson versions #### v0.1.8 - Finished - Change navi section bg color - Some web styles reworked - LED control functions renamed - Captive portal fix - only on ap mode - Separate all update divs to new tab - Fix online update esp32 - Add Zigbee buttons: check connection, check firware revision, toggle LED - All Zigbee functions moved to separate file - Still in development - Add Zigbee fw file update div - Add Zigbee fw file upload - Add online Zigbee fw check - Add IntelHEX fw file check - Fix cutted files while hex save - Add IntelHEX ccfg check inside - Clean debug msg in IntelHEX - Fix close file after IntelHEX - Add IntelHEX 2652R7 and 1352P7 support
1 parent cea0ce3 commit 1c0b1b9

10 files changed

+136
-39
lines changed

bin/UZG-01.bin

10.8 KB
Binary file not shown.

bin/UZG-01_v0.1.9.full.bin

-1020 KB
Binary file not shown.

bin/UZG-01_v0.2.0.full.bin

1 MB
Binary file not shown.

platformio.ini

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ lib_deps =
3232
marian-craciunescu/ESP32Ping@>=1.7
3333
sstaub/Ticker@>=4.4.0
3434
knolleary/PubSubClient@^2.8
35+
ESP Async WebServer
3536
monitor_filters = esp32_exception_decoder, default, log2file
3637
monitor_speed = 115200
3738
upload_speed = 460800

src/config.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#define BSL_LEVEL 0 //0-LOW 1-HIGH
3333

3434

35-
const int16_t overseerInterval = 10 * 1000; // check lan or wifi connection every 5sec
35+
const int16_t overseerInterval = 5 * 1000; // check lan or wifi connection every 5sec
3636
const uint8_t overseerMaxRetry = 3; // 5x12 = 60sec delay for AP start
3737
const uint8_t LED_USB = 12; // RED
3838
const uint8_t LED_PWR = 14; // BLUE

src/version.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

22
// AUTO GENERATED FILE, DO NOT EDIT
33
#ifndef VERSION
4-
#define VERSION "0.1.9"
4+
#define VERSION "0.2.0"
55
#endif
66
#ifndef BUILD_TIMESTAMP
7-
#define BUILD_TIMESTAMP "2024-01-13 16:19:12.097501"
7+
#define BUILD_TIMESTAMP "2024-01-14 18:40:00.000000"
88
#endif
99

src/web.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,7 @@ void progressFunc(unsigned int progress, unsigned int total)
15691569
float percent = ((float)progress / total) * 100.0;
15701570

15711571
sendEvent(tagESP_FW_progress, eventLen, String(percent));
1572+
printLogMsg(String(percent));
15721573

15731574
if (int(percent) % 5 == 0)
15741575
{

src/websrc/html/PAGE_SYSTOOLS.html

+69-22
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,11 @@
114114
<textarea class="form-control col-sm-12 mb-2" id="console" rows="8"></textarea>
115115
<button type="button" data-cmd="8" onclick="$('console').val('')"
116116
class="btn btn-outline-primary col-sm-12 col-md-auto mb-1 me-1">Clear Console</button>
117-
<button type="button" data-cmd="11" class="btn btn-outline-accent2 col-sm-12 col-md-auto mb-1 me-1">Check
117+
<button type="button" data-cmd="11"
118+
class="btn btn-outline-accent2 col-sm-12 col-md-auto mb-1 me-1">Check
118119
Zigbee connection</button>
119-
<button type="button" data-cmd="10" class="btn btn-outline-success col-sm-12 col-md-auto mb-1 me-1">Check
120+
<button type="button" data-cmd="10"
121+
class="btn btn-outline-success col-sm-12 col-md-auto mb-1 me-1">Check
120122
Zigbee revision</button>
121123
</div>
122124
</div>
@@ -183,9 +185,22 @@
183185
<label id='file-input' for='file'> Choose file...</label>
184186
<input id="updButton" type='submit' class='btn btn-warning mb-2' value='ESP32 file update' disabled>
185187
<br>
186-
<div id='prg'></div>
187-
<div id='prgbar'>
188-
<div id='bar'></div>
188+
<div class="container" style="max-width: 300px; margin-top: 30px;">
189+
<div id='prg'></div>
190+
<div id='prgbar'>
191+
<div id='bar'></div>
192+
</div>
193+
</div>
194+
<br>
195+
<div class="container" style="max-width: 300px; margin-top: 15px;">
196+
<div class="row">
197+
<button type="button" id="upd_esp_git" class="btn btn-warning col-sm-12 mb-2">Install latest from
198+
Github</button>
199+
</div>
200+
<div class="row">
201+
<button type="button" id="info_esp_git" class="btn btn-outline-warning col-sm-12 flsh_esp mb-2">Show
202+
verison info</button>
203+
</div>
189204
</div>
190205
</form>
191206
</div>
@@ -209,23 +224,23 @@
209224
</form>
210225
</div>
211226
</div>
212-
</div>-->
227+
</div> data-cmd="9" -->
213228

214-
<div class="col-sm-12 col-md-6 mb-4">
229+
<!-- <div class="col-sm-12 col-md-6 mb-4">
215230
<div class='card'>
216231
<div class='card-header'>ESP32 OTA online update</div>
217232
<div class='card-body'>
218233
<div class="container" style="max-width: 400px;">
219234
<div class="row">
220-
<button type="button" data-cmd="9" id="upd_esp_git" class="btn btn-warning col-sm-12 mb-2">Install latest from Github</button>
235+
<button type="button" id="upd_esp_git" class="btn btn-warning col-sm-12 mb-2">Install latest from Github</button>
221236
</div>
222237
<div class="row">
223238
<button type="button" class="btn btn-outline-warning col-sm-12 flsh_esp mb-2">Show changelog</button>
224239
</div>
225240
</div>
226241
</div>
227242
</div>
228-
</div>
243+
</div> -->
229244

230245
<!-- <div class="col-sm-12 col-md-6 mb-4">
231246
<div class='card'>
@@ -280,6 +295,15 @@
280295
e.preventDefault();
281296
var form = $('#upload_form')[0];
282297
var data = new FormData(form);
298+
299+
ESPfwStartEvents();
300+
301+
//setTimeout(function () {
302+
// $.get(apiLink + api.actions.API_CMD + "&cmd=9", function (data) { });
303+
// console.log("[flash] start");
304+
// $('#prg').html('Github download starting...');
305+
//}, 500);
306+
283307
$.ajax({
284308
url: '/update',
285309
type: 'POST',
@@ -288,20 +312,21 @@
288312
processData: false,
289313
xhr: function () {
290314
var xhr = new window.XMLHttpRequest();
291-
xhr.upload.addEventListener('progress', function (evt) {
292-
if (evt.lengthComputable) {
293-
var per = evt.loaded / evt.total;
294-
$('#prg').html('progress: ' + Math.round(per * 100) + '%');
295-
$('#bar').css('width', Math.round(per * 100) + '%');
296-
}
297-
}, false);
315+
//xhr.upload.addEventListener('progress', function (evt) {
316+
// if (evt.lengthComputable) {
317+
// var per = evt.loaded / evt.total;
318+
// $('#prg').html('progress: ' + Math.round(per * 100) + '%');
319+
// $('#bar').css('width', Math.round(per * 100) + '%');
320+
// }
321+
//}, false);
322+
298323
return xhr;
299324
},
300325
success: function (d, s) {
301326
console.log('success!');
302-
$('#prg').html('Update completed!<br>Rebooting!');
327+
//$('#prg').html('Update completed!<br>Rebooting!');
303328
//window.location.href = '/';
304-
rebootWait();
329+
//rebootWait();
305330
},
306331
error: function (a, b, c) {
307332
}
@@ -339,17 +364,39 @@
339364
}
340365
});
341366
});
342-
367+
343368

344369
$('button#upd_esp_git').click(function () {
345370

346371
console.log('Update from Git started... Just be patient!');
347-
//$('#prg').html('Update from Git started...<br>Just be patient!');
348372
localStorage.setItem('update_notify', 0);
349373
espFlashGitWait();
350-
//ESPfwStartEvents();
351374

352-
});
375+
});
376+
</script>
377+
<script src="https://unpkg.com/[email protected]/dist/commonmark.js"></script>
378+
<script>
379+
380+
$('button#info_esp_git').click(function () {
381+
382+
383+
processResponses().then(combinedData => {
384+
385+
var asset = combinedData.jsonData.assets[0];
386+
var downloadCount = 0;
387+
for (var i = 0; i < combinedData.jsonData.assets.length; i++) {
388+
downloadCount += combinedData.jsonData.assets[i].download_count;
389+
}
390+
var text = "Local version is v" + combinedData.textData + ". GitHub version is " + combinedData.jsonData.tag_name + " and it was downloaded " + downloadCount.toLocaleString() + " times. It's your turn now 🚀";
391+
392+
var reader = new commonmark.Parser();
393+
var writer = new commonmark.HtmlRenderer();
394+
var parsed = reader.parse(combinedData.jsonData.body);
395+
var chglog = writer.render(parsed);
396+
397+
modalConstructor("espFlashGitInfo", { text, chglog });
398+
});
399+
});
353400

354401

355402
</script>

src/websrc/js/functions.js

+61-13
Original file line numberDiff line numberDiff line change
@@ -462,15 +462,22 @@ function rebootWait() {
462462
}
463463

464464
function espFlashGitWait() {
465+
ESPfwStartEvents();
466+
//setTimeout(function () {
467+
// modalConstructor("espFlashGitWait");
468+
// console.log("[espFlashGitWait] start");
469+
//}, 500);
465470
setTimeout(function () {
466-
modalConstructor("espFlashGitWait");
467-
console.log("[espFlashGitWait] start");
471+
$.get(apiLink + api.actions.API_CMD + "&cmd=9", function (data) { });
472+
console.log("[flash] start");
473+
$('#prg').html('Github download starting...');
468474
}, 500);
469475
}
470476

471477
function ESPfwStartEvents() {
472478
var source = new EventSource('/events');
473479
console.log("Events try");
480+
474481
source.addEventListener('open', function (e) {
475482
console.log("Events Connected");
476483
}, false);
@@ -480,11 +487,30 @@ function ESPfwStartEvents() {
480487
console.log("Events Err");
481488
}
482489
}, false);
490+
483491
source.addEventListener('ESP_FW_prgs', function (e) {
484-
const val = e.data + "%";
485-
console.log(val);
486-
$('#prg').html('progress: ' + val);
487-
$('#bar').css('width', val);
492+
493+
//const val = e.data + "%";
494+
//console.log(val);
495+
496+
$('#prg').html('progress: ' + Math.round(e.data) + '%');
497+
$('#bar').css('width', Math.round(e.data) + '%');
498+
499+
if (Math.round(e.data) > 99.5) {
500+
setTimeout(function () {
501+
$('#prg').html('Update completed!<br>Rebooting!');
502+
//window.location.href = '/';
503+
rebootWait();
504+
}, 250);
505+
}
506+
//const data = e.data.replaceAll("`", "<br>");
507+
//$(modalBtns).html("");
508+
//$("#zbFlshPgsTxt").html(data);
509+
//$(".progress").addClass(classHide);
510+
//$(modalBody).html(e.data).css("color", "red");
511+
//modalAddClose();
512+
513+
488514
}, false);
489515
}
490516

@@ -680,6 +706,29 @@ function modalConstructor(type, params) {
680706
}
681707
}).appendTo(modalBtns);
682708
break;
709+
case "espFlashGitInfo":
710+
$(headerText).text("Latest ESP32 firmware");
711+
$(modalBody).text(params.text);
712+
$(params.chglog).appendTo(modalBody);
713+
$('<button>', {
714+
type: "button",
715+
"class": "btn btn-primary",
716+
text: "Close",
717+
click: function () {
718+
closeModal();
719+
}
720+
}).appendTo(modalBtns);
721+
$('<button>', {
722+
type: "button",
723+
"class": "btn btn-warning",
724+
text: "Update now",
725+
click: function () {
726+
closeModal();
727+
localStorage.setItem('update_notify', 0);
728+
espFlashGitWait();
729+
}
730+
}).appendTo(modalBtns);
731+
break;
683732
case "espFlashGitWait":
684733
$(headerText).text("ESP32 GIT UPDATE");
685734
$(modalBody).text("Downloading and flashing latest release from Github. 🚀 This window will automatically close when the device reboots.");
@@ -718,22 +767,21 @@ function modalConstructor(type, params) {
718767
$(modalBody).text(params);
719768
$('<button>', {
720769
type: "button",
721-
"class": "btn btn-warning",
770+
"class": "btn btn-primary",
722771
text: "Later",
723772
click: function () {
724-
localStorage.setItem('update_notify', 1);
725773
closeModal();
774+
localStorage.setItem('update_notify', 0);
726775
}
727776
}).appendTo(modalBtns);
728777
$('<button>', {
729778
type: "button",
730-
"class": "btn btn-success",
731-
text: "Update now",
779+
"class": "btn btn-danger",
780+
text: "Don't remind",
732781
click: function () {
733782
closeModal();
734-
$.get(apiLink + api.actions.API_CMD + "&cmd=9", function (data) { });
735-
localStorage.setItem('update_notify', 0);
736-
espFlashGitWait();
783+
localStorage.setItem('update_notify', 1);
784+
//espFlashGitWait();
737785
}
738786
}).appendTo(modalBtns);
739787
break;

tools/version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.9
1+
0.2.0

0 commit comments

Comments
 (0)