I'm using Arduino Nano 33 Iot to send data through WiFi with UDP protocol. I'm using the OSC library by Adrian Freed.
It works, but I have to send multiple messages and I would to ask what is the best way to do this, in particular if I have to use one big UDP packet for all messages or use multiple packets for every message.
Here an example of multiple packets for msg1 and 2
Udp.beginPacket(outIp, outPort);
msg1.send(Udp);
Udp.endPacket(); // mark the end of the OSC Packet
Udp.beginPacket(outIp, outPort);
msg2.send(Udp);
Udp.endPacket(); // mark the end of the OSC Packet
I would tend to use a seperate packet for each message
howver, remember that UDP is an unreliable protocol so the Arduino will not know if messages arrive sucessfully
you can add a sequence number to messages so at least the receiver is aware if messages are lost
if you require a reliable communications protocol use TCP - see TCP-vs-UDP
what is 'real time'? every millisecond, every 100milliseconds, every second???
do you read some control parameters and transmit them?
do you poll controls, e.g. read a potentiometer using an ADC, or use events, e.g. push buttons?
think we need more information regarding the application
sounds like you are polling the sensor(s) in a loop transmitting values to the audio system
how large is the sensor packet in bytes?
you could have a simple loop reading sensor and transmitting the packet
can the receiver keep up or would have to add a deley to loop?
are you implementing the receiver code or using an existing system?