linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yunhan Wang <yunhanw@nestlabs.com>
To: Martin Turon <mturon@google.com>,
	Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
	Marcel Holtmann <marcel@holtmann.org>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: BLE advertisement re-enabling after ble connection goes away
Date: Thu, 13 Dec 2018 15:13:26 -0800	[thread overview]
Message-ID: <CALvjcs9jRvfb6uFN5BZx26Nh3ojwL5S_Bt08Q72aHPjZUZTtUA@mail.gmail.com> (raw)
In-Reply-To: <CALvjcs8wE7ntp6F23ALKU_3=CziqHgQ1OGgqdqO299sMoeKamQ@mail.gmail.com>

Hi, Luiz

Rephrasing a little bit..

From what you describes, it seems Bluez is taking the responsibility
to reenable the advertisement in peripheral side after the previous
ble connection goes
away.

When I did local test, the ble peripheral is using bluez, I create
gatt server and ble advertisment using Bluez DBus API,  when remote
connection in central disconnects, I see kernel in Bluez in peripheral
side do receive
HCI_EV_DISCONN_COMPLETE event, and trigger
hci_req_reenable_advertising.

Maybe you can share the code location where Bluez is reenabling the
advertisement after ble connection goes away?

Thanks
Best wishes
On Thu, Dec 13, 2018 at 3:10 PM Yunhan Wang <yunhanw@nestlabs.com> wrote:
>
> Hi, Luiz
>
> From what you describes, it seems Bluez is taking the responsibility
> to reenable the advertisement after the previous ble connection goes
> away.
>
> When I did local test, the ble peripheral is using bluez, I create
> gatt server and ble advertisment using Bluez DBus API,  when remote
> connection in central disconnects, I see kernel in Bluez do receive
> HCI_EV_DISCONN_COMPLETE event, and trigger
> hci_req_reenable_advertising.
>
> Maybe you can share the code location where Bluez is reenabling the
> advertisement after ble connection goes away?
>
> Thanks
> Best wishes
> Yunhan
>
> On Thu, Dec 13, 2018 at 2:30 PM Martin Turon <mturon@google.com> wrote:
> >
> > Hi Luiz,
> >
> > Is this behavior also expected on raw hci sockets?  Because my observation is that when working with raw hci over such sockets, auto-reenable does not occur.
> >
> >     #define BTPROTO_HCI                 1
> >     #define HCI_CHANNEL_USER         1
> >
> >     struct sockaddr_hci shci;
> >     shci.hci_family = AF_BLUETOOTH;
> >     shci.hci_dev = s_ble_hci_device;
> >     shci.hci_channel = HCI_CHANNEL_USER;
> >
> >     s = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
> >     rc = bind(s, (struct sockaddr *)&shci, sizeof(shci));
> >
> > Also, which API allows the user to control the advertising instances you describe?  Are they automatically created by the kernel when HCI is sent to a raw socket to enable advertising?
> >
> > Thanks,
> > Martin
> >
> > _____________________________
> > Martin Turon  |  Google
> >
> >
> >
> > On Thu, Dec 13, 2018 at 1:49 PM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote:
> >>
> >> Hi Yunhan,
> >>
> >> The BlueZ API operates a bit different than HCI, it keeps re-enabling the advertisement if there is any instance active, but the user can stop this by removing its instance once a connection is made, this is considered more convenient than having the user to reprogram the advertisement on every disconnection.
> >>
> >> On Thu, 13 Dec 2018, 18:38 Yunhan Wang <yunhanw@nestlabs.com wrote:
> >>>
> >>> +Martin
> >>>
> >>> Hi, Luiz and Marcel
> >>>
> >>> When I take a look at the bluetooth code, it seems it is re-enabling
> >>> ble advertisement after ble connection goes away. Any idea?
> >>>
> >>> https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git/tree/net/bluetooth/hci_event.c#n2634
> >>> https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git/tree/net/bluetooth/hci_event.c#n2712
> >>> https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git/tree/net/bluetooth/hci_request.c#n1386
> >>> https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git/tree/net/bluetooth/hci_request.c#n1734
> >>>
> >>> Thanks
> >>> Best wishes
> >>> Yunhan
> >>> On Wed, Dec 5, 2018 at 6:54 PM Yunhan Wang <yunhanw@nestlabs.com> wrote:
> >>> >
> >>> > Hi, Luiz and Marcel
> >>> >
> >>> > May I have a question on ble behavior on BLE re-advertisement?
> >>> >
> >>> > According to Bluetooth spec Vol. 3 (the host volume), 9.2.4.2, "The
> >>> > device shall remain in general discoverable mode until a connection is
> >>> > established or the Host terminates the mode."
> >>> >
> >>> > There is no description on re-enabling the advertising "after"
> >>> > disconnection, so the responsibility for re-enabling the advertising
> >>> > is bluez or kernel or application code? In other words, does kernel or
> >>> > bluez or application would re-enable the ble advertisement after ble
> >>> > disconnection happens?
> >>> >
> >>> > Thanks
> >>> > Best wishes
> >>> > Yunhan.

  reply	other threads:[~2018-12-13 23:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-06  2:54 BLE advertisement re-enabling after ble connection goes away Yunhan Wang
2018-12-13 21:38 ` Yunhan Wang
     [not found]   ` <CABBYNZLPeHRWcG78USDYHL6zzw392JuefRaD9S_+RuXhDQ9ZCw@mail.gmail.com>
     [not found]     ` <CAOOu1=BiJ9VjiMXiiPuXb=4cu-62OYmT+h1Z83ip440KwSpeAw@mail.gmail.com>
2018-12-13 23:10       ` Yunhan Wang
2018-12-13 23:13         ` Yunhan Wang [this message]
2018-12-14  1:21           ` Luiz Augusto von Dentz
2018-12-14  2:06             ` Yunhan Wang
2018-12-14  2:32               ` Luiz Augusto von Dentz
2018-12-14  3:08                 ` Yunhan Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALvjcs9jRvfb6uFN5BZx26Nh3ojwL5S_Bt08Q72aHPjZUZTtUA@mail.gmail.com \
    --to=yunhanw@nestlabs.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.org \
    --cc=mturon@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).