# 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 atour sweet
#
# 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.

name:
    12.4.4. [TC-CNET-4.4] [WiFi] Verification for ScanNetworks command
    [DUT-Server]

PICS:
    - CNET.S.F00

config:
    nodeId: 0x12344321
    cluster: "Network Commissioning"
    #PIXIT.CNET.ENDPOINT_WIFI
    endpoint: 0
    PIXIT.CNET.WIFI_1ST_ACCESSPOINT_SSID:
        type: octet_string
        defaultValue: "hex:47524C50726976617465"

tests:
    - label: "Precondition: TH reads FeatureMap attribute from the DUT"
      command: "readAttribute"
      attribute: "FeatureMap"
      response:
          value: 1
          constraints:
              type: bitmap32

    - label:
          "Step 1a: TH sends ScanNetworks command to the DUT with the SSID field
          set to 'null' and Breadcrumb field set to 1"
      PICS: CNET.S.C00.Rsp && CNET.S.C01.Tx
      command: "ScanNetworks"
      arguments:
          values:
              - name: "SSID"
                value: null
              - name: "Breadcrumb"
                value: 1
      response:
          values:
              - name: "NetworkingStatus"
                constraints:
                    anyOf: [0, 1, 5, 6, 12]
              - name: "DebugText"
                constraints:
                    maxLength: 512
              - name: "WiFiScanResults"
                constraints:
                    type: list

    - label:
          "Step 1a: Verify each element in the WiFiScanResults list will have
          the following fields:"
      verification: |
          Via the TH (chip-tool), verify:
          -the Security value is in the type of map8 with length range 0 to 254.
          -the SSID value is in the  ype of octstr with length range 1 to 32.
          -the BSSID value is in the type of octstr with length range of 6.
          -the Channel is in the type of uint16 with range 0 to 65,535.
          -the WiFi Band is in the of type enum8 with a range of -128 to 127.
          -the RSSI is in the of type int8 with a range of -120 to 0.
      cluster: "LogCommands"
      command: "UserPrompt"
      PICS: PICS_USER_PROMPT && CNET.S.C00.Rsp && CNET.S.C01.Tx
      arguments:
          values:
              - name: "message"
                value: "Please enter 'y' for success"
              - name: "expectedValue"
                value: "y"

    - label:
          "Step 1b: TH reads Breadcrumb attribute from the General Commissioning
          Cluster"
      cluster: "General Commissioning"
      command: "readAttribute"
      attribute: "Breadcrumb"
      response:
          value: 1
          constraints:
              type: int64u

    - label:
          "Step 2a: TH sends ScanNetworks Command to the DUT with SSID field set
          to PIXIT.CNET.WIFI_1ST_ACCESSPOINT_SSID and Breadcrumb field set to 2"
      PICS: CNET.S.C00.Rsp && CNET.S.C01.Tx
      command: "ScanNetworks"
      arguments:
          values:
              - name: "SSID"
                value: PIXIT.CNET.WIFI_1ST_ACCESSPOINT_SSID
              - name: "Breadcrumb"
                value: 2
      response:
          values:
              - name: "NetworkingStatus"
                value: 0
              - name: "DebugText"
                constraints:
                    maxLength: 512
              - name: "WiFiScanResults"
                constraints:
                    type: list

    - label:
          "Step 2a: Verify each element in the WiFiScanResults list will have
          the following fields: "
      verification: |
          Via the TH (chip-tool), verify:
          -the Security value is in the type of map8 with length range 0 to 254.
          -the SSID value is in the  ype of octstr with length range 1 to 32.
          -the BSSID value is in the type of octstr with length range of 6.
          -the Channel is in the type of uint16 with range 0 to 65,535.
          -the WiFi Band is in the of type enum8 with a range of -128 to 127.
          -the RSSI is in the of type int8 with a range of -120 to 0.
      cluster: "LogCommands"
      command: "UserPrompt"
      PICS: PICS_USER_PROMPT && CNET.S.C00.Rsp && CNET.S.C01.Tx
      arguments:
          values:
              - name: "message"
                value: "Please enter 'y' for success"
              - name: "expectedValue"
                value: "y"

    - label:
          "Step 2b: TH reads Breadcrumb attribute from the General Commissioning
          Cluster"
      cluster: "General Commissioning"
      command: "readAttribute"
      attribute: "Breadcrumb"
      response:
          value: 2
          constraints:
              type: int64u
