@@ -72,13 +72,13 @@ extern "C" {
7272using namespace chip ::DeviceLayer::Silabs;
7373using WiFiBandEnum = chip::app::Clusters::NetworkCommissioning::WiFiBandEnum;
7474
75- // TODO : Temporary work-around for wifi-init failure in 917NCP ACX module boards .
76- // Can be removed after Wiseconnect fixes region code for all ACX module boards .
77- # if defined(EXP_BOARD)
78- # define REGION_CODE IGNORE_REGION
79- #else
75+ // The REGION_CODE macro defines the regulatory region for the Wi-Fi device .
76+ // The default value is 'US'. Users can override this macro to specify a different region code .
77+ // The region code must match one of the values defined in the 'sl_wifi_region_code_t' enum,
78+ // which is located in 'wifi-sdk/inc/sl_wifi_constants.h'. Example values include US, EU, JP, etc.
79+ #ifndef REGION_CODE
8080#define REGION_CODE US
81- #endif
81+ #endif // !REGION_CODE
8282
8383// TODO: This needs to be refactored so we don't need the global object
8484WfxRsi_t wfx_rsi;
@@ -698,7 +698,20 @@ sl_status_t WifiInterfaceImpl::JoinWifiNetwork(void)
698698
699699 status = sl_net_up (SL_NET_WIFI_CLIENT_INTERFACE, SL_NET_DEFAULT_WIFI_CLIENT_PROFILE_ID);
700700
701- if (status == SL_STATUS_OK || status == SL_STATUS_IN_PROGRESS)
701+ if (!(wfx_rsi.dev_state .Has (WifiInterface::WifiState::kStationConnecting )))
702+ {
703+ // TODO: Remove this check once the sl_net_up is fixed, sl_net_up is not completely synchronous
704+ // and issue is mostly seen on OPEN access points
705+
706+ // sl_net_up can return SL_STATUS_SUCCESS, even if the join callback has been called
707+ // If the state has changed, it means that the join callback has already been called
708+ // rejoin already started, so we should not proceed with further processing
709+ ChipLogDetail (DeviceLayer, " JoinCallback already called, skipping further processing" );
710+
711+ status = SL_STATUS_FAIL;
712+ }
713+
714+ if (status == SL_STATUS_OK)
702715 {
703716#if CHIP_CONFIG_ENABLE_ICD_SERVER
704717 // Remove High performance request that might have been added during the connect/retry process
@@ -722,7 +735,17 @@ sl_status_t WifiInterfaceImpl::JoinWifiNetwork(void)
722735sl_status_t WifiInterfaceImpl::JoinCallback (sl_wifi_event_t event, char * result, uint32_t resultLenght, void * arg)
723736{
724737 sl_status_t status = SL_STATUS_OK;
725- wfx_rsi.dev_state .Clear (WifiInterface::WifiState::kStationConnecting );
738+ // If the failed event is encountered when sl_net_up is in-progress,
739+ // we ignore it and wait for the sl_net_up to complete.
740+ if (wfx_rsi.dev_state .Has (WifiInterface::WifiState::kStationConnecting ))
741+ {
742+ wfx_rsi.dev_state .Clear (WifiState::kStationConnecting );
743+ if (SL_WIFI_CHECK_IF_EVENT_FAILED (event))
744+ {
745+ return SL_STATUS_IN_PROGRESS;
746+ }
747+ }
748+
726749 if (SL_WIFI_CHECK_IF_EVENT_FAILED (event))
727750 {
728751 status = *reinterpret_cast <sl_status_t *>(result);
0 commit comments