-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server side event support #12059
Server side event support #12059
Changes from all commits
f35b6aa
649ef9f
52bde92
c26b2da
6708064
97e6b22
1c5fd13
da37a47
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* | ||
* Copyright (c) 2021 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 <app/ConcreteEventPath.h> | ||
#include <app/EventLoggingDelegate.h> | ||
#include <app/data-model/Encode.h> | ||
#include <app/data-model/List.h> // So we can encode lists | ||
|
||
namespace chip { | ||
namespace app { | ||
|
||
template <typename T> | ||
class EventLogger : EventLoggingDelegate | ||
{ | ||
public: | ||
EventLogger(const T & aEventData) : mEventData(aEventData){}; | ||
CHIP_ERROR WriteEvent(chip::TLV::TLVWriter & aWriter) final override { return mEventData.Encode(aWriter, TLV::AnonymousTag); } | ||
|
||
private: | ||
const T & mEventData; | ||
}; | ||
|
||
template <typename T> | ||
CHIP_ERROR LogEvent(const T & aEventData, EndpointId aEndpoint, EventOptions aEventOptions, EventNumber & aEventNumber) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. aEventNumber needs documentation. Is this an outparam? And in/out param? What purpose does it serve? When would it be used, outside of our test command? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. EventNumber is outParam, Yes, we need to consolidate around EventOption, remove EventSchema, and put ConcreteEventPath as a member inside EventOption There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
My point is that this should be documented, not in a github comment. |
||
{ | ||
EventLogger<T> eventData(aEventData); | ||
ConcreteEventPath path(aEndpoint, aEventData.GetClusterId(), aEventData.GetEventId()); | ||
// log the actual event | ||
aEventNumber = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall the eventNumber be an monotonically increasing ephemeral unique number? |
||
return CHIP_NO_ERROR; | ||
} | ||
|
||
} // namespace app | ||
} // namespace chip |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ | |
#include <app/AttributeAccessInterface.h> | ||
#include <app/CommandHandler.h> | ||
#include <app/ConcreteCommandPath.h> | ||
#include <app/EventLogging.h> | ||
#include <app/util/attribute-storage.h> | ||
#include <lib/core/CHIPSafeCasts.h> | ||
#include <lib/core/CHIPTLV.h> | ||
|
@@ -353,9 +354,26 @@ bool emberAfTestClusterClusterTestListStructArgumentRequestCallback( | |
|
||
return SendBooleanResponse(commandObj, commandPath, shouldReturnTrue); | ||
} | ||
bool emberAfTestClusterClusterTestEmitTestEventRequestCallback( | ||
CommandHandler * commandObj, const ConcreteCommandPath & commandPath, | ||
const Commands::TestEmitTestEventRequest::DecodableType & commandData) | ||
{ | ||
Commands::TestEmitTestEventResponse::Type responseData; | ||
DataModel::List<const Structs::SimpleStruct::Type> arg5; | ||
DataModel::List<const SimpleEnum> arg6; | ||
Comment on lines
+362
to
+363
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not pass these in the command payload? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd recommend using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That was the original pattern I was shooting for, but the interface to go from DecodableType to Type proved to be marginally more complicated, so I mocked up something temporary. Will fix. |
||
EventOptions eventOptions; | ||
Events::TestEvent::Type event{ commandData.arg1, commandData.arg2, commandData.arg3, commandData.arg4, arg5, arg6 }; | ||
if (CHIP_NO_ERROR != LogEvent(event, commandPath.mEndpointId, eventOptions, responseData.value)) | ||
{ | ||
emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); | ||
return true; | ||
} | ||
commandObj->AddResponseData(commandPath, responseData); | ||
return true; | ||
} | ||
|
||
bool emberAfTestClusterClusterTestListInt8UArgumentRequestCallback( | ||
app::CommandHandler * commandObj, app::ConcreteCommandPath const & commandPath, | ||
CommandHandler * commandObj, ConcreteCommandPath const & commandPath, | ||
Commands::TestListInt8UArgumentRequest::DecodableType const & commandData) | ||
{ | ||
bool shouldReturnTrue = true; | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to decide whether we're doing the
EventSchema
thing (which would mean endpoint, etc is included in the EventOptions) or whether we are getting the cluster and event id from the data type and passing in the endpoint like this.Seems to me that EventSchema should just go away.
That said event priority is not statically deducible from the data type, so we will need to pass that in, via either the EventOptions or some other mechanism.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed.
I'd rather we consolidate around
EventOptions
, removeEventSchema
(schema is poor term for it anyways) and consequently, removempEventSchema
fromEventOptions
.