From 1160256167c1cd7976523b7205d9abdc2b09b571 Mon Sep 17 00:00:00 2001 From: srningap <107042150+srningap@users.noreply.github.com> Date: Fri, 14 Apr 2023 18:59:06 +0530 Subject: [PATCH] [Silabs] WiFi factory reset support for window-app 917SoC (#26066) * adds factory reset support for 917SoC window-app * applied restyle --- .../silabs/SiWx917/src/AppTask.cpp | 2 +- .../silabs/SiWx917/src/AppTask.cpp | 2 +- .../lock-app/silabs/SiWx917/src/AppTask.cpp | 2 +- .../SiWx917/SiWx917/hal/rsi_hal_mcu_m4.c | 3 ++- .../silabs/SiWx917/include/WindowAppImpl.h | 1 + .../silabs/SiWx917/src/WindowAppImpl.cpp | 26 ++++++++++++++++--- 6 files changed, 28 insertions(+), 8 deletions(-) diff --git a/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp b/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp index 3ea96abf726399..2fbad4ed4d3286 100644 --- a/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp +++ b/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp @@ -265,7 +265,7 @@ void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction) button_event.Handler = SwitchActionEventHandler; sAppTask.PostEvent(&button_event); } - else if (button == SIWx917_BTN0) + else if (button == SIWx917_BTN0 && btnAction == SL_SIMPLE_BUTTON_PRESSED) { button_event.Handler = BaseApplication::ButtonHandler; sAppTask.PostEvent(&button_event); diff --git a/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp b/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp index 6133df35c33610..8da8003549c216 100644 --- a/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp +++ b/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp @@ -246,7 +246,7 @@ void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction) button_event.Handler = LightActionEventHandler; sAppTask.PostEvent(&button_event); } - else if (button == SIWx917_BTN0) + else if (button == SIWx917_BTN0 && btnAction == SL_SIMPLE_BUTTON_PRESSED) { button_event.Handler = BaseApplication::ButtonHandler; sAppTask.PostEvent(&button_event); diff --git a/examples/lock-app/silabs/SiWx917/src/AppTask.cpp b/examples/lock-app/silabs/SiWx917/src/AppTask.cpp index bb9d15b6328039..abc276588bdab6 100644 --- a/examples/lock-app/silabs/SiWx917/src/AppTask.cpp +++ b/examples/lock-app/silabs/SiWx917/src/AppTask.cpp @@ -358,7 +358,7 @@ void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction) button_event.Handler = LockActionEventHandler; sAppTask.PostEvent(&button_event); } - else if (button == SIWx917_BTN0) + else if (button == SIWx917_BTN0 && btnAction == SL_SIMPLE_BUTTON_PRESSED) { button_event.Handler = BaseApplication::ButtonHandler; sAppTask.PostEvent(&button_event); diff --git a/examples/platform/silabs/SiWx917/SiWx917/hal/rsi_hal_mcu_m4.c b/examples/platform/silabs/SiWx917/SiWx917/hal/rsi_hal_mcu_m4.c index 87d998e0e0ddbb..bcedf1c8a52c16 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/hal/rsi_hal_mcu_m4.c +++ b/examples/platform/silabs/SiWx917/SiWx917/hal/rsi_hal_mcu_m4.c @@ -92,9 +92,10 @@ void IRQ021_Handler(void) btn1 = 0; sl_button_on_change(1, 1); } - if (RSI_NPSSGPIO_GetPin(NPSS_GPIO_0)) + if (RSI_NPSSGPIO_GetPin(NPSS_GPIO_0) && (!btn0)) { btn0 = 1; + sl_button_on_change(0, 0); } if (!RSI_NPSSGPIO_GetPin(NPSS_GPIO_0) && btn0) { diff --git a/examples/window-app/silabs/SiWx917/include/WindowAppImpl.h b/examples/window-app/silabs/SiWx917/include/WindowAppImpl.h index efaf194618b3a9..0acb38a4b1de22 100644 --- a/examples/window-app/silabs/SiWx917/include/WindowAppImpl.h +++ b/examples/window-app/silabs/SiWx917/include/WindowAppImpl.h @@ -44,6 +44,7 @@ class WindowAppImpl : public WindowApp { public: static WindowAppImpl sInstance; + bool mWindowAppInit = false; WindowAppImpl(); CHIP_ERROR Init() override; diff --git a/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp b/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp index 4cb033e349a366..694bc918f5bcd0 100644 --- a/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp +++ b/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp @@ -227,6 +227,8 @@ CHIP_ERROR WindowAppImpl::Init() } #endif // QR_CODE_ENABLED + mWindowAppInit = true; + return CHIP_NO_ERROR; } @@ -531,14 +533,30 @@ WindowAppImpl::Button::Button(WindowApp::Button::Id id, const char * name) : Win void WindowAppImpl::OnButtonChange(uint8_t Btn, uint8_t btnAction) { WindowApp::Button * btn = static_cast