Skip to content

Commit 6cf7ad2

Browse files
authoredOct 31, 2024
Merge branch 'release_2.4-1.4' into bugfix/scan_fix
2 parents fc15c9f + 657da9e commit 6cf7ad2

File tree

9 files changed

+94
-73
lines changed

9 files changed

+94
-73
lines changed
 

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -3275,7 +3275,7 @@ endpoint 1 {
32753275
callback attribute acceptedCommandList;
32763276
callback attribute eventList;
32773277
callback attribute attributeList;
3278-
ram attribute featureMap default = 0x7DB3;
3278+
ram attribute featureMap default = 0x1DB3;
32793279
ram attribute clusterRevision default = 7;
32803280

32813281
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

+10-3
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

@@ -258,7 +265,7 @@ void LockManager::UnlockAfterUnlatch()
258265
if (mUnlatchContext.mEndpointId != kInvalidEndpointId)
259266
{
260267
succes = setLockState(mUnlatchContext.mEndpointId, mUnlatchContext.mFabricIdx, mUnlatchContext.mNodeId,
261-
DlLockState::kUnlocked, mUnlatchContext.mPin, mUnlatchContext.mErr);
268+
DlLockState::kUnlocked, MakeOptional(chip::ByteSpan(mUnlatchContext.mPinBuffer, mUnlatchContext.mPinLength)), mUnlatchContext.mErr);
262269
}
263270

264271
if (!succes)

‎examples/platform/silabs/provision/ProvisionStorageDefault.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -403,14 +403,14 @@ CHIP_ERROR Storage::GetManufacturingDate(uint8_t * value, size_t max, size_t & s
403403
return SilabsConfig::ReadConfigValueStr(SilabsConfig::kConfigKey_ManufacturingDate, (char *) value, max, size);
404404
}
405405

406-
CHIP_ERROR Storage::SetUniqueId(const uint8_t * value, size_t size)
406+
CHIP_ERROR Storage::SetPersistentUniqueId(const uint8_t * value, size_t size)
407407
{
408-
return SilabsConfig::WriteConfigValueBin(SilabsConfig::kConfigKey_UniqueId, value, size);
408+
return SilabsConfig::WriteConfigValueBin(SilabsConfig::kConfigKey_PersistentUniqueId, value, size);
409409
}
410410

411-
CHIP_ERROR Storage::GetUniqueId(uint8_t * value, size_t max, size_t & size)
411+
CHIP_ERROR Storage::GetPersistentUniqueId(uint8_t * value, size_t max, size_t & size)
412412
{
413-
return SilabsConfig::ReadConfigValueBin(SilabsConfig::kConfigKey_UniqueId, value, max, size);
413+
return SilabsConfig::ReadConfigValueBin(SilabsConfig::kConfigKey_PersistentUniqueId, value, max, size);
414414
}
415415

416416
//

‎examples/platform/silabs/provision/ProvisionStorageFlash.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ CHIP_ERROR DecodeTotal(Encoding::Buffer & reader, uint16_t & total)
7878
ReturnErrorOnFailure(reader.Get(sz));
7979
total = (0xffff == sz) ? sizeof(uint16_t) : sz;
8080
reader.in = reader.begin + total;
81-
ReturnErrorCodeIf(reader.in > reader.end, CHIP_ERROR_INTERNAL);
81+
VerifyOrReturnError(reader.in <= reader.end, CHIP_ERROR_INTERNAL);
8282
return CHIP_NO_ERROR;
8383
}
8484

