#define MAC_PANIK2 { 0x90, 0xA2, 0xDA, 0x0E, 0xF3, 0x77 }
#define MAC_ADDRESS MAC_PANIK2
-
// include Arduino libraries
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <Ethernet.h>
+#include <EthernetUdp.h>
// include third party libraries
#include "WebServer.h"
// instanciate web server
WebServer webserver(PREFIX, 80);
+// and EthernetUDP instance to send notifications
+EthernetUDP Udp;
+IPAddress udp_remote_ip(192, 168, 17, 224);
+
+
#define NAMELEN 4
#define VALUELEN 4
Serial.println(F("Network Error"));
while (1) ;
}
+ if (! Udp.begin(1312)) {
+ Serial.println(F("Failed to initiate UDP"));
+ }
// set mode for used pins
pinMode(RELAY_RED_LEDS, OUTPUT);
//Serial.println(F("Button 2 released"));
if (activeSelection != blinkingSelection)
{
+ char str_selection[20];
digitalWrite(ledsArray[activeSelection], RELAY_STATE_CLOSED);
activeSelection = blinkingSelection; // relay states must be changed now
Serial.print(F("Active Selection: "));
Serial.println(activeSelection);
+ // notify over UDP
+ snprintf(str_selection, 19, "{\"active\": %d}", activeSelection);
+ Udp.beginPacket(udp_remote_ip, 1312);
+ Udp.write(str_selection);
+ Udp.endPacket();
break;
}
}