Re: BLE advertisement re-enabling after ble connection goes away

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Yunhan,

On Fri, Dec 14, 2018 at 4:06 AM Yunhan Wang <yunhanw@xxxxxxxxxxxx> wrote:
>
> Hi, Luiz
>
> Thanks for your reply. A little bit confused here.
>
> There is no code in bluez that directly re-enable advertisement, if
> there is, could you show the code location in bluez?

Isn't that what the following code does:

https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git/tree/net/bluetooth/hci_request.c#n1386

> Bluetooth in kernel is responsible for re-enabling advertisement? The
> responsibility for re-enabling the advertising is kernel instead of
> bluez and user application code.

Yes it is the kernel which re-enables it and it has been doing this
for a long while so I wonder why all of the a sudden we are discussing
about it. Is there a bug related to it?

> Thanks
> Best wishes
> Yunhan
>
>
>
> On Thu, Dec 13, 2018 at 5:21 PM Luiz Augusto von Dentz
> <luiz.dentz@xxxxxxxxx> wrote:
> >
> > Hi Yunhan,
> >
> > You already answered your question, it is reenabled by
> > hci_req_reenable_advertising
> >
> >
> > On Fri, Dec 14, 2018 at 1:13 AM Yunhan Wang <yunhanw@xxxxxxxxxxxx> wrote:
> > >
> > > 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@xxxxxxxxxxxx> 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@xxxxxxxxxx> 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));
> >
> > Raw socket commands might actually work but here you are using it with
> > a user channel which afaik disables the stack processing.
> >
> > > > > 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?
> >
> > Nope you need to use the management interface to use the advertising
> > instances, or better yet use the D-Bus API:
> >
> > https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/advertising-api.txt
> >
> > > > > Thanks,
> > > > > Martin
> > > > >
> > > > > _____________________________
> > > > > Martin Turon  |  Google
> > > > >
> > > > >
> > > > >
> > > > > On Thu, Dec 13, 2018 at 1:49 PM Luiz Augusto von Dentz <luiz.dentz@xxxxxxxxx> 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@xxxxxxxxxxxx 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@xxxxxxxxxxxx> 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.
> >
> >
> >
> > --
> > Luiz Augusto von Dentz



-- 
Luiz Augusto von Dentz




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux