diff --git a/examples/bridge-app/telink/include/AppEvent.h b/examples/bridge-app/telink/include/AppEvent.h deleted file mode 100644 index f570dfd1e7cdf7..00000000000000 --- a/examples/bridge-app/telink/include/AppEvent.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * - * Copyright (c) 2023 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include - -struct AppEvent; -typedef void (*EventHandler)(AppEvent *); - -class LEDWidget; - -struct AppEvent -{ - enum AppEventTypes - { - kEventType_Button = 0, - kEventType_Timer, - kEventType_UpdateLedState, - kEventType_IdentifyStart, - kEventType_IdentifyStop, - kEventType_Lighting, - }; - - uint16_t Type; - - union - { - struct - { - uint8_t Action; - } ButtonEvent; - struct - { - void * Context; - } TimerEvent; - struct - { - uint8_t Action; - int32_t Actor; - } LightingEvent; - struct - { - LEDWidget * LedWidget; - } UpdateLedStateEvent; - }; - - EventHandler Handler; -}; diff --git a/examples/bridge-app/telink/src/AppTask.cpp b/examples/bridge-app/telink/src/AppTask.cpp index 76a59c4de5e293..e080e40eb5dda9 100644 --- a/examples/bridge-app/telink/src/AppTask.cpp +++ b/examples/bridge-app/telink/src/AppTask.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2023 Project CHIP Authors + * Copyright (c) 2023-2024 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -539,10 +539,10 @@ void AppTask::LightingActionEventHandler(AppEvent * aEvent) Action_t action = INVALID_ACTION; int32_t actor = 0; - if (aEvent->Type == AppEvent::kEventType_Lighting) + if (aEvent->Type == AppEvent::kEventType_DeviceAction) { - action = static_cast(aEvent->LightingEvent.Action); - actor = aEvent->LightingEvent.Actor; + action = static_cast(aEvent->DeviceEvent.Action); + actor = aEvent->DeviceEvent.Actor; } else if (aEvent->Type == AppEvent::kEventType_Button) { diff --git a/examples/contact-sensor-app/telink/src/AppTask.cpp b/examples/contact-sensor-app/telink/src/AppTask.cpp index 8ddb43d7b7f084..aa7b28d0679c9f 100644 --- a/examples/contact-sensor-app/telink/src/AppTask.cpp +++ b/examples/contact-sensor-app/telink/src/AppTask.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2022-2023 Project CHIP Authors + * Copyright (c) 2022-2024 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -67,9 +67,9 @@ void AppTask::OnStateChanged(ContactSensorManager::State aState) void AppTask::PostContactActionRequest(ContactSensorManager::Action aAction) { AppEvent event; - event.Type = AppEvent::kEventType_Contact; - event.ContactEvent.Action = static_cast(aAction); - event.Handler = ContactActionEventHandler; + event.Type = AppEvent::kEventType_DeviceAction; + event.DeviceEvent.Action = static_cast(aAction); + event.Handler = ContactActionEventHandler; sAppTask.PostEvent(&event); } @@ -95,9 +95,9 @@ void AppTask::ContactActionEventHandler(AppEvent * aEvent) ChipLogProgress(NotSpecified, "ContactActionEventHandler"); - if (aEvent->Type == AppEvent::kEventType_Contact) + if (aEvent->Type == AppEvent::kEventType_DeviceAction) { - action = static_cast(aEvent->ContactEvent.Action); + action = static_cast(aEvent->DeviceEvent.Action); } else if (aEvent->Type == AppEvent::kEventType_Button) { diff --git a/examples/contact-sensor-app/telink/src/ContactSensorManager.cpp b/examples/contact-sensor-app/telink/src/ContactSensorManager.cpp index a5822df5f8515e..efb5244db59755 100644 --- a/examples/contact-sensor-app/telink/src/ContactSensorManager.cpp +++ b/examples/contact-sensor-app/telink/src/ContactSensorManager.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2022 Project CHIP Authors + * Copyright (c) 2022-2024 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -54,15 +54,15 @@ bool ContactSensorManager::IsContactClosed() void ContactSensorManager::InitiateAction(Action aAction) { AppEvent event; - event.Type = AppEvent::kEventType_Contact; - event.ContactEvent.Action = static_cast(aAction); - event.Handler = HandleAction; + event.Type = AppEvent::kEventType_DeviceAction; + event.DeviceEvent.Action = static_cast(aAction); + event.Handler = HandleAction; GetAppTask().PostEvent(&event); } void ContactSensorManager::HandleAction(AppEvent * aEvent) { - Action action = static_cast(aEvent->ContactEvent.Action); + Action action = static_cast(aEvent->DeviceEvent.Action); // Change current state based on action: // - if state is closed and action is signal lost, change state to opened // - if state is opened and action is signal detected, change state to closed diff --git a/examples/lighting-app/telink/src/AppTask.cpp b/examples/lighting-app/telink/src/AppTask.cpp index bb4dc4150db2be..f250de450def21 100644 --- a/examples/lighting-app/telink/src/AppTask.cpp +++ b/examples/lighting-app/telink/src/AppTask.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2022-2023 Project CHIP Authors + * Copyright (c) 2022-2024 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -48,7 +48,7 @@ void AppTask::PowerOnFactoryReset(void) { LOG_INF("Lighting App Power On Factory Reset"); AppEvent event; - event.Type = AppEvent::kEventType_Lighting; + event.Type = AppEvent::kEventType_DeviceAction; event.Handler = PowerOnFactoryResetEventHandler; GetAppTask().PostEvent(&event); } @@ -77,7 +77,7 @@ CHIP_ERROR AppTask::Init(void) if (status == Protocols::InteractionModel::Status::Success) { // Set actual state to stored before reboot - SetInitiateAction(storedValue ? ON_ACTION : OFF_ACTION, static_cast(AppEvent::kEventType_Lighting), nullptr); + SetInitiateAction(storedValue ? ON_ACTION : OFF_ACTION, static_cast(AppEvent::kEventType_DeviceAction), nullptr); } return CHIP_NO_ERROR; @@ -88,10 +88,10 @@ void AppTask::LightingActionEventHandler(AppEvent * aEvent) Fixture_Action action = INVALID_ACTION; int32_t actor = 0; - if (aEvent->Type == AppEvent::kEventType_Lighting) + if (aEvent->Type == AppEvent::kEventType_DeviceAction) { - action = static_cast(aEvent->LightingEvent.Action); - actor = aEvent->LightingEvent.Actor; + action = static_cast(aEvent->DeviceEvent.Action); + actor = aEvent->DeviceEvent.Actor; } else if (aEvent->Type == AppEvent::kEventType_Button) { diff --git a/examples/lighting-app/telink/src/ZclCallbacks.cpp b/examples/lighting-app/telink/src/ZclCallbacks.cpp index 75b43f7c39eee1..447edaf8beead8 100644 --- a/examples/lighting-app/telink/src/ZclCallbacks.cpp +++ b/examples/lighting-app/telink/src/ZclCallbacks.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2022 Project CHIP Authors + * Copyright (c) 2022-2024 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -42,14 +42,14 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & { ChipLogDetail(Zcl, "Cluster OnOff: attribute OnOff set to %u", *value); GetAppTask().SetInitiateAction(*value ? AppTask::ON_ACTION : AppTask::OFF_ACTION, - static_cast(AppEvent::kEventType_Lighting), value); + static_cast(AppEvent::kEventType_DeviceAction), value); } else if (clusterId == LevelControl::Id && attributeId == LevelControl::Attributes::CurrentLevel::Id) { if (GetAppTask().IsTurnedOn()) { ChipLogDetail(Zcl, "Cluster LevelControl: attribute CurrentLevel set to %u", *value); - GetAppTask().SetInitiateAction(AppTask::LEVEL_ACTION, static_cast(AppEvent::kEventType_Lighting), value); + GetAppTask().SetInitiateAction(AppTask::LEVEL_ACTION, static_cast(AppEvent::kEventType_DeviceAction), value); } else { @@ -79,7 +79,7 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & } ChipLogDetail(Zcl, "New XY color: %u|%u", xy.x, xy.y); - GetAppTask().SetInitiateAction(AppTask::COLOR_ACTION_XY, static_cast(AppEvent::kEventType_Lighting), + GetAppTask().SetInitiateAction(AppTask::COLOR_ACTION_XY, static_cast(AppEvent::kEventType_DeviceAction), (uint8_t *) &xy); } /* HSV color space */ @@ -101,14 +101,14 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & hsv.s = *value; } ChipLogDetail(Zcl, "New HSV color: hue = %u| saturation = %u", hsv.h, hsv.s); - GetAppTask().SetInitiateAction(AppTask::COLOR_ACTION_HSV, static_cast(AppEvent::kEventType_Lighting), + GetAppTask().SetInitiateAction(AppTask::COLOR_ACTION_HSV, static_cast(AppEvent::kEventType_DeviceAction), (uint8_t *) &hsv); } /* Temperature Mireds color space */ else if (attributeId == ColorControl::Attributes::ColorTemperatureMireds::Id) { ChipLogDetail(Zcl, "New Temperature Mireds color = %u", *(uint16_t *) value); - GetAppTask().SetInitiateAction(AppTask::COLOR_ACTION_CT, static_cast(AppEvent::kEventType_Lighting), value); + GetAppTask().SetInitiateAction(AppTask::COLOR_ACTION_CT, static_cast(AppEvent::kEventType_DeviceAction), value); } else { diff --git a/examples/lock-app/telink/src/AppTask.cpp b/examples/lock-app/telink/src/AppTask.cpp index 46e34db66710e5..540a14f76f64ba 100644 --- a/examples/lock-app/telink/src/AppTask.cpp +++ b/examples/lock-app/telink/src/AppTask.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2023 Project CHIP Authors + * Copyright (c) 2023-2024 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -130,11 +130,11 @@ void AppTask::LockActionEventHandler(AppEvent * aEvent) { case LockManager::kState_NotFulyLocked: case LockManager::kState_LockCompleted: - LockMgr().LockAction(AppEvent::kEventType_Lock, LockManager::UNLOCK_ACTION, LockManager::OperationSource::kButton, + LockMgr().LockAction(AppEvent::kEventType_DeviceAction, LockManager::UNLOCK_ACTION, LockManager::OperationSource::kButton, kExampleEndpointId); break; case LockManager::kState_UnlockCompleted: - LockMgr().LockAction(AppEvent::kEventType_Lock, LockManager::LOCK_ACTION, LockManager::OperationSource::kButton, + LockMgr().LockAction(AppEvent::kEventType_DeviceAction, LockManager::LOCK_ACTION, LockManager::OperationSource::kButton, kExampleEndpointId); break; default: diff --git a/examples/lock-app/telink/src/ZclCallbacks.cpp b/examples/lock-app/telink/src/ZclCallbacks.cpp index 7eaf0b303fd697..555c46f8814489 100644 --- a/examples/lock-app/telink/src/ZclCallbacks.cpp +++ b/examples/lock-app/telink/src/ZclCallbacks.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2023 Project CHIP Authors + * Copyright (c) 2023-2024 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -75,7 +75,7 @@ bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const N { ChipLogProgress(Zcl, "Door Lock App: Lock Command endpoint=%d", endpointId); - return LockMgr().LockAction(AppEvent::kEventType_Lock, LockManager::LOCK_ACTION, LockManager::OperationSource::kRemote, + return LockMgr().LockAction(AppEvent::kEventType_DeviceAction, LockManager::LOCK_ACTION, LockManager::OperationSource::kRemote, endpointId, err, fabricIdx, nodeId, pinCode); } @@ -85,7 +85,7 @@ bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const { ChipLogProgress(Zcl, "Door Lock App: Unlock Command endpoint=%d", endpointId); - return LockMgr().LockAction(AppEvent::kEventType_Lock, LockManager::UNLOCK_ACTION, LockManager::OperationSource::kRemote, + return LockMgr().LockAction(AppEvent::kEventType_DeviceAction, LockManager::UNLOCK_ACTION, LockManager::OperationSource::kRemote, endpointId, err, fabricIdx, nodeId, pinCode); } @@ -96,7 +96,7 @@ bool emberAfPluginDoorLockOnDoorUnboltCommand(chip::EndpointId endpointId, const { ChipLogProgress(Zcl, "Door Lock App: Unbolt Command endpoint=%d", endpointId); - return LockMgr().LockAction(AppEvent::kEventType_Lock, LockManager::UNBOLT_ACTION, LockManager::OperationSource::kRemote, + return LockMgr().LockAction(AppEvent::kEventType_DeviceAction, LockManager::UNBOLT_ACTION, LockManager::OperationSource::kRemote, endpointId, err, fabricIdx, nodeId, pinCode); } @@ -170,5 +170,5 @@ DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t h void emberAfPluginDoorLockOnAutoRelock(chip::EndpointId endpointId) { // Apply the relock state in the application control - LockMgr().LockAction(AppEvent::kEventType_Lock, LockManager::LOCK_ACTION, LockManager::OperationSource::kRemote, endpointId); + LockMgr().LockAction(AppEvent::kEventType_DeviceAction, LockManager::LOCK_ACTION, LockManager::OperationSource::kRemote, endpointId); } diff --git a/examples/platform/telink/common/include/AppEventCommon.h b/examples/platform/telink/common/include/AppEventCommon.h index b9fa40ece20bc5..dea362f24c50a7 100644 --- a/examples/platform/telink/common/include/AppEventCommon.h +++ b/examples/platform/telink/common/include/AppEventCommon.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2022 Project CHIP Authors + * Copyright (c) 2022-2024 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -31,15 +31,9 @@ struct AppEvent { kEventType_Button = 0, kEventType_Timer, - kEventType_UpdateLedState, kEventType_IdentifyStart, kEventType_IdentifyStop, - kEventType_Lighting, - kEventType_Thermostat, - kEventType_Install, - kEventType_Contact, - kEventType_Start, - kEventType_Lock + kEventType_DeviceAction }; uint16_t Type; @@ -58,20 +52,7 @@ struct AppEvent { uint8_t Action; int32_t Actor; - } LightingEvent; - struct - { - uint8_t Action; - } ContactEvent; - struct - { - uint8_t Action; - int32_t Actor; - } StartEvent; - struct - { - LEDWidget * LedWidget; - } UpdateLedStateEvent; + } DeviceEvent; }; EventHandler Handler; diff --git a/examples/pump-app/telink/src/AppTask.cpp b/examples/pump-app/telink/src/AppTask.cpp index a7a360b934cd8f..ba89d33bca3a69 100644 --- a/examples/pump-app/telink/src/AppTask.cpp +++ b/examples/pump-app/telink/src/AppTask.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2023 Project CHIP Authors + * Copyright (c) 2023-2024 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -85,9 +85,9 @@ void AppTask::ActionCompleted(PumpManager::Action_t action, int32_t actor) void AppTask::PostStartActionRequest(int32_t actor, PumpManager::Action_t action) { AppEvent event; - event.Type = AppEvent::kEventType_Start; - event.StartEvent.Actor = actor; - event.StartEvent.Action = action; + event.Type = AppEvent::kEventType_DeviceAction; + event.DeviceEvent.Actor = actor; + event.DeviceEvent.Action = action; event.Handler = StartActionEventHandler; sAppTask.PostEvent(&event); } @@ -97,10 +97,10 @@ void AppTask::StartActionEventHandler(AppEvent * aEvent) PumpManager::Action_t action = PumpManager::INVALID_ACTION; int32_t actor = 0; - if (aEvent->Type == AppEvent::kEventType_Start) + if (aEvent->Type == AppEvent::kEventType_DeviceAction) { - action = static_cast(aEvent->StartEvent.Action); - actor = aEvent->StartEvent.Actor; + action = static_cast(aEvent->DeviceEvent.Action); + actor = aEvent->DeviceEvent.Actor; } else if (aEvent->Type == AppEvent::kEventType_Button) { diff --git a/examples/pump-controller-app/telink/src/AppTask.cpp b/examples/pump-controller-app/telink/src/AppTask.cpp index 681f0fa4fd799e..cab294ecef7563 100644 --- a/examples/pump-controller-app/telink/src/AppTask.cpp +++ b/examples/pump-controller-app/telink/src/AppTask.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2023 Project CHIP Authors + * Copyright (c) 2023-2024 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -47,10 +47,10 @@ void AppTask::StartActionEventHandler(AppEvent * aEvent) PumpManager::Action_t action = PumpManager::INVALID_ACTION; int32_t actor = 0; - if (aEvent->Type == AppEvent::kEventType_Start) + if (aEvent->Type == AppEvent::kEventType_DeviceAction) { - action = static_cast(aEvent->StartEvent.Action); - actor = aEvent->StartEvent.Actor; + action = static_cast(aEvent->DeviceEvent.Action); + actor = aEvent->DeviceEvent.Actor; } else if (aEvent->Type == AppEvent::kEventType_Button) { @@ -103,9 +103,9 @@ void AppTask::ActionCompleted(PumpManager::Action_t action, int32_t actor) void AppTask::PostStartActionRequest(int32_t actor, PumpManager::Action_t action) { AppEvent event; - event.Type = AppEvent::kEventType_Start; - event.StartEvent.Actor = actor; - event.StartEvent.Action = action; + event.Type = AppEvent::kEventType_DeviceAction; + event.DeviceEvent.Actor = actor; + event.DeviceEvent.Action = action; event.Handler = StartActionEventHandler; sAppTask.PostEvent(&event); }