用蓝牙连接两个树莓派时出错

时间:2021-06-21 09:30:57

标签: bluetooth bluetooth-lowenergy raspberry-pi4

我正在开展一个项目,其中一个树莓派将成为 BLE GATT 服务器,另一个将成为客户端。第一步是通过命令行测试正常的蓝牙连接,但它不起作用,我不知道为什么。 两者都是树莓派 4 B 型;第一个是带有 Linux raspberrypi 5.10.17-v7l+ 的 raspbian buster,而第二个是带有 Linux ubuntu 5.4.0-1036-raspi 的 Ubuntu 20.04 服务器。

使用 bluetoothctl,在第一个(从属)上我设置了 agent on discoverable onpairable on,而在第二个我使用 scan on。第二个树莓找到另一个 MAC 地址,所以我继续 pair DC:A6:32:2C:D4:90。配对似乎成功了,但它甚至不要求输入密码:

从 RPI 输出:

Changing discoverable on succeeded
[CHG] Controller DC:A6:32:2C:D4:90 Discoverable: yes
[NEW] Device DC:A6:32:FD:47:E0 ubuntu
[CHG] Device DC:A6:32:FD:47:E0 Modalias: usb:v1D6Bp0246d0535
[CHG] Device DC:A6:32:FD:47:E0 UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Device DC:A6:32:FD:47:E0 UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Device DC:A6:32:FD:47:E0 UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Device DC:A6:32:FD:47:E0 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device DC:A6:32:FD:47:E0 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device DC:A6:32:FD:47:E0 ServicesResolved: yes
[CHG] Device DC:A6:32:FD:47:E0 Paired: yes
[CHG] Device DC:A6:32:FD:47:E0 ServicesResolved: no
[CHG] Device DC:A6:32:FD:47:E0 Connected: no

主 RPI 输出:

Attempting to pair with DC:A6:32:2C:D4:90
[CHG] Device DC:A6:32:2C:D4:90 Connected: yes
[CHG] Device DC:A6:32:2C:D4:90 UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Device DC:A6:32:2C:D4:90 UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Device DC:A6:32:2C:D4:90 UUIDs: 0000112d-0000-1000-8000-00805f9b34fb
[CHG] Device DC:A6:32:2C:D4:90 UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Device DC:A6:32:2C:D4:90 ServicesResolved: yes
[CHG] Device DC:A6:32:2C:D4:90 Paired: yes
Pairing successful
[CHG] Device DC:A6:32:2C:D4:90 ServicesResolved: no
[CHG] Device DC:A6:32:2C:D4:90 Connected: no

ubuntu 是另一个 RPI 的名称,它的 MAC 是 DC:A6:32:FD:47:E0,如您在输出中所见。在配对过程中,连接建立几秒钟,然后断开连接。当我尝试从主服务器连接 connect DC:A6:32:2C:D4:90 时,情况基本相同:

[CHG] Device DC:A6:32:2C:D4:90 Connected: yes
[CHG] Device DC:A6:32:2C:D4:90 ServicesResolved: yes
Failed to connect: org.bluez.Error.NotAvailable
[CHG] Device DC:A6:32:2C:D4:90 ServicesResolved: no
[CHG] Device DC:A6:32:2C:D4:90 Connected: no

将 bluetoothctl 与 sudo 结合使用并信任设备似乎无济于事。

编辑:通过在两台设备上使用 default-agent,我被要求确认 pin 但连接仍然失败

0 个答案:

没有答案