diff --git a/examples/lock-app/silabs/data_model/lock-app.matter b/examples/lock-app/silabs/data_model/lock-app.matter index 512435d998..8a7695c75d 100644 --- a/examples/lock-app/silabs/data_model/lock-app.matter +++ b/examples/lock-app/silabs/data_model/lock-app.matter @@ -3261,7 +3261,7 @@ endpoint 1 { callback attribute generatedCommandList; callback attribute acceptedCommandList; callback attribute attributeList; - ram attribute featureMap default = 0x7DB3; + ram attribute featureMap default = 0x1DB3; ram attribute clusterRevision default = 7; handle command LockDoor; diff --git a/examples/lock-app/silabs/data_model/lock-app.zap b/examples/lock-app/silabs/data_model/lock-app.zap index a10a27ee9a..e3488a663b 100644 --- a/examples/lock-app/silabs/data_model/lock-app.zap +++ b/examples/lock-app/silabs/data_model/lock-app.zap @@ -6188,7 +6188,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x7DB3", + "defaultValue": "0x1DB3", "reportable": 1, "minInterval": 1, "maxInterval": 65534, diff --git a/examples/lock-app/silabs/include/LockManager.h b/examples/lock-app/silabs/include/LockManager.h index 7345782d69..00a4407c34 100644 --- a/examples/lock-app/silabs/include/LockManager.h +++ b/examples/lock-app/silabs/include/LockManager.h @@ -199,10 +199,12 @@ class LockManager private: struct UnlatchContext { + static constexpr uint8_t kMaxPinLength = UINT8_MAX; + uint8_t mPinBuffer[kMaxPinLength]; + uint8_t mPinLength; chip::EndpointId mEndpointId; Nullable mFabricIdx; Nullable mNodeId; - Optional mPin; OperationErrorEnum mErr; void Update(chip::EndpointId endpointId, const Nullable & fabricIdx, @@ -211,8 +213,18 @@ class LockManager mEndpointId = endpointId; mFabricIdx = fabricIdx; mNodeId = nodeId; - mPin = pin; mErr = err; + + if (pin.HasValue()) + { + memcpy(mPinBuffer, pin.Value().data(), pin.Value().size()); + mPinLength = static_cast(pin.Value().size()); + } + else + { + memset(mPinBuffer, 0, kMaxPinLength); + mPinLength = 0; + } } }; UnlatchContext mUnlatchContext; @@ -242,11 +254,7 @@ class LockManager uint8_t mCredentialData[kNumCredentialTypes][kMaxCredentials][kMaxCredentialSize]; CredentialStruct mCredentials[kMaxUsers][kMaxCredentials]; - static LockManager sLock; EFR32DoorLock::LockInitParams::LockParam LockParams; }; -inline LockManager & LockMgr() -{ - return LockManager::sLock; -} +LockManager & LockMgr(); diff --git a/examples/lock-app/silabs/src/LockManager.cpp b/examples/lock-app/silabs/src/LockManager.cpp index 04527e53ac..1a4fd93463 100644 --- a/examples/lock-app/silabs/src/LockManager.cpp +++ b/examples/lock-app/silabs/src/LockManager.cpp @@ -25,11 +25,18 @@ #include #include -LockManager LockManager::sLock; - using namespace ::chip::DeviceLayer::Internal; using namespace EFR32DoorLock::LockInitParams; +namespace { +LockManager sLock; +} // namespace + +LockManager & LockMgr() +{ + return sLock; +} + CHIP_ERROR LockManager::Init(chip::app::DataModel::Nullable state, LockParam lockParam) { @@ -257,8 +264,9 @@ void LockManager::UnlockAfterUnlatch() bool succes = false; if (mUnlatchContext.mEndpointId != kInvalidEndpointId) { - succes = setLockState(mUnlatchContext.mEndpointId, mUnlatchContext.mFabricIdx, mUnlatchContext.mNodeId, - DlLockState::kUnlocked, mUnlatchContext.mPin, mUnlatchContext.mErr); + succes = setLockState( + mUnlatchContext.mEndpointId, mUnlatchContext.mFabricIdx, mUnlatchContext.mNodeId, DlLockState::kUnlocked, + MakeOptional(chip::ByteSpan(mUnlatchContext.mPinBuffer, mUnlatchContext.mPinLength)), mUnlatchContext.mErr); } if (!succes)