我正在尝试在具有NAP配置文件的Ubuntu计算机上使用BlueZ 5.37模拟免提汽车系统的连接过程。
Ubuntu计算机正在运行NAP配置文件,我可以成功连接客户端设备并使用蓝牙网络共享功能。
问题是,每次启动Ubuntu计算机时,我都需要手动重新连接设备。我的目标是让Ubuntu计算机在启动时自动连接到我的手机。该设备的配对/信任过程已经完成。因此,就像免提汽车系统一样,我只需要在第一次配对时进入蓝牙设置即可。设备启动时,我在附近的其他任何时间都应该自动连接。
我只运行NAP配置文件,这是我的bluetoothctl show命令输出:
[bluetooth]# show Controller 5C:F3:70:88:D5:E1
Name: BlueZ 5.37
Alias: Test Bluetooth
Class: 0x020000
Powered: yes
Discoverable: no
Pairable: yes
UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
UUID: NAP (00001116-0000-1000-8000-00805f9b34fb)
UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb)
UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb)
Modalias: usb:v1D6Bp0246d0525
Discovering: no
当前,当我尝试将连接请求从Ubuntu端发送到已经配对/信任的任何客户端设备时,我得到以下输出:
[bluetooth]# connect 00:1A:7D:DA:71:0A
Attempting to connect to 00:1A:7D:DA:71:0A
[CHG] Device 00:1A:7D:DA:71:0A Connected: yes
Failed to connect: org.bluez.Error.NotAvailable
[CHG] Device 00:1A:7D:DA:71:0A Connected: no
当我从Ubuntu端启动连接时,蓝牙服务输出如下:
Sep 28 03:50:20 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/adapter.c:resume_discovery()
Sep 28 03:50:34 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/device.c:connect_profiles() /org/bluez/hci0/dev_00_1A_7D_DA_71_0A (all), client :1.28
Sep 28 03:50:34 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/device.c:connect_profiles() Resolving services for /org/bluez/hci0/dev_00_1A_7D_DA_71_0A
Sep 28 03:50:35 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/adapter.c:connected_callback() hci0 device 00:1A:7D:DA:71:0A connected eir_len 14
Sep 28 03:50:35 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/device.c:search_cb() 00:1A:7D:DA:71:0A: No service update
Sep 28 03:50:35 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/device.c:device_svc_resolved() /org/bluez/hci0/dev_00_1A_7D_DA_71_0A err 0
Sep 28 03:50:35 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/device.c:connect_profiles() /org/bluez/hci0/dev_00_1A_7D_DA_71_0A (all), client :1.28
Sep 28 03:50:39 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/adapter.c:dev_disconnected() Device 00:1A:7D:DA:71:0A disconnected, reason 2
Sep 28 03:50:39 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/adapter.c:adapter_remove_connection()
Sep 28 03:50:39 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/adapter.c:bonding_attempt_complete() hci0 bdaddr 00:1A:7D:DA:71:0A type 0 status 0xe
Sep 28 03:50:39 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/device.c:device_bonding_complete() bonding (nil) status 0x0e
Sep 28 03:50:39 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/device.c:device_bonding_failed() status 14
由客户端设备启动的(成功)连接的日志:
Sep 28 03:50:39 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/adapter.c:resume_discovery()
Sep 28 04:23:11 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/src/adapter.c:connected_callback() hci0 device A8:96:75:32:09:E9 connected eir_len 5
Sep 28 04:23:11 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/profiles/network/server.c:confirm_event() BNEP: incoming connect from A8:96:75:32:09:E9
Sep 28 04:23:11 Aruba8320Bluetooth bluetoothd[6240]: ../bluez-5.37/profiles/network/bnep.c:bnep_getsuppfeat() supported features: 0x1
Sep 28 04:23:11 Aruba8320Bluetooth bluetoothd[6240]: bnep: bridge bt-pan: interface bnep0 added
是否可以使用NAP配置文件实现与配对的蓝牙设备的无缝重新连接,还是每次都需要从客户端设备进行手动连接?
如果是这样,我要去哪里了?