forked from nrfconnect/ncs-matter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_task.cpp
More file actions
447 lines (392 loc) · 17.8 KB
/
Copy pathapp_task.cpp
File metadata and controls
447 lines (392 loc) · 17.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
#include "app_task.h"
#include "app/matter_init.h"
#include "app/task_executor.h"
#include "board/board.h"
#include "clusters/identify.h"
#include "lib/core/CHIPError.h"
#include "lib/support/CodeUtils.h"
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerHandler.h>
#include <app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.h>
#include <setup_payload/OnboardingCodesUtil.h>
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);
using namespace ::chip;
using namespace ::chip::app;
using namespace ::chip::app::Clusters;
using namespace ::chip::DeviceLayer;
namespace
{
constexpr uint32_t kExpressedStateLedEvenBlinkMs = 300;
constexpr uint32_t kExpressedStateLedOddBlink1Ms = 300;
constexpr uint32_t kExpressedStateLedOddBlink2Ms = 700;
constexpr uint32_t kSelfTestDurationMs = 5000;
constexpr uint32_t kSelfTestLedUpdateTimeMs = 200;
static std::array<Clusters::SmokeCoAlarm::ExpressedStateEnum, SmokeCoAlarmServer::kPriorityOrderLength>
sPriorityOrder = { Clusters::SmokeCoAlarm::ExpressedStateEnum::kSmokeAlarm,
Clusters::SmokeCoAlarm::ExpressedStateEnum::kCOAlarm,
Clusters::SmokeCoAlarm::ExpressedStateEnum::kHardwareFault,
Clusters::SmokeCoAlarm::ExpressedStateEnum::kTesting,
Clusters::SmokeCoAlarm::ExpressedStateEnum::kEndOfService,
Clusters::SmokeCoAlarm::ExpressedStateEnum::kBatteryAlert,
Clusters::SmokeCoAlarm::ExpressedStateEnum::kInterconnectSmoke,
Clusters::SmokeCoAlarm::ExpressedStateEnum::kInterconnectCO };
constexpr chip::EndpointId kWiredPowerSourceEndpointId = 0;
constexpr chip::EndpointId kBatteryPowerSourceEndpointId = 1;
Nrf::Matter::IdentifyCluster sIdentifyCluster(AppTask::kSmokeCoAlarmEndpointId);
class SmokeCoAlarmDelegateImpl final : public chip::app::Clusters::SmokeCoAlarmDelegate {
public:
void OnSelfTestRequested() override { AppTask::Instance().SelfTestHandler(); }
};
SmokeCoAlarmDelegateImpl sSmokeCoAlarmDelegate;
#ifdef CONFIG_CHIP_ICD_UAT_SUPPORT
#define UAT_BUTTON_MASK DK_BTN3_MSK
#endif
} /* namespace */
void AppTask::ButtonEventHandler(Nrf::ButtonState state, Nrf::ButtonMask hasChanged)
{
#ifdef CONFIG_CHIP_ICD_UAT_SUPPORT
if ((UAT_BUTTON_MASK & state & hasChanged)) {
LOG_INF("ICD UserActiveMode has been triggered.");
Server::GetInstance().GetICDManager().OnNetworkActivity();
}
#endif
}
void AppTask::UpdatedExpressedLedState()
{
Clusters::SmokeCoAlarm::ExpressedStateEnum state;
SmokeCoAlarmServer::Instance().GetExpressedState(AppTask::kSmokeCoAlarmEndpointId, state);
if (mCurrentState == state) {
return;
}
mCurrentState = state;
k_timer_stop(&mSelfTestLedTimer);
switch (state) {
case Clusters::SmokeCoAlarm::ExpressedStateEnum::kNormal:
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED2).Set(false);
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED3).Set(false);
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED4).Set(false);
break;
case Clusters::SmokeCoAlarm::ExpressedStateEnum::kSmokeAlarm:
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED2).Blink(kExpressedStateLedEvenBlinkMs);
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED3).Set(false);
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED4).Set(false);
break;
case Clusters::SmokeCoAlarm::ExpressedStateEnum::kCOAlarm:
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED2).Set(false);
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED3).Blink(kExpressedStateLedEvenBlinkMs);
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED4).Set(false);
break;
case Clusters::SmokeCoAlarm::ExpressedStateEnum::kBatteryAlert:
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED2).Set(false);
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED3).Set(false);
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED4).Blink(kExpressedStateLedEvenBlinkMs);
break;
case Clusters::SmokeCoAlarm::ExpressedStateEnum::kTesting:
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED2).Set(false);
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED3).Set(false);
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED4).Set(false);
k_timer_start(&mSelfTestLedTimer, K_MSEC(kSelfTestLedUpdateTimeMs), K_NO_WAIT);
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED2).Set(true);
break;
case Clusters::SmokeCoAlarm::ExpressedStateEnum::kHardwareFault:
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED2).Set(false);
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED3).Set(false);
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED4).Set(false);
Nrf::GetBoard()
.GetLED(Nrf::DeviceLeds::LED2)
.Blink(kExpressedStateLedOddBlink1Ms, kExpressedStateLedOddBlink2Ms);
Nrf::GetBoard()
.GetLED(Nrf::DeviceLeds::LED3)
.Blink(kExpressedStateLedOddBlink1Ms, kExpressedStateLedOddBlink2Ms);
Nrf::GetBoard()
.GetLED(Nrf::DeviceLeds::LED4)
.Blink(kExpressedStateLedOddBlink1Ms, kExpressedStateLedOddBlink2Ms);
break;
case Clusters::SmokeCoAlarm::ExpressedStateEnum::kEndOfService:
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED2).Set(false);
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED3).Set(false);
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED4).Set(false);
Nrf::GetBoard()
.GetLED(Nrf::DeviceLeds::LED2)
.Blink(kExpressedStateLedOddBlink2Ms, kExpressedStateLedOddBlink1Ms);
Nrf::GetBoard()
.GetLED(Nrf::DeviceLeds::LED3)
.Blink(kExpressedStateLedOddBlink2Ms, kExpressedStateLedOddBlink1Ms);
Nrf::GetBoard()
.GetLED(Nrf::DeviceLeds::LED4)
.Blink(kExpressedStateLedOddBlink2Ms, kExpressedStateLedOddBlink1Ms);
break;
case Clusters::SmokeCoAlarm::ExpressedStateEnum::kInterconnectSmoke:
case Clusters::SmokeCoAlarm::ExpressedStateEnum::kInterconnectCO:
case Clusters::SmokeCoAlarm::ExpressedStateEnum::kUnknownEnumValue:
default:
break;
}
}
bool HandleSmokeCOTestEventTrigger(uint64_t eventTrigger)
{
SmokeCOTrigger trigger = static_cast<SmokeCOTrigger>(eventTrigger);
switch (trigger) {
case SmokeCOTrigger::kForceSmokeCritical:
LOG_INF("Triggered smoke alarm with critical severity");
VerifyOrReturnValue(
SmokeCoAlarmServer::Instance().SetSmokeState(AppTask::kSmokeCoAlarmEndpointId,
Clusters::SmokeCoAlarm::AlarmStateEnum::kCritical),
false);
SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(AppTask::kSmokeCoAlarmEndpointId,
sPriorityOrder);
break;
case SmokeCOTrigger::kForceCOCritical:
LOG_INF("Triggered CO alarm with critical severity");
VerifyOrReturnValue(
SmokeCoAlarmServer::Instance().SetCOState(AppTask::kSmokeCoAlarmEndpointId,
Clusters::SmokeCoAlarm::AlarmStateEnum::kCritical),
false);
SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(AppTask::kSmokeCoAlarmEndpointId,
sPriorityOrder);
break;
case SmokeCOTrigger::kForceMalfunction:
LOG_INF("Triggered hardware fault alert");
SmokeCoAlarmServer::Instance().SetHardwareFaultAlert(AppTask::kSmokeCoAlarmEndpointId, true);
SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(AppTask::kSmokeCoAlarmEndpointId, sPriorityOrder);
break;
case SmokeCOTrigger::kForceLowBatteryCritical:
LOG_INF("Triggered low battery alert with critical severity");
SmokeCoAlarmServer::Instance().SetBatteryAlert(
AppTask::kSmokeCoAlarmEndpointId, Clusters::SmokeCoAlarm::AlarmStateEnum::kCritical);
SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(AppTask::kSmokeCoAlarmEndpointId, sPriorityOrder);
break;
case SmokeCOTrigger::kForceEndOfLife:
LOG_INF("Triggered end of service alert");
SmokeCoAlarmServer::Instance().SetEndOfServiceAlert(
AppTask::kSmokeCoAlarmEndpointId, Clusters::SmokeCoAlarm::EndOfServiceEnum::kExpired);
SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(AppTask::kSmokeCoAlarmEndpointId, sPriorityOrder);
break;
case SmokeCOTrigger::kClearSmoke:
LOG_INF("Triggered end of smoke alarm action");
VerifyOrReturnValue(
SmokeCoAlarmServer::Instance().SetSmokeState(AppTask::kSmokeCoAlarmEndpointId,
Clusters::SmokeCoAlarm::AlarmStateEnum::kNormal),
false);
SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(AppTask::kSmokeCoAlarmEndpointId,
sPriorityOrder);
break;
case SmokeCOTrigger::kClearCO:
LOG_INF("Triggered end of CO alarm action");
VerifyOrReturnValue(
SmokeCoAlarmServer::Instance().SetCOState(AppTask::kSmokeCoAlarmEndpointId,
Clusters::SmokeCoAlarm::AlarmStateEnum::kNormal),
false);
SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(AppTask::kSmokeCoAlarmEndpointId,
sPriorityOrder);
break;
case SmokeCOTrigger::kClearMalfunction:
LOG_INF("Triggered end of hardware fault alert action");
SmokeCoAlarmServer::Instance().SetHardwareFaultAlert(AppTask::kSmokeCoAlarmEndpointId, false);
SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(AppTask::kSmokeCoAlarmEndpointId, sPriorityOrder);
break;
case SmokeCOTrigger::kClearEndOfLife:
LOG_INF("Triggered end of end of service alert action");
SmokeCoAlarmServer::Instance().SetEndOfServiceAlert(
AppTask::kSmokeCoAlarmEndpointId, Clusters::SmokeCoAlarm::EndOfServiceEnum::kNormal);
SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(AppTask::kSmokeCoAlarmEndpointId, sPriorityOrder);
break;
case SmokeCOTrigger::kClearBatteryLevelLow:
LOG_INF("Triggered end of low battery level alert action");
SmokeCoAlarmServer::Instance().SetBatteryAlert(
AppTask::kSmokeCoAlarmEndpointId, Clusters::SmokeCoAlarm::AlarmStateEnum::kNormal);
SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(AppTask::kSmokeCoAlarmEndpointId, sPriorityOrder);
break;
case SmokeCOTrigger::kForceSmokeWarning:
LOG_WRN("Triggered unsupported smoke alarm with warning severity");
return false;
case SmokeCOTrigger::kForceSmokeInterconnect:
LOG_WRN("Triggered unsupported smoke interconnect alarm");
return false;
case SmokeCOTrigger::kForceCOWarning:
LOG_WRN("Triggered unsupported CO alarm with warning severity");
return false;
case SmokeCOTrigger::kForceCOInterconnect:
LOG_WRN("Triggered unsupported CO interconnect alarm");
return false;
case SmokeCOTrigger::kForceSmokeContaminationHigh:
LOG_WRN("Triggered unsupported high smoke contamination alarm");
return false;
case SmokeCOTrigger::kForceSmokeContaminationLow:
LOG_WRN("Triggered unsupported low smoke contamination alarm");
return false;
case SmokeCOTrigger::kForceSmokeSensitivityHigh:
LOG_WRN("Triggered unsupported high smoke sensitivity alarm");
return false;
case SmokeCOTrigger::kForceSmokeSensitivityLow:
LOG_WRN("Triggered unsupported low smoke sensitivity alarm");
return false;
case SmokeCOTrigger::kForceLowBatteryWarning:
LOG_WRN("Triggered unsupported low battery alert with warning severity");
return false;
case SmokeCOTrigger::kForceSilence:
LOG_WRN("Triggered unsupported alarm mute action");
return false;
case SmokeCOTrigger::kClearSmokeInterconnect:
LOG_WRN("Triggered unsupported end of smoke interconnect alarm action");
return false;
case SmokeCOTrigger::kClearCOInterconnect:
LOG_WRN("Triggered unsupported end of CO interconnect alarm action");
return false;
case SmokeCOTrigger::kClearSilence:
LOG_WRN("Triggered unsupported unmute action");
return false;
case SmokeCOTrigger::kClearContamination:
LOG_WRN("Triggered unsupported end of smoke contamination alert action");
return false;
case SmokeCOTrigger::kClearSensitivity:
LOG_WRN("Triggered unsupported end of smoke sensitivity alert action");
return false;
default:
return false;
}
AppTask::Instance().UpdatedExpressedLedState();
return true;
}
void AppTask::SelfTestTimerTimeoutCallback(k_timer *timer)
{
Nrf::PostTask([] { EndSelfTestEventHandler(); });
}
void AppTask::EndSelfTestEventHandler()
{
LOG_INF("Alarm self test action end");
SmokeCoAlarmServer::Instance().SetTestInProgress(kSmokeCoAlarmEndpointId, false);
SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(kSmokeCoAlarmEndpointId, sPriorityOrder);
Instance().UpdatedExpressedLedState();
}
void AppTask::SelfTestLedTimerTimeoutCallback(k_timer *timer)
{
Nrf::PostTask([] { SelfTestLedTimerEventHandler(); });
}
void AppTask::SelfTestLedTimerEventHandler()
{
if (Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED2).GetState()) {
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED2).Set(false);
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED3).Set(true);
} else if (Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED3).GetState()) {
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED3).Set(false);
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED4).Set(true);
} else if (Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED4).GetState()) {
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED4).Set(false);
Nrf::GetBoard().GetLED(Nrf::DeviceLeds::LED2).Set(true);
}
k_timer_start(&Instance().mSelfTestLedTimer, K_MSEC(kSelfTestLedUpdateTimeMs), K_NO_WAIT);
}
#ifdef CONFIG_MATTER_TEST_EVENT_TRIGGERS
CHIP_ERROR AppTask::PowerSourceOnEventCallback(Nrf::Matter::TestEventTrigger::TriggerValue endpointId)
{
if (endpointId == kWiredPowerSourceEndpointId || endpointId == kBatteryPowerSourceEndpointId) {
LOG_INF("Event Trigger: Power Source on endpoint id %d activated.", endpointId);
} else {
LOG_ERR("Event Trigger: Power Source On triggered on invalid endpoint id %d", endpointId);
return CHIP_ERROR_INVALID_ARGUMENT;
}
/* Wired power source is treated as primary one. */
if (endpointId == kWiredPowerSourceEndpointId) {
Clusters::PowerSource::Attributes::Status::Set(kWiredPowerSourceEndpointId,
Clusters::PowerSource::PowerSourceStatusEnum::kActive);
Clusters::PowerSource::PowerSourceStatusEnum status;
Clusters::PowerSource::Attributes::Status::Get(kBatteryPowerSourceEndpointId, &status);
/* If battery power source was active, change its state to standby. */
if (status == Clusters::PowerSource::PowerSourceStatusEnum::kActive) {
Clusters::PowerSource::Attributes::Status::Set(
kBatteryPowerSourceEndpointId, Clusters::PowerSource::PowerSourceStatusEnum::kStandby);
}
} else {
Clusters::PowerSource::PowerSourceStatusEnum status;
Clusters::PowerSource::Attributes::Status::Get(kWiredPowerSourceEndpointId, &status);
/* If wired power source is active, change put requested power source into standby state to standby. */
if (status == Clusters::PowerSource::PowerSourceStatusEnum::kActive) {
Clusters::PowerSource::Attributes::Status::Set(
kBatteryPowerSourceEndpointId, Clusters::PowerSource::PowerSourceStatusEnum::kStandby);
} else {
Clusters::PowerSource::Attributes::Status::Set(
kBatteryPowerSourceEndpointId, Clusters::PowerSource::PowerSourceStatusEnum::kActive);
}
}
return CHIP_NO_ERROR;
}
CHIP_ERROR AppTask::PowerSourceOffEventCallback(Nrf::Matter::TestEventTrigger::TriggerValue endpointId)
{
if (endpointId == kWiredPowerSourceEndpointId || endpointId == kBatteryPowerSourceEndpointId) {
LOG_INF("Event Trigger: Power Source on endpoint id %d deactivated.", endpointId);
} else {
LOG_ERR("Event Trigger: Power Source Off triggered on invalid endpoint id %d", endpointId);
return CHIP_ERROR_INVALID_ARGUMENT;
}
/* Wired power source is treated as primary one. */
if (endpointId == kWiredPowerSourceEndpointId) {
Clusters::PowerSource::Attributes::Status::Set(
kWiredPowerSourceEndpointId, Clusters::PowerSource::PowerSourceStatusEnum::kUnavailable);
Clusters::PowerSource::PowerSourceStatusEnum status;
Clusters::PowerSource::Attributes::Status::Get(kBatteryPowerSourceEndpointId, &status);
/* If battery power source was standby, change its state to active. */
if (status == Clusters::PowerSource::PowerSourceStatusEnum::kStandby) {
Clusters::PowerSource::Attributes::Status::Set(
kBatteryPowerSourceEndpointId, Clusters::PowerSource::PowerSourceStatusEnum::kActive);
}
} else {
Clusters::PowerSource::Attributes::Status::Set(
kBatteryPowerSourceEndpointId, Clusters::PowerSource::PowerSourceStatusEnum::kUnavailable);
}
return CHIP_NO_ERROR;
}
#endif
CHIP_ERROR AppTask::Init()
{
/* Initialize Matter stack */
ReturnErrorOnFailure(Nrf::Matter::PrepareServer());
if (!Nrf::GetBoard().Init(ButtonEventHandler)) {
LOG_ERR("User interface initialization failed.");
return CHIP_ERROR_INCORRECT_STATE;
}
k_timer_init(&mSelfTestLedTimer, &SelfTestLedTimerTimeoutCallback, nullptr);
k_timer_init(&mSelfTestTimer, &SelfTestTimerTimeoutCallback, nullptr);
SmokeCoAlarmCluster::Config smokeCoAlarmConfig;
smokeCoAlarmConfig.featureMap.Set(SmokeCoAlarm::Feature::kSmokeAlarm).Set(SmokeCoAlarm::Feature::kCoAlarm);
ReturnErrorOnFailure(
SmokeCoAlarmServer::Instance().Init(kSmokeCoAlarmEndpointId, smokeCoAlarmConfig, &sSmokeCoAlarmDelegate));
/* Register Matter event handler that controls the connectivity status LED based on the captured Matter network
* state. */
ReturnErrorOnFailure(Nrf::Matter::RegisterEventHandler(Nrf::Board::DefaultMatterEventHandler, 0));
/* Register Smoke CO Alarm test event triggers */
#ifdef CONFIG_MATTER_TEST_EVENT_TRIGGERS
/* Register Smoke CO alarm test events handler */
static chip::SmokeCOTestEventTriggerHandler sSmokeCoAlarmTestEventTrigger;
ReturnErrorOnFailure(Nrf::Matter::TestEventTrigger::Instance().RegisterTestEventTriggerHandler(
&sSmokeCoAlarmTestEventTrigger));
/* Register test event handler to change the power source. */
ReturnErrorOnFailure(Nrf::Matter::TestEventTrigger::Instance().RegisterTestEventTrigger(
kPowerSourceOnEventTriggerId,
Nrf::Matter::TestEventTrigger::EventTrigger{ 0xFFFF, PowerSourceOnEventCallback }));
ReturnErrorOnFailure(Nrf::Matter::TestEventTrigger::Instance().RegisterTestEventTrigger(
kPowerSourceOffEventTriggerId,
Nrf::Matter::TestEventTrigger::EventTrigger{ 0xFFFF, PowerSourceOffEventCallback }));
#endif
return Nrf::Matter::StartServer();
}
CHIP_ERROR AppTask::StartApp()
{
ReturnErrorOnFailure(Init());
while (true) {
Nrf::DispatchNextTask();
}
return CHIP_NO_ERROR;
}
void AppTask::SelfTestHandler()
{
LOG_INF("Triggered alarm self test action");
k_timer_start(&Instance().mSelfTestTimer, K_MSEC(kSelfTestDurationMs), K_NO_WAIT);
UpdatedExpressedLedState();
}