|
@ -14,6 +14,7 @@ Copyright (C) 2016-2017 by Xose Pérez <xose dot perez at gmail dot com> |
|
|
#include <Hash.h>
|
|
|
#include <Hash.h>
|
|
|
#include <AsyncJson.h>
|
|
|
#include <AsyncJson.h>
|
|
|
#include <ArduinoJson.h>
|
|
|
#include <ArduinoJson.h>
|
|
|
|
|
|
#include <Ticker.h>
|
|
|
|
|
|
|
|
|
AsyncWebServer server(80); |
|
|
AsyncWebServer server(80); |
|
|
AsyncWebSocket ws("/ws"); |
|
|
AsyncWebSocket ws("/ws"); |
|
@ -24,6 +25,7 @@ typedef struct { |
|
|
} ws_ticket_t; |
|
|
} ws_ticket_t; |
|
|
|
|
|
|
|
|
ws_ticket_t _ticket[WS_BUFFER_SIZE]; |
|
|
ws_ticket_t _ticket[WS_BUFFER_SIZE]; |
|
|
|
|
|
Ticker deferred; |
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
// -----------------------------------------------------------------------------
|
|
|
// WEBSOCKETS
|
|
|
// WEBSOCKETS
|
|
@ -75,7 +77,12 @@ void _wsParse(uint32_t client_id, uint8_t * payload, size_t length) { |
|
|
DEBUG_MSG("[WEBSOCKET] Requested action: %s\n", action.c_str()); |
|
|
DEBUG_MSG("[WEBSOCKET] Requested action: %s\n", action.c_str()); |
|
|
|
|
|
|
|
|
if (action.equals("reset")) ESP.reset(); |
|
|
if (action.equals("reset")) ESP.reset(); |
|
|
if (action.equals("reconnect")) wifiDisconnect(); |
|
|
|
|
|
|
|
|
if (action.equals("reconnect")) { |
|
|
|
|
|
|
|
|
|
|
|
// Let the HTTP request return and disconnect after 100ms
|
|
|
|
|
|
deferred.once_ms(100, wifiDisconnect); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
if (action.equals("on")) relayStatus(relayID, true); |
|
|
if (action.equals("on")) relayStatus(relayID, true); |
|
|
if (action.equals("off")) relayStatus(relayID, false); |
|
|
if (action.equals("off")) relayStatus(relayID, false); |
|
|
|
|
|
|
|
|