diff --git a/.github/actions/bootstrap/action.yaml b/.github/actions/bootstrap/action.yaml index 66e6645fff4992..8f94830b8c0e51 100644 --- a/.github/actions/bootstrap/action.yaml +++ b/.github/actions/bootstrap/action.yaml @@ -1,8 +1,13 @@ name: Bootstrap description: Bootstrap +inputs: + platform: + description: "Platform name" + required: false + default: none runs: using: "composite" steps: - name: Bootstrap shell: bash - run: bash scripts/bootstrap.sh + run: bash scripts/bootstrap.sh -p all,${{ inputs.platform }} diff --git a/.github/actions/checkout-submodules-and-bootstrap/action.yaml b/.github/actions/checkout-submodules-and-bootstrap/action.yaml index 22b3629f0e7052..8226b7e7bd3d41 100644 --- a/.github/actions/checkout-submodules-and-bootstrap/action.yaml +++ b/.github/actions/checkout-submodules-and-bootstrap/action.yaml @@ -24,6 +24,8 @@ runs: uses: ./.github/actions/bootstrap-cache - name: Bootstrap uses: ./.github/actions/bootstrap + with: + platform: ${{ inputs.platform }} - name: Upload Bootstrap Logs uses: ./.github/actions/upload-bootstrap-logs with: diff --git a/.github/issue-labeler.yml b/.github/issue-labeler.yml index b4b6f70c8ada15..210ae86a24fbf6 100644 --- a/.github/issue-labeler.yml +++ b/.github/issue-labeler.yml @@ -1,8 +1,16 @@ darwin: - - "(ios|homepod|darwin|mac|macos)" + # Make sure we don't match random words that contain "mac" inside. + # + # Make sure we don't match random words that contain "ios" inside + # (like "kiosk" or whatnot), but do allow matching "ios8" and things + # like that. + # + # \\b means "word boundary" + # (?![a-z]) means "there is no next char in the range a-z". + - "/(\\bios(?![a-z])|homepod|darwin|\\bmac\\b|macos)/i" linux: - - "(linux)" + - "/(linux)/i" # Special Keywords for Cert Blockers air purifiers: diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index c462203ae6cd0d..48135fd924afa5 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -427,7 +427,7 @@ jobs: - name: Build Python REPL and example apps run: | - scripts/run_in_build_env.sh './scripts/build_python.sh --install_virtual_env out/venv --extra_packages "mobly"' + scripts/run_in_build_env.sh './scripts/build_python.sh --install_virtual_env out/venv' ./scripts/run_in_build_env.sh \ "./scripts/build/build_examples.py \ --target linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test \ diff --git a/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp b/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp index 66f86e5b28ab99..e6e18ab9edb32a 100644 --- a/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/smco-stub.cpp @@ -15,9 +15,173 @@ * limitations under the License. */ -#include +#include +#include -bool emberAfPluginSmokeCoAlarmSelfTestRequestCommand(chip::EndpointId endpointId) +#include + +using namespace chip; +using namespace chip::app::Clusters::SmokeCoAlarm; +using namespace chip::DeviceLayer; + +namespace { + +constexpr const uint16_t kSelfTestingTimeoutSec = 10; + +} // namespace + +static std::array sPriorityOrder = { + ExpressedStateEnum::kSmokeAlarm, ExpressedStateEnum::kInterconnectSmoke, ExpressedStateEnum::kCOAlarm, + ExpressedStateEnum::kInterconnectCO, ExpressedStateEnum::kHardwareFault, ExpressedStateEnum::kTesting, + ExpressedStateEnum::kEndOfService, ExpressedStateEnum::kBatteryAlert +}; + +void EndSelfTestingEventHandler(System::Layer * systemLayer, void * appState) +{ + SmokeCoAlarmServer::Instance().SetTestInProgress(1, false); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + + ChipLogProgress(Support, "[Smoke-CO-Alarm] => Self test complete"); +} + +bool emberAfPluginSmokeCoAlarmSelfTestRequestCommand(EndpointId endpointId) { + SmokeCoAlarmServer::Instance().SetTestInProgress(1, true); + + ChipLogProgress(Support, "[Smoke-CO-Alarm] => Self test running"); + + DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds32(kSelfTestingTimeoutSec), EndSelfTestingEventHandler, nullptr); + + return true; +} + +bool HandleSmokeCOTestEventTrigger(uint64_t eventTrigger) +{ + SmokeCOTrigger trigger = static_cast(eventTrigger); + + switch (trigger) + { + case SmokeCOTrigger::kForceSmokeCritical: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force smoke (critical)"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetSmokeState(1, AlarmStateEnum::kCritical), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kForceSmokeWarning: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force smoke (warning)"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetSmokeState(1, AlarmStateEnum::kWarning), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kForceSmokeInterconnect: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force smoke interconnect (warning)"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetInterconnectSmokeAlarm(1, AlarmStateEnum::kWarning), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kForceCOCritical: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force CO (critical)"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetCOState(1, AlarmStateEnum::kCritical), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kForceCOWarning: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force CO (warning)"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetCOState(1, AlarmStateEnum::kWarning), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kForceCOInterconnect: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force CO (warning)"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetInterconnectCOAlarm(1, AlarmStateEnum::kWarning), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kForceSmokeContaminationHigh: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force smoke contamination (critical)"); + SmokeCoAlarmServer::Instance().SetContaminationState(1, ContaminationStateEnum::kCritical); + break; + case SmokeCOTrigger::kForceSmokeContaminationLow: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force smoke contamination (warning)"); + SmokeCoAlarmServer::Instance().SetContaminationState(1, ContaminationStateEnum::kLow); + break; + case SmokeCOTrigger::kForceSmokeSensitivityHigh: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force smoke sensistivity (high)"); + SmokeCoAlarmServer::Instance().SetSmokeSensitivityLevel(1, SensitivityEnum::kHigh); + break; + case SmokeCOTrigger::kForceSmokeSensitivityLow: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force smoke sensitivity (low)"); + SmokeCoAlarmServer::Instance().SetSmokeSensitivityLevel(1, SensitivityEnum::kLow); + break; + case SmokeCOTrigger::kForceMalfunction: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force malfunction"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetHardwareFaultAlert(1, true), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kForceLowBatteryWarning: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force low battery (warning)"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetBatteryAlert(1, AlarmStateEnum::kWarning), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kForceLowBatteryCritical: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force low battery (critical)"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetBatteryAlert(1, AlarmStateEnum::kCritical), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kForceEndOfLife: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force end-of-life"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetEndOfServiceAlert(1, EndOfServiceEnum::kExpired), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kForceSilence: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force silence"); + SmokeCoAlarmServer::Instance().SetDeviceMuted(1, MuteStateEnum::kMuted); + break; + case SmokeCOTrigger::kClearSmoke: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Clear smoke"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetSmokeState(1, AlarmStateEnum::kNormal), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kClearCO: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Clear CO"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetCOState(1, AlarmStateEnum::kNormal), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kClearSmokeInterconnect: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Clear smoke interconnect"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetInterconnectSmokeAlarm(1, AlarmStateEnum::kNormal), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kClearCOInterconnect: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Clear CO interconnect"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetInterconnectCOAlarm(1, AlarmStateEnum::kNormal), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kClearMalfunction: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Clear malfunction"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetHardwareFaultAlert(1, false), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kClearEndOfLife: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Clear end-of-life"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetEndOfServiceAlert(1, EndOfServiceEnum::kNormal), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kClearSilence: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Clear silence"); + SmokeCoAlarmServer::Instance().SetDeviceMuted(1, MuteStateEnum::kNotMuted); + break; + case SmokeCOTrigger::kClearBatteryLevelLow: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Clear low battery"); + VerifyOrReturnValue(SmokeCoAlarmServer::Instance().SetBatteryAlert(1, AlarmStateEnum::kNormal), true); + SmokeCoAlarmServer::Instance().SetExpressedStateByPriority(1, sPriorityOrder); + break; + case SmokeCOTrigger::kClearContamination: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Force SmokeContamination (warning)"); + SmokeCoAlarmServer::Instance().SetContaminationState(1, ContaminationStateEnum::kNormal); + break; + case SmokeCOTrigger::kClearSensitivity: + ChipLogProgress(Support, "[Smoke-CO-Alarm-Test-Event] => Clear Smoke Sensitivity"); + SmokeCoAlarmServer::Instance().SetSmokeSensitivityLevel(1, SensitivityEnum::kStandard); + break; + default: + + return false; + } + return true; } diff --git a/examples/all-clusters-app/linux/.kvs b/examples/all-clusters-app/linux/.kvs deleted file mode 100644 index 9976ff5b8b7caf..00000000000000 --- a/examples/all-clusters-app/linux/.kvs +++ /dev/null @@ -1,28 +0,0 @@ -[DEFAULT] -f/1/ac/0/0=FSQBBSQCAjYDBmm2AQAYNAQY -f/1/g=FSQBACQCACQDACQEACQFACQGASQHABg= -f/1/i=FTABAQEkAgE3AyQUARgmBIAigScmBYAlTTo3BiQTAhgkBwEkCAEwCUEE3KqJqpPwju/MeqShRDFpusi544wfWj6+gYRG/nor4oHRLfTRz4+zihd9ONWqQ9zwA/CQomn+sjmIvbcRYIYh2DcKNQEpARgkAmAwBBQPVaSOYFdX6pOarWj2mXieOQsSJzAFFGx6kZSTgFw3YQDgKHYjei851xbkGDALQPRuk4wx/ZAQXSmais4GD0JyZl9Jwxq1MM8TUdUQ1nCQ0Q/VuHZqy0pR9HxjgLUDPy2b4YFJIT1rIf8ZYHAeaCMY -f/1/k/0=FSQBACQCATYDFScEUAIAAOx/AAAlBVRMMAYQ7QtLfz7zOjEY6QUsagDDPRgVJAQAJAUAMAYQAAAAAAAAAAAAAAAAAAAAABgVJAQAJAUAMAYQAAAAAAAAAAAAAAAAAAAAABgYJQf//xg= -f/1/m=FSUA8f8sAQAY -f/1/n=FTABAQEkAgE3AyQTAhgmBIAigScmBYAlTTo3BiQVASYRIUM0EhgkBwEkCAEwCUEE7R7vwTlybDjtGBspWXkUMSnID4um6q91pa7EQdCSIioP+AgPAA3zqzXyYunmoZbVijM9UbzOUhvacYvA+2xanzcKNQEoARgkAgE2AwQCBAEYMAQUi5rGWgAt12jH/3fxeswo+bhw+YcwBRQPVaSOYFdX6pOarWj2mXieOQsSJxgwC0AtXja1zqi99vqxUOcDooFbR7g3dR6FHR/DjYJOy2QgtY0m1Krqo9Whb9A//TtnLTpsXj+DKnl4cBJ6Zb1WGdhrGA== -f/1/o=FSQAATABYQTtHu/BOXJsOO0YGylZeRQxKcgPi6bqr3WlrsRB0JIiKg/4CA8ADfOrNfJi6eahltWKMz1RvM5SG9pxi8D7bFqftpuGwM3zJ0gq/ZXqozNld3ZK32h4PWWNKTlq3zM9wUEY -f/1/r=FTABAQEkAgE3AyQUARgmBIAigScmBYAlTTo3BiQUARgkBwEkCAEwCUEECT5tju37pQzMYxhc2pumcwtyKq7elKv8mcWFxDqluOWVK6RJYxiytMv4NQA+JFg/rN8AVPzfz2txBhBJKEF0UDcKNQEpARgkAmAwBBRsepGUk4BcN2EA4Ch2I3ovOdcW5DAFFGx6kZSTgFw3YQDgKHYjei851xbkGDALQBPAPvpTcPaJ51tb6/5sPfKuU6QWe2ClszX+T9fCPL4ZSeJZq0ukzeGMqOgnlAh3MVzkugI2IKdO9e/lcAib04QY -f/1/s/000000000001B669=FTADEO0xJXt8dKE+RAjHrjhJCREwBCAkLjwW/9P1MAh7PKST7kCABWTyP5W6JnAccoRVc8JXPDAFDAAAAAAAAAAAAAAAABg= -g/a/0/2b/0=BWVuLVVT -g/a/1/102/7=Gw== -g/a/1/300/4001=Ag== -g/a/1/300/7=AAA= -g/a/1/8/0=/g== -g/fidx=FSQAAjYBBAEYGA== -g/gcc=E0Y8Aw== -g/gdc=PtW/BQ== -g/gfl=FSQBASQCARg= -g/im/ec=AAABAAAAAAA= -g/lkgt=FSYAgwxNLBg= -g/s/7TEle3x0oT5ECMeuOEkJEQ\x3d\x3d=FSQBASYCabYBABg= -g/sri=FhUkAQEmAmm2AQAYGA== -g/sum=MAA= -g/ts/tz=FhUgAAAkAQAsAkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGBg= -wifi-pass= -wifi-ssid= - diff --git a/examples/all-clusters-app/linux/args.gni b/examples/all-clusters-app/linux/args.gni index c4c9a18cec9cf5..1bcd86f18843b8 100644 --- a/examples/all-clusters-app/linux/args.gni +++ b/examples/all-clusters-app/linux/args.gni @@ -27,3 +27,4 @@ chip_project_config_include_dirs += [ "${chip_root}/config/standalone" ] matter_enable_tracing_support = true matter_log_json_payload_decode_full = true matter_log_json_payload_hex = true +chip_enable_smoke_co_trigger = true diff --git a/examples/all-clusters-app/tizen/BUILD.gn b/examples/all-clusters-app/tizen/BUILD.gn index 484732400b64f1..8bf7f00152148f 100644 --- a/examples/all-clusters-app/tizen/BUILD.gn +++ b/examples/all-clusters-app/tizen/BUILD.gn @@ -34,6 +34,7 @@ source_set("chip-all-clusters-common") { deps = [ "${chip_root}/examples/all-clusters-app/all-clusters-common", + "${chip_root}/examples/platform/tizen:app-main", "${chip_root}/src/lib/shell:shell_core", ] diff --git a/examples/all-clusters-minimal-app/tizen/BUILD.gn b/examples/all-clusters-minimal-app/tizen/BUILD.gn index 5485fdd469d223..99f857e86303ea 100644 --- a/examples/all-clusters-minimal-app/tizen/BUILD.gn +++ b/examples/all-clusters-minimal-app/tizen/BUILD.gn @@ -31,6 +31,7 @@ source_set("chip-all-clusters-common") { deps = [ "${chip_root}/examples/all-clusters-minimal-app/all-clusters-common", + "${chip_root}/examples/platform/tizen:app-main", "${chip_root}/src/lib/shell:shell_core", ] diff --git a/examples/platform/linux/AppMain.cpp b/examples/platform/linux/AppMain.cpp index 22ff4d2db71cb6..ea52a49e79634a 100644 --- a/examples/platform/linux/AppMain.cpp +++ b/examples/platform/linux/AppMain.cpp @@ -75,6 +75,9 @@ #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR #include #endif +#if CHIP_DEVICE_CONFIG_ENABLE_SMOKE_CO_TRIGGER +#include +#endif #include #include @@ -522,6 +525,12 @@ void ChipLinuxAppMainLoop(AppMainLoopImplementation * impl) static OTATestEventTriggerDelegate otaTestEventTriggerDelegate{ ByteSpan( LinuxDeviceOptions::GetInstance().testEventTriggerEnableKey) }; otherDelegate = &otaTestEventTriggerDelegate; +#endif +#if CHIP_DEVICE_CONFIG_ENABLE_SMOKE_CO_TRIGGER + static SmokeCOTestEventTriggerDelegate smokeCOTestEventTriggerDelegate{ + ByteSpan(LinuxDeviceOptions::GetInstance().testEventTriggerEnableKey), otherDelegate + }; + otherDelegate = &smokeCOTestEventTriggerDelegate; #endif // For general testing of TestEventTrigger, we have a common "core" event trigger delegate. static SampleTestEventTriggerDelegate testEventTriggerDelegate; diff --git a/examples/platform/linux/BUILD.gn b/examples/platform/linux/BUILD.gn index 8427fe8aa80104..44a96b12c00604 100644 --- a/examples/platform/linux/BUILD.gn +++ b/examples/platform/linux/BUILD.gn @@ -19,6 +19,10 @@ import("${chip_root}/src/lib/core/core.gni") import("${chip_root}/src/lib/lib.gni") import("${chip_root}/src/tracing/tracing_args.gni") +declare_args() { + chip_enable_smoke_co_trigger = false +} + config("app-main-config") { include_dirs = [ "." ] } @@ -29,6 +33,10 @@ source_set("ota-test-event-trigger") { ] } +source_set("smco-test-event-trigger") { + sources = [ "${chip_root}/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.h" ] +} + source_set("app-main") { defines = [ "ENABLE_TRACING=${matter_enable_tracing_support}" ] sources = [ @@ -51,6 +59,7 @@ source_set("app-main") { ] public_deps = [ + ":smco-test-event-trigger", "${chip_root}/src/lib", "${chip_root}/src/platform/logging:force_stdio", ] @@ -85,6 +94,10 @@ source_set("app-main") { ] } + if (chip_enable_smoke_co_trigger) { + defines += [ "CHIP_DEVICE_CONFIG_ENABLE_SMOKE_CO_TRIGGER=1" ] + } + public_configs = [ ":app-main-config" ] } diff --git a/examples/platform/silabs/efr32/rs911x/rsi_if.c b/examples/platform/silabs/efr32/rs911x/rsi_if.c index 900e07a42ce235..a2e0f563727fbe 100644 --- a/examples/platform/silabs/efr32/rs911x/rsi_if.c +++ b/examples/platform/silabs/efr32/rs911x/rsi_if.c @@ -184,7 +184,7 @@ int32_t wfx_rsi_disconnect() return status; } -#if CHIP_CONFIG_ENABLE_ICD_SERVER +#if SL_ICD_ENABLED /****************************************************************** * @fn wfx_rsi_power_save() * @brief @@ -215,7 +215,7 @@ int32_t wfx_rsi_power_save() SILABS_LOG("Powersave Config Success"); return status; } -#endif /* CHIP_CONFIG_ENABLE_ICD_SERVER */ +#endif /* SL_ICD_ENABLED */ /****************************************************************** * @fn wfx_rsi_join_cb(uint16_t status, const uint8_t *buf, const uint16_t len) diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsi.h b/examples/platform/silabs/efr32/rs911x/wfx_rsi.h index d793244aa23cca..2275549ef7af41 100644 --- a/examples/platform/silabs/efr32/rs911x/wfx_rsi.h +++ b/examples/platform/silabs/efr32/rs911x/wfx_rsi.h @@ -90,9 +90,9 @@ int32_t wfx_rsi_get_ap_info(wfx_wifi_scan_result_t * ap); int32_t wfx_rsi_get_ap_ext(wfx_wifi_scan_ext_t * extra_info); int32_t wfx_rsi_reset_count(); int32_t wfx_rsi_disconnect(); -#if CHIP_CONFIG_ENABLE_ICD_SERVER +#if SL_ICD_ENABLED int32_t wfx_rsi_power_save(); -#endif /* CHIP_CONFIG_ENABLE_ICD_SERVER */ +#endif /* SL_ICD_ENABLED */ #ifdef __cplusplus } diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c index a448f3a0a45667..4b75a7b0c30411 100644 --- a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c +++ b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c @@ -193,7 +193,7 @@ sl_status_t wfx_connect_to_ap(void) return SL_STATUS_OK; } -#if CHIP_CONFIG_ENABLE_ICD_SERVER +#if SL_ICD_ENABLED /********************************************************************* * @fn sl_status_t wfx_power_save() * @brief @@ -210,7 +210,7 @@ sl_status_t wfx_power_save() } return SL_STATUS_OK; } -#endif /* CHIP_CONFIG_ENABLE_ICD_SERVER */ +#endif /* SL_ICD_ENABLED */ /********************************************************************* * @fn void wfx_setup_ip6_link_local(sl_wfx_interface_t whichif) diff --git a/examples/platform/telink/common/src/AppTaskCommon.cpp b/examples/platform/telink/common/src/AppTaskCommon.cpp index 41d3a0c3e3fec5..a59f660a8a7788 100644 --- a/examples/platform/telink/common/src/AppTaskCommon.cpp +++ b/examples/platform/telink/common/src/AppTaskCommon.cpp @@ -157,6 +157,7 @@ class AppFabricTableDelegate : public FabricTable::Delegate { if (chip::Server::GetInstance().GetFabricTable().FabricCount() == 0) { + bool isCommissioningFailed = chip::Server::GetInstance().GetCommissioningWindowManager().IsCommissioningWindowOpen(); ChipLogProgress(DeviceLayer, "Performing erasing of settings partition"); #ifdef CONFIG_CHIP_FACTORY_RESET_ERASE_NVS @@ -168,9 +169,12 @@ class AppFabricTableDelegate : public FabricTable::Delegate status = nvs_clear(static_cast(storage)); } - if (!status) + if (!isCommissioningFailed) { - status = nvs_mount(static_cast(storage)); + if (!status) + { + status = nvs_mount(static_cast(storage)); + } } if (status) @@ -187,6 +191,10 @@ class AppFabricTableDelegate : public FabricTable::Delegate ConnectivityMgr().ErasePersistentInfo(); #endif + if (isCommissioningFailed) + { + PlatformMgr().Shutdown(); + } } } }; diff --git a/integrations/docker/images/base/chip-build/version b/integrations/docker/images/base/chip-build/version index dfab429dbd9f0a..ca7bc016f5ad62 100644 --- a/integrations/docker/images/base/chip-build/version +++ b/integrations/docker/images/base/chip-build/version @@ -1 +1 @@ -5 : Use west to download the K32W0 SDK +8 : Update Silabs GSDK to v4.3.1 diff --git a/integrations/docker/images/chip-cert-bins/Dockerfile b/integrations/docker/images/chip-cert-bins/Dockerfile index 47d7cc0b606742..6c3872df43102e 100644 --- a/integrations/docker/images/chip-cert-bins/Dockerfile +++ b/integrations/docker/images/chip-cert-bins/Dockerfile @@ -3,7 +3,7 @@ FROM ubuntu:22.04 as chip-build-cert LABEL org.opencontainers.image.source https://github.com/project-chip/connectedhomeip ARG TARGETPLATFORM # COMMITHASH defines the target commit to build from. May be passed in using --build-arg. -ARG COMMITHASH=7b99e6399c6069037c613782d78132c69b9dcabb +ARG COMMITHASH=c1ec2d777456924dcaa59b53351b00d73caf378f # Ensure TARGETPLATFORM is set RUN case ${TARGETPLATFORM} in \ @@ -268,5 +268,11 @@ COPY --from=chip-build-cert-bins /root/connectedhomeip/out/chip-app1 chip-app1 # Stage 3.1 Setup the Matter Python environment COPY --from=chip-build-cert-bins /root/connectedhomeip/out/python_lib python_lib COPY --from=chip-build-cert-bins /root/connectedhomeip/src/python_testing python_testing -RUN pip install click websockets lark diskcache + +COPY --from=chip-build-cert-bins /root/connectedhomeip/scripts/tests/requirements.txt /tmp/requirements.txt +RUN pip install -r /tmp/requirements.txt && rm /tmp/requirements.txt + +COPY --from=chip-build-cert-bins /root/connectedhomeip/src/python_testing/requirements.txt /tmp/requirements.txt +RUN pip install -r /tmp/requirements.txt && rm /tmp/requirements.txt + RUN pip install --no-cache-dir python_lib/controller/python/chip*.whl diff --git a/integrations/docker/images/stage-2/chip-build-efr32/Dockerfile b/integrations/docker/images/stage-2/chip-build-efr32/Dockerfile index 1946a0e6073717..619dcb870ba2b2 100644 --- a/integrations/docker/images/stage-2/chip-build-efr32/Dockerfile +++ b/integrations/docker/images/stage-2/chip-build-efr32/Dockerfile @@ -17,8 +17,8 @@ RUN set -x \ && : # last line -#Clone Gecko SDK 4.2.0 (ef05eb6) -RUN git clone --depth=1 --branch=v4.2.3 https://github.com/SiliconLabs/gecko_sdk.git && \ +#Clone Gecko SDK 4.3.1 (2ba59bf) +RUN git clone --depth=1 --branch=v4.3.1 https://github.com/SiliconLabs/gecko_sdk.git && \ cd gecko_sdk && \ rm -rf .git \ && : # last line diff --git a/integrations/docker/images/stage-2/chip-build-k32w/Dockerfile b/integrations/docker/images/stage-2/chip-build-k32w/Dockerfile index dd629a9824c6ee..5bc74d4410c668 100644 --- a/integrations/docker/images/stage-2/chip-build-k32w/Dockerfile +++ b/integrations/docker/images/stage-2/chip-build-k32w/Dockerfile @@ -22,8 +22,15 @@ RUN set -x \ && cp -R examples/* core/boards && rm -rf examples \ && : # last line +RUN set -x \ + && mkdir -p k32w1 \ + && wget https://cache.nxp.com/lgfiles/bsps/SDK_2_12_5_K32W148-EVK.zip \ + && unzip SDK_2_12_5_K32W148-EVK.zip -d k32w1 \ + && rm -rf SDK_2_12_5_K32W148-EVK.zip + FROM ghcr.io/project-chip/chip-build:${VERSION} COPY --from=build /opt/sdk/ /opt/sdk/ ENV NXP_K32W0_SDK_ROOT=/opt/sdk/core +ENV NXP_K32W1_SDK_ROOT=/opt/sdk/k32w1 diff --git a/integrations/docker/images/vscode/chip-build-vscode/Dockerfile b/integrations/docker/images/vscode/chip-build-vscode/Dockerfile index bf90c8ae7dfedf..4f924867fdc05c 100644 --- a/integrations/docker/images/vscode/chip-build-vscode/Dockerfile +++ b/integrations/docker/images/vscode/chip-build-vscode/Dockerfile @@ -48,7 +48,7 @@ COPY --from=crosscompile /opt/ubuntu-22.04.1-aarch64-sysroot /opt/ubuntu-22.04.1 COPY --from=ameba /opt/ameba /opt/ameba -COPY --from=k32w /opt/sdk /opt/k32w_sdk +COPY --from=k32w /opt/sdk /opt/k32w COPY --from=imx /opt/fsl-imx-xwayland /opt/fsl-imx-xwayland @@ -104,7 +104,8 @@ ENV IDF_TOOLS_PATH=/opt/espressif/tools ENV IMX_SDK_ROOT=/opt/fsl-imx-xwayland/6.1-langdale ENV JAVA_PATH=/usr/lib/jvm/java-8-openjdk-amd64 ENV NRF5_TOOLS_ROOT=/opt/NordicSemiconductor/nRF5_tools -ENV NXP_K32W0_SDK_ROOT=/opt/k32w_sdk +ENV NXP_K32W0_SDK_ROOT=/opt/k32w/core +ENV NXP_K32W1_SDK_ROOT=/opt/k32w/k32w1 ENV OPENOCD_PATH=/opt/openocd/ ENV PW_ENVIRONMENT_ROOT=/home/vscode/pigweed/env ENV QEMU_ESP32=/opt/espressif/qemu/xtensa-softmmu/qemu-system-xtensa @@ -112,7 +113,7 @@ ENV QEMU_ESP32_DIR=/opt/espressif/qemu ENV SYSROOT_AARCH64=/opt/ubuntu-22.04.1-aarch64-sysroot ENV TELINK_ZEPHYR_BASE=/opt/telink/zephyrproject/zephyr ENV TELINK_ZEPHYR_SDK_DIR=/opt/telink/zephyr-sdk-0.16.1 -ENV TI_SYSCONFIG_ROOT=/opt/ti/sysconfig_1.13.0 +ENV TI_SYSCONFIG_ROOT=/opt/ti/sysconfig_1.15.0 ENV ZEPHYR_BASE=/opt/NordicSemiconductor/nrfconnect/zephyr ENV ZEPHYR_SDK_INSTALL_DIR=/opt/NordicSemiconductor/nRF5_tools/zephyr-sdk-0.16.0 ENV ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb diff --git a/scripts/build_python.sh b/scripts/build_python.sh index 08ad42965d5b99..5a0a12f9df84fe 100755 --- a/scripts/build_python.sh +++ b/scripts/build_python.sh @@ -64,7 +64,8 @@ Input Options: represents where the virtual environment is to be created. -c, --clean_virtual_env When installing a virtual environment, create/clean it first. Defaults to yes. - --include_pytest_deps Install requirements.python_tests.txt. + --include_pytest_deps Install requirements.txt for running scripts/tests and + src/python_testing scripts. Defaults to yes. --extra_packages PACKAGES Install extra Python packages from PyPI --include_yamltests Whether to install the matter_yamltests wheel. @@ -214,7 +215,8 @@ if [ -n "$install_virtual_env" ]; then if [ "$install_pytest_requirements" = "yes" ]; then echo_blue "Installing python test dependencies ..." - "$ENVIRONMENT_ROOT"/bin/pip install -r "$CHIP_ROOT/scripts/setup/requirements.python_tests.txt" + "$ENVIRONMENT_ROOT"/bin/pip install -r "$CHIP_ROOT/scripts/tests/requirements.txt" + "$ENVIRONMENT_ROOT"/bin/pip install -r "$CHIP_ROOT/src/python_testing/requirements.txt" fi echo "" diff --git a/scripts/py_matter_idl/setup.cfg b/scripts/py_matter_idl/setup.cfg index 2a7d386375a2e7..57f93c3dd9aa82 100644 --- a/scripts/py_matter_idl/setup.cfg +++ b/scripts/py_matter_idl/setup.cfg @@ -21,6 +21,10 @@ description = Parse matter idl files [options] packages = find: zip_safe = False +install_requires= + lark + jinja2 + stringcase [options.package_data] matter_idl = diff --git a/scripts/py_matter_yamltests/setup.cfg b/scripts/py_matter_yamltests/setup.cfg index 497022ce1459d9..a3c7983e7299cd 100644 --- a/scripts/py_matter_yamltests/setup.cfg +++ b/scripts/py_matter_yamltests/setup.cfg @@ -20,5 +20,8 @@ description = Parse matter yaml tests files [options] packages = find: - zip_safe = False +install_requires= + diskcache + lark + websockets diff --git a/scripts/setup/requirements.all.txt b/scripts/setup/requirements.all.txt index 378959cce0f17e..2cccfdbf84db03 100644 --- a/scripts/setup/requirements.all.txt +++ b/scripts/setup/requirements.all.txt @@ -8,16 +8,9 @@ virtualenv -c constraints.esp32.txt -r requirements.esp32.txt --r requirements.mbed.txt --r requirements.bouffalolab.txt --r requirements.openiotsdk.txt --r requirements.infineon.txt --r requirements.ti.txt --r requirements.telink.txt -r requirements.zephyr.txt -r requirements.cirque.txt -r requirements.memory.txt --r requirements.yaml_tests.txt # device controller wheel package wheel; sys_platform == 'linux' @@ -26,6 +19,14 @@ pyobjc-core; sys_platform == 'darwin' pyobjc-framework-cocoa; sys_platform == 'darwin' pyobjc-framework-corebluetooth; sys_platform == 'darwin' +# python unit tests run directly without installing +# built venv +# +# TODO: this should change in the Future +diskcache +lark +websockets + # mobly tests portpicker mobly diff --git a/scripts/setup/requirements.python_tests.txt b/scripts/setup/requirements.python_tests.txt deleted file mode 100644 index 92d6db9016814e..00000000000000 --- a/scripts/setup/requirements.python_tests.txt +++ /dev/null @@ -1,16 +0,0 @@ -# scripts/tests -click -colorama -diskcache -websockets - -# scripts/py_matter_idl -# TODO: these should be wheel dependencies -lark -jinja2 -stringcase - -# src/python_testing -mobly -pyasn1 -pyasn1_modules diff --git a/scripts/setup/requirements.yaml_tests.txt b/scripts/setup/requirements.yaml_tests.txt deleted file mode 100644 index 7fc0c5f653c194..00000000000000 --- a/scripts/setup/requirements.yaml_tests.txt +++ /dev/null @@ -1,2 +0,0 @@ -diskcache -websockets diff --git a/scripts/tests/chiptest/__init__.py b/scripts/tests/chiptest/__init__.py index e3d2f25d2db368..29942b0a2e2ac4 100644 --- a/scripts/tests/chiptest/__init__.py +++ b/scripts/tests/chiptest/__init__.py @@ -170,6 +170,9 @@ def _GetChipReplUnsupportedTests() -> Set[str]: "Test_TC_DRLK_2_8.yaml", # Test fails only in chip-repl: Refer--> https://github.com/project-chip/connectedhomeip/pull/27011#issuecomment-1593339855 "Test_TC_ACE_1_6.yaml", # Test fails only in chip-repl: Refer--> https://github.com/project-chip/connectedhomeip/pull/27910#issuecomment-1632485584 "Test_TC_IDM_1_2.yaml", # chip-repl does not support AnyCommands (19/07/2023) + "Test_TC_DRLK_2_2.yaml", # chip-repl does not support EqualityCommands pseudo-cluster (08/04/2023) + "Test_TC_DRLK_2_3.yaml", # chip-repl does not support EqualityCommands pseudo-cluster (08/04/2023) + "Test_TC_DRLK_2_12.yaml", # chip-repl does not support EqualityCommands pseudo-cluster (08/04/2023) "TestGroupKeyManagementCluster.yaml", # chip-repl does not support EqualityCommands (2023-08-04) "Test_TC_S_2_2.yaml", # chip-repl does not support scenes cluster commands "Test_TC_S_2_3.yaml", # chip-repl does not support scenes cluster commands diff --git a/scripts/tests/requirements.txt b/scripts/tests/requirements.txt new file mode 100644 index 00000000000000..d3c26e9cba23c6 --- /dev/null +++ b/scripts/tests/requirements.txt @@ -0,0 +1,5 @@ +# Python requirements for scripts in this location +click +colorama +diskcache +websockets diff --git a/src/app/CommandHandler.cpp b/src/app/CommandHandler.cpp index 14ad098965f5e5..cd67ffd59e436f 100644 --- a/src/app/CommandHandler.cpp +++ b/src/app/CommandHandler.cpp @@ -272,7 +272,7 @@ Status CommandHandler::ProcessCommandDataIB(CommandDataIB::Parser & aCommandElem ChipLogDetail(DataManagement, "No command " ChipLogFormatMEI " in Cluster " ChipLogFormatMEI " on Endpoint 0x%x", ChipLogValueMEI(concretePath.mCommandId), ChipLogValueMEI(concretePath.mClusterId), concretePath.mEndpointId); - return AddStatus(concretePath, commandExists) != CHIP_NO_ERROR ? Status::Failure : Status::Success; + return FallibleAddStatus(concretePath, commandExists) != CHIP_NO_ERROR ? Status::Failure : Status::Success; } } @@ -287,10 +287,10 @@ Status CommandHandler::ProcessCommandDataIB(CommandDataIB::Parser & aCommandElem { if (err != CHIP_ERROR_ACCESS_DENIED) { - return AddStatus(concretePath, Status::Failure) != CHIP_NO_ERROR ? Status::Failure : Status::Success; + return FallibleAddStatus(concretePath, Status::Failure) != CHIP_NO_ERROR ? Status::Failure : Status::Success; } // TODO: when wildcard invokes are supported, handle them to discard rather than fail with status - return AddStatus(concretePath, Status::UnsupportedAccess) != CHIP_NO_ERROR ? Status::Failure : Status::Success; + return FallibleAddStatus(concretePath, Status::UnsupportedAccess) != CHIP_NO_ERROR ? Status::Failure : Status::Success; } } @@ -298,18 +298,21 @@ Status CommandHandler::ProcessCommandDataIB(CommandDataIB::Parser & aCommandElem { // TODO: when wildcard invokes are supported, discard a // wildcard-expanded path instead of returning a status. - return AddStatus(concretePath, Status::NeedsTimedInteraction) != CHIP_NO_ERROR ? Status::Failure : Status::Success; + return FallibleAddStatus(concretePath, Status::NeedsTimedInteraction) != CHIP_NO_ERROR ? Status::Failure : Status::Success; } if (CommandIsFabricScoped(concretePath.mClusterId, concretePath.mCommandId)) { + // SPEC: Else if the command in the path is fabric-scoped and there is no accessing fabric, + // a CommandStatusIB SHALL be generated with the UNSUPPORTED_ACCESS Status Code. + // Fabric-scoped commands are not allowed before a specific accessing fabric is available. // This is mostly just during a PASE session before AddNOC. if (GetAccessingFabricIndex() == kUndefinedFabricIndex) { // TODO: when wildcard invokes are supported, discard a // wildcard-expanded path instead of returning a status. - return AddStatus(concretePath, Status::UnsupportedAccess) != CHIP_NO_ERROR ? Status::Failure : Status::Success; + return FallibleAddStatus(concretePath, Status::UnsupportedAccess) != CHIP_NO_ERROR ? Status::Failure : Status::Success; } } @@ -334,7 +337,7 @@ Status CommandHandler::ProcessCommandDataIB(CommandDataIB::Parser & aCommandElem exit: if (err != CHIP_NO_ERROR) { - return AddStatus(concretePath, Status::InvalidCommand) != CHIP_NO_ERROR ? Status::Failure : Status::Success; + return FallibleAddStatus(concretePath, Status::InvalidCommand) != CHIP_NO_ERROR ? Status::Failure : Status::Success; } // We have handled the error status above and put the error status in response, now return success status so we can process @@ -465,24 +468,31 @@ CHIP_ERROR CommandHandler::AddStatusInternal(const ConcreteCommandPath & aComman return FinishStatus(); } -CHIP_ERROR CommandHandler::AddStatus(const ConcreteCommandPath & aCommandPath, const Status aStatus) +void CommandHandler::AddStatus(const ConcreteCommandPath & aCommandPath, const Protocols::InteractionModel::Status aStatus, + const char * context) { - return AddStatusInternal(aCommandPath, StatusIB(aStatus)); + + VerifyOrDie(FallibleAddStatus(aCommandPath, aStatus, context) == CHIP_NO_ERROR); } -CHIP_ERROR CommandHandler::AddStatusAndLogIfFailure(const ConcreteCommandPath & aCommandPath, const Status aStatus, - const char * aMessage) +CHIP_ERROR CommandHandler::FallibleAddStatus(const ConcreteCommandPath & path, const Protocols::InteractionModel::Status status, + const char * context) { - if (aStatus != Status::Success) + + if (status != Status::Success) { + if (context == nullptr) + { + context = "no additional context"; + } + ChipLogError(DataManagement, - "Failed to handle on Endpoint=%u Cluster=" ChipLogFormatMEI " Command=" ChipLogFormatMEI - " with " ChipLogFormatIMStatus ": %s", - aCommandPath.mEndpointId, ChipLogValueMEI(aCommandPath.mClusterId), ChipLogValueMEI(aCommandPath.mCommandId), - ChipLogValueIMStatus(aStatus), aMessage); + "Endpoint=%u Cluster=" ChipLogFormatMEI " Command=" ChipLogFormatMEI " status " ChipLogFormatIMStatus " (%s)", + path.mEndpointId, ChipLogValueMEI(path.mClusterId), ChipLogValueMEI(path.mCommandId), + ChipLogValueIMStatus(status), context); } - return AddStatus(aCommandPath, aStatus); + return AddStatusInternal(path, StatusIB(status)); } CHIP_ERROR CommandHandler::AddClusterSpecificSuccess(const ConcreteCommandPath & aCommandPath, ClusterStatus aClusterStatus) diff --git a/src/app/CommandHandler.h b/src/app/CommandHandler.h index e2d2f4a6f75e1e..3c9a86c97b6052 100644 --- a/src/app/CommandHandler.h +++ b/src/app/CommandHandler.h @@ -170,12 +170,20 @@ class CommandHandler : public Messaging::ExchangeDelegate */ void OnInvokeCommandRequest(Messaging::ExchangeContext * ec, const PayloadHeader & payloadHeader, System::PacketBufferHandle && payload, bool isTimedInvoke); - CHIP_ERROR AddStatus(const ConcreteCommandPath & aCommandPath, const Protocols::InteractionModel::Status aStatus); - // Same as AddStatus, but logs that the command represented by aCommandPath failed with the given - // error status and error message, if aStatus is an error. - CHIP_ERROR AddStatusAndLogIfFailure(const ConcreteCommandPath & aCommandPath, const Protocols::InteractionModel::Status aStatus, - const char * aMessage); + /** + * Adds the given command status and returns any failures in adding statuses (e.g. out + * of buffer space) to the caller + */ + CHIP_ERROR FallibleAddStatus(const ConcreteCommandPath & aCommandPath, const Protocols::InteractionModel::Status aStatus, + const char * context = nullptr); + + /** + * Adds a status when the caller is unable to handle any failures. Logging is performed + * and failure to register the status is checked with VerifyOrDie. + */ + void AddStatus(const ConcreteCommandPath & aCommandPath, const Protocols::InteractionModel::Status aStatus, + const char * context = nullptr); CHIP_ERROR AddClusterSpecificSuccess(const ConcreteCommandPath & aCommandPath, ClusterStatus aClusterStatus); @@ -237,13 +245,9 @@ class CommandHandler : public Messaging::ExchangeDelegate template void AddResponse(const ConcreteCommandPath & aRequestCommandPath, const CommandData & aData) { - if (CHIP_NO_ERROR != AddResponseData(aRequestCommandPath, aData)) + if (AddResponseData(aRequestCommandPath, aData) != CHIP_NO_ERROR) { - CHIP_ERROR err = AddStatus(aRequestCommandPath, Protocols::InteractionModel::Status::Failure); - if (err != CHIP_NO_ERROR) - { - ChipLogError(DataManagement, "Failed to encode status: %" CHIP_ERROR_FORMAT, err.Format()); - } + AddStatus(aRequestCommandPath, Protocols::InteractionModel::Status::Failure); } } diff --git a/src/app/CommandResponseHelper.h b/src/app/CommandResponseHelper.h index a85e92b72cc587..48d36d1ea82013 100644 --- a/src/app/CommandResponseHelper.h +++ b/src/app/CommandResponseHelper.h @@ -53,7 +53,7 @@ class CommandResponseHelper CHIP_ERROR Failure(Protocols::InteractionModel::Status aStatus) { - CHIP_ERROR err = mCommandHandler->AddStatus(mCommandPath, aStatus); + CHIP_ERROR err = mCommandHandler->FallibleAddStatus(mCommandPath, aStatus); if (err == CHIP_NO_ERROR) { mSentResponse = true; diff --git a/src/app/ReadHandler.cpp b/src/app/ReadHandler.cpp index 4e9e8fccdf5646..1295cc6920c462 100644 --- a/src/app/ReadHandler.cpp +++ b/src/app/ReadHandler.cpp @@ -79,7 +79,6 @@ ReadHandler::ReadHandler(ManagementCallback & apCallback, Messaging::ExchangeCon VerifyOrDie(observer != nullptr); mObserver = observer; - mObserver->OnReadHandlerCreated(this); } #if CHIP_CONFIG_PERSIST_SUBSCRIPTIONS @@ -92,7 +91,6 @@ ReadHandler::ReadHandler(ManagementCallback & apCallback, Observer * observer) : VerifyOrDie(observer != nullptr); mObserver = observer; - mObserver->OnReadHandlerCreated(this); } void ReadHandler::ResumeSubscription(CASESessionManager & caseSessionManager, @@ -235,6 +233,7 @@ CHIP_ERROR ReadHandler::OnStatusResponse(Messaging::ExchangeContext * apExchange { appCallback->OnSubscriptionEstablished(*this); } + mObserver->OnSubscriptionEstablished(this); } } else @@ -246,10 +245,10 @@ CHIP_ERROR ReadHandler::OnStatusResponse(Messaging::ExchangeContext * apExchange return CHIP_NO_ERROR; } - MoveToState(HandlerState::GeneratingReports); + MoveToState(HandlerState::CanStartReporting); break; - case HandlerState::GeneratingReports: + case HandlerState::CanStartReporting: case HandlerState::Idle: default: err = CHIP_ERROR_INCORRECT_STATE; @@ -262,7 +261,7 @@ CHIP_ERROR ReadHandler::OnStatusResponse(Messaging::ExchangeContext * apExchange CHIP_ERROR ReadHandler::SendStatusReport(Protocols::InteractionModel::Status aStatus) { - VerifyOrReturnLogError(mState == HandlerState::GeneratingReports, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnLogError(mState == HandlerState::CanStartReporting, CHIP_ERROR_INCORRECT_STATE); if (IsPriming() || IsChunkedReport()) { mSessionHandle.Grab(mExchangeCtx->GetSessionHandle()); @@ -286,7 +285,7 @@ CHIP_ERROR ReadHandler::SendStatusReport(Protocols::InteractionModel::Status aSt CHIP_ERROR ReadHandler::SendReportData(System::PacketBufferHandle && aPayload, bool aMoreChunks) { - VerifyOrReturnLogError(mState == HandlerState::GeneratingReports, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnLogError(mState == HandlerState::CanStartReporting, CHIP_ERROR_INCORRECT_STATE); VerifyOrDie(!IsAwaitingReportResponse()); // Should not be reportable! if (IsPriming() || IsChunkedReport()) { @@ -335,7 +334,7 @@ CHIP_ERROR ReadHandler::SendReportData(System::PacketBufferHandle && aPayload, b // Priming reports are handled when we send a SubscribeResponse. if (IsType(InteractionType::Subscribe) && !IsPriming() && !IsChunkedReport()) { - mObserver->OnSubscriptionAction(this); + mObserver->OnSubscriptionReportSent(this); } } if (!aMoreChunks) @@ -456,7 +455,7 @@ CHIP_ERROR ReadHandler::ProcessReadRequest(System::PacketBufferHandle && aPayloa ReturnErrorOnFailure(readRequestParser.GetIsFabricFiltered(&isFabricFiltered)); SetStateFlag(ReadHandlerFlags::FabricFiltered, isFabricFiltered); ReturnErrorOnFailure(readRequestParser.ExitContainer()); - MoveToState(HandlerState::GeneratingReports); + MoveToState(HandlerState::CanStartReporting); mExchangeCtx->WillSendMessage(); @@ -574,8 +573,8 @@ const char * ReadHandler::GetStateStr() const return "Idle"; case HandlerState::AwaitingDestruction: return "AwaitingDestruction"; - case HandlerState::GeneratingReports: - return "GeneratingReports"; + case HandlerState::CanStartReporting: + return "CanStartReporting"; case HandlerState::AwaitingReportResponse: return "AwaitingReportResponse"; @@ -603,10 +602,17 @@ void ReadHandler::MoveToState(const HandlerState aTargetState) // If we just unblocked sending reports, let's go ahead and schedule the reporting // engine to run to kick that off. // - if (aTargetState == HandlerState::GeneratingReports) + if (aTargetState == HandlerState::CanStartReporting) { - // mObserver will take care of scheduling the report as soon as allowed - mObserver->OnBecameReportable(this); + if (ShouldReportUnscheduled()) + { + InteractionModelEngine::GetInstance()->GetReportingEngine().ScheduleRun(); + } + else + { + // If we became reportable, the scheduler will schedule a run as soon as allowed + mObserver->OnBecameReportable(this); + } } } @@ -647,8 +653,6 @@ CHIP_ERROR ReadHandler::SendSubscribeResponse() ReturnErrorOnFailure(writer.Finalize(&packet)); VerifyOrReturnLogError(mExchangeCtx, CHIP_ERROR_INCORRECT_STATE); - mObserver->OnSubscriptionAction(this); - ClearStateFlag(ReadHandlerFlags::PrimingReports); return mExchangeCtx->SendMessage(Protocols::InteractionModel::MsgType::SubscribeResponse, std::move(packet)); } @@ -785,7 +789,7 @@ CHIP_ERROR ReadHandler::ProcessSubscribeRequest(System::PacketBufferHandle && aP SetStateFlag(ReadHandlerFlags::FabricFiltered, isFabricFiltered); ReturnErrorOnFailure(Crypto::DRBG_get_bytes(reinterpret_cast(&mSubscriptionId), sizeof(mSubscriptionId))); ReturnErrorOnFailure(subscribeRequestParser.ExitContainer()); - MoveToState(HandlerState::GeneratingReports); + MoveToState(HandlerState::CanStartReporting); mExchangeCtx->WillSendMessage(); @@ -872,11 +876,11 @@ void ReadHandler::ForceDirtyState() void ReadHandler::SetStateFlag(ReadHandlerFlags aFlag, bool aValue) { - bool oldReportable = IsReportable(); + bool oldReportable = ShouldStartReporting(); mFlags.Set(aFlag, aValue); // If we became reportable, schedule a reporting run. - if (!oldReportable && IsReportable()) + if (!oldReportable && ShouldStartReporting()) { // If we became reportable, the scheduler will schedule a run as soon as allowed mObserver->OnBecameReportable(this); @@ -895,7 +899,7 @@ void ReadHandler::HandleDeviceConnected(void * context, Messaging::ExchangeManag _this->mSessionHandle.Grab(sessionHandle); - _this->MoveToState(HandlerState::GeneratingReports); + _this->MoveToState(HandlerState::CanStartReporting); ObjectList * attributePath = _this->mpAttributePathList; while (attributePath) diff --git a/src/app/ReadHandler.h b/src/app/ReadHandler.h index a87c121ffaf8b0..ecdc0c1c0696c1 100644 --- a/src/app/ReadHandler.h +++ b/src/app/ReadHandler.h @@ -166,20 +166,23 @@ class ReadHandler : public Messaging::ExchangeDelegate public: virtual ~Observer() = default; - /// @brief Callback invoked to notify a ReadHandler was created and can be registered - /// @param[in] apReadHandler ReadHandler getting added - virtual void OnReadHandlerCreated(ReadHandler * apReadHandler) = 0; - - /// @brief Callback invoked when a ReadHandler went from a non reportable state to a reportable state so a report can be - /// sent immediately if the minimal interval allows it. Otherwise the report should be rescheduled to the earliest time - /// allowed. - /// @param[in] apReadHandler ReadHandler that became dirty + /// @brief Callback invoked to notify a subscription was successfully established for the ReadHandler + /// @param[in] apReadHandler ReadHandler that completed its subscription + virtual void OnSubscriptionEstablished(ReadHandler * apReadHandler) = 0; + + /// @brief Callback invoked when a ReadHandler went from a non reportable state to a reportable state. Indicates to the + /// observer that a report should be emitted when the min interval allows it. + /// + /// This will only be invoked for subscribe-type ReadHandler objects, and only after + /// OnSubscriptionEstablished has been called. + /// + /// @param[in] apReadHandler ReadHandler that became dirty and in HandlerState::CanStartReporting state virtual void OnBecameReportable(ReadHandler * apReadHandler) = 0; /// @brief Callback invoked when the read handler needs to make sure to send a message to the subscriber within the next /// maxInterval time period. /// @param[in] apReadHandler ReadHandler that has generated a report - virtual void OnSubscriptionAction(ReadHandler * apReadHandler) = 0; + virtual void OnSubscriptionReportSent(ReadHandler * apReadHandler) = 0; /// @brief Callback invoked when a ReadHandler is getting removed so it can be unregistered /// @param[in] apReadHandler ReadHandler getting destroyed @@ -333,13 +336,22 @@ class ReadHandler : public Messaging::ExchangeDelegate bool IsIdle() const { return mState == HandlerState::Idle; } /// @brief Returns whether the ReadHandler is in a state where it can send a report and there is data to report. - bool IsReportable() const + bool ShouldStartReporting() const { - // Important: Anything that changes the state IsReportable must call mObserver->OnBecameReportable(this) for the scheduler - // to plan the next run accordingly. - return mState == HandlerState::GeneratingReports && IsDirty(); + // Important: Anything that changes ShouldStartReporting() from false to true + // (which can only happen for subscriptions) must call + // mObserver->OnBecameReportable(this). + return CanStartReporting() && (ShouldReportUnscheduled() || IsDirty()); + } + /// @brief CanStartReporting() is true if the ReadHandler is in a state where it could generate + /// a (possibly empty) report if someone asked it to. + bool CanStartReporting() const { return mState == HandlerState::CanStartReporting; } + /// @brief ShouldReportUnscheduled() is true if the ReadHandler should be asked to generate reports + /// without consulting the report scheduler. + bool ShouldReportUnscheduled() const + { + return CanStartReporting() && (IsType(ReadHandler::InteractionType::Read) || IsPriming()); } - bool IsGeneratingReports() const { return mState == HandlerState::GeneratingReports; } bool IsAwaitingReportResponse() const { return mState == HandlerState::AwaitingReportResponse; } // Resets the path iterator to the beginning of the whole report for generating a series of new reports. @@ -418,14 +430,14 @@ class ReadHandler : public Messaging::ExchangeDelegate friend class chip::app::reporting::Engine; friend class chip::app::InteractionModelEngine; - // The report scheduler needs to be able to access StateFlag private functions IsReportable(), IsGeneratingReports(), + // The report scheduler needs to be able to access StateFlag private functions ShouldStartReporting(), CanStartReporting(), // ForceDirtyState() and IsDirty() to know when to schedule a run so it is declared as a friend class. friend class chip::app::reporting::ReportScheduler; enum class HandlerState : uint8_t { Idle, ///< The handler has been initialized and is ready - GeneratingReports, ///< The handler has is now capable of generating reports and may generate one immediately + CanStartReporting, ///< The handler has is now capable of generating reports and may generate one immediately ///< or later when other criteria are satisfied (e.g hold-off for min reporting interval). AwaitingReportResponse, ///< The handler has sent the report to the client and is awaiting a status response. AwaitingDestruction, ///< The object has completed its work and is awaiting destruction by the application. diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni index d484d7ce654e9b..d20e28a83bbee8 100644 --- a/src/app/chip_data_model.gni +++ b/src/app/chip_data_model.gni @@ -287,6 +287,13 @@ template("chip_data_model") { "${_app_root}/clusters/${cluster}/resource-monitoring-cluster-objects.cpp", "${_app_root}/clusters/${cluster}/resource-monitoring-cluster-objects.h", ] + } else if (cluster == "smoke-co-alarm-server") { + sources += [ + "${_app_root}/clusters/${cluster}/${cluster}.cpp", + "${_app_root}/clusters/${cluster}/${cluster}.h", + "${_app_root}/clusters/${cluster}/SmokeCOTestEventTriggerDelegate.cpp", + "${_app_root}/clusters/${cluster}/SmokeCOTestEventTriggerDelegate.h", + ] } else { sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp" ] } diff --git a/src/app/clusters/barrier-control-server/barrier-control-server.cpp b/src/app/clusters/barrier-control-server/barrier-control-server.cpp index a7531aee1bcf91..645fc943078355 100644 --- a/src/app/clusters/barrier-control-server/barrier-control-server.cpp +++ b/src/app/clusters/barrier-control-server/barrier-control-server.cpp @@ -286,10 +286,7 @@ void emberAfBarrierControlClusterServerTickCallback(EndpointId endpoint) static void sendDefaultResponse(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, Status status) { - if (commandObj->AddStatus(commandPath, status) != CHIP_NO_ERROR) - { - ChipLogProgress(Zcl, "Failed to send default response"); - } + commandObj->AddStatus(commandPath, status); } bool emberAfBarrierControlClusterBarrierControlGoToPercentCallback( diff --git a/src/app/clusters/door-lock-server/door-lock-server.cpp b/src/app/clusters/door-lock-server/door-lock-server.cpp index ad201e78cf7d2f..a9b3cdd4dc106d 100644 --- a/src/app/clusters/door-lock-server/door-lock-server.cpp +++ b/src/app/clusters/door-lock-server/door-lock-server.cpp @@ -3314,23 +3314,20 @@ bool DoorLockServer::RemoteOperationEnabled(chip::EndpointId endpointId) const mode != OperatingModeEnum::kPrivacy && mode != OperatingModeEnum::kNoRemoteLockUnlock; } -CHIP_ERROR DoorLockServer::sendClusterResponse(chip::app::CommandHandler * commandObj, - const chip::app::ConcreteCommandPath & commandPath, EmberAfStatus status) +void DoorLockServer::sendClusterResponse(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + EmberAfStatus status) { VerifyOrDie(nullptr != commandObj); - auto err = CHIP_NO_ERROR; auto statusAsInteger = to_underlying(status); if (statusAsInteger == to_underlying(DlStatus::kOccupied) || statusAsInteger == to_underlying(DlStatus::kDuplicate)) { - err = commandObj->AddClusterSpecificFailure(commandPath, static_cast(status)); + VerifyOrDie(commandObj->AddClusterSpecificFailure(commandPath, static_cast(status)) == CHIP_NO_ERROR); } else { - err = commandObj->AddStatus(commandPath, ToInteractionModelStatus(status)); + commandObj->AddStatus(commandPath, ToInteractionModelStatus(status)); } - - return err; } EmberAfDoorLockEndpointContext * DoorLockServer::getContext(chip::EndpointId endpointId) diff --git a/src/app/clusters/door-lock-server/door-lock-server.h b/src/app/clusters/door-lock-server/door-lock-server.h index 212c374077298f..70988c17786964 100644 --- a/src/app/clusters/door-lock-server/door-lock-server.h +++ b/src/app/clusters/door-lock-server/door-lock-server.h @@ -422,8 +422,8 @@ class DoorLockServer bool engageLockout(chip::EndpointId endpointId); - static CHIP_ERROR sendClusterResponse(chip::app::CommandHandler * commandObj, - const chip::app::ConcreteCommandPath & commandPath, EmberAfStatus status); + static void sendClusterResponse(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + EmberAfStatus status); /** * @brief Common handler for LockDoor, UnlockDoor, UnlockWithTimeout commands diff --git a/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp b/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp index ef66957d754d68..536ac205454862 100644 --- a/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp +++ b/src/app/clusters/general-commissioning-server/general-commissioning-server.cpp @@ -50,11 +50,7 @@ using Transport::Session; { \ if (!::chip::ChipError::IsSuccess(expr)) \ { \ - CHIP_ERROR statusErr = commandObj->AddStatus(commandPath, Protocols::InteractionModel::Status::code); \ - if (statusErr != CHIP_NO_ERROR) \ - { \ - ChipLogError(Zcl, "%s: %" CHIP_ERROR_FORMAT, #expr, statusErr.Format()); \ - } \ + commandObj->AddStatus(commandPath, Protocols::InteractionModel::Status::code, #expr); \ return true; \ } \ } while (false) diff --git a/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp b/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp index 9ff43d9a2ef834..f4da9238611528 100644 --- a/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp +++ b/src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp @@ -401,7 +401,34 @@ ValidateKeySetWriteArguments(const chip::app::Clusters::GroupKeyManagement::Comm return Status::Success; } -constexpr uint16_t GroupKeyManagementAttributeAccess::kClusterRevision; +bool GetProviderAndFabric(chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + Credentials::GroupDataProvider ** outGroupDataProvider, const FabricInfo ** outFabricInfo) +{ + VerifyOrDie(commandObj != nullptr); + VerifyOrDie(outGroupDataProvider != nullptr); + VerifyOrDie(outFabricInfo != nullptr); + + // Internal failures on internal inconsistencies. + auto provider = GetGroupDataProvider(); + auto fabric = Server::GetInstance().GetFabricTable().FindFabricWithIndex(commandObj->GetAccessingFabricIndex()); + + if (nullptr == provider) + { + commandObj->AddStatus(commandPath, Status::Failure, "Internal consistency error on provider!"); + return false; + } + + if (nullptr == fabric) + { + commandObj->AddStatus(commandPath, Status::Failure, "Internal consistency error on access fabric!"); + return false; + } + + *outGroupDataProvider = provider; + *outFabricInfo = fabric; + + return true; +} GroupKeyManagementAttributeAccess gAttribute; @@ -420,12 +447,12 @@ bool emberAfGroupKeyManagementClusterKeySetWriteCallback( chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::DecodableType & commandData) { - auto provider = GetGroupDataProvider(); - auto fabric = Server::GetInstance().GetFabricTable().FindFabricWithIndex(commandObj->GetAccessingFabricIndex()); + Credentials::GroupDataProvider * provider = nullptr; + const FabricInfo * fabric = nullptr; - if (nullptr == provider || nullptr == fabric) + if (!GetProviderAndFabric(commandObj, commandPath, &provider, &fabric)) { - commandObj->AddStatusAndLogIfFailure(commandPath, Status::Failure, "Internal consistency error on provider/fabric"); + // Command will already have status populated from validation. return true; } @@ -433,7 +460,7 @@ bool emberAfGroupKeyManagementClusterKeySetWriteCallback( Status status = ValidateKeySetWriteArguments(commandData); if (status != Status::Success) { - commandObj->AddStatusAndLogIfFailure(commandPath, status, "Failure to validate KeySet data dependencies."); + commandObj->AddStatus(commandPath, status, "Failure to validate KeySet data dependencies."); return true; } @@ -443,8 +470,7 @@ bool emberAfGroupKeyManagementClusterKeySetWriteCallback( // supported by the server, because it is ... a new value unrecognized // by a legacy server, then the server SHALL generate a general // constraint error - commandObj->AddStatusAndLogIfFailure(commandPath, Status::ConstraintError, - "Received unknown GroupKeySecurityPolicyEnum value"); + commandObj->AddStatus(commandPath, Status::ConstraintError, "Received unknown GroupKeySecurityPolicyEnum value"); return true; } @@ -455,8 +481,8 @@ bool emberAfGroupKeyManagementClusterKeySetWriteCallback( // any action attempting to set CacheAndSync in the // GroupKeySecurityPolicy field SHALL fail with an INVALID_COMMAND // error. - commandObj->AddStatusAndLogIfFailure(commandPath, Status::InvalidCommand, - "Received a CacheAndSync GroupKeySecurityPolicyEnum when MCSP not supported"); + commandObj->AddStatus(commandPath, Status::InvalidCommand, + "Received a CacheAndSync GroupKeySecurityPolicyEnum when MCSP not supported"); return true; } @@ -502,7 +528,7 @@ bool emberAfGroupKeyManagementClusterKeySetWriteCallback( err = provider->SetKeySet(fabric->GetFabricIndex(), compressed_fabric_id, keyset); if (CHIP_ERROR_INVALID_LIST_LENGTH == err) { - commandObj->AddStatusAndLogIfFailure(commandPath, Status::ResourceExhausted, "Not enough space left to add a new KeySet"); + commandObj->AddStatus(commandPath, Status::ResourceExhausted, "Not enough space left to add a new KeySet"); return true; } @@ -516,11 +542,7 @@ bool emberAfGroupKeyManagementClusterKeySetWriteCallback( } // Send response - err = commandObj->AddStatus(commandPath, StatusIB(err).mStatus); - if (CHIP_NO_ERROR != err) - { - ChipLogDetail(Zcl, "GroupKeyManagementCluster: KeySetWrite failed: %" CHIP_ERROR_FORMAT, err.Format()); - } + commandObj->AddStatus(commandPath, StatusIB(err).mStatus); return true; } @@ -528,20 +550,21 @@ bool emberAfGroupKeyManagementClusterKeySetReadCallback( chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::GroupKeyManagement::Commands::KeySetRead::DecodableType & commandData) { - auto fabric = commandObj->GetAccessingFabricIndex(); - auto * provider = GetGroupDataProvider(); + Credentials::GroupDataProvider * provider = nullptr; + const FabricInfo * fabric = nullptr; - if (nullptr == provider) + if (!GetProviderAndFabric(commandObj, commandPath, &provider, &fabric)) { - commandObj->AddStatus(commandPath, Status::Failure); + // Command will already have status populated from validation. return true; } + FabricIndex fabricIndex = fabric->GetFabricIndex(); GroupDataProvider::KeySet keyset; - if (CHIP_NO_ERROR != provider->GetKeySet(fabric, commandData.groupKeySetID, keyset)) + if (CHIP_NO_ERROR != provider->GetKeySet(fabricIndex, commandData.groupKeySetID, keyset)) { // KeySet ID not found - commandObj->AddStatus(commandPath, Status::NotFound); + commandObj->AddStatus(commandPath, Status::NotFound, "Keyset ID not found in KeySetRead"); return true; } @@ -592,30 +615,39 @@ bool emberAfGroupKeyManagementClusterKeySetRemoveCallback( const chip::app::Clusters::GroupKeyManagement::Commands::KeySetRemove::DecodableType & commandData) { - auto fabric = commandObj->GetAccessingFabricIndex(); - auto * provider = GetGroupDataProvider(); - Status status = Status::Failure; + Credentials::GroupDataProvider * provider = nullptr; + const FabricInfo * fabric = nullptr; - if (nullptr != provider) + if (!GetProviderAndFabric(commandObj, commandPath, &provider, &fabric)) { - // Remove keyset - CHIP_ERROR err = provider->RemoveKeySet(fabric, commandData.groupKeySetID); - if (CHIP_ERROR_KEY_NOT_FOUND == err) - { - status = Status::NotFound; - } - else if (CHIP_NO_ERROR == err) - { - status = Status::Success; - } + // Command will already have status populated from validation. + return true; } - // Send response - CHIP_ERROR send_err = commandObj->AddStatus(commandPath, status); - if (CHIP_NO_ERROR != send_err) + if (commandData.groupKeySetID == GroupDataProvider::kIdentityProtectionKeySetId) { - ChipLogDetail(Zcl, "GroupKeyManagementCluster: KeySetRemove failed: %" CHIP_ERROR_FORMAT, send_err.Format()); + // SPEC: This command SHALL fail with an INVALID_COMMAND status code back to the initiator if the GroupKeySetID being + // removed is 0, which is the Key Set associated with the Identity Protection Key (IPK). + commandObj->AddStatus(commandPath, Status::InvalidCommand, "Attempted to KeySetRemove the identity protection key!"); + return true; } + + // Remove keyset + FabricIndex fabricIndex = fabric->GetFabricIndex(); + CHIP_ERROR err = provider->RemoveKeySet(fabricIndex, commandData.groupKeySetID); + + Status status = Status::Success; + if (CHIP_ERROR_KEY_NOT_FOUND == err) + { + status = Status::NotFound; + } + else if (CHIP_NO_ERROR != err) + { + status = Status::Failure; + } + + // Send status response. + commandObj->AddStatus(commandPath, status, "KeySetRemove failed"); return true; } @@ -654,19 +686,20 @@ bool emberAfGroupKeyManagementClusterKeySetReadAllIndicesCallback( chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::GroupKeyManagement::Commands::KeySetReadAllIndices::DecodableType & commandData) { - auto fabric = commandObj->GetAccessingFabricIndex(); - auto * provider = GetGroupDataProvider(); + Credentials::GroupDataProvider * provider = nullptr; + const FabricInfo * fabric = nullptr; - if (nullptr == provider) + if (!GetProviderAndFabric(commandObj, commandPath, &provider, &fabric)) { - commandObj->AddStatus(commandPath, Status::Failure); + // Command will already have status populated from validation. return true; } - auto keysIt = provider->IterateKeySets(fabric); + FabricIndex fabricIndex = fabric->GetFabricIndex(); + auto keysIt = provider->IterateKeySets(fabricIndex); if (nullptr == keysIt) { - commandObj->AddStatus(commandPath, Status::Failure); + commandObj->AddStatus(commandPath, Status::Failure, "Failed iteration of key set indices!"); return true; } diff --git a/src/app/clusters/groups-server/groups-server.cpp b/src/app/clusters/groups-server/groups-server.cpp index 00196ad94c9419..ccb4fb1d439a72 100644 --- a/src/app/clusters/groups-server/groups-server.cpp +++ b/src/app/clusters/groups-server/groups-server.cpp @@ -351,11 +351,7 @@ bool emberAfGroupsClusterAddGroupIfIdentifyingCallback(app::CommandHandler * com status = GroupAdd(fabricIndex, endpointId, groupId, groupName); } - CHIP_ERROR sendErr = commandObj->AddStatus(commandPath, status); - if (CHIP_NO_ERROR != sendErr) - { - ChipLogDetail(Zcl, "Groups: failed to send %s: %" CHIP_ERROR_FORMAT, "status_response", sendErr.Format()); - } + commandObj->AddStatus(commandPath, status); return true; } diff --git a/src/app/clusters/mode-base-server/mode-base-server.cpp b/src/app/clusters/mode-base-server/mode-base-server.cpp index b5b8a403b9ba3e..2b9cc232f87e8d 100644 --- a/src/app/clusters/mode-base-server/mode-base-server.cpp +++ b/src/app/clusters/mode-base-server/mode-base-server.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include using namespace chip; @@ -52,7 +51,7 @@ Instance::Instance(Delegate * aDelegate, EndpointId aEndpointId, ClusterId aClus Instance::~Instance() { - UnregisterInstance(); + UnregisterThisInstance(); chip::app::InteractionModelEngine::GetInstance()->UnregisterCommandHandler(this); unregisterAttributeAccessOverride(this); } @@ -69,7 +68,7 @@ CHIP_ERROR Instance::Init() ReturnErrorOnFailure(chip::app::InteractionModelEngine::GetInstance()->RegisterCommandHandler(this)); VerifyOrReturnError(registerAttributeAccessOverride(this), CHIP_ERROR_INCORRECT_STATE); - RegisterInstance(); + RegisterThisInstance(); ReturnErrorOnFailure(mDelegate->Init()); // If the StartUpMode is set, the CurrentMode attribute SHALL be set to the StartUpMode value, when the server is powered up. @@ -350,7 +349,7 @@ CHIP_ERROR Instance::Write(const ConcreteDataAttributePath & attributePath, Attr return CHIP_ERROR_INCORRECT_STATE; } -void Instance::RegisterInstance() +void Instance::RegisterThisInstance() { if (!gModeBaseAliasesInstances.Contains(this)) { @@ -358,7 +357,7 @@ void Instance::RegisterInstance() } } -void Instance::UnregisterInstance() +void Instance::UnregisterThisInstance() { gModeBaseAliasesInstances.Remove(this); } @@ -369,6 +368,11 @@ void Instance::HandleChangeToMode(HandlerContext & ctx, const Commands::ChangeTo Commands::ChangeToModeResponse::Type response; + // If the NewMode field doesn't match the Mode field of any entry of the SupportedModes list, + // the ChangeToModeResponse command's Status field SHALL indicate UnsupportedMode and + // the StatusText field SHALL be included and MAY be used to indicate the issue, with a human readable string, + // or include an empty string. + // We are leaving the StatusText empty since the Status is descriptive enough. if (!IsSupportedMode(newMode)) { ChipLogError(Zcl, "ModeBase: Failed to find the option with mode %u", newMode); @@ -377,6 +381,17 @@ void Instance::HandleChangeToMode(HandlerContext & ctx, const Commands::ChangeTo return; } + // If the NewMode field is the same as the value of the CurrentMode attribute + // the ChangeToModeResponse command SHALL have the Status field set to Success and + // the StatusText field MAY be supplied with a human readable string or include an empty string. + // We are leaving the StatusText empty since the Status is descriptive enough. + if (newMode == GetCurrentMode()) + { + response.status = to_underlying(ModeBase::StatusCode::kSuccess); + ctx.mCommandHandler.AddResponse(ctx.mRequestPath, response); + return; + } + mDelegate->HandleChangeToMode(newMode, response); if (response.status == to_underlying(StatusCode::kSuccess)) diff --git a/src/app/clusters/mode-base-server/mode-base-server.h b/src/app/clusters/mode-base-server/mode-base-server.h index 10a2a97c07080f..ef88ee8269dd46 100644 --- a/src/app/clusters/mode-base-server/mode-base-server.h +++ b/src/app/clusters/mode-base-server/mode-base-server.h @@ -124,11 +124,12 @@ class Instance : public CommandHandlerInterface, public AttributeAccessInterface private: Delegate * mDelegate; - EndpointId mEndpointId{}; - ClusterId mClusterId{}; + EndpointId mEndpointId; + ClusterId mClusterId; // Attribute data store - uint8_t mCurrentMode; + uint8_t mCurrentMode = 0; // This is a temporary value and may not be valid. We will change this to the value of the first + // mode in the list at the start of the Init function to ensure that it represents a valid mode. DataModel::Nullable mStartUpMode; DataModel::Nullable mOnMode; uint32_t mFeature; @@ -146,14 +147,14 @@ class Instance : public CommandHandlerInterface, public AttributeAccessInterface CHIP_ERROR Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder) override; /** - * Register this ModeBase instance. + * Register this ModeBase instance in gModeBaseAliasesInstances. */ - void RegisterInstance(); + void RegisterThisInstance(); /** - * Unregister this ModeBase instance. + * Unregister this ModeBase instance in gModeBaseAliasesInstances. */ - void UnregisterInstance(); + void UnregisterThisInstance(); /** * Internal change-to-mode command handler function. diff --git a/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.cpp b/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.cpp new file mode 100644 index 00000000000000..597737b14bb768 --- /dev/null +++ b/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.cpp @@ -0,0 +1,42 @@ +/* + * + * 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. + */ + +#include "SmokeCOTestEventTriggerDelegate.h" + +using namespace chip::app::Clusters::SmokeCoAlarm; + +namespace chip { + +bool SmokeCOTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableKey) const +{ + return !mEnableKey.empty() && mEnableKey.data_equal(enableKey); +} + +CHIP_ERROR SmokeCOTestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger) +{ + if (HandleSmokeCOTestEventTrigger(eventTrigger)) + { + return CHIP_NO_ERROR; + } + if (mOtherDelegate != nullptr) + { + return mOtherDelegate->HandleEventTrigger(eventTrigger); + } + return CHIP_ERROR_INVALID_ARGUMENT; +} + +} // namespace chip diff --git a/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.h b/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.h new file mode 100644 index 00000000000000..599eb6ab2fc080 --- /dev/null +++ b/src/app/clusters/smoke-co-alarm-server/SmokeCOTestEventTriggerDelegate.h @@ -0,0 +1,83 @@ +/* + * + * 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. + */ + +#pragma once + +#include +#include + +namespace chip { + +enum class SmokeCOTrigger : uint64_t +{ + // Force alarm commands + kForceSmokeWarning = 0xffffffff00000090, + kForceCOWarning = 0xffffffff00000091, + kForceSmokeInterconnect = 0xffffffff00000092, + kForceMalfunction = 0xffffffff00000093, + kForceCOInterconnect = 0xffffffff00000094, + kForceLowBatteryWarning = 0xffffffff00000095, + kForceSmokeContaminationHigh = 0xffffffff00000096, + kForceSmokeContaminationLow = 0xffffffff00000097, + kForceSmokeSensitivityHigh = 0xffffffff00000098, + kForceSmokeSensitivityLow = 0xffffffff00000099, + kForceEndOfLife = 0xffffffff0000009a, + kForceSilence = 0xffffffff0000009b, + kForceSmokeCritical = 0xffffffff0000009c, + kForceCOCritical = 0xffffffff0000009d, + kForceLowBatteryCritical = 0xffffffff0000009e, + // Clear alarm commands + kClearSmoke = 0xffffffff000000a0, + kClearCO = 0xffffffff000000a1, + kClearSmokeInterconnect = 0xffffffff000000a2, + kClearMalfunction = 0xffffffff000000a3, + kClearCOInterconnect = 0xffffffff000000a4, + kClearBatteryLevelLow = 0xffffffff000000a5, + kClearContamination = 0xffffffff000000a6, + kClearSensitivity = 0xffffffff000000a8, + kClearEndOfLife = 0xffffffff000000aa, + kClearSilence = 0xffffffff000000ab +}; + +class SmokeCOTestEventTriggerDelegate : public TestEventTriggerDelegate +{ +public: + explicit SmokeCOTestEventTriggerDelegate(const ByteSpan & enableKey, TestEventTriggerDelegate * otherDelegate) : + mEnableKey(enableKey), mOtherDelegate(otherDelegate) + {} + + bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override; + CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override; + +private: + ByteSpan mEnableKey; + TestEventTriggerDelegate * mOtherDelegate; +}; + +} // namespace chip + +/** + * @brief User handler for handling the test event trigger + * + * @note If TestEventTrigger is enabled, it needs to be implemented in the app + * + * @param eventTrigger Event trigger to handle + * + * @retval true on success + * @retval false if error happened + */ +bool HandleSmokeCOTestEventTrigger(uint64_t eventTrigger); diff --git a/src/app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.cpp b/src/app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.cpp index c5f109fac63a31..19f1da4f8a8d76 100644 --- a/src/app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.cpp +++ b/src/app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.cpp @@ -22,23 +22,12 @@ */ #include "smoke-co-alarm-server.h" + #include -#include -#include #include -#include -#include -#include -#include - -#include -#include -#include -#include using namespace chip; using namespace chip::app; -using namespace chip::app::DataModel; using namespace chip::app::Clusters::SmokeCoAlarm; using chip::Protocols::InteractionModel::Status; @@ -72,6 +61,55 @@ bool SmokeCoAlarmServer::SetExpressedState(EndpointId endpointId, ExpressedState return success; } +void SmokeCoAlarmServer::SetExpressedStateByPriority(EndpointId endpointId, + const std::array & priorityOrder) +{ + AlarmStateEnum alarmState = AlarmStateEnum::kNormal; + EndOfServiceEnum endOfServiceState = EndOfServiceEnum::kNormal; + bool active = false; + + for (ExpressedStateEnum priority : priorityOrder) + { + switch (priority) + { + case ExpressedStateEnum::kSmokeAlarm: + VerifyOrReturn(GetSmokeState(endpointId, alarmState)); + break; + case ExpressedStateEnum::kCOAlarm: + VerifyOrReturn(GetCOState(endpointId, alarmState)); + break; + case ExpressedStateEnum::kBatteryAlert: + VerifyOrReturn(GetBatteryAlert(endpointId, alarmState)); + break; + case ExpressedStateEnum::kTesting: + VerifyOrReturn(GetTestInProgress(endpointId, active)); + break; + case ExpressedStateEnum::kHardwareFault: + VerifyOrReturn(GetHardwareFaultAlert(endpointId, active)); + break; + case ExpressedStateEnum::kEndOfService: + VerifyOrReturn(GetEndOfServiceAlert(endpointId, endOfServiceState)); + break; + case ExpressedStateEnum::kInterconnectSmoke: + VerifyOrReturn(GetInterconnectSmokeAlarm(endpointId, alarmState)); + break; + case ExpressedStateEnum::kInterconnectCO: + VerifyOrReturn(GetInterconnectCOAlarm(endpointId, alarmState)); + break; + default: + break; + } + + if ((alarmState != AlarmStateEnum::kNormal) || (endOfServiceState != EndOfServiceEnum::kNormal) || active) + { + VerifyOrDo(SetExpressedState(endpointId, priority), ChipLogError(NotSpecified, "Set ExpressedState failed")); + return; + } + } + + VerifyOrDo(SetExpressedState(endpointId, ExpressedStateEnum::kNormal), ChipLogError(NotSpecified, "Set ExpressedState failed")); +} + bool SmokeCoAlarmServer::SetSmokeState(EndpointId endpointId, AlarmStateEnum newSmokeState) { AlarmStateEnum smokeState; diff --git a/src/app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.h b/src/app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.h index 529df2ed766807..0df9583371b67a 100644 --- a/src/app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.h +++ b/src/app/clusters/smoke-co-alarm-server/smoke-co-alarm-server.h @@ -25,10 +25,7 @@ #include #include -#include #include -#include -#include /** * @brief Smoke CO Alarm Server Plugin class @@ -38,6 +35,9 @@ class SmokeCoAlarmServer public: static SmokeCoAlarmServer & Instance(); + /* Expected byte size of the PriorityOrder */ + static constexpr size_t kPriorityOrderLength = 8; + using AlarmStateEnum = chip::app::Clusters::SmokeCoAlarm::AlarmStateEnum; using ContaminationStateEnum = chip::app::Clusters::SmokeCoAlarm::ContaminationStateEnum; using EndOfServiceEnum = chip::app::Clusters::SmokeCoAlarm::EndOfServiceEnum; @@ -61,6 +61,14 @@ class SmokeCoAlarmServer */ bool SetExpressedState(chip::EndpointId endpointId, ExpressedStateEnum newExpressedState); + /** + * @brief Set the highest level of Expressed State according to priorityOrder + * @param endpointId ID of the endpoint + * @param priorityOrder Priority order of expressed state from highest to lowest + */ + void SetExpressedStateByPriority(chip::EndpointId endpointId, + const std::array & priorityOrder); + bool SetSmokeState(chip::EndpointId endpointId, AlarmStateEnum newSmokeState); bool SetCOState(chip::EndpointId endpointId, AlarmStateEnum newCOState); bool SetBatteryAlert(chip::EndpointId endpointId, AlarmStateEnum newBatteryAlert); diff --git a/src/app/clusters/window-covering-server/window-covering-server.cpp b/src/app/clusters/window-covering-server/window-covering-server.cpp index 2bdd972cd634f7..a78a3d138bbd39 100644 --- a/src/app/clusters/window-covering-server/window-covering-server.cpp +++ b/src/app/clusters/window-covering-server/window-covering-server.cpp @@ -771,7 +771,8 @@ bool emberAfWindowCoveringClusterStopMotionCallback(app::CommandHandler * comman } } - return CHIP_NO_ERROR == commandObj->AddStatus(commandPath, Status::Success); + commandObj->AddStatus(commandPath, Status::Success); + return true; } /** diff --git a/src/app/reporting/Engine.cpp b/src/app/reporting/Engine.cpp index a1eae3abe0d1b0..0a3eedd4ad767c 100644 --- a/src/app/reporting/Engine.cpp +++ b/src/app/reporting/Engine.cpp @@ -638,7 +638,7 @@ void Engine::Run() ReadHandler * readHandler = imEngine->ActiveHandlerAt(mCurReadHandlerIdx % (uint32_t) imEngine->mReadHandlers.Allocated()); VerifyOrDie(readHandler != nullptr); - if (imEngine->GetReportScheduler()->IsReportableNow(readHandler)) + if (readHandler->ShouldReportUnscheduled() || imEngine->GetReportScheduler()->IsReportableNow(readHandler)) { mRunningReadHandler = readHandler; CHIP_ERROR err = BuildAndSendSingleReportData(readHandler); @@ -831,7 +831,7 @@ CHIP_ERROR Engine::SetDirty(AttributePathParams & aAttributePath) // We call AttributePathIsDirty for both read interactions and subscribe interactions, since we may send inconsistent // attribute data between two chunks. AttributePathIsDirty will not schedule a new run for read handlers which are // waiting for a response to the last message chunk for read interactions. - if (handler->IsGeneratingReports() || handler->IsAwaitingReportResponse()) + if (handler->CanStartReporting() || handler->IsAwaitingReportResponse()) { for (auto object = handler->GetAttributePathList(); object != nullptr; object = object->mpNext) { diff --git a/src/app/reporting/ReportScheduler.h b/src/app/reporting/ReportScheduler.h index 068237780b86a0..5b7b62709985bd 100644 --- a/src/app/reporting/ReportScheduler.h +++ b/src/app/reporting/ReportScheduler.h @@ -82,7 +82,7 @@ class ReportScheduler : public ReadHandler::Observer, public ICDStateObserver { Timestamp now = mTimerDelegate->GetCurrentMonotonicTimestamp(); - return (mReadHandler->IsGeneratingReports() && + return (mReadHandler->CanStartReporting() && (now >= mMinTimestamp && (mReadHandler->IsDirty() || now >= mMaxTimestamp || now >= mSyncTimestamp))); } @@ -139,9 +139,13 @@ class ReportScheduler : public ReadHandler::Observer, public ICDStateObserver /// @brief Check whether a ReadHandler is reportable right now, taking into account its minimum and maximum intervals. /// @param aReadHandler read handler to check - bool IsReportableNow(ReadHandler * aReadHandler) { return FindReadHandlerNode(aReadHandler)->IsReportableNow(); } + bool IsReportableNow(ReadHandler * aReadHandler) + { + ReadHandlerNode * node = FindReadHandlerNode(aReadHandler); + return (nullptr != node) ? node->IsReportableNow() : false; + } /// @brief Check if a ReadHandler is reportable without considering the timing - bool IsReadHandlerReportable(ReadHandler * aReadHandler) const { return aReadHandler->IsReportable(); } + bool IsReadHandlerReportable(ReadHandler * aReadHandler) const { return aReadHandler->ShouldStartReporting(); } /// @brief Sets the ForceDirty flag of a ReadHandler void HandlerForceDirtyState(ReadHandler * aReadHandler) { aReadHandler->ForceDirtyState(); } diff --git a/src/app/reporting/ReportSchedulerImpl.cpp b/src/app/reporting/ReportSchedulerImpl.cpp index 74f75a663277aa..44be647b921d9d 100644 --- a/src/app/reporting/ReportSchedulerImpl.cpp +++ b/src/app/reporting/ReportSchedulerImpl.cpp @@ -54,8 +54,10 @@ void ReportSchedulerImpl::OnEnterActiveMode() #endif } -/// @brief When a ReadHandler is added, register it, which will schedule an engine run -void ReportSchedulerImpl::OnReadHandlerCreated(ReadHandler * aReadHandler) +/// @brief When a ReadHandler is added, register it in the scheduler node pool. Scheduling the report here is un-necessary since the +/// ReadHandler will call MoveToState(HandlerState::CanStartReporting);, which will call OnBecameReportable() and schedule the +/// report. +void ReportSchedulerImpl::OnSubscriptionEstablished(ReadHandler * aReadHandler) { ReadHandlerNode * newNode = FindReadHandlerNode(aReadHandler); // Handler must not be registered yet; it's just being constructed. @@ -68,11 +70,6 @@ void ReportSchedulerImpl::OnReadHandlerCreated(ReadHandler * aReadHandler) "Registered a ReadHandler that will schedule a report between system Timestamp: %" PRIu64 " and system Timestamp %" PRIu64 ".", newNode->GetMinTimestamp().count(), newNode->GetMaxTimestamp().count()); - - Milliseconds32 newTimeout; - // No need to check for error here, since the node is already in the list otherwise we would have Died - CalculateNextReportTimeout(newTimeout, newNode); - ScheduleReport(newTimeout, newNode); } /// @brief When a ReadHandler becomes reportable, schedule, recalculate and reschedule the report. @@ -85,7 +82,7 @@ void ReportSchedulerImpl::OnBecameReportable(ReadHandler * aReadHandler) ScheduleReport(newTimeout, node); } -void ReportSchedulerImpl::OnSubscriptionAction(ReadHandler * aReadHandler) +void ReportSchedulerImpl::OnSubscriptionReportSent(ReadHandler * aReadHandler) { ReadHandlerNode * node = FindReadHandlerNode(aReadHandler); VerifyOrReturn(nullptr != node); diff --git a/src/app/reporting/ReportSchedulerImpl.h b/src/app/reporting/ReportSchedulerImpl.h index 573184ada02d5a..003be7cb4637eb 100644 --- a/src/app/reporting/ReportSchedulerImpl.h +++ b/src/app/reporting/ReportSchedulerImpl.h @@ -36,9 +36,9 @@ class ReportSchedulerImpl : public ReportScheduler void OnEnterActiveMode() override; // ReadHandlerObserver - void OnReadHandlerCreated(ReadHandler * aReadHandler) final; + void OnSubscriptionEstablished(ReadHandler * aReadHandler) final; void OnBecameReportable(ReadHandler * aReadHandler) final; - void OnSubscriptionAction(ReadHandler * aReadHandler) final; + void OnSubscriptionReportSent(ReadHandler * aReadHandler) final; void OnReadHandlerDestroyed(ReadHandler * aReadHandler) override; bool IsReportScheduled(ReadHandler * aReadHandler); diff --git a/src/app/tests/TestCommandInteraction.cpp b/src/app/tests/TestCommandInteraction.cpp index d90ce4d97b3d7c..14418aecc2877a 100644 --- a/src/app/tests/TestCommandInteraction.cpp +++ b/src/app/tests/TestCommandInteraction.cpp @@ -1095,9 +1095,8 @@ void TestCommandInteraction::TestCommandHandlerCommandEncodeExternalFailure(nlTe err = commandHandler.AddResponseData(ConcreteCommandPath(path.mEndpointId, path.mClusterId, path.mCommandId), BadFields()); NL_TEST_ASSERT(apSuite, err != CHIP_NO_ERROR); - err = commandHandler.AddStatus(ConcreteCommandPath(path.mEndpointId, path.mClusterId, path.mCommandId), - Protocols::InteractionModel::Status::Failure); - NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); + commandHandler.AddStatus(ConcreteCommandPath(path.mEndpointId, path.mClusterId, path.mCommandId), + Protocols::InteractionModel::Status::Failure); err = commandHandler.Finalize(commandPacket); NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR); diff --git a/src/app/tests/TestReadInteraction.cpp b/src/app/tests/TestReadInteraction.cpp index 0f907567ee44f4..ea464c3d9471b0 100644 --- a/src/app/tests/TestReadInteraction.cpp +++ b/src/app/tests/TestReadInteraction.cpp @@ -2234,7 +2234,7 @@ void TestReadInteraction::TestSubscribeUrgentWildcardEvent(nlTestSuite * apSuite reportScheduler->GetMinTimestampForHandler(delegate.mpReadHandler) < System::SystemClock().GetMonotonicTimestamp()); NL_TEST_ASSERT(apSuite, !delegate.mpReadHandler->IsDirty()); - NL_TEST_ASSERT(apSuite, !delegate.mpReadHandler->IsReportable()); + NL_TEST_ASSERT(apSuite, !delegate.mpReadHandler->ShouldStartReporting()); // And the non-urgent one should not have changed state either, since // it's waiting for the max-interval. @@ -2245,7 +2245,7 @@ void TestReadInteraction::TestSubscribeUrgentWildcardEvent(nlTestSuite * apSuite reportScheduler->GetMaxTimestampForHandler(nonUrgentDelegate.mpReadHandler) > System::SystemClock().GetMonotonicTimestamp()); NL_TEST_ASSERT(apSuite, !nonUrgentDelegate.mpReadHandler->IsDirty()); - NL_TEST_ASSERT(apSuite, !nonUrgentDelegate.mpReadHandler->IsReportable()); + NL_TEST_ASSERT(apSuite, !nonUrgentDelegate.mpReadHandler->ShouldStartReporting()); // There should be no reporting run scheduled. This is very important; // otherwise we can get a false-positive pass below because the run was @@ -2257,12 +2257,12 @@ void TestReadInteraction::TestSubscribeUrgentWildcardEvent(nlTestSuite * apSuite // Urgent read handler should now be dirty, and reportable. NL_TEST_ASSERT(apSuite, delegate.mpReadHandler->IsDirty()); - NL_TEST_ASSERT(apSuite, delegate.mpReadHandler->IsReportable()); + NL_TEST_ASSERT(apSuite, delegate.mpReadHandler->ShouldStartReporting()); NL_TEST_ASSERT(apSuite, reportScheduler->IsReadHandlerReportable(delegate.mpReadHandler)); // Non-urgent read handler should not be reportable. NL_TEST_ASSERT(apSuite, !nonUrgentDelegate.mpReadHandler->IsDirty()); - NL_TEST_ASSERT(apSuite, !nonUrgentDelegate.mpReadHandler->IsReportable()); + NL_TEST_ASSERT(apSuite, !nonUrgentDelegate.mpReadHandler->ShouldStartReporting()); // Still no reporting should have happened. NL_TEST_ASSERT(apSuite, !delegate.mGotEventResponse); diff --git a/src/app/tests/TestReportScheduler.cpp b/src/app/tests/TestReportScheduler.cpp index 9d19f85636e15e..5f8fd3ffd36949 100644 --- a/src/app/tests/TestReportScheduler.cpp +++ b/src/app/tests/TestReportScheduler.cpp @@ -135,9 +135,6 @@ class TestTimerDelegate : public ReportScheduler::TimerDelegate static void TimerCallbackInterface(System::Layer * aLayer, void * aAppState) { - // Normaly we would call the callback here, thus scheduling an engine run, but we don't need it for this test as we simulate - // all the callbacks related to report emissions. The actual callback should look like this: - // TimerContext * context = static_cast(aAppState); context->TimerFired(); ChipLogProgress(DataManagement, "Simluating engine run for Handler: %p", aAppState); @@ -249,6 +246,23 @@ SynchronizedReportSchedulerImpl syncScheduler(&sTestTimerSynchronizedDelegate); class TestReportScheduler { public: + /// @brief Mimicks the various operations that happen on a subscription transaction after a read handler was created so that + /// readhandlers are in the expected state for further tests. + /// @param readHandler + /// @param scheduler + static CHIP_ERROR MockReadHandlerSubscriptionTransation(ReadHandler * readHandler, ReportScheduler * scheduler, + uint8_t min_interval_seconds, uint8_t max_interval_seconds) + { + ReturnErrorOnFailure(readHandler->SetMaxReportingInterval(max_interval_seconds)); + ReturnErrorOnFailure(readHandler->SetMinReportingIntervalForTests(min_interval_seconds)); + readHandler->ClearStateFlag(ReadHandler::ReadHandlerFlags::PrimingReports); + readHandler->SetStateFlag(ReadHandler::ReadHandlerFlags::ActiveSubscription); + scheduler->OnSubscriptionEstablished(readHandler); + readHandler->MoveToState(ReadHandler::HandlerState::CanStartReporting); + + return CHIP_NO_ERROR; + } + static ReadHandler * GetReadHandlerFromPool(ReportScheduler * scheduler, uint32_t target) { uint32_t i = 0; @@ -285,6 +299,7 @@ class TestReportScheduler { ReadHandler * readHandler = readHandlerPool.CreateObject(nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, &sScheduler); + sScheduler.OnSubscriptionEstablished(readHandler); NL_TEST_ASSERT(aSuite, nullptr != readHandler); VerifyOrReturn(nullptr != readHandler); NL_TEST_ASSERT(aSuite, nullptr != sScheduler.FindReadHandlerNode(readHandler)); @@ -349,31 +364,18 @@ class TestReportScheduler // Test OnReadHandler created ReadHandler * readHandler1 = readHandlerPool.CreateObject(nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, &sScheduler); - - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == readHandler1->SetMaxReportingInterval(2)); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == readHandler1->SetMinReportingIntervalForTests(1)); - ReadHandlerNode * node = sScheduler.FindReadHandlerNode(readHandler1); - node->SetIntervalTimeStamps(readHandler1); - readHandler1->MoveToState(ReadHandler::HandlerState::GeneratingReports); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == MockReadHandlerSubscriptionTransation(readHandler1, &sScheduler, 1, 2)); readHandler1->ForceDirtyState(); // Clean read handler, will be triggered at max interval ReadHandler * readHandler2 = readHandlerPool.CreateObject(nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, &sScheduler); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == readHandler2->SetMaxReportingInterval(3)); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == readHandler2->SetMinReportingIntervalForTests(0)); - node = sScheduler.FindReadHandlerNode(readHandler2); - node->SetIntervalTimeStamps(readHandler2); - readHandler2->MoveToState(ReadHandler::HandlerState::GeneratingReports); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == MockReadHandlerSubscriptionTransation(readHandler2, &sScheduler, 0, 3)); // Clean read handler, will be triggered at max interval, but will be cancelled before ReadHandler * readHandler3 = readHandlerPool.CreateObject(nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, &sScheduler); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == readHandler3->SetMaxReportingInterval(3)); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == readHandler3->SetMinReportingIntervalForTests(0)); - node = sScheduler.FindReadHandlerNode(readHandler3); - node->SetIntervalTimeStamps(readHandler3); - readHandler3->MoveToState(ReadHandler::HandlerState::GeneratingReports); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == MockReadHandlerSubscriptionTransation(readHandler3, &sScheduler, 0, 3)); // Confirms that none of the ReadHandlers are currently reportable NL_TEST_ASSERT(aSuite, !sScheduler.IsReportableNow(readHandler1)); @@ -427,22 +429,20 @@ class TestReportScheduler ReadHandler * readHandler = readHandlerPool.CreateObject(nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, &sScheduler); - // Test OnReadHandler created registered the ReadHandler in the scheduler + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == MockReadHandlerSubscriptionTransation(readHandler, &sScheduler, 1, 2)); + + // Verifies OnSubscriptionEstablished registered the ReadHandler in the scheduler NL_TEST_ASSERT(aSuite, nullptr != sScheduler.FindReadHandlerNode(readHandler)); // Should have registered the read handler in the scheduler and scheduled a report NL_TEST_ASSERT(aSuite, sScheduler.GetNumReadHandlers() == 1); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == readHandler->SetMaxReportingInterval(2)); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == readHandler->SetMinReportingIntervalForTests(1)); + ReadHandlerNode * node = sScheduler.FindReadHandlerNode(readHandler); - node->SetIntervalTimeStamps(readHandler); // Test OnReportingIntervalsChanged modified the intervals and re-scheduled a report NL_TEST_ASSERT(aSuite, node->GetMinTimestamp().count() == 1000); NL_TEST_ASSERT(aSuite, node->GetMaxTimestamp().count() == 2000); - // Do those manually to avoid scheduling an engine run - readHandler->MoveToState(ReadHandler::HandlerState::GeneratingReports); NL_TEST_ASSERT(aSuite, sScheduler.IsReportScheduled(readHandler)); NL_TEST_ASSERT(aSuite, nullptr != node); @@ -459,9 +459,9 @@ class TestReportScheduler // Check that no report is scheduled since the min interval has expired, the timer should now be stopped NL_TEST_ASSERT(aSuite, !sScheduler.IsReportScheduled(readHandler)); - // Test OnSubscriptionAction + // Test OnSubscriptionReportSent readHandler->ClearForceDirtyFlag(); - readHandler->mObserver->OnSubscriptionAction(readHandler); + readHandler->mObserver->OnSubscriptionReportSent(readHandler); // Should have changed the scheduled timeout to the handlers max interval, to check, we wait for the min interval to // confirm it is not expired yet so the report should still be scheduled @@ -505,19 +505,13 @@ class TestReportScheduler ReadHandler * readHandler1 = readHandlerPool.CreateObject(nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, &syncScheduler); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == readHandler1->SetMaxReportingInterval(2)); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == readHandler1->SetMinReportingIntervalForTests(0)); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == MockReadHandlerSubscriptionTransation(readHandler1, &syncScheduler, 0, 2)); ReadHandlerNode * node1 = syncScheduler.FindReadHandlerNode(readHandler1); - node1->SetIntervalTimeStamps(readHandler1); - readHandler1->MoveToState(ReadHandler::HandlerState::GeneratingReports); ReadHandler * readHandler2 = readHandlerPool.CreateObject(nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, &syncScheduler); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == readHandler2->SetMaxReportingInterval(3)); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == readHandler2->SetMinReportingIntervalForTests(1)); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == MockReadHandlerSubscriptionTransation(readHandler2, &syncScheduler, 1, 3)); ReadHandlerNode * node2 = syncScheduler.FindReadHandlerNode(readHandler2); - node2->SetIntervalTimeStamps(readHandler2); - readHandler2->MoveToState(ReadHandler::HandlerState::GeneratingReports); // Confirm all handler are currently registered in the scheduler NL_TEST_ASSERT(aSuite, syncScheduler.GetNumReadHandlers() == 2); @@ -544,9 +538,9 @@ class TestReportScheduler NL_TEST_ASSERT(aSuite, !sScheduler.IsReportScheduled(readHandler2)); // Simulate a report emission for readHandler1 - readHandler1->mObserver->OnSubscriptionAction(readHandler1); + readHandler1->mObserver->OnSubscriptionReportSent(readHandler1); // Simulate a report emission for readHandler2 - readHandler2->mObserver->OnSubscriptionAction(readHandler2); + readHandler2->mObserver->OnSubscriptionReportSent(readHandler2); // Validate that the max timestamp for both readhandlers got updated and that the next report emission is scheduled on // the new max timestamp for readhandler1 @@ -572,13 +566,13 @@ class TestReportScheduler NL_TEST_ASSERT(aSuite, syncScheduler.mTestNextReportTimestamp == node2->GetMinTimestamp()); // Simulate a report emission for readHandler1 - readHandler1->mObserver->OnSubscriptionAction(readHandler1); + readHandler1->mObserver->OnSubscriptionReportSent(readHandler1); NL_TEST_ASSERT(aSuite, !syncScheduler.IsReportableNow(readHandler1)); // ReadHandler 2 should still be reportable since it hasn't emitted a report yet NL_TEST_ASSERT(aSuite, syncScheduler.IsReportableNow(readHandler2)); readHandler2->ClearForceDirtyFlag(); - readHandler2->mObserver->OnSubscriptionAction(readHandler2); + readHandler2->mObserver->OnSubscriptionReportSent(readHandler2); NL_TEST_ASSERT(aSuite, !syncScheduler.IsReportableNow(readHandler2)); // Validate next report scheduled on the max timestamp of readHandler1 @@ -594,7 +588,7 @@ class TestReportScheduler // Simulate a report emission for readHandler1 readHandler1->ClearForceDirtyFlag(); - readHandler1->mObserver->OnSubscriptionAction(readHandler1); + readHandler1->mObserver->OnSubscriptionReportSent(readHandler1); NL_TEST_ASSERT(aSuite, !syncScheduler.IsReportableNow(readHandler1)); NL_TEST_ASSERT(aSuite, !syncScheduler.IsReportableNow(readHandler2)); @@ -605,8 +599,8 @@ class TestReportScheduler sTestTimerSynchronizedDelegate.IncrementMockTimestamp(System::Clock::Milliseconds64(2000)); NL_TEST_ASSERT(aSuite, syncScheduler.IsReportableNow(readHandler1)); NL_TEST_ASSERT(aSuite, syncScheduler.IsReportableNow(readHandler2)); - readHandler1->mObserver->OnSubscriptionAction(readHandler1); - readHandler2->mObserver->OnSubscriptionAction(readHandler2); + readHandler1->mObserver->OnSubscriptionReportSent(readHandler1); + readHandler2->mObserver->OnSubscriptionReportSent(readHandler2); NL_TEST_ASSERT(aSuite, !syncScheduler.IsReportableNow(readHandler1)); NL_TEST_ASSERT(aSuite, !syncScheduler.IsReportableNow(readHandler2)); NL_TEST_ASSERT(aSuite, syncScheduler.mTestNextReportTimestamp == node1->GetMaxTimestamp()); @@ -618,11 +612,8 @@ class TestReportScheduler ReadHandler * readHandler3 = readHandlerPool.CreateObject(nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, &syncScheduler); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == readHandler3->SetMaxReportingInterval(3)); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == readHandler3->SetMinReportingIntervalForTests(2)); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == MockReadHandlerSubscriptionTransation(readHandler3, &syncScheduler, 2, 3)); ReadHandlerNode * node3 = syncScheduler.FindReadHandlerNode(readHandler3); - node3->SetIntervalTimeStamps(readHandler3); - readHandler3->MoveToState(ReadHandler::HandlerState::GeneratingReports); // Confirm all handler are currently registered in the scheduler NL_TEST_ASSERT(aSuite, syncScheduler.GetNumReadHandlers() == 3); @@ -643,8 +634,8 @@ class TestReportScheduler readHandler2->mObserver->OnBecameReportable(readHandler2); // Simulate a report emission for readHandler1 and readHandler2 - readHandler1->mObserver->OnSubscriptionAction(readHandler1); - readHandler1->mObserver->OnSubscriptionAction(readHandler2); + readHandler1->mObserver->OnSubscriptionReportSent(readHandler1); + readHandler1->mObserver->OnSubscriptionReportSent(readHandler2); NL_TEST_ASSERT(aSuite, !syncScheduler.IsReportableNow(readHandler1)); NL_TEST_ASSERT(aSuite, !syncScheduler.IsReportableNow(readHandler2)); @@ -662,9 +653,9 @@ class TestReportScheduler readHandler2->mObserver->OnBecameReportable(readHandler2); readHandler3->mObserver->OnBecameReportable(readHandler3); // Engine run should happen here and send all reports - readHandler1->mObserver->OnSubscriptionAction(readHandler1); - readHandler2->mObserver->OnSubscriptionAction(readHandler2); - readHandler3->mObserver->OnSubscriptionAction(readHandler3); + readHandler1->mObserver->OnSubscriptionReportSent(readHandler1); + readHandler2->mObserver->OnSubscriptionReportSent(readHandler2); + readHandler3->mObserver->OnSubscriptionReportSent(readHandler3); NL_TEST_ASSERT(aSuite, !syncScheduler.IsReportableNow(readHandler1)); NL_TEST_ASSERT(aSuite, !syncScheduler.IsReportableNow(readHandler2)); NL_TEST_ASSERT(aSuite, !syncScheduler.IsReportableNow(readHandler3)); @@ -675,11 +666,8 @@ class TestReportScheduler // Now simulate a new readHandler being added with a max forcing a conflict ReadHandler * readHandler4 = readHandlerPool.CreateObject(nullCallback, exchangeCtx, ReadHandler::InteractionType::Subscribe, &syncScheduler); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == readHandler4->SetMaxReportingInterval(1)); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == readHandler4->SetMinReportingIntervalForTests(0)); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == MockReadHandlerSubscriptionTransation(readHandler4, &syncScheduler, 0, 1)); ReadHandlerNode * node4 = syncScheduler.FindReadHandlerNode(readHandler4); - node4->SetIntervalTimeStamps(readHandler4); - readHandler4->MoveToState(ReadHandler::HandlerState::GeneratingReports); // Confirm all handler are currently registered in the scheduler NL_TEST_ASSERT(aSuite, syncScheduler.GetNumReadHandlers() == 4); @@ -704,9 +692,9 @@ class TestReportScheduler readHandler4->mObserver->OnBecameReportable(readHandler1); readHandler4->mObserver->OnBecameReportable(readHandler2); readHandler4->mObserver->OnBecameReportable(readHandler4); - readHandler4->mObserver->OnSubscriptionAction(readHandler1); - readHandler4->mObserver->OnSubscriptionAction(readHandler2); - readHandler4->mObserver->OnSubscriptionAction(readHandler4); + readHandler4->mObserver->OnSubscriptionReportSent(readHandler1); + readHandler4->mObserver->OnSubscriptionReportSent(readHandler2); + readHandler4->mObserver->OnSubscriptionReportSent(readHandler4); NL_TEST_ASSERT(aSuite, !syncScheduler.IsReportableNow(readHandler1)); NL_TEST_ASSERT(aSuite, !syncScheduler.IsReportableNow(readHandler2)); NL_TEST_ASSERT(aSuite, !syncScheduler.IsReportableNow(readHandler4)); @@ -722,10 +710,10 @@ class TestReportScheduler syncScheduler.OnBecameReportable(readHandler2); syncScheduler.OnBecameReportable(readHandler3); syncScheduler.OnBecameReportable(readHandler4); - syncScheduler.OnSubscriptionAction(readHandler1); - syncScheduler.OnSubscriptionAction(readHandler2); - syncScheduler.OnSubscriptionAction(readHandler3); - syncScheduler.OnSubscriptionAction(readHandler4); + syncScheduler.OnSubscriptionReportSent(readHandler1); + syncScheduler.OnSubscriptionReportSent(readHandler2); + syncScheduler.OnSubscriptionReportSent(readHandler3); + syncScheduler.OnSubscriptionReportSent(readHandler4); NL_TEST_ASSERT(aSuite, !syncScheduler.IsReportableNow(readHandler1)); NL_TEST_ASSERT(aSuite, !syncScheduler.IsReportableNow(readHandler2)); NL_TEST_ASSERT(aSuite, !syncScheduler.IsReportableNow(readHandler3)); @@ -759,19 +747,14 @@ class TestReportScheduler NL_TEST_ASSERT(aSuite, syncScheduler.GetNumReadHandlers() == 0); readHandler1->MoveToState(ReadHandler::HandlerState::Idle); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == readHandler1->SetMaxReportingInterval(2)); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == readHandler1->SetMinReportingIntervalForTests(0)); - readHandler1->MoveToState(ReadHandler::HandlerState::GeneratingReports); - syncScheduler.OnReadHandlerCreated(readHandler1); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == MockReadHandlerSubscriptionTransation(readHandler1, &syncScheduler, 0, 2)); + // Forcing the dirty flag to make the scheduler call Engine::ScheduleRun() immediately readHandler1->ForceDirtyState(); NL_TEST_ASSERT(aSuite, syncScheduler.IsReportableNow(readHandler1)); readHandler2->MoveToState(ReadHandler::HandlerState::Idle); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == readHandler2->SetMaxReportingInterval(4)); - NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == readHandler2->SetMinReportingIntervalForTests(3)); - readHandler2->MoveToState(ReadHandler::HandlerState::GeneratingReports); - syncScheduler.OnReadHandlerCreated(readHandler2); + NL_TEST_ASSERT(aSuite, CHIP_NO_ERROR == MockReadHandlerSubscriptionTransation(readHandler2, &syncScheduler, 3, 4)); readHandler2->ForceDirtyState(); NL_TEST_ASSERT(aSuite, !syncScheduler.IsReportableNow(readHandler2)); @@ -779,7 +762,7 @@ class TestReportScheduler node2 = syncScheduler.FindReadHandlerNode(readHandler2); readHandler1->ClearForceDirtyFlag(); // report got emited so clear dirty flag - syncScheduler.OnSubscriptionAction(readHandler1); + syncScheduler.OnSubscriptionReportSent(readHandler1); NL_TEST_ASSERT(aSuite, !syncScheduler.IsReportableNow(readHandler1)); NL_TEST_ASSERT(aSuite, !syncScheduler.IsReportableNow(readHandler2)); @@ -795,7 +778,7 @@ class TestReportScheduler syncScheduler.OnBecameReportable(readHandler1); // simulate run with only readhandler1 reportable - syncScheduler.OnSubscriptionAction(readHandler1); + syncScheduler.OnSubscriptionReportSent(readHandler1); NL_TEST_ASSERT(aSuite, !syncScheduler.IsReportableNow(readHandler1)); NL_TEST_ASSERT(aSuite, !syncScheduler.IsReportableNow(readHandler2)); NL_TEST_ASSERT(aSuite, syncScheduler.mTestNextReportTimestamp == node2->GetMinTimestamp()); @@ -806,8 +789,8 @@ class TestReportScheduler NL_TEST_ASSERT(aSuite, syncScheduler.IsReportableNow(readHandler2)); readHandler2->ClearForceDirtyFlag(); - syncScheduler.OnSubscriptionAction(readHandler1); - syncScheduler.OnSubscriptionAction(readHandler2); + syncScheduler.OnSubscriptionReportSent(readHandler1); + syncScheduler.OnSubscriptionReportSent(readHandler2); NL_TEST_ASSERT(aSuite, syncScheduler.mTestNextReportTimestamp == node1->GetMaxTimestamp()); NL_TEST_ASSERT(aSuite, node2->GetSyncTimestamp() == node2->GetMaxTimestamp()); diff --git a/src/app/tests/suites/TestGroupKeyManagementCluster.yaml b/src/app/tests/suites/TestGroupKeyManagementCluster.yaml index 11d190c78738d6..82e10bc2120374 100644 --- a/src/app/tests/suites/TestGroupKeyManagementCluster.yaml +++ b/src/app/tests/suites/TestGroupKeyManagementCluster.yaml @@ -556,6 +556,15 @@ tests: response: error: RESOURCE_EXHAUSTED + - label: "Try to remove KeySet index 0 should fail" + command: "KeySetRemove" + arguments: + values: + - name: "GroupKeySetID" + value: 0 + response: + error: INVALID_COMMAND + - label: "Write Group Keys (invalid)" command: "writeAttribute" attribute: "GroupKeyMap" diff --git a/src/app/tests/suites/certification/Test_TC_DRLK_2_1.yaml b/src/app/tests/suites/certification/Test_TC_DRLK_2_1.yaml index 686061edda9c34..1353bfb2390404 100644 --- a/src/app/tests/suites/certification/Test_TC_DRLK_2_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_DRLK_2_1.yaml @@ -31,6 +31,31 @@ tests: - name: "nodeId" value: nodeId + - label: "Precondition: Create new PIN credential and lock/unlock user" + PICS: DRLK.S.F00 && DRLK.S.F07 + command: "SetCredential" + timedInteractionTimeoutMs: 1000 + arguments: + values: + - name: "OperationType" + value: 0 + - name: "Credential" + value: { CredentialType: 1, CredentialIndex: 1 } + - name: "CredentialData" + value: "123456" + - name: "UserIndex" + value: null + - name: "UserStatus" + value: 1 + - name: "UserType" + value: 0 + response: + values: + - name: "Status" + value: 0 + - name: "NextCredentialIndex" + value: 2 + - label: "Step 1a: TH reads LockState attribute from DUT" PICS: DRLK.S.A0000 command: "readAttribute" @@ -59,10 +84,19 @@ tests: value: LockStateValue - label: "Step 1d: TH sends a Lock Door command to the DUT." - PICS: DRLK.S.C00.Rsp + PICS: DRLK.S.C00.Rsp && !(DRLK.S.F00 && DRLK.S.F07) command: "LockDoor" timedInteractionTimeoutMs: 1000 + - label: "Step 1d: TH sends a Lock Door command to the DUT." + PICS: DRLK.S.C00.Rsp && DRLK.S.F00 && DRLK.S.F07 + command: "LockDoor" + timedInteractionTimeoutMs: 1000 + arguments: + values: + - name: "PINCode" + value: "123456" + - label: "Step 1d: TH reads LockState attribute from DUT" PICS: DRLK.S.A0000 command: "readAttribute" @@ -71,10 +105,19 @@ tests: value: 1 - label: "Step 1e: TH sends a Unlock Door command to the DUT." - PICS: DRLK.S.C01.Rsp + PICS: DRLK.S.C01.Rsp && !(DRLK.S.F00 && DRLK.S.F07) command: "UnlockDoor" timedInteractionTimeoutMs: 1000 + - label: "Step 1e: TH sends a Unlock Door command to the DUT." + PICS: DRLK.S.C01.Rsp && DRLK.S.F00 && DRLK.S.F07 + command: "UnlockDoor" + timedInteractionTimeoutMs: 1000 + arguments: + values: + - name: "PINCode" + value: "123456" + - label: "Step 1e: TH reads LockState attribute from DUT" PICS: DRLK.S.A0000 command: "readAttribute" @@ -822,10 +865,20 @@ tests: command: "readAttribute" attribute: "SupportedOperatingModes" response: - value: 0xFFF6 saveAs: Current_Supported constraints: type: enum16 + anyOf: + [ + 0xFFF6, + 0xFFF4, + 0xFFF2, + 0xFFF0, + 0xFFE6, + 0xFFE4, + 0xFFE2, + 0xFFE0, + ] - label: "Step 23b: TH writes Supported OperatingModes attribute as bit 0 is @@ -985,8 +1038,11 @@ tests: command: "readAttribute" attribute: "EnableLocalProgramming" response: - value: 1 saveAs: Current_EnableLocal_Programming + constraints: + type: boolean + minValue: 0 + maxValue: 1 - label: "Step 26b: TH writes EnableLocalProgramming attribute as false" PICS: DRLK.S.A0028.Write @@ -1023,7 +1079,10 @@ tests: command: "readAttribute" attribute: "EnableOneTouchLocking" response: - value: 0 + constraints: + type: boolean + minValue: 0 + maxValue: 1 - label: "Step 27b: TH writes EnableOneTouchLocking attribute as true" PICS: DRLK.S.A0029 @@ -1044,7 +1103,10 @@ tests: command: "readAttribute" attribute: "EnableInsideStatusLED" response: - value: 0 + constraints: + type: boolean + minValue: 0 + maxValue: 1 - label: "Step 28b: TH writes EnableInsideStatusLED attribute as true" PICS: DRLK.S.A002a @@ -1065,7 +1127,10 @@ tests: command: "readAttribute" attribute: "EnablePrivacyModeButton" response: - value: 0 + constraints: + type: boolean + minValue: 0 + maxValue: 1 - label: "Step 29b: TH writes EnablePrivacy ModeButton attribute as true" PICS: DRLK.S.A002b @@ -1420,7 +1485,10 @@ tests: command: "readAttribute" attribute: "RequirePINforRemoteOperation" response: - value: 0 + constraints: + type: boolean + minValue: 0 + maxValue: 1 saveAs: Current_RequirePINFor_RemoteOperation - label: @@ -1530,3 +1598,12 @@ tests: attribute: "NumberOfCredentialsSupportedPerUser" response: value: NumberOfCredentialsSupportedPerUserValue + + - label: "Clean the created credential/user" + PICS: DRLK.S.F00 && DRLK.S.F07 + command: "ClearCredential" + timedInteractionTimeoutMs: 1000 + arguments: + values: + - name: "Credential" + value: { CredentialType: 1, CredentialIndex: 1 } diff --git a/src/app/tests/suites/certification/Test_TC_DRLK_2_12.yaml b/src/app/tests/suites/certification/Test_TC_DRLK_2_12.yaml index 2964d1c83b3bec..bbb2828c0784ef 100644 --- a/src/app/tests/suites/certification/Test_TC_DRLK_2_12.yaml +++ b/src/app/tests/suites/certification/Test_TC_DRLK_2_12.yaml @@ -21,6 +21,9 @@ config: nodeId: 0x12344321 cluster: "Door Lock" endpoint: 1 + requirePINIsTrue: + type: BOOLEAN + defaultValue: false tests: - label: "Wait for the commissioned device to be retrieved" @@ -152,13 +155,61 @@ tests: command: "readAttribute" attribute: "RequirePINforRemoteOperation" response: - value: false + saveAs: requirePINIsTrue + constraints: + type: boolean + minValue: 0 + maxValue: 1 + + - label: + "Step 2a: TH verifies the RequirePINforRemoteOperation attribute value + is now False on the DUT" + PICS: DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033.Write + cluster: "EqualityCommands" + command: "BooleanEquals" + arguments: + values: + - name: "Value1" + value: requirePINIsTrue + - name: "Value2" + value: false + response: + - values: + - name: "Equals" + value: true + + - label: "Step 2b: Compute RequirePINforRemoteOperation" + cluster: "EqualityCommands" + command: "BooleanEquals" + arguments: + values: + - name: "Value1" + value: requirePINIsTrue + - name: "Value2" + value: false + response: + - values: + - name: "Equals" + saveAs: requirePINIsFalse + constraints: + type: boolean + minValue: 0 + maxValue: 1 - label: "Step 3: TH sends Ubolt Door Command to the DUT without PINCode" + runIf: requirePINIsFalse PICS: DRLK.S.C27.Rsp command: "UnboltDoor" timedInteractionTimeoutMs: 1000 + - label: "Step 3: TH sends Ubolt Door Command to the DUT without PINCode" + runIf: requirePINIsTrue + PICS: DRLK.S.C27.Rsp + command: "UnboltDoor" + timedInteractionTimeoutMs: 1000 + response: + error: FAILURE + - label: "Step 4: TH sends Ubolt Door Command to the DUT with PINCode" PICS: DRLK.S.C27.Rsp command: "UnboltDoor" @@ -195,19 +246,49 @@ tests: command: "readAttribute" attribute: "RequirePINforRemoteOperation" response: - value: true + saveAs: requirePINIsTrue + constraints: + type: boolean + minValue: 0 + maxValue: 1 - - label: "Step 7: TH sends Ubolt Door Command to the DUT with valid PINCode" - PICS: DRLK.S.C27.Rsp - command: "UnboltDoor" - timedInteractionTimeoutMs: 1000 + - label: + "Step 6a: TH verifies the RequirePINforRemoteOperation attribute value + is now True on the DUT" + PICS: DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033.Write + cluster: "EqualityCommands" + command: "BooleanEquals" arguments: values: - - name: "PINCode" - value: "123456" + - name: "Value1" + value: requirePINIsTrue + - name: "Value2" + value: true + response: + - values: + - name: "Equals" + value: true + + - label: "Step 6b: Compute RequirePINforRemoteOperation" + cluster: "EqualityCommands" + command: "BooleanEquals" + arguments: + values: + - name: "Value1" + value: requirePINIsTrue + - name: "Value2" + value: false + response: + - values: + - name: "Equals" + saveAs: requirePINIsFalse + constraints: + type: boolean + minValue: 0 + maxValue: 1 - label: - "Step 8: TH sends Unbolt Door Command to the DUT with Invalid PINCode" + "Step 7: TH sends Unbolt Door Command to the DUT with Invalid PINCode" PICS: DRLK.S.C27.Rsp command: "UnboltDoor" timedInteractionTimeoutMs: 1000 @@ -218,13 +299,29 @@ tests: response: error: FAILURE - - label: "Step 9: TH sends Unbolt Door Command to the DUT without PINCode" + - label: "Step 8: TH sends Unbolt Door Command to the DUT without PINCode" + runIf: requirePINIsTrue PICS: DRLK.S.C27.Rsp command: "UnboltDoor" timedInteractionTimeoutMs: 1000 response: error: FAILURE + - label: "Step 8: TH sends Unbolt Door Command to the DUT without PINCode" + runIf: requirePINIsFalse + PICS: DRLK.S.C27.Rsp + command: "UnboltDoor" + timedInteractionTimeoutMs: 1000 + + - label: "Step 9: TH sends Ubolt Door Command to the DUT with valid PINCode" + PICS: DRLK.S.C27.Rsp + command: "UnboltDoor" + timedInteractionTimeoutMs: 1000 + arguments: + values: + - name: "PINCode" + value: "123456" + - label: "Step 10: TH writes WrongCodeEntryLimit attribute value as 3 on the DUT" diff --git a/src/app/tests/suites/certification/Test_TC_DRLK_2_2.yaml b/src/app/tests/suites/certification/Test_TC_DRLK_2_2.yaml index 4481532c0ca1af..c4e8dcb483e4e1 100644 --- a/src/app/tests/suites/certification/Test_TC_DRLK_2_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_DRLK_2_2.yaml @@ -21,6 +21,9 @@ config: nodeId: 0x12344321 cluster: "Door Lock" endpoint: 1 + requirePINIsTrue: + type: BOOLEAN + defaultValue: false tests: - label: "Wait for the commissioned device to be retrieved" @@ -126,18 +129,18 @@ tests: value: null - label: - "Step 1a: TH writes the RequirePINforRemoteOperation attribute value - as False on the DUT" - PICS: DRLK.S.A0033 + "Step 1: TH writes the RequirePINforRemoteOperation attribute value as + False on the DUT" + PICS: DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033.Write command: "writeAttribute" attribute: "RequirePINforRemoteOperation" arguments: value: false - label: - "Step 1b: TH writes the RequirePINforRemoteOperation attribute value - as False on the DUT and Verify DUT responds with UNSUPPORTED_WRITE" - PICS: "!DRLK.S.A0033" + "Step 1: TH writes the RequirePINforRemoteOperation attribute value as + False on the DUT" + PICS: DRLK.S.F07 && DRLK.S.F00 && !DRLK.S.A0033.Write command: "writeAttribute" attribute: "RequirePINforRemoteOperation" arguments: @@ -152,12 +155,60 @@ tests: command: "readAttribute" attribute: "RequirePINforRemoteOperation" response: - value: false + saveAs: requirePINIsTrue + constraints: + type: boolean + minValue: 0 + maxValue: 1 + + - label: + "Step 2a: TH verifies the RequirePINforRemoteOperation attribute value + is now False on the DUT" + PICS: DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033.Write + cluster: "EqualityCommands" + command: "BooleanEquals" + arguments: + values: + - name: "Value1" + value: requirePINIsTrue + - name: "Value2" + value: false + response: + - values: + - name: "Equals" + value: true + + - label: "Step 2b: Compute RequirePINforRemoteOperation" + cluster: "EqualityCommands" + command: "BooleanEquals" + arguments: + values: + - name: "Value1" + value: requirePINIsTrue + - name: "Value2" + value: false + response: + - values: + - name: "Equals" + saveAs: requirePINIsFalse + constraints: + type: boolean + minValue: 0 + maxValue: 1 + + - label: "Step 3: TH sends Lock Door Command to the DUT without PINCode" + runIf: requirePINIsFalse + PICS: DRLK.S.C00.Rsp + command: "LockDoor" + timedInteractionTimeoutMs: 1000 - label: "Step 3: TH sends Lock Door Command to the DUT without PINCode" + runIf: requirePINIsTrue PICS: DRLK.S.C00.Rsp command: "LockDoor" timedInteractionTimeoutMs: 1000 + response: + error: FAILURE - label: "Step 4: TH sends Lock Door Command to the DUT with valid PINCode" PICS: DRLK.S.C00.Rsp @@ -169,18 +220,18 @@ tests: value: "123456" - label: - "Step 5a: TH writes the RequirePINforRemoteOperation attribute value - as False on the DUT" - PICS: DRLK.S.A0033 + "Step 5: TH writes the RequirePINforRemoteOperation attribute value as + true on the DUT" + PICS: DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033.Write command: "writeAttribute" attribute: "RequirePINforRemoteOperation" arguments: value: true - label: - "Step 5b: TH writes the RequirePINforRemoteOperation attribute value - as False on the DUT and Verify DUT responds with UNSUPPORTED_WRITE" - PICS: "!DRLK.S.A0033" + "Step 5: TH writes the RequirePINforRemoteOperation attribute value as + true on the DUT" + PICS: DRLK.S.F07 && DRLK.S.F00 && !DRLK.S.A0033.Write command: "writeAttribute" attribute: "RequirePINforRemoteOperation" arguments: @@ -195,19 +246,49 @@ tests: command: "readAttribute" attribute: "RequirePINforRemoteOperation" response: - value: true + saveAs: requirePINIsTrue + constraints: + type: boolean + minValue: 0 + maxValue: 1 - - label: "Step 7: TH sends Lock Door Command to the DUT with valid PINCode" - PICS: DRLK.S.C00.Rsp && DRLK.S.A0033 - command: "LockDoor" - timedInteractionTimeoutMs: 1000 + - label: + "Step 6a: TH verifies the RequirePINforRemoteOperation attribute value + is now True on the DUT" + PICS: DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033.Write + cluster: "EqualityCommands" + command: "BooleanEquals" arguments: values: - - name: "PINCode" - value: "123456" + - name: "Value1" + value: requirePINIsTrue + - name: "Value2" + value: true + response: + - values: + - name: "Equals" + value: true + + - label: "Step 6b: Compute RequirePINforRemoteOperation" + cluster: "EqualityCommands" + command: "BooleanEquals" + arguments: + values: + - name: "Value1" + value: requirePINIsTrue + - name: "Value2" + value: false + response: + - values: + - name: "Equals" + saveAs: requirePINIsFalse + constraints: + type: boolean + minValue: 0 + maxValue: 1 - label: - "Step 8: TH sends Lock Door Command to the DUT without valid PINCode" + "Step 7: TH sends Lock Door Command to the DUT without valid PINCode" PICS: DRLK.S.C00.Rsp && DRLK.S.A0033 command: "LockDoor" timedInteractionTimeoutMs: 1000 @@ -218,15 +299,29 @@ tests: response: error: FAILURE - - label: - "Step 9: TH sends Lock Door Command to the DUT without any argument - PINCode" + - label: "Step 8: TH sends Lock Door Command to the DUT without PINCode" + runIf: requirePINIsTrue PICS: DRLK.S.C00.Rsp && DRLK.S.A0033 command: "LockDoor" timedInteractionTimeoutMs: 1000 response: error: FAILURE + - label: "Step 8: TH sends Lock Door Command to the DUT without PINCode" + runIf: requirePINIsFalse + PICS: DRLK.S.C00.Rsp && DRLK.S.A0033 + command: "LockDoor" + timedInteractionTimeoutMs: 1000 + + - label: "Step 9: TH sends Lock Door Command to the DUT with valid PINCode" + PICS: DRLK.S.C00.Rsp && DRLK.S.A0033 + command: "LockDoor" + timedInteractionTimeoutMs: 1000 + arguments: + values: + - name: "PINCode" + value: "123456" + - label: "Step 10a: H reads the WrongCodeEntryLimit attribute from the DUT" PICS: DRLK.S.A0030 command: "readAttribute" @@ -355,7 +450,7 @@ tests: - label: "Step 10e: TH writes WrongCodeEntryLimit attribute value as between 1 and 255 on the DUT and Verify that the DUT sends Success response" - PICS: DRLK.S.A0030 + PICS: ( DRLK.S.F00 || DRLK.S.F01 ) && DRLK.S.A0030.Write command: "writeAttribute" attribute: "WrongCodeEntryLimit" arguments: @@ -364,7 +459,7 @@ tests: - label: "Step 10e: TH writes WrongCodeEntryLimit attribute value as between 1 and 255 on the DUT and verify DUT responds with UNSUPPORTED_WRITE" - PICS: "!DRLK.S.A0030" + PICS: ( DRLK.S.F00 || DRLK.S.F01 ) && !DRLK.S.A0030.Write command: "writeAttribute" attribute: "WrongCodeEntryLimit" arguments: @@ -387,7 +482,7 @@ tests: "Step 12a: TH writes UserCodeTemporaryDisableTime attribute value as between 1 and 255 on the DUT and Verify that the DUT sends Success response" - PICS: DRLK.S.A0031 + PICS: ( DRLK.S.F00 || DRLK.S.F01 ) && DRLK.S.A0031.Write command: "writeAttribute" attribute: "UserCodeTemporaryDisableTime" arguments: @@ -397,7 +492,7 @@ tests: "Step 12a: TH writes UserCodeTemporaryDisableTime attribute value as between 1 and 255 on the DUT and verify DUT responds with UNSUPPORTED_WRITE" - PICS: "!DRLK.S.A0031" + PICS: ( DRLK.S.F00 || DRLK.S.F01 ) && !DRLK.S.A0031.Write command: "writeAttribute" attribute: "UserCodeTemporaryDisableTime" arguments: diff --git a/src/app/tests/suites/certification/Test_TC_DRLK_2_3.yaml b/src/app/tests/suites/certification/Test_TC_DRLK_2_3.yaml index 644d59a39d146f..e8e0583619bde5 100644 --- a/src/app/tests/suites/certification/Test_TC_DRLK_2_3.yaml +++ b/src/app/tests/suites/certification/Test_TC_DRLK_2_3.yaml @@ -22,6 +22,9 @@ config: cluster: "Door Lock" endpoint: 1 timeout: 200 + requirePINIsTrue: + type: BOOLEAN + defaultValue: false tests: - label: "Wait for the commissioned device to be retrieved" @@ -127,18 +130,18 @@ tests: value: null - label: - "Step 1a: TH writes the RequirePINforRemoteOperation attribute value - as False on the DUT" - PICS: DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033 + "Step 1: TH writes the RequirePINforRemoteOperation attribute value as + False on the DUT" + PICS: DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033.Write command: "writeAttribute" attribute: "RequirePINforRemoteOperation" arguments: value: false - label: - "Step 1b: TH writes the RequirePINforRemoteOperation attribute value - as False on the DUT and Verify DUT responds with UNSUPPORTED_WRITE" - PICS: DRLK.S.F07 && DRLK.S.F00 && !DRLK.S.A0033 + "Step 1: TH writes the RequirePINforRemoteOperation attribute value as + False on the DUT" + PICS: DRLK.S.F07 && DRLK.S.F00 && !DRLK.S.A0033.Write command: "writeAttribute" attribute: "RequirePINforRemoteOperation" arguments: @@ -153,14 +156,63 @@ tests: command: "readAttribute" attribute: "RequirePINforRemoteOperation" response: - value: false + saveAs: requirePINIsTrue + constraints: + type: boolean + minValue: 0 + maxValue: 1 + + - label: + "Step 2a: TH verifies the RequirePINforRemoteOperation attribute value + is now False on the DUT" + PICS: DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033.Write + cluster: "EqualityCommands" + command: "BooleanEquals" + arguments: + values: + - name: "Value1" + value: requirePINIsTrue + - name: "Value2" + value: false + response: + - values: + - name: "Equals" + value: true + + - label: "Step 2b: Compute RequirePINforRemoteOperation" + cluster: "EqualityCommands" + command: "BooleanEquals" + arguments: + values: + - name: "Value1" + value: requirePINIsTrue + - name: "Value2" + value: false + response: + - values: + - name: "Equals" + saveAs: requirePINIsFalse + constraints: + type: boolean + minValue: 0 + maxValue: 1 - label: "Step 3: TH sends the unlock Door command to the DUT without PINCode" + runIf: requirePINIsFalse PICS: DRLK.S.C01.Rsp command: "UnlockDoor" timedInteractionTimeoutMs: 1000 + - label: + "Step 3: TH sends the unlock Door command to the DUT without PINCode" + runIf: requirePINIsTrue + PICS: DRLK.S.C01.Rsp + command: "UnlockDoor" + timedInteractionTimeoutMs: 1000 + response: + error: FAILURE + - label: "Step 4: TH sends the unlock Door command to the DUT with valid PINCode" @@ -173,18 +225,18 @@ tests: value: "123456" - label: - "Step 5a: TH writes the RequirePINforRemoteOperation attribute value - as False on the DUT" - PICS: DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033 + "Step 5: TH writes the RequirePINforRemoteOperation attribute value as + true on the DUT" + PICS: DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033.Write command: "writeAttribute" attribute: "RequirePINforRemoteOperation" arguments: value: true - label: - "Step 5b: TH writes the RequirePINforRemoteOperation attribute value - as False on the DUT and Verify DUT responds with UNSUPPORTED_WRITE" - PICS: DRLK.S.F07 && DRLK.S.F00 && !DRLK.S.A0033 + "Step 5: TH writes the RequirePINforRemoteOperation attribute value as + true on the DUT" + PICS: DRLK.S.F07 && DRLK.S.F00 && !DRLK.S.A0033.Write command: "writeAttribute" attribute: "RequirePINforRemoteOperation" arguments: @@ -199,21 +251,49 @@ tests: command: "readAttribute" attribute: "RequirePINforRemoteOperation" response: - value: true + saveAs: requirePINIsTrue + constraints: + type: boolean + minValue: 0 + maxValue: 1 - label: - "Step 7: TH sends the unlock Door command to the DUT with valid - PINCode" - PICS: DRLK.S.C01.Rsp && DRLK.S.A0033 - command: "UnlockDoor" - timedInteractionTimeoutMs: 1000 + "Step 6a: TH verifies the RequirePINforRemoteOperation attribute value + is now True on the DUT" + PICS: DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033.Write + cluster: "EqualityCommands" + command: "BooleanEquals" arguments: values: - - name: "PINCode" - value: "123456" + - name: "Value1" + value: requirePINIsTrue + - name: "Value2" + value: true + response: + - values: + - name: "Equals" + value: true + + - label: "Step 6b: Compute RequirePINforRemoteOperation" + cluster: "EqualityCommands" + command: "BooleanEquals" + arguments: + values: + - name: "Value1" + value: requirePINIsTrue + - name: "Value2" + value: false + response: + - values: + - name: "Equals" + saveAs: requirePINIsFalse + constraints: + type: boolean + minValue: 0 + maxValue: 1 - label: - "Step 8: TH sends the unlock Door command to the DUT with invalid + "Step 7: TH sends the unlock Door command to the DUT with invalid PINCode" PICS: DRLK.S.C01.Rsp && DRLK.S.A0033 command: "UnlockDoor" @@ -226,7 +306,8 @@ tests: error: FAILURE - label: - "Step 9: TH sends the unlock Door command to the DUT without PINCode" + "Step 8: TH sends the unlock Door command to the DUT without PINCode" + runIf: requirePINIsTrue PICS: DRLK.S.C01.Rsp && DRLK.S.A0033 command: "UnlockDoor" timedInteractionTimeoutMs: 1000 @@ -234,18 +315,36 @@ tests: error: FAILURE - label: - "Step 10a: TH writes WrongCodeEntryLimit attribute value as 3 on the - DUT and Verify that the DUT sends Success response" - PICS: DRLK.S.F00 && DRLK.S.F01 && DRLK.S.A0030.Write + "Step 8: TH sends the unlock Door command to the DUT without PINCode" + runIf: requirePINIsFalse + PICS: DRLK.S.C01.Rsp && DRLK.S.A0033 + command: "UnlockDoor" + timedInteractionTimeoutMs: 1000 + + - label: + "Step 9: TH sends the unlock Door command to the DUT with valid + PINCode" + PICS: DRLK.S.C01.Rsp && DRLK.S.A0033 + command: "UnlockDoor" + timedInteractionTimeoutMs: 1000 + arguments: + values: + - name: "PINCode" + value: "123456" + + - label: + "Step 10: TH writes WrongCodeEntryLimit attribute value as 3 on the + DUT" + PICS: ( DRLK.S.F00 || DRLK.S.F01 ) && DRLK.S.A0030.Write command: "writeAttribute" attribute: "WrongCodeEntryLimit" arguments: value: 3 - label: - "Step 10b: TH writes WrongCodeEntryLimit attribute value as 3 on the - DUT and verify DUT responds with UNSUPPORTED_WRITE" - PICS: DRLK.S.F00 && DRLK.S.F01 && !DRLK.S.A0030.Write + "Step 10: TH writes WrongCodeEntryLimit attribute value as 3 on the + DUT" + PICS: ( DRLK.S.F00 || DRLK.S.F01 ) && !DRLK.S.A0030.Write command: "writeAttribute" attribute: "WrongCodeEntryLimit" arguments: @@ -254,18 +353,18 @@ tests: error: UNSUPPORTED_WRITE - label: - "Step 11a: TH writes UserCodeTemporaryDisableTime attribute value as - 15 Seconds on the DUT and Verify that the DUT sends Success response" - PICS: DRLK.S.F00 && DRLK.S.F01 && DRLK.S.A0031.Write + "Step 11: TH writes UserCodeTemporaryDisableTime attribute value as 15 + Seconds on the DUT and Verify that the DUT sends Success response" + PICS: ( DRLK.S.F00 || DRLK.S.F01 ) && DRLK.S.A0031.Write command: "writeAttribute" attribute: "UserCodeTemporaryDisableTime" arguments: value: 15 - label: - "Step 11b: TH writes UserCodeTemporaryDisableTime attribute value as - 15 Seconds on the DUT and Verify that the DUT sends Success response" - PICS: DRLK.S.F00 && DRLK.S.F01 && !DRLK.S.A0031.Write + "Step 11: TH writes UserCodeTemporaryDisableTime attribute value as 15 + Seconds on the DUT and Verify that the DUT sends Success response" + PICS: ( DRLK.S.F00 || DRLK.S.F01 ) && !DRLK.S.A0031.Write command: "writeAttribute" attribute: "UserCodeTemporaryDisableTime" arguments: @@ -326,9 +425,8 @@ tests: error: FAILURE - label: - "Step 13: TH reads the UserCodeTemporaryDisableTime attribute from the - DUT and check attribute is triggered" - PICS: DRLK.S.F00 && DRLK.S.F01 && DRLK.S.A0031 + "Step 13: TH reads UserCodedTemporaryDisableTime attribute from DUT" + PICS: ( DRLK.S.F00 || DRLK.S.F01 ) && DRLK.S.A0031 command: "readAttribute" attribute: "UserCodeTemporaryDisableTime" response: @@ -350,7 +448,7 @@ tests: - label: "Wait for UserCodeTemporaryDisableTime expires" cluster: "DelayCommands" command: "WaitForMs" - PICS: DRLK.S.F00 && DRLK.S.F01 && DRLK.S.A0031 + PICS: ( DRLK.S.F00 || DRLK.S.F01 ) && DRLK.S.A0031 arguments: values: - name: "ms" diff --git a/src/app/tests/suites/ciTests.json b/src/app/tests/suites/ciTests.json index 25ba9a6b338a2b..d3e92a4470dfa5 100644 --- a/src/app/tests/suites/ciTests.json +++ b/src/app/tests/suites/ciTests.json @@ -285,15 +285,12 @@ "DL_LockUnlock", "DL_Schedules", "Test_TC_DRLK_1_1", - "Test_TC_DRLK_2_2", - "Test_TC_DRLK_2_3", "Test_TC_DRLK_2_4", "Test_TC_DRLK_2_5", "Test_TC_DRLK_2_6", "Test_TC_DRLK_2_7", "Test_TC_DRLK_2_8", - "Test_TC_DRLK_2_11", - "Test_TC_DRLK_2_12" + "Test_TC_DRLK_2_11" ], "Groups": [ "TestGroupMessaging", diff --git a/src/app/util/af-enums.h b/src/app/util/af-enums.h index 646ea32c5565d7..27a9c76855bfee 100644 --- a/src/app/util/af-enums.h +++ b/src/app/util/af-enums.h @@ -67,5 +67,6 @@ enum EmberAfStatus : uint8_t EMBER_ZCL_STATUS_PATHS_EXHAUSTED = 0xC8, EMBER_ZCL_STATUS_TIMED_REQUEST_MISMATCH = 0xC9, EMBER_ZCL_STATUS_FAILSAFE_REQUIRED = 0xCA, + EMBER_ZCL_STATE_INVALID_IN_STATE = 0xCB, EMBER_ZCL_STATUS_WRITE_IGNORED = 0xF0, // NOT SPEC COMPLIANT FOR TEST ONLY }; diff --git a/src/controller/java/src/chip/devicecontroller/model/EventState.java b/src/controller/java/src/chip/devicecontroller/model/EventState.java index 23988c7884687f..72b14c1391dc93 100644 --- a/src/controller/java/src/chip/devicecontroller/model/EventState.java +++ b/src/controller/java/src/chip/devicecontroller/model/EventState.java @@ -40,7 +40,7 @@ public EventState( long eventNumber, int priorityLevel, int timestampType, - long systemTimeStamp, + long timestampValue, Object valueObject, byte[] tlv, String jsonString) { diff --git a/src/controller/python/chip/ble/LinuxImpl.cpp b/src/controller/python/chip/ble/LinuxImpl.cpp index 41e589e3c62944..c33dddd1325dcc 100644 --- a/src/controller/python/chip/ble/LinuxImpl.cpp +++ b/src/controller/python/chip/ble/LinuxImpl.cpp @@ -78,11 +78,11 @@ class ScannerDelegateImpl : public ChipDeviceScannerDelegate void SetScanner(std::unique_ptr scanner) { mScanner = std::move(scanner); } - void OnDeviceScanned(BluezDevice1 * device, const chip::Ble::ChipBLEDeviceIdentificationInfo & info) override + void OnDeviceScanned(BluezDevice1 & device, const chip::Ble::ChipBLEDeviceIdentificationInfo & info) override { if (mScanCallback) { - mScanCallback(mContext, bluez_device1_get_address(device), info.GetDeviceDiscriminator(), info.GetProductId(), + mScanCallback(mContext, bluez_device1_get_address(&device), info.GetDeviceDiscriminator(), info.GetProductId(), info.GetVendorId()); } } diff --git a/src/controller/tests/data_model/TestCommands.cpp b/src/controller/tests/data_model/TestCommands.cpp index f9d1e35a900b73..0cb30647b6da4e 100644 --- a/src/controller/tests/data_model/TestCommands.cpp +++ b/src/controller/tests/data_model/TestCommands.cpp @@ -85,8 +85,7 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, chip if (DataModel::Decode(aReader, dataRequest) != CHIP_NO_ERROR) { - apCommandObj->AddStatusAndLogIfFailure(aCommandPath, Protocols::InteractionModel::Status::Failure, - "Unable to decode the request"); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::Failure, "Unable to decode the request"); return; } @@ -116,15 +115,18 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, chip } else if (responseDirective == kSendMultipleSuccessStatusCodes) { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::Success, + "No error but testing status success case"); + // TODO: Right now all but the first AddStatus call fail, so this // test is not really testing what it should. - for (size_t i = 0; i < 4; ++i) + for (size_t i = 0; i < 3; ++i) { - apCommandObj->AddStatusAndLogIfFailure(aCommandPath, Protocols::InteractionModel::Status::Success, - "No error but testing AddStatusAndLogIfFailure in success case"); + (void) apCommandObj->FallibleAddStatus(aCommandPath, Protocols::InteractionModel::Status::Success, + "No error but testing status success case"); } // And one failure on the end. - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::Failure); + (void) apCommandObj->FallibleAddStatus(aCommandPath, Protocols::InteractionModel::Status::Failure); } else if (responseDirective == kSendError) { @@ -132,11 +134,13 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, chip } else if (responseDirective == kSendMultipleErrors) { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::Failure); + // TODO: Right now all but the first AddStatus call fail, so this // test is not really testing what it should. - for (size_t i = 0; i < 4; ++i) + for (size_t i = 0; i < 3; ++i) { - apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::Failure); + (void) apCommandObj->FallibleAddStatus(aCommandPath, Protocols::InteractionModel::Status::Failure); } } else if (responseDirective == kSendSuccessStatusCodeWithClusterStatus) diff --git a/src/credentials/FabricTable.cpp b/src/credentials/FabricTable.cpp index 8ec4691f9f80fa..f9b7503a7bad9e 100644 --- a/src/credentials/FabricTable.cpp +++ b/src/credentials/FabricTable.cpp @@ -510,6 +510,11 @@ FabricInfo * FabricTable::GetMutableFabricByIndex(FabricIndex fabricIndex) const FabricInfo * FabricTable::FindFabricWithIndex(FabricIndex fabricIndex) const { + if (fabricIndex == kUndefinedFabricIndex) + { + return nullptr; + } + // Try to match pending fabric first if available if (HasPendingFabricUpdate() && (mPendingFabric.GetFabricIndex() == fabricIndex)) { diff --git a/src/credentials/tests/TestFabricTable.cpp b/src/credentials/tests/TestFabricTable.cpp index 96ed242a684310..0ed6db832f3b17 100644 --- a/src/credentials/tests/TestFabricTable.cpp +++ b/src/credentials/tests/TestFabricTable.cpp @@ -2391,6 +2391,11 @@ void TestFabricLookup(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, fabricInfo->GetFabricIndex() == 2); NL_TEST_ASSERT(inSuite, !fabricInfo->ShouldAdvertiseIdentity()); } + + // Attempt lookup of FabricIndex 0 --> should always fail. + { + NL_TEST_ASSERT(inSuite, fabricTable.FindFabricWithIndex(0) == nullptr); + } } void TestFetchCATs(nlTestSuite * inSuite, void * inContext) diff --git a/src/platform/ESP32/ConnectivityManagerImpl.h b/src/platform/ESP32/ConnectivityManagerImpl.h index 97d07b894cb9c2..0add13da49886c 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl.h +++ b/src/platform/ESP32/ConnectivityManagerImpl.h @@ -167,6 +167,12 @@ class ConnectivityManagerImpl final : public ConnectivityManager, void OnStationIPv6AddressAvailable(const ip_event_got_ip6_t & got_ip); #endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI +#if CHIP_DEVICE_CONFIG_ENABLE_ETHERNET + void OnEthernetIPv4AddressAvailable(const ip_event_got_ip_t & got_ip); + void OnEthernetIPv4AddressLost(void); + void OnEthernetIPv6AddressAvailable(const ip_event_got_ip6_t & got_ip); +#endif // CHIP_DEVICE_CONFIG_ENABLE_ETHERNET + // ===== Members for internal use by the following friends. friend ConnectivityManager & ConnectivityMgr(void); diff --git a/src/platform/ESP32/ConnectivityManagerImpl_Ethernet.cpp b/src/platform/ESP32/ConnectivityManagerImpl_Ethernet.cpp index ec8d729d417d85..d8f7137047ebac 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl_Ethernet.cpp +++ b/src/platform/ESP32/ConnectivityManagerImpl_Ethernet.cpp @@ -55,15 +55,52 @@ CHIP_ERROR ConnectivityManagerImpl::InitEthernet() return CHIP_NO_ERROR; } +void ConnectivityManagerImpl::OnEthernetIPv4AddressAvailable(const ip_event_got_ip_t & got_ip) +{ + ChipLogProgress(DeviceLayer, "IPv4 address available on Ethernet interface: " IPSTR "/" IPSTR " gateway " IPSTR, + IP2STR(&got_ip.ip_info.ip), IP2STR(&got_ip.ip_info.netmask), IP2STR(&got_ip.ip_info.gw)); + + ChipDeviceEvent event; + event.Type = DeviceEventType::kInterfaceIpAddressChanged; + event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV4_Assigned; + PlatformMgr().PostEventOrDie(&event); +} + +void ConnectivityManagerImpl::OnEthernetIPv4AddressLost(void) +{ + ChipLogProgress(DeviceLayer, "IPv4 address lost on Ethernet interface"); + + ChipDeviceEvent event; + event.Type = DeviceEventType::kInterfaceIpAddressChanged; + event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV4_Lost; + PlatformMgr().PostEventOrDie(&event); +} + +void ConnectivityManagerImpl::OnEthernetIPv6AddressAvailable(const ip_event_got_ip6_t & got_ip) +{ + ChipLogProgress(DeviceLayer, "IPv6 address available on Ethernet interface: " IPV6STR, IPV62STR(got_ip.ip6_info.ip)); + + ChipDeviceEvent event; + event.Type = DeviceEventType::kInterfaceIpAddressChanged; + event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV6_Assigned; + PlatformMgr().PostEventOrDie(&event); +} + void ConnectivityManagerImpl::OnEthernetPlatformEvent(const ChipDeviceEvent * event) { switch (event->Platform.ESPSystemEvent.Id) { case IP_EVENT_ETH_GOT_IP: - ChipLogProgress(DeviceLayer, "Ethernet Link Up"); + OnEthernetIPv4AddressAvailable(event->Platform.ESPSystemEvent.Data.IpGotIp); break; case IP_EVENT_ETH_LOST_IP: - ChipLogProgress(DeviceLayer, "Ethernet Link Down"); + OnEthernetIPv4AddressLost(); + break; + case IP_EVENT_GOT_IP6: + if (strcmp(esp_netif_get_ifkey(event->Platform.ESPSystemEvent.Data.IpGotIp6.esp_netif), "ETH_DEF") == 0) + { + OnEthernetIPv6AddressAvailable(event->Platform.ESPSystemEvent.Data.IpGotIp6); + } break; case ETHERNET_EVENT_START: ChipLogProgress(DeviceLayer, "Ethernet Started"); diff --git a/src/platform/webos/GlibTypeDeleter.h b/src/platform/GLibTypeDeleter.h similarity index 70% rename from src/platform/webos/GlibTypeDeleter.h rename to src/platform/GLibTypeDeleter.h index 476a00a9ae5c50..bd93be76203cd2 100644 --- a/src/platform/webos/GlibTypeDeleter.h +++ b/src/platform/GLibTypeDeleter.h @@ -17,7 +17,12 @@ #pragma once +#include + #include +#include + +namespace chip { template class UniquePointerReceiver @@ -69,3 +74,49 @@ struct GBytesDeleter { void operator()(GBytes * object) { g_bytes_unref(object); } }; + +template +struct GAutoPtrDeleter +{ +}; + +template <> +struct GAutoPtrDeleter +{ + using deleter = GFree; +}; + +template <> +struct GAutoPtrDeleter +{ + using deleter = GBytesDeleter; +}; + +template <> +struct GAutoPtrDeleter +{ + using deleter = GObjectDeleter; +}; + +template <> +struct GAutoPtrDeleter +{ + using deleter = GErrorDeleter; +}; + +template <> +struct GAutoPtrDeleter +{ + using deleter = GVariantDeleter; +}; + +template <> +struct GAutoPtrDeleter +{ + using deleter = GVariantIterDeleter; +}; + +template +using GAutoPtr = std::unique_ptr::deleter>; + +} // namespace chip diff --git a/src/platform/Linux/BLEManagerImpl.cpp b/src/platform/Linux/BLEManagerImpl.cpp index 07ea5d6170d8c4..deab037321dd27 100644 --- a/src/platform/Linux/BLEManagerImpl.cpp +++ b/src/platform/Linux/BLEManagerImpl.cpp @@ -21,20 +21,26 @@ * Provides an implementation of the BLEManager singleton object * for Linux platforms. */ -#include -#include -#include -#include -#include -#include -#include +/** + * Note: BLEManager requires ConnectivityManager to be defined beforehand, + * otherwise we will face circular dependency between them. */ +#include + +/** + * Note: Use public include for BLEManager which includes our local + * platform//BLEManagerImpl.h after defining interface class. */ +#include "platform/internal/BLEManager.h" #include #include #include -#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE +#include +#include +#include +#include +#include #include "bluez/Helper.h" @@ -773,9 +779,9 @@ void BLEManagerImpl::NotifyBLEPeripheralAdvStopComplete(bool aIsSuccess, void * PlatformMgr().PostEventOrDie(&event); } -void BLEManagerImpl::OnDeviceScanned(BluezDevice1 * device, const chip::Ble::ChipBLEDeviceIdentificationInfo & info) +void BLEManagerImpl::OnDeviceScanned(BluezDevice1 & device, const chip::Ble::ChipBLEDeviceIdentificationInfo & info) { - ChipLogProgress(Ble, "New device scanned: %s", bluez_device1_get_address(device)); + ChipLogProgress(Ble, "New device scanned: %s", bluez_device1_get_address(&device)); if (mBLEScanConfig.mBleScanState == BleScanState::kScanForDiscriminator) { @@ -787,7 +793,7 @@ void BLEManagerImpl::OnDeviceScanned(BluezDevice1 * device, const chip::Ble::Chi } else if (mBLEScanConfig.mBleScanState == BleScanState::kScanForAddress) { - if (strcmp(bluez_device1_get_address(device), mBLEScanConfig.mAddress.c_str()) != 0) + if (strcmp(bluez_device1_get_address(&device), mBLEScanConfig.mAddress.c_str()) != 0) { return; } @@ -837,5 +843,3 @@ void BLEManagerImpl::OnScanError(CHIP_ERROR err) } // namespace Internal } // namespace DeviceLayer } // namespace chip - -#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE diff --git a/src/platform/Linux/BLEManagerImpl.h b/src/platform/Linux/BLEManagerImpl.h index 319b4b3468e0ff..23e182f2281b31 100644 --- a/src/platform/Linux/BLEManagerImpl.h +++ b/src/platform/Linux/BLEManagerImpl.h @@ -26,8 +26,6 @@ #include #include -#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE - #include "bluez/ChipDeviceScanner.h" #include "bluez/Types.h" @@ -154,7 +152,7 @@ class BLEManagerImpl final : public BLEManager, CHIP_ERROR CancelConnection() override; // ===== Members that implement virtual methods on ChipDeviceScannerDelegate - void OnDeviceScanned(BluezDevice1 * device, const chip::Ble::ChipBLEDeviceIdentificationInfo & info) override; + void OnDeviceScanned(BluezDevice1 & device, const chip::Ble::ChipBLEDeviceIdentificationInfo & info) override; void OnScanComplete() override; // ===== Members for internal use by the following friends. @@ -181,9 +179,9 @@ class BLEManagerImpl final : public BLEManager, enum { - kMaxConnections = 1, // TODO: right max connection - kMaxDeviceNameLength = 20, // TODO: right-size this - kMaxAdvertismentDataSetSize = 31 // TODO: verify this + kMaxConnections = 1, // TODO: right max connection + kMaxDeviceNameLength = 20, // TODO: right-size this + kMaxAdvertisementDataSetSize = 31 // TODO: verify this }; CHIP_ERROR StartBLEAdvertising(); @@ -246,5 +244,3 @@ inline bool BLEManagerImpl::_IsAdvertising() } // namespace Internal } // namespace DeviceLayer } // namespace chip - -#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE diff --git a/src/platform/Linux/BUILD.gn b/src/platform/Linux/BUILD.gn index 69d0289254d063..56324ff5c4a494 100644 --- a/src/platform/Linux/BUILD.gn +++ b/src/platform/Linux/BUILD.gn @@ -41,10 +41,8 @@ static_library("Linux") { sources = [ "../DeviceSafeQueue.cpp", "../DeviceSafeQueue.h", + "../GLibTypeDeleter.h", "../SingletonConfigurationManager.cpp", - "BLEManagerImpl.cpp", - "BLEManagerImpl.h", - "BlePlatformConfig.h", "CHIPDevicePlatformConfig.h", "CHIPDevicePlatformEvent.h", "CHIPLinuxStorage.cpp", @@ -85,6 +83,9 @@ static_library("Linux") { if (chip_enable_ble) { sources += [ + "BLEManagerImpl.cpp", + "BLEManagerImpl.h", + "BlePlatformConfig.h", "bluez/AdapterIterator.cpp", "bluez/AdapterIterator.h", "bluez/ChipDeviceScanner.cpp", @@ -125,7 +126,6 @@ static_library("Linux") { if (chip_enable_openthread) { sources += [ - "GlibTypeDeleter.h", "ThreadStackManagerImpl.cpp", "ThreadStackManagerImpl.h", ] @@ -138,10 +138,7 @@ static_library("Linux") { } if (chip_enable_wifi) { - sources += [ - "GlibTypeDeleter.h", - "NetworkCommissioningWiFiDriver.cpp", - ] + sources += [ "NetworkCommissioningWiFiDriver.cpp" ] public_deps += [ "dbus/wpa" ] } diff --git a/src/platform/Linux/ConnectivityManagerImpl.cpp b/src/platform/Linux/ConnectivityManagerImpl.cpp index d393008102bbb4..b9686d8ce104f8 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.cpp +++ b/src/platform/Linux/ConnectivityManagerImpl.cpp @@ -58,7 +58,7 @@ #endif #if CHIP_DEVICE_CONFIG_ENABLE_WPA -#include +#include #include #endif @@ -76,6 +76,23 @@ using namespace ::chip::app::Clusters::WiFiNetworkDiagnostics; using namespace ::chip::DeviceLayer::NetworkCommissioning; namespace chip { + +#if CHIP_DEVICE_CONFIG_ENABLE_WPA + +template <> +struct GAutoPtrDeleter +{ + using deleter = GObjectDeleter; +}; + +template <> +struct GAutoPtrDeleter +{ + using deleter = GObjectDeleter; +}; + +#endif // CHIP_DEVICE_CONFIG_ENABLE_WPA + namespace DeviceLayer { ConnectivityManagerImpl ConnectivityManagerImpl::sInstance; @@ -1070,8 +1087,7 @@ ConnectivityManagerImpl::ConnectWiFiNetworkAsync(ByteSpan ssid, ByteSpan credent void ConnectivityManagerImpl::_ConnectWiFiNetworkAsyncCallback(GObject * source_object, GAsyncResult * res, gpointer user_data) { ConnectivityManagerImpl * this_ = reinterpret_cast(user_data); - std::unique_ptr attachRes; - std::unique_ptr err; + GAutoPtr err; std::lock_guard lock(mWpaSupplicantMutex); @@ -1159,7 +1175,7 @@ void ConnectivityManagerImpl::PostNetworkConnect() CHIP_ERROR ConnectivityManagerImpl::CommitConfig() { gboolean result; - std::unique_ptr err; + GAutoPtr err; std::lock_guard lock(mWpaSupplicantMutex); @@ -1290,7 +1306,7 @@ CHIP_ERROR ConnectivityManagerImpl::GetWiFiVersion(WiFiVersionEnum & wiFiVersion int32_t ConnectivityManagerImpl::GetDisconnectReason() { std::lock_guard lock(mWpaSupplicantMutex); - std::unique_ptr err; + GAutoPtr err; gint errorValue = wpa_fi_w1_wpa_supplicant1_interface_get_disconnect_reason(mWpaSupplicant.iface); // wpa_supplicant DBus API: DisconnectReason: The most recent IEEE 802.11 reason code for disconnect. Negative value @@ -1306,7 +1322,7 @@ CHIP_ERROR ConnectivityManagerImpl::GetConfiguredNetwork(NetworkCommissioning::N // with the proxy object. std::lock_guard lock(mWpaSupplicantMutex); - std::unique_ptr err; + GAutoPtr err; if (mWpaSupplicant.iface == nullptr) { @@ -1322,10 +1338,9 @@ CHIP_ERROR ConnectivityManagerImpl::GetConfiguredNetwork(NetworkCommissioning::N return CHIP_ERROR_KEY_NOT_FOUND; } - std::unique_ptr networkInfo( - wpa_fi_w1_wpa_supplicant1_network_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, - kWpaSupplicantServiceName, networkPath, nullptr, - &MakeUniquePointerReceiver(err).Get())); + GAutoPtr networkInfo(wpa_fi_w1_wpa_supplicant1_network_proxy_new_for_bus_sync( + G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, kWpaSupplicantServiceName, networkPath, nullptr, + &MakeUniquePointerReceiver(err).Get())); if (networkInfo == nullptr) { return CHIP_ERROR_INTERNAL; @@ -1333,9 +1348,9 @@ CHIP_ERROR ConnectivityManagerImpl::GetConfiguredNetwork(NetworkCommissioning::N network.connected = wpa_fi_w1_wpa_supplicant1_network_get_enabled(networkInfo.get()); GVariant * properties = wpa_fi_w1_wpa_supplicant1_network_get_properties(networkInfo.get()); - GVariant * ssid = g_variant_lookup_value(properties, "ssid", nullptr); + GAutoPtr ssid(g_variant_lookup_value(properties, "ssid", nullptr)); gsize length; - const gchar * ssidStr = g_variant_get_string(ssid, &length); + const gchar * ssidStr = g_variant_get_string(ssid.get(), &length); // TODO: wpa_supplicant will return ssid with quotes! We should have a better way to get the actual ssid in bytes. gsize length_actual = length - 2; VerifyOrReturnError(length_actual <= sizeof(network.networkID), CHIP_ERROR_INTERNAL); @@ -1350,7 +1365,7 @@ CHIP_ERROR ConnectivityManagerImpl::StopAutoScan() std::lock_guard lock(mWpaSupplicantMutex); VerifyOrReturnError(mWpaSupplicant.iface != nullptr, CHIP_ERROR_INCORRECT_STATE); - std::unique_ptr err; + GAutoPtr err; gboolean result; ChipLogDetail(DeviceLayer, "wpa_supplicant: disabling auto scan"); @@ -1407,6 +1422,7 @@ CHIP_ERROR ConnectivityManagerImpl::StartWiFiScan(ByteSpan ssid, WiFiDriver::Sca } namespace { + // wpa_supplicant's scan results don't contains the channel infomation, so we need this lookup table for resolving the band and // channel infomation. std::pair GetBandAndChannelFromFrequency(uint32_t freq) @@ -1505,6 +1521,7 @@ std::pair GetBandAndChannelFromFrequency(uint32_t freq) } return ret; } + } // namespace bool ConnectivityManagerImpl::_GetBssInfo(const gchar * bssPath, NetworkCommissioning::WiFiScanResponse & result) @@ -1514,8 +1531,8 @@ bool ConnectivityManagerImpl::_GetBssInfo(const gchar * bssPath, NetworkCommissi // completed before this function returns. Also, no external callbacks are registered // with the proxy object. - std::unique_ptr err; - std::unique_ptr bss( + GAutoPtr err; + GAutoPtr bss( wpa_fi_w1_wpa_supplicant1_bss_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, kWpaSupplicantServiceName, bssPath, nullptr, &MakeUniquePointerReceiver(err).Get())); @@ -1526,8 +1543,8 @@ bool ConnectivityManagerImpl::_GetBssInfo(const gchar * bssPath, NetworkCommissi WpaFiW1Wpa_supplicant1BSSProxy * bssProxy = WPA_FI_W1_WPA_SUPPLICANT1_BSS_PROXY(bss.get()); - std::unique_ptr ssid(g_dbus_proxy_get_cached_property(G_DBUS_PROXY(bssProxy), "SSID")); - std::unique_ptr bssid(g_dbus_proxy_get_cached_property(G_DBUS_PROXY(bssProxy), "BSSID")); + GAutoPtr ssid(g_dbus_proxy_get_cached_property(G_DBUS_PROXY(bssProxy), "SSID")); + GAutoPtr bssid(g_dbus_proxy_get_cached_property(G_DBUS_PROXY(bssProxy), "BSSID")); // Network scan is performed in the background, so the BSS // may be gone when we try to get the properties. @@ -1635,8 +1652,8 @@ bool ConnectivityManagerImpl::_GetBssInfo(const gchar * bssPath, NetworkCommissi return res; }; auto GetNetworkSecurityType = [IsNetworkWPAPSK, IsNetworkWPA2PSK](WpaFiW1Wpa_supplicant1BSSProxy * proxy) -> uint8_t { - std::unique_ptr wpa(g_dbus_proxy_get_cached_property(G_DBUS_PROXY(proxy), "WPA")); - std::unique_ptr rsn(g_dbus_proxy_get_cached_property(G_DBUS_PROXY(proxy), "RSN")); + GAutoPtr wpa(g_dbus_proxy_get_cached_property(G_DBUS_PROXY(proxy), "WPA")); + GAutoPtr rsn(g_dbus_proxy_get_cached_property(G_DBUS_PROXY(proxy), "RSN")); uint8_t res = IsNetworkWPAPSK(wpa.get()) | IsNetworkWPA2PSK(rsn.get()); if (res == 0) diff --git a/src/platform/Linux/GlibTypeDeleter.h b/src/platform/Linux/GlibTypeDeleter.h deleted file mode 100644 index 476a00a9ae5c50..00000000000000 --- a/src/platform/Linux/GlibTypeDeleter.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * - * Copyright (c) 2020 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. - */ - -#pragma once - -#include - -template -class UniquePointerReceiver -{ -public: - UniquePointerReceiver(std::unique_ptr & target) : mTarget(target) {} - - ~UniquePointerReceiver() { mTarget.reset(mValue); } - - T *& Get() { return mValue; } - -private: - std::unique_ptr & mTarget; - T * mValue = nullptr; -}; - -template -UniquePointerReceiver MakeUniquePointerReceiver(std::unique_ptr & target) -{ - return UniquePointerReceiver(target); -} - -struct GFree -{ - void operator()(gpointer object) { g_free(object); } -}; - -struct GObjectDeleter -{ - void operator()(gpointer object) { g_object_unref(object); } -}; - -struct GErrorDeleter -{ - void operator()(GError * object) { g_error_free(object); } -}; - -struct GVariantDeleter -{ - void operator()(GVariant * object) { g_variant_unref(object); } -}; - -struct GVariantIterDeleter -{ - void operator()(GVariantIter * object) { g_variant_iter_free(object); } -}; - -struct GBytesDeleter -{ - void operator()(GBytes * object) { g_bytes_unref(object); } -}; diff --git a/src/platform/Linux/ThreadStackManagerImpl.cpp b/src/platform/Linux/ThreadStackManagerImpl.cpp index 8e27a9fece2b0f..dfaee5297f6f11 100755 --- a/src/platform/Linux/ThreadStackManagerImpl.cpp +++ b/src/platform/Linux/ThreadStackManagerImpl.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -65,10 +66,10 @@ CHIP_ERROR GLibMatterContextSetActiveDataset(SetActiveDatasetContext * context) // all D-Bus signals will be delivered to the GLib global default main context. VerifyOrDie(g_main_context_get_thread_default() != nullptr); - std::unique_ptr bytes(g_bytes_new(context->netInfo.data(), context->netInfo.size())); + GAutoPtr bytes(g_bytes_new(context->netInfo.data(), context->netInfo.size())); if (!bytes) return CHIP_ERROR_NO_MEMORY; - std::unique_ptr value(g_variant_new_from_bytes(G_VARIANT_TYPE_BYTESTRING, bytes.release(), true)); + GAutoPtr value(g_variant_new_from_bytes(G_VARIANT_TYPE_BYTESTRING, bytes.release(), true)); if (!value) return CHIP_ERROR_NO_MEMORY; openthread_io_openthread_border_router_set_active_dataset_tlvs(context->proxy, value.release()); @@ -85,7 +86,7 @@ CHIP_ERROR ThreadStackManagerImpl::GLibMatterContextInitThreadStack(ThreadStackM // all D-Bus signals will be delivered to the GLib global default main context. VerifyOrDie(g_main_context_get_thread_default() != nullptr); - std::unique_ptr err; + GAutoPtr err; self->mProxy.reset(openthread_io_openthread_border_router_proxy_new_for_bus_sync( G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, kDBusOpenThreadService, kDBusOpenThreadObjectPath, nullptr, &MakeUniquePointerReceiver(err).Get())); @@ -107,7 +108,7 @@ CHIP_ERROR ThreadStackManagerImpl::_InitThreadStack() // If get property is called inside dbus thread (we are going to make it so), XXX_get_XXX can be used instead of XXX_dup_XXX // which is a little bit faster and the returned object doesn't need to be freed. Same for all following get properties. - std::unique_ptr role(openthread_io_openthread_border_router_dup_device_role(mProxy.get())); + GAutoPtr role(openthread_io_openthread_border_router_dup_device_role(mProxy.get())); if (role) { ThreadDeviceRoleChangedHandler(role.get()); @@ -125,7 +126,7 @@ void ThreadStackManagerImpl::OnDbusPropertiesChanged(OpenthreadIoOpenthreadBorde const gchar * key; GVariant * value; - std::unique_ptr iter; + GAutoPtr iter; g_variant_get(changed_properties, "a{sv}", &MakeUniquePointerReceiver(iter).Get()); if (!iter) return; @@ -189,13 +190,13 @@ bool ThreadStackManagerImpl::_HaveRouteToAddress(const Inet::IPAddress & destAdd return true; } - std::unique_ptr routes(openthread_io_openthread_border_router_dup_external_routes(mProxy.get())); + GAutoPtr routes(openthread_io_openthread_border_router_dup_external_routes(mProxy.get())); if (!routes) return false; if (g_variant_n_children(routes.get()) > 0) { - std::unique_ptr iter; + GAutoPtr iter; g_variant_get(routes.get(), "av", &MakeUniquePointerReceiver(iter).Get()); if (!iter) return false; @@ -205,7 +206,7 @@ bool ThreadStackManagerImpl::_HaveRouteToAddress(const Inet::IPAddress & destAdd { if (route == nullptr) continue; - std::unique_ptr prefix; + GAutoPtr prefix; guint16 rloc16; guchar preference; gboolean stable; @@ -215,7 +216,7 @@ bool ThreadStackManagerImpl::_HaveRouteToAddress(const Inet::IPAddress & destAdd if (!prefix) continue; - std::unique_ptr address; + GAutoPtr address; guchar prefixLength; g_variant_get(prefix.get(), "(&vy)", &MakeUniquePointerReceiver(address).Get(), &prefixLength); if (!address) @@ -273,12 +274,11 @@ CHIP_ERROR ThreadStackManagerImpl::_GetThreadProvision(Thread::OperationalDatase VerifyOrReturnError(mProxy, CHIP_ERROR_INCORRECT_STATE); { - std::unique_ptr err; - - std::unique_ptr response( - g_dbus_proxy_call_sync(G_DBUS_PROXY(mProxy.get()), "org.freedesktop.DBus.Properties.Get", - g_variant_new("(ss)", "io.openthread.BorderRouter", "ActiveDatasetTlvs"), G_DBUS_CALL_FLAGS_NONE, - -1, nullptr, &MakeUniquePointerReceiver(err).Get())); + GAutoPtr err; + GAutoPtr response(g_dbus_proxy_call_sync(G_DBUS_PROXY(mProxy.get()), "org.freedesktop.DBus.Properties.Get", + g_variant_new("(ss)", "io.openthread.BorderRouter", "ActiveDatasetTlvs"), + G_DBUS_CALL_FLAGS_NONE, -1, nullptr, + &MakeUniquePointerReceiver(err).Get())); if (err) { @@ -293,14 +293,14 @@ CHIP_ERROR ThreadStackManagerImpl::_GetThreadProvision(Thread::OperationalDatase return CHIP_ERROR_KEY_NOT_FOUND; } - std::unique_ptr tupleContent(g_variant_get_child_value(response.get(), 0)); + GAutoPtr tupleContent(g_variant_get_child_value(response.get(), 0)); if (tupleContent == nullptr) { return CHIP_ERROR_KEY_NOT_FOUND; } - std::unique_ptr value(g_variant_get_variant(tupleContent.get())); + GAutoPtr value(g_variant_get_variant(tupleContent.get())); if (value == nullptr) { @@ -331,12 +331,10 @@ bool ThreadStackManagerImpl::_IsThreadEnabled() { VerifyOrReturnError(mProxy, false); - std::unique_ptr err; - - std::unique_ptr response( - g_dbus_proxy_call_sync(G_DBUS_PROXY(mProxy.get()), "org.freedesktop.DBus.Properties.Get", - g_variant_new("(ss)", "io.openthread.BorderRouter", "DeviceRole"), G_DBUS_CALL_FLAGS_NONE, -1, - nullptr, &MakeUniquePointerReceiver(err).Get())); + GAutoPtr err; + GAutoPtr response(g_dbus_proxy_call_sync(G_DBUS_PROXY(mProxy.get()), "org.freedesktop.DBus.Properties.Get", + g_variant_new("(ss)", "io.openthread.BorderRouter", "DeviceRole"), + G_DBUS_CALL_FLAGS_NONE, -1, nullptr, &MakeUniquePointerReceiver(err).Get())); if (err) { @@ -349,14 +347,14 @@ bool ThreadStackManagerImpl::_IsThreadEnabled() return false; } - std::unique_ptr tupleContent(g_variant_get_child_value(response.get(), 0)); + GAutoPtr tupleContent(g_variant_get_child_value(response.get(), 0)); if (tupleContent == nullptr) { return false; } - std::unique_ptr value(g_variant_get_variant(tupleContent.get())); + GAutoPtr value(g_variant_get_variant(tupleContent.get())); if (value == nullptr) { @@ -395,7 +393,7 @@ CHIP_ERROR ThreadStackManagerImpl::_SetThreadEnabled(bool val) } else { - std::unique_ptr err; + GAutoPtr err; gboolean result = openthread_io_openthread_border_router_call_reset_sync(mProxy.get(), nullptr, &MakeUniquePointerReceiver(err).Get()); if (err) @@ -416,8 +414,8 @@ CHIP_ERROR ThreadStackManagerImpl::_SetThreadEnabled(bool val) void ThreadStackManagerImpl::_OnThreadBrAttachFinished(GObject * source_object, GAsyncResult * res, gpointer user_data) { ThreadStackManagerImpl * this_ = reinterpret_cast(user_data); - std::unique_ptr attachRes; - std::unique_ptr err; + GAutoPtr attachRes; + GAutoPtr err; { gboolean result = openthread_io_openthread_border_router_call_attach_finish(this_->mProxy.get(), res, &MakeUniquePointerReceiver(err).Get()); @@ -457,7 +455,7 @@ ConnectivityManager::ThreadDeviceType ThreadStackManagerImpl::_GetThreadDeviceTy return ConnectivityManager::ThreadDeviceType::kThreadDeviceType_NotSupported; } - std::unique_ptr role(openthread_io_openthread_border_router_dup_device_role(mProxy.get())); + GAutoPtr role(openthread_io_openthread_border_router_dup_device_role(mProxy.get())); if (!role) return ConnectivityManager::ThreadDeviceType::kThreadDeviceType_NotSupported; if (strcmp(role.get(), kOpenthreadDeviceRoleDetached) == 0 || strcmp(role.get(), kOpenthreadDeviceRoleDisabled) == 0) @@ -466,7 +464,7 @@ ConnectivityManager::ThreadDeviceType ThreadStackManagerImpl::_GetThreadDeviceTy } if (strcmp(role.get(), kOpenthreadDeviceRoleChild) == 0) { - std::unique_ptr linkMode(openthread_io_openthread_border_router_dup_link_mode(mProxy.get())); + GAutoPtr linkMode(openthread_io_openthread_border_router_dup_link_mode(mProxy.get())); if (!linkMode) return ConnectivityManager::ThreadDeviceType::kThreadDeviceType_NotSupported; gboolean rx_on_when_idle; @@ -511,7 +509,7 @@ CHIP_ERROR ThreadStackManagerImpl::_SetThreadDeviceType(ConnectivityManager::Thr if (!network_data) { - std::unique_ptr linkMode(g_variant_new("(bbb)", rx_on_when_idle, device_type, network_data)); + GAutoPtr linkMode(g_variant_new("(bbb)", rx_on_when_idle, device_type, network_data)); if (!linkMode) return CHIP_ERROR_NO_MEMORY; openthread_io_openthread_border_router_set_link_mode(mProxy.get(), linkMode.release()); @@ -646,8 +644,8 @@ void ThreadStackManagerImpl::_OnNetworkScanFinished(GObject * source_object, GAs void ThreadStackManagerImpl::_OnNetworkScanFinished(GAsyncResult * res) { - std::unique_ptr scan_result; - std::unique_ptr err; + GAutoPtr scan_result; + GAutoPtr err; { gboolean result = openthread_io_openthread_border_router_call_scan_finish( mProxy.get(), &MakeUniquePointerReceiver(scan_result).Get(), res, &MakeUniquePointerReceiver(err).Get()); @@ -671,7 +669,7 @@ void ThreadStackManagerImpl::_OnNetworkScanFinished(GAsyncResult * res) if (g_variant_n_children(scan_result.get()) > 0) { - std::unique_ptr iter; + GAutoPtr iter; g_variant_get(scan_result.get(), "a(tstayqqyyyybb)", &MakeUniquePointerReceiver(iter).Get()); if (!iter) { diff --git a/src/platform/Linux/ThreadStackManagerImpl.h b/src/platform/Linux/ThreadStackManagerImpl.h index 3914c04524b14c..22bbc7f5191924 100755 --- a/src/platform/Linux/ThreadStackManagerImpl.h +++ b/src/platform/Linux/ThreadStackManagerImpl.h @@ -22,13 +22,20 @@ #include #include -#include +#include #include #include #include #include namespace chip { + +template <> +struct GAutoPtrDeleter +{ + using deleter = GObjectDeleter; +}; + namespace DeviceLayer { class ThreadStackManagerImpl : public ThreadStackManager @@ -148,7 +155,7 @@ class ThreadStackManagerImpl : public ThreadStackManager uint8_t lqi; }; - std::unique_ptr mProxy; + GAutoPtr mProxy; static CHIP_ERROR GLibMatterContextInitThreadStack(ThreadStackManagerImpl * self); static CHIP_ERROR GLibMatterContextCallAttach(ThreadStackManagerImpl * self); diff --git a/src/platform/Linux/bluez/AdapterIterator.cpp b/src/platform/Linux/bluez/AdapterIterator.cpp index bc892247ac8986..868671e405eaf3 100644 --- a/src/platform/Linux/bluez/AdapterIterator.cpp +++ b/src/platform/Linux/bluez/AdapterIterator.cpp @@ -17,8 +17,6 @@ #include "AdapterIterator.h" -#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE - #include #include #include @@ -139,5 +137,3 @@ bool AdapterIterator::Next() } // namespace Internal } // namespace DeviceLayer } // namespace chip - -#endif diff --git a/src/platform/Linux/bluez/AdapterIterator.h b/src/platform/Linux/bluez/AdapterIterator.h index c06ea8cb97a73f..2908c7a28e51d3 100644 --- a/src/platform/Linux/bluez/AdapterIterator.h +++ b/src/platform/Linux/bluez/AdapterIterator.h @@ -17,12 +17,14 @@ #pragma once +#include + +#include + #include "lib/core/CHIPError.h" #include "Types.h" -#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE - namespace chip { namespace DeviceLayer { namespace Internal { @@ -92,5 +94,3 @@ class AdapterIterator } // namespace Internal } // namespace DeviceLayer } // namespace chip - -#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE diff --git a/src/platform/Linux/bluez/ChipDeviceScanner.cpp b/src/platform/Linux/bluez/ChipDeviceScanner.cpp index 26543fe6a78f77..fec7ff519b2425 100644 --- a/src/platform/Linux/bluez/ChipDeviceScanner.cpp +++ b/src/platform/Linux/bluez/ChipDeviceScanner.cpp @@ -17,14 +17,12 @@ #include "ChipDeviceScanner.h" -#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE - #include #include #include #include -#include +#include #include "BluezObjectList.h" #include "Types.h" @@ -61,7 +59,7 @@ CHIP_ERROR MainLoopCreateObjectManager(GDBusCreateObjectManagerContext * context // all D-Bus signals will be delivered to the GLib global default main context. VerifyOrDie(g_main_context_get_thread_default() != nullptr); - std::unique_ptr err; + GAutoPtr err; context->object = g_dbus_object_manager_client_new_for_bus_sync( G_BUS_TYPE_SYSTEM, G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, BLUEZ_INTERFACE, "/", bluez_object_manager_client_get_proxy_type, nullptr /* unused user data in the Proxy Type Func */, @@ -78,11 +76,11 @@ bool BluezGetChipDeviceInfo(BluezDevice1 & aDevice, chip::Ble::ChipBLEDeviceIden GVariant * serviceData = bluez_device1_get_service_data(&aDevice); VerifyOrReturnError(serviceData != nullptr, false); - GVariant * dataValue = g_variant_lookup_value(serviceData, CHIP_BLE_UUID_SERVICE_STRING, nullptr); + GAutoPtr dataValue(g_variant_lookup_value(serviceData, CHIP_BLE_UUID_SERVICE_STRING, nullptr)); VerifyOrReturnError(dataValue != nullptr, false); size_t dataLen = 0; - const void * dataBytes = g_variant_get_fixed_array(dataValue, &dataLen, sizeof(uint8_t)); + const void * dataBytes = g_variant_get_fixed_array(dataValue.get(), &dataLen, sizeof(uint8_t)); VerifyOrReturnError(dataBytes != nullptr && dataLen >= sizeof(aDeviceInfo), false); memcpy(&aDeviceInfo, dataBytes, sizeof(aDeviceInfo)); @@ -225,59 +223,59 @@ CHIP_ERROR ChipDeviceScanner::MainLoopStopScan(ChipDeviceScanner * self) void ChipDeviceScanner::SignalObjectAdded(GDBusObjectManager * manager, GDBusObject * object, ChipDeviceScanner * self) { - self->ReportDevice(bluez_object_get_device1(BLUEZ_OBJECT(object))); + BluezDevice1 * device = bluez_object_get_device1(BLUEZ_OBJECT(object)); + VerifyOrReturn(device != nullptr); + + self->ReportDevice(*device); + + g_object_unref(device); } void ChipDeviceScanner::SignalInterfaceChanged(GDBusObjectManagerClient * manager, GDBusObjectProxy * object, GDBusProxy * aInterface, GVariant * aChangedProperties, const gchar * const * aInvalidatedProps, ChipDeviceScanner * self) { - self->ReportDevice(bluez_object_get_device1(BLUEZ_OBJECT(object))); + BluezDevice1 * device = bluez_object_get_device1(BLUEZ_OBJECT(object)); + VerifyOrReturn(device != nullptr); + + self->ReportDevice(*device); + + g_object_unref(device); } -void ChipDeviceScanner::ReportDevice(BluezDevice1 * device) +void ChipDeviceScanner::ReportDevice(BluezDevice1 & device) { - if (device == nullptr) - { - return; - } - - if (strcmp(bluez_device1_get_adapter(device), g_dbus_proxy_get_object_path(G_DBUS_PROXY(mAdapter))) != 0) + if (strcmp(bluez_device1_get_adapter(&device), g_dbus_proxy_get_object_path(G_DBUS_PROXY(mAdapter))) != 0) { return; } chip::Ble::ChipBLEDeviceIdentificationInfo deviceInfo; - if (!BluezGetChipDeviceInfo(*device, deviceInfo)) + if (!BluezGetChipDeviceInfo(device, deviceInfo)) { - ChipLogDetail(Ble, "Device %s does not look like a CHIP device.", bluez_device1_get_address(device)); + ChipLogDetail(Ble, "Device %s does not look like a CHIP device.", bluez_device1_get_address(&device)); return; } mDelegate->OnDeviceScanned(device, deviceInfo); } -void ChipDeviceScanner::RemoveDevice(BluezDevice1 * device) +void ChipDeviceScanner::RemoveDevice(BluezDevice1 & device) { - if (device == nullptr) - { - return; - } - - if (strcmp(bluez_device1_get_adapter(device), g_dbus_proxy_get_object_path(G_DBUS_PROXY(mAdapter))) != 0) + if (strcmp(bluez_device1_get_adapter(&device), g_dbus_proxy_get_object_path(G_DBUS_PROXY(mAdapter))) != 0) { return; } chip::Ble::ChipBLEDeviceIdentificationInfo deviceInfo; - if (!BluezGetChipDeviceInfo(*device, deviceInfo)) + if (!BluezGetChipDeviceInfo(device, deviceInfo)) { return; } - const auto devicePath = g_dbus_proxy_get_object_path(G_DBUS_PROXY(device)); + const auto devicePath = g_dbus_proxy_get_object_path(G_DBUS_PROXY(&device)); GError * error = nullptr; if (!bluez_adapter1_call_remove_device_sync(mAdapter, devicePath, nullptr, &error)) @@ -298,7 +296,12 @@ CHIP_ERROR ChipDeviceScanner::MainLoopStartScan(ChipDeviceScanner * self) ChipLogProgress(Ble, "BLE removing known devices."); for (BluezObject & object : BluezObjectList(self->mManager)) { - self->RemoveDevice(bluez_object_get_device1(&object)); + BluezDevice1 * device = bluez_object_get_device1(&object); + if (device != nullptr) + { + self->RemoveDevice(*device); + g_object_unref(device); + } } // Search for LE only. @@ -335,5 +338,3 @@ CHIP_ERROR ChipDeviceScanner::MainLoopStartScan(ChipDeviceScanner * self) } // namespace Internal } // namespace DeviceLayer } // namespace chip - -#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE diff --git a/src/platform/Linux/bluez/ChipDeviceScanner.h b/src/platform/Linux/bluez/ChipDeviceScanner.h index 2c8c9763b2d6b4..f07606b2ae3b29 100644 --- a/src/platform/Linux/bluez/ChipDeviceScanner.h +++ b/src/platform/Linux/bluez/ChipDeviceScanner.h @@ -19,8 +19,6 @@ #include -#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE - #include #include @@ -40,7 +38,7 @@ class ChipDeviceScannerDelegate virtual ~ChipDeviceScannerDelegate() {} // Called when a CHIP device was found - virtual void OnDeviceScanned(BluezDevice1 * device, const chip::Ble::ChipBLEDeviceIdentificationInfo & info) = 0; + virtual void OnDeviceScanned(BluezDevice1 & device, const chip::Ble::ChipBLEDeviceIdentificationInfo & info) = 0; // Called when a scan was completed (stopped or timed out) virtual void OnScanComplete() = 0; @@ -93,11 +91,11 @@ class ChipDeviceScanner ChipDeviceScanner * self); /// Check if a given device is a CHIP device and if yes, report it as discovered - void ReportDevice(BluezDevice1 * device); + void ReportDevice(BluezDevice1 & device); /// Check if a given device is a CHIP device and if yes, remove it from the adapter /// so that it can be re-discovered if it's still advertising. - void RemoveDevice(BluezDevice1 * device); + void RemoveDevice(BluezDevice1 & device); GDBusObjectManager * mManager = nullptr; BluezAdapter1 * mAdapter = nullptr; @@ -107,12 +105,10 @@ class ChipDeviceScanner gulong mInterfaceChangedSignal = 0; bool mIsScanning = false; bool mIsStopping = false; - /// Used to track if timer has alread expired and doesn't need to be canceled. + /// Used to track if timer has already expired and doesn't need to be canceled. bool mTimerExpired = false; }; } // namespace Internal } // namespace DeviceLayer } // namespace chip - -#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE diff --git a/src/platform/Linux/bluez/Helper.cpp b/src/platform/Linux/bluez/Helper.cpp index d071f3b304acb3..19d008a88cc2cb 100644 --- a/src/platform/Linux/bluez/Helper.cpp +++ b/src/platform/Linux/bluez/Helper.cpp @@ -47,29 +47,31 @@ * @file * Provides Bluez dbus implementation for BLE */ -#include -#include -#include -#include -#include -#include -#include -#include -#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE #include #include -#include #include #include #include #include #include +#include +#include +#include + +#include +#include +#include +#include +#include #include #include #include +#include #include +#include +#include #include #include "BluezObjectIterator.h" @@ -992,11 +994,10 @@ static void BluezSignalOnObjectRemoved(GDBusObjectManager * aManager, GDBusObjec // for Characteristic1, or GattService -- handle here via calling otPlatTobleHandleDisconnected, or ignore. } -static BluezGattService1 * BluezServiceCreate(gpointer apClosure) +static BluezGattService1 * BluezServiceCreate(BluezEndpoint * endpoint) { BluezObjectSkeleton * object; BluezGattService1 * service; - BluezEndpoint * endpoint = static_cast(apClosure); endpoint->mpServicePath = g_strdup_printf("%s/service", endpoint->mpRootPath); ChipLogDetail(DeviceLayer, "CREATE service object at %s", endpoint->mpServicePath); @@ -1156,7 +1157,7 @@ static BluezConnection * BluezCharacteristicGetBluezConnection(BluezGattCharacte } #endif // CHIP_BLUEZ_CENTRAL_SUPPORT -void EndpointCleanup(BluezEndpoint * apEndpoint) +static void EndpointCleanup(BluezEndpoint * apEndpoint) { if (apEndpoint != nullptr) { @@ -1262,24 +1263,23 @@ static void UpdateAdditionalDataCharacteristic(BluezGattCharacteristic1 * charac } #endif -static void BluezPeripheralObjectsSetup(gpointer apClosure) +static void BluezPeripheralObjectsSetup(BluezEndpoint * endpoint) { static const char * const c1_flags[] = { "write", nullptr }; static const char * const c2_flags[] = { "read", "indicate", nullptr }; +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING static const char * const c3_flags[] = { "read", nullptr }; +#endif - BluezEndpoint * endpoint = static_cast(apClosure); - VerifyOrExit(endpoint != nullptr, ChipLogError(DeviceLayer, "endpoint is NULL in %s", __func__)); - - endpoint->mpService = BluezServiceCreate(apClosure); + endpoint->mpService = BluezServiceCreate(endpoint); // C1 characteristic endpoint->mpC1 = BluezCharacteristicCreate(endpoint->mpService, "c1", CHIP_PLAT_BLE_UUID_C1_STRING, endpoint->mpRoot); bluez_gatt_characteristic1_set_flags(endpoint->mpC1, c1_flags); - g_signal_connect(endpoint->mpC1, "handle-read-value", G_CALLBACK(BluezCharacteristicReadValue), apClosure); + g_signal_connect(endpoint->mpC1, "handle-read-value", G_CALLBACK(BluezCharacteristicReadValue), endpoint); g_signal_connect(endpoint->mpC1, "handle-write-value", G_CALLBACK(BluezCharacteristicWriteValueError), nullptr); - g_signal_connect(endpoint->mpC1, "handle-acquire-write", G_CALLBACK(BluezCharacteristicAcquireWrite), apClosure); + g_signal_connect(endpoint->mpC1, "handle-acquire-write", G_CALLBACK(BluezCharacteristicAcquireWrite), endpoint); g_signal_connect(endpoint->mpC1, "handle-acquire-notify", G_CALLBACK(BluezCharacteristicAcquireNotifyError), nullptr); g_signal_connect(endpoint->mpC1, "handle-start-notify", G_CALLBACK(BluezCharacteristicStartNotifyError), nullptr); g_signal_connect(endpoint->mpC1, "handle-stop-notify", G_CALLBACK(BluezCharacteristicStopNotifyError), nullptr); @@ -1287,13 +1287,13 @@ static void BluezPeripheralObjectsSetup(gpointer apClosure) endpoint->mpC2 = BluezCharacteristicCreate(endpoint->mpService, "c2", CHIP_PLAT_BLE_UUID_C2_STRING, endpoint->mpRoot); bluez_gatt_characteristic1_set_flags(endpoint->mpC2, c2_flags); - g_signal_connect(endpoint->mpC2, "handle-read-value", G_CALLBACK(BluezCharacteristicReadValue), apClosure); + g_signal_connect(endpoint->mpC2, "handle-read-value", G_CALLBACK(BluezCharacteristicReadValue), endpoint); g_signal_connect(endpoint->mpC2, "handle-write-value", G_CALLBACK(BluezCharacteristicWriteValueError), nullptr); g_signal_connect(endpoint->mpC2, "handle-acquire-write", G_CALLBACK(BluezCharacteristicAcquireWriteError), nullptr); - g_signal_connect(endpoint->mpC2, "handle-acquire-notify", G_CALLBACK(BluezCharacteristicAcquireNotify), apClosure); - g_signal_connect(endpoint->mpC2, "handle-start-notify", G_CALLBACK(BluezCharacteristicStartNotify), apClosure); - g_signal_connect(endpoint->mpC2, "handle-stop-notify", G_CALLBACK(BluezCharacteristicStopNotify), apClosure); - g_signal_connect(endpoint->mpC2, "handle-confirm", G_CALLBACK(BluezCharacteristicConfirm), apClosure); + g_signal_connect(endpoint->mpC2, "handle-acquire-notify", G_CALLBACK(BluezCharacteristicAcquireNotify), endpoint); + g_signal_connect(endpoint->mpC2, "handle-start-notify", G_CALLBACK(BluezCharacteristicStartNotify), endpoint); + g_signal_connect(endpoint->mpC2, "handle-stop-notify", G_CALLBACK(BluezCharacteristicStopNotify), endpoint); + g_signal_connect(endpoint->mpC2, "handle-confirm", G_CALLBACK(BluezCharacteristicConfirm), endpoint); ChipLogDetail(DeviceLayer, "CHIP BTP C1 %s", bluez_gatt_characteristic1_get_service(endpoint->mpC1)); ChipLogDetail(DeviceLayer, "CHIP BTP C2 %s", bluez_gatt_characteristic1_get_service(endpoint->mpC2)); @@ -1303,23 +1303,19 @@ static void BluezPeripheralObjectsSetup(gpointer apClosure) // Additional data characteristics endpoint->mpC3 = BluezCharacteristicCreate(endpoint->mpService, "c3", CHIP_PLAT_BLE_UUID_C3_STRING, endpoint->mpRoot); bluez_gatt_characteristic1_set_flags(endpoint->mpC3, c3_flags); - g_signal_connect(endpoint->mpC3, "handle-read-value", G_CALLBACK(BluezCharacteristicReadValue), apClosure); + g_signal_connect(endpoint->mpC3, "handle-read-value", G_CALLBACK(BluezCharacteristicReadValue), endpoint); g_signal_connect(endpoint->mpC3, "handle-write-value", G_CALLBACK(BluezCharacteristicWriteValueError), nullptr); g_signal_connect(endpoint->mpC3, "handle-acquire-write", G_CALLBACK(BluezCharacteristicAcquireWriteError), nullptr); - g_signal_connect(endpoint->mpC3, "handle-acquire-notify", G_CALLBACK(BluezCharacteristicAcquireNotify), apClosure); - g_signal_connect(endpoint->mpC3, "handle-start-notify", G_CALLBACK(BluezCharacteristicStartNotify), apClosure); - g_signal_connect(endpoint->mpC3, "handle-stop-notify", G_CALLBACK(BluezCharacteristicStopNotify), apClosure); - g_signal_connect(endpoint->mpC3, "handle-confirm", G_CALLBACK(BluezCharacteristicConfirm), apClosure); + g_signal_connect(endpoint->mpC3, "handle-acquire-notify", G_CALLBACK(BluezCharacteristicAcquireNotify), endpoint); + g_signal_connect(endpoint->mpC3, "handle-start-notify", G_CALLBACK(BluezCharacteristicStartNotify), endpoint); + g_signal_connect(endpoint->mpC3, "handle-stop-notify", G_CALLBACK(BluezCharacteristicStopNotify), endpoint); + g_signal_connect(endpoint->mpC3, "handle-confirm", G_CALLBACK(BluezCharacteristicConfirm), endpoint); // update the characteristic value UpdateAdditionalDataCharacteristic(endpoint->mpC3); ChipLogDetail(DeviceLayer, "CHIP BTP C3 %s", bluez_gatt_characteristic1_get_service(endpoint->mpC3)); #else ChipLogDetail(DeviceLayer, "CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING is FALSE"); - (void) c3_flags; #endif - -exit: - return; } static void BluezOnBusAcquired(GDBusConnection * aConn, const gchar * aName, gpointer apClosure) @@ -1335,7 +1331,7 @@ static void BluezOnBusAcquired(GDBusConnection * aConn, const gchar * aName, gpo endpoint->mpRoot = g_dbus_object_manager_server_new(endpoint->mpRootPath); g_dbus_object_manager_server_set_connection(endpoint->mpRoot, aConn); - BluezPeripheralObjectsSetup(apClosure); + BluezPeripheralObjectsSetup(endpoint); } exit: @@ -1356,39 +1352,35 @@ static void BluezOnNameLost(GDBusConnection * aConn, const gchar * aName, gpoint static CHIP_ERROR StartupEndpointBindings(BluezEndpoint * endpoint) { - GDBusObjectManager * manager; - GError * error = nullptr; - GDBusConnection * conn = nullptr; - VerifyOrExit(endpoint != nullptr, ChipLogError(DeviceLayer, "endpoint is NULL in %s", __func__)); + VerifyOrReturnError(endpoint != nullptr, CHIP_ERROR_INVALID_ARGUMENT, + ChipLogError(DeviceLayer, "endpoint is NULL in %s", __func__)); - conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, &error); - VerifyOrExit(conn != nullptr, ChipLogError(DeviceLayer, "FAIL: get bus sync in %s, error: %s", __func__, error->message)); + GAutoPtr err; + GAutoPtr conn(g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, &MakeUniquePointerReceiver(err).Get())); + VerifyOrReturnError(conn != nullptr, CHIP_ERROR_INTERNAL, + ChipLogError(DeviceLayer, "FAIL: get bus sync in %s, error: %s", __func__, err->message)); if (endpoint->mpAdapterName != nullptr) endpoint->mpOwningName = g_strdup_printf("%s", endpoint->mpAdapterName); else endpoint->mpOwningName = g_strdup_printf("C-%04x", getpid() & 0xffff); - BluezOnBusAcquired(conn, endpoint->mpOwningName, endpoint); + BluezOnBusAcquired(conn.get(), endpoint->mpOwningName, endpoint); - manager = g_dbus_object_manager_client_new_sync( - conn, G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, BLUEZ_INTERFACE, "/", bluez_object_manager_client_get_proxy_type, - nullptr /* unused user data in the Proxy Type Func */, nullptr /*destroy notify */, nullptr /* cancellable */, &error); - - VerifyOrExit(manager != nullptr, ChipLogError(DeviceLayer, "FAIL: Error getting object manager client: %s", error->message)); + GDBusObjectManager * manager = g_dbus_object_manager_client_new_sync( + conn.get(), G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE, BLUEZ_INTERFACE, "/", bluez_object_manager_client_get_proxy_type, + nullptr /* unused user data in the Proxy Type Func */, nullptr /*destroy notify */, nullptr /* cancellable */, + &MakeUniquePointerReceiver(err).Get()); + VerifyOrReturnError(manager != nullptr, CHIP_ERROR_INTERNAL, + ChipLogError(DeviceLayer, "FAIL: Error getting object manager client: %s", err->message)); endpoint->mpObjMgr = manager; - bluezObjectsSetup(endpoint); g_signal_connect(manager, "object-added", G_CALLBACK(BluezSignalOnObjectAdded), endpoint); g_signal_connect(manager, "object-removed", G_CALLBACK(BluezSignalOnObjectRemoved), endpoint); g_signal_connect(manager, "interface-proxy-properties-changed", G_CALLBACK(BluezSignalInterfacePropertiesChanged), endpoint); -exit: - if (error != nullptr) - g_error_free(error); - return CHIP_NO_ERROR; } @@ -1454,10 +1446,9 @@ CHIP_ERROR SendBluezIndication(BLE_CONNECTION_OBJECT apConn, chip::System::Packe return PlatformMgrImpl().GLibMatterContextInvokeSync(BluezC2Indicate, MakeConnectionDataBundle(apConn, apBuf)); } -static CHIP_ERROR BluezDisconnect(void * apClosure) +static CHIP_ERROR BluezDisconnect(BluezConnection * conn) { - BluezConnection * conn = static_cast(apClosure); - GError * error = nullptr; + GError * error = nullptr; gboolean success; VerifyOrExit(conn != nullptr, ChipLogError(DeviceLayer, "conn is NULL in %s", __func__)); @@ -1474,14 +1465,9 @@ static CHIP_ERROR BluezDisconnect(void * apClosure) return CHIP_NO_ERROR; } -static CHIP_ERROR CloseBleconnectionCB(void * apAppState) -{ - return BluezDisconnect(apAppState); -} - CHIP_ERROR CloseBluezConnection(BLE_CONNECTION_OBJECT apConn) { - return PlatformMgrImpl().GLibMatterContextInvokeSync(CloseBleconnectionCB, apConn); + return PlatformMgrImpl().GLibMatterContextInvokeSync(BluezDisconnect, static_cast(apConn)); } CHIP_ERROR StartBluezAdv(BluezEndpoint * apEndpoint) @@ -1516,12 +1502,12 @@ CHIP_ERROR BluezGattsAppRegister(BluezEndpoint * apEndpoint) return err; } -CHIP_ERROR ConfigureBluezAdv(BLEAdvConfig & aBleAdvConfig, BluezEndpoint * apEndpoint) +static CHIP_ERROR ConfigureBluezAdv(const BLEAdvConfig & aBleAdvConfig, BluezEndpoint * apEndpoint) { const char * msg = nullptr; CHIP_ERROR err = CHIP_NO_ERROR; VerifyOrExit(aBleAdvConfig.mpBleName != nullptr, msg = "FAIL: BLE name is NULL"); - VerifyOrExit(aBleAdvConfig.mpAdvertisingUUID != nullptr, msg = "FAIL: BLE mpAdvertisingUUID is NULL in %s"); + VerifyOrExit(aBleAdvConfig.mpAdvertisingUUID != nullptr, msg = "FAIL: BLE mpAdvertisingUUID is NULL"); apEndpoint->mpAdapterName = g_strdup(aBleAdvConfig.mpBleName); apEndpoint->mpAdvertisingUUID = g_strdup(aBleAdvConfig.mpAdvertisingUUID); @@ -1546,20 +1532,14 @@ CHIP_ERROR ConfigureBluezAdv(BLEAdvConfig & aBleAdvConfig, BluezEndpoint * apEnd return err; } -CHIP_ERROR InitBluezBleLayer(bool aIsCentral, char * apBleAddr, BLEAdvConfig & aBleAdvConfig, BluezEndpoint *& apEndpoint) +CHIP_ERROR InitBluezBleLayer(bool aIsCentral, const char * apBleAddr, const BLEAdvConfig & aBleAdvConfig, + BluezEndpoint *& apEndpoint) { + BluezEndpoint * endpoint = g_new0(BluezEndpoint, 1); CHIP_ERROR err = CHIP_NO_ERROR; - bool retval = false; - BluezEndpoint * endpoint = nullptr; - - // initialize server endpoint - endpoint = g_new0(BluezEndpoint, 1); - VerifyOrExit(endpoint != nullptr, ChipLogError(DeviceLayer, "FAIL: memory allocation in %s", __func__)); if (apBleAddr != nullptr) endpoint->mpAdapterAddr = g_strdup(apBleAddr); - else - endpoint->mpAdapterAddr = nullptr; endpoint->mpConnMap = g_hash_table_new(g_str_hash, g_str_equal); endpoint->mIsCentral = aIsCentral; @@ -1578,10 +1558,8 @@ CHIP_ERROR InitBluezBleLayer(bool aIsCentral, char * apBleAddr, BLEAdvConfig & a err = PlatformMgrImpl().GLibMatterContextInvokeSync(StartupEndpointBindings, endpoint); VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(DeviceLayer, "Failed to schedule endpoint initialization")); - retval = TRUE; - exit: - if (retval) + if (err == CHIP_NO_ERROR) { apEndpoint = endpoint; ChipLogDetail(DeviceLayer, "PlatformBlueZInit init success"); @@ -1651,12 +1629,12 @@ static void OnCharacteristicChanged(GDBusProxy * aInterface, GVariant * aChanged gpointer apConnection) { BLE_CONNECTION_OBJECT connection = static_cast(apConnection); - GVariant * value = g_variant_lookup_value(aChangedProperties, "Value", G_VARIANT_TYPE_BYTESTRING); - VerifyOrReturn(value != nullptr); + GAutoPtr dataValue(g_variant_lookup_value(aChangedProperties, "Value", G_VARIANT_TYPE_BYTESTRING)); + VerifyOrReturn(dataValue != nullptr); size_t bufferLen; - auto buffer = g_variant_get_fixed_array(value, &bufferLen, sizeof(uint8_t)); - VerifyOrReturn(value != nullptr, ChipLogError(DeviceLayer, "Characteristic value has unexpected type")); + auto buffer = g_variant_get_fixed_array(dataValue.get(), &bufferLen, sizeof(uint8_t)); + VerifyOrReturn(buffer != nullptr, ChipLogError(DeviceLayer, "Characteristic value has unexpected type")); BLEManagerImpl::HandleTXCharChanged(connection, static_cast(buffer), bufferLen); } @@ -1735,7 +1713,10 @@ CHIP_ERROR BluezUnsubscribeCharacteristic(BLE_CONNECTION_OBJECT apConn) struct ConnectParams { - ConnectParams(BluezDevice1 * device, BluezEndpoint * endpoint) : mDevice(device), mEndpoint(endpoint), mNumRetries(0) {} + ConnectParams(BluezDevice1 * device, BluezEndpoint * endpoint) : + mDevice(reinterpret_cast(g_object_ref(device))), mEndpoint(endpoint), mNumRetries(0) + {} + ~ConnectParams() { g_object_unref(mDevice); } BluezDevice1 * mDevice; BluezEndpoint * mEndpoint; uint16_t mNumRetries; @@ -1793,20 +1774,16 @@ static CHIP_ERROR ConnectDeviceImpl(ConnectParams * apParams) g_cancellable_reset(endpoint->mpConnectCancellable); bluez_device1_call_connect(device, endpoint->mpConnectCancellable, ConnectDeviceDone, apParams); - g_object_unref(device); return CHIP_NO_ERROR; } -CHIP_ERROR ConnectDevice(BluezDevice1 * apDevice, BluezEndpoint * apEndpoint) +CHIP_ERROR ConnectDevice(BluezDevice1 & aDevice, BluezEndpoint * apEndpoint) { - auto params = chip::Platform::New(apDevice, apEndpoint); - g_object_ref(apDevice); - + auto params = chip::Platform::New(&aDevice, apEndpoint); if (PlatformMgrImpl().GLibMatterContextInvokeSync(ConnectDeviceImpl, params) != CHIP_NO_ERROR) { ChipLogError(Ble, "Failed to schedule ConnectDeviceImpl() on CHIPoBluez thread"); - g_object_unref(apDevice); chip::Platform::Delete(params); return CHIP_ERROR_INCORRECT_STATE; } @@ -1823,4 +1800,3 @@ void CancelConnect(BluezEndpoint * apEndpoint) } // namespace Internal } // namespace DeviceLayer } // namespace chip -#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE diff --git a/src/platform/Linux/bluez/Helper.h b/src/platform/Linux/bluez/Helper.h index d2576e019751ba..687e9a166c4b72 100644 --- a/src/platform/Linux/bluez/Helper.h +++ b/src/platform/Linux/bluez/Helper.h @@ -50,15 +50,17 @@ #pragma once -#include "Types.h" +#include +#include -#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE +#include "Types.h" namespace chip { namespace DeviceLayer { namespace Internal { -CHIP_ERROR InitBluezBleLayer(bool aIsCentral, char * apBleAddr, BLEAdvConfig & aBleAdvConfig, BluezEndpoint *& apEndpoint); +CHIP_ERROR InitBluezBleLayer(bool aIsCentral, const char * apBleAddr, const BLEAdvConfig & aBleAdvConfig, + BluezEndpoint *& apEndpoint); CHIP_ERROR ShutdownBluezBleLayer(BluezEndpoint * apEndpoint); CHIP_ERROR SendBluezIndication(BLE_CONNECTION_OBJECT apConn, chip::System::PacketBufferHandle apBuf); CHIP_ERROR CloseBluezConnection(BLE_CONNECTION_OBJECT apConn); @@ -74,11 +76,9 @@ CHIP_ERROR BluezSubscribeCharacteristic(BLE_CONNECTION_OBJECT apConn); /// Unsubscribe from the CHIP TX characteristic on the remote peripheral device CHIP_ERROR BluezUnsubscribeCharacteristic(BLE_CONNECTION_OBJECT apConn); -CHIP_ERROR ConnectDevice(BluezDevice1 * apDevice, BluezEndpoint * apEndpoint); +CHIP_ERROR ConnectDevice(BluezDevice1 & aDevice, BluezEndpoint * apEndpoint); void CancelConnect(BluezEndpoint * apEndpoint); } // namespace Internal } // namespace DeviceLayer } // namespace chip - -#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE diff --git a/src/platform/bouffalolab/common/BLEManagerImpl.cpp b/src/platform/bouffalolab/common/BLEManagerImpl.cpp index 73a6f8ff466650..b233721953161e 100644 --- a/src/platform/bouffalolab/common/BLEManagerImpl.cpp +++ b/src/platform/bouffalolab/common/BLEManagerImpl.cpp @@ -146,6 +146,12 @@ CHIP_ERROR BLEManagerImpl::_Init() return CHIP_NO_ERROR; } +void BLEManagerImpl::_Shutdown() +{ + // Release BLE Stack resources + mFlags.Set(Flags::kChipoBleShutDown); +} + void BLEManagerImpl::DriveBLEState(intptr_t arg) { BLEMgrImpl().DriveBLEState(); @@ -435,7 +441,7 @@ CHIP_ERROR BLEManagerImpl::HandleGAPDisconnect(const ChipDeviceEvent * event) { case BT_HCI_ERR_REMOTE_USER_TERM_CONN: // Do not treat proper connection termination as an error and exit. - VerifyOrExit(!ConfigurationMgr().IsFullyProvisioned(), ); + VerifyOrExit(!ConfigurationMgr().IsFullyProvisioned(), BLEMgrImpl()._Shutdown()); disconReason = BLE_ERROR_REMOTE_DEVICE_DISCONNECTED; break; case BT_HCI_ERR_LOCALHOST_TERM_CONN: @@ -457,7 +463,19 @@ CHIP_ERROR BLEManagerImpl::HandleGAPDisconnect(const ChipDeviceEvent * event) ChipDeviceEvent disconnectEvent; disconnectEvent.Type = DeviceEventType::kCHIPoBLEConnectionClosed; ReturnErrorOnFailure(PlatformMgr().PostEvent(&disconnectEvent)); - + if (mFlags.Has(Flags::kChipoBleShutDown)) + { + int ret = bt_disable(); + if (ret) + { + ChipLogError(DeviceLayer, "CHIPoBLE Shutdown faild =%d", ret); + } + else + { + mFlags.Clear(Flags::kChipoBleShutDown); + } + return CHIP_NO_ERROR; + } // Force a reconfiguration of advertising in case we switched to non-connectable mode when // the BLE connection was established. mFlags.Set(Flags::kAdvertisingRefreshNeeded); diff --git a/src/platform/bouffalolab/common/BLEManagerImpl.h b/src/platform/bouffalolab/common/BLEManagerImpl.h index 1589d88006a19d..d5d571ef7949cd 100644 --- a/src/platform/bouffalolab/common/BLEManagerImpl.h +++ b/src/platform/bouffalolab/common/BLEManagerImpl.h @@ -44,7 +44,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla std::conditional_t::value, bt_gatt_indicate_params *, const bt_gatt_attr *>; CHIP_ERROR _Init(void); - void _Shutdown() {} + void _Shutdown(); bool _IsAdvertisingEnabled(void); CHIP_ERROR _SetAdvertisingEnabled(bool val); bool _IsAdvertising(void); @@ -85,6 +85,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla kAdvertisingRefreshNeeded = 0x0010, /**< The advertising state/configuration has changed, but the SoftDevice has yet to be updated. */ kChipoBleGattServiceRegister = 0x0020, /**< The system has currently CHIPoBLE GATT service registered. */ + kChipoBleShutDown = 0x0040, /**< The system has disable ble stack. */ }; struct ServiceData; diff --git a/src/platform/bouffalolab/common/ConfigurationManagerImpl.cpp b/src/platform/bouffalolab/common/ConfigurationManagerImpl.cpp index d4c06dc2d3868e..b9719b795d15c3 100644 --- a/src/platform/bouffalolab/common/ConfigurationManagerImpl.cpp +++ b/src/platform/bouffalolab/common/ConfigurationManagerImpl.cpp @@ -34,7 +34,17 @@ ConfigurationManagerImpl & ConfigurationManagerImpl::GetDefaultInstance() static ConfigurationManagerImpl sInstance; return sInstance; } - +bool ConfigurationManagerImpl::IsFullyProvisioned() +{ + return +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION + ConnectivityMgr().IsWiFiStationProvisioned() && +#endif +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + ConnectivityMgr().IsThreadProvisioned() && +#endif + true; +} CHIP_ERROR ConfigurationManagerImpl::Init() { CHIP_ERROR err; diff --git a/src/platform/bouffalolab/common/ConfigurationManagerImpl.h b/src/platform/bouffalolab/common/ConfigurationManagerImpl.h index b9d207fc1ec9d2..d882f76f89e3bf 100644 --- a/src/platform/bouffalolab/common/ConfigurationManagerImpl.h +++ b/src/platform/bouffalolab/common/ConfigurationManagerImpl.h @@ -36,6 +36,7 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp CHIP_ERROR StoreRebootCount(uint32_t rebootCount); CHIP_ERROR GetTotalOperationalHours(uint32_t & totalOperationalHours); CHIP_ERROR StoreTotalOperationalHours(uint32_t totalOperationalHours); + bool IsFullyProvisioned(); private: // ===== Members that implement the ConfigurationManager private interface. diff --git a/src/platform/silabs/CHIPDevicePlatformConfig.h b/src/platform/silabs/CHIPDevicePlatformConfig.h index c51a923367ffaf..0ba1cecc6bef31 100644 --- a/src/platform/silabs/CHIPDevicePlatformConfig.h +++ b/src/platform/silabs/CHIPDevicePlatformConfig.h @@ -104,10 +104,10 @@ #define CHIP_DEVICE_CONFIG_ENABLE_IPV4 0 #endif /* CHIP_DEVICE_CONFIG_ENABLE_IPV4 */ -#if CHIP_CONFIG_ENABLE_ICD_SERVER +#if SL_ICD_ENABLED #define CHIP_DEVICE_CONFIG_ICD_SLOW_POLL_INTERVAL chip::System::Clock::Milliseconds32(300) #define CHIP_DEVICE_CONFIG_ICD_FAST_POLL_INTERVAL chip::System::Clock::Milliseconds32(10) -#endif /* CHIP_CONFIG_ENABLE_ICD_SERVER */ +#endif /* SL_ICD_ENABLED */ #endif /* SL_WIFI */ diff --git a/src/platform/silabs/efr32/wifi/wfx_host_events.h b/src/platform/silabs/efr32/wifi/wfx_host_events.h index 5fae93e82053f0..ab722f649532cc 100644 --- a/src/platform/silabs/efr32/wifi/wfx_host_events.h +++ b/src/platform/silabs/efr32/wifi/wfx_host_events.h @@ -353,9 +353,9 @@ void wfx_ipv6_notify(int got_ip); #ifdef RS911X_WIFI /* RSI Power Save */ -#if CHIP_CONFIG_ENABLE_ICD_SERVER +#if SL_ICD_ENABLED sl_status_t wfx_power_save(); -#endif /* CHIP_CONFIG_ENABLE_ICD_SERVER */ +#endif /* SL_ICD_ENABLED */ /* RSI for LWIP */ void * wfx_rsi_alloc_pkt(void); void wfx_rsi_pkt_add_data(void * p, uint8_t * buf, uint16_t len, uint16_t off); diff --git a/src/platform/webos/BLEManagerImpl.h b/src/platform/webos/BLEManagerImpl.h index eb26e9d498819a..4780bbe661227a 100644 --- a/src/platform/webos/BLEManagerImpl.h +++ b/src/platform/webos/BLEManagerImpl.h @@ -163,9 +163,9 @@ class BLEManagerImpl final : public BLEManager, enum { - kMaxConnections = 1, // TODO: right max connection - kMaxDeviceNameLength = 20, // TODO: right-size this - kMaxAdvertismentDataSetSize = 31 // TODO: verify this + kMaxConnections = 1, // TODO: right max connection + kMaxDeviceNameLength = 20, // TODO: right-size this + kMaxAdvertisementDataSetSize = 31 // TODO: verify this }; struct BLEConnection diff --git a/src/platform/webos/BUILD.gn b/src/platform/webos/BUILD.gn index 7ab184f2442a84..719f3c70254b2c 100644 --- a/src/platform/webos/BUILD.gn +++ b/src/platform/webos/BUILD.gn @@ -59,6 +59,7 @@ static_library("webos") { sources = [ "../DeviceSafeQueue.cpp", "../DeviceSafeQueue.h", + "../GLibTypeDeleter.h", "../SingletonConfigurationManager.cpp", "BLEManagerImpl.cpp", "BLEManagerImpl.h", @@ -126,7 +127,6 @@ static_library("webos") { if (chip_enable_openthread) { sources += [ - "GlibTypeDeleter.h", "ThreadStackManagerImpl.cpp", "ThreadStackManagerImpl.h", ] diff --git a/src/platform/webos/ThreadStackManagerImpl.h b/src/platform/webos/ThreadStackManagerImpl.h index e2391dffd78aba..b70910878c08d0 100644 --- a/src/platform/webos/ThreadStackManagerImpl.h +++ b/src/platform/webos/ThreadStackManagerImpl.h @@ -22,10 +22,10 @@ #include #include +#include #include #include #include -#include #include namespace chip { diff --git a/src/protocols/interaction_model/StatusCodeList.h b/src/protocols/interaction_model/StatusCodeList.h index 62891c2e7b978d..1c37440e5c6eaa 100644 --- a/src/protocols/interaction_model/StatusCodeList.h +++ b/src/protocols/interaction_model/StatusCodeList.h @@ -69,5 +69,6 @@ CHIP_IM_STATUS_CODE(UnsupportedEvent , UNSUPPORTED_EVENT , 0xc7) CHIP_IM_STATUS_CODE(PathsExhausted , PATHS_EXHAUSTED , 0xc8) CHIP_IM_STATUS_CODE(TimedRequestMismatch , TIMED_REQUEST_MISMATCH , 0xc9) CHIP_IM_STATUS_CODE(FailsafeRequired , FAILSAFE_REQUIRED , 0xca) +CHIP_IM_STATUS_CODE(InvalidInState , INVALID_IN_STATE , 0xcb) CHIP_IM_STATUS_CODE(WriteIgnored , WRITE_IGNORED , 0xF0) // non-spec error code and use only internally // clang-format on diff --git a/src/python_testing/requirements.txt b/src/python_testing/requirements.txt new file mode 100644 index 00000000000000..84196f3f9e48f2 --- /dev/null +++ b/src/python_testing/requirements.txt @@ -0,0 +1,3 @@ +mobly +pyasn1 +pyasn1_modules diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index b64115bee8df00..c66cad9e1d95c8 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -310,15 +310,12 @@ class TestList : public Command printf("DL_LockUnlock\n"); printf("DL_Schedules\n"); printf("Test_TC_DRLK_1_1\n"); - printf("Test_TC_DRLK_2_2\n"); - printf("Test_TC_DRLK_2_3\n"); printf("Test_TC_DRLK_2_4\n"); printf("Test_TC_DRLK_2_5\n"); printf("Test_TC_DRLK_2_6\n"); printf("Test_TC_DRLK_2_7\n"); printf("Test_TC_DRLK_2_8\n"); printf("Test_TC_DRLK_2_11\n"); - printf("Test_TC_DRLK_2_12\n"); printf("TestGroupMessaging\n"); printf("TestGroupsCluster\n"); printf("Test_TC_G_1_1\n"); @@ -108954,1182 +108951,6 @@ class Test_TC_DRLK_1_1Suite : public TestCommand } }; -class Test_TC_DRLK_2_2Suite : public TestCommand -{ -public: - Test_TC_DRLK_2_2Suite(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_DRLK_2_2", 27, credsIssuerConfig) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_DRLK_2_2Suite() {} - - chip::System::Clock::Timeout GetWaitDuration() const override - { - return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); - } - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - chip::app::Clusters::DoorLock::Commands::GetUserResponse::DecodableType value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("userIndex", value.userIndex, 1U)); - VerifyOrReturn(CheckValueNonNull("userName", value.userName)); - VerifyOrReturn(CheckValueAsString("userName.Value()", value.userName.Value(), chip::CharSpan("xxx", 3))); - VerifyOrReturn(CheckValueNonNull("userUniqueID", value.userUniqueID)); - VerifyOrReturn(CheckValue("userUniqueID.Value()", value.userUniqueID.Value(), 6452UL)); - VerifyOrReturn(CheckValueNonNull("userStatus", value.userStatus)); - VerifyOrReturn(CheckValue("userStatus.Value()", value.userStatus.Value(), 1U)); - VerifyOrReturn(CheckValueNonNull("userType", value.userType)); - VerifyOrReturn(CheckValue("userType.Value()", value.userType.Value(), 0U)); - VerifyOrReturn(CheckValueNonNull("credentialRule", value.credentialRule)); - VerifyOrReturn(CheckValue("credentialRule.Value()", value.credentialRule.Value(), 0U)); - VerifyOrReturn(CheckValueNonNull("credentials", value.credentials)); - { - auto iter_1 = value.credentials.Value().begin(); - VerifyOrReturn(CheckNoMoreListItems("credentials.Value()", iter_1, 0)); - } - VerifyOrReturn(CheckValueNonNull("creatorFabricIndex", value.creatorFabricIndex)); - VerifyOrReturn(CheckValue("creatorFabricIndex.Value()", value.creatorFabricIndex.Value(), 1U)); - VerifyOrReturn(CheckValueNonNull("lastModifiedFabricIndex", value.lastModifiedFabricIndex)); - VerifyOrReturn(CheckValue("lastModifiedFabricIndex.Value()", value.lastModifiedFabricIndex.Value(), 1U)); - VerifyOrReturn(CheckValueNull("nextUserIndex", value.nextUserIndex)); - } - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - chip::app::Clusters::DoorLock::Commands::SetCredentialResponse::DecodableType value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("status", value.status, 0U)); - VerifyOrReturn(CheckValueNull("userIndex", value.userIndex)); - VerifyOrReturn(CheckValueNonNull("nextCredentialIndex", value.nextCredentialIndex)); - VerifyOrReturn(CheckValue("nextCredentialIndex.Value()", value.nextCredentialIndex.Value(), 2U)); - } - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - chip::app::Clusters::DoorLock::Commands::GetCredentialStatusResponse::DecodableType value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("credentialExists", value.credentialExists, true)); - VerifyOrReturn(CheckValueNonNull("userIndex", value.userIndex)); - VerifyOrReturn(CheckValue("userIndex.Value()", value.userIndex.Value(), 1U)); - VerifyOrReturn(CheckValueNonNull("creatorFabricIndex", value.creatorFabricIndex)); - VerifyOrReturn(CheckValue("creatorFabricIndex.Value()", value.creatorFabricIndex.Value(), 1U)); - VerifyOrReturn(CheckValueNonNull("lastModifiedFabricIndex", value.lastModifiedFabricIndex)); - VerifyOrReturn(CheckValue("lastModifiedFabricIndex.Value()", value.lastModifiedFabricIndex.Value(), 1U)); - VerifyOrReturn(CheckValueNull("nextCredentialIndex", value.nextCredentialIndex)); - } - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - bool value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("requirePINforRemoteOperation", value, false)); - } - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - bool value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("requirePINforRemoteOperation", value, true)); - } - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - uint8_t value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckConstraintMinValue("value", value, 1U)); - VerifyOrReturn(CheckConstraintMaxValue("value", value, 255U)); - } - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - uint8_t value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckConstraintMinValue("value", value, 1U)); - VerifyOrReturn(CheckConstraintMaxValue("value", value, 255U)); - } - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "Wait for the commissioned device to be retrieved"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee(kIdentityAlpha, value); - } - case 1: { - LogStep(1, "Precondition: Create new user"); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::SetUser::Type value; - value.operationType = static_cast(0); - value.userIndex = 1U; - value.userName.SetNonNull(); - value.userName.Value() = chip::Span("xxxgarbage: not in length on purpose", 3); - value.userUniqueID.SetNonNull(); - value.userUniqueID.Value() = 6452UL; - value.userStatus.SetNonNull(); - value.userStatus.Value() = static_cast(1); - value.userType.SetNonNull(); - value.userType.Value() = static_cast(0); - value.credentialRule.SetNonNull(); - value.credentialRule.Value() = static_cast(0); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::SetUser::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 2: { - LogStep(2, "Precondition: Read the user back and verify its fields"); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::GetUser::Type value; - value.userIndex = 1U; - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::GetUser::Id, value, - chip::NullOptional - - ); - } - case 3: { - LogStep(3, "Precondition: Create new PIN credential and lock/unlock user"); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::SetCredential::Type value; - value.operationType = static_cast(0); - - value.credential.credentialType = static_cast(1); - value.credential.credentialIndex = 1U; - - value.credentialData = chip::ByteSpan(chip::Uint8::from_const_char("123456garbage: not in length on purpose"), 6); - value.userIndex.SetNonNull(); - value.userIndex.Value() = 1U; - value.userStatus.SetNull(); - value.userType.SetNull(); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::SetCredential::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 4: { - LogStep(4, "Precondition: Verify created PIN credential"); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::GetCredentialStatus::Type value; - - value.credential.credentialType = static_cast(1); - value.credential.credentialIndex = 1U; - - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::GetCredentialStatus::Id, value, - chip::NullOptional - - ); - } - case 5: { - LogStep(5, "Step 1a: TH writes the RequirePINforRemoteOperation attribute value as False on the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.A0033"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - bool value; - value = false; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::RequirePINforRemoteOperation::Id, value, chip::NullOptional, - chip::NullOptional); - } - case 6: { - LogStep(6, - "Step 1b: TH writes the RequirePINforRemoteOperation attribute value as False on the DUT and Verify DUT " - "responds with UNSUPPORTED_WRITE"); - VerifyOrDo(!ShouldSkip("!DRLK.S.A0033"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - bool value; - value = false; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::RequirePINforRemoteOperation::Id, value, chip::NullOptional, - chip::NullOptional); - } - case 7: { - LogStep(7, "Step 2: TH reads the RequirePINforRemoteOperation attribute from the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return ReadAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::RequirePINforRemoteOperation::Id, true, chip::NullOptional); - } - case 8: { - LogStep(8, "Step 3: TH sends Lock Door Command to the DUT without PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C00.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::LockDoor::Type value; - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::LockDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 9: { - LogStep(9, "Step 4: TH sends Lock Door Command to the DUT with valid PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C00.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::LockDoor::Type value; - value.PINCode.Emplace(); - value.PINCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123456garbage: not in length on purpose"), 6); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::LockDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 10: { - LogStep(10, "Step 5a: TH writes the RequirePINforRemoteOperation attribute value as False on the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.A0033"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - bool value; - value = true; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::RequirePINforRemoteOperation::Id, value, chip::NullOptional, - chip::NullOptional); - } - case 11: { - LogStep(11, - "Step 5b: TH writes the RequirePINforRemoteOperation attribute value as False on the DUT and Verify DUT " - "responds with UNSUPPORTED_WRITE"); - VerifyOrDo(!ShouldSkip("!DRLK.S.A0033"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - bool value; - value = true; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::RequirePINforRemoteOperation::Id, value, chip::NullOptional, - chip::NullOptional); - } - case 12: { - LogStep(12, "Step 6: TH reads the RequirePINforRemoteOperation attribute from the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return ReadAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::RequirePINforRemoteOperation::Id, true, chip::NullOptional); - } - case 13: { - LogStep(13, "Step 7: TH sends Lock Door Command to the DUT with valid PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C00.Rsp && DRLK.S.A0033"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::LockDoor::Type value; - value.PINCode.Emplace(); - value.PINCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123456garbage: not in length on purpose"), 6); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::LockDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 14: { - LogStep(14, "Step 8: TH sends Lock Door Command to the DUT without valid PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C00.Rsp && DRLK.S.A0033"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::LockDoor::Type value; - value.PINCode.Emplace(); - value.PINCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("645321garbage: not in length on purpose"), 6); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::LockDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 15: { - LogStep(15, "Step 9: TH sends Lock Door Command to the DUT without any argument PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C00.Rsp && DRLK.S.A0033"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::LockDoor::Type value; - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::LockDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 16: { - LogStep(16, "Step 10a: H reads the WrongCodeEntryLimit attribute from the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.A0030"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return ReadAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::WrongCodeEntryLimit::Id, true, - chip::NullOptional); - } - case 17: { - LogStep(17, - "Step 10b: TH sends an Unlock Door Command from the DUT with invalid PINCode. Repeat this step " - "PIXIT.DRLK.WrongCodeEntryLimit times and Verify that DUT sends failure response to the TH"); - VerifyOrDo(!ShouldSkip("PICS_USER_PROMPT && DRLK.S.A0030"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt(kIdentityAlpha, value); - } - case 18: { - LogStep(18, - "Step 10c: TH sends an Unlock Door Command from User1 to the DUT with the valid PINCode and verify the DUT " - "response"); - VerifyOrDo(!ShouldSkip("PICS_USER_PROMPT && DRLK.S.A0030"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt(kIdentityAlpha, value); - } - case 19: { - LogStep(19, - "Step 10d: Wait for PIXIT.DRLK.UserCodeTemporaryDisableTime.TH then sends an Unlock Door Command from User1 to " - "the DUT with the valid PINCode."); - VerifyOrDo(!ShouldSkip("PICS_USER_PROMPT && DRLK.S.A0030"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt(kIdentityAlpha, value); - } - case 20: { - LogStep(20, - "Step 10e: TH writes WrongCodeEntryLimit attribute value as between 1 and 255 on the DUT and Verify that the " - "DUT sends Success response"); - VerifyOrDo(!ShouldSkip("DRLK.S.A0030"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - uint8_t value; - value = 3U; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::WrongCodeEntryLimit::Id, - value, chip::NullOptional, chip::NullOptional); - } - case 21: { - LogStep(21, - "Step 10e: TH writes WrongCodeEntryLimit attribute value as between 1 and 255 on the DUT and verify DUT " - "responds with UNSUPPORTED_WRITE"); - VerifyOrDo(!ShouldSkip("!DRLK.S.A0030"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - uint8_t value; - value = 3U; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::WrongCodeEntryLimit::Id, - value, chip::NullOptional, chip::NullOptional); - } - case 22: { - LogStep(22, "Step 11a: TH reads the UserCodeTemporaryDisableTime attribute from the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.A0031"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return ReadAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::UserCodeTemporaryDisableTime::Id, true, chip::NullOptional); - } - case 23: { - LogStep(23, - "Step 12a: TH writes UserCodeTemporaryDisableTime attribute value as between 1 and 255 on the DUT and Verify " - "that the DUT sends Success response"); - VerifyOrDo(!ShouldSkip("DRLK.S.A0031"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - uint8_t value; - value = 15U; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::UserCodeTemporaryDisableTime::Id, value, chip::NullOptional, - chip::NullOptional); - } - case 24: { - LogStep(24, - "Step 12a: TH writes UserCodeTemporaryDisableTime attribute value as between 1 and 255 on the DUT and verify " - "DUT responds with UNSUPPORTED_WRITE"); - VerifyOrDo(!ShouldSkip("!DRLK.S.A0031"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - uint8_t value; - value = 15U; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::UserCodeTemporaryDisableTime::Id, value, chip::NullOptional, - chip::NullOptional); - } - case 25: { - LogStep(25, "Clean the created user"); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::ClearUser::Type value; - value.userIndex = 1U; - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::ClearUser::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 26: { - LogStep(26, "Cleanup the created credential"); - VerifyOrDo(!ShouldSkip("DRLK.S.C26.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::ClearCredential::Type value; - value.credential.SetNonNull(); - - value.credential.Value().credentialType = static_cast(1); - value.credential.Value().credentialIndex = 1U; - - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::ClearCredential::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - } - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_2_3Suite : public TestCommand -{ -public: - Test_TC_DRLK_2_3Suite(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_DRLK_2_3", 39, credsIssuerConfig) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_DRLK_2_3Suite() {} - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(200)); } - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - chip::app::Clusters::DoorLock::Commands::GetUserResponse::DecodableType value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("userIndex", value.userIndex, 1U)); - VerifyOrReturn(CheckValueNonNull("userName", value.userName)); - VerifyOrReturn(CheckValueAsString("userName.Value()", value.userName.Value(), chip::CharSpan("xxx", 3))); - VerifyOrReturn(CheckValueNonNull("userUniqueID", value.userUniqueID)); - VerifyOrReturn(CheckValue("userUniqueID.Value()", value.userUniqueID.Value(), 6452UL)); - VerifyOrReturn(CheckValueNonNull("userStatus", value.userStatus)); - VerifyOrReturn(CheckValue("userStatus.Value()", value.userStatus.Value(), 1U)); - VerifyOrReturn(CheckValueNonNull("userType", value.userType)); - VerifyOrReturn(CheckValue("userType.Value()", value.userType.Value(), 0U)); - VerifyOrReturn(CheckValueNonNull("credentialRule", value.credentialRule)); - VerifyOrReturn(CheckValue("credentialRule.Value()", value.credentialRule.Value(), 0U)); - VerifyOrReturn(CheckValueNonNull("credentials", value.credentials)); - { - auto iter_1 = value.credentials.Value().begin(); - VerifyOrReturn(CheckNoMoreListItems("credentials.Value()", iter_1, 0)); - } - VerifyOrReturn(CheckValueNonNull("creatorFabricIndex", value.creatorFabricIndex)); - VerifyOrReturn(CheckValue("creatorFabricIndex.Value()", value.creatorFabricIndex.Value(), 1U)); - VerifyOrReturn(CheckValueNonNull("lastModifiedFabricIndex", value.lastModifiedFabricIndex)); - VerifyOrReturn(CheckValue("lastModifiedFabricIndex.Value()", value.lastModifiedFabricIndex.Value(), 1U)); - VerifyOrReturn(CheckValueNull("nextUserIndex", value.nextUserIndex)); - } - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - chip::app::Clusters::DoorLock::Commands::SetCredentialResponse::DecodableType value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("status", value.status, 0U)); - VerifyOrReturn(CheckValueNull("userIndex", value.userIndex)); - VerifyOrReturn(CheckValueNonNull("nextCredentialIndex", value.nextCredentialIndex)); - VerifyOrReturn(CheckValue("nextCredentialIndex.Value()", value.nextCredentialIndex.Value(), 2U)); - } - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - chip::app::Clusters::DoorLock::Commands::GetCredentialStatusResponse::DecodableType value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("credentialExists", value.credentialExists, true)); - VerifyOrReturn(CheckValueNonNull("userIndex", value.userIndex)); - VerifyOrReturn(CheckValue("userIndex.Value()", value.userIndex.Value(), 1U)); - VerifyOrReturn(CheckValueNonNull("creatorFabricIndex", value.creatorFabricIndex)); - VerifyOrReturn(CheckValue("creatorFabricIndex.Value()", value.creatorFabricIndex.Value(), 1U)); - VerifyOrReturn(CheckValueNonNull("lastModifiedFabricIndex", value.lastModifiedFabricIndex)); - VerifyOrReturn(CheckValue("lastModifiedFabricIndex.Value()", value.lastModifiedFabricIndex.Value(), 1U)); - VerifyOrReturn(CheckValueNull("nextCredentialIndex", value.nextCredentialIndex)); - } - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - bool value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("requirePINforRemoteOperation", value, false)); - } - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - bool value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("requirePINforRemoteOperation", value, true)); - } - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - uint8_t value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("userCodeTemporaryDisableTime", value, 15U)); - } - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - uint32_t value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("autoRelockTime", value, 10UL)); - } - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - uint32_t value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("autoRelockTime", value, 60UL)); - } - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - chip::app::DataModel::Nullable value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValueNonNull("lockState", value)); - VerifyOrReturn(CheckValue("lockState.Value()", value.Value(), 1U)); - } - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "Wait for the commissioned device to be retrieved"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee(kIdentityAlpha, value); - } - case 1: { - LogStep(1, "Precondition: Create new user"); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::SetUser::Type value; - value.operationType = static_cast(0); - value.userIndex = 1U; - value.userName.SetNonNull(); - value.userName.Value() = chip::Span("xxxgarbage: not in length on purpose", 3); - value.userUniqueID.SetNonNull(); - value.userUniqueID.Value() = 6452UL; - value.userStatus.SetNonNull(); - value.userStatus.Value() = static_cast(1); - value.userType.SetNonNull(); - value.userType.Value() = static_cast(0); - value.credentialRule.SetNonNull(); - value.credentialRule.Value() = static_cast(0); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::SetUser::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 2: { - LogStep(2, "Precondition: Read the user back and verify its fields"); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::GetUser::Type value; - value.userIndex = 1U; - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::GetUser::Id, value, - chip::NullOptional - - ); - } - case 3: { - LogStep(3, "Precondition: Create new PIN credential and lock/unlock user"); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::SetCredential::Type value; - value.operationType = static_cast(0); - - value.credential.credentialType = static_cast(1); - value.credential.credentialIndex = 1U; - - value.credentialData = chip::ByteSpan(chip::Uint8::from_const_char("123456garbage: not in length on purpose"), 6); - value.userIndex.SetNonNull(); - value.userIndex.Value() = 1U; - value.userStatus.SetNull(); - value.userType.SetNull(); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::SetCredential::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 4: { - LogStep(4, "Precondition: Verify created PIN credential"); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::GetCredentialStatus::Type value; - - value.credential.credentialType = static_cast(1); - value.credential.credentialIndex = 1U; - - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::GetCredentialStatus::Id, value, - chip::NullOptional - - ); - } - case 5: { - LogStep(5, "Step 1a: TH writes the RequirePINforRemoteOperation attribute value as False on the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - bool value; - value = false; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::RequirePINforRemoteOperation::Id, value, chip::NullOptional, - chip::NullOptional); - } - case 6: { - LogStep(6, - "Step 1b: TH writes the RequirePINforRemoteOperation attribute value as False on the DUT and Verify DUT " - "responds with UNSUPPORTED_WRITE"); - VerifyOrDo(!ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && !DRLK.S.A0033"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - bool value; - value = false; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::RequirePINforRemoteOperation::Id, value, chip::NullOptional, - chip::NullOptional); - } - case 7: { - LogStep(7, "Step 2: TH reads the RequirePINforRemoteOperation attribute from the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return ReadAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::RequirePINforRemoteOperation::Id, true, chip::NullOptional); - } - case 8: { - LogStep(8, "Step 3: TH sends the unlock Door command to the DUT without PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C01.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnlockDoor::Type value; - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnlockDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 9: { - LogStep(9, "Step 4: TH sends the unlock Door command to the DUT with valid PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C01.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnlockDoor::Type value; - value.PINCode.Emplace(); - value.PINCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123456garbage: not in length on purpose"), 6); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnlockDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 10: { - LogStep(10, "Step 5a: TH writes the RequirePINforRemoteOperation attribute value as False on the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - bool value; - value = true; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::RequirePINforRemoteOperation::Id, value, chip::NullOptional, - chip::NullOptional); - } - case 11: { - LogStep(11, - "Step 5b: TH writes the RequirePINforRemoteOperation attribute value as False on the DUT and Verify DUT " - "responds with UNSUPPORTED_WRITE"); - VerifyOrDo(!ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && !DRLK.S.A0033"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - bool value; - value = true; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::RequirePINforRemoteOperation::Id, value, chip::NullOptional, - chip::NullOptional); - } - case 12: { - LogStep(12, "Step 6: TH reads the RequirePINforRemoteOperation attribute from the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return ReadAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::RequirePINforRemoteOperation::Id, true, chip::NullOptional); - } - case 13: { - LogStep(13, "Step 7: TH sends the unlock Door command to the DUT with valid PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C01.Rsp && DRLK.S.A0033"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnlockDoor::Type value; - value.PINCode.Emplace(); - value.PINCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123456garbage: not in length on purpose"), 6); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnlockDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 14: { - LogStep(14, "Step 8: TH sends the unlock Door command to the DUT with invalid PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C01.Rsp && DRLK.S.A0033"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnlockDoor::Type value; - value.PINCode.Emplace(); - value.PINCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("1234568garbage: not in length on purpose"), 7); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnlockDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 15: { - LogStep(15, "Step 9: TH sends the unlock Door command to the DUT without PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C01.Rsp && DRLK.S.A0033"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnlockDoor::Type value; - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnlockDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 16: { - LogStep(16, - "Step 10a: TH writes WrongCodeEntryLimit attribute value as 3 on the DUT and Verify that the DUT sends Success " - "response"); - VerifyOrDo(!ShouldSkip("DRLK.S.F00 && DRLK.S.F01 && DRLK.S.A0030.Write"), - return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - uint8_t value; - value = 3U; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::WrongCodeEntryLimit::Id, - value, chip::NullOptional, chip::NullOptional); - } - case 17: { - LogStep(17, - "Step 10b: TH writes WrongCodeEntryLimit attribute value as 3 on the DUT and verify DUT responds with " - "UNSUPPORTED_WRITE"); - VerifyOrDo(!ShouldSkip("DRLK.S.F00 && DRLK.S.F01 && !DRLK.S.A0030.Write"), - return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - uint8_t value; - value = 3U; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::WrongCodeEntryLimit::Id, - value, chip::NullOptional, chip::NullOptional); - } - case 18: { - LogStep(18, - "Step 11a: TH writes UserCodeTemporaryDisableTime attribute value as 15 Seconds on the DUT and Verify that the " - "DUT sends Success response"); - VerifyOrDo(!ShouldSkip("DRLK.S.F00 && DRLK.S.F01 && DRLK.S.A0031.Write"), - return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - uint8_t value; - value = 15U; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::UserCodeTemporaryDisableTime::Id, value, chip::NullOptional, - chip::NullOptional); - } - case 19: { - LogStep(19, - "Step 11b: TH writes UserCodeTemporaryDisableTime attribute value as 15 Seconds on the DUT and Verify that the " - "DUT sends Success response"); - VerifyOrDo(!ShouldSkip("DRLK.S.F00 && DRLK.S.F01 && !DRLK.S.A0031.Write"), - return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - uint8_t value; - value = 15U; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::UserCodeTemporaryDisableTime::Id, value, chip::NullOptional, - chip::NullOptional); - } - case 20: { - LogStep(20, "Step 12a: TH sends the unlock Door command to the DUT with invalid PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C01.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnlockDoor::Type value; - value.PINCode.Emplace(); - value.PINCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("1234568garbage: not in length on purpose"), 7); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnlockDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 21: { - LogStep(21, "Step 12b: TH sends the unlock Door command to the DUT with invalid PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C01.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnlockDoor::Type value; - value.PINCode.Emplace(); - value.PINCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("1234568garbage: not in length on purpose"), 7); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnlockDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 22: { - LogStep(22, "Step 12c: TH sends the unlock Door command to the DUT with invalid PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C01.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnlockDoor::Type value; - value.PINCode.Emplace(); - value.PINCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("1234568garbage: not in length on purpose"), 7); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnlockDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 23: { - LogStep(23, "Step 12d: TH sends the unlock Door command to the DUT with invalid PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C01.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnlockDoor::Type value; - value.PINCode.Emplace(); - value.PINCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("1234568garbage: not in length on purpose"), 7); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnlockDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 24: { - LogStep(24, - "Step 13: TH reads the UserCodeTemporaryDisableTime attribute from the DUT and check attribute is triggered"); - VerifyOrDo(!ShouldSkip("DRLK.S.F00 && DRLK.S.F01 && DRLK.S.A0031"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return ReadAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::UserCodeTemporaryDisableTime::Id, true, chip::NullOptional); - } - case 25: { - LogStep(25, "Step 14: TH sends the unlock Door command to the DUT with valid PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C01.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnlockDoor::Type value; - value.PINCode.Emplace(); - value.PINCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123456garbage: not in length on purpose"), 6); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnlockDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 26: { - LogStep(26, "Wait for UserCodeTemporaryDisableTime expires"); - VerifyOrDo(!ShouldSkip("DRLK.S.F00 && DRLK.S.F01 && DRLK.S.A0031"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 15000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 27: { - LogStep(27, "Step 15a: TH writes AutoRelockTime attribute value as 10 seconds on the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.A0023.Write && PICS_SDK_CI_ONLY"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - uint32_t value; - value = 10UL; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::AutoRelockTime::Id, value, - chip::NullOptional, chip::NullOptional); - } - case 28: { - LogStep(28, "Step 15b: TH writes AutoRelockTime attribute value as 60 seconds on the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.A0023.Write && PICS_SKIP_SAMPLE_APP"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - uint32_t value; - value = 60UL; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::AutoRelockTime::Id, value, - chip::NullOptional, chip::NullOptional); - } - case 29: { - LogStep(29, "Step 15c: TH writes AutoRelockTime attribute value as 10 seconds on the DUT"); - VerifyOrDo(!ShouldSkip(" !DRLK.S.A0023.Write && PICS_SDK_CI_ONLY "), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - uint32_t value; - value = 10UL; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::AutoRelockTime::Id, value, - chip::NullOptional, chip::NullOptional); - } - case 30: { - LogStep(30, "Step 15d: TH writes AutoRelockTime attribute value as 60 seconds on the DUT"); - VerifyOrDo(!ShouldSkip(" !DRLK.S.A0023.Write && PICS_SKIP_SAMPLE_APP "), - return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - uint32_t value; - value = 60UL; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::AutoRelockTime::Id, value, - chip::NullOptional, chip::NullOptional); - } - case 31: { - LogStep(31, "Step 16a: TH reads the AutoRelockTime attribute from the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.A0023 && PICS_SDK_CI_ONLY"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return ReadAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::AutoRelockTime::Id, true, - chip::NullOptional); - } - case 32: { - LogStep(32, "Step 16b: TH reads the AutoRelockTime attribute from the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.A0023 && PICS_SKIP_SAMPLE_APP"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return ReadAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::AutoRelockTime::Id, true, - chip::NullOptional); - } - case 33: { - LogStep(33, - "Step 17: TH sends the unlock Door command to the DUT with valid PINCode and Verify that DUT sends SUCCESS " - "response to the TH"); - VerifyOrDo(!ShouldSkip("DRLK.S.C01.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnlockDoor::Type value; - value.PINCode.Emplace(); - value.PINCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123456garbage: not in length on purpose"), 6); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnlockDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 34: { - LogStep(34, "Wait for AutoRelockTime Expires"); - VerifyOrDo(!ShouldSkip("DRLK.S.A0023 && PICS_SDK_CI_ONLY"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 35: { - LogStep(35, "Wait for AutoRelockTime Expires"); - VerifyOrDo(!ShouldSkip("DRLK.S.A0023 && PICS_SKIP_SAMPLE_APP"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 60000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 36: { - LogStep(36, "Step 18: TH reads LockState attribute"); - VerifyOrDo(!ShouldSkip("DRLK.S.A0000 && DRLK.S.C01.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return ReadAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::LockState::Id, true, - chip::NullOptional); - } - case 37: { - LogStep(37, "Cleanup the created user"); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::ClearUser::Type value; - value.userIndex = 1U; - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::ClearUser::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 38: { - LogStep(38, "Clean the created credential"); - VerifyOrDo(!ShouldSkip("DRLK.S.C26.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::ClearCredential::Type value; - value.credential.SetNonNull(); - - value.credential.Value().credentialType = static_cast(1); - value.credential.Value().credentialIndex = 1U; - - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::ClearCredential::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - } - return CHIP_NO_ERROR; - } -}; - class Test_TC_DRLK_2_4Suite : public TestCommand { public: @@ -112523,670 +111344,6 @@ class Test_TC_DRLK_2_11Suite : public TestCommand } }; -class Test_TC_DRLK_2_12Suite : public TestCommand -{ -public: - Test_TC_DRLK_2_12Suite(CredentialIssuerCommands * credsIssuerConfig) : TestCommand("Test_TC_DRLK_2_12", 39, credsIssuerConfig) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - - ~Test_TC_DRLK_2_12Suite() {} - - chip::System::Clock::Timeout GetWaitDuration() const override - { - return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); - } - -private: - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - chip::EndpointId GetEndpoint(chip::EndpointId endpoint) { return mEndpoint.HasValue() ? mEndpoint.Value() : endpoint; } - - // - // Tests methods - // - - void OnResponse(const chip::app::StatusIB & status, chip::TLV::TLVReader * data) override - { - bool shouldContinue = false; - - switch (mTestIndex - 1) - { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - chip::app::Clusters::DoorLock::Commands::GetUserResponse::DecodableType value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("userIndex", value.userIndex, 1U)); - VerifyOrReturn(CheckValueNonNull("userName", value.userName)); - VerifyOrReturn(CheckValueAsString("userName.Value()", value.userName.Value(), chip::CharSpan("xxx", 3))); - VerifyOrReturn(CheckValueNonNull("userUniqueID", value.userUniqueID)); - VerifyOrReturn(CheckValue("userUniqueID.Value()", value.userUniqueID.Value(), 6452UL)); - VerifyOrReturn(CheckValueNonNull("userStatus", value.userStatus)); - VerifyOrReturn(CheckValue("userStatus.Value()", value.userStatus.Value(), 1U)); - VerifyOrReturn(CheckValueNonNull("userType", value.userType)); - VerifyOrReturn(CheckValue("userType.Value()", value.userType.Value(), 0U)); - VerifyOrReturn(CheckValueNonNull("credentialRule", value.credentialRule)); - VerifyOrReturn(CheckValue("credentialRule.Value()", value.credentialRule.Value(), 0U)); - VerifyOrReturn(CheckValueNonNull("credentials", value.credentials)); - { - auto iter_1 = value.credentials.Value().begin(); - VerifyOrReturn(CheckNoMoreListItems("credentials.Value()", iter_1, 0)); - } - VerifyOrReturn(CheckValueNonNull("creatorFabricIndex", value.creatorFabricIndex)); - VerifyOrReturn(CheckValue("creatorFabricIndex.Value()", value.creatorFabricIndex.Value(), 1U)); - VerifyOrReturn(CheckValueNonNull("lastModifiedFabricIndex", value.lastModifiedFabricIndex)); - VerifyOrReturn(CheckValue("lastModifiedFabricIndex.Value()", value.lastModifiedFabricIndex.Value(), 1U)); - VerifyOrReturn(CheckValueNull("nextUserIndex", value.nextUserIndex)); - } - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - chip::app::Clusters::DoorLock::Commands::SetCredentialResponse::DecodableType value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("status", value.status, 0U)); - VerifyOrReturn(CheckValueNull("userIndex", value.userIndex)); - VerifyOrReturn(CheckValueNonNull("nextCredentialIndex", value.nextCredentialIndex)); - VerifyOrReturn(CheckValue("nextCredentialIndex.Value()", value.nextCredentialIndex.Value(), 2U)); - } - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - chip::app::Clusters::DoorLock::Commands::GetCredentialStatusResponse::DecodableType value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("credentialExists", value.credentialExists, true)); - VerifyOrReturn(CheckValueNonNull("userIndex", value.userIndex)); - VerifyOrReturn(CheckValue("userIndex.Value()", value.userIndex.Value(), 1U)); - VerifyOrReturn(CheckValueNonNull("creatorFabricIndex", value.creatorFabricIndex)); - VerifyOrReturn(CheckValue("creatorFabricIndex.Value()", value.creatorFabricIndex.Value(), 1U)); - VerifyOrReturn(CheckValueNonNull("lastModifiedFabricIndex", value.lastModifiedFabricIndex)); - VerifyOrReturn(CheckValue("lastModifiedFabricIndex.Value()", value.lastModifiedFabricIndex.Value(), 1U)); - VerifyOrReturn(CheckValueNull("nextCredentialIndex", value.nextCredentialIndex)); - } - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - bool value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("requirePINforRemoteOperation", value, false)); - } - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - bool value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("requirePINforRemoteOperation", value, true)); - } - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - uint8_t value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("userCodeTemporaryDisableTime", value, 15U)); - } - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - uint32_t value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("autoRelockTime", value, 10UL)); - } - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - uint32_t value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("autoRelockTime", value, 60UL)); - } - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - shouldContinue = true; - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - chip::app::DataModel::Nullable value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValueNonNull("lockState", value)); - VerifyOrReturn(CheckValue("lockState.Value()", value.Value(), 1U)); - } - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - default: - LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); - } - - if (shouldContinue) - { - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - } - - CHIP_ERROR DoTestStep(uint16_t testIndex) override - { - using namespace chip::app::Clusters; - switch (testIndex) - { - case 0: { - LogStep(0, "Wait for the commissioned device to be retrieved"); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee(kIdentityAlpha, value); - } - case 1: { - LogStep(1, "Precondition: Create new user"); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::SetUser::Type value; - value.operationType = static_cast(0); - value.userIndex = 1U; - value.userName.SetNonNull(); - value.userName.Value() = chip::Span("xxxgarbage: not in length on purpose", 3); - value.userUniqueID.SetNonNull(); - value.userUniqueID.Value() = 6452UL; - value.userStatus.SetNonNull(); - value.userStatus.Value() = static_cast(1); - value.userType.SetNonNull(); - value.userType.Value() = static_cast(0); - value.credentialRule.SetNonNull(); - value.credentialRule.Value() = static_cast(0); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::SetUser::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 2: { - LogStep(2, "Precondition: Read the user back and verify its fields"); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::GetUser::Type value; - value.userIndex = 1U; - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::GetUser::Id, value, - chip::NullOptional - - ); - } - case 3: { - LogStep(3, "Precondition: Create new PIN credential and lock/unlock user"); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::SetCredential::Type value; - value.operationType = static_cast(0); - - value.credential.credentialType = static_cast(1); - value.credential.credentialIndex = 1U; - - value.credentialData = chip::ByteSpan(chip::Uint8::from_const_char("123456garbage: not in length on purpose"), 6); - value.userIndex.SetNonNull(); - value.userIndex.Value() = 1U; - value.userStatus.SetNull(); - value.userType.SetNull(); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::SetCredential::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 4: { - LogStep(4, "Precondition: Verify created PIN credential"); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::GetCredentialStatus::Type value; - - value.credential.credentialType = static_cast(1); - value.credential.credentialIndex = 1U; - - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::GetCredentialStatus::Id, value, - chip::NullOptional - - ); - } - case 5: { - LogStep(5, "Step 1: TH writes the RequirePINforRemoteOperation attribute value as False on the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033.Write"), - return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - bool value; - value = false; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::RequirePINforRemoteOperation::Id, value, chip::NullOptional, - chip::NullOptional); - } - case 6: { - LogStep(6, "Step 1: TH writes the RequirePINforRemoteOperation attribute value as False on the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && !DRLK.S.A0033.Write"), - return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - bool value; - value = false; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::RequirePINforRemoteOperation::Id, value, chip::NullOptional, - chip::NullOptional); - } - case 7: { - LogStep(7, "Step 2: TH reads the RequirePINforRemoteOperation attribute from the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return ReadAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::RequirePINforRemoteOperation::Id, true, chip::NullOptional); - } - case 8: { - LogStep(8, "Step 3: TH sends Ubolt Door Command to the DUT without PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C27.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnboltDoor::Type value; - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnboltDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 9: { - LogStep(9, "Step 4: TH sends Ubolt Door Command to the DUT with PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C27.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnboltDoor::Type value; - value.PINCode.Emplace(); - value.PINCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123456garbage: not in length on purpose"), 6); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnboltDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 10: { - LogStep(10, "Step 5: TH writes the RequirePINforRemoteOperation attribute value as true on the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033.Write"), - return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - bool value; - value = true; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::RequirePINforRemoteOperation::Id, value, chip::NullOptional, - chip::NullOptional); - } - case 11: { - LogStep(11, "Step 5: TH writes the RequirePINforRemoteOperation attribute value as true on the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && !DRLK.S.A0033.Write"), - return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - bool value; - value = true; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::RequirePINforRemoteOperation::Id, value, chip::NullOptional, - chip::NullOptional); - } - case 12: { - LogStep(12, "Step 6: TH reads the RequirePINforRemoteOperation attribute from the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return ReadAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::RequirePINforRemoteOperation::Id, true, chip::NullOptional); - } - case 13: { - LogStep(13, "Step 7: TH sends Ubolt Door Command to the DUT with valid PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C27.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnboltDoor::Type value; - value.PINCode.Emplace(); - value.PINCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123456garbage: not in length on purpose"), 6); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnboltDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 14: { - LogStep(14, "Step 8: TH sends Unbolt Door Command to the DUT with Invalid PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C27.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnboltDoor::Type value; - value.PINCode.Emplace(); - value.PINCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123458garbage: not in length on purpose"), 6); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnboltDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 15: { - LogStep(15, "Step 9: TH sends Unbolt Door Command to the DUT without PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C27.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnboltDoor::Type value; - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnboltDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 16: { - LogStep(16, "Step 10: TH writes WrongCodeEntryLimit attribute value as 3 on the DUT"); - VerifyOrDo(!ShouldSkip("( DRLK.S.F00 || DRLK.S.F01 ) && DRLK.S.A0030.Write"), - return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - uint8_t value; - value = 3U; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::WrongCodeEntryLimit::Id, - value, chip::NullOptional, chip::NullOptional); - } - case 17: { - LogStep(17, "Step 10: TH writes WrongCodeEntryLimit attribute value as 3 on the DUT"); - VerifyOrDo(!ShouldSkip("( DRLK.S.F00 || DRLK.S.F01 ) && !DRLK.S.A0030.Write"), - return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - uint8_t value; - value = 3U; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::WrongCodeEntryLimit::Id, - value, chip::NullOptional, chip::NullOptional); - } - case 18: { - LogStep(18, - "Step 11: TH writes UserCodeTemporaryDisableTime attribute value as 15 Seconds on the DUT and Verify that the " - "DUT sends Success response"); - VerifyOrDo(!ShouldSkip("( DRLK.S.F00 || DRLK.S.F01 ) && DRLK.S.A0031.Write"), - return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - uint8_t value; - value = 15U; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::UserCodeTemporaryDisableTime::Id, value, chip::NullOptional, - chip::NullOptional); - } - case 19: { - LogStep(19, - "Step 11: TH writes UserCodeTemporaryDisableTime attribute value as 15 Seconds on the DUT and Verify that the " - "DUT sends Success response"); - VerifyOrDo(!ShouldSkip("( DRLK.S.F00 || DRLK.S.F01 ) && !DRLK.S.A0031.Write"), - return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - uint8_t value; - value = 15U; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::UserCodeTemporaryDisableTime::Id, value, chip::NullOptional, - chip::NullOptional); - } - case 20: { - LogStep(20, "Step 12a: TH sends Unbolt Door Command to the DUT with invalid PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C27.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnboltDoor::Type value; - value.PINCode.Emplace(); - value.PINCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123457garbage: not in length on purpose"), 6); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnboltDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 21: { - LogStep(21, "Step 12b: TH sends Unbolt Door Command to the DUT with invalid PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C27.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnboltDoor::Type value; - value.PINCode.Emplace(); - value.PINCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123458garbage: not in length on purpose"), 6); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnboltDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 22: { - LogStep(22, "Step 12c: TH sends Unbolt Door Command to the DUT with invalid PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C27.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnboltDoor::Type value; - value.PINCode.Emplace(); - value.PINCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123459garbage: not in length on purpose"), 6); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnboltDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 23: { - LogStep(23, "Step 12d: TH sends Unbolt Door Command to the DUT with invalid PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C27.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnboltDoor::Type value; - value.PINCode.Emplace(); - value.PINCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123460garbage: not in length on purpose"), 6); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnboltDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 24: { - LogStep(24, "Step 13: TH reads UserCodedTemporaryDisableTime attribute from DUT"); - VerifyOrDo(!ShouldSkip("( DRLK.S.F00 || DRLK.S.F01 ) && DRLK.S.A0031"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return ReadAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, - DoorLock::Attributes::UserCodeTemporaryDisableTime::Id, true, chip::NullOptional); - } - case 25: { - LogStep( - 25, - "Step 14: TH sends Unbolt Door Command to the DUT with valid PINCode before UserCodeTemporaryDisableTime expires"); - VerifyOrDo(!ShouldSkip("DRLK.S.C27.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnboltDoor::Type value; - value.PINCode.Emplace(); - value.PINCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123456garbage: not in length on purpose"), 6); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnboltDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 26: { - LogStep(26, "Wait for UserCodeTemporaryDisableTime expires"); - VerifyOrDo(!ShouldSkip("( DRLK.S.F00 || DRLK.S.F01 ) && DRLK.S.A0031"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 15000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 27: { - LogStep(27, "Step 15: TH writes AutoRelockTime attribute value as 60 seconds on the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.A0023.Write && PICS_SDK_CI_ONLY"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - uint32_t value; - value = 10UL; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::AutoRelockTime::Id, value, - chip::NullOptional, chip::NullOptional); - } - case 28: { - LogStep(28, "Step 15: TH writes AutoRelockTime attribute value as 60 seconds on the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.A0023.Write && PICS_SKIP_SAMPLE_APP"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - uint32_t value; - value = 60UL; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::AutoRelockTime::Id, value, - chip::NullOptional, chip::NullOptional); - } - case 29: { - LogStep(29, "Step 15: TH writes AutoRelockTime attribute value as 10 seconds on the DUT"); - VerifyOrDo(!ShouldSkip("PICS_SDK_CI_ONLY && !DRLK.S.A0023.Write"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - uint32_t value; - value = 10UL; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::AutoRelockTime::Id, value, - chip::NullOptional, chip::NullOptional); - } - case 30: { - LogStep(30, "Step 15: TH writes AutoRelockTime attribute value as 60 seconds on the DUT"); - VerifyOrDo(!ShouldSkip("PICS_SKIP_SAMPLE_APP && !DRLK.S.A0023.Write"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - uint32_t value; - value = 60UL; - return WriteAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::AutoRelockTime::Id, value, - chip::NullOptional, chip::NullOptional); - } - case 31: { - LogStep(31, "Step 16: TH reads the AutoRelockTime attribute from the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.A0023 && PICS_SDK_CI_ONLY"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return ReadAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::AutoRelockTime::Id, true, - chip::NullOptional); - } - case 32: { - LogStep(32, "Step 16: TH reads the AutoRelockTime attribute from the DUT"); - VerifyOrDo(!ShouldSkip("DRLK.S.A0023 && PICS_SKIP_SAMPLE_APP"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return ReadAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::AutoRelockTime::Id, true, - chip::NullOptional); - } - case 33: { - LogStep(33, "Step 17: TH sends the Unbolt Door command to the DUT with valid PINCode"); - VerifyOrDo(!ShouldSkip("DRLK.S.C27.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::UnboltDoor::Type value; - value.PINCode.Emplace(); - value.PINCode.Value() = chip::ByteSpan(chip::Uint8::from_const_char("123456garbage: not in length on purpose"), 6); - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::UnboltDoor::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 34: { - LogStep(34, "Wait for AutoRelockTime Expires"); - VerifyOrDo(!ShouldSkip("DRLK.S.A0023 && PICS_SDK_CI_ONLY"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 35: { - LogStep(35, "Wait for AutoRelockTime Expires"); - VerifyOrDo(!ShouldSkip("DRLK.S.A0023 && PICS_SKIP_SAMPLE_APP"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 60000UL; - return WaitForMs(kIdentityAlpha, value); - } - case 36: { - LogStep(36, "Step 18: TH reads LockState attribute"); - VerifyOrDo(!ShouldSkip("DRLK.S.A0000 && DRLK.S.C01.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - return ReadAttribute(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Attributes::LockState::Id, true, - chip::NullOptional); - } - case 37: { - LogStep(37, "Cleanup the created user"); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::ClearUser::Type value; - value.userIndex = 1U; - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::ClearUser::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - case 38: { - LogStep(38, "Clean the created credential"); - VerifyOrDo(!ShouldSkip("DRLK.S.C26.Rsp"), return ContinueOnChipMainThread(CHIP_NO_ERROR)); - ListFreer listFreer; - chip::app::Clusters::DoorLock::Commands::ClearCredential::Type value; - value.credential.SetNonNull(); - - value.credential.Value().credentialType = static_cast(1); - value.credential.Value().credentialIndex = 1U; - - return SendCommand(kIdentityAlpha, GetEndpoint(1), DoorLock::Id, DoorLock::Commands::ClearCredential::Id, value, - chip::Optional(1000), chip::NullOptional - - ); - } - } - return CHIP_NO_ERROR; - } -}; - class TestGroupMessagingSuite : public TestCommand { public: @@ -143884,15 +142041,12 @@ void registerCommandsTests(Commands & commands, CredentialIssuerCommands * creds make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), - make_unique(credsIssuerConfig), - make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), - make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index bae08b8fa26891..feeeed0da0bc56 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -279,15 +279,12 @@ class TestList : public Command { printf("DL_UsersAndCredentials\n"); printf("DL_Schedules\n"); printf("Test_TC_DRLK_1_1\n"); - printf("Test_TC_DRLK_2_2\n"); - printf("Test_TC_DRLK_2_3\n"); printf("Test_TC_DRLK_2_4\n"); printf("Test_TC_DRLK_2_5\n"); printf("Test_TC_DRLK_2_6\n"); printf("Test_TC_DRLK_2_7\n"); printf("Test_TC_DRLK_2_8\n"); printf("Test_TC_DRLK_2_11\n"); - printf("Test_TC_DRLK_2_12\n"); printf("TestGroupsCluster\n"); printf("Test_TC_G_1_1\n"); printf("TestActivatedCarbonFilterMonitoring\n"); @@ -167999,11 +167996,11 @@ class Test_TC_DRLK_1_1 : public TestCommandBridge { } }; -class Test_TC_DRLK_2_2 : public TestCommandBridge { +class Test_TC_DRLK_2_4 : public TestCommandBridge { public: // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_2() - : TestCommandBridge("Test_TC_DRLK_2_2") + Test_TC_DRLK_2_4() + : TestCommandBridge("Test_TC_DRLK_2_4") , mTestIndex(0) { AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); @@ -168013,7 +168010,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { } // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - ~Test_TC_DRLK_2_2() {} + ~Test_TC_DRLK_2_4() {} /////////// TestCommand Interface ///////// void NextTest() override @@ -168021,11 +168018,11 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { CHIP_ERROR err = CHIP_NO_ERROR; if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_2\n"); + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_4\n"); } if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_2\n"); + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_4\n"); SetCommandExitStatus(CHIP_NO_ERROR); return; } @@ -168042,217 +168039,110 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); break; case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Create new user\n"); - err = TestPreconditionCreateNewUser_1(); + ChipLogProgress(chipTool, " ***** Test Step 1 : Create new user\n"); + err = TestCreateNewUser_1(); break; case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Precondition: Read the user back and verify its fields\n"); - err = TestPreconditionReadTheUserBackAndVerifyItsFields_2(); + ChipLogProgress(chipTool, " ***** Test Step 2 : Read the user back and verify its fields\n"); + err = TestReadTheUserBackAndVerifyItsFields_2(); break; case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Precondition: Create new PIN credential and lock/unlock user\n"); - err = TestPreconditionCreateNewPinCredentialAndLockUnlockUser_3(); + ChipLogProgress(chipTool, " ***** Test Step 3 : Create new PIN credential and lock/unlock user\n"); + err = TestCreateNewPinCredentialAndLockUnlockUser_3(); break; case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Precondition: Verify created PIN credential\n"); - err = TestPreconditionVerifyCreatedPinCredential_4(); + ChipLogProgress(chipTool, " ***** Test Step 4 : Verify created PIN credential\n"); + err = TestVerifyCreatedPinCredential_4(); break; case 5: - ChipLogProgress(chipTool, - " ***** Test Step 5 : Step 1a: TH writes the RequirePINforRemoteOperation attribute value as False on the DUT\n"); - if (ShouldSkip("DRLK.S.A0033")) { + ChipLogProgress( + chipTool, " ***** Test Step 5 : Step 1a: TH writes AutoRelockTime attribute value as 10 seconds on the DUT\n"); + if (ShouldSkip("DRLK.S.A0023.Write && PICS_SDK_CI_ONLY")) { NextTest(); return; } - err = TestStep1aThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDut_5(); + err = TestStep1aThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_5(); break; case 6: - ChipLogProgress(chipTool, - " ***** Test Step 6 : Step 1b: TH writes the RequirePINforRemoteOperation attribute value as False on the DUT and " - "Verify DUT responds with UNSUPPORTED_WRITE\n"); - if (ShouldSkip("!DRLK.S.A0033")) { + ChipLogProgress( + chipTool, " ***** Test Step 6 : Step 1b: TH writes AutoRelockTime attribute value as 60 seconds on the DUT\n"); + if (ShouldSkip("DRLK.S.A0023.Write && PICS_SKIP_SAMPLE_APP")) { NextTest(); return; } - err = TestStep1bThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDutAndVerifyDutRespondsWithUnsupportedWrite_6(); + err = TestStep1bThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_6(); break; case 7: ChipLogProgress( - chipTool, " ***** Test Step 7 : Step 2: TH reads the RequirePINforRemoteOperation attribute from the DUT\n"); - if (ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033")) { + chipTool, " ***** Test Step 7 : Step 1c: TH writes AutoRelockTime attribute value as 10 seconds on the DUT\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY && !DRLK.S.A0023.Write")) { NextTest(); return; } - err = TestStep2ThReadsTheRequirePINforRemoteOperationAttributeFromTheDut_7(); + err = TestStep1cThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_7(); break; case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3: TH sends Lock Door Command to the DUT without PINCode\n"); - if (ShouldSkip("DRLK.S.C00.Rsp")) { + ChipLogProgress( + chipTool, " ***** Test Step 8 : Step 1d: TH writes AutoRelockTime attribute value as 60 seconds on the DUT\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && !DRLK.S.A0023.Write")) { NextTest(); return; } - err = TestStep3ThSendsLockDoorCommandToTheDutWithoutPINCode_8(); + err = TestStep1dThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_8(); break; case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4: TH sends Lock Door Command to the DUT with valid PINCode\n"); - if (ShouldSkip("DRLK.S.C00.Rsp")) { + ChipLogProgress( + chipTool, " ***** Test Step 9 : Step 2a: TH sends the Unlock with Timeout argument value as 10 seconds\n"); + if (ShouldSkip("DRLK.S.C03.Rsp && PICS_SDK_CI_ONLY")) { NextTest(); return; } - err = TestStep4ThSendsLockDoorCommandToTheDutWithValidPINCode_9(); + err = TestStep2aThSendsTheUnlockWithTimeoutArgumentValueAs10Seconds_9(); break; case 10: - ChipLogProgress(chipTool, - " ***** Test Step 10 : Step 5a: TH writes the RequirePINforRemoteOperation attribute value as False on the DUT\n"); - if (ShouldSkip("DRLK.S.A0033")) { + ChipLogProgress( + chipTool, " ***** Test Step 10 : Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds\n"); + if (ShouldSkip("DRLK.S.C03.Rsp && PICS_SKIP_SAMPLE_APP")) { NextTest(); return; } - err = TestStep5aThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDut_10(); + err = TestStep2bThSendsTheUnlockWithTimeoutArgumentValueAs60Seconds_10(); break; case 11: - ChipLogProgress(chipTool, - " ***** Test Step 11 : Step 5b: TH writes the RequirePINforRemoteOperation attribute value as False on the DUT and " - "Verify DUT responds with UNSUPPORTED_WRITE\n"); - if (ShouldSkip("!DRLK.S.A0033")) { + ChipLogProgress(chipTool, " ***** Test Step 11 : Wait for AutoRelockTime Expires\n"); + if (ShouldSkip("DRLK.S.C03.Rsp && PICS_SDK_CI_ONLY")) { NextTest(); return; } - err = TestStep5bThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDutAndVerifyDutRespondsWithUnsupportedWrite_11(); + err = TestWaitForAutoRelockTimeExpires_11(); break; case 12: - ChipLogProgress( - chipTool, " ***** Test Step 12 : Step 6: TH reads the RequirePINforRemoteOperation attribute from the DUT\n"); - if (ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033")) { + ChipLogProgress(chipTool, " ***** Test Step 12 : Wait for AutoRelockTime Expires\n"); + if (ShouldSkip("DRLK.S.C03.Rsp && PICS_SKIP_SAMPLE_APP")) { NextTest(); return; } - err = TestStep6ThReadsTheRequirePINforRemoteOperationAttributeFromTheDut_12(); + err = TestWaitForAutoRelockTimeExpires_12(); break; case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: TH sends Lock Door Command to the DUT with valid PINCode\n"); - if (ShouldSkip("DRLK.S.C00.Rsp && DRLK.S.A0033")) { + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2c: TH reads LockState attribute\n"); + if (ShouldSkip("DRLK.S.A0000 && DRLK.S.C03.Rsp")) { NextTest(); return; } - err = TestStep7ThSendsLockDoorCommandToTheDutWithValidPINCode_13(); + err = TestStep2cThReadsLockStateAttribute_13(); break; case 14: - ChipLogProgress( - chipTool, " ***** Test Step 14 : Step 8: TH sends Lock Door Command to the DUT without valid PINCode\n"); - if (ShouldSkip("DRLK.S.C00.Rsp && DRLK.S.A0033")) { - NextTest(); - return; - } - err = TestStep8ThSendsLockDoorCommandToTheDutWithoutValidPINCode_14(); + ChipLogProgress(chipTool, " ***** Test Step 14 : Cleanup the created user\n"); + err = TestCleanupTheCreatedUser_14(); break; case 15: - ChipLogProgress( - chipTool, " ***** Test Step 15 : Step 9: TH sends Lock Door Command to the DUT without any argument PINCode\n"); - if (ShouldSkip("DRLK.S.C00.Rsp && DRLK.S.A0033")) { - NextTest(); - return; - } - err = TestStep9ThSendsLockDoorCommandToTheDutWithoutAnyArgumentPINCode_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 10a: H reads the WrongCodeEntryLimit attribute from the DUT\n"); - if (ShouldSkip("DRLK.S.A0030")) { - NextTest(); - return; - } - err = TestStep10aHReadsTheWrongCodeEntryLimitAttributeFromTheDut_16(); - break; - case 17: - ChipLogProgress(chipTool, - " ***** Test Step 17 : Step 10b: TH sends an Unlock Door Command from the DUT with invalid PINCode. Repeat this " - "step PIXIT.DRLK.WrongCodeEntryLimit times and Verify that DUT sends failure response to the TH\n"); - if (ShouldSkip("PICS_USER_PROMPT && DRLK.S.A0030")) { - NextTest(); - return; - } - err = TestStep10bThSendsAnUnlockDoorCommandFromTheDutWithInvalidPINCodeRepeatThisStepPIXITDRLKWrongCodeEntryLimitTimesAndVerifyThatDutSendsFailureResponseToTheTh_17(); - break; - case 18: - ChipLogProgress(chipTool, - " ***** Test Step 18 : Step 10c: TH sends an Unlock Door Command from User1 to the DUT with the valid PINCode and " - "verify the DUT response\n"); - if (ShouldSkip("PICS_USER_PROMPT && DRLK.S.A0030")) { - NextTest(); - return; - } - err = TestStep10cThSendsAnUnlockDoorCommandFromUser1ToTheDutWithTheValidPINCodeAndVerifyTheDutResponse_18(); - break; - case 19: - ChipLogProgress(chipTool, - " ***** Test Step 19 : Step 10d: Wait for PIXIT.DRLK.UserCodeTemporaryDisableTime.TH then sends an Unlock Door " - "Command from User1 to the DUT with the valid PINCode.\n"); - if (ShouldSkip("PICS_USER_PROMPT && DRLK.S.A0030")) { - NextTest(); - return; - } - err = TestStep10dWaitForPIXITDRLKUserCodeTemporaryDisableTimeTHThenSendsAnUnlockDoorCommandFromUser1ToTheDutWithTheValidPINCode_19(); - break; - case 20: - ChipLogProgress(chipTool, - " ***** Test Step 20 : Step 10e: TH writes WrongCodeEntryLimit attribute value as between 1 and 255 on the DUT and " - "Verify that the DUT sends Success response\n"); - if (ShouldSkip("DRLK.S.A0030")) { - NextTest(); - return; - } - err = TestStep10eThWritesWrongCodeEntryLimitAttributeValueAsBetween1And255OnTheDutAndVerifyThatTheDutSendsSuccessResponse_20(); - break; - case 21: - ChipLogProgress(chipTool, - " ***** Test Step 21 : Step 10e: TH writes WrongCodeEntryLimit attribute value as between 1 and 255 on the DUT and " - "verify DUT responds with UNSUPPORTED_WRITE\n"); - if (ShouldSkip("!DRLK.S.A0030")) { - NextTest(); - return; - } - err = TestStep10eThWritesWrongCodeEntryLimitAttributeValueAsBetween1And255OnTheDutAndVerifyDutRespondsWithUnsupportedWrite_21(); - break; - case 22: - ChipLogProgress( - chipTool, " ***** Test Step 22 : Step 11a: TH reads the UserCodeTemporaryDisableTime attribute from the DUT\n"); - if (ShouldSkip("DRLK.S.A0031")) { - NextTest(); - return; - } - err = TestStep11aThReadsTheUserCodeTemporaryDisableTimeAttributeFromTheDut_22(); - break; - case 23: - ChipLogProgress(chipTool, - " ***** Test Step 23 : Step 12a: TH writes UserCodeTemporaryDisableTime attribute value as between 1 and 255 on " - "the DUT and Verify that the DUT sends Success response\n"); - if (ShouldSkip("DRLK.S.A0031")) { - NextTest(); - return; - } - err = TestStep12aThWritesUserCodeTemporaryDisableTimeAttributeValueAsBetween1And255OnTheDutAndVerifyThatTheDutSendsSuccessResponse_23(); - break; - case 24: - ChipLogProgress(chipTool, - " ***** Test Step 24 : Step 12a: TH writes UserCodeTemporaryDisableTime attribute value as between 1 and 255 on " - "the DUT and verify DUT responds with UNSUPPORTED_WRITE\n"); - if (ShouldSkip("!DRLK.S.A0031")) { - NextTest(); - return; - } - err = TestStep12aThWritesUserCodeTemporaryDisableTimeAttributeValueAsBetween1And255OnTheDutAndVerifyDutRespondsWithUnsupportedWrite_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Clean the created user\n"); - err = TestCleanTheCreatedUser_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Cleanup the created credential\n"); + ChipLogProgress(chipTool, " ***** Test Step 15 : Clean the created credential\n"); if (ShouldSkip("DRLK.S.C26.Rsp")) { NextTest(); return; } - err = TestCleanupTheCreatedCredential_26(); + err = TestCleanTheCreatedCredential_15(); break; } @@ -168284,13 +168174,13 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); break; case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); break; case 9: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); @@ -168299,7 +168189,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 12: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); @@ -168308,42 +168198,9 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 25: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; - case 26: + case 15: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; } @@ -168359,7 +168216,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 27; + const uint16_t mTestCount = 16; chip::Optional mNodeId; chip::Optional mCluster; @@ -168374,7 +168231,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { return WaitForCommissionee("alpha", value); } - CHIP_ERROR TestPreconditionCreateNewUser_1() + CHIP_ERROR TestCreateNewUser_1() { MTRBaseDevice * device = GetDevice("alpha"); @@ -168391,7 +168248,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { params.credentialRule = [NSNumber numberWithUnsignedChar:0U]; [cluster setUserWithParams:params completion:^(NSError * _Nullable err) { - NSLog(@"Precondition: Create new user Error: %@", err); + NSLog(@"Create new user Error: %@", err); VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); @@ -168401,7 +168258,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestPreconditionReadTheUserBackAndVerifyItsFields_2() + CHIP_ERROR TestReadTheUserBackAndVerifyItsFields_2() { MTRBaseDevice * device = GetDevice("alpha"); @@ -168412,7 +168269,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { params.userIndex = [NSNumber numberWithUnsignedShort:1U]; [cluster getUserWithParams:params completion:^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - NSLog(@"Precondition: Read the user back and verify its fields Error: %@", err); + NSLog(@"Read the user back and verify its fields Error: %@", err); VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); @@ -168480,7 +168337,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestPreconditionCreateNewPinCredentialAndLockUnlockUser_3() + CHIP_ERROR TestCreateNewPinCredentialAndLockUnlockUser_3() { MTRBaseDevice * device = GetDevice("alpha"); @@ -168500,7 +168357,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { [cluster setCredentialWithParams:params completion:^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - NSLog(@"Precondition: Create new PIN credential and lock/unlock user Error: %@", err); + NSLog(@"Create new PIN credential and lock/unlock user Error: %@", err); VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); @@ -168526,7 +168383,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestPreconditionVerifyCreatedPinCredential_4() + CHIP_ERROR TestVerifyCreatedPinCredential_4() { MTRBaseDevice * device = GetDevice("alpha"); @@ -168541,7 +168398,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { [cluster getCredentialStatusWithParams:params completion:^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - NSLog(@"Precondition: Verify created PIN credential Error: %@", err); + NSLog(@"Verify created PIN credential Error: %@", err); VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); @@ -168579,386 +168436,185 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestStep1aThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id requirePINforRemoteOperationArgument; - requirePINforRemoteOperationArgument = [NSNumber numberWithBool:false]; - [cluster writeAttributeRequirePINforRemoteOperationWithValue:requirePINforRemoteOperationArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 1a: TH writes the RequirePINforRemoteOperation " - @"attribute value as False on the DUT Error: %@", - err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR - TestStep1bThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDutAndVerifyDutRespondsWithUnsupportedWrite_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id requirePINforRemoteOperationArgument; - requirePINforRemoteOperationArgument = [NSNumber numberWithBool:false]; - [cluster writeAttributeRequirePINforRemoteOperationWithValue:requirePINforRemoteOperationArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 1b: TH writes the RequirePINforRemoteOperation " - @"attribute value as False on the DUT and Verify DUT responds " - @"with UNSUPPORTED_WRITE Error: %@", - err); - - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] - ? err.code - : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheRequirePINforRemoteOperationAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRequirePINforRemoteOperationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 2: TH reads the RequirePINforRemoteOperation attribute from the DUT Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("RequirePINforRemoteOperation", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsLockDoorCommandToTheDutWithoutPINCode_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterLockDoorParams alloc] init]; - [cluster lockDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 3: TH sends Lock Door Command to the DUT without PINCode Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsLockDoorCommandToTheDutWithValidPINCode_9() + CHIP_ERROR TestStep1aThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_5() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterLockDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"123456" length:6]; - [cluster lockDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 4: TH sends Lock Door Command to the DUT with valid PINCode Error: %@", err); + id autoRelockTimeArgument; + autoRelockTimeArgument = [NSNumber numberWithUnsignedInt:10UL]; + [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument + completion:^(NSError * _Nullable err) { + NSLog(@"Step 1a: TH writes AutoRelockTime attribute value as 10 seconds on the DUT " + @"Error: %@", + err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep5aThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDut_10() + CHIP_ERROR TestStep1bThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_6() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - id requirePINforRemoteOperationArgument; - requirePINforRemoteOperationArgument = [NSNumber numberWithBool:true]; - [cluster writeAttributeRequirePINforRemoteOperationWithValue:requirePINforRemoteOperationArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 5a: TH writes the RequirePINforRemoteOperation " - @"attribute value as False on the DUT Error: %@", - err); + id autoRelockTimeArgument; + autoRelockTimeArgument = [NSNumber numberWithUnsignedInt:60UL]; + [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument + completion:^(NSError * _Nullable err) { + NSLog(@"Step 1b: TH writes AutoRelockTime attribute value as 60 seconds on the DUT " + @"Error: %@", + err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR - TestStep5bThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDutAndVerifyDutRespondsWithUnsupportedWrite_11() + CHIP_ERROR TestStep1cThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_7() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - id requirePINforRemoteOperationArgument; - requirePINforRemoteOperationArgument = [NSNumber numberWithBool:true]; - [cluster writeAttributeRequirePINforRemoteOperationWithValue:requirePINforRemoteOperationArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 5b: TH writes the RequirePINforRemoteOperation " - @"attribute value as False on the DUT and Verify DUT responds " - @"with UNSUPPORTED_WRITE Error: %@", - err); + id autoRelockTimeArgument; + autoRelockTimeArgument = [NSNumber numberWithUnsignedInt:10UL]; + [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument + completion:^(NSError * _Nullable err) { + NSLog(@"Step 1c: TH writes AutoRelockTime attribute value as 10 seconds on the DUT " + @"Error: %@", + err); - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] - ? err.code - : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; + VerifyOrReturn(CheckValue("status", + err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] + ? err.code + : EMBER_ZCL_STATUS_FAILURE) + : 0, + EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep6ThReadsTheRequirePINforRemoteOperationAttributeFromTheDut_12() + CHIP_ERROR TestStep1dThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_8() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - [cluster readAttributeRequirePINforRemoteOperationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 6: TH reads the RequirePINforRemoteOperation attribute from the DUT Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("RequirePINforRemoteOperation", actualValue, true)); - } + id autoRelockTimeArgument; + autoRelockTimeArgument = [NSNumber numberWithUnsignedInt:60UL]; + [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument + completion:^(NSError * _Nullable err) { + NSLog(@"Step 1d: TH writes AutoRelockTime attribute value as 60 seconds on the DUT " + @"Error: %@", + err); - NextTest(); - }]; + VerifyOrReturn(CheckValue("status", + err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] + ? err.code + : EMBER_ZCL_STATUS_FAILURE) + : 0, + EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep7ThSendsLockDoorCommandToTheDutWithValidPINCode_13() + CHIP_ERROR TestStep2aThSendsTheUnlockWithTimeoutArgumentValueAs10Seconds_9() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterLockDoorParams alloc] init]; + __auto_type * params = [[MTRDoorLockClusterUnlockWithTimeoutParams alloc] init]; + params.timeout = [NSNumber numberWithUnsignedShort:10U]; params.pinCode = [[NSData alloc] initWithBytes:"123456" length:6]; - [cluster lockDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 7: TH sends Lock Door Command to the DUT with valid PINCode Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThSendsLockDoorCommandToTheDutWithoutValidPINCode_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterLockDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"645321" length:6]; [cluster - lockDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 8: TH sends Lock Door Command to the DUT without valid PINCode Error: %@", err); - - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThSendsLockDoorCommandToTheDutWithoutAnyArgumentPINCode_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + unlockWithTimeoutWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 2a: TH sends the Unlock with Timeout argument value as 10 seconds Error: %@", err); - __auto_type * params = [[MTRDoorLockClusterLockDoorParams alloc] init]; - [cluster - lockDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 9: TH sends Lock Door Command to the DUT without any argument PINCode Error: %@", err); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep10aHReadsTheWrongCodeEntryLimitAttributeFromTheDut_16() + CHIP_ERROR TestStep2bThSendsTheUnlockWithTimeoutArgumentValueAs60Seconds_10() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - [cluster readAttributeWrongCodeEntryLimitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 10a: H reads the WrongCodeEntryLimit attribute from the DUT Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + __auto_type * params = [[MTRDoorLockClusterUnlockWithTimeoutParams alloc] init]; + params.timeout = [NSNumber numberWithUnsignedShort:60U]; + params.pinCode = [[NSData alloc] initWithBytes:"123456" length:6]; + [cluster + unlockWithTimeoutWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds Error: %@", err); - VerifyOrReturn(CheckConstraintMinValue("wrongCodeEntryLimit", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("wrongCodeEntryLimit", [value unsignedCharValue], 255U)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR - TestStep10bThSendsAnUnlockDoorCommandFromTheDutWithInvalidPINCodeRepeatThisStepPIXITDRLKWrongCodeEntryLimitTimesAndVerifyThatDutSendsFailureResponseToTheTh_17() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep10cThSendsAnUnlockDoorCommandFromUser1ToTheDutWithTheValidPINCodeAndVerifyTheDutResponse_18() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR - TestStep10dWaitForPIXITDRLKUserCodeTemporaryDisableTimeTHThenSendsAnUnlockDoorCommandFromUser1ToTheDutWithTheValidPINCode_19() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR - TestStep10eThWritesWrongCodeEntryLimitAttributeValueAsBetween1And255OnTheDutAndVerifyThatTheDutSendsSuccessResponse_20() + CHIP_ERROR TestWaitForAutoRelockTimeExpires_11() { - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id wrongCodeEntryLimitArgument; - wrongCodeEntryLimitArgument = [NSNumber numberWithUnsignedChar:3U]; - [cluster - writeAttributeWrongCodeEntryLimitWithValue:wrongCodeEntryLimitArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 10e: TH writes WrongCodeEntryLimit attribute value as between 1 and " - @"255 on the DUT and Verify that the DUT sends Success response Error: %@", - err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 11000UL; + return WaitForMs("alpha", value); } - CHIP_ERROR - TestStep10eThWritesWrongCodeEntryLimitAttributeValueAsBetween1And255OnTheDutAndVerifyDutRespondsWithUnsupportedWrite_21() + CHIP_ERROR TestWaitForAutoRelockTimeExpires_12() { - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id wrongCodeEntryLimitArgument; - wrongCodeEntryLimitArgument = [NSNumber numberWithUnsignedChar:3U]; - [cluster - writeAttributeWrongCodeEntryLimitWithValue:wrongCodeEntryLimitArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 10e: TH writes WrongCodeEntryLimit attribute value as between 1 and " - @"255 on the DUT and verify DUT responds with UNSUPPORTED_WRITE Error: %@", - err); - - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] - ? err.code - : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 70000UL; + return WaitForMs("alpha", value); } - CHIP_ERROR TestStep11aThReadsTheUserCodeTemporaryDisableTimeAttributeFromTheDut_22() + CHIP_ERROR TestStep2cThReadsLockStateAttribute_13() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - [cluster readAttributeUserCodeTemporaryDisableTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 11a: TH reads the UserCodeTemporaryDisableTime attribute from the DUT Error: %@", err); + [cluster readAttributeLockStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 2c: TH reads LockState attribute Error: %@", err); VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - VerifyOrReturn(CheckConstraintMinValue("userCodeTemporaryDisableTime", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("userCodeTemporaryDisableTime", [value unsignedCharValue], 255U)); + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("LockState", actualValue)); + VerifyOrReturn(CheckValue("LockState", actualValue, 1U)); + } NextTest(); }]; @@ -168966,61 +168622,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR - TestStep12aThWritesUserCodeTemporaryDisableTimeAttributeValueAsBetween1And255OnTheDutAndVerifyThatTheDutSendsSuccessResponse_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id userCodeTemporaryDisableTimeArgument; - userCodeTemporaryDisableTimeArgument = [NSNumber numberWithUnsignedChar:15U]; - [cluster writeAttributeUserCodeTemporaryDisableTimeWithValue:userCodeTemporaryDisableTimeArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 12a: TH writes UserCodeTemporaryDisableTime attribute " - @"value as between 1 and 255 on the DUT and Verify that the " - @"DUT sends Success response Error: %@", - err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR - TestStep12aThWritesUserCodeTemporaryDisableTimeAttributeValueAsBetween1And255OnTheDutAndVerifyDutRespondsWithUnsupportedWrite_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id userCodeTemporaryDisableTimeArgument; - userCodeTemporaryDisableTimeArgument = [NSNumber numberWithUnsignedChar:15U]; - [cluster writeAttributeUserCodeTemporaryDisableTimeWithValue:userCodeTemporaryDisableTimeArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 12a: TH writes UserCodeTemporaryDisableTime attribute " - @"value as between 1 and 255 on the DUT and verify DUT " - @"responds with UNSUPPORTED_WRITE Error: %@", - err); - - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] - ? err.code - : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanTheCreatedUser_25() + CHIP_ERROR TestCleanupTheCreatedUser_14() { MTRBaseDevice * device = GetDevice("alpha"); @@ -169031,7 +168633,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { params.userIndex = [NSNumber numberWithUnsignedShort:1U]; [cluster clearUserWithParams:params completion:^(NSError * _Nullable err) { - NSLog(@"Clean the created user Error: %@", err); + NSLog(@"Cleanup the created user Error: %@", err); VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); @@ -169041,7 +168643,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestCleanupTheCreatedCredential_26() + CHIP_ERROR TestCleanTheCreatedCredential_15() { MTRBaseDevice * device = GetDevice("alpha"); @@ -169055,7 +168657,7 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { [cluster clearCredentialWithParams:params completion:^(NSError * _Nullable err) { - NSLog(@"Cleanup the created credential Error: %@", err); + NSLog(@"Clean the created credential Error: %@", err); VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); @@ -169066,11 +168668,11 @@ class Test_TC_DRLK_2_2 : public TestCommandBridge { } }; -class Test_TC_DRLK_2_3 : public TestCommandBridge { +class Test_TC_DRLK_2_5 : public TestCommandBridge { public: // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_3() - : TestCommandBridge("Test_TC_DRLK_2_3") + Test_TC_DRLK_2_5() + : TestCommandBridge("Test_TC_DRLK_2_5") , mTestIndex(0) { AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); @@ -169080,7 +168682,7 @@ class Test_TC_DRLK_2_3 : public TestCommandBridge { } // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - ~Test_TC_DRLK_2_3() {} + ~Test_TC_DRLK_2_5() {} /////////// TestCommand Interface ///////// void NextTest() override @@ -169088,11 +168690,11 @@ class Test_TC_DRLK_2_3 : public TestCommandBridge { CHIP_ERROR err = CHIP_NO_ERROR; if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_3\n"); + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_5\n"); } if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_3\n"); + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_5\n"); SetCommandExitStatus(CHIP_NO_ERROR); return; } @@ -169117,313 +168719,73 @@ class Test_TC_DRLK_2_3 : public TestCommandBridge { err = TestPreconditionReadTheUserBackAndVerifyItsFields_2(); break; case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Precondition: Create new PIN credential and lock/unlock user\n"); - err = TestPreconditionCreateNewPinCredentialAndLockUnlockUser_3(); + ChipLogProgress( + chipTool, " ***** Test Step 3 : Step 1: TH reads NumberOfWeekDay SchedulesSupportedPerUser attribute\n"); + if (ShouldSkip("DRLK.S.F04 && DRLK.S.A0014")) { + NextTest(); + return; + } + err = TestStep1ThReadsNumberOfWeekDaySchedulesSupportedPerUserAttribute_3(); break; case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Precondition: Verify created PIN credential\n"); - err = TestPreconditionVerifyCreatedPinCredential_4(); + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2: TH reads NumberOfTotalUsers Supported attribute\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { + NextTest(); + return; + } + err = TestStep2ThReadsNumberOfTotalUsersSupportedAttribute_4(); break; case 5: - ChipLogProgress(chipTool, - " ***** Test Step 5 : Step 1a: TH writes the RequirePINforRemoteOperation attribute value as False on the DUT\n"); - if (ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033")) { + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH send Set Week Day Schedule Command\n"); + if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0b.Rsp")) { NextTest(); return; } - err = TestStep1aThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDut_5(); + err = TestStep3ThSendSetWeekDayScheduleCommand_5(); break; case 6: - ChipLogProgress(chipTool, - " ***** Test Step 6 : Step 1b: TH writes the RequirePINforRemoteOperation attribute value as False on the DUT and " - "Verify DUT responds with UNSUPPORTED_WRITE\n"); - if (ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && !DRLK.S.A0033")) { + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH send Get Week Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx")) { NextTest(); return; } - err = TestStep1bThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDutAndVerifyDutRespondsWithUnsupportedWrite_6(); + err = TestStep4ThSendGetWeekDayScheduleCommandToDut_6(); break; case 7: - ChipLogProgress( - chipTool, " ***** Test Step 7 : Step 2: TH reads the RequirePINforRemoteOperation attribute from the DUT\n"); - if (ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033")) { + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH send Set Week Day Schedule Command\n"); + if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0b.Rsp")) { NextTest(); return; } - err = TestStep2ThReadsTheRequirePINforRemoteOperationAttributeFromTheDut_7(); + err = TestStep5ThSendSetWeekDayScheduleCommand_7(); break; case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3: TH sends the unlock Door command to the DUT without PINCode\n"); - if (ShouldSkip("DRLK.S.C01.Rsp")) { + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH send Get Week Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx")) { NextTest(); return; } - err = TestStep3ThSendsTheUnlockDoorCommandToTheDutWithoutPINCode_8(); + err = TestStep6ThSendGetWeekDayScheduleCommandToDut_8(); break; case 9: - ChipLogProgress( - chipTool, " ***** Test Step 9 : Step 4: TH sends the unlock Door command to the DUT with valid PINCode\n"); - if (ShouldSkip("DRLK.S.C01.Rsp")) { + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH sends Clear Week Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0d.Rsp")) { NextTest(); return; } - err = TestStep4ThSendsTheUnlockDoorCommandToTheDutWithValidPINCode_9(); + err = TestStep7ThSendsClearWeekDayScheduleCommandToDut_9(); break; case 10: - ChipLogProgress(chipTool, - " ***** Test Step 10 : Step 5a: TH writes the RequirePINforRemoteOperation attribute value as False on the DUT\n"); - if (ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033")) { + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 8: TH sends Get Week Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx")) { NextTest(); return; } - err = TestStep5aThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDut_10(); + err = TestStep8ThSendsGetWeekDayScheduleCommandToDut_10(); break; case 11: - ChipLogProgress(chipTool, - " ***** Test Step 11 : Step 5b: TH writes the RequirePINforRemoteOperation attribute value as False on the DUT and " - "Verify DUT responds with UNSUPPORTED_WRITE\n"); - if (ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && !DRLK.S.A0033")) { - NextTest(); - return; - } - err = TestStep5bThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDutAndVerifyDutRespondsWithUnsupportedWrite_11(); - break; - case 12: - ChipLogProgress( - chipTool, " ***** Test Step 12 : Step 6: TH reads the RequirePINforRemoteOperation attribute from the DUT\n"); - if (ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheRequirePINforRemoteOperationAttributeFromTheDut_12(); - break; - case 13: - ChipLogProgress( - chipTool, " ***** Test Step 13 : Step 7: TH sends the unlock Door command to the DUT with valid PINCode\n"); - if (ShouldSkip("DRLK.S.C01.Rsp && DRLK.S.A0033")) { - NextTest(); - return; - } - err = TestStep7ThSendsTheUnlockDoorCommandToTheDutWithValidPINCode_13(); - break; - case 14: - ChipLogProgress( - chipTool, " ***** Test Step 14 : Step 8: TH sends the unlock Door command to the DUT with invalid PINCode\n"); - if (ShouldSkip("DRLK.S.C01.Rsp && DRLK.S.A0033")) { - NextTest(); - return; - } - err = TestStep8ThSendsTheUnlockDoorCommandToTheDutWithInvalidPINCode_14(); - break; - case 15: - ChipLogProgress( - chipTool, " ***** Test Step 15 : Step 9: TH sends the unlock Door command to the DUT without PINCode\n"); - if (ShouldSkip("DRLK.S.C01.Rsp && DRLK.S.A0033")) { - NextTest(); - return; - } - err = TestStep9ThSendsTheUnlockDoorCommandToTheDutWithoutPINCode_15(); - break; - case 16: - ChipLogProgress(chipTool, - " ***** Test Step 16 : Step 10a: TH writes WrongCodeEntryLimit attribute value as 3 on the DUT and Verify that the " - "DUT sends Success response\n"); - if (ShouldSkip("DRLK.S.F00 && DRLK.S.F01 && DRLK.S.A0030.Write")) { - NextTest(); - return; - } - err = TestStep10aThWritesWrongCodeEntryLimitAttributeValueAs3OnTheDutAndVerifyThatTheDutSendsSuccessResponse_16(); - break; - case 17: - ChipLogProgress(chipTool, - " ***** Test Step 17 : Step 10b: TH writes WrongCodeEntryLimit attribute value as 3 on the DUT and verify DUT " - "responds with UNSUPPORTED_WRITE\n"); - if (ShouldSkip("DRLK.S.F00 && DRLK.S.F01 && !DRLK.S.A0030.Write")) { - NextTest(); - return; - } - err = TestStep10bThWritesWrongCodeEntryLimitAttributeValueAs3OnTheDutAndVerifyDutRespondsWithUnsupportedWrite_17(); - break; - case 18: - ChipLogProgress(chipTool, - " ***** Test Step 18 : Step 11a: TH writes UserCodeTemporaryDisableTime attribute value as 15 Seconds on the DUT " - "and Verify that the DUT sends Success response\n"); - if (ShouldSkip("DRLK.S.F00 && DRLK.S.F01 && DRLK.S.A0031.Write")) { - NextTest(); - return; - } - err = TestStep11aThWritesUserCodeTemporaryDisableTimeAttributeValueAs15SecondsOnTheDutAndVerifyThatTheDutSendsSuccessResponse_18(); - break; - case 19: - ChipLogProgress(chipTool, - " ***** Test Step 19 : Step 11b: TH writes UserCodeTemporaryDisableTime attribute value as 15 Seconds on the DUT " - "and Verify that the DUT sends Success response\n"); - if (ShouldSkip("DRLK.S.F00 && DRLK.S.F01 && !DRLK.S.A0031.Write")) { - NextTest(); - return; - } - err = TestStep11bThWritesUserCodeTemporaryDisableTimeAttributeValueAs15SecondsOnTheDutAndVerifyThatTheDutSendsSuccessResponse_19(); - break; - case 20: - ChipLogProgress( - chipTool, " ***** Test Step 20 : Step 12a: TH sends the unlock Door command to the DUT with invalid PINCode\n"); - if (ShouldSkip("DRLK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep12aThSendsTheUnlockDoorCommandToTheDutWithInvalidPINCode_20(); - break; - case 21: - ChipLogProgress( - chipTool, " ***** Test Step 21 : Step 12b: TH sends the unlock Door command to the DUT with invalid PINCode\n"); - if (ShouldSkip("DRLK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep12bThSendsTheUnlockDoorCommandToTheDutWithInvalidPINCode_21(); - break; - case 22: - ChipLogProgress( - chipTool, " ***** Test Step 22 : Step 12c: TH sends the unlock Door command to the DUT with invalid PINCode\n"); - if (ShouldSkip("DRLK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep12cThSendsTheUnlockDoorCommandToTheDutWithInvalidPINCode_22(); - break; - case 23: - ChipLogProgress( - chipTool, " ***** Test Step 23 : Step 12d: TH sends the unlock Door command to the DUT with invalid PINCode\n"); - if (ShouldSkip("DRLK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep12dThSendsTheUnlockDoorCommandToTheDutWithInvalidPINCode_23(); - break; - case 24: - ChipLogProgress(chipTool, - " ***** Test Step 24 : Step 13: TH reads the UserCodeTemporaryDisableTime attribute from the DUT and check " - "attribute is triggered\n"); - if (ShouldSkip("DRLK.S.F00 && DRLK.S.F01 && DRLK.S.A0031")) { - NextTest(); - return; - } - err = TestStep13ThReadsTheUserCodeTemporaryDisableTimeAttributeFromTheDutAndCheckAttributeIsTriggered_24(); - break; - case 25: - ChipLogProgress( - chipTool, " ***** Test Step 25 : Step 14: TH sends the unlock Door command to the DUT with valid PINCode\n"); - if (ShouldSkip("DRLK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep14ThSendsTheUnlockDoorCommandToTheDutWithValidPINCode_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Wait for UserCodeTemporaryDisableTime expires\n"); - if (ShouldSkip("DRLK.S.F00 && DRLK.S.F01 && DRLK.S.A0031")) { - NextTest(); - return; - } - err = TestWaitForUserCodeTemporaryDisableTimeExpires_26(); - break; - case 27: - ChipLogProgress( - chipTool, " ***** Test Step 27 : Step 15a: TH writes AutoRelockTime attribute value as 10 seconds on the DUT\n"); - if (ShouldSkip("DRLK.S.A0023.Write && PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep15aThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_27(); - break; - case 28: - ChipLogProgress( - chipTool, " ***** Test Step 28 : Step 15b: TH writes AutoRelockTime attribute value as 60 seconds on the DUT\n"); - if (ShouldSkip("DRLK.S.A0023.Write && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep15bThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_28(); - break; - case 29: - ChipLogProgress( - chipTool, " ***** Test Step 29 : Step 15c: TH writes AutoRelockTime attribute value as 10 seconds on the DUT\n"); - if (ShouldSkip(" !DRLK.S.A0023.Write && PICS_SDK_CI_ONLY ")) { - NextTest(); - return; - } - err = TestStep15cThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_29(); - break; - case 30: - ChipLogProgress( - chipTool, " ***** Test Step 30 : Step 15d: TH writes AutoRelockTime attribute value as 60 seconds on the DUT\n"); - if (ShouldSkip(" !DRLK.S.A0023.Write && PICS_SKIP_SAMPLE_APP ")) { - NextTest(); - return; - } - err = TestStep15dThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 16a: TH reads the AutoRelockTime attribute from the DUT\n"); - if (ShouldSkip("DRLK.S.A0023 && PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep16aThReadsTheAutoRelockTimeAttributeFromTheDut_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 16b: TH reads the AutoRelockTime attribute from the DUT\n"); - if (ShouldSkip("DRLK.S.A0023 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep16bThReadsTheAutoRelockTimeAttributeFromTheDut_32(); - break; - case 33: - ChipLogProgress(chipTool, - " ***** Test Step 33 : Step 17: TH sends the unlock Door command to the DUT with valid PINCode and Verify that DUT " - "sends SUCCESS response to the TH\n"); - if (ShouldSkip("DRLK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep17ThSendsTheUnlockDoorCommandToTheDutWithValidPINCodeAndVerifyThatDutSendsSuccessResponseToTheTh_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Wait for AutoRelockTime Expires\n"); - if (ShouldSkip("DRLK.S.A0023 && PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestWaitForAutoRelockTimeExpires_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Wait for AutoRelockTime Expires\n"); - if (ShouldSkip("DRLK.S.A0023 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestWaitForAutoRelockTimeExpires_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 18: TH reads LockState attribute\n"); - if (ShouldSkip("DRLK.S.A0000 && DRLK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep18ThReadsLockStateAttribute_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Cleanup the created user\n"); - err = TestCleanupTheCreatedUser_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Clean the created credential\n"); - if (ShouldSkip("DRLK.S.C26.Rsp")) { - NextTest(); - return; - } - err = TestCleanTheCreatedCredential_38(); + ChipLogProgress(chipTool, " ***** Test Step 11 : Cleanup the created user\n"); + err = TestCleanupTheCreatedUser_11(); break; } @@ -169455,10 +168817,10 @@ class Test_TC_DRLK_2_3 : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); break; case 8: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); @@ -169470,87 +168832,6 @@ class Test_TC_DRLK_2_3 : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; } @@ -169559,11 +168840,14 @@ class Test_TC_DRLK_2_3 : public TestCommandBridge { ContinueOnChipMainThread(CHIP_NO_ERROR); } - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(200)); } + chip::System::Clock::Timeout GetWaitDuration() const override + { + return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); + } private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 39; + const uint16_t mTestCount = 12; chip::Optional mNodeId; chip::Optional mCluster; @@ -169683,582 +168967,543 @@ class Test_TC_DRLK_2_3 : public TestCommandBridge { return CHIP_NO_ERROR; } + NSNumber * _Nonnull NumberOfWeekDaySchedulesSupportedPerUser; - CHIP_ERROR TestPreconditionCreateNewPinCredentialAndLockUnlockUser_3() + CHIP_ERROR TestStep1ThReadsNumberOfWeekDaySchedulesSupportedPerUserAttribute_3() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster - setCredentialWithParams:params - completion:^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - NSLog(@"Precondition: Create new PIN credential and lock/unlock user Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } + [cluster readAttributeNumberOfWeekDaySchedulesSupportedPerUserWithCompletion:^( + NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 1: TH reads NumberOfWeekDay SchedulesSupportedPerUser attribute Error: %@", err); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } + VerifyOrReturn( + CheckConstraintMinValue("numberOfWeekDaySchedulesSupportedPerUser", [value unsignedCharValue], 0U)); + VerifyOrReturn( + CheckConstraintMaxValue("numberOfWeekDaySchedulesSupportedPerUser", [value unsignedCharValue], 255U)); + { + NumberOfWeekDaySchedulesSupportedPerUser = value; + } - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } + NSNumber * _Nonnull NumberOfTotalUsersSupported; - CHIP_ERROR TestPreconditionVerifyCreatedPinCredential_4() + CHIP_ERROR TestStep2ThReadsNumberOfTotalUsersSupportedAttribute_4() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params - completion:^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Precondition: Verify created PIN credential Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } + [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 2: TH reads NumberOfTotalUsers Supported attribute Error: %@", err); - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } + VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65534U)); + { + NumberOfTotalUsersSupported = value; + } - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep1aThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDut_5() + CHIP_ERROR TestStep3ThSendSetWeekDayScheduleCommand_5() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - id requirePINforRemoteOperationArgument; - requirePINforRemoteOperationArgument = [NSNumber numberWithBool:false]; - [cluster writeAttributeRequirePINforRemoteOperationWithValue:requirePINforRemoteOperationArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 1a: TH writes the RequirePINforRemoteOperation " - @"attribute value as False on the DUT Error: %@", - err); + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = [NSNumber numberWithUnsignedShort:1U]; + params.daysMask = [NSNumber numberWithUnsignedChar:2U]; + params.startHour = [NSNumber numberWithUnsignedChar:15U]; + params.startMinute = [NSNumber numberWithUnsignedChar:45U]; + params.endHour = [NSNumber numberWithUnsignedChar:16U]; + params.endMinute = [NSNumber numberWithUnsignedChar:55U]; + [cluster setWeekDayScheduleWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 3: TH send Set Week Day Schedule Command Error: %@", err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR - TestStep1bThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDutAndVerifyDutRespondsWithUnsupportedWrite_6() + CHIP_ERROR TestStep4ThSendGetWeekDayScheduleCommandToDut_6() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - id requirePINforRemoteOperationArgument; - requirePINforRemoteOperationArgument = [NSNumber numberWithBool:false]; - [cluster writeAttributeRequirePINforRemoteOperationWithValue:requirePINforRemoteOperationArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 1b: TH writes the RequirePINforRemoteOperation " - @"attribute value as False on the DUT and Verify DUT responds " - @"with UNSUPPORTED_WRITE Error: %@", - err); - - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] - ? err.code - : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = [NSNumber numberWithUnsignedShort:1U]; + [cluster + getWeekDayScheduleWithParams:params + completion:^( + MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + NSLog(@"Step 4: TH send Get Week Day Schedule Command to DUT Error: %@", err); - CHIP_ERROR TestStep2ThReadsTheRequirePINforRemoteOperationAttributeFromTheDut_7() - { + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); + } - [cluster readAttributeRequirePINforRemoteOperationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 2: TH reads the RequirePINforRemoteOperation attribute from the DUT Error: %@", err); + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } - { - id actualValue = value; - VerifyOrReturn(CheckValue("RequirePINforRemoteOperation", actualValue, false)); - } + { + id actualValue = values.daysMask; + VerifyOrReturn(CheckValue("DaysMask", actualValue, 2U)); + } - NextTest(); - }]; + { + id actualValue = values.startHour; + VerifyOrReturn(CheckValue("StartHour", actualValue, 15U)); + } - return CHIP_NO_ERROR; - } + { + id actualValue = values.startMinute; + VerifyOrReturn(CheckValue("StartMinute", actualValue, 45U)); + } - CHIP_ERROR TestStep3ThSendsTheUnlockDoorCommandToTheDutWithoutPINCode_8() - { + VerifyOrReturn(CheckConstraintHasValue("endHour", values.endHour, true)); + if (values.endHour != nil) { - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturn( + CheckConstraintMinValue("endHour", [values.endHour unsignedCharValue], 16U)); + } - __auto_type * params = [[MTRDoorLockClusterUnlockDoorParams alloc] init]; - [cluster unlockDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 3: TH sends the unlock Door command to the DUT without PINCode Error: %@", err); + VerifyOrReturn(CheckConstraintHasValue("endMinute", values.endMinute, true)); + if (values.endMinute != nil) { - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn( + CheckConstraintMinValue("endMinute", [values.endMinute unsignedCharValue], 55U)); + } - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep4ThSendsTheUnlockDoorCommandToTheDutWithValidPINCode_9() + CHIP_ERROR TestStep5ThSendSetWeekDayScheduleCommand_7() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterUnlockDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"123456" length:6]; - [cluster unlockDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 4: TH sends the unlock Door command to the DUT with valid PINCode Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = [NSNumber numberWithUnsignedShort:1U]; + params.daysMask = [NSNumber numberWithUnsignedChar:7U]; + params.startHour = [NSNumber numberWithUnsignedChar:15U]; + params.startMinute = [NSNumber numberWithUnsignedChar:45U]; + params.endHour = [NSNumber numberWithUnsignedChar:16U]; + params.endMinute = [NSNumber numberWithUnsignedChar:55U]; + [cluster setWeekDayScheduleWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 5: TH send Set Week Day Schedule Command Error: %@", err); - NextTest(); - }]; + VerifyOrReturn(CheckValue("status", + err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code + : EMBER_ZCL_STATUS_FAILURE) + : 0, + EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep5aThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDut_10() + CHIP_ERROR TestStep6ThSendGetWeekDayScheduleCommandToDut_8() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - id requirePINforRemoteOperationArgument; - requirePINforRemoteOperationArgument = [NSNumber numberWithBool:true]; - [cluster writeAttributeRequirePINforRemoteOperationWithValue:requirePINforRemoteOperationArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 5a: TH writes the RequirePINforRemoteOperation " - @"attribute value as False on the DUT Error: %@", - err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR - TestStep5bThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDutAndVerifyDutRespondsWithUnsupportedWrite_11() - { + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = [NSNumber numberWithUnsignedShort:1U]; + [cluster getWeekDayScheduleWithParams:params + completion:^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Step 6: TH send Get Week Day Schedule Command to DUT Error: %@", err); - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - id requirePINforRemoteOperationArgument; - requirePINforRemoteOperationArgument = [NSNumber numberWithBool:true]; - [cluster writeAttributeRequirePINforRemoteOperationWithValue:requirePINforRemoteOperationArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 5b: TH writes the RequirePINforRemoteOperation " - @"attribute value as False on the DUT and Verify DUT responds " - @"with UNSUPPORTED_WRITE Error: %@", - err); + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 0U)); + } - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] - ? err.code - : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } - return CHIP_NO_ERROR; - } + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } - CHIP_ERROR TestStep6ThReadsTheRequirePINforRemoteOperationAttributeFromTheDut_12() - { + VerifyOrReturn(CheckConstraintHasValue("daysMask", values.daysMask, false)); + if (values.daysMask != nil) { + } - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturn(CheckConstraintHasValue("startHour", values.startHour, false)); + if (values.startHour != nil) { + } - [cluster readAttributeRequirePINforRemoteOperationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 6: TH reads the RequirePINforRemoteOperation attribute from the DUT Error: %@", err); + VerifyOrReturn(CheckConstraintHasValue("startMinute", values.startMinute, false)); + if (values.startMinute != nil) { + } - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckConstraintHasValue("endHour", values.endHour, false)); + if (values.endHour != nil) { + } - { - id actualValue = value; - VerifyOrReturn(CheckValue("RequirePINforRemoteOperation", actualValue, true)); - } + VerifyOrReturn(CheckConstraintHasValue("endMinute", values.endMinute, false)); + if (values.endMinute != nil) { + } - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep7ThSendsTheUnlockDoorCommandToTheDutWithValidPINCode_13() + CHIP_ERROR TestStep7ThSendsClearWeekDayScheduleCommandToDut_9() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterUnlockDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"123456" length:6]; - [cluster unlockDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 7: TH sends the unlock Door command to the DUT with valid PINCode Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThSendsTheUnlockDoorCommandToTheDutWithInvalidPINCode_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; + params.weekDayIndex = [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = [NSNumber numberWithUnsignedShort:1U]; + [cluster clearWeekDayScheduleWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 7: TH sends Clear Week Day Schedule Command to DUT Error: %@", err); - __auto_type * params = [[MTRDoorLockClusterUnlockDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"1234568" length:7]; - [cluster - unlockDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 8: TH sends the unlock Door command to the DUT with invalid PINCode Error: %@", err); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep9ThSendsTheUnlockDoorCommandToTheDutWithoutPINCode_15() + CHIP_ERROR TestStep8ThSendsGetWeekDayScheduleCommandToDut_10() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterUnlockDoorParams alloc] init]; - [cluster - unlockDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 9: TH sends the unlock Door command to the DUT without PINCode Error: %@", err); - - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = [NSNumber numberWithUnsignedShort:1U]; + [cluster getWeekDayScheduleWithParams:params + completion:^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Step 8: TH sends Get Week Day Schedule Command to DUT Error: %@", err); - CHIP_ERROR TestStep10aThWritesWrongCodeEntryLimitAttributeValueAs3OnTheDutAndVerifyThatTheDutSendsSuccessResponse_16() - { + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); + } - id wrongCodeEntryLimitArgument; - wrongCodeEntryLimitArgument = [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeWrongCodeEntryLimitWithValue:wrongCodeEntryLimitArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 10a: TH writes WrongCodeEntryLimit attribute value as 3 on the " - @"DUT and Verify that the DUT sends Success response Error: %@", - err); + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } - NextTest(); - }]; + VerifyOrReturn(CheckConstraintHasValue("daysMask", values.daysMask, false)); + if (values.daysMask != nil) { + } - return CHIP_NO_ERROR; - } + VerifyOrReturn(CheckConstraintHasValue("startHour", values.startHour, false)); + if (values.startHour != nil) { + } - CHIP_ERROR TestStep10bThWritesWrongCodeEntryLimitAttributeValueAs3OnTheDutAndVerifyDutRespondsWithUnsupportedWrite_17() - { + VerifyOrReturn(CheckConstraintHasValue("startMinute", values.startMinute, false)); + if (values.startMinute != nil) { + } - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturn(CheckConstraintHasValue("endHour", values.endHour, false)); + if (values.endHour != nil) { + } - id wrongCodeEntryLimitArgument; - wrongCodeEntryLimitArgument = [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeWrongCodeEntryLimitWithValue:wrongCodeEntryLimitArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 10b: TH writes WrongCodeEntryLimit attribute value as 3 on the " - @"DUT and verify DUT responds with UNSUPPORTED_WRITE Error: %@", - err); + VerifyOrReturn(CheckConstraintHasValue("endMinute", values.endMinute, false)); + if (values.endMinute != nil) { + } - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] - ? err.code - : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR - TestStep11aThWritesUserCodeTemporaryDisableTimeAttributeValueAs15SecondsOnTheDutAndVerifyThatTheDutSendsSuccessResponse_18() + CHIP_ERROR TestCleanupTheCreatedUser_11() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - id userCodeTemporaryDisableTimeArgument; - userCodeTemporaryDisableTimeArgument = [NSNumber numberWithUnsignedChar:15U]; - [cluster writeAttributeUserCodeTemporaryDisableTimeWithValue:userCodeTemporaryDisableTimeArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 11a: TH writes UserCodeTemporaryDisableTime attribute " - @"value as 15 Seconds on the DUT and Verify that the DUT sends " - @"Success response Error: %@", - err); + __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; + params.userIndex = [NSNumber numberWithUnsignedShort:1U]; + [cluster clearUserWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Cleanup the created user Error: %@", err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } +}; - CHIP_ERROR - TestStep11bThWritesUserCodeTemporaryDisableTimeAttributeValueAs15SecondsOnTheDutAndVerifyThatTheDutSendsSuccessResponse_19() +class Test_TC_DRLK_2_6 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_DRLK_2_6() + : TestCommandBridge("Test_TC_DRLK_2_6") + , mTestIndex(0) { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id userCodeTemporaryDisableTimeArgument; - userCodeTemporaryDisableTimeArgument = [NSNumber numberWithUnsignedChar:15U]; - [cluster writeAttributeUserCodeTemporaryDisableTimeWithValue:userCodeTemporaryDisableTimeArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 11b: TH writes UserCodeTemporaryDisableTime attribute " - @"value as 15 Seconds on the DUT and Verify that the DUT sends " - @"Success response Error: %@", - err); - - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] - ? err.code - : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - CHIP_ERROR TestStep12aThSendsTheUnlockDoorCommandToTheDutWithInvalidPINCode_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterUnlockDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"1234568" length:7]; - [cluster - unlockDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 12a: TH sends the unlock Door command to the DUT with invalid PINCode Error: %@", err); - - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } + ~Test_TC_DRLK_2_6() {} - CHIP_ERROR TestStep12bThSendsTheUnlockDoorCommandToTheDutWithInvalidPINCode_21() + /////////// TestCommand Interface ///////// + void NextTest() override { + CHIP_ERROR err = CHIP_NO_ERROR; - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_6\n"); + } - __auto_type * params = [[MTRDoorLockClusterUnlockDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"1234568" length:7]; - [cluster - unlockDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 12b: TH sends the unlock Door command to the DUT with invalid PINCode Error: %@", err); + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_6\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; + Wait(); - return CHIP_NO_ERROR; + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for commissionee\n"); + err = TestWaitForCommissionee_0(); + break; + case 1: + ChipLogProgress( + chipTool, " ***** Test Step 1 : Step 1: TH reads NumberOfHoliday SchedulesSupported and saves for future use.\n"); + if (ShouldSkip("DRLK.S.F0b && DRLK.S.A0016")) { + NextTest(); + return; + } + err = TestStep1ThReadsNumberOfHolidaySchedulesSupportedAndSavesForFutureUse_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: Create Holiday schedule with 1 index\n"); + if (ShouldSkip("DRLK.S.F0b && DRLK.S.C11.Rsp")) { + NextTest(); + return; + } + err = TestStep2CreateHolidayScheduleWith1Index_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: Get Holiday Schedule with HolidayIndex as 1\n"); + if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { + NextTest(); + return; + } + err = TestStep3aGetHolidayScheduleWithHolidayIndexAs1_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: Create Holiday schedule with invalid operating mode\n"); + if (ShouldSkip("DRLK.S.C11.Rsp")) { + NextTest(); + return; + } + err = TestStep4CreateHolidayScheduleWithInvalidOperatingMode_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: Get Holiday Schedule with Invalid HolidayIndex 15.\n"); + if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { + NextTest(); + return; + } + err = TestStep5GetHolidayScheduleWithInvalidHolidayIndex15_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: Get Holiday Schedule with the Non-scheduled HolidayIndex\n"); + if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { + NextTest(); + return; + } + err = TestStep6GetHolidayScheduleWithTheNonScheduledHolidayIndex_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: Clear Holiday schedule with 1 index\n"); + if (ShouldSkip("DRLK.S.F0b && DRLK.S.C13.Rsp")) { + NextTest(); + return; + } + err = TestStep7ClearHolidayScheduleWith1Index_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: Make sure that holiday schedule was deleted\n"); + if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { + NextTest(); + return; + } + err = TestStep8MakeSureThatHolidayScheduleWasDeleted_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Cleanup the created user\n"); + err = TestCleanupTheCreatedUser_9(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } } - CHIP_ERROR TestStep12cThSendsTheUnlockDoorCommandToTheDutWithInvalidPINCode_22() + void OnStatusUpdate(const chip::app::StatusIB & status) override { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterUnlockDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"1234568" length:7]; - [cluster - unlockDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 12c: TH sends the unlock Door command to the DUT with invalid PINCode Error: %@", err); - - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); } - CHIP_ERROR TestStep12dThSendsTheUnlockDoorCommandToTheDutWithInvalidPINCode_23() + chip::System::Clock::Timeout GetWaitDuration() const override { + return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); + } - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 10; - __auto_type * params = [[MTRDoorLockClusterUnlockDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"1234568" length:7]; - [cluster - unlockDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 12d: TH sends the unlock Door command to the DUT with invalid PINCode Error: %@", err); + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; + CHIP_ERROR TestWaitForCommissionee_0() + { - return CHIP_NO_ERROR; + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); } + NSNumber * _Nonnull NumberOfHolidaySchedulesSupported; - CHIP_ERROR TestStep13ThReadsTheUserCodeTemporaryDisableTimeAttributeFromTheDutAndCheckAttributeIsTriggered_24() + CHIP_ERROR TestStep1ThReadsNumberOfHolidaySchedulesSupportedAndSavesForFutureUse_1() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - [cluster readAttributeUserCodeTemporaryDisableTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 13: TH reads the UserCodeTemporaryDisableTime attribute from the DUT and check attribute is triggered " - @"Error: %@", - err); + [cluster readAttributeNumberOfHolidaySchedulesSupportedWithCompletion:^( + NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 1: TH reads NumberOfHoliday SchedulesSupported and saves for future use. Error: %@", err); VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckConstraintMinValue("numberOfHolidaySchedulesSupported", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("numberOfHolidaySchedulesSupported", [value unsignedCharValue], 255U)); { - id actualValue = value; - VerifyOrReturn(CheckValue("UserCodeTemporaryDisableTime", actualValue, 15U)); + NumberOfHolidaySchedulesSupported = value; } NextTest(); @@ -170267,248 +169512,228 @@ class Test_TC_DRLK_2_3 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestStep14ThSendsTheUnlockDoorCommandToTheDutWithValidPINCode_25() + CHIP_ERROR TestStep2CreateHolidayScheduleWith1Index_2() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterUnlockDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"123456" length:6]; - [cluster - unlockDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 14: TH sends the unlock Door command to the DUT with valid PINCode Error: %@", err); - - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; + __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; + params.holidayIndex = [NSNumber numberWithUnsignedChar:1U]; + params.localStartTime = [NSNumber numberWithUnsignedInt:20UL]; + params.localEndTime = [NSNumber numberWithUnsignedInt:30UL]; + params.operatingMode = [NSNumber numberWithUnsignedChar:0U]; + [cluster setHolidayScheduleWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 2: Create Holiday schedule with 1 index Error: %@", err); - return CHIP_NO_ERROR; - } + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - CHIP_ERROR TestWaitForUserCodeTemporaryDisableTimeExpires_26() - { + NextTest(); + }]; - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 15000UL; - return WaitForMs("alpha", value); + return CHIP_NO_ERROR; } - CHIP_ERROR TestStep15aThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_27() + CHIP_ERROR TestStep3aGetHolidayScheduleWithHolidayIndexAs1_3() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - id autoRelockTimeArgument; - autoRelockTimeArgument = [NSNumber numberWithUnsignedInt:10UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 15a: TH writes AutoRelockTime attribute value as 10 seconds on the " - @"DUT Error: %@", - err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15bThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_28() - { + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = [NSNumber numberWithUnsignedChar:1U]; + [cluster getHolidayScheduleWithParams:params + completion:^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Step 3a: Get Holiday Schedule with HolidayIndex as 1 Error: %@", err); - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - id autoRelockTimeArgument; - autoRelockTimeArgument = [NSNumber numberWithUnsignedInt:60UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 15b: TH writes AutoRelockTime attribute value as 60 seconds on the " - @"DUT Error: %@", - err); + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); + } - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } - NextTest(); - }]; + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 20UL)); + } - return CHIP_NO_ERROR; - } + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 30UL)); + } - CHIP_ERROR TestStep15cThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_29() - { + if (values.localEndTime != nil) { - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturn(CheckConstraintMinValue( + "localEndTime", [values.localEndTime unsignedIntValue], 21UL)); + } - id autoRelockTimeArgument; - autoRelockTimeArgument = [NSNumber numberWithUnsignedInt:10UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 15c: TH writes AutoRelockTime attribute value as 10 seconds on the " - @"DUT Error: %@", - err); + { + id actualValue = values.operatingMode; + VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); + } - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] - ? err.code - : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep15dThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_30() + CHIP_ERROR TestStep4CreateHolidayScheduleWithInvalidOperatingMode_4() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - id autoRelockTimeArgument; - autoRelockTimeArgument = [NSNumber numberWithUnsignedInt:60UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 15d: TH writes AutoRelockTime attribute value as 60 seconds on the " - @"DUT Error: %@", - err); + __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; + params.holidayIndex = [NSNumber numberWithUnsignedChar:1U]; + params.localStartTime = [NSNumber numberWithUnsignedInt:20UL]; + params.localEndTime = [NSNumber numberWithUnsignedInt:30UL]; + params.operatingMode = [NSNumber numberWithUnsignedChar:5U]; + [cluster setHolidayScheduleWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 4: Create Holiday schedule with invalid operating mode Error: %@", err); - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] - ? err.code - : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; + VerifyOrReturn(CheckValue("status", + err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code + : EMBER_ZCL_STATUS_FAILURE) + : 0, + EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep16aThReadsTheAutoRelockTimeAttributeFromTheDut_31() + CHIP_ERROR TestStep5GetHolidayScheduleWithInvalidHolidayIndex15_5() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - [cluster readAttributeAutoRelockTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 16a: TH reads the AutoRelockTime attribute from the DUT Error: %@", err); + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = [NSNumber numberWithUnsignedChar:15U]; + [cluster getHolidayScheduleWithParams:params + completion:^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Step 5: Get Holiday Schedule with Invalid HolidayIndex 15. Error: %@", err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - { - id actualValue = value; - VerifyOrReturn(CheckValue("AutoRelockTime", actualValue, 10UL)); - } + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 15U)); + } - NextTest(); - }]; + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep16bThReadsTheAutoRelockTimeAttributeFromTheDut_32() + CHIP_ERROR TestStep6GetHolidayScheduleWithTheNonScheduledHolidayIndex_6() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - [cluster readAttributeAutoRelockTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 16b: TH reads the AutoRelockTime attribute from the DUT Error: %@", err); + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = [NSNumber numberWithUnsignedChar:10U]; + [cluster getHolidayScheduleWithParams:params + completion:^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Step 6: Get Holiday Schedule with the Non-scheduled HolidayIndex Error: %@", err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - { - id actualValue = value; - VerifyOrReturn(CheckValue("AutoRelockTime", actualValue, 60UL)); - } + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 10U)); + } - NextTest(); - }]; + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep17ThSendsTheUnlockDoorCommandToTheDutWithValidPINCodeAndVerifyThatDutSendsSuccessResponseToTheTh_33() + CHIP_ERROR TestStep7ClearHolidayScheduleWith1Index_7() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterUnlockDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"123456" length:6]; - [cluster unlockDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 17: TH sends the unlock Door command to the DUT with valid PINCode and Verify that DUT " - @"sends SUCCESS response to the TH Error: %@", - err); + __auto_type * params = [[MTRDoorLockClusterClearHolidayScheduleParams alloc] init]; + params.holidayIndex = [NSNumber numberWithUnsignedChar:1U]; + [cluster clearHolidayScheduleWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 7: Clear Holiday schedule with 1 index Error: %@", err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestWaitForAutoRelockTimeExpires_34() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestWaitForAutoRelockTimeExpires_35() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 60000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep18ThReadsLockStateAttribute_36() + CHIP_ERROR TestStep8MakeSureThatHolidayScheduleWasDeleted_8() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - [cluster readAttributeLockStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 18: TH reads LockState attribute Error: %@", err); + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = [NSNumber numberWithUnsignedChar:1U]; + [cluster getHolidayScheduleWithParams:params + completion:^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Step 8: Make sure that holiday schedule was deleted Error: %@", err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LockState", actualValue)); - VerifyOrReturn(CheckValue("LockState", actualValue, 1U)); - } + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); + } - NextTest(); - }]; + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestCleanupTheCreatedUser_37() + CHIP_ERROR TestCleanupTheCreatedUser_9() { MTRBaseDevice * device = GetDevice("alpha"); @@ -170528,37 +169753,13 @@ class Test_TC_DRLK_2_3 : public TestCommandBridge { return CHIP_NO_ERROR; } - - CHIP_ERROR TestCleanTheCreatedCredential_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Clean the created credential Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } }; -class Test_TC_DRLK_2_4 : public TestCommandBridge { +class Test_TC_DRLK_2_7 : public TestCommandBridge { public: // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_4() - : TestCommandBridge("Test_TC_DRLK_2_4") + Test_TC_DRLK_2_7() + : TestCommandBridge("Test_TC_DRLK_2_7") , mTestIndex(0) { AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); @@ -170568,7 +169769,7 @@ class Test_TC_DRLK_2_4 : public TestCommandBridge { } // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - ~Test_TC_DRLK_2_4() {} + ~Test_TC_DRLK_2_7() {} /////////// TestCommand Interface ///////// void NextTest() override @@ -170576,11 +169777,11 @@ class Test_TC_DRLK_2_4 : public TestCommandBridge { CHIP_ERROR err = CHIP_NO_ERROR; if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_4\n"); + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_7\n"); } if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_4\n"); + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_7\n"); SetCommandExitStatus(CHIP_NO_ERROR); return; } @@ -170597,110 +169798,129 @@ class Test_TC_DRLK_2_4 : public TestCommandBridge { err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); break; case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Create new user\n"); - err = TestCreateNewUser_1(); + ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Create new user\n"); + err = TestPreconditionCreateNewUser_1(); break; case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read the user back and verify its fields\n"); - err = TestReadTheUserBackAndVerifyItsFields_2(); + ChipLogProgress(chipTool, " ***** Test Step 2 : Precondition: Read the user back and verify its fields\n"); + err = TestPreconditionReadTheUserBackAndVerifyItsFields_2(); break; case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Create new PIN credential and lock/unlock user\n"); - err = TestCreateNewPinCredentialAndLockUnlockUser_3(); + ChipLogProgress( + chipTool, " ***** Test Step 3 : Step 1: TH reads NumberOfYearDay SchedulesSupportedPerUser attribute\n"); + if (ShouldSkip("DRLK.S.F0a && DRLK.S.A0015")) { + NextTest(); + return; + } + err = TestStep1ThReadsNumberOfYearDaySchedulesSupportedPerUserAttribute_3(); break; case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Verify created PIN credential\n"); - err = TestVerifyCreatedPinCredential_4(); + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2: TH reads NumberOfTotalUsers Supported attribute\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { + NextTest(); + return; + } + err = TestStep2ThReadsNumberOfTotalUsersSupportedAttribute_4(); break; case 5: - ChipLogProgress( - chipTool, " ***** Test Step 5 : Step 1a: TH writes AutoRelockTime attribute value as 10 seconds on the DUT\n"); - if (ShouldSkip("DRLK.S.A0023.Write && PICS_SDK_CI_ONLY")) { + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH sends Set Year Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0e.Rsp")) { NextTest(); return; } - err = TestStep1aThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_5(); + err = TestStep3ThSendsSetYearDayScheduleCommandToDut_5(); break; case 6: - ChipLogProgress( - chipTool, " ***** Test Step 6 : Step 1b: TH writes AutoRelockTime attribute value as 60 seconds on the DUT\n"); - if (ShouldSkip("DRLK.S.A0023.Write && PICS_SKIP_SAMPLE_APP")) { + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a & 4b: TH sends Get Year Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { NextTest(); return; } - err = TestStep1bThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_6(); + err = TestStep4a4bThSendsGetYearDayScheduleCommandToDut_6(); break; case 7: - ChipLogProgress( - chipTool, " ***** Test Step 7 : Step 1c: TH writes AutoRelockTime attribute value as 10 seconds on the DUT\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY && !DRLK.S.A0023.Write")) { + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH send Set Year Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.C0e.Rsp")) { NextTest(); return; } - err = TestStep1cThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_7(); + err = TestStep5ThSendSetYearDayScheduleCommandToDut_7(); break; case 8: - ChipLogProgress( - chipTool, " ***** Test Step 8 : Step 1d: TH writes AutoRelockTime attribute value as 60 seconds on the DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && !DRLK.S.A0023.Write")) { + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH sends Get Year Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { NextTest(); return; } - err = TestStep1dThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_8(); + err = TestStep6ThSendsGetYearDayScheduleCommandToDut_8(); break; case 9: - ChipLogProgress( - chipTool, " ***** Test Step 9 : Step 2a: TH sends the Unlock with Timeout argument value as 10 seconds\n"); - if (ShouldSkip("DRLK.S.C03.Rsp && PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep2aThSendsTheUnlockWithTimeoutArgumentValueAs10Seconds_9(); + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7a: Create a user with userIndex as 5\n"); + err = TestStep7aCreateAUserWithUserIndexAs5_9(); break; case 10: - ChipLogProgress( - chipTool, " ***** Test Step 10 : Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds\n"); - if (ShouldSkip("DRLK.S.C03.Rsp && PICS_SKIP_SAMPLE_APP")) { + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7b: TH sends Get Year Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { NextTest(); return; } - err = TestStep2bThSendsTheUnlockWithTimeoutArgumentValueAs60Seconds_10(); + err = TestStep7bThSendsGetYearDayScheduleCommandToDut_10(); break; case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Wait for AutoRelockTime Expires\n"); - if (ShouldSkip("DRLK.S.C03.Rsp && PICS_SDK_CI_ONLY")) { + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 8: TH sends Clear Year Day Schedule to DUT\n"); + if (ShouldSkip("DRLK.S.C10.Rsp")) { NextTest(); return; } - err = TestWaitForAutoRelockTimeExpires_11(); + err = TestStep8ThSendsClearYearDayScheduleToDut_11(); break; case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait for AutoRelockTime Expires\n"); - if (ShouldSkip("DRLK.S.C03.Rsp && PICS_SKIP_SAMPLE_APP")) { + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 9: TH sends Get Year Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx && DRLK.S.C10.Rsp")) { NextTest(); return; } - err = TestWaitForAutoRelockTimeExpires_12(); + err = TestStep9ThSendsGetYearDayScheduleCommandToDut_12(); break; case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2c: TH reads LockState attribute\n"); - if (ShouldSkip("DRLK.S.A0000 && DRLK.S.C03.Rsp")) { + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 10: TH sends Set Year Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.C0e.Rsp")) { NextTest(); return; } - err = TestStep2cThReadsLockStateAttribute_13(); + err = TestStep10ThSendsSetYearDayScheduleCommandToDut_13(); break; case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Cleanup the created user\n"); - err = TestCleanupTheCreatedUser_14(); + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 11: TH sends Get Year Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { + NextTest(); + return; + } + err = TestStep11ThSendsGetYearDayScheduleCommandToDut_14(); break; case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Clean the created credential\n"); - if (ShouldSkip("DRLK.S.C26.Rsp")) { + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 12: TH sends Clear Year Day Schedule to DUT\n"); + if (ShouldSkip("DRLK.S.F0a && DRLK.S.C10.Rsp")) { NextTest(); return; } - err = TestCleanTheCreatedCredential_15(); + err = TestStep12ThSendsClearYearDayScheduleToDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Clear a year day schedule for the first user\n"); + if (ShouldSkip("DRLK.S.F0a && DRLK.S.C10.Rsp")) { + NextTest(); + return; + } + err = TestClearAYearDayScheduleForTheFirstUser_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Cleanup the created user with UserIndex 1\n"); + err = TestCleanupTheCreatedUserWithUserIndex1_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Cleanup the created user with UserIndex 5\n"); + err = TestCleanupTheCreatedUserWithUserIndex5_18(); break; } @@ -170735,10 +169955,10 @@ class Test_TC_DRLK_2_4 : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); break; case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 9: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); @@ -170759,6 +169979,15 @@ class Test_TC_DRLK_2_4 : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; } @@ -170774,7 +170003,7 @@ class Test_TC_DRLK_2_4 : public TestCommandBridge { private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 16; + const uint16_t mTestCount = 19; chip::Optional mNodeId; chip::Optional mCluster; @@ -170789,7 +170018,7 @@ class Test_TC_DRLK_2_4 : public TestCommandBridge { return WaitForCommissionee("alpha", value); } - CHIP_ERROR TestCreateNewUser_1() + CHIP_ERROR TestPreconditionCreateNewUser_1() { MTRBaseDevice * device = GetDevice("alpha"); @@ -170806,7 +170035,7 @@ class Test_TC_DRLK_2_4 : public TestCommandBridge { params.credentialRule = [NSNumber numberWithUnsignedChar:0U]; [cluster setUserWithParams:params completion:^(NSError * _Nullable err) { - NSLog(@"Create new user Error: %@", err); + NSLog(@"Precondition: Create new user Error: %@", err); VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); @@ -170816,7 +170045,7 @@ class Test_TC_DRLK_2_4 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestReadTheUserBackAndVerifyItsFields_2() + CHIP_ERROR TestPreconditionReadTheUserBackAndVerifyItsFields_2() { MTRBaseDevice * device = GetDevice("alpha"); @@ -170827,7 +170056,7 @@ class Test_TC_DRLK_2_4 : public TestCommandBridge { params.userIndex = [NSNumber numberWithUnsignedShort:1U]; [cluster getUserWithParams:params completion:^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - NSLog(@"Read the user back and verify its fields Error: %@", err); + NSLog(@"Precondition: Read the user back and verify its fields Error: %@", err); VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); @@ -170894,293 +170123,480 @@ class Test_TC_DRLK_2_4 : public TestCommandBridge { return CHIP_NO_ERROR; } + NSNumber * _Nonnull NumberOfYearDaySchedulesSupportedPerUser; - CHIP_ERROR TestCreateNewPinCredentialAndLockUnlockUser_3() + CHIP_ERROR TestStep1ThReadsNumberOfYearDaySchedulesSupportedPerUserAttribute_3() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster - setCredentialWithParams:params - completion:^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - NSLog(@"Create new PIN credential and lock/unlock user Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } + [cluster readAttributeNumberOfYearDaySchedulesSupportedPerUserWithCompletion:^( + NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 1: TH reads NumberOfYearDay SchedulesSupportedPerUser attribute Error: %@", err); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } + VerifyOrReturn( + CheckConstraintMinValue("numberOfYearDaySchedulesSupportedPerUser", [value unsignedCharValue], 0U)); + VerifyOrReturn( + CheckConstraintMaxValue("numberOfYearDaySchedulesSupportedPerUser", [value unsignedCharValue], 255U)); + { + NumberOfYearDaySchedulesSupportedPerUser = value; + } - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } + NSNumber * _Nonnull NumberOfTotalUsersSupported; - CHIP_ERROR TestVerifyCreatedPinCredential_4() + CHIP_ERROR TestStep2ThReadsNumberOfTotalUsersSupportedAttribute_4() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params - completion:^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Verify created PIN credential Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } + [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 2: TH reads NumberOfTotalUsers Supported attribute Error: %@", err); - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } + VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65534U)); + { + NumberOfTotalUsersSupported = value; + } - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep1aThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_5() + CHIP_ERROR TestStep3ThSendsSetYearDayScheduleCommandToDut_5() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - id autoRelockTimeArgument; - autoRelockTimeArgument = [NSNumber numberWithUnsignedInt:10UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 1a: TH writes AutoRelockTime attribute value as 10 seconds on the DUT " - @"Error: %@", - err); + __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; + params.yearDayIndex = [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = [NSNumber numberWithUnsignedShort:1U]; + params.localStartTime = [NSNumber numberWithUnsignedInt:960UL]; + params.localEndTime = [NSNumber numberWithUnsignedInt:1980UL]; + [cluster setYearDayScheduleWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 3: TH sends Set Year Day Schedule Command to DUT Error: %@", err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep1bThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_6() + CHIP_ERROR TestStep4a4bThSendsGetYearDayScheduleCommandToDut_6() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - id autoRelockTimeArgument; - autoRelockTimeArgument = [NSNumber numberWithUnsignedInt:60UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 1b: TH writes AutoRelockTime attribute value as 60 seconds on the DUT " - @"Error: %@", - err); + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params + completion:^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Step 4a & 4b: TH sends Get Year Day Schedule Command to DUT Error: %@", err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - NextTest(); - }]; + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 960UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 1980UL)); + } + + if (values.localEndTime != nil) { + + VerifyOrReturn(CheckConstraintMinValue( + "localEndTime", [values.localEndTime unsignedIntValue], 961UL)); + } + + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep1cThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_7() + CHIP_ERROR TestStep5ThSendSetYearDayScheduleCommandToDut_7() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - id autoRelockTimeArgument; - autoRelockTimeArgument = [NSNumber numberWithUnsignedInt:10UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 1c: TH writes AutoRelockTime attribute value as 10 seconds on the DUT " - @"Error: %@", - err); - - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] - ? err.code - : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; + __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; + params.yearDayIndex = [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = [NSNumber numberWithUnsignedShort:15U]; + params.localStartTime = [NSNumber numberWithUnsignedInt:1020UL]; + params.localEndTime = [NSNumber numberWithUnsignedInt:2040UL]; + [cluster setYearDayScheduleWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 5: TH send Set Year Day Schedule Command to DUT Error: %@", err); + + VerifyOrReturn(CheckValue("status", + err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code + : EMBER_ZCL_STATUS_FAILURE) + : 0, + EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep1dThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_8() + CHIP_ERROR TestStep6ThSendsGetYearDayScheduleCommandToDut_8() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - id autoRelockTimeArgument; - autoRelockTimeArgument = [NSNumber numberWithUnsignedInt:60UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 1d: TH writes AutoRelockTime attribute value as 60 seconds on the DUT " - @"Error: %@", - err); + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = [NSNumber numberWithUnsignedShort:15U]; + [cluster getYearDayScheduleWithParams:params + completion:^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Step 6: TH sends Get Year Day Schedule Command to DUT Error: %@", err); - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] - ? err.code - : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 15U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + VerifyOrReturn(CheckConstraintHasValue("localStartTime", values.localStartTime, false)); + if (values.localStartTime != nil) { + } + + VerifyOrReturn(CheckConstraintHasValue("localEndTime", values.localEndTime, false)); + if (values.localEndTime != nil) { + } + + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep2aThSendsTheUnlockWithTimeoutArgumentValueAs10Seconds_9() + CHIP_ERROR TestStep7aCreateAUserWithUserIndexAs5_9() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterUnlockWithTimeoutParams alloc] init]; - params.timeout = [NSNumber numberWithUnsignedShort:10U]; - params.pinCode = [[NSData alloc] initWithBytes:"123456" length:6]; - [cluster - unlockWithTimeoutWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 2a: TH sends the Unlock with Timeout argument value as 10 seconds Error: %@", err); + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = [NSNumber numberWithUnsignedShort:5U]; + params.userName = @"xxx"; + params.userUniqueID = [NSNumber numberWithUnsignedInt:6452UL]; + params.userStatus = [NSNumber numberWithUnsignedChar:1U]; + params.userType = [NSNumber numberWithUnsignedChar:0U]; + params.credentialRule = [NSNumber numberWithUnsignedChar:0U]; + [cluster setUserWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 7a: Create a user with userIndex as 5 Error: %@", err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep2bThSendsTheUnlockWithTimeoutArgumentValueAs60Seconds_10() + CHIP_ERROR TestStep7bThSendsGetYearDayScheduleCommandToDut_10() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterUnlockWithTimeoutParams alloc] init]; - params.timeout = [NSNumber numberWithUnsignedShort:60U]; - params.pinCode = [[NSData alloc] initWithBytes:"123456" length:6]; - [cluster - unlockWithTimeoutWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds Error: %@", err); + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = [NumberOfYearDaySchedulesSupportedPerUser copy]; + params.userIndex = [NSNumber numberWithUnsignedShort:5U]; + [cluster getYearDayScheduleWithParams:params + completion:^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Step 7b: TH sends Get Year Day Schedule Command to DUT Error: %@", err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - NextTest(); - }]; + { + id actualValue = values.yearDayIndex; + VerifyOrReturn( + CheckValue("YearDayIndex", actualValue, NumberOfYearDaySchedulesSupportedPerUser)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 5U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + VerifyOrReturn(CheckConstraintHasValue("localStartTime", values.localStartTime, false)); + if (values.localStartTime != nil) { + } + + VerifyOrReturn(CheckConstraintHasValue("localEndTime", values.localEndTime, false)); + if (values.localEndTime != nil) { + } + + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestWaitForAutoRelockTimeExpires_11() + CHIP_ERROR TestStep8ThSendsClearYearDayScheduleToDut_11() { - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 11000UL; - return WaitForMs("alpha", value); + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; + params.yearDayIndex = [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = [NSNumber numberWithUnsignedShort:1U]; + [cluster clearYearDayScheduleWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 8: TH sends Clear Year Day Schedule to DUT Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; } - CHIP_ERROR TestWaitForAutoRelockTimeExpires_12() + CHIP_ERROR TestStep9ThSendsGetYearDayScheduleCommandToDut_12() { - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 70000UL; - return WaitForMs("alpha", value); + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params + completion:^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Step 9: TH sends Get Year Day Schedule Command to DUT Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + VerifyOrReturn(CheckConstraintHasValue("localStartTime", values.localStartTime, false)); + if (values.localStartTime != nil) { + } + + VerifyOrReturn(CheckConstraintHasValue("localEndTime", values.localEndTime, false)); + if (values.localEndTime != nil) { + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; } - CHIP_ERROR TestStep2cThReadsLockStateAttribute_13() + CHIP_ERROR TestStep10ThSendsSetYearDayScheduleCommandToDut_13() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - [cluster readAttributeLockStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 2c: TH reads LockState attribute Error: %@", err); + __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; + params.yearDayIndex = [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = [NSNumber numberWithUnsignedShort:1U]; + params.localStartTime = [NSNumber numberWithUnsignedInt:1080UL]; + params.localEndTime = [NSNumber numberWithUnsignedInt:2100UL]; + [cluster setYearDayScheduleWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 10: TH sends Set Year Day Schedule Command to DUT Error: %@", err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LockState", actualValue)); - VerifyOrReturn(CheckValue("LockState", actualValue, 1U)); - } + NextTest(); + }]; - NextTest(); - }]; + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThSendsGetYearDayScheduleCommandToDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params + completion:^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Step 11: TH sends Get Year Day Schedule Command to DUT Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 1080UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 2100UL)); + } + + if (values.localEndTime != nil) { + + VerifyOrReturn(CheckConstraintMinValue( + "localEndTime", [values.localEndTime unsignedIntValue], 1081UL)); + } + + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestCleanupTheCreatedUser_14() + CHIP_ERROR TestStep12ThSendsClearYearDayScheduleToDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; + params.yearDayIndex = [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = [NSNumber numberWithUnsignedShort:0U]; + [cluster + clearYearDayScheduleWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 12: TH sends Clear Year Day Schedule to DUT Error: %@", err); + + VerifyOrReturn(CheckValue("status", + err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code + : EMBER_ZCL_STATUS_FAILURE) + : 0, + EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearAYearDayScheduleForTheFirstUser_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; + params.yearDayIndex = [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = [NSNumber numberWithUnsignedShort:1U]; + [cluster clearYearDayScheduleWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Clear a year day schedule for the first user Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCleanupTheCreatedUserWithUserIndex1_17() { MTRBaseDevice * device = GetDevice("alpha"); @@ -171191,7 +170607,7 @@ class Test_TC_DRLK_2_4 : public TestCommandBridge { params.userIndex = [NSNumber numberWithUnsignedShort:1U]; [cluster clearUserWithParams:params completion:^(NSError * _Nullable err) { - NSLog(@"Cleanup the created user Error: %@", err); + NSLog(@"Cleanup the created user with UserIndex 1 Error: %@", err); VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); @@ -171201,36 +170617,33 @@ class Test_TC_DRLK_2_4 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestCleanTheCreatedCredential_15() + CHIP_ERROR TestCleanupTheCreatedUserWithUserIndex5_18() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Clean the created credential Error: %@", err); + __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; + params.userIndex = [NSNumber numberWithUnsignedShort:5U]; + [cluster clearUserWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Cleanup the created user with UserIndex 5 Error: %@", err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } }; -class Test_TC_DRLK_2_5 : public TestCommandBridge { +class Test_TC_DRLK_2_8 : public TestCommandBridge { public: // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_5() - : TestCommandBridge("Test_TC_DRLK_2_5") + Test_TC_DRLK_2_8() + : TestCommandBridge("Test_TC_DRLK_2_8") , mTestIndex(0) { AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); @@ -171240,7 +170653,7 @@ class Test_TC_DRLK_2_5 : public TestCommandBridge { } // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - ~Test_TC_DRLK_2_5() {} + ~Test_TC_DRLK_2_8() {} /////////// TestCommand Interface ///////// void NextTest() override @@ -171248,11 +170661,11 @@ class Test_TC_DRLK_2_5 : public TestCommandBridge { CHIP_ERROR err = CHIP_NO_ERROR; if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_5\n"); + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_8\n"); } if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_5\n"); + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_8\n"); SetCommandExitStatus(CHIP_NO_ERROR); return; } @@ -171269,81 +170682,125 @@ class Test_TC_DRLK_2_5 : public TestCommandBridge { err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); break; case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Create new user\n"); - err = TestPreconditionCreateNewUser_1(); + ChipLogProgress(chipTool, + " ***** Test Step 1 : Step 1: TH reads NumberOfTotalUsers Supported attribute and saves for future use.\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { + NextTest(); + return; + } + err = TestStep1ThReadsNumberOfTotalUsersSupportedAttributeAndSavesForFutureUse_1(); break; case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Precondition: Read the user back and verify its fields\n"); - err = TestPreconditionReadTheUserBackAndVerifyItsFields_2(); + ChipLogProgress(chipTool, + " ***** Test Step 2 : Step 2: TH sends Set User Command to DUT with the following values: OperationType as 0 " + "UserIndex as 1 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 0 CredentialRule as 0\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { + NextTest(); + return; + } + err = TestStep2ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs0CredentialRuleAs0_2(); break; case 3: - ChipLogProgress( - chipTool, " ***** Test Step 3 : Step 1: TH reads NumberOfWeekDay SchedulesSupportedPerUser attribute\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.A0014")) { + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH sends Get User Command to DUT with UserIndex as 1\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { NextTest(); return; } - err = TestStep1ThReadsNumberOfWeekDaySchedulesSupportedPerUserAttribute_3(); + err = TestStep3ThSendsGetUserCommandToDutWithUserIndexAs1_3(); break; case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2: TH reads NumberOfTotalUsers Supported attribute\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { + ChipLogProgress(chipTool, + " ***** Test Step 4 : Step 4: TH sends Set User Command to DUT with the following values: OperationType as 0 " + "UserIndex as 2 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 10 (Invalid value) CredentialRule " + "as 3\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { NextTest(); return; } - err = TestStep2ThReadsNumberOfTotalUsersSupportedAttribute_4(); + err = TestStep4ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs10InvalidValueCredentialRuleAs3_4(); break; case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH send Set Week Day Schedule Command\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0b.Rsp")) { + ChipLogProgress(chipTool, + " ***** Test Step 5 : Step 5: TH sends Set User Command to DUT with the following values: OperationType as 0 " + "UserIndex as 1 (Same as step 2) UserName as xxx UserUniqueID as 8965 UserStatus as 1 UserType as 0 CredentialRule " + "as 0\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { NextTest(); return; } - err = TestStep3ThSendSetWeekDayScheduleCommand_5(); + err = TestStep5ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1SameAsStep2UserNameAsXxxUserUniqueIDAs8965UserStatusAs1UserTypeAs0CredentialRuleAs0_5(); break; case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH send Get Week Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx")) { + ChipLogProgress(chipTool, + " ***** Test Step 6 : Step 6a: TH sends Set User Command to DUT with the following values: OperationType as 0 " + "UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as " + "NULL\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { NextTest(); return; } - err = TestStep4ThSendGetWeekDayScheduleCommandToDut_6(); + err = TestStep6aThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_6(); break; case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH send Set Week Day Schedule Command\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0b.Rsp")) { + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6b: TH sends Get User Command to DUT with UserIndex as 2\n"); + if (ShouldSkip("DRLK.S.C1a.Rsp && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { NextTest(); return; } - err = TestStep5ThSendSetWeekDayScheduleCommand_7(); + err = TestStep6bThSendsGetUserCommandToDutWithUserIndexAs2_7(); break; case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH send Get Week Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx")) { + ChipLogProgress(chipTool, + " ***** Test Step 8 : Step 7: TH sends Set User Command to DUT with the following values: OperationType as 2 " + "UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as " + "NULL\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { NextTest(); return; } - err = TestStep6ThSendGetWeekDayScheduleCommandToDut_8(); + err = TestStep7ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs2UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_8(); break; case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH sends Clear Week Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0d.Rsp")) { + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 8: TH sends Get User Command to DUT with the UserIndex as 2\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { NextTest(); return; } - err = TestStep7ThSendsClearWeekDayScheduleCommandToDut_9(); + err = TestStep8ThSendsGetUserCommandToDutWithTheUserIndexAs2_9(); break; case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 8: TH sends Get Week Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx")) { + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 9: TH sends Clear User Command to DUT with the UserIndex as 1\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1d.Rsp")) { NextTest(); return; } - err = TestStep8ThSendsGetWeekDayScheduleCommandToDut_10(); + err = TestStep9ThSendsClearUserCommandToDutWithTheUserIndexAs1_10(); break; case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Cleanup the created user\n"); - err = TestCleanupTheCreatedUser_11(); + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 10: TH sends Get User Command to DUT with the UserIndex as 1\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { + NextTest(); + return; + } + err = TestStep10ThSendsGetUserCommandToDutWithTheUserIndexAs1_11(); + break; + case 12: + ChipLogProgress( + chipTool, " ***** Test Step 12 : Test cleanup: TH sends Clear User Command to DUT with the UserIndex as 2\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1d.Rsp")) { + NextTest(); + return; + } + err = TestTestCleanupThSendsClearUserCommandToDutWithTheUserIndexAs2_12(); + break; + case 13: + ChipLogProgress( + chipTool, " ***** Test Step 13 : Test cleanup: TH sends Get User Command to DUT with the UserIndex as 2\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { + NextTest(); + return; + } + err = TestTestCleanupThSendsGetUserCommandToDutWithTheUserIndexAs2_13(); break; } @@ -171369,16 +170826,18 @@ class Test_TC_DRLK_2_5 : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); break; case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("clusterStatus present", status.mClusterStatus.HasValue(), true)); + VerifyOrReturn(CheckValue("clusterStatus value", status.mClusterStatus.Value(), 3)); break; case 6: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 8: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); @@ -171392,6 +170851,12 @@ class Test_TC_DRLK_2_5 : public TestCommandBridge { case 11: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; } // Go on to the next test. @@ -171405,7 +170870,7 @@ class Test_TC_DRLK_2_5 : public TestCommandBridge { private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; + const uint16_t mTestCount = 14; chip::Optional mNodeId; chip::Optional mCluster; @@ -171419,8 +170884,34 @@ class Test_TC_DRLK_2_5 : public TestCommandBridge { value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; return WaitForCommissionee("alpha", value); } + NSNumber * _Nonnull Current_NumberOfTotalUsersSupported; - CHIP_ERROR TestPreconditionCreateNewUser_1() + CHIP_ERROR TestStep1ThReadsNumberOfTotalUsersSupportedAttributeAndSavesForFutureUse_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 1: TH reads NumberOfTotalUsers Supported attribute and saves for future use. Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65534U)); + { + Current_NumberOfTotalUsersSupported = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR + TestStep2ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs0CredentialRuleAs0_2() { MTRBaseDevice * device = GetDevice("alpha"); @@ -171435,19 +170926,22 @@ class Test_TC_DRLK_2_5 : public TestCommandBridge { params.userStatus = [NSNumber numberWithUnsignedChar:1U]; params.userType = [NSNumber numberWithUnsignedChar:0U]; params.credentialRule = [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Precondition: Create new user Error: %@", err); + [cluster + setUserWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 2: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as " + @"1 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 0 CredentialRule as 0 Error: %@", + err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestPreconditionReadTheUserBackAndVerifyItsFields_2() + CHIP_ERROR TestStep3ThSendsGetUserCommandToDutWithUserIndexAs1_3() { MTRBaseDevice * device = GetDevice("alpha"); @@ -171458,7 +170952,7 @@ class Test_TC_DRLK_2_5 : public TestCommandBridge { params.userIndex = [NSNumber numberWithUnsignedShort:1U]; [cluster getUserWithParams:params completion:^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - NSLog(@"Precondition: Read the user back and verify its fields Error: %@", err); + NSLog(@"Step 3: TH sends Get User Command to DUT with UserIndex as 1 Error: %@", err); VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); @@ -171525,324 +171019,385 @@ class Test_TC_DRLK_2_5 : public TestCommandBridge { return CHIP_NO_ERROR; } - NSNumber * _Nonnull NumberOfWeekDaySchedulesSupportedPerUser; - CHIP_ERROR TestStep1ThReadsNumberOfWeekDaySchedulesSupportedPerUserAttribute_3() + CHIP_ERROR + TestStep4ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs10InvalidValueCredentialRuleAs3_4() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - [cluster readAttributeNumberOfWeekDaySchedulesSupportedPerUserWithCompletion:^( - NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 1: TH reads NumberOfWeekDay SchedulesSupportedPerUser attribute Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn( - CheckConstraintMinValue("numberOfWeekDaySchedulesSupportedPerUser", [value unsignedCharValue], 0U)); - VerifyOrReturn( - CheckConstraintMaxValue("numberOfWeekDaySchedulesSupportedPerUser", [value unsignedCharValue], 255U)); - { - NumberOfWeekDaySchedulesSupportedPerUser = value; - } + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = [NSNumber numberWithUnsignedShort:2U]; + params.userName = @"xxx"; + params.userUniqueID = [NSNumber numberWithUnsignedInt:6452UL]; + params.userStatus = [NSNumber numberWithUnsignedChar:1U]; + params.userType = [NSNumber numberWithUnsignedChar:10U]; + params.credentialRule = [NSNumber numberWithUnsignedChar:3U]; + [cluster + setUserWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 4: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as " + @"2 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 10 (Invalid value) " + @"CredentialRule as 3 Error: %@", + err); - NextTest(); - }]; + VerifyOrReturn(CheckValue("status", + err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, + EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; return CHIP_NO_ERROR; } - NSNumber * _Nonnull NumberOfTotalUsersSupported; - CHIP_ERROR TestStep2ThReadsNumberOfTotalUsersSupportedAttribute_4() + CHIP_ERROR + TestStep5ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1SameAsStep2UserNameAsXxxUserUniqueIDAs8965UserStatusAs1UserTypeAs0CredentialRuleAs0_5() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 2: TH reads NumberOfTotalUsers Supported attribute Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65534U)); - { - NumberOfTotalUsersSupported = value; - } + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = [NSNumber numberWithUnsignedShort:1U]; + params.userName = @"xxx"; + params.userUniqueID = [NSNumber numberWithUnsignedInt:8965UL]; + params.userStatus = [NSNumber numberWithUnsignedChar:1U]; + params.userType = [NSNumber numberWithUnsignedChar:0U]; + params.credentialRule = [NSNumber numberWithUnsignedChar:0U]; + [cluster + setUserWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 5: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as " + @"1 (Same as step 2) UserName as xxx UserUniqueID as 8965 UserStatus as 1 UserType as 0 " + @"CredentialRule as 0 Error: %@", + err); - NextTest(); - }]; + VerifyOrReturn(CheckValue("status", + err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, + EMBER_ZCL_STATUS_FAILURE)); + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep3ThSendSetWeekDayScheduleCommand_5() + CHIP_ERROR + TestStep6aThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_6() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = [NSNumber numberWithUnsignedChar:2U]; - params.startHour = [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = [NSNumber numberWithUnsignedChar:45U]; - params.endHour = [NSNumber numberWithUnsignedChar:16U]; - params.endMinute = [NSNumber numberWithUnsignedChar:55U]; - [cluster setWeekDayScheduleWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 3: TH send Set Week Day Schedule Command Error: %@", err); + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = [NSNumber numberWithUnsignedShort:2U]; + params.userName = nil; + params.userUniqueID = nil; + params.userStatus = nil; + params.userType = nil; + params.credentialRule = nil; + [cluster setUserWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 6a: TH sends Set User Command to DUT with the following values: OperationType as 0 " + @"UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL " + @"CredentialRule as NULL Error: %@", + err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep4ThSendGetWeekDayScheduleCommandToDut_6() + CHIP_ERROR TestStep6bThSendsGetUserCommandToDutWithUserIndexAs2_7() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - [cluster - getWeekDayScheduleWithParams:params - completion:^( - MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - NSLog(@"Step 4: TH send Get Week Day Schedule Command to DUT Error: %@", err); + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = [NSNumber numberWithUnsignedShort:2U]; + [cluster getUserWithParams:params + completion:^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + NSLog(@"Step 6b: TH sends Get User Command to DUT with UserIndex as 2 Error: %@", err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); + } - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); + } - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 2U)); - } + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 15U)); - } + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 45U)); - } + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } - VerifyOrReturn(CheckConstraintHasValue("endHour", values.endHour, true)); - if (values.endHour != nil) { + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); + } - VerifyOrReturn( - CheckConstraintMinValue("endHour", [values.endHour unsignedCharValue], 16U)); - } + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } - VerifyOrReturn(CheckConstraintHasValue("endMinute", values.endMinute, true)); - if (values.endMinute != nil) { + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } - VerifyOrReturn( - CheckConstraintMinValue("endMinute", [values.endMinute unsignedCharValue], 55U)); - } + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep5ThSendSetWeekDayScheduleCommand_7() + CHIP_ERROR + TestStep7ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs2UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_8() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = [NSNumber numberWithUnsignedChar:7U]; - params.startHour = [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = [NSNumber numberWithUnsignedChar:45U]; - params.endHour = [NSNumber numberWithUnsignedChar:16U]; - params.endMinute = [NSNumber numberWithUnsignedChar:55U]; - [cluster setWeekDayScheduleWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 5: TH send Set Week Day Schedule Command Error: %@", err); + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = [NSNumber numberWithUnsignedChar:2U]; + params.userIndex = [NSNumber numberWithUnsignedShort:2U]; + params.userName = nil; + params.userUniqueID = nil; + params.userStatus = nil; + params.userType = nil; + params.credentialRule = nil; + [cluster setUserWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 7: TH sends Set User Command to DUT with the following values: OperationType as 2 " + @"UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL " + @"CredentialRule as NULL Error: %@", + err); - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code - : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep6ThSendGetWeekDayScheduleCommandToDut_8() + CHIP_ERROR TestStep8ThSendsGetUserCommandToDutWithTheUserIndexAs2_9() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params - completion:^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Step 6: TH send Get Week Day Schedule Command to DUT Error: %@", err); + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = [NSNumber numberWithUnsignedShort:2U]; + [cluster getUserWithParams:params + completion:^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + NSLog(@"Step 8: TH sends Get User Command to DUT with the UserIndex as 2 Error: %@", err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 0U)); - } + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); + } - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); + } - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } - VerifyOrReturn(CheckConstraintHasValue("daysMask", values.daysMask, false)); - if (values.daysMask != nil) { - } + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } - VerifyOrReturn(CheckConstraintHasValue("startHour", values.startHour, false)); - if (values.startHour != nil) { - } + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } - VerifyOrReturn(CheckConstraintHasValue("startMinute", values.startMinute, false)); - if (values.startMinute != nil) { - } + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } - VerifyOrReturn(CheckConstraintHasValue("endHour", values.endHour, false)); - if (values.endHour != nil) { - } + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); + } - VerifyOrReturn(CheckConstraintHasValue("endMinute", values.endMinute, false)); - if (values.endMinute != nil) { - } + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } - NextTest(); - }]; + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep7ThSendsClearWeekDayScheduleCommandToDut_9() + CHIP_ERROR TestStep9ThSendsClearUserCommandToDutWithTheUserIndexAs1_10() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = [NSNumber numberWithUnsignedChar:1U]; + __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - [cluster clearWeekDayScheduleWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 7: TH sends Clear Week Day Schedule Command to DUT Error: %@", err); + [cluster clearUserWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 9: TH sends Clear User Command to DUT with the UserIndex as 1 Error: %@", err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep8ThSendsGetWeekDayScheduleCommandToDut_10() + CHIP_ERROR TestStep10ThSendsGetUserCommandToDutWithTheUserIndexAs1_11() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = [NSNumber numberWithUnsignedChar:1U]; + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params - completion:^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Step 8: TH sends Get Week Day Schedule Command to DUT Error: %@", err); + [cluster getUserWithParams:params + completion:^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + NSLog(@"Step 10: TH sends Get User Command to DUT with the UserIndex as 1 Error: %@", err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNull("UserName", actualValue)); + } - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } - VerifyOrReturn(CheckConstraintHasValue("daysMask", values.daysMask, false)); - if (values.daysMask != nil) { - } + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); + } - VerifyOrReturn(CheckConstraintHasValue("startHour", values.startHour, false)); - if (values.startHour != nil) { - } + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNull("UserType", actualValue)); + } - VerifyOrReturn(CheckConstraintHasValue("startMinute", values.startMinute, false)); - if (values.startMinute != nil) { - } + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); + } - VerifyOrReturn(CheckConstraintHasValue("endHour", values.endHour, false)); - if (values.endHour != nil) { - } + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNull("Credentials", actualValue)); + } - VerifyOrReturn(CheckConstraintHasValue("endMinute", values.endMinute, false)); - if (values.endMinute != nil) { - } + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } - NextTest(); - }]; + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); + VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); + } + + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestCleanupTheCreatedUser_11() + CHIP_ERROR TestTestCleanupThSendsClearUserCommandToDutWithTheUserIndexAs2_12() { MTRBaseDevice * device = GetDevice("alpha"); @@ -171850,10 +171405,10 @@ class Test_TC_DRLK_2_5 : public TestCommandBridge { VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; + params.userIndex = [NSNumber numberWithUnsignedShort:2U]; [cluster clearUserWithParams:params completion:^(NSError * _Nullable err) { - NSLog(@"Cleanup the created user Error: %@", err); + NSLog(@"Test cleanup: TH sends Clear User Command to DUT with the UserIndex as 2 Error: %@", err); VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); @@ -171862,2618 +171417,65 @@ class Test_TC_DRLK_2_5 : public TestCommandBridge { return CHIP_NO_ERROR; } -}; -class Test_TC_DRLK_2_6 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_6() - : TestCommandBridge("Test_TC_DRLK_2_6") - , mTestIndex(0) + CHIP_ERROR TestTestCleanupThSendsGetUserCommandToDutWithTheUserIndexAs2_13() { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_2_6() {} - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_6\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_6\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for commissionee\n"); - err = TestWaitForCommissionee_0(); - break; - case 1: - ChipLogProgress( - chipTool, " ***** Test Step 1 : Step 1: TH reads NumberOfHoliday SchedulesSupported and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.A0016")) { - NextTest(); - return; - } - err = TestStep1ThReadsNumberOfHolidaySchedulesSupportedAndSavesForFutureUse_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: Create Holiday schedule with 1 index\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C11.Rsp")) { - NextTest(); - return; - } - err = TestStep2CreateHolidayScheduleWith1Index_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: Get Holiday Schedule with HolidayIndex as 1\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { - NextTest(); - return; - } - err = TestStep3aGetHolidayScheduleWithHolidayIndexAs1_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: Create Holiday schedule with invalid operating mode\n"); - if (ShouldSkip("DRLK.S.C11.Rsp")) { - NextTest(); - return; - } - err = TestStep4CreateHolidayScheduleWithInvalidOperatingMode_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: Get Holiday Schedule with Invalid HolidayIndex 15.\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { - NextTest(); - return; - } - err = TestStep5GetHolidayScheduleWithInvalidHolidayIndex15_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: Get Holiday Schedule with the Non-scheduled HolidayIndex\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { - NextTest(); - return; - } - err = TestStep6GetHolidayScheduleWithTheNonScheduledHolidayIndex_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: Clear Holiday schedule with 1 index\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C13.Rsp")) { - NextTest(); - return; - } - err = TestStep7ClearHolidayScheduleWith1Index_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: Make sure that holiday schedule was deleted\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { - NextTest(); - return; - } - err = TestStep8MakeSureThatHolidayScheduleWasDeleted_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Cleanup the created user\n"); - err = TestCleanupTheCreatedUser_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override - { - return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); - } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForCommissionee_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull NumberOfHolidaySchedulesSupported; - - CHIP_ERROR TestStep1ThReadsNumberOfHolidaySchedulesSupportedAndSavesForFutureUse_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfHolidaySchedulesSupportedWithCompletion:^( - NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 1: TH reads NumberOfHoliday SchedulesSupported and saves for future use. Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfHolidaySchedulesSupported", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfHolidaySchedulesSupported", [value unsignedCharValue], 255U)); - { - NumberOfHolidaySchedulesSupported = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2CreateHolidayScheduleWith1Index_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = [NSNumber numberWithUnsignedChar:1U]; - params.localStartTime = [NSNumber numberWithUnsignedInt:20UL]; - params.localEndTime = [NSNumber numberWithUnsignedInt:30UL]; - params.operatingMode = [NSNumber numberWithUnsignedChar:0U]; - [cluster setHolidayScheduleWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 2: Create Holiday schedule with 1 index Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aGetHolidayScheduleWithHolidayIndexAs1_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params - completion:^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Step 3a: Get Holiday Schedule with HolidayIndex as 1 Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 20UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 30UL)); - } - - if (values.localEndTime != nil) { - - VerifyOrReturn(CheckConstraintMinValue( - "localEndTime", [values.localEndTime unsignedIntValue], 21UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4CreateHolidayScheduleWithInvalidOperatingMode_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = [NSNumber numberWithUnsignedChar:1U]; - params.localStartTime = [NSNumber numberWithUnsignedInt:20UL]; - params.localEndTime = [NSNumber numberWithUnsignedInt:30UL]; - params.operatingMode = [NSNumber numberWithUnsignedChar:5U]; - [cluster setHolidayScheduleWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 4: Create Holiday schedule with invalid operating mode Error: %@", err); - - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code - : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5GetHolidayScheduleWithInvalidHolidayIndex15_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = [NSNumber numberWithUnsignedChar:15U]; - [cluster getHolidayScheduleWithParams:params - completion:^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Step 5: Get Holiday Schedule with Invalid HolidayIndex 15. Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 15U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6GetHolidayScheduleWithTheNonScheduledHolidayIndex_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = [NSNumber numberWithUnsignedChar:10U]; - [cluster getHolidayScheduleWithParams:params - completion:^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Step 6: Get Holiday Schedule with the Non-scheduled HolidayIndex Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 10U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ClearHolidayScheduleWith1Index_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearHolidayScheduleParams alloc] init]; - params.holidayIndex = [NSNumber numberWithUnsignedChar:1U]; - [cluster clearHolidayScheduleWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 7: Clear Holiday schedule with 1 index Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8MakeSureThatHolidayScheduleWasDeleted_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params - completion:^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Step 8: Make sure that holiday schedule was deleted Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanupTheCreatedUser_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Cleanup the created user Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_2_7 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_7() - : TestCommandBridge("Test_TC_DRLK_2_7") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_2_7() {} - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_7\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_7\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Create new user\n"); - err = TestPreconditionCreateNewUser_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Precondition: Read the user back and verify its fields\n"); - err = TestPreconditionReadTheUserBackAndVerifyItsFields_2(); - break; - case 3: - ChipLogProgress( - chipTool, " ***** Test Step 3 : Step 1: TH reads NumberOfYearDay SchedulesSupportedPerUser attribute\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.A0015")) { - NextTest(); - return; - } - err = TestStep1ThReadsNumberOfYearDaySchedulesSupportedPerUserAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2: TH reads NumberOfTotalUsers Supported attribute\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { - NextTest(); - return; - } - err = TestStep2ThReadsNumberOfTotalUsersSupportedAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH sends Set Year Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0e.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendsSetYearDayScheduleCommandToDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a & 4b: TH sends Get Year Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { - NextTest(); - return; - } - err = TestStep4a4bThSendsGetYearDayScheduleCommandToDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH send Set Year Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.C0e.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendSetYearDayScheduleCommandToDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH sends Get Year Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { - NextTest(); - return; - } - err = TestStep6ThSendsGetYearDayScheduleCommandToDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7a: Create a user with userIndex as 5\n"); - err = TestStep7aCreateAUserWithUserIndexAs5_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7b: TH sends Get Year Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { - NextTest(); - return; - } - err = TestStep7bThSendsGetYearDayScheduleCommandToDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 8: TH sends Clear Year Day Schedule to DUT\n"); - if (ShouldSkip("DRLK.S.C10.Rsp")) { - NextTest(); - return; - } - err = TestStep8ThSendsClearYearDayScheduleToDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 9: TH sends Get Year Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx && DRLK.S.C10.Rsp")) { - NextTest(); - return; - } - err = TestStep9ThSendsGetYearDayScheduleCommandToDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 10: TH sends Set Year Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.C0e.Rsp")) { - NextTest(); - return; - } - err = TestStep10ThSendsSetYearDayScheduleCommandToDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 11: TH sends Get Year Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { - NextTest(); - return; - } - err = TestStep11ThSendsGetYearDayScheduleCommandToDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 12: TH sends Clear Year Day Schedule to DUT\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C10.Rsp")) { - NextTest(); - return; - } - err = TestStep12ThSendsClearYearDayScheduleToDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Clear a year day schedule for the first user\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C10.Rsp")) { - NextTest(); - return; - } - err = TestClearAYearDayScheduleForTheFirstUser_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Cleanup the created user with UserIndex 1\n"); - err = TestCleanupTheCreatedUserWithUserIndex1_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Cleanup the created user with UserIndex 5\n"); - err = TestCleanupTheCreatedUserWithUserIndex5_18(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override - { - return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); - } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 19; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionCreateNewUser_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"xxx"; - params.userUniqueID = [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = [NSNumber numberWithUnsignedChar:1U]; - params.userType = [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Precondition: Create new user Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionReadTheUserBackAndVerifyItsFields_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params - completion:^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - NSLog(@"Precondition: Read the user back and verify its fields Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfYearDaySchedulesSupportedPerUser; - - CHIP_ERROR TestStep1ThReadsNumberOfYearDaySchedulesSupportedPerUserAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfYearDaySchedulesSupportedPerUserWithCompletion:^( - NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 1: TH reads NumberOfYearDay SchedulesSupportedPerUser attribute Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn( - CheckConstraintMinValue("numberOfYearDaySchedulesSupportedPerUser", [value unsignedCharValue], 0U)); - VerifyOrReturn( - CheckConstraintMaxValue("numberOfYearDaySchedulesSupportedPerUser", [value unsignedCharValue], 255U)); - { - NumberOfYearDaySchedulesSupportedPerUser = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfTotalUsersSupported; - - CHIP_ERROR TestStep2ThReadsNumberOfTotalUsersSupportedAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 2: TH reads NumberOfTotalUsers Supported attribute Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65534U)); - { - NumberOfTotalUsersSupported = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsSetYearDayScheduleCommandToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = [NSNumber numberWithUnsignedInt:960UL]; - params.localEndTime = [NSNumber numberWithUnsignedInt:1980UL]; - [cluster setYearDayScheduleWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 3: TH sends Set Year Day Schedule Command to DUT Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a4bThSendsGetYearDayScheduleCommandToDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params - completion:^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Step 4a & 4b: TH sends Get Year Day Schedule Command to DUT Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 960UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 1980UL)); - } - - if (values.localEndTime != nil) { - - VerifyOrReturn(CheckConstraintMinValue( - "localEndTime", [values.localEndTime unsignedIntValue], 961UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendSetYearDayScheduleCommandToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = [NSNumber numberWithUnsignedShort:15U]; - params.localStartTime = [NSNumber numberWithUnsignedInt:1020UL]; - params.localEndTime = [NSNumber numberWithUnsignedInt:2040UL]; - [cluster setYearDayScheduleWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 5: TH send Set Year Day Schedule Command to DUT Error: %@", err); - - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code - : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThSendsGetYearDayScheduleCommandToDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = [NSNumber numberWithUnsignedShort:15U]; - [cluster getYearDayScheduleWithParams:params - completion:^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Step 6: TH sends Get Year Day Schedule Command to DUT Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 15U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - VerifyOrReturn(CheckConstraintHasValue("localStartTime", values.localStartTime, false)); - if (values.localStartTime != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("localEndTime", values.localEndTime, false)); - if (values.localEndTime != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aCreateAUserWithUserIndexAs5_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = [NSNumber numberWithUnsignedShort:5U]; - params.userName = @"xxx"; - params.userUniqueID = [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = [NSNumber numberWithUnsignedChar:1U]; - params.userType = [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 7a: Create a user with userIndex as 5 Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bThSendsGetYearDayScheduleCommandToDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = [NumberOfYearDaySchedulesSupportedPerUser copy]; - params.userIndex = [NSNumber numberWithUnsignedShort:5U]; - [cluster getYearDayScheduleWithParams:params - completion:^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Step 7b: TH sends Get Year Day Schedule Command to DUT Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn( - CheckValue("YearDayIndex", actualValue, NumberOfYearDaySchedulesSupportedPerUser)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 5U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - VerifyOrReturn(CheckConstraintHasValue("localStartTime", values.localStartTime, false)); - if (values.localStartTime != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("localEndTime", values.localEndTime, false)); - if (values.localEndTime != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThSendsClearYearDayScheduleToDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - [cluster clearYearDayScheduleWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 8: TH sends Clear Year Day Schedule to DUT Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThSendsGetYearDayScheduleCommandToDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params - completion:^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Step 9: TH sends Get Year Day Schedule Command to DUT Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - VerifyOrReturn(CheckConstraintHasValue("localStartTime", values.localStartTime, false)); - if (values.localStartTime != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("localEndTime", values.localEndTime, false)); - if (values.localEndTime != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThSendsSetYearDayScheduleCommandToDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = [NSNumber numberWithUnsignedInt:1080UL]; - params.localEndTime = [NSNumber numberWithUnsignedInt:2100UL]; - [cluster setYearDayScheduleWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 10: TH sends Set Year Day Schedule Command to DUT Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThSendsGetYearDayScheduleCommandToDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params - completion:^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Step 11: TH sends Get Year Day Schedule Command to DUT Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 1080UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 2100UL)); - } - - if (values.localEndTime != nil) { - - VerifyOrReturn(CheckConstraintMinValue( - "localEndTime", [values.localEndTime unsignedIntValue], 1081UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThSendsClearYearDayScheduleToDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = [NSNumber numberWithUnsignedShort:0U]; - [cluster - clearYearDayScheduleWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 12: TH sends Clear Year Day Schedule to DUT Error: %@", err); - - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code - : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAYearDayScheduleForTheFirstUser_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - [cluster clearYearDayScheduleWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Clear a year day schedule for the first user Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanupTheCreatedUserWithUserIndex1_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Cleanup the created user with UserIndex 1 Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanupTheCreatedUserWithUserIndex5_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = [NSNumber numberWithUnsignedShort:5U]; - [cluster clearUserWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Cleanup the created user with UserIndex 5 Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_2_8 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_8() - : TestCommandBridge("Test_TC_DRLK_2_8") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_2_8() {} - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_8\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_8\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, - " ***** Test Step 1 : Step 1: TH reads NumberOfTotalUsers Supported attribute and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { - NextTest(); - return; - } - err = TestStep1ThReadsNumberOfTotalUsersSupportedAttributeAndSavesForFutureUse_1(); - break; - case 2: - ChipLogProgress(chipTool, - " ***** Test Step 2 : Step 2: TH sends Set User Command to DUT with the following values: OperationType as 0 " - "UserIndex as 1 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 0 CredentialRule as 0\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs0CredentialRuleAs0_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH sends Get User Command to DUT with UserIndex as 1\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { - NextTest(); - return; - } - err = TestStep3ThSendsGetUserCommandToDutWithUserIndexAs1_3(); - break; - case 4: - ChipLogProgress(chipTool, - " ***** Test Step 4 : Step 4: TH sends Set User Command to DUT with the following values: OperationType as 0 " - "UserIndex as 2 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 10 (Invalid value) CredentialRule " - "as 3\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs10InvalidValueCredentialRuleAs3_4(); - break; - case 5: - ChipLogProgress(chipTool, - " ***** Test Step 5 : Step 5: TH sends Set User Command to DUT with the following values: OperationType as 0 " - "UserIndex as 1 (Same as step 2) UserName as xxx UserUniqueID as 8965 UserStatus as 1 UserType as 0 CredentialRule " - "as 0\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1SameAsStep2UserNameAsXxxUserUniqueIDAs8965UserStatusAs1UserTypeAs0CredentialRuleAs0_5(); - break; - case 6: - ChipLogProgress(chipTool, - " ***** Test Step 6 : Step 6a: TH sends Set User Command to DUT with the following values: OperationType as 0 " - "UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as " - "NULL\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { - NextTest(); - return; - } - err = TestStep6aThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6b: TH sends Get User Command to DUT with UserIndex as 2\n"); - if (ShouldSkip("DRLK.S.C1a.Rsp && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { - NextTest(); - return; - } - err = TestStep6bThSendsGetUserCommandToDutWithUserIndexAs2_7(); - break; - case 8: - ChipLogProgress(chipTool, - " ***** Test Step 8 : Step 7: TH sends Set User Command to DUT with the following values: OperationType as 2 " - "UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as " - "NULL\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs2UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 8: TH sends Get User Command to DUT with the UserIndex as 2\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { - NextTest(); - return; - } - err = TestStep8ThSendsGetUserCommandToDutWithTheUserIndexAs2_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 9: TH sends Clear User Command to DUT with the UserIndex as 1\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1d.Rsp")) { - NextTest(); - return; - } - err = TestStep9ThSendsClearUserCommandToDutWithTheUserIndexAs1_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 10: TH sends Get User Command to DUT with the UserIndex as 1\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { - NextTest(); - return; - } - err = TestStep10ThSendsGetUserCommandToDutWithTheUserIndexAs1_11(); - break; - case 12: - ChipLogProgress( - chipTool, " ***** Test Step 12 : Test cleanup: TH sends Clear User Command to DUT with the UserIndex as 2\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1d.Rsp")) { - NextTest(); - return; - } - err = TestTestCleanupThSendsClearUserCommandToDutWithTheUserIndexAs2_12(); - break; - case 13: - ChipLogProgress( - chipTool, " ***** Test Step 13 : Test cleanup: TH sends Get User Command to DUT with the UserIndex as 2\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { - NextTest(); - return; - } - err = TestTestCleanupThSendsGetUserCommandToDutWithTheUserIndexAs2_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - VerifyOrReturn(CheckValue("clusterStatus present", status.mClusterStatus.HasValue(), true)); - VerifyOrReturn(CheckValue("clusterStatus value", status.mClusterStatus.Value(), 3)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override - { - return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); - } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull Current_NumberOfTotalUsersSupported; - - CHIP_ERROR TestStep1ThReadsNumberOfTotalUsersSupportedAttributeAndSavesForFutureUse_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 1: TH reads NumberOfTotalUsers Supported attribute and saves for future use. Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65534U)); - { - Current_NumberOfTotalUsersSupported = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR - TestStep2ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs0CredentialRuleAs0_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"xxx"; - params.userUniqueID = [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = [NSNumber numberWithUnsignedChar:1U]; - params.userType = [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = [NSNumber numberWithUnsignedChar:0U]; - [cluster - setUserWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 2: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as " - @"1 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 0 CredentialRule as 0 Error: %@", - err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsGetUserCommandToDutWithUserIndexAs1_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params - completion:^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - NSLog(@"Step 3: TH sends Get User Command to DUT with UserIndex as 1 Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR - TestStep4ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs10InvalidValueCredentialRuleAs3_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = [NSNumber numberWithUnsignedShort:2U]; - params.userName = @"xxx"; - params.userUniqueID = [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = [NSNumber numberWithUnsignedChar:1U]; - params.userType = [NSNumber numberWithUnsignedChar:10U]; - params.credentialRule = [NSNumber numberWithUnsignedChar:3U]; - [cluster - setUserWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 4: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as " - @"2 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 10 (Invalid value) " - @"CredentialRule as 3 Error: %@", - err); - - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, - EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR - TestStep5ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1SameAsStep2UserNameAsXxxUserUniqueIDAs8965UserStatusAs1UserTypeAs0CredentialRuleAs0_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"xxx"; - params.userUniqueID = [NSNumber numberWithUnsignedInt:8965UL]; - params.userStatus = [NSNumber numberWithUnsignedChar:1U]; - params.userType = [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = [NSNumber numberWithUnsignedChar:0U]; - [cluster - setUserWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 5: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as " - @"1 (Same as step 2) UserName as xxx UserUniqueID as 8965 UserStatus as 1 UserType as 0 " - @"CredentialRule as 0 Error: %@", - err); - - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, - EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR - TestStep6aThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = [NSNumber numberWithUnsignedShort:2U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 6a: TH sends Set User Command to DUT with the following values: OperationType as 0 " - @"UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL " - @"CredentialRule as NULL Error: %@", - err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThSendsGetUserCommandToDutWithUserIndexAs2_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params - completion:^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - NSLog(@"Step 6b: TH sends Get User Command to DUT with UserIndex as 2 Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR - TestStep7ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs2UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = [NSNumber numberWithUnsignedShort:2U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 7: TH sends Set User Command to DUT with the following values: OperationType as 2 " - @"UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL " - @"CredentialRule as NULL Error: %@", - err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThSendsGetUserCommandToDutWithTheUserIndexAs2_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params - completion:^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - NSLog(@"Step 8: TH sends Get User Command to DUT with the UserIndex as 2 Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThSendsClearUserCommandToDutWithTheUserIndexAs1_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 9: TH sends Clear User Command to DUT with the UserIndex as 1 Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThSendsGetUserCommandToDutWithTheUserIndexAs1_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params - completion:^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - NSLog(@"Step 10: TH sends Get User Command to DUT with the UserIndex as 1 Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); - VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTestCleanupThSendsClearUserCommandToDutWithTheUserIndexAs2_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = [NSNumber numberWithUnsignedShort:2U]; - [cluster clearUserWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Test cleanup: TH sends Clear User Command to DUT with the UserIndex as 2 Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTestCleanupThSendsGetUserCommandToDutWithTheUserIndexAs2_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params - completion:^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - NSLog(@"Test cleanup: TH sends Get User Command to DUT with the UserIndex as 2 Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_2_11 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_11() - : TestCommandBridge("Test_TC_DRLK_2_11") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("PINCredentialData", &mPINCredentialData); - AddArgument("RFIDCredentialData", &mRFIDCredentialData); - AddArgument("FingerVeinCredentialData", &mFingerVeinCredentialData); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_2_11() {} - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_11\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_11\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Create new user with default parameters\n"); - err = TestPreconditionCreateNewUserWithDefaultParameters_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Precondition: Read the user back and verify its fields\n"); - err = TestPreconditionReadTheUserBackAndVerifyItsFields_2(); - break; - case 3: - ChipLogProgress( - chipTool, " ***** Test Step 3 : Step 1a: TH reads NumberOfTotalUsersSupported and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { - NextTest(); - return; - } - err = TestStep1aThReadsNumberOfTotalUsersSupportedAndSavesForFutureUse_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1b: TH reads MinPINCodeLength and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestStep1bThReadsMinPINCodeLengthAndSavesForFutureUse_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1c: TH reads MaxPINCodeLength and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestStep1cThReadsMaxPINCodeLengthAndSavesForFutureUse_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1d: TH reads MinRFIDCodeLength and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.A001a")) { - NextTest(); - return; - } - err = TestStep1dThReadsMinRFIDCodeLengthAndSavesForFutureUse_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 1e: TH reads MaxRFIDCodeLength and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.A0019")) { - NextTest(); - return; - } - err = TestStep1eThReadsMaxRFIDCodeLengthAndSavesForFutureUse_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2a: TH sends Set Credential Command to DUT with type PIN\n"); - if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx")) { - NextTest(); - return; - } - err = TestStep2aThSendsSetCredentialCommandToDutWithTypePin_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2b: TH sends Set Credential Command to DUT with type RFID\n"); - if (ShouldSkip("DRLK.S.F01 && DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx")) { - NextTest(); - return; - } - err = TestStep2bThSendsSetCredentialCommandToDutWithTypeRfid_9(); - break; - case 10: - ChipLogProgress( - chipTool, " ***** Test Step 10 : Step 2c: TH sends Set Credential Command to DUT with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F02 && DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx")) { - NextTest(); - return; - } - err = TestStep2cThSendsSetCredentialCommandToDutWithTypeFingerVein_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3a: TH sends Get Credential Status Command with type PIN\n"); - if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep3aThSendsGetCredentialStatusCommandWithTypePin_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3b: TH sends Get Credential Status Command with type RFID\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep3bThSendsGetCredentialStatusCommandWithTypeRfid_12(); - break; - case 13: - ChipLogProgress( - chipTool, " ***** Test Step 13 : Step 3c: TH sends Get Credential Status Command with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F02 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep3cThSendsGetCredentialStatusCommandWithTypeFingerVein_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4a: TH sends Clear Credential Command to DUT with type PIN\n"); - if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C26.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsClearCredentialCommandToDutWithTypePin_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4b: TH sends Get Credential Status Command with type RFID\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep4bThSendsGetCredentialStatusCommandWithTypeRfid_15(); - break; - case 16: - ChipLogProgress( - chipTool, " ***** Test Step 16 : Step 4c: TH sends Get Credential Status Command with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F02 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep4cThSendsGetCredentialStatusCommandWithTypeFingerVein_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4d: TH sends Clear Credential Command to DUT with type RFID\n"); - if (ShouldSkip("DRLK.S.F01 && DRLK.S.F08 && DRLK.S.C26.Rsp")) { - NextTest(); - return; - } - err = TestStep4dThSendsClearCredentialCommandToDutWithTypeRfid_17(); - break; - case 18: - ChipLogProgress( - chipTool, " ***** Test Step 18 : Step 4e: TH sends Get Credential Status Command with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F02 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep4eThSendsGetCredentialStatusCommandWithTypeFingerVein_18(); - break; - case 19: - ChipLogProgress( - chipTool, " ***** Test Step 19 : Step 4f: TH sends Clear Credential Command to DUT with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F02 && DRLK.S.F08 && DRLK.S.C26.Rsp")) { - NextTest(); - return; - } - err = TestStep4fThSendsClearCredentialCommandToDutWithTypeFingerVein_19(); - break; - case 20: - ChipLogProgress( - chipTool, " ***** Test Step 20 : Step 5a: TH sends Get Credential Status Command to DUT with type PIN\n"); - if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep5aThSendsGetCredentialStatusCommandToDutWithTypePin_20(); - break; - case 21: - ChipLogProgress( - chipTool, " ***** Test Step 21 : Step 5b: TH sends Get Credential Status Command to DUT with type RFID\n"); - if (ShouldSkip("DRLK.S.F01 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep5bThSendsGetCredentialStatusCommandToDutWithTypeRfid_21(); - break; - case 22: - ChipLogProgress( - chipTool, " ***** Test Step 22 : Step 5c: TH sends Get Credential Status Command to DUT with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F02 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep5cThSendsGetCredentialStatusCommandToDutWithTypeFingerVein_22(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override - { - return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); - } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 23; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mPINCredentialData; - chip::Optional mRFIDCredentialData; - chip::Optional mFingerVeinCredentialData; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionCreateNewUserWithDefaultParameters_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"xxx"; - params.userUniqueID = [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = [NSNumber numberWithUnsignedChar:1U]; - params.userType = [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Precondition: Create new user with default parameters Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionReadTheUserBackAndVerifyItsFields_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; + params.userIndex = [NSNumber numberWithUnsignedShort:2U]; [cluster getUserWithParams:params completion:^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - NSLog(@"Precondition: Read the user back and verify its fields Error: %@", err); + NSLog(@"Test cleanup: TH sends Get User Command to DUT with the UserIndex as 2 Error: %@", err); VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); { id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); } { id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); + VerifyOrReturn(CheckValueNull("UserName", actualValue)); } { id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); } { id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); } { id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + VerifyOrReturn(CheckValueNull("UserType", actualValue)); } { id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); } { id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); + VerifyOrReturn(CheckValueNull("Credentials", actualValue)); } { id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); } { id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); } { @@ -174486,825 +171488,26 @@ class Test_TC_DRLK_2_11 : public TestCommandBridge { return CHIP_NO_ERROR; } - - CHIP_ERROR TestStep1aThReadsNumberOfTotalUsersSupportedAndSavesForFutureUse_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 1a: TH reads NumberOfTotalUsersSupported and saves for future use. Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThReadsMinPINCodeLengthAndSavesForFutureUse_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinPINCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 1b: TH reads MinPINCodeLength and saves for future use. Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("minPINCodeLength", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minPINCodeLength", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThReadsMaxPINCodeLengthAndSavesForFutureUse_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxPINCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 1c: TH reads MaxPINCodeLength and saves for future use. Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("maxPINCodeLength", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxPINCodeLength", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThReadsMinRFIDCodeLengthAndSavesForFutureUse_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinRFIDCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 1d: TH reads MinRFIDCodeLength and saves for future use. Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("minRFIDCodeLength", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minRFIDCodeLength", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1eThReadsMaxRFIDCodeLengthAndSavesForFutureUse_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxRFIDCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 1e: TH reads MaxRFIDCodeLength and saves for future use. Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("maxRFIDCodeLength", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxRFIDCodeLength", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsSetCredentialCommandToDutWithTypePin_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = mPINCredentialData.HasValue() - ? [NSData dataWithBytes:mPINCredentialData.Value().data() length:mPINCredentialData.Value().size()] - : [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster - setCredentialWithParams:params - completion:^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - NSLog(@"Step 2a: TH sends Set Credential Command to DUT with type PIN Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsSetCredentialCommandToDutWithTypeRfid_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = mRFIDCredentialData.HasValue() - ? [NSData dataWithBytes:mRFIDCredentialData.Value().data() length:mRFIDCredentialData.Value().size()] - : [[NSData alloc] initWithBytes:"123456789A" length:10]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster - setCredentialWithParams:params - completion:^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - NSLog(@"Step 2b: TH sends Set Credential Command to DUT with type RFID Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThSendsSetCredentialCommandToDutWithTypeFingerVein_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = mFingerVeinCredentialData.HasValue() - ? [NSData dataWithBytes:mFingerVeinCredentialData.Value().data() length:mFingerVeinCredentialData.Value().size()] - : [[NSData alloc] initWithBytes:"123456789A" length:10]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster - setCredentialWithParams:params - completion:^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - NSLog(@"Step 2c: TH sends Set Credential Command to DUT with type FingerVein Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsGetCredentialStatusCommandWithTypePin_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params - completion:^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Step 3a: TH sends Get Credential Status Command with type PIN Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThSendsGetCredentialStatusCommandWithTypeRfid_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params - completion:^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Step 3b: TH sends Get Credential Status Command with type RFID Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThSendsGetCredentialStatusCommandWithTypeFingerVein_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - [cluster - getCredentialStatusWithParams:params - completion:^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Step 3c: TH sends Get Credential Status Command with type FingerVein Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsClearCredentialCommandToDutWithTypePin_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 4a: TH sends Clear Credential Command to DUT with type PIN Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThSendsGetCredentialStatusCommandWithTypeRfid_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params - completion:^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Step 4b: TH sends Get Credential Status Command with type RFID Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThSendsGetCredentialStatusCommandWithTypeFingerVein_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - [cluster - getCredentialStatusWithParams:params - completion:^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Step 4c: TH sends Get Credential Status Command with type FingerVein Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThSendsClearCredentialCommandToDutWithTypeRfid_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 4d: TH sends Clear Credential Command to DUT with type RFID Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThSendsGetCredentialStatusCommandWithTypeFingerVein_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - [cluster - getCredentialStatusWithParams:params - completion:^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Step 4e: TH sends Get Credential Status Command with type FingerVein Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThSendsClearCredentialCommandToDutWithTypeFingerVein_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 4f: TH sends Clear Credential Command to DUT with type FingerVein Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThSendsGetCredentialStatusCommandToDutWithTypePin_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - [cluster - getCredentialStatusWithParams:params - completion:^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Step 5a: TH sends Get Credential Status Command to DUT with type PIN Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThSendsGetCredentialStatusCommandToDutWithTypeRfid_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - [cluster - getCredentialStatusWithParams:params - completion:^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Step 5b: TH sends Get Credential Status Command to DUT with type RFID Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cThSendsGetCredentialStatusCommandToDutWithTypeFingerVein_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - [cluster - getCredentialStatusWithParams:params - completion:^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Step 5c: TH sends Get Credential Status Command to DUT with type FingerVein Error: %@", - err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } }; -class Test_TC_DRLK_2_12 : public TestCommandBridge { +class Test_TC_DRLK_2_11 : public TestCommandBridge { public: // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_12() - : TestCommandBridge("Test_TC_DRLK_2_12") + Test_TC_DRLK_2_11() + : TestCommandBridge("Test_TC_DRLK_2_11") , mTestIndex(0) { AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); AddArgument("cluster", &mCluster); AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("PINCredentialData", &mPINCredentialData); + AddArgument("RFIDCredentialData", &mRFIDCredentialData); + AddArgument("FingerVeinCredentialData", &mFingerVeinCredentialData); AddArgument("timeout", 0, UINT16_MAX, &mTimeout); } // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - ~Test_TC_DRLK_2_12() {} + ~Test_TC_DRLK_2_11() {} /////////// TestCommand Interface ///////// void NextTest() override @@ -175312,11 +171515,11 @@ class Test_TC_DRLK_2_12 : public TestCommandBridge { CHIP_ERROR err = CHIP_NO_ERROR; if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_12\n"); + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_11\n"); } if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_12\n"); + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_11\n"); SetCommandExitStatus(CHIP_NO_ERROR); return; } @@ -175333,312 +171536,181 @@ class Test_TC_DRLK_2_12 : public TestCommandBridge { err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); break; case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Create new user\n"); - err = TestPreconditionCreateNewUser_1(); + ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Create new user with default parameters\n"); + err = TestPreconditionCreateNewUserWithDefaultParameters_1(); break; case 2: ChipLogProgress(chipTool, " ***** Test Step 2 : Precondition: Read the user back and verify its fields\n"); err = TestPreconditionReadTheUserBackAndVerifyItsFields_2(); break; case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Precondition: Create new PIN credential and lock/unlock user\n"); - err = TestPreconditionCreateNewPinCredentialAndLockUnlockUser_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Precondition: Verify created PIN credential\n"); - err = TestPreconditionVerifyCreatedPinCredential_4(); - break; - case 5: - ChipLogProgress(chipTool, - " ***** Test Step 5 : Step 1: TH writes the RequirePINforRemoteOperation attribute value as False on the DUT\n"); - if (ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033.Write")) { - NextTest(); - return; - } - err = TestStep1ThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, - " ***** Test Step 6 : Step 1: TH writes the RequirePINforRemoteOperation attribute value as False on the DUT\n"); - if (ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && !DRLK.S.A0033.Write")) { - NextTest(); - return; - } - err = TestStep1ThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDut_6(); - break; - case 7: - ChipLogProgress( - chipTool, " ***** Test Step 7 : Step 2: TH reads the RequirePINforRemoteOperation attribute from the DUT\n"); - if (ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheRequirePINforRemoteOperationAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3: TH sends Ubolt Door Command to the DUT without PINCode\n"); - if (ShouldSkip("DRLK.S.C27.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendsUboltDoorCommandToTheDutWithoutPINCode_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4: TH sends Ubolt Door Command to the DUT with PINCode\n"); - if (ShouldSkip("DRLK.S.C27.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsUboltDoorCommandToTheDutWithPINCode_9(); - break; - case 10: - ChipLogProgress(chipTool, - " ***** Test Step 10 : Step 5: TH writes the RequirePINforRemoteOperation attribute value as true on the DUT\n"); - if (ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033.Write")) { - NextTest(); - return; - } - err = TestStep5ThWritesTheRequirePINforRemoteOperationAttributeValueAsTrueOnTheDut_10(); - break; - case 11: - ChipLogProgress(chipTool, - " ***** Test Step 11 : Step 5: TH writes the RequirePINforRemoteOperation attribute value as true on the DUT\n"); - if (ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && !DRLK.S.A0033.Write")) { - NextTest(); - return; - } - err = TestStep5ThWritesTheRequirePINforRemoteOperationAttributeValueAsTrueOnTheDut_11(); - break; - case 12: - ChipLogProgress( - chipTool, " ***** Test Step 12 : Step 6: TH reads the RequirePINforRemoteOperation attribute from the DUT\n"); - if (ShouldSkip("DRLK.S.F07 && DRLK.S.F00 && DRLK.S.A0033")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheRequirePINforRemoteOperationAttributeFromTheDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: TH sends Ubolt Door Command to the DUT with valid PINCode\n"); - if (ShouldSkip("DRLK.S.C27.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendsUboltDoorCommandToTheDutWithValidPINCode_13(); - break; - case 14: - ChipLogProgress( - chipTool, " ***** Test Step 14 : Step 8: TH sends Unbolt Door Command to the DUT with Invalid PINCode\n"); - if (ShouldSkip("DRLK.S.C27.Rsp")) { - NextTest(); - return; - } - err = TestStep8ThSendsUnboltDoorCommandToTheDutWithInvalidPINCode_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 9: TH sends Unbolt Door Command to the DUT without PINCode\n"); - if (ShouldSkip("DRLK.S.C27.Rsp")) { - NextTest(); - return; - } - err = TestStep9ThSendsUnboltDoorCommandToTheDutWithoutPINCode_15(); - break; - case 16: ChipLogProgress( - chipTool, " ***** Test Step 16 : Step 10: TH writes WrongCodeEntryLimit attribute value as 3 on the DUT\n"); - if (ShouldSkip("( DRLK.S.F00 || DRLK.S.F01 ) && DRLK.S.A0030.Write")) { + chipTool, " ***** Test Step 3 : Step 1a: TH reads NumberOfTotalUsersSupported and saves for future use.\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { NextTest(); return; } - err = TestStep10ThWritesWrongCodeEntryLimitAttributeValueAs3OnTheDut_16(); + err = TestStep1aThReadsNumberOfTotalUsersSupportedAndSavesForFutureUse_3(); break; - case 17: - ChipLogProgress( - chipTool, " ***** Test Step 17 : Step 10: TH writes WrongCodeEntryLimit attribute value as 3 on the DUT\n"); - if (ShouldSkip("( DRLK.S.F00 || DRLK.S.F01 ) && !DRLK.S.A0030.Write")) { + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1b: TH reads MinPINCodeLength and saves for future use.\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { NextTest(); return; } - err = TestStep10ThWritesWrongCodeEntryLimitAttributeValueAs3OnTheDut_17(); + err = TestStep1bThReadsMinPINCodeLengthAndSavesForFutureUse_4(); break; - case 18: - ChipLogProgress(chipTool, - " ***** Test Step 18 : Step 11: TH writes UserCodeTemporaryDisableTime attribute value as 15 Seconds on the DUT " - "and Verify that the DUT sends Success response\n"); - if (ShouldSkip("( DRLK.S.F00 || DRLK.S.F01 ) && DRLK.S.A0031.Write")) { + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1c: TH reads MaxPINCodeLength and saves for future use.\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { NextTest(); return; } - err = TestStep11ThWritesUserCodeTemporaryDisableTimeAttributeValueAs15SecondsOnTheDutAndVerifyThatTheDutSendsSuccessResponse_18(); + err = TestStep1cThReadsMaxPINCodeLengthAndSavesForFutureUse_5(); break; - case 19: - ChipLogProgress(chipTool, - " ***** Test Step 19 : Step 11: TH writes UserCodeTemporaryDisableTime attribute value as 15 Seconds on the DUT " - "and Verify that the DUT sends Success response\n"); - if (ShouldSkip("( DRLK.S.F00 || DRLK.S.F01 ) && !DRLK.S.A0031.Write")) { + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1d: TH reads MinRFIDCodeLength and saves for future use.\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.A001a")) { NextTest(); return; } - err = TestStep11ThWritesUserCodeTemporaryDisableTimeAttributeValueAs15SecondsOnTheDutAndVerifyThatTheDutSendsSuccessResponse_19(); + err = TestStep1dThReadsMinRFIDCodeLengthAndSavesForFutureUse_6(); break; - case 20: - ChipLogProgress( - chipTool, " ***** Test Step 20 : Step 12a: TH sends Unbolt Door Command to the DUT with invalid PINCode\n"); - if (ShouldSkip("DRLK.S.C27.Rsp")) { + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 1e: TH reads MaxRFIDCodeLength and saves for future use.\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.A0019")) { NextTest(); return; } - err = TestStep12aThSendsUnboltDoorCommandToTheDutWithInvalidPINCode_20(); + err = TestStep1eThReadsMaxRFIDCodeLengthAndSavesForFutureUse_7(); break; - case 21: - ChipLogProgress( - chipTool, " ***** Test Step 21 : Step 12b: TH sends Unbolt Door Command to the DUT with invalid PINCode\n"); - if (ShouldSkip("DRLK.S.C27.Rsp")) { + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2a: TH sends Set Credential Command to DUT with type PIN\n"); + if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx")) { NextTest(); return; } - err = TestStep12bThSendsUnboltDoorCommandToTheDutWithInvalidPINCode_21(); + err = TestStep2aThSendsSetCredentialCommandToDutWithTypePin_8(); break; - case 22: - ChipLogProgress( - chipTool, " ***** Test Step 22 : Step 12c: TH sends Unbolt Door Command to the DUT with invalid PINCode\n"); - if (ShouldSkip("DRLK.S.C27.Rsp")) { + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2b: TH sends Set Credential Command to DUT with type RFID\n"); + if (ShouldSkip("DRLK.S.F01 && DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx")) { NextTest(); return; } - err = TestStep12cThSendsUnboltDoorCommandToTheDutWithInvalidPINCode_22(); + err = TestStep2bThSendsSetCredentialCommandToDutWithTypeRfid_9(); break; - case 23: + case 10: ChipLogProgress( - chipTool, " ***** Test Step 23 : Step 12d: TH sends Unbolt Door Command to the DUT with invalid PINCode\n"); - if (ShouldSkip("DRLK.S.C27.Rsp")) { - NextTest(); - return; - } - err = TestStep12dThSendsUnboltDoorCommandToTheDutWithInvalidPINCode_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 13: TH reads UserCodedTemporaryDisableTime attribute from DUT\n"); - if (ShouldSkip("( DRLK.S.F00 || DRLK.S.F01 ) && DRLK.S.A0031")) { - NextTest(); - return; - } - err = TestStep13ThReadsUserCodedTemporaryDisableTimeAttributeFromDut_24(); - break; - case 25: - ChipLogProgress(chipTool, - " ***** Test Step 25 : Step 14: TH sends Unbolt Door Command to the DUT with valid PINCode before " - "UserCodeTemporaryDisableTime expires\n"); - if (ShouldSkip("DRLK.S.C27.Rsp")) { + chipTool, " ***** Test Step 10 : Step 2c: TH sends Set Credential Command to DUT with type FingerVein\n"); + if (ShouldSkip("DRLK.S.F02 && DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx")) { NextTest(); return; } - err = TestStep14ThSendsUnboltDoorCommandToTheDutWithValidPINCodeBeforeUserCodeTemporaryDisableTimeExpires_25(); + err = TestStep2cThSendsSetCredentialCommandToDutWithTypeFingerVein_10(); break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Wait for UserCodeTemporaryDisableTime expires\n"); - if (ShouldSkip("( DRLK.S.F00 || DRLK.S.F01 ) && DRLK.S.A0031")) { + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3a: TH sends Get Credential Status Command with type PIN\n"); + if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { NextTest(); return; } - err = TestWaitForUserCodeTemporaryDisableTimeExpires_26(); + err = TestStep3aThSendsGetCredentialStatusCommandWithTypePin_11(); break; - case 27: - ChipLogProgress( - chipTool, " ***** Test Step 27 : Step 15: TH writes AutoRelockTime attribute value as 60 seconds on the DUT\n"); - if (ShouldSkip("DRLK.S.A0023.Write && PICS_SDK_CI_ONLY")) { + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3b: TH sends Get Credential Status Command with type RFID\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { NextTest(); return; } - err = TestStep15ThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_27(); + err = TestStep3bThSendsGetCredentialStatusCommandWithTypeRfid_12(); break; - case 28: + case 13: ChipLogProgress( - chipTool, " ***** Test Step 28 : Step 15: TH writes AutoRelockTime attribute value as 60 seconds on the DUT\n"); - if (ShouldSkip("DRLK.S.A0023.Write && PICS_SKIP_SAMPLE_APP")) { + chipTool, " ***** Test Step 13 : Step 3c: TH sends Get Credential Status Command with type FingerVein\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F02 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { NextTest(); return; } - err = TestStep15ThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_28(); + err = TestStep3cThSendsGetCredentialStatusCommandWithTypeFingerVein_13(); break; - case 29: - ChipLogProgress( - chipTool, " ***** Test Step 29 : Step 15: TH writes AutoRelockTime attribute value as 10 seconds on the DUT\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY && !DRLK.S.A0023.Write")) { + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4a: TH sends Clear Credential Command to DUT with type PIN\n"); + if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C26.Rsp")) { NextTest(); return; } - err = TestStep15ThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_29(); + err = TestStep4aThSendsClearCredentialCommandToDutWithTypePin_14(); break; - case 30: - ChipLogProgress( - chipTool, " ***** Test Step 30 : Step 15: TH writes AutoRelockTime attribute value as 60 seconds on the DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && !DRLK.S.A0023.Write")) { + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4b: TH sends Get Credential Status Command with type RFID\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { NextTest(); return; } - err = TestStep15ThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_30(); + err = TestStep4bThSendsGetCredentialStatusCommandWithTypeRfid_15(); break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 16: TH reads the AutoRelockTime attribute from the DUT\n"); - if (ShouldSkip("DRLK.S.A0023 && PICS_SDK_CI_ONLY")) { + case 16: + ChipLogProgress( + chipTool, " ***** Test Step 16 : Step 4c: TH sends Get Credential Status Command with type FingerVein\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F02 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { NextTest(); return; } - err = TestStep16ThReadsTheAutoRelockTimeAttributeFromTheDut_31(); + err = TestStep4cThSendsGetCredentialStatusCommandWithTypeFingerVein_16(); break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 16: TH reads the AutoRelockTime attribute from the DUT\n"); - if (ShouldSkip("DRLK.S.A0023 && PICS_SKIP_SAMPLE_APP")) { + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4d: TH sends Clear Credential Command to DUT with type RFID\n"); + if (ShouldSkip("DRLK.S.F01 && DRLK.S.F08 && DRLK.S.C26.Rsp")) { NextTest(); return; } - err = TestStep16ThReadsTheAutoRelockTimeAttributeFromTheDut_32(); + err = TestStep4dThSendsClearCredentialCommandToDutWithTypeRfid_17(); break; - case 33: + case 18: ChipLogProgress( - chipTool, " ***** Test Step 33 : Step 17: TH sends the Unbolt Door command to the DUT with valid PINCode\n"); - if (ShouldSkip("DRLK.S.C27.Rsp")) { + chipTool, " ***** Test Step 18 : Step 4e: TH sends Get Credential Status Command with type FingerVein\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F02 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { NextTest(); return; } - err = TestStep17ThSendsTheUnboltDoorCommandToTheDutWithValidPINCode_33(); + err = TestStep4eThSendsGetCredentialStatusCommandWithTypeFingerVein_18(); break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Wait for AutoRelockTime Expires\n"); - if (ShouldSkip("DRLK.S.A0023 && PICS_SDK_CI_ONLY")) { + case 19: + ChipLogProgress( + chipTool, " ***** Test Step 19 : Step 4f: TH sends Clear Credential Command to DUT with type FingerVein\n"); + if (ShouldSkip("DRLK.S.F02 && DRLK.S.F08 && DRLK.S.C26.Rsp")) { NextTest(); return; } - err = TestWaitForAutoRelockTimeExpires_34(); + err = TestStep4fThSendsClearCredentialCommandToDutWithTypeFingerVein_19(); break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Wait for AutoRelockTime Expires\n"); - if (ShouldSkip("DRLK.S.A0023 && PICS_SKIP_SAMPLE_APP")) { + case 20: + ChipLogProgress( + chipTool, " ***** Test Step 20 : Step 5a: TH sends Get Credential Status Command to DUT with type PIN\n"); + if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { NextTest(); return; } - err = TestWaitForAutoRelockTimeExpires_35(); + err = TestStep5aThSendsGetCredentialStatusCommandToDutWithTypePin_20(); break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 18: TH reads LockState attribute\n"); - if (ShouldSkip("DRLK.S.A0000 && DRLK.S.C01.Rsp")) { + case 21: + ChipLogProgress( + chipTool, " ***** Test Step 21 : Step 5b: TH sends Get Credential Status Command to DUT with type RFID\n"); + if (ShouldSkip("DRLK.S.F01 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { NextTest(); return; } - err = TestStep18ThReadsLockStateAttribute_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Cleanup the created user\n"); - err = TestCleanupTheCreatedUser_37(); + err = TestStep5bThSendsGetCredentialStatusCommandToDutWithTypeRfid_21(); break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Clean the created credential\n"); - if (ShouldSkip("DRLK.S.C26.Rsp")) { + case 22: + ChipLogProgress( + chipTool, " ***** Test Step 22 : Step 5c: TH sends Get Credential Status Command to DUT with type FingerVein\n"); + if (ShouldSkip("DRLK.S.F02 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { NextTest(); return; } - err = TestCleanTheCreatedCredential_38(); + err = TestStep5cThSendsGetCredentialStatusCommandToDutWithTypeFingerVein_22(); break; } @@ -175670,7 +171742,7 @@ class Test_TC_DRLK_2_12 : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 7: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); @@ -175685,7 +171757,7 @@ class Test_TC_DRLK_2_12 : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 12: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); @@ -175694,78 +171766,30 @@ class Test_TC_DRLK_2_12 : public TestCommandBridge { VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 16: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 18: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; - case 36: + case 20: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; - case 37: + case 21: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; - case 38: + case 22: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; } @@ -175781,11 +171805,14 @@ class Test_TC_DRLK_2_12 : public TestCommandBridge { private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 39; + const uint16_t mTestCount = 23; chip::Optional mNodeId; chip::Optional mCluster; chip::Optional mEndpoint; + chip::Optional mPINCredentialData; + chip::Optional mRFIDCredentialData; + chip::Optional mFingerVeinCredentialData; chip::Optional mTimeout; CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() @@ -175796,7 +171823,7 @@ class Test_TC_DRLK_2_12 : public TestCommandBridge { return WaitForCommissionee("alpha", value); } - CHIP_ERROR TestPreconditionCreateNewUser_1() + CHIP_ERROR TestPreconditionCreateNewUserWithDefaultParameters_1() { MTRBaseDevice * device = GetDevice("alpha"); @@ -175813,7 +171840,7 @@ class Test_TC_DRLK_2_12 : public TestCommandBridge { params.credentialRule = [NSNumber numberWithUnsignedChar:0U]; [cluster setUserWithParams:params completion:^(NSError * _Nullable err) { - NSLog(@"Precondition: Create new user Error: %@", err); + NSLog(@"Precondition: Create new user with default parameters Error: %@", err); VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); @@ -175902,171 +171929,83 @@ class Test_TC_DRLK_2_12 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestPreconditionCreateNewPinCredentialAndLockUnlockUser_3() + CHIP_ERROR TestStep1aThReadsNumberOfTotalUsersSupportedAndSavesForFutureUse_3() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster - setCredentialWithParams:params - completion:^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - NSLog(@"Precondition: Create new PIN credential and lock/unlock user Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } + [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 1a: TH reads NumberOfTotalUsersSupported and saves for future use. Error: %@", err); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } + VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65535U)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestPreconditionVerifyCreatedPinCredential_4() + CHIP_ERROR TestStep1bThReadsMinPINCodeLengthAndSavesForFutureUse_4() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params - completion:^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, - NSError * _Nullable err) { - NSLog(@"Precondition: Verify created PIN credential Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } + [cluster readAttributeMinPINCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 1b: TH reads MinPINCodeLength and saves for future use. Error: %@", err); - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } + VerifyOrReturn(CheckConstraintMinValue("minPINCodeLength", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("minPINCodeLength", [value unsignedCharValue], 255U)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep1ThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDut_5() + CHIP_ERROR TestStep1cThReadsMaxPINCodeLengthAndSavesForFutureUse_5() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - id requirePINforRemoteOperationArgument; - requirePINforRemoteOperationArgument = [NSNumber numberWithBool:false]; - [cluster writeAttributeRequirePINforRemoteOperationWithValue:requirePINforRemoteOperationArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 1: TH writes the RequirePINforRemoteOperation attribute " - @"value as False on the DUT Error: %@", - err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1ThWritesTheRequirePINforRemoteOperationAttributeValueAsFalseOnTheDut_6() - { + [cluster readAttributeMaxPINCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 1c: TH reads MaxPINCodeLength and saves for future use. Error: %@", err); - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - id requirePINforRemoteOperationArgument; - requirePINforRemoteOperationArgument = [NSNumber numberWithBool:false]; - [cluster writeAttributeRequirePINforRemoteOperationWithValue:requirePINforRemoteOperationArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 1: TH writes the RequirePINforRemoteOperation attribute " - @"value as False on the DUT Error: %@", - err); + VerifyOrReturn(CheckConstraintMinValue("maxPINCodeLength", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("maxPINCodeLength", [value unsignedCharValue], 255U)); - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] - ? err.code - : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep2ThReadsTheRequirePINforRemoteOperationAttributeFromTheDut_7() + CHIP_ERROR TestStep1dThReadsMinRFIDCodeLengthAndSavesForFutureUse_6() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - [cluster readAttributeRequirePINforRemoteOperationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 2: TH reads the RequirePINforRemoteOperation attribute from the DUT Error: %@", err); + [cluster readAttributeMinRFIDCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 1d: TH reads MinRFIDCodeLength and saves for future use. Error: %@", err); VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - { - id actualValue = value; - VerifyOrReturn(CheckValue("RequirePINforRemoteOperation", actualValue, false)); - } + VerifyOrReturn(CheckConstraintMinValue("minRFIDCodeLength", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("minRFIDCodeLength", [value unsignedCharValue], 255U)); NextTest(); }]; @@ -176074,693 +172013,720 @@ class Test_TC_DRLK_2_12 : public TestCommandBridge { return CHIP_NO_ERROR; } - CHIP_ERROR TestStep3ThSendsUboltDoorCommandToTheDutWithoutPINCode_8() + CHIP_ERROR TestStep1eThReadsMaxRFIDCodeLengthAndSavesForFutureUse_7() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterUnboltDoorParams alloc] init]; - [cluster unboltDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 3: TH sends Ubolt Door Command to the DUT without PINCode Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsUboltDoorCommandToTheDutWithPINCode_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + [cluster readAttributeMaxRFIDCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"Step 1e: TH reads MaxRFIDCodeLength and saves for future use. Error: %@", err); - __auto_type * params = [[MTRDoorLockClusterUnboltDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"123456" length:6]; - [cluster unboltDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 4: TH sends Ubolt Door Command to the DUT with PINCode Error: %@", err); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckConstraintMinValue("maxRFIDCodeLength", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("maxRFIDCodeLength", [value unsignedCharValue], 255U)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep5ThWritesTheRequirePINforRemoteOperationAttributeValueAsTrueOnTheDut_10() + CHIP_ERROR TestStep2aThSendsSetCredentialCommandToDutWithTypePin_8() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - id requirePINforRemoteOperationArgument; - requirePINforRemoteOperationArgument = [NSNumber numberWithBool:true]; - [cluster writeAttributeRequirePINforRemoteOperationWithValue:requirePINforRemoteOperationArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 5: TH writes the RequirePINforRemoteOperation attribute " - @"value as true on the DUT Error: %@", - err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - NextTest(); - }]; + params.credentialData = mPINCredentialData.HasValue() + ? [NSData dataWithBytes:mPINCredentialData.Value().data() length:mPINCredentialData.Value().size()] + : [[NSData alloc] initWithBytes:"123456" length:6]; + params.userIndex = [NSNumber numberWithUnsignedShort:1U]; + params.userStatus = nil; + params.userType = nil; + [cluster + setCredentialWithParams:params + completion:^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + NSLog(@"Step 2a: TH sends Set Credential Command to DUT with type PIN Error: %@", err); - return CHIP_NO_ERROR; - } + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - CHIP_ERROR TestStep5ThWritesTheRequirePINforRemoteOperationAttributeValueAsTrueOnTheDut_11() - { + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } - id requirePINforRemoteOperationArgument; - requirePINforRemoteOperationArgument = [NSNumber numberWithBool:true]; - [cluster writeAttributeRequirePINforRemoteOperationWithValue:requirePINforRemoteOperationArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 5: TH writes the RequirePINforRemoteOperation attribute " - @"value as true on the DUT Error: %@", - err); + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] - ? err.code - : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep6ThReadsTheRequirePINforRemoteOperationAttributeFromTheDut_12() + CHIP_ERROR TestStep2bThSendsSetCredentialCommandToDutWithTypeRfid_9() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - [cluster readAttributeRequirePINforRemoteOperationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 6: TH reads the RequirePINforRemoteOperation attribute from the DUT Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("RequirePINforRemoteOperation", actualValue, true)); - } - - NextTest(); - }]; + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - return CHIP_NO_ERROR; - } + params.credentialData = mRFIDCredentialData.HasValue() + ? [NSData dataWithBytes:mRFIDCredentialData.Value().data() length:mRFIDCredentialData.Value().size()] + : [[NSData alloc] initWithBytes:"123456789A" length:10]; + params.userIndex = [NSNumber numberWithUnsignedShort:1U]; + params.userStatus = nil; + params.userType = nil; + [cluster + setCredentialWithParams:params + completion:^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + NSLog(@"Step 2b: TH sends Set Credential Command to DUT with type RFID Error: %@", err); - CHIP_ERROR TestStep7ThSendsUboltDoorCommandToTheDutWithValidPINCode_13() - { + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } - __auto_type * params = [[MTRDoorLockClusterUnboltDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"123456" length:6]; - [cluster unboltDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 7: TH sends Ubolt Door Command to the DUT with valid PINCode Error: %@", err); + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep8ThSendsUnboltDoorCommandToTheDutWithInvalidPINCode_14() + CHIP_ERROR TestStep2cThSendsSetCredentialCommandToDutWithTypeFingerVein_10() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterUnboltDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"123458" length:6]; - [cluster - unboltDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 8: TH sends Unbolt Door Command to the DUT with Invalid PINCode Error: %@", err); + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:4U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; + params.credentialData = mFingerVeinCredentialData.HasValue() + ? [NSData dataWithBytes:mFingerVeinCredentialData.Value().data() length:mFingerVeinCredentialData.Value().size()] + : [[NSData alloc] initWithBytes:"123456789A" length:10]; + params.userIndex = [NSNumber numberWithUnsignedShort:1U]; + params.userStatus = nil; + params.userType = nil; + [cluster + setCredentialWithParams:params + completion:^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + NSLog(@"Step 2c: TH sends Set Credential Command to DUT with type FingerVein Error: %@", err); - return CHIP_NO_ERROR; - } + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - CHIP_ERROR TestStep9ThSendsUnboltDoorCommandToTheDutWithoutPINCode_15() - { + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } - __auto_type * params = [[MTRDoorLockClusterUnboltDoorParams alloc] init]; - [cluster - unboltDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 9: TH sends Unbolt Door Command to the DUT without PINCode Error: %@", err); + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep10ThWritesWrongCodeEntryLimitAttributeValueAs3OnTheDut_16() + CHIP_ERROR TestStep3aThSendsGetCredentialStatusCommandWithTypePin_11() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - id wrongCodeEntryLimitArgument; - wrongCodeEntryLimitArgument = [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeWrongCodeEntryLimitWithValue:wrongCodeEntryLimitArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 10: TH writes WrongCodeEntryLimit attribute value as 3 on the " - @"DUT Error: %@", - err); + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + [cluster getCredentialStatusWithParams:params + completion:^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Step 3a: TH sends Get Credential Status Command with type PIN Error: %@", err); - NextTest(); - }]; + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - return CHIP_NO_ERROR; - } + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); + } - CHIP_ERROR TestStep10ThWritesWrongCodeEntryLimitAttributeValueAs3OnTheDut_17() - { + VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } - id wrongCodeEntryLimitArgument; - wrongCodeEntryLimitArgument = [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeWrongCodeEntryLimitWithValue:wrongCodeEntryLimitArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 10: TH writes WrongCodeEntryLimit attribute value as 3 on the " - @"DUT Error: %@", - err); + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] - ? err.code - : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR - TestStep11ThWritesUserCodeTemporaryDisableTimeAttributeValueAs15SecondsOnTheDutAndVerifyThatTheDutSendsSuccessResponse_18() + CHIP_ERROR TestStep3bThSendsGetCredentialStatusCommandWithTypeRfid_12() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - id userCodeTemporaryDisableTimeArgument; - userCodeTemporaryDisableTimeArgument = [NSNumber numberWithUnsignedChar:15U]; - [cluster writeAttributeUserCodeTemporaryDisableTimeWithValue:userCodeTemporaryDisableTimeArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 11: TH writes UserCodeTemporaryDisableTime attribute " - @"value as 15 Seconds on the DUT and Verify that the DUT sends " - @"Success response Error: %@", - err); + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + [cluster getCredentialStatusWithParams:params + completion:^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Step 3b: TH sends Get Credential Status Command with type RFID Error: %@", err); - NextTest(); - }]; + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - return CHIP_NO_ERROR; - } + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); + } - CHIP_ERROR - TestStep11ThWritesUserCodeTemporaryDisableTimeAttributeValueAs15SecondsOnTheDutAndVerifyThatTheDutSendsSuccessResponse_19() - { + VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } - id userCodeTemporaryDisableTimeArgument; - userCodeTemporaryDisableTimeArgument = [NSNumber numberWithUnsignedChar:15U]; - [cluster writeAttributeUserCodeTemporaryDisableTimeWithValue:userCodeTemporaryDisableTimeArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 11: TH writes UserCodeTemporaryDisableTime attribute " - @"value as 15 Seconds on the DUT and Verify that the DUT sends " - @"Success response Error: %@", - err); + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] - ? err.code - : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep12aThSendsUnboltDoorCommandToTheDutWithInvalidPINCode_20() + CHIP_ERROR TestStep3cThSendsGetCredentialStatusCommandWithTypeFingerVein_13() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterUnboltDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"123457" length:6]; + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:4U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; + [cluster - unboltDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 12a: TH sends Unbolt Door Command to the DUT with invalid PINCode Error: %@", err); + getCredentialStatusWithParams:params + completion:^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Step 3c: TH sends Get Credential Status Command with type FingerVein Error: %@", err); - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - return CHIP_NO_ERROR; - } + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); + } - CHIP_ERROR TestStep12bThSendsUnboltDoorCommandToTheDutWithInvalidPINCode_21() - { + VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } - __auto_type * params = [[MTRDoorLockClusterUnboltDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"123458" length:6]; - [cluster - unboltDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 12b: TH sends Unbolt Door Command to the DUT with invalid PINCode Error: %@", err); + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep12cThSendsUnboltDoorCommandToTheDutWithInvalidPINCode_22() + CHIP_ERROR TestStep4aThSendsClearCredentialCommandToDutWithTypePin_14() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterUnboltDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"123459" length:6]; - [cluster - unboltDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 12c: TH sends Unbolt Door Command to the DUT with invalid PINCode Error: %@", err); - - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12dThSendsUnboltDoorCommandToTheDutWithInvalidPINCode_23() - { + __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + [cluster clearCredentialWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 4a: TH sends Clear Credential Command to DUT with type PIN Error: %@", err); - __auto_type * params = [[MTRDoorLockClusterUnboltDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"123460" length:6]; - [cluster - unboltDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 12d: TH sends Unbolt Door Command to the DUT with invalid PINCode Error: %@", err); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep13ThReadsUserCodedTemporaryDisableTimeAttributeFromDut_24() + CHIP_ERROR TestStep4bThSendsGetCredentialStatusCommandWithTypeRfid_15() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - [cluster readAttributeUserCodeTemporaryDisableTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 13: TH reads UserCodedTemporaryDisableTime attribute from DUT Error: %@", err); + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + [cluster getCredentialStatusWithParams:params + completion:^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Step 4b: TH sends Get Credential Status Command with type RFID Error: %@", err); - { - id actualValue = value; - VerifyOrReturn(CheckValue("UserCodeTemporaryDisableTime", actualValue, 15U)); - } + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - NextTest(); - }]; + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); + } - return CHIP_NO_ERROR; - } + VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } - CHIP_ERROR TestStep14ThSendsUnboltDoorCommandToTheDutWithValidPINCodeBeforeUserCodeTemporaryDisableTimeExpires_25() - { + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } - __auto_type * params = [[MTRDoorLockClusterUnboltDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"123456" length:6]; - [cluster - unboltDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 14: TH sends Unbolt Door Command to the DUT with valid PINCode before " - @"UserCodeTemporaryDisableTime expires Error: %@", - err); + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestWaitForUserCodeTemporaryDisableTimeExpires_26() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 15000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep15ThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_27() + CHIP_ERROR TestStep4cThSendsGetCredentialStatusCommandWithTypeFingerVein_16() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - id autoRelockTimeArgument; - autoRelockTimeArgument = [NSNumber numberWithUnsignedInt:10UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 15: TH writes AutoRelockTime attribute value as 60 seconds on the DUT " - @"Error: %@", - err); + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:4U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + [cluster + getCredentialStatusWithParams:params + completion:^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Step 4c: TH sends Get Credential Status Command with type FingerVein Error: %@", err); - NextTest(); - }]; + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - return CHIP_NO_ERROR; - } + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); + } - CHIP_ERROR TestStep15ThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_28() - { + VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } - id autoRelockTimeArgument; - autoRelockTimeArgument = [NSNumber numberWithUnsignedInt:60UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 15: TH writes AutoRelockTime attribute value as 60 seconds on the DUT " - @"Error: %@", - err); + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep15ThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_29() + CHIP_ERROR TestStep4dThSendsClearCredentialCommandToDutWithTypeRfid_17() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - id autoRelockTimeArgument; - autoRelockTimeArgument = [NSNumber numberWithUnsignedInt:10UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 15: TH writes AutoRelockTime attribute value as 10 seconds on the DUT " - @"Error: %@", - err); + __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] - ? err.code - : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; + [cluster clearCredentialWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 4d: TH sends Clear Credential Command to DUT with type RFID Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep15ThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_30() + CHIP_ERROR TestStep4eThSendsGetCredentialStatusCommandWithTypeFingerVein_18() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - id autoRelockTimeArgument; - autoRelockTimeArgument = [NSNumber numberWithUnsignedInt:60UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument - completion:^(NSError * _Nullable err) { - NSLog(@"Step 15: TH writes AutoRelockTime attribute value as 60 seconds on the DUT " - @"Error: %@", - err); + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:4U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - VerifyOrReturn(CheckValue("status", - err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] - ? err.code - : EMBER_ZCL_STATUS_FAILURE) - : 0, - EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; + [cluster + getCredentialStatusWithParams:params + completion:^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Step 4e: TH sends Get Credential Status Command with type FingerVein Error: %@", err); - return CHIP_NO_ERROR; - } + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - CHIP_ERROR TestStep16ThReadsTheAutoRelockTimeAttributeFromTheDut_31() - { + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); + } - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } - [cluster readAttributeAutoRelockTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 16: TH reads the AutoRelockTime attribute from the DUT Error: %@", err); + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } - { - id actualValue = value; - VerifyOrReturn(CheckValue("AutoRelockTime", actualValue, 10UL)); - } + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep16ThReadsTheAutoRelockTimeAttributeFromTheDut_32() + CHIP_ERROR TestStep4fThSendsClearCredentialCommandToDutWithTypeFingerVein_19() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - [cluster readAttributeAutoRelockTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 16: TH reads the AutoRelockTime attribute from the DUT Error: %@", err); + __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:4U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + [cluster clearCredentialWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Step 4f: TH sends Clear Credential Command to DUT with type FingerVein Error: %@", err); - { - id actualValue = value; - VerifyOrReturn(CheckValue("AutoRelockTime", actualValue, 60UL)); - } + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestStep17ThSendsTheUnboltDoorCommandToTheDutWithValidPINCode_33() + CHIP_ERROR TestStep5aThSendsGetCredentialStatusCommandToDutWithTypePin_20() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterUnboltDoorParams alloc] init]; - params.pinCode = [[NSData alloc] initWithBytes:"123456" length:6]; - [cluster unboltDoorWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Step 17: TH sends the Unbolt Door command to the DUT with valid PINCode Error: %@", err); + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + [cluster + getCredentialStatusWithParams:params + completion:^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Step 5a: TH sends Get Credential Status Command to DUT with type PIN Error: %@", err); - NextTest(); - }]; + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - return CHIP_NO_ERROR; - } + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); + } - CHIP_ERROR TestWaitForAutoRelockTimeExpires_34() - { + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } - CHIP_ERROR TestWaitForAutoRelockTimeExpires_35() - { + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 60000UL; - return WaitForMs("alpha", value); + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; } - CHIP_ERROR TestStep18ThReadsLockStateAttribute_36() + CHIP_ERROR TestStep5bThSendsGetCredentialStatusCommandToDutWithTypeRfid_21() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - [cluster readAttributeLockStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - NSLog(@"Step 18: TH reads LockState attribute Error: %@", err); - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LockState", actualValue)); - VerifyOrReturn(CheckValue("LockState", actualValue, 1U)); - } + [cluster + getCredentialStatusWithParams:params + completion:^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Step 5b: TH sends Get Credential Status Command to DUT with type RFID Error: %@", err); - NextTest(); - }]; + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - return CHIP_NO_ERROR; - } + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); + } - CHIP_ERROR TestCleanupTheCreatedUser_37() - { + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Cleanup the created user Error: %@", err); + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } - NextTest(); - }]; + NextTest(); + }]; return CHIP_NO_ERROR; } - CHIP_ERROR TestCleanTheCreatedCredential_38() + CHIP_ERROR TestStep5cThSendsGetCredentialStatusCommandToDutWithTypeFingerVein_22() { MTRBaseDevice * device = GetDevice("alpha"); __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = [NSNumber numberWithUnsignedChar:4U]; ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = [NSNumber numberWithUnsignedShort:1U]; - [cluster clearCredentialWithParams:params - completion:^(NSError * _Nullable err) { - NSLog(@"Clean the created credential Error: %@", err); + [cluster + getCredentialStatusWithParams:params + completion:^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, + NSError * _Nullable err) { + NSLog(@"Step 5c: TH sends Get Credential Status Command to DUT with type FingerVein Error: %@", + err); - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - NextTest(); - }]; + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; return CHIP_NO_ERROR; } @@ -180525,15 +176491,12 @@ void registerCommandsTests(Commands & commands) make_unique(), make_unique(), make_unique(), - make_unique(), - make_unique(), make_unique(), make_unique(), make_unique(), make_unique(), make_unique(), make_unique(), - make_unique(), make_unique(), make_unique(), make_unique(),