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 serhiiSalamakha committed Dec 7, 2023
1 parent 2bdebfd commit 1428458
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 33 deletions.
32 changes: 19 additions & 13 deletions examples/lock-app/telink/src/LockManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,13 @@ bool LockManager::ReadConfigValues()

for (uint8_t i = 0; i < kNumCredentialTypes; i++)
{
ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_Credential[i], reinterpret_cast<uint8_t *>(&mLockCredentials[i]),
sizeof(EmberAfPluginDoorLockCredentialInfo) * kMaxCredentials, outLen);
ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_Credential[i],
reinterpret_cast<uint8_t *>(&mLockCredentials[i]),
sizeof(EmberAfPluginDoorLockCredentialInfo) * kMaxCredentials, outLen);

ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialData[i], reinterpret_cast<uint8_t *>(mCredentialData[i]),
kMaxCredentials * kMaxCredentialSize, outLen);
ZephyrConfig::ReadConfigValueBin(LockSettingsStorage::kConfigKey_CredentialData[i],
reinterpret_cast<uint8_t *>(mCredentialData[i]), kMaxCredentials * kMaxCredentialSize,
outLen);
}

return true;
Expand Down Expand Up @@ -668,23 +670,27 @@ bool LockManager::SetCredential(chip::EndpointId endpointId, uint16_t credential
for (uint8_t i = 0; i < kNumCredentialTypes; i++)
{
// Save credential information in NVM flash
err = ZephyrConfig::WriteConfigValueBin(
LockSettingsStorage::kConfigKey_Credential[i], reinterpret_cast<const uint8_t *>(&mLockCredentials[i]),
sizeof(EmberAfPluginDoorLockCredentialInfo) * kMaxCredentials);
err = ZephyrConfig::WriteConfigValueBin(LockSettingsStorage::kConfigKey_Credential[i],
reinterpret_cast<const uint8_t *>(&mLockCredentials[i]),
sizeof(EmberAfPluginDoorLockCredentialInfo) * kMaxCredentials);
if (err != CHIP_NO_ERROR)
{
ChipLogError(Zcl,
"Failed to write kConfigKey_Credential(%d). User data will be resetted during reboot. Not enough storage space \n", i);
ChipLogError(
Zcl,
"Failed to write kConfigKey_Credential(%d). User data will be resetted during reboot. Not enough storage space \n",
i);
break;
}

err = ZephyrConfig::WriteConfigValueBin(
LockSettingsStorage::kConfigKey_CredentialData[i],reinterpret_cast<const uint8_t *>(&mCredentialData[i]),
kMaxCredentials * kMaxCredentialSize);
err = ZephyrConfig::WriteConfigValueBin(LockSettingsStorage::kConfigKey_CredentialData[i],
reinterpret_cast<const uint8_t *>(&mCredentialData[i]),
kMaxCredentials * kMaxCredentialSize);
if (err != CHIP_NO_ERROR)
{
ChipLogError(Zcl,
"Failed to write kConfigKey_CredentialData(%d). User data will be resetted during reboot. Not enough storage space \n", i);
"Failed to write kConfigKey_CredentialData(%d). User data will be resetted during reboot. Not enough "
"storage space \n",
i);
break;
}
}
Expand Down
32 changes: 12 additions & 20 deletions examples/lock-app/telink/src/LockSettingsStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,24 @@ namespace Internal {
(key); \
static_assert(sizeof(key) <= SETTINGS_MAX_NAME_LEN, "Config key too long: " key)

#define CONFIG_KEY_CREDENTIAL(type) (NAMESPACE_CONFIG "credential-" type)
#define CONFIG_KEY_CREDENTIAL_DATA(type) (NAMESPACE_CONFIG "credential-" type "-data")
#define CONFIG_KEY_CREDENTIAL(type) (NAMESPACE_CONFIG "credential-" type)
#define CONFIG_KEY_CREDENTIAL_DATA(type) (NAMESPACE_CONFIG "credential-" type "-data")

#define NAMESPACE_CONFIG CHIP_DEVICE_CONFIG_SETTINGS_KEY "/cfg/"

const ZephyrConfig::Key LockSettingsStorage::kConfigKey_LockUser = CONFIG_KEY(NAMESPACE_CONFIG "lock-user");
const ZephyrConfig::Key LockSettingsStorage::kConfigKey_LockUserName = CONFIG_KEY(NAMESPACE_CONFIG "lock-user-name");
const ZephyrConfig::Key LockSettingsStorage::kConfigKey_UserCredentials = CONFIG_KEY(NAMESPACE_CONFIG "user-credentials");
const ZephyrConfig::Key LockSettingsStorage::kConfigKey_WeekDaySchedules = CONFIG_KEY(NAMESPACE_CONFIG "week-day-schedules");
const ZephyrConfig::Key LockSettingsStorage::kConfigKey_YearDaySchedules = CONFIG_KEY(NAMESPACE_CONFIG "year-day-schedules");
const ZephyrConfig::Key LockSettingsStorage::kConfigKey_HolidaySchedules = CONFIG_KEY(NAMESPACE_CONFIG "holiday-schedules");
const ZephyrConfig::Key LockSettingsStorage::kConfigKey_LockUser = CONFIG_KEY(NAMESPACE_CONFIG "lock-user");
const ZephyrConfig::Key LockSettingsStorage::kConfigKey_LockUserName = CONFIG_KEY(NAMESPACE_CONFIG "lock-user-name");
const ZephyrConfig::Key LockSettingsStorage::kConfigKey_UserCredentials = CONFIG_KEY(NAMESPACE_CONFIG "user-credentials");
const ZephyrConfig::Key LockSettingsStorage::kConfigKey_WeekDaySchedules = CONFIG_KEY(NAMESPACE_CONFIG "week-day-schedules");
const ZephyrConfig::Key LockSettingsStorage::kConfigKey_YearDaySchedules = CONFIG_KEY(NAMESPACE_CONFIG "year-day-schedules");
const ZephyrConfig::Key LockSettingsStorage::kConfigKey_HolidaySchedules = CONFIG_KEY(NAMESPACE_CONFIG "holiday-schedules");
const char * LockSettingsStorage::kConfigKey_Credential[kNumCredentialTypes] = {
CONFIG_KEY_CREDENTIAL("programming-pin"),
CONFIG_KEY_CREDENTIAL("pin"),
CONFIG_KEY_CREDENTIAL("rfid"),
CONFIG_KEY_CREDENTIAL("finger-print"),
CONFIG_KEY_CREDENTIAL("finger-vein"),
CONFIG_KEY_CREDENTIAL("face")
CONFIG_KEY_CREDENTIAL("programming-pin"), CONFIG_KEY_CREDENTIAL("pin"), CONFIG_KEY_CREDENTIAL("rfid"),
CONFIG_KEY_CREDENTIAL("finger-print"), CONFIG_KEY_CREDENTIAL("finger-vein"), CONFIG_KEY_CREDENTIAL("face")
};
const char * LockSettingsStorage::kConfigKey_CredentialData[kNumCredentialTypes] = {
CONFIG_KEY_CREDENTIAL_DATA("programming-pin"),
CONFIG_KEY_CREDENTIAL_DATA("pin"),
CONFIG_KEY_CREDENTIAL_DATA("rfid"),
CONFIG_KEY_CREDENTIAL_DATA("finger-print"),
CONFIG_KEY_CREDENTIAL_DATA("finger-vein"),
CONFIG_KEY_CREDENTIAL_DATA("face")
CONFIG_KEY_CREDENTIAL_DATA("programming-pin"), CONFIG_KEY_CREDENTIAL_DATA("pin"), CONFIG_KEY_CREDENTIAL_DATA("rfid"),
CONFIG_KEY_CREDENTIAL_DATA("finger-print"), CONFIG_KEY_CREDENTIAL_DATA("finger-vein"), CONFIG_KEY_CREDENTIAL_DATA("face")
};

} // namespace Internal
Expand Down

0 comments on commit 1428458

Please sign in to comment.