Serial communication to Mobile Processing


Have any of you tried to communicate to a mobile phone over bluetooth from oF on mac? I would like to use Mobile Processing on the phone, and i’ve made a serial com port to the phone that OF connects to. But i have no idea how to get any data though to the mobile processing app. Have any of you ideas for that?


I haven’t tried it myself, but I would think that once you have a working bluetooth service sending data from your oF app, getting a phone to connect to it would be easy. But getting the service up and running depends on your OS. For osx, samples are on the dev site, for linux I’d think (just think, I don’t have my linux machine here) you just need to tap into bluez

From there you should just be able to use the Bluetooth library for mP:

There’s some code here that talks to a bluetooth Arduino:

Thanks… I will look more on the links, but one thing I managed to do now is make a serial port on my mac for the phone, and use it. My phone sees the connection, and when i through ofSerial sends bytes, they are receiven on the phone correctly! But when i send a byte from the phone, I don’t receive anything until i close the connection. Any suggestions!?


When I look at this example I see a call to flush() after all the write calls which is what I would expect, but it’s not in the documentation, so that’s a bit confusing.

Thanks alot! That did it :slight_smile:

Note for other people trying to do the same.

  1. First i paired my phone with my mac

  2. I made a Mobile Processing applet with the following important lines to note:

Bluetooth bt;  
bt = new Bluetooth(this, Bluetooth.UUID_SERIALPORT); //Makes a serial port over bluetooth  
bt.start("MyService"); //Creates a service  
// ... //  
void libraryEvent(Object library, int event, Object data) {  
  if (library == bt) {  
    switch (event) {  
    case Bluetooth.EVENT_CLIENT_CONNECTED:  
      c = (Client) data;  
      connected = true;  

  1. I uploaded the applet to my phone, and startet it.

  2. In bluetooth settings in system preferences i selected my phone and rediscovered services on the phone. The “MyService” should turn up now!

  3. Now i went to serial port configuration while having the phone selected and added one port for RS-232, and MyService as service. The path is the one you can connect to with ofSerial.

Thats it, to send bytes from the phone, you write


and to receive;


You don’t have to do anything other than create a single ofSerial instance and call write() on it?