本文介绍了蓝牙"带外&QUOT的; (OOB)在Android配对?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找互联网并没有看到在如何准确实现OOB配对的方式事情。我希望这里的人可以点我的一些例子code来帮助我。在Android开发者网站上的聊天的例子并没有真正深入到这种类型的配对在所有的。

基本上,我有,我想安全地与设备配对,C ++编写,已经没有内置在显示/ IO机制的Andr​​oid平板电脑。进行配对的平板电脑将作为GUI / IO接口,我会发短信回来和第四蓝牙。因此,我想通过OOB配对方案,以安全地配对的平板电脑与每一个设备。

我明白OOB的概念,但我很难找到合适的方法,找上了android.developers.com网站我的Andr​​oid客户端code时调用。此外,当在看bluez的东西,我找不到太多的去为我的C ++编写的服务器。

的基本的使用情况是,用户将通过USB连接平板连接到设备。 USB连接将有助于传球键/ MAC地址对每一个设备,然后利用这些信息对蓝牙与对方。

我可以计算出USB一部分,但一旦我有客户端和服务器上的按键和必要的信息,我似乎无法追查正确的方法,呼吁两端顺利,安全地进行配对。

我已经有一个客户机/服务器通过一个不安全的连接坦率的谈话真是我在使用的实际配对两端麻烦的唯一部分。因为一旦我配对,我可以用一个secureRFComm做我将来的所有消息的。

由于任何人都可以帮助!

解决方案

我有我的问题,95%解决,但我已经打了小路障。首先,我会更新这个帖子有一个更具体的答案,原来的问题,并张贴我的问题在最后。

要回顾一下,我的任务是利用带外(OOB)配对通过USB安全地配对使用蜂巢3.2的Andr​​oid平板电脑到小猎犬板。我不能发布具体的code,但我会给你所有需要得到这个工作的步骤。

在小猎犬板,我已经安装了dbusoob插件安装的bluez 4.96堆栈。要确认这是正确设置安装在比格板2蓝牙软件狗和运行OOB测试code在测试文件夹中的bluez档案发现研究。这是一个Python脚本。这个脚本应该成功配对2蓝牙软件狗,如果不是的bluez可能是不正确设置。

要获得USB通信结合的平板电脑工作,你需要安装mtpfs和MTP-工具。这些用于安装平板电脑。他们的方法我解决了获得2个设备之间的OOB信息均安装在小猎犬板上的平板电脑。一旦安装在平板电脑和小猎犬板可以写出来与所需的信息的文件。

在android的侧OOB不支持公共API中这样的事情变得棘手。我相信这是因为蜂巢3.2不具有正式支持OOB联结的bluez的堆栈,但谷歌在,我相信这一点,因为如果你姜饼源$ C ​​$ C蓝牙适配器某种实施codeD与蓝牙设备类,你可以看到OOB方法可用,但通过记录的API不暴露。

这些方法仍市民这样你就可以通过反射调用它们。使用反射,你也可以得到所有的方法签名的一类。这是我想通了什么方法,我提供给我。

虽然小心,很多人都没有记载,这不是很明显的一些东西做。其中重要的要记下是readOutOfBandData()在设备类的适配器类和setDeviceOutOfandData()。

当你写你的OOB数据,以在平板电脑上的文件由小猎犬板读你可能会遇到另外一个疑难杂症的。由于Android采用MTP你必须索引的文件后,它被写入到内部SD卡存储。为了解决这个问题,你需要利用MediaScannerConnection类和SCANFILE()方法。

希望上面的帮助别人与此相同的问题。

现在对我的问题。我有我的Andr​​oid应用程序伟大的工作,而我的Beagle Board code是testOOB例如更新的一端从文件中读取OOB信息。现在我看到的问题是,当执行每个人都看到了对方很大,但在平板电脑上我仍然得到一个消息,询问我是否要配对的设备XYZ。有没有密钥或数字。它只是要求配对设备XYZ或类似的规定。

如果我preSS配对这一切都是从看片点配对,但python脚本返回的配对失败。在比格板的Python脚本呼吁做设备之间的结合实际的方法。甚至当我有机器人发起createBond呼叫我看到了同样的结果。我可以保证,我已经尝试配对在两种情况下,这样似乎并不被前设置两端所需的OOB数据。

所以,我的问题是,我希望有人能帮助我的:

1)为什么我还可以得到一个消息,在Android上,如果OOB数据是正确交换?是否有其他呼叫我失去了和哪一端?

2)为什么甚至认为我preSS配对在平板电脑上显示的弹出小猎犬板python脚本返回配对失败。片剂和布鲁斯监测都显示设备的配对。一些再我倾向于,我失去了一些东西的想法。

由于任何人都可以帮助:)

编辑:

要在此处添加更多的信息的logcat的输出:

