# 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.1.12. [TC-DD-1.12] Onboarding Payload Verification - Custom Flow = 0 [DUT
    - Commissionee]

PICS:
    - MCORE.ROLE.COMMISSIONEE
    - MCORE.DD.QR
    - MCORE.DD.STANDARD_COMM_FLOW

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

tests:
    - label: "Preconditions"
      verification: |
          QR Code/ Manual Pairing Code is printed on the Commissionee device or in additional provided materials (ex: manual, companion app, web service).
      disabled: true

    - label: "Step 1: Scan the DUTs QR code using the TH."
      verification: |
          1. Run DUT. Example for DUT=all-clusters-app
          ./chip-all-clusters-app --version 0 --vendor-id 0xFFF1 --product-id 0x8001 --custom-flow 0 --capabilities 4 --discriminator 3840 --passcode 20202021

          ...
          [1657213978.633542][366513:366513] CHIP:DL: Device Configuration:
          [1657213978.633637][366513:366513] CHIP:DL:   Serial Number: (not set)
          [1657213978.633681][366513:366513] CHIP:DL:   Vendor Id: 65521 (0xFFF1)
          [1657213978.633721][366513:366513] CHIP:DL:   Product Id: 32769 (0x8001)
          [1657213978.633773][366513:366513] CHIP:DL:   Hardware Version: 0
          [1657213978.633815][366513:366513] CHIP:DL:   Setup Pin Code (0 for UNKNOWN/ERROR): 20202021
          [1657213978.633875][366513:366513] CHIP:DL:   Setup Discriminator (0xFFFF for UNKNOWN/ERROR): 3840 (0xF00)
          [1657213978.633927][366513:366513] CHIP:DL:   Manufacturing Date: (not set)
          [1657213978.633985][366513:366513] CHIP:DL:   Device Type: 65535 (0xFFFF)
          [1657213978.634025][366513:366513] CHIP:-: ==== Onboarding payload for Standard Commissioning Flow ====
          [1657213978.634100][366513:366513] CHIP:SVR: SetupQRCode: [MT:-24J0AFN00KA0648G00]

          2. Parse onboarding payload using TH=chip-tool
          ./chip-tool payload parse-setup-payload MT:-24J0AFN00KA0648G00

          Verify in TH (CHIP-TOOL)

          [1657214153060] [29000:16610528] CHIP: [SPL] Parsing base38Representation: MT:-24J0AFN00KA0648G00
          [1657214153060] [29000:16610528] CHIP: [SPL] Version:       0
          [1657214153060] [29000:16610528] CHIP: [SPL] VendorID:      65521
          [1657214153060] [29000:16610528] CHIP: [SPL] ProductID:     32769
          [1657214153060] [29000:16610528] CHIP: [SPL] Custom flow:   0    (STANDARD)
          [1657214153060] [29000:16610528] CHIP: [SPL] Capabilities:  0x04 (On IP network)
          [1657214153060] [29000:16610528] CHIP: [SPL] Discriminator: 3840
          [1657214153060] [29000:16610528] CHIP: [SPL] Passcode:      20202021
      disabled: true

    - label: "Step 2: Reboot the DUT device."
      verification: |
          1. Verify DUT is advertising in commissioning mode. On DUT, verify through commissioning

          Verify in TH (CHIP-TOOL)

           ./chip-tool pairing code 1 MT:-24J0AFN00KA0648G00

          ...
          [1657214364908] [29006:16612760] CHIP: [CTL] Starting commissioning discovery over DNS-SD
          [1657214364908] [29006:16612760] CHIP: [DL] Browsing for: _matterc._udp,_L3840
          [1657214365080] [29006:16612761] CHIP: [DL] Mdns: OnBrowseAdd  name: E5EFE5FB9DC494B9, type: _matterc._udp., domain: local., interface: 7
          [1657214365080] [29006:16612761] CHIP: [DL] Resolve type=_matterc._udp name=E5EFE5FB9DC494B9 interface=7
          [1657214365080] [29006:16612761] CHIP: [DL] Mdns : OnNewInterface hostname:DCA6328D2B9F0000.local. fullname:E5EFE5FB9DC494B9._matterc._udp.local. interface: 7
          [1657214365082] [29006:16612761] CHIP: [DL] Mdns: OnNewAddress interface: 7 ip:fd54:23a1:c6de:4637:4c4:ee82:2a0f:b5e2
          [1657214365082] [29006:16612761] CHIP: [DL] Mdns: OnNewAddress interface: 7 ip:fe80::1e81:3e0:3865:2d29
          [1657214365082] [29006:16612761] CHIP: [DL] Mdns: OnNewAddress interface: 7 ip:192.168.1.10
          [1657214365082] [29006:16612761] CHIP: [CTL] Discovered device to be commissioned over DNS-SD
      disabled: true
