问题描述
我是Android世界的新手.如果我的问题太幼稚,请原谅我.
I am a complete newbie to the world of Android.Please forgive me if my question is too naive.
我一直在研究一个示例应用程序,以实现Linux Box(运行Bluez-5.42的FC-21)和Android平板电脑之间的蓝牙配对.我正在使用NFC将蓝牙名称,地址和OOB数据从PC传输到Android.我可以通过NFC(准确地说是光束)将上述数据从PC发送到Android,并且可以在Android端解析和解码所有数据.有了Android上可用的Linux box的蓝牙地址,我可以调用CreateBond()将Android平板电脑与Linux Box配对.我已经测试了这一部分,它可以按预期工作.
I have been working on a sample application to realize Bluetooth pairing between a Linux Box (FC-21 running Bluez-5.42) and an Android tablet. I am using NFC to transfer the Bluetooth name, address and OOB data from the PC to Android.I am able to send the above data from PC to Android over NFC (beam to be precise) and I am able to parse and decode all the data at the Android side.With the Bluetooth address of the Linux box available at Android, I can call CreateBond() to pair the Android tablet with Linux Box. I have tested this part and it works as expected.
现在,此方法的问题在于,在蓝牙配对期间,使用了数字比较或密码输入关联模型,当他使用NFC进行配对时,我觉得这是用户体验的一种畸变.由于我已经拥有PC的OOB数据,因此我想使用OOB关联进行配对,以便不影响用户体验.
Now, the problem with this method is that, during Bluetooth pairing Numeric comparison or passkey entry association model is used, which I feel is an aberration to the user experience when he is using NFC to do the pairing.Since I already have the OOB data of the PC, I would like to use the OOB association for pairing such that the user experience is not compromised.
为此,当我使用反射将CreateBond()替换为CreateBondOutOfBand()时,没有配对请求从Android发送到Linux PC.
To do this, when I replace CreateBond() with CreateBondOutOfBand() [using reflection], no pairing request is sent from Android to the Linux PC.
try {
showLog("Pairing started");
Method m = bDev.getClass().getMethod("createBondOutOfBand", byte[].class, byte[].class);
showLog("Found method");
Boolean flag = (Boolean) m.invoke(bDev, Hash, Rand,(Object[]) null);
//Method m = bDev.getClass().getMethod("createBond", (Class[]) null);
//Boolean flag = (Boolean) m.invoke(bDev, (Object[]) null);
if(flag)
showLog("Pairing successfully finished.");
else
showLog("Pairing failed");
} catch (Exception e) {
showLog("Pairing failed.");
}
我在线搜索,但找不到任何具体证据表明可以在Android中实现OOB配对.
I searched online but could not find any concrete evidence that OOB pairing can be implemented in Android.
此外,要检查本机Android的行为,我创建了带有Linux框的蓝牙名称,地址和OOB数据的NFC标签.当我将标签放置在Android平板电脑上时,Bluettoth已开始配对,但仍未使用OOB关联模型.
Further, to check the behavior of native Android, I created a NFC tag with the Bluetooth name, address and OOB data of the Linux box. When I held the tag against the Android tablet, Bluettoth pairing was started but it was still not using OOB association model.
我的问题如下,
- Android上确实支持OOB关联模型吗?
- 如果支持OOB关联模型,则CreateBondOutOfBand()使用的API还是我需要使用的其他API?
- Is OOB association model really supported on Android?
- If OOB association model is supported, is CreateBondOutOfBand() theAPI to be used or is there any other API that I need to use?
任何输入将不胜感激.
谢谢
赛
推荐答案
根据此,
由于createBondOutOfBand()和removeBond()从公共文档中隐藏了 ,这些方法仅受Android 9的限制.使用反射调用这些方法将导致异常.
Since createBondOutOfBand() and removeBond() are hidden from public documentation, these methods are restricted from Android 9. Calling these methods using reflection will cause exceptions.
这篇关于Android是否真的支持Bluetooth OOB配对?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!