最后两行似乎是触发弹出式Android上要么对/取消与问题的设备。我想安卓知道的只是汽车的债券,甚至不问。我可能会错过一个电话或做出来的东西才能为我所知道的。最后我做我的code是创造这似乎是明显的地方做债券....

感谢您的任何建议!

I've been searching the internet and haven't seen anything in the way of how to exactly implement OOB pairing. I was hoping somebody here could point me to some example code to help me out. The chat example in the android developers site didn't really dive into this type of paring at all.

Basically, I have an Android tablet that I want to securely pair with a device, written in c++, that has no built in display/IO mechanism. The tablet to be paired will act as the GUI/IO interface and I'll send message back and fourth over Bluetooth. Thus I want to securely pair the tablet with each device through the OOB paring scheme.

I understand the concept of OOB but I'm having difficulty finding the proper methods to call when looking on the android.developers.com site for my android client code. Also when looking at the bluez stuff I can't find much to go on for my c++ written server.

The basic use case is the user will connect the tablet to the device via a USB connection. The USB connection will facilitate the passing of keys/mac addresses for each device and then using that information pair bluetooth with each other.

I can figure out the USB part but once I have the keys and necessary information on the client and server I can't seem to track down the correct methods to call for both ends to successfully and securely pair.

I already have a client/server talking via an insecure connection so really the only part I'm having trouble with is the actually pairing on both ends. As once I'm paired I can used a secureRFComm to do all of my future messaging.

Thanks to anybody that can help!

解决方案

I have my issue 95% solved but I have hit a small road block. First I'll update this post with a more concrete answer to the original question and post my question at the end.

To recap, my task is to use out of band (oob) pairing to securely pair an android tablet using Honeycomb 3.2 to a beagle board through USB. I can't post specific code, but I'll give you all the steps needed to get this done.

On the beagle board, I have the bluez 4.96 stack installed with the dbusoob plugin installed. To confirm this is set up correctly install 2 Bluetooth dongles on the beagle board and run the OOB Test Code found in in the bluez archive in the test folder. This is a python script. The script should successfully pair the 2 Bluetooth dongles, if not bluez is probably not setup correctly.

To get USB communications with a tablet working you need to install mtpfs and mtp-tools. These are used to mount your tablet. They way I solved getting OOB information between the 2 devices were to mount the tablet on the beagle board. Once mounted the tablet and beagle board can write out a file with the information needed.

On the android side OOB is not supported in the public API so things get tricky. I believe this is because Honeycomb 3.2 does not have a bluez stack that officially supports OOB bonding, but Google has some kind of implementation coded in. I believe this because if you look at gingerbread source code for the Bluetooth Adapter and Bluetooth Device classes you can see OOB methods available but not exposed through the documented API.

These methods are still public so you can call them through reflection. Using reflection you can also get all of the method signatures in a class. This is how I figured out what methods I had available to me.

Beware though that many are not documented and it's not obvious what some do. The important ones to make note of are the readOutOfBandData() in the adapter class and setDeviceOutOfandData() in the device class.

Another gotcha you might run into is when you write your oob data to a file on the tablet to be read by the beagle board. Since android uses mtp you must index your file after it is written to the internal sdcard storage. To solve this you need to make use of the MediaScannerConnection class and the scanFile() method.

Hopefully the above helps anybody else with this same issue.

Now on to my question. I have my android application working great and my beagle board code is the testOOB example updated to have one end read OOB information from a file. Now the issue I see is when executed everybody sees each other great, but on the tablet I still get a message asking if I want to pair with device xyz. There are no keys or numbers. It just asks "Pair with Device XYZ" or something along those lines.

If I press "pair" it's all paired from the tablets point of view, BUT the python script returns that the paring failed. The python script on the beagle board is calling the actual method to do the bonding between the devices. Even when I have the android initiate the createBond call I see the same outcome. I can guarantee that I have set the required OOB data on both ends before trying to pair in both cases so that doesn't seem to be it.

So my issues that I'm hoping somebody can help me with are:

1) Why do I even get a message on android if the OOB data is exchanged properly? Is there another call I'm missing and on which end?

2) Why does the beagle board python script return paring failed even thought I press "pair" popup displayed on the tablet. The tablet and blues monitor both show the devices as paired. Some again I'm leaning towards the idea that I am missing something.

Thanks to anybody that can help :)

EDIT:

To add more information here is the logcat output:

The last two line seems to be triggering the popup on Android to either Pair/Cancel with the Device in questions. I would like Android to know to just auto bond and not even ask. I could be missing a call or doing something out of order for all I know. The last thing I do in my code is to create the bond which seems to be the obvious place to do it....

Thanks for any suggestions!

这篇关于蓝牙"带外&QUOT的; (OOB)在Android配对?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 14:11