简体   繁体   English

Bluecove:检查设备是否配对?

[英]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. 我是使用Bluecove API ,似乎经过大量研究,我仍然找不到一种方法来检查RemoteDevice是否已与运行中的机器配对。

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 ... 首先,我成功地开始进行扫描,但是,我感到奇怪的是, Bluecove没有提供仅查找处于可发现模式的设备的方法,因此需要检查是否已配对...

To be more precisded I am "translating" a project that I developped in C# using InTheHand.dll for Bluetooth management. 更确切地说,我正在“翻译”一个使用InTheHand.dll在C#中开发的项目进行蓝牙管理。 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 . 这个程序集很棒,并帮助我实现了我想做的事情:以可发现的模式和范围扫描设备,启动配对过程,通过Bluetooth streams处理数据。 I need to do the same thing with Bluecove . 我需要对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() . 尽管我设法配对了一个我知道不是通过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. 注意:无论配对状态如何,同时使用RemoteDevice.isAuthenticated()RemoteDeviceHelper.implIsAuthenticated(remoteDevice)始终返回false

Note 2 : Furthermore, having a lookg at RemoteDeviceHelper.java from http://bluecove.googlecode.com/svn/trunk/bluecove/src/main/java/com/intel/bluetooth/RemoteDeviceHelper.java , there is a private property for boolean paired . 注意2:此外,从http://bluecove.googlecode.com/svn/trunk/bluecove/src/main/java/com/intel/bluetooth/RemoteDeviceHelper.java看一下RemoteDeviceHelper.java ,有一个私有属性对于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. 甚至在调试器模式下,通过查看特定的RemoteDevice ,也很奇怪和令人沮丧,我可以看到此属性的值。 It is indeed false when device is not paired, and true if device is paired ! 设备未配对时确实为false,而设备未配对则为true! So why can't the API tell me so ? 那么,为什么API不能告诉我呢?

What should I do ? 我该怎么办 ? Thanks for the help ! 谢谢您的帮助 !

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) getFriendlyName()的布尔参数表示代理是否应查询设备的名称,但如果设备不可用则返回缓存的名称(至少我的测试表明)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM