Hi, i'm trying to send an OSC message to my PC over WiFi with my MKR1000, but i'm kinda stuck. I can ping my device but that's about the only way i can see any traffic. This is my code:
#include <WiFi101.h>
#include <WiFiUdp.h>
#include <OSCBundle.h>
// Wi-Fi settings
char ssid[] = "xxxx";
char password[] = "xxxx";
// IP address of the computer running the OSC receiver
IPAddress destinationIP(192, 168, 8, 213);
const unsigned int destinationPort = 3250; // OSC receiver port
// Create a UDP instance for sending OSC messages
WiFiUDP Udp;
void setup() {
// Initialize serial communication for debugging
Serial.begin(9600);
// Connect to Wi-Fi network
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("Connected to Wi-Fi");
// Print the local IP address
IPAddress localIP = WiFi.localIP();
Serial.print("Local IP: ");
Serial.println(localIP);
}
void loop() {
// Create an OSC bundle
OSCBundle bundle;
// Add OSC messages to the bundle
int valueOSC = 1; // Read an analog sensor
bundle.add("/control/t1/play").add(valueOSC);
// Send the OSC bundle
Udp.beginPacket(destinationIP, destinationPort);
bundle.send(Udp); // Send the bundle over UDP
Udp.endPacket();
Serial.print("Sent OSC message: ");
// Wait for a while before sending the next message
delay(1000);
}