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.
Le Thursday 12 May 2016 ? 11:39:44 (+0300), Luiz Augusto von Dentz a ?crit :
> 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.
> 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.
Hi Arthur,
On Wed, May 11, 2016 at 3:51 PM, Arthur LAMBERT
<[email protected]> wrote:
> 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.
> [arthur * dev] uname -a
> Linux arthur-bzh 3.13.0-88-generic #135-Ubuntu SMP Wed Jun 8 21:10:42 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
That kernel doesn't support the MGMT_OP_READ_ADV_FEATURES. You should
try updating your kernel. Ubuntu 14.04.4 uses kernel 4.2.
> Okay, the 'Unknown Command' lines don't look so good, what kernel are
> you running?
[arthur * dev] uname -a
Linux arthur-bzh 3.13.0-88-generic #135-Ubuntu SMP Wed Jun 8 21:10:42 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
> [arthur ] sudo ./bluetoothd -nE -d src/gatt-database.
> bluetoothd[11131]: Bluetooth daemon 5.39
> bluetoothd[11131]: Starting SDP server
> bluetoothd[11131]: Bluetooth management interface 1.4 initialized
> bluetoothd[11131]: Failed to obtain handles for "Service Changed" characteristic
> bluetoothd[11131]: Failed to read advertising features: Unknown Command (0x01)
> bluetoothd[11131]: hci0 Load Connection Parameters failed: Unknown Command (0x01)
>
> This test is running on ubuntu 14.04. We stop bluetooth service before starting bluetoothd.
> We also run the test on arm target but without trouble this time.
Okay, the 'Unknown Command' lines don't look so good, what kernel are
you running?
> What version of bluez are you using?
5.37 & 5.39 & 5.40. Same result for all these versions.
> Yes you can also look at tools/gatt-service.c for a C example of using
> the GATT dbus API.
Ok thanks. I will check that.
> Can you run 'bluetoothd -nE -d src/gatt-database.c'. Do you see
> something like 'GATT Manager registered for adapter: /org/bluez/hci0'?
[arthur ] sudo ./bluetoothd -nE -d src/gatt-database.
[sudo] password for arthur:
bluetoothd[9754]: Bluetooth daemon 5.39
bluetoothd[9754]: Unknown key PageTimeout in main.conf
bluetoothd[9754]: Unknown key InitiallyPowered in main.conf
bluetoothd[9754]: Unknown key RememberPowered in main.conf
bluetoothd[9754]: Unknown key EnableGatt in main.conf
bluetoothd[9754]: Starting SDP server
bluetoothd[9754]: Bluetooth management interface 1.4 initialized
bluetoothd[9754]: Failed to obtain handles for "Service Changed" characteristic
bluetoothd[9754]: Failed to read advertising features: Unknown Command (0x01)
bluetoothd[9754]: hci0 Load Connection Parameters failed: Unknown Command (0x01)
I replace the main.conf from source in /etc and retry the test :
[arthur ] sudo ./bluetoothd -nE -d src/gatt-database.
bluetoothd[11131]: Bluetooth daemon 5.39
bluetoothd[11131]: Starting SDP server
bluetoothd[11131]: Bluetooth management interface 1.4 initialized
bluetoothd[11131]: Failed to obtain handles for "Service Changed" characteristic
bluetoothd[11131]: Failed to read advertising features: Unknown Command (0x01)
bluetoothd[11131]: hci0 Load Connection Parameters failed: Unknown Command (0x01)
This test is running on ubuntu 14.04. We stop bluetooth service before starting bluetoothd.
We also run the test on arm target but without trouble this time.
Arthur.
Hi,
What version of bluez are you using?
> 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.
> * 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
> 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.
Sorry for the delay of my answer.
> You should update your kernel. Ubuntu 14.04.4 uses kernel 4.2.
Ok I tried to update my kernel with linux-image-4.2.0-41-generic + headers with
apt-get. After rebooting my device all my peripherals are not working (wifi/bt/usb).
Due to that I will work directly on my ARM target. I will try to fix the problem
on x86 later.
Thanks for your help.
Arthur.