I think I have it working on my system, but I’m not sure how it is supposed to work.
I see this image on both of my system; macos desktop and android Samsung tablet.
The dot used to change color but now just stays white. In order to connect to my Android tablet I had to change the permissions in the Manifest by adding the following:
Reference is here: https://stackoverflow.com/questions/56266801/java-net-socketexception-socket-failed-eperm-operation-not-permitted
Prior to adding those I got an EPERM error.
The log window of the Processing app is below:
I did change your source code; I added some code to the Android side from one of the oscP5 examples (client side). Below is what I used:
Processing:
import oscP5.*;
import netP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
int colour = 255;
void setup() {
size(600, 600);
/* start oscP5, listening for incoming messages at port 1200 */
oscP5 = new OscP5(this,1200);
println(this);
/* the address of this device */
myRemoteLocation = new NetAddress("127.0.0.1",1300);
}
void draw() {
background(0);
fill(colour);
circle(width/2, height/2, 200);
int i = int(random(0, 200));
if (i == 1) sendmessage();
}
void sendmessage() {
/* create the message */
OscMessage myMessage = new OscMessage("/one");
color c = color(random(0, 255), random(0, 255), random(0, 255));
myMessage.add(c);
/* send the message */
println("Sending message: " + myMessage);
oscP5.send(myMessage, myRemoteLocation);
}
/* incoming osc message are forwarded to the oscEvent method */
void oscEvent(OscMessage theOscMessage) {
colour = theOscMessage.get(0).intValue();
}
Android:
import oscP5.*;
import netP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
int colour = 255;
NetAddressList myNetAddressList = new NetAddressList();
/* listeningPort is the port the server is listening for incoming messages */
int myListeningPort = 32000;
/* the broadcast port is the port the clients should listen for incoming messages from the server*/
int myBroadcastPort = 12000;
String myConnectPattern = "/server/connect";
String myDisconnectPattern = "/server/disconnect";
void setup() {
size(600, 600);
/* start oscP5, listening for incoming messages at port 12000 */
oscP5 = new OscP5(this,1300);
println(this);
/* the address of this device */
myRemoteLocation = new NetAddress("10.0.0.251",1200);
}
void draw(){
background(0);
fill(colour);
circle(width/2, height/2, 200);
int i = int(random(0, 200));
if (i == 1) sendmessage();
}
void sendmessage() {
/* create the message */
OscMessage myMessage = new OscMessage("/two");
color c = color(random(0, 255), random(0, 255), random(0, 255));
myMessage.add(c);
/* send the message */
println("Sending message: " + myMessage);
oscP5.send(myMessage, myRemoteLocation);
}
/* incoming osc message are forwarded to the oscEvent method */
//void oscEvent(OscMessage theOscMessage) {
// colour = theOscMessage.get(0).intValue();
//}
void oscEvent(OscMessage theOscMessage) {
/* check if the address pattern fits any of our patterns */
if (theOscMessage.addrPattern().equals(myConnectPattern)) {
connect(theOscMessage.netAddress().address());
colour = theOscMessage.get(0).intValue();
println("colour = ",colour);
}
else if (theOscMessage.addrPattern().equals(myDisconnectPattern)) {
disconnect(theOscMessage.netAddress().address());
}
/**
* if pattern matching was not successful, then broadcast the incoming
* message to all addresses in the netAddresList.
*/
else {
oscP5.send(theOscMessage, myNetAddressList);
}
}
private void connect(String theIPaddress) {
if (!myNetAddressList.contains(theIPaddress, myBroadcastPort)) {
myNetAddressList.add(new NetAddress(theIPaddress, myBroadcastPort));
println("### adding "+theIPaddress+" to the list.");
} else {
println("### "+theIPaddress+" is already connected.");
}
println("### currently there are "+myNetAddressList.list().size()+" remote locations connected.");
}
private void disconnect(String theIPaddress) {
if (myNetAddressList.contains(theIPaddress, myBroadcastPort)) {
myNetAddressList.remove(theIPaddress, myBroadcastPort);
println("### removing "+theIPaddress+" from the list.");
} else {
println("### "+theIPaddress+" is not connected.");
}
println("### currently there are "+myNetAddressList.list().size());
}
Addendum:
Finally got it changing colors on the Processing side, but not the Android side. Log on Processing side shows both one and two messages.
I have to keep setting the Permissions on the Android side because apparently the editor keeps erasing them. Don’t see ‘one’ showing up on the Android side however. It appears that Android is sending the ‘two’ string and Processing app is receiving it, but Android app is not receiving the ‘one’ string that Processing app is sending.
Android console: (no ‘one’)
Fix:
If you change one line of your Android code it should now work as expected:
import oscP5.*;
import netP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
int colour = 255;
void setup() {
size(600, 600);
/* start oscP5, listening for incoming messages at port 12000 */
oscP5 = new OscP5(this,1200);
// oscP5 = new OscP5(this,1300);
println(this);
/* the address of this device */
myRemoteLocation = new NetAddress("127.0.0.1",1200);
}
void draw() {
background(0);
fill(colour);
circle(width/2, height/2, 200);
int i = int(random(0, 200));
if (i == 1) sendmessage();
}
void sendmessage() {
/* create the message */
OscMessage myMessage = new OscMessage("/two");
color c = color(random(0, 255), random(0, 255), random(0, 255));
myMessage.add(c);
/* send the message */
println("Sending message: " + myMessage);
oscP5.send(myMessage, myRemoteLocation);
}
/* incoming osc message are forwarded to the oscEvent method */
void oscEvent(OscMessage theOscMessage) {
colour = theOscMessage.get(0).intValue();
println("incoming",colour);
}
I changed:
oscP5 = new OscP5(this,1300);
to:
oscP5 = new OscP5(this,1200);
The Android log now shows incoming data; it’s a negative number but I think that’s the color which is not being transmitted correctly. However, the Android dot now changes colors just like the Processing app.






