我遇到一个问题,蓝牙连接1-2秒后就断开了,主控端会显示以下错误:
org.bluez.error.inprogress
追踪日志我看到它会输入以下功能:
un 11 16:23:46 rap bluetoothd[21474]: src/device.c:search_cb() 00:0E:8E:8B:CA:9D: No service update
Jun 11 16:23:46 rap bluetoothd[21474]: src/device.c:device_svc_resolved() /org/bluez/hci0/dev_00_0E_8E_8B_CA_9D err 0
Jun 11 16:23:46 rap bluetoothd[21474]: src/device.c:connect_profiles() /org/bluez/hci0/dev_00_0E_8E_8B_CA_9D (all), client :1.394
...
Jun 11 16:23:49 rap kernel: [12110.003903] bluetooth:l2cap_sock_release:1197: sock 0000000078f38a7c, sk 00000000f306c001
Jun 11 16:23:49 rap kernel: [12110.003907] bluetooth:l2cap_sock_shutdown:1113: sock 0000000078f38a7c, sk 00000000f306c001
Jun 11 16:23:49 rap kernel: [12110.003910] bluetooth:l2cap_sock_shutdown:1123: Handling sock shutdown
Jun 11 16:23:49 rap kernel: [12110.003913] bluetooth:l2cap_chan_hold:489: chan 0000000093211dd1 orig refcnt 3
Jun 11 16:23:49 rap kernel: [12110.003916] bluetooth:l2cap_sock_shutdown:1132: chan 0000000093211dd1 state BT_CONNECTED
Jun 11 16:23:49 rap kernel: [12110.003921] bluetooth:l2cap_chan_close:732: chan 0000000093211dd1 state BT_CONNECTED
Jun 11 16:23:49 rap kernel: [12110.003924] bluetooth:l2cap_chan_hold:489: chan 0000000093211dd1 orig refcnt 4
Jun 11 16:23:49 rap kernel: [12110.003930] bluetooth:l2cap_build_cmd:2931: conn 000000003e9a2ca4, code 0x06, ident 0x05, len 4
Jun 11 16:23:49 rap kernel: [12110.003936] bluetooth:l2cap_send_cmd:865: code 0x06
并追踪到 blueZ 中的代码:
static DBusMessage *connect_profiles(struct btd_device *dev, uint8_t bdaddr_type,
DBusMessage *msg, const char *uuid)
{
struct bearer_state *state = get_state(dev, bdaddr_type);
int err;
DBG("%s %s, client %s", dev->path, uuid ? uuid : "(all)",
dbus_message_get_sender(msg));
if (dev->pending || dev->connect || dev->browse)
return btd_error_in_progress(msg); <------------------ HERE
...
}
我的问题是,我能否以某种方式知道哪个条件(待处理/连接/浏览)导致此错误,而无需添加编辑代码,因为我没有权限这样做?如果出现任何这种情况,blueZ 为何会尝试连接到配置文件?
尝试重新启动蓝牙服务。出现了同样的错误,并通过重新启动蓝牙服务设法解决了该问题。
sudo service restart bluetooth
尝试运行上面的命令,看看是否有帮助。