Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Silabs] WiFi factory reset support for window-app 917SoC #26066

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/silabs/SiWx917/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/silabs/SiWx917/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class WindowAppImpl : public WindowApp
{
public:
static WindowAppImpl sInstance;
bool mWindowAppInit = false;

WindowAppImpl();
CHIP_ERROR Init() override;
Expand Down
26 changes: 22 additions & 4 deletions examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ CHIP_ERROR WindowAppImpl::Init()
}
#endif // QR_CODE_ENABLED

mWindowAppInit = true;

return CHIP_NO_ERROR;
}

Expand Down Expand Up @@ -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<Button *>((Btn == SIWx917_BTN0) ? sInstance.mButtonUp : sInstance.mButtonDown);
btn->Press();
// since sl_button_on_change is being called only with button press, calling Release() without condition
btn->Release();
if (Btn == SIWx917_BTN1)
{
btn->Press();
btn->Release();
}
else
{
if (btnAction)
{
btn->Press();
}
else
{
btn->Release();
}
}
}

// Silabs button callback from button event ISR
void sl_button_on_change(uint8_t btn, uint8_t btnAction)
{
WindowAppImpl * app = static_cast<WindowAppImpl *>(&WindowAppImpl::sInstance);
app->OnButtonChange(btn, btnAction);
if (app->mWindowAppInit)
{
app->OnButtonChange(btn, btnAction);
}
}