-
Notifications
You must be signed in to change notification settings - Fork 21
Bluetooth: Host: Fix handling of adv reports when scanning for connection #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…tion bug: v/78367 In some cases, the host starts scanning internally for establishing connections (BT_LE_SCAN_USER_CONN), such as host-based resolving or auto-connection. In this situation, even if the application does not start explicit scan, the host still needs to handle the advertising reports to continue the connection process. Previously, both bt_hci_le_adv_report() and bt_hci_le_adv_ext_report() will break or discard all reports when explicit scan is not active. This causes the connection to stay in SCAN_BEFORE_INITIATING and never move forward. This patch adds checking of BT_LE_SCAN_USER_CONN to allow advertising reports to be processed during connection-purpose scanning. When the scan is started explicitly by application, the behavior remains the same, only small comments are updated to describe this behavior and keep the original code style unchanged. Signed-off-by: Zhijie Zhong <[email protected]>
bug: v/78367 When building an observer-only build the check_pending_conn label would result in CI warnings/errors due to this only being a C23 feature: scan.c:692:1: error: label at end of compound statement is a C23 extension Turns out the #ifdefs are completely unnecessary, and the code can simply take advantage of IS_ENABLED(), which should get rid of the warning. Signed-off-by: Johan Hedberg <[email protected]>
015aed2 to
e04a341
Compare
| * skip app callbacks but allow pending-conn check logic. | ||
| */ | ||
| if (!explicit_scan && conn_scan) { | ||
| goto check_pending_conn; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 679 would not report scan_dev_found_cb when le_adv_recv, and when would it report?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when it is start by user app, 'explicit_scan' is true.
| struct bt_le_scan_recv_info adv_info; | ||
|
|
||
| if (!atomic_test_bit(hdev->scan_ctx->scan_state.scan_flags, BT_LE_SCAN_USER_EXPLICIT_SCAN)) { | ||
| if (!explicit_scan && !conn_scan) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will it discrad all conn_scan adv when BT_LE_SCAN_USER_CONN was actived?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BT_LE_SCAN_USER_CONN is only trigger by host rpa re-connect. not by user le scan
|
🧩 Change Background When calling: int bt_conn_le_create(const bt_addr_le_t *peer, bt_conn_set_state(conn, BT_CONN_INITIATING); err = bt_le_create_conn(conn); } After pairing and distributing IRK, if (bt_dev.le.rl_entries > bt_dev.le.rl_size) { } BT_LE_SCAN_USER_CONN However, in le_adv_recv(), if the scan is not started by user (not BT_LE_SCAN_USER_EXPLICIT_SCAN), if (!atomic_test_bit(scan_state.scan_flags, BT_LE_SCAN_USER_EXPLICIT_SCAN)) { As a result, the connection logic below can never be triggered: conn = bt_conn_lookup_state_le(BT_ID_DEFAULT, id_addr, err = bt_le_scan_user_remove(BT_LE_SCAN_USER_CONN); The bad effect is that the host keeps scanning forever but never establishes the LE connection. |
huangyulong3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
huangyulong3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
bug: v/78367
In some cases, the host starts scanning internally for establishing
connections (BT_LE_SCAN_USER_CONN), such as host-based resolving or
auto-connection. In this situation, even if the application does not
start explicit scan, the host still needs to handle the advertising
reports to continue the connection process.
Previously, both bt_hci_le_adv_report() and bt_hci_le_adv_ext_report()
will break or discard all reports when explicit scan is not active.
This causes the connection to stay in SCAN_BEFORE_INITIATING and never
move forward.
This patch adds checking of BT_LE_SCAN_USER_CONN to allow advertising
reports to be processed during connection-purpose scanning. When the
scan is started explicitly by application, the behavior remains the
same, only small comments are updated to describe this behavior and keep
the original code style unchanged.
This PR is cherry-pick from
zephyrproject-rtos/zephyr#98411
zephyrproject-rtos/zephyr#98859