Skip to content

Commit

Permalink
[Silabs] Bugfix/silabs lock app aliro fix (#36300)
Browse files Browse the repository at this point in the history
* [SL-UP] 917 static variable retention fix (#79)

* [SL-UP] Doorlock featuremap Aliro Removal (#80)
  • Loading branch information
lpbeliveau-silabs authored Oct 30, 2024
1 parent 79a3224 commit f59ec38
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion examples/lock-app/silabs/data_model/lock-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/silabs/data_model/lock-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -6188,7 +6188,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x7DB3",
"defaultValue": "0x1DB3",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down
22 changes: 15 additions & 7 deletions examples/lock-app/silabs/include/LockManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<chip::FabricIndex> mFabricIdx;
Nullable<chip::NodeId> mNodeId;
Optional<chip::ByteSpan> mPin;
OperationErrorEnum mErr;

void Update(chip::EndpointId endpointId, const Nullable<chip::FabricIndex> & fabricIdx,
Expand All @@ -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<uint8_t>(pin.Value().size());
}
else
{
memset(mPinBuffer, 0, kMaxPinLength);
mPinLength = 0;
}
}
};
UnlatchContext mUnlatchContext;
Expand Down Expand Up @@ -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();
16 changes: 12 additions & 4 deletions examples/lock-app/silabs/src/LockManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,18 @@
#include <cstring>
#include <lib/support/logging/CHIPLogging.h>

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<chip::app::Clusters::DoorLock::DlLockState> state, LockParam lockParam)
{

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f59ec38

Please sign in to comment.