All of lore.kernel.org
 help / color / mirror / Atom feed
* gatt server and reset of hci device
@ 2016-05-11 12:51 Arthur LAMBERT
  2016-05-12  8:39 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 10+ messages in thread
From: Arthur LAMBERT @ 2016-05-11 12:51 UTC (permalink / raw)
  To: linux-bluetooth

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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gatt server and reset of hci device
  2016-05-11 12:51 gatt server and reset of hci device Arthur LAMBERT
@ 2016-05-12  8:39 ` Luiz Augusto von Dentz
  2016-05-12  9:56   ` Arthur LAMBERT
  2016-06-27 15:54   ` Arthur LAMBERT
  0 siblings, 2 replies; 10+ messages in thread
From: Luiz Augusto von Dentz @ 2016-05-12  8:39 UTC (permalink / raw)
  To: Arthur LAMBERT; +Cc: linux-bluetooth

Hi Arthur,

On Wed, May 11, 2016 at 3:51 PM, Arthur LAMBERT
<lambertarthur22@gmail.com> 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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gatt server and reset of hci device
  2016-05-12  8:39 ` Luiz Augusto von Dentz
@ 2016-05-12  9:56   ` Arthur LAMBERT
  2016-06-27 15:54   ` Arthur LAMBERT
  1 sibling, 0 replies; 10+ messages in thread
From: Arthur LAMBERT @ 2016-05-12  9:56 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gatt server and reset of hci device
  2016-05-12  8:39 ` Luiz Augusto von Dentz
  2016-05-12  9:56   ` Arthur LAMBERT
@ 2016-06-27 15:54   ` Arthur LAMBERT
  2016-06-29  7:20     ` Tobias Svehagen
  1 sibling, 1 reply; 10+ messages in thread
From: Arthur LAMBERT @ 2016-06-27 15:54 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

> 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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gatt server and reset of hci device
  2016-06-27 15:54   ` Arthur LAMBERT
@ 2016-06-29  7:20     ` Tobias Svehagen
  0 siblings, 0 replies; 10+ messages in thread
From: Tobias Svehagen @ 2016-06-29  7:20 UTC (permalink / raw)
  To: linux-bluetooth

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gatt server and reset of hci device
@ 2016-07-07 14:55 Arthur LAMBERT
  0 siblings, 0 replies; 10+ messages in thread
From: Arthur LAMBERT @ 2016-07-07 14:55 UTC (permalink / raw)
  To: Tobias Svehagen; +Cc: linux-bluetooth

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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gatt server and reset of hci device
  2016-06-29 13:31 Arthur LAMBERT
@ 2016-06-29 13:39 ` Tobias Svehagen
  0 siblings, 0 replies; 10+ messages in thread
From: Tobias Svehagen @ 2016-06-29 13:39 UTC (permalink / raw)
  To: linux-bluetooth

> [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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gatt server and reset of hci device
@ 2016-06-29 13:31 Arthur LAMBERT
  2016-06-29 13:39 ` Tobias Svehagen
  0 siblings, 1 reply; 10+ messages in thread
From: Arthur LAMBERT @ 2016-06-29 13:31 UTC (permalink / raw)
  To: Tobias Svehagen; +Cc: linux-bluetooth

> 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gatt server and reset of hci device
  2016-06-29 12:33 Arthur LAMBERT
@ 2016-06-29 13:22 ` Tobias Svehagen
  0 siblings, 0 replies; 10+ messages in thread
From: Tobias Svehagen @ 2016-06-29 13:22 UTC (permalink / raw)
  To: linux-bluetooth

> [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?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: gatt server and reset of hci device
@ 2016-06-29 12:33 Arthur LAMBERT
  2016-06-29 13:22 ` Tobias Svehagen
  0 siblings, 1 reply; 10+ messages in thread
From: Arthur LAMBERT @ 2016-06-29 12:33 UTC (permalink / raw)
  To: Tobias Svehagen; +Cc: linux-bluetooth

> 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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-07-07 14:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-11 12:51 gatt server and reset of hci device Arthur LAMBERT
2016-05-12  8:39 ` Luiz Augusto von Dentz
2016-05-12  9:56   ` Arthur LAMBERT
2016-06-27 15:54   ` Arthur LAMBERT
2016-06-29  7:20     ` Tobias Svehagen
2016-06-29 12:33 Arthur LAMBERT
2016-06-29 13:22 ` Tobias Svehagen
2016-06-29 13:31 Arthur LAMBERT
2016-06-29 13:39 ` Tobias Svehagen
2016-07-07 14:55 Arthur LAMBERT

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.