diff --git a/code/espurna/data/script.js.gz b/code/espurna/data/script.js.gz index c85032e7..168524e0 100644 Binary files a/code/espurna/data/script.js.gz and b/code/espurna/data/script.js.gz differ diff --git a/code/espurna/ota.ino b/code/espurna/ota.ino index ff4137ce..07f27c5d 100644 --- a/code/espurna/ota.ino +++ b/code/espurna/ota.ino @@ -24,10 +24,13 @@ void otaSetup() { ArduinoOTA.onStart([]() { DEBUG_MSG("[OTA] Start\n"); + wsSend("{\"message\": \"OTA update started\"}"); }); ArduinoOTA.onEnd([]() { DEBUG_MSG("\n[OTA] End\n"); + wsSend("{\"action\": \"reload\"}"); + delay(100); }); ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { diff --git a/code/espurna/pow.ino b/code/espurna/pow.ino index 0b2d6910..c71c282c 100644 --- a/code/espurna/pow.ino +++ b/code/espurna/pow.ino @@ -181,7 +181,7 @@ void powLoop() { String output; root.printTo(output); - wsSend((char *) output.c_str()); + wsSend(output.c_str()); if (--report_count == 0) { diff --git a/code/espurna/relay.ino b/code/espurna/relay.ino index 356fc630..3a2c6b5f 100644 --- a/code/espurna/relay.ino +++ b/code/espurna/relay.ino @@ -52,7 +52,7 @@ String relayString() { void relayWS() { String output = relayString(); - wsSend((char *) output.c_str()); + wsSend(output.c_str()); } bool relayStatus(unsigned char id) { diff --git a/code/espurna/web.ino b/code/espurna/web.ino index d0aa13e6..41d085fb 100644 --- a/code/espurna/web.ino +++ b/code/espurna/web.ino @@ -30,24 +30,24 @@ Ticker deferred; // WEBSOCKETS // ----------------------------------------------------------------------------- -bool wsSend(char * payload) { - //DEBUG_MSG("[WEBSOCKET] Broadcasting '%s'\n", payload); +bool wsSend(const char * payload) { + DEBUG_MSG("[WEBSOCKET] Broadcasting '%s'\n", payload); ws.textAll(payload); } -bool wsSend(uint32_t client_id, char * payload) { - //DEBUG_MSG("[WEBSOCKET] Sending '%s' to #%ld\n", payload, client_id); +bool wsSend(uint32_t client_id, const char * payload) { + DEBUG_MSG("[WEBSOCKET] Sending '%s' to #%ld\n", payload, client_id); ws.text(client_id, payload); } void wsMQTTCallback(unsigned int type, const char * topic, const char * payload) { if (type == MQTT_CONNECT_EVENT) { - wsSend((char *) "{\"mqttStatus\": true}"); + wsSend("{\"mqttStatus\": true}"); } if (type == MQTT_DISCONNECT_EVENT) { - wsSend((char *) "{\"mqttStatus\": false}"); + wsSend("{\"mqttStatus\": false}"); } } @@ -564,8 +564,6 @@ ArRequestHandlerFunction _onRelayStatusWrapper(unsigned int relayID) { if (request->method() == HTTP_PUT) { if (request->hasParam("status", true)) { AsyncWebParameter* p = request->getParam("status", true); - wsSend((char *) String(relayID).c_str()); - wsSend((char *) p->value().c_str()); unsigned int value = p->value().toInt(); if (value == 2) { relayToggle(relayID); diff --git a/code/html/custom.js b/code/html/custom.js index cae8fc19..118c1ac7 100644 --- a/code/html/custom.js +++ b/code/html/custom.js @@ -207,6 +207,8 @@ function processData(data) { window.location = "/"; }); + } else { + window.location = "/"; } }