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 & HelpOther Libraries › Bluetooth Device Search
Page Index Toggle Pages: 1
Bluetooth Device Search (Read 488 times)
Bluetooth Device Search
Mar 15th, 2009, 4:24pm
 
Hi,

I am using the bluetoothDesktop library with the simple bluetooth example. This is fairly close to what I am trying to do..search for and print out the device names picked up onto the screen. The problem I am having is that I want it to do this every 1 or 2 minutes..that it will search and update every 2 minutes. I am quite new to processing and have being trying loops and timers with no success. I would really appreciate if somebody could point me in the right direction on how I should go about this. Thank you.
John.
Re: Bluetooth Device Search
Reply #1 - Mar 17th, 2009, 8:40pm
 
i'm also in a similiar situation, having trouble getting the bluetooth search to refresh. anyone any pointers?
Re: Bluetooth Device Search
Reply #2 - Mar 19th, 2009, 9:11pm
 
Eventually got it to keep updating devices being picked up! this is the simpleBluetooth example stripped down a little.. all that is really changed is the   bt.find(); is moved into draw! so if you are out of range or turn off your bluetooth your name disappears from the screen..and if you change your name it will update that too!!!!

import bluetoothDesktop.*;

PFont font;
Bluetooth bt;
//new array for bluetooth devices
Device[] devices = new Device[0];

void setup() {
 //initialize bluetooth
 try {
   bt = new Bluetooth(this, Bluetooth.UUID_RFCOMM); // RFCOMM

     // Start a Service
   bt.start("simpleService");

 }
 catch (RuntimeException e) {
 }
 size(600,300);
 frameRate(100);
 fill( random(200,255), random(200,255), random(200,255), random(200,255));

}

void draw() {
 background(0);
 font = createFont("Courier", 30);
 textFont(font);
 translate(20, 60);

 bt.find();

 if (devices!=null) {
  for (int i=0; i<devices.length; i++) {
   fill (30+i*20,12+i*20,3+i*20);
     text(devices[i].name, 0, 30+i*30);
      println(i);
     
   }
 }
 
}
void deviceDiscoveryCompleteEvent(Device[] d) {

 devices =  d;
}
Page Index Toggle Pages: 1