Skip to content
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

Add pre-execution command callback. #20357

Merged
merged 16 commits into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/app/CommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@ CHIP_ERROR CommandHandler::ProcessCommandDataIB(CommandDataIB::Parser & aCommand
{
ChipLogDetail(DataManagement, "Received command for Endpoint=%u Cluster=" ChipLogFormatMEI " Command=" ChipLogFormatMEI,
concretePath.mEndpointId, ChipLogValueMEI(concretePath.mClusterId), ChipLogValueMEI(concretePath.mCommandId));
SuccessOrExit(MatterPreCommandReceivedCallback(concretePath));
SuccessOrExit(MatterPreCommandReceivedCallback(concretePath, GetSubjectDescriptor()));
mpCallback->DispatchCommand(*this, concretePath, commandDataReader);
MatterPostCommandReceivedCallback(concretePath);
MatterPostCommandReceivedCallback(concretePath, GetSubjectDescriptor());
}

exit:
Expand Down Expand Up @@ -432,12 +432,11 @@ CHIP_ERROR CommandHandler::ProcessGroupCommandDataIB(CommandDataIB::Parser & aCo
continue;
}
}

if ((err = MatterPreCommandReceivedCallback(concretePath)) == CHIP_NO_ERROR)
if ((err = MatterPreCommandReceivedCallback(concretePath, GetSubjectDescriptor())) == CHIP_NO_ERROR)
{
TLV::TLVReader dataReader(commandDataReader);
mpCallback->DispatchCommand(*this, concretePath, dataReader);
MatterPostCommandReceivedCallback(concretePath);
MatterPostCommandReceivedCallback(concretePath, GetSubjectDescriptor());
}
else
{
Expand Down Expand Up @@ -675,8 +674,10 @@ void CommandHandler::Abort()
} // namespace app
} // namespace chip

CHIP_ERROR __attribute__((weak)) MatterPreCommandReceivedCallback(const chip::app::ConcreteCommandPath & commandPath)
CHIP_ERROR __attribute__((weak)) MatterPreCommandReceivedCallback(const chip::app::ConcreteCommandPath & commandPath,
const chip::Access::SubjectDescriptor & subjectDescriptor)
{
return CHIP_NO_ERROR;
}
void __attribute__((weak)) MatterPostCommandReceivedCallback(const chip::app::ConcreteCommandPath & commandPath) {}
void __attribute__((weak)) MatterPostCommandReceivedCallback(const chip::app::ConcreteCommandPath & commandPath,
const chip::Access::SubjectDescriptor & subjectDescriptor) {}
6 changes: 4 additions & 2 deletions src/app/util/MatterCallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ void MatterPostAttributeWriteCallback(const chip::app::ConcreteAttributePath & a
* This callback is called once the message has been determined to be a command, and
* before the command is dispatched to the receiver.
*/
CHIP_ERROR MatterPreCommandReceivedCallback(const chip::app::ConcreteCommandPath & commandPath);
CHIP_ERROR MatterPreCommandReceivedCallback(const chip::app::ConcreteCommandPath & commandPath,
const chip::Access::SubjectDescriptor & subjectDescriptor);

/** @brief Matter Post Command Received
*
* This callback is called once the message has been determined to be a command, but
* after it being dispatched to the receiver.
*/
void MatterPostCommandReceivedCallback(const chip::app::ConcreteCommandPath & commandPath);
void MatterPostCommandReceivedCallback(const chip::app::ConcreteCommandPath & commandPath,
const chip::Access::SubjectDescriptor & subjectDescriptor);