如何使Android BLE连接到Bluez Peripheral? (连接问题) [英] How to make Android BLE connect to Bluez Peripheral? (Connection issues)

查看:228
本文介绍了如何使Android BLE连接到Bluez Peripheral? (连接问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用低功耗蓝牙将Nexus 5(Android 6.0.1)智能手机连接到台式计算机(Ubuntu 15.04 64位和BlueZ 5.36). 我使用的是带有CSR BC8510芯片组的BT 4.0 USB加密狗.

I am trying to connect my Nexus 5 (Android 6.0.1) smartphone to my desktop computer (Ubuntu 15.04 64-bit with BlueZ 5.36) using Bluetooth Low Energy. I use a BT 4.0 USB dongle with a CSR BC8510 chipset.

该设置实际上仅在几天前就起作用了. 然后,我切换到Broadcom USB软件狗,它开始变得不稳定. 连接变慢并开始失败. 即使我切换回CSR加密狗和另一台Ubuntu计算机(仍使用同一Android设备),它现在也不再起作用. 但是,接收广告包不会受到影响,并且仍然可以正常工作. 我的项目正在使用 Android信标库,并不断扫描BLE广告包.

The setup did actually work just a couple of days ago. Then I switched to a Broadcom USB dongle and it started to become unstable. Connecting became slow and started to fail. It now does not work anymore at all even though I switched back to the CSR dongle and a different Ubuntu machine (still using the same Android device). However receiving advertising packets was not affected and does still work. My Project was using the Android Beacon Library and continuously scanned for BLE advertising packets.

以下对我不起作用的最小设置-但我认为应该如此:

A minimal setup that does not work for me --but should in my opinion-- is the following:

使用以下脚本让BlueZ做广告:

Make BlueZ advertise using the following script:

# Set advertising data (AltBeacon format).
sudo hcitool -i hci0 cmd 0x08 0x0008 1F 02 01 02 1B FF 00 00 BE AC 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 BC 00

# Set advertising interval.
sudo hcitool -i hci0 cmd 0x08 0x0006 A0 00 A0 00 00 00 00 00 00 00 00 00 00 07 00

# Start advertising.
sudo hcitool -i hci0 cmd 0x08 0x000a 01

# Run Bluez example gatt server.
./test/example-gatt-server

启动BLE扫描器,例如这一个.它接收广告包并列出外围设备,但尝试连接失败.

Start a BLE scanner, for example this one. It receives the advertising packets and lists the peripheral but trying to connect fails.

到目前为止,我尝试过

  • 不同的BlueZ版本
  • 不同的Linux机器
  • Google Play商店中的不同BLE扫描仪应用程序
  • 拔下并重新插入加密狗
  • 重新启动Ubuntu和Android
  • 重置网络设置,甚至恢复出厂设置的Android

使用BlueZ btmon工具,尝试连接时没有看到HCI通信. 这让我猜测问题出在我的BlueZ HCI配置中,还是在Android或Android硬件中. 我尚未尝试使用其他Android设备,但会尽快这样做.

Using the BlueZ btmon tool I see no HCI traffic when trying to connect. That makes me guess the problem is somewhere in my BlueZ HCI configuration or inside Android or my Android hardware. I did not yet try a different Android device but I will do so as soon as possible.

有人遇到过类似的问题,还是知道如何进行更深层次的调试? 非常感谢.

Did anyone have similar issues or know how to debug at a deeper level? Thank you very much.

推荐答案

我遇到了类似的问题.这是我取得的进步

I am having a similar problem. Here is the progress I've made

确保将Android配置为仅以BLE模式连接:

Make sure Android is configured to connect only in BLE mode:

mBluetoothGatt = device.connectGatt(this, false, mGattCallback, TRANSPORT_LE);

首先尝试从非Android设备进行连接(这是我遇到的问题)

Try connecting from a non-Android device first (this is the part I'm stuck on)

这篇关于如何使Android BLE连接到Bluez Peripheral? (连接问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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