diff --git a/src/controller_main.cpp b/src/controller_main.cpp index f2e7ebb..48ae83d 100644 --- a/src/controller_main.cpp +++ b/src/controller_main.cpp @@ -122,16 +122,26 @@ void setup() { server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) { request->send(200, "text/plain", "Current Status: To Be done"); }); - server.on("/allon", HTTP_GET, [](AsyncWebServerRequest *request) { + server.on("/allblink", HTTP_GET, [](AsyncWebServerRequest *request) { ws.textAll("blinkLamp"); request->send(200, "text/plain", "Alarming All"); }); - server.on("/alloff", HTTP_GET, [](AsyncWebServerRequest *request) { + server.on("/allnoblink", HTTP_GET, [](AsyncWebServerRequest *request) { ws.textAll("noBlinkLamp"); request->send(200, "text/plain", "Alarm stopped"); }); + server.on("/allon", HTTP_GET, [](AsyncWebServerRequest *request) { + ws.textAll("lampon"); + request->send(200, "text/plain", "Alarming All"); + }); + + server.on("/alloff", HTTP_GET, [](AsyncWebServerRequest *request) { + ws.textAll("lampoff"); + request->send(200, "text/plain", "Alarm stopped"); + }); + server.onNotFound(notFound); server.begin(); @@ -149,7 +159,7 @@ void loop() { if (!inputActive) { // React when the signal starts if (millis() - activateTimeout >= 60000) { // 1 Minute timeout Serial.println("Activate triggered"); - ws.textAll("blinkLamp"); + ws.textAll("lampon"); } } } @@ -162,7 +172,7 @@ void loop() { clearActive = digitalRead(PIN_CLEAR); if (clearActive) { // React when the signal is over Serial.println("Clear triggered"); - ws.textAll("noBlinkLamp"); + ws.textAll("lampoff"); activateTimeout = millis(); } } diff --git a/src/light_main.cpp b/src/light_main.cpp index b7cdd1a..b2095e9 100644 --- a/src/light_main.cpp +++ b/src/light_main.cpp @@ -70,6 +70,16 @@ void noBlinkLamp() { digitalWrite(lampOutputPin, LOW); } +void lampon() { + isBlinking = false; + digitalWrite(lampOutputPin, HIGH); +} + +void lampoff() { + isBlinking = false; + digitalWrite(lampOutputPin, LOW); +} + void webSocketEvent(WStype_t type, uint8_t *payload, size_t length) { switch (type) { @@ -91,6 +101,12 @@ void webSocketEvent(WStype_t type, uint8_t *payload, size_t length) { } else if (strcmp((char *)payload, "noBlinkLamp") == 0) { noBlinkLamp(); Serial.println("Disable Blinking!"); + } else if (strcmp((char *)payload, "lampon") == 0) { + lampon(); + Serial.println("Disable Blinking!"); + } else if (strcmp((char *)payload, "lampoff") == 0) { + lampoff(); + Serial.println("Disable Blinking!"); } break; } @@ -155,15 +171,6 @@ void browseService(const char *service, const char *proto) { void loop() { if (!foundIp && eth_connected && ((millis() - connectTimer) > connectDuration)) { browseService("http", "tcp"); - /* - ip = MDNS.queryHost("a2clcontroller"); - Serial.println(ip); - foundIp = true; - webSocket.begin(ip, 80, "/ws"); - webSocket.onEvent(webSocketEvent); - // webSocket.setAuthorization("user", "Password"); - webSocket.setReconnectInterval(3000); - */ connectTimer = millis(); }