You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
/// READ OSC MESSAGES ///
#include <WiFiUdp.h>
#include <OSCMessage.h>
bool light = false; bool fog = false; int humidityctrl = 80; bool fogstate = false; bool prevfogstate = false;
WiFiUDP Udp; // A UDP instance to let us send and receive packets over UDP
// const IPAddress dest(192, 168, 8, 255);
const unsigned int rxport = 54321; // remote port to receive OSC
const unsigned int txport = 12345; // local port to listen for OSC packets (actually not used for sending)
void on_light(OSCMessage &msg, int addrOffset) {
int lighton;
if(msg.isFloat(0)){ lighton = msg.getFloat(0); }
if (lighton){ light = true ; }else{ light = false; }
}
////////////////////////////////
///////////////////////////////
void on_fog(OSCMessage &msg, int addrOffset) {
int fogon;
if(msg.isFloat(0)){ fogon = msg.getFloat(0); }
if (fogon){ fog = true ; }else{ fog = false ; }
}
void on_humidity(OSCMessage &msg, int addrOffset) {
int humidityon;
if(msg.isFloat(0)){ humidityon = msg.getFloat(0); }
humidityctrl = int(humidityon);
}
////////////////////////////////
///////////////////////////////
void osc_message_pump() { OSCMessage in; int size;
if( (size = Udp.parsePacket()) > 0) { Serial.println("processing OSC package"); // parse incoming OSC message
while(size--) { in.fill( Udp.read() ); }
if(!in.hasError()) { in.route("/light", on_light); in.route("/fog", on_fog); in.route("/humidity", on_humidity); }
Serial.println("OSC MESSAGE RECEIVED"); // Serial.println (light);
// Serial.println (fog);
}
} ///////////////////////////////
|