Mackovich
Mackovich

Reputation: 3563

Bluecove : check if device is paired?

I am new to using Bluecove API and it seems that after a lot of research, I still cannot find a way to check if a RemoteDevice is already paired to the running machine or not.

First of all, I successfully manage to start a scan however, I find it strange that Bluecove does not offer a way to only look for devices that are in discoverable mode hence the need to check if paired or not ...

To be more precisded I am "translating" a project that I developped in C# using InTheHand.dll for Bluetooth management. This assembly is great and helped me achieved what I wanted to do : scan for devices in discoverable mode and in range, initiate pairing process, handle data via Bluetooth streams. I need to do the same thing with Bluecove.

Why is it so hard to find answers ? The documentation says almost nothing about pairing although I managed to pair a device I knew was not paired via RemoteDevice.authenticate().

Anyway to summup :

  1. How to start a scan for only devices in discovery mode ?
  2. How to find out whether a device was already paired or not ?

Note : using both RemoteDevice.isAuthenticated() and RemoteDeviceHelper.implIsAuthenticated(remoteDevice) always return false regardless of the paired status.

Note 2 : Furthermore, having a lookg at RemoteDeviceHelper.javafrom http://bluecove.googlecode.com/svn/trunk/bluecove/src/main/java/com/intel/bluetooth/RemoteDeviceHelper.java , there is a private property for boolean paired.

It seems no public method will use it ...

Even weirder and desperatly frustating, in the debugger mode, looking at a specific RemoteDevice, I can see the value of this property. It is indeed false when device is not paired, and true if device is paired ! So why can't the API tell me so ?

What should I do ? Thanks for the help !

Upvotes: 1

Views: 2316

Answers (1)

JozefS
JozefS

Reputation: 448

List of paired devices:

import javax.bluetooth.*
...
RemoteDevice[] rdList = LocalDevice.getLocalDevice().getDiscoveryAgent().retrieveDevices(DiscoveryAgent.PREKNOWN);

Get name & address of paired device:

rdList[0].getBlueToothAddress();
rdList[0].getFriendlyName(true);

Some comments:

  1. list of paired devices can contain multiple devices having the same name
  2. boolean parameter of getFriendlyName() means if agent should query device for its name, but returns cached name if device is not available (at least my tests showed that)

Upvotes: 3

Related Questions