Browse Source

fixed timezone for time sync from browser #336 (thx @DanielR92)

pull/317/head
lumapu 2 years ago
parent
commit
dbdc2ad5ab
  1. 2
      tools/esp8266/app.cpp
  2. 4
      tools/esp8266/html/serial.html
  3. 5
      tools/esp8266/html/setup.html
  4. 6
      tools/esp8266/webApi.cpp

2
tools/esp8266/app.cpp

@ -125,7 +125,7 @@ void app::loop(void) {
mPayload[iv->id].txId = p->packet[0];
DPRINTLN(DBG_DEBUG, F("Response from devcontrol request received"));
iv->devControlRequest = false;
if (p->packet[12] == ActivePowerContr && p->packet[13] == 0x00) {
if ((p->packet[12] == ActivePowerContr) && (p->packet[13] == 0x00)) {
if (p->packet[10] == 0x00 && p->packet[11] == 0x00)
DPRINTLN(DBG_INFO, F("Inverter ") + String(iv->id) + F(" has accepted power limit set point ") + String(iv->powerLimit[0]) + F(" with PowerLimitControl ") + String(iv->powerLimit[1]));
else

4
tools/esp8266/html/serial.html

@ -42,9 +42,9 @@
<select name="pwrlimcntrl" id="pwrlimcntrl">
<option value="" selected disabled hidden>select the unit and persistence</option>
<option value="0">absolute in Watt non persistent</option>
<option value="1">relativ in percent non persistent</option>
<option value="1">relative in percent non persistent</option>
<option value="256">absolute in Watt persistent</option>
<option value="257">relativ in percent persistent</option>
<option value="257">relative in percent persistent</option>
</select>
<br/>
<input type="button" value="Send Power Limit" class="btn" id="sendpwrlim"/>

5
tools/esp8266/html/setup.html

@ -135,16 +135,17 @@
function apiCb(obj) {
var e = document.getElementById("apiResult");
if(obj["success"])
e.innerHTML = "ok";
e.innerHTML = "command excuted";
else
e.innerHTML = "Error: " + obj["error"];
}
function setTime() {
var date = new Date();
var offset = date.getTimezoneOffset() * -60;
var obj = new Object();
obj.cmd = "set_time";
obj.ts = parseInt(date.getTime() / 1000);
obj.ts = parseInt(offset + (date.getTime() / 1000));
getAjax("/api/setup", apiCb, "POST", JSON.stringify(obj));
}

6
tools/esp8266/webApi.cpp

@ -392,12 +392,10 @@ bool webApi::setCtrl(DynamicJsonDocument jsonIn, JsonObject jsonOut) {
//-----------------------------------------------------------------------------
bool webApi::setSetup(DynamicJsonDocument jsonIn, JsonObject jsonOut) {
if(F("set_time") == jsonIn[F("cmd")]) {
if(F("set_time") == jsonIn[F("cmd")])
mApp->setTimestamp(jsonIn[F("ts")]);
}
else if(F("sync_ntp") == jsonIn[F("cmd")]) {
else if(F("sync_ntp") == jsonIn[F("cmd")])
mApp->setTimestamp(0); // 0: update ntp flag
}
else {
jsonOut[F("error")] = F("unknown cmd");
return false;

Loading…
Cancel
Save