Skip to content

Commit

Permalink
Omit write-only attributes in wildcard processing (#22686)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
mrjerryjohns authored and pull[bot] committed Jul 19, 2023
1 parent b407518 commit 2733986
Show file tree
Hide file tree
Showing 23 changed files with 415 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3708,6 +3708,7 @@ server cluster TestCluster = 4294048773 {
attribute nullable int8s nullableRangeRestrictedInt8s = 16423;
attribute nullable int16u nullableRangeRestrictedInt16u = 16424;
attribute nullable int16s nullableRangeRestrictedInt16s = 16425;
attribute int8u writeOnlyInt8u = 16426;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;

Expand Down Expand Up @@ -4772,6 +4773,7 @@ endpoint 1 {
ram attribute nullableRangeRestrictedInt8s default = -20;
ram attribute nullableRangeRestrictedInt16u default = 200;
ram attribute nullableRangeRestrictedInt16s default = -100;
callback attribute writeOnlyInt8u;
ram attribute featureMap;
ram attribute clusterRevision default = 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20700,6 +20700,22 @@
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "write_only_int8u",
"code": 16426,
"mfgCode": null,
"side": "server",
"type": "int8u",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "AttributeList",
"code": 65531,
Expand Down Expand Up @@ -24724,5 +24740,6 @@
"endpointVersion": 1,
"deviceIdentifier": 61442
}
]
],
"log": []
}
3 changes: 3 additions & 0 deletions src/app/clusters/test-cluster-server/test-cluster-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ CHIP_ERROR TestAttrAccess::Read(const ConcreteReadAttributePath & aPath, Attribu
case ClusterErrorBoolean::Id: {
return StatusIB(Protocols::InteractionModel::Status::Failure, 17).ToChipError();
}
case WriteOnlyInt8u::Id: {
return StatusIB(Protocols::InteractionModel::Status::UnsupportedRead).ToChipError();
}
default: {
break;
}
Expand Down
9 changes: 9 additions & 0 deletions src/app/util/ember-compatibility-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,15 @@ CHIP_ERROR ReadViaAccessInterface(FabricIndex aAccessingFabricIndex, bool aIsFab
AttributeValueEncoder valueEncoder(aAttributeReports, aAccessingFabricIndex, aPath, version, aIsFabricFiltered, state);
CHIP_ERROR err = aAccessInterface->Read(aPath, valueEncoder);

if (err == CHIP_IM_GLOBAL_STATUS(UnsupportedRead) && aPath.mExpanded)
{
//
// Set this to true to ensure our caller will return immediately without proceeding further.
//
*aTriedEncode = true;
return CHIP_NO_ERROR;
}

if (err != CHIP_NO_ERROR)
{
// If the err is not CHIP_NO_ERROR, means the encoding was aborted, then the valueEncoder may save its state.
Expand Down
2 changes: 2 additions & 0 deletions src/app/zap-templates/zcl/data-model/chip/test-cluster.xml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ limitations under the License.
<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>
<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>

<attribute side="server" code="0x402A" define="WRITE_ONLY_INT8U" type="INT8U" writable="true" default="0" optional="true">write_only_int8u</attribute>

<!-- This attribute should not be enabled on the server side -->
<attribute side="server" code="0x00FF" define="UNSUPPORTED" type="BOOLEAN" writable="true" optional="true">unsupported</attribute>

Expand Down
18 changes: 18 additions & 0 deletions src/controller/python/chip/clusters/Objects.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/controller/python/test/test_scripts/cluster_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ async def TestCommandWithResponse(cls, devCtrl):
if res.returnValue != 5:
raise ValueError()

@classmethod
@base.test_case
async def TestReadWriteOnlyAttribute(cls, devCtrl):
logger.info("Test wildcard read of attributes containing write-only attribute")
res = await devCtrl.ReadAttribute(nodeid=NODE_ID, attributes=[(Clusters.TestCluster)])
if Clusters.TestCluster.Attributes.WriteOnlyInt8u in res[1][Clusters.TestCluster]:
raise AssertionError("Received un-expected WriteOnlyInt8u attribute in TestCluster")

@classmethod
@base.test_case
async def TestWriteRequest(cls, devCtrl):
Expand Down Expand Up @@ -560,6 +568,7 @@ def eventPathPossibilities():
async def RunTest(cls, devCtrl):
try:
cls.TestAPI()
await cls.TestReadWriteOnlyAttribute(devCtrl)
await cls.TestCommandRoundTrip(devCtrl)
await cls.TestCommandRoundTripWithBadEndpoint(devCtrl)
await cls.TestCommandWithResponse(devCtrl)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

100 changes: 100 additions & 0 deletions src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/darwin/Framework/CHIP/zap-generated/MTRClusters.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2733986

Please sign in to comment.