-
Notifications
You must be signed in to change notification settings - Fork 8k
Description
Describe the bug
Description
When using bt_le_ext_adv_start()
to start advertising, an error message "No valid legacy adv to resume" is logged by bt_hci_le_enh_conn_complete()
during normal connection establishment. This error message appears even though the system is functioning correctly, causing confusion for developers.
Expected Behavior
No error messages should be logged during normal operation when using advertising APIs correctly.
Actual Behavior
The following error message appears in logs when a connection is established after starting advertising:
[00:00:00.123,456] <err> bt_adv: No valid legacy adv to resume
Root Cause Analysis
The issue was introduced in commit 39cb574438f
which changed the log level from LOG_DBG
to LOG_ERR
in bt_le_adv_resume()
function.
Code Flow:
- Application calls
bt_le_ext_adv_start()
to start advertising - Extended advertising does not create a legacy advertiser instance (
adv_create_legacy()
) - When a connection is established,
bt_hci_le_enh_conn_complete()
is called - If controller supports
BT_LE_STATES_PER_CONN_ADV
,bt_le_adv_resume()
is called unconditionally (line 1500 inhci_core.c
) bt_le_adv_resume()
callsbt_le_adv_lookup_legacy()
which returns NULL for extended advertising- The error message is logged even though this is expected behavior
Relevant Code Locations:
zephyr/subsys/bluetooth/host/hci_core.c:1494-1501
/* if the controller supports, lets advertise for another
* peripheral connection.
* check for connectable advertising state is sufficient as
* this is how this le connection complete for peripheral occurred.
*/
if (BT_LE_STATES_PER_CONN_ADV(bt_dev.le.states)) {
bt_le_adv_resume();
}
zephyr/subsys/bluetooth/host/adv.c:1531-1534
if (!adv) {
LOG_ERR("No valid legacy adv to resume");
return;
}
Proposed Solutions
Option 1: Improve Logic in bt_hci_le_enh_conn_complete()
Modify bt_hci_le_enh_conn_complete()
to only call bt_le_adv_resume()
when there's actually a legacy advertiser to resume:
if (BT_LE_STATES_PER_CONN_ADV(bt_dev.le.states)) {
struct bt_le_ext_adv *adv = bt_le_adv_lookup_legacy();
if (adv && atomic_test_bit(adv->flags, BT_ADV_PERSIST) &&
!atomic_test_bit(adv->flags, BT_ADV_ENABLED)) {
bt_le_adv_resume();
}
}
This approach prevents the unnecessary call to bt_le_adv_resume()
when using extended advertising.
Option 2: Revert Log Level (Minimal Fix)
Change the log level back to LOG_DBG
in bt_le_adv_resume()
since the absence of a legacy advertiser is expected when using extended advertising.
if (!adv) {
LOG_DBG("No valid legacy adv to resume");
return;
}
Option 3: Enhanced Error Handling (Alternative)
Add context-aware logging that distinguishes between actual errors and expected behavior:
if (!adv) {
if (IS_ENABLED(CONFIG_BT_EXT_ADV) &&
BT_DEV_FEAT_LE_EXT_ADV(bt_dev.le.features)) {
LOG_DBG("No legacy adv to resume (extended advertising in use)");
} else {
LOG_ERR("No valid legacy adv to resume");
}
return;
}
Regression
- This is a regression.
Steps to reproduce
- Configure Zephyr with extended advertising support (
CONFIG_BT_EXT_ADV=y
) - Create an advertising set using
bt_le_ext_adv_create()
- Start advertising using
bt_le_ext_adv_start()
- Establish a connection from a central device
- Observe the error log during connection establishment
Relevant log output
[00:05:00.875,000] <err> bt_adv: No valid legacy adv to resume
[00:05:00.876,000] <inf> app: connected
Impact
Annoyance – Minor irritation; no significant impact on usability or functionality.
- Severity: Low (cosmetic issue, no functional impact)
- User Experience: Confusing error messages in logs during normal operation
- Debugging: Makes it harder to identify actual issues due to noise in logs
Environment
- Zephyr Version: v4.2.0+ (commit 39cb574438f and later)
- Architecture: Any (issue is in host stack)
- Board: Any with Bluetooth LE support and controller that supports BT_LE_STATES_PER_CONN_ADV
Additional Context
The original intent of commit 39cb574438f was to aid in debugging by making advertising resume failures more visible. However, the change didn't account for the fact that extended advertising scenarios legitimately don't have legacy advertisers to resume.
This issue affects any application using the extended advertising APIs (bt_le_ext_adv_*) in Zephyr 4.2.0 and later versions.