# 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.15. [TC-DD-3.15] Commissioning Flow - Manual Pairing Code [DUT -
    Commissioner]

PICS:
    - MCORE.ROLE.COMMISSIONER
    - MCORE.DD.MANUAL_PC_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: |
          Preconditions
          1 - DUT is on an operational network and has accurate date, time, timezone, regulatory, and fabric information available.

          2 - 5.1.4.2 - Manual Pairing Code is printed on the Commissionee device or in additional provided materials (ex: manual, companion app, web service).

          An example onboarding payload could be "34970112332" (11-digit) or could be "749701123365521327694" (21-digit) (following 5.1.4. Table 37. "Manual Pairing Code Elements") which each include:

          - 1-bit VID_PID_PRESENT = 0 (11-digit) or = 1 (21-digit)

          - 1-bit VERSION=0

          - 4-bit SHORT DISCRIMINATOR=0xF00 (4 Most-significant bits of the 12-bits Discriminator value)

          - 27-bit PASSCODE=20202021 (see section 5.1.6. Generation of the Passcode)

          - 16-bit VENDOR_ID=0xFFF1 (as defined in section 2.5.2. "Vendor Identifier", for 21-digit Manual Pairing Code only)

          - 16-bit PRODUCT_ID=0x8001 (as defined in section 2.5.3. "Product Identifier", present if and only if VID is present)

          - A generated CHECK_DIGIT (see section 5.1.4. Manual Pairing Code, subsection "Check Digit")
      disabled: true

    - label:
          "Step 1a: Verify the THs 11-digit Manual Pairing Code meets the
          following criteria: - VERSION bit string string up to date with the
          current Matter spec. documentation - VID_PID_PRESENT bit string set to
          0"
      PICS: MCORE.DD.11_MANUAL_PC
      verification: |
          Verify on the TH (All-cluster-app)
           ./chip-all-clusters-app
          [1651108891.390266][30833:30833] CHIP:DL: Device Configuration:
          [1651108891.390455][30833:30833] CHIP:DL:   Serial Number: TEST_SN
          [1651108891.390505][30833:30833] CHIP:DL:   Vendor Id: 65521 (0xFFF1)
          [1651108891.390551][30833:30833] CHIP:DL:   Product Id: 32769 (0x8001)
          [1651108891.390592][30833:30833] CHIP:DL:   Hardware Version: 0
          [1651108891.390623][30833:30833] CHIP:DL:   Setup Pin Code (0 for UNKNOWN/ERROR): 20202021
          [1651108891.390650][30833:30833] CHIP:DL:   Setup Discriminator (0xFFFF for UNKNOWN/ERROR): 3840 (0xF00)
          [1651108891.390687][30833:30833] CHIP:DL:   Manufacturing Date: (not set)
          [1651108891.390717][30833:30833] CHIP:DL:   Device Type: 65535 (0xFFFF)
          [1651108891.390744][30833:30833] CHIP:-: ==== Onboarding payload for Standard Commissioning Flow ====
          [1651108891.390809][30833:30833] CHIP:SVR: SetupQRCode: [MT:-24J0AFN00KA0648G00]
          [1651108891.390848][30833:30833] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code:
          [1651108891.390876][30833:30833] CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J0AFN00KA0648G00
          [1651108891.390917][30833:30833] CHIP:SVR: Manual pairing code: [34970112332]
      disabled: true

    - label:
          "Step 1b: Provide the Manual Pairing Code, generated in the previous
          step, to the DUT in any format supported by the DUT. Follow any steps
          needed for the Commissioner/Commissionee to complete the commissioning
          process."
      PICS: MCORE.DD.11_MANUAL_PC
      verification: |
          Verify on the TH (All-cluster-app)
          [1651109112.909458][30833:30833] CHIP:SVR: Commissioning completed successfully
          [1651109112.909503][30833:30833] CHIP:DIS: Updating services using commissioning mode 0

          Verify on the DUT (Chip-tool):
           ./chip-tool pairing code 1 34970112332

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

    - label:
          "Step 2a: Verify the THs 21-digit Manual Pairing Code meets the
          following criteria: - A VERSION bit string string up-to-date with the
          current Matter spec. documentation - A VID_PID_PRESENT bit string set
          to 1 - A VENDOR_ID present (as defined in section 2.5.2. 'Vendor
          Identifier') - A PRODUCT_ID present (as defined in section 2.5.3.
          'Product Identifier')"
      PICS: MCORE.DD.21_MANUAL_PC
      verification: |
          Verify on the TH (All-cluster-app)
           ./chip-all-clusters-app

          [1651109167.022364][30980:30980] CHIP:DL: Device Configuration:
          [1651109167.022443][30980:30980] CHIP:DL:   Serial Number: TEST_SN
          [1651109167.022492][30980:30980] CHIP:DL:   Vendor Id: 65521 (0xFFF1)
          [1651109167.022542][30980:30980] CHIP:DL:   Product Id: 32769 (0x8001)
          [1651109167.022586][30980:30980] CHIP:DL:   Hardware Version: 0
          [1651109167.022619][30980:30980] CHIP:DL:   Setup Pin Code (0 for UNKNOWN/ERROR): 20202021
          [1651109167.022650][30980:30980] CHIP:DL:   Setup Discriminator (0xFFFF for UNKNOWN/ERROR): 3840 (0xF00)
          [1651109167.022691][30980:30980] CHIP:DL:   Manufacturing Date: (not set)
          [1651109167.022723][30980:30980] CHIP:DL:   Device Type: 65535 (0xFFFF)
          [1651109167.022753][30980:30980] CHIP:-: ==== Onboarding payload for Standard Commissioning Flow ====
          [1651109167.022825][30980:30980] CHIP:SVR: SetupQRCode: [MT:-24J0AFN00KA0648G00]
          [1651109167.022868][30980:30980] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code:
          [1651109167.022898][30980:30980] CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J0AFN00KA0648G00
          [1651109167.022942][30980:30980] CHIP:SVR: Manual pairing code: [34970112332]
          [1651109167.022974][30980:30980] CHIP:-: ==== Onboarding payload for Custom Commissioning Flows ====
          [1651109167.023050][30980:30980] CHIP:SVR: SetupQRCode: [MT:-24J029Q00KA0648G00]
          [1651109167.023090][30980:30980] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code:
          [1651109167.023120][30980:30980] CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J029Q00KA0648G00
          [1651109167.023167][30980:30980] CHIP:SVR: Manual pairing code: [749701123365521327694]
      disabled: true

    - label:
          "Step 2b: Provide the Manual Pairing Code, generated in the previous
          step, to the DUT in any format supported by the DUT. Follow any steps
          needed for the Commissioner/Commissionee to complete the commissioning
          process."
      PICS: MCORE.DD.21_MANUAL_PC
      verification: |
          Verify on the TH (All-cluster-app)
          [1651109219.100167][30980:30980] CHIP:SVR: Commissioning completed successfully
          [1651109219.100213][30980:30980] CHIP:DIS: Updating services using commissioning mode 0

          Verify on the DUT (Chip-tool):
           ./chip-tool pairing code 1 749701123365521327694

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