* BLE advertisement re-enabling after ble connection goes away @ 2018-12-06 2:54 Yunhan Wang 2018-12-13 21:38 ` Yunhan Wang 0 siblings, 1 reply; 8+ messages in thread From: Yunhan Wang @ 2018-12-06 2:54 UTC (permalink / raw) To: Luiz Augusto von Dentz, linux-bluetooth, Marcel Holtmann 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. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: BLE advertisement re-enabling after ble connection goes away 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> 0 siblings, 1 reply; 8+ messages in thread From: Yunhan Wang @ 2018-12-13 21:38 UTC (permalink / raw) To: Luiz Augusto von Dentz, linux-bluetooth, Marcel Holtmann, Martin Turon +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. ^ permalink raw reply [flat|nested] 8+ messages in thread
[parent not found: <CABBYNZLPeHRWcG78USDYHL6zzw392JuefRaD9S_+RuXhDQ9ZCw@mail.gmail.com>]
[parent not found: <CAOOu1=BiJ9VjiMXiiPuXb=4cu-62OYmT+h1Z83ip440KwSpeAw@mail.gmail.com>]
* Re: BLE advertisement re-enabling after ble connection goes away [not found] ` <CAOOu1=BiJ9VjiMXiiPuXb=4cu-62OYmT+h1Z83ip440KwSpeAw@mail.gmail.com> @ 2018-12-13 23:10 ` Yunhan Wang 2018-12-13 23:13 ` Yunhan Wang 0 siblings, 1 reply; 8+ messages in thread From: Yunhan Wang @ 2018-12-13 23:10 UTC (permalink / raw) To: Martin Turon, Luiz Augusto von Dentz, Marcel Holtmann; +Cc: linux-bluetooth 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. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: BLE advertisement re-enabling after ble connection goes away 2018-12-13 23:10 ` Yunhan Wang @ 2018-12-13 23:13 ` Yunhan Wang 2018-12-14 1:21 ` Luiz Augusto von Dentz 0 siblings, 1 reply; 8+ messages in thread From: Yunhan Wang @ 2018-12-13 23:13 UTC (permalink / raw) To: Martin Turon, Luiz Augusto von Dentz, Marcel Holtmann; +Cc: linux-bluetooth 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. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: BLE advertisement re-enabling after ble connection goes away 2018-12-13 23:13 ` Yunhan Wang @ 2018-12-14 1:21 ` Luiz Augusto von Dentz 2018-12-14 2:06 ` Yunhan Wang 0 siblings, 1 reply; 8+ messages in thread From: Luiz Augusto von Dentz @ 2018-12-14 1:21 UTC (permalink / raw) To: Yunhan Wang; +Cc: mturon, Marcel Holtmann, linux-bluetooth 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@nestlabs.com> 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@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)); 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@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. -- Luiz Augusto von Dentz ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: BLE advertisement re-enabling after ble connection goes away 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 0 siblings, 1 reply; 8+ messages in thread From: Yunhan Wang @ 2018-12-14 2:06 UTC (permalink / raw) To: Luiz Augusto von Dentz; +Cc: Martin Turon, Marcel Holtmann, linux-bluetooth 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? 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. Thanks Best wishes Yunhan On Thu, Dec 13, 2018 at 5:21 PM Luiz Augusto von Dentz <luiz.dentz@gmail.com> 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@nestlabs.com> 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@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)); > > 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@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. > > > > -- > Luiz Augusto von Dentz ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: BLE advertisement re-enabling after ble connection goes away 2018-12-14 2:06 ` Yunhan Wang @ 2018-12-14 2:32 ` Luiz Augusto von Dentz 2018-12-14 3:08 ` Yunhan Wang 0 siblings, 1 reply; 8+ messages in thread From: Luiz Augusto von Dentz @ 2018-12-14 2:32 UTC (permalink / raw) To: Yunhan Wang; +Cc: mturon, Marcel Holtmann, linux-bluetooth Hi Yunhan, On Fri, Dec 14, 2018 at 4:06 AM Yunhan Wang <yunhanw@nestlabs.com> 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@gmail.com> 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@nestlabs.com> 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@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)); > > > > 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@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. > > > > > > > > -- > > Luiz Augusto von Dentz -- Luiz Augusto von Dentz ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: BLE advertisement re-enabling after ble connection goes away 2018-12-14 2:32 ` Luiz Augusto von Dentz @ 2018-12-14 3:08 ` Yunhan Wang 0 siblings, 0 replies; 8+ messages in thread From: Yunhan Wang @ 2018-12-14 3:08 UTC (permalink / raw) To: Luiz Augusto von Dentz; +Cc: Martin Turon, Marcel Holtmann, linux-bluetooth Hi, Luiz Thanks for the clarification. On Thu, Dec 13, 2018 at 6:32 PM Luiz Augusto von Dentz <luiz.dentz@gmail.com> wrote: > > Hi Yunhan, > > On Fri, Dec 14, 2018 at 4:06 AM Yunhan Wang <yunhanw@nestlabs.com> 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 > I think this link is bluetooth code in kernel, and it is not bluez code. Now I understand you think this bluetooth code is part of bluez.. > > 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? > I am seeing chrome os bluetooth kernel doesn't re-enable advertisement, so I wanna figure out if bluetooth in kernel or bluez user space or user application needs take this responsibility to re-enable the advertisement. Clearly you mention bluetooth kernel needs to re-enable the advertisement, I would further figure out the root cause in chrome os kernel... Thanks Best wishes Yunhan > > Thanks > > Best wishes > > Yunhan > > > > > > > > On Thu, Dec 13, 2018 at 5:21 PM Luiz Augusto von Dentz > > <luiz.dentz@gmail.com> 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@nestlabs.com> 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@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)); > > > > > > 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@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. > > > > > > > > > > > > -- > > > Luiz Augusto von Dentz > > > > -- > Luiz Augusto von Dentz ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-12-14 3:09 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 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 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
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).