Fix advertising not resuming in extended mode#51309
Fix advertising not resuming in extended mode#51309tgagneret-embedded wants to merge 1 commit intozephyrproject-rtos:mainfrom
Conversation
Flag CONFIG_BT_EXT_ADV is only relevant and used in legacy mode. It should not be taken into account when using extended advertising. Signed-off-by: Thomas Gagneret <tgagneret@witekio.com>
|
Hi, My problem comes from the fact that when I advertise and one device connects, even if CONFIG_BT_MAX_CONN is set to 10, advertising is not resumed automatically. After some verification it seems that the problem is elsewhere. It is possible to enable CONFIG_BT_EXT_ADV but start legacy advertising. But doing this seems to break the resume because for some reason BT_ADV_ENABLED is cleared only if CONFIG_BT_EXT_ADV is not enabled. So I think that verification does not use the correct information. If I disabled CONFIG_BT_EXT_ADV from my prj.conf, then I have the expected behavior. So there is a problem I think, but this PR does not solve anything. Thanks |
|
@tgagneret-embedded could this be the fix you are looking for? #51256 |
|
Hi, I don't think so. If you want to reproduce my issue:
Expected behavior: Actual behavior: Analysis: My fix clear this issue but I'm not sure it's the root problem. |
|
@tgagneret-embedded could you please open a GitHub issue with the info you provided? |
ppryga-nordic
left a comment
There was a problem hiding this comment.
I think that the problem should be fixed in right place, which is in my humble opinion here:
zephyr/subsys/bluetooth/host/hci_core.c
Lines 1223 to 1233 in 31afbf7
In case CONFIG_BT_EXT_ADV is enabled and a Controller's extended advertising feature bit is set the BT_ADV_ENABLED bit is not cleared.
BTW. The commit message does not align witch changes done in the commit. It is hard to connect reason of the change with the change itself.
|
I am not sure I follow this change at all. The commit message doesn't make sense to me:
The PR title suggests that this fix will enable persisting advertising for extended advertisers, which, based on the changes, it doesn't seem to do. Extended advertising is currently, by design, not persisting, see e.g. /**
* @brief Advertise one time.
*
* Don't try to resume connectable advertising after a connection.
* This option is only meaningful when used together with
* BT_LE_ADV_OPT_CONNECTABLE. If set the advertising will be stopped
* when bt_le_adv_stop() is called or when an incoming (peripheral)
* connection happens. If this option is not set the stack will
* take care of keeping advertising enabled even as connections
* occur.
* If Advertising directed or the advertiser was started with
* @ref bt_le_ext_adv_start then this behavior is the default behavior
* and this flag has no effect.
*/
BT_LE_ADV_OPT_ONE_TIME = BIT(1),The properly support persistent extended advertising, I created #30699 a while ago, and this PR seems to miss several of the challenges of implementing this. |
|
Hi, You're right @Thalley , my message is not correct at all. The goal is to resume a LEGACY advertising (started by bt_le_adv_start) when EXTENDED is enabled during compilation. Maybe my fix is not the correct one. The problem is probably before this and @ppryga-nordic points to the right problem I think: |
If by extended mode, you mean that the advertising set is not setting the legacy flag ( Keep in mind that Basically
|
|
To clarify and make sure we understand because I'm not sure to understand the solution here. First forget about my commit it's the wrong one. Second, we establish that the problem comes from these 2 samples: zephyr/subsys/bluetooth/host/hci_core.c Lines 1223 to 1233 in 31afbf7 zephyr/subsys/bluetooth/host/adv.c Lines 1441 to 1444 in 31afbf7 So even if So instead of testing CONFIG_BT_EXT_ADV is enabled we should test Doing this means means calling zephyr/subsys/bluetooth/host/adv.c Lines 296 to 303 in 31afbf7 Am I correct ? If so, let me know I can update the PR if you want. Thanks |
No, because
Not sure I fully followed this part, but yes |
|
Hi, So maybe the problem is not from Zephyr but the firmware in the CPU NET (on nrf5340). With our conversation I understand that when So if I think the problem might come the CPU NET firmware. Do you agree ? Thanks |
Advertising is never resumed automatically by the controller (or the CPU NET as you use here) - That is a feature that has been implemented for legacy advertising in the Zephyr host |
|
Hi, Just to make sure I understand correctly: My program does not resume advertising in these condition. So if you agree, can you point me to the right direction on how to solve my issue ? Thanks |
Assuming that Are you running your own application? Can you replicate the issue using the https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/bluetooth/peripheral sample, which should work that way. If I run that sample with |
|
Hi, If I run the However if FYI, I'm using NRF Connect SDK, so my issue is probably not be related to mainline Zephyr. I will open a ticket at Nordic for this issue. |
|
Hi, Sorry, I forgot to add So "advertising never starts" is not true. Instead I can reproduce the initial issue, advertising never resume after a connection. Sorry for that. |
Thanks for testing. I had forgotten to I don't have the solution to the issue on hand, but if you can verify that your PR fixes this, then that's great. Alternatively, if you don't |
|
Hi, Yes this is the issue I want to fix even if I'm not sure the PR fixes it correctly. Thanks. |
If you run the sample with your PR, does it correct resume the advertising? But yeah, it looks like Zephyr has a problem with handling this, as the description for Furthermore, the concept of actual act of resuming the advertising after connection isn't something that I can find documentation for in I would need to spend more time on this before I can figure out what needs to be done, than I have time for right now. Perhaps @alwa-nordic can help here? |
|
Hi, I've pointed where is the actual source of the issue in my comment: #51309 (review). Following on information there. If zephyr/subsys/bluetooth/host/adv.c Lines 1441 to 1444 in c27a6af This is caused by check zephyr/subsys/bluetooth/host/hci_core.c Line 1225 in 31afbf7 The advertising resume after disconnect will not work when The change required update of conditions in What more, it looks to me that zephyr/subsys/bluetooth/host/adv.c Line 1347 in c27a6af BTW. I've just found that there are |
I find it all confusing too. Both Another issue is that advertising is, with Yet another issue is that Maybe these issues need to be tackled at the same time, or maybe they should be tackled individually. |
|
I have no strong opinion whether approach this as single issue or in multiple steps. BTW. There is another issue related to advertising resume, it could be addressed at the same time: #50438. |
|
@tgagneret-embedded I have created an issue to track this, and will try to come up with a proper fix. |
|
Closing the PR since we all seem to agree this is not the correct or full solution. The issue will be tracked in #53048 . |

Flag CONFIG_BT_EXT_ADV is only relevant and used in legacy mode. It should not be taken into account when using extended advertising.