Hey, how is it going?
Im trying to receive osc on my mobile, using OscP5 library and android mode 4.0-beta2. Codes:
Android app
import oscP5.*;
import netP5.*;
OscP5 oscP5;
NetAddress endereco;
float x = 1.0;
float y = 2.0;
float z = 3.0;
void setup() {
fullScreen();
orientation(LANDSCAPE);
textSize(100);
oscP5 = new OscP5(this, 9000);
endereco = new NetAddress("localhost", 10000); // not sure if i even need to import netP5
}
void draw() {
background(0);
fill(255);
text("x = " + x, 20, 200);
text("y = " + y, 20, 400);
text("z = " + z, 20, 600);
}
void oscEvent(OscMessage mensagem) {
// tests if any message is being received at all
fill(255);
rect(50, 30, 100, 100);
if (mensagem.checkAddrPattern("/x")) x = mensagem.get(0).floatValue();
else if (mensagem.checkAddrPattern("/y")) y = mensagem.get(0).floatValue();
else if (mensagem.checkAddrPattern("/z")) z = mensagem.get(0).floatValue();
}
Java code running on my laptop
import oscP5.*;
import netP5.*;
OscP5 osc;
NetAddress endereco;
float x = 0;
float y = 0;
float z = 0;
OscMessage mx = new OscMessage("/x");
OscMessage my = new OscMessage("/y");
OscMessage mz = new OscMessage("/z");
void setup() {
osc = new OscP5(this, 12000);
endereco = new NetAddress("192.168.25.2", 9000);
}
void draw() {
}
void keyPressed() {
if (key == 'q') {
x += 10.4;
mx.add(x);
osc.send(mx, endereco);
mx.clearArguments();
} else if (key == 'w') {
x -= 10.5;
mx.add(x);
osc.send(mx, endereco);
mx.clearArguments();
} else if (key == 'a') {
y += 10.4;
my.add(y);
osc.send(my, endereco);
my.clearArguments();
} else if (key == 's') {
y -= 10.5;
my.add(y);
osc.send(my, endereco);
my.clearArguments();
} else if (key == 'z') {
z += 10.4;
mz.add(z);
osc.send(mz, endereco);
mz.clearArguments();
} else if (key == 'x') {
z -= 10.5;
mz.add(z);
osc.send(mz, endereco);
mz.clearArguments();
}
}
They are both connected to the same Wifi network, im pretty sure the IP address is correct, but it just does not receive the message sent, the INTERNET permission is checked for the app. What can I be missing?
Using Processing 3.2.1, Android Mode 4.0-beta2, Android 6.0 (API 23), Zenphone 2 Laser Android 5.0.2.
All best Thanks in advance