From 55fcf6a06bb4f738fd6e2ad2f234b343e6abf1ec Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Fri, 2 Jun 2023 16:17:45 +0200 Subject: [PATCH] [chiptool.py] Carry over the data version for attribute reads returned by chip-tool --- examples/chip-tool/commands/common/RemoteDataModelLogger.cpp | 5 +++++ .../matter_chip_tool_adapter/decoder.py | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp b/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp index 45cd4461dae7ab..057d1f2059e05f 100644 --- a/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp +++ b/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp @@ -21,6 +21,7 @@ #include #include +constexpr const char * kDataVersionKey = "dataVersion"; constexpr const char * kClusterIdKey = "clusterId"; constexpr const char * kEndpointIdKey = "endpointId"; constexpr const char * kAttributeIdKey = "attributeId"; @@ -69,6 +70,10 @@ CHIP_ERROR LogAttributeAsJSON(const chip::app::ConcreteDataAttributePath & path, value[kClusterIdKey] = path.mClusterId; value[kEndpointIdKey] = path.mEndpointId; value[kAttributeIdKey] = path.mAttributeId; + if (path.mDataVersion.HasValue()) + { + value[kDataVersionKey] = path.mDataVersion.Value(); + } chip::TLV::TLVReader reader; reader.Init(*data); diff --git a/examples/chip-tool/py_matter_chip_tool_adapter/matter_chip_tool_adapter/decoder.py b/examples/chip-tool/py_matter_chip_tool_adapter/matter_chip_tool_adapter/decoder.py index df906ec318b83e..052e254fe7573a 100644 --- a/examples/chip-tool/py_matter_chip_tool_adapter/matter_chip_tool_adapter/decoder.py +++ b/examples/chip-tool/py_matter_chip_tool_adapter/matter_chip_tool_adapter/decoder.py @@ -34,6 +34,7 @@ _ERROR = 'error' _CLUSTER_ERROR = 'clusterError' _VALUE = 'value' +_DATA_VERSION = 'dataVersion' # FabricIndex is a special case where the field is added as a struct field by the SDK # if needed but is not part of the XML definition of the struct. @@ -88,7 +89,7 @@ def __translate_names(self, payloads): elif key == _EVENT_ID: key = _EVENT value = specs.get_event_name(payload[_CLUSTER_ID], value) - elif key == _VALUE or key == _ERROR or key == _CLUSTER_ERROR: + elif key == _VALUE or key == _ERROR or key == _CLUSTER_ERROR or key == _DATA_VERSION: pass else: # Raise an error since the other fields probably needs to be translated too.