Skip to content

Commit

Permalink
update2.html, glcd.cpp, evse.h, evse.cpp: Implement AutoUpdate, default
Browse files Browse the repository at this point in the history
= OFF!!
  • Loading branch information
dingo35 committed Jun 20, 2024
1 parent 5401cce commit 9210e49
Show file tree
Hide file tree
Showing 39 changed files with 428 additions and 4,615 deletions.
47 changes: 39 additions & 8 deletions SmartEVSE-3/data/update2.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,46 @@
let REPO_FACT="SmartEVSE-3";
let OWNER_COMM="dingo35";
let REPO_COMM="SmartEVSE-3.5";
let update_url="";
// Helper function to display upload status
var setStatus = function(text) {
document.getElementById('el3').innerText = text;
};

function fetchProgress() {
fetch('/autoupdate')
.then(res => res.json())
.then(data => {
// code to handle the response
if (data.progress == -1) { //sucess
setStatus('Firmware update succesfully completed, will reboot as soon as no EV is connected.');
}
else {
if (data.progress == -2) { //fail
setStatus('ERROR: Firmware update fail.');
} else {
setStatus('Firmware update progress: ' + data.progress + '/' + data.size);
}
}
})
.catch(err => {
console.error('Error: ', err)
})
}
function update_fw(owner, debug) {
window.location.href = "/autoupdate?owner=" + owner + "&debug=" + debug;
fetch("/autoupdate?owner=" + owner + "&debug=" + debug)
.then(res => res.json())
.then(data => {
setStatus('Firmware update progress: ' + data.progress + '/' + data.size);
// code to handle the response
var fetchInterval = 1000; // 1 seconds.
// Invoke the request every 1 seconds.
setInterval(fetchProgress, fetchInterval);
})
.catch(err => {
console.error('Error: ', err)
})
}

</script>
</head>
<body onload="loadData()">
Expand Down Expand Up @@ -112,11 +148,6 @@
// Copyright (c) 2020 Cesanta Software Limited
// All rights reserved

// Helper function to display upload status
var setStatus = function(text) {
document.getElementById('el3').innerText = text;
};

// When user clicks on a button, trigger file selection dialog
var button = document.getElementById('el2');
button.onclick = function(ev) {
Expand All @@ -131,7 +162,7 @@
var url = '/update?offset=' + offset + '&file=' + encodeURIComponent(name) + '&size=' + data.length;
var ok;
if (offset + chunk.length == data.length) {
setStatus('Upload of ' + name + ' finished, you can close this page.');
setStatus('Upload of ' + name + ' finished, will reboot. You can close this page.');
window.location.href = "/";
}
else
Expand Down
20 changes: 11 additions & 9 deletions SmartEVSE-3/include/evse.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ extern RemoteDebug Debug;
#define DELAYEDSTOPTIME 0 // The default StopTime for delayed charged, 0 = not stopping
#define SOLARSTARTTIME 40 // Seconds to keep chargecurrent at 6A
#define OCPP_MODE 0

#define AUTOUPDATE 0 // default for Automatic Firmware Update: 0 = disabled, 1 = enabled

// Mode settings
#define MODE_NORMAL 0
Expand Down Expand Up @@ -397,18 +397,19 @@ extern RemoteDebug Debug;
#define MENU_EMCUSTOM_EDIVISOR 32 // 0x0217: Divisor for Energy (kWh) of custom electric meter (10^x)
#define MENU_EMCUSTOM_READMAX 33 // 0x0218: Maximum register read (ToDo)
#define MENU_WIFI 34 // 0x0219: WiFi mode
#define MENU_C2 35
#define MENU_MAX_TEMP 36
#define MENU_SUMMAINS 37
#define MENU_AUTOUPDATE 35
#define MENU_C2 36
#define MENU_MAX_TEMP 37
#define MENU_SUMMAINS 38
#if ENABLE_OCPP == 0
#define MENU_OFF 38 // so access bit is reset and charging stops when pressing < button 2 seconds
#define MENU_ON 39 // so access bit is set and charging starts when pressing > button 2 seconds
#define MENU_EXIT 40
#else
#define MENU_OCPP 38 // OCPP Disable / Enable / Further modes
#define MENU_OFF 39 // so access bit is reset and charging stops when pressing < button 2 seconds
#define MENU_ON 40 // so access bit is set and charging starts when pressing > button 2 seconds
#define MENU_EXIT 41
#else
#define MENU_OCPP 39 // OCPP Disable / Enable / Further modes
#define MENU_OFF 40 // so access bit is reset and charging stops when pressing < button 2 seconds
#define MENU_ON 41 // so access bit is set and charging starts when pressing > button 2 seconds
#define MENU_EXIT 42
#endif

#define MENU_STATE 50
Expand Down Expand Up @@ -564,6 +565,7 @@ const struct {
{"ENE DIVI","Divisor for Energy (kWh) of custom electric meter", 0, 7, EMCUSTOM_EDIVISOR},
{"READ MAX","Max register read at once of custom electric meter", 3, 255, 3},
{"WIFI", "Connect to WiFi access point", 0, 2, WIFI_MODE},
{"AUTOUPDAT","Automatic Firmware Update", 0, 1, AUTOUPDATE},
{"CONTACT 2","Contactor2 (C2) behaviour", 0, sizeof(StrEnableC2) / sizeof(StrEnableC2[0])-1, ENABLE_C2},
{"MAX TEMP","Maximum temperature for the EVSE module", 40, 75, MAX_TEMPERATURE},
{"SUM MAINS","Capacity Rate limit on sum of MAINS Current (A)", 10, 600, MAX_SUMMAINS},
Expand Down
24 changes: 0 additions & 24 deletions SmartEVSE-3/lib/esp32FOTA/LICENSE

This file was deleted.

Loading

0 comments on commit 9210e49

Please sign in to comment.