We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpElectronics,  Serial Library › Bluetooth connection for desktop
Page Index Toggle Pages: 1
Bluetooth connection for desktop (Read 2051 times)
Bluetooth connection for desktop
Oct 31st, 2008, 12:55am
 
Hello,
I am trying to use my built in bluetooth adapter to
recognize another blue tooth device, either a phone or the 'Smirf' from arduino.  I downloaded the processing bluetooth library and installed it. But when I run the
following example script it gives me the following error (below)

My adapter has a broadcom stack, which according to bluecove.org it is supported . I have the latest Java installed as well.as well.
I am able to connect to the arduino bluetooth as a serial device, but then it is a serial port, not a true bluetooth connection.  I am not able to therefor do things like search for other blue tooth devices.

What am I missing?

"java.lang.RuntimeException: No supported stack installed or no dongle available"

Code:
import bluetoothDesktop.*;


PFont font;
Bluetooth bt;
String statusMsg = "inactive";
Service[] services = new Service[0];
Device[] devices = new Device[0];
Client[] clients = new Client[0];

void setup() {
 size(600,300);
 font = createFont("Courier", 15);
 textFont(font);
 try {
   bt = new Bluetooth(this, Bluetooth.UUID_RFCOMM);
//I have also tried bt=new Bluetooth(this); with no luck
   // Start a Service
   bt.start("simpleService");
   bt.find();
   statusMsg = "starting search";
 }
 catch (RuntimeException e) {
   statusMsg = "bluetooth off?";
   println(e);
 }

}

void draw() {
 background(0);
 fill(255);
 text("Status: " + statusMsg, 10, 30);

 translate(20, 60);
 text("Devices:", 0, 0);
 if (devices!=null) {
   for (int i=0; i<devices.length; i++) {
     text(devices[i].name, 0, 30+i*20);
   }
 }

 translate(160, 0);
 text("Services:", 0, 0);
 if (services!=null) {
   for (int i=0; i<services.length; i++) {
     text(services[i].name, 0,30+ i*20);
   }
 }

 translate(200, 0);
 text("Clients:", 0, 0);
 if (clients!=null) {
   for (int i=0; i<clients.length; i++) {
     text(clients[i].device.name, 0, 30+i*20);
   }
 }

 for (int i=0; i<clients.length; i++) {
   if (clients[i].available()>0) {
     println("Client " + i + " sent: " + clients[i].readUTF());
   }
 }


}

void deviceDiscoverEvent(Device d) {
 statusMsg = "Found device at: " + d.address + "...";
 devices = (Device[])append(devices, d);
}

void deviceDiscoveryCompleteEvent(Device[] d) {
 statusMsg = "Found " + d.length + " devices found.";
 devices =  d;
}

void serviceDiscoverEvent(Service[] s) {
 statusMsg = "Found Service " + s[0].name + "...";
 services = (Service[])append(services,s[0]);
}

void serviceDiscoveryCompleteEvent(Service[] s) {
 services = (Service[])s;
 statusMsg = "Search complete.";
}

void clientConnectEvent(Client c) {
 clients = (Client[])append(clients, c);
}

void keyPressed() {
 
 for (int i=0; i<clients.length; i++) {
   clients[i].writeUTF(""+key);
   println("Server sent to all clients: " + key);
 }
 
}

Re: Bluetooth connection for desktop
Reply #1 - Dec 4th, 2008, 5:30pm
 
Hi,

I had the same issue off the bat.

You need to delete the stack that you are not using. Go into the bluetooth desktop folder, then into libraries. If you are using bluecove, which it sounds like you are, you need to delete the avetana file.

Once you delete it processing shouldn't get confused about which one to use.

Re: Bluetooth connection for desktop
Reply #2 - Mar 15th, 2009, 2:15pm
 
Hi,

I am also using the bluetoothDesktop library. I am getting it to run ok and pick up devices but I want to get it to search again after say 1 or 2 minutes and update the devices picked up. I'm quite new to processing so im not sure the right way to go about this.. iv being trying timers and loops with no success. It would be great if somebody could point me in the right direction. Thanks.
Re: Bluetooth connection for desktop
Reply #3 - Apr 22nd, 2009, 9:28pm
 
Hi,

I'm also using the bluetoothDesktop library. Right now I use it to detect a BlueSmirf modem that is attached to an Arduino. Everything seems to connect ok and the BlueSmirf indicates that it's connected. I can even stream data from the Arduino through the connection to Processing (I've tried streaming numbers from 1 through 50 with luck; i.e. Arduino ==> BlueSmirf ==> Processing).

My problem is that I don't seem to be having any luck sending data to the BlueSmirf. For trouble shooting, I'm using a simple for loop to blink an LED on/off based on the value that is sent to the Arduino.

Regardless of the values sent from Processing ==> BlueSmirf ==> Arduino all I get is 13 blinks of the LED. I suspect that all I'm seeing is the carriage return on the Arduino serial line.

Any help would be appreciated. Thanks.
Page Index Toggle Pages: 1