Skip to content

Commit 46c43b1

Browse files
committed
update to 0.2.7
- possibility to deactivate basicAuth (Safari Mode) in Settings to fix Problem with Safari Browser - fixed meter reading via API
1 parent 8fdbdf1 commit 46c43b1

File tree

7 files changed

+50
-18
lines changed

7 files changed

+50
-18
lines changed

SimpleEVSE-WiFi.ino

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ bool useRFID = false;
133133
bool useSMeter = false;
134134
bool useMMeter = false;
135135
bool useButton = false;
136+
bool dontUseWsAuthentication = false;
136137
bool inAPMode = false;
137138
bool inFallbackMode = false;
138139
bool isWifiConnected = false;
@@ -849,6 +850,9 @@ bool ICACHE_FLASH_ATTR deactivateEVSE(bool logUpdate) {
849850
meteredKWh = readMeter(0x0156) - startTotal;
850851
}
851852
}
853+
else{
854+
startTotal += meteredKWh;
855+
}
852856
if(logUpdate){
853857
updateLog(false);
854858
}
@@ -878,7 +882,7 @@ bool ICACHE_FLASH_ATTR setEVSEcurrent(){ // telegram 1: write EVSE current
878882
Serial.println(" occured while setting current in EVSE - trying again...");
879883
return false;
880884
}
881-
else{
885+
else{
882886
// register successufully written
883887
if(debug) Serial.println("[ ModBus ] Current successfully set");
884888
evseAmpsConfig = currentToSet; //foce update in WebUI
@@ -1384,7 +1388,14 @@ bool ICACHE_FLASH_ATTR loadConfiguration() {
13841388
int wmode = json["wmode"];
13851389
adminpass = strdup(json["adminpwd"]);
13861390

1387-
ws.setAuthentication("admin", adminpass);
1391+
if(json.containsKey("wsauth")){
1392+
dontUseWsAuthentication = json["wsauth"];
1393+
}
1394+
1395+
if(!dontUseWsAuthentication){
1396+
ws.setAuthentication("admin", adminpass);
1397+
if(debug)Serial.println("[ Websocket ] Use Basic Authentication for Websocket");
1398+
}
13881399
server.addHandler(new SPIFFSEditor("admin", adminpass));
13891400

13901401
queryEVSE();
@@ -1721,7 +1732,7 @@ void ICACHE_FLASH_ATTR startWebserver() {
17211732
// HTTP basic authentication
17221733
server.on("/login", HTTP_GET, [](AsyncWebServerRequest * request) {
17231734
if (!request->authenticate("admin", adminpass)) {
1724-
return request->requestAuthentication();
1735+
return request->requestAuthentication();
17251736
}
17261737
request->send(200, "text/plain", "Success");
17271738
});

bin/latest/built.bin

320 Bytes
Binary file not shown.

bin/latest/version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "0.2.6-patch1"
2+
"version": "0.2.7"
33
}

data/config.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@
1818
"maxinstall": "10",
1919
"buttonactive": false,
2020
"avgconsumption": "11.5"
21-
}
21+
"wsauth": false
22+
}

src/websrc.h

Lines changed: 5 additions & 5 deletions
Large diffs are not rendered by default.

websrc/index.htm

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<a href="#" onclick="loadUsers()"><nobr><span class="glyphicon glyphicon-user"></span>&nbsp;&nbsp;Users</nobr></a>
2020
<a href="#" onclick="loadSettings()"><nobr><span class="glyphicon glyphicon-cog"></span>&nbsp;&nbsp;Settings</nobr></a>
2121
<a href="#" onclick="loadLog()"><nobr><span class="glyphicon glyphicon-list-alt"></span>&nbsp;&nbsp;Log</nobr></a>
22-
<div style="position: fixed; bottom: 0px; padding: 10px 10px 10px 10px">v0.2.6-patch1</div>
22+
<div style="position: fixed; bottom: 0px; padding: 10px 10px 10px 10px">v0.2.7</div>
2323
</div>
2424
<!-- Current Modal -->
2525
<div class="modal fade" id="currentModal" tabindex="-1" role="dialog" aria-labelledby="currentModalLabel" aria-hidden="true">
@@ -30,7 +30,7 @@
3030
<h4 class="modal-title" id="current-title">Current&nbsp;<span id="slider_current"></span>&nbsp;A</h4>
3131
</div>
3232
<div class="modal-body">
33-
<div class="""slidecontainer">
33+
<div class="slidecontainer">
3434
<input type="range" min="6" max="25" value="20" class="slider" id="myRange" oninput="handleSlider(this.value)">
3535
</div>
3636
</div>
@@ -136,7 +136,7 @@ <h3 class="text-muted">EVSE Control</h3>
136136
<div class="panel panel-default table-responsive">
137137
<table class="table table-hover" >
138138
<tbody style="transition:0.5s">
139-
<tr data-toggle="modal" data-target="#currentModal" style="transition:0.3s">
139+
<tr onclick="showCurrentModal()">
140140
<th><span class="glyphicon glyphicon-cog"></span>&nbsp;&nbsp;Max. Current >></th>
141141
<td id="evse_current_limit" class="text-right"></td>
142142
</tr>
@@ -366,7 +366,7 @@ <h3 class="text-muted">Settings</h3>
366366
<table class="table table-hover table-striped">
367367
<caption>
368368
<span style="float: left">EVSE Registers</span>
369-
<span style="float: right" class="glyphicon glyphicon-pencil" data-toggle="modal" data-target="#evseRegModal" style="transition:0.3s"></span>
369+
<span style="float: right" class="glyphicon glyphicon-pencil" onclick="showEvseRegModal()"></span>
370370
</caption>
371371
<tr>
372372
<th>1000: Configured Current</th>
@@ -701,6 +701,14 @@ <h6 class="text-muted">Please refer the <a href="https://github.com/CurtRod/Simp
701701
<label class="checkbox-inline"><input type="checkbox" id="checkboxDebug" value="">Active</label>
702702
</form>
703703
</span>
704+
</div>
705+
<div class="row form-group">
706+
<label data-toggle="tooltip" title="Disables BasicAuthentication for Websocket. This opens a security hole but is necessary when using Safari Browser." class="col-xs-3">Disable BasicAuth (Safari Mode)</label>
707+
<span class="col-xs-9 col-md-5">
708+
<form>
709+
<label class="checkbox-inline"><input type="checkbox" id="checkboxSafari" value="">Active</label>
710+
</form>
711+
</span>
704712
</div>
705713
<br>
706714
</div>
@@ -844,7 +852,7 @@ <h4><a href="https://www.paypal.com/pools/c/85c7xRbeay">Donate now!</a></h4>
844852
</div>
845853
<div>
846854
<legend>Update Firmware</legend>
847-
<h6 class="text-muted">Current Firmware Version:&nbsp;0.2.6-patch1</h6>
855+
<h6 class="text-muted">Current Firmware Version:&nbsp;0.2.7</h6>
848856
<h6 class="text-muted">Download <a href="https://github.com/CurtRod/SimpleEVSE-WiFi/releases" target="_blank">latest version</a> from GitHub.</h6>
849857
<form class="form-inline" method="POST" action="/update" enctype="multipart/form-data">
850858
<div class="form-group">
@@ -864,4 +872,4 @@ <h6 class="text-muted"><a href="https://github.com/CurtRod/SimpleEVSE-WiFi" targ
864872
</div>
865873
<script src="script.js" type="text/javascript"></script>
866874
</body>
867-
</html>
875+
</html>

websrc/script.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,9 @@ function listCONF(obj) {
506506
document.getElementById("gain").value = obj.rfidgain;
507507
document.getElementById("gpiobutton").value = obj.buttonpin;
508508

509+
if (typeof obj.wsauth !== "undefined"){
510+
document.getElementById("checkboxSafari").checked = obj.wsauth;
511+
}
509512
if (typeof obj.debug !== "undefined"){
510513
document.getElementById("checkboxDebug").checked = obj.debug;
511514
}
@@ -792,6 +795,7 @@ function saveConf() {
792795
datatosend.dns = document.getElementById("dnsch").value;
793796
}
794797

798+
datatosend.wsauth = document.getElementById("checkboxSafari").checked;
795799
datatosend.debug = document.getElementById("checkboxDebug").checked;
796800

797801
datatosend.rfid = document.getElementById("checkboxRfid").checked;
@@ -1030,6 +1034,14 @@ function closeNav() {
10301034
document.getElementById("mySidenav").style.width = "0";
10311035
}
10321036

1037+
function showCurrentModal() {
1038+
$("#currentModal").modal();
1039+
}
1040+
1041+
function showEvseRegModal() {
1042+
$("#evseRegModal").modal();
1043+
}
1044+
10331045
$(document).ready(function(){
10341046
$('[data-toggle="tooltip"]').tooltip();
10351047
});
@@ -1135,10 +1147,10 @@ function socketErrorListener(evt) {
11351147
}
11361148
function login() {
11371149
var username = "admin"
1138-
var password = document.getElementById("password").value;
1150+
var passwd = document.getElementById("password").value;
11391151
var url = "/login";
11401152
var xhr = new XMLHttpRequest();
1141-
xhr.open("get", url, true, username, password);
1153+
xhr.open("get", url, true, username, passwd);
11421154
xhr.onload = function(e) {
11431155
if (xhr.readyState === 4) {
11441156
if (xhr.status === 200) {

0 commit comments

Comments
 (0)