Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 57
Registered: ‎04-07-2009
My Device: 8300

Bluetooth: inquiryCompleted issue

Hi

I tried to detect bluetooth devices with this code - 

try { LocalDevice localDevice = LocalDevice.getLocalDevice(); DiscoveryAgent discoveryAgent = localDevice.getDiscoveryAgent(); discoveryAgent.startInquiry(DiscoveryAgent.GIAC, this); } catch(Exception e) { }

 

It detects one or two devices, and device discovered method is called, and sudenly inquiryCompleted is called, and no other device is detected.

 

What I want is to make the inquiry mode longer so that it can detect all the devices active near me. How can I do that?

 

Thanks.

 

Developer
Posts: 57
Registered: ‎04-07-2009
My Device: 8300

Re: Bluetooth: inquiryCompleted issue

Hi

I really in need of help in this issue.

If my problem is not clear, please ask me.

 

Developer
Posts: 98
Registered: ‎01-06-2009
My Device: Pearl 8110

Re: Bluetooth: inquiryCompleted issue

Do you have more than two devices around that you want to detect?

Make the other devices are discoverable if you want GIAC inquiry to find them.

 

Use retreiveDevices(CACHED/PREKNOWN) to get list of previously pair 

devices. Link:javax.bluetooth 

 

 

Developer
Posts: 57
Registered: ‎04-07-2009
My Device: 8300

Re: Bluetooth: inquiryCompleted issue

Hi Bottomfish

 

Thanks for reply.

 

Yes, I have more than two discoverable devices around. 

When I search 1/2 device(s) is discovered. If I search immediately it discovers 1/2 devices again, sometimes same devices, some times another 1/2 devices. No consistency. What should I do then?

Developer
Posts: 98
Registered: ‎01-06-2009
My Device: Pearl 8110

Re: Bluetooth: inquiryCompleted issue

Your other devices may be only set to be discoverable for only a limited period.

For example, my pearl can be set to be discoverable for only 2 minutes beside 

the yes or no options.

 

Try a stub discoverylistener object and pass it startInquiry.

Print out any devices discovered and inquiry completed status

for both startInquiry(GIAC and LIAC, listener)...

 

Please provide more info about your other devices. 

Developer
Posts: 57
Registered: ‎04-07-2009
My Device: 8300

Re: Bluetooth: inquiryCompleted issue


Bottomfish wrote:

Your other devices may be only set to be discoverable for only a limited period.



I don't think so, the bluetooth demo that came with blackberry can discover all of those 7/8 devices.

 


Bottomfish wrote:

Try a stub discoverylistener object and pass it startInquiry.

Print out any devices discovered and inquiry completed status

for both startInquiry(GIAC and LIAC, listener)...

 


 
Can you give me sample code?
Thanks.

 

 

Highlighted
Developer
Posts: 98
Registered: ‎01-06-2009
My Device: Pearl 8110

Re: Bluetooth: inquiryCompleted issue

Post your code, let us see what your are doing for

devicediscovered and inquirycomplete methods. 

Developer
Posts: 57
Registered: ‎04-07-2009
My Device: 8300

Re: Bluetooth: inquiryCompleted issue

I coded in office, now this is weekend. I will go to office next Sunday, and will give you the code.

 

Thanks for posting.

 

Best Regards

New Developer
Posts: 1
Registered: ‎11-05-2009
My Device: Not Specified

Re: Bluetooth: inquiryCompleted issue

Bottomfish,

 

I have the same issue.I also tried to call agent.startInquiry(DiscoveryAgent.GIAC, this) more than once, but without success. I have 3 diffrent BT-GPS  (V10, 382502) and it only find finds one @ a time, but sometimes two;

 

Below is my code posted..

 

    public void deviceDiscovered(RemoteDevice remoteDevice, DeviceClass deviceClass)
    {
        String strDevName = null;
        try {
            strDevName = remoteDevice.getFriendlyName(true);
        }
        catch (Exception e) {
            //TODO
            e.printStackTrace();
        }
       
        if (strDevName != null && !hstDevInfo.containsKey(strDevName) ) {
            hstDevInfo.put(strDevName, new Boolean(false));
            activeDevices.append(strDevName, null);
            devicesFound.addElement(remoteDevice);
        }
        if (iInquiryCounter < 5) {
            iInquiryCounter++;
            System.out.println("==========>starting Inguiry #" + iInquiryCounter);
            try {
                agent.startInquiry(DiscoveryAgent.GIAC, this);
            } catch (BluetoothStateException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

 

    public void inquiryCompleted(int param)
    {
        switch (param) {
            case DiscoveryListener.INQUIRY_COMPLETED:
                if (devicesFound.size() > 0) {
                    activeDevices.addCommand(select);
                    activeDevices.setSelectCommand(select);
                } else {
                    try {
                          activeDevices.append("No Devices Found", null);
                    }
                    catch (Exception e) {
                        //TODO
                    }
                }
                display.setCurrent(activeDevices);
                break;
           
            case DiscoveryListener.INQUIRY_ERROR:
                break;
           
            case DiscoveryListener.INQUIRY_TERMINATED:
                break;
        }
    }

New Developer
Posts: 21
Registered: ‎12-24-2009
My Device: Not Specified

Re: Bluetooth: inquiryCompleted issue

Did you ever get resolution for this issue?  I had the same problem and resolved it by not calling getFriendlyName from the diveceDiscovered callback.  Store up the remote devices and go through the names after words.