在 LE 读取远程使用的功能时,树莓派的蓝牙连接失败

Posted

技术标签:

【中文标题】在 LE 读取远程使用的功能时,树莓派的蓝牙连接失败【英文标题】:Bluetooth connection failed from Raspberry Pi at LE Read Remote Used Features 【发布时间】:2021-09-26 07:40:26 【问题描述】:

我正在尝试将 Raspberry Pi 4 型号 B 与 Ortho remote 配对,但连接失败。

我使用的是 Linux raspberrypi 5.10.17-v7l+ 内核

我对调试蓝牙仍然很陌生,但它看起来在“LE 读取远程使用的功能”步骤中失败,并出现“无法建立连接 (0x3e)”错误。这是什么意思?我可以做些什么来进一步调试?

$ sudo bluetoothctl
[bluetooth]# trust F9:XX:XX:XX:XX:XX
Changing F9:XX:XX:XX:XX:XX trust succeeded
[bluetooth]# connect F9:XX:XX:XX:XX:XX
Attempting to connect to F9:XX:XX:XX:XX:XX
[CHG] Device F9:XX:XX:XX:XX:XX Connected: yes
Failed to connect: org.bluez.Error.Failed
[CHG] Device F9:XX:XX:XX:XX:XX Connected: no
[bluetooth]# pair F9:XX:XX:XX:XX:XX
Attempting to pair with F9:XX:XX:XX:XX:XX
[CHG] Device F9:XX:XX:XX:XX:XX Connected: yes
Failed to pair: org.bluez.Error.AuthenticationFailed
[CHG] Device F9:XX:XX:XX:XX:XX Connected: no


$ sudo btmon
...
@ MGMT Event: Device Connected (0x000b) plen 44                                                                                                          0x0002 [hci0] 1979.845117
        LE Address: F9:XX:XX:XX:XX:XX (Static)
        Flags: 0x00000000
        Data length: 31
        Name (complete): ortho remote
        Flags: 0x04
          BR/EDR Not Supported
        Company: not assigned (1104)
          Data: 01005238434b4931324b
< HCI Command: LE Read Remote Used Features (0x08|0x0016) plen 2                                                                                            #1688 [hci0] 1979.845351
        Handle: 64
> HCI Event: Command Status (0x0f) plen 4                                                                                                                   #1689 [hci0] 1979.846487
      LE Read Remote Used Features (0x08|0x0016) ncmd 1
        Status: Success (0x00)
> HCI Event: Command Complete (0x0e) plen 14                                                                                                                #1690 [hci0] 1979.846501
      LE Read Remote Used Features (0x08|0x0016) ncmd 1
        Status: Success (0x00)
        00 00 00 00 00 00 00 00 00 00                    ..........
> HCI Event: LE Meta Event (0x3e) plen 12                                                                                                                   #1691 [hci0] 1980.142018
      LE Read Remote Used Features (0x04)
        Status: Connection Failed to be Established (0x3e)
        Handle: 64
        Features: 0x3f 0x00 0x00 0x08 0x00 0x00 0x00 0x00
          LE Encryption
          Connection Parameter Request Procedure
          Extended Reject Indication
          Slave-initiated Features Exchange
          LE Ping
          LE Data Packet Length Extension
          Unknown features (0x0000000008000000)
@ MGMT Event: Command Complete (0x0001) plen 10                                                                                                          0x0001 [hci0] 1980.142093
      Pair Device (0x0019) plen 7
        Status: Failed (0x03)
        LE Address: F9:XX:XX:XX:XX:XX (Static)
> HCI Event: Disconnect Complete (0x05) plen 4                                                                                                              #1692 [hci0] 1980.143150
        Status: Success (0x00)
        Handle: 64
        Reason: Connection Failed to be Established (0x3e)
@ MGMT Event: Device Disconnected (0x000c) plen 8                                                                                                        0x0001 [hci0] 1980.143206
        LE Address: F9:XX:XX:XX:XX:XX (Static)
        Reason: Unspecified (0x00)
@ MGMT Event: Device Disconnected (0x000c) plen 8                                                                                                        0x0002 [hci0] 1980.143206
        LE Address: F9:XX:XX:XX:XX:XX (Static)
        Reason: Unspecified (0x00)

【问题讨论】:

检查我的答案here。 可以分享设备的电子表格吗?该网站的设计非常糟糕。 非常感谢@Mr.Panda,看起来设置 ControllerMode = dual 就可以了。你想把这个写成答案让我接受吗? 我猜这是因为***.com/a/63813446/556495,但不确定。 【参考方案1】:

似乎出于某种原因您的蓝牙模式设置为bredr,并且因为您的设备是不支持蓝牙经典BLE设备 -> @ 987654322@,您无法连接。因此,将其设置为 dual 就可以了。您可以通过编辑etc/bluetooth/main.conf 将其设置为dual 模式。如果您也将其设置为 le,我会期待相同的行为。

# Restricts all controllers to the specified transport. Default value
# is "dual", i.e. both BR/EDR and LE enabled (when supported by the HW).
# Possible values: "dual", "bredr", "le"
ControllerMode = dual

【讨论】:

以上是关于在 LE 读取远程使用的功能时,树莓派的蓝牙连接失败的主要内容,如果未能解决你的问题,请参考以下文章

使用PyCharm连接树莓派远程编程

远程桌面连接树莓派

树莓派学习系列3——树莓派的远程登录操作(图文)

树莓派-----局域网电脑远程桌面连接

怎么用VNC远程控制树莓派

树莓派连接wifi和蓝牙