[mobil java] Verify available BlueTooth devices

M

Manuel

Hi,

for a university project I'm trying to implement a "where am I?"-Detection for in-buildings, using Java and Nokia 6630.

I tried to use deviceDiscovered() to build up a vector with all nearby devices, but realized, that devices will be found by deviceDiscovered() even after thy are switched off (up to 1100 seconds later).

As it seems, there is no method to clear the BT-devices-hardwarestack, I tried to verify Devices' availability by searching for services on each discovered device when inquiryCompleted() is called


public void inquiryCompleted(int complete)
{

UUID[] uuids=new UUID[1];
uuids[0] = uuid;

int[] attrSet = null;

for (int i=0; i< remoteDevices.size(); i++)
{
RemoteDevice remoteDevice = (RemoteDevice) remoteDevices.elementAt(i);
try
{
int transId = agent.searchServices(attrSet, uuids, remoteDevice, this);
}
catch (BluetoothStateException btse)
{
LogFile.log(""+btse);

}
catch (IOException ioe)
{
LogFile.log(""+ioe);
}

}

}


public void servicesDiscovered(int transId, ServiceRecord[] records)
{
String s = new String();
try
{
s = new String(records[0].getHostDevice().getFriendlyName(false));
}
catch (IOException ioe)
{
LogFile.log(""+ioe);
}
if(!verifiedDevices.contains(s))
{
try
{
verifiedDevices.addElement(records[0].getHostDevice().getFriendlyName(false));
}
catch(IOException ioe)
{
LogFile.log(""+ioe);
}
}

}

This, of cause, didn't work neither, due to the for() -loop and the given listener-pattern:

It will work for the 1st found devices, but for the other it will generate a bluetoothstack-exciption: Busy, because the discoveryAgent hasn't finished service discovery on the 1. device.

Does anybody have an idea, how to achieve the goal of building a fast "where am i?"-recognition by using Java and BlueTooth, or do you think, it is just impossible?

Thanks, Manuel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top