Skip to content

Commit d59c111

Browse files
committed
Merge remote-tracking branch 'origin' into fan-control-updates
2 parents 44a7296 + 6ddc6f9 commit d59c111

File tree

43 files changed

+170
-698
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+170
-698
lines changed

examples/chef/efr32/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class AppTask : public BaseApplication
7777
* @param btnAction button action - SL_SIMPLE_BUTTON_PRESSED,
7878
* SL_SIMPLE_BUTTON_RELEASED or SL_SIMPLE_BUTTON_DISABLED
7979
*/
80-
void ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) override;
80+
static void ButtonEventHandler(uint8_t button, uint8_t btnAction) override;
8181

8282
/**
8383
* @brief Callback called by the identify-server when an identify command is received

examples/chef/efr32/src/AppTask.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141

4242
#include <assert.h>
4343

44+
#include <platform/silabs/platformAbstraction/SilabsPlatform.h>
45+
4446
#include <setup_payload/QRCodeSetupPayloadGenerator.h>
4547
#include <setup_payload/SetupPayload.h>
4648

@@ -49,7 +51,7 @@
4951
#include <platform/CHIPDeviceLayer.h>
5052

5153
#define SYSTEM_STATE_LED 0
52-
#define APP_FUNCTION_BUTTON &sl_button_btn0
54+
#define APP_FUNCTION_BUTTON 0
5355

5456
using namespace chip;
5557
using namespace ::chip::DeviceLayer;
@@ -123,6 +125,9 @@ AppTask AppTask::sAppTask;
123125
CHIP_ERROR AppTask::Init()
124126
{
125127
CHIP_ERROR err = CHIP_NO_ERROR;
128+
#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
129+
chip::DeviceLayer::Silabs::GetPlatform().SetButtonsCb(AppTask::ButtonEventHandler);
130+
#endif
126131

127132
err = BaseApplication::Init(&gIdentify);
128133
if (err != CHIP_NO_ERROR)
@@ -164,18 +169,13 @@ void AppTask::AppTaskMain(void * pvParameter)
164169
}
165170
}
166171

167-
void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction)
172+
void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction)
168173
{
169-
if (buttonHandle == NULL)
170-
{
171-
return;
172-
}
173-
174174
AppEvent button_event = {};
175175
button_event.Type = AppEvent::kEventType_Button;
176176
button_event.ButtonEvent.Action = btnAction;
177177

178-
if (buttonHandle == APP_FUNCTION_BUTTON)
178+
if (button == APP_FUNCTION_BUTTON)
179179
{
180180
button_event.Handler = BaseApplication::ButtonHandler;
181181
sAppTask.PostEvent(&button_event);

examples/chef/efr32/src/main.cpp

-84
This file was deleted.

examples/light-switch-app/silabs/SiWx917/BUILD.gn

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ silabs_executable("light_switch_app") {
7373
sources = [
7474
"${chip_root}/examples/light-switch-app/silabs/common/BindingHandler.cpp",
7575
"${chip_root}/examples/light-switch-app/silabs/common/LightSwitchMgr.cpp",
76+
"${examples_common_plat_dir}/main.cpp",
7677
"src/AppTask.cpp",
7778
"src/ZclCallbacks.cpp",
78-
"src/main.cpp",
7979
]
8080

8181
deps = [

examples/light-switch-app/silabs/SiWx917/include/AppConfig.h

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
#define APP_TASK_NAME "Lit"
2525

26+
#define BLE_DEV_NAME "SiLabs-Light-Switch"
27+
2628
// Time it takes in ms for the simulated actuator to move from one
2729
// state to another.
2830
#define ACTUATOR_MOVEMENT_PERIOS_MS 10

examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252

5353
#include <app/clusters/identify-server/identify-server.h>
5454

55+
#include <platform/silabs/platformAbstraction/SilabsPlatform.h>
56+
5557
/**********************************************************
5658
* Defines and Constants
5759
*********************************************************/
@@ -152,6 +154,9 @@ AppTask AppTask::sAppTask;
152154
CHIP_ERROR AppTask::Init()
153155
{
154156
CHIP_ERROR err = CHIP_NO_ERROR;
157+
158+
chip::DeviceLayer::Silabs::GetPlatform().SetButtonsCb(AppTask::ButtonEventHandler);
159+
155160
#ifdef DISPLAY_ENABLED
156161
GetLCD().Init((uint8_t *) "Light Switch");
157162
#endif

examples/light-switch-app/silabs/SiWx917/src/main.cpp

-87
This file was deleted.

examples/light-switch-app/silabs/efr32/BUILD.gn

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ silabs_executable("light_switch_app") {
9191
sources = [
9292
"${chip_root}/examples/light-switch-app/silabs/common/BindingHandler.cpp",
9393
"${chip_root}/examples/light-switch-app/silabs/common/LightSwitchMgr.cpp",
94+
"${examples_common_plat_dir}/main.cpp",
9495
"src/AppTask.cpp",
9596
"src/ZclCallbacks.cpp",
96-
"src/main.cpp",
9797
]
9898

9999
deps = [

examples/light-switch-app/silabs/efr32/include/AppConfig.h

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
#define APP_TASK_NAME "Lit"
2525

26+
#define BLE_DEV_NAME "SiLabs-Light-Switch"
27+
2628
// Time it takes in ms for the simulated actuator to move from one
2729
// state to another.
2830
#define ACTUATOR_MOVEMENT_PERIOS_MS 10

examples/light-switch-app/silabs/efr32/include/AppTask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class AppTask : public BaseApplication
7777
* @param btnAction button action - SL_SIMPLE_BUTTON_PRESSED,
7878
* SL_SIMPLE_BUTTON_RELEASED or SL_SIMPLE_BUTTON_DISABLED
7979
*/
80-
void ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction) override;
80+
static void ButtonEventHandler(uint8_t button, uint8_t btnAction);
8181

8282
/**
8383
* @brief Callback called by the identify-server when an identify command is received

examples/light-switch-app/silabs/efr32/src/AppTask.cpp

+11-7
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,16 @@
4848

4949
#include <app/clusters/identify-server/identify-server.h>
5050

51+
#include <platform/silabs/platformAbstraction/SilabsPlatform.h>
52+
5153
/**********************************************************
5254
* Defines and Constants
5355
*********************************************************/
5456

5557
#define SYSTEM_STATE_LED &sl_led_led0
5658

57-
#define APP_FUNCTION_BUTTON &sl_button_btn0
58-
#define APP_LIGHT_SWITCH &sl_button_btn1
59+
#define APP_FUNCTION_BUTTON 0
60+
#define APP_LIGHT_SWITCH 1
5961

6062
namespace {
6163

@@ -151,6 +153,10 @@ AppTask AppTask::sAppTask;
151153
CHIP_ERROR AppTask::Init()
152154
{
153155
CHIP_ERROR err = CHIP_NO_ERROR;
156+
#ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT
157+
chip::DeviceLayer::Silabs::GetPlatform().SetButtonsCb(AppTask::ButtonEventHandler);
158+
#endif
159+
154160
#ifdef DISPLAY_ENABLED
155161
GetLCD().Init((uint8_t *) "Light Switch");
156162
#endif
@@ -248,20 +254,18 @@ void AppTask::SwitchActionEventHandler(AppEvent * aEvent)
248254
}
249255
}
250256

251-
void AppTask::ButtonEventHandler(const sl_button_t * buttonHandle, uint8_t btnAction)
257+
void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction)
252258
{
253-
VerifyOrReturn(buttonHandle != NULL);
254-
255259
AppEvent button_event = {};
256260
button_event.Type = AppEvent::kEventType_Button;
257261
button_event.ButtonEvent.Action = btnAction;
258262

259-
if (buttonHandle == APP_LIGHT_SWITCH)
263+
if (button == APP_LIGHT_SWITCH)
260264
{
261265
button_event.Handler = SwitchActionEventHandler;
262266
sAppTask.PostEvent(&button_event);
263267
}
264-
else if (buttonHandle == APP_FUNCTION_BUTTON)
268+
else if (button == APP_FUNCTION_BUTTON)
265269
{
266270
button_event.Handler = BaseApplication::ButtonHandler;
267271
sAppTask.PostEvent(&button_event);

0 commit comments

Comments
 (0)