Skip to content

Commit

Permalink
Restyled by clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits authored and erwinpan1 committed Mar 11, 2024
1 parent a093820 commit eb4bd7c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "chef-lock-endpoint.h"
#include <app-common/zap-generated/attributes/Accessors.h>
#include <cstring>
#include <platform/CHIPDeviceLayer.h>
#include <platform/internal/CHIPDeviceLayerInternal.h>
#include "chef-lock-endpoint.h"

using chip::to_underlying;
using chip::app::DataModel::MakeNullable;
Expand Down Expand Up @@ -605,8 +605,9 @@ bool LockEndpoint::weekDayScheduleForbidsAccess(uint16_t userIndex, bool * haveS
[currentTime, calendarTime](const WeekDaysScheduleInfo & s) {
auto startTime = s.schedule.startHour * chip::kSecondsPerHour + s.schedule.startMinute * chip::kSecondsPerMinute;
auto endTime = s.schedule.endHour * chip::kSecondsPerHour + s.schedule.endMinute * chip::kSecondsPerMinute;
bool ret = (s.status == DlScheduleStatus::kOccupied && (to_underlying(s.schedule.daysMask) & (1 << calendarTime.tm_wday)) &&
startTime <= currentTime && currentTime <= endTime);
bool ret =
(s.status == DlScheduleStatus::kOccupied && (to_underlying(s.schedule.daysMask) & (1 << calendarTime.tm_wday)) &&
startTime <= currentTime && currentTime <= endTime);
return s.status == DlScheduleStatus::kOccupied && (to_underlying(s.schedule.daysMask) & (1 << calendarTime.tm_wday)) &&
startTime <= currentTime && currentTime <= endTime;
});
Expand Down
26 changes: 15 additions & 11 deletions examples/chef/common/clusters/door-lock/chef-lock-manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
* limitations under the License.
*/

#include "chef-lock-manager.h"
#include <iostream>
#include <lib/support/logging/CHIPLogging.h>
#include "chef-lock-manager.h"

using chip::to_underlying;

Expand Down Expand Up @@ -115,24 +115,26 @@ bool LockManager::InitEndpoint(chip::EndpointId endpointId)
chip::FabricIndex modifier(1);
const chip::CharSpan userName = chip::CharSpan::fromCharString("user1"); // default
// username
uint32_t uniqueId = 0xFFFFFFFF; // null
uint32_t uniqueId = 0xFFFFFFFF; // null
UserStatusEnum userStatus = UserStatusEnum::kOccupiedEnabled;
// Set to programming user instead of unrestrict user to perform
// priviledged function
UserTypeEnum usertype = UserTypeEnum::kProgrammingUser;
UserTypeEnum usertype = UserTypeEnum::kProgrammingUser;
CredentialRuleEnum credentialRule = CredentialRuleEnum::kSingle;

constexpr size_t totalCredentials(2);
// According to spec (5.2.6.26.2. CredentialIndex Field), programming PIN credential should be always indexed as 0
uint16_t credentialIndex0(0);
// 1st non ProgrammingPIN credential should be indexed as 1
// 1st non ProgrammingPIN credential should be indexed as 1
uint16_t credentialIndex1(1);

const CredentialStruct credentials[totalCredentials] = {
{credentialType: CredentialTypeEnum::kProgrammingPIN, credentialIndex: credentialIndex0},
{credentialType: CredentialTypeEnum::kPin, credentialIndex: credentialIndex1}};
{ credentialType : CredentialTypeEnum::kProgrammingPIN, credentialIndex : credentialIndex0 },
{ credentialType : CredentialTypeEnum::kPin, credentialIndex : credentialIndex1 }
};

if (!SetUser(endpointId, userIndex, creator, modifier, userName, uniqueId, userStatus, usertype, credentialRule, &credentials[0], totalCredentials))
if (!SetUser(endpointId, userIndex, creator, modifier, userName, uniqueId, userStatus, usertype, credentialRule,
&credentials[0], totalCredentials))
{
ChipLogError(Zcl, "Unable to set the User [endpointId=%d]", endpointId);
return false;
Expand All @@ -141,16 +143,18 @@ bool LockManager::InitEndpoint(chip::EndpointId endpointId)
DlCredentialStatus credentialStatus = DlCredentialStatus::kOccupied;

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

// Set the default user's non ProgrammingPIN credential
uint8_t defaultPin[6] = { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36 }; // 123456
if (!SetCredential(endpointId, credentialIndex1, creator, modifier, credentialStatus, CredentialTypeEnum::kPin, chip::ByteSpan(defaultPin)))
uint8_t defaultPin[6] = { 0x31, 0x32, 0x33, 0x34, 0x35, 0x36 }; // 123456
if (!SetCredential(endpointId, credentialIndex1, creator, modifier, credentialStatus, CredentialTypeEnum::kPin,
chip::ByteSpan(defaultPin)))
{
ChipLogError(Zcl, "Unable to set the credential - endpoint does not exist or not initialized [endpointId=%d]", endpointId);
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

#pragma once

#include "chef-lock-endpoint.h"
#include <app/clusters/door-lock-server/door-lock-server.h>
#include <cstdint>
#include "chef-lock-endpoint.h"

#include <app/util/af.h>

Expand Down

0 comments on commit eb4bd7c

Please sign in to comment.