Skip to content

Commit f59ec38

Browse files
[Silabs] Bugfix/silabs lock app aliro fix (#36300)
* [SL-UP] 917 static variable retention fix (#79) * [SL-UP] Doorlock featuremap Aliro Removal (#80)
1 parent 79a3224 commit f59ec38

File tree

4 files changed

+29
-13
lines changed

4 files changed

+29
-13
lines changed

examples/lock-app/silabs/data_model/lock-app.matter

+1-1
Original file line numberDiff line numberDiff line change
@@ -3261,7 +3261,7 @@ endpoint 1 {
32613261
callback attribute generatedCommandList;
32623262
callback attribute acceptedCommandList;
32633263
callback attribute attributeList;
3264-
ram attribute featureMap default = 0x7DB3;
3264+
ram attribute featureMap default = 0x1DB3;
32653265
ram attribute clusterRevision default = 7;
32663266

32673267
handle command LockDoor;

examples/lock-app/silabs/data_model/lock-app.zap

+1-1
Original file line numberDiff line numberDiff line change
@@ -6188,7 +6188,7 @@
61886188
"storageOption": "RAM",
61896189
"singleton": 0,
61906190
"bounded": 0,
6191-
"defaultValue": "0x7DB3",
6191+
"defaultValue": "0x1DB3",
61926192
"reportable": 1,
61936193
"minInterval": 1,
61946194
"maxInterval": 65534,

examples/lock-app/silabs/include/LockManager.h

+15-7
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,12 @@ class LockManager
199199
private:
200200
struct UnlatchContext
201201
{
202+
static constexpr uint8_t kMaxPinLength = UINT8_MAX;
203+
uint8_t mPinBuffer[kMaxPinLength];
204+
uint8_t mPinLength;
202205
chip::EndpointId mEndpointId;
203206
Nullable<chip::FabricIndex> mFabricIdx;
204207
Nullable<chip::NodeId> mNodeId;
205-
Optional<chip::ByteSpan> mPin;
206208
OperationErrorEnum mErr;
207209

208210
void Update(chip::EndpointId endpointId, const Nullable<chip::FabricIndex> & fabricIdx,
@@ -211,8 +213,18 @@ class LockManager
211213
mEndpointId = endpointId;
212214
mFabricIdx = fabricIdx;
213215
mNodeId = nodeId;
214-
mPin = pin;
215216
mErr = err;
217+
218+
if (pin.HasValue())
219+
{
220+
memcpy(mPinBuffer, pin.Value().data(), pin.Value().size());
221+
mPinLength = static_cast<uint8_t>(pin.Value().size());
222+
}
223+
else
224+
{
225+
memset(mPinBuffer, 0, kMaxPinLength);
226+
mPinLength = 0;
227+
}
216228
}
217229
};
218230
UnlatchContext mUnlatchContext;
@@ -242,11 +254,7 @@ class LockManager
242254
uint8_t mCredentialData[kNumCredentialTypes][kMaxCredentials][kMaxCredentialSize];
243255
CredentialStruct mCredentials[kMaxUsers][kMaxCredentials];
244256

245-
static LockManager sLock;
246257
EFR32DoorLock::LockInitParams::LockParam LockParams;
247258
};
248259

249-
inline LockManager & LockMgr()
250-
{
251-
return LockManager::sLock;
252-
}
260+
LockManager & LockMgr();

examples/lock-app/silabs/src/LockManager.cpp

+12-4
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,18 @@
2525
#include <cstring>
2626
#include <lib/support/logging/CHIPLogging.h>
2727

28-
LockManager LockManager::sLock;
29-
3028
using namespace ::chip::DeviceLayer::Internal;
3129
using namespace EFR32DoorLock::LockInitParams;
3230

31+
namespace {
32+
LockManager sLock;
33+
} // namespace
34+
35+
LockManager & LockMgr()
36+
{
37+
return sLock;
38+
}
39+
3340
CHIP_ERROR LockManager::Init(chip::app::DataModel::Nullable<chip::app::Clusters::DoorLock::DlLockState> state, LockParam lockParam)
3441
{
3542

@@ -257,8 +264,9 @@ void LockManager::UnlockAfterUnlatch()
257264
bool succes = false;
258265
if (mUnlatchContext.mEndpointId != kInvalidEndpointId)
259266
{
260-
succes = setLockState(mUnlatchContext.mEndpointId, mUnlatchContext.mFabricIdx, mUnlatchContext.mNodeId,
261-
DlLockState::kUnlocked, mUnlatchContext.mPin, mUnlatchContext.mErr);
267+
succes = setLockState(
268+
mUnlatchContext.mEndpointId, mUnlatchContext.mFabricIdx, mUnlatchContext.mNodeId, DlLockState::kUnlocked,
269+
MakeOptional(chip::ByteSpan(mUnlatchContext.mPinBuffer, mUnlatchContext.mPinLength)), mUnlatchContext.mErr);
262270
}
263271

264272
if (!succes)

0 commit comments

Comments
 (0)