Skip to content

Commit 3256265

Browse files
yunhanw-googlepull[bot]
authored andcommitted
Refresh IM attribute encoding for attributeData and attribute report and corresponding read/write logic (#11514)
* Refresh IM attribute encoding for attributeData and attribute report and corresponding read/write logic * run codegen
1 parent 2f4fcc0 commit 3256265

File tree

66 files changed

+3387
-3548
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+3387
-3548
lines changed

src/app/AttributeAccessInterface.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#pragma once
2020

2121
#include <app/ConcreteAttributePath.h>
22-
#include <app/MessageDef/AttributeDataElement.h>
22+
#include <app/MessageDef/AttributeDataIB.h>
2323
#include <app/data-model/Encode.h>
2424
#include <app/data-model/List.h> // So we can encode lists
2525
#include <app/data-model/TagBoundEncoder.h>
@@ -44,7 +44,8 @@ class AttributeValueEncoder : protected TagBoundEncoder
4444
{
4545
public:
4646
AttributeValueEncoder(TLV::TLVWriter * aWriter, FabricIndex aAccessingFabricIndex) :
47-
TagBoundEncoder(aWriter, TLV::ContextTag(AttributeDataElement::kCsTag_Data)), mAccessingFabricIndex(aAccessingFabricIndex)
47+
TagBoundEncoder(aWriter, TLV::ContextTag(to_underlying(AttributeDataIB::Tag::kData))),
48+
mAccessingFabricIndex(aAccessingFabricIndex)
4849
{}
4950

5051
template <typename... Ts>

src/app/AttributePathParams.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ CHIP_ERROR AttributePathParams::BuildAttributePath(AttributePathIB::Builder & aB
3636

3737
if (!HasWildcardAttributeId())
3838
{
39-
aBuilder.Attribute(mFieldId);
39+
aBuilder.Attribute(mAttributeId);
4040
}
4141

4242
if (!HasWildcardListIndex())

src/app/AttributePathParams.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ struct AttributePathParams
3737
AttributePathParams(aEndpointId, aClusterId, ClusterInfo::kInvalidAttributeId, ClusterInfo::kInvalidListIndex)
3838
{}
3939

40-
AttributePathParams(EndpointId aEndpointId, ClusterId aClusterId, AttributeId aFieldId) :
41-
AttributePathParams(aEndpointId, aClusterId, aFieldId, ClusterInfo::kInvalidListIndex)
40+
AttributePathParams(EndpointId aEndpointId, ClusterId aClusterId, AttributeId aAttributeId) :
41+
AttributePathParams(aEndpointId, aClusterId, aAttributeId, ClusterInfo::kInvalidListIndex)
4242
{}
4343

44-
AttributePathParams(EndpointId aEndpointId, ClusterId aClusterId, AttributeId aFieldId, ListIndex aListIndex) :
45-
mEndpointId(aEndpointId), mClusterId(aClusterId), mFieldId(aFieldId), mListIndex(aListIndex)
44+
AttributePathParams(EndpointId aEndpointId, ClusterId aClusterId, AttributeId aAttributeId, ListIndex aListIndex) :
45+
mEndpointId(aEndpointId), mClusterId(aClusterId), mAttributeId(aAttributeId), mListIndex(aListIndex)
4646
{}
4747

4848
AttributePathParams() {}
@@ -60,13 +60,13 @@ struct AttributePathParams
6060

6161
inline bool HasWildcardEndpointId() const { return mEndpointId == ClusterInfo::kInvalidEndpointId; }
6262
inline bool HasWildcardClusterId() const { return mClusterId == ClusterInfo::kInvalidClusterId; }
63-
inline bool HasWildcardAttributeId() const { return mFieldId == ClusterInfo::kInvalidAttributeId; }
63+
inline bool HasWildcardAttributeId() const { return mAttributeId == ClusterInfo::kInvalidAttributeId; }
6464
inline bool HasWildcardListIndex() const { return mListIndex == ClusterInfo::kInvalidListIndex; }
6565

66-
EndpointId mEndpointId = ClusterInfo::kInvalidEndpointId;
67-
ClusterId mClusterId = ClusterInfo::kInvalidClusterId;
68-
AttributeId mFieldId = ClusterInfo::kInvalidAttributeId;
69-
ListIndex mListIndex = ClusterInfo::kInvalidListIndex;
66+
EndpointId mEndpointId = ClusterInfo::kInvalidEndpointId;
67+
ClusterId mClusterId = ClusterInfo::kInvalidClusterId;
68+
AttributeId mAttributeId = ClusterInfo::kInvalidAttributeId;
69+
ListIndex mListIndex = ClusterInfo::kInvalidListIndex;
7070
};
7171
} // namespace app
7272
} // namespace chip

src/app/BUILD.gn

