×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    6

    Bluetooth inquiry length

    Hi every body, this is my first post here and i hope that you can hepl me. My problem is :
    i need to increase the inquiry time length in java ( j2me), i need a j2me code that to do this.
    I need this because i'm searching for a device in a crowded place where all people open their bluetooth phones.
    SO please can any one help?

  2. #2
    Super Contributor
    Join Date
    Dec 2005
    Location
    England,UK
    Posts
    1,600

    Re: Bluetooth inquiry length

    Some one once showed me this bit of code which copes with multiple devices I have had 17 work with it.

    public void startApp() {
    startServer();
    }
    private void startServer() {
    if (mServer !=null)
    return;
    //start the server and receiver
    mServer = new Thread(this);
    mServer.start();
    }


    Procedure run() {
    if (deviceVector == null) deviceVector = new Vector();
    if (agent == null) agent = local.getDiscoveryAgent();

    /* Retrieve PREKNOWN devices and add them to our Vector */

    RemoteDevice[] devices = agent.retrieveDevices(DiscoveryAgent.PREKNOWN);
    /*
    * Synchronize on vector to obtain object lock before loop.
    * Else, object lock will be obtained every iteration.
    */
    synchronized(deviceVector) {

    for (int i = devices.length-1;i >=0;i--) {
    deviceVector.addElement(devices[i]);

    try {
    name = devices[i].getFriendlyName(false);

    }catch (IOException ioe) {
    name = devices[i].getBluetoothAddress();
    }
    if (name.equals("")) name = devices[i].getBluetoothAddress();
    knownDevices.insert(0,name,null);
    }
    } //End synchronized
    }
    }

    The code is executed in its own thread


    Note the synchronized(deviceVector) this locks the variable as
    bluetooth does not have to wait for a lock and makes for faster updating.
    This speed is neccessary as there will be lots of devices responding and in discovery mode in a short period of time.


    So to summarise
    devices = agent.retrieveDevices(DiscoveryAgent.PREKNOWN);
    devices = agent.retrieveDevices(DiscoveryAgent.GIAC);
    devices = agent.retrieveDevices(DiscoveryAgent.CACHED);

    repeating the in the above code each time will obviously extend the time
    of the search and allow all devices to respond.
    You would the pick a remote device address and use that address for a service record profile search.
    Bluetooth control panel does not have a way of increasing the amount of time to search and on phones you dont have a control panel

    Jim

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    6

    Re: Bluetooth inquiry length

    Thank you for the reply Jim!

    Does J2ME support threads?

    I have seen some codes on the internet that can manipulate the inquiry times, but I think the code was for Symbian only not J2ME (Java).

    I was hoping that there's a mechanism to modify the default value...

    Assume that there are around 50 devices in the range and I need to capture them all in order to look for a certain device.
    What I'm trying to do is make a mobile phone look for a specific PC in a crowded place. The inquiry times out and not all devices are returned and most often, the PC I'm looking for isn't found, even though it's very close to the mobile!!

    If it's not possible to change the default inquiry time within Java, is it possible to modify the way Bluetooth searches for devices?
    From what it seems, it's certainly not looking for the closer to the farther.

    Thank you in advance

  4. #4
    Super Contributor
    Join Date
    Dec 2005
    Location
    England,UK
    Posts
    1,600

    Re: Bluetooth inquiry length

    Hi,
    Does J2ME support threads?
    Yes! it does example
    -------------------------
    Thread mServer = null;
    //start the server Thread
    mServer = new Thread(this);
    mServer.start();

    public run ()
    {
    your code
    }
    -----------------------------
    I have seen some codes on the internet that can manipulate the inquiry times, but I think the code was for Symbian only not J2ME (Java).
    Symbian probably supports timeout changes as C++ is lower level language,but consequently means more lines of code.


    JSR82 library java.bluetooth.* does not support such low level changes.
    If you do discovery of devices using each of these options.
    PREKNOWN, GIAC,CACHE and build up a list of devices in the cache the read
    them all in. Try first getting all the addresses then get all the name on the second time round.


    You will eventually find all devices,but beware of Microsoft drivers because
    because by default they set discovery off and WIDCOMM drivers by default sets discovery on.

    If you are trying to discover lots of devices sometimes its easier to switch discovery on your devices off so that they do not has to respond to requests from other devices

    Do you set your device to master of slave when searching services.
    Your device must be master=true to find all the services properly.
    Jim

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    6

    Re: Bluetooth inquiry length

    Hi Jim ,

    what do u mean with master=true ?


    Thanx alot
    Hisham

  6. #6
    Super Contributor
    Join Date
    Dec 2005
    Location
    England,UK
    Posts
    1,600

    Re: Bluetooth inquiry length

    Hisham asked Jim:
    what do u mean with master=true ?

    Thanx alot
    Hisham
    In all piconets( mob phone nets) there is a master. This is a quote from an article and explains it much better than I could.

    [
    The discovery process
    requires the piconet master to be in the inquiry substate
    when a potential slave device is in the inquiry scan substate.
    Although a piconet is limited to eight active devices,
    Click on the link for the full article of the role of master and slave

    Bluetooth Discovery Time with Multiple Inquirers

    From the call documentation:-
    public java.lang.String getConnectionURL(int requiredSecurity,boolean mustBeMaster)
    throws java.lang.IllegalArgumentException

    In the case of a Serial Port service record, this string might look like "btspp://0050CD00321B:3;authenticate=true;encrypt=false;master=true", where "0050CD00321B" is the Bluetooth address of the device that provided this ServiceRecord, "3" is the RFCOMM server channel mentioned in this ServiceRecord, and there are three optional parameters related to security and master/slave roles.
    I hope helps
    Good Luck
    Jim
    Last edited by jimgilmour1; 2006-05-26 at 10:24.

  7. #7
    Registered User
    Join Date
    May 2006
    Posts
    6

    Re: Bluetooth inquiry length

    Thanx alot for the help
    but u know getConnectionURL need to find the device first, but i can't find, i want some thing that let my mobile serach and find my laptop in a place where (arround) 50 bluetooth devices are working.
    Thanx Jim


    Hisham

  8. #8
    Super Contributor
    Join Date
    Dec 2005
    Location
    England,UK
    Posts
    1,600

    Re: Bluetooth inquiry length

    Try this as bluetooth works better at short distance.
    Why dont you try the phone next to BT USB device on PC, at 0.1Metre ,1 foot, away from the PC that you cannot find.

    The bluetooth radio at that distance 0.1M would have such a strong signal that it would block out the other devices proving it is distance, not timing that is the problem.

    I have put my bluetooth USB for PC on 0.2M ,1.5feet, extender cable and this has improved performance and distance considerably as there is less radio interference for PC components.


    If this works, it means that there is too weaker radio signal from the USB, due interference problems. I believe this is a indicates hardware problems.

    If you get no connection you need to check the settings of the bluetooth driver and whether it is has discovery enable.

    Does the BT device detect other devices?.

    Is the same device used on working PC?.

    Is the BT software the same as on Working PC?

    Are the BT software settings the same as on working discoverable PC?.

    Good Luck
    Jim





    Jim

Similar Threads

  1. using menu bar kills bluetooth inquiry
    By sfitw in forum Bluetooth Technology
    Replies: 0
    Last Post: 2004-06-08, 04:36
  2. Nokia 7650 support Bluetooth audo?
    By ovjo12 in forum Bluetooth Technology
    Replies: 5
    Last Post: 2003-07-17, 18:50
  3. Using non-UI guided Bluetooth device inquiry -- issues
    By tkedem in forum Bluetooth Technology
    Replies: 1
    Last Post: 2003-03-30, 02:55
  4. Bluetooth Inquiry Problem.
    By manivannancoimbatore in forum Symbian Tools & SDKs
    Replies: 0
    Last Post: 2003-02-14, 08:31
  5. Virtual Com Ports from Digianswer software.
    By mareksuski in forum Bluetooth Technology
    Replies: 3
    Last Post: 2002-06-27, 09:49

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •