Skip to content

Commit 35409b2

Browse files
committed
Enable PrivacyMode, Remove debug message
1 parent 5c3262a commit 35409b2

File tree

5 files changed

+21
-40
lines changed

5 files changed

+21
-40
lines changed

examples/chef/common/clusters/door-lock/chef-lock-endpoint.cpp

+1-22
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,6 @@ bool LockEndpoint::SetUser(uint16_t userIndex, chip::FabricIndex creator, chip::
117117
mEndpointId, userIndex, creator, modifier, static_cast<int>(userName.size()), userName.data(), uniqueId,
118118
to_underlying(userStatus), to_underlying(usertype), to_underlying(credentialRule), credentials,
119119
static_cast<unsigned int>(totalCredentials));
120-
printf("\033[44m Lock App: LockEndpoint::SetUser "
121-
"[endpoint=%d,userIndex=%u,creator=%d,modifier=%d,userName=\"%.*s\",uniqueId=%" PRIx32
122-
",userStatus=%u,userType=%u,"
123-
"credentialRule=%u,credentials=%p,totalCredentials=%u] \033[0m\n",
124-
mEndpointId, userIndex, creator, modifier, static_cast<int>(userName.size()), userName.data(), uniqueId,
125-
to_underlying(userStatus), to_underlying(usertype), to_underlying(credentialRule), credentials,
126-
static_cast<unsigned int>(totalCredentials));
127120

128121
auto adjustedUserIndex = static_cast<uint16_t>(userIndex - 1);
129122
if (adjustedUserIndex > mLockUsers.size())
@@ -264,6 +257,7 @@ bool LockEndpoint::SetCredential(uint16_t credentialIndex, chip::FabricIndex cre
264257
return false;
265258
}
266259

260+
// Assign to arrary by credentialIndex. Note: 0 is reserved for programmingPIN only
267261
auto & credentialInStorage = mLockCredentials[to_underlying(credentialType)][credentialIndex];
268262
if (credentialData.size() > DOOR_LOCK_CREDENTIAL_INFO_MAX_DATA_SIZE)
269263
{
@@ -285,13 +279,6 @@ bool LockEndpoint::SetCredential(uint16_t credentialIndex, chip::FabricIndex cre
285279
mEndpointId, credentialIndex, to_underlying(credentialType), credentialInStorage.createdBy,
286280
credentialInStorage.modifiedBy);
287281

288-
printf("\033[41m %s, %d \033[0m \n credential=", __func__, __LINE__);
289-
for (size_t i=0; i < credentialData.size(); i++)
290-
{
291-
printf("%c", credentialInStorage.credentialData[i]);
292-
}
293-
printf("\n \033[41m %s, %d \033[0m \n", __func__, __LINE__);
294-
295282
return true;
296283
}
297284

@@ -467,13 +454,6 @@ bool LockEndpoint::setLockState(const Nullable<chip::FabricIndex> & fabricIdx, c
467454
return false;
468455
}
469456

