如何创建机器人RFCOMM插座无需来自用户的任何输入? [英] How to create an Android RFCOMM socket without any input from the user?

查看:128
本文介绍了如何创建机器人RFCOMM插座无需来自用户的任何输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的情况:

我需要编写一个应用程序为Android创造一个RFCOMM插座一个蓝牙适配器电脑(我会写的服务器也是如此)。

I need to write an application for Android to create a RFCOMM socket to a PC with a Bluetooth dongle (I'm going to write the server too).

我的要求是,用户不必手动配对设备

My requirement is that the user doesn't have to pair device manually.

其实,有一个大的黑客,我使用的<一个href="http://www.kiwidoc.com/java/l/p/android/android/5/p/android.bluetooth/c/BluetoothDevice#createInsecureRfcommSocket%28I%29"相对=nofollow> createInsecureRfcommSocket 。

Actually, with a big hack, I'm using the createInsecureRfcommSocket.

一个小的场景的:我有一个Android应用程序,它与在Linux中有一个RFCOMM插座打开交换信息。我可以手动设置设备上的PIN(硬编码它是一个选项)

A little scenario: I've an Android application which exchanges information with a Linux box with a RFCOMM socket opened. I can manually set the PIN on the devices (hard coding it IS an option)

我在寻找不同的道路:

写JNI包装

由于已经完成这里马克斯凯勒曼,我可以写一个JNI层让所有的配对阶段。这应该是一个不错的选择,但有一个问题:

As has been done here by Max Kellermann, I can write a JNI layer to make all the pairing phase. This should be a good option, but there's a problem:

NDK的4b中不提供libbluetooth库,因此-lbluetooth失败,以及NDK的V.3。

选项:

  1. 找到的NDK 1.5(其中包括LIB蓝牙)。经过网络搜索的日子里,我一直没能找到答案。任何人有或者知道哪里可以找到它?
  2. 编译libbluetooth为Android由我自己,并将其用于-lbluetooth。不幸运在那里,我不能够建立他们。任何提示?

使用的东西通过API公开

任何人知道我该如何使用<一个href="http://developer.android.com/reference/android/bluetooth/BluetoothDevice.html#createRfcommSocketToServiceRecord"相对=nofollow> createRfcommSocketToServiceRecord 并让用户不手动配对的设备?可能吗?我应该怎么写服务器?

Any one know how can I use createRfcommSocketToServiceRecord and have the user not to manually pair the device? Is it possible? How should I write the server?

的东西我不知道

也许(当然!)有什么我不知道。也许我可以用别的东西?不RFCOMM? SDP?

Maybe (sure!) there is something I do not know. Maybe I can use something else? Not RFCOMM? SDP?

也许我可以手动配对的Andr​​oid的API?

Maybe I can manually pair with the Android API?

我希望已经明确的是,如果不是只问。再次,因为这不是第一次,我在你的手中:)

I hope to have been clear enough, if not just ask. And again, as it's not the first time, I'm in your hands :)

感谢所有支持你们!

推荐答案

最后,我可以说,您不能

即使你找到一种方法,使用包裹,编写C模块等,Android的发展可能会改变你使用的东西。

Even if you find a way, using wrappers, writing C modules and so on, android evolution will probably change the thing you're using.

因此​​,没有选择。可悲的是,

And so, there's no option. Sadly.

让我们来看看Android的蓝牙API将在未来的变化。

Let's see how Android Bluetooth API will change in the future.

这篇关于如何创建机器人RFCOMM插座无需来自用户的任何输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