lunedì 25 maggio 2009

DEVICE DISCOVERED.JAVA
import javax.bluetooth.*;
import javax.util.*;

public class DeviceDiscoverer implements DiscoveryListener {
Probe sonda;
Vector dispositivi=new Vector();
DiscoveryAgent agente;

public DeviceDiscoverer(Prpbe p) {
sonda=p;
try{
LocalDevice ld=LocalDevice.getLocalDevice();
agente=ld.getDiscoveryAgent();
sonda.updateStatus("Trova le periferiche bluetoot");
agente.startInquiry(DiscoveryAgent.giac,this);
} catch (Exception e){
e.printStackTrace();
}
}

public void deviceDiscovered(RemoteDevice remoteDevice,DeviceClass cod){
try {
dispositivi.addElement(remoteDevice);
sonda.updatestatus("Tovato: "+remoteDevice.getFriendlyName(true));
} catch (ExCeption e){
e.printStackTrace();
}
}

public void inquiryComleted(int discType){
String inqStatus=null;
if (discType==DiscoveryListener.INQUIRY.COMPLETED)
inqStatus="\n Inquiry completato";
else if(discType==DiscoveryListener.INQUIRY_TERMINATED)
inqStatus="\n Inquiry terminato";
else if(discType==DiscoveryListener.INQUIRY_ERROR)
inqStatus="\n Errore inquiry";

sonda.updateStatus(inqStatus);
sonda.f.addCommand(sonda.findS);
sonda.updateStaus("\n Premi Cerca servizi per trovare tutti i servizi disponibili");
}

public void servicesDiscovered(int transID, ServiceRecord[],servRecord){}

public void serviceSearchComplete(int transID, int respCode) {}

}

Nessun commento: