Skip to content

Commit

Permalink
update to 0.2.7
Browse files Browse the repository at this point in the history
- possibility to deactivate basicAuth (Safari Mode) in Settings to fix Problem with Safari Browser
- fixed meter reading via API
  • Loading branch information
CurtRod committed Dec 27, 2018
1 parent 8fdbdf1 commit 46c43b1
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 18 deletions.
17 changes: 14 additions & 3 deletions SimpleEVSE-WiFi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ bool useRFID = false;
bool useSMeter = false;
bool useMMeter = false;
bool useButton = false;
bool dontUseWsAuthentication = false;
bool inAPMode = false;
bool inFallbackMode = false;
bool isWifiConnected = false;
Expand Down Expand Up @@ -849,6 +850,9 @@ bool ICACHE_FLASH_ATTR deactivateEVSE(bool logUpdate) {
meteredKWh = readMeter(0x0156) - startTotal;
}
}
else{
startTotal += meteredKWh;
}
if(logUpdate){
updateLog(false);
}
Expand Down Expand Up @@ -878,7 +882,7 @@ bool ICACHE_FLASH_ATTR setEVSEcurrent(){ // telegram 1: write EVSE current
Serial.println(" occured while setting current in EVSE - trying again...");
return false;
}
else{
else{
// register successufully written
if(debug) Serial.println("[ ModBus ] Current successfully set");
evseAmpsConfig = currentToSet; //foce update in WebUI
Expand Down Expand Up @@ -1384,7 +1388,14 @@ bool ICACHE_FLASH_ATTR loadConfiguration() {
int wmode = json["wmode"];
adminpass = strdup(json["adminpwd"]);

ws.setAuthentication("admin", adminpass);
if(json.containsKey("wsauth")){
dontUseWsAuthentication = json["wsauth"];
}

if(!dontUseWsAuthentication){
ws.setAuthentication("admin", adminpass);
if(debug)Serial.println("[ Websocket ] Use Basic Authentication for Websocket");
}
server.addHandler(new SPIFFSEditor("admin", adminpass));

queryEVSE();
Expand Down Expand Up @@ -1721,7 +1732,7 @@ void ICACHE_FLASH_ATTR startWebserver() {
// HTTP basic authentication
server.on("/login", HTTP_GET, [](AsyncWebServerRequest * request) {
if (!request->authenticate("admin", adminpass)) {
return request->requestAuthentication();
return request->requestAuthentication();
}
request->send(200, "text/plain", "Success");
});
Expand Down
Binary file modified bin/latest/built.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion bin/latest/version.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "0.2.6-patch1"
"version": "0.2.7"
}
3 changes: 2 additions & 1 deletion data/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
"maxinstall": "10",
"buttonactive": false,
"avgconsumption": "11.5"
}
"wsauth": false
}
10 changes: 5 additions & 5 deletions src/websrc.h

Large diffs are not rendered by default.

20 changes: 14 additions & 6 deletions websrc/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<a href="#" onclick="loadUsers()"><nobr><span class="glyphicon glyphicon-user"></span>&nbsp;&nbsp;Users</nobr></a>
<a href="#" onclick="loadSettings()"><nobr><span class="glyphicon glyphicon-cog"></span>&nbsp;&nbsp;Settings</nobr></a>
<a href="#" onclick="loadLog()"><nobr><span class="glyphicon glyphicon-list-alt"></span>&nbsp;&nbsp;Log</nobr></a>
<div style="position: fixed; bottom: 0px; padding: 10px 10px 10px 10px">v0.2.6-patch1</div>
<div style="position: fixed; bottom: 0px; padding: 10px 10px 10px 10px">v0.2.7</div>
</div>
<!-- Current Modal -->
<div class="modal fade" id="currentModal" tabindex="-1" role="dialog" aria-labelledby="currentModalLabel" aria-hidden="true">
Expand All @@ -30,7 +30,7 @@
<h4 class="modal-title" id="current-title">Current&nbsp;<span id="slider_current"></span>&nbsp;A</h4>
</div>
<div class="modal-body">
<div class="""slidecontainer">
<div class="slidecontainer">
<input type="range" min="6" max="25" value="20" class="slider" id="myRange" oninput="handleSlider(this.value)">
</div>
</div>
Expand Down Expand Up @@ -136,7 +136,7 @@ <h3 class="text-muted">EVSE Control</h3>
<div class="panel panel-default table-responsive">
<table class="table table-hover" >
<tbody style="transition:0.5s">
<tr data-toggle="modal" data-target="#currentModal" style="transition:0.3s">
<tr onclick="showCurrentModal()">
<th><span class="glyphicon glyphicon-cog"></span>&nbsp;&nbsp;Max. Current >></th>
<td id="evse_current_limit" class="text-right"></td>
</tr>
Expand Down Expand Up @@ -366,7 +366,7 @@ <h3 class="text-muted">Settings</h3>
<table class="table table-hover table-striped">
<caption>
<span style="float: left">EVSE Registers</span>
<span style="float: right" class="glyphicon glyphicon-pencil" data-toggle="modal" data-target="#evseRegModal" style="transition:0.3s"></span>
<span style="float: right" class="glyphicon glyphicon-pencil" onclick="showEvseRegModal()"></span>
</caption>
<tr>
<th>1000: Configured Current</th>
Expand Down Expand Up @@ -701,6 +701,14 @@ <h6 class="text-muted">Please refer the <a href="https://github.com/CurtRod/Simp
<label class="checkbox-inline"><input type="checkbox" id="checkboxDebug" value="">Active</label>
</form>
</span>
</div>
<div class="row form-group">
<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>
<span class="col-xs-9 col-md-5">
<form>
<label class="checkbox-inline"><input type="checkbox" id="checkboxSafari" value="">Active</label>
</form>
</span>
</div>
<br>
</div>
Expand Down Expand Up @@ -844,7 +852,7 @@ <h4><a href="https://www.paypal.com/pools/c/85c7xRbeay">Donate now!</a></h4>
</div>
<div>
<legend>Update Firmware</legend>
<h6 class="text-muted">Current Firmware Version:&nbsp;0.2.6-patch1</h6>
<h6 class="text-muted">Current Firmware Version:&nbsp;0.2.7</h6>
<h6 class="text-muted">Download <a href="https://github.com/CurtRod/SimpleEVSE-WiFi/releases" target="_blank">latest version</a> from GitHub.</h6>
<form class="form-inline" method="POST" action="/update" enctype="multipart/form-data">
<div class="form-group">
Expand All @@ -864,4 +872,4 @@ <h6 class="text-muted"><a href="https://github.com/CurtRod/SimpleEVSE-WiFi" targ
</div>
<script src="script.js" type="text/javascript"></script>
</body>
</html>
</html>
16 changes: 14 additions & 2 deletions websrc/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,9 @@ function listCONF(obj) {
document.getElementById("gain").value = obj.rfidgain;
document.getElementById("gpiobutton").value = obj.buttonpin;

if (typeof obj.wsauth !== "undefined"){
document.getElementById("checkboxSafari").checked = obj.wsauth;
}
if (typeof obj.debug !== "undefined"){
document.getElementById("checkboxDebug").checked = obj.debug;
}
Expand Down Expand Up @@ -792,6 +795,7 @@ function saveConf() {
datatosend.dns = document.getElementById("dnsch").value;
}

datatosend.wsauth = document.getElementById("checkboxSafari").checked;
datatosend.debug = document.getElementById("checkboxDebug").checked;

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

function showCurrentModal() {
$("#currentModal").modal();
}

function showEvseRegModal() {
$("#evseRegModal").modal();
}

$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
Expand Down Expand Up @@ -1135,10 +1147,10 @@ function socketErrorListener(evt) {
}
function login() {
var username = "admin"
var password = document.getElementById("password").value;
var passwd = document.getElementById("password").value;
var url = "/login";
var xhr = new XMLHttpRequest();
xhr.open("get", url, true, username, password);
xhr.open("get", url, true, username, passwd);
xhr.onload = function(e) {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
Expand Down

0 comments on commit 46c43b1

Please sign in to comment.