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

[CI] Add Matter[Pre/Post]CommandReceivedCallback #10500

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
12 changes: 11 additions & 1 deletion src/app/CommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "InteractionModelEngine.h"
#include "messaging/ExchangeContext.h"

#include <app/util/MatterCallbacks.h>
#include <lib/support/TypeTraits.h>
#include <protocols/secure_channel/Constants.h>

Expand Down Expand Up @@ -186,7 +187,10 @@ CHIP_ERROR CommandHandler::ProcessCommandDataIB(CommandDataIB::Parser & aCommand
ChipLogDetail(DataManagement,
"Received command for Endpoint=%" PRIu16 " Cluster=" ChipLogFormatMEI " Command=" ChipLogFormatMEI,
endpointId, ChipLogValueMEI(clusterId), ChipLogValueMEI(commandId));
DispatchSingleClusterCommand(ConcreteCommandPath(endpointId, clusterId, commandId), commandDataReader, this);
const ConcreteCommandPath concretePath(endpointId, clusterId, commandId);
SuccessOrExit(MatterPreCommandReceivedCallback(concretePath));
DispatchSingleClusterCommand(concretePath, commandDataReader, this);
MatterPostCommandReceivedCallback(concretePath);
}

exit:
Expand Down Expand Up @@ -341,3 +345,9 @@ TLV::TLVWriter * CommandHandler::GetCommandDataIBTLVWriter()

} // namespace app
} // namespace chip

CHIP_ERROR __attribute__((weak)) MatterPreCommandReceivedCallback(const chip::app::ConcreteCommandPath & commandPath)
{
return CHIP_NO_ERROR;
}
void __attribute__((weak)) MatterPostCommandReceivedCallback(const chip::app::ConcreteCommandPath & commandPath) {}
13 changes: 12 additions & 1 deletion src/app/WriteHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <app/MessageDef/EventPathIB.h>
#include <app/WriteHandler.h>
#include <app/reporting/Engine.h>
#include <app/util/MatterCallbacks.h>
#include <lib/support/TypeTraits.h>

namespace chip {
Expand Down Expand Up @@ -151,7 +152,14 @@ CHIP_ERROR WriteHandler::ProcessAttributeDataList(TLV::TLVReader & aAttributeDat

err = element.GetData(&dataReader);
SuccessOrExit(err);
err = WriteSingleClusterData(clusterInfo, dataReader, this);

{
const ConcreteAttributePath concretePath =
ConcreteAttributePath(clusterInfo.mEndpointId, clusterInfo.mClusterId, clusterInfo.mFieldId);
MatterPreAttributeWriteCallback(concretePath);
err = WriteSingleClusterData(clusterInfo, dataReader, this);
MatterPostAttributeWriteCallback(concretePath);
}
SuccessOrExit(err);
}

Expand Down Expand Up @@ -286,3 +294,6 @@ void WriteHandler::ClearState()

} // namespace app
} // namespace chip

void __attribute__((weak)) MatterPreAttributeWriteCallback(const chip::app::ConcreteAttributePath & attributePath) {}
void __attribute__((weak)) MatterPostAttributeWriteCallback(const chip::app::ConcreteAttributePath & attributePath) {}
6 changes: 6 additions & 0 deletions src/app/reporting/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <app/AppBuildConfig.h>
#include <app/InteractionModelEngine.h>
#include <app/reporting/Engine.h>
#include <app/util/MatterCallbacks.h>

namespace chip {
namespace app {
Expand Down Expand Up @@ -80,7 +81,9 @@ Engine::RetrieveClusterData(FabricIndex aAccessingFabricIndex, AttributeDataList
ChipLogDetail(DataManagement, "<RE:Run> Cluster %" PRIx32 ", Field %" PRIx32 " is dirty", aClusterInfo.mClusterId,
aClusterInfo.mFieldId);

MatterPreAttributeReadCallback(path);
err = ReadSingleClusterData(aAccessingFabricIndex, path, attributeDataElementBuilder.GetWriter(), nullptr /* data exists */);
MatterPostAttributeReadCallback(path);
SuccessOrExit(err);
attributeDataElementBuilder.MoreClusterData(false);
attributeDataElementBuilder.EndOfAttributeDataElement();
Expand Down Expand Up @@ -459,3 +462,6 @@ void Engine::OnReportConfirm()
}; // namespace reporting
}; // namespace app
}; // namespace chip

void __attribute__((weak)) MatterPreAttributeReadCallback(const chip::app::ConcreteAttributePath & attributePath) {}
void __attribute__((weak)) MatterPostAttributeReadCallback(const chip::app::ConcreteAttributePath & attributePath) {}
39 changes: 39 additions & 0 deletions src/app/util/MatterCallbacks.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
*
* Copyright (c) 2021 Project CHIP Authors
*
* 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.
*/

// THIS FILE IS GENERATED BY ZAP

#pragma once

void MatterPreAttributeReadCallback(const chip::app::ConcreteAttributePath & attributePath);
void MatterPostAttributeReadCallback(const chip::app::ConcreteAttributePath & attributePath);
void MatterPreAttributeWriteCallback(const chip::app::ConcreteAttributePath & attributePath);
void MatterPostAttributeWriteCallback(const chip::app::ConcreteAttributePath & attributePath);

/** @brief Matter Pre Command Received
*
* 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);

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