我有 BT4.0 USB 棒并且运行 BlueZ。无论我使用哪种类型的代理,Bluetoothctl 都会执行此操作:
[bluetooth]# agent
DisplayOnly KeyboardDisplay NoInputNoOutput on
DisplayYesNo KeyboardOnly off
[bluetooth]# agent DisplayYesNo
Agent registered
[bluetooth]# pair C4:F1:D4:D0:44:06
Attempting to pair with C4:F1:D4:D0:44:06
[CHG] Device C4:F1:D4:D0:44:06 UUIDs:
00001800-0000-1000-8000-00805f9b34fb
00001801-0000-1000-8000-00805f9b34fb
0000180a-0000-1000-8000-00805f9b34fb
e95d93af-251d-470a-a062-fa1922dfa9a8
e95d93b0-251d-470a-a062-fa1922dfa9a8
[CHG] Device C4:F1:D4:D0:44:06 Paired: yes
Pairing successful
[CHG] Device C4:F1:D4:D0:44:06 Appearance: 0x0200
但是,一旦 micro:bit 退出配对模式并恢复正常运行,我就会断开连接。在 microbit 上,我从未看到 PIN 码或配对成功。然后我无法连接 gatttool。
gatttool --adapter=hci0 -b C4:F1:D4:D0:44:06 --interactive
[C4:F1:D4:D0:44:06][LE]> connect
Attempting to connect to C4:F1:D4:D0:44:06
Error: connect error: Connection refused (111)