@@ -184,7 +184,7 @@ void WiFiManager::SuppEventHandler(net_mgmt_event_callback * cb, uint64_t mgmtEv
184184{
185185 if (mgmtEvent == NET_EVENT_SUPPLICANT_NOT_READY)
186186 {
187- SystemLayer ().ScheduleLambda ([] {
187+ SystemLayer ().ScheduleLambda ([]() -> void {
188188 if (Instance ().mWiFiState == WIFI_STATE_COMPLETED)
189189 {
190190 Instance ().mReconnect = true ;
@@ -194,12 +194,21 @@ void WiFiManager::SuppEventHandler(net_mgmt_event_callback * cb, uint64_t mgmtEv
194194 }
195195 else if (mgmtEvent == NET_EVENT_SUPPLICANT_READY)
196196 {
197- SystemLayer ().ScheduleLambda ([] {
197+ SystemLayer ().ScheduleLambda ([]() -> void {
198198 if (Instance ().mWantedNetwork .IsConfigured () && Instance ().mReconnect )
199199 {
200200 Instance ().mReconnect = false ;
201- Instance ().SetLowPowerMode (Instance ().mWiFiPsEnabled );
202- Instance ().Scan (Instance ().mWantedNetwork .GetSsidSpan (), nullptr , nullptr , true /* internal scan */ );
201+ CHIP_ERROR err = Instance ().SetLowPowerMode (Instance ().mWiFiPsEnabled );
202+ if (err != CHIP_NO_ERROR)
203+ {
204+ ChipLogError (DeviceLayer, " SetLowPowerMode failed: %" CHIP_ERROR_FORMAT, err.Format ());
205+ }
206+ CHIP_ERROR scanErr =
207+ Instance ().Scan (Instance ().mWantedNetwork .GetSsidSpan (), nullptr , nullptr , true /* internal scan */ );
208+ if (scanErr != CHIP_NO_ERROR)
209+ {
210+ ChipLogError (DeviceLayer, " WiFi recovery scan failed: %" CHIP_ERROR_FORMAT, scanErr.Format ());
211+ }
203212 }
204213 });
205214 }
@@ -366,7 +375,7 @@ void WiFiManager::ScanResultHandler(Platform::UniquePtr<uint8_t> data, size_t le
366375 // In case there are many networks with the same SSID choose the one with the best RSSI
367376 if (scanResult->rssi > Instance ().mWiFiParams .mRssi )
368377 {
369- Instance ().ClearStationProvisioningData ();
378+ TEMPORARY_RETURN_IGNORED Instance ().ClearStationProvisioningData ();
370379 Instance ().mWiFiParams .mParams .ssid_length = static_cast <uint8_t >(Instance ().mWantedNetwork .ssidLen );
371380 Instance ().mWiFiParams .mParams .ssid = Instance ().mWantedNetwork .ssid ;
372381 // Fallback to the WIFI_SECURITY_TYPE_PSK if the security is unknown
@@ -488,7 +497,7 @@ void WiFiManager::ConnectHandler(Platform::UniquePtr<uint8_t> data, size_t lengt
488497 // Validate that input data size matches the expected one.
489498 VerifyOrReturn (length == sizeof (wifi_status));
490499
491- CHIP_ERROR err = SystemLayer ().ScheduleLambda ([capturedData = data.get ()] {
500+ CHIP_ERROR err = SystemLayer ().ScheduleLambda ([capturedData = data.get ()]() -> void {
492501 Platform::UniquePtr<uint8_t > safePtr (capturedData);
493502 uint8_t * rawData = safePtr.get ();
494503 const wifi_status * status = reinterpret_cast <const wifi_status *>(rawData);
@@ -564,7 +573,11 @@ void WiFiManager::ConnectHandler(Platform::UniquePtr<uint8_t> data, size_t lengt
564573 }
565574 }
566575 // cleanup the provisioning data as it is configured per each connect request
567- Instance ().ClearStationProvisioningData ();
576+ CHIP_ERROR clearErr = Instance ().ClearStationProvisioningData ();
577+ if (clearErr != CHIP_NO_ERROR)
578+ {
579+ ChipLogError (DeviceLayer, " ClearStationProvisioningData failed: %" CHIP_ERROR_FORMAT, clearErr.Format ());
580+ }
568581 });
569582
570583 if (CHIP_NO_ERROR == err)
@@ -678,7 +691,11 @@ void WiFiManager::Recover(System::Layer *, void *)
678691 return ;
679692 }
680693
681- Instance ().Scan (Instance ().mWantedNetwork .GetSsidSpan (), nullptr , nullptr , true /* internal scan */ );
694+ CHIP_ERROR scanErr = Instance ().Scan (Instance ().mWantedNetwork .GetSsidSpan (), nullptr , nullptr , true /* internal scan */ );
695+ if (scanErr != CHIP_NO_ERROR)
696+ {
697+ ChipLogError (DeviceLayer, " Connection recovery scan failed: %" CHIP_ERROR_FORMAT, scanErr.Format ());
698+ }
682699}
683700
684701void WiFiManager::ResetRecoveryTime ()
0 commit comments