Bluetooth: stabilize BT_SCAN_PAIR and centralize controller helpers#217
Merged
vnarapar merged 2 commits intoqualcomm-linux:mainfrom Nov 28, 2025
Merged
Bluetooth: stabilize BT_SCAN_PAIR and centralize controller helpers#217vnarapar merged 2 commits intoqualcomm-linux:mainfrom
vnarapar merged 2 commits intoqualcomm-linux:mainfrom
Conversation
- Add rfkill/sysfs based helpers (rfkillunblocksysfs, listhcis, findhcisysfs) and btgetbdaddr() to reliably discover HCI adapters and their BD_ADDR. - Make bt_l2ping_check() more tolerant by adding a short grace period after connect, retrying l2ping a couple of times, and logging each attempt, which avoids false FAILs when manual l2ping is already stable. Signed-off-by: Srikanth Muppandam <smuppand@qti.qualcomm.com>
- Source lib_bluetooth.sh alongside functestlib to reuse common BT helpers. - Dynamically detect the Bluetooth adapter (BT_ADAPTER) via listhcis instead of hard-coding hci0. - Resolve effective BT_MAC from (in order): environment, CLI argument, and bt_device_list.txt fallback, keeping BT_MAC as the common variable name for LAVA secrets. - Ensure the controller is visible to bluetoothctl using bt_ensure_controller_visible(), which applies public-addr when needed. - Use btpower() to power on the adapter only when required, rather than always forcing hciconfig up. - Remove all previously paired devices before starting the test, and perform per-MAC cleanup via bt_cleanup_paired_device() in the trap. - Implement direct pairing path for BT_MAC with PAIR_RETRIES, calling bt_pair_with_mac(), bt_post_pair_connect(), and bt_l2ping_check() and writing BT_SCAN_PAIR.res as PASS/FAIL while always exiting with status 0 for LAVA. Signed-off-by: Srikanth Muppandam <smuppand@qti.qualcomm.com>
bhargav0610
approved these changes
Nov 24, 2025
vnarapar
reviewed
Nov 24, 2025
| # Output: prints "MAC NAME" lines; returns 0 if any device (or MAC_ID) found. | ||
| # shellcheck disable=SC2120 | ||
| bt_scan_devices() { | ||
| bt_scan_devices_expect() { |
Contributor
There was a problem hiding this comment.
I dont see this function being used anywhere. is this required?
Logic is similar to the new function bt_scan_devices, can u please check?
Contributor
Author
There was a problem hiding this comment.
I dont see this function being used anywhere. is this required? Logic is similar to the new function bt_scan_devices, can u please check?
Yes, these functions are kept for future use in case logic based on expect is required. There are no plans to remove them.
vnarapar
reviewed
Nov 24, 2025
|
|
||
| # Pair with Bluetooth device using MAC (with retries and timestamped logs) | ||
| bt_pair_with_mac() { | ||
| bt_pair_with_mac_expect() { |
Contributor
Author
There was a problem hiding this comment.
Same as above
Here as well
vnarapar
reviewed
Nov 24, 2025
|
|
||
| # Post-pairing connection test with bluetoothctl and l2ping fallback | ||
| bt_post_pair_connect() { | ||
| bt_post_pair_connect_1() { |
Contributor
Author
There was a problem hiding this comment.
Same as above
Here as well
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR brings