]> git.0d.be Git - PanikSwitch.git/commitdiff
put udp code behind ENABLE_UDP #define
authorFrédéric Péters <fpeters@0d.be>
Wed, 24 Mar 2021 14:16:47 +0000 (15:16 +0100)
committerFrédéric Péters <fpeters@0d.be>
Thu, 25 Mar 2021 07:13:36 +0000 (08:13 +0100)
FINAL2013V2.ino

index 0734bd8f647b4fe7cd523b2afee4b801359fa0e6..5415ece0f4107be3f9a70344bb845a50cc71626c 100644 (file)
@@ -1,6 +1,7 @@
 // Panik Web Form Demo
 
 #define SERIAL_DEBUG
+#define ENABLE_UDP
 
 
 // define network constants
@@ -14,7 +15,9 @@
 #include <SPI.h>
 #include <SD.h>
 #include <Ethernet.h>
+#ifdef ENABLE_UDP
 #include <EthernetUdp.h>
+#endif
 
 // include third party libraries
 #include "WebServer.h"
@@ -91,9 +94,11 @@ static uint8_t mac[] = MAC_ADDRESS;
 // instanciate web server
 WebServer webserver(PREFIX, 80);
 
+#ifdef ENABLE_UDP
 // and EthernetUDP instance to send notifications
 EthernetUDP Udp;
 IPAddress udp_remote_ip(192, 168, 17, 224);
+#endif
 
 
 #define NAMELEN 4
@@ -181,11 +186,13 @@ void setup()
     #endif
     while (1) ;
   }
+  #ifdef ENABLE_UDP
   if (! Udp.begin(1312)) {
     #ifdef SERIAL_DEBUG
     Serial.println(F("Failed to initiate UDP"));
     #endif
   }
+  #endif
 
   // set mode for used pins
   pinMode(RELAY_RED_LEDS, OUTPUT);
@@ -279,11 +286,13 @@ void loop()
         Serial.print(F("Active Selection: "));
         Serial.println(activeSelection);
         #endif
+        #ifdef ENABLE_UDP
         // notify over UDP
         snprintf(str_selection, 19, "{\"active\": %d}", activeSelection);
         Udp.beginPacket(udp_remote_ip, 1312);
         Udp.write(str_selection);
         Udp.endPacket();
+        #endif
         break;
       }
   }