New issue 94 by evoid.de: retrieveDevices of DiscovereyAgent always returns
null
http://code.google.com/p/bluecove/issues/detail?id=94
To reproduce the problem, use exactly the following code on Ubuntu Linux
9.10 while having at least one bluetooth device paired with the system the
code is running on:
public class Test
{
public static void main( String[] args ) throws IOException
{
RemoteDevices[] devices =
LocalDevice.getLocalDevice().getDiscoveryAgent().retrieveDevices(
DiscoveryAgent.PREKNOWN );
System.our.println( devices );
}
}
The expected output will be a list that contains your paired devices. But
what I get is always 'null', no metter whether the paired devices are
running (have bluetooth turned on) or not.
I'm using the latest BlueCove release, namely version 2.1.0, including the
bluecove-gpl module. I don't know where to look up the build number this
tool is requesting me for. I'm not sure but I think it's all 32 bit here.
Thanks in advance
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
import java.io.IOException;
import java.util.Vector;
import javax.bluetooth.DeviceClass;
import javax.bluetooth.DiscoveryAgent;
import javax.bluetooth.DiscoveryListener;
import javax.bluetooth.LocalDevice;
import javax.bluetooth.RemoteDevice;
import javax.bluetooth.ServiceRecord;
public class NewClass {
private LocalDevice local = null;
private DiscoveryAgent agent = null;
public static void main(String[] args) {
try {
new NewClass().find();
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void find() throws Exception {
local = LocalDevice.getLocalDevice();
agent = local.getDiscoveryAgent();
System.out.println("searching for devices...");
DeviceDiscoverer discoverer = new DeviceDiscoverer();
agent.startInquiry(DiscoveryAgent.GIAC, discoverer);
Thread.sleep(40000);
}
}
class DeviceDiscoverer implements DiscoveryListener {
public static Vector devices = new Vector();
private RemoteDevice[] rDevices = null;
int y = 0;
public void deviceDiscovered(RemoteDevice remote, DeviceClass dClass) {
try {
devices.addElement(remote);
System.out.println(remote.getFriendlyName(true));
} catch (IOException ex) {
}
}
public void inquiryCompleted(int descType) {
String message = "";
switch (descType) {
case DiscoveryListener.INQUIRY_COMPLETED:
message = "INQUIRY_COMPLETED";
break;
case DiscoveryListener.INQUIRY_TERMINATED:
message = "INQUIRY_TERMINATED";
break;
case DiscoveryListener.INQUIRY_ERROR:
message = "INQUIRY_ERROR";
break;
}
rDevices = new RemoteDevice[devices.size()];
for (int i = 0; i < devices.size(); i++) {
rDevices[i] = (RemoteDevice) devices.elementAt(i);
try {
System.out.println(rDevices[i].getFriendlyName(true));
} catch (IOException ex) {
}
}
}
public void servicesDiscovered(int transId, ServiceRecord[] services) {
}
public void serviceSearchCompleted(int transId, int respCode) {
How is this supposed to help me? I think you did not understand what my
problem is. I
don't want to perform an inquiry for new devices, I just want to get a list
of all
the devices that are already paired with my system. Or do you want to say
that I must
perform an inquiry first anyway?