Skip to content
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

[rtl872x] BLE scanning panic #2650

Merged
merged 2 commits into from
Apr 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion hal/src/rtl872x/ble_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1171,11 +1171,13 @@ int BleGap::stop() {
if (isAdvertising_) {
// This will also wait for advertisements to stop
stopAdvertising();
isAdvertising_ = false;
}

if (isScanning_) {
stopScanning();
le_scan_stop(); // Just in case
isScanning_ = false;
}

// Prevent BLE stack from generating coexistence events, otherwise we may leak memory
Expand Down Expand Up @@ -1626,7 +1628,15 @@ int BleGap::startScanning(hal_ble_on_scan_result_cb_t callback, void* context) {
}
HAL_Delay_Milliseconds(10);
}
SPARK_ASSERT(!isScanning_);
if (isScanning_) {
int ret = stop();
SPARK_ASSERT(ret == SYSTEM_ERROR_NONE);
ret = init();
SPARK_ASSERT(ret == SYSTEM_ERROR_NONE);
ret = start();
SPARK_ASSERT(ret == SYSTEM_ERROR_NONE);
}
isScanning_ = false;
clearPendingResult();
}
});
Expand Down