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: 46
Registered: ‎07-12-2008
My Device: Not Specified

javax.bluetooth DeviceClass question

Hi, I'm writing an application for blackberry right now that uses the javax.bluetooth API's to communicate to a custom bluetooth device. During device discovery I'm filtering devices based on the Device Class that is returned in the DiscoveryListener.deviceDiscovered callback.

My problem is that the if the device is not paired with the phone, then all three DeviceClass methods (getServiceClass(), getMajorDeviceClass(), getMinorDeviceClass() return zero. Once I pair with a device then these methods are returning real numbers. This behavior is the same regardless of whether the device is our custom one, another phone, a computer, headset, etc..

Is this standard java behavior?

My end goal is to be able to filter out based on the Device Class before the user has to pair with the device.

Thanks!
BlackBerry Development Advisor
Posts: 15,697
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: javax.bluetooth DeviceClass question

This is expected.  A BlackBerry requires a Bluetooth device to be paired before it can connect to it.
Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Developer
Posts: 46
Registered: ‎07-12-2008
My Device: Not Specified

Re: javax.bluetooth DeviceClass question

When I go into bluetooth options on a blackberry and choose Add Device, it will search for bluetooth devices and display a list.  At first the list shows "Phone", "Computer", or maybe "Unknown Device".  After the search stops the friendly names are populated.

 

Nowhere do I have to pair with these devices for the Blackberry to find the "Phone" or "Computer" information.  Is this not possible to do from a third party application?  Do I have to use the RIM bluetooth API's to do this?

 

My only other option is to filter based on the friendly name, which I would rather not do because it takes a couple seconds to get the friendly name for a device.

 

Retired
Posts: 86
Registered: ‎07-11-2008
My Device: Not Specified

Re: javax.bluetooth DeviceClass question

Ryan,

 

Setting up a test application, in 4.3, 4.5, and 4.6, in all cases, I was able to retrieve the values of the major class, minor class, and service class from the DeviceClass retrieved in the discovery.

 

To initiate the query, use DiscoveryAgent.startInquiry(), specifying a GIAC access code.  Add all elements discovered in the deviceDiscovered() method to an array of some sort, keeping refernce to both the RemoteDevice and DeviceClass.  Once you receive the inquiryCompleted() event, iterate through your array, accessing the DeviceClass elements you need to narrow down your search results. 

  
Brian Zubert
Technical Partnership Manager
Research In Motion
Developer
Posts: 191
Registered: ‎04-03-2008
My Device: Bold 9700

Re: javax.bluetooth DeviceClass question

I'm successful in 4.3 as well, but not in 4.2.1.  Could you perhaps check on a 4.2.1 device?  I checked the release notes for 4.2.1 and 4.3.0 and didn't see that anything change related to Bluetooth (besides an A2DP setting).
Developer
Posts: 46
Registered: ‎07-12-2008
My Device: Not Specified

Re: javax.bluetooth DeviceClass question

I'm working with 4.2.x devices (some are 4.2.2 and some are 4.2.1), and my code is compiled with the 4.2.1 RIM libraries...maybe that is why I'm seeing this behavior...
Retired
Posts: 86
Registered: ‎07-11-2008
My Device: Not Specified

Re: javax.bluetooth DeviceClass question

Confirmed to be a bug with 4.2.1 and 4.2.2, fixed in 4.3.0 and above.  In 4.2.1 and 4.2.2, the values returned by the DeviceClass will not be set until the device is paired with the BlackBerry.
Brian Zubert
Technical Partnership Manager
Research In Motion