Verify available BlueTooth devices

Discussion in 'Java' started by Manuel, Jun 14, 2005.

  1. Manuel

    Manuel Guest

    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

    Code:
    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
    Manuel, Jun 14, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Manuel
    Replies:
    0
    Views:
    410
    Manuel
    Jun 14, 2005
  2. champion
    Replies:
    0
    Views:
    774
    champion
    Jan 5, 2010
  3. izzahmeor
    Replies:
    0
    Views:
    783
    izzahmeor
    Feb 3, 2010
  4. Naveen Vaila

    "Windows CE Devices and Palm Devices Help Needed"

    Naveen Vaila, May 24, 2004, in forum: ASP .Net Mobile
    Replies:
    1
    Views:
    501
    Abraham Durairaj
    Jun 23, 2004
  5. Nikola Dlaka

    Sending a file between two devices via Bluetooth

    Nikola Dlaka, May 29, 2006, in forum: ASP .Net Mobile
    Replies:
    1
    Views:
    923
    Peter Foot [MVP]
    Jun 2, 2006
Loading...

Share This Page