470-
printf("\033[41m %s, %d \033[0m \n pin=", __func__, __LINE__);
471-
for (size_t i=0; i < pin.Value().size(); i++)
472-
{
473-
printf("%c", pin.Value()[i]);
474-
}
475-
printf("\n \033[41m %s, %d \033[0m \n", __func__, __LINE__);
476-
477457
// Find the credential so we can make sure it is not absent right away
478458
auto & pinCredentials = mLockCredentials[to_underlying(CredentialTypeEnum::kPin)];
479459
auto credential = std::find_if(pinCredentials.begin(), pinCredentials.end(), [&pin](const LockCredentialInfo & c) {
@@ -627,7 +607,6 @@ bool LockEndpoint::weekDayScheduleForbidsAccess(uint16_t userIndex, bool * haveS
627607
auto endTime = s.schedule.endHour * chip::kSecondsPerHour + s.schedule.endMinute * chip::kSecondsPerMinute;
628608
bool ret = (s.status == DlScheduleStatus::kOccupied && (to_underlying(s.schedule.daysMask) & (1 << calendarTime.tm_wday)) &&
629609
startTime <= currentTime && currentTime <= endTime);
630-
printf("\033[44m %s, %d, s.status=%d, ret=%d \033[0m \n", __func__, __LINE__, to_underlying(s.status), static_cast<int>(ret));
631610
return s.status == DlScheduleStatus::kOccupied && (to_underlying(s.schedule.daysMask) & (1 << calendarTime.tm_wday)) &&
632611
startTime <= currentTime && currentTime <= endTime;
633612
});

examples/chef/common/clusters/door-lock/chef-lock-endpoint.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ struct YearDayScheduleInfo;
3939
struct HolidayScheduleInfo;
4040

4141
static constexpr size_t DOOR_LOCK_CREDENTIAL_INFO_MAX_DATA_SIZE = 20;
42-
static constexpr size_t DOOR_LOCK_CREDENTIAL_INFO_MAX_TYPES = 6;
42+
static constexpr size_t DOOR_LOCK_CREDENTIAL_INFO_MAX_TYPES = 6; // 0: ProgrammingPIN ~ 5: Face
4343

4444
class LockEndpoint
4545
{

examples/chef/common/clusters/door-lock/chef-lock-manager.cpp

+16-14
Original file line numberDiff line numberDiff line change
@@ -121,39 +121,41 @@ bool LockManager::InitEndpoint(chip::EndpointId endpointId)
121121
// priviledged function
122122
UserTypeEnum usertype = UserTypeEnum::kProgrammingUser;
123123
CredentialRuleEnum credentialRule = CredentialRuleEnum::kSingle;
124-
uint16_t programmingPINCredentialIndex(1); // According to spec, programming PIN
125-
// should be always indexed as 0
126-
uint16_t user1CredentialIndex(2);
127-
const CredentialStruct credentials[2] = {
128-
{credentialType: CredentialTypeEnum::kProgrammingPIN, credentialIndex: programmingPINCredentialIndex},
129-
{credentialType: CredentialTypeEnum::kPin, credentialIndex: user1CredentialIndex}};
130-
size_t totalCredentials(2);
124+
125+
constexpr size_t totalCredentials(2);
126+
// According to spec (5.2.6.26.2. CredentialIndex Field), programming PIN credential should be always indexed as 0
127+
uint16_t credentialIndex0(0);
128+
// 1st non ProgrammingPIN credential should be indexed as 1
129+
uint16_t credentialIndex1(1);
130+
131+
const CredentialStruct credentials[totalCredentials] = {
132+
{credentialType: CredentialTypeEnum::kProgrammingPIN, credentialIndex: credentialIndex0},
133+
{credentialType: CredentialTypeEnum::kPin, credentialIndex: credentialIndex1}};
134+
131135
if (!SetUser(endpointId, userIndex, creator, modifier, userName, uniqueId, userStatus, usertype, credentialRule, &credentials[0], totalCredentials))
132136
{
133137
ChipLogError(Zcl, "Unable to set the User [endpointId=%d]", endpointId);
134138
return false;
135139
}
136140

137141
DlCredentialStatus credentialStatus = DlCredentialStatus::kOccupied;
138-
uint8_t defaultProgrammingPIN[6] = { 0x39, 0x39, 0x39, 0x39, 0x39, 0x39 }; // 000000
139-
const chip::ByteSpan programmingPINCredentialData(defaultProgrammingPIN);
140142

141-
if (!SetCredential(endpointId, programmingPINCredentialIndex, creator, modifier, credentialStatus, CredentialTypeEnum::kProgrammingPIN, programmingPINCredentialData))
143+
// Set the default user's ProgrammingPIN credential
144+
uint8_t defaultProgrammingPIN[6] = { 0x39, 0x39, 0x39, 0x39, 0x39, 0x39 }; // 000000
145+
if (!SetCredential(endpointId, credentialIndex0, creator, modifier, credentialStatus, CredentialTypeEnum::kProgrammingPIN, chip::ByteSpan(defaultProgrammingPIN)))
142146
{
143147
ChipLogError(Zcl, "Unable to set the credential - endpoint does not exist or not initialized [endpointId=%d]", endpointId);
144148
return false;
145149
}
146150

151+
// Set the default user's non ProgrammingPIN credential
147152
uint8_t defaultPin[6] = { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36 }; // 123456
148-
const chip::ByteSpan credentialData(defaultPin);
149-
150-
if (!SetCredential(endpointId, user1CredentialIndex, creator, modifier, credentialStatus, CredentialTypeEnum::kPin, credentialData))
153+
if (!SetCredential(endpointId, credentialIndex1, creator, modifier, credentialStatus, CredentialTypeEnum::kPin, chip::ByteSpan(defaultPin)))
151154
{
152155
ChipLogError(Zcl, "Unable to set the credential - endpoint does not exist or not initialized [endpointId=%d]", endpointId);
153156
return false;
154157
}
155158

156-
157159
ChipLogProgress(Zcl,
158160
"Initialized new lock door endpoint "
159161
"[id=%d,users=%d,credentials=%d,weekDaySchedulesPerUser=%d,yearDaySchedulesPerUser=%d,"

examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter

+1-1
Original file line numberDiff line numberDiff line change
@@ -2420,7 +2420,7 @@ endpoint 1 {
24202420
ram attribute autoRelockTime default = 5;
24212421
ram attribute soundVolume default = 0;
24222422
ram attribute operatingMode default = 0;
2423-
ram attribute supportedOperatingModes default = 0xFFF6;
2423+
ram attribute supportedOperatingModes default = 0xFFFF;
24242424
ram attribute enableOneTouchLocking default = 0;
24252425
ram attribute enablePrivacyModeButton default = 0;
24262426
ram attribute wrongCodeEntryLimit default = 3;

examples/chef/devices/rootnode_doorlock_aNKYAreMXE.zap

+2-2
Original file line numberDiff line numberDiff line change
@@ -3712,7 +3712,7 @@
37123712
"storageOption": "RAM",
37133713
"singleton": 0,
37143714
"bounded": 0,
3715-
"defaultValue": "0xFFF6",
3715+
"defaultValue": "0xFFFF",
37163716
"reportable": 1,
37173717
"minInterval": 1,
37183718
"maxInterval": 65534,
@@ -3954,4 +3954,4 @@
39543954
"parentEndpointIdentifier": null
39553955
}
39563956
]
3957-
}
3957+
}

0 commit comments

Comments
 (0)