Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yunhanw-google committed Jan 31, 2022
1 parent 9f5be31 commit 0d52ab6
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/app/ReadClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ CHIP_ERROR ReadClient::ProcessAttributeReportIBs(TLV::TLVReader & aAttributeRepo
TLV::TLVReader reader = aAttributeReportIBsReader;
ReturnErrorOnFailure(report.Init(reader));

DataVersion version = 0;
DataVersion version = kUndefinedDataVersion;
err = report.GetAttributeStatus(&status);
if (CHIP_NO_ERROR == err)
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/TestAttributeCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void DataSeriesGenerator::Generate()
System::PacketBufferTLVReader reader;
ReadClient::Callback * callback = mReadCallback;
StatusIB status;
DataVersion version = 0;
DataVersion version = kUndefinedDataVersion;
callback->OnReportBegin();

uint8_t index = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/TestBufferedReadCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void DataSeriesGenerator::Generate()
ReadClient::Callback * callback = &mReadCallback;
StatusIB status;
bool hasData;
DataVersion version = 0;
DataVersion version = kUndefinedDataVersion;

callback->OnReportBegin();

Expand Down
2 changes: 1 addition & 1 deletion src/app/tests/TestMessageDef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ void ParseAttributeDataIB(nlTestSuite * apSuite, AttributeDataIB::Parser & aAttr
{
CHIP_ERROR err = CHIP_NO_ERROR;
AttributePathIB::Parser attributePathParser;
chip::DataVersion version = 0;
chip::DataVersion version = chip::kUndefinedDataVersion;
#if CHIP_CONFIG_IM_ENABLE_SCHEMA_CHECK
err = aAttributeDataIBParser.CheckSchemaValidity();
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);
Expand Down
7 changes: 3 additions & 4 deletions src/app/util/ember-compatibility-functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ namespace chip {
namespace app {
namespace Compatibility {
namespace {
constexpr uint32_t kTemporaryDataVersion = 0;
// On some apps, ATTRIBUTE_LARGEST can as small as 3, making compiler unhappy since data[kAttributeReadBufferSize] cannot hold
// uint64_t. Make kAttributeReadBufferSize at least 8 so it can fit all basic types.
constexpr size_t kAttributeReadBufferSize = (ATTRIBUTE_LARGEST >= 8 ? ATTRIBUTE_LARGEST : 8);
Expand Down Expand Up @@ -361,8 +360,8 @@ CHIP_ERROR ReadViaAccessInterface(FabricIndex aAccessingFabricIndex, bool aIsFab
{
AttributeValueEncoder::AttributeEncodeState state =
(aEncoderState == nullptr ? AttributeValueEncoder::AttributeEncodeState() : *aEncoderState);
DataVersion version = kTemporaryDataVersion;
ReadClusterDataVersion(aPath.mEndpointId, aPath.mClusterId, version);
DataVersion version = kUndefinedDataVersion;
ReturnErrorOnFailure(ReadClusterDataVersion(aPath.mEndpointId, aPath.mClusterId, version));
AttributeValueEncoder valueEncoder(aAttributeReports, aAccessingFabricIndex, aPath, version, aIsFabricFiltered, state);
CHIP_ERROR err = aAccessInterface->Read(aPath, valueEncoder);

Expand Down Expand Up @@ -461,7 +460,7 @@ CHIP_ERROR ReadSingleClusterData(const SubjectDescriptor & aSubjectDescriptor, b
AttributeDataIB::Builder & attributeDataIBBuilder = attributeReport.CreateAttributeData();
ReturnErrorOnFailure(attributeDataIBBuilder.GetError());

DataVersion version = kTemporaryDataVersion;
DataVersion version = kUndefinedDataVersion;
ReturnErrorOnFailure(ReadClusterDataVersion(aPath.mEndpointId, aPath.mClusterId, version));
attributeDataIBBuilder.DataVersion(version);
ReturnErrorOnFailure(attributeDataIBBuilder.GetError());
Expand Down
14 changes: 7 additions & 7 deletions src/controller/python/chip/clusters/Attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class AttributeCache:
attributeCache: Dict[int, List[Cluster]] = field(
default_factory=lambda: {})

def UpdateTLV(self, path: AttributePath, version: int, data: Union[bytes, ValueDecodeFailure]):
def UpdateTLV(self, path: AttributePath, dataVersion: int, data: Union[bytes, ValueDecodeFailure]):
''' Store data in TLV since that makes it easiest to eventually convert to either the
cluster or attribute view representations (see below in UpdateCachedData).
'''
Expand Down Expand Up @@ -539,7 +539,7 @@ def SetClientObjPointers(self, pReadClient, pReadCallback):
def GetAllEventValues(self):
return self._events

def _handleAttributeData(self, path: AttributePathWithListIndex, version: int, status: int, data: bytes):
def _handleAttributeData(self, path: AttributePathWithListIndex, dataVersion: int, status: int, data: bytes):
try:
imStatus = status
try:
Expand All @@ -554,14 +554,14 @@ def _handleAttributeData(self, path: AttributePathWithListIndex, version: int, s
tlvData = chip.tlv.TLVReader(data).get().get("Any", {})
attributeValue = tlvData

self._cache.UpdateTLV(path, version, attributeValue)
self._cache.UpdateTLV(path, dataVersion, attributeValue)
self._changedPathSet.add(path)

except Exception as ex:
logging.exception(ex)

def handleAttributeData(self, path: AttributePath, version: int, status: int, data: bytes):
self._handleAttributeData(path, version, status, data)
def handleAttributeData(self, path: AttributePath, dataVersion: int, status: int, data: bytes):
self._handleAttributeData(path, dataVersion, status, data)

def _handleEventData(self, header: EventHeader, path: EventPath, data: bytes):
try:
Expand Down Expand Up @@ -702,10 +702,10 @@ def handleDone(self):


@_OnReadAttributeDataCallbackFunct
def _OnReadAttributeDataCallback(closure, version: int, endpoint: int, cluster: int, attribute: int, status, data, len):
def _OnReadAttributeDataCallback(closure, dataVersion: int, endpoint: int, cluster: int, attribute: int, status, data, len):
dataBytes = ctypes.string_at(data, len)
closure.handleAttributeData(AttributePath(
EndpointId=endpoint, ClusterId=cluster, AttributeId=attribute), version, status, dataBytes[:])
EndpointId=endpoint, ClusterId=cluster, AttributeId=attribute), dataVersion, status, dataBytes[:])


@_OnReadEventDataCallbackFunct
Expand Down
2 changes: 1 addition & 1 deletion src/lib/core/DataModelTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ constexpr FabricIndex kUndefinedFabricIndex = 0;
constexpr EndpointId kInvalidEndpointId = 0xFFFF;
constexpr EndpointId kRootEndpointId = 0;
constexpr ListIndex kInvalidListIndex = 0xFFFF; // List index is a uint16 thus 0xFFFF is a invalid list index.

constexpr DataVersion kUndefinedDataVersion = 0;
// These are MEIs, 0xFFFF is not a valid manufacturer code,
// thus 0xFFFF'FFFF is not a valid MEI.
static constexpr ClusterId kInvalidClusterId = 0xFFFF'FFFF;
Expand Down

0 comments on commit 0d52ab6

Please sign in to comment.