]> git.0d.be Git - PanikSwitch.git/commitdiff
also send udp notification when setting over HTTP
authorFrédéric Péters <fpeters@0d.be>
Wed, 24 Mar 2021 17:03:02 +0000 (18:03 +0100)
committerFrédéric Péters <fpeters@0d.be>
Thu, 25 Mar 2021 07:13:36 +0000 (08:13 +0100)
FINAL2013V2.ino

index 544548175e1087a7de32c4324c8ee52fb8cab707..a486110e1625f991b2af29dc2c90fa1ffffd9f61 100644 (file)
@@ -130,10 +130,25 @@ void webCmd(WebServer &server, WebServer::ConnectionType type, char *url_tail, b
     while (server.readPOSTparam(name, NAMELEN, value, VALUELEN))
     {
       if (strcmp(name, "s") == 0) {
+        char str_selection[20];
+
         digitalWrite(ledsArray[activeSelection], RELAY_STATE_CLOSED);
         blinkingSelection = static_cast<switchSelection_t>(atoi(value));
         activeSelection = static_cast<switchSelection_t>(atoi(value));
         response_status = POST_OK;
+
+        #ifdef ENABLE_UDP
+        // notify over UDP
+        snprintf(str_selection, 19, "{\"active\": %d}", activeSelection);
+        #ifdef SERIAL_DEBUG
+        Serial.println(F("Sending UDP... "));
+        Serial.println(str_selection);
+        #endif
+        Udp.beginPacket(udp_remote_ip, 1312);
+        Udp.write(str_selection);
+        Udp.endPacket();
+        #endif
+
       }
     }
   }