bluez 5.30: "Not enough free handles to register service" error in starting bluetoothd
Solution 1
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. 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.
Solution 2
Also you can try to check rfkill service. It could block connections sometime for lan, wifi and bluetooth You can check of what is blocked by this command: rfkill list
My bluetooth was blocked. I used this command:
rfkill unblock bluetooth
Solution 3
rfkill is a subsystem that manages the power to the various radio transmitters that your device might have (such as wifi and bluetooth). 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. 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
It is highly likely that your bluetooth is blocked by rfkill which can be called by power management.
Admin
Updated on July 26, 2022Comments
-
Admin almost 2 years
What I have done correctly: in linux environment
hciattach /dev/ttyUSB0 any 115200
hciconfig hci0 up
addgroup -S messagebus
adduser -S messagebus -G messagebus
dbus-daemon --system
syslogd
In executing
/libexec/bluetooth/bluetoothd --plugin=time -d -E -n
, The errorNot enough free handles to register service
happens as below: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.The root cause is the servers
glist
parameter is always NULL, which is ing_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 serversglist
. But the weird thing is no where it gets called through the whole bluez source code tree.So shall I call
btd_adapter_gatt_server_start()
somewhere in my code? Or any other steps I should do to resolve the issue?