Commit 937a027f authored by Tiansong Cui's avatar Tiansong Cui Committed by Commit Bot

[Chromecast][BLE] Pause and restart BLE scan when setting parameters

We have to pause BLE scan before setting scan parameters. This CL
will make the API easier to use.

Bug: internal b/140961065
Test: Build and run, check HCI logs
Change-Id: Ia63b392ab09505d3d284d150d71b07d134d8a4e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1850801Reviewed-by: default avatarYuchen Liu <yucliu@chromium.org>
Commit-Queue: Tiansong Cui <tiansong@google.com>
Auto-Submit: Tiansong Cui <tiansong@google.com>
Cr-Commit-Position: refs/heads/master@{#704464}
parent 1f02214a
......@@ -141,9 +141,25 @@ void LeScanManagerImpl::RestartScan() {
void LeScanManagerImpl::SetScanParameters(int scan_interval_ms,
int scan_window_ms) {
MAKE_SURE_IO_THREAD(SetScanParameters, scan_interval_ms, scan_window_ms);
if (scan_handle_ids_.empty()) {
LOG(ERROR) << "Can't set scan parameters, no scan handle";
return;
}
// We could only set scan parameters when scan is paused.
if (!le_scanner_->StopScan()) {
LOG(ERROR) << "Failed to pause scanning before setting scan parameters";
return;
}
if (!le_scanner_->SetScanParameters(scan_interval_ms, scan_window_ms)) {
LOG(ERROR) << "Failed to set scan parameters";
return;
}
if (!le_scanner_->StartScan()) {
LOG(ERROR) << "Failed to restart scanning after setting scan parameters";
return;
}
LOG(INFO) << __func__ << " scan_interval: " << scan_interval_ms
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment