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 service loop
Page Index Toggle Pages: 1
bluetooth service loop (Read 256 times)
bluetooth service loop
Nov 5th, 2008, 4:28pm
 
Greetings from Snatiago Chile,

Hello Im trying to make  a loop with the searching device but it doesnt work. Any ideas?

import bluetoothDesktop.*;

PFont font;
Bluetooth bt;
String statusMsg = "inactive";

Device[] devices = new Device[0];


String Saludo;
int s = second();

void setup() {
 size(800,600);
 noLoop();
 font = createFont("Courier", 15);
 textFont(font);
 try {
   bt = new Bluetooth(this, Bluetooth.UUID_RFCOMM); // RFCOMM

   // Start a Service
   bt.start("simpleService");
   bt.find();
   statusMsg = "emepzandoa buscar";
 }
 catch (RuntimeException e) {
   statusMsg = "bluetooth off?";
   println(e);
 }

}

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

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

}

void deviceDiscoverEvent(Device d) {
 statusMsg = "Dispostivos Encontrados: " + d.address + "...";
 devices = (Device[])append(devices, d);
Saludo = "";
}

void deviceDiscoveryCompleteEvent(Device[] d) {
 statusMsg = "Encontrados " + d.length + " dispositivos encontrados.";
 devices =  d;
 Saludo = "Hola ";
if (s == 10) {
 loop();
 }
 
}

Page Index Toggle Pages: 1