gatt server and reset of hci device
Hi,
I am working with bluez 5.39. I have a custom gatt server which used c api from btgatt-server from bluez source. Eveything is working great exept when I reset hci device. I need to disable bluetooth for few hours for specific use case.
If I run hci down/up and try again to connect to gatt server, the client is able to connect but services are not available. Moreover my server does not see the client connexion.
Do I need to make a specific stuff to be able to make it work this use case ?
Output from btgatt-client :
[arthur ] ./btgatt-client -d 00:AE:FA:BC:77:69
Connecting to device... Done
[GATT client]# services
GATT client not initialized
Output from server :
[arthur ] ./mygatt_server
Started listening on ATT channel. Waiting for connections
Thanks,
Arthur.
Luiz Augusto von Dentz
maintainerHi Arthur,
Quoted 11 lines · Arthur LAMBERT
Hi,
I am working with bluez 5.39. I have a custom gatt server which used c api from btgatt-server from bluez source. Eveything is working great exept when I reset hci device. I need to disable bluetooth for few hours for specific use case.
If I run hci down/up and try again to connect to gatt server, the client is able to connect but services are not available. Moreover my server does not see the client connexion.
Do I need to make a specific stuff to be able to make it work this use case ?
Is that something preventing you to use bluetoothd and just create a plugin or use the GATT API for your server? Manually using hciconfig is not recommended since it may interfere with other users, for manual testing it is actually recommended to use btmgmt or bluetoothd + bluetoothctl. Also note that having btgatt-server along side with bluetoothd will not work because both listen on the same channel and the kernel can only redirect the packets to one process.
Quoted 5 lines · Luiz Augusto von Dentz
Is that something preventing you to use bluetoothd and just create a plugin or use the GATT API for your server? Manually using hciconfig is not recommended since it may interfere with other users, for manual testing it is actually recommended to use btmgmt or bluetoothd + bluetoothctl.
I need to have the ble server in my stand alone binary. That's why I am not using bluetoothd plugin. About GATT API, you are probably talking about dbus api to create custom service instead of using private c API. I am not very familiar with dbus, I was not able to find a working example of dbus example with bluez5. I have some delay issue to release my code, that's why I am using c api to gain some precious time.
Quoted 4 lines
Also note that having btgatt-server along side with bluetoothctl. Also note that having btgatt-server along side with bluetoothd will not work because both listen on the same channel and the kernel can only redirect the packets to one process.
I know that bluetoothd cannot run with my custom gatt server. Problem is that I am not able to set hci friendly name with hciconfig without bluetoothd. So I have a very dirty way to do it : run bluetoothd few seconds, kill it and then run my code. Thanks to that I am able to update the hci friendly name (I guess that some init which are missing in my code are running in bluetoothd)
So your advise is to use btmgmt instead of hciconfig to play with hci device ?
Thanks,
Arthur.
Quoted 7 lines
Is that something preventing you to use bluetoothd and just create a plugin or use the GATT API for your server? Manually using hciconfig is not recommended since it may interfere with other users, for manual testing it is actually recommended to use btmgmt or bluetoothd + bluetoothctl. Also note that having btgatt-server along side with bluetoothd will not work because both listen on the same channel and the kernel can only redirect the packets to one process.
If I want to properly implement custom gatt service with dbus instead of low c api. Can we use the python script test/example-gatt-server as reference ? Is there any example in c using glibdbus ?
Is it normal that I am not able to run it with success ?
* Run bluetoothd with experimental mode enable :
sudo ./bluetoothd -E
* Run python script from test directory :
[arthur ] python3 ./example-gatt-server
Failed to register application: org.bluez.Error.Failed: No object received
Thanks,
Arthur.
Hi,
What version of bluez are you using?
Quoted 1 line
Is there any example in c using glibdbus ?
Yes you can also look at tools/gatt-service.c for a C example of using the GATT dbus API.
Quoted 2 lines
* Run bluetoothd with experimental mode enable :
sudo ./bluetoothd -E
Can you run 'bluetoothd -nE -d src/gatt-database.c'. Do you see something like 'GATT Manager registered for adapter: /org/bluez/hci0'?
/Tobias