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: 205
Registered: ‎07-14-2008
My Device: 7230, 8700, 8820, 9000

Bug in Bluetooth DiscoveryAgent/DiscoveryListener

I believe I found a bug in the set of events that DiscoverAgent sends to a DiscoveryListener

 

In the following code, a neighbour is an object that implements DiscoveryListener and contains a RemoteDevice objec and a flag indicating if service discovery is in progres.

synchronized (pNeighbours[i]) { // Indicate that we are scanning. pNeighbours[i].m_bServiceDiscovery = true; try { // Initiate a service discovery. int nTransID = pAgent.searchServices(null, pUUID, pNeighbours[i].m_pDevice, pNeighbours[i]); // Loop until the service discovery finishes. // This loop to prevent the user from waking up the // thread by requesting a scan. while (pNeighbours[i].m_bServiceDiscovery) { try { pNeighbours[i].wait(); } catch (InterruptedException e) { } } } catch (BluetoothStateException e) { } }

 

When the device initiates the services search, it attempts to pair with the other BlackBerry.  If I ignore the pairing prompt, the search will timeout an a SERVICE_SEARCH_DEVICE_NOT_REACHABLE response will be sent to the following DiscoverListener method:

 

 

public synchronized void serviceSearchCompleted(int transID, int respCode) { switch (respCode) { case SERVICE_SEARCH_COMPLETED: case SERVICE_SEARCH_TERMINATED:

case SERVICE_SEARCH_ERROR: case SERVICE_SEARCH_DEVICE_NOT_REACHABLE:

// TODO  

break; case SERVICE_SEARCH_NO_RECORDS:

// TODO 

  break; } m_bServiceDiscovery = false; // Wake up the calling thread. notify(); }

 

If I manually cancel the pairing prompt on the searching device, no response is given to the DiscoveryListener.  My application remains blocked iindefinitely.  

 

The work around is simple, but I am pretty sure that this is a bug in your JSR 82 implementation.

 

I am testing on a pair of 8820s running App 4.3.1.19 (54) Platform 2.7.0.19.

Earl Oliver
BlackBerry Development Advisor
Posts: 15,809
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Bug in Bluetooth DiscoveryAgent/DiscoveryListener

Are you able to upgrade the BlackBerry 8820 to version 4.5.0?  If so are you seeing the same behaviour there?
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Developer
Posts: 205
Registered: ‎07-14-2008
My Device: 7230, 8700, 8820, 9000

Re: Bug in Bluetooth DiscoveryAgent/DiscoveryListener

I would be happy to test with 4.5.  Can you send me a link to download it?

 

Earl 

Earl Oliver
BlackBerry Development Advisor
Posts: 15,809
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Bug in Bluetooth DiscoveryAgent/DiscoveryListener

Assuming your carrier has release BlackBerry handheld software version 4.5.0, you can download it from your carrier's web site or from here:  http://na.blackberry.com/eng/support/downloads/download_sites.jsp
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Developer
Posts: 205
Registered: ‎07-14-2008
My Device: 7230, 8700, 8820, 9000

Re: Bug in Bluetooth DiscoveryAgent/DiscoveryListener

I have verified that this bug is also present in 4.5.0.64 on the 8820. 

 

If the user manually cancels the pairing request during a service discovery then serviceSearchCompleted(...) is never called.

 

Earl 

Earl Oliver
Highlighted
Developer
Posts: 205
Registered: ‎07-14-2008
My Device: 7230, 8700, 8820, 9000

Re: Bug in Bluetooth DiscoveryAgent/DiscoveryListener

I have found another issue that could be considered a bug or a misinterpretation of the JSR 82 spec.

 

My device has Bluetooth disabled.  When I call startInquiry(...) on a DisocoveryAgent it returns true.

 

Since the antenna is off, it is impossible to start a device inquiry.  I believe that call should return false, throw a BluetoothStateException, or the documentation should be modified to reflect this.

 

Earl 

Earl Oliver
BlackBerry Development Advisor
Posts: 15,809
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Bug in Bluetooth DiscoveryAgent/DiscoveryListener

Thanks for the update.  I have been able to reproduce both issues and will report them to our development team.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Developer
Posts: 205
Registered: ‎07-14-2008
My Device: 7230, 8700, 8820, 9000

Re: Bug in Bluetooth DiscoveryAgent/DiscoveryListener

I have another possible problem.  When doing a service discovery, servicesDiscovered(...) was called twice for the same transaction ID and provided the same array of ServiceRecord objects.  serviceSearchCompleted(...) was also called twice to indicate SERVICE_SEARCH_COMPLETED.

 

I have been unable to reproduce it, but I am quite certain it took place.  You may want to include a comment in the dev track report.

 

Earl 

Earl Oliver
BlackBerry Development Advisor
Posts: 15,809
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Bug in Bluetooth DiscoveryAgent/DiscoveryListener

Thanks for the update.  Please let me know if you are able to reproduce this.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
New Developer
Posts: 3
Registered: ‎08-02-2008
My Device: BlackBerry 8700r

Re: Bug in Bluetooth DiscoveryAgent/DiscoveryListener

I had this same problem!  eaoliver is da man!

 

RIM, you should put this guy on payroll!  LOL 

 

Mike