Skip to content

Bluetooth: make BT_SCAN discovery robust with retry-based scanning#453

Open
smuppand wants to merge 3 commits into
qualcomm-linux:mainfrom
smuppand:bt-scan-fix
Open

Bluetooth: make BT_SCAN discovery robust with retry-based scanning#453
smuppand wants to merge 3 commits into
qualcomm-linux:mainfrom
smuppand:bt-scan-fix

Conversation

@smuppand
Copy link
Copy Markdown
Contributor

@smuppand smuppand commented May 12, 2026

This PR improves the robustness of the BT_SCAN testcase by reusing and hardening the common Bluetooth scan helper instead of relying on a single scan window followed by one bluetoothctl devices cache lookup.

Why this PR is needed

BT_SCAN was intermittently failing in LAVA even when a Bluetooth peer/dongle was present nearby. The failure happened because the test only checked bluetoothctl devices after scan completion:

No devices discovered in bluetoothctl devices after scan ON.

lava jobs for reference: https://lava.infra.foundries.io/scheduler/job/209191
https://lava.infra.foundries.io/scheduler/job/209192

smuppand added 3 commits May 12, 2026 06:34
Update bt_scan_devices() to make Bluetooth scanning more robust on
minimal and CI images.

The helper now parses both live bluetoothctl scan output and cached
bluetoothctl devices output across multiple scan attempts. This avoids
false failures where advertisements are visible during scan but BlueZ
does not immediately populate the devices cache.

Also accept MAC-only discovery because name resolution can be delayed
or unavailable on minimal images.

This keeps the existing bt_scan_devices() API and avoids adding another
parallel scan helper.

Signed-off-by: Srikanth Muppandam <smuppand@qti.qualcomm.com>
Update BT_SCAN/run.sh to use the common bt_scan_devices() helper instead
of open-coding a single scan window followed by one bluetoothctl devices
cache check.

Add scan tuning knobs for CI stability:

- BT_SCAN_SECONDS
- BT_SCAN_RETRIES
- BT_SCAN_RETRY_DELAY

Also add matching CLI options:

- --scan-seconds
- --scan-retries
- --scan-retry-delay

This keeps generic scan mode unchanged while making it less flaky when
BlueZ cache updates are delayed.

Signed-off-by: Srikanth Muppandam <smuppand@qti.qualcomm.com>
Add README.md for BT_SCAN covering generic scan mode, target MAC mode,
adapter selection, scan retry tuning, result handling, LAVA usage, and
debugging steps.

Signed-off-by: Srikanth Muppandam <smuppand@qti.qualcomm.com>
@smuppand smuppand requested review from Vkenjam and bhargav0610 May 12, 2026 01:33
@smuppand smuppand marked this pull request as ready for review May 12, 2026 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant