diff --git a/examples/all-clusters-app/linux/BUILD.gn b/examples/all-clusters-app/linux/BUILD.gn index 6c71b7e61b64f5..1b8ff71bc66e76 100644 --- a/examples/all-clusters-app/linux/BUILD.gn +++ b/examples/all-clusters-app/linux/BUILD.gn @@ -52,14 +52,16 @@ source_set("chip-all-clusters-common") { source_set("chip-lock-app-common") { sources = [ - "${chip_root}/examples/lock-app/linux/src/LockEndpoint.cpp", - "${chip_root}/examples/lock-app/linux/src/LockManager.cpp", - "${chip_root}/examples/lock-app/linux/src/ZCLDoorLockCallbacks.cpp", + "${chip_root}/examples/lock-app/lock-common/include/LockEndpoint.h", + "${chip_root}/examples/lock-app/lock-common/include/LockManager.h", + "${chip_root}/examples/lock-app/lock-common/src/LockEndpoint.cpp", + "${chip_root}/examples/lock-app/lock-common/src/LockManager.cpp", + "${chip_root}/examples/lock-app/lock-common/src/ZCLDoorLockCallbacks.cpp", ] deps = [ "${chip_root}/examples/all-clusters-app/all-clusters-common" ] - include_dirs = [ "${chip_root}/examples/lock-app/linux/include" ] + include_dirs = [ "${chip_root}/examples/lock-app/lock-common/include" ] cflags = [ "-Wconversion" ] } diff --git a/examples/all-clusters-minimal-app/linux/BUILD.gn b/examples/all-clusters-minimal-app/linux/BUILD.gn index cf3f915fe0d828..24154fe758f958 100644 --- a/examples/all-clusters-minimal-app/linux/BUILD.gn +++ b/examples/all-clusters-minimal-app/linux/BUILD.gn @@ -49,15 +49,17 @@ source_set("chip-all-clusters-common") { source_set("chip-lock-app-common") { sources = [ - "${chip_root}/examples/lock-app/linux/src/LockEndpoint.cpp", - "${chip_root}/examples/lock-app/linux/src/LockManager.cpp", - "${chip_root}/examples/lock-app/linux/src/ZCLDoorLockCallbacks.cpp", + "${chip_root}/examples/lock-app/lock-common/include/LockEndpoint.h", + "${chip_root}/examples/lock-app/lock-common/include/LockManager.h", + "${chip_root}/examples/lock-app/lock-common/src/LockEndpoint.cpp", + "${chip_root}/examples/lock-app/lock-common/src/LockManager.cpp", + "${chip_root}/examples/lock-app/lock-common/src/ZCLDoorLockCallbacks.cpp", ] deps = [ "${chip_root}/examples/all-clusters-minimal-app/all-clusters-common" ] - include_dirs = [ "${chip_root}/examples/lock-app/linux/include" ] + include_dirs = [ "${chip_root}/examples/lock-app/lock-common/include" ] cflags = [ "-Wconversion" ] } diff --git a/examples/lock-app/linux/BUILD.gn b/examples/lock-app/linux/BUILD.gn index fc4bc76d9c8b2f..ce54d7d4fd906d 100644 --- a/examples/lock-app/linux/BUILD.gn +++ b/examples/lock-app/linux/BUILD.gn @@ -19,22 +19,17 @@ executable("chip-lock-app") { sources = [ "main.cpp", "src/LockAppCommandDelegate.cpp", - "src/LockEndpoint.cpp", - "src/LockManager.cpp", - "src/ZCLDoorLockCallbacks.cpp", ] deps = [ "${chip_root}/examples/lock-app/lock-common", + "${chip_root}/examples/lock-app/lock-common:lock-cluster-service", "${chip_root}/examples/platform/linux:app-main", "${chip_root}/src/lib", "${chip_root}/third_party/jsoncpp", ] - include_dirs = [ - "${chip_root}/examples/lock-app/lock-common/include", - "include", - ] + include_dirs = [ "include" ] cflags = [ "-Wconversion" ] diff --git a/examples/lock-app/lock-common/BUILD.gn b/examples/lock-app/lock-common/BUILD.gn index 1b1a7d31311a6a..4237883f3fb2b0 100644 --- a/examples/lock-app/lock-common/BUILD.gn +++ b/examples/lock-app/lock-common/BUILD.gn @@ -22,3 +22,22 @@ chip_data_model("lock-common") { zap_pregenerated_dir = "${chip_root}/zzz_generated/lock-app/zap-generated" is_server = true } + +config("config") { + include_dirs = [ "include" ] +} + +source_set("lock-cluster-service") { + deps = [ + "${chip_root}/examples/lock-app/lock-common", + "${chip_root}/src/lib", + ] + public_configs = [ ":config" ] + sources = [ + "include/LockEndpoint.h", + "include/LockManager.h", + "src/LockEndpoint.cpp", + "src/LockManager.cpp", + "src/ZCLDoorLockCallbacks.cpp", + ] +} diff --git a/examples/lock-app/linux/include/LockEndpoint.h b/examples/lock-app/lock-common/include/LockEndpoint.h similarity index 99% rename from examples/lock-app/linux/include/LockEndpoint.h rename to examples/lock-app/lock-common/include/LockEndpoint.h index f652ec2df6f0a8..cabbf5822e211e 100644 --- a/examples/lock-app/linux/include/LockEndpoint.h +++ b/examples/lock-app/lock-common/include/LockEndpoint.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2022 Project CHIP Authors + * Copyright (c) 2022-2023 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/examples/lock-app/linux/include/LockManager.h b/examples/lock-app/lock-common/include/LockManager.h similarity index 98% rename from examples/lock-app/linux/include/LockManager.h rename to examples/lock-app/lock-common/include/LockManager.h index 9f274abe487598..9eb313aa5d276c 100644 --- a/examples/lock-app/linux/include/LockManager.h +++ b/examples/lock-app/lock-common/include/LockManager.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2023 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/examples/lock-app/lock-common/lock-app.cmake b/examples/lock-app/lock-common/lock-app.cmake new file mode 100644 index 00000000000000..9cd897730b8f25 --- /dev/null +++ b/examples/lock-app/lock-common/lock-app.cmake @@ -0,0 +1,45 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +cmake_minimum_required(VERSION 3.21) + +set(CHIP_LOCK_COMMON_BASE_DIR ${CMAKE_CURRENT_LIST_DIR}) + + +# Add common lock sources to the specific target +# [Args]: +# target - target name +# Available options are: +# SCOPE sources scope for the target, PRIVATE as default +macro(chip_add_lock_app_common target) + set(SCOPE PRIVATE) + cmake_parse_arguments(ARG "" "SCOPE" "" ${ARGN}) + if (ARG_SCOPE) + set(SCOPE ${ARG_SCOPE}) + endif() + + target_include_directories(${target} + ${SCOPE} + ${CHIP_LOCK_COMMON_BASE_DIR}/include + ) + + target_sources(${target} + ${SCOPE} + ${CHIP_LOCK_COMMON_BASE_DIR}/src/ZCLDoorLockCallbacks.cpp + ${CHIP_LOCK_COMMON_BASE_DIR}/src/LockManager.cpp + ${CHIP_LOCK_COMMON_BASE_DIR}/src/LockEndpoint.cpp + ) +endmacro() diff --git a/examples/lock-app/linux/src/LockEndpoint.cpp b/examples/lock-app/lock-common/src/LockEndpoint.cpp similarity index 98% rename from examples/lock-app/linux/src/LockEndpoint.cpp rename to examples/lock-app/lock-common/src/LockEndpoint.cpp index 6c68f9f3a12be0..db1fde79b9b4dc 100644 --- a/examples/lock-app/linux/src/LockEndpoint.cpp +++ b/examples/lock-app/lock-common/src/LockEndpoint.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2022 Project CHIP Authors + * Copyright (c) 2022-2023 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -392,8 +392,8 @@ bool LockEndpoint::setLockState(DlLockState lockState, const Optional #include diff --git a/examples/lock-app/openiotsdk/CMakeLists.txt b/examples/lock-app/openiotsdk/CMakeLists.txt index ec75b81afdf3d2..fca486fed81d09 100644 --- a/examples/lock-app/openiotsdk/CMakeLists.txt +++ b/examples/lock-app/openiotsdk/CMakeLists.txt @@ -19,8 +19,10 @@ cmake_minimum_required(VERSION 3.21) get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../.. REALPATH) get_filename_component(OPEN_IOT_SDK_CONFIG ${CHIP_ROOT}/config/openiotsdk REALPATH) get_filename_component(OPEN_IOT_SDK_EXAMPLE_COMMON ${CHIP_ROOT}/examples/platform/openiotsdk REALPATH) +get_filename_component(LOCK_APP_COMMON ${CHIP_ROOT}/examples/lock-app/lock-common REALPATH) list(APPEND CMAKE_MODULE_PATH ${OPEN_IOT_SDK_CONFIG}/cmake) +list(APPEND CMAKE_MODULE_PATH ${LOCK_APP_COMMON}) set(APP_TARGET chip-openiotsdk-lock-app-example_ns) @@ -61,6 +63,12 @@ add_subdirectory(${OPEN_IOT_SDK_EXAMPLE_COMMON}/app ./app_build) chip_add_data_model(openiotsdk-app PUBLIC lock) +# Add common lock-app sources +include(lock-app) +chip_add_lock_app_common(openiotsdk-app + SCOPE PUBLIC +) + target_include_directories(${APP_TARGET} PRIVATE main/include @@ -69,9 +77,6 @@ target_include_directories(${APP_TARGET} target_sources(${APP_TARGET} PRIVATE main/main_ns.cpp - main/ZclCallbacks.cpp - main/LockManager.cpp - main/LockEndpoint.cpp ) target_link_libraries(${APP_TARGET} diff --git a/examples/lock-app/openiotsdk/main/LockEndpoint.cpp b/examples/lock-app/openiotsdk/main/LockEndpoint.cpp deleted file mode 100644 index 453520c6470cca..00000000000000 --- a/examples/lock-app/openiotsdk/main/LockEndpoint.cpp +++ /dev/null @@ -1,350 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "LockEndpoint.h" -#include - -using chip::to_underlying; - -bool LockEndpoint::Lock(const Optional & pin, OperationErrorEnum & err) -{ - return setLockState(DlLockState::kLocked, pin, err); -} - -bool LockEndpoint::Unlock(const Optional & pin, OperationErrorEnum & err) -{ - return setLockState(DlLockState::kUnlocked, pin, err); -} - -bool LockEndpoint::GetUser(uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user) const -{ - ChipLogDetail(Zcl, "Lock App: LockEndpoint::GetUser [endpoint=%d,userIndex=%hu]", mEndpointId, userIndex); - - auto adjustedUserIndex = static_cast(userIndex - 1); - if (adjustedUserIndex > mLockUsers.size()) - { - ChipLogError(Zcl, "Cannot get user - index out of range [endpoint=%d,index=%hu,adjustedIndex=%d]", mEndpointId, userIndex, - adjustedUserIndex); - return false; - } - - const auto & userInDb = mLockUsers[adjustedUserIndex]; - user.userStatus = userInDb.userStatus; - if (UserStatusEnum::kAvailable == user.userStatus) - { - ChipLogDetail(Zcl, "Found unoccupied user [endpoint=%d,adjustedIndex=%hu]", mEndpointId, adjustedUserIndex); - return true; - } - - user.userName = chip::CharSpan(userInDb.userName, strlen(userInDb.userName)); - user.credentials = chip::Span(userInDb.credentials.data(), userInDb.credentials.size()); - user.userUniqueId = userInDb.userUniqueId; - user.userType = userInDb.userType; - user.credentialRule = userInDb.credentialRule; - user.createdBy = userInDb.createdBy; - user.lastModifiedBy = userInDb.lastModifiedBy; - - ChipLogDetail(Zcl, - "Found occupied user " - "[endpoint=%d,adjustedIndex=%hu,name=\"%.*s\",credentialsCount=%u,uniqueId=%x,type=%u,credentialRule=%u," - "createdBy=%d,lastModifiedBy=%d]", - mEndpointId, adjustedUserIndex, static_cast(user.userName.size()), user.userName.data(), - static_cast(user.credentials.size()), user.userUniqueId, to_underlying(user.userType), - to_underlying(user.credentialRule), user.createdBy, user.lastModifiedBy); - - return true; -} - -bool LockEndpoint::SetUser(uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - const chip::CharSpan & userName, uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, - CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials) -{ - ChipLogProgress(Zcl, - "SetUser " - "[endpoint=%d,userIndex=%u,creator=%d,modifier=%d,userName=\"%.*s\",uniqueId=%" PRIx32 - ",userStatus=%u,userType=%u," - "credentialRule=%u,credentials=%p,totalCredentials=%u]", - mEndpointId, userIndex, creator, modifier, static_cast(userName.size()), userName.data(), uniqueId, - to_underlying(userStatus), to_underlying(usertype), to_underlying(credentialRule), credentials, - static_cast(totalCredentials)); - - auto adjustedUserIndex = static_cast(userIndex - 1); - if (adjustedUserIndex > mLockUsers.size()) - { - ChipLogError(Zcl, "Cannot set user - index out of range [endpoint=%d,index=%d,adjustedUserIndex=%u]", mEndpointId, - userIndex, adjustedUserIndex); - return false; - } - - auto & userInStorage = mLockUsers[adjustedUserIndex]; - if (userName.size() > DOOR_LOCK_MAX_USER_NAME_SIZE) - { - ChipLogError(Zcl, "Cannot set user - user name is too long [endpoint=%d,index=%d,adjustedUserIndex=%u]", mEndpointId, - userIndex, adjustedUserIndex); - return false; - } - - if (totalCredentials > userInStorage.credentials.capacity()) - { - ChipLogError(Zcl, - "Cannot set user - total number of credentials is too big [endpoint=%d,index=%d,adjustedUserIndex=%u" - ",totalCredentials=%u,maxNumberOfCredentials=%u]", - mEndpointId, userIndex, adjustedUserIndex, static_cast(totalCredentials), - static_cast(userInStorage.credentials.capacity())); - return false; - } - - chip::Platform::CopyString(userInStorage.userName, userName); - userInStorage.userName[userName.size()] = 0; - userInStorage.userUniqueId = uniqueId; - userInStorage.userStatus = userStatus; - userInStorage.userType = usertype; - userInStorage.credentialRule = credentialRule; - userInStorage.lastModifiedBy = modifier; - userInStorage.createdBy = creator; - - userInStorage.credentials.clear(); - for (size_t i = 0; i < totalCredentials; ++i) - { - userInStorage.credentials.push_back(credentials[i]); - } - - ChipLogProgress(Zcl, "Successfully set the user [mEndpointId=%d,index=%d,adjustedIndex=%d]", mEndpointId, userIndex, - adjustedUserIndex); - - return true; -} - -bool LockEndpoint::GetCredential(uint16_t credentialIndex, CredentialTypeEnum credentialType, - EmberAfPluginDoorLockCredentialInfo & credential) const -{ - ChipLogDetail(Zcl, "GetCredential [endpoint=%d,credentialIndex=%u,credentialType=%u]", mEndpointId, credentialIndex, - to_underlying(credentialType)); - - if (credentialIndex >= mLockCredentials.size() || - (0 == credentialIndex && CredentialTypeEnum::kProgrammingPIN != credentialType)) - { - ChipLogError(Zcl, "Cannot get the credential - index out of range [endpoint=%d,index=%d]", mEndpointId, credentialIndex); - return false; - } - - const auto & credentialInStorage = mLockCredentials[credentialIndex]; - - credential.status = credentialInStorage.status; - if (DlCredentialStatus::kAvailable == credential.status) - { - ChipLogDetail(Zcl, "Found unoccupied credential [endpoint=%d,index=%u]", mEndpointId, credentialIndex); - return true; - } - credential.credentialType = credentialInStorage.credentialType; - credential.credentialData = chip::ByteSpan(credentialInStorage.credentialData, credentialInStorage.credentialDataSize); - credential.createdBy = credentialInStorage.createdBy; - credential.lastModifiedBy = credentialInStorage.modifiedBy; - - ChipLogDetail(Zcl, "Found occupied credential [endpoint=%d,index=%u,type=%u,dataSize=%u,createdBy=%u,modifiedBy=%u]", - mEndpointId, credentialIndex, to_underlying(credential.credentialType), - static_cast(credential.credentialData.size()), credential.createdBy, credential.lastModifiedBy); - - return true; -} - -bool LockEndpoint::SetCredential(uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, - const chip::ByteSpan & credentialData) -{ - ChipLogDetail( - Zcl, - "SetCredential " - "[endpoint=%d,credentialIndex=%u,credentialStatus=%u,credentialType=%u,credentialDataSize=%u,creator=%u,modifier=%u]", - mEndpointId, credentialIndex, to_underlying(credentialStatus), to_underlying(credentialType), - static_cast(credentialData.size()), creator, modifier); - - if (credentialIndex >= mLockCredentials.size() || - (0 == credentialIndex && CredentialTypeEnum::kProgrammingPIN != credentialType)) - { - ChipLogError(Zcl, "Cannot set the credential - index out of range [endpoint=%d,index=%d]", mEndpointId, credentialIndex); - return false; - } - - auto & credentialInStorage = mLockCredentials[credentialIndex]; - if (credentialData.size() > DOOR_LOCK_CREDENTIAL_INFO_MAX_DATA_SIZE) - { - ChipLogError(Zcl, - "Cannot get the credential - data size exceeds limit " - "[endpoint=%d,index=%d,dataSize=%u,maxDataSize=%u]", - mEndpointId, credentialIndex, static_cast(credentialData.size()), - static_cast(DOOR_LOCK_CREDENTIAL_INFO_MAX_DATA_SIZE)); - return false; - } - credentialInStorage.status = credentialStatus; - credentialInStorage.credentialType = credentialType; - credentialInStorage.createdBy = creator; - credentialInStorage.modifiedBy = modifier; - std::memcpy(credentialInStorage.credentialData, credentialData.data(), credentialData.size()); - credentialInStorage.credentialDataSize = credentialData.size(); - - ChipLogProgress(Zcl, "Successfully set the credential [mEndpointId=%d,index=%d,credentialType=%u,creator=%u,modifier=%u]", - mEndpointId, credentialIndex, to_underlying(credentialType), credentialInStorage.createdBy, - credentialInStorage.modifiedBy); - - return true; -} - -DlStatus LockEndpoint::GetSchedule(uint8_t weekDayIndex, uint16_t userIndex, EmberAfPluginDoorLockWeekDaySchedule & schedule) -{ - if (0 == userIndex || userIndex > mWeekDaySchedules.size()) - { - return DlStatus::kFailure; - } - - if (0 == weekDayIndex || weekDayIndex > mWeekDaySchedules.at(userIndex - 1).size()) - { - return DlStatus::kFailure; - } - - const auto & scheduleInStorage = mWeekDaySchedules.at(userIndex - 1).at(weekDayIndex - 1); - if (DlScheduleStatus::kAvailable == scheduleInStorage.status) - { - return DlStatus::kNotFound; - } - - schedule = scheduleInStorage.schedule; - - return DlStatus::kSuccess; -} - -DlStatus LockEndpoint::SetSchedule(uint8_t weekDayIndex, uint16_t userIndex, DlScheduleStatus status, DaysMaskMap daysMask, - uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute) -{ - if (0 == userIndex || userIndex > mWeekDaySchedules.size()) - { - return DlStatus::kFailure; - } - - if (0 == weekDayIndex || weekDayIndex > mWeekDaySchedules.at(userIndex - 1).size()) - { - return DlStatus::kFailure; - } - - auto & scheduleInStorage = mWeekDaySchedules.at(userIndex - 1).at(weekDayIndex - 1); - - scheduleInStorage.schedule.daysMask = daysMask; - scheduleInStorage.schedule.startHour = startHour; - scheduleInStorage.schedule.startMinute = startMinute; - scheduleInStorage.schedule.endHour = endHour; - scheduleInStorage.schedule.endMinute = endMinute; - scheduleInStorage.status = status; - - return DlStatus::kSuccess; -} - -DlStatus LockEndpoint::GetSchedule(uint8_t yearDayIndex, uint16_t userIndex, EmberAfPluginDoorLockYearDaySchedule & schedule) -{ - if (0 == userIndex || userIndex > mYearDaySchedules.size()) - { - return DlStatus::kFailure; - } - - if (0 == yearDayIndex || yearDayIndex > mYearDaySchedules.at(userIndex - 1).size()) - { - return DlStatus::kFailure; - } - - const auto & scheduleInStorage = mYearDaySchedules.at(userIndex - 1).at(yearDayIndex - 1); - if (DlScheduleStatus::kAvailable == scheduleInStorage.status) - { - return DlStatus::kNotFound; - } - - schedule = scheduleInStorage.schedule; - - return DlStatus::kSuccess; -} - -DlStatus LockEndpoint::SetSchedule(uint8_t yearDayIndex, uint16_t userIndex, DlScheduleStatus status, uint32_t localStartTime, - uint32_t localEndTime) -{ - if (0 == userIndex || userIndex > mYearDaySchedules.size()) - { - return DlStatus::kFailure; - } - - if (0 == yearDayIndex || yearDayIndex > mYearDaySchedules.at(userIndex - 1).size()) - { - return DlStatus::kFailure; - } - - auto & scheduleInStorage = mYearDaySchedules.at(userIndex - 1).at(yearDayIndex - 1); - scheduleInStorage.schedule.localStartTime = localStartTime; - scheduleInStorage.schedule.localEndTime = localEndTime; - scheduleInStorage.status = status; - - return DlStatus::kSuccess; -} - -bool LockEndpoint::setLockState(DlLockState lockState, const Optional & pin, OperationErrorEnum & err) -{ - if (!pin.HasValue()) - { - ChipLogDetail(Zcl, "PIN code is not specified, setting door lock state to \"%s\" [endpointId=%d]", - lockStateToString(lockState), mEndpointId); - mLockState = lockState; - return true; - } - - // Check the PIN code - for (const auto & pinCredential : mLockCredentials) - { - if (pinCredential.credentialType != CredentialTypeEnum::kPin || pinCredential.status == DlCredentialStatus::kAvailable) - { - continue; - } - - chip::ByteSpan credentialData(pinCredential.credentialData, pinCredential.credentialDataSize); - if (credentialData.data_equal(pin.Value())) - { - ChipLogProgress(Zcl, "Setting door lock state to \"%s\" [endpointId=%d]", lockStateToString(lockState), mEndpointId); - - mLockState = lockState; - return true; - } - } - - ChipLogDetail(Zcl, - "Specified PIN code was not found in the database, ignoring command to set lock state to \"%s\" " - "[endpointId=%d]", - lockStateToString(lockState), mEndpointId); - - err = OperationErrorEnum::kInvalidCredential; - return false; -} - -const char * LockEndpoint::lockStateToString(DlLockState lockState) const -{ - switch (lockState) - { - case DlLockState::kNotFullyLocked: - return "Not Fully Locked"; - case DlLockState::kLocked: - return "Locked"; - case DlLockState::kUnlocked: - return "Unlocked"; - } - - return "Unknown"; -} diff --git a/examples/lock-app/openiotsdk/main/LockManager.cpp b/examples/lock-app/openiotsdk/main/LockManager.cpp deleted file mode 100644 index 68318b2d497b98..00000000000000 --- a/examples/lock-app/openiotsdk/main/LockManager.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "LockManager.h" - -#include - -#include -#include -#include - -using chip::to_underlying; - -LockManager LockManager::instance; - -LockManager & LockManager::Instance() -{ - return instance; -} - -bool LockManager::InitEndpoint(chip::EndpointId endpointId) -{ - uint16_t numberOfSupportedUsers = 0; - if (!DoorLockServer::Instance().GetNumberOfUserSupported(endpointId, numberOfSupportedUsers)) - { - ChipLogError(Zcl, - "Unable to get number of supported users when initializing lock endpoint, defaulting to 10 [endpointId=%d]", - endpointId); - numberOfSupportedUsers = CHIP_LOCK_MANAGER_USER_NUMBER; - } - - uint16_t numberOfSupportedCredentials = 0; - // We're planning to use shared storage for PIN and RFID users so we will have the maximum of both sizes her to simplify logic - uint16_t numberOfPINCredentialsSupported = 0; - uint16_t numberOfRFIDCredentialsSupported = 0; - if (!DoorLockServer::Instance().GetNumberOfPINCredentialsSupported(endpointId, numberOfPINCredentialsSupported) || - !DoorLockServer::Instance().GetNumberOfRFIDCredentialsSupported(endpointId, numberOfRFIDCredentialsSupported)) - { - ChipLogError( - Zcl, "Unable to get number of supported credentials when initializing lock endpoint, defaulting to 10 [endpointId=%d]", - endpointId); - numberOfSupportedCredentials = CHIP_LOCK_MANAGER_CREDENTIALS_NUMBER; - } - else - { - numberOfSupportedCredentials = std::max(numberOfPINCredentialsSupported, numberOfRFIDCredentialsSupported); - } - - uint8_t numberOfCredentialsSupportedPerUser = 0; - if (!DoorLockServer::Instance().GetNumberOfCredentialsSupportedPerUser(endpointId, numberOfCredentialsSupportedPerUser)) - { - ChipLogError(Zcl, - "Unable to get number of credentials supported per user when initializing lock endpoint, defaulting to 5 " - "[endpointId=%d]", - endpointId); - numberOfCredentialsSupportedPerUser = CHIP_LOCK_MANAGER_CREDENTIALS_PER_USER_NUMBER; - } - - uint8_t numberOfWeekDaySchedulesPerUser = 0; - if (!DoorLockServer::Instance().GetNumberOfWeekDaySchedulesPerUserSupported(endpointId, numberOfWeekDaySchedulesPerUser)) - { - ChipLogError(Zcl, - "Unable to get number of supported week day schedules per user when initializing lock endpoint, defaulting to " - "10 [endpointId=%d]", - endpointId); - numberOfWeekDaySchedulesPerUser = CHIP_LOCK_MANAGER_WEEK_DAY_SCHEDULES_PER_USER_NUMBER; - } - - uint8_t numberOfYearDaySchedulesPerUser = 0; - if (!DoorLockServer::Instance().GetNumberOfYearDaySchedulesPerUserSupported(endpointId, numberOfYearDaySchedulesPerUser)) - { - ChipLogError(Zcl, - "Unable to get number of supported year day schedules per user when initializing lock endpoint, defaulting to " - "10 [endpointId=%d]", - endpointId); - numberOfYearDaySchedulesPerUser = CHIP_LOCK_MANAGER_YEAR_DAY_SCHEDULES_PER_USER_NUMBER; - } - - mEndpoints.emplace_back(endpointId, numberOfSupportedUsers, numberOfSupportedCredentials, numberOfWeekDaySchedulesPerUser, - numberOfYearDaySchedulesPerUser, numberOfCredentialsSupportedPerUser); - - ChipLogProgress(Zcl, - "Initialized new lock door endpoint " - "[id=%d,users=%d,credentials=%d,weekDaySchedulesPerUser=%d,yearDaySchedulesPerUser=%d," - "numberOfCredentialsSupportedPerUser=%d]", - endpointId, numberOfSupportedUsers, numberOfSupportedCredentials, numberOfWeekDaySchedulesPerUser, - numberOfYearDaySchedulesPerUser, numberOfCredentialsSupportedPerUser); - - return true; -} - -bool LockManager::Lock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err) -{ - auto lockEndpoint = getEndpoint(endpointId); - if (nullptr == lockEndpoint) - { - ChipLogError(Zcl, "Unable to lock the door - endpoint does not exist or not initialized [endpointId=%d]", endpointId); - return false; - } - - VerifyOrReturnValue(lockEndpoint->Lock(pin, err), false); - - return DoorLockServer::Instance().SetLockState(endpointId, DlLockState::kLocked); -} - -bool LockManager::Unlock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err) -{ - auto lockEndpoint = getEndpoint(endpointId); - if (nullptr == lockEndpoint) - { - ChipLogError(Zcl, "Unable to unlock the door - endpoint does not exist or not initialized [endpointId=%d]", endpointId); - return false; - } - - VerifyOrReturnValue(lockEndpoint->Unlock(pin, err), false); - - return DoorLockServer::Instance().SetLockState(endpointId, DlLockState::kUnlocked); -} - -bool LockManager::GetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user) -{ - auto lockEndpoint = getEndpoint(endpointId); - if (nullptr == lockEndpoint) - { - ChipLogError(Zcl, "Unable to get the user - endpoint does not exist or not initialized [endpointId=%d]", endpointId); - return false; - } - return lockEndpoint->GetUser(userIndex, user); -} - -bool LockManager::SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - const chip::CharSpan & userName, uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, - CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials) -{ - auto lockEndpoint = getEndpoint(endpointId); - if (nullptr == lockEndpoint) - { - ChipLogError(Zcl, "Unable to set the user - endpoint does not exist or not initialized [endpointId=%d]", endpointId); - return false; - } - return lockEndpoint->SetUser(userIndex, creator, modifier, userName, uniqueId, userStatus, usertype, credentialRule, - credentials, totalCredentials); -} - -bool LockManager::GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, - EmberAfPluginDoorLockCredentialInfo & credential) -{ - auto lockEndpoint = getEndpoint(endpointId); - if (nullptr == lockEndpoint) - { - ChipLogError(Zcl, "Unable to get the credential - endpoint does not exist or not initialized [endpointId=%d]", endpointId); - return false; - } - return lockEndpoint->GetCredential(credentialIndex, credentialType, credential); -} - -bool LockManager::SetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, - chip::FabricIndex modifier, DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, - const chip::ByteSpan & credentialData) -{ - auto lockEndpoint = getEndpoint(endpointId); - if (nullptr == lockEndpoint) - { - ChipLogError(Zcl, "Unable to set the credential - endpoint does not exist or not initialized [endpointId=%d]", endpointId); - return false; - } - return lockEndpoint->SetCredential(credentialIndex, creator, modifier, credentialStatus, credentialType, credentialData); -} - -DlStatus LockManager::GetSchedule(chip::EndpointId endpointId, uint8_t weekDayIndex, uint16_t userIndex, - EmberAfPluginDoorLockWeekDaySchedule & schedule) -{ - auto lockEndpoint = getEndpoint(endpointId); - if (nullptr == lockEndpoint) - { - ChipLogError(Zcl, "Unable to get the week day schedule - endpoint does not exist or not initialized [endpointId=%d]", - endpointId); - return DlStatus::kFailure; - } - return lockEndpoint->GetSchedule(weekDayIndex, userIndex, schedule); -} - -DlStatus LockManager::SetSchedule(chip::EndpointId endpointId, uint8_t weekDayIndex, uint16_t userIndex, DlScheduleStatus status, - DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute) -{ - auto lockEndpoint = getEndpoint(endpointId); - if (nullptr == lockEndpoint) - { - ChipLogError(Zcl, "Unable to set the week day schedule - endpoint does not exist or not initialized [endpointId=%d]", - endpointId); - return DlStatus::kFailure; - } - return lockEndpoint->SetSchedule(weekDayIndex, userIndex, status, daysMask, startHour, startMinute, endHour, endMinute); -} - -DlStatus LockManager::GetSchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, - EmberAfPluginDoorLockYearDaySchedule & schedule) -{ - auto lockEndpoint = getEndpoint(endpointId); - if (nullptr == lockEndpoint) - { - ChipLogError(Zcl, "Unable to get the year day schedule - endpoint does not exist or not initialized [endpointId=%d]", - endpointId); - return DlStatus::kFailure; - } - return lockEndpoint->GetSchedule(yearDayIndex, userIndex, schedule); -} - -DlStatus LockManager::SetSchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, DlScheduleStatus status, - uint32_t localStartTime, uint32_t localEndTime) -{ - auto lockEndpoint = getEndpoint(endpointId); - if (nullptr == lockEndpoint) - { - ChipLogError(Zcl, "Unable to set the year day schedule - endpoint does not exist or not initialized [endpointId=%d]", - endpointId); - return DlStatus::kFailure; - } - return lockEndpoint->SetSchedule(yearDayIndex, userIndex, status, localStartTime, localEndTime); -} - -LockEndpoint * LockManager::getEndpoint(chip::EndpointId endpointId) -{ - for (auto & mEndpoint : mEndpoints) - { - if (mEndpoint.GetEndpointId() == endpointId) - { - return &mEndpoint; - } - } - return nullptr; -} diff --git a/examples/lock-app/openiotsdk/main/ZclCallbacks.cpp b/examples/lock-app/openiotsdk/main/ZclCallbacks.cpp deleted file mode 100644 index 0ebcf686bbebcc..00000000000000 --- a/examples/lock-app/openiotsdk/main/ZclCallbacks.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * - * Copyright (c) 2020-2021 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include "LockManager.h" - -using namespace chip; -using namespace chip::app::Clusters; -using namespace chip::app::Clusters::DoorLock; - -bool emberAfPluginDoorLockOnDoorLockCommand(chip::EndpointId endpointId, const Optional & pinCode, - OperationErrorEnum & err) -{ - return LockManager::Instance().Lock(endpointId, pinCode, err); -} - -bool emberAfPluginDoorLockOnDoorUnlockCommand(chip::EndpointId endpointId, const Optional & pinCode, - OperationErrorEnum & err) -{ - return LockManager::Instance().Unlock(endpointId, pinCode, err); -} - -bool emberAfPluginDoorLockGetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user) -{ - return LockManager::Instance().GetUser(endpointId, userIndex, user); -} - -bool emberAfPluginDoorLockSetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, - chip::FabricIndex modifier, const chip::CharSpan & userName, uint32_t uniqueId, - UserStatusEnum userStatus, UserTypeEnum usertype, CredentialRuleEnum credentialRule, - const CredentialStruct * credentials, size_t totalCredentials) -{ - - return LockManager::Instance().SetUser(endpointId, userIndex, creator, modifier, userName, uniqueId, userStatus, usertype, - credentialRule, credentials, totalCredentials); -} - -bool emberAfPluginDoorLockGetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, - EmberAfPluginDoorLockCredentialInfo & credential) -{ - return LockManager::Instance().GetCredential(endpointId, credentialIndex, credentialType, credential); -} - -bool emberAfPluginDoorLockSetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, - chip::FabricIndex modifier, DlCredentialStatus credentialStatus, - CredentialTypeEnum credentialType, const chip::ByteSpan & credentialData) -{ - return LockManager::Instance().SetCredential(endpointId, credentialIndex, creator, modifier, credentialStatus, credentialType, - credentialData); -} - -DlStatus emberAfPluginDoorLockGetSchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, - EmberAfPluginDoorLockWeekDaySchedule & schedule) -{ - return LockManager::Instance().GetSchedule(endpointId, weekdayIndex, userIndex, schedule); -} - -DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t weekdayIndex, uint16_t userIndex, - DlScheduleStatus status, DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, - uint8_t endHour, uint8_t endMinute) -{ - return LockManager::Instance().SetSchedule(endpointId, weekdayIndex, userIndex, status, daysMask, startHour, startMinute, - endHour, endMinute); -} - -DlStatus emberAfPluginDoorLockSetSchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, - DlScheduleStatus status, uint32_t localStartTime, uint32_t localEndTime) -{ - return LockManager::Instance().SetSchedule(endpointId, yearDayIndex, userIndex, status, localStartTime, localEndTime); -} - -DlStatus emberAfPluginDoorLockGetSchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, - EmberAfPluginDoorLockYearDaySchedule & schedule) -{ - return LockManager::Instance().GetSchedule(endpointId, yearDayIndex, userIndex, schedule); -} - -void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, - uint8_t * value) -{ - VerifyOrReturn(attributePath.mClusterId == DoorLock::Id && attributePath.mAttributeId == DoorLock::Attributes::LockState::Id); - - emberAfDoorLockClusterPrintln("Door Lock attribute changed"); -} - -void emberAfDoorLockClusterInitCallback(EndpointId endpoint) -{ - DoorLockServer::Instance().InitServer(endpoint); - LockManager::Instance().InitEndpoint(endpoint); -} diff --git a/examples/lock-app/openiotsdk/main/include/LockEndpoint.h b/examples/lock-app/openiotsdk/main/include/LockEndpoint.h deleted file mode 100644 index 069ab270707f1f..00000000000000 --- a/examples/lock-app/openiotsdk/main/include/LockEndpoint.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include -#include - -struct LockUserInfo -{ - char userName[DOOR_LOCK_USER_NAME_BUFFER_SIZE]; - uint32_t userUniqueId; - UserStatusEnum userStatus; - UserTypeEnum userType; - CredentialRuleEnum credentialRule; - std::vector credentials; - chip::FabricIndex createdBy; - chip::FabricIndex lastModifiedBy; -}; - -struct LockCredentialInfo; -struct WeekDaysScheduleInfo; -struct YearDayScheduleInfo; - -static constexpr size_t DOOR_LOCK_CREDENTIAL_INFO_MAX_DATA_SIZE = 20; - -class LockEndpoint -{ -public: - LockEndpoint(chip::EndpointId endpointId, uint16_t numberOfLockUsersSupported, uint16_t numberOfCredentialsSupported, - uint8_t weekDaySchedulesPerUser, uint8_t yearDaySchedulesPerUser, uint8_t numberOfCredentialsPerUser) : - mEndpointId{ endpointId }, - mLockState{ DlLockState::kLocked }, mLockUsers(numberOfLockUsersSupported), - mLockCredentials(numberOfCredentialsSupported + 1), - mWeekDaySchedules(numberOfLockUsersSupported, std::vector(weekDaySchedulesPerUser)), - mYearDaySchedules(numberOfLockUsersSupported, std::vector(yearDaySchedulesPerUser)) - { - for (auto & lockUser : mLockUsers) - { - lockUser.credentials.reserve(numberOfCredentialsPerUser); - } - } - - inline chip::EndpointId GetEndpointId() const { return mEndpointId; } - - bool Lock(const Optional & pin, OperationErrorEnum & err); - bool Unlock(const Optional & pin, OperationErrorEnum & err); - - bool GetUser(uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user) const; - bool SetUser(uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, const chip::CharSpan & userName, - uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, CredentialRuleEnum credentialRule, - const CredentialStruct * credentials, size_t totalCredentials); - - bool GetCredential(uint16_t credentialIndex, CredentialTypeEnum credentialType, - EmberAfPluginDoorLockCredentialInfo & credential) const; - - bool SetCredential(uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, - const chip::ByteSpan & credentialData); - - DlStatus GetSchedule(uint8_t weekDayIndex, uint16_t userIndex, EmberAfPluginDoorLockWeekDaySchedule & schedule); - DlStatus GetSchedule(uint8_t yearDayIndex, uint16_t userIndex, EmberAfPluginDoorLockYearDaySchedule & schedule); - DlStatus SetSchedule(uint8_t weekDayIndex, uint16_t userIndex, DlScheduleStatus status, DaysMaskMap daysMask, uint8_t startHour, - uint8_t startMinute, uint8_t endHour, uint8_t endMinute); - DlStatus SetSchedule(uint8_t yearDayIndex, uint16_t userIndex, DlScheduleStatus status, uint32_t localStartTime, - uint32_t localEndTime); - -private: - bool setLockState(DlLockState lockState, const Optional & pin, OperationErrorEnum & err); - const char * lockStateToString(DlLockState lockState) const; - - chip::EndpointId mEndpointId; - DlLockState mLockState; - - // This is very naive implementation of users/credentials/schedules database and by no means the best practice. Proper storage - // of those items is out of scope of this example. - std::vector mLockUsers; - std::vector mLockCredentials; - std::vector> mWeekDaySchedules; - std::vector> mYearDaySchedules; -}; - -struct LockCredentialInfo -{ - DlCredentialStatus status; - CredentialTypeEnum credentialType; - chip::FabricIndex createdBy; - chip::FabricIndex modifiedBy; - uint8_t credentialData[DOOR_LOCK_CREDENTIAL_INFO_MAX_DATA_SIZE]; - size_t credentialDataSize; -}; - -struct WeekDaysScheduleInfo -{ - DlScheduleStatus status; - EmberAfPluginDoorLockWeekDaySchedule schedule; -}; - -struct YearDayScheduleInfo -{ - DlScheduleStatus status; - EmberAfPluginDoorLockYearDaySchedule schedule; -}; diff --git a/examples/lock-app/openiotsdk/main/include/LockManager.h b/examples/lock-app/openiotsdk/main/include/LockManager.h deleted file mode 100644 index 349fee22adee8a..00000000000000 --- a/examples/lock-app/openiotsdk/main/include/LockManager.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include -#include -#include - -#include - -class LockManager -{ -public: - LockManager() {} - - bool InitEndpoint(chip::EndpointId endpointId); - - bool Lock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err); - bool Unlock(chip::EndpointId endpointId, const Optional & pin, OperationErrorEnum & err); - - bool GetUser(chip::EndpointId endpointId, uint16_t userIndex, EmberAfPluginDoorLockUserInfo & user); - bool SetUser(chip::EndpointId endpointId, uint16_t userIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - const chip::CharSpan & userName, uint32_t uniqueId, UserStatusEnum userStatus, UserTypeEnum usertype, - CredentialRuleEnum credentialRule, const CredentialStruct * credentials, size_t totalCredentials); - - bool GetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, CredentialTypeEnum credentialType, - EmberAfPluginDoorLockCredentialInfo & credential); - - bool SetCredential(chip::EndpointId endpointId, uint16_t credentialIndex, chip::FabricIndex creator, chip::FabricIndex modifier, - DlCredentialStatus credentialStatus, CredentialTypeEnum credentialType, - const chip::ByteSpan & credentialData); - - DlStatus GetSchedule(chip::EndpointId endpointId, uint8_t weekDayIndex, uint16_t userIndex, - EmberAfPluginDoorLockWeekDaySchedule & schedule); - DlStatus GetSchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, - EmberAfPluginDoorLockYearDaySchedule & schedule); - DlStatus SetSchedule(chip::EndpointId endpointId, uint8_t weekDayIndex, uint16_t userIndex, DlScheduleStatus status, - DaysMaskMap daysMask, uint8_t startHour, uint8_t startMinute, uint8_t endHour, uint8_t endMinute); - DlStatus SetSchedule(chip::EndpointId endpointId, uint8_t yearDayIndex, uint16_t userIndex, DlScheduleStatus status, - uint32_t localStartTime, uint32_t localEndTime); - - static LockManager & Instance(); - -private: - LockEndpoint * getEndpoint(chip::EndpointId endpointId); - - std::vector mEndpoints; - - static LockManager instance; -}; diff --git a/src/test_driver/openiotsdk/integration-tests/lock-app/test_app.py b/src/test_driver/openiotsdk/integration-tests/lock-app/test_app.py index b2fc33ef64ffff..72ff8fdd78d8c1 100644 --- a/src/test_driver/openiotsdk/integration-tests/lock-app/test_app.py +++ b/src/test_driver/openiotsdk/integration-tests/lock-app/test_app.py @@ -154,7 +154,7 @@ def test_lock_ctrl(device, controller): LOCK_CTRL_TEST_PIN_CODE), requestTimeoutMs=1000) assert err == 0 - ret = device.wait_for_output("Setting door lock state to \"Locked\" [endpointId={}]".format(LOCK_CTRL_TEST_ENDPOINT_ID)) + ret = device.wait_for_output("setting door lock state to \"Locked\"") assert ret is not None and len(ret) > 0 err, res = read_zcl_attribute( @@ -167,7 +167,7 @@ def test_lock_ctrl(device, controller): LOCK_CTRL_TEST_PIN_CODE), requestTimeoutMs=1000) assert err == 0 - ret = device.wait_for_output("Setting door lock state to \"Unlocked\" [endpointId={}]".format(LOCK_CTRL_TEST_ENDPOINT_ID)) + ret = device.wait_for_output("setting door lock state to \"Unlocked\"") assert ret is not None and len(ret) > 0 err, res = read_zcl_attribute(