Bluetoothctl 反复连接和断开连接

Bluetoothctl 反复连接和断开连接

我使用的是 Raspberry Pi Zero,物联网并且能够使用 USB 电缆通过 ssh 进入 Pi本教程。然后我用 pHat 设置了我的家庭 WiFi。然后我用单独的电源为 Pi 供电。然后我就可以通过我的家庭网络无线 ssh 进入 Pi。

最后回答我的问题。我想将 Pi 连接到无线键盘。我正在尝试使用该bluetoothctl工具进行连接。运行时scan on,Pi 可以识别键盘,但配对时无法配对。这是终端会话:

[CHG] Device 0C:4D:12:11:01:E4 Name: Bluetooth Keyboard
[CHG] Device 0C:4D:12:11:01:E4 Alias: Bluetooth Keyboard
[bluetooth]# pair 0C:4D:12:11:01:E4
Attempting to pair with 0C:4D:12:11:01:E4
[CHG] Device 0C:4D:12:11:01:E4 Connected: yes
[CHG] Device 0C:4D:12:11:01:E4 Connected: no
[CHG] Device 0C:4D:12:11:01:E4 Connected: yes
[CHG] Device 0C:4D:12:11:01:E4 Connected: no
[CHG] Device 0C:4D:12:11:01:E4 Connected: yes
[CHG] Device 0C:4D:12:11:01:E4 Connected: no
[CHG] Device 0C:4D:12:11:01:E4 Connected: yes
Failed to pair: org.bluez.Error.AuthenticationFailed
[CHG] Device 0C:4D:12:11:01:E4 Connected: no

正如您所见,它似乎反复连接和断开连接。

答案1

尝试这些步骤;

  • 将键盘置于配对模式(k380,您将按住您想要分配设备的 bt 键)
  • 在 pi 控制台上,运行bluetoothctl
  • 类型power on
  • 类型agent on
  • 类型pair 0C:4D:12:11:01:E4
  • 根据提示在键盘上输入配对代码
  • 类型connect 0C:4D:12:11:01:E4
  • 类型trust 0C:4D:12:11:01:E4
  • 类型agent off
  • 类型quit

希望您连接了一个蓝牙键盘。您可能需要做一些额外的工作来确保蓝牙将在设备重启时开机并配对。

您需要启用代理,以便键盘可以执行配对代码。某些键盘可能会有所不同。

希望这可以帮助。

答案2

我在 arch 上运行这个,但遇到了类似的错误。对我来说,问题是在连接之前不信任设备:

[bluetooth]# scan on
Discovery started
[CHG] Controller 00:25:56:CD:5B:63 Discovering: yes
[NEW] Device 34:88:5D:D5:3E:C0 Keyboard K380
[bluetooth]# pair 34:88:5D:D5:3E:C0
Attempting to pair with 34:88:5D:D5:3E:C0
[CHG] Device 34:88:5D:D5:3E:C0 Connected: yes
[agent] Passkey: 740377
[agent] Passkey: 740377
[agent] Passkey: 740377
[agent] Passkey: 740377
[agent] Passkey: 740377
[agent] Passkey: 740377
[agent] Passkey: 740377
[Keyboard K380]# connect 34:88:5D:D5:3E:C0
Attempting to connect to 34:88:5D:D5:3E:C0
Failed to pair: org.bluez.Error.AuthenticationFailed
[CHG] Device 34:88:5D:D5:3E:C0 ServicesResolved: yes
Failed to connect: org.bluez.Error.Failed
[CHG] Device 34:88:5D:D5:3E:C0 ServicesResolved: no
[CHG] Device 34:88:5D:D5:3E:C0 Connected: no
[bluetooth]# trust 34:88:5D:D5:3E:C0
[CHG] Device 34:88:5D:D5:3E:C0 Trusted: yes
Changing 34:88:5D:D5:3E:C0 trust succeeded
[bluetooth]# connect 34:88:5D:D5:3E:C0
Attempting to connect to 34:88:5D:D5:3E:C0
[CHG] Device 34:88:5D:D5:3E:C0 Connected: yes
[CHG] Device 34:88:5D:D5:3E:C0 Modalias: usb:v046DpB342d4201
[CHG] Device 34:88:5D:D5:3E:C0 UUIDs: 00001000-0000-1000-8000-00805f9b34fb
[CHG] Device 34:88:5D:D5:3E:C0 UUIDs: 00001124-0000-1000-8000-00805f9b34fb
[CHG] Device 34:88:5D:D5:3E:C0 UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Device 34:88:5D:D5:3E:C0 ServicesResolved: yes
[CHG] Device 34:88:5D:D5:3E:C0 Paired: yes
Connection successful
[Keyboard K380]#

相关内容