【问题标题】:Cannot connect bluetooth remote control to SBC running linux无法将蓝牙遥控器连接到运行 linux 的 SBC
【发布时间】:2018-05-21 14:50:12
【问题描述】:

我正在 nanopi NEO 空气板上运行 buildroot 生成的 linux 映像(内核 4.11.2),但我很难连接到我的 ruwido 遥控器。
当我使用 hcitool 扫描设备时,我可以看到它:

# hcitool lescan
LE Scan ...
<snip>
5C:F8:21:85:8E:67 ruwido
<snip>

但我无法建立连接(就像遥控器不在这里一样):

# hcitool cc 5C:F8:21:85:8E:67
Can't create connection: Input/output error

我唯一能做的就是获取一些关于它的信息:

# hcitool leinfo 5C:F8:21:85:8E:67
Requesting information ...
        Handle: 64 (0x0040)
        LMP Version: 4.0 (0x6) LMP Subversion: 0x140
        Manufacturer: Texas Instruments Inc. (13)
        Features: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00

我也无法使用 bluetoothctl,因为它没有检测到我的界面,即使它已初始化,bluetoothd 正在运行并且模块已加载:

# lsmod
Module                  Size  Used by
bnep                   20480  2
hci_uart               61440  1
btbcm                  16384  1 hci_uart
btqca                  16384  1 hci_uart
btintel                16384  1 hci_uart
bluetooth             348160  12 hci_uart,btintel,btqca,bnep,btbcm
brcmfmac              245760  0
brcmutil               16384  1 brcmfmac
sunxi_cir              16384  0
# ps -e | grep bluetooth
  553 root     /usr/sbin/bluetoothd
  731 root     grep bluetooth
# sudo hciconfig -a
hci0:   Type: Primary  Bus: UART
        BD Address: F7:93:3E:74:CF:62  ACL MTU: 1021:8  SCO MTU: 64:1
        UP RUNNING 
        RX bytes:12593 acl:7 sco:0 events:292 errors:0
        TX bytes:2050 acl:4 sco:0 commands:155 errors:0
        Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
        Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
        Link policy: RSWITCH SNIFF 
        Link mode: SLAVE ACCEPT 
        Name: 'NanoPi-NEO-Air'
        Class: 0x000000
        Service Classes: Unspecified
        Device Class: Miscellaneous, 
        HCI Version: 4.1 (0x7)  Revision: 0x0
        LMP Version: 4.1 (0x7)  Subversion: 0x2209
        Manufacturer: Broadcom Corporation (15)

# bluetoothctl 
Agent registered
[bluetooth]# power on
No default controller available

我的问题是,如何将遥控器配对并连接到电路板?不管是通过 hcitool、bluetoothctl 还是其他工具。

更新

感谢Prabhakar Lad's 的评论,bluetoothctl 现在正在检测接口,问题仍然存在,问题似乎已经缩小:

# rfkill unblock all
# hciconfig hci0 up
# hciconfig -a
hci0:   Type: Primary  Bus: UART
        BD Address: AA:AA:AA:AA:AA:AA  ACL MTU: 1021:8  SCO MTU: 64:1
        UP RUNNING PSCAN 
        RX bytes:1930 acl:0 sco:0 events:101 errors:0
        TX bytes:1587 acl:0 sco:0 commands:103 errors:0
        Features: 0xbf 0xfe 0xcf 0xfe 0xdb 0xff 0x7b 0x87
        Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 
        Link policy: RSWITCH SNIFF 
        Link mode: SLAVE ACCEPT 
        Name: 'BlueZ 5.47'
        Class: 0x000000
        Service Classes: Unspecified
        Device Class: Miscellaneous, 
        HCI Version: 4.1 (0x7)  Revision: 0x0
        LMP Version: 4.1 (0x7)  Subversion: 0x2209
        Manufacturer: Broadcom Corporation (15)

