From a5d3c572170a5eb4e66ec6d4922f0838f64c3c89 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Fri, 4 Nov 2022 07:55:14 -0700 Subject: [PATCH 1/2] [linux] Fix the device failed to reconnect wifi after power cycle --- src/platform/Linux/ConnectivityManagerImpl.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/platform/Linux/ConnectivityManagerImpl.cpp b/src/platform/Linux/ConnectivityManagerImpl.cpp index ca7251d72a28cc..e151d67c6ffe45 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.cpp +++ b/src/platform/Linux/ConnectivityManagerImpl.cpp @@ -1061,6 +1061,24 @@ void ConnectivityManagerImpl::_ConnectWiFiNetworkAsyncCallback(GObject * source_ mpConnectCallback = nullptr; }); } + else + { + GError * gerror = nullptr; + + result = wpa_fi_w1_wpa_supplicant1_interface_call_save_config_sync(mWpaSupplicant.iface, nullptr, &gerror); + if (result) + { + ChipLogProgress(DeviceLayer, "wpa_supplicant: save config succeeded!"); + } + else + { + ChipLogProgress(DeviceLayer, "wpa_supplicant: failed to save config: %s", + gerror ? gerror->message : "unknown error"); + } + + if (gerror != nullptr) + g_error_free(gerror); + } } } From fbd87eab7c698429c8c6912d22277d964a25defc Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Fri, 4 Nov 2022 09:52:38 -0700 Subject: [PATCH 2/2] Add return to prevent indent in the following code --- .../Linux/ConnectivityManagerImpl.cpp | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/platform/Linux/ConnectivityManagerImpl.cpp b/src/platform/Linux/ConnectivityManagerImpl.cpp index e151d67c6ffe45..41b8af50158bd9 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.cpp +++ b/src/platform/Linux/ConnectivityManagerImpl.cpp @@ -1060,25 +1060,24 @@ void ConnectivityManagerImpl::_ConnectWiFiNetworkAsyncCallback(GObject * source_ } mpConnectCallback = nullptr; }); + + return; } - else - { - GError * gerror = nullptr; - result = wpa_fi_w1_wpa_supplicant1_interface_call_save_config_sync(mWpaSupplicant.iface, nullptr, &gerror); - if (result) - { - ChipLogProgress(DeviceLayer, "wpa_supplicant: save config succeeded!"); - } - else - { - ChipLogProgress(DeviceLayer, "wpa_supplicant: failed to save config: %s", - gerror ? gerror->message : "unknown error"); - } + GError * gerror = nullptr; - if (gerror != nullptr) - g_error_free(gerror); + result = wpa_fi_w1_wpa_supplicant1_interface_call_save_config_sync(mWpaSupplicant.iface, nullptr, &gerror); + if (result) + { + ChipLogProgress(DeviceLayer, "wpa_supplicant: save config succeeded!"); } + else + { + ChipLogProgress(DeviceLayer, "wpa_supplicant: failed to save config: %s", gerror ? gerror->message : "unknown error"); + } + + if (gerror != nullptr) + g_error_free(gerror); } }