Skip to content

Commit

Permalink
Fix WiFi auto scan stopping - wait for iface proxy (#15302)
Browse files Browse the repository at this point in the history
In order to disable WiFi auto scan we need wpa_supplicant interface
proxy to be ready.
  • Loading branch information
arkq authored and pull[bot] committed Aug 22, 2023
1 parent d05cbdb commit 1295824
Showing 1 changed file with 15 additions and 12 deletions.
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

0 comments on commit 1295824

Please sign in to comment.