简体   繁体   English

bluez 5.30:启动 bluetoothd 时出现“没有足够的空闲句柄来注册服务”错误

[英]bluez 5.30: “Not enough free handles to register service” error in starting bluetoothd

What I have done correctly: in linux environment我做对了什么:在linux环境中

  1. hciattach /dev/ttyUSB0 any 115200
  2. hciconfig hci0 up
  3. addgroup -S messagebus
  4. adduser -S messagebus -G messagebus
  5. dbus-daemon --system
  6. syslogd

    In executing /libexec/bluetooth/bluetoothd --plugin=time -d -E -n , The error Not enough free handles to register service happens as below:在执行/libexec/bluetooth/bluetoothd --plugin=time -d -E -n ,错误Not enough free handles to register service发生如下:

     bluetoothd[756]: src/adapter.c:clear_uuids() sending clear uuids command for index 0 <br/> bluetoothd[756]: src/adapter.c:set_mode() sending set mode command for index 0 <br/> bluetoothd[756]: src/gatt-database.c:btd_gatt_database_new() GATT Manager registered for adapter: /org/bluez/hci0 <br/> bluetoothd[756]: src/adapter.c:adapter_service_add() /org/bluez/hci0 <br/> bluetoothd[756]: src/sdpd-service.c:add_record_to_server() Adding record with handle 0x10002 <br/> bluetoothd[756]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000007-0000-1000-8000-00805f9 <br/> bluetoothd[756]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000100-0000-1000-8000-00805f9 <br/> bluetoothd[756]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001002-0000-1000-8000-00805f9 <br/> bluetoothd[756]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001800-0000-1000-8000-00805f9 <br/> bluetoothd[756]: src/adapter.c:adapter_service_insert() /org/bluez/hci0 <br/> bluetoothd[756]: src/adapter.c:add_uuid() sending add uuid command for index 0 <br/> bluetoothd[756]: src/gatt-database.c:gatt_db_service_added() GATT Service added to local database <br/> bluetoothd[756]: Failed to obtain handles for "Service Changed" characteristic <br/> bluetoothd[756]: src/adapter.c:adapter_service_add() /org/bluez/hci0 <br/> bluetoothd[756]: src/sdpd-service.c:add_record_to_server() Adding record with handle 0x10003 <br/> bluetoothd[756]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000007-0000-1000-8000-00805f9 <br/> bluetoothd[756]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00000100-0000-1000-8000-00805f9 <br/> bluetoothd[756]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001002-0000-1000-8000-00805f9 <br/> bluetoothd[756]: src/sdpd-service.c:add_record_to_server() Record pattern UUID 00001801-0000-1000-8000-00805f9 <br/> bluetoothd[756]: src/adapter.c:adapter_service_insert() /org/bluez/hci0 <br/> bluetoothd[756]: src/adapter.c:add_uuid() sending add uuid command for index 0 <br/> bluetoothd[756]: src/gatt-database.c:gatt_db_service_added() GATT Service added to local database <br/> bluetoothd[756]: src/advertising.c:btd_advertising_manager_new() LE Advertising Manager created for adapter: /org/bluez/hci0 <br/> bluetoothd[756]: profiles/time/server.c:time_server_init() path /org/bluez/hci0 <br/> bluetoothd[756]: src/attrib-server.c:attrib_db_find_avail() enter! <br/> bluetoothd[756]: src/attrib-server.c:attrib_db_find_avail() BT_UUID16! <br/> ***bluetoothd[756]: Not enough free handles to register service*** <br/> bluetoothd[756]: Current Time Service could not be registered <br/> bluetoothd[756]: gatt-time-server: Input/output error (5) <br/>

I dived into the code for debugging the issue a little bit.我深入研究了调试问题的代码。 The attrib_db_find_avail(adapter, svc_uuid, size)[in function: gatt_service_add()] always return 0. attrib_db_find_avail(adapter, svc_uuid, size)[in function: gatt_service_add()]总是返回 0。

The root cause is the servers glist parameter is always NULL, which is in g_slist_find_custom(servers, adapter, adapter_cmp)[called from find_uuid16_avail()/find_uuid128_avail()] .根本原因是服务器glist参数始终为 NULL,它在g_slist_find_custom(servers, adapter, adapter_cmp)[called from find_uuid16_avail()/find_uuid128_avail()]

I noticed there is the call: **btd_adapter_gatt_server_start**(struct btd_adapter *adapter) to be used to add a server into the servers glist .我注意到有一个调用: **btd_adapter_gatt_server_start**(struct btd_adapter *adapter)用于将服务器添加到服务器glist But the weird thing is no where it gets called through the whole bluez source code tree.但奇怪的是没有在整个 bluez 源代码树中调用它。

So shall I call btd_adapter_gatt_server_start() somewhere in my code?那么我btd_adapter_gatt_server_start()在代码中的某处调用btd_adapter_gatt_server_start()吗? Or any other steps I should do to resolve the issue?或者我应该采取任何其他步骤来解决问题?

I was having trouble with bluetooth as well.我也遇到蓝牙问题。 In my case I was receiving the following error messages several times a minute, as my device went up and down intermitently:在我的情况下,我每分钟收到几次以下错误消息,因为我的设备断断续续地上下移动:

bluetoothd[3196]: Failed to obtain handles for "Service Changed" characteristic
bluetoothd[3196]: Endpoint registered: sender=:1.51 path=/MediaEndpoint/A2DPSource
bluetoothd[3196]: Endpoint registered: sender=:1.51 path=/MediaEndpoint/A2DPSink
bluetoothd[3196]: Failed to set mode: Failed (0x03)

After some research, I found out this thread , where some people fixed their bluetooth problems by deleting ~/.config/pulse.经过一番研究,我发现了这个线程,其中有些人通过删除 ~/.config/pulse 来修复他们的蓝牙问题。 It also solved the problem for me.它也为我解决了这个问题。

I don't have a explanation for why this works, but I'm leaving this tip because it may solve other people's issues as well.我没有解释为什么会这样,但我留下这个技巧是因为它也可以解决其他人的问题。

Also you can try to check rfkill service.您也可以尝试检查 rfkill 服务。 It could block connections sometime for lan, wifi and bluetooth You can check of what is blocked by this command: rfkill list它可能会在某个时候阻止 lan、wifi 和蓝牙的连接您可以检查此命令阻止的内容:rfkill list

My bluetooth was blocked.我的蓝牙被屏蔽了。 I used this command:我使用了这个命令:

rfkill unblock bluetooth rfkill 解锁蓝牙

rfkill is a subsystem that manages the power to the various radio transmitters that your device might have (such as wifi and bluetooth). rfkill 是一个子系统,用于管理设备可能具有的各种无线电发射器(例如 wifi 和蓝牙)的电源。 It has the ability to manage these devices with software switches (so that they can be temporarily disabled such as to save power) or hardware switches (which might need a reboot to re-enable).它能够使用软件开关(以便可以暂时禁用它们以节省电力)或硬件开关(可能需要重新启动才能重新启用)来管理这些设备。 rfkill has a command line interface which enables you to control this subsystem. rfkill 有一个命令行界面,可以让你控制这个子系统。 More info can be found from Red Hat https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/power_management_guide/rfkill可以从 Red Hat https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/power_management_guide/rfkill找到更多信息

It is highly likely that your bluetooth is blocked by rfkill which can be called by power management.您的蓝牙很可能被电源管理调用的 rfkill 阻止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM