无法发现蓝牙设备
我想在 Android 手机和远程设备之间建立蓝牙通信。远程设备的类是一个基本类,只是一个简单的蓝牙适配器。当我使用蓝牙扫描设备功能时,手机可以识别不同类别的设备(例如计算机、手机、蓝牙耳机),但不能识别这一类设备。 我在配备 Android 2.1 的 Samsung Galaxy Theos 和 HTC Wildfire 上进行了尝试,但两者都得到了相同的结果。 手机制造商或 Android 是否有可能过滤某些类别的设备?否则,是否有其他方法可以使该设备被发现?
提前致谢。
洛伦斯
I'd like to establish a Bluetooth communication between an Android phone and a remote device. The class of the remote device is a basic one just a simple Bluetooth adapter. When I use the Bluetooth scan devices function, the phone recognizes devices from different class (ex. computer, phone, Bluetooth headset) but not this one.
I tried it on a Samsung Galaxy Theos and a HTC Wildfire with Android 2.1 but I got the same result with both.
Is that possible that the phone manufacturer or Android filters certain class of devices? Otherwise, is there another way to make this device discoverable?
Thanks in advance.
lorenth
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我能够解决这个问题,不是通过改变 Android 端的东西,而是通过改变蓝牙适配器的类。我知道这并不能解决 0x00 类设备被阻止的原始问题,但至少您可以在 Android 上使用 BT 串行设备,尽管存在错误。
我从 ebay 购买了一个蓝牙串行转换器(链接在这里:http://www.ebay.co.uk/itm/Bluetooth-RS232-serial-Converter-Module-Adapter-Board-/190508188703?pt=LH_DefaultDomain_0&hash=item2c5b2c441f ),正如预期的那样,我的 HTC Desire 在默认配置下无法识别它。
我不想尝试上面提到的 Zorn 软件的应用程序,因为有些人报告说它弄乱了他们的 HTC 手机。相反,我从 BT 设备的 AT 命令数据表中发现,除其他参数外,您还可以通过使用 UART 连接和终端程序来更改设备的类号。
我花了一段时间才发现你不能使用蓝牙串行连接来访问配置接口,而是必须使用设备上的物理 RX 和 TX 引脚。您还需要将名为“Key”的引脚连接到 Vcc 以激活命令模式。因此,我使用AVR串行编程器设备的RS232转UART接口连接到RX/TX引脚,并使用Realterm作为终端程序。一旦我获得了正确的波特率 38400,并交换了我最初以错误方式连接的 RX 和 TX 引线,AT 命令接口就可以工作了。
我在这里使用了发电机
http://bluetooth-pentest.narod.ru/software/bluetooth_class_of_device-service_generator.html
获取有效的非零类号(我使用对象传输/计算机/桌面工作站,总计 0x100104),并使用命令
at+class=100104\r\n
将其输入到设备,其中 \r\n 表示输入(参见数据表)。
关闭 BT 适配器、断开“Key”引脚并再次打开后,我能够以正常方式将其与手机配对。数据传输也有效。我再次使用 AVR 编程器的 UART 和 Realterm 将一些数据(ASCII 格式的 Hello World 消息)发送到适配器的 RX/TX 引脚。在Android端,我使用应用程序SENA Bterm来接收数据。
我希望这可以帮助人们用手机和嵌入式系统做有趣的事情。
I was able to work around the issue not by changing things at the Android end but by changing the class of the bluetooth adapter. I know this doesn't solve the original issue of class 0x00 devices being blocked, but at least you can use a BT serial device with android despite the bug.
I bought a Bluetooth serial converter from ebay (link here: http://www.ebay.co.uk/itm/Bluetooth-RS232-serial-Converter-Module-Adapter-Board-/190508188703?pt=LH_DefaultDomain_0&hash=item2c5b2c441f ) which, as expected, wasn't recognized by my HTC Desire in its default configuration.
I didn't want to try the app by Zorn software mentioned above, because some people reported it messing up their HTC phones. Instead, I found from the BT device's AT commands datasheet that you can change, among other parameters, the device's class number by using an UART connection and a terminal program.
It took me a while to figure out that you can't use the Bluetooth serial connection to access the configuration interface, but that you must use the physical RX and TX pins on the device instead. You also need to connect the pin named "Key" to Vcc to activate the command mode. So I used an AVR serial programmer device's RS232 to UART interface to connect to the RX/TX pins and used Realterm as the terminal program. This got the AT command interface working once I had the right baudrate, 38400, and swapped the RX and TX leads which I initially connected the wrong way around.
I used the generator here
http://bluetooth-pentest.narod.ru/software/bluetooth_class_of_device-service_generator.html
to get a valid non-zero class number (I used object transfer/computer/desktop workstation, which amounts to 0x100104), and entered it to the device with the command
at+class=100104\r\n
where \r\n indicates Enter (see the datasheet).
After switching the BT adapter off, disconnecting the "Key" pin and switching on again, I was able to pair it with my phone the normal way. Data transfer also worked. I again used the AVR programmer's UART and Realterm to send some data (a Hello World message in ASCII) to the RX/TX pins of the adapter. In the Android end, I used the app SENA Bterm to receive the data.
I hope this helps someone do interesting things with their phones and embedded systems.
好的,经过在网络上的一些研究,对于那些想要在 Android 上开发蓝牙应用程序的人(在 2.1 Eclair 上进行了测试,我不知道其他版本)似乎某些手机制造商决定忽略任何标榜自己为 < 的蓝牙设备强>类0×00并且不会允许连接,在发现时触发意图,甚至在蓝牙设置页面上列出它。这是 Eclipse LogCat 部分的调试模式下的样子,
我在 Samsung Galaxy 3 teos 和 HTC Wildfire 上进行了尝试。显然它在 Nexus One 上运行良好。可惜谷歌停止销售它了。如果你们中的一些人在其他手机上进行了测试并且可以正常工作,请告诉我们。
洛伦斯
Ok after some research on the web, for those who want to develop a Bluetooth application on Android (tested on 2.1 Eclair I don't know for other versions) It seems that some phone manufacturer decided to ignore any bluetooth device which advertises itself as class 0×00 and wont allow connections, fire off Intents on discovery or even list it on the bluetooth settings page. Here what it looks like in debugging mode in the LogCat section of Eclipse
I tried it on a Samsung Galaxy 3 teos and a HTC Wildfire. Apparently it works fine on the Nexus One. Well too bad Google stopped selling it. If some of you tested on other phones and it works please let us know.
Lorenth
我已经在一些不同版本的 Android 上测试了与串行(类 0x00)设备的蓝牙连接,结果如下:
Android 2.1(橙色或 O2,不记得了):配对正常
运行 Android 2.2 的东芝上网本:配对正常
HTC Desire、Vodafone、Android 2.2:无法发现设备
HTC Desire HD、Vodafone、Android 2.2:无法发现设备
因此很可能某些电话公司已阻止 0x00 访问。我与沃达丰联系,以 a) 获得澄清;b) 说服他们(如果可能)解决此问题。如果我得到任何有用的东西,我会发布。
大卫
I have tested BlueTooth connections to a serial (Class 0x00) device on some different flavours of Android, with these results:
Android 2.1 (Orange or O2, can't remmeber) : pairs ok
Toshiba Netbook running Android 2.2 : pairs ok
HTC Desire, Vodafone, Android 2.2 : fails to discover device
HTC Desire HD, Vodafone, Android 2.2 : fails to discover device
So it is quite possible that some phone companies have blocked 0x00 access. I am in touch with Vodafone to a) get clarification and b) persuade them if possible to fix this. I'll post if I get anything useful.
David
更新: 此解决方案依赖于从应用程序内读取 logcat 的权限,因此不适用于现代版本的 Android(> 大约 3.0)。如果有人使用 Android v2.x,请在此处留下答案并提供更新的链接。
假设您正在为手机编写应用程序,我已经编写了一个解决此问题的类:
http://zornsoftware.codenature.info/blog/pairing-spp-bluetooth-devices- with-android-phones.html
我可以确认 LG Optimus One 和三星 Galaxy S(均为 Android 2.2)都存在此问题。我已就此事联系 LG 和三星,并将回复我听到的任何结果。
UPDATE: This solution relies on access to read logcat from within your app, so will not work on modern versions of Android (> about 3.0). Answer left here with updated link in case someone is using Android v2.x.
Assuming you are writing an app for your phone, I have written a class that works around this issue:
http://zornsoftware.codenature.info/blog/pairing-spp-bluetooth-devices-with-android-phones.html
I can confirm the LG Optimus One, and also the Samsung Galaxy S (both Android 2.2) both suffer from this problem. I have contacted LG and Samsung about it and will post back any results i hear.