@@ -503,6 +503,9 @@ sl_status_t SetWifiConfigurations()
503503 .encryption = SL_WIFI_DEFAULT_ENCRYPTION,
504504 .client_options = SL_WIFI_JOIN_WITH_SCAN,
505505 .credential_id = SL_NET_DEFAULT_WIFI_CLIENT_CREDENTIAL_ID,
506+ .channel_bitmap = {
507+ .channel_bitmap_2_4 = SL_WIFI_DEFAULT_CHANNEL_BITMAP
508+ },
506509 },
507510 .ip = {
508511 .mode = SL_IP_MANAGEMENT_DHCP,
@@ -520,7 +523,8 @@ sl_status_t SetWifiConfigurations()
520523 {
521524 // AP channel is known - This indicates that the network scan was done for a specific SSID.
522525 // Providing the channel and BSSID in the profile avoids scanning all channels again.
523- profile.config .channel .channel = wfx_rsi.ap_chan ;
526+ profile.config .channel .channel = wfx_rsi.ap_chan ;
527+ profile.config .channel_bitmap .channel_bitmap_2_4 = (1UL << (wfx_rsi.ap_chan - 1 ));
524528
525529 chip::MutableByteSpan bssidSpan (profile.config .bssid .octet , kWiFiBSSIDLength );
526530 chip::ByteSpan inBssid (wfx_rsi.ap_bssid .data (), kWiFiBSSIDLength );
@@ -662,7 +666,7 @@ void WifiInterfaceImpl::ProcessEvent(WifiPlatformEvent event)
662666
663667 case WifiPlatformEvent::kStationDisconnect : {
664668 ChipLogDetail (DeviceLayer, " WifiPlatformEvent::kStationDisconnect" );
665- // TODO: This event is not being posted anywhere, seems to be a dead code or we are missing something
669+ TriggerPlatformWifiDisconnection ();
666670
667671 wfx_rsi.dev_state .Clear (WifiInterface::WifiState::kStationReady )
668672 .Clear (WifiInterface::WifiState::kStationConnecting )
@@ -681,15 +685,18 @@ void WifiInterfaceImpl::ProcessEvent(WifiPlatformEvent event)
681685 // TODO: Currently unimplemented
682686 break ;
683687
684- case WifiPlatformEvent::kStationStartJoin :
685- ChipLogDetail (DeviceLayer, " WifiPlatformEvent::kStationStartJoin" );
686-
687- // To avoid IOP issues, it is recommended to enable high-performance mode before joining the network.
688- // TODO: Remove this once the IOP issue related to power save mode switching is fixed in the Wi-Fi SDK.
688+ case WifiPlatformEvent::kStationStartScan :
689+ ChipLogDetail (DeviceLayer, " WifiPlatformEvent::kStationStartScan" );
690+ // To avoid IOP issues, enable high-performance mode before scan/join. TODO: Remove once IOP fix is in Wi-Fi SDK.
689691#if CHIP_CONFIG_ENABLE_ICD_SERVER
690692 TEMPORARY_RETURN_IGNORED chip::DeviceLayer::Silabs::WifiSleepManager::GetInstance ().RequestHighPerformanceWithTransition ();
691693#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
692694 InitiateScan ();
695+ PostWifiPlatformEvent (WifiPlatformEvent::kStationStartJoin );
696+ break ;
697+
698+ case WifiPlatformEvent::kStationStartJoin :
699+ ChipLogDetail (DeviceLayer, " WifiPlatformEvent::kStationStartJoin" );
693700 JoinWifiNetwork ();
694701 break ;
695702
@@ -765,6 +772,7 @@ sl_status_t WifiInterfaceImpl::JoinWifiNetwork(void)
765772 ChipLogError (DeviceLayer, " sl_net_up failed: 0x%lx" , static_cast <uint32_t >(status));
766773
767774 wfx_rsi.dev_state .Clear (WifiInterface::WifiState::kStationConnecting ).Clear (WifiInterface::WifiState::kStationConnected );
775+ mUseQuickJoin = !(status == SL_STATUS_SI91X_NO_AP_FOUND);
768776 ScheduleConnectionAttempt ();
769777
770778 return status;
@@ -793,6 +801,7 @@ sl_status_t WifiInterfaceImpl::JoinCallback(sl_wifi_event_t event, char * result
793801 ChipLogError (DeviceLayer, " JoinCallback: failed: 0x%lx" , status);
794802 wfx_rsi.dev_state .Clear (WifiInterface::WifiState::kStationConnected );
795803
804+ mInstance .mUseQuickJoin = !(status == SL_STATUS_SI91X_NO_AP_FOUND);
796805 mInstance .ScheduleConnectionAttempt ();
797806 }
798807
@@ -894,7 +903,10 @@ void WifiInterfaceImpl::PostWifiPlatformEvent(WifiPlatformEvent event)
894903
895904sl_status_t WifiInterfaceImpl::TriggerPlatformWifiDisconnection ()
896905{
897- return sl_net_down (SL_NET_WIFI_CLIENT_INTERFACE);
906+ sl_status_t status = sl_net_down (SL_NET_WIFI_CLIENT_INTERFACE);
907+ VerifyOrReturnError (status == SL_STATUS_OK, status, ChipLogError (DeviceLayer, " sl_net_down failed: 0x%lx" , status));
908+
909+ return SL_STATUS_OK;
898910}
899911
900912#if CHIP_CONFIG_ENABLE_ICD_SERVER
@@ -1067,12 +1079,9 @@ bool WifiInterfaceImpl::IsStationReady()
10671079 return wfx_rsi.dev_state .Has (WifiState::kStationInit );
10681080}
10691081
1070- CHIP_ERROR WifiInterfaceImpl::TriggerDisconnection ()
1082+ void WifiInterfaceImpl::TriggerDisconnection ()
10711083{
1072- VerifyOrReturnError (TriggerPlatformWifiDisconnection () == SL_STATUS_OK, CHIP_ERROR_INTERNAL);
1073- wfx_rsi.dev_state .Clear (WifiState::kStationConnected );
1074-
1075- return CHIP_NO_ERROR;
1084+ PostWifiPlatformEvent (WifiPlatformEvent::kStationDisconnect );
10761085}
10771086
10781087void WifiInterfaceImpl::NotifyConnectivity (void )
@@ -1131,25 +1140,22 @@ bool WifiInterfaceImpl::IsWifiProvisioned()
11311140 return wfx_rsi.dev_state .Has (WifiState::kStationProvisioned );
11321141}
11331142
1134- void WifiInterfaceImpl::SetWifiCredentials (const WiFiCredentials & credentials)
1143+ CHIP_ERROR WifiInterfaceImpl::SetWifiCredentials (const WiFiCredentials & credentials)
11351144{
1145+ VerifyOrReturnError (credentials.ssidLen , CHIP_ERROR_INVALID_ARGUMENT);
1146+ VerifyOrReturnError (credentials.ssidLen <= kMaxWiFiSSIDLength , CHIP_ERROR_INVALID_ARGUMENT);
11361147 wfx_rsi.credentials = credentials;
11371148 wfx_rsi.dev_state .Set (WifiState::kStationProvisioned );
1149+ return CHIP_NO_ERROR;
11381150}
11391151
11401152CHIP_ERROR WifiInterfaceImpl::ConnectToAccessPoint ()
11411153{
11421154 VerifyOrReturnError (IsWifiProvisioned (), CHIP_ERROR_INCORRECT_STATE);
1143- VerifyOrReturnError (wfx_rsi.credentials .ssidLen , CHIP_ERROR_INCORRECT_STATE);
1144-
1145- // TODO: We should move this validation to where we set the credentials. It is too late here.
1146- VerifyOrReturnError (wfx_rsi.credentials .ssidLen <= kMaxWiFiSSIDLength , CHIP_ERROR_INVALID_ARGUMENT);
11471155
1148- ChipLogProgress (DeviceLayer, " connect to access point: %s" , wfx_rsi.credentials .ssid );
1149-
1150- WifiPlatformEvent event = WifiPlatformEvent::kStationStartJoin ;
1151- PostWifiPlatformEvent (event);
1156+ ChipLogProgress (DeviceLayer, " %s to access point: %s" , mUseQuickJoin ? " quick join" : " connect" , wfx_rsi.credentials .ssid );
11521157
1158+ PostWifiPlatformEvent (mUseQuickJoin ? WifiPlatformEvent::kStationStartJoin : WifiPlatformEvent::kStationStartScan );
11531159 return CHIP_NO_ERROR;
11541160}
11551161
0 commit comments