From 6b8616719ccec262cf07eba7b2adefefb21533ae Mon Sep 17 00:00:00 2001 From: Yunhan Wang Date: Tue, 7 Dec 2021 21:12:53 -0800 Subject: [PATCH] Improve LogEvent API --- src/app/EventLogging.h | 16 +++++++++------- .../test-cluster-server/test-cluster-server.cpp | 3 +-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/app/EventLogging.h b/src/app/EventLogging.h index 83ce5ebcabe32d..1252496fcffbed 100644 --- a/src/app/EventLogging.h +++ b/src/app/EventLogging.h @@ -54,23 +54,25 @@ class EventLogger : public EventLoggingDelegate * `ClusterID` and `EventId`. * * @param[in] apDelegate The EventLoggingDelegate to serialize the event data - * - * @param[in] aEventOptions The options for the event metadata. - * + * @param[in] aEndpoint The current cluster's Endpoint Id + * @param[in] aUrgent The EventOption Type, kUrgent or kNotUrgent * @param[out] aEventNumber The event Number if the event was written to the * log, 0 otherwise. The Event number is expected to monotonically increase. * * @return CHIP_ERROR CHIP Error Code */ template -CHIP_ERROR LogEvent(const T & aEventData, EndpointId aEndpoint, EventOptions aEventOptions, EventNumber & aEventNumber) +CHIP_ERROR LogEvent(const T & aEventData, EndpointId aEndpoint, EventNumber & aEventNumber, + EventOptions::Type aUrgent = EventOptions::Type::kNotUrgent) { EventLogger eventData(aEventData); ConcreteEventPath path(aEndpoint, aEventData.GetClusterId(), aEventData.GetEventId()); EventManagement & logMgmt = chip::app::EventManagement::GetInstance(); - aEventOptions.mPath = path; - aEventOptions.mPriority = aEventData.GetPriorityLevel(); - return logMgmt.LogEvent(&eventData, aEventOptions, aEventNumber); + EventOptions eventOptions; + eventOptions.mUrgent = aUrgent; + eventOptions.mPath = path; + eventOptions.mPriority = aEventData.GetPriorityLevel(); + return logMgmt.LogEvent(&eventData, eventOptions, aEventNumber); } } // namespace app diff --git a/src/app/clusters/test-cluster-server/test-cluster-server.cpp b/src/app/clusters/test-cluster-server/test-cluster-server.cpp index db20926b429290..3477012589b379 100644 --- a/src/app/clusters/test-cluster-server/test-cluster-server.cpp +++ b/src/app/clusters/test-cluster-server/test-cluster-server.cpp @@ -452,12 +452,11 @@ bool emberAfTestClusterClusterTestEmitTestEventRequestCallback( Structs::SimpleStruct::Type arg4; DataModel::List arg5; DataModel::List arg6; - EventOptions eventOptions; // TODO: Add code to pull arg4, arg5 and arg6 from the arguments of the command Events::TestEvent::Type event{ commandData.arg1, commandData.arg2, commandData.arg3, arg4, arg5, arg6 }; - if (CHIP_NO_ERROR != LogEvent(event, commandPath.mEndpointId, eventOptions, responseData.value)) + if (CHIP_NO_ERROR != LogEvent(event, commandPath.mEndpointId, responseData.value)) { emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); return true;