@@ -118,7 +118,7 @@ CHIP_ERROR Set(uint16_t id, Encoding::Buffer & in)
118118
{
119119
// New entry
120120
size_t temp_total = found.offset;
121-
ReturnErrorCodeIf(temp_total + in.Size() > kPageSize, CHIP_ERROR_INVALID_ARGUMENT);
121+
VerifyOrReturnError(temp_total + in.Size() <= kPageSize, CHIP_ERROR_INVALID_ARGUMENT);
122122
// Copy entry
123123
ReturnErrorOnFailure(in.Get(page + temp_total, in.Size()));
124124
// Update total
@@ -138,7 +138,7 @@ CHIP_ERROR Set(uint16_t id, Encoding::Buffer & in)
138138
{
139139
// Size change, move to the end
140140
uint16_t temp_total = total - found.encoded_size;
141-
ReturnErrorCodeIf(temp_total + in.Size() > kPageSize, CHIP_ERROR_INVALID_ARGUMENT);
141+
VerifyOrReturnError(temp_total + in.Size() <= kPageSize, CHIP_ERROR_INVALID_ARGUMENT);
142142
// Remove the entry
143143
memmove(page + found.offset, page + found.offset + found.encoded_size, temp_total);
144144
// Add the entry
@@ -470,14 +470,14 @@ CHIP_ERROR Storage::GetManufacturingDate(uint8_t * value, size_t max, size_t & s
470470
return Flash::Get(Parameters::ID::kManufacturingDate, value, max, size);
471471
}
472472

473-
CHIP_ERROR Storage::SetUniqueId(const uint8_t * value, size_t size)
473+
CHIP_ERROR Storage::SetPersistentUniqueId(const uint8_t * value, size_t size)
474474
{
475-
return Flash::Set(Parameters::ID::kUniqueId, value, size);
475+
return Flash::Set(Parameters::ID::kPersistentUniqueId, value, size);
476476
}
477477

478-
CHIP_ERROR Storage::GetUniqueId(uint8_t * value, size_t max, size_t & size)
478+
CHIP_ERROR Storage::GetPersistentUniqueId(uint8_t * value, size_t max, size_t & size)
479479
{
480-
return Flash::Get(Parameters::ID::kUniqueId, value, max, size);
480+
return Flash::Get(Parameters::ID::kPersistentUniqueId, value, max, size);
481481
}
482482

483483
//

‎src/platform/silabs/SilabsConfig.h

+38-34
Original file line numberDiff line numberDiff line change
@@ -120,42 +120,46 @@ class SilabsConfig
120120
static constexpr Key kConfigKey_hostname = SilabsConfigKey(kMatterFactory_KeyBase, 0x15);
121121
static constexpr Key kConfigKey_clientid = SilabsConfigKey(kMatterFactory_KeyBase, 0x16);
122122
static constexpr Key kConfigKey_Test_Event_Trigger_Key = SilabsConfigKey(kMatterFactory_KeyBase, 0x17);
123-
static constexpr Key kConfigKey_UniqueId = SilabsConfigKey(kMatterFactory_KeyBase, 0x1F);
124-
static constexpr Key kConfigKey_Creds_KeyId = SilabsConfigKey(kMatterFactory_KeyBase, 0x20);
125-
static constexpr Key kConfigKey_Creds_Base_Addr = SilabsConfigKey(kMatterFactory_KeyBase, 0x21);
126-
static constexpr Key kConfigKey_Creds_DAC_Offset = SilabsConfigKey(kMatterFactory_KeyBase, 0x22);
127-
static constexpr Key kConfigKey_Creds_DAC_Size = SilabsConfigKey(kMatterFactory_KeyBase, 0x23);
128-
static constexpr Key kConfigKey_Creds_PAI_Offset = SilabsConfigKey(kMatterFactory_KeyBase, 0x24);
129-
static constexpr Key kConfigKey_Creds_PAI_Size = SilabsConfigKey(kMatterFactory_KeyBase, 0x25);
130-
static constexpr Key kConfigKey_Creds_CD_Offset = SilabsConfigKey(kMatterFactory_KeyBase, 0x26);
131-
static constexpr Key kConfigKey_Creds_CD_Size = SilabsConfigKey(kMatterFactory_KeyBase, 0x27);
132-
static constexpr Key kConfigKey_Provision_Request = SilabsConfigKey(kMatterFactory_KeyBase, 0x28);
133-
static constexpr Key kConfigKey_Provision_Version = SilabsConfigKey(kMatterFactory_KeyBase, 0x29);
134-
135-
static constexpr Key kOtaTlvEncryption_KeyId = SilabsConfigKey(kMatterFactory_KeyBase, 0x30);
123+
// kConfigKey_PersistentUniqueId is the inputkey in the generating of the Rotating Device ID
124+
// SHALL NOT be the same as the UniqueID attribute exposed in the Basic Information cluster.
125+
static constexpr Key kConfigKey_PersistentUniqueId = SilabsConfigKey(kMatterFactory_KeyBase, 0x1F);
126+
static constexpr Key kConfigKey_Creds_KeyId = SilabsConfigKey(kMatterFactory_KeyBase, 0x20);
127+
static constexpr Key kConfigKey_Creds_Base_Addr = SilabsConfigKey(kMatterFactory_KeyBase, 0x21);
128+
static constexpr Key kConfigKey_Creds_DAC_Offset = SilabsConfigKey(kMatterFactory_KeyBase, 0x22);
129+
static constexpr Key kConfigKey_Creds_DAC_Size = SilabsConfigKey(kMatterFactory_KeyBase, 0x23);
130+
static constexpr Key kConfigKey_Creds_PAI_Offset = SilabsConfigKey(kMatterFactory_KeyBase, 0x24);
131+
static constexpr Key kConfigKey_Creds_PAI_Size = SilabsConfigKey(kMatterFactory_KeyBase, 0x25);
132+
static constexpr Key kConfigKey_Creds_CD_Offset = SilabsConfigKey(kMatterFactory_KeyBase, 0x26);
133+
static constexpr Key kConfigKey_Creds_CD_Size = SilabsConfigKey(kMatterFactory_KeyBase, 0x27);
134+
static constexpr Key kConfigKey_Provision_Request = SilabsConfigKey(kMatterFactory_KeyBase, 0x28);
135+
static constexpr Key kConfigKey_Provision_Version = SilabsConfigKey(kMatterFactory_KeyBase, 0x29);
136+
static constexpr Key kOtaTlvEncryption_KeyId = SilabsConfigKey(kMatterFactory_KeyBase, 0x30);
136137

137138
// Matter Config Keys
138-
static constexpr Key kConfigKey_ServiceConfig = SilabsConfigKey(kMatterConfig_KeyBase, 0x01);
139-
static constexpr Key kConfigKey_PairedAccountId = SilabsConfigKey(kMatterConfig_KeyBase, 0x02);
140-
static constexpr Key kConfigKey_ServiceId = SilabsConfigKey(kMatterConfig_KeyBase, 0x03);
141-
static constexpr Key kConfigKey_LastUsedEpochKeyId = SilabsConfigKey(kMatterConfig_KeyBase, 0x05);
142-
static constexpr Key kConfigKey_FailSafeArmed = SilabsConfigKey(kMatterConfig_KeyBase, 0x06);
143-
static constexpr Key kConfigKey_GroupKey = SilabsConfigKey(kMatterConfig_KeyBase, 0x07);
144-
static constexpr Key kConfigKey_HardwareVersion = SilabsConfigKey(kMatterConfig_KeyBase, 0x08);
145-
static constexpr Key kConfigKey_RegulatoryLocation = SilabsConfigKey(kMatterConfig_KeyBase, 0x09);
146-
static constexpr Key kConfigKey_CountryCode = SilabsConfigKey(kMatterConfig_KeyBase, 0x0A);
147-
static constexpr Key kConfigKey_WiFiSSID = SilabsConfigKey(kMatterConfig_KeyBase, 0x0C);
148-
static constexpr Key kConfigKey_WiFiPSK = SilabsConfigKey(kMatterConfig_KeyBase, 0x0D);
149-
static constexpr Key kConfigKey_WiFiSEC = SilabsConfigKey(kMatterConfig_KeyBase, 0x0E);
150-
static constexpr Key kConfigKey_GroupKeyBase = SilabsConfigKey(kMatterConfig_KeyBase, 0x0F);
151-
static constexpr Key kConfigKey_LockUser = SilabsConfigKey(kMatterConfig_KeyBase, 0x10);
152-
static constexpr Key kConfigKey_Credential = SilabsConfigKey(kMatterConfig_KeyBase, 0x11);
153-
static constexpr Key kConfigKey_LockUserName = SilabsConfigKey(kMatterConfig_KeyBase, 0x12);
154-
static constexpr Key kConfigKey_CredentialData = SilabsConfigKey(kMatterConfig_KeyBase, 0x13);
155-
static constexpr Key kConfigKey_UserCredentials = SilabsConfigKey(kMatterConfig_KeyBase, 0x14);
156-
static constexpr Key kConfigKey_WeekDaySchedules = SilabsConfigKey(kMatterConfig_KeyBase, 0x15);
157-
static constexpr Key kConfigKey_YearDaySchedules = SilabsConfigKey(kMatterConfig_KeyBase, 0x16);
158-
static constexpr Key kConfigKey_HolidaySchedules = SilabsConfigKey(kMatterConfig_KeyBase, 0x17);
139+
static constexpr Key kConfigKey_ServiceConfig = SilabsConfigKey(kMatterConfig_KeyBase, 0x01);
140+
static constexpr Key kConfigKey_PairedAccountId = SilabsConfigKey(kMatterConfig_KeyBase, 0x02);
141+
static constexpr Key kConfigKey_ServiceId = SilabsConfigKey(kMatterConfig_KeyBase, 0x03);
142+
static constexpr Key kConfigKey_LastUsedEpochKeyId = SilabsConfigKey(kMatterConfig_KeyBase, 0x05);
143+
static constexpr Key kConfigKey_FailSafeArmed = SilabsConfigKey(kMatterConfig_KeyBase, 0x06);
144+
static constexpr Key kConfigKey_GroupKey = SilabsConfigKey(kMatterConfig_KeyBase, 0x07);
145+
static constexpr Key kConfigKey_HardwareVersion = SilabsConfigKey(kMatterConfig_KeyBase, 0x08);
146+
static constexpr Key kConfigKey_RegulatoryLocation = SilabsConfigKey(kMatterConfig_KeyBase, 0x09);
147+
static constexpr Key kConfigKey_CountryCode = SilabsConfigKey(kMatterConfig_KeyBase, 0x0A);
148+
static constexpr Key kConfigKey_WiFiSSID = SilabsConfigKey(kMatterConfig_KeyBase, 0x0C);
149+
static constexpr Key kConfigKey_WiFiPSK = SilabsConfigKey(kMatterConfig_KeyBase, 0x0D);
150+
static constexpr Key kConfigKey_WiFiSEC = SilabsConfigKey(kMatterConfig_KeyBase, 0x0E);
151+
static constexpr Key kConfigKey_GroupKeyBase = SilabsConfigKey(kMatterConfig_KeyBase, 0x0F);
152+
static constexpr Key kConfigKey_LockUser = SilabsConfigKey(kMatterConfig_KeyBase, 0x10);
153+
static constexpr Key kConfigKey_Credential = SilabsConfigKey(kMatterConfig_KeyBase, 0x11);
154+
static constexpr Key kConfigKey_LockUserName = SilabsConfigKey(kMatterConfig_KeyBase, 0x12);
155+
static constexpr Key kConfigKey_CredentialData = SilabsConfigKey(kMatterConfig_KeyBase, 0x13);
156+
static constexpr Key kConfigKey_UserCredentials = SilabsConfigKey(kMatterConfig_KeyBase, 0x14);
157+
static constexpr Key kConfigKey_WeekDaySchedules = SilabsConfigKey(kMatterConfig_KeyBase, 0x15);
158+
static constexpr Key kConfigKey_YearDaySchedules = SilabsConfigKey(kMatterConfig_KeyBase, 0x16);
159+
static constexpr Key kConfigKey_HolidaySchedules = SilabsConfigKey(kMatterConfig_KeyBase, 0x17);
160+
// UniqueId exposed in the Basic Information cluster. It is cleared on factoryreset
161+
// We will generate a random ID, if none was previously provided.
162+
static constexpr Key kConfigKey_UniqueId = SilabsConfigKey(kMatterConfig_KeyBase, 0x18);
159163
static constexpr Key kConfigKey_OpKeyMap = SilabsConfigKey(kMatterConfig_KeyBase, 0x20);
160164
static constexpr Key kConfigKey_BootCount = SilabsConfigKey(kMatterConfig_KeyBase, 0x21);
161165
static constexpr Key kConfigKey_TotalOperationalHours = SilabsConfigKey(kMatterConfig_KeyBase, 0x22);

‎src/platform/silabs/provision/ProvisionStorage.h

+17-15
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,18 @@ enum ID : uint16_t
6262
kCertToolPath = 0x0137,
6363
kPylinkLib = 0x0138,
6464
// Instance Info,
65-
kSerialNumber = 0x0141,
66-
kVendorId = 0x0142,
67-
kVendorName = 0x0143,
68-
kProductId = 0x0144,
69-
kProductName = 0x0145,
70-
kProductLabel = 0x0146,
71-
kProductUrl = 0x0147,
72-
kPartNumber = 0x0148,
73-
kHwVersion = 0x0151,
74-
kHwVersionStr = 0x0152,
75-
kManufacturingDate = 0x0153,
76-
kUniqueId = 0x0154,
65+
kSerialNumber = 0x0141,
66+
kVendorId = 0x0142,
67+
kVendorName = 0x0143,
68+
kProductId = 0x0144,
69+
kProductName = 0x0145,
70+
kProductLabel = 0x0146,
71+
kProductUrl = 0x0147,
72+
kPartNumber = 0x0148,
73+
kHwVersion = 0x0151,
74+
kHwVersionStr = 0x0152,
75+
kManufacturingDate = 0x0153,
76+
kPersistentUniqueId = 0x0154,
7777
// Commissionable Data,
7878
kDiscriminator = 0x0161,
7979
kSpake2pPasscode = 0x0162,
@@ -143,7 +143,7 @@ struct Storage : public GenericStorage,
143143
static constexpr size_t kPartNumberLengthMax = 32;
144144
static constexpr size_t kHardwareVersionStrLengthMax = 32;
145145
static constexpr size_t kManufacturingDateLengthMax = 11; // yyyy-mm-dd + \0
146-
static constexpr size_t kUniqueIdLengthMax = 16;
146+
static constexpr size_t kPersistentUniqueIdMaxLength = 16;
147147
static constexpr size_t kSpake2pVerifierB64LengthMax = BASE64_ENCODED_LEN(chip::Crypto::kSpake2p_VerifierSerialized_Length) + 1;
148148
static constexpr size_t kSpake2pSaltB64LengthMax = BASE64_ENCODED_LEN(chip::Crypto::kSpake2p_Max_PBKDF_Salt_Length) + 1;
149149
static constexpr size_t kFirmwareInfoSizeMax = 32;
@@ -259,8 +259,10 @@ struct Storage : public GenericStorage,
259259
CHIP_ERROR SetHardwareVersionString(const char * value, size_t len);
260260
CHIP_ERROR SetManufacturingDate(const char * value, size_t len);
261261
CHIP_ERROR GetManufacturingDate(uint8_t * value, size_t max, size_t & size);
262-
CHIP_ERROR SetUniqueId(const uint8_t * value, size_t size);
263-
CHIP_ERROR GetUniqueId(uint8_t * value, size_t max, size_t & size);
262+
// PersistentUniqueId is used to generate the RotatingUniqueId
263+
// This PersistentUniqueId SHALL NOT be the same as the UniqueID attribute exposed in the Basic Information cluster.
264+
CHIP_ERROR SetPersistentUniqueId(const uint8_t * value, size_t size);
265+
CHIP_ERROR GetPersistentUniqueId(uint8_t * value, size_t max, size_t & size);
264266
// CommissionableDataProvider
265267
CHIP_ERROR SetSetupDiscriminator(uint16_t value);
266268
CHIP_ERROR SetSpake2pIterationCount(uint32_t value);

0 commit comments

Comments
 (0)