Skip to content

Commit

Permalink
Refresh IM attribute encoding for attributeData and attribute report …
Browse files Browse the repository at this point in the history
…and corresponding read/write logic (#11514)

* Refresh IM attribute encoding for attributeData and attribute report and corresponding read/write logic

* run codegen
  • Loading branch information
yunhanw-google authored and pull[bot] committed Apr 22, 2022
1 parent 57de77f commit 8239697
Show file tree
Hide file tree
Showing 66 changed files with 3,387 additions and 3,548 deletions.
5 changes: 3 additions & 2 deletions src/app/AttributeAccessInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#pragma once

#include <app/ConcreteAttributePath.h>
#include <app/MessageDef/AttributeDataElement.h>
#include <app/MessageDef/AttributeDataIB.h>
#include <app/data-model/Encode.h>
#include <app/data-model/List.h> // So we can encode lists
#include <app/data-model/TagBoundEncoder.h>
Expand All @@ -44,7 +44,8 @@ class AttributeValueEncoder : protected TagBoundEncoder
{
public:
AttributeValueEncoder(TLV::TLVWriter * aWriter, FabricIndex aAccessingFabricIndex) :
TagBoundEncoder(aWriter, TLV::ContextTag(AttributeDataElement::kCsTag_Data)), mAccessingFabricIndex(aAccessingFabricIndex)
TagBoundEncoder(aWriter, TLV::ContextTag(to_underlying(AttributeDataIB::Tag::kData))),
mAccessingFabricIndex(aAccessingFabricIndex)
{}

template <typename... Ts>
Expand Down
2 changes: 1 addition & 1 deletion src/app/AttributePathParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ CHIP_ERROR AttributePathParams::BuildAttributePath(AttributePathIB::Builder & aB

if (!HasWildcardAttributeId())
{
aBuilder.Attribute(mFieldId);
aBuilder.Attribute(mAttributeId);
}

if (!HasWildcardListIndex())
Expand Down
18 changes: 9 additions & 9 deletions src/app/AttributePathParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ struct AttributePathParams
AttributePathParams(aEndpointId, aClusterId, ClusterInfo::kInvalidAttributeId, ClusterInfo::kInvalidListIndex)
{}

AttributePathParams(EndpointId aEndpointId, ClusterId aClusterId, AttributeId aFieldId) :
AttributePathParams(aEndpointId, aClusterId, aFieldId, ClusterInfo::kInvalidListIndex)
AttributePathParams(EndpointId aEndpointId, ClusterId aClusterId, AttributeId aAttributeId) :
AttributePathParams(aEndpointId, aClusterId, aAttributeId, ClusterInfo::kInvalidListIndex)
{}

AttributePathParams(EndpointId aEndpointId, ClusterId aClusterId, AttributeId aFieldId, ListIndex aListIndex) :
mEndpointId(aEndpointId), mClusterId(aClusterId), mFieldId(aFieldId), mListIndex(aListIndex)
AttributePathParams(EndpointId aEndpointId, ClusterId aClusterId, AttributeId aAttributeId, ListIndex aListIndex) :
mEndpointId(aEndpointId), mClusterId(aClusterId), mAttributeId(aAttributeId), mListIndex(aListIndex)
{}

AttributePathParams() {}
Expand All @@ -60,13 +60,13 @@ struct AttributePathParams

inline bool HasWildcardEndpointId() const { return mEndpointId == ClusterInfo::kInvalidEndpointId; }
inline bool HasWildcardClusterId() const { return mClusterId == ClusterInfo::kInvalidClusterId; }
inline bool HasWildcardAttributeId() const { return mFieldId == ClusterInfo::kInvalidAttributeId; }
inline bool HasWildcardAttributeId() const { return mAttributeId == ClusterInfo::kInvalidAttributeId; }
inline bool HasWildcardListIndex() const { return mListIndex == ClusterInfo::kInvalidListIndex; }

EndpointId mEndpointId = ClusterInfo::kInvalidEndpointId;
ClusterId mClusterId = ClusterInfo::kInvalidClusterId;
AttributeId mFieldId = ClusterInfo::kInvalidAttributeId;
ListIndex mListIndex = ClusterInfo::kInvalidListIndex;
EndpointId mEndpointId = ClusterInfo::kInvalidEndpointId;
ClusterId mClusterId = ClusterInfo::kInvalidClusterId;
AttributeId mAttributeId = ClusterInfo::kInvalidAttributeId;
ListIndex mListIndex = ClusterInfo::kInvalidListIndex;
};
} // namespace app
} // namespace chip
16 changes: 10 additions & 6 deletions src/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,20 @@ static_library("app") {
"InteractionModelEngine.cpp",
"MessageDef/ArrayBuilder.cpp",
"MessageDef/ArrayParser.cpp",
"MessageDef/AttributeDataElement.cpp",
"MessageDef/AttributeDataElement.h",
"MessageDef/AttributeDataList.cpp",
"MessageDef/AttributeDataList.h",
"MessageDef/AttributeDataIB.cpp",
"MessageDef/AttributeDataIB.h",
"MessageDef/AttributeDataIBs.cpp",
"MessageDef/AttributeDataIBs.h",
"MessageDef/AttributeDataVersionList.cpp",
"MessageDef/AttributeDataVersionList.h",
"MessageDef/AttributePathIB.cpp",
"MessageDef/AttributePathIB.h",
"MessageDef/AttributePaths.cpp",
"MessageDef/AttributePaths.h",
"MessageDef/AttributePathIBs.cpp",
"MessageDef/AttributePathIBs.h",
"MessageDef/AttributeReportIB.cpp",
"MessageDef/AttributeReportIB.h",
"MessageDef/AttributeReportIBs.cpp",
"MessageDef/AttributeReportIBs.h",
"MessageDef/AttributeStatusIB.cpp",
"MessageDef/AttributeStatusIB.h",
"MessageDef/AttributeStatuses.cpp",
Expand Down
18 changes: 9 additions & 9 deletions src/app/ClusterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ struct ClusterInfo
{
VerifyOrReturnError(HasWildcardEndpointId() || mEndpointId == other.mEndpointId, false);
VerifyOrReturnError(HasWildcardClusterId() || mClusterId == other.mClusterId, false);
VerifyOrReturnError(HasWildcardAttributeId() || mFieldId == other.mFieldId, false);
VerifyOrReturnError(HasWildcardAttributeId() || mAttributeId == other.mAttributeId, false);
VerifyOrReturnError(HasWildcardListIndex() || mListIndex == other.mListIndex, false);

return true;
Expand All @@ -70,7 +70,7 @@ struct ClusterInfo
inline bool HasWildcardNodeId() const { return mNodeId == kUndefinedNodeId; }
inline bool HasWildcardEndpointId() const { return mEndpointId == kInvalidEndpointId; }
inline bool HasWildcardClusterId() const { return mClusterId == kInvalidClusterId; }
inline bool HasWildcardAttributeId() const { return mFieldId == kInvalidAttributeId; }
inline bool HasWildcardAttributeId() const { return mAttributeId == kInvalidAttributeId; }
inline bool HasWildcardListIndex() const { return mListIndex == kInvalidListIndex; }
inline bool HasWildcardEventId() const { return mEventId == kInvalidEventId; }

Expand All @@ -81,13 +81,13 @@ struct ClusterInfo
* Changing order to something more natural (e.g. endpoint id before cluster id) will result
* in extra memory alignment padding.
*/
NodeId mNodeId = kUndefinedNodeId; // uint64
ClusterInfo * mpNext = nullptr; // pointer width (32/64 bits)
ClusterId mClusterId = kInvalidClusterId; // uint32
AttributeId mFieldId = kInvalidAttributeId; // uint32
EventId mEventId = kInvalidEventId; // uint32
ListIndex mListIndex = kInvalidListIndex; // uint16
EndpointId mEndpointId = kInvalidEndpointId; // uint16
NodeId mNodeId = kUndefinedNodeId; // uint64
ClusterInfo * mpNext = nullptr; // pointer width (32/64 bits)
ClusterId mClusterId = kInvalidClusterId; // uint32
AttributeId mAttributeId = kInvalidAttributeId; // uint32
EventId mEventId = kInvalidEventId; // uint32
ListIndex mListIndex = kInvalidListIndex; // uint16
EndpointId mEndpointId = kInvalidEndpointId; // uint16
};
} // namespace app
} // namespace chip
2 changes: 1 addition & 1 deletion src/app/CommandSender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ CHIP_ERROR CommandSender::ProcessInvokeResponseIB(InvokeResponseIB::Parser & aIn
if (CHIP_NO_ERROR == err)
{
CommandPathIB::Parser commandPath;
commandStatus.GetPath(&commandPath);
ReturnErrorOnFailure(commandStatus.GetPath(&commandPath));
ReturnErrorOnFailure(commandPath.GetClusterId(&clusterId));
ReturnErrorOnFailure(commandPath.GetCommandId(&commandId));
ReturnErrorOnFailure(commandPath.GetEndpointId(&endpointId));
Expand Down
4 changes: 2 additions & 2 deletions src/app/InteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,8 @@ bool InteractionModelEngine::MergeOverlappedAttributePath(ClusterInfo * apAttrib
}
if (aAttributePath.IsAttributePathSupersetOf(*runner))
{
runner->mListIndex = aAttributePath.mListIndex;
runner->mFieldId = aAttributePath.mFieldId;
runner->mListIndex = aAttributePath.mListIndex;
runner->mAttributeId = aAttributePath.mAttributeId;
return true;
}
runner = runner->mpNext;
Expand Down
17 changes: 7 additions & 10 deletions src/app/InteractionModelEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,26 +255,23 @@ void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPa
bool ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath);

/**
* Fetch attribute value and version info and write to the TLVWriter provided.
* Fetch attribute value and version info and write to the AttributeReport provided.
* When the endpoint / cluster / attribute / event data specified by aClusterInfo does not exist, corresponding interaction model
* error code will be put into the writer, and CHIP_NO_ERROR will be returned and apDataExists will be set to false.
* If the data exists on the server, the data (with tag kCsTag_Data) and the data version (with tag kCsTag_DataVersion) will be put
* into the TLVWriter and apDataExists will be set to true. TLVWriter error will be returned if any error occurred during encoding
* error code will be put into the writer, and CHIP_NO_ERROR will be returned.
* If the data exists on the server, the data (with tag kData) and the data version (with tag kDataVersion) will be put
* into the TLVWriter. TLVWriter error will be returned if any error occurred during encoding
* these values.
* This function is implemented by CHIP as a part of cluster data storage & management.
* The apWriter and apDataExists can be nullptr.
*
* @param[in] aAccessingFabricIndex The accessing fabric index for the read.
* @param[in] aPath The concrete path of the data being read.
* @param[in] apWriter The TLVWriter for holding cluster data. Can be a nullptr if the caller does not care
* the exact value of the attribute.
* @param[out] apDataExists Tell whether the cluster data exist on server. Can be a nullptr if the caller does not care
* whether the data exists.
* @param[in] aAttributeReport The TLV Builder for Cluter attribute builder.
*
* @retval CHIP_NO_ERROR on success
*/
CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const ConcreteAttributePath & aPath, TLV::TLVWriter * apWriter,
bool * apDataExists);
CHIP_ERROR ReadSingleClusterData(FabricIndex aAccessingFabricIndex, const ConcreteAttributePath & aPath,
AttributeReportIB::Builder & aAttributeReport);

/**
* TODO: Document.
Expand Down
Loading

0 comments on commit 8239697

Please sign in to comment.