We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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
Answers
well, ive changed doors from 9000 to 7000 and it worked.. thanks for the attention =) how do i mark this as solved?
By "doors" you mean "port", correct? Port 7000. Thanks for sharing your solution.
yes, port =)
Hey! I'm having a similar problem. I'm trying to SEND a message from my android tablet, and receive on my computer. I was able to get this code to work on two computers, so wondering if this has something to do with the port number or android mode?
Here is the code on my tablet:
Here is the code on my computer:
Change line 16 in your tablet code from 7000 to 12000. Does it solve your problem?
Kf
same problem here, changin the port doesnt work, the sketch was working in android mode 3.0 but since i update it to 4.0 Osc fail. Does anyone have a solution?
Hey @Sesmusician , I'm having same problem here... Sending OSC from android device to laptop is working great, but the other way around fails. I'm getting BindException EADDRINUSE (address already in use) I've tried several different port numbers but it always fails...
Has anybody found a solution?
(with android mode 4.0)
Did you turn on the internet permission? For me that fixed it.