diff --git a/examples/lock-app/silabs/src/LockManager.cpp b/examples/lock-app/silabs/src/LockManager.cpp index 1a4fd934631707..6f5aba9147f6b2 100644 --- a/examples/lock-app/silabs/src/LockManager.cpp +++ b/examples/lock-app/silabs/src/LockManager.cpp @@ -264,9 +264,11 @@ void LockManager::UnlockAfterUnlatch() bool succes = false; if (mUnlatchContext.mEndpointId != kInvalidEndpointId) { - succes = setLockState( - mUnlatchContext.mEndpointId, mUnlatchContext.mFabricIdx, mUnlatchContext.mNodeId, DlLockState::kUnlocked, - MakeOptional(chip::ByteSpan(mUnlatchContext.mPinBuffer, mUnlatchContext.mPinLength)), mUnlatchContext.mErr); + Optional pin = (mUnlatchContext.mPinLength) + ? MakeOptional(chip::ByteSpan(mUnlatchContext.mPinBuffer, mUnlatchContext.mPinLength)) + : Optional::Missing(); + succes = setLockState(mUnlatchContext.mEndpointId, mUnlatchContext.mFabricIdx, mUnlatchContext.mNodeId, + DlLockState::kUnlocked, pin, mUnlatchContext.mErr); } if (!succes)