I have working JUCE code that receives UDP Broadcast packets on the Desktop, but it does not seem to work on an Android device. I am able to communicate with the device with a unicast packet, so I know basic communications is working.
Does anyone have any experience with this? Several discussions of Android/UDP broadcast reception indicated having to use a MulticastLock, but those are references to Java related code, not C. And per those posts, I hoped that possibly just adding <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"> to the manifest would do the trick, but no such luck.
@Don_Turner I know you are an audio guy, but maybe you know someone who could help me out?
Do you create the DatagramSocket object with “enableBroadcasting = true”? I use it for recognising different devices in a network and works well on Android, iOS, Linux etc.
@MBO, thanks for replying. I am pretty sure I had the enableBroadcasting flag set to true. I’ll double check when I circle back to the issue. Your example shows sending a broadcast message, but I am needing to receive a broadcast message. Do you have an example of your receive code?
@MBO, thanks again. my code matches what you have shown here, but it’s not working. I don’t know if it relates to the Android OS version (7.1.1, patched May 1st 2018), or the broadcast mask, which for ArtNet is just the last octet (ie. 192.168.1.255), where in your send broadcast example you are doing all four (255.255.255.255). Bottom line, you have verified that JUCE does the right thing for Android, and it should be working, so I’ll need to scratch my head for a bit on this.
Some time ago I had a similar issue, so I would suggest running a receiver application on different computers/devices to verify where is the problem. Another thing is that UDP messages are not guaranteed to arrive…
This same code works like a champ on multiple (Windows) desktop machines on this network. Next week my new Mac is coming in, so I will be verifying/testing on OSX, and also iOS.
An occasional dropped packet would be one thing, but the device is missing 5-100+ packets coming in at about ~8 second intervals…
Maybe try on another Android device if possible?
You can try to turn off Bluetooth on this Android device and check if it helps - on some devices it can be a problem, especially with Bluetooth/wifi combos.
Check also if you have dropouts with the global (255.255.255.255) broadcast.