33
33
#endif // QR_CODE_ENABLED
34
34
#endif // DISPLAY_ENABLED
35
35
36
+ #include < app-common/zap-generated/attributes/Accessors.h>
37
+ #include < app-common/zap-generated/ids/Clusters.h>
36
38
#include < app/server/OnboardingCodesUtil.h>
37
39
#include < app/server/Server.h>
38
40
#include < app/util/attribute-storage.h>
39
41
#include < assert.h>
40
42
#include < lib/support/CodeUtils.h>
41
43
#include < platform/CHIPDeviceLayer.h>
44
+ #include < platform/silabs/platformAbstraction/SilabsPlatform.h>
42
45
#include < setup_payload/QRCodeSetupPayloadGenerator.h>
43
46
#include < setup_payload/SetupPayload.h>
44
47
45
- #include < platform/silabs/platformAbstraction/SilabsPlatform.h>
46
-
47
48
/* *********************************************************
48
49
* Defines and Constants
49
50
*********************************************************/
@@ -103,6 +104,8 @@ void AppTask::AppTaskMain(void * pvParameter)
103
104
appError (err);
104
105
}
105
106
107
+ chip::Server::GetInstance ().GetICDManager ().RegisterObserver (&sAppTask );
108
+
106
109
#if !(defined(CHIP_CONFIG_ENABLE_ICD_SERVER) && CHIP_CONFIG_ENABLE_ICD_SERVER)
107
110
sAppTask .StartStatusLEDTimer ();
108
111
#endif
@@ -122,7 +125,28 @@ void AppTask::AppTaskMain(void * pvParameter)
122
125
void AppTask::ApplicationEventHandler (AppEvent * aEvent)
123
126
{
124
127
VerifyOrReturn (aEvent->Type == AppEvent::kEventType_Button );
125
- // TODO - trigger some application event
128
+ VerifyOrReturn (aEvent->ButtonEvent .Action == static_cast <uint8_t >(SilabsPlatform::ButtonAction::ButtonPressed));
129
+
130
+ // Simple Application logic that toggles the BoleanState StateValue attribute.
131
+ // DO NOT COPY for product logic. LIT ICD app is a test app with very simple application logic to enable testing.
132
+ // The goal of the app is just to enable testing of LIT ICD features without impacting product sample apps.
133
+ PlatformMgr ().ScheduleWork ([](intptr_t ) {
134
+ bool state = true ;
135
+
136
+ Protocols::InteractionModel::Status status = chip::app::Clusters::BooleanState::Attributes::StateValue::Get (1 , &state);
137
+ if (status != Protocols::InteractionModel::Status::Success)
138
+ {
139
+ // Failed to read StateValue. Default to true (open state)
140
+ state = true ;
141
+ ChipLogError (NotSpecified, " ERR: reading boolean status value %x" , to_underlying (status));
142
+ }
143
+
144
+ status = chip::app::Clusters::BooleanState::Attributes::StateValue::Set (1 , !state);
145
+ if (status != Protocols::InteractionModel::Status::Success)
146
+ {
147
+ ChipLogError (NotSpecified, " ERR: updating boolean status value %x" , to_underlying (status));
148
+ }
149
+ });
126
150
}
127
151
128
152
void AppTask::ButtonEventHandler (uint8_t button, uint8_t btnAction)
@@ -142,3 +166,15 @@ void AppTask::ButtonEventHandler(uint8_t button, uint8_t btnAction)
142
166
sAppTask .PostEvent (&button_event);
143
167
}
144
168
}
169
+
170
+ // DO NOT COPY for product logic. LIT ICD app is a test app with very simple application logic to enable testing.
171
+ void AppTask::OnEnterActiveMode ()
172
+ {
173
+ sAppTask .GetLCD ().WriteDemoUI (true );
174
+ }
175
+
176
+ // DO NOT COPY for product logic. LIT ICD app is a test app with very simple application logic to enable testing.
177
+ void AppTask::OnEnterIdleMode ()
178
+ {
179
+ sAppTask .GetLCD ().WriteDemoUI (false );
180
+ }
0 commit comments