File tree 2 files changed +25
-31
lines changed
lighting-app/infineon/psoc6/src
lock-app/infineon/psoc6/src
2 files changed +25
-31
lines changed Original file line number Diff line number Diff line change @@ -305,18 +305,18 @@ void AppTask::AppTaskMain(void * pvParameter)
305
305
306
306
void AppTask::LightActionEventHandler (AppEvent * event)
307
307
{
308
- bool initiated = false ;
309
308
LightingManager::Action_t action;
310
- int32_t actor = 0 ;
311
- CHIP_ERROR err = CHIP_NO_ERROR;
309
+ int32_t actor;
312
310
313
- if (event->Type == AppEvent:: kEventType_Light )
311
+ switch (event->Type )
314
312
{
313
+ case AppEvent::kEventType_Light : {
315
314
action = static_cast <LightingManager::Action_t>(event->LightEvent .Action );
316
315
actor = event->LightEvent .Actor ;
316
+ break ;
317
317
}
318
- else if (event-> Type == AppEvent:: kEventType_Button )
319
- {
318
+
319
+ case AppEvent:: kEventType_Button : {
320
320
if (LightMgr ().IsLightOn ())
321
321
{
322
322
action = LightingManager::OFF_ACTION;
@@ -325,21 +325,18 @@ void AppTask::LightActionEventHandler(AppEvent * event)
325
325
{
326
326
action = LightingManager::ON_ACTION;
327
327
}
328
+
328
329
actor = AppEvent::kEventType_Button ;
330
+ break ;
329
331
}
330
- else
331
- {
332
- err = APP_ERROR_UNHANDLED_EVENT ;
332
+
333
+ default :
334
+ return ;
333
335
}
334
336
335
- if (err == CHIP_NO_ERROR )
337
+ if (! LightMgr (). InitiateAction (actor, action) )
336
338
{
337
- initiated = LightMgr ().InitiateAction (actor, action);
338
-
339
- if (!initiated)
340
- {
341
- P6_LOG (" Action is already in progress or active." );
342
- }
339
+ P6_LOG (" Action is already in progress or active." );
343
340
}
344
341
}
345
342
Original file line number Diff line number Diff line change @@ -388,18 +388,18 @@ void AppTask::AppTaskMain(void * pvParameter)
388
388
389
389
void AppTask::LockActionEventHandler (AppEvent * event)
390
390
{
391
- bool initiated = false ;
392
391
LockManager::Action_t action;
393
392
int32_t actor;
394
- CHIP_ERROR err = CHIP_NO_ERROR;
395
393
396
- if (event->Type == AppEvent:: kEventType_Lock )
394
+ switch (event->Type )
397
395
{
396
+ case AppEvent::kEventType_Lock : {
398
397
action = static_cast <LockManager::Action_t>(event->LockEvent .Action );
399
398
actor = event->LockEvent .Actor ;
399
+ break ;
400
400
}
401
- else if (event-> Type == AppEvent:: kEventType_Button )
402
- {
401
+
402
+ case AppEvent:: kEventType_Button : {
403
403
if (LockMgr ().NextState () == true )
404
404
{
405
405
action = LockManager::LOCK_ACTION;
@@ -408,21 +408,18 @@ void AppTask::LockActionEventHandler(AppEvent * event)
408
408
{
409
409
action = LockManager::UNLOCK_ACTION;
410
410
}
411
+
411
412
actor = AppEvent::kEventType_Button ;
413
+ break ;
412
414
}
413
- else
414
- {
415
- err = APP_ERROR_UNHANDLED_EVENT ;
415
+
416
+ default :
417
+ return ;
416
418
}
417
419
418
- if (err == CHIP_NO_ERROR )
420
+ if (! LockMgr (). InitiateAction (actor, action) )
419
421
{
420
- initiated = LockMgr ().InitiateAction (actor, action);
421
-
422
- if (!initiated)
423
- {
424
- P6_LOG (" Action is already in progress or active." );
425
- }
422
+ P6_LOG (" Action is already in progress or active." );
426
423
}
427
424
}
428
425
You can’t perform that action at this time.
0 commit comments