+10-6
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,20 @@ static_library("app") {
4444
"InteractionModelEngine.cpp",
4545
"MessageDef/ArrayBuilder.cpp",
4646
"MessageDef/ArrayParser.cpp",
47-
"MessageDef/AttributeDataElement.cpp",
48-
"MessageDef/AttributeDataElement.h",
49-
"MessageDef/AttributeDataList.cpp",
50-
"MessageDef/AttributeDataList.h",
47+
"MessageDef/AttributeDataIB.cpp",
48+
"MessageDef/AttributeDataIB.h",
49+
"MessageDef/AttributeDataIBs.cpp",
50+
"MessageDef/AttributeDataIBs.h",
5151
"MessageDef/AttributeDataVersionList.cpp",
5252
"MessageDef/AttributeDataVersionList.h",
5353
"MessageDef/AttributePathIB.cpp",
5454
"MessageDef/AttributePathIB.h",
55-
"MessageDef/AttributePaths.cpp",
56-
"MessageDef/AttributePaths.h",
55+
"MessageDef/AttributePathIBs.cpp",
56+
"MessageDef/AttributePathIBs.h",
57+
"MessageDef/AttributeReportIB.cpp",
58+
"MessageDef/AttributeReportIB.h",
59+
"MessageDef/AttributeReportIBs.cpp",
60+
"MessageDef/AttributeReportIBs.h",
5761
"MessageDef/AttributeStatusIB.cpp",
5862
"MessageDef/AttributeStatusIB.h",
5963
"MessageDef/AttributeStatuses.cpp",

src/app/ClusterInfo.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct ClusterInfo
5252
{
5353
VerifyOrReturnError(HasWildcardEndpointId() || mEndpointId == other.mEndpointId, false);
5454
VerifyOrReturnError(HasWildcardClusterId() || mClusterId == other.mClusterId, false);
55-
VerifyOrReturnError(HasWildcardAttributeId() || mFieldId == other.mFieldId, false);
55+
VerifyOrReturnError(HasWildcardAttributeId() || mAttributeId == other.mAttributeId, false);
5656
VerifyOrReturnError(HasWildcardListIndex() || mListIndex == other.mListIndex, false);
5757

5858
return true;
@@ -70,7 +70,7 @@ struct ClusterInfo
7070
inline bool HasWildcardNodeId() const { return mNodeId == kUndefinedNodeId; }
7171
inline bool HasWildcardEndpointId() const { return mEndpointId == kInvalidEndpointId; }
7272
inline bool HasWildcardClusterId() const { return mClusterId == kInvalidClusterId; }
73-
inline bool HasWildcardAttributeId() const { return mFieldId == kInvalidAttributeId; }
73+
inline bool HasWildcardAttributeId() const { return mAttributeId == kInvalidAttributeId; }
7474
inline bool HasWildcardListIndex() const { return mListIndex == kInvalidListIndex; }
7575
inline bool HasWildcardEventId() const { return mEventId == kInvalidEventId; }
7676

@@ -81,13 +81,13 @@ struct ClusterInfo
8181
* Changing order to something more natural (e.g. endpoint id before cluster id) will result
8282
* in extra memory alignment padding.
8383
*/
84-
NodeId mNodeId = kUndefinedNodeId; // uint64
85-
ClusterInfo * mpNext = nullptr; // pointer width (32/64 bits)
86-
ClusterId mClusterId = kInvalidClusterId; // uint32
87-
AttributeId mFieldId = kInvalidAttributeId; // uint32
88-
EventId mEventId = kInvalidEventId; // uint32
89-
ListIndex mListIndex = kInvalidListIndex; // uint16
90-
EndpointId mEndpointId = kInvalidEndpointId; // uint16
84+
NodeId mNodeId = kUndefinedNodeId; // uint64
85+
ClusterInfo * mpNext = nullptr; // pointer width (32/64 bits)
86+
ClusterId mClusterId = kInvalidClusterId; // uint32
87+
AttributeId mAttributeId = kInvalidAttributeId; // uint32
88+
EventId mEventId = kInvalidEventId; // uint32
89+
ListIndex mListIndex = kInvalidListIndex; // uint16
90+
EndpointId mEndpointId = kInvalidEndpointId; // uint16
9191
};
9292
} // namespace app
9393
} // namespace chip

src/app/CommandSender.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ CHIP_ERROR CommandSender::ProcessInvokeResponseIB(InvokeResponseIB::Parser & aIn
198198
if (CHIP_NO_ERROR == err)
199199
{
200200
CommandPathIB::Parser commandPath;
201-
commandStatus.GetPath(&commandPath);
201+
ReturnErrorOnFailure(commandStatus.GetPath(&commandPath));
202202
ReturnErrorOnFailure(commandPath.GetClusterId(&clusterId));
203203
ReturnErrorOnFailure(commandPath.GetCommandId(&commandId));
204204
ReturnErrorOnFailure(commandPath.GetEndpointId(&endpointId));

src/app/InteractionModelEngine.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,8 @@ bool InteractionModelEngine::MergeOverlappedAttributePath(ClusterInfo * apAttrib
516516
}
517517
if (aAttributePath.IsAttributePathSupersetOf(*runner))
518518
{
519-
runner->mListIndex = aAttributePath.mListIndex;
520-
runner->mFieldId = aAttributePath.mFieldId;
519+
runner->mListIndex = aAttributePath.mListIndex;
520+
runner->mAttributeId = aAttributePath.mAttributeId;
521521
return true;
522522
}
523523
runner = runner->mpNext;

src/app/InteractionModelEngine.h

+7-10
Original file line numberDiff line numberDiff line change
@@ -255,26 +255,23 @@ void DispatchSingleClusterResponseCommand(const ConcreteCommandPath & aCommandPa
255255
bool ServerClusterCommandExists(const ConcreteCommandPath & aCommandPath);
256256

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

279276
/**
280277
* TODO: Document.

0 commit comments

Comments
 (0)