Skip to content

Commit

Permalink
Create WPA DBUS proxy synchronously (project-chip#8834)
Browse files Browse the repository at this point in the history
  • Loading branch information
tewarid committed Aug 23, 2021
1 parent deb227f commit 987c79e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
2 changes: 2 additions & 0 deletions src/inet/IPEndPointBasis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ static CHIP_ERROR SocketsIPv4JoinLeaveMulticastGroup(int aSocket, InterfaceId aI
{
IPAddress lInterfaceAddress;
bool lInterfaceAddressFound = false;
char ipAddress[INET6_ADDRSTRLEN];

for (InterfaceAddressIterator lAddressIterator; lAddressIterator.HasCurrent(); lAddressIterator.Next())
{
Expand All @@ -249,6 +250,7 @@ static CHIP_ERROR SocketsIPv4JoinLeaveMulticastGroup(int aSocket, InterfaceId aI
{
if (lCurrentAddress.IsIPv4())
{
ChipLogProgress(Inet, "Found interface %d with address %s.", aInterfaceId, ipAddress);
lInterfaceAddressFound = true;
lInterfaceAddress = lCurrentAddress;
break;
Expand Down
28 changes: 12 additions & 16 deletions src/platform/Linux/ConnectivityManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,11 +591,21 @@ void ConnectivityManagerImpl::_OnWpaInterfaceRemoved(WpaFiW1Wpa_supplicant1 * pr
}
}

void ConnectivityManagerImpl::_OnWpaProxyReady(GObject * source_object, GAsyncResult * res, gpointer user_data)
void ConnectivityManagerImpl::StartWiFiManagement()
{
GError * err = nullptr;

mWpaSupplicant.proxy = wpa_fi_w1_wpa_supplicant1_proxy_new_for_bus_finish(res, &err);
mConnectivityFlag.ClearAll();
mWpaSupplicant.state = GDBusWpaSupplicant::INIT;
mWpaSupplicant.scanState = GDBusWpaSupplicant::WIFI_SCANNING_IDLE;
mWpaSupplicant.proxy = nullptr;
mWpaSupplicant.iface = nullptr;
mWpaSupplicant.interfacePath = nullptr;
mWpaSupplicant.networkPath = nullptr;

mWpaSupplicant.proxy = wpa_fi_w1_wpa_supplicant1_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE,
kWpaSupplicantServiceName,
kWpaSupplicantObjectPath, nullptr, &err);
if (mWpaSupplicant.proxy != nullptr && err == nullptr)
{
mWpaSupplicant.state = GDBusWpaSupplicant::WPA_CONNECTED;
Expand All @@ -619,20 +629,6 @@ void ConnectivityManagerImpl::_OnWpaProxyReady(GObject * source_object, GAsyncRe
g_error_free(err);
}

void ConnectivityManagerImpl::StartWiFiManagement()
{
mConnectivityFlag.ClearAll();
mWpaSupplicant.state = GDBusWpaSupplicant::INIT;
mWpaSupplicant.scanState = GDBusWpaSupplicant::WIFI_SCANNING_IDLE;
mWpaSupplicant.proxy = nullptr;
mWpaSupplicant.iface = nullptr;
mWpaSupplicant.interfacePath = nullptr;
mWpaSupplicant.networkPath = nullptr;

wpa_fi_w1_wpa_supplicant1_proxy_new_for_bus(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, kWpaSupplicantServiceName,
kWpaSupplicantObjectPath, nullptr, _OnWpaProxyReady, nullptr);
}

void ConnectivityManagerImpl::DriveAPState()
{
CHIP_ERROR err = CHIP_NO_ERROR;
Expand Down

0 comments on commit 987c79e

Please sign in to comment.