Skip to content

Commit 786a01e

Browse files
authored
Omit write-only attributes in wildcard processing (#22686)
* Omit write-only attributes in wildcard processing This omits processing write-only attributes during wildcard processing of Reads/Subscribes. It only achieves this for attributes backed by the AttributeAccessInterface. Specifically, it watches for UnsupportedRead error being returned by AttributeAccessInterface::Read and if so, ignores the error specifically when handling a wildcard-based interaction. Added a Python test that validates that the new WriteOnlyInt8u attribute is not served when doing a wildcard read. * Restyle
1 parent 69551a1 commit 786a01e

File tree

23 files changed

+415
-11
lines changed

23 files changed

+415
-11
lines changed

examples/all-clusters-app/all-clusters-common/all-clusters-app.matter

+2
Original file line numberDiff line numberDiff line change
@@ -3708,6 +3708,7 @@ server cluster TestCluster = 4294048773 {
37083708
attribute nullable int8s nullableRangeRestrictedInt8s = 16423;
37093709
attribute nullable int16u nullableRangeRestrictedInt16u = 16424;
37103710
attribute nullable int16s nullableRangeRestrictedInt16s = 16425;
3711+
attribute int8u writeOnlyInt8u = 16426;
37113712
readonly attribute bitmap32 featureMap = 65532;
37123713
readonly attribute int16u clusterRevision = 65533;
37133714

@@ -4772,6 +4773,7 @@ endpoint 1 {
47724773
ram attribute nullableRangeRestrictedInt8s default = -20;
47734774
ram attribute nullableRangeRestrictedInt16u default = 200;
47744775
ram attribute nullableRangeRestrictedInt16s default = -100;
4776+
callback attribute writeOnlyInt8u;
47754777
ram attribute featureMap;
47764778
ram attribute clusterRevision default = 1;
47774779
}

examples/all-clusters-app/all-clusters-common/all-clusters-app.zap

+18-1
Original file line numberDiff line numberDiff line change
@@ -20700,6 +20700,22 @@
2070020700
"maxInterval": 65534,
2070120701
"reportableChange": 0
2070220702
},
20703+
{
20704+
"name": "write_only_int8u",
20705+
"code": 16426,
20706+
"mfgCode": null,
20707+
"side": "server",
20708+
"type": "int8u",
20709+
"included": 1,
20710+
"storageOption": "External",
20711+
"singleton": 0,
20712+
"bounded": 0,
20713+
"defaultValue": "0",
20714+
"reportable": 1,
20715+
"minInterval": 1,
20716+
"maxInterval": 65534,
20717+
"reportableChange": 0
20718+
},
2070320719
{
2070420720
"name": "AttributeList",
2070520721
"code": 65531,
@@ -24724,5 +24740,6 @@
2472424740
"endpointVersion": 1,
2472524741
"deviceIdentifier": 61442
2472624742
}
24727-
]
24743+
],
24744+
"log": []
2472824745
}

src/app/clusters/test-cluster-server/test-cluster-server.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ CHIP_ERROR TestAttrAccess::Read(const ConcreteReadAttributePath & aPath, Attribu
170170
case ClusterErrorBoolean::Id: {
171171
return StatusIB(Protocols::InteractionModel::Status::Failure, 17).ToChipError();
172172
}
173+
case WriteOnlyInt8u::Id: {
174+
return StatusIB(Protocols::InteractionModel::Status::UnsupportedRead).ToChipError();
175+
}
173176
default: {
174177
break;
175178
}

src/app/util/ember-compatibility-functions.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,15 @@ CHIP_ERROR ReadViaAccessInterface(FabricIndex aAccessingFabricIndex, bool aIsFab
475475
AttributeValueEncoder valueEncoder(aAttributeReports, aAccessingFabricIndex, aPath, version, aIsFabricFiltered, state);
476476
CHIP_ERROR err = aAccessInterface->Read(aPath, valueEncoder);
477477

478+
if (err == CHIP_IM_GLOBAL_STATUS(UnsupportedRead) && aPath.mExpanded)
479+
{
480+
//
481+
// Set this to true to ensure our caller will return immediately without proceeding further.
482+
//
483+
*aTriedEncode = true;
484+
return CHIP_NO_ERROR;
485+
}
486+
478487
if (err != CHIP_NO_ERROR)
479488
{
480489
// If the err is not CHIP_NO_ERROR, means the encoding was aborted, then the valueEncoder may save its state.

src/app/zap-templates/zcl/data-model/chip/test-cluster.xml

+2
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ limitations under the License.
232232
<attribute side="server" code="0x4028" define="NULLABLE_RANGE_RESTRICTED_INT16U" type="int16u" min="100" max="1000" writable="true" isNullable="true" optional="false" default="200">nullable_range_restricted_int16u</attribute>
233233
<attribute side="server" code="0x4029" define="NULLABLE_RANGE_RESTRICTED_INT16S" type="int16s" min="-150" max="200" writable="true" isNullable="true" optional="false" default="-5">nullable_range_restricted_int16s</attribute>
234234

235+
<attribute side="server" code="0x402A" define="WRITE_ONLY_INT8U" type="INT8U" writable="true" default="0" optional="true">write_only_int8u</attribute>
236+
235237
<!-- This attribute should not be enabled on the server side -->
236238
<attribute side="server" code="0x00FF" define="UNSUPPORTED" type="BOOLEAN" writable="true" optional="true">unsupported</attribute>
237239

src/controller/python/chip/clusters/Objects.py

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/controller/python/test/test_scripts/cluster_objects.py

+9
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,14 @@ async def TestCommandWithResponse(cls, devCtrl):
122122
if res.returnValue != 5:
123123
raise ValueError()
124124

125+
@classmethod
126+
@base.test_case
127+
async def TestReadWriteOnlyAttribute(cls, devCtrl):
128+
logger.info("Test wildcard read of attributes containing write-only attribute")
129+
res = await devCtrl.ReadAttribute(nodeid=NODE_ID, attributes=[(Clusters.TestCluster)])
130+
if Clusters.TestCluster.Attributes.WriteOnlyInt8u in res[1][Clusters.TestCluster]:
131+
raise AssertionError("Received un-expected WriteOnlyInt8u attribute in TestCluster")
132+
125133
@classmethod
126134
@base.test_case
127135
async def TestWriteRequest(cls, devCtrl):
@@ -560,6 +568,7 @@ def eventPathPossibilities():
560568
async def RunTest(cls, devCtrl):
561569
try:
562570
cls.TestAPI()
571+
await cls.TestReadWriteOnlyAttribute(devCtrl)
563572
await cls.TestCommandRoundTrip(devCtrl)
564573
await cls.TestCommandRoundTripWithBadEndpoint(devCtrl)
565574
await cls.TestCommandWithResponse(devCtrl)

src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm

+100
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/darwin/Framework/CHIP/zap-generated/MTRClusters.h

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm

+27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)