From 5c575cd3162b75bf4a1fbeecfa146ce49e194143 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 24 Mar 2021 15:16:47 +0100 Subject: [PATCH] put udp code behind ENABLE_UDP #define --- FINAL2013V2.ino | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/FINAL2013V2.ino b/FINAL2013V2.ino index 0734bd8..5415ece 100644 --- a/FINAL2013V2.ino +++ b/FINAL2013V2.ino @@ -1,6 +1,7 @@ // Panik Web Form Demo #define SERIAL_DEBUG +#define ENABLE_UDP // define network constants @@ -14,7 +15,9 @@ #include #include #include +#ifdef ENABLE_UDP #include +#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; } } -- 2.39.2