From e4c96d01e877145147c6970775b8f1539406dc7b Mon Sep 17 00:00:00 2001 From: lpbeliveau-silabs <112982107+lpbeliveau-silabs@users.noreply.github.com> Date: Thu, 28 Nov 2024 09:44:13 -0500 Subject: [PATCH 1/6] [SL-UP] Bugfix/silabs out rtt removal (#142) --- src/platform/silabs/Logging.cpp | 13 ++++--------- third_party/silabs/SiWx917_sdk.gni | 8 +------- third_party/silabs/efr32_sdk.gni | 8 +------- 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/src/platform/silabs/Logging.cpp b/src/platform/silabs/Logging.cpp index b6345da431..5a2e3b770b 100644 --- a/src/platform/silabs/Logging.cpp +++ b/src/platform/silabs/Logging.cpp @@ -52,13 +52,8 @@ #include "uart.h" #endif -// Enable RTT by default -#ifndef SILABS_LOG_OUT_RTT -#define SILABS_LOG_OUT_RTT 1 -#endif - // SEGGER_RTT includes -#if SILABS_LOG_OUT_RTT +#if !SILABS_LOG_OUT_UART #include "SEGGER_RTT.h" #include "SEGGER_RTT_Conf.h" #endif @@ -137,7 +132,7 @@ static void PrintLog(const char * msg) SEGGER_RTT_WriteNoLock(LOG_RTT_BUFFER_INDEX, msg, sz); #endif // SILABS_LOG_OUT_UART -#if SILABS_LOG_OUT_RTT || PW_RPC_ENABLED +#if !SILABS_LOG_OUT_UART || PW_RPC_ENABLED const char * newline = "\r\n"; sz = strlen(newline); #if PW_RPC_ENABLED @@ -155,7 +150,7 @@ static void PrintLog(const char * msg) extern "C" void silabsInitLog(void) { #if SILABS_LOG_ENABLED -#if SILABS_LOG_OUT_RTT +#if !SILABS_LOG_OUT_UART #if LOG_RTT_BUFFER_INDEX != 0 SEGGER_RTT_ConfigUpBuffer(LOG_RTT_BUFFER_INDEX, LOG_RTT_BUFFER_NAME, sLogBuffer, LOG_RTT_BUFFER_SIZE, SEGGER_RTT_MODE_NO_BLOCK_TRIM); @@ -165,7 +160,7 @@ extern "C" void silabsInitLog(void) #else SEGGER_RTT_SetFlagsUpBuffer(LOG_RTT_BUFFER_INDEX, SEGGER_RTT_MODE_NO_BLOCK_TRIM); #endif -#endif // SILABS_LOG_OUT_RTT +#endif // !SILABS_LOG_OUT_UART #ifdef PW_RPC_ENABLED PigweedLogger::init(); diff --git a/third_party/silabs/SiWx917_sdk.gni b/third_party/silabs/SiWx917_sdk.gni index 5843c7faa6..6873cc267e 100644 --- a/third_party/silabs/SiWx917_sdk.gni +++ b/third_party/silabs/SiWx917_sdk.gni @@ -251,6 +251,7 @@ template("siwx917_sdk") { "UDMA_ROMDRIVER_PRESENT=1", "PLL_ROMDRIVER_PRESENT=1", "SL_MATTER_GN_BUILD=1", + "SILABS_LOG_OUT_UART=${sl_uart_log_output}", ] if (silabs_log_enabled && chip_logging) { @@ -333,13 +334,6 @@ template("siwx917_sdk") { ] } - if (sl_uart_log_output) { - defines += [ - "SILABS_LOG_OUT_UART=1", - "SILABS_LOG_OUT_RTT=0", - ] - } - if (chip_build_libshell) { # matter shell defines += [ "ENABLE_CHIP_SHELL" ] } diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 40296046cc..943a0e3763 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -481,6 +481,7 @@ template("efr32_sdk") { "SL_OPENTHREAD_STACK_FEATURES_CONFIG_FILE=\"sl_openthread_features_config.h\"", "SL_CSL_TIMEOUT=${sl_ot_csl_timeout_sec}", "CIRCULAR_QUEUE_USE_LOCAL_CONFIG_HEADER=1", + "SILABS_LOG_OUT_UART=${sl_uart_log_output}", ] if (silabs_log_enabled && chip_logging) { @@ -489,13 +490,6 @@ template("efr32_sdk") { defines += [ "SILABS_LOG_ENABLED=0" ] } - if (sl_uart_log_output) { - defines += [ - "SILABS_LOG_OUT_UART=1", - "SILABS_LOG_OUT_RTT=0", - ] - } - if (use_silabs_thread_lib) { defines += [ "SL_CONFIG_OPENTHREAD_LIB=1" ] } else { From 43891a307515a95703bcff992f7c86b2c5cb099a Mon Sep 17 00:00:00 2001 From: Mathieu Kardous <84793247+mkardous-silabs@users.noreply.github.com> Date: Thu, 28 Nov 2024 10:42:48 -0500 Subject: [PATCH 2/6] [SL-ONLY] Add business logic for the selective listening impl (#139) Co-authored-by: lpbeliveau-silabs <112982107+lpbeliveau-silabs@users.noreply.github.com> --- examples/platform/silabs/BaseApplication.cpp | 16 ++++++++ examples/platform/silabs/BaseApplication.h | 1 + examples/platform/silabs/MatterConfig.cpp | 1 - .../wifi/icd/ApplicationSleepManager.cpp | 38 ++++++++++++++++--- .../silabs/wifi/icd/ApplicationSleepManager.h | 32 +++++++++++----- 5 files changed, 73 insertions(+), 15 deletions(-) diff --git a/examples/platform/silabs/BaseApplication.cpp b/examples/platform/silabs/BaseApplication.cpp index c80dc1091b..5051edac48 100644 --- a/examples/platform/silabs/BaseApplication.cpp +++ b/examples/platform/silabs/BaseApplication.cpp @@ -96,6 +96,11 @@ #include #endif // MATTER_TRACING_ENABLED +// sl-only +#if SL_MATTER_ENABLE_APP_SLEEP_MANAGER +#include +#endif // SL_MATTER_ENABLE_APP_SLEEP_MANAGER + /********************************************************** * Defines and Constants *********************************************************/ @@ -213,8 +218,19 @@ void BaseApplicationDelegate::OnCommissioningSessionStopped() #endif // SL_WIFI && CHIP_CONFIG_ENABLE_ICD_SERVER } +void BaseApplicationDelegate::OnCommissioningWindowOpened() +{ +#if SL_MATTER_ENABLE_APP_SLEEP_MANAGER + app::Silabs::ApplicationSleepManager::GetInstance().OnCommissioningWindowOpened(); +#endif // SL_MATTER_ENABLE_APP_SLEEP_MANAGER +} + void BaseApplicationDelegate::OnCommissioningWindowClosed() { +#if SL_MATTER_ENABLE_APP_SLEEP_MANAGER + app::Silabs::ApplicationSleepManager::GetInstance().OnCommissioningWindowClosed(); +#endif // SL_MATTER_ENABLE_APP_SLEEP_MANAGER + if (BaseApplication::GetProvisionStatus()) { // After the device is provisioned and the commissioning passed diff --git a/examples/platform/silabs/BaseApplication.h b/examples/platform/silabs/BaseApplication.h index 994d62f14f..d28596220b 100644 --- a/examples/platform/silabs/BaseApplication.h +++ b/examples/platform/silabs/BaseApplication.h @@ -74,6 +74,7 @@ class BaseApplicationDelegate : public AppDelegate, public chip::FabricTable::De void OnCommissioningSessionStarted() override; void OnCommissioningSessionStopped() override; void OnCommissioningWindowClosed() override; + void OnCommissioningWindowOpened() override; // FabricTable::Delegate void OnFabricCommitted(const chip::FabricTable & fabricTable, chip::FabricIndex fabricIndex) override; diff --git a/examples/platform/silabs/MatterConfig.cpp b/examples/platform/silabs/MatterConfig.cpp index b146a12547..80209b3aea 100644 --- a/examples/platform/silabs/MatterConfig.cpp +++ b/examples/platform/silabs/MatterConfig.cpp @@ -342,7 +342,6 @@ CHIP_ERROR SilabsMatterConfig::InitMatter(const char * appName) err = app::Silabs::ApplicationSleepManager::GetInstance() .SetFabricTable(&Server::GetInstance().GetFabricTable()) .SetSubscriptionInfoProvider(app::InteractionModelEngine::GetInstance()) - .SetCommissioningWindowManager(&Server::GetInstance().GetCommissioningWindowManager()) .SetWifiSleepManager(&WifiSleepManager::GetInstance()) .Init(); VerifyOrReturnError(err == CHIP_NO_ERROR, err, ChipLogError(DeviceLayer, "ApplicationSleepManager init failed")); diff --git a/examples/platform/silabs/wifi/icd/ApplicationSleepManager.cpp b/examples/platform/silabs/wifi/icd/ApplicationSleepManager.cpp index cdf32f07e2..ae88c21308 100644 --- a/examples/platform/silabs/wifi/icd/ApplicationSleepManager.cpp +++ b/examples/platform/silabs/wifi/icd/ApplicationSleepManager.cpp @@ -29,8 +29,6 @@ CHIP_ERROR ApplicationSleepManager::Init() VerifyOrReturnError(mFabricTable != nullptr, CHIP_ERROR_INVALID_ARGUMENT, ChipLogError(AppServer, "FabricTable is null")); VerifyOrReturnError(mSubscriptionsInfoProvider != nullptr, CHIP_ERROR_INVALID_ARGUMENT, ChipLogError(AppServer, "SubscriptionsInfoProvider is null")); - VerifyOrReturnError(mCommissioningWindowManager != nullptr, CHIP_ERROR_INVALID_ARGUMENT, - ChipLogError(AppServer, "CommissioningWindowManager is null")); VerifyOrReturnError(mWifiSleepManager != nullptr, CHIP_ERROR_INVALID_ARGUMENT, ChipLogError(AppServer, "WifiSleepManager is null")); @@ -42,6 +40,18 @@ CHIP_ERROR ApplicationSleepManager::Init() return CHIP_NO_ERROR; } +void ApplicationSleepManager::OnCommissioningWindowOpened() +{ + mIsCommissionningWindowOpen = true; + mWifiSleepManager->VerifyAndTransitionToLowPowerMode(); +} + +void ApplicationSleepManager::OnCommissioningWindowClosed() +{ + mIsCommissionningWindowOpen = false; + mWifiSleepManager->VerifyAndTransitionToLowPowerMode(); +} + void ApplicationSleepManager::OnSubscriptionEstablished(chip::app::ReadHandler & aReadHandler) { mWifiSleepManager->VerifyAndTransitionToLowPowerMode(); @@ -71,10 +81,28 @@ void ApplicationSleepManager::OnFabricCommitted(const chip::FabricTable & fabric bool ApplicationSleepManager::CanGoToLIBasedSleep() { - // TODO: Implement your logic here + bool canGoToLIBasedSleep = true; + + if (mIsCommissionningWindowOpen) + { + ChipLogProgress(AppServer, "Commissioning Window is Open - Cannot go to LI based sleep"); + canGoToLIBasedSleep = false; + } + else + { + for (auto it = mFabricTable->begin(); it != mFabricTable->end(); ++it) + { + if (!mSubscriptionsInfoProvider->FabricHasAtLeastOneActiveSubscription(it->GetFabricIndex())) + { + ChipLogProgress(AppServer, "Fabric index %u has no active subscriptions - Cannot go to LI based sleep", + it->GetFabricIndex()); + canGoToLIBasedSleep = false; + break; + } + } + } - ChipLogProgress(AppServer, "CanGoToLIBasedSleep was called!"); - return false; + return canGoToLIBasedSleep; } } // namespace Silabs diff --git a/examples/platform/silabs/wifi/icd/ApplicationSleepManager.h b/examples/platform/silabs/wifi/icd/ApplicationSleepManager.h index 8eba8fcdc4..800c1f980c 100644 --- a/examples/platform/silabs/wifi/icd/ApplicationSleepManager.h +++ b/examples/platform/silabs/wifi/icd/ApplicationSleepManager.h @@ -61,18 +61,26 @@ class ApplicationSleepManager : public chip::app::ReadHandler::ApplicationCallba return *this; } - ApplicationSleepManager & SetCommissioningWindowManager(chip::CommissioningWindowManager * commissioningWindowManager) - { - mCommissioningWindowManager = commissioningWindowManager; - return *this; - } - ApplicationSleepManager & SetWifiSleepManager(chip::DeviceLayer::Silabs::WifiSleepManager * wifiSleepManager) { mWifiSleepManager = wifiSleepManager; return *this; } + /** + * @brief Sets the commissioning window state to open and calls the WifiSleepManager VerifyAndTransitionToLowPowerMode. + * The VerifyAndTransitionToLowPowerMode function is responsible of then queriyng the ApplicationSleepManager to + * determine in which low power state the Wi-Fi device can transition to. + */ + void OnCommissioningWindowOpened(); + + /** + * @brief Sets the commissioning window state to open and calls the WifiSleepManager VerifyAndTransitionToLowPowerMode. + * The VerifyAndTransitionToLowPowerMode function is responsible of then queriyng the ApplicationSleepManager to + * determine in which low power state the Wi-Fi device can transition to. + */ + void OnCommissioningWindowClosed(); + // ReadHandler::ApplicationCallback implementation /** @@ -94,10 +102,14 @@ class ApplicationSleepManager : public chip::app::ReadHandler::ApplicationCallba // WifiSleepManager::ApplicationCallback implementation /** - * @brief TODO + * @brief Function encapsulates the application logic to determine if the Wi-Fi device can go into LI based sleep. * - * @return true - * @return false + * - 1. Check if the commissioning window is open. If it is open, the Wi-Fi device cannot go to LI based sleep. + * - 2. Check if all Fabrics have at least 1 subscription. If there is at least one fabric without a subscription, the + * Wi-Fi cannot go to LI based sleep. + * + * @return true if the device can go to LI sleep + * false if the device cannot go to LI sleep */ bool CanGoToLIBasedSleep() override; @@ -131,6 +143,8 @@ class ApplicationSleepManager : public chip::app::ReadHandler::ApplicationCallba chip::app::SubscriptionsInfoProvider * mSubscriptionsInfoProvider = nullptr; chip::CommissioningWindowManager * mCommissioningWindowManager = nullptr; chip::DeviceLayer::Silabs::WifiSleepManager * mWifiSleepManager = nullptr; + + bool mIsCommissionningWindowOpen = false; }; } // namespace Silabs From 583900c2dc268de380bf1c113f5b1bf9ce3dabd5 Mon Sep 17 00:00:00 2001 From: lpbeliveau-silabs <112982107+lpbeliveau-silabs@users.noreply.github.com> Date: Thu, 28 Nov 2024 10:45:04 -0500 Subject: [PATCH 3/6] [SL-ONLY]Bugfix/wrong boot end trace (#143) --- examples/platform/silabs/MatterConfig.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/platform/silabs/MatterConfig.cpp b/examples/platform/silabs/MatterConfig.cpp index 80209b3aea..3e17d154f8 100644 --- a/examples/platform/silabs/MatterConfig.cpp +++ b/examples/platform/silabs/MatterConfig.cpp @@ -227,9 +227,6 @@ void SilabsMatterConfig::AppInit() ChipLogProgress(DeviceLayer, "Starting scheduler"); VerifyOrDie(sMainTaskHandle); // We can't proceed if the Main Task creation failed. -#if MATTER_TRACING_ENABLED - SilabsTracer::Instance().TimeTraceEnd(TimeTraceOperation::kBootup); -#endif // MATTER_TRACING_ENABLED GetPlatform().StartScheduler(); // Should never get here. From a71fb43a6edee79b52939020da25b196c39b95b1 Mon Sep 17 00:00:00 2001 From: lpbeliveau-silabs <112982107+lpbeliveau-silabs@users.noreply.github.com> Date: Thu, 28 Nov 2024 14:39:12 -0500 Subject: [PATCH 4/6] [SL-ONLY] Bugfix/gn true to define true (#144) --- third_party/silabs/SiWx917_sdk.gni | 7 ++++++- third_party/silabs/efr32_sdk.gni | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/third_party/silabs/SiWx917_sdk.gni b/third_party/silabs/SiWx917_sdk.gni index 6873cc267e..3d22486601 100644 --- a/third_party/silabs/SiWx917_sdk.gni +++ b/third_party/silabs/SiWx917_sdk.gni @@ -251,7 +251,6 @@ template("siwx917_sdk") { "UDMA_ROMDRIVER_PRESENT=1", "PLL_ROMDRIVER_PRESENT=1", "SL_MATTER_GN_BUILD=1", - "SILABS_LOG_OUT_UART=${sl_uart_log_output}", ] if (silabs_log_enabled && chip_logging) { @@ -334,6 +333,12 @@ template("siwx917_sdk") { ] } + if (sl_uart_log_output) { + defines += [ "SILABS_LOG_OUT_UART=1" ] + } else { + defines += [ "SILABS_LOG_OUT_UART=0" ] + } + if (chip_build_libshell) { # matter shell defines += [ "ENABLE_CHIP_SHELL" ] } diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 943a0e3763..a477809326 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -481,7 +481,6 @@ template("efr32_sdk") { "SL_OPENTHREAD_STACK_FEATURES_CONFIG_FILE=\"sl_openthread_features_config.h\"", "SL_CSL_TIMEOUT=${sl_ot_csl_timeout_sec}", "CIRCULAR_QUEUE_USE_LOCAL_CONFIG_HEADER=1", - "SILABS_LOG_OUT_UART=${sl_uart_log_output}", ] if (silabs_log_enabled && chip_logging) { @@ -490,6 +489,12 @@ template("efr32_sdk") { defines += [ "SILABS_LOG_ENABLED=0" ] } + if (sl_uart_log_output) { + defines += [ "SILABS_LOG_OUT_UART=1" ] + } else { + defines += [ "SILABS_LOG_OUT_UART=0" ] + } + if (use_silabs_thread_lib) { defines += [ "SL_CONFIG_OPENTHREAD_LIB=1" ] } else { From 524062b75c36fc06d63fb2353fb656726f66d7b9 Mon Sep 17 00:00:00 2001 From: Mathieu Kardous <84793247+mkardous-silabs@users.noreply.github.com> Date: Thu, 28 Nov 2024 15:14:17 -0500 Subject: [PATCH 5/6] [SL-ONLY] Fix init sequence for the Application Sleep Manager (#145) --- examples/platform/silabs/MatterConfig.cpp | 6 +++--- .../platform/silabs/wifi/icd/ApplicationSleepManager.cpp | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/platform/silabs/MatterConfig.cpp b/examples/platform/silabs/MatterConfig.cpp index 3e17d154f8..b7f007b07b 100644 --- a/examples/platform/silabs/MatterConfig.cpp +++ b/examples/platform/silabs/MatterConfig.cpp @@ -331,9 +331,6 @@ CHIP_ERROR SilabsMatterConfig::InitMatter(const char * appName) initParams.appDelegate = &BaseApplication::sAppDelegate; - // Init Matter Server and Start Event Loop - err = chip::Server::GetInstance().Init(initParams); - // [sl-only]: Configure Wi-Fi App Sleep Manager #if SL_MATTER_ENABLE_APP_SLEEP_MANAGER err = app::Silabs::ApplicationSleepManager::GetInstance() @@ -348,6 +345,9 @@ CHIP_ERROR SilabsMatterConfig::InitMatter(const char * appName) &app::Silabs::ApplicationSleepManager::GetInstance()); #endif // SL_MATTER_ENABLE_APP_SLEEP_MANAGER + // Init Matter Server and Start Event Loop + err = chip::Server::GetInstance().Init(initParams); + #if MATTER_TRACING_ENABLED static Tracing::Silabs::BackendImpl backend; Tracing::Register(backend); diff --git a/examples/platform/silabs/wifi/icd/ApplicationSleepManager.cpp b/examples/platform/silabs/wifi/icd/ApplicationSleepManager.cpp index ae88c21308..5d75e609cb 100644 --- a/examples/platform/silabs/wifi/icd/ApplicationSleepManager.cpp +++ b/examples/platform/silabs/wifi/icd/ApplicationSleepManager.cpp @@ -99,6 +99,7 @@ bool ApplicationSleepManager::CanGoToLIBasedSleep() canGoToLIBasedSleep = false; break; } + ChipLogProgress(AppServer, "All Fabrics have at least 1 active subscription!"); } } From 29ada7416c6a59f5d25480e5bf7db6933147a52e Mon Sep 17 00:00:00 2001 From: senthilku Date: Fri, 29 Nov 2024 02:31:02 +0530 Subject: [PATCH 6/6] [SL-UP] Fix for access point power cycle rejoin issue with ecosystem (#119) Co-authored-by: Mathieu Kardous <84793247+mkardous-silabs@users.noreply.github.com> --- .../silabs/wifi/SiWx/WifiInterface.cpp | 55 ++++++++++++++++--- 1 file changed, 48 insertions(+), 7 deletions(-) diff --git a/src/platform/silabs/wifi/SiWx/WifiInterface.cpp b/src/platform/silabs/wifi/SiWx/WifiInterface.cpp index 36bdbf2217..0e8181cc06 100644 --- a/src/platform/silabs/wifi/SiWx/WifiInterface.cpp +++ b/src/platform/silabs/wifi/SiWx/WifiInterface.cpp @@ -298,14 +298,17 @@ sl_status_t ScanCallback(sl_wifi_event_t event, sl_wifi_scan_result_t * scan_res sl_status_t status = SL_STATUS_OK; if (SL_WIFI_CHECK_IF_EVENT_FAILED(event)) { - ChipLogError(DeviceLayer, "Scan Netwrok Failed: 0x%lx", *reinterpret_cast(status)); + if (scan_result != nullptr) + { + status = *reinterpret_cast(scan_result); + ChipLogError(DeviceLayer, "ScanCallback: failed: 0x%lx", static_cast(status)); + } + #if WIFI_ENABLE_SECURITY_WPA3_TRANSITION security = SL_WIFI_WPA3; #else security = SL_WIFI_WPA_WPA2_MIXED; #endif /* WIFI_ENABLE_SECURITY_WPA3_TRANSITION */ - - status = SL_STATUS_FAIL; } else { @@ -408,6 +411,45 @@ sl_status_t SetWifiConfigurations() return status; } +/** + * @brief Callback function for the SL_WIFI_JOIN_EVENTS group + * + * This callback handler will be invoked when any event within join event group occurs, providing the event details and any associated data + * The callback doesn't get called when we join a network using the sl net APIs + * + * @note In case of failure, the 'result' parameter will be of type sl_status_t, and the 'resultLenght' parameter should be ignored + * + * @param[in] event sl_wifi_event_t that triggered the callback + * @param[in] result Pointer to the response data received + * @param[in] result_length Length of the data received in bytes + * @param[in] arg Optional user provided argument + * + * @return sl_status_t Returns the status of the operation + */ +sl_status_t JoinCallback(sl_wifi_event_t event, char * result, uint32_t resultLenght, void * arg) +{ + sl_status_t status = SL_STATUS_OK; + wfx_rsi.dev_state.Clear(WifiState::kStationConnecting); + if (SL_WIFI_CHECK_IF_EVENT_FAILED(event)) + { + status = *reinterpret_cast(result); + ChipLogError(DeviceLayer, "JoinCallback: failed: 0x%lx", static_cast(status)); + wfx_rsi.dev_state.Clear(WifiState::kStationConnected); + wfx_retry_connection(++wfx_rsi.join_retries); + return status; + } + + /* + * Join was complete - Do the DHCP + */ + ChipLogDetail(DeviceLayer, "JoinCallback: success"); + memset(&temp_reset, 0, sizeof(temp_reset)); + + WifiEvent wifievent = WifiEvent::kStationConnect; + sl_matter_wifi_post_event(wifievent); + wfx_rsi.join_retries = 0; + return status; +} sl_status_t JoinWifiNetwork(void) { VerifyOrReturnError(!wfx_rsi.dev_state.HasAny(WifiState::kStationConnecting, WifiState::kStationConnected), @@ -420,6 +462,9 @@ sl_status_t JoinWifiNetwork(void) status = SetWifiConfigurations(); VerifyOrReturnError(status == SL_STATUS_OK, status, ChipLogError(DeviceLayer, "Failure to set the Wifi Configurations!")); + status = sl_wifi_set_join_callback(JoinCallback, nullptr); + VerifyOrReturnError(status == SL_STATUS_OK, status); + status = sl_net_up((sl_net_interface_t) SL_NET_WIFI_CLIENT_INTERFACE, SL_NET_DEFAULT_WIFI_CLIENT_PROFILE_ID); if (status == SL_STATUS_OK || status == SL_STATUS_IN_PROGRESS) @@ -437,16 +482,12 @@ sl_status_t JoinWifiNetwork(void) // failure only happens when the firmware returns an error ChipLogError(DeviceLayer, "sl_wifi_connect failed: 0x%lx", static_cast(status)); - VerifyOrReturnError((wfx_rsi.join_retries <= MAX_JOIN_RETRIES_COUNT), status); wfx_rsi.dev_state.Clear(WifiState::kStationConnecting).Clear(WifiState::kStationConnected); ChipLogProgress(DeviceLayer, "Connection retry attempt %d", wfx_rsi.join_retries); wfx_retry_connection(++wfx_rsi.join_retries); - WifiEvent event = WifiEvent::kStationStartJoin; - sl_matter_wifi_post_event(event); - return status; }