]> git.0d.be Git - PanikSwitch.git/blobdiff - FINAL2013V2.ino
also send udp notification when setting over HTTP
[PanikSwitch.git] / 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
+
       }
     }
   }