# bluetoothctl
[NEW] Controller F7:93:3E:74:CF:62 BlueZ 5.47 [default]
[NEW] Device 5C:F8:21:85:8E:67 ruwido
Agent registered
[bluetooth]# agent on
Agent is already registered
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# scan on
Discovery started
[CHG] Controller F7:93:3E:74:CF:62 Discovering: yes
<snip>
[NEW] Device 5C:F8:21:85:8E:67 ruwido
<snip>
[bluetooth]# scan off
<snip>
[CHG] Device 5C:F8:21:85:8E:67 RSSI is nil
<snip>
[CHG] Controller F7:93:3E:74:CF:62 Discovering: no
Discovery stopped
[bluetooth]# pair 5C:F8:21:85:8E:67
Attempting to pair with 5C:F8:21:85:8E:67
[CHG] Device 5C:F8:21:85:8E:67 Connected: yes
[ruwido]# [  501.424858] Bluetooth: hci0 unexpected SMP command 0x0b from 5c:f8:21:85:8e:67
[CHG] Device 5C:F8:21:85:8E:67 Connected: no
[bluetooth]# pair 5C:F8:21:85:8E:67
Attempting to pair with 5C:F8:21:85:8E:67
Failed to pair: org.bluez.Error.ConnectionAttemptFailed

SMP错误似乎与bluetooth low-energy security有关,所以我应该使用不同的工具进行配对吗?

其他信息

我实际上将busybox init系统与我在制造商的图片(nanopi-neo-air_FriendlyCore-Xenial_4.11.2_20171113.img)中找到的蓝牙初始化脚本一起使用,并进行了调整,以便它们可以与busybox init一起使用(图片上的init系统是systemd/upstart) .
所以我有两个文件:

我在 buildroot 2017.08.1 中使用 bluez 5.47 和以下选项:

BR2_PACKAGE_BLUEZ_TOOLS=y
# BR2_PACKAGE_BLUEZ_UTILS is not set
BR2_PACKAGE_BLUEZ5_UTILS=y
BR2_PACKAGE_BLUEZ5_UTILS_OBEX=y
BR2_PACKAGE_BLUEZ5_UTILS_CLIENT=y
BR2_PACKAGE_BLUEZ5_UTILS_DEPRECATED=y
# BR2_PACKAGE_BLUEZ5_UTILS_EXPERIMENTAL is not set
# BR2_PACKAGE_BLUEZ5_PLUGINS_HEALTH is not set
# BR2_PACKAGE_BLUEZ5_PLUGINS_MIDI is not set
# BR2_PACKAGE_BLUEZ5_PLUGINS_NFC is not set
# BR2_PACKAGE_BLUEZ5_PLUGINS_SAP is not set
BR2_PACKAGE_BLUEZ5_UTILS_TEST=y
# BR2_PACKAGE_BLUEZ5_UTILS_GATTTOOL is not set

【问题讨论】:

  • 你能试试'rfkill unblock all'然后重启蓝牙服务'systemctl restart bluetooth'然后试试bluetoothctl工具。顺便说一句,您使用的是哪个版本的 bluez? Fyi C 代码配对 [1] prabhakarlad.blogspot.co.uk/2017/09/…
  • 非常感谢您的回复,bluetoothctl 正在工作,但是遥控器无法连接。我已经用新状态更新了我的帖子。

标签: bluetooth embedded-linux hci nanopi


【解决方案1】:

你没有通过我完整的post,你需要执行以下操作 完成 rfkill 和服务重启后的步骤:

a]bluetoothctl

Start the tool, this should detect the controller

b][bluetooth]# agent on

Turn on the pairing agent

c][bluetooth]# scan on

Let bluez detect your device, look in my post it should print you baddr (5C:F8:21:85:8E:67)

d][bluetooth]# scan off

Turn off scanning once your device is discovered

e] [蓝牙]#pair 5C:F8:21:85:8E:67

Now pair to the device

现在应该已配对。 注意:在 bluez 扫描设备之前,您无法配对设备。

【讨论】:

  • 再次感谢,我不认为扫描是强制性的。该帖子已更新为当前状态。它实际上看起来像是一个安全问题。
  • 应用此补丁bugzilla.kernel.org/attachment.cgi?id=186691&action=edit 看看是否能解决您的问题!
  • 它已经应用在我使用的内核中,所以它没有改变问题。我确实设法使用 gatttool 从远程读取特征,所以我想知道使用它来读取按下的键的值。
  • 您的意思是 gatttool 能够连接?你也可以试试github.com/sandeepmistry/noble 这会让生活更轻松!
  • 是的,我可以使用 gatttool 连接到远程。感谢您的建议,但不幸的是我无法在我正在处理的项目中使用 nodeJS。
猜你喜欢
  • 1970-01-01
  • 2015-01-19
  • 1970-01-01
  • 1970-01-01
  • 2018-01-01
  • 2016-07-08
  • 2012-12-12
  • 2017-02-02
  • 2018-07-07
相关资源
最近更新 更多