From 0e3bbaea217be0e9c0b875a31a0a92ccb7ed6ae7 Mon Sep 17 00:00:00 2001 From: ShubhamMalasane <108782058+ShubhamMalasane@users.noreply.github.com> Date: Thu, 8 Sep 2022 21:12:08 +0530 Subject: [PATCH] [EFR32] window app implementation for wifi (#22451) * [EFR32] window app implementation for wifi * removed log message from common file * [EFR32] added comment --- examples/window-app/efr32/BUILD.gn | 4 +++ .../efr32/include/CHIPProjectConfig.h | 4 ++- .../window-app/efr32/src/WindowAppImpl.cpp | 33 ++++++++++++------- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/examples/window-app/efr32/BUILD.gn b/examples/window-app/efr32/BUILD.gn index 08dabc3593696e..45250e7a46341f 100644 --- a/examples/window-app/efr32/BUILD.gn +++ b/examples/window-app/efr32/BUILD.gn @@ -35,6 +35,9 @@ declare_args() { # PIN code for PASE session establishment. setupPinCode = 20202021 + #default Discriminator value + setupDiscriminator = 3840 + # Monitor & log memory usage at runtime. enable_heap_monitoring = false @@ -128,6 +131,7 @@ efr32_sdk("sdk") { defines = [ "BOARD_ID=${efr32_board}", "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}", + "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}", "OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}", ] diff --git a/examples/window-app/efr32/include/CHIPProjectConfig.h b/examples/window-app/efr32/include/CHIPProjectConfig.h index 4f69721d3d971e..4621081b6d9d3d 100644 --- a/examples/window-app/efr32/include/CHIPProjectConfig.h +++ b/examples/window-app/efr32/include/CHIPProjectConfig.h @@ -32,8 +32,10 @@ #ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 #endif -#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 +#ifndef CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR +#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 +#endif // For convenience, Chip Security Test Mode can be enabled and the // requirement for authentication in various protocols can be disabled. // diff --git a/examples/window-app/efr32/src/WindowAppImpl.cpp b/examples/window-app/efr32/src/WindowAppImpl.cpp index 3f2cad957c068a..c4a1d3fd6762b8 100644 --- a/examples/window-app/efr32/src/WindowAppImpl.cpp +++ b/examples/window-app/efr32/src/WindowAppImpl.cpp @@ -33,6 +33,8 @@ #ifdef SL_WIFI #include "wfx_host_events.h" +#include +#include #endif #ifdef DISPLAY_ENABLED @@ -51,6 +53,10 @@ using namespace chip::app::Clusters::WindowCovering; #define APP_STATE_LED &sl_led_led0 #define APP_ACTION_LED &sl_led_led1 +#ifdef SL_WIFI +chip::app::Clusters::NetworkCommissioning::Instance + sWiFiNetworkCommissioningInstance(0 /* Endpoint Id */, &(chip::DeviceLayer::NetworkCommissioning::SlWiFiDriver::GetInstance())); +#endif //------------------------------------------------------------------------------ // Timers //------------------------------------------------------------------------------ @@ -145,6 +151,21 @@ WindowAppImpl::WindowAppImpl() {} void WindowAppImpl::OnTaskCallback(void * parameter) { +#ifdef SL_WIFI + /* + * Wait for the WiFi to be initialized + */ + EFR32_LOG("APP: Wait WiFi Init"); + while (!wfx_hw_ready()) + { + vTaskDelay(10); + } + EFR32_LOG("APP: Done WiFi Init"); + /* We will init server when we get IP */ + sWiFiNetworkCommissioningInstance.Init(); + /* added for commisioning with wifi */ +#endif + sInstance.Run(); } @@ -158,18 +179,6 @@ void WindowAppImpl::OnIconTimeout(WindowApp::Timer & timer) CHIP_ERROR WindowAppImpl::Init() { -#ifdef SL_WIFI - /* - * Wait for the WiFi to be initialized - */ - EFR32_LOG("APP: Wait WiFi Init"); - while (!wfx_hw_ready()) - { - vTaskDelay(10); - } - EFR32_LOG("APP: Done WiFi Init"); - /* We will init server when we get IP */ -#endif WindowApp::Init(); // Initialize App Task