From 8dc374e20ef4e6e407dcf0d3d55b99eb6978fab9 Mon Sep 17 00:00:00 2001 From: Pankaj Garg Date: Wed, 2 Jun 2021 20:54:05 -0700 Subject: [PATCH] Message counter storage issue temporary fix (#7288) --- src/controller/CHIPDevice.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/controller/CHIPDevice.cpp b/src/controller/CHIPDevice.cpp index a010515c0139ac..6398cd3c1f729d 100644 --- a/src/controller/CHIPDevice.cpp +++ b/src/controller/CHIPDevice.cpp @@ -235,6 +235,14 @@ CHIP_ERROR Device::Deserialize(const SerializedDevice & input) mLocalMessageCounter = Encoding::LittleEndian::HostSwap32(serializable.mLocalMessageCounter); mPeerMessageCounter = Encoding::LittleEndian::HostSwap32(serializable.mPeerMessageCounter); + // TODO - Remove the hack that's incrementing message counter while deserializing device + // This hack was added as a quick workaround for TE3 testing. The commissioning code + // is closing the exchange after the device has already been serialized and persisted to the storage. + // While closing the exchange, the outstanding ack gets sent to the device, thus incrementing + // the local message counter. As the device information was stored prior to sending the ack, it now has + // the old counter value (which is 1 less than the updated counter). + mLocalMessageCounter++; + mCASESessionKeyId = Encoding::LittleEndian::HostSwap16(serializable.mCASESessionKeyId); mDeviceProvisioningComplete = (serializable.mDeviceProvisioningComplete != 0);