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

Fix WiFi auto scan stopping - wait for iface proxy #15302

Merged
merged 1 commit into from
Feb 28, 2022
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
27 changes: 15 additions & 12 deletions src/platform/Linux/ConnectivityManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,15 @@ void ConnectivityManagerImpl::_OnWpaInterfaceProxyReady(GObject * source_object,
mWpaSupplicant.state = GDBusWpaSupplicant::WPA_NOT_CONNECTED;
}

// We need to stop auto scan or it will block our network scan.
DeviceLayer::SystemLayer().ScheduleLambda([]() {
CHIP_ERROR errInner = StopAutoScan();
if (errInner != CHIP_NO_ERROR)
{
ChipLogError(DeviceLayer, "wpa_supplicant: Failed to stop auto scan: %s", ErrorStr(errInner));
}
});

if (err != nullptr)
g_error_free(err);
}
Expand Down Expand Up @@ -644,17 +653,6 @@ void ConnectivityManagerImpl::_OnWpaProxyReady(GObject * source_object, GAsyncRe
mWpaSupplicant.state = GDBusWpaSupplicant::WPA_NOT_CONNECTED;
}

// We need to stop auto scan or it will block our network scan.
DeviceLayer::SystemLayer().ScheduleLambda([]() {
std::lock_guard<std::mutex> innerLock(mWpaSupplicantMutex);
ChipLogDetail(DeviceLayer, "Disabling auto scan");
CHIP_ERROR errInner = StopAutoScan();
if (errInner != CHIP_NO_ERROR)
{
ChipLogError(DeviceLayer, "Failed to stop auto scan");
}
});

if (err != nullptr)
g_error_free(err);
}
Expand Down Expand Up @@ -1312,9 +1310,14 @@ CHIP_ERROR ConnectivityManagerImpl::GetConnectedNetwork(NetworkCommissioning::Ne

CHIP_ERROR ConnectivityManagerImpl::StopAutoScan()
{
std::unique_ptr<GError, GErrorDeleter> err;
std::lock_guard<std::mutex> lock(mWpaSupplicantMutex);
VerifyOrReturnError(mWpaSupplicant.iface != nullptr, CHIP_ERROR_INCORRECT_STATE);

std::unique_ptr<GError, GErrorDeleter> err;
gboolean result;

ChipLogDetail(DeviceLayer, "wpa_supplicant: disabling auto scan");

result = wpa_fi_w1_wpa_supplicant1_interface_call_auto_scan_sync(
mWpaSupplicant.iface, "" /* empty string means disabling auto scan */, nullptr, &MakeUniquePointerReceiver(err).Get());
if (!result)
Expand Down