@@ -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 );
@@ -661,7 +665,7 @@ void WifiInterfaceImpl::ProcessEvent(WifiPlatformEvent event)
661665
662666 case WifiPlatformEvent::kStationDisconnect : {
663667 ChipLogDetail (DeviceLayer, " WifiPlatformEvent::kStationDisconnect" );
664- // TODO: This event is not being posted anywhere, seems to be a dead code or we are missing something
668+ TriggerPlatformWifiDisconnection ();
665669
666670 wfx_rsi.dev_state .Clear (WifiInterface::WifiState::kStationReady )
667671 .Clear (WifiInterface::WifiState::kStationConnecting )
@@ -680,15 +684,18 @@ void WifiInterfaceImpl::ProcessEvent(WifiPlatformEvent event)
680684 // TODO: Currently unimplemented
681685 break ;
682686
683- case WifiPlatformEvent::kStationStartJoin :
684- ChipLogDetail (DeviceLayer, " WifiPlatformEvent::kStationStartJoin" );
685-
686- // To avoid IOP issues, it is recommended to enable high-performance mode before joining the network.
687- // TODO: Remove this once the IOP issue related to power save mode switching is fixed in the Wi-Fi SDK.
687+ case WifiPlatformEvent::kStationStartScan :
688+ ChipLogDetail (DeviceLayer, " WifiPlatformEvent::kStationStartScan" );
689+ // To avoid IOP issues, enable high-performance mode before scan/join. TODO: Remove once IOP fix is in Wi-Fi SDK.
688690#if CHIP_CONFIG_ENABLE_ICD_SERVER
689691 TEMPORARY_RETURN_IGNORED chip::DeviceLayer::Silabs::WifiSleepManager::GetInstance ().RequestHighPerformanceWithTransition ();
690692#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
691693 InitiateScan ();
694+ PostWifiPlatformEvent (WifiPlatformEvent::kStationStartJoin );
695+ break ;
696+
697+ case WifiPlatformEvent::kStationStartJoin :
698+ ChipLogDetail (DeviceLayer, " WifiPlatformEvent::kStationStartJoin" );
692699 JoinWifiNetwork ();
693700 break ;
694701
@@ -764,6 +771,7 @@ sl_status_t WifiInterfaceImpl::JoinWifiNetwork(void)
764771 ChipLogError (DeviceLayer, " sl_net_up failed: 0x%lx" , static_cast <uint32_t >(status));
765772
766773 wfx_rsi.dev_state .Clear (WifiInterface::WifiState::kStationConnecting ).Clear (WifiInterface::WifiState::kStationConnected );
774+ mUseQuickJoin = !(status == SL_STATUS_SI91X_NO_AP_FOUND);
767775 ScheduleConnectionAttempt ();
768776
769777 return status;
@@ -792,6 +800,7 @@ sl_status_t WifiInterfaceImpl::JoinCallback(sl_wifi_event_t event, char * result
792800 ChipLogError (DeviceLayer, " JoinCallback: failed: 0x%lx" , status);
793801 wfx_rsi.dev_state .Clear (WifiInterface::WifiState::kStationConnected );
794802
803+ mInstance .mUseQuickJoin = !(status == SL_STATUS_SI91X_NO_AP_FOUND);
795804 mInstance .ScheduleConnectionAttempt ();
796805 }
797806
@@ -893,7 +902,10 @@ void WifiInterfaceImpl::PostWifiPlatformEvent(WifiPlatformEvent event)
893902
894903sl_status_t WifiInterfaceImpl::TriggerPlatformWifiDisconnection ()
895904{
896- return sl_net_down (SL_NET_WIFI_CLIENT_INTERFACE);
905+ sl_status_t status = sl_net_down (SL_NET_WIFI_CLIENT_INTERFACE);
906+ VerifyOrReturnError (status == SL_STATUS_OK, status, ChipLogError (DeviceLayer, " sl_net_down failed: 0x%lx" , status));
907+
908+ return SL_STATUS_OK;
897909}
898910
899911#if CHIP_CONFIG_ENABLE_ICD_SERVER
@@ -1062,12 +1074,9 @@ bool WifiInterfaceImpl::IsStationReady()
10621074 return wfx_rsi.dev_state .Has (WifiState::kStationInit );
10631075}
10641076
1065- CHIP_ERROR WifiInterfaceImpl::TriggerDisconnection ()
1077+ void WifiInterfaceImpl::TriggerDisconnection ()
10661078{
1067- VerifyOrReturnError (TriggerPlatformWifiDisconnection () == SL_STATUS_OK, CHIP_ERROR_INTERNAL);
1068- wfx_rsi.dev_state .Clear (WifiState::kStationConnected );
1069-
1070- return CHIP_NO_ERROR;
1079+ PostWifiPlatformEvent (WifiPlatformEvent::kStationDisconnect );
10711080}
10721081
10731082void WifiInterfaceImpl::NotifyConnectivity (void )
@@ -1126,25 +1135,22 @@ bool WifiInterfaceImpl::IsWifiProvisioned()
11261135 return wfx_rsi.dev_state .Has (WifiState::kStationProvisioned );
11271136}
11281137
1129- void WifiInterfaceImpl::SetWifiCredentials (const WiFiCredentials & credentials)
1138+ CHIP_ERROR WifiInterfaceImpl::SetWifiCredentials (const WiFiCredentials & credentials)
11301139{
1140+ VerifyOrReturnError (credentials.ssidLen , CHIP_ERROR_INVALID_ARGUMENT);
1141+ VerifyOrReturnError (credentials.ssidLen <= kMaxWiFiSSIDLength , CHIP_ERROR_INVALID_ARGUMENT);
11311142 wfx_rsi.credentials = credentials;
11321143 wfx_rsi.dev_state .Set (WifiState::kStationProvisioned );
1144+ return CHIP_NO_ERROR;
11331145}
11341146
11351147CHIP_ERROR WifiInterfaceImpl::ConnectToAccessPoint ()
11361148{
11371149 VerifyOrReturnError (IsWifiProvisioned (), CHIP_ERROR_INCORRECT_STATE);
1138- VerifyOrReturnError (wfx_rsi.credentials .ssidLen , CHIP_ERROR_INCORRECT_STATE);
1139-
1140- // TODO: We should move this validation to where we set the credentials. It is too late here.
1141- VerifyOrReturnError (wfx_rsi.credentials .ssidLen <= kMaxWiFiSSIDLength , CHIP_ERROR_INVALID_ARGUMENT);
11421150
1143- ChipLogProgress (DeviceLayer, " connect to access point: %s" , wfx_rsi.credentials .ssid );
1144-
1145- WifiPlatformEvent event = WifiPlatformEvent::kStationStartJoin ;
1146- PostWifiPlatformEvent (event);
1151+ ChipLogProgress (DeviceLayer, " %s to access point: %s" , mUseQuickJoin ? " quick join" : " connect" , wfx_rsi.credentials .ssid );
11471152
1153+ PostWifiPlatformEvent (mUseQuickJoin ? WifiPlatformEvent::kStationStartJoin : WifiPlatformEvent::kStationStartScan );
11481154 return CHIP_NO_ERROR;
11491155}
11501156
0 commit comments