Skip to content

Commit

Permalink
add function to modify SOC over webUI
Browse files Browse the repository at this point in the history
  • Loading branch information
softwarecrash committed Feb 11, 2024
1 parent 3d7575d commit f8d20d2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
platform = [email protected]
framework = arduino
monitor_speed = 115200
custom_prog_version = 2.12.0
custom_prog_version = 2.12.1A3
build_flags =
-DVERSION=${this.custom_prog_version}
-DPIO_SRC_NAM="Daly2MQTT"
Expand Down
14 changes: 13 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,18 @@ void handleWebSocketMessage(void *arg, uint8_t *data, size_t len)
DEBUG_PRINTLN(F("<WEBS> wakeup manual from Web"));
DEBUG_WEBLN(F("<WEBS> wakeup manual from Web"));
}
if (strncmp((char *)data , "setSOC_", 7) == 0)
{
char* socVal = (char *)&data[7];
if(atof(socVal) >= 0 && atof(socVal) <= 100)
{
DEBUG_WEBLN("<WEBS> webUI Change SOC to: " + (String)atof(socVal));
bms.setSOC(atof(socVal));
} else {
DEBUG_WEBLN(F("<WEBS> webUI Change SOC rejected, value out of range"));
}

}
mqtttimer = (_settings.data.mqttRefresh * 1000) * (-1);
webSocketAction = true;
}
Expand Down Expand Up @@ -382,7 +394,7 @@ void setup()

AsyncWiFiManager wm(&server, &dns);
wm.setDebugOutput(false); // disable wifimanager debug output
wm.setMinimumSignalQuality(20); // filter weak wifi signals
wm.setMinimumSignalQuality(25); // filter weak wifi signals
// wm.setConnectTimeout(15); // how long to try to connect for before continuing
wm.setConfigPortalTimeout(120); // auto close configportal after n seconds
wm.setSaveConfigCallback(saveConfigCallback);
Expand Down
12 changes: 12 additions & 0 deletions src/webpages/HTML_MAIN.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ <h2 id="devicename"></h2>
BarChart(data);
alert(data);


if (data.Pack.Status == "Offline") {
document.getElementById("status").style.color = "red";
document.getElementById("wakebms").style.display = '';
Expand Down Expand Up @@ -238,6 +239,7 @@ <h2 id="devicename"></h2>
document.getElementById('relaisOutputActive').addEventListener('click', RelaisOutputSwitch);
document.getElementById('wakebms').addEventListener('click', wakeBms);
document.getElementById('ClickSOC').addEventListener('click', cellState);
document.getElementById('ClickSOC').addEventListener('dblclick',SetSOC);
}

function wakeBms() {
Expand Down Expand Up @@ -349,6 +351,16 @@ <h2 id="devicename"></h2>
}
}

function SetSOC() {
newSOC = prompt ("Set the SOC to", ($('#packSOC').attr('aria-valuenow')));
if (newSOC != null) {
var sendSOC = "setSOC_"+newSOC
console.log(sendSOC)
websocket.send(sendSOC);
}

}

function checkWS() {
if (websocket.readyState !== WebSocket.CLOSED) {
websocket.send("ping");
Expand Down

0 comments on commit f8d20d2

Please sign in to comment.