# Copyright (c) 2021 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.
# Auto-generated scripts for harness use only, please review before automation. The endpoints and cluster names are currently set to default

name:
    3.3.21. [TC-DD-3.21] Commissioning Flow - Commission Multiple-Endpoint
    Device [DUT - Commissioner]

PICS:
    - MCORE.ROLE.COMMISSIONER
    - MCORE.DD.QR_COMMISSIONING

config:
    nodeId: 0x12344321
    cluster: "Basic Information"
    endpoint: 0

tests:
    - label: "Note"
      verification: |
          Chip-tool command used below are an example to verify the DUT as commissioner test cases. For certification test, we expect DUT should have a capability or way to run the equivalent command.
      disabled: true

    - label: "Preconditions"
      verification: |
          1 - DUT is on an operational network and has accurate date, time, timezone, regulatory, and fabric information available.
          2 - 5.1.3 - QR code is printed on the Commissionee device or in additional provided materials (ex: manual).
      disabled: true

    - label:
          "Step 1: Place TH into commissioning mode using the TH manufacturers
          means to be discovered by the DUT Commissioner"
      verification: |
          ./chip-all-clusters-app --discriminator 3840

          Verify on TH (All-cluster-app):
          [1651109580.413197][31207:31207] CHIP:DL: Device Configuration:
          [1651109580.413259][31207:31207] CHIP:DL:   Serial Number: TEST_SN
          [1651109580.413294][31207:31207] CHIP:DL:   Vendor Id: 65521 (0xFFF1)
          [1651109580.413327][31207:31207] CHIP:DL:   Product Id: 32769 (0x8001)
          [1651109580.413358][31207:31207] CHIP:DL:   Hardware Version: 0
          [1651109580.413380][31207:31207] CHIP:DL:   Setup Pin Code (0 for UNKNOWN/ERROR): 20202021
          [1651109580.413401][31207:31207] CHIP:DL:   Setup Discriminator (0xFFFF for UNKNOWN/ERROR): 3840 (0xF00)
          [1651109580.413428][31207:31207] CHIP:DL:   Manufacturing Date: (not set)
          [1651109580.413450][31207:31207] CHIP:DL:   Device Type: 65535 (0xFFFF)
          [1651109580.413470][31207:31207] CHIP:-: ==== Onboarding payload for Standard Commissioning Flow ====
          [1651109580.413525][31207:31207] CHIP:SVR: SetupQRCode: [MT:-24J0AFN00KA0648G00]
      disabled: true

    - label: "Step 2a: Scan THs QR code using the DUT Commissioner."
      PICS: MCORE.DD.SCAN_QR_CODE
      verification: |
          1. Verify the QR code is scanned by DUT
          Note: chip-tool does not support physically scanning QR codes
      disabled: true

    - label:
          "Step 2b: DUT parses THs QR code. Follow any steps needed for the
          Commissioner/Commissionee to complete the commissioning process over
          the TH Commissionees method of device discovery"
      verification: |
          Verify on TH (All-cluster-app):
          [1651109784.452770][31207:31207] CHIP:SVR: Commissioning completed successfully
          [1651109784.452813][31207:31207] CHIP:DIS: Updating services using commissioning mode 0

          Verify on DUT (Chip-tool):
           ./chip-tool pairing code 1 MT:-24J0AFN00KA0648G00

          [1651109784376] [95553:65657838] CHIP: [CTL] Received CommissioningComplete response
          [1651109784376] [95553:65657838] CHIP: [CTL] Successfully finished commissioning step 'SendComplete'
          [1651109784376] [95553:65657838] CHIP: [CTL] Commissioning stage next step: 'SendComplete' -> 'Cleanup'
          [1651109784376] [95553:65657838] CHIP: [CTL] Performing next commissioning step 'Cleanup'
          [1651109784376] [95553:65657838] CHIP: [CTL] Successfully finished commissioning step 'Cleanup'
          [1651109784376] [95553:65657838] CHIP: [TOO] Device commissioning completed with success
      disabled: true

    - label:
          "Step 3: For each TH Endpoint that implements the On/Off light device,
          verify that the DUT acknowledges the existence of the Endpoint through
          DUT issuing an On command to the respective Endpoint (e.g. through
          some user action to trigger such command)."
      verification: |
          1. Send 'on' command from Commissioner to TH Endpoint 1
          Verify on DUT (Chip-tool):
           ./chip-tool onoff on 1 1
          [...]
          [1657930715416] [56399:2451384] CHIP: [DMG] Received Command Response Status for Endpoint=1 Cluster=0x0000_0006 Command=0x0000_0001 Status=0x0

          Verify on TH (All-cluster-app):
          [...]
          [1657930715.432295][2911:2911] CHIP:ZCL: On/Off set value: 1 1
          [1657930715.432341][2911:2911] CHIP:ZCL: Toggle on/off from 0 to 1
          [1657930715.432383][2911:2911] CHIP:ZCL: On Command - OffWaitTime :  0
          [1657930715.432422][2911:2911] CHIP:DMG: Endpoint 1, Cluster 0x0000_0006 update version to ce1d8e1f
          [1657930715.432468][2911:2911] CHIP:ZCL: On/Toggle Command - Stop Timer
          [1657930715.432509][2911:2911] CHIP:DMG: Endpoint 1, Cluster 0x0000_0006 update version to ce1d8e20


          2. Send 'on' command from Commissioner to TH Endpoint 2
          Verify on DUT (Chip-tool):
           ./chip-tool onoff on 1 2
          [...]
          [1657930953792] [56404:2453640] CHIP: [DMG] Received Command Response Status for Endpoint=2 Cluster=0x0000_0006 Command=0x0000_0001 Status=0x0

          Verify on TH (All-cluster-app):
          [...]
          [1657930953.816805][2911:2911] CHIP:ZCL: On/Off set value: 2 1
          [1657930953.816841][2911:2911] CHIP:ZCL: Toggle on/off from 0 to 1
          [1657930953.816870][2911:2911] CHIP:DMG: Endpoint 2, Cluster 0x0000_0006 update version to 6475f591
      disabled: true
