diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index b860db10af8d43..f8e46241763eb4 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -25,9 +25,10 @@ ENV LANG en_US.utf8 # these are installed for terminal/dev convenience. If more tooling for build is required, please # add them to chip-build (in integrations/docker/images/chip-build) -RUN apt-get update -RUN apt-get install -y locales && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 -RUN apt-get -fy install git vim emacs sudo \ +RUN apt-get update \ + && apt-get install -y locales \ + && localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 \ + && apt-get -fy install git vim emacs sudo \ apt-utils dialog zsh \ iproute2 procps lsb-release \ bash-completion \ @@ -36,49 +37,31 @@ RUN apt-get -fy install git vim emacs sudo \ docker.io \ iputils-ping net-tools \ libncurses5 \ - libpython2.7 - -RUN groupadd -g $USER_GID $USERNAME -RUN useradd -s /bin/bash -u $USER_UID -g $USER_GID -G docker -m $USERNAME -RUN echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME -RUN chmod 0440 /etc/sudoers.d/$USERNAME - -RUN mkdir -p /var/downloads -RUN cd /var/downloads -RUN curl -JL https://github.com/microsoft/vscode-cpptools/releases/download/0.27.0/cpptools-linux.vsix > extension.zip -RUN unzip extension.zip -RUN mkdir -p /home/$USERNAME/.vscode-server/extensions -RUN mv extension /home/$USERNAME/.vscode-server/extensions/ms-vscode.cpptools-0.27.0 -RUN mkdir -p /home/$USERNAME/bin -RUN curl https://raw.githubusercontent.com/restyled-io/restyler/master/bin/restyle-path -o /home/$USERNAME/bin/restyle-path -RUN chmod +x /home/$USERNAME/bin/restyle-path -RUN chown -R $USERNAME:$USERNAME /home/$USERNAME -RUN echo "PATH=/home/$USERNAME/bin:${PATH}" >> /home/$USERNAME/.bashrc - -# $USERNAME needs to own the esp-idf and tools for the examples to build -RUN chown -R $USERNAME:$USERNAME /opt/espressif/esp-idf -RUN chown -R $USERNAME:$USERNAME /opt/espressif/tools - -# $USERNAME needs to own west configuration to build nRF Connect examples -RUN chown -R $USERNAME:$USERNAME /opt/NordicSemiconductor/nrfconnect/ - -# allow read/write access to header and libraries -RUN chown -R $USERNAME:$USERNAME /opt/ubuntu-21.04-aarch64-sysroot/usr/ - -# allow licenses to be accepted -RUN chown -R $USERNAME:$USERNAME /opt/android/sdk - -# AmebaD requires access to change build_info.h -RUN chown -R $USERNAME:$USERNAME /opt/ameba/ambd_sdk_with_chip_non_NDA/ - -# NXP uses a patch_sdk script to change SDK files -RUN mkdir -p /opt/sdk/sdks/ -RUN chown -R $USERNAME:$USERNAME /opt/sdk/sdks/ - -RUN chown -R $USERNAME:$USERNAME /opt/fsl-imx-xwayland/5.15-kirkstone/ - -# Add access to openocd for VSCode debugging -RUN chown -R $USERNAME:$USERNAME /opt/openocd + libpython2.7 \ + && : + +RUN groupadd -g $USER_GID $USERNAME \ + && useradd -s /bin/bash -u $USER_UID -g $USER_GID -G docker,sudo -m $USERNAME \ + && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \ + && chmod 0440 /etc/sudoers.d/$USERNAME \ + && : + +RUN curl https://raw.githubusercontent.com/restyled-io/restyler/master/bin/restyle-path -o /usr/local/bin/restyle-path \ + && chmod +x /usr/local/bin/restyle-path \ + && : + +RUN mkdir -p /opt/sdk/sdks/ \ + && chown -R $USERNAME:$USERNAME \ + /opt/sdk/sdks/ `# NXP uses a patch_sdk script to change SDK files` \ + /opt/espressif/esp-idf `# $USERNAME needs to own the esp-idf and tools for the examples to build` \ + /opt/espressif/tools \ + /opt/NordicSemiconductor/nrfconnect/ `# $USERNAME needs to own west configuration to build nRF Connect examples` \ + /opt/ubuntu-21.04-aarch64-sysroot/usr/ `# allow read/write access to header and libraries` \ + /opt/android/sdk `# allow licenses to be accepted` \ + /opt/ameba/ambd_sdk_with_chip_non_NDA/ `# AmebaD requires access to change build_info.h` \ + /opt/fsl-imx-xwayland/5.15-kirkstone/ \ + /opt/openocd \ + && : # Fix Tizen SDK paths for new user RUN sed -i '/^TIZEN_SDK_DATA_PATH/d' $TIZEN_SDK_ROOT/sdk.info \ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 70c206f1058ce3..5ddef22276ed10 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -17,7 +17,7 @@ "build": { "dockerfile": "Dockerfile", "args": { - "BUILD_VERSION": "0.6.18" + "BUILD_VERSION": "0.6.27" } }, "remoteUser": "vscode", @@ -34,6 +34,7 @@ "maelvalais.autoconf", "marus25.cortex-debug", "ms-azuretools.vscode-docker", + "ms-vscode.cpptools", "msedge-dev.gnls", "redhat.vscode-yaml", "vadimcn.vscode-lldb", diff --git a/.github/workflows/bloat_check.yaml b/.github/workflows/bloat_check.yaml index b5325da5ec1ff3..ba734f22758ca9 100644 --- a/.github/workflows/bloat_check.yaml +++ b/.github/workflows/bloat_check.yaml @@ -30,7 +30,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 steps: - uses: Wandalen/wretry.action@v1.0.36 diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 443210b15c3c05..00ab192750e13f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -36,7 +36,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 @@ -138,7 +138,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 @@ -308,7 +308,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" options: --sysctl "net.ipv6.conf.all.disable_ipv6=0 diff --git a/.github/workflows/chef.yaml b/.github/workflows/chef.yaml index 3a7a91d60663e9..eca0463b31931a 100644 --- a/.github/workflows/chef.yaml +++ b/.github/workflows/chef.yaml @@ -29,7 +29,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 options: --user root steps: @@ -57,7 +57,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.6.18 + image: connectedhomeip/chip-build-esp32:0.6.27 options: --user root steps: @@ -85,6 +85,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: + # TODO: update this to connectedhomeip/chip-build-vscode:0.6.27 once we can compile with latest NRF image: connectedhomeip/chip-build-nrf-platform:0.6.18 options: --user root diff --git a/.github/workflows/cirque.yaml b/.github/workflows/cirque.yaml index c55e84b7a9273d..58fc8091a224df 100644 --- a/.github/workflows/cirque.yaml +++ b/.github/workflows/cirque.yaml @@ -29,7 +29,7 @@ jobs: timeout-minutes: 90 env: - DOCKER_RUN_VERSION: 0.6.18 + DOCKER_RUN_VERSION: 0.6.27 GITHUB_CACHE_PATH: /tmp/cirque-cache/ runs-on: ubuntu-latest @@ -38,7 +38,7 @@ jobs: # need to run with privilege, which isn't supported by job.XXX.contaner # https://github.com/actions/container-action/issues/2 # container: - # image: connectedhomeip/chip-build-cirque:0.6.18 + # image: connectedhomeip/chip-build-cirque:0.6.27 # volumes: # - "/tmp:/tmp" # - "/dev/pts:/dev/pts" diff --git a/.github/workflows/doxygen.yaml b/.github/workflows/doxygen.yaml index d5f84576ff0fc7..669efca5f6d4c7 100644 --- a/.github/workflows/doxygen.yaml +++ b/.github/workflows/doxygen.yaml @@ -82,7 +82,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build-doxygen:0.6.18 + image: connectedhomeip/chip-build-doxygen:0.6.27 if: github.actor != 'restyled-io[bot]' diff --git a/.github/workflows/examples-ameba.yaml b/.github/workflows/examples-ameba.yaml index 6986e6b6bda00b..3b568a270aa0ae 100644 --- a/.github/workflows/examples-ameba.yaml +++ b/.github/workflows/examples-ameba.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-ameba:0.6.18 + image: connectedhomeip/chip-build-ameba:0.6.27 options: --user root steps: diff --git a/.github/workflows/examples-bouffalolab.yaml b/.github/workflows/examples-bouffalolab.yaml index a62e0dad3c74dd..04331435bc6e14 100644 --- a/.github/workflows/examples-bouffalolab.yaml +++ b/.github/workflows/examples-bouffalolab.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-bouffalolab:0.6.18 + image: connectedhomeip/chip-build-bouffalolab:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-cc13x2x7_26x2x7.yaml b/.github/workflows/examples-cc13x2x7_26x2x7.yaml index d8598c6561eba9..99baf383bbaf3f 100644 --- a/.github/workflows/examples-cc13x2x7_26x2x7.yaml +++ b/.github/workflows/examples-cc13x2x7_26x2x7.yaml @@ -28,7 +28,7 @@ env: jobs: cc26x2x7: name: cc26x2x7 - timeout-minutes: 60 + timeout-minutes: 120 env: BUILD_TYPE: gn_cc26x2x7 @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-ti:0.6.18 + image: connectedhomeip/chip-build-ti:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: @@ -68,7 +68,7 @@ jobs: .environment/gn_out/.ninja_log .environment/pigweed-venv/*.log - name: Build examples - timeout-minutes: 60 + timeout-minutes: 100 run: | scripts/run_in_build_env.sh "\ ./scripts/build/build_examples.py \ diff --git a/.github/workflows/examples-efr32.yaml b/.github/workflows/examples-efr32.yaml index 30374f090bfe96..90e0e397c82517 100644 --- a/.github/workflows/examples-efr32.yaml +++ b/.github/workflows/examples-efr32.yaml @@ -38,7 +38,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-efr32:0.6.18 + image: connectedhomeip/chip-build-efr32:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-esp32.yaml b/.github/workflows/examples-esp32.yaml index 61d9d032042c9d..13a025fe229767 100644 --- a/.github/workflows/examples-esp32.yaml +++ b/.github/workflows/examples-esp32.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.6.18 + image: connectedhomeip/chip-build-esp32:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" @@ -140,7 +140,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32:0.6.18 + image: connectedhomeip/chip-build-esp32:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-infineon.yaml b/.github/workflows/examples-infineon.yaml index 51d89d81c0b316..bb629fa999fcf2 100644 --- a/.github/workflows/examples-infineon.yaml +++ b/.github/workflows/examples-infineon.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-infineon:0.6.18 + image: connectedhomeip/chip-build-infineon:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-k32w.yaml b/.github/workflows/examples-k32w.yaml index 76f8d8237f2d56..53b1aa46701771 100644 --- a/.github/workflows/examples-k32w.yaml +++ b/.github/workflows/examples-k32w.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-k32w:0.6.18 + image: connectedhomeip/chip-build-k32w:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-linux-arm.yaml b/.github/workflows/examples-linux-arm.yaml index 1a5b9c07395482..159960bef927a4 100644 --- a/.github/workflows/examples-linux-arm.yaml +++ b/.github/workflows/examples-linux-arm.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-crosscompile:0.6.18 + image: connectedhomeip/chip-build-crosscompile:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-linux-imx.yaml b/.github/workflows/examples-linux-imx.yaml index b8bfdc0c086c14..42f426bfa959b0 100644 --- a/.github/workflows/examples-linux-imx.yaml +++ b/.github/workflows/examples-linux-imx.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-imx:0.6.18 + image: connectedhomeip/chip-build-imx:0.6.27 steps: - uses: Wandalen/wretry.action@v1.0.36 diff --git a/.github/workflows/examples-linux-standalone.yaml b/.github/workflows/examples-linux-standalone.yaml index 2c09f5871e7f7f..11c913cfee488c 100644 --- a/.github/workflows/examples-linux-standalone.yaml +++ b/.github/workflows/examples-linux-standalone.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-mbed.yaml b/.github/workflows/examples-mbed.yaml index 3a9d522b1aa676..91f9f6f82a2097 100644 --- a/.github/workflows/examples-mbed.yaml +++ b/.github/workflows/examples-mbed.yaml @@ -40,7 +40,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-mbed-os:0.6.18 + image: connectedhomeip/chip-build-mbed-os:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-mw320.yaml b/.github/workflows/examples-mw320.yaml index aedded0398df28..7fc6238cc81034 100755 --- a/.github/workflows/examples-mw320.yaml +++ b/.github/workflows/examples-mw320.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-nrfconnect.yaml b/.github/workflows/examples-nrfconnect.yaml index 7d0c274dc2d029..1fa32d751037e8 100644 --- a/.github/workflows/examples-nrfconnect.yaml +++ b/.github/workflows/examples-nrfconnect.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-nrf-platform:0.6.18 + image: connectedhomeip/chip-build-nrf-platform:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-openiotsdk.yaml b/.github/workflows/examples-openiotsdk.yaml index f3b49f828704ff..7e043d58d98ee5 100644 --- a/.github/workflows/examples-openiotsdk.yaml +++ b/.github/workflows/examples-openiotsdk.yaml @@ -35,7 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-openiotsdk:0.6.18 + image: connectedhomeip/chip-build-openiotsdk:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" options: --privileged diff --git a/.github/workflows/examples-qpg.yaml b/.github/workflows/examples-qpg.yaml index c32dd590ddc930..35bc2987a4d10a 100644 --- a/.github/workflows/examples-qpg.yaml +++ b/.github/workflows/examples-qpg.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.github/workflows/examples-telink.yaml b/.github/workflows/examples-telink.yaml index 2099621e165ed3..9e5737c84828f9 100644 --- a/.github/workflows/examples-telink.yaml +++ b/.github/workflows/examples-telink.yaml @@ -35,6 +35,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: + # TODO: update this to connectedhomeip/chip-build-vscode:0.6.27 once we can compile image: connectedhomeip/chip-build-telink:0.6.18 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/examples-tizen.yaml b/.github/workflows/examples-tizen.yaml index 259733a008237c..8f892c8c712f13 100644 --- a/.github/workflows/examples-tizen.yaml +++ b/.github/workflows/examples-tizen.yaml @@ -33,7 +33,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-tizen:0.6.18 + image: connectedhomeip/chip-build-tizen:0.6.27 options: --user root volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" diff --git a/.github/workflows/full-android.yaml b/.github/workflows/full-android.yaml index 1173adaf7c82d5..8f87a48a9e6043 100644 --- a/.github/workflows/full-android.yaml +++ b/.github/workflows/full-android.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-android:0.6.18 + image: connectedhomeip/chip-build-android:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/fuzzing-build.yaml b/.github/workflows/fuzzing-build.yaml index bd96ff35792e31..bfb1eac538a138 100644 --- a/.github/workflows/fuzzing-build.yaml +++ b/.github/workflows/fuzzing-build.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 89e8c44d26a37f..3bfcc32bd9da4c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -98,13 +98,13 @@ jobs: if [ "$idl_file" = './examples/window-app/common/window-app.matter' ]; then continue; fi # Test files are intentionally small and not spec-compilant, just parse-compliant - if [ "$idl_file" = "./scripts/idl/tests/inputs/cluster_struct_attribute.matter" ]; then continue; fi - if [ "$idl_file" = "./scripts/idl/tests/inputs/global_struct_attribute.matter" ]; then continue; fi - if [ "$idl_file" = "./scripts/idl/tests/inputs/optional_argument.matter" ]; then continue; fi - if [ "$idl_file" = "./scripts/idl/tests/inputs/several_clusters.matter" ]; then continue; fi - if [ "$idl_file" = "./scripts/idl/tests/inputs/simple_attribute.matter" ]; then continue; fi - if [ "$idl_file" = "./scripts/idl/tests/inputs/large_lighting_app.matter" ]; then continue; fi - if [ "$idl_file" = "./scripts/idl/tests/inputs/large_all_clusters_app.matter" ]; then continue; fi + if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/cluster_struct_attribute.matter" ]; then continue; fi + if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/global_struct_attribute.matter" ]; then continue; fi + if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/optional_argument.matter" ]; then continue; fi + if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/several_clusters.matter" ]; then continue; fi + if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/simple_attribute.matter" ]; then continue; fi + if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/large_lighting_app.matter" ]; then continue; fi + if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/large_all_clusters_app.matter" ]; then continue; fi ./scripts/run_in_build_env.sh "./scripts/idl_lint.py --log-level warn $idl_file" >/dev/null || exit 1 done diff --git a/.github/workflows/qemu.yaml b/.github/workflows/qemu.yaml index 1a0c88e28d47b3..965e69ae1f3576 100644 --- a/.github/workflows/qemu.yaml +++ b/.github/workflows/qemu.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-esp32-qemu:0.6.18 + image: connectedhomeip/chip-build-esp32-qemu:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/release_artifacts.yaml b/.github/workflows/release_artifacts.yaml index 6b57156ba01f2d..5a6c13f85f8f14 100644 --- a/.github/workflows/release_artifacts.yaml +++ b/.github/workflows/release_artifacts.yaml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build-esp32:0.6.18 + image: connectedhomeip/chip-build-esp32:0.6.27 steps: - uses: Wandalen/wretry.action@v1.0.36 @@ -75,7 +75,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build-efr32:0.6.18 + image: connectedhomeip/chip-build-efr32:0.6.27 steps: - uses: Wandalen/wretry.action@v1.0.36 name: Checkout diff --git a/.github/workflows/smoketest-android.yaml b/.github/workflows/smoketest-android.yaml index 04c4c8ecb77d2b..dc8ee425c28fca 100644 --- a/.github/workflows/smoketest-android.yaml +++ b/.github/workflows/smoketest-android.yaml @@ -37,7 +37,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-android:0.6.18 + image: connectedhomeip/chip-build-android:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 7d35cde0db27ff..e492cba4c6b360 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -47,7 +47,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" @@ -105,7 +105,7 @@ jobs: # things. run: | ./scripts/run_in_build_env.sh \ - "./scripts/idl/xml_parser.py \ + "./scripts/py_matter_idl/matter_idl/xml_parser.py \ --no-print \ --log-level info \ src/app/zap-templates/zcl/data-model/chip/global-attributes.xml \ @@ -352,7 +352,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=0 net.ipv6.conf.all.forwarding=0" @@ -426,7 +426,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=0 net.ipv6.conf.all.forwarding=0" diff --git a/.github/workflows/unit_integration_test.yaml b/.github/workflows/unit_integration_test.yaml index a0ea6842e24dc0..a6cb192b058a99 100644 --- a/.github/workflows/unit_integration_test.yaml +++ b/.github/workflows/unit_integration_test.yaml @@ -37,7 +37,7 @@ jobs: runs-on: ubuntu-latest container: - image: connectedhomeip/chip-build:0.6.18 + image: connectedhomeip/chip-build:0.6.27 volumes: - "/tmp/log_output:/tmp/test_logs" options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" diff --git a/.github/workflows/zap_regeneration.yaml b/.github/workflows/zap_regeneration.yaml index 19960d000c4fcb..72cdc5fbc47808 100644 --- a/.github/workflows/zap_regeneration.yaml +++ b/.github/workflows/zap_regeneration.yaml @@ -28,7 +28,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build:0.6.25 + image: connectedhomeip/chip-build:0.6.28 defaults: run: shell: sh diff --git a/.github/workflows/zap_templates.yaml b/.github/workflows/zap_templates.yaml index e35ad0d7495d16..4a53d2b180a1df 100644 --- a/.github/workflows/zap_templates.yaml +++ b/.github/workflows/zap_templates.yaml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-20.04 container: - image: connectedhomeip/chip-build:0.6.25 + image: connectedhomeip/chip-build:0.6.28 defaults: run: shell: sh diff --git a/.gitmodules b/.gitmodules index f211ca385789ff..9e5b4f09f0fb39 100644 --- a/.gitmodules +++ b/.gitmodules @@ -290,3 +290,7 @@ url = https://github.com/bouffalolab/bl_iot_sdk_tiny.git branch = main platforms = bouffalolab +[submodule "third_party/libwebsockets/repo"] + path = third_party/libwebsockets/repo + url = https://github.com/warmcat/libwebsockets + platforms = linux,darwin diff --git a/.restyled.yaml b/.restyled.yaml index 13d499b2b8967f..75b649d9e4242d 100644 --- a/.restyled.yaml +++ b/.restyled.yaml @@ -69,7 +69,7 @@ exclude: - "third_party/android_deps/gradlew" # gradle wrapper generated file - "src/controller/python/chip/clusters/Objects.py" # generated file, no point to restyle - "src/controller/python/chip/clusters/CHIPClusters.py" # generated file, no point to restyle - - "scripts/idl/tests/outputs/**/*" # Matches generated output 1:1 + - "scripts/py_matter_idl/matter_idl/tests/outputs/**/*" # Matches generated output 1:1 - "examples/chef/sample_app_util/test_files/*.yaml" - "examples/chef/zzz_generated/**/*" - "examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/**/*" diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 352fb19ae65035..d5969bc3ae58f2 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -15,6 +15,7 @@ "maelvalais.autoconf", "marus25.cortex-debug", "ms-azuretools.vscode-docker", + "ms-vscode.cpptools", "msedge-dev.gnls", "redhat.vscode-yaml", "vadimcn.vscode-lldb", diff --git a/BUILD.gn b/BUILD.gn index e4e1b8e02da1b5..ce3a154774d272 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -120,7 +120,10 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") { } pw_python_pip_install("pip_install_matter_packages") { - packages = [ "//examples/common/pigweed/rpc_console:chip_rpc_distribution" ] + packages = [ + "//examples/common/pigweed/rpc_console:chip_rpc_distribution", + "//scripts:matter_yamltests_distribution", + ] } # Python packages installed during bootstrap. @@ -260,7 +263,8 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") { "//:fake_platform_tests", "//examples/chef:chef.tests", "//scripts/build:build_examples.tests", - "//scripts/idl:idl.tests", + "//scripts/py_matter_idl:matter_idl.tests", + "//scripts/py_matter_yamltests:matter_yamltests.tests", "//src:tests_run", ] } diff --git a/build/chip/chip_codegen.gni b/build/chip/chip_codegen.gni index 533cd02b27ea76..d59277ae1e484d 100644 --- a/build/chip/chip_codegen.gni +++ b/build/chip/chip_codegen.gni @@ -17,7 +17,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/pigweed.gni") import("$dir_pw_build/python.gni") -import("${chip_root}/scripts/idl/files.gni") +import("${chip_root}/scripts/py_matter_idl/files.gni") declare_args() { # Location where code has been pre-generated diff --git a/config/nrfconnect/chip-module/Kconfig b/config/nrfconnect/chip-module/Kconfig index 4b477d357287d1..b6700cbe7f3602 100644 --- a/config/nrfconnect/chip-module/Kconfig +++ b/config/nrfconnect/chip-module/Kconfig @@ -135,16 +135,45 @@ config CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE As a result, a new output file merged.hex will consist of all partitions including factory data. -# Use default certificates without generating or providing them -config CHIP_FACTORY_DATA_USE_DEFAULT_CERTS - bool "Use default certificates located in Matter repository" - default y +# Select source of the certificates +choice CHIP_FACTORY_DATA_CERT_SOURCE + prompt "Attestation certificate file source" + default CHIP_FACTORY_DATA_USE_DEFAULT_CERTS + + config CHIP_FACTORY_DATA_USE_DEFAULT_CERTS + bool "Use pre-generated development certificates" + help + Use pre-generated certificate files from the credentials/development/attestation/ + directory that match the configured Product ID. This can be used for development + purpose. + config CHIP_FACTORY_DATA_CERT_SOURCE_GENERATED + bool "Auto-generate certificates" + help + Generate new certificates instead of using pre-generated ones. + The certificates are generated on every build. + config CHIP_FACTORY_DATA_CERT_SOURCE_USER + bool "Use user-provided certificate files" + help + Use user-provided certificate files. + The user needs to specify the absolute path to all necessary files. +endchoice + +if CHIP_FACTORY_DATA_CERT_SOURCE_USER + +config CHIP_FACTORY_DATA_USER_CERTS_DAC_CERT + string "Path to the DAC certificate *.der-file" + help + Absolute path to the DAC certificate file in binary format. +config CHIP_FACTORY_DATA_USER_CERTS_DAC_KEY + string "Path to the DAC private key *.der-file" help - Pre-generated certificates can be used for development purpose. - This config includes default pre-generated certificates - which are located in credentials/development/attestation/ directory - instead of generating new ones. - If this config is set to `n` new certificates will be generated. + Absolute path to the DAC keysfile in binary format. + Note that both public and private keys must be present (will be extracted automatically). +config CHIP_FACTORY_DATA_USER_CERTS_PAI_CERT + string "Path to the PAI certificate *.der-file" + help + Absolute path pointing to the PAI certificate in binary format. +endif # Configs for SPAKE2 generation config CHIP_FACTORY_DATA_GENERATE_SPAKE2_VERIFIER diff --git a/config/nrfconnect/chip-module/generate_factory_data.cmake b/config/nrfconnect/chip-module/generate_factory_data.cmake index 2888822efcaea3..be0c4c0fac692c 100644 --- a/config/nrfconnect/chip-module/generate_factory_data.cmake +++ b/config/nrfconnect/chip-module/generate_factory_data.cmake @@ -69,6 +69,10 @@ if(CONFIG_CHIP_FACTORY_DATA_USE_DEFAULT_CERTS) string(APPEND script_args "--dac_cert \"${CHIP_ROOT}/credentials/development/attestation/Matter-Development-DAC-${raw_pid_upper}-Cert.der\"\n") string(APPEND script_args "--dac_key \"${CHIP_ROOT}/credentials/development/attestation/Matter-Development-DAC-${raw_pid_upper}-Key.der\"\n") string(APPEND script_args "--pai_cert \"${CHIP_ROOT}/credentials/development/attestation/Matter-Development-PAI-noPID-Cert.der\"\n") +elseif(CONFIG_CHIP_FACTORY_DATA_CERT_SOURCE_USER) + string(APPEND script_args "--dac_cert \"${CONFIG_CHIP_FACTORY_DATA_USER_CERTS_DAC_CERT}\"\n") + string(APPEND script_args "--dac_key \"${CONFIG_CHIP_FACTORY_DATA_USER_CERTS_DAC_KEY}\"\n") + string(APPEND script_args "--pai_cert \"${CONFIG_CHIP_FACTORY_DATA_USER_CERTS_PAI_CERT}\"\n") else() find_program(chip_cert_exe NAMES chip-cert REQUIRED) string(APPEND script_args "--gen_cd\n") diff --git a/credentials/test/attestation/Chip-Test-PAA-NoVID-ToResignPAIs-Cert.der b/credentials/test/attestation/Chip-Test-PAA-NoVID-ToResignPAIs-Cert.der new file mode 100644 index 00000000000000..93f956666154af Binary files /dev/null and b/credentials/test/attestation/Chip-Test-PAA-NoVID-ToResignPAIs-Cert.der differ diff --git a/credentials/test/attestation/Chip-Test-PAA-NoVID-ToResignPAIs-Cert.pem b/credentials/test/attestation/Chip-Test-PAA-NoVID-ToResignPAIs-Cert.pem new file mode 100644 index 00000000000000..5c28c0a147b4a6 --- /dev/null +++ b/credentials/test/attestation/Chip-Test-PAA-NoVID-ToResignPAIs-Cert.pem @@ -0,0 +1,12 @@ +-----BEGIN CERTIFICATE----- +MIIBsDCCAVagAwIBAgIIfQAKFyO+3wYwCgYIKoZIzj0EAwIwKTEnMCUGA1UEAwwe +TWF0dGVyIFRlc3QgUEFBIFRvIFJlc2lnbiBQQUlzMCAXDTIxMDYyODE0MjM0M1oY +Dzk5OTkxMjMxMjM1OTU5WjApMScwJQYDVQQDDB5NYXR0ZXIgVGVzdCBQQUEgVG8g +UmVzaWduIFBBSXMwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAAQQ7wKoGoe2gSH7 +qNMZePgHoxflCqioKERoKJFLkz3o7dSlw5yf9xpM42R/1/YmU7fSSV/LpMD0f4do +gAOeByBKo2YwZDASBgNVHRMBAf8ECDAGAQH/AgEBMA4GA1UdDwEB/wQEAwIBBjAd +BgNVHQ4EFgQUeFznBbhrj05vx5OqYMtD6mlogtUwHwYDVR0jBBgwFoAUeFznBbhr +j05vx5OqYMtD6mlogtUwCgYIKoZIzj0EAwIDSAAwRQIge2P1stiHl9JjsD+th707 +jIa88A+Zb6hz6P0vgGDCHW8CIQCS4Uyz9pfBj4yFTR9wVL5vGqvOzPPVngzSwnIM +svDIdg== +-----END CERTIFICATE----- diff --git a/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-Resigned-Cert.der b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-Resigned-Cert.der new file mode 100644 index 00000000000000..bb13cb0f7d8247 Binary files /dev/null and b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-Resigned-Cert.der differ diff --git a/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-Resigned-Cert.pem b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-Resigned-Cert.pem new file mode 100644 index 00000000000000..b3620594118e4a --- /dev/null +++ b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-Resigned-Cert.pem @@ -0,0 +1,12 @@ +-----BEGIN CERTIFICATE----- +MIIBzTCCAXOgAwIBAgIIYnLHqgoTIJ0wCgYIKoZIzj0EAwIwKTEnMCUGA1UEAwwe +TWF0dGVyIFRlc3QgUEFBIFRvIFJlc2lnbiBQQUlzMCAXDTIxMDYyODE0MjM0M1oY +Dzk5OTkxMjMxMjM1OTU5WjBGMRgwFgYDVQQDDA9NYXR0ZXIgVGVzdCBQQUkxFDAS +BgorBgEEAYKifAIBDARGRkYyMRQwEgYKKwYBBAGConwCAgwEODAwMTBZMBMGByqG +SM49AgEGCCqGSM49AwEHA0IABCwGPCCLt88/idiccLJo3sLwrYkZLwIvlUetzHIq +BoBpynI1YIO3JHcbIXZMskxXEbU+/of+T+C0cxQbzKEEso2jZjBkMBIGA1UdEwEB +/wQIMAYBAf8CAQAwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTQWptncaGjepvB +nZXotduPQwC2OjAfBgNVHSMEGDAWgBR4XOcFuGuPTm/Hk6pgy0PqaWiC1TAKBggq +hkjOPQQDAgNIADBFAiEAnw1UN+kJn4U4ylMO6J0qs2QkXOkrIcnKvseb1U0Y5hwC +IHbQ5x/16FDq3QfUgx51RtF51uK22OHGF6xWpeyhVAI4 +-----END CERTIFICATE----- diff --git a/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Cert.der b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Cert.der new file mode 100644 index 00000000000000..89b0d9ded65a0b Binary files /dev/null and b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Cert.der differ diff --git a/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Cert.pem b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Cert.pem new file mode 100644 index 00000000000000..3eed75c53562ae --- /dev/null +++ b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Cert.pem @@ -0,0 +1,12 @@ +-----BEGIN CERTIFICATE----- +MIIBzDCCAXOgAwIBAgIITzzC3bEdxMswCgYIKoZIzj0EAwIwKTEnMCUGA1UEAwwe +TWF0dGVyIFRlc3QgUEFBIFRvIFJlc2lnbiBQQUlzMCAXDTIxMDYyODE0MjM0M1oY +Dzk5OTkxMjMxMjM1OTU5WjBGMRgwFgYDVQQDDA9NYXR0ZXIgVGVzdCBQQUkxFDAS +BgorBgEEAYKifAIBDARGRkYyMRQwEgYKKwYBBAGConwCAgwEODAwMTBZMBMGByqG +SM49AgEGCCqGSM49AwEHA0IABKH6SCo8kvOkZmOc4zVxOLakyd1EdhaOx+xcRQgr +3BvAbZuU00x53wXfxAsnEIBEC3qItDY4rEye5DnHQZwU3fqjZjBkMBIGA1UdEwEB +/wQIMAYBAf8CAQAwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTbd9JbY20EOKGS +HEFSED7q4sQ7BzAfBgNVHSMEGDAWgBR4XOcFuGuPTm/Hk6pgy0PqaWiC1TAKBggq +hkjOPQQDAgNHADBEAiAFHzA0Vv3rAf/95Hmf+7Q9bdFIZTSK1j+SusvKYMgcKQIg +ERLDCvsqkvYALhR4OSA7Rdu4JVFhsP0M0F4MpMRwyPE= +-----END CERTIFICATE----- diff --git a/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Key.der b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Key.der new file mode 100644 index 00000000000000..b3791b55bb3686 Binary files /dev/null and b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Key.der differ diff --git a/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Key.pem b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Key.pem new file mode 100644 index 00000000000000..7b19f537833cf5 --- /dev/null +++ b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEINGuYvtNswX+o4yj6UR0TRvAv/mUqHTcxfV6F/i1GFE1oAoGCCqGSM49 +AwEHoUQDQgAEofpIKjyS86RmY5zjNXE4tqTJ3UR2Fo7H7FxFCCvcG8Btm5TTTHnf +Bd/ECycQgEQLeoi0NjisTJ7kOcdBnBTd+g== +-----END EC PRIVATE KEY----- diff --git a/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSubjectDiff-Cert.der b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSubjectDiff-Cert.der new file mode 100644 index 00000000000000..9bb62f9625d67c Binary files /dev/null and b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSubjectDiff-Cert.der differ diff --git a/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSubjectDiff-Cert.pem b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSubjectDiff-Cert.pem new file mode 100644 index 00000000000000..3e28439c9a470f --- /dev/null +++ b/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSubjectDiff-Cert.pem @@ -0,0 +1,12 @@ +-----BEGIN CERTIFICATE----- +MIIB1jCCAXygAwIBAgIIR+1jaCGXaTEwCgYIKoZIzj0EAwIwKTEnMCUGA1UEAwwe +TWF0dGVyIFRlc3QgUEFBIFRvIFJlc2lnbiBQQUlzMCAXDTIxMDYyODE0MjM0M1oY +Dzk5OTkxMjMxMjM1OTU5WjBPMSEwHwYDVQQDDBhNYXR0ZXIgVGVzdCBQQUkgUmVz +aWduZWQxFDASBgorBgEEAYKifAIBDARGRkYyMRQwEgYKKwYBBAGConwCAgwEODAw +MTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCwGPCCLt88/idiccLJo3sLwrYkZ +LwIvlUetzHIqBoBpynI1YIO3JHcbIXZMskxXEbU+/of+T+C0cxQbzKEEso2jZjBk +MBIGA1UdEwEB/wQIMAYBAf8CAQAwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTQ +WptncaGjepvBnZXotduPQwC2OjAfBgNVHSMEGDAWgBR4XOcFuGuPTm/Hk6pgy0Pq +aWiC1TAKBggqhkjOPQQDAgNIADBFAiEA6LLGEXBKVAZ5DMXIhzg4iQOcGO3yPV7i +VRUOD/R178kCIH8NlJHm5pHAVcugsEpykHaiWC+zueMKFb7D0FzpES/8 +-----END CERTIFICATE----- diff --git a/credentials/test/attestation/Chip-Test-PAI-FFF2-NoPID-Resigned-Cert.der b/credentials/test/attestation/Chip-Test-PAI-FFF2-NoPID-Resigned-Cert.der new file mode 100644 index 00000000000000..8c7bc50d173b66 Binary files /dev/null and b/credentials/test/attestation/Chip-Test-PAI-FFF2-NoPID-Resigned-Cert.der differ diff --git a/credentials/test/attestation/Chip-Test-PAI-FFF2-NoPID-Resigned-Cert.pem b/credentials/test/attestation/Chip-Test-PAI-FFF2-NoPID-Resigned-Cert.pem new file mode 100644 index 00000000000000..d65148427a2dbb --- /dev/null +++ b/credentials/test/attestation/Chip-Test-PAI-FFF2-NoPID-Resigned-Cert.pem @@ -0,0 +1,12 @@ +-----BEGIN CERTIFICATE----- +MIIBtzCCAV2gAwIBAgIIXQpZwBdLO2UwCgYIKoZIzj0EAwIwKTEnMCUGA1UEAwwe +TWF0dGVyIFRlc3QgUEFBIFRvIFJlc2lnbiBQQUlzMCAXDTIxMDYyODE0MjM0M1oY +Dzk5OTkxMjMxMjM1OTU5WjAwMRgwFgYDVQQDDA9NYXR0ZXIgVGVzdCBQQUkxFDAS +BgorBgEEAYKifAIBDARGRkYyMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE2L+T +R5LPjq7awk/8lmyRdiD7ly+6uY7G1RMUoHrpjhoD+0GR0m4tEny5UnYhw26XOhhs +VtDK2ZmwQcJwqbHLP6NmMGQwEgYDVR0TAQH/BAgwBgEB/wIBADAOBgNVHQ8BAf8E +BAMCAQYwHQYDVR0OBBYEFGE90Ic1XvCLrgHkxpqPxz2sjH39MB8GA1UdIwQYMBaA +FHhc5wW4a49Ob8eTqmDLQ+ppaILVMAoGCCqGSM49BAMCA0gAMEUCIH5fn1//Bus5 +/xNPWu1/P5ZhP+Lxf097v1EkPipzU3D4AiEA7FR9eHPbRYDx6NjpLsrsJF2ICogX +/NgcZ6j65JWO2oI= +-----END CERTIFICATE----- diff --git a/credentials/test/gen-test-attestation-certs.sh b/credentials/test/gen-test-attestation-certs.sh index 2bd8d85894211c..83bc7668a62bb2 100755 --- a/credentials/test/gen-test-attestation-certs.sh +++ b/credentials/test/gen-test-attestation-certs.sh @@ -309,6 +309,37 @@ cert_lifetime=4294967295 "$chip_cert_tool" gen-att-cert --type d --subject-cn "Matter Test DAC $dac" --subject-vid "$vid" --subject-pid "$pid" --valid-from "$cert_valid_from_1sec_before_in_future" --lifetime "$cert_lifetime_1year" --ca-key "$pai_key_file".pem --ca-cert "$pai_cert_file".pem --out-key "$dac_key_file".pem --out "$dac_cert_file".pem } +# Set #7: +# - Generate new PAA to resign already generated PAIs +{ + vid=FFF2 + pid=8001 + + paa_key_file="$dest_dir/Chip-Test-PAA-NoVID-Key" + paa_cert_file="$dest_dir/Chip-Test-PAA-NoVID-ToResignPAIs-Cert" + + "$chip_cert_tool" gen-att-cert --type a --subject-cn "Matter Test PAA To Resign PAIs" --valid-from "$cert_valid_from" --lifetime "$cert_lifetime" --key "$paa_key_file".pem --out "$paa_cert_file".pem + + pai_key_file="$dest_dir/Chip-Test-PAI-$vid-$pid-Key" + pai_cert_file="$dest_dir/Chip-Test-PAI-$vid-$pid-Resigned-Cert" + + "$chip_cert_tool" gen-att-cert --type i --subject-cn "Matter Test PAI" --subject-vid "$vid" --subject-pid "$pid" --valid-from "$cert_valid_from" --lifetime "$cert_lifetime" --ca-key "$paa_key_file".pem --ca-cert "$paa_cert_file".pem --key "$pai_key_file".pem --out "$pai_cert_file".pem + + pai_cert_file="$dest_dir/Chip-Test-PAI-$vid-$pid-ResignedSubjectDiff-Cert" + + "$chip_cert_tool" gen-att-cert --type i --subject-cn "Matter Test PAI Resigned" --subject-vid "$vid" --subject-pid "$pid" --valid-from "$cert_valid_from" --lifetime "$cert_lifetime" --ca-key "$paa_key_file".pem --ca-cert "$paa_cert_file".pem --key "$pai_key_file".pem --out "$pai_cert_file".pem + + pai_key_file="$dest_dir/Chip-Test-PAI-$vid-$pid-ResignedSKIDDiff-Key" + pai_cert_file="$dest_dir/Chip-Test-PAI-$vid-$pid-ResignedSKIDDiff-Cert" + + "$chip_cert_tool" gen-att-cert --type i --subject-cn "Matter Test PAI" --subject-vid "$vid" --subject-pid "$pid" --valid-from "$cert_valid_from" --lifetime "$cert_lifetime" --ca-key "$paa_key_file".pem --ca-cert "$paa_cert_file".pem --out-key "$pai_key_file".pem --out "$pai_cert_file".pem + + pai_key_file="$dest_dir/Chip-Test-PAI-$vid-NoPID-Key" + pai_cert_file="$dest_dir/Chip-Test-PAI-$vid-NoPID-Resigned-Cert" + + "$chip_cert_tool" gen-att-cert --type i --subject-cn "Matter Test PAI" --subject-vid "$vid" --valid-from "$cert_valid_from" --lifetime "$cert_lifetime" --ca-key "$paa_key_file".pem --ca-cert "$paa_cert_file".pem --key "$pai_key_file".pem --out "$pai_cert_file".pem +} + # In addition to PEM format also create certificates in DER form. for cert_file_pem in "$dest_dir"/*Cert.pem; do cert_file_der="${cert_file_pem/.pem/.der}" @@ -366,7 +397,7 @@ namespace TestCerts { printf "$header_includes" >>"$output_cstyle_file".h printf "$namespaces_open\n" >>"$output_cstyle_file".cpp printf "$namespaces_open\n" >>"$output_cstyle_file".h - for cert_file_pem in credentials/test/attestation/*Cert.pem; do + for cert_file_pem in "$dest_dir"/*Cert.pem; do params_prefix="${cert_file_pem/*Chip-Test/sTestCert}" params_prefix="${params_prefix//-/_}" params_prefix="${params_prefix/_Cert.pem/}" @@ -387,24 +418,31 @@ namespace TestCerts { printf "};\n\n" printf "extern const ByteSpan ${params_prefix}_SKID = ByteSpan(${params_prefix}_SKID_Array);\n\n" - printf "// \${chip_root}/$key_file_pem\n\n" + # Print key data if present + if test -f "$key_file_pem"; then + printf "// \${chip_root}/$key_file_pem\n\n" - printf "constexpr uint8_t ${params_prefix}_PublicKey_Array[] = {\n" - openssl ec -text -noout -in "$key_file_pem" | sed '0,/pub:$/d' | sed '/ASN1 OID:/,$d' | sed 's/:/ /g' | sed 's/\/,/g' | sed "s/^[ \t]*/ /" | sed 's/ *$//' - printf "};\n\n" - printf "extern const ByteSpan ${params_prefix}_PublicKey = ByteSpan(${params_prefix}_PublicKey_Array);\n\n" + printf "constexpr uint8_t ${params_prefix}_PublicKey_Array[] = {\n" + openssl ec -text -noout -in "$key_file_pem" | sed '0,/pub:$/d' | sed '/ASN1 OID:/,$d' | sed 's/:/ /g' | sed 's/\/,/g' | sed "s/^[ \t]*/ /" | sed 's/ *$//' + printf "};\n\n" + printf "extern const ByteSpan ${params_prefix}_PublicKey = ByteSpan(${params_prefix}_PublicKey_Array);\n\n" - printf "constexpr uint8_t ${params_prefix}_PrivateKey_Array[] = {\n" - openssl ec -text -noout -in "$key_file_pem" | sed '0,/priv:$/d' | sed '/pub:/,$d' | sed 's/:/ /g' | sed 's/\/,/g' | sed "s/^[ \t]*/ /" | sed 's/ *$//' - printf "};\n\n" - printf "extern const ByteSpan ${params_prefix}_PrivateKey = ByteSpan(${params_prefix}_PrivateKey_Array);\n\n" + printf "constexpr uint8_t ${params_prefix}_PrivateKey_Array[] = {\n" + openssl ec -text -noout -in "$key_file_pem" | sed '0,/priv:$/d' | sed '/pub:/,$d' | sed 's/:/ /g' | sed 's/\/,/g' | sed "s/^[ \t]*/ /" | sed 's/ *$//' + printf "};\n\n" + printf "extern const ByteSpan ${params_prefix}_PrivateKey = ByteSpan(${params_prefix}_PrivateKey_Array);\n\n" + fi } >>"$output_cstyle_file".cpp { printf "extern const ByteSpan ${params_prefix}_Cert;\n" printf "extern const ByteSpan ${params_prefix}_SKID;\n" - printf "extern const ByteSpan ${params_prefix}_PublicKey;\n" - printf "extern const ByteSpan ${params_prefix}_PrivateKey;\n\n" + # Print key data if present + if test -f "$key_file_pem"; then + printf "extern const ByteSpan ${params_prefix}_PublicKey;\n" + printf "extern const ByteSpan ${params_prefix}_PrivateKey;\n" + fi + printf "\n" } >>"$output_cstyle_file".h done diff --git a/docs/code_generation.md b/docs/code_generation.md index 7deed7ba05fb1a..c676fa887ebd7c 100644 --- a/docs/code_generation.md +++ b/docs/code_generation.md @@ -84,9 +84,10 @@ specific codegen. ### `*.matter` parsing and codegen `*.matter` files are both human and machine readable. Code that can process -these files is available at `scripts/idl` and `scripts/codegen.py`. You can read -the [scripts/idl/README.md](../scripts/idl/README.md) for details of how things -work. +these files is available at `scripts/py_matter_idl` and `scripts/codegen.py`. +You can read the +[scripts/py_matter_idl/matter_idl/README.md](../scripts/py_matter_idl/matter_idl/README.md) +for details of how things work. `scripts/codegen.py` can generate various outputs based on an input `*.matter` file. @@ -198,7 +199,7 @@ Code pre-generation can be used: generation at build time or to save the code generation time at the expense of running code generation for every possible zap/generation type - To check changes in generated code across versions, beyond the comparisons - of golden image tests in `scripts/idl/tests` + of golden image tests in `scripts/py_matter_idl/matter_idl/tests` The script to trigger code pre-generation is `scripts/code_pregenerate.py` and requires the pre-generation output directory as an argument diff --git a/docs/guides/nrfconnect_factory_data_configuration.md b/docs/guides/nrfconnect_factory_data_configuration.md index 4f3e054feb05d9..c0152276f00737 100644 --- a/docs/guides/nrfconnect_factory_data_configuration.md +++ b/docs/guides/nrfconnect_factory_data_configuration.md @@ -39,6 +39,8 @@ data secure by applying hardware write protection. - [Enabling factory data support](#enabling-factory-data-support) - [Generating factory data](#generating-factory-data) - [Creating factory data JSON file with the first script](#creating-factory-data-json-file-with-the-first-script) + - [How to set user data](#how-to-set-user-data) + - [How to handle user data](#how-to-handle-user-data) - [Verifying using the JSON Schema tool](#verifying-using-the-json-schema-tool) - [Option 1: Using the php-json-schema tool](#option-1-using-the-php-json-schema-tool) - [Option 2: Using a website validator](#option-2-using-a-website-validator) @@ -106,7 +108,7 @@ The following table lists the parameters of a factory data set: | `spake2_verifier` | SPAKE2+ verifier | 97 B | byte string | mandatory | The SPAKE2+ verifier generated using SPAKE2+ salt, iteration counter, and passcode. | | `discriminator` | Discriminator | 2 B | uint16 | mandatory | A 12-bit value matching the field of the same name in the setup code. The discriminator is used during the discovery process. | | `passcode` | SPAKE passcode | 4 B | uint32 | optional | A pairing passcode is a 27-bit unsigned integer which serves as a proof of possession during the commissioning. Its value must be restricted to the values from `0x0000001` to `0x5F5E0FE` (`00000001` to `99999998` in decimal), excluding the following invalid passcode values: `00000000`, `11111111`, `22222222`, `33333333`, `44444444`, `55555555`, `66666666`, `77777777`, `88888888`, `99999999`, `12345678`, `87654321`. | -| `user` | User data | variable | JSON string | max 1024 B | The user data is provided in the JSON format. This parameter is optional and depends on user's or manufacturer's purpose (or both). It is provided as a string from persistent storage and should be parsed in the user application. This data is not used by the Matter stack. | +| `user` | User data | variable | JSON string | max 1024 B | The user data is provided in the JSON format. This parameter is optional and depends on device manufacturer's purpose. It is provided as a CBOR map type from persistent storage and should be parsed in the user application. This data is not used by the Matter stack. To learn how to work with user data, see [How to set user data](#how-to-set-user-data) section. | ### Factory data format @@ -340,6 +342,89 @@ If the script finishes successfully, go to the location you provided with the > location as an existing file. To allow overwriting, add the `--overwrite` > option to the argument list of the Python script. +### How to set user data + +The user data is an optional field provided in the factory data JSON file and +depends on the manufacturer's purpose. The `user` field in a JSON factory data +file is represented by a flat JSON map and it can consist of `string` or `int32` +data types only. On the device side, the `user` data will be available as a CBOR +map containing all defined `string` and `int32` fields. + +To add user data as an argument to the +[generate_nrfconnect_chip_factory_data.py](../../scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py) +script, add the following line to the argument list: + +``` +--user-data {user data JSON} +``` + +As `user data JSON`, provide a flat JSON map with a value file that consists of +`string` or `int32` types. For example, you can use a JSON file that looks like +follows: + +``` +{ + "name": "product_name", + "version": 123, + "revision": "0x123" +} +``` + +When added to the argument line, the final result would look like follows: + +``` +--user-data '{"name": "product_name", "version": 123, "revision": "0x123"}' +``` + +#### How to handle user data + +The user data is not handled anywhere in the Matter stack, so you must handle it +in your application. To do this, you can use the +[Factory Data Provider](../../src/platform/nrfconnect/FactoryDataProvider.h) and +apply one of the following methods: + +- `GetUserData` method to obtain raw data in the CBOR format as a + `MutableByteSpan`. + +- `GetUserKey` method that lets you search along the user data list using a + specific key, and if the key exists in the user data, the method returns its + value. + +If you opt for `GetUserKey`, complete the following steps to set up the search: + +1. Add the `GetUserKey` method to your code. + +2. Given that all integer fields of the `user` Factory Data field are `int32`, + provide a buffer that has a size of at least `4B` or an `int32_t` variable to + `GetUserKey`. To read a string field from user data, the buffer should have a + size of at least the length of the expected string. + +3. Set it up to read all user data fields. + +Only after this setup is complete, can you use all variables in your code and +cast the result to your own purpose. + +The code example of how to read all fields from the JSON example one by one can +look like follows: + + ``` + chip::DeviceLayer::FactoryDataProvider factoryDataProvider; + + factoryDataProvider.Init(); + + uint8_t user_name[12]; + size_t name_len = sizeof(user_name); + factoryDataProvider.GetUserKey("name", user_name, name_len); + + int32_t version; + size_t version_len = sizeof(version); + factoryDataProvider.GetUserKey("version", &version, version_len); + + uint8_t revision[5]; + size_t revision_len = sizeof(revision); + factoryDataProvider.GetUserKey("revision", revision, revision_len); + ``` + ### Verifying using the JSON Schema tool The JSON file that contains factory data can be verified using the diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index 754985f37dd4f4..d3c4b3c21e166e 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -862,6 +862,21 @@ server cluster PowerSource = 47 { kReplaceable = 0x8; } + info event WiredFaultChange = 0 { + WiredFault current[] = 0; + WiredFault previous[] = 1; + } + + info event BatFaultChange = 1 { + BatFault current[] = 0; + BatFault previous[] = 1; + } + + info event BatChargeFaultChange = 2 { + BatChargeFault current[] = 0; + BatChargeFault previous[] = 1; + } + readonly attribute PowerSourceStatus status = 0; readonly attribute int8u order = 1; readonly attribute char_string<60> description = 2; @@ -964,7 +979,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter index 58e0c12b20d3e9..78a720bf22610c 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter @@ -794,6 +794,21 @@ server cluster PowerSource = 47 { kReplaceable = 0x8; } + info event WiredFaultChange = 0 { + WiredFault current[] = 0; + WiredFault previous[] = 1; + } + + info event BatFaultChange = 1 { + BatFault current[] = 0; + BatFault previous[] = 1; + } + + info event BatChargeFaultChange = 2 { + BatChargeFault current[] = 0; + BatChargeFault previous[] = 1; + } + readonly attribute PowerSourceStatus status = 0; readonly attribute int8u order = 1; readonly attribute char_string<60> description = 2; @@ -893,7 +908,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/bridge-app/bridge-common/bridge-app.matter b/examples/bridge-app/bridge-common/bridge-app.matter index bc512081ede0c3..9e196b071bb2df 100644 --- a/examples/bridge-app/bridge-common/bridge-app.matter +++ b/examples/bridge-app/bridge-common/bridge-app.matter @@ -654,7 +654,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter b/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter index b581d736f30482..64f4e158311dc2 100644 --- a/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter +++ b/examples/chef/devices/rootnode_colortemperaturelight_hbUnzYVeyn.matter @@ -624,7 +624,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter b/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter index cfaef808114702..92c6d0e9a303bd 100644 --- a/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter +++ b/examples/chef/devices/rootnode_contactsensor_lFAGG1bfRO.matter @@ -497,7 +497,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter b/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter index 7c314a9211d015..5d9520811f7de6 100644 --- a/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter +++ b/examples/chef/devices/rootnode_dimmablelight_bCwGYSDpoe.matter @@ -646,7 +646,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter b/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter index 472e9477262e0a..d60f528e15b86f 100644 --- a/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter +++ b/examples/chef/devices/rootnode_doorlock_aNKYAreMXE.matter @@ -497,7 +497,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter b/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter index dff1a98eed5aa3..9657afc4259cea 100644 --- a/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter +++ b/examples/chef/devices/rootnode_extendedcolorlight_8lcaaYJVAa.matter @@ -646,7 +646,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_fan_7N2TobIlOX.matter b/examples/chef/devices/rootnode_fan_7N2TobIlOX.matter index 15e0a1034d897c..0da03778068ce3 100644 --- a/examples/chef/devices/rootnode_fan_7N2TobIlOX.matter +++ b/examples/chef/devices/rootnode_fan_7N2TobIlOX.matter @@ -499,7 +499,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter b/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter index 7c6446e1e8cc9b..f1551f204ef330 100644 --- a/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter +++ b/examples/chef/devices/rootnode_flowsensor_1zVxHedlaV.matter @@ -510,7 +510,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter b/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter index 3b36f2ae987519..ee51f83d2e671b 100644 --- a/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter +++ b/examples/chef/devices/rootnode_heatingcoolingunit_ncdGai1E5a.matter @@ -639,7 +639,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter b/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter index 39ad6dd5f3013c..b8d3088688c159 100644 --- a/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter +++ b/examples/chef/devices/rootnode_humiditysensor_Xyj4gda6Hb.matter @@ -510,7 +510,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter b/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter index a0a6b310a10319..3c337b37201a94 100644 --- a/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter +++ b/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter @@ -510,7 +510,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter b/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter index 770f2495594654..dbe0949d0bef74 100644 --- a/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter +++ b/examples/chef/devices/rootnode_occupancysensor_iHyVgifZuo.matter @@ -510,7 +510,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.matter b/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.matter index f3f026c679f961..736958cc69273b 100644 --- a/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.matter +++ b/examples/chef/devices/rootnode_onofflight_bbs1b7IaOV.matter @@ -646,7 +646,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter b/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter index 647f5be459e9da..2d3dab4480ef7b 100644 --- a/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter +++ b/examples/chef/devices/rootnode_onofflightswitch_FsPlMr090Q.matter @@ -589,7 +589,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter b/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter index e5a1c171203196..9c6d87a08b45a2 100644 --- a/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter +++ b/examples/chef/devices/rootnode_onoffpluginunit_Wtf8ss5EBY.matter @@ -547,7 +547,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter b/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter index efb2f5ebbb9e58..a05ec34df74a70 100644 --- a/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter +++ b/examples/chef/devices/rootnode_pressuresensor_s0qC9wLH4k.matter @@ -515,7 +515,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter b/examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter index 0a3f54e975dfb5..b22236fb5eaad6 100644 --- a/examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter +++ b/examples/chef/devices/rootnode_speaker_RpzeXdimqA.matter @@ -637,7 +637,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter b/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter index 4ca3f3231e275f..956938cf4a91a1 100644 --- a/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter +++ b/examples/chef/devices/rootnode_temperaturesensor_Qy1zkNW7c3.matter @@ -510,7 +510,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter index 35202e6eb9c2e6..c15a487a642a67 100644 --- a/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter +++ b/examples/chef/devices/rootnode_thermostat_bm3fb8dhYi.matter @@ -497,7 +497,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter b/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter index 455c6dc74ddb73..729ceff4fe6636 100644 --- a/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter +++ b/examples/chef/devices/rootnode_windowcovering_RLCxaGi9Yx.matter @@ -497,7 +497,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/chip-tool/BUILD.gn b/examples/chip-tool/BUILD.gn index 86e003a69201c4..4b2a0cee169cb6 100644 --- a/examples/chip-tool/BUILD.gn +++ b/examples/chip-tool/BUILD.gn @@ -59,6 +59,7 @@ static_library("chip-tool-utils") { "commands/common/Commands.h", "commands/common/CredentialIssuerCommands.h", "commands/common/HexConversion.h", + "commands/delay/SleepCommand.cpp", "commands/discover/DiscoverCommand.cpp", "commands/discover/DiscoverCommissionablesCommand.cpp", "commands/discover/DiscoverCommissionersCommand.cpp", diff --git a/examples/chip-tool/commands/clusters/ClusterCommand.h b/examples/chip-tool/commands/clusters/ClusterCommand.h index f6cb307021ac5d..c2562843e024a8 100644 --- a/examples/chip-tool/commands/clusters/ClusterCommand.h +++ b/examples/chip-tool/commands/clusters/ClusterCommand.h @@ -173,6 +173,8 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs, "If provided, do a timed invoke with the given timed interaction timeout. See \"7.6.10. Timed Interaction\" in " "the Matter specification."); + AddArgument("busyWaitForMs", 0, UINT16_MAX, &mBusyWaitForMs, + "If provided, block the main thread processing for the given time right after sending a command."); AddArgument("suppressResponse", 0, 1, &mSuppressResponse); AddArgument("repeat-count", 1, UINT16_MAX, &mRepeatCount); AddArgument("repeat-delay-ms", 0, UINT16_MAX, &mRepeatDelayInMs); diff --git a/examples/chip-tool/commands/clusters/WriteAttributeCommand.h b/examples/chip-tool/commands/clusters/WriteAttributeCommand.h index 56363cb481721d..9b5e8f3ef70728 100644 --- a/examples/chip-tool/commands/clusters/WriteAttributeCommand.h +++ b/examples/chip-tool/commands/clusters/WriteAttributeCommand.h @@ -228,6 +228,8 @@ class WriteAttribute : public InteractionModelWriter, public ModelCommand, publi AddArgument("timedInteractionTimeoutMs", 0, UINT16_MAX, &mTimedInteractionTimeoutMs, "If provided, do a timed write with the given timed interaction timeout. See \"7.6.10. Timed Interaction\" in " "the Matter specification."); + AddArgument("busyWaitForMs", 0, UINT16_MAX, &mBusyWaitForMs, + "If provided, block the main thread processing for the given time right after sending a command."); AddArgument("data-version", 0, UINT32_MAX, &mDataVersions, "Comma-separated list of data versions for the clusters being written."); AddArgument("suppressResponse", 0, 1, &mSuppressResponse); diff --git a/examples/chip-tool/commands/delay/Commands.h b/examples/chip-tool/commands/delay/Commands.h new file mode 100644 index 00000000000000..337de3b14d217a --- /dev/null +++ b/examples/chip-tool/commands/delay/Commands.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * 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 "commands/common/Commands.h" +#include "commands/delay/SleepCommand.h" + +void registerCommandsDelay(Commands & commands, CredentialIssuerCommands * credsIssuerConfig) +{ + const char * clusterName = "Delay"; + commands_list clusterCommands = { + make_unique(credsIssuerConfig), // + }; + + commands.Register(clusterName, clusterCommands); +} diff --git a/examples/chip-tool/commands/delay/SleepCommand.cpp b/examples/chip-tool/commands/delay/SleepCommand.cpp new file mode 100644 index 00000000000000..de1db49b4b3f5f --- /dev/null +++ b/examples/chip-tool/commands/delay/SleepCommand.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * 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 "SleepCommand.h" +#include +#include + +CHIP_ERROR SleepCommand::RunCommand() +{ + std::this_thread::sleep_for(std::chrono::milliseconds(mDurationInMs)); + SetCommandExitStatus(CHIP_NO_ERROR); + return CHIP_NO_ERROR; +} diff --git a/examples/chip-tool/commands/delay/SleepCommand.h b/examples/chip-tool/commands/delay/SleepCommand.h new file mode 100644 index 00000000000000..aa1cddcbf94be8 --- /dev/null +++ b/examples/chip-tool/commands/delay/SleepCommand.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * 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 "../common/CHIPCommand.h" + +/** + * This command blocks the event loop processing for a given amount of time. + * + * For example when the event loop is blocked the messages coming-in will not be acked, + * forcing a retransmission on the other side. + * + */ + +class SleepCommand : public CHIPCommand +{ +public: + SleepCommand(CredentialIssuerCommands * credIssuerCommands) : CHIPCommand("sleep", credIssuerCommands) + { + AddArgument("duration-in-ms", 0, UINT32_MAX, &mDurationInMs, + "Block the event loop processing for duration-in-ms milliseconds."); + } + + /////////// CHIPCommand Interface ///////// + CHIP_ERROR RunCommand() override; + chip::System::Clock::Timeout GetWaitDuration() const override + { + // The allowed duration of this method is at least as long as the time specified for blocking the + // event loop. In order to not fail on some small delays in processing some extra time before + // failing is added. + constexpr uint16_t mExtraTimeForFailure = 1000; + + return chip::System::Clock::Milliseconds32(mDurationInMs + mExtraTimeForFailure); + } + +private: + uint32_t mDurationInMs; +}; diff --git a/examples/chip-tool/main.cpp b/examples/chip-tool/main.cpp index c9a391b25e5f98..0ca5b243c9243e 100644 --- a/examples/chip-tool/main.cpp +++ b/examples/chip-tool/main.cpp @@ -19,6 +19,7 @@ #include "commands/common/Commands.h" #include "commands/example/ExampleCredentialIssuerCommands.h" +#include "commands/delay/Commands.h" #include "commands/discover/Commands.h" #include "commands/group/Commands.h" #include "commands/interactive/Commands.h" @@ -36,6 +37,7 @@ int main(int argc, char * argv[]) { ExampleCredentialIssuerCommands credIssuerCommands; Commands commands; + registerCommandsDelay(commands, &credIssuerCommands); registerCommandsDiscover(commands, &credIssuerCommands); registerCommandsInteractive(commands, &credIssuerCommands); registerCommandsPayload(commands); diff --git a/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter b/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter index 108218687f5598..0696014926b2f5 100644 --- a/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter +++ b/examples/contact-sensor-app/contact-sensor-common/contact-sensor-app.matter @@ -500,7 +500,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/dynamic-bridge-app/bridge-common/bridge-app.matter b/examples/dynamic-bridge-app/bridge-common/bridge-app.matter index bc512081ede0c3..9e196b071bb2df 100644 --- a/examples/dynamic-bridge-app/bridge-common/bridge-app.matter +++ b/examples/dynamic-bridge-app/bridge-common/bridge-app.matter @@ -654,7 +654,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/light-switch-app/light-switch-common/light-switch-app.matter b/examples/light-switch-app/light-switch-common/light-switch-app.matter index 60163b655d90a8..af2fc54a7ec4ee 100644 --- a/examples/light-switch-app/light-switch-common/light-switch-app.matter +++ b/examples/light-switch-app/light-switch-common/light-switch-app.matter @@ -702,7 +702,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/lighting-app/lighting-common/lighting-app.matter b/examples/lighting-app/lighting-common/lighting-app.matter index 7b2c429fd448c4..34d79e80f4df80 100644 --- a/examples/lighting-app/lighting-common/lighting-app.matter +++ b/examples/lighting-app/lighting-common/lighting-app.matter @@ -658,7 +658,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/lighting-app/nxp/zap/lighting-on-off.matter b/examples/lighting-app/nxp/zap/lighting-on-off.matter index 35d6253d4f3e75..ce768f1eda4bbe 100644 --- a/examples/lighting-app/nxp/zap/lighting-on-off.matter +++ b/examples/lighting-app/nxp/zap/lighting-on-off.matter @@ -612,7 +612,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/lock-app/lock-common/lock-app.matter b/examples/lock-app/lock-common/lock-app.matter index 72510069747932..2e7ff08d46cbaa 100644 --- a/examples/lock-app/lock-common/lock-app.matter +++ b/examples/lock-app/lock-common/lock-app.matter @@ -455,6 +455,21 @@ server cluster PowerSource = 47 { kReplaceable = 0x8; } + info event WiredFaultChange = 0 { + WiredFault current[] = 0; + WiredFault previous[] = 1; + } + + info event BatFaultChange = 1 { + BatFault current[] = 0; + BatFault previous[] = 1; + } + + info event BatChargeFaultChange = 2 { + BatChargeFault current[] = 0; + BatChargeFault previous[] = 1; + } + readonly attribute PowerSourceStatus status = 0; readonly attribute int8u order = 1; readonly attribute char_string<60> description = 2; @@ -559,7 +574,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/log-source-app/log-source-common/log-source-app.matter b/examples/log-source-app/log-source-common/log-source-app.matter index 28341bb99c23f0..e00f69ca61edc0 100644 --- a/examples/log-source-app/log-source-common/log-source-app.matter +++ b/examples/log-source-app/log-source-common/log-source-app.matter @@ -157,7 +157,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/ota-provider-app/ota-provider-common/ota-provider-app.matter b/examples/ota-provider-app/ota-provider-common/ota-provider-app.matter index dafc45b9628fc9..631d8303ffa7c8 100644 --- a/examples/ota-provider-app/ota-provider-common/ota-provider-app.matter +++ b/examples/ota-provider-app/ota-provider-common/ota-provider-app.matter @@ -393,7 +393,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.matter b/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.matter index 00ec6a26d82721..a2ce3e2b02aa6f 100644 --- a/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.matter +++ b/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.matter @@ -558,7 +558,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/placeholder/linux/apps/app1/config.matter b/examples/placeholder/linux/apps/app1/config.matter index 383b1096765494..f8ffde9dff6c9b 100644 --- a/examples/placeholder/linux/apps/app1/config.matter +++ b/examples/placeholder/linux/apps/app1/config.matter @@ -627,6 +627,21 @@ server cluster PowerSource = 47 { kReplaceable = 0x8; } + info event WiredFaultChange = 0 { + WiredFault current[] = 0; + WiredFault previous[] = 1; + } + + info event BatFaultChange = 1 { + BatFault current[] = 0; + BatFault previous[] = 1; + } + + info event BatChargeFaultChange = 2 { + BatChargeFault current[] = 0; + BatChargeFault previous[] = 1; + } + readonly attribute PowerSourceStatus status = 0; readonly attribute int8u order = 1; readonly attribute char_string<60> description = 2; @@ -804,7 +819,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/placeholder/linux/apps/app2/config.matter b/examples/placeholder/linux/apps/app2/config.matter index 383b1096765494..f8ffde9dff6c9b 100644 --- a/examples/placeholder/linux/apps/app2/config.matter +++ b/examples/placeholder/linux/apps/app2/config.matter @@ -627,6 +627,21 @@ server cluster PowerSource = 47 { kReplaceable = 0x8; } + info event WiredFaultChange = 0 { + WiredFault current[] = 0; + WiredFault previous[] = 1; + } + + info event BatFaultChange = 1 { + BatFault current[] = 0; + BatFault previous[] = 1; + } + + info event BatChargeFaultChange = 2 { + BatChargeFault current[] = 0; + BatChargeFault previous[] = 1; + } + readonly attribute PowerSourceStatus status = 0; readonly attribute int8u order = 1; readonly attribute char_string<60> description = 2; @@ -804,7 +819,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/platform/cc13x2_26x2/BUILD.gn b/examples/platform/cc13x2_26x2/BUILD.gn index a886bd6ee48c63..619ecdfa446dc5 100644 --- a/examples/platform/cc13x2_26x2/BUILD.gn +++ b/examples/platform/cc13x2_26x2/BUILD.gn @@ -14,11 +14,22 @@ import("//build_overrides/chip.gni") -config("chip_examples_project_config") { - include_dirs = [ "project_include" ] +config("attestation-credentials-config") { + include_dirs = [ "${chip_root}" ] + + defines = [ "CC13X2_26X2_ATTESTATION_CREDENTIALS" ] } -source_set("openthread_core_config_cc13x2_26x2_chip_examples") { - sources = [ "project_include/OpenThreadConfig.h" ] - public_configs = [ ":chip_examples_project_config" ] +source_set("cc13x2_26x2-attestation-credentials") { + sources = [ + "CC13X2_26X2DeviceAttestationCreds.cpp", + "CC13X2_26X2DeviceAttestationCreds.h", + ] + + public_deps = [ + "${chip_root}/src/credentials", + "${chip_root}/src/platform:platform_base", + ] + + public_configs = [ ":attestation-credentials-config" ] } diff --git a/examples/platform/cc13x2_26x2/CC13X2_26X2DeviceAttestationCreds.cpp b/examples/platform/cc13x2_26x2/CC13X2_26X2DeviceAttestationCreds.cpp new file mode 100644 index 00000000000000..9e39a54c263668 --- /dev/null +++ b/examples/platform/cc13x2_26x2/CC13X2_26X2DeviceAttestationCreds.cpp @@ -0,0 +1,258 @@ +/* + * + * Copyright (c) 2022 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 "CC13X2_26X2DeviceAttestationCreds.h" +#include +#include +#include +#include +#include +#include + +extern uint32_t __attestation_credentials_base; + +namespace chip { +namespace Credentials { +namespace CC13X2_26X2 { + +namespace { + +typedef struct +{ + const uint32_t len; + uint8_t const * data; +} data_ptr; + +typedef struct +{ + data_ptr dac_priv_key; + data_ptr dac_pub_key; + data_ptr dac_cert; + data_ptr pai_cert; +} factoryData; + +const uint8_t gDacPrivKey[] = { + 0x50, 0x5a, 0x21, 0x1d, 0xbd, 0xa8, 0x71, 0x33, 0x0d, 0x63, 0x5d, 0xa3, 0xb0, 0x7e, 0xb1, 0xc5, + 0x08, 0x8a, 0x8f, 0xc7, 0x01, 0x24, 0xfb, 0xb3, 0x3e, 0x93, 0xd5, 0x06, 0x05, 0x82, 0xc7, 0xc5, +}; +const uint8_t gDacPubKey[] = { + 0x04, 0xc5, 0x65, 0xfd, 0xad, 0xfd, 0x16, 0xdd, 0x62, 0xe4, 0x3f, 0x19, 0x60, 0xb9, 0x93, 0xbb, 0x57, + 0x2c, 0xfd, 0xd8, 0x1f, 0x6d, 0x71, 0x67, 0x67, 0x1b, 0x77, 0x45, 0xdc, 0xbe, 0x6f, 0x65, 0xaf, 0x66, + 0x5a, 0x1d, 0x93, 0x1c, 0x05, 0xb9, 0xf9, 0xa3, 0xe9, 0x45, 0x66, 0x85, 0x60, 0x2c, 0x05, 0xc6, 0x96, + 0x46, 0xb8, 0xf7, 0x59, 0x98, 0xdb, 0xaa, 0x68, 0x7a, 0x5c, 0x56, 0x49, 0x02, 0xda, +}; +const uint8_t gDacCert[] = { + 0x30, 0x82, 0x01, 0xf7, 0x30, 0x82, 0x01, 0x9d, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x46, 0x88, 0xeb, 0x94, 0xad, 0x32, + 0xb2, 0xe4, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x4d, 0x31, 0x1f, 0x30, 0x1d, 0x06, + 0x03, 0x55, 0x04, 0x03, 0x0c, 0x16, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x6d, + 0x65, 0x6e, 0x74, 0x20, 0x50, 0x41, 0x49, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, + 0x02, 0x01, 0x0c, 0x04, 0x46, 0x46, 0x46, 0x31, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, + 0x7c, 0x02, 0x02, 0x0c, 0x04, 0x38, 0x30, 0x30, 0x36, 0x30, 0x20, 0x17, 0x0d, 0x32, 0x31, 0x30, 0x36, 0x32, 0x38, 0x31, 0x34, + 0x32, 0x33, 0x34, 0x33, 0x5a, 0x18, 0x0f, 0x39, 0x39, 0x39, 0x39, 0x31, 0x32, 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, + 0x5a, 0x30, 0x52, 0x31, 0x24, 0x30, 0x22, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1b, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, + 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x44, 0x41, 0x43, 0x20, 0x30, 0x30, 0x30, 0x30, 0x31, + 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, 0x01, 0x0c, 0x04, 0x46, 0x46, 0x46, 0x31, + 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, 0x02, 0x0c, 0x04, 0x38, 0x30, 0x30, + 0x36, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, + 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0xc5, 0x65, 0xfd, 0xad, 0xfd, 0x16, 0xdd, 0x62, 0xe4, 0x3f, 0x19, 0x60, 0xb9, 0x93, + 0xbb, 0x57, 0x2c, 0xfd, 0xd8, 0x1f, 0x6d, 0x71, 0x67, 0x67, 0x1b, 0x77, 0x45, 0xdc, 0xbe, 0x6f, 0x65, 0xaf, 0x66, 0x5a, 0x1d, + 0x93, 0x1c, 0x05, 0xb9, 0xf9, 0xa3, 0xe9, 0x45, 0x66, 0x85, 0x60, 0x2c, 0x05, 0xc6, 0x96, 0x46, 0xb8, 0xf7, 0x59, 0x98, 0xdb, + 0xaa, 0x68, 0x7a, 0x5c, 0x56, 0x49, 0x02, 0xda, 0xa3, 0x60, 0x30, 0x5e, 0x30, 0x0c, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, + 0xff, 0x04, 0x02, 0x30, 0x00, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x07, 0x80, + 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x9b, 0x40, 0x60, 0x6f, 0x9e, 0x04, 0x7f, 0xb8, 0x60, 0x78, + 0x8e, 0x3d, 0xc1, 0x12, 0xd7, 0x5e, 0x87, 0x95, 0x77, 0x68, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, + 0x80, 0x14, 0x43, 0x34, 0x57, 0x12, 0xba, 0x2c, 0x87, 0xef, 0x25, 0x49, 0x7b, 0x11, 0xd7, 0x98, 0x58, 0x9b, 0x84, 0x35, 0x7f, + 0x88, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x48, 0x00, 0x30, 0x45, 0x02, 0x21, 0x00, + 0xb9, 0x28, 0xf9, 0x3e, 0xe3, 0x87, 0xef, 0x3e, 0x00, 0x72, 0x88, 0x22, 0x84, 0xbd, 0x8a, 0xdd, 0x5c, 0xd6, 0xd0, 0x55, 0x81, + 0xbf, 0xcc, 0x55, 0x17, 0xcf, 0x9e, 0x9b, 0xcd, 0xd4, 0x37, 0xda, 0x02, 0x20, 0x10, 0x07, 0x9c, 0xcf, 0x7f, 0x1f, 0x2d, 0xda, + 0x46, 0xac, 0xe9, 0x67, 0xae, 0x5b, 0xe9, 0x66, 0xe7, 0xf2, 0x8a, 0xdf, 0xa0, 0x28, 0xb8, 0xf8, 0x7f, 0x93, 0x9e, 0xd4, 0x15, + 0x8d, 0xc0, 0xf8, +}; + +const uint8_t gPaiCert[] = { + 0x30, 0x82, 0x01, 0xdc, 0x30, 0x82, 0x01, 0x81, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x7f, 0x7e, 0xf3, 0xdb, 0x08, 0xa3, + 0x8f, 0x68, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x30, 0x31, 0x18, 0x30, 0x16, 0x06, + 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0f, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x41, + 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, 0x01, 0x0c, 0x04, 0x46, 0x46, 0x46, + 0x31, 0x30, 0x20, 0x17, 0x0d, 0x32, 0x31, 0x30, 0x36, 0x32, 0x38, 0x31, 0x34, 0x32, 0x33, 0x34, 0x33, 0x5a, 0x18, 0x0f, 0x39, + 0x39, 0x39, 0x39, 0x31, 0x32, 0x33, 0x31, 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, 0x4d, 0x31, 0x1f, 0x30, 0x1d, 0x06, + 0x03, 0x55, 0x04, 0x03, 0x0c, 0x16, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x44, 0x65, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x6d, + 0x65, 0x6e, 0x74, 0x20, 0x50, 0x41, 0x49, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, + 0x02, 0x01, 0x0c, 0x04, 0x46, 0x46, 0x46, 0x31, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, + 0x7c, 0x02, 0x02, 0x0c, 0x04, 0x38, 0x30, 0x30, 0x36, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, + 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x42, 0x93, 0x55, 0x77, 0x35, 0x35, + 0x15, 0xce, 0xfa, 0x8f, 0x0e, 0x30, 0xe2, 0x34, 0x7e, 0x90, 0xee, 0xd6, 0xfd, 0x51, 0x5b, 0xe8, 0x82, 0xd1, 0xbc, 0xba, 0x74, + 0x83, 0xd7, 0xff, 0x6e, 0xf4, 0xde, 0xdf, 0x98, 0xf7, 0xf7, 0x4f, 0x17, 0x42, 0x1d, 0xe5, 0x45, 0x0c, 0xff, 0xfb, 0x3e, 0x7f, + 0x6d, 0x4f, 0x62, 0x28, 0x53, 0x41, 0x14, 0xfb, 0xb8, 0x5c, 0x2d, 0x52, 0xd1, 0x82, 0xb6, 0x6a, 0xa3, 0x66, 0x30, 0x64, 0x30, + 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x00, 0x30, 0x0e, + 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, + 0x04, 0x16, 0x04, 0x14, 0x43, 0x34, 0x57, 0x12, 0xba, 0x2c, 0x87, 0xef, 0x25, 0x49, 0x7b, 0x11, 0xd7, 0x98, 0x58, 0x9b, 0x84, + 0x35, 0x7f, 0x88, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0x6a, 0xfd, 0x22, 0x77, 0x1f, + 0x51, 0x1f, 0xec, 0xbf, 0x16, 0x41, 0x97, 0x67, 0x10, 0xdc, 0xdc, 0x31, 0xa1, 0x71, 0x7e, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, + 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x49, 0x00, 0x30, 0x46, 0x02, 0x21, 0x00, 0xff, 0x25, 0xf1, 0xd1, 0x54, 0xc3, 0x13, + 0x7e, 0x0e, 0x08, 0x6d, 0x82, 0xab, 0x0b, 0x11, 0xb5, 0x66, 0x18, 0x39, 0xb7, 0x12, 0xb1, 0x34, 0x2c, 0x6c, 0xde, 0x94, 0xfb, + 0xe3, 0x18, 0xa9, 0x2b, 0x02, 0x21, 0x00, 0x92, 0xe2, 0x81, 0xf9, 0x8a, 0x2f, 0xcc, 0x14, 0xcd, 0xf4, 0x07, 0x50, 0xd2, 0x80, + 0xd7, 0xdf, 0xea, 0x3f, 0x4d, 0xa4, 0x6f, 0x35, 0x7a, 0xfe, 0xac, 0xb8, 0x9b, 0x26, 0x77, 0x06, 0xd2, 0x8a, +}; + +const factoryData gFactoryData = { + .dac_priv_key = { + .len = sizeof(gDacPrivKey), + .data = gDacPrivKey, + }, + .dac_pub_key = { + .len = sizeof(gDacPubKey), + .data = gDacPubKey, + }, + .dac_cert = { + .len = sizeof(gDacCert), + .data = gDacCert, + }, + .pai_cert = { + .len = sizeof(gPaiCert), + .data = gPaiCert, + }, +}; + +CHIP_ERROR LoadKeypairFromRaw(ByteSpan private_key, ByteSpan public_key, Crypto::P256Keypair & keypair) +{ + Crypto::P256SerializedKeypair serialized_keypair; + ReturnErrorOnFailure(serialized_keypair.SetLength(private_key.size() + public_key.size())); + memcpy(serialized_keypair.Bytes(), public_key.data(), public_key.size()); + memcpy(serialized_keypair.Bytes() + public_key.size(), private_key.data(), private_key.size()); + return keypair.Deserialize(serialized_keypair); +} + +class DeviceAttestationCredsCC13X2_26X2 : public DeviceAttestationCredentialsProvider +{ + +public: + CHIP_ERROR GetCertificationDeclaration(MutableByteSpan & out_buffer) override; + CHIP_ERROR GetFirmwareInformation(MutableByteSpan & out_firmware_info_buffer) override; + CHIP_ERROR GetDeviceAttestationCert(MutableByteSpan & out_buffer) override; + CHIP_ERROR GetProductAttestationIntermediateCert(MutableByteSpan & out_buffer) override; + CHIP_ERROR SignWithDeviceAttestationKey(const ByteSpan & message_to_sign, MutableByteSpan & out_buffer) override; + +private: + factoryData const * mFactoryData = &gFactoryData; +}; + +CHIP_ERROR DeviceAttestationCredsCC13X2_26X2::GetCertificationDeclaration(MutableByteSpan & out_buffer) +{ + //-> format_version = 1 + //-> vendor_id = 0xFFF1 + //-> product_id_array = [ 0x8000, 0x8001, 0x8002, 0x8003, 0x8004, 0x8005, 0x8006, 0x8007, 0x8008, 0x8009, 0x800A, 0x800B, + // 0x800C, 0x800D, 0x800E, 0x800F, 0x8010, 0x8011, 0x8012, 0x8013, 0x8014, 0x8015, 0x8016, 0x8017, 0x8018, 0x8019, 0x801A, + // 0x801B, 0x801C, 0x801D, 0x801E, 0x801F, 0x8020, 0x8021, 0x8022, 0x8023, 0x8024, 0x8025, 0x8026, 0x8027, 0x8028, 0x8029, + // 0x802A, 0x802B, 0x802C, 0x802D, 0x802E, 0x802F, 0x8030, 0x8031, 0x8032, 0x8033, 0x8034, 0x8035, 0x8036, 0x8037, 0x8038, + // 0x8039, 0x803A, 0x803B, 0x803C, 0x803D, 0x803E, 0x803F, 0x8040, 0x8041, 0x8042, 0x8043, 0x8044, 0x8045, 0x8046, 0x8047, + // 0x8048, 0x8049, 0x804A, 0x804B, 0x804C, 0x804D, 0x804E, 0x804F, 0x8050, 0x8051, 0x8052, 0x8053, 0x8054, 0x8055, 0x8056, + // 0x8057, 0x8058, 0x8059, 0x805A, 0x805B, 0x805C, 0x805D, 0x805E, 0x805F, 0x8060, 0x8061, 0x8062, 0x8063 ] + //-> device_type_id = 0x0016 + //-> certificate_id = "ZIG20142ZB330003-24" + //-> security_level = 0 + //-> security_information = 0 + //-> version_number = 0x2694 + //-> certification_type = 0 + //-> dac_origin_vendor_id is not present + //-> dac_origin_product_id is not present + static const uint8_t kCdForAllExamples[] = { + 0x30, 0x82, 0x02, 0x19, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02, 0xa0, 0x82, 0x02, 0x0a, 0x30, + 0x82, 0x02, 0x06, 0x02, 0x01, 0x03, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, + 0x01, 0x30, 0x82, 0x01, 0x71, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, 0xa0, 0x82, 0x01, 0x62, + 0x04, 0x82, 0x01, 0x5e, 0x15, 0x24, 0x00, 0x01, 0x25, 0x01, 0xf1, 0xff, 0x36, 0x02, 0x05, 0x00, 0x80, 0x05, 0x01, 0x80, + 0x05, 0x02, 0x80, 0x05, 0x03, 0x80, 0x05, 0x04, 0x80, 0x05, 0x05, 0x80, 0x05, 0x06, 0x80, 0x05, 0x07, 0x80, 0x05, 0x08, + 0x80, 0x05, 0x09, 0x80, 0x05, 0x0a, 0x80, 0x05, 0x0b, 0x80, 0x05, 0x0c, 0x80, 0x05, 0x0d, 0x80, 0x05, 0x0e, 0x80, 0x05, + 0x0f, 0x80, 0x05, 0x10, 0x80, 0x05, 0x11, 0x80, 0x05, 0x12, 0x80, 0x05, 0x13, 0x80, 0x05, 0x14, 0x80, 0x05, 0x15, 0x80, + 0x05, 0x16, 0x80, 0x05, 0x17, 0x80, 0x05, 0x18, 0x80, 0x05, 0x19, 0x80, 0x05, 0x1a, 0x80, 0x05, 0x1b, 0x80, 0x05, 0x1c, + 0x80, 0x05, 0x1d, 0x80, 0x05, 0x1e, 0x80, 0x05, 0x1f, 0x80, 0x05, 0x20, 0x80, 0x05, 0x21, 0x80, 0x05, 0x22, 0x80, 0x05, + 0x23, 0x80, 0x05, 0x24, 0x80, 0x05, 0x25, 0x80, 0x05, 0x26, 0x80, 0x05, 0x27, 0x80, 0x05, 0x28, 0x80, 0x05, 0x29, 0x80, + 0x05, 0x2a, 0x80, 0x05, 0x2b, 0x80, 0x05, 0x2c, 0x80, 0x05, 0x2d, 0x80, 0x05, 0x2e, 0x80, 0x05, 0x2f, 0x80, 0x05, 0x30, + 0x80, 0x05, 0x31, 0x80, 0x05, 0x32, 0x80, 0x05, 0x33, 0x80, 0x05, 0x34, 0x80, 0x05, 0x35, 0x80, 0x05, 0x36, 0x80, 0x05, + 0x37, 0x80, 0x05, 0x38, 0x80, 0x05, 0x39, 0x80, 0x05, 0x3a, 0x80, 0x05, 0x3b, 0x80, 0x05, 0x3c, 0x80, 0x05, 0x3d, 0x80, + 0x05, 0x3e, 0x80, 0x05, 0x3f, 0x80, 0x05, 0x40, 0x80, 0x05, 0x41, 0x80, 0x05, 0x42, 0x80, 0x05, 0x43, 0x80, 0x05, 0x44, + 0x80, 0x05, 0x45, 0x80, 0x05, 0x46, 0x80, 0x05, 0x47, 0x80, 0x05, 0x48, 0x80, 0x05, 0x49, 0x80, 0x05, 0x4a, 0x80, 0x05, + 0x4b, 0x80, 0x05, 0x4c, 0x80, 0x05, 0x4d, 0x80, 0x05, 0x4e, 0x80, 0x05, 0x4f, 0x80, 0x05, 0x50, 0x80, 0x05, 0x51, 0x80, + 0x05, 0x52, 0x80, 0x05, 0x53, 0x80, 0x05, 0x54, 0x80, 0x05, 0x55, 0x80, 0x05, 0x56, 0x80, 0x05, 0x57, 0x80, 0x05, 0x58, + 0x80, 0x05, 0x59, 0x80, 0x05, 0x5a, 0x80, 0x05, 0x5b, 0x80, 0x05, 0x5c, 0x80, 0x05, 0x5d, 0x80, 0x05, 0x5e, 0x80, 0x05, + 0x5f, 0x80, 0x05, 0x60, 0x80, 0x05, 0x61, 0x80, 0x05, 0x62, 0x80, 0x05, 0x63, 0x80, 0x18, 0x24, 0x03, 0x16, 0x2c, 0x04, + 0x13, 0x5a, 0x49, 0x47, 0x32, 0x30, 0x31, 0x34, 0x32, 0x5a, 0x42, 0x33, 0x33, 0x30, 0x30, 0x30, 0x33, 0x2d, 0x32, 0x34, + 0x24, 0x05, 0x00, 0x24, 0x06, 0x00, 0x25, 0x07, 0x94, 0x26, 0x24, 0x08, 0x00, 0x18, 0x31, 0x7d, 0x30, 0x7b, 0x02, 0x01, + 0x03, 0x80, 0x14, 0x62, 0xfa, 0x82, 0x33, 0x59, 0xac, 0xfa, 0xa9, 0x96, 0x3e, 0x1c, 0xfa, 0x14, 0x0a, 0xdd, 0xf5, 0x04, + 0xf3, 0x71, 0x60, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x30, 0x0a, 0x06, 0x08, + 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x04, 0x47, 0x30, 0x45, 0x02, 0x20, 0x24, 0xe5, 0xd1, 0xf4, 0x7a, 0x7d, + 0x7b, 0x0d, 0x20, 0x6a, 0x26, 0xef, 0x69, 0x9b, 0x7c, 0x97, 0x57, 0xb7, 0x2d, 0x46, 0x90, 0x89, 0xde, 0x31, 0x92, 0xe6, + 0x78, 0xc7, 0x45, 0xe7, 0xf6, 0x0c, 0x02, 0x21, 0x00, 0xf8, 0xaa, 0x2f, 0xa7, 0x11, 0xfc, 0xb7, 0x9b, 0x97, 0xe3, 0x97, + 0xce, 0xda, 0x66, 0x7b, 0xae, 0x46, 0x4e, 0x2b, 0xd3, 0xff, 0xdf, 0xc3, 0xcc, 0xed, 0x7a, 0xa8, 0xca, 0x5f, 0x4c, 0x1a, + 0x7c, + }; + + return CopySpanToMutableSpan(ByteSpan{ kCdForAllExamples }, out_buffer); +} + +CHIP_ERROR DeviceAttestationCredsCC13X2_26X2::GetFirmwareInformation(MutableByteSpan & out_firmware_info_buffer) +{ + out_firmware_info_buffer.reduce_size(0); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DeviceAttestationCredsCC13X2_26X2::GetDeviceAttestationCert(MutableByteSpan & out_buffer) +{ + ReturnErrorCodeIf(out_buffer.size() < mFactoryData->dac_cert.len, CHIP_ERROR_BUFFER_TOO_SMALL); + ReturnErrorCodeIf(!mFactoryData->dac_cert.data, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + + return CopySpanToMutableSpan(ByteSpan{ mFactoryData->dac_cert.data, mFactoryData->dac_cert.len }, out_buffer); +} + +CHIP_ERROR DeviceAttestationCredsCC13X2_26X2::GetProductAttestationIntermediateCert(MutableByteSpan & out_buffer) +{ + ReturnErrorCodeIf(out_buffer.size() < mFactoryData->pai_cert.len, CHIP_ERROR_BUFFER_TOO_SMALL); + ReturnErrorCodeIf(!mFactoryData->pai_cert.data, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + + return CopySpanToMutableSpan(ByteSpan{ mFactoryData->pai_cert.data, mFactoryData->pai_cert.len }, out_buffer); +} + +CHIP_ERROR DeviceAttestationCredsCC13X2_26X2::SignWithDeviceAttestationKey(const ByteSpan & message_to_sign, + MutableByteSpan & out_buffer) +{ + Crypto::P256ECDSASignature signature; + Crypto::P256Keypair keypair; + + VerifyOrReturnError(IsSpanUsable(out_buffer), CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(IsSpanUsable(message_to_sign), CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(out_buffer.size() >= signature.Capacity(), CHIP_ERROR_BUFFER_TOO_SMALL); + + // In a non-exemplary implementation, the public key is not needed here. It is used here merely because + // Crypto::P256Keypair is only (currently) constructable from raw keys if both private/public keys are present. + ReturnErrorOnFailure(LoadKeypairFromRaw(ByteSpan(mFactoryData->dac_priv_key.data, mFactoryData->dac_priv_key.len), + ByteSpan(mFactoryData->dac_pub_key.data, mFactoryData->dac_pub_key.len), keypair)); + ReturnErrorOnFailure(keypair.ECDSA_sign_msg(message_to_sign.data(), message_to_sign.size(), signature)); + + return CopySpanToMutableSpan(ByteSpan{ signature.ConstBytes(), signature.Length() }, out_buffer); +} + +} // namespace + +DeviceAttestationCredentialsProvider * GetCC13X2_26X2DacProvider() +{ + static DeviceAttestationCredsCC13X2_26X2 dac_provider; + return &dac_provider; +} + +} // namespace CC13X2_26X2 +} // namespace Credentials +} // namespace chip diff --git a/examples/platform/cc13x2_26x2/CC13X2_26X2DeviceAttestationCreds.h b/examples/platform/cc13x2_26x2/CC13X2_26X2DeviceAttestationCreds.h new file mode 100644 index 00000000000000..37edd157a228ce --- /dev/null +++ b/examples/platform/cc13x2_26x2/CC13X2_26X2DeviceAttestationCreds.h @@ -0,0 +1,36 @@ +/* + * + * Copyright (c) 2022 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 + +namespace chip { +namespace Credentials { +namespace CC13X2_26X2 { + +/** + * @brief Get implementation of a sample DAC provider to validate device + * attestation procedure. + * + * @returns a singleton DeviceAttestationCredentialsProvider that relies on no + * storage abstractions. + */ +DeviceAttestationCredentialsProvider * GetCC13X2_26X2DacProvider(); + +} // namespace CC13X2_26X2 +} // namespace Credentials +} // namespace chip diff --git a/examples/pump-app/cc13x2x7_26x2x7/BUILD.gn b/examples/pump-app/cc13x2x7_26x2x7/BUILD.gn index 00bd404700ccba..7eadbc73e8c4a9 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/BUILD.gn +++ b/examples/pump-app/cc13x2x7_26x2x7/BUILD.gn @@ -85,6 +85,7 @@ ti_simplelink_executable("pump_app") { deps = [ ":sdk", ":sysconfig", + "${chip_root}/examples/platform/cc13x2_26x2:cc13x2_26x2-attestation-credentials", "${chip_root}/examples/pump-app/pump-common", "${chip_root}/src/lib", ] diff --git a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp index ec04f66a5216f1..62a5e436a58310 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp +++ b/examples/pump-app/cc13x2x7_26x2x7/main/AppTask.cpp @@ -26,12 +26,12 @@ #include #include "FreeRTOS.h" -#include -#include - #include #include #include +#include +#include +#include #if defined(CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR) #include @@ -221,8 +221,12 @@ int AppTask::Init() (void) initParams.InitializeStaticResourcesBeforeServerInit(); chip::Server::GetInstance().Init(initParams); - // Initialize device attestation config +// Initialize device attestation config +#ifdef CC13X2_26X2_ATTESTATION_CREDENTIALS + SetDeviceAttestationCredentialsProvider(CC13X2_26X2::GetCC13X2_26X2DacProvider()); +#else SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); +#endif ConfigurationMgr().LogDeviceConfig(); diff --git a/examples/pump-app/pump-common/pump-app.matter b/examples/pump-app/pump-common/pump-app.matter index 9f7d9dd521d959..729a6ad9012a7d 100644 --- a/examples/pump-app/pump-common/pump-app.matter +++ b/examples/pump-app/pump-common/pump-app.matter @@ -561,7 +561,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter b/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter index fbbb3ad0e1a546..da44ef42b0a06b 100644 --- a/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter +++ b/examples/pump-controller-app/pump-controller-common/pump-controller-app.matter @@ -460,7 +460,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/temperature-measurement-app/esp32/main/temperature-measurement.matter b/examples/temperature-measurement-app/esp32/main/temperature-measurement.matter index bf88563db716ce..c49f2ec01f56e4 100644 --- a/examples/temperature-measurement-app/esp32/main/temperature-measurement.matter +++ b/examples/temperature-measurement-app/esp32/main/temperature-measurement.matter @@ -274,7 +274,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/thermostat/thermostat-common/thermostat.matter b/examples/thermostat/thermostat-common/thermostat.matter index 28f3870a5a281c..15d06410def29c 100644 --- a/examples/thermostat/thermostat-common/thermostat.matter +++ b/examples/thermostat/thermostat-common/thermostat.matter @@ -662,7 +662,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/tv-app/tv-common/tv-app.matter b/examples/tv-app/tv-common/tv-app.matter index 98b68bf8f34b43..e3c07dd6d3bd8b 100644 --- a/examples/tv-app/tv-common/tv-app.matter +++ b/examples/tv-app/tv-common/tv-app.matter @@ -573,7 +573,7 @@ client cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; @@ -707,7 +707,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/tv-casting-app/tv-casting-common/include/CastingServer.h b/examples/tv-casting-app/tv-casting-common/include/CastingServer.h index 09fb76d21525df..0eab5ab0311dcb 100644 --- a/examples/tv-casting-app/tv-casting-common/include/CastingServer.h +++ b/examples/tv-casting-app/tv-casting-common/include/CastingServer.h @@ -415,7 +415,8 @@ class CastingServer void ReadServerClusters(chip::EndpointId endpointId); PersistenceManager mPersistenceManager; - bool mInited = false; + bool mInited = false; + bool mUdcInProgress = false; TargetVideoPlayerInfo mActiveTargetVideoPlayerInfo; TargetVideoPlayerInfo mCachedTargetVideoPlayerInfo[kMaxCachedVideoPlayers]; uint16_t mTargetVideoPlayerVendorId = 0; diff --git a/examples/tv-casting-app/tv-casting-common/include/TargetVideoPlayerInfo.h b/examples/tv-casting-app/tv-casting-common/include/TargetVideoPlayerInfo.h index c362ec95c99a24..4c0fd1455e7ea1 100644 --- a/examples/tv-casting-app/tv-casting-common/include/TargetVideoPlayerInfo.h +++ b/examples/tv-casting-app/tv-casting-common/include/TargetVideoPlayerInfo.h @@ -43,6 +43,7 @@ class TargetVideoPlayerInfo size_t GetNumIPs() const { return mNumIPs; } const chip::Inet::IPAddress * GetIpAddresses() const { return mIpAddress; } bool IsSameAs(const chip::Dnssd::DiscoveredNodeData * discoveredNodeData); + bool IsSameAs(const char * deviceName, size_t numIPs, const chip::Inet::IPAddress * ipAddresses); chip::OperationalDeviceProxy * GetOperationalDeviceProxy() { diff --git a/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp b/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp index 1fa2965abcbff6..558139f3cff155 100644 --- a/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp +++ b/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp @@ -130,6 +130,7 @@ CHIP_ERROR CastingServer::SendUserDirectedCommissioningRequest(chip::Transport:: CHIP_ERROR CastingServer::SendUserDirectedCommissioningRequest(Dnssd::DiscoveredNodeData * selectedCommissioner) { + mUdcInProgress = true; // Send User Directed commissioning request ReturnErrorOnFailure(SendUserDirectedCommissioningRequest(chip::Transport::PeerAddress::UDP( selectedCommissioner->resolutionData.ipAddress[0], selectedCommissioner->resolutionData.port, @@ -320,24 +321,92 @@ CastingServer::ContentLauncherLaunchURL(TargetEndpointInfo * endpoint, const cha void CastingServer::DeviceEventCallback(const DeviceLayer::ChipDeviceEvent * event, intptr_t arg) { + bool runPostCommissioning = false; + chip::NodeId targetPeerNodeId = 0; + chip::FabricIndex targetFabricIndex = 0; if (event->Type == DeviceLayer::DeviceEventType::kBindingsChangedViaCluster) { + ChipLogProgress(AppServer, "CastingServer::DeviceEventCallback kBindingsChangedViaCluster received"); if (CastingServer::GetInstance()->GetActiveTargetVideoPlayer()->IsInitialized()) { + ChipLogProgress(AppServer, + "CastingServer::DeviceEventCallback already connected to video player, reading server clusters"); CastingServer::GetInstance()->ReadServerClustersForNode( CastingServer::GetInstance()->GetActiveTargetVideoPlayer()->GetNodeId()); } + else if (CastingServer::GetInstance()->mUdcInProgress) + { + ChipLogProgress(AppServer, + "CastingServer::DeviceEventCallback UDC is in progress while handling kBindingsChangedViaCluster"); + CastingServer::GetInstance()->mUdcInProgress = false; + if (CastingServer::GetInstance()->mTargetVideoPlayerNumIPs > 0) + { + TargetVideoPlayerInfo * connectableVideoPlayerList = + CastingServer::GetInstance()->ReadCachedTargetVideoPlayerInfos(); + if (connectableVideoPlayerList == nullptr || !connectableVideoPlayerList[0].IsInitialized()) + { + ChipLogError(AppServer, "CastingServer::DeviceEventCallback No cached video players found"); + CastingServer::GetInstance()->mCommissioningCompleteCallback(CHIP_ERROR_INCORRECT_STATE); + return; + } + + for (size_t i = 0; i < kMaxCachedVideoPlayers && connectableVideoPlayerList[i].IsInitialized(); i++) + { + if (connectableVideoPlayerList[i].IsSameAs(CastingServer::GetInstance()->mTargetVideoPlayerDeviceName, + CastingServer::GetInstance()->mTargetVideoPlayerNumIPs, + CastingServer::GetInstance()->mTargetVideoPlayerIpAddress)) + { + ChipLogProgress(AppServer, + "CastingServer::DeviceEventCallback found the video player to initialize/connect to"); + targetPeerNodeId = connectableVideoPlayerList[i].GetNodeId(); + targetFabricIndex = connectableVideoPlayerList[i].GetFabricIndex(); + runPostCommissioning = true; + } + } + + if (targetPeerNodeId == 0 && runPostCommissioning == false) + { + ChipLogError(AppServer, + "CastingServer::DeviceEventCallback did NOT find the video player to initialize/connect to"); + CastingServer::GetInstance()->mCommissioningCompleteCallback(CHIP_ERROR_INCORRECT_STATE); + return; + } + } + } } else if (event->Type == DeviceLayer::DeviceEventType::kCommissioningComplete) { + ChipLogProgress(AppServer, "CastingServer::DeviceEventCallback kCommissioningComplete received"); + CastingServer::GetInstance()->mUdcInProgress = false; + targetPeerNodeId = event->CommissioningComplete.nodeId; + targetFabricIndex = event->CommissioningComplete.fabricIndex; + runPostCommissioning = true; + } + + if (runPostCommissioning) + { + ChipLogProgress(AppServer, + "CastingServer::DeviceEventCallback will connect with nodeId=0x" ChipLogFormatX64 " fabricIndex=%d", + ChipLogValueX64(targetPeerNodeId), targetFabricIndex); CHIP_ERROR err = CastingServer::GetInstance()->GetActiveTargetVideoPlayer()->Initialize( - event->CommissioningComplete.nodeId, event->CommissioningComplete.fabricIndex, - CastingServer::GetInstance()->mOnConnectionSuccessClientCallback, + targetPeerNodeId, targetFabricIndex, CastingServer::GetInstance()->mOnConnectionSuccessClientCallback, CastingServer::GetInstance()->mOnConnectionFailureClientCallback, CastingServer::GetInstance()->mTargetVideoPlayerVendorId, CastingServer::GetInstance()->mTargetVideoPlayerProductId, CastingServer::GetInstance()->mTargetVideoPlayerDeviceType, CastingServer::GetInstance()->mTargetVideoPlayerDeviceName, CastingServer::GetInstance()->mTargetVideoPlayerNumIPs, CastingServer::GetInstance()->mTargetVideoPlayerIpAddress); + if (err != CHIP_NO_ERROR) + { + ChipLogError(AppServer, "Failed to initialize target video player"); + } + + err = CastingServer::GetInstance()->mPersistenceManager.AddVideoPlayer( + &CastingServer::GetInstance()->mActiveTargetVideoPlayerInfo); + if (err != CHIP_NO_ERROR) + { + ChipLogError(AppServer, "AddVideoPlayer(ToCache) error: %" CHIP_ERROR_FORMAT, err.Format()); + } + CastingServer::GetInstance()->mCommissioningCompleteCallback(err); } } diff --git a/examples/tv-casting-app/tv-casting-common/src/TargetVideoPlayerInfo.cpp b/examples/tv-casting-app/tv-casting-common/src/TargetVideoPlayerInfo.cpp index 70609f328fc5ef..7e1d13f7e4677a 100644 --- a/examples/tv-casting-app/tv-casting-common/src/TargetVideoPlayerInfo.cpp +++ b/examples/tv-casting-app/tv-casting-common/src/TargetVideoPlayerInfo.cpp @@ -126,16 +126,10 @@ void TargetVideoPlayerInfo::PrintInfo() } } -bool TargetVideoPlayerInfo::IsSameAs(const chip::Dnssd::DiscoveredNodeData * discoveredNodeData) +bool TargetVideoPlayerInfo::IsSameAs(const char * deviceName, size_t numIPs, const chip::Inet::IPAddress * ipAddresses) { - // return false because 'this' VideoPlayer is not null - if (discoveredNodeData == nullptr) - { - return false; - } - // return false because deviceNames are different - if (strcmp(mDeviceName, discoveredNodeData->commissionData.deviceName) != 0) + if (strcmp(mDeviceName, deviceName) != 0) { return false; } @@ -146,10 +140,9 @@ bool TargetVideoPlayerInfo::IsSameAs(const chip::Dnssd::DiscoveredNodeData * dis bool matchFound = false; for (size_t i = 0; i < mNumIPs && i < chip::Dnssd::CommonResolutionData::kMaxIPAddresses; i++) { - for (size_t j = 0; - j < discoveredNodeData->resolutionData.numIPs && j < chip::Dnssd::CommonResolutionData::kMaxIPAddresses; j++) + for (size_t j = 0; j < numIPs && j < chip::Dnssd::CommonResolutionData::kMaxIPAddresses; j++) { - if (mIpAddress[i] == discoveredNodeData->resolutionData.ipAddress[j]) + if (mIpAddress[i] == ipAddresses[j]) { matchFound = true; break; @@ -169,3 +162,15 @@ bool TargetVideoPlayerInfo::IsSameAs(const chip::Dnssd::DiscoveredNodeData * dis return true; } + +bool TargetVideoPlayerInfo::IsSameAs(const chip::Dnssd::DiscoveredNodeData * discoveredNodeData) +{ + // return false because 'this' VideoPlayer is not null + if (discoveredNodeData == nullptr) + { + return false; + } + + return IsSameAs(discoveredNodeData->commissionData.deviceName, discoveredNodeData->resolutionData.numIPs, + discoveredNodeData->resolutionData.ipAddress); +} diff --git a/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter b/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter index ea6c92a294542b..b073a35a99aea5 100644 --- a/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter +++ b/examples/tv-casting-app/tv-casting-common/tv-casting-app.matter @@ -879,7 +879,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/examples/window-app/common/window-app.matter b/examples/window-app/common/window-app.matter index 578b658092fabc..c29a4d437cd2d4 100644 --- a/examples/window-app/common/window-app.matter +++ b/examples/window-app/common/window-app.matter @@ -617,6 +617,21 @@ server cluster PowerSource = 47 { kReplaceable = 0x8; } + info event WiredFaultChange = 0 { + WiredFault current[] = 0; + WiredFault previous[] = 1; + } + + info event BatFaultChange = 1 { + BatFault current[] = 0; + BatFault previous[] = 1; + } + + info event BatChargeFaultChange = 2 { + BatChargeFault current[] = 0; + BatChargeFault previous[] = 1; + } + readonly attribute PowerSourceStatus status = 0; readonly attribute int8u order = 1; readonly attribute char_string<60> description = 2; @@ -725,7 +740,7 @@ server cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/integrations/cloudbuild/build-all.yaml b/integrations/cloudbuild/build-all.yaml index 5a80129f54496b..863a7105c23290 100644 --- a/integrations/cloudbuild/build-all.yaml +++ b/integrations/cloudbuild/build-all.yaml @@ -6,7 +6,7 @@ steps: - "--init" - "--recursive" id: Submodules - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -21,7 +21,7 @@ steps: path: /pwenv timeout: 900s - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -76,6 +76,7 @@ steps: --target k32w-shell build --create-archives /workspace/artifacts/ + # TODO: update this to connectedhomeip/chip-build-vscode:0.6.27 once we can compile with latest NRF - name: "connectedhomeip/chip-build-vscode:0.6.18" env: - PW_ENVIRONMENT_ROOT=/pwenv diff --git a/integrations/cloudbuild/build-coverage.yaml b/integrations/cloudbuild/build-coverage.yaml index 3973c85147a623..8beb8b6d18f19c 100644 --- a/integrations/cloudbuild/build-coverage.yaml +++ b/integrations/cloudbuild/build-coverage.yaml @@ -7,7 +7,7 @@ steps: - "--recursive" id: Submodules - - name: "connectedhomeip/chip-build:0.6.18" + - name: "connectedhomeip/chip-build:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -22,7 +22,7 @@ steps: path: /pwenv timeout: 900s - - name: "connectedhomeip/chip-build:0.6.17" + - name: "connectedhomeip/chip-build:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: diff --git a/integrations/cloudbuild/chef.yaml b/integrations/cloudbuild/chef.yaml index 0cfebde9cf97ea..494869a38e318e 100644 --- a/integrations/cloudbuild/chef.yaml +++ b/integrations/cloudbuild/chef.yaml @@ -1,5 +1,5 @@ steps: - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -12,7 +12,7 @@ steps: path: /pwenv timeout: 2700s - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -26,7 +26,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: diff --git a/integrations/cloudbuild/smoke-test.yaml b/integrations/cloudbuild/smoke-test.yaml index 47145edfc2aabc..c2f34ea5f72cdc 100644 --- a/integrations/cloudbuild/smoke-test.yaml +++ b/integrations/cloudbuild/smoke-test.yaml @@ -1,5 +1,5 @@ steps: - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" entrypoint: "bash" args: - "-c" @@ -7,7 +7,7 @@ steps: git config --global --add safe.directory "*" git submodule update --init --recursive id: Submodules - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" env: - PW_ENVIRONMENT_ROOT=/pwenv args: @@ -22,7 +22,7 @@ steps: path: /pwenv timeout: 900s - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" id: ESP32 env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -41,6 +41,7 @@ steps: - name: pwenv path: /pwenv + # TODO: update this to connectedhomeip/chip-build-vscode:0.6.27 once we can compile with latest NRF - name: "connectedhomeip/chip-build-vscode:0.6.18" id: NRFConnect env: @@ -62,7 +63,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" id: EFR32 env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -84,7 +85,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" id: Linux env: - PW_ENVIRONMENT_ROOT=/pwenv @@ -142,7 +143,7 @@ steps: - name: pwenv path: /pwenv - - name: "connectedhomeip/chip-build-vscode:0.6.18" + - name: "connectedhomeip/chip-build-vscode:0.6.27" id: Android env: - PW_ENVIRONMENT_ROOT=/pwenv diff --git a/integrations/docker/images/chip-build-ameba/Dockerfile b/integrations/docker/images/chip-build-ameba/Dockerfile index 2a7f2b4574b65f..95fa65905b89e6 100644 --- a/integrations/docker/images/chip-build-ameba/Dockerfile +++ b/integrations/docker/images/chip-build-ameba/Dockerfile @@ -3,7 +3,7 @@ FROM connectedhomeip/chip-build:${VERSION} # Setup Ameba ARG AMEBA_DIR=/opt/ameba -ARG TAG_NAME=ameba_update_2022_11_25 +ARG TAG_NAME=ameba_update_2022_12_21 RUN set -x \ && apt-get update \ && mkdir ${AMEBA_DIR} \ diff --git a/integrations/docker/images/chip-build/Dockerfile b/integrations/docker/images/chip-build/Dockerfile index 57eb0030689518..9d8b2ebdd9d8da 100644 --- a/integrations/docker/images/chip-build/Dockerfile +++ b/integrations/docker/images/chip-build/Dockerfile @@ -178,7 +178,7 @@ RUN set -x \ # Install a known ZAP release # Only keep the cli version, since `zap` is 143MB and not usable (UI) -ENV ZAP_VERSION=v2022.12.20-nightly +ENV ZAP_VERSION=v2023.01.05-nightly RUN set -x \ && mkdir -p /opt/zap-${ZAP_VERSION} \ && cd /opt/zap-${ZAP_VERSION} \ diff --git a/integrations/docker/images/chip-build/version b/integrations/docker/images/chip-build/version index bcccaaff02e138..121070f6e3a7f3 100644 --- a/integrations/docker/images/chip-build/version +++ b/integrations/docker/images/chip-build/version @@ -1 +1 @@ -0.6.27 Version bump reason: [Telink] Update Telink Docker image (Zephyr update) +0.6.29 Version bump reason: [Ameba] Update Docker image (fix bugs) diff --git a/scripts/BUILD.gn b/scripts/BUILD.gn index 141e262d5db3e4..e14db546195de5 100644 --- a/scripts/BUILD.gn +++ b/scripts/BUILD.gn @@ -12,6 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") + import("//build_overrides/pigweed.gni") +import("$dir_pw_build/python_dist.gni") -import("$dir_pw_build/python.gni") +# This target creates a single Python package and wheel for yamltests. It will +# merge all Python dependencies Matter. The output is located in: +# out/obj/matter_yamltests_distribution/ <- source files here +# out/obj/matter_yamltests_distribution._build_wheel/matter_yamltests-0.0.1-py3-none-any.whl +pw_python_distribution("matter_yamltests_distribution") { + packages = [ "${chip_root}/scripts/py_matter_yamltests:matter_yamltests" ] + generate_setup_cfg = { + common_config_file = "common_setup.cfg" + include_default_pyproject_file = true + append_date_to_version = true + } +} diff --git a/scripts/codegen.py b/scripts/codegen.py index 67898af6ebce5f..5d824be7bfebf8 100755 --- a/scripts/codegen.py +++ b/scripts/codegen.py @@ -25,14 +25,14 @@ _has_coloredlogs = False try: - from idl.matter_idl_parser import CreateParser + from matter_idl.matter_idl_parser import CreateParser except: import os - sys.path.append(os.path.abspath(os.path.dirname(__file__))) - from idl.matter_idl_parser import CreateParser + sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 'py_matter_idl'))) + from matter_idl.matter_idl_parser import CreateParser -from idl.generators import FileSystemGeneratorStorage, GeneratorStorage -from idl.generators.registry import CodeGenerator, GENERATORS +from matter_idl.generators import FileSystemGeneratorStorage, GeneratorStorage +from matter_idl.generators.registry import CodeGenerator, GENERATORS class ListGeneratedFilesStorage(GeneratorStorage): diff --git a/scripts/common_setup.cfg b/scripts/common_setup.cfg new file mode 100644 index 00000000000000..76987454de4736 --- /dev/null +++ b/scripts/common_setup.cfg @@ -0,0 +1,19 @@ +# Copyright (c) 2022 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. +[metadata] +name = matter_yamltests +version = 0.0.1 + +[options] +zip_safe = False diff --git a/scripts/idl/BUILD.gn b/scripts/idl/BUILD.gn deleted file mode 100644 index 324ed3a737bbf0..00000000000000 --- a/scripts/idl/BUILD.gn +++ /dev/null @@ -1,79 +0,0 @@ -# Copyright (c) 2022 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. - -import("//build_overrides/build.gni") -import("//build_overrides/chip.gni") - -import("//build_overrides/pigweed.gni") -import("$dir_pw_build/python.gni") - -import("${chip_root}/scripts/idl/files.gni") - -pw_python_package("idl") { - setup = [ "setup.py" ] - inputs = matter_idl_generator_templates - inputs += [ - # Dependency grammar - "matter_grammar.lark", - - # Unit test data - "tests/available_tests.yaml", - "tests/inputs/cluster_struct_attribute.matter", - "tests/inputs/global_struct_attribute.matter", - "tests/inputs/optional_argument.matter", - "tests/inputs/several_clusters.matter", - "tests/inputs/simple_attribute.matter", - "tests/outputs/cluster_struct_attribute/bridge/BridgeClustersImpl.h", - "tests/outputs/cluster_struct_attribute/bridge/BridgeGlobalStructs.h", - "tests/outputs/cluster_struct_attribute/bridge/DemoClusterServer.h", - "tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp", - "tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp", - "tests/outputs/global_struct_attribute/bridge/BridgeClustersImpl.h", - "tests/outputs/global_struct_attribute/bridge/BridgeGlobalStructs.h", - "tests/outputs/global_struct_attribute/bridge/DemoClusterServer.h", - "tests/outputs/global_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp", - "tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp", - "tests/outputs/optional_argument/jni/MyClusterClient-ReadImpl.cpp", - "tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp", - "tests/outputs/several_clusters/bridge/BridgeClustersImpl.h", - "tests/outputs/several_clusters/bridge/BridgeGlobalStructs.h", - "tests/outputs/several_clusters/bridge/FirstServer.h", - "tests/outputs/several_clusters/bridge/SecondServer.h", - "tests/outputs/several_clusters/bridge/Third.h", - "tests/outputs/several_clusters/bridge/ThirdServer.h", - "tests/outputs/several_clusters/jni/FirstClient-ReadImpl.cpp", - "tests/outputs/several_clusters/jni/SecondClient-ReadImpl.cpp", - "tests/outputs/several_clusters/jni/ThirdClient-ReadImpl.cpp", - "tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp", - "tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp", - "tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp", - "tests/outputs/simple_attribute/bridge/BridgeClustersImpl.h", - "tests/outputs/simple_attribute/bridge/BridgeGlobalStructs.h", - "tests/outputs/simple_attribute/bridge/MyClusterServer.h", - "tests/outputs/simple_attribute/jni/MyClusterClient-ReadImpl.cpp", - "tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp", - ] - - sources = matter_idl_generator_sources - - tests = [ - "test_matter_idl_parser.py", - "test_generators.py", - "test_xml_parser.py", - ] - - # TODO: at a future time consider enabling all (* or missing) here to get - # pylint checking these files - static_analysis = [] -} diff --git a/scripts/idl/files.gni b/scripts/idl/files.gni deleted file mode 100644 index 997f1eab8b06c5..00000000000000 --- a/scripts/idl/files.gni +++ /dev/null @@ -1,37 +0,0 @@ -import("//build_overrides/build.gni") -import("//build_overrides/chip.gni") - -# Templates used for generation -matter_idl_generator_templates = [ - "${chip_root}/scripts/idl/generators/bridge/BridgeClustersCpp.jinja", - "${chip_root}/scripts/idl/generators/bridge/BridgeClustersCommon.jinja", - "${chip_root}/scripts/idl/generators/bridge/BridgeClustersGlobalStructs.jinja", - "${chip_root}/scripts/idl/generators/java/ChipClustersCpp.jinja", - "${chip_root}/scripts/idl/generators/java/ChipClustersRead.jinja", - "${chip_root}/scripts/idl/generators/cpp/application/CallbackStubSource.jinja", - "${chip_root}/scripts/idl/generators/cpp/application/PluginApplicationCallbacksHeader.jinja", -] - -matter_idl_generator_sources = [ - "${chip_root}/scripts/idl/__init__.py", - "${chip_root}/scripts/idl/generators/__init__.py", - "${chip_root}/scripts/idl/generators/bridge/__init__.py", - "${chip_root}/scripts/idl/generators/cpp/__init__.py", - "${chip_root}/scripts/idl/generators/cpp/application/__init__.py", - "${chip_root}/scripts/idl/generators/filters.py", - "${chip_root}/scripts/idl/generators/java/__init__.py", - "${chip_root}/scripts/idl/generators/types.py", - "${chip_root}/scripts/idl/matter_idl_parser.py", - "${chip_root}/scripts/idl/matter_idl_types.py", - "${chip_root}/scripts/idl/xml_parser.py", - "${chip_root}/scripts/idl/zapxml/__init__.py", - "${chip_root}/scripts/idl/zapxml/handlers/__init__.py", - "${chip_root}/scripts/idl/zapxml/handlers/base.py", - "${chip_root}/scripts/idl/zapxml/handlers/context.py", - "${chip_root}/scripts/idl/zapxml/handlers/handlers.py", - "${chip_root}/scripts/idl/zapxml/handlers/parsing.py", -] - -# All the files that the matter idl infrastructure will use -matter_idl_generator_files = - matter_idl_generator_templates + matter_idl_generator_sources diff --git a/scripts/idl_lint.py b/scripts/idl_lint.py index 83f606201f8bac..a9271afbd73fc0 100755 --- a/scripts/idl_lint.py +++ b/scripts/idl_lint.py @@ -23,12 +23,12 @@ from typing import List, Optional try: - from idl import matter_idl_parser + from matter_idl import matter_idl_parser except: - sys.path.append(os.path.abspath(os.path.dirname(__file__))) - from idl import matter_idl_parser + sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 'py_matter_idl'))) + from matter_idl import matter_idl_parser -import idl.lint +import matter_idl.lint # Supported log levels, mapping string values required for argument # parsing into logging constants @@ -64,7 +64,7 @@ def main(log_level, rules, idl_path): lint_rules = [] logging.info("Loading rules from %s" % rules) - lint_rules.extend(idl.lint.CreateParser(rules).parse()) + lint_rules.extend(matter_idl.lint.CreateParser(rules).parse()) logging.info("Parsing idl from %s" % idl_path) idl_tree = matter_idl_parser.CreateParser().parse(open(idl_path, "rt").read(), file_name=idl_path) diff --git a/scripts/py_matter_idl/BUILD.gn b/scripts/py_matter_idl/BUILD.gn new file mode 100644 index 00000000000000..7e3254573e9cac --- /dev/null +++ b/scripts/py_matter_idl/BUILD.gn @@ -0,0 +1,83 @@ +# Copyright (c) 2022 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. + +import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") + +import("//build_overrides/pigweed.gni") +import("$dir_pw_build/python.gni") + +import("${chip_root}/scripts/py_matter_idl/files.gni") + +pw_python_package("matter_idl") { + setup = [ + "setup.py", + "setup.cfg", + "pyproject.toml", + ] + inputs = matter_idl_generator_templates + inputs += [ + # Dependency grammar + "matter_idl/matter_grammar.lark", + + # Unit test data + "matter_idl/tests/available_tests.yaml", + "matter_idl/tests/inputs/cluster_struct_attribute.matter", + "matter_idl/tests/inputs/global_struct_attribute.matter", + "matter_idl/tests/inputs/optional_argument.matter", + "matter_idl/tests/inputs/several_clusters.matter", + "matter_idl/tests/inputs/simple_attribute.matter", + "matter_idl/tests/outputs/cluster_struct_attribute/bridge/BridgeClustersImpl.h", + "matter_idl/tests/outputs/cluster_struct_attribute/bridge/BridgeGlobalStructs.h", + "matter_idl/tests/outputs/cluster_struct_attribute/bridge/DemoClusterServer.h", + "matter_idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp", + "matter_idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp", + "matter_idl/tests/outputs/global_struct_attribute/bridge/BridgeClustersImpl.h", + "matter_idl/tests/outputs/global_struct_attribute/bridge/BridgeGlobalStructs.h", + "matter_idl/tests/outputs/global_struct_attribute/bridge/DemoClusterServer.h", + "matter_idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp", + "matter_idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp", + "matter_idl/tests/outputs/optional_argument/jni/MyClusterClient-ReadImpl.cpp", + "matter_idl/tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp", + "matter_idl/tests/outputs/several_clusters/bridge/BridgeClustersImpl.h", + "matter_idl/tests/outputs/several_clusters/bridge/BridgeGlobalStructs.h", + "matter_idl/tests/outputs/several_clusters/bridge/FirstServer.h", + "matter_idl/tests/outputs/several_clusters/bridge/SecondServer.h", + "matter_idl/tests/outputs/several_clusters/bridge/Third.h", + "matter_idl/tests/outputs/several_clusters/bridge/ThirdServer.h", + "matter_idl/tests/outputs/several_clusters/jni/FirstClient-ReadImpl.cpp", + "matter_idl/tests/outputs/several_clusters/jni/SecondClient-ReadImpl.cpp", + "matter_idl/tests/outputs/several_clusters/jni/ThirdClient-ReadImpl.cpp", + "matter_idl/tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp", + "matter_idl/tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp", + "matter_idl/tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp", + "matter_idl/tests/outputs/simple_attribute/bridge/BridgeClustersImpl.h", + "matter_idl/tests/outputs/simple_attribute/bridge/BridgeGlobalStructs.h", + "matter_idl/tests/outputs/simple_attribute/bridge/MyClusterServer.h", + "matter_idl/tests/outputs/simple_attribute/jni/MyClusterClient-ReadImpl.cpp", + "matter_idl/tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp", + ] + + sources = matter_idl_generator_sources + + tests = [ + "matter_idl/test_matter_idl_parser.py", + "matter_idl/test_generators.py", + "matter_idl/test_xml_parser.py", + ] + + # TODO: at a future time consider enabling all (* or missing) here to get + # pylint checking these files + static_analysis = [] +} diff --git a/scripts/py_matter_idl/files.gni b/scripts/py_matter_idl/files.gni new file mode 100644 index 00000000000000..aa22f705caff2d --- /dev/null +++ b/scripts/py_matter_idl/files.gni @@ -0,0 +1,37 @@ +import("//build_overrides/build.gni") +import("//build_overrides/chip.gni") + +# Templates used for generation +matter_idl_generator_templates = [ + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersCpp.jinja", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersCommon.jinja", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersGlobalStructs.jinja", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/java/ChipClustersCpp.jinja", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/java/ChipClustersRead.jinja", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/cpp/application/CallbackStubSource.jinja", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/cpp/application/PluginApplicationCallbacksHeader.jinja", +] + +matter_idl_generator_sources = [ + "${chip_root}/scripts/py_matter_idl/matter_idl/__init__.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/__init__.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/cpp/__init__.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/cpp/application/__init__.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/filters.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/java/__init__.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/generators/types.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/matter_idl_parser.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/matter_idl_types.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/xml_parser.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/zapxml/__init__.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/zapxml/handlers/__init__.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/zapxml/handlers/base.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/zapxml/handlers/context.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/zapxml/handlers/handlers.py", + "${chip_root}/scripts/py_matter_idl/matter_idl/zapxml/handlers/parsing.py", +] + +# All the files that the matter idl infrastructure will use +matter_idl_generator_files = + matter_idl_generator_templates + matter_idl_generator_sources diff --git a/scripts/idl/README.md b/scripts/py_matter_idl/matter_idl/README.md similarity index 99% rename from scripts/idl/README.md rename to scripts/py_matter_idl/matter_idl/README.md index ac3ddf517f8277..e46fb4d00c853a 100644 --- a/scripts/idl/README.md +++ b/scripts/py_matter_idl/matter_idl/README.md @@ -184,7 +184,7 @@ endpoint 0 { ## Parsing of IDLs -IDL parsing is done within the `idl` python package (this is the current +IDL parsing is done within the `matter_idl` python package (this is the current directory of this README). Most of the heavy lifting is done by the lark using [matter_grammar.lark](./matter_grammar.lark), which is then turned into an AST: diff --git a/scripts/idl/__init__.py b/scripts/py_matter_idl/matter_idl/__init__.py similarity index 100% rename from scripts/idl/__init__.py rename to scripts/py_matter_idl/matter_idl/__init__.py diff --git a/scripts/idl/generators/__init__.py b/scripts/py_matter_idl/matter_idl/generators/__init__.py similarity index 97% rename from scripts/idl/generators/__init__.py rename to scripts/py_matter_idl/matter_idl/generators/__init__.py index 1adbb6d4d0071b..779c5ad800ace2 100644 --- a/scripts/idl/generators/__init__.py +++ b/scripts/py_matter_idl/matter_idl/generators/__init__.py @@ -18,7 +18,7 @@ import jinja2 from typing import Dict -from idl.matter_idl_types import Idl +from matter_idl.matter_idl_types import Idl from .filters import RegisterCommonFilters @@ -113,7 +113,8 @@ def __init__(self, storage: GeneratorStorage, idl: Idl): self.storage = storage self.idl = idl self.jinja_env = jinja2.Environment( - loader=jinja2.FileSystemLoader(searchpath=os.path.dirname(__file__)), + loader=jinja2.FileSystemLoader( + searchpath=os.path.dirname(__file__)), keep_trailing_newline=True) self.dry_run = False diff --git a/scripts/idl/generators/bridge/BridgeClustersCommon.jinja b/scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersCommon.jinja similarity index 100% rename from scripts/idl/generators/bridge/BridgeClustersCommon.jinja rename to scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersCommon.jinja diff --git a/scripts/idl/generators/bridge/BridgeClustersCpp.jinja b/scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersCpp.jinja similarity index 100% rename from scripts/idl/generators/bridge/BridgeClustersCpp.jinja rename to scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersCpp.jinja diff --git a/scripts/idl/generators/bridge/BridgeClustersGlobalStructs.jinja b/scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersGlobalStructs.jinja similarity index 100% rename from scripts/idl/generators/bridge/BridgeClustersGlobalStructs.jinja rename to scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersGlobalStructs.jinja diff --git a/scripts/idl/generators/bridge/BridgeClustersHeader.jinja b/scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersHeader.jinja similarity index 100% rename from scripts/idl/generators/bridge/BridgeClustersHeader.jinja rename to scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersHeader.jinja diff --git a/scripts/idl/generators/bridge/__init__.py b/scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py similarity index 91% rename from scripts/idl/generators/bridge/__init__.py rename to scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py index 7a43c9e802b88a..149e6cf33e1d04 100644 --- a/scripts/idl/generators/bridge/__init__.py +++ b/scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py @@ -17,11 +17,11 @@ import logging import re -from idl.generators import CodeGenerator, GeneratorStorage -from idl.matter_idl_types import Idl, Field, Attribute, Cluster, ClusterSide -from idl import matter_idl_types -from idl.generators.types import (ParseDataType, BasicString, BasicInteger, FundamentalType, - IdlType, IdlEnumType, IdlBitmapType, TypeLookupContext) +from matter_idl.generators import CodeGenerator, GeneratorStorage +from matter_idl.matter_idl_types import Idl, Field, Attribute, Cluster, ClusterSide +from matter_idl import matter_idl_types +from matter_idl.generators.types import (ParseDataType, BasicString, BasicInteger, FundamentalType, + IdlType, IdlEnumType, IdlBitmapType, TypeLookupContext) from typing import Union, List, Set @@ -74,14 +74,16 @@ def get_field_info(definition: Field, cluster: Cluster, idl: Idl): def get_raw_size_and_type(attr: Attribute, cluster: Cluster, idl: Idl): - container, cType, size, matterType = get_field_info(attr.definition, cluster, idl) + container, cType, size, matterType = get_field_info( + attr.definition, cluster, idl) if attr.definition.is_list: return 'ZCL_ARRAY_ATTRIBUTE_TYPE, {}'.format(size) return '{}, {}'.format(matterType, size) def get_field_type(definition: Field, cluster: Cluster, idl: Idl): - container, cType, size, matterType = get_field_info(definition, cluster, idl) + container, cType, size, matterType = get_field_info( + definition, cluster, idl) if container == 'OctetString': return 'std::string' if definition.is_list: diff --git a/scripts/idl/generators/cpp/__init__.py b/scripts/py_matter_idl/matter_idl/generators/cpp/__init__.py similarity index 100% rename from scripts/idl/generators/cpp/__init__.py rename to scripts/py_matter_idl/matter_idl/generators/cpp/__init__.py diff --git a/scripts/idl/generators/cpp/application/CallbackStubSource.jinja b/scripts/py_matter_idl/matter_idl/generators/cpp/application/CallbackStubSource.jinja similarity index 100% rename from scripts/idl/generators/cpp/application/CallbackStubSource.jinja rename to scripts/py_matter_idl/matter_idl/generators/cpp/application/CallbackStubSource.jinja diff --git a/scripts/idl/generators/cpp/application/PluginApplicationCallbacksHeader.jinja b/scripts/py_matter_idl/matter_idl/generators/cpp/application/PluginApplicationCallbacksHeader.jinja similarity index 100% rename from scripts/idl/generators/cpp/application/PluginApplicationCallbacksHeader.jinja rename to scripts/py_matter_idl/matter_idl/generators/cpp/application/PluginApplicationCallbacksHeader.jinja diff --git a/scripts/idl/generators/cpp/application/__init__.py b/scripts/py_matter_idl/matter_idl/generators/cpp/application/__init__.py similarity index 84% rename from scripts/idl/generators/cpp/application/__init__.py rename to scripts/py_matter_idl/matter_idl/generators/cpp/application/__init__.py index 4a7a3b0035ce75..ead462b2c33cb0 100644 --- a/scripts/idl/generators/cpp/application/__init__.py +++ b/scripts/py_matter_idl/matter_idl/generators/cpp/application/__init__.py @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from idl.generators import CodeGenerator, GeneratorStorage -from idl.matter_idl_types import Idl, ClusterSide, Field, Attribute, Cluster, FieldQuality, Command, DataType -from idl import matter_idl_types -from idl.generators.types import ParseDataType, BasicString, BasicInteger, FundamentalType, IdlType, IdlEnumType, IdlBitmapType, TypeLookupContext +from matter_idl.generators import CodeGenerator, GeneratorStorage +from matter_idl.matter_idl_types import Idl, ClusterSide, Field, Attribute, Cluster, FieldQuality, Command, DataType +from matter_idl import matter_idl_types +from matter_idl.generators.types import ParseDataType, BasicString, BasicInteger, FundamentalType, IdlType, IdlEnumType, IdlBitmapType, TypeLookupContext from typing import Union, List, Set from stringcase import capitalcase diff --git a/scripts/idl/generators/filters.py b/scripts/py_matter_idl/matter_idl/generators/filters.py similarity index 100% rename from scripts/idl/generators/filters.py rename to scripts/py_matter_idl/matter_idl/generators/filters.py diff --git a/scripts/idl/generators/java/ChipClustersCpp.jinja b/scripts/py_matter_idl/matter_idl/generators/java/ChipClustersCpp.jinja similarity index 100% rename from scripts/idl/generators/java/ChipClustersCpp.jinja rename to scripts/py_matter_idl/matter_idl/generators/java/ChipClustersCpp.jinja diff --git a/scripts/idl/generators/java/ChipClustersRead.jinja b/scripts/py_matter_idl/matter_idl/generators/java/ChipClustersRead.jinja similarity index 100% rename from scripts/idl/generators/java/ChipClustersRead.jinja rename to scripts/py_matter_idl/matter_idl/generators/java/ChipClustersRead.jinja diff --git a/scripts/idl/generators/java/__init__.py b/scripts/py_matter_idl/matter_idl/generators/java/__init__.py similarity index 97% rename from scripts/idl/generators/java/__init__.py rename to scripts/py_matter_idl/matter_idl/generators/java/__init__.py index 6f18e9629304e5..a0f465b4e2f416 100644 --- a/scripts/idl/generators/java/__init__.py +++ b/scripts/py_matter_idl/matter_idl/generators/java/__init__.py @@ -13,10 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from idl.generators import CodeGenerator, GeneratorStorage -from idl.matter_idl_types import Idl, ClusterSide, Field, Attribute, Cluster, FieldQuality, Command, DataType -from idl import matter_idl_types -from idl.generators.types import ParseDataType, BasicString, BasicInteger, FundamentalType, IdlType, IdlEnumType, IdlBitmapType, TypeLookupContext +from matter_idl.generators import CodeGenerator, GeneratorStorage +from matter_idl.matter_idl_types import Idl, ClusterSide, Field, Attribute, Cluster, FieldQuality, Command, DataType +from matter_idl import matter_idl_types +from matter_idl.generators.types import ParseDataType, BasicString, BasicInteger, FundamentalType, IdlType, IdlEnumType, IdlBitmapType, TypeLookupContext from typing import Union, List, Set from stringcase import capitalcase diff --git a/scripts/idl/generators/registry.py b/scripts/py_matter_idl/matter_idl/generators/registry.py similarity index 90% rename from scripts/idl/generators/registry.py rename to scripts/py_matter_idl/matter_idl/generators/registry.py index 8feeb2c48d1124..5510d3976dc623 100644 --- a/scripts/idl/generators/registry.py +++ b/scripts/py_matter_idl/matter_idl/generators/registry.py @@ -14,9 +14,9 @@ import enum -from idl.generators.java import JavaGenerator -from idl.generators.bridge import BridgeGenerator -from idl.generators.cpp.application import CppApplicationGenerator +from matter_idl.generators.java import JavaGenerator +from matter_idl.generators.bridge import BridgeGenerator +from matter_idl.generators.cpp.application import CppApplicationGenerator class CodeGenerator(enum.Enum): diff --git a/scripts/idl/generators/types.py b/scripts/py_matter_idl/matter_idl/generators/types.py similarity index 99% rename from scripts/idl/generators/types.py rename to scripts/py_matter_idl/matter_idl/generators/types.py index b6f216802de0d8..dd7705dc7070f9 100644 --- a/scripts/idl/generators/types.py +++ b/scripts/py_matter_idl/matter_idl/generators/types.py @@ -15,8 +15,8 @@ import logging import enum -from idl.matter_idl_types import DataType -from idl import matter_idl_types # to explicitly say 'Enum' +from matter_idl.matter_idl_types import DataType +from matter_idl import matter_idl_types # to explicitly say 'Enum' from typing import Union, List, Optional from dataclasses import dataclass diff --git a/scripts/idl/lint/__init__.py b/scripts/py_matter_idl/matter_idl/lint/__init__.py similarity index 100% rename from scripts/idl/lint/__init__.py rename to scripts/py_matter_idl/matter_idl/lint/__init__.py diff --git a/scripts/idl/lint/lint_rules_grammar.lark b/scripts/py_matter_idl/matter_idl/lint/lint_rules_grammar.lark similarity index 100% rename from scripts/idl/lint/lint_rules_grammar.lark rename to scripts/py_matter_idl/matter_idl/lint/lint_rules_grammar.lark diff --git a/scripts/idl/lint/lint_rules_parser.py b/scripts/py_matter_idl/matter_idl/lint/lint_rules_parser.py similarity index 91% rename from scripts/idl/lint/lint_rules_parser.py rename to scripts/py_matter_idl/matter_idl/lint/lint_rules_parser.py index fdd507cdbc383e..18bbb473b7871c 100755 --- a/scripts/idl/lint/lint_rules_parser.py +++ b/scripts/py_matter_idl/matter_idl/lint/lint_rules_parser.py @@ -16,8 +16,9 @@ except: import sys - sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "..")) - from idl.lint.types import RequiredAttributesRule, AttributeRequirement, ClusterRequirement, RequiredCommandsRule, ClusterCommandRequirement + sys.path.append(os.path.join(os.path.abspath( + os.path.dirname(__file__)), "..", "..")) + from matter_idl.lint.types import RequiredAttributesRule, AttributeRequirement, ClusterRequirement, RequiredCommandsRule, ClusterCommandRequirement def parseNumberString(n): @@ -90,7 +91,8 @@ def DecodeClusterFromXml(element: xml.etree.ElementTree.Element): if 'optional' in cmd.attrib and cmd.attrib['optional'] == 'true': continue - required_commands.append(RequiredCommand(name=cmd.attrib["name"], code=parseNumberString(cmd.attrib['code']))) + required_commands.append(RequiredCommand( + name=cmd.attrib["name"], code=parseNumberString(cmd.attrib['code']))) return DecodedCluster( name=name, @@ -124,8 +126,10 @@ class LintRulesContext: """ def __init__(self): - self._required_attributes_rule = RequiredAttributesRule("Required attributes") - self._required_commands_rule = RequiredCommandsRule("Required commands") + self._required_attributes_rule = RequiredAttributesRule( + "Required attributes") + self._required_commands_rule = RequiredCommandsRule( + "Required commands") # Map cluster names to the underlying code self._cluster_codes: Mapping[str, int] = {} @@ -146,7 +150,8 @@ def RequireClusterInEndpoint(self, name: str, code: int): name = "ID_%s" % name except ValueError: logging.error("UNKNOWN cluster name %s" % name) - logging.error("Known names: %s" % (",".join(self._cluster_codes.keys()), )) + logging.error("Known names: %s" % + (",".join(self._cluster_codes.keys()), )) return else: cluster_code = self._cluster_codes[name] @@ -237,7 +242,8 @@ def all_endpoint_rule(self, attributes): @v_args(inline=True) def load_xml(self, path): if not os.path.isabs(path): - path = os.path.abspath(os.path.join(os.path.dirname(self.file_name), path)) + path = os.path.abspath(os.path.join( + os.path.dirname(self.file_name), path)) self.context.LoadXml(path) @@ -262,7 +268,8 @@ def __init__(self, parser, file_name: str): self.file_name = file_name def parse(self): - data = LintRulesTransformer(self.file_name).transform(self.parser.parse(open(self.file_name, "rt").read())) + data = LintRulesTransformer(self.file_name).transform( + self.parser.parse(open(self.file_name, "rt").read())) return data diff --git a/scripts/idl/lint/types.py b/scripts/py_matter_idl/matter_idl/lint/types.py similarity index 92% rename from scripts/idl/lint/types.py rename to scripts/py_matter_idl/matter_idl/lint/types.py index 85dfbdeacd0bc3..8ee6a805ec4d4e 100644 --- a/scripts/idl/lint/types.py +++ b/scripts/py_matter_idl/matter_idl/lint/types.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from idl.matter_idl_types import Idl, ParseMetaData, ClusterSide +from matter_idl.matter_idl_types import Idl, ParseMetaData, ClusterSide from abc import ABC, abstractmethod from typing import List, Optional from dataclasses import dataclass, field @@ -40,7 +40,8 @@ class LintError: def __init__(self, text: str, location: Optional[LocationInFile] = None): self.message = text if location: - self.message += " at %s:%d:%d" % (location.file_name, location.line, location.column) + self.message += " at %s:%d:%d" % (location.file_name, + location.line, location.column) def __str__(self): return self.message @@ -84,7 +85,8 @@ def __init__(self, name): self._idl = None def _AddLintError(self, text, location): - self._lint_errors.append(LintError("%s: %s" % (self.name, text), location)) + self._lint_errors.append( + LintError("%s: %s" % (self.name, text), location)) def _ParseLocation(self, meta: Optional[ParseMetaData]) -> Optional[LocationInFile]: """Create a location in the current file that is being parsed. """ @@ -146,11 +148,13 @@ def _ServerClusterDefinition(self, name: str, location: Optional[LocationInFile] c for c in self._idl.clusters if c.name == name and c.side == ClusterSide.SERVER ] if not cluster_definition: - self._AddLintError("Cluster definition for %s not found" % cluster.name, location) + self._AddLintError( + "Cluster definition for %s not found" % cluster.name, location) return None if len(cluster_definition) > 1: - self._AddLintError("Multiple cluster definitions found for %s" % cluster.name, location) + self._AddLintError( + "Multiple cluster definitions found for %s" % cluster.name, location) return None return cluster_definition[0] @@ -161,7 +165,8 @@ def _LintImpl(self): cluster_codes = set() for cluster in endpoint.server_clusters: - cluster_definition = self._ServerClusterDefinition(cluster.name, self._ParseLocation(cluster.parse_meta)) + cluster_definition = self._ServerClusterDefinition( + cluster.name, self._ParseLocation(cluster.parse_meta)) if not cluster_definition: continue @@ -215,7 +220,8 @@ def __init__(self, name): super(RequiredCommandsRule, self).__init__(name) # Maps cluster id to mandatory cluster requirement - self._mandatory_commands: Maping[int, List[ClusterCommandRequirement]] = {} + self._mandatory_commands: Maping[int, + List[ClusterCommandRequirement]] = {} def __repr__(self): result = "RequiredCommandsRule{\n" diff --git a/scripts/idl/matter_grammar.lark b/scripts/py_matter_idl/matter_idl/matter_grammar.lark similarity index 100% rename from scripts/idl/matter_grammar.lark rename to scripts/py_matter_idl/matter_idl/matter_grammar.lark diff --git a/scripts/idl/matter_idl_parser.py b/scripts/py_matter_idl/matter_idl/matter_idl_parser.py similarity index 100% rename from scripts/idl/matter_idl_parser.py rename to scripts/py_matter_idl/matter_idl/matter_idl_parser.py diff --git a/scripts/idl/matter_idl_types.py b/scripts/py_matter_idl/matter_idl/matter_idl_types.py similarity index 100% rename from scripts/idl/matter_idl_types.py rename to scripts/py_matter_idl/matter_idl/matter_idl_types.py diff --git a/scripts/idl/test_generators.py b/scripts/py_matter_idl/matter_idl/test_generators.py similarity index 93% rename from scripts/idl/test_generators.py rename to scripts/py_matter_idl/matter_idl/test_generators.py index 730bfdbc610762..9fb21aecf565dd 100755 --- a/scripts/idl/test_generators.py +++ b/scripts/py_matter_idl/matter_idl/test_generators.py @@ -22,19 +22,19 @@ from dataclasses import dataclass, field try: - from idl.matter_idl_parser import CreateParser + from matter_idl.matter_idl_parser import CreateParser except: import sys sys.path.append(os.path.abspath( os.path.join(os.path.dirname(__file__), '..'))) - from idl.matter_idl_parser import CreateParser + from matter_idl.matter_idl_parser import CreateParser -from idl.matter_idl_types import Idl -from idl.generators.java import JavaGenerator -from idl.generators.bridge import BridgeGenerator -from idl.generators.cpp.application import CppApplicationGenerator -from idl.generators import GeneratorStorage +from matter_idl.matter_idl_types import Idl +from matter_idl.generators.java import JavaGenerator +from matter_idl.generators.bridge import BridgeGenerator +from matter_idl.generators.cpp.application import CppApplicationGenerator +from matter_idl.generators import GeneratorStorage TESTS_DIR = os.path.join(os.path.dirname(__file__), "tests") diff --git a/scripts/idl/test_matter_idl_parser.py b/scripts/py_matter_idl/matter_idl/test_matter_idl_parser.py similarity index 100% rename from scripts/idl/test_matter_idl_parser.py rename to scripts/py_matter_idl/matter_idl/test_matter_idl_parser.py diff --git a/scripts/idl/test_xml_parser.py b/scripts/py_matter_idl/matter_idl/test_xml_parser.py similarity index 90% rename from scripts/idl/test_xml_parser.py rename to scripts/py_matter_idl/matter_idl/test_xml_parser.py index 932a5731d59268..e8645cb0f4043d 100755 --- a/scripts/idl/test_xml_parser.py +++ b/scripts/py_matter_idl/matter_idl/test_xml_parser.py @@ -19,16 +19,17 @@ from typing import Optional, Union, List try: - from idl.matter_idl_types import * - from idl.zapxml import ParseSource, ParseXmls + from matter_idl.matter_idl_types import * + from matter_idl.zapxml import ParseSource, ParseXmls except: import os import sys - sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) + sys.path.append(os.path.abspath( + os.path.join(os.path.dirname(__file__), '..'))) - from idl.matter_idl_types import * - from idl.zapxml import ParseSource, ParseXmls + from matter_idl.matter_idl_types import * + from matter_idl.zapxml import ParseSource, ParseXmls def XmlToIdl(what: Union[str, List[str]]) -> Idl: @@ -37,7 +38,8 @@ def XmlToIdl(what: Union[str, List[str]]) -> Idl: sources = [] for idx, txt in enumerate(what): - sources.append(ParseSource(source=io.StringIO(txt), name=("Input %d" % (idx + 1)))) + sources.append(ParseSource(source=io.StringIO( + txt), name=("Input %d" % (idx + 1)))) return ParseXmls(sources, include_meta_data=False) @@ -97,8 +99,10 @@ def testCluster(self): structs=[ Struct(name='GetSomeDataRequest', fields=[ - Field(data_type=DataType(name='INT8U'), code=0, name='firstInput'), - Field(data_type=DataType(name='INT16U'), code=1, name='secondInput') + Field(data_type=DataType( + name='INT8U'), code=0, name='firstInput'), + Field(data_type=DataType( + name='INT16U'), code=1, name='secondInput') ], tag=StructTag.REQUEST), Struct(name='GetSomeDataResponse', @@ -142,8 +146,10 @@ def testBitmap(self): self.assertEqual(idl, Idl(clusters=[ - Cluster(side=ClusterSide.CLIENT, name='Test1', code=1, bitmaps=[bitmap]), - Cluster(side=ClusterSide.CLIENT, name='Test2', code=2, bitmaps=[bitmap]), + Cluster(side=ClusterSide.CLIENT, + name='Test1', code=1, bitmaps=[bitmap]), + Cluster(side=ClusterSide.CLIENT, + name='Test2', code=2, bitmaps=[bitmap]), ])) def testFabricScopedAndSensitive(self): @@ -226,19 +232,23 @@ def testStruct(self): name='SomeStruct', qualities=StructQuality.FABRIC_SCOPED, fields=[ - Field(data_type=DataType(name='int16u'), code=0, name='FirstMember'), - Field(data_type=DataType(name='int32u'), code=1, name='SecondMember') + Field(data_type=DataType(name='int16u'), + code=0, name='FirstMember'), + Field(data_type=DataType(name='int32u'), + code=1, name='SecondMember') ] ) self.assertEqual(idl, Idl(clusters=[ - Cluster(side=ClusterSide.CLIENT, name='Test1', code=10, structs=[struct]), + Cluster(side=ClusterSide.CLIENT, + name='Test1', code=10, structs=[struct]), Cluster(side=ClusterSide.CLIENT, name='Test2', code=20, structs=[struct], attributes=[ Attribute( definition=Field( - data_type=DataType(name='SomeStruct'), + data_type=DataType( + name='SomeStruct'), code=123, name='FabricAttribute', qualities=FieldQuality.NULLABLE @@ -287,7 +297,8 @@ def testSkipsNotProcessedFields(self): attributes=[ Attribute( definition=Field( - data_type=DataType(name='Type'), + data_type=DataType( + name='Type'), code=0, name='Type', ), diff --git a/scripts/idl/tests/available_tests.yaml b/scripts/py_matter_idl/matter_idl/tests/available_tests.yaml similarity index 100% rename from scripts/idl/tests/available_tests.yaml rename to scripts/py_matter_idl/matter_idl/tests/available_tests.yaml diff --git a/scripts/idl/tests/inputs/cluster_struct_attribute.matter b/scripts/py_matter_idl/matter_idl/tests/inputs/cluster_struct_attribute.matter similarity index 100% rename from scripts/idl/tests/inputs/cluster_struct_attribute.matter rename to scripts/py_matter_idl/matter_idl/tests/inputs/cluster_struct_attribute.matter diff --git a/scripts/idl/tests/inputs/global_struct_attribute.matter b/scripts/py_matter_idl/matter_idl/tests/inputs/global_struct_attribute.matter similarity index 100% rename from scripts/idl/tests/inputs/global_struct_attribute.matter rename to scripts/py_matter_idl/matter_idl/tests/inputs/global_struct_attribute.matter diff --git a/scripts/idl/tests/inputs/large_all_clusters_app.matter b/scripts/py_matter_idl/matter_idl/tests/inputs/large_all_clusters_app.matter similarity index 100% rename from scripts/idl/tests/inputs/large_all_clusters_app.matter rename to scripts/py_matter_idl/matter_idl/tests/inputs/large_all_clusters_app.matter diff --git a/scripts/idl/tests/inputs/large_lighting_app.matter b/scripts/py_matter_idl/matter_idl/tests/inputs/large_lighting_app.matter similarity index 100% rename from scripts/idl/tests/inputs/large_lighting_app.matter rename to scripts/py_matter_idl/matter_idl/tests/inputs/large_lighting_app.matter diff --git a/scripts/idl/tests/inputs/optional_argument.matter b/scripts/py_matter_idl/matter_idl/tests/inputs/optional_argument.matter similarity index 100% rename from scripts/idl/tests/inputs/optional_argument.matter rename to scripts/py_matter_idl/matter_idl/tests/inputs/optional_argument.matter diff --git a/scripts/idl/tests/inputs/several_clusters.matter b/scripts/py_matter_idl/matter_idl/tests/inputs/several_clusters.matter similarity index 100% rename from scripts/idl/tests/inputs/several_clusters.matter rename to scripts/py_matter_idl/matter_idl/tests/inputs/several_clusters.matter diff --git a/scripts/idl/tests/inputs/simple_attribute.matter b/scripts/py_matter_idl/matter_idl/tests/inputs/simple_attribute.matter similarity index 100% rename from scripts/idl/tests/inputs/simple_attribute.matter rename to scripts/py_matter_idl/matter_idl/tests/inputs/simple_attribute.matter diff --git a/scripts/idl/tests/outputs/cluster_struct_attribute/bridge/BridgeClustersImpl.h b/scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/bridge/BridgeClustersImpl.h similarity index 100% rename from scripts/idl/tests/outputs/cluster_struct_attribute/bridge/BridgeClustersImpl.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/bridge/BridgeClustersImpl.h diff --git a/scripts/idl/tests/outputs/cluster_struct_attribute/bridge/BridgeGlobalStructs.h b/scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/bridge/BridgeGlobalStructs.h similarity index 100% rename from scripts/idl/tests/outputs/cluster_struct_attribute/bridge/BridgeGlobalStructs.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/bridge/BridgeGlobalStructs.h diff --git a/scripts/idl/tests/outputs/cluster_struct_attribute/bridge/DemoClusterServer.h b/scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/bridge/DemoClusterServer.h similarity index 100% rename from scripts/idl/tests/outputs/cluster_struct_attribute/bridge/DemoClusterServer.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/bridge/DemoClusterServer.h diff --git a/scripts/idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp diff --git a/scripts/idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp diff --git a/scripts/idl/tests/outputs/global_struct_attribute/bridge/BridgeClustersImpl.h b/scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/bridge/BridgeClustersImpl.h similarity index 100% rename from scripts/idl/tests/outputs/global_struct_attribute/bridge/BridgeClustersImpl.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/bridge/BridgeClustersImpl.h diff --git a/scripts/idl/tests/outputs/global_struct_attribute/bridge/BridgeGlobalStructs.h b/scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/bridge/BridgeGlobalStructs.h similarity index 100% rename from scripts/idl/tests/outputs/global_struct_attribute/bridge/BridgeGlobalStructs.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/bridge/BridgeGlobalStructs.h diff --git a/scripts/idl/tests/outputs/global_struct_attribute/bridge/DemoClusterServer.h b/scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/bridge/DemoClusterServer.h similarity index 100% rename from scripts/idl/tests/outputs/global_struct_attribute/bridge/DemoClusterServer.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/bridge/DemoClusterServer.h diff --git a/scripts/idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp diff --git a/scripts/idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp diff --git a/scripts/idl/tests/outputs/large_all_clusters_app/cpp-app/PluginApplicationCallbacks.h b/scripts/py_matter_idl/matter_idl/tests/outputs/large_all_clusters_app/cpp-app/PluginApplicationCallbacks.h similarity index 100% rename from scripts/idl/tests/outputs/large_all_clusters_app/cpp-app/PluginApplicationCallbacks.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/large_all_clusters_app/cpp-app/PluginApplicationCallbacks.h diff --git a/scripts/idl/tests/outputs/large_all_clusters_app/cpp-app/callback-stub.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/large_all_clusters_app/cpp-app/callback-stub.cpp similarity index 100% rename from scripts/idl/tests/outputs/large_all_clusters_app/cpp-app/callback-stub.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/large_all_clusters_app/cpp-app/callback-stub.cpp diff --git a/scripts/idl/tests/outputs/large_lighting_app/cpp-app/PluginApplicationCallbacks.h b/scripts/py_matter_idl/matter_idl/tests/outputs/large_lighting_app/cpp-app/PluginApplicationCallbacks.h similarity index 100% rename from scripts/idl/tests/outputs/large_lighting_app/cpp-app/PluginApplicationCallbacks.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/large_lighting_app/cpp-app/PluginApplicationCallbacks.h diff --git a/scripts/idl/tests/outputs/large_lighting_app/cpp-app/callback-stub.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/large_lighting_app/cpp-app/callback-stub.cpp similarity index 100% rename from scripts/idl/tests/outputs/large_lighting_app/cpp-app/callback-stub.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/large_lighting_app/cpp-app/callback-stub.cpp diff --git a/scripts/idl/tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp diff --git a/scripts/idl/tests/outputs/optional_argument/jni/MyClusterClient-ReadImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/optional_argument/jni/MyClusterClient-ReadImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/optional_argument/jni/MyClusterClient-ReadImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/optional_argument/jni/MyClusterClient-ReadImpl.cpp diff --git a/scripts/idl/tests/outputs/several_clusters/bridge/BridgeClustersImpl.h b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/BridgeClustersImpl.h similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/bridge/BridgeClustersImpl.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/BridgeClustersImpl.h diff --git a/scripts/idl/tests/outputs/several_clusters/bridge/BridgeGlobalStructs.h b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/BridgeGlobalStructs.h similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/bridge/BridgeGlobalStructs.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/BridgeGlobalStructs.h diff --git a/scripts/idl/tests/outputs/several_clusters/bridge/FirstServer.h b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/FirstServer.h similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/bridge/FirstServer.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/FirstServer.h diff --git a/scripts/idl/tests/outputs/several_clusters/bridge/SecondServer.h b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/SecondServer.h similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/bridge/SecondServer.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/SecondServer.h diff --git a/scripts/idl/tests/outputs/several_clusters/bridge/Third.h b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/Third.h similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/bridge/Third.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/Third.h diff --git a/scripts/idl/tests/outputs/several_clusters/bridge/ThirdServer.h b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/ThirdServer.h similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/bridge/ThirdServer.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/ThirdServer.h diff --git a/scripts/idl/tests/outputs/several_clusters/cpp-app/PluginApplicationCallbacks.h b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/cpp-app/PluginApplicationCallbacks.h similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/cpp-app/PluginApplicationCallbacks.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/cpp-app/PluginApplicationCallbacks.h diff --git a/scripts/idl/tests/outputs/several_clusters/cpp-app/callback-stub.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/cpp-app/callback-stub.cpp similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/cpp-app/callback-stub.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/cpp-app/callback-stub.cpp diff --git a/scripts/idl/tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp diff --git a/scripts/idl/tests/outputs/several_clusters/jni/FirstClient-ReadImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/FirstClient-ReadImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/jni/FirstClient-ReadImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/FirstClient-ReadImpl.cpp diff --git a/scripts/idl/tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp diff --git a/scripts/idl/tests/outputs/several_clusters/jni/SecondClient-ReadImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/SecondClient-ReadImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/jni/SecondClient-ReadImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/SecondClient-ReadImpl.cpp diff --git a/scripts/idl/tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp diff --git a/scripts/idl/tests/outputs/several_clusters/jni/ThirdClient-ReadImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/ThirdClient-ReadImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/several_clusters/jni/ThirdClient-ReadImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/ThirdClient-ReadImpl.cpp diff --git a/scripts/idl/tests/outputs/simple_attribute/bridge/BridgeClustersImpl.h b/scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/bridge/BridgeClustersImpl.h similarity index 100% rename from scripts/idl/tests/outputs/simple_attribute/bridge/BridgeClustersImpl.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/bridge/BridgeClustersImpl.h diff --git a/scripts/idl/tests/outputs/simple_attribute/bridge/BridgeGlobalStructs.h b/scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/bridge/BridgeGlobalStructs.h similarity index 100% rename from scripts/idl/tests/outputs/simple_attribute/bridge/BridgeGlobalStructs.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/bridge/BridgeGlobalStructs.h diff --git a/scripts/idl/tests/outputs/simple_attribute/bridge/MyClusterServer.h b/scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/bridge/MyClusterServer.h similarity index 100% rename from scripts/idl/tests/outputs/simple_attribute/bridge/MyClusterServer.h rename to scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/bridge/MyClusterServer.h diff --git a/scripts/idl/tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp diff --git a/scripts/idl/tests/outputs/simple_attribute/jni/MyClusterClient-ReadImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/jni/MyClusterClient-ReadImpl.cpp similarity index 100% rename from scripts/idl/tests/outputs/simple_attribute/jni/MyClusterClient-ReadImpl.cpp rename to scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/jni/MyClusterClient-ReadImpl.cpp diff --git a/scripts/idl/xml_parser.py b/scripts/py_matter_idl/matter_idl/xml_parser.py similarity index 93% rename from scripts/idl/xml_parser.py rename to scripts/py_matter_idl/matter_idl/xml_parser.py index f2955c973ef632..5ef145ee377462 100755 --- a/scripts/idl/xml_parser.py +++ b/scripts/py_matter_idl/matter_idl/xml_parser.py @@ -21,15 +21,15 @@ import xml.sax.handler try: - from idl.matter_idl_types import Idl + from matter_idl.matter_idl_types import Idl except: import sys sys.path.append(os.path.abspath( os.path.join(os.path.dirname(__file__), '..'))) - from idl.matter_idl_types import Idl + from matter_idl.matter_idl_types import Idl -from idl.zapxml import ParseSource, ParseXmls +from matter_idl.zapxml import ParseSource, ParseXmls if __name__ == '__main__': diff --git a/scripts/idl/zapxml/__init__.py b/scripts/py_matter_idl/matter_idl/zapxml/__init__.py similarity index 90% rename from scripts/idl/zapxml/__init__.py rename to scripts/py_matter_idl/matter_idl/zapxml/__init__.py index 332d1c244bea3b..41b31b452ae066 100644 --- a/scripts/idl/zapxml/__init__.py +++ b/scripts/py_matter_idl/matter_idl/zapxml/__init__.py @@ -19,8 +19,8 @@ from dataclasses import dataclass from typing import Optional, Union, List -from idl.zapxml.handlers import Context, ZapXmlHandler -from idl.matter_idl_types import Idl +from matter_idl.zapxml.handlers import Context, ZapXmlHandler +from matter_idl.matter_idl_types import Idl class ParseHandler(xml.sax.handler.ContentHandler): @@ -32,7 +32,7 @@ class ParseHandler(xml.sax.handler.ContentHandler): - sets up parsing location within the context - keeps track of ParsePath - Overall converts a python SAX handler into idl.zapxml.handlers + Overall converts a python SAX handler into matter_idl.zapxml.handlers """ def __init__(self, include_meta_data=True): @@ -66,7 +66,8 @@ def endDocument(self): def startElement(self, name: str, attrs): logging.debug("ELEMENT START: %r / %r" % (name, attrs)) self._context.path.push(name) - self._processing_stack.append(self._processing_stack[-1].GetNextProcessor(name, attrs)) + self._processing_stack.append( + self._processing_stack[-1].GetNextProcessor(name, attrs)) def endElement(self, name: str): logging.debug("ELEMENT END: %r" % name) @@ -89,7 +90,8 @@ class ParseSource: Allows for named data sources to be parsed. """ source: Union[str, typing.IO] # filename or stream - name: Optional[str] = None # actual filename to use, None if the source is a filename already + # actual filename to use, None if the source is a filename already + name: Optional[str] = None @ property def source_file_name(self): diff --git a/scripts/idl/zapxml/handlers/__init__.py b/scripts/py_matter_idl/matter_idl/zapxml/handlers/__init__.py similarity index 96% rename from scripts/idl/zapxml/handlers/__init__.py rename to scripts/py_matter_idl/matter_idl/zapxml/handlers/__init__.py index 7a6bfa04682921..3745954a195cfd 100644 --- a/scripts/idl/zapxml/handlers/__init__.py +++ b/scripts/py_matter_idl/matter_idl/zapxml/handlers/__init__.py @@ -16,7 +16,7 @@ from .context import Context from .handlers import ConfiguratorHandler -from idl.matter_idl_types import Idl +from matter_idl.matter_idl_types import Idl class ZapXmlHandler(BaseHandler): diff --git a/scripts/idl/zapxml/handlers/base.py b/scripts/py_matter_idl/matter_idl/zapxml/handlers/base.py similarity index 100% rename from scripts/idl/zapxml/handlers/base.py rename to scripts/py_matter_idl/matter_idl/zapxml/handlers/base.py diff --git a/scripts/idl/zapxml/handlers/context.py b/scripts/py_matter_idl/matter_idl/zapxml/handlers/context.py similarity index 95% rename from scripts/idl/zapxml/handlers/context.py rename to scripts/py_matter_idl/matter_idl/zapxml/handlers/context.py index 2d82153d76d959..b8fd748dfdcfd2 100644 --- a/scripts/idl/zapxml/handlers/context.py +++ b/scripts/py_matter_idl/matter_idl/zapxml/handlers/context.py @@ -15,7 +15,7 @@ import logging import xml.sax.xmlreader -from idl.matter_idl_types import Idl, ParseMetaData, Attribute +from matter_idl.matter_idl_types import Idl, ParseMetaData, Attribute from typing import Optional, List @@ -104,7 +104,8 @@ def AddGlobalAttribute(self, attribute: Attribute): # NOTE: this may get added several times as both 'client' and 'server' # however matter should not differentiate between the two code = attribute.definition.code - logging.info('Adding global attribute 0x%X (%d): %s' % (code, code, attribute.definition.name)) + logging.info('Adding global attribute 0x%X (%d): %s' % + (code, code, attribute.definition.name)) self._global_attributes[code] = attribute diff --git a/scripts/idl/zapxml/handlers/handlers.py b/scripts/py_matter_idl/matter_idl/zapxml/handlers/handlers.py similarity index 96% rename from scripts/idl/zapxml/handlers/handlers.py rename to scripts/py_matter_idl/matter_idl/zapxml/handlers/handlers.py index 313fc61e8cdbb7..f1396627247a36 100644 --- a/scripts/idl/zapxml/handlers/handlers.py +++ b/scripts/py_matter_idl/matter_idl/zapxml/handlers/handlers.py @@ -14,7 +14,7 @@ import logging -from idl.matter_idl_types import * +from matter_idl.matter_idl_types import * from typing import Optional, Union, List from .context import Context, IdlPostProcessor @@ -245,7 +245,8 @@ class EnumHandler(BaseHandler, IdlPostProcessor): def __init__(self, context: Context, attrs): super().__init__(context) self._cluster_code = None # if set, enum belongs to a specific cluster - self._enum = Enum(name=attrs['name'], base_type=attrs['type'], entries=[]) + self._enum = Enum(name=attrs['name'], + base_type=attrs['type'], entries=[]) def GetNextProcessor(self, name, attrs): if name.lower() == 'item': @@ -256,7 +257,8 @@ def GetNextProcessor(self, name, attrs): return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) elif name.lower() == 'cluster': if self._cluster_code is not None: - raise Exception('Multiple cluster codes for enum %s' % self._enum.name) + raise Exception( + 'Multiple cluster codes for enum %s' % self._enum.name) self._cluster_code = ParseInt(attrs['code']) return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) else: @@ -290,7 +292,8 @@ class BitmapHandler(BaseHandler): def __init__(self, context: Context, attrs): super().__init__(context) self._cluster_codes = set() - self._bitmap = Bitmap(name=attrs['name'], base_type=attrs['type'], entries=[]) + self._bitmap = Bitmap( + name=attrs['name'], base_type=attrs['type'], entries=[]) def GetNextProcessor(self, name, attrs): if name.lower() == 'cluster': @@ -410,7 +413,8 @@ def GetNextProcessor(self, name: str, attrs): if self._command: self._command.invokeacl = AttrsToAccessPrivilege(attrs) else: - logging.warning("Ignored access role for reply %r" % self._struct) + logging.warning( + "Ignored access role for reply %r" % self._struct) return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) elif name.lower() == 'arg': self._struct.fields.append(self.GetArgumentField(attrs)) @@ -444,13 +448,15 @@ def GetNextProcessor(self, name: str, attrs): if name.lower() == 'featurebit': # It is uncler what featurebits mean. likely a bitmap should be created # here, however only one such example exists currently: door-lock-cluster.xml - logging.info('Ignoring featurebit tag for global attribute 0x%X (%d)' % (self._code, self._code)) + logging.info('Ignoring featurebit tag for global attribute 0x%X (%d)' % ( + self._code, self._code)) return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) else: return BaseHandler(self.context) def EndProcessing(self): - self._cluster.attributes.append(self.context.GetGlobalAttribute(self._code)) + self._cluster.attributes.append( + self.context.GetGlobalAttribute(self._code)) class ClusterHandler(BaseHandler): @@ -566,7 +572,8 @@ def GetNextProcessor(self, name, attrs): if attrs['side'].lower() == 'client': # We expect to also have 'server' equivalent, so ignore client # side attributes - logging.debug('Ignoring global client-side attribute %s' % (attrs['code'])) + logging.debug( + 'Ignoring global client-side attribute %s' % (attrs['code'])) return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG) return GlobalAttributeHandler(self.context, AttrsToAttribute(attrs)) diff --git a/scripts/idl/zapxml/handlers/parsing.py b/scripts/py_matter_idl/matter_idl/zapxml/handlers/parsing.py similarity index 98% rename from scripts/idl/zapxml/handlers/parsing.py rename to scripts/py_matter_idl/matter_idl/zapxml/handlers/parsing.py index f9315f3dab6875..40553edc0d4d1e 100644 --- a/scripts/idl/zapxml/handlers/parsing.py +++ b/scripts/py_matter_idl/matter_idl/zapxml/handlers/parsing.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from idl.matter_idl_types import * +from matter_idl.matter_idl_types import * def ParseInt(value: str) -> int: diff --git a/scripts/py_matter_idl/pyproject.toml b/scripts/py_matter_idl/pyproject.toml new file mode 100644 index 00000000000000..ab9c08adaab8b5 --- /dev/null +++ b/scripts/py_matter_idl/pyproject.toml @@ -0,0 +1,17 @@ +# Copyright (c) 2022 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. + +[build-system] +requires = ['setuptools', 'wheel'] +build-backend = 'setuptools.build_meta' diff --git a/scripts/py_matter_idl/setup.cfg b/scripts/py_matter_idl/setup.cfg new file mode 100644 index 00000000000000..91e84f82ca8990 --- /dev/null +++ b/scripts/py_matter_idl/setup.cfg @@ -0,0 +1,36 @@ +# Copyright (c) 2022 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. + +[metadata] +name = matter_idl +version = 0.0.1 +author = Project CHIP Authors +description = Parse matter idl files + +[options] +packages = find: +zip_safe = False + +[options.package_data] +matter_idl = + lint/lint_rules_grammar.lark + matter_grammar.lark + generators/java/ChipClustersRead.jinja + generators/java/ChipClustersCpp.jinja + generators/cpp/application/CallbackStubSource.jinja + generators/cpp/application/PluginApplicationCallbacksHeader.jinja + generators/bridge/BridgeClustersHeader.jinja + generators/bridge/BridgeClustersCommon.jinja + generators/bridge/BridgeClustersCpp.jinja + generators/bridge/BridgeClustersGlobalStructs.jinja diff --git a/scripts/idl/setup.py b/scripts/py_matter_idl/setup.py similarity index 70% rename from scripts/idl/setup.py rename to scripts/py_matter_idl/setup.py index 4566792c40074a..5c10e05ae39916 100644 --- a/scripts/idl/setup.py +++ b/scripts/py_matter_idl/setup.py @@ -13,16 +13,8 @@ # limitations under the License. -"""The idl package.""" +"""The matter_idl package.""" import setuptools # type: ignore -setuptools.setup( - name='idl', - version='0.0.1', - author='Project CHIP Authors', - description='Parse matter idl files', - packages=setuptools.find_packages(), - package_data={'idl': ['py.typed']}, - zip_safe=False, -) +setuptools.setup() # Package definition in setup.cfg diff --git a/scripts/tests/yamltests/BUILD.gn b/scripts/py_matter_yamltests/BUILD.gn similarity index 72% rename from scripts/tests/yamltests/BUILD.gn rename to scripts/py_matter_yamltests/BUILD.gn index 2f9a49c0744181..88ba5a41b1cc19 100644 --- a/scripts/tests/yamltests/BUILD.gn +++ b/scripts/py_matter_yamltests/BUILD.gn @@ -18,18 +18,22 @@ import("//build_overrides/chip.gni") import("//build_overrides/pigweed.gni") import("$dir_pw_build/python.gni") -pw_python_package("yamltests") { - setup = [ "setup.py" ] +pw_python_package("matter_yamltests") { + setup = [ + "setup.py", + "setup.cfg", + "pyproject.toml", + ] sources = [ - "__init__.py", - "constraints.py", - "definitions.py", - "fixes.py", - "parser.py", + "matter_yamltests/__init__.py", + "matter_yamltests/constraints.py", + "matter_yamltests/definitions.py", + "matter_yamltests/fixes.py", + "matter_yamltests/parser.py", ] - python_deps = [ "${chip_root}/scripts/idl" ] + python_deps = [ "${chip_root}/scripts/py_matter_idl:matter_idl" ] tests = [ "test_spec_definitions.py" ] diff --git a/scripts/tests/yamltests/__init__.py b/scripts/py_matter_yamltests/matter_yamltests/__init__.py similarity index 100% rename from scripts/tests/yamltests/__init__.py rename to scripts/py_matter_yamltests/matter_yamltests/__init__.py diff --git a/scripts/tests/yamltests/constraints.py b/scripts/py_matter_yamltests/matter_yamltests/constraints.py similarity index 100% rename from scripts/tests/yamltests/constraints.py rename to scripts/py_matter_yamltests/matter_yamltests/constraints.py diff --git a/scripts/tests/yamltests/definitions.py b/scripts/py_matter_yamltests/matter_yamltests/definitions.py similarity index 82% rename from scripts/tests/yamltests/definitions.py rename to scripts/py_matter_yamltests/matter_yamltests/definitions.py index 006704993d7bab..f4b39b134e3f1a 100644 --- a/scripts/tests/yamltests/definitions.py +++ b/scripts/py_matter_yamltests/matter_yamltests/definitions.py @@ -16,16 +16,8 @@ from typing import List import enum -try: - from idl.zapxml import ParseSource, ParseXmls - from idl.matter_idl_types import * -except: - import os - import sys - sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..'))) - - from idl.zapxml import ParseSource, ParseXmls - from idl.matter_idl_types import * +from matter_idl.zapxml import ParseSource, ParseXmls +from matter_idl.matter_idl_types import * class _ItemType(enum.Enum): @@ -66,23 +58,31 @@ def __init__(self, sources: List[ParseSource]): self.__clusters_by_id[code] = cluster self.__commands_by_id[code] = {c.code: c for c in cluster.commands} self.__responses_by_id[code] = {} - self.__attributes_by_id[code] = {a.definition.code: a for a in cluster.attributes} + self.__attributes_by_id[code] = { + a.definition.code: a for a in cluster.attributes} self.__events_by_id[code] = {e.code: e for e in cluster.events} self.__clusters_by_name[name] = cluster.code - self.__commands_by_name[name] = {c.name.lower(): c.code for c in cluster.commands} + self.__commands_by_name[name] = { + c.name.lower(): c.code for c in cluster.commands} self.__responses_by_name[name] = {} - self.__attributes_by_name[name] = {a.definition.name.lower(): a.definition.code for a in cluster.attributes} - self.__events_by_name[name] = {e.name.lower(): e.code for e in cluster.events} - - self.__bitmaps_by_name[name] = {b.name.lower(): b for b in cluster.bitmaps} - self.__enums_by_name[name] = {e.name.lower(): e for e in cluster.enums} - self.__structs_by_name[name] = {s.name.lower(): s for s in cluster.structs} + self.__attributes_by_name[name] = { + a.definition.name.lower(): a.definition.code for a in cluster.attributes} + self.__events_by_name[name] = { + e.name.lower(): e.code for e in cluster.events} + + self.__bitmaps_by_name[name] = { + b.name.lower(): b for b in cluster.bitmaps} + self.__enums_by_name[name] = { + e.name.lower(): e for e in cluster.enums} + self.__structs_by_name[name] = { + s.name.lower(): s for s in cluster.structs} for struct in cluster.structs: if struct.tag == StructTag.RESPONSE: self.__responses_by_id[code][struct.code] = struct - self.__responses_by_name[name][struct.name.lower()] = struct.code + self.__responses_by_name[name][struct.name.lower( + )] = struct.code def get_cluster_name(self, cluster_id: int) -> str: cluster = self.__clusters_by_id.get(cluster_id) @@ -93,11 +93,13 @@ def get_command_name(self, cluster_id: int, command_id: int) -> str: return command.name if command else None def get_response_name(self, cluster_id: int, response_id: int) -> str: - response = self.__get_by_id(cluster_id, response_id, _ItemType.Response) + response = self.__get_by_id( + cluster_id, response_id, _ItemType.Response) return response.name if response else None def get_attribute_name(self, cluster_id: int, attribute_id: int) -> str: - attribute = self.__get_by_id(cluster_id, attribute_id, _ItemType.Attribute) + attribute = self.__get_by_id( + cluster_id, attribute_id, _ItemType.Attribute) return attribute.definition.name if attribute else None def get_event_name(self, cluster_id: int, event_id: int) -> str: @@ -162,16 +164,20 @@ def __get_by_name(self, cluster_name: str, target_name: str, target_type: _ItemT target = None if target_type == _ItemType.Request: - target_id = self.__commands_by_name.get(cluster_name).get(target_name) + target_id = self.__commands_by_name.get( + cluster_name).get(target_name) target = self.__get_by_id(cluster_id, target_id, target_type) elif target_type == _ItemType.Response: - target_id = self.__responses_by_name.get(cluster_name).get(target_name) + target_id = self.__responses_by_name.get( + cluster_name).get(target_name) target = self.__get_by_id(cluster_id, target_id, target_type) elif target_type == _ItemType.Event: - target_id = self.__events_by_name.get(cluster_name).get(target_name) + target_id = self.__events_by_name.get( + cluster_name).get(target_name) target = self.__get_by_id(cluster_id, target_id, target_type) elif target_type == _ItemType.Attribute: - target_id = self.__attributes_by_name.get(cluster_name).get(target_name) + target_id = self.__attributes_by_name.get( + cluster_name).get(target_name) target = self.__get_by_id(cluster_id, target_id, target_type) elif target_type == _ItemType.Bitmap: target = self.__bitmaps_by_name.get(cluster_name).get(target_name) diff --git a/scripts/tests/yamltests/fixes.py b/scripts/py_matter_yamltests/matter_yamltests/fixes.py similarity index 100% rename from scripts/tests/yamltests/fixes.py rename to scripts/py_matter_yamltests/matter_yamltests/fixes.py diff --git a/scripts/tests/yamltests/parser.py b/scripts/py_matter_yamltests/matter_yamltests/parser.py similarity index 100% rename from scripts/tests/yamltests/parser.py rename to scripts/py_matter_yamltests/matter_yamltests/parser.py diff --git a/scripts/py_matter_yamltests/pyproject.toml b/scripts/py_matter_yamltests/pyproject.toml new file mode 100644 index 00000000000000..ab9c08adaab8b5 --- /dev/null +++ b/scripts/py_matter_yamltests/pyproject.toml @@ -0,0 +1,17 @@ +# Copyright (c) 2022 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. + +[build-system] +requires = ['setuptools', 'wheel'] +build-backend = 'setuptools.build_meta' diff --git a/scripts/py_matter_yamltests/setup.cfg b/scripts/py_matter_yamltests/setup.cfg new file mode 100644 index 00000000000000..497022ce1459d9 --- /dev/null +++ b/scripts/py_matter_yamltests/setup.cfg @@ -0,0 +1,24 @@ +# Copyright (c) 2022 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. + +[metadata] +name = matter_yamltests +version = 0.0.1 +author = Project CHIP Authors +description = Parse matter yaml tests files + +[options] +packages = find: + +zip_safe = False diff --git a/scripts/tests/yamltests/setup.py b/scripts/py_matter_yamltests/setup.py similarity index 68% rename from scripts/tests/yamltests/setup.py rename to scripts/py_matter_yamltests/setup.py index 2bcdfbe8c61d46..8917fa45238cf5 100644 --- a/scripts/tests/yamltests/setup.py +++ b/scripts/py_matter_yamltests/setup.py @@ -13,16 +13,8 @@ # limitations under the License. -"""The yamltest package.""" +"""The matter_yamltests package.""" import setuptools # type: ignore -setuptools.setup( - name='yamltests', - version='0.0.1', - author='Project CHIP Authors', - description='Parse matter yaml test files', - packages=setuptools.find_packages(), - package_data={'yamltest': ['py.typed']}, - zip_safe=False, -) +setuptools.setup() # Package definition in setup.cfg diff --git a/scripts/py_matter_yamltests/test_spec_definitions.py b/scripts/py_matter_yamltests/test_spec_definitions.py new file mode 100644 index 00000000000000..35a2dcd29f911a --- /dev/null +++ b/scripts/py_matter_yamltests/test_spec_definitions.py @@ -0,0 +1,358 @@ +#!/usr/bin/env -S python3 -B +# +# Copyright (c) 2022 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. + +from matter_yamltests.definitions import * + +import unittest +import io + +source_cluster = ''' + + + Test + 0x1234 + + +''' + +source_command = ''' + + + Test + 0x1234 + + + + + +''' + +source_response = ''' + + + Test + 0x1234 + + + + + + + +''' + +source_attribute = ''' + + + TestGlobalAttribute + + + + Test + 0x1234 + + + TestAttribute + + + +''' + +source_event = ''' + + + Test + 0x1234 + + + + + +''' + +source_bitmap = ''' + + + + + + + + + + + + + Test + 0x1234 + + + + TestWrong + 0x4321 + + +''' + +source_enum = ''' + + + + + + + + + + + + + Test + 0x1234 + + + + TestWrong + 0x4321 + + +''' + +source_struct = ''' + + + + + + + + + + + + + + + + + + Test + 0x1234 + + + + TestWrong + 0x4321 + + +''' + + +class TestSpecDefinitions(unittest.TestCase): + def test_cluster_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_cluster), name='source_cluster')]) + self.assertIsNone(definitions.get_cluster_name(0x4321)) + self.assertEqual(definitions.get_cluster_name(0x1234), 'Test') + + def test_command_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_command), name='source_command')]) + self.assertIsNone(definitions.get_command_name(0x4321, 0x0)) + self.assertIsNone(definitions.get_command_name(0x1234, 0x1)) + self.assertEqual(definitions.get_command_name( + 0x1234, 0x0), 'TestCommand') + + def test_response_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_response), name='source_response')]) + self.assertIsNone(definitions.get_response_name(0x4321, 0x0)) + self.assertIsNone(definitions.get_response_name(0x1234, 0x1)) + self.assertEqual(definitions.get_response_name( + 0x1234, 0x0), 'TestCommandResponse') + + def test_attribute_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_attribute), name='source_attribute')]) + self.assertIsNone(definitions.get_attribute_name(0x4321, 0x0)) + self.assertIsNone(definitions.get_attribute_name(0x4321, 0xFFFD)) + self.assertIsNone(definitions.get_attribute_name(0x1234, 0x1)) + self.assertEqual(definitions.get_attribute_name( + 0x1234, 0x0), 'TestAttribute') + self.assertEqual(definitions.get_attribute_name( + 0x1234, 0xFFFD), 'TestGlobalAttribute') + + def test_event_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_event), name='source_event')]) + self.assertIsNone(definitions.get_event_name(0x4321, 0x0)) + self.assertIsNone(definitions.get_event_name(0x1234, 0x1)) + self.assertEqual(definitions.get_event_name(0x1234, 0x0), 'TestEvent') + + def test_get_command_by_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_command), name='source_command')]) + self.assertIsNone(definitions.get_command_by_name( + 'WrongName', 'TestCommand')) + self.assertIsNone(definitions.get_command_by_name( + 'Test', 'TestWrongCommand')) + self.assertIsNone( + definitions.get_response_by_name('Test', 'TestCommand')) + self.assertIsInstance(definitions.get_command_by_name( + 'Test', 'TestCommand'), Command) + self.assertIsNone( + definitions.get_command_by_name('test', 'TestCommand')) + self.assertIsInstance(definitions.get_command_by_name( + 'Test', 'testcommand'), Command) + + def test_get_response_by_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_response), name='source_response')]) + self.assertIsNone(definitions.get_response_by_name( + 'WrongName', 'TestCommandResponse')) + self.assertIsNone(definitions.get_response_by_name( + 'Test', 'TestWrongCommandResponse')) + self.assertIsNone(definitions.get_command_by_name( + 'Test', 'TestCommandResponse')) + self.assertIsInstance(definitions.get_response_by_name( + 'Test', 'TestCommandResponse'), Struct) + self.assertIsNone(definitions.get_response_by_name( + 'test', 'TestCommandResponse')) + self.assertIsInstance(definitions.get_response_by_name( + 'Test', 'testcommandresponse'), Struct) + + def test_get_attribute_by_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_attribute), name='source_attribute')]) + self.assertIsNone(definitions.get_attribute_by_name( + 'WrongName', 'TestAttribute')) + self.assertIsNone(definitions.get_attribute_by_name( + 'WrongName', 'TestGlobalAttribute')) + self.assertIsNone(definitions.get_attribute_by_name( + 'Test', 'TestWrongAttribute')) + self.assertIsInstance(definitions.get_attribute_by_name( + 'Test', 'TestAttribute'), Attribute) + self.assertIsInstance(definitions.get_attribute_by_name( + 'Test', 'TestGlobalAttribute'), Attribute) + self.assertIsNone(definitions.get_attribute_by_name( + 'test', 'TestAttribute')) + self.assertIsNone(definitions.get_attribute_by_name( + 'test', 'TestGlobalAttribute')) + self.assertIsInstance(definitions.get_attribute_by_name( + 'Test', 'testattribute'), Attribute) + self.assertIsInstance(definitions.get_attribute_by_name( + 'Test', 'testglobalattribute'), Attribute) + + def test_get_event_by_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_event), name='source_event')]) + self.assertIsNone(definitions.get_event_by_name( + 'WrongName', 'TestEvent')) + self.assertIsNone(definitions.get_event_by_name( + 'Test', 'TestWrongEvent')) + self.assertIsInstance( + definitions.get_event_by_name('Test', 'TestEvent'), Event) + self.assertIsNone(definitions.get_event_by_name('test', 'TestEvent')) + self.assertIsInstance( + definitions.get_event_by_name('Test', 'testevent'), Event) + + def test_get_bitmap_by_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_bitmap), name='source_bitmap')]) + self.assertIsNone(definitions.get_bitmap_by_name( + 'WrongName', 'TestBitmap')) + self.assertIsNone(definitions.get_bitmap_by_name( + 'Test', 'TestWrongBitmap')) + self.assertIsInstance(definitions.get_bitmap_by_name( + 'Test', 'TestBitmap'), Bitmap) + self.assertIsNone(definitions.get_bitmap_by_name('test', 'TestBitmap')) + self.assertIsInstance(definitions.get_bitmap_by_name( + 'Test', 'testbitmap'), Bitmap) + + def test_get_enum_by_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_enum), name='source_enum')]) + self.assertIsNone(definitions.get_enum_by_name( + 'WrongName', 'TestEnum')) + self.assertIsNone(definitions.get_enum_by_name( + 'Test', 'TestWrongEnum')) + self.assertIsInstance( + definitions.get_enum_by_name('Test', 'TestEnum'), Enum) + self.assertIsNone(definitions.get_enum_by_name('test', 'TestEnum')) + self.assertIsInstance( + definitions.get_enum_by_name('Test', 'testenum'), Enum) + + def test_get_struct_by_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_struct), name='source_struct')]) + self.assertIsNone(definitions.get_struct_by_name( + 'WrongName', 'TestStruct')) + self.assertIsNone(definitions.get_struct_by_name( + 'Test', 'TestWrongStruct')) + self.assertIsInstance(definitions.get_struct_by_name( + 'Test', 'TestStruct'), Struct) + self.assertIsNone(definitions.get_struct_by_name('test', 'TestStruct')) + self.assertIsInstance(definitions.get_struct_by_name( + 'Test', 'teststruct'), Struct) + + def test_get_type_by_name(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_command), name='source_command')]) + self.assertIsNone(definitions.get_type_by_name('Test', 'TestCommand')) + + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_response), name='source_response')]) + self.assertIsInstance(definitions.get_type_by_name( + 'Test', 'TestCommandResponse'), Struct) + + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_attribute), name='source_attribute')]) + self.assertIsNone(definitions.get_type_by_name( + 'Test', 'TestAttribute')) + + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_event), name='source_event')]) + self.assertIsNone(definitions.get_type_by_name('Test', 'TestEvent')) + + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_bitmap), name='source_bitmap')]) + self.assertIsInstance(definitions.get_type_by_name( + 'Test', 'TestBitmap'), Bitmap) + + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_enum), name='source_enum')]) + self.assertIsInstance( + definitions.get_type_by_name('Test', 'TestEnum'), Enum) + + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_struct), name='source_struct')]) + self.assertIsInstance(definitions.get_type_by_name( + 'Test', 'TestStruct'), Struct) + + def test_is_fabric_scoped(self): + definitions = SpecDefinitions( + [ParseSource(source=io.StringIO(source_struct), name='source_struct')]) + + struct = definitions.get_struct_by_name('Test', 'TestStruct') + self.assertFalse(definitions.is_fabric_scoped(struct)) + + struct = definitions.get_struct_by_name( + 'Test', 'TestStructFabricScoped') + self.assertTrue(definitions.is_fabric_scoped(struct)) + + +if __name__ == '__main__': + unittest.main() diff --git a/scripts/tests/test_yaml_parser.py b/scripts/py_matter_yamltests/test_yaml_parser.py similarity index 92% rename from scripts/tests/test_yaml_parser.py rename to scripts/py_matter_yamltests/test_yaml_parser.py index c6a73da4f8eed9..78df2c35fe64ad 100644 --- a/scripts/tests/test_yaml_parser.py +++ b/scripts/py_matter_yamltests/test_yaml_parser.py @@ -23,8 +23,8 @@ import tempfile import unittest -from yamltests.definitions import * -from yamltests.parser import TestParser +from matter_yamltests.definitions import * +from matter_yamltests.parser import TestParser simple_test_description = ''' @@ -75,7 +75,8 @@ def setUp(self): with open(self._temp_file.name, 'w') as f: f.writelines(simple_test_yaml) pics_file = None - self._yaml_parser = TestParser(self._temp_file.name, pics_file, self._definitions) + self._yaml_parser = TestParser( + self._temp_file.name, pics_file, self._definitions) def test_able_to_iterate_over_all_parsed_tests(self): # self._yaml_parser.tests implements `__next__`, which does value substitution. We are diff --git a/scripts/requirements.txt b/scripts/requirements.txt index b39ec86833bf6e..eb7b423cd90b05 100644 --- a/scripts/requirements.txt +++ b/scripts/requirements.txt @@ -69,8 +69,9 @@ tabulate # scripts/build click -# scripts/idl +# scripts/py_matter_idl/matter_idl lark +# scripts/py_matter_idl/matter_idl and scripts/py_matter_yamtests/matter_yamltests stringcase cryptography diff --git a/scripts/tests/yamltests/test_spec_definitions.py b/scripts/tests/yamltests/test_spec_definitions.py deleted file mode 100644 index 00a15da9940d0c..00000000000000 --- a/scripts/tests/yamltests/test_spec_definitions.py +++ /dev/null @@ -1,291 +0,0 @@ -#!/usr/bin/env -S python3 -B -# -# Copyright (c) 2022 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. - -from definitions import * - -import unittest -import io - -source_cluster = ''' - - - Test - 0x1234 - - -''' - -source_command = ''' - - - Test - 0x1234 - - - - - -''' - -source_response = ''' - - - Test - 0x1234 - - - - - - - -''' - -source_attribute = ''' - - - TestGlobalAttribute - - - - Test - 0x1234 - - - TestAttribute - - - -''' - -source_event = ''' - - - Test - 0x1234 - - - - - -''' - -source_bitmap = ''' - - - - - - - - - - - - - Test - 0x1234 - - - - TestWrong - 0x4321 - - -''' - -source_enum = ''' - - - - - - - - - - - - - Test - 0x1234 - - - - TestWrong - 0x4321 - - -''' - -source_struct = ''' - - - - - - - - - - - - - - - - - - Test - 0x1234 - - - - TestWrong - 0x4321 - - -''' - - -class TestSpecDefinitions(unittest.TestCase): - def test_cluster_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_cluster), name='source_cluster')]) - self.assertIsNone(definitions.get_cluster_name(0x4321)) - self.assertEqual(definitions.get_cluster_name(0x1234), 'Test') - - def test_command_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_command), name='source_command')]) - self.assertIsNone(definitions.get_command_name(0x4321, 0x0)) - self.assertIsNone(definitions.get_command_name(0x1234, 0x1)) - self.assertEqual(definitions.get_command_name(0x1234, 0x0), 'TestCommand') - - def test_response_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_response), name='source_response')]) - self.assertIsNone(definitions.get_response_name(0x4321, 0x0)) - self.assertIsNone(definitions.get_response_name(0x1234, 0x1)) - self.assertEqual(definitions.get_response_name(0x1234, 0x0), 'TestCommandResponse') - - def test_attribute_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_attribute), name='source_attribute')]) - self.assertIsNone(definitions.get_attribute_name(0x4321, 0x0)) - self.assertIsNone(definitions.get_attribute_name(0x4321, 0xFFFD)) - self.assertIsNone(definitions.get_attribute_name(0x1234, 0x1)) - self.assertEqual(definitions.get_attribute_name(0x1234, 0x0), 'TestAttribute') - self.assertEqual(definitions.get_attribute_name(0x1234, 0xFFFD), 'TestGlobalAttribute') - - def test_event_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_event), name='source_event')]) - self.assertIsNone(definitions.get_event_name(0x4321, 0x0)) - self.assertIsNone(definitions.get_event_name(0x1234, 0x1)) - self.assertEqual(definitions.get_event_name(0x1234, 0x0), 'TestEvent') - - def test_get_command_by_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_command), name='source_command')]) - self.assertIsNone(definitions.get_command_by_name('WrongName', 'TestCommand')) - self.assertIsNone(definitions.get_command_by_name('Test', 'TestWrongCommand')) - self.assertIsNone(definitions.get_response_by_name('Test', 'TestCommand')) - self.assertIsInstance(definitions.get_command_by_name('Test', 'TestCommand'), Command) - self.assertIsNone(definitions.get_command_by_name('test', 'TestCommand')) - self.assertIsInstance(definitions.get_command_by_name('Test', 'testcommand'), Command) - - def test_get_response_by_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_response), name='source_response')]) - self.assertIsNone(definitions.get_response_by_name('WrongName', 'TestCommandResponse')) - self.assertIsNone(definitions.get_response_by_name('Test', 'TestWrongCommandResponse')) - self.assertIsNone(definitions.get_command_by_name('Test', 'TestCommandResponse')) - self.assertIsInstance(definitions.get_response_by_name('Test', 'TestCommandResponse'), Struct) - self.assertIsNone(definitions.get_response_by_name('test', 'TestCommandResponse')) - self.assertIsInstance(definitions.get_response_by_name('Test', 'testcommandresponse'), Struct) - - def test_get_attribute_by_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_attribute), name='source_attribute')]) - self.assertIsNone(definitions.get_attribute_by_name('WrongName', 'TestAttribute')) - self.assertIsNone(definitions.get_attribute_by_name('WrongName', 'TestGlobalAttribute')) - self.assertIsNone(definitions.get_attribute_by_name('Test', 'TestWrongAttribute')) - self.assertIsInstance(definitions.get_attribute_by_name('Test', 'TestAttribute'), Attribute) - self.assertIsInstance(definitions.get_attribute_by_name('Test', 'TestGlobalAttribute'), Attribute) - self.assertIsNone(definitions.get_attribute_by_name('test', 'TestAttribute')) - self.assertIsNone(definitions.get_attribute_by_name('test', 'TestGlobalAttribute')) - self.assertIsInstance(definitions.get_attribute_by_name('Test', 'testattribute'), Attribute) - self.assertIsInstance(definitions.get_attribute_by_name('Test', 'testglobalattribute'), Attribute) - - def test_get_event_by_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_event), name='source_event')]) - self.assertIsNone(definitions.get_event_by_name('WrongName', 'TestEvent')) - self.assertIsNone(definitions.get_event_by_name('Test', 'TestWrongEvent')) - self.assertIsInstance(definitions.get_event_by_name('Test', 'TestEvent'), Event) - self.assertIsNone(definitions.get_event_by_name('test', 'TestEvent')) - self.assertIsInstance(definitions.get_event_by_name('Test', 'testevent'), Event) - - def test_get_bitmap_by_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_bitmap), name='source_bitmap')]) - self.assertIsNone(definitions.get_bitmap_by_name('WrongName', 'TestBitmap')) - self.assertIsNone(definitions.get_bitmap_by_name('Test', 'TestWrongBitmap')) - self.assertIsInstance(definitions.get_bitmap_by_name('Test', 'TestBitmap'), Bitmap) - self.assertIsNone(definitions.get_bitmap_by_name('test', 'TestBitmap')) - self.assertIsInstance(definitions.get_bitmap_by_name('Test', 'testbitmap'), Bitmap) - - def test_get_enum_by_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_enum), name='source_enum')]) - self.assertIsNone(definitions.get_enum_by_name('WrongName', 'TestEnum')) - self.assertIsNone(definitions.get_enum_by_name('Test', 'TestWrongEnum')) - self.assertIsInstance(definitions.get_enum_by_name('Test', 'TestEnum'), Enum) - self.assertIsNone(definitions.get_enum_by_name('test', 'TestEnum')) - self.assertIsInstance(definitions.get_enum_by_name('Test', 'testenum'), Enum) - - def test_get_struct_by_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_struct), name='source_struct')]) - self.assertIsNone(definitions.get_struct_by_name('WrongName', 'TestStruct')) - self.assertIsNone(definitions.get_struct_by_name('Test', 'TestWrongStruct')) - self.assertIsInstance(definitions.get_struct_by_name('Test', 'TestStruct'), Struct) - self.assertIsNone(definitions.get_struct_by_name('test', 'TestStruct')) - self.assertIsInstance(definitions.get_struct_by_name('Test', 'teststruct'), Struct) - - def test_get_type_by_name(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_command), name='source_command')]) - self.assertIsNone(definitions.get_type_by_name('Test', 'TestCommand')) - - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_response), name='source_response')]) - self.assertIsInstance(definitions.get_type_by_name('Test', 'TestCommandResponse'), Struct) - - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_attribute), name='source_attribute')]) - self.assertIsNone(definitions.get_type_by_name('Test', 'TestAttribute')) - - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_event), name='source_event')]) - self.assertIsNone(definitions.get_type_by_name('Test', 'TestEvent')) - - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_bitmap), name='source_bitmap')]) - self.assertIsInstance(definitions.get_type_by_name('Test', 'TestBitmap'), Bitmap) - - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_enum), name='source_enum')]) - self.assertIsInstance(definitions.get_type_by_name('Test', 'TestEnum'), Enum) - - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_struct), name='source_struct')]) - self.assertIsInstance(definitions.get_type_by_name('Test', 'TestStruct'), Struct) - - def test_is_fabric_scoped(self): - definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_struct), name='source_struct')]) - - struct = definitions.get_struct_by_name('Test', 'TestStruct') - self.assertFalse(definitions.is_fabric_scoped(struct)) - - struct = definitions.get_struct_by_name('Test', 'TestStructFabricScoped') - self.assertTrue(definitions.is_fabric_scoped(struct)) - - -if __name__ == '__main__': - unittest.main() diff --git a/scripts/tools/nrfconnect/tests/test_generate_factory_data.py b/scripts/tools/nrfconnect/tests/test_generate_factory_data.py index ea6ccc445f733f..d3fd86f69bf3e5 100755 --- a/scripts/tools/nrfconnect/tests/test_generate_factory_data.py +++ b/scripts/tools/nrfconnect/tests/test_generate_factory_data.py @@ -171,6 +171,7 @@ def test_generate_factory_data_all_specified(self): '--discriminator', '0xFED', '--rd_uid', '91a9c12a7c80700a31ddcfa7fce63e44', '--enable_key', '00112233445566778899aabbccddeeff', + '--user', '{"name": "product_name", "version": 123, "revision": "0x123"}', '-o', os.path.join(outdir, 'fd.json') ]) @@ -199,6 +200,15 @@ def test_generate_factory_data_all_specified(self): self.assertEqual(factory_data.get('passcode'), 13243546) self.assertEqual(factory_data.get('rd_uid'), 'hex:91a9c12a7c80700a31ddcfa7fce63e44') self.assertEqual(factory_data.get('enable_key'), 'hex:00112233445566778899aabbccddeeff') + self.assertEqual(factory_data.get('user'), {'name': 'product_name', 'version': 123, 'revision': '0x123'}) + + subprocess.check_call(['python3', os.path.join(TOOLS_DIR, 'nrfconnect_generate_partition.py'), + '-i', os.path.join(outdir, 'fd.json'), + '-o', os.path.join(outdir, 'fd'), + '--offset', "0xfb000", + '--size', "0x1000", + '--raw' + ]) def test_generate_spake2p_verifier_default(self): with tempfile.TemporaryDirectory() as outdir: @@ -223,6 +233,7 @@ def test_generate_spake2p_verifier_default(self): '--spake2_salt', 'U1BBS0UyUCBLZXkgU2FsdA==', '--passcode', '20202021', '--discriminator', '0xFED', + '--user', '{"name": "product_name", "version": 123, "revision": "0x123"}', '-o', os.path.join(outdir, 'fd.json') ]) @@ -234,6 +245,15 @@ def test_generate_spake2p_verifier_default(self): self.assertEqual(factory_data.get('spake2_it'), 1000) self.assertEqual(factory_data.get('spake2_verifier'), base64_to_json( 'uWFwqugDNGiEck/po7KHwwMwwqZgN10XuyBajPGuyzUEV/iree4lOrao5GuwnlQ65CJzbeUB49s31EH+NEkg0JVI5MGCQGMMT/SRPFNRODm3wH/MBiehuFc6FJ/NH6Rmzw==')) + self.assertEqual(factory_data.get('user'), {'name': 'product_name', 'version': 123, 'revision': '0x123'}) + + subprocess.check_call(['python3', os.path.join(TOOLS_DIR, 'nrfconnect_generate_partition.py'), + '-i', os.path.join(outdir, 'fd.json'), + '-o', os.path.join(outdir, 'fd'), + '--offset', "0xfb000", + '--size', "0x1000", + '--raw' + ]) if __name__ == '__main__': diff --git a/src/app/common/templates/templates.json b/src/app/common/templates/templates.json index 03327d0469b013..400511cce6ff86 100644 --- a/src/app/common/templates/templates.json +++ b/src/app/common/templates/templates.json @@ -8,6 +8,9 @@ "templates/app/helper.js", "templates/chip/helper.js" ], + "resources": { + "weak-enum-list": "weak-enum-list.yaml" + }, "override": "../../zap-templates/common/override.js", "partials": [ { diff --git a/src/app/common/templates/weak-enum-list.yaml b/src/app/common/templates/weak-enum-list.yaml new file mode 100644 index 00000000000000..24e3fc3b89de4a --- /dev/null +++ b/src/app/common/templates/weak-enum-list.yaml @@ -0,0 +1,39 @@ +# Allow-list of enums that we generate as enums, not enum classes. The goal is +# to drive this down to 0. +- AttributeWritePermission +- BarrierControlBarrierPosition +- BarrierControlMovingState +- ColorControlOptions +- ColorLoopAction +- ColorLoopDirection +- ColorMode +- ContentLaunchStatus +- ContentLaunchStreamingType +- EnhancedColorMode +- HardwareFaultType +- HueDirection +- HueMoveMode +- HueStepMode +- IdentifyEffectIdentifier +- IdentifyEffectVariant +- IdentifyIdentifyType +- InterfaceType +- KeypadLockout +- LevelControlOptions +- MoveMode +- NetworkFaultType +- OnOffDelayedAllOffEffectVariant +- OnOffDyingLightEffectVariant +- OnOffEffectIdentifier +- PHYRateType +- RadioFaultType +- RoutingRole +- SaturationMoveMode +- SaturationStepMode +- SecurityType +- SetpointAdjustMode +- StartUpOnOffValue +- StatusCode +- StepMode +- TemperatureDisplayMode +- WiFiVersionType diff --git a/src/app/tests/suites/TestGroupKeyManagementCluster.yaml b/src/app/tests/suites/TestGroupKeyManagementCluster.yaml index f388434370cb6a..62fbfe4e1cb7c4 100644 --- a/src/app/tests/suites/TestGroupKeyManagementCluster.yaml +++ b/src/app/tests/suites/TestGroupKeyManagementCluster.yaml @@ -295,3 +295,77 @@ tests: value: 0x01a2 response: error: NOT_FOUND + + - label: "KeySet Write 1" + command: "KeySetWrite" + arguments: + values: + - name: "GroupKeySet" + value: + { + GroupKeySetID: 0x01a1, + GroupKeySecurityPolicy: 0, + EpochKey0: "\xa0\xa1\xa2\xa3\xa4\xa5\xa6\xa7\xa8\xa9\xaa\xab\xac\xad\xae\xaf", + EpochStartTime0: 1110000, + EpochKey1: "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf", + EpochStartTime1: 1110001, + EpochKey2: "\xc0\xc1\xc2\xc3\xc4\xc5\xc6\xc7\xc8\xc9\xca\xcb\xcc\xcd\xce\xcf", + EpochStartTime2: 1110002, + } + + - label: "KeySet Write 2" + command: "KeySetWrite" + arguments: + values: + - name: "GroupKeySet" + value: + { + GroupKeySetID: 0x01a2, + GroupKeySecurityPolicy: 1, + EpochKey0: "\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf", + EpochStartTime0: 2110000, + EpochKey1: "\xe0\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef", + EpochStartTime1: 2110001, + EpochKey2: "\xf0\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff", + EpochStartTime2: 2110002, + } + + - label: "Map Group 1 and Group 2 to KeySet 1 and group 2 to KeySet 2" + command: "writeAttribute" + attribute: "GroupKeyMap" + arguments: + value: + [ + { FabricIndex: 1, GroupId: 0x0101, GroupKeySetID: 0x01a1 }, + { FabricIndex: 1, GroupId: 0x0102, GroupKeySetID: 0x01a2 }, + { FabricIndex: 1, GroupId: 0x0102, GroupKeySetID: 0x01a1 }, + ] + + - label: "Remove keyset 1" + command: "KeySetRemove" + arguments: + values: + - name: "GroupKeySetID" + value: 0x01a1 + + - label: "TH verifies GroupKeyMap entries for KeySet 1 have been removed" + cluster: "Group Key Management" + endpoint: 0 + command: "readAttribute" + attribute: "GroupKeyMap" + response: + value: [{ FabricIndex: 1, GroupId: 0x0102, GroupKeySetID: 0x01a2 }] + - label: "Remove keyset 2" + command: "KeySetRemove" + arguments: + values: + - name: "GroupKeySetID" + value: 0x01a2 + + - label: "TH verifies GroupKeyMap entries for KeySet 2 have been removed" + cluster: "Group Key Management" + endpoint: 0 + command: "readAttribute" + attribute: "GroupKeyMap" + response: + value: [] diff --git a/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp b/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp index ad4bf1603a258d..542f4ffd29368f 100644 --- a/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp +++ b/src/app/tests/suites/commands/interaction_model/InteractionModel.cpp @@ -21,6 +21,21 @@ using namespace chip; using namespace chip::app; +namespace chip { +namespace test_utils { +void BusyWaitMillis(uint16_t busyWaitForMs) +{ + auto & clock = chip::System::SystemClock(); + auto start = clock.GetMonotonicTimestamp(); + chip::System::Clock::Milliseconds32 durationInMs(busyWaitForMs); + while (clock.GetMonotonicTimestamp() - start < durationInMs) + { + // nothing to do. + }; +} +} // namespace test_utils +} // namespace chip + CHIP_ERROR InteractionModel::ReadAttribute(const char * identity, EndpointId endpointId, ClusterId clusterId, AttributeId attributeId, bool fabricFiltered, const Optional & dataVersion) { diff --git a/src/app/tests/suites/commands/interaction_model/InteractionModel.h b/src/app/tests/suites/commands/interaction_model/InteractionModel.h index 83a0d6fff769b6..1d3e2eb735e116 100644 --- a/src/app/tests/suites/commands/interaction_model/InteractionModel.h +++ b/src/app/tests/suites/commands/interaction_model/InteractionModel.h @@ -30,6 +30,12 @@ constexpr uint8_t kMaxAllowedPaths = 10; +namespace chip { +namespace test_utils { +void BusyWaitMillis(uint16_t busyWaitForMs); +} // namespace test_utils +} // namespace chip + class InteractionModelConfig { public: @@ -237,6 +243,11 @@ class InteractionModelCommands ReturnErrorOnFailure(commandSender->SendCommandRequest(device->GetSecureSession().Value())); mCommandSender.push_back(std::move(commandSender)); + if (mBusyWaitForMs.HasValue()) + { + chip::test_utils::BusyWaitMillis(mBusyWaitForMs.Value()); + } + if (mRepeatDelayInMs.HasValue()) { chip::test_utils::SleepMillis(mRepeatDelayInMs.Value()); @@ -321,18 +332,32 @@ class InteractionModelCommands return *this; } + InteractionModelCommands & SetBusyWaitForMs(uint16_t busyWaitForMs) + { + mBusyWaitForMs.SetValue(busyWaitForMs); + return *this; + } + + InteractionModelCommands & SetBusyWaitForMs(const chip::Optional & busyWaitForMs) + { + mBusyWaitForMs = busyWaitForMs; + return *this; + } + void ResetOptions() { mTimedInteractionTimeoutMs = chip::NullOptional; mSuppressResponse = chip::NullOptional; mRepeatCount = chip::NullOptional; mRepeatDelayInMs = chip::NullOptional; + mBusyWaitForMs = chip::NullOptional; } chip::Optional mTimedInteractionTimeoutMs; chip::Optional mSuppressResponse; chip::Optional mRepeatCount; chip::Optional mRepeatDelayInMs; + chip::Optional mBusyWaitForMs; }; class InteractionModelWriter @@ -370,6 +395,11 @@ class InteractionModelWriter ReturnErrorOnFailure(mWriteClient->SendWriteRequest(device->GetSecureSession().Value())); + if (mBusyWaitForMs.HasValue()) + { + chip::test_utils::BusyWaitMillis(mBusyWaitForMs.Value()); + } + if (mRepeatDelayInMs.HasValue()) { chip::test_utils::SleepMillis(mRepeatDelayInMs.Value()); @@ -487,6 +517,18 @@ class InteractionModelWriter return *this; } + InteractionModelWriter & SetBusyWaitForMs(uint16_t busyWaitForMs) + { + mBusyWaitForMs.SetValue(busyWaitForMs); + return *this; + } + + InteractionModelWriter & SetBusyWaitForMs(const chip::Optional & busyWaitForMs) + { + mBusyWaitForMs = busyWaitForMs; + return *this; + } + void ResetOptions() { mTimedInteractionTimeoutMs = chip::NullOptional; @@ -494,6 +536,7 @@ class InteractionModelWriter mDataVersions = chip::NullOptional; mRepeatCount = chip::NullOptional; mRepeatDelayInMs = chip::NullOptional; + mBusyWaitForMs = chip::NullOptional; } chip::Optional mTimedInteractionTimeoutMs; @@ -501,6 +544,7 @@ class InteractionModelWriter chip::Optional mSuppressResponse; chip::Optional mRepeatCount; chip::Optional mRepeatDelayInMs; + chip::Optional mBusyWaitForMs; private: template diff --git a/src/app/zap-templates/zcl/data-model/chip/network-commissioning-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/network-commissioning-cluster.xml index eaf97404c4365b..57d469de794daa 100644 --- a/src/app/zap-templates/zcl/data-model/chip/network-commissioning-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/network-commissioning-cluster.xml @@ -43,7 +43,7 @@ limitations under the License. - + @@ -171,8 +171,8 @@ limitations under the License. - - - + + + diff --git a/src/app/zap-templates/zcl/data-model/chip/power-source-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/power-source-cluster.xml index 28ba55b9f30983..76b350a52bf239 100644 --- a/src/app/zap-templates/zcl/data-model/chip/power-source-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/power-source-cluster.xml @@ -59,22 +59,23 @@ limitations under the License. BatChargingCurrent ActiveBatChargeFaults - @@ -131,7 +132,7 @@ limitations under the License. - + @@ -152,6 +153,8 @@ limitations under the License. + @@ -170,4 +173,4 @@ limitations under the License. - \ No newline at end of file + diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index d3ce74301608c7..f7573977ba4a49 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -995,6 +995,21 @@ client cluster PowerSource = 47 { kReplaceable = 0x8; } + info event WiredFaultChange = 0 { + WiredFault current[] = 0; + WiredFault previous[] = 1; + } + + info event BatFaultChange = 1 { + BatFault current[] = 0; + BatFault previous[] = 1; + } + + info event BatChargeFaultChange = 2 { + BatChargeFault current[] = 0; + BatChargeFault previous[] = 1; + } + readonly attribute PowerSourceStatus status = 0; readonly attribute int8u order = 1; readonly attribute char_string<60> description = 2; @@ -1128,7 +1143,7 @@ client cluster NetworkCommissioning = 49 { bitmap WiFiSecurity : BITMAP8 { kUnencrypted = 0x1; - kWepPersonal = 0x2; + kWep = 0x2; kWpaPersonal = 0x4; kWpa2Personal = 0x8; kWpa3Personal = 0x10; diff --git a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp index d8b949d64e8a8c..8313fe238777cc 100644 --- a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp @@ -967,6 +967,179 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & using namespace app::Clusters::PowerSource; switch (aPath.mEventId) { + case Events::WiredFaultChange::Id: { + Events::WiredFaultChange::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value_current; + chip::JniReferences::GetInstance().CreateArrayList(value_current); + + auto iter_value_current_0 = cppValue.current.begin(); + while (iter_value_current_0.Next()) + { + auto & entry_0 = iter_value_current_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Integer"; + std::string newElement_0CtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), static_cast(entry_0), newElement_0); + chip::JniReferences::GetInstance().AddToList(value_current, newElement_0); + } + + jobject value_previous; + chip::JniReferences::GetInstance().CreateArrayList(value_previous); + + auto iter_value_previous_0 = cppValue.previous.begin(); + while (iter_value_previous_0.Next()) + { + auto & entry_0 = iter_value_previous_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Integer"; + std::string newElement_0CtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), static_cast(entry_0), newElement_0); + chip::JniReferences::GetInstance().AddToList(value_previous, newElement_0); + } + + jclass wiredFaultChangeStructClass; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipEventStructs$PowerSourceClusterWiredFaultChangeEvent", wiredFaultChangeStructClass); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipEventStructs$PowerSourceClusterWiredFaultChangeEvent"); + return nullptr; + } + jmethodID wiredFaultChangeStructCtor = + env->GetMethodID(wiredFaultChangeStructClass, "", "(Ljava/util/ArrayList;Ljava/util/ArrayList;)V"); + if (wiredFaultChangeStructCtor == nullptr) + { + ChipLogError(Zcl, "Could not find ChipEventStructs$PowerSourceClusterWiredFaultChangeEvent constructor"); + return nullptr; + } + + jobject value = env->NewObject(wiredFaultChangeStructClass, wiredFaultChangeStructCtor, value_current, value_previous); + + return value; + } + case Events::BatFaultChange::Id: { + Events::BatFaultChange::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value_current; + chip::JniReferences::GetInstance().CreateArrayList(value_current); + + auto iter_value_current_0 = cppValue.current.begin(); + while (iter_value_current_0.Next()) + { + auto & entry_0 = iter_value_current_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Integer"; + std::string newElement_0CtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), static_cast(entry_0), newElement_0); + chip::JniReferences::GetInstance().AddToList(value_current, newElement_0); + } + + jobject value_previous; + chip::JniReferences::GetInstance().CreateArrayList(value_previous); + + auto iter_value_previous_0 = cppValue.previous.begin(); + while (iter_value_previous_0.Next()) + { + auto & entry_0 = iter_value_previous_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Integer"; + std::string newElement_0CtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), static_cast(entry_0), newElement_0); + chip::JniReferences::GetInstance().AddToList(value_previous, newElement_0); + } + + jclass batFaultChangeStructClass; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipEventStructs$PowerSourceClusterBatFaultChangeEvent", batFaultChangeStructClass); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipEventStructs$PowerSourceClusterBatFaultChangeEvent"); + return nullptr; + } + jmethodID batFaultChangeStructCtor = + env->GetMethodID(batFaultChangeStructClass, "", "(Ljava/util/ArrayList;Ljava/util/ArrayList;)V"); + if (batFaultChangeStructCtor == nullptr) + { + ChipLogError(Zcl, "Could not find ChipEventStructs$PowerSourceClusterBatFaultChangeEvent constructor"); + return nullptr; + } + + jobject value = env->NewObject(batFaultChangeStructClass, batFaultChangeStructCtor, value_current, value_previous); + + return value; + } + case Events::BatChargeFaultChange::Id: { + Events::BatChargeFaultChange::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value_current; + chip::JniReferences::GetInstance().CreateArrayList(value_current); + + auto iter_value_current_0 = cppValue.current.begin(); + while (iter_value_current_0.Next()) + { + auto & entry_0 = iter_value_current_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Integer"; + std::string newElement_0CtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), static_cast(entry_0), newElement_0); + chip::JniReferences::GetInstance().AddToList(value_current, newElement_0); + } + + jobject value_previous; + chip::JniReferences::GetInstance().CreateArrayList(value_previous); + + auto iter_value_previous_0 = cppValue.previous.begin(); + while (iter_value_previous_0.Next()) + { + auto & entry_0 = iter_value_previous_0.GetValue(); + jobject newElement_0; + std::string newElement_0ClassName = "java/lang/Integer"; + std::string newElement_0CtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0ClassName.c_str(), newElement_0CtorSignature.c_str(), static_cast(entry_0), newElement_0); + chip::JniReferences::GetInstance().AddToList(value_previous, newElement_0); + } + + jclass batChargeFaultChangeStructClass; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipEventStructs$PowerSourceClusterBatChargeFaultChangeEvent", + batChargeFaultChangeStructClass); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipEventStructs$PowerSourceClusterBatChargeFaultChangeEvent"); + return nullptr; + } + jmethodID batChargeFaultChangeStructCtor = + env->GetMethodID(batChargeFaultChangeStructClass, "", "(Ljava/util/ArrayList;Ljava/util/ArrayList;)V"); + if (batChargeFaultChangeStructCtor == nullptr) + { + ChipLogError(Zcl, "Could not find ChipEventStructs$PowerSourceClusterBatChargeFaultChangeEvent constructor"); + return nullptr; + } + + jobject value = + env->NewObject(batChargeFaultChangeStructClass, batChargeFaultChangeStructCtor, value_current, value_previous); + + return value; + } default: *aError = CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB; break; diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ChipEventStructs.java b/src/controller/java/zap-generated/chip/devicecontroller/ChipEventStructs.java index fe77f3667f8c89..2040b030738a89 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipEventStructs.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipEventStructs.java @@ -347,6 +347,81 @@ public String toString() { } } + public static class PowerSourceClusterWiredFaultChangeEvent { + public ArrayList current; + public ArrayList previous; + + public PowerSourceClusterWiredFaultChangeEvent( + ArrayList current, ArrayList previous) { + this.current = current; + this.previous = previous; + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("PowerSourceClusterWiredFaultChangeEvent {\n"); + output.append("\tcurrent: "); + output.append(current); + output.append("\n"); + output.append("\tprevious: "); + output.append(previous); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } + } + + public static class PowerSourceClusterBatFaultChangeEvent { + public ArrayList current; + public ArrayList previous; + + public PowerSourceClusterBatFaultChangeEvent( + ArrayList current, ArrayList previous) { + this.current = current; + this.previous = previous; + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("PowerSourceClusterBatFaultChangeEvent {\n"); + output.append("\tcurrent: "); + output.append(current); + output.append("\n"); + output.append("\tprevious: "); + output.append(previous); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } + } + + public static class PowerSourceClusterBatChargeFaultChangeEvent { + public ArrayList current; + public ArrayList previous; + + public PowerSourceClusterBatChargeFaultChangeEvent( + ArrayList current, ArrayList previous) { + this.current = current; + this.previous = previous; + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("PowerSourceClusterBatChargeFaultChangeEvent {\n"); + output.append("\tcurrent: "); + output.append(current); + output.append("\n"); + output.append("\tprevious: "); + output.append(previous); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } + } + public static class GeneralDiagnosticsClusterHardwareFaultChangeEvent { public ArrayList current; public ArrayList previous; diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ChipIdLookup.java b/src/controller/java/zap-generated/chip/devicecontroller/ChipIdLookup.java index 0bcad38c702c69..195215f6e8f56d 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipIdLookup.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipIdLookup.java @@ -3183,6 +3183,15 @@ public static String eventIdToName(long clusterId, long eventId) { return ""; } if (clusterId == 47L) { + if (eventId == 0L) { + return "WiredFaultChange"; + } + if (eventId == 1L) { + return "BatFaultChange"; + } + if (eventId == 2L) { + return "BatChargeFaultChange"; + } return ""; } if (clusterId == 48L) { diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index a72378c2f393b3..6dea0ef9539d5d 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -6171,6 +6171,70 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: value: 'uint' = 0 + class Events: + @dataclass + class WiredFaultChange(ClusterEvent): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x002F + + @ChipUtility.classproperty + def event_id(cls) -> int: + return 0x00000000 + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields = [ + ClusterObjectFieldDescriptor(Label="current", Tag=0, Type=typing.List[PowerSource.Enums.WiredFault]), + ClusterObjectFieldDescriptor(Label="previous", Tag=1, Type=typing.List[PowerSource.Enums.WiredFault]), + ]) + + current: 'typing.List[PowerSource.Enums.WiredFault]' = field(default_factory=lambda: []) + previous: 'typing.List[PowerSource.Enums.WiredFault]' = field(default_factory=lambda: []) + + @dataclass + class BatFaultChange(ClusterEvent): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x002F + + @ChipUtility.classproperty + def event_id(cls) -> int: + return 0x00000001 + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields = [ + ClusterObjectFieldDescriptor(Label="current", Tag=0, Type=typing.List[PowerSource.Enums.BatFault]), + ClusterObjectFieldDescriptor(Label="previous", Tag=1, Type=typing.List[PowerSource.Enums.BatFault]), + ]) + + current: 'typing.List[PowerSource.Enums.BatFault]' = field(default_factory=lambda: []) + previous: 'typing.List[PowerSource.Enums.BatFault]' = field(default_factory=lambda: []) + + @dataclass + class BatChargeFaultChange(ClusterEvent): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x002F + + @ChipUtility.classproperty + def event_id(cls) -> int: + return 0x00000002 + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields = [ + ClusterObjectFieldDescriptor(Label="current", Tag=0, Type=typing.List[PowerSource.Enums.BatChargeFault]), + ClusterObjectFieldDescriptor(Label="previous", Tag=1, Type=typing.List[PowerSource.Enums.BatChargeFault]), + ]) + + current: 'typing.List[PowerSource.Enums.BatChargeFault]' = field(default_factory=lambda: []) + previous: 'typing.List[PowerSource.Enums.BatChargeFault]' = field(default_factory=lambda: []) + @dataclass class GeneralCommissioning(Cluster): diff --git a/src/credentials/GroupDataProviderImpl.cpp b/src/credentials/GroupDataProviderImpl.cpp index 95764967dab051..fde6cec2343ad8 100644 --- a/src/credentials/GroupDataProviderImpl.cpp +++ b/src/credentials/GroupDataProviderImpl.cpp @@ -503,6 +503,37 @@ struct KeyMapData : public GroupDataProvider::GroupKey, LinkedData id = static_cast(max_id + 1); return false; } + + // returns index if the find_id is found, otherwise std::numeric_limits::max + size_t Find(PersistentStorageDelegate * storage, const FabricData & fabric, const KeysetId find_id) + { + fabric_index = fabric.fabric_index; + id = fabric.first_map; + max_id = 0; + index = 0; + first = true; + + while (index < fabric.map_count) + { + if (CHIP_NO_ERROR != Load(storage)) + { + break; + } + if (keyset_id == find_id) + { + // Match found + return index; + } + max_id = std::max(id, max_id); + first = false; + prev = id; + id = next; + index++; + } + + id = static_cast(max_id + 1); + return std::numeric_limits::max(); + } }; struct EndpointData : GroupDataProvider::GroupEndpoint, PersistentData @@ -1574,7 +1605,25 @@ CHIP_ERROR GroupDataProviderImpl::RemoveKeySet(chip::FabricIndex fabric_index, u fabric.keyset_count--; } // Update fabric info - return fabric.Save(mStorage); + ReturnErrorOnFailure(fabric.Save(mStorage)); + + // Removing a key set also removes the associated group mappings + KeyMapData map; + uint16_t original_count = fabric.map_count; + for (uint16_t i = 0; i < original_count; ++i) + { + fabric.Load(mStorage); + size_t idx = map.Find(mStorage, fabric, target_id); + if (idx == std::numeric_limits::max()) + { + break; + } + // NOTE: It's unclear what should happen here if we have removed the key set + // and possibly some mappings before failing. For now, ignoring errors, but + // open to suggestsions for the correct behavior. + RemoveGroupKeyAt(fabric_index, idx); + } + return CHIP_NO_ERROR; } GroupDataProvider::KeySetIterator * GroupDataProviderImpl::IterateKeySets(chip::FabricIndex fabric_index) diff --git a/src/credentials/tests/CHIPAttCert_test_vectors.cpp b/src/credentials/tests/CHIPAttCert_test_vectors.cpp index 0bb32b7b72f32a..82cda1285d8980 100644 --- a/src/credentials/tests/CHIPAttCert_test_vectors.cpp +++ b/src/credentials/tests/CHIPAttCert_test_vectors.cpp @@ -2596,6 +2596,40 @@ constexpr uint8_t sTestCert_PAA_NoVID_PrivateKey_Array[] = { extern const ByteSpan sTestCert_PAA_NoVID_PrivateKey = ByteSpan(sTestCert_PAA_NoVID_PrivateKey_Array); +// ${chip_root}/credentials/test/attestation/Chip-Test-PAA-NoVID-ToResignPAIs-Cert.pem + +constexpr uint8_t sTestCert_PAA_NoVID_ToResignPAIs_Cert_Array[] = { + 0x30, 0x82, 0x01, 0xb0, 0x30, 0x82, 0x01, 0x56, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x7d, 0x00, 0x0a, 0x17, 0x23, 0xbe, + 0xdf, 0x06, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x29, 0x31, 0x27, 0x30, 0x25, 0x06, + 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1e, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x41, + 0x20, 0x54, 0x6f, 0x20, 0x52, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x20, 0x50, 0x41, 0x49, 0x73, 0x30, 0x20, 0x17, 0x0d, 0x32, 0x31, + 0x30, 0x36, 0x32, 0x38, 0x31, 0x34, 0x32, 0x33, 0x34, 0x33, 0x5a, 0x18, 0x0f, 0x39, 0x39, 0x39, 0x39, 0x31, 0x32, 0x33, 0x31, + 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, 0x29, 0x31, 0x27, 0x30, 0x25, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1e, 0x4d, + 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x41, 0x20, 0x54, 0x6f, 0x20, 0x52, 0x65, 0x73, + 0x69, 0x67, 0x6e, 0x20, 0x50, 0x41, 0x49, 0x73, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, + 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x10, 0xef, 0x02, 0xa8, 0x1a, 0x87, 0xb6, + 0x81, 0x21, 0xfb, 0xa8, 0xd3, 0x19, 0x78, 0xf8, 0x07, 0xa3, 0x17, 0xe5, 0x0a, 0xa8, 0xa8, 0x28, 0x44, 0x68, 0x28, 0x91, 0x4b, + 0x93, 0x3d, 0xe8, 0xed, 0xd4, 0xa5, 0xc3, 0x9c, 0x9f, 0xf7, 0x1a, 0x4c, 0xe3, 0x64, 0x7f, 0xd7, 0xf6, 0x26, 0x53, 0xb7, 0xd2, + 0x49, 0x5f, 0xcb, 0xa4, 0xc0, 0xf4, 0x7f, 0x87, 0x68, 0x80, 0x03, 0x9e, 0x07, 0x20, 0x4a, 0xa3, 0x66, 0x30, 0x64, 0x30, 0x12, + 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x01, 0x30, 0x0e, 0x06, + 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, + 0x16, 0x04, 0x14, 0x78, 0x5c, 0xe7, 0x05, 0xb8, 0x6b, 0x8f, 0x4e, 0x6f, 0xc7, 0x93, 0xaa, 0x60, 0xcb, 0x43, 0xea, 0x69, 0x68, + 0x82, 0xd5, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0x78, 0x5c, 0xe7, 0x05, 0xb8, 0x6b, + 0x8f, 0x4e, 0x6f, 0xc7, 0x93, 0xaa, 0x60, 0xcb, 0x43, 0xea, 0x69, 0x68, 0x82, 0xd5, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, + 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x48, 0x00, 0x30, 0x45, 0x02, 0x20, 0x7b, 0x63, 0xf5, 0xb2, 0xd8, 0x87, 0x97, 0xd2, 0x63, + 0xb0, 0x3f, 0xad, 0x87, 0xbd, 0x3b, 0x8c, 0x86, 0xbc, 0xf0, 0x0f, 0x99, 0x6f, 0xa8, 0x73, 0xe8, 0xfd, 0x2f, 0x80, 0x60, 0xc2, + 0x1d, 0x6f, 0x02, 0x21, 0x00, 0x92, 0xe1, 0x4c, 0xb3, 0xf6, 0x97, 0xc1, 0x8f, 0x8c, 0x85, 0x4d, 0x1f, 0x70, 0x54, 0xbe, 0x6f, + 0x1a, 0xab, 0xce, 0xcc, 0xf3, 0xd5, 0x9e, 0x0c, 0xd2, 0xc2, 0x72, 0x0c, 0xb2, 0xf0, 0xc8, 0x76, +}; + +extern const ByteSpan sTestCert_PAA_NoVID_ToResignPAIs_Cert = ByteSpan(sTestCert_PAA_NoVID_ToResignPAIs_Cert_Array); + +constexpr uint8_t sTestCert_PAA_NoVID_ToResignPAIs_SKID_Array[] = { + 0x78, 0x5C, 0xE7, 0x05, 0xB8, 0x6B, 0x8F, 0x4E, 0x6F, 0xC7, 0x93, 0xAA, 0x60, 0xCB, 0x43, 0xEA, 0x69, 0x68, 0x82, 0xD5, +}; + +extern const ByteSpan sTestCert_PAA_NoVID_ToResignPAIs_SKID = ByteSpan(sTestCert_PAA_NoVID_ToResignPAIs_SKID_Array); + // ${chip_root}/credentials/test/attestation/Chip-Test-PAI-FFF1-8000-Cert.pem constexpr uint8_t sTestCert_PAI_FFF1_8000_Cert_Array[] = { @@ -2703,6 +2737,136 @@ constexpr uint8_t sTestCert_PAI_FFF2_8001_PrivateKey_Array[] = { extern const ByteSpan sTestCert_PAI_FFF2_8001_PrivateKey = ByteSpan(sTestCert_PAI_FFF2_8001_PrivateKey_Array); +// ${chip_root}/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-Resigned-Cert.pem + +constexpr uint8_t sTestCert_PAI_FFF2_8001_Resigned_Cert_Array[] = { + 0x30, 0x82, 0x01, 0xcd, 0x30, 0x82, 0x01, 0x73, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x62, 0x72, 0xc7, 0xaa, 0x0a, 0x13, + 0x20, 0x9d, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x29, 0x31, 0x27, 0x30, 0x25, 0x06, + 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1e, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x41, + 0x20, 0x54, 0x6f, 0x20, 0x52, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x20, 0x50, 0x41, 0x49, 0x73, 0x30, 0x20, 0x17, 0x0d, 0x32, 0x31, + 0x30, 0x36, 0x32, 0x38, 0x31, 0x34, 0x32, 0x33, 0x34, 0x33, 0x5a, 0x18, 0x0f, 0x39, 0x39, 0x39, 0x39, 0x31, 0x32, 0x33, 0x31, + 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, 0x46, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0f, 0x4d, + 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x49, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, + 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, 0x01, 0x0c, 0x04, 0x46, 0x46, 0x46, 0x32, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, + 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, 0x02, 0x0c, 0x04, 0x38, 0x30, 0x30, 0x31, 0x30, 0x59, 0x30, 0x13, 0x06, + 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, + 0x04, 0x2c, 0x06, 0x3c, 0x20, 0x8b, 0xb7, 0xcf, 0x3f, 0x89, 0xd8, 0x9c, 0x70, 0xb2, 0x68, 0xde, 0xc2, 0xf0, 0xad, 0x89, 0x19, + 0x2f, 0x02, 0x2f, 0x95, 0x47, 0xad, 0xcc, 0x72, 0x2a, 0x06, 0x80, 0x69, 0xca, 0x72, 0x35, 0x60, 0x83, 0xb7, 0x24, 0x77, 0x1b, + 0x21, 0x76, 0x4c, 0xb2, 0x4c, 0x57, 0x11, 0xb5, 0x3e, 0xfe, 0x87, 0xfe, 0x4f, 0xe0, 0xb4, 0x73, 0x14, 0x1b, 0xcc, 0xa1, 0x04, + 0xb2, 0x8d, 0xa3, 0x66, 0x30, 0x64, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, + 0x01, 0xff, 0x02, 0x01, 0x00, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, + 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xd0, 0x5a, 0x9b, 0x67, 0x71, 0xa1, 0xa3, 0x7a, 0x9b, 0xc1, + 0x9d, 0x95, 0xe8, 0xb5, 0xdb, 0x8f, 0x43, 0x00, 0xb6, 0x3a, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, + 0x80, 0x14, 0x78, 0x5c, 0xe7, 0x05, 0xb8, 0x6b, 0x8f, 0x4e, 0x6f, 0xc7, 0x93, 0xaa, 0x60, 0xcb, 0x43, 0xea, 0x69, 0x68, 0x82, + 0xd5, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x48, 0x00, 0x30, 0x45, 0x02, 0x21, 0x00, + 0x9f, 0x0d, 0x54, 0x37, 0xe9, 0x09, 0x9f, 0x85, 0x38, 0xca, 0x53, 0x0e, 0xe8, 0x9d, 0x2a, 0xb3, 0x64, 0x24, 0x5c, 0xe9, 0x2b, + 0x21, 0xc9, 0xca, 0xbe, 0xc7, 0x9b, 0xd5, 0x4d, 0x18, 0xe6, 0x1c, 0x02, 0x20, 0x76, 0xd0, 0xe7, 0x1f, 0xf5, 0xe8, 0x50, 0xea, + 0xdd, 0x07, 0xd4, 0x83, 0x1e, 0x75, 0x46, 0xd1, 0x79, 0xd6, 0xe2, 0xb6, 0xd8, 0xe1, 0xc6, 0x17, 0xac, 0x56, 0xa5, 0xec, 0xa1, + 0x54, 0x02, 0x38, +}; + +extern const ByteSpan sTestCert_PAI_FFF2_8001_Resigned_Cert = ByteSpan(sTestCert_PAI_FFF2_8001_Resigned_Cert_Array); + +constexpr uint8_t sTestCert_PAI_FFF2_8001_Resigned_SKID_Array[] = { + 0xD0, 0x5A, 0x9B, 0x67, 0x71, 0xA1, 0xA3, 0x7A, 0x9B, 0xC1, 0x9D, 0x95, 0xE8, 0xB5, 0xDB, 0x8F, 0x43, 0x00, 0xB6, 0x3A, +}; + +extern const ByteSpan sTestCert_PAI_FFF2_8001_Resigned_SKID = ByteSpan(sTestCert_PAI_FFF2_8001_Resigned_SKID_Array); + +// ${chip_root}/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Cert.pem + +constexpr uint8_t sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_Cert_Array[] = { + 0x30, 0x82, 0x01, 0xcc, 0x30, 0x82, 0x01, 0x73, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x4f, 0x3c, 0xc2, 0xdd, 0xb1, 0x1d, + 0xc4, 0xcb, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x29, 0x31, 0x27, 0x30, 0x25, 0x06, + 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1e, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x41, + 0x20, 0x54, 0x6f, 0x20, 0x52, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x20, 0x50, 0x41, 0x49, 0x73, 0x30, 0x20, 0x17, 0x0d, 0x32, 0x31, + 0x30, 0x36, 0x32, 0x38, 0x31, 0x34, 0x32, 0x33, 0x34, 0x33, 0x5a, 0x18, 0x0f, 0x39, 0x39, 0x39, 0x39, 0x31, 0x32, 0x33, 0x31, + 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, 0x46, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0f, 0x4d, + 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x49, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, + 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, 0x01, 0x0c, 0x04, 0x46, 0x46, 0x46, 0x32, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, + 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, 0x02, 0x0c, 0x04, 0x38, 0x30, 0x30, 0x31, 0x30, 0x59, 0x30, 0x13, 0x06, + 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, + 0x04, 0xa1, 0xfa, 0x48, 0x2a, 0x3c, 0x92, 0xf3, 0xa4, 0x66, 0x63, 0x9c, 0xe3, 0x35, 0x71, 0x38, 0xb6, 0xa4, 0xc9, 0xdd, 0x44, + 0x76, 0x16, 0x8e, 0xc7, 0xec, 0x5c, 0x45, 0x08, 0x2b, 0xdc, 0x1b, 0xc0, 0x6d, 0x9b, 0x94, 0xd3, 0x4c, 0x79, 0xdf, 0x05, 0xdf, + 0xc4, 0x0b, 0x27, 0x10, 0x80, 0x44, 0x0b, 0x7a, 0x88, 0xb4, 0x36, 0x38, 0xac, 0x4c, 0x9e, 0xe4, 0x39, 0xc7, 0x41, 0x9c, 0x14, + 0xdd, 0xfa, 0xa3, 0x66, 0x30, 0x64, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, + 0x01, 0xff, 0x02, 0x01, 0x00, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, + 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xdb, 0x77, 0xd2, 0x5b, 0x63, 0x6d, 0x04, 0x38, 0xa1, 0x92, + 0x1c, 0x41, 0x52, 0x10, 0x3e, 0xea, 0xe2, 0xc4, 0x3b, 0x07, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, + 0x80, 0x14, 0x78, 0x5c, 0xe7, 0x05, 0xb8, 0x6b, 0x8f, 0x4e, 0x6f, 0xc7, 0x93, 0xaa, 0x60, 0xcb, 0x43, 0xea, 0x69, 0x68, 0x82, + 0xd5, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x47, 0x00, 0x30, 0x44, 0x02, 0x20, 0x05, + 0x1f, 0x30, 0x34, 0x56, 0xfd, 0xeb, 0x01, 0xff, 0xfd, 0xe4, 0x79, 0x9f, 0xfb, 0xb4, 0x3d, 0x6d, 0xd1, 0x48, 0x65, 0x34, 0x8a, + 0xd6, 0x3f, 0x92, 0xba, 0xcb, 0xca, 0x60, 0xc8, 0x1c, 0x29, 0x02, 0x20, 0x11, 0x12, 0xc3, 0x0a, 0xfb, 0x2a, 0x92, 0xf6, 0x00, + 0x2e, 0x14, 0x78, 0x39, 0x20, 0x3b, 0x45, 0xdb, 0xb8, 0x25, 0x51, 0x61, 0xb0, 0xfd, 0x0c, 0xd0, 0x5e, 0x0c, 0xa4, 0xc4, 0x70, + 0xc8, 0xf1, +}; + +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_Cert = ByteSpan(sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_Cert_Array); + +constexpr uint8_t sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_SKID_Array[] = { + 0xDB, 0x77, 0xD2, 0x5B, 0x63, 0x6D, 0x04, 0x38, 0xA1, 0x92, 0x1C, 0x41, 0x52, 0x10, 0x3E, 0xEA, 0xE2, 0xC4, 0x3B, 0x07, +}; + +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_SKID = ByteSpan(sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_SKID_Array); + +// ${chip_root}/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSKIDDiff-Key.pem + +constexpr uint8_t sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_PublicKey_Array[] = { + 0x04, 0xa1, 0xfa, 0x48, 0x2a, 0x3c, 0x92, 0xf3, 0xa4, 0x66, 0x63, 0x9c, 0xe3, 0x35, 0x71, 0x38, 0xb6, + 0xa4, 0xc9, 0xdd, 0x44, 0x76, 0x16, 0x8e, 0xc7, 0xec, 0x5c, 0x45, 0x08, 0x2b, 0xdc, 0x1b, 0xc0, 0x6d, + 0x9b, 0x94, 0xd3, 0x4c, 0x79, 0xdf, 0x05, 0xdf, 0xc4, 0x0b, 0x27, 0x10, 0x80, 0x44, 0x0b, 0x7a, 0x88, + 0xb4, 0x36, 0x38, 0xac, 0x4c, 0x9e, 0xe4, 0x39, 0xc7, 0x41, 0x9c, 0x14, 0xdd, 0xfa, +}; + +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_PublicKey = + ByteSpan(sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_PublicKey_Array); + +constexpr uint8_t sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_PrivateKey_Array[] = { + 0xd1, 0xae, 0x62, 0xfb, 0x4d, 0xb3, 0x05, 0xfe, 0xa3, 0x8c, 0xa3, 0xe9, 0x44, 0x74, 0x4d, 0x1b, + 0xc0, 0xbf, 0xf9, 0x94, 0xa8, 0x74, 0xdc, 0xc5, 0xf5, 0x7a, 0x17, 0xf8, 0xb5, 0x18, 0x51, 0x35, +}; + +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_PrivateKey = + ByteSpan(sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_PrivateKey_Array); + +// ${chip_root}/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-ResignedSubjectDiff-Cert.pem + +constexpr uint8_t sTestCert_PAI_FFF2_8001_ResignedSubjectDiff_Cert_Array[] = { + 0x30, 0x82, 0x01, 0xd6, 0x30, 0x82, 0x01, 0x7c, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x47, 0xed, 0x63, 0x68, 0x21, 0x97, + 0x69, 0x31, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x29, 0x31, 0x27, 0x30, 0x25, 0x06, + 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1e, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x41, + 0x20, 0x54, 0x6f, 0x20, 0x52, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x20, 0x50, 0x41, 0x49, 0x73, 0x30, 0x20, 0x17, 0x0d, 0x32, 0x31, + 0x30, 0x36, 0x32, 0x38, 0x31, 0x34, 0x32, 0x33, 0x34, 0x33, 0x5a, 0x18, 0x0f, 0x39, 0x39, 0x39, 0x39, 0x31, 0x32, 0x33, 0x31, + 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, 0x4f, 0x31, 0x21, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x18, 0x4d, + 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x49, 0x20, 0x52, 0x65, 0x73, 0x69, 0x67, 0x6e, + 0x65, 0x64, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, 0x01, 0x0c, 0x04, 0x46, + 0x46, 0x46, 0x32, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, 0x02, 0x0c, 0x04, + 0x38, 0x30, 0x30, 0x31, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, + 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, 0x2c, 0x06, 0x3c, 0x20, 0x8b, 0xb7, 0xcf, 0x3f, 0x89, 0xd8, 0x9c, + 0x70, 0xb2, 0x68, 0xde, 0xc2, 0xf0, 0xad, 0x89, 0x19, 0x2f, 0x02, 0x2f, 0x95, 0x47, 0xad, 0xcc, 0x72, 0x2a, 0x06, 0x80, 0x69, + 0xca, 0x72, 0x35, 0x60, 0x83, 0xb7, 0x24, 0x77, 0x1b, 0x21, 0x76, 0x4c, 0xb2, 0x4c, 0x57, 0x11, 0xb5, 0x3e, 0xfe, 0x87, 0xfe, + 0x4f, 0xe0, 0xb4, 0x73, 0x14, 0x1b, 0xcc, 0xa1, 0x04, 0xb2, 0x8d, 0xa3, 0x66, 0x30, 0x64, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, + 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x00, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, + 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0xd0, + 0x5a, 0x9b, 0x67, 0x71, 0xa1, 0xa3, 0x7a, 0x9b, 0xc1, 0x9d, 0x95, 0xe8, 0xb5, 0xdb, 0x8f, 0x43, 0x00, 0xb6, 0x3a, 0x30, 0x1f, + 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14, 0x78, 0x5c, 0xe7, 0x05, 0xb8, 0x6b, 0x8f, 0x4e, 0x6f, 0xc7, + 0x93, 0xaa, 0x60, 0xcb, 0x43, 0xea, 0x69, 0x68, 0x82, 0xd5, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, + 0x02, 0x03, 0x48, 0x00, 0x30, 0x45, 0x02, 0x21, 0x00, 0xe8, 0xb2, 0xc6, 0x11, 0x70, 0x4a, 0x54, 0x06, 0x79, 0x0c, 0xc5, 0xc8, + 0x87, 0x38, 0x38, 0x89, 0x03, 0x9c, 0x18, 0xed, 0xf2, 0x3d, 0x5e, 0xe2, 0x55, 0x15, 0x0e, 0x0f, 0xf4, 0x75, 0xef, 0xc9, 0x02, + 0x20, 0x7f, 0x0d, 0x94, 0x91, 0xe6, 0xe6, 0x91, 0xc0, 0x55, 0xcb, 0xa0, 0xb0, 0x4a, 0x72, 0x90, 0x76, 0xa2, 0x58, 0x2f, 0xb3, + 0xb9, 0xe3, 0x0a, 0x15, 0xbe, 0xc3, 0xd0, 0x5c, 0xe9, 0x11, 0x2f, 0xfc, +}; + +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSubjectDiff_Cert = + ByteSpan(sTestCert_PAI_FFF2_8001_ResignedSubjectDiff_Cert_Array); + +constexpr uint8_t sTestCert_PAI_FFF2_8001_ResignedSubjectDiff_SKID_Array[] = { + 0xD0, 0x5A, 0x9B, 0x67, 0x71, 0xA1, 0xA3, 0x7A, 0x9B, 0xC1, 0x9D, 0x95, 0xE8, 0xB5, 0xDB, 0x8F, 0x43, 0x00, 0xB6, 0x3A, +}; + +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSubjectDiff_SKID = + ByteSpan(sTestCert_PAI_FFF2_8001_ResignedSubjectDiff_SKID_Array); + // ${chip_root}/credentials/test/attestation/Chip-Test-PAI-FFF2-8004-FB-Cert.pem constexpr uint8_t sTestCert_PAI_FFF2_8004_FB_Cert_Array[] = { @@ -3129,5 +3293,40 @@ constexpr uint8_t sTestCert_PAI_FFF2_NoPID_FB_PrivateKey_Array[] = { extern const ByteSpan sTestCert_PAI_FFF2_NoPID_FB_PrivateKey = ByteSpan(sTestCert_PAI_FFF2_NoPID_FB_PrivateKey_Array); +// ${chip_root}/credentials/test/attestation/Chip-Test-PAI-FFF2-NoPID-Resigned-Cert.pem + +constexpr uint8_t sTestCert_PAI_FFF2_NoPID_Resigned_Cert_Array[] = { + 0x30, 0x82, 0x01, 0xb7, 0x30, 0x82, 0x01, 0x5d, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x08, 0x5d, 0x0a, 0x59, 0xc0, 0x17, 0x4b, + 0x3b, 0x65, 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x30, 0x29, 0x31, 0x27, 0x30, 0x25, 0x06, + 0x03, 0x55, 0x04, 0x03, 0x0c, 0x1e, 0x4d, 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x41, + 0x20, 0x54, 0x6f, 0x20, 0x52, 0x65, 0x73, 0x69, 0x67, 0x6e, 0x20, 0x50, 0x41, 0x49, 0x73, 0x30, 0x20, 0x17, 0x0d, 0x32, 0x31, + 0x30, 0x36, 0x32, 0x38, 0x31, 0x34, 0x32, 0x33, 0x34, 0x33, 0x5a, 0x18, 0x0f, 0x39, 0x39, 0x39, 0x39, 0x31, 0x32, 0x33, 0x31, + 0x32, 0x33, 0x35, 0x39, 0x35, 0x39, 0x5a, 0x30, 0x30, 0x31, 0x18, 0x30, 0x16, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x0f, 0x4d, + 0x61, 0x74, 0x74, 0x65, 0x72, 0x20, 0x54, 0x65, 0x73, 0x74, 0x20, 0x50, 0x41, 0x49, 0x31, 0x14, 0x30, 0x12, 0x06, 0x0a, 0x2b, + 0x06, 0x01, 0x04, 0x01, 0x82, 0xa2, 0x7c, 0x02, 0x01, 0x0c, 0x04, 0x46, 0x46, 0x46, 0x32, 0x30, 0x59, 0x30, 0x13, 0x06, 0x07, + 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x02, 0x01, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x03, 0x01, 0x07, 0x03, 0x42, 0x00, 0x04, + 0xd8, 0xbf, 0x93, 0x47, 0x92, 0xcf, 0x8e, 0xae, 0xda, 0xc2, 0x4f, 0xfc, 0x96, 0x6c, 0x91, 0x76, 0x20, 0xfb, 0x97, 0x2f, 0xba, + 0xb9, 0x8e, 0xc6, 0xd5, 0x13, 0x14, 0xa0, 0x7a, 0xe9, 0x8e, 0x1a, 0x03, 0xfb, 0x41, 0x91, 0xd2, 0x6e, 0x2d, 0x12, 0x7c, 0xb9, + 0x52, 0x76, 0x21, 0xc3, 0x6e, 0x97, 0x3a, 0x18, 0x6c, 0x56, 0xd0, 0xca, 0xd9, 0x99, 0xb0, 0x41, 0xc2, 0x70, 0xa9, 0xb1, 0xcb, + 0x3f, 0xa3, 0x66, 0x30, 0x64, 0x30, 0x12, 0x06, 0x03, 0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08, 0x30, 0x06, 0x01, 0x01, + 0xff, 0x02, 0x01, 0x00, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04, 0x03, 0x02, 0x01, 0x06, 0x30, + 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x61, 0x3d, 0xd0, 0x87, 0x35, 0x5e, 0xf0, 0x8b, 0xae, 0x01, 0xe4, + 0xc6, 0x9a, 0x8f, 0xc7, 0x3d, 0xac, 0x8c, 0x7d, 0xfd, 0x30, 0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, + 0x14, 0x78, 0x5c, 0xe7, 0x05, 0xb8, 0x6b, 0x8f, 0x4e, 0x6f, 0xc7, 0x93, 0xaa, 0x60, 0xcb, 0x43, 0xea, 0x69, 0x68, 0x82, 0xd5, + 0x30, 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x03, 0x48, 0x00, 0x30, 0x45, 0x02, 0x20, 0x7e, 0x5f, + 0x9f, 0x5f, 0xff, 0x06, 0xeb, 0x39, 0xff, 0x13, 0x4f, 0x5a, 0xed, 0x7f, 0x3f, 0x96, 0x61, 0x3f, 0xe2, 0xf1, 0x7f, 0x4f, 0x7b, + 0xbf, 0x51, 0x24, 0x3e, 0x2a, 0x73, 0x53, 0x70, 0xf8, 0x02, 0x21, 0x00, 0xec, 0x54, 0x7d, 0x78, 0x73, 0xdb, 0x45, 0x80, 0xf1, + 0xe8, 0xd8, 0xe9, 0x2e, 0xca, 0xec, 0x24, 0x5d, 0x88, 0x0a, 0x88, 0x17, 0xfc, 0xd8, 0x1c, 0x67, 0xa8, 0xfa, 0xe4, 0x95, 0x8e, + 0xda, 0x82, +}; + +extern const ByteSpan sTestCert_PAI_FFF2_NoPID_Resigned_Cert = ByteSpan(sTestCert_PAI_FFF2_NoPID_Resigned_Cert_Array); + +constexpr uint8_t sTestCert_PAI_FFF2_NoPID_Resigned_SKID_Array[] = { + 0x61, 0x3D, 0xD0, 0x87, 0x35, 0x5E, 0xF0, 0x8B, 0xAE, 0x01, 0xE4, 0xC6, 0x9A, 0x8F, 0xC7, 0x3D, 0xAC, 0x8C, 0x7D, 0xFD, +}; + +extern const ByteSpan sTestCert_PAI_FFF2_NoPID_Resigned_SKID = ByteSpan(sTestCert_PAI_FFF2_NoPID_Resigned_SKID_Array); + } // namespace TestCerts } // namespace chip diff --git a/src/credentials/tests/CHIPAttCert_test_vectors.h b/src/credentials/tests/CHIPAttCert_test_vectors.h index a38a48e6fe81cd..2419c6bfd578c3 100644 --- a/src/credentials/tests/CHIPAttCert_test_vectors.h +++ b/src/credentials/tests/CHIPAttCert_test_vectors.h @@ -258,6 +258,9 @@ extern const ByteSpan sTestCert_PAA_NoVID_SKID; extern const ByteSpan sTestCert_PAA_NoVID_PublicKey; extern const ByteSpan sTestCert_PAA_NoVID_PrivateKey; +extern const ByteSpan sTestCert_PAA_NoVID_ToResignPAIs_Cert; +extern const ByteSpan sTestCert_PAA_NoVID_ToResignPAIs_SKID; + extern const ByteSpan sTestCert_PAI_FFF1_8000_Cert; extern const ByteSpan sTestCert_PAI_FFF1_8000_SKID; extern const ByteSpan sTestCert_PAI_FFF1_8000_PublicKey; @@ -268,6 +271,17 @@ extern const ByteSpan sTestCert_PAI_FFF2_8001_SKID; extern const ByteSpan sTestCert_PAI_FFF2_8001_PublicKey; extern const ByteSpan sTestCert_PAI_FFF2_8001_PrivateKey; +extern const ByteSpan sTestCert_PAI_FFF2_8001_Resigned_Cert; +extern const ByteSpan sTestCert_PAI_FFF2_8001_Resigned_SKID; + +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_Cert; +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_SKID; +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_PublicKey; +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_PrivateKey; + +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSubjectDiff_Cert; +extern const ByteSpan sTestCert_PAI_FFF2_8001_ResignedSubjectDiff_SKID; + extern const ByteSpan sTestCert_PAI_FFF2_8004_FB_Cert; extern const ByteSpan sTestCert_PAI_FFF2_8004_FB_SKID; extern const ByteSpan sTestCert_PAI_FFF2_8004_FB_PublicKey; @@ -308,5 +322,8 @@ extern const ByteSpan sTestCert_PAI_FFF2_NoPID_FB_SKID; extern const ByteSpan sTestCert_PAI_FFF2_NoPID_FB_PublicKey; extern const ByteSpan sTestCert_PAI_FFF2_NoPID_FB_PrivateKey; +extern const ByteSpan sTestCert_PAI_FFF2_NoPID_Resigned_Cert; +extern const ByteSpan sTestCert_PAI_FFF2_NoPID_Resigned_SKID; + } // namespace TestCerts } // namespace chip diff --git a/src/crypto/CHIPCryptoPAL.h b/src/crypto/CHIPCryptoPAL.h index e87400604d8a84..00733b7d9e7402 100644 --- a/src/crypto/CHIPCryptoPAL.h +++ b/src/crypto/CHIPCryptoPAL.h @@ -1492,6 +1492,29 @@ CHIP_ERROR ExtractSKIDFromX509Cert(const ByteSpan & certificate, MutableByteSpan **/ CHIP_ERROR ExtractAKIDFromX509Cert(const ByteSpan & certificate, MutableByteSpan & akid); +/** + * @brief Checks for resigned version of the certificate in the list and returns it. + * + * The following conditions SHOULD be satisfied for the certificate to qualify as + * a resigned version of a reference certificate: + * - SKID of the candidate and the reference certificate should match. + * - SubjectDN of the candidate and the reference certificate should match. + * + * If no resigned version is found then reference certificate itself is returned. + * + * @param referenceCertificate A DER certificate. + * @param candidateCertificates A pointer to the list of DER Certificates, which should be searched + * for the resigned version of `referenceCertificate`. + * @param candidateCertificatesCount Number of certificates in the `candidateCertificates` list. + * @param outCertificate A reference to the certificate or it's resigned version if found. + * Note that it points to either `referenceCertificate` or one of + * `candidateCertificates`, but it doesn't copy data. + * + * @returns error if there is certificate parsing/format issue or CHIP_NO_ERROR otherwise. + **/ +CHIP_ERROR ReplaceCertIfResignedCertFound(const ByteSpan & referenceCertificate, const ByteSpan * candidateCertificates, + size_t candidateCertificatesCount, ByteSpan & outCertificate); + /** * Defines DN attribute types that can include endocing of VID/PID parameters. */ diff --git a/src/crypto/CHIPCryptoPALOpenSSL.cpp b/src/crypto/CHIPCryptoPALOpenSSL.cpp index 8a24fde3c54fd4..def307997f5e04 100644 --- a/src/crypto/CHIPCryptoPALOpenSSL.cpp +++ b/src/crypto/CHIPCryptoPALOpenSSL.cpp @@ -2045,5 +2045,65 @@ CHIP_ERROR ExtractVIDPIDFromX509Cert(const ByteSpan & certificate, AttestationCe return err; } +CHIP_ERROR ReplaceCertIfResignedCertFound(const ByteSpan & referenceCertificate, const ByteSpan * candidateCertificates, + size_t candidateCertificatesCount, ByteSpan & outCertificate) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + X509 * x509ReferenceCertificate = nullptr; + X509 * x509CandidateCertificate = nullptr; + const uint8_t * pReferenceCertificate = referenceCertificate.data(); + X509_NAME * referenceSubject = nullptr; + X509_NAME * candidateSubject = nullptr; + uint8_t referenceSKIDBuf[kSubjectKeyIdentifierLength]; + uint8_t candidateSKIDBuf[kSubjectKeyIdentifierLength]; + MutableByteSpan referenceSKID(referenceSKIDBuf); + MutableByteSpan candidateSKID(candidateSKIDBuf); + + ReturnErrorCodeIf(referenceCertificate.empty(), CHIP_ERROR_INVALID_ARGUMENT); + + outCertificate = referenceCertificate; + + ReturnErrorCodeIf(candidateCertificates == nullptr || candidateCertificatesCount == 0, CHIP_NO_ERROR); + + ReturnErrorOnFailure(ExtractSKIDFromX509Cert(referenceCertificate, referenceSKID)); + + x509ReferenceCertificate = d2i_X509(nullptr, &pReferenceCertificate, static_cast(referenceCertificate.size())); + VerifyOrExit(x509ReferenceCertificate != nullptr, err = CHIP_ERROR_NO_MEMORY); + + referenceSubject = X509_get_subject_name(x509ReferenceCertificate); + VerifyOrExit(referenceSubject != nullptr, err = CHIP_ERROR_INTERNAL); + + for (size_t i = 0; i < candidateCertificatesCount; i++) + { + const ByteSpan candidateCertificate = candidateCertificates[i]; + const uint8_t * pCandidateCertificate = candidateCertificate.data(); + + VerifyOrExit(!candidateCertificate.empty(), err = CHIP_ERROR_INVALID_ARGUMENT); + + SuccessOrExit(err = ExtractSKIDFromX509Cert(candidateCertificate, candidateSKID)); + + x509CandidateCertificate = d2i_X509(nullptr, &pCandidateCertificate, static_cast(candidateCertificate.size())); + VerifyOrExit(x509CandidateCertificate != nullptr, err = CHIP_ERROR_NO_MEMORY); + + candidateSubject = X509_get_subject_name(x509CandidateCertificate); + VerifyOrExit(candidateSubject != nullptr, err = CHIP_ERROR_INTERNAL); + + if (referenceSKID.data_equal(candidateSKID) && X509_NAME_cmp(referenceSubject, candidateSubject) == 0) + { + outCertificate = candidateCertificate; + ExitNow(); + } + + X509_free(x509CandidateCertificate); + x509CandidateCertificate = nullptr; + } + +exit: + X509_free(x509ReferenceCertificate); + X509_free(x509CandidateCertificate); + + return err; +} + } // namespace Crypto } // namespace chip diff --git a/src/crypto/CHIPCryptoPALTinyCrypt.cpp b/src/crypto/CHIPCryptoPALTinyCrypt.cpp index b89bbcd22a76b3..dd6f875a58287b 100644 --- a/src/crypto/CHIPCryptoPALTinyCrypt.cpp +++ b/src/crypto/CHIPCryptoPALTinyCrypt.cpp @@ -1691,5 +1691,82 @@ CHIP_ERROR ExtractVIDPIDFromX509Cert(const ByteSpan & certificate, AttestationCe return error; } +namespace { +#if defined(MBEDTLS_X509_CRT_PARSE_C) +CHIP_ERROR ExtractRawSubjectFromX509Cert(const ByteSpan & certificate, MutableByteSpan & subject) +{ + CHIP_ERROR error = CHIP_NO_ERROR; + int result = 0; + uint8_t * p = nullptr; + size_t len = 0; + mbedtls_x509_crt mbedCertificate; + + ReturnErrorCodeIf(certificate.empty(), CHIP_ERROR_INVALID_ARGUMENT); + + mbedtls_x509_crt_init(&mbedCertificate); + result = mbedtls_x509_crt_parse(&mbedCertificate, Uint8::to_const_uchar(certificate.data()), certificate.size()); + VerifyOrExit(result == 0, error = CHIP_ERROR_INTERNAL); + + len = mbedCertificate.CHIP_CRYPTO_PAL_PRIVATE_X509(subject_raw).CHIP_CRYPTO_PAL_PRIVATE_X509(len); + p = mbedCertificate.CHIP_CRYPTO_PAL_PRIVATE_X509(subject_raw).CHIP_CRYPTO_PAL_PRIVATE_X509(p); + + VerifyOrExit(len <= subject.size(), error = CHIP_ERROR_BUFFER_TOO_SMALL); + memcpy(subject.data(), p, len); + subject.reduce_size(len); + +exit: + _log_mbedTLS_error(result); + mbedtls_x509_crt_free(&mbedCertificate); + + return error; +} +#endif // defined(MBEDTLS_X509_CRT_PARSE_C) +} // namespace + +CHIP_ERROR ReplaceCertIfResignedCertFound(const ByteSpan & referenceCertificate, const ByteSpan * candidateCertificates, + size_t candidateCertificatesCount, ByteSpan & outCertificate) +{ +#if defined(MBEDTLS_X509_CRT_PARSE_C) + constexpr size_t kMaxCertificateSubjectLength = 150; + uint8_t referenceSubjectBuf[kMaxCertificateSubjectLength]; + uint8_t referenceSKIDBuf[kSubjectKeyIdentifierLength]; + MutableByteSpan referenceSubject(referenceSubjectBuf); + MutableByteSpan referenceSKID(referenceSKIDBuf); + + outCertificate = referenceCertificate; + + ReturnErrorCodeIf(candidateCertificates == nullptr || candidateCertificatesCount == 0, CHIP_NO_ERROR); + + ReturnErrorOnFailure(ExtractRawSubjectFromX509Cert(referenceCertificate, referenceSubject)); + ReturnErrorOnFailure(ExtractSKIDFromX509Cert(referenceCertificate, referenceSKID)); + + for (size_t i = 0; i < candidateCertificatesCount; i++) + { + const ByteSpan candidateCertificate = candidateCertificates[i]; + uint8_t candidateSubjectBuf[kMaxCertificateSubjectLength]; + uint8_t candidateSKIDBuf[kSubjectKeyIdentifierLength]; + MutableByteSpan candidateSubject(candidateSubjectBuf); + MutableByteSpan candidateSKID(candidateSKIDBuf); + + ReturnErrorOnFailure(ExtractRawSubjectFromX509Cert(candidateCertificate, candidateSubject)); + ReturnErrorOnFailure(ExtractSKIDFromX509Cert(candidateCertificate, candidateSKID)); + + if (referenceSKID.data_equal(candidateSKID) && referenceSubject.data_equal(candidateSubject)) + { + outCertificate = candidateCertificate; + return CHIP_NO_ERROR; + } + } + + return CHIP_NO_ERROR; +#else + (void) referenceCertificate; + (void) candidateCertificates; + (void) candidateCertificatesCount; + (void) outCertificate; + return CHIP_ERROR_NOT_IMPLEMENTED; +#endif // defined(MBEDTLS_X509_CRT_PARSE_C) +} + } // namespace Crypto } // namespace chip diff --git a/src/crypto/CHIPCryptoPALmbedTLS.cpp b/src/crypto/CHIPCryptoPALmbedTLS.cpp index 2ce3bc7aba8c30..ff42f9e3df411b 100644 --- a/src/crypto/CHIPCryptoPALmbedTLS.cpp +++ b/src/crypto/CHIPCryptoPALmbedTLS.cpp @@ -1836,5 +1836,82 @@ CHIP_ERROR ExtractVIDPIDFromX509Cert(const ByteSpan & certificate, AttestationCe return error; } +namespace { +#if defined(MBEDTLS_X509_CRT_PARSE_C) +CHIP_ERROR ExtractRawSubjectFromX509Cert(const ByteSpan & certificate, MutableByteSpan & subject) +{ + CHIP_ERROR error = CHIP_NO_ERROR; + int result = 0; + uint8_t * p = nullptr; + size_t len = 0; + mbedtls_x509_crt mbedCertificate; + + ReturnErrorCodeIf(certificate.empty(), CHIP_ERROR_INVALID_ARGUMENT); + + mbedtls_x509_crt_init(&mbedCertificate); + result = mbedtls_x509_crt_parse(&mbedCertificate, Uint8::to_const_uchar(certificate.data()), certificate.size()); + VerifyOrExit(result == 0, error = CHIP_ERROR_INTERNAL); + + len = mbedCertificate.CHIP_CRYPTO_PAL_PRIVATE_X509(subject_raw).CHIP_CRYPTO_PAL_PRIVATE_X509(len); + p = mbedCertificate.CHIP_CRYPTO_PAL_PRIVATE_X509(subject_raw).CHIP_CRYPTO_PAL_PRIVATE_X509(p); + + VerifyOrExit(len <= subject.size(), error = CHIP_ERROR_BUFFER_TOO_SMALL); + memcpy(subject.data(), p, len); + subject.reduce_size(len); + +exit: + _log_mbedTLS_error(result); + mbedtls_x509_crt_free(&mbedCertificate); + + return error; +} +#endif // defined(MBEDTLS_X509_CRT_PARSE_C) +} // namespace + +CHIP_ERROR ReplaceCertIfResignedCertFound(const ByteSpan & referenceCertificate, const ByteSpan * candidateCertificates, + size_t candidateCertificatesCount, ByteSpan & outCertificate) +{ +#if defined(MBEDTLS_X509_CRT_PARSE_C) + constexpr size_t kMaxCertificateSubjectLength = 150; + uint8_t referenceSubjectBuf[kMaxCertificateSubjectLength]; + uint8_t referenceSKIDBuf[kSubjectKeyIdentifierLength]; + MutableByteSpan referenceSubject(referenceSubjectBuf); + MutableByteSpan referenceSKID(referenceSKIDBuf); + + outCertificate = referenceCertificate; + + ReturnErrorCodeIf(candidateCertificates == nullptr || candidateCertificatesCount == 0, CHIP_NO_ERROR); + + ReturnErrorOnFailure(ExtractRawSubjectFromX509Cert(referenceCertificate, referenceSubject)); + ReturnErrorOnFailure(ExtractSKIDFromX509Cert(referenceCertificate, referenceSKID)); + + for (size_t i = 0; i < candidateCertificatesCount; i++) + { + const ByteSpan candidateCertificate = candidateCertificates[i]; + uint8_t candidateSubjectBuf[kMaxCertificateSubjectLength]; + uint8_t candidateSKIDBuf[kSubjectKeyIdentifierLength]; + MutableByteSpan candidateSubject(candidateSubjectBuf); + MutableByteSpan candidateSKID(candidateSKIDBuf); + + ReturnErrorOnFailure(ExtractRawSubjectFromX509Cert(candidateCertificate, candidateSubject)); + ReturnErrorOnFailure(ExtractSKIDFromX509Cert(candidateCertificate, candidateSKID)); + + if (referenceSKID.data_equal(candidateSKID) && referenceSubject.data_equal(candidateSubject)) + { + outCertificate = candidateCertificate; + return CHIP_NO_ERROR; + } + } + + return CHIP_NO_ERROR; +#else + (void) referenceCertificate; + (void) candidateCertificates; + (void) candidateCertificatesCount; + (void) outCertificate; + return CHIP_ERROR_NOT_IMPLEMENTED; +#endif // defined(MBEDTLS_X509_CRT_PARSE_C) +} + } // namespace Crypto } // namespace chip diff --git a/src/crypto/tests/CHIPCryptoPALTest.cpp b/src/crypto/tests/CHIPCryptoPALTest.cpp index f79a967f652f74..c8b2810ddd0f40 100644 --- a/src/crypto/tests/CHIPCryptoPALTest.cpp +++ b/src/crypto/tests/CHIPCryptoPALTest.cpp @@ -2301,6 +2301,87 @@ static void TestVIDPID_x509Extraction(nlTestSuite * inSuite, void * inContext) } } +static void TestX509_ReplaceCertIfResignedCertFound(nlTestSuite * inSuite, void * inContext) +{ + using namespace TestCerts; + + HeapChecker heapChecker(inSuite); + + struct TestCase + { + ByteSpan referenceCert; + ByteSpan * candidateCertsList; + size_t candidateCertsCount; + ByteSpan expectedOutCert; + }; + + // clang-format off + ByteSpan TestCandidateCertsList1[] = { sTestCert_DAC_FFF1_8000_0004_Cert, + sTestCert_PAI_FFF2_8004_FB_Cert, + sTestCert_PAA_FFF1_Cert }; + ByteSpan TestCandidateCertsList2[] = { sTestCert_DAC_FFF1_8000_0004_Cert, + sTestCert_PAI_FFF2_NoPID_Resigned_Cert }; + ByteSpan TestCandidateCertsList3[] = { sTestCert_DAC_FFF1_8000_0004_Cert, + sTestCert_PAI_FFF2_8001_Resigned_Cert }; + ByteSpan TestCandidateCertsList4[] = { sTestCert_PAI_FFF2_8001_Resigned_Cert, + sTestCert_PAI_FFF1_8000_Cert }; + ByteSpan TestCandidateCertsList5[] = { sTestCert_PAI_FFF2_NoPID_Resigned_Cert, + sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_Cert }; + ByteSpan TestCandidateCertsList6[] = { sTestCert_PAI_FFF2_8001_ResignedSubjectDiff_Cert, + sTestCert_DAC_FFF1_8000_0004_Cert }; + ByteSpan TestCandidateCertsList7[] = { sTestCert_PAA_NoVID_ToResignPAIs_Cert, + sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_Cert, + sTestCert_PAI_FFF2_8001_ResignedSubjectDiff_Cert, + sTestCert_PAI_FFF2_8001_Resigned_Cert, + sTestCert_PAI_FFF2_NoPID_Resigned_Cert }; + ByteSpan TestCandidateCertsList8[] = { sTestCert_PAA_NoVID_ToResignPAIs_Cert, + sTestCert_PAI_FFF2_8001_Resigned_Cert, + ByteSpan(), + sTestCert_PAI_FFF2_8001_ResignedSKIDDiff_Cert, + sTestCert_PAI_FFF2_8001_ResignedSubjectDiff_Cert, + sTestCert_PAI_FFF2_NoPID_Resigned_Cert }; + + const TestCase kTestCases[] = { + { sTestCert_PAI_FFF2_8001_Cert, nullptr, 5, sTestCert_PAI_FFF2_8001_Cert }, + { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList3, 0, sTestCert_PAI_FFF2_8001_Cert }, + { sTestCert_PAI_FFF1_8000_Cert, TestCandidateCertsList1, ArraySize(TestCandidateCertsList1), sTestCert_PAI_FFF1_8000_Cert }, + { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList2, ArraySize(TestCandidateCertsList2), sTestCert_PAI_FFF2_8001_Cert }, + { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList3, ArraySize(TestCandidateCertsList3), sTestCert_PAI_FFF2_8001_Resigned_Cert }, + { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList4, ArraySize(TestCandidateCertsList4), sTestCert_PAI_FFF2_8001_Resigned_Cert }, + { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList5, ArraySize(TestCandidateCertsList5), sTestCert_PAI_FFF2_8001_Cert }, + { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList6, ArraySize(TestCandidateCertsList6), sTestCert_PAI_FFF2_8001_Cert }, + { sTestCert_PAI_FFF2_8001_Cert, TestCandidateCertsList7, ArraySize(TestCandidateCertsList7), sTestCert_PAI_FFF2_8001_Resigned_Cert }, + { sTestCert_PAI_FFF2_NoPID_Cert, TestCandidateCertsList7, ArraySize(TestCandidateCertsList7), sTestCert_PAI_FFF2_NoPID_Resigned_Cert }, + }; + // clang-format on + + for (const auto & testCase : kTestCases) + { + ByteSpan outCert; + CHIP_ERROR result = ReplaceCertIfResignedCertFound(testCase.referenceCert, testCase.candidateCertsList, + testCase.candidateCertsCount, outCert); + + NL_TEST_ASSERT(inSuite, result == CHIP_NO_ERROR); + NL_TEST_ASSERT(inSuite, outCert.data_equal(testCase.expectedOutCert)); + } + + // Error case: invalid input argument for referenceCertificate + { + ByteSpan outCert; + CHIP_ERROR result = + ReplaceCertIfResignedCertFound(ByteSpan(), TestCandidateCertsList7, ArraySize(TestCandidateCertsList7), outCert); + NL_TEST_ASSERT(inSuite, result == CHIP_ERROR_INVALID_ARGUMENT); + } + + // Error case: invalid input argument for one of the certificates in the candidateCertificates list + { + ByteSpan outCert; + CHIP_ERROR result = + ReplaceCertIfResignedCertFound(ByteSpan(), TestCandidateCertsList8, ArraySize(TestCandidateCertsList8), outCert); + NL_TEST_ASSERT(inSuite, result == CHIP_ERROR_INVALID_ARGUMENT); + } +} + static const uint8_t kCompressedFabricId[] = { 0x29, 0x06, 0xC9, 0x08, 0xD1, 0x15, 0xD3, 0x62 }; const uint8_t kEpochKeyBuffer1[Crypto::CHIP_CRYPTO_SYMMETRIC_KEY_LENGTH_BYTES] = { 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, @@ -2462,6 +2543,7 @@ static const nlTest sTests[] = { NL_TEST_DEF("Test Authority Key Id Extraction from x509 Certificate", TestAKID_x509Extraction), NL_TEST_DEF("Test Vendor ID and Product ID Extraction from Attribute String", TestVIDPID_StringExtraction), NL_TEST_DEF("Test Vendor ID and Product ID Extraction from x509 Attestation Certificate", TestVIDPID_x509Extraction), + NL_TEST_DEF("Test Replace Resigned Certificate Version if Found", TestX509_ReplaceCertIfResignedCertFound), NL_TEST_DEF("Test Group Operation Key Derivation", TestGroup_OperationalKeyDerivation), NL_TEST_DEF("Test Group Session ID Derivation", TestGroup_SessionIdDerivation), NL_TEST_DEF("Test Group Privacy Key Derivation", TestGroup_PrivacyKeyDerivation), diff --git a/src/darwin/Framework/CHIP/MTRBaseDevice.mm b/src/darwin/Framework/CHIP/MTRBaseDevice.mm index 7725c9ab6e1f1b..e8211845e91cae 100644 --- a/src/darwin/Framework/CHIP/MTRBaseDevice.mm +++ b/src/darwin/Framework/CHIP/MTRBaseDevice.mm @@ -1437,7 +1437,7 @@ + (id)CHIPEncodeAndDecodeNSObject:(id)object uint8_t buffer[1024]; writer.Init(buffer, sizeof(buffer)); - CHIP_ERROR error = originalData.Encode(writer, chip::TLV::Tag(1)); + CHIP_ERROR error = originalData.Encode(writer, chip::TLV::CommonTag(1)); if (error != CHIP_NO_ERROR) { MTR_LOG_ERROR("Error: Data encoding failed: %s", error.AsString()); return nil; @@ -1456,8 +1456,9 @@ + (id)CHIPEncodeAndDecodeNSObject:(id)object return nil; } __auto_type tag = reader.GetTag(); - if (tag != chip::TLV::Tag(1)) { - MTR_LOG_ERROR("Error: TLV reader did not read the tag correctly: %llu", tag.mVal); + if (tag != chip::TLV::CommonTag(1)) { + MTR_LOG_ERROR("Error: TLV reader did not read the tag correctly: %x.%u", chip::TLV::ProfileIdFromTag(tag), + chip::TLV::TagNumFromTag(tag)); return nil; } MTRDataValueDictionaryDecodableType decodedData; diff --git a/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt b/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt index 433c778543c4dd..f7c229a0fbb14e 100644 --- a/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt @@ -84,13 +84,13 @@ subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptio {{#*inline "enumDef"}} typedef NS_ENUM({{asUnderlyingZclType name}}, {{objCEnumName clusterName enumName}}) { {{#zcl_enum_items}} - {{objCEnumName ../clusterName ../enumName}}{{objCEnumItemLabel label}} {{availability ../clusterName enum=../enumName enumValue=(objCEnumItemLabel label) deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (objCEnumItemLabel label))}} = {{asHex value 2}}, + {{objCEnumName ../clusterName ../enumName}}{{asUpperCamelCase label preserveAcronyms=true}} {{availability ../clusterName enum=../enumName enumValue=(asUpperCamelCase label preserveAcronyms=true) deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (asUpperCamelCase label preserveAcronyms=true))}} = {{asHex value 2}}, {{#*inline "oldNameItemDecl"}} {{#if oldItemName}} - {{objCEnumName ../clusterName ../enumName}}{{objCEnumItemLabel oldItemName}} {{availability ../clusterName enum=../enumName enumValue=oldItemName deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (objCEnumItemLabel label))}} = {{asHex value 2}}, + {{objCEnumName ../clusterName ../enumName}}{{objCEnumItemLabel oldItemName}} {{availability ../clusterName enum=../enumName enumValue=oldItemName deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (asUpperCamelCase label preserveAcronyms=true))}} = {{asHex value 2}}, {{/if}} {{/inline}} - {{> oldNameItemDecl oldItemName=(oldName ../clusterName enum=../enumName enumValue=(objCEnumItemLabel label))}} + {{> oldNameItemDecl oldItemName=(oldName ../clusterName enum=../enumName enumValue=(asUpperCamelCase label preserveAcronyms=true))}} {{/zcl_enum_items}} } {{/inline}} @@ -118,13 +118,13 @@ typedef NS_ENUM({{asUnderlyingZclType name}}, {{objCEnumName clusterName enumNam {{#*inline "bitmapDef"}} typedef NS_OPTIONS({{asUnderlyingZclType name}}, {{objCEnumName clusterName bitmapName}}) { {{#zcl_bitmap_items}} - {{objCEnumName ../clusterName ../bitmapName}}{{objCEnumItemLabel label}} {{availability ../clusterName bitmap=../bitmapName bitmapValue=(objCEnumItemLabel label) deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (objCEnumItemLabel label))}} = {{asHex mask}}, + {{objCEnumName ../clusterName ../bitmapName}}{{asUpperCamelCase label preserveAcronyms=true}} {{availability ../clusterName bitmap=../bitmapName bitmapValue=(asUpperCamelCase label preserveAcronyms=true) deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (asUpperCamelCase label preserveAcronyms=true))}} = {{asHex mask}}, {{#*inline "oldNameItemDecl"}} {{#if oldItemName}} - {{objCEnumName ../clusterName ../bitmapName}}{{objCEnumItemLabel oldItemName}} {{availability ../clusterName bitmap=../enumName bitmapValue=oldItemName deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (objCEnumItemLabel label))}} = {{asHex value 2}}, + {{objCEnumName ../clusterName ../bitmapName}}{{objCEnumItemLabel oldItemName}} {{availability ../clusterName bitmap=../bitmapName bitmapValue=oldItemName deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (asUpperCamelCase label preserveAcronyms=true))}} = {{asHex mask}}, {{/if}} {{/inline}} - {{> oldNameItemDecl oldItemName=(oldName ../clusterName bitmap=../bitmapName bitmapValue=(objCEnumItemLabel label))}} + {{> oldNameItemDecl oldItemName=(oldName ../clusterName bitmap=../bitmapName bitmapValue=(asUpperCamelCase label preserveAcronyms=true))}} {{/zcl_bitmap_items}} } {{/inline}} diff --git a/src/darwin/Framework/CHIP/templates/availability.yaml b/src/darwin/Framework/CHIP/templates/availability.yaml index 010bddd35779d5..79510e723f9877 100644 --- a/src/darwin/Framework/CHIP/templates/availability.yaml +++ b/src/darwin/Framework/CHIP/templates/availability.yaml @@ -5043,6 +5043,10 @@ - ShutDown - Leave - ReachableChanged + PowerSource: + - WiredFaultChange + - BatFaultChange + - BatChargeFaultChange event fields: Switch: MultiPressComplete: @@ -5078,6 +5082,16 @@ - fabricIndex ReachableChanged: - reachableNewValue + PowerSource: + WiredFaultChange: + - current + - previous + BatFaultChange: + - current + - previous + BatChargeFaultChange: + - current + - previous enums: OTASoftwareUpdateProvider: - OTAApplyUpdateAction @@ -5149,6 +5163,9 @@ - PASE - CASE - Group + PowerSource: + BatChargeLevel: + - OK bitmaps: UnitTesting: - Bitmap8MaskMap @@ -5188,6 +5205,12 @@ LevelControlOptions: - ExecuteIfOff - CoupleColorTempToLevel + NetworkCommissioning: + WiFiSecurity: + - WEP + - WPAPersonal + - WPA2Personal + - WPA3Personal deprecated: clusters: - OtaSoftwareUpdateProvider @@ -5229,6 +5252,10 @@ AccessControl: - AccessControlEntry - ExtensionEntry + PowerSource: + - WiredFaultChangeType + - BatFaultChangeType + - BatChargeFaultChangeType struct fields: Descriptor: DeviceTypeStruct: @@ -5245,6 +5272,16 @@ GeneralCommissioning: CommissioningError: - Ok + PowerSource: + BatChargeLevel: + - Ok + bitmap values: + NetworkCommissioning: + WiFiSecurity: + - WepPersonal + - WpaPersonal + - Wpa2Personal + - Wpa3Personal apis: - Timed Invoke for server to client commands - Deprecated global attribute names @@ -5320,3 +5357,13 @@ GeneralCommissioning: CommissioningError: OK: Ok + PowerSource: + BatChargeLevel: + OK: Ok + bitmap values: + NetworkCommissioning: + WiFiSecurity: + WEP: WepPersonal + WPAPersonal: WpaPersonal + WPA2Personal: Wpa2Personal + WPA3Personal: Wpa3Personal diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h index c433a209131c12..0934f592496b57 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h @@ -17416,7 +17416,10 @@ typedef NS_ENUM(uint8_t, MTRPowerSourceBatChargeFault) { } API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); typedef NS_ENUM(uint8_t, MTRPowerSourceBatChargeLevel) { - MTRPowerSourceBatChargeLevelOk API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x00, + MTRPowerSourceBatChargeLevelOK MTR_NEWLY_AVAILABLE = 0x00, + MTRPowerSourceBatChargeLevelOk API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRPowerSourceBatChargeLevelOK") + = 0x00, MTRPowerSourceBatChargeLevelWarning API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x01, MTRPowerSourceBatChargeLevelCritical API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x02, } API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); @@ -17519,10 +17522,22 @@ typedef NS_OPTIONS(uint32_t, MTRNetworkCommissioningFeature) { typedef NS_OPTIONS(uint8_t, MTRNetworkCommissioningWiFiSecurity) { MTRNetworkCommissioningWiFiSecurityUnencrypted API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x1, - MTRNetworkCommissioningWiFiSecurityWepPersonal API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x2, - MTRNetworkCommissioningWiFiSecurityWpaPersonal API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x4, - MTRNetworkCommissioningWiFiSecurityWpa2Personal API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x8, - MTRNetworkCommissioningWiFiSecurityWpa3Personal API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) = 0x10, + MTRNetworkCommissioningWiFiSecurityWEP MTR_NEWLY_AVAILABLE = 0x2, + MTRNetworkCommissioningWiFiSecurityWepPersonal API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRNetworkCommissioningWiFiSecurityWEP") + = 0x2, + MTRNetworkCommissioningWiFiSecurityWPAPersonal MTR_NEWLY_AVAILABLE = 0x4, + MTRNetworkCommissioningWiFiSecurityWpaPersonal API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRNetworkCommissioningWiFiSecurityWPAPersonal") + = 0x4, + MTRNetworkCommissioningWiFiSecurityWPA2Personal MTR_NEWLY_AVAILABLE = 0x8, + MTRNetworkCommissioningWiFiSecurityWpa2Personal API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRNetworkCommissioningWiFiSecurityWPA2Personal") + = 0x8, + MTRNetworkCommissioningWiFiSecurityWPA3Personal MTR_NEWLY_AVAILABLE = 0x10, + MTRNetworkCommissioningWiFiSecurityWpa3Personal API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRNetworkCommissioningWiFiSecurityWPA3Personal") + = 0x10, } API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); typedef NS_ENUM(uint8_t, MTRDiagnosticLogsLogsIntent) { diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h index 53942f6a40012c..bdc6ae0152ada0 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h @@ -6821,6 +6821,13 @@ typedef NS_ENUM(uint32_t, MTREventIDType) { MTREventIDTypeClusterOTASoftwareUpdateRequestorEventVersionAppliedID MTR_NEWLY_AVAILABLE = 0x00000001, MTREventIDTypeClusterOTASoftwareUpdateRequestorEventDownloadErrorID MTR_NEWLY_AVAILABLE = 0x00000002, + // Cluster PowerSource deprecated event names + + // Cluster PowerSource events + MTREventIDTypeClusterPowerSourceEventWiredFaultChangeID MTR_NEWLY_AVAILABLE = 0x00000000, + MTREventIDTypeClusterPowerSourceEventBatFaultChangeID MTR_NEWLY_AVAILABLE = 0x00000001, + MTREventIDTypeClusterPowerSourceEventBatChargeFaultChangeID MTR_NEWLY_AVAILABLE = 0x00000002, + // Cluster GeneralDiagnostics deprecated event names MTRClusterGeneralDiagnosticsEventHardwareFaultChangeID API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) MTR_NEWLY_DEPRECATED("Please use MTREventIDTypeClusterGeneralDiagnosticsEventHardwareFaultChangeID") diff --git a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm index 8e5f792ae28582..a2fa781704a557 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm @@ -610,6 +610,165 @@ id MTRDecodeEventPayload(const ConcreteEventPath & aPath, TLV::TLVReader & aRead using namespace Clusters::PowerSource; switch (aPath.mEventId) { + case Events::WiredFaultChange::Id: { + Events::WiredFaultChange::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + + __auto_type * value = [MTRPowerSourceClusterWiredFaultChangeEvent new]; + + do { + NSArray * _Nonnull memberValue; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = cppValue.current.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0)]; + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + memberValue = array_0; + } + value.current = memberValue; + } while (0); + do { + NSArray * _Nonnull memberValue; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = cppValue.previous.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0)]; + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + memberValue = array_0; + } + value.previous = memberValue; + } while (0); + + return value; + } + + case Events::BatFaultChange::Id: { + Events::BatFaultChange::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + + __auto_type * value = [MTRPowerSourceClusterBatFaultChangeEvent new]; + + do { + NSArray * _Nonnull memberValue; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = cppValue.current.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0)]; + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + memberValue = array_0; + } + value.current = memberValue; + } while (0); + do { + NSArray * _Nonnull memberValue; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = cppValue.previous.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0)]; + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + memberValue = array_0; + } + value.previous = memberValue; + } while (0); + + return value; + } + + case Events::BatChargeFaultChange::Id: { + Events::BatChargeFaultChange::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + + __auto_type * value = [MTRPowerSourceClusterBatChargeFaultChangeEvent new]; + + do { + NSArray * _Nonnull memberValue; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = cppValue.current.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0)]; + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + memberValue = array_0; + } + value.current = memberValue; + } while (0); + do { + NSArray * _Nonnull memberValue; + { // Scope for our temporary variables + auto * array_0 = [NSMutableArray new]; + auto iter_0 = cppValue.previous.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + NSNumber * newElement_0; + newElement_0 = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0)]; + [array_0 addObject:newElement_0]; + } + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + memberValue = array_0; + } + value.previous = memberValue; + } while (0); + + return value; + } + default: *aError = CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB; break; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h index e67a9749c7bda0..9c5aa2ee441931 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h @@ -239,21 +239,48 @@ MTR_NEWLY_DEPRECATED("Please use MTROTASoftwareUpdateRequestorClusterDownloadErr @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) +MTR_NEWLY_DEPRECATED("This struct is unused and will be removed") @interface MTRPowerSourceClusterBatChargeFaultChangeType : NSObject -@property (nonatomic, copy) NSArray * _Nonnull current API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); -@property (nonatomic, copy) NSArray * _Nonnull previous API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); +@property (nonatomic, copy) NSArray * _Nonnull current API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRPowerSourceClusterBatChargeFaultChangeType"); +@property (nonatomic, copy) NSArray * _Nonnull previous API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRPowerSourceClusterBatChargeFaultChangeType"); @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) +MTR_NEWLY_DEPRECATED("This struct is unused and will be removed") @interface MTRPowerSourceClusterBatFaultChangeType : NSObject -@property (nonatomic, copy) NSArray * _Nonnull current API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); -@property (nonatomic, copy) NSArray * _Nonnull previous API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); +@property (nonatomic, copy) NSArray * _Nonnull current API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRPowerSourceClusterBatFaultChangeType"); +@property (nonatomic, copy) NSArray * _Nonnull previous API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRPowerSourceClusterBatFaultChangeType"); @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) +MTR_NEWLY_DEPRECATED("This struct is unused and will be removed") @interface MTRPowerSourceClusterWiredFaultChangeType : NSObject -@property (nonatomic, copy) NSArray * _Nonnull current API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); -@property (nonatomic, copy) NSArray * _Nonnull previous API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); +@property (nonatomic, copy) NSArray * _Nonnull current API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRPowerSourceClusterWiredFaultChangeType"); +@property (nonatomic, copy) NSArray * _Nonnull previous API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) + MTR_NEWLY_DEPRECATED("Please use MTRPowerSourceClusterWiredFaultChangeType"); +@end + +MTR_NEWLY_AVAILABLE +@interface MTRPowerSourceClusterWiredFaultChangeEvent : NSObject +@property (nonatomic, copy) NSArray * _Nonnull current MTR_NEWLY_AVAILABLE; +@property (nonatomic, copy) NSArray * _Nonnull previous MTR_NEWLY_AVAILABLE; +@end + +MTR_NEWLY_AVAILABLE +@interface MTRPowerSourceClusterBatFaultChangeEvent : NSObject +@property (nonatomic, copy) NSArray * _Nonnull current MTR_NEWLY_AVAILABLE; +@property (nonatomic, copy) NSArray * _Nonnull previous MTR_NEWLY_AVAILABLE; +@end + +MTR_NEWLY_AVAILABLE +@interface MTRPowerSourceClusterBatChargeFaultChangeEvent : NSObject +@property (nonatomic, copy) NSArray * _Nonnull current MTR_NEWLY_AVAILABLE; +@property (nonatomic, copy) NSArray * _Nonnull previous MTR_NEWLY_AVAILABLE; @end API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm index 178783a5a2d40e..bdb39bf37da445 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm @@ -910,6 +910,99 @@ - (NSString *)description @end +@implementation MTRPowerSourceClusterWiredFaultChangeEvent +- (instancetype)init +{ + if (self = [super init]) { + + _current = [NSArray array]; + + _previous = [NSArray array]; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRPowerSourceClusterWiredFaultChangeEvent alloc] init]; + + other.current = self.current; + other.previous = self.previous; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = + [NSString stringWithFormat:@"<%@: current:%@; previous:%@; >", NSStringFromClass([self class]), _current, _previous]; + return descriptionString; +} + +@end + +@implementation MTRPowerSourceClusterBatFaultChangeEvent +- (instancetype)init +{ + if (self = [super init]) { + + _current = [NSArray array]; + + _previous = [NSArray array]; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRPowerSourceClusterBatFaultChangeEvent alloc] init]; + + other.current = self.current; + other.previous = self.previous; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = + [NSString stringWithFormat:@"<%@: current:%@; previous:%@; >", NSStringFromClass([self class]), _current, _previous]; + return descriptionString; +} + +@end + +@implementation MTRPowerSourceClusterBatChargeFaultChangeEvent +- (instancetype)init +{ + if (self = [super init]) { + + _current = [NSArray array]; + + _previous = [NSArray array]; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRPowerSourceClusterBatChargeFaultChangeEvent alloc] init]; + + other.current = self.current; + other.previous = self.previous; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = + [NSString stringWithFormat:@"<%@: current:%@; previous:%@; >", NSStringFromClass([self class]), _current, _previous]; + return descriptionString; +} + +@end + @implementation MTRGeneralCommissioningClusterBasicCommissioningInfo - (instancetype)init { diff --git a/src/lib/core/CHIPTLVReader.cpp b/src/lib/core/CHIPTLVReader.cpp index 9a95a42779e9dc..5d175eb35b7108 100644 --- a/src/lib/core/CHIPTLVReader.cpp +++ b/src/lib/core/CHIPTLVReader.cpp @@ -749,7 +749,7 @@ CHIP_ERROR TLVReader::VerifyElement() } else { - if (mElemTag == UnknownImplicitTag) + if (mElemTag == UnknownImplicitTag()) return CHIP_ERROR_UNKNOWN_IMPLICIT_TLV_TAG; switch (mContainerType) { @@ -806,11 +806,11 @@ Tag TLVReader::ReadTag(TLVTagControl tagControl, const uint8_t *& p) const return CommonTag(LittleEndian::Read32(p)); case TLVTagControl::ImplicitProfile_2Bytes: if (ImplicitProfileId == kProfileIdNotSpecified) - return UnknownImplicitTag; + return UnknownImplicitTag(); return ProfileTag(ImplicitProfileId, LittleEndian::Read16(p)); case TLVTagControl::ImplicitProfile_4Bytes: if (ImplicitProfileId == kProfileIdNotSpecified) - return UnknownImplicitTag; + return UnknownImplicitTag(); return ProfileTag(ImplicitProfileId, LittleEndian::Read32(p)); case TLVTagControl::FullyQualified_6Bytes: vendorId = LittleEndian::Read16(p); diff --git a/src/lib/core/CHIPTLVTags.h b/src/lib/core/CHIPTLVTags.h index 12de1d9e3ef2e1..da8f91006fae48 100644 --- a/src/lib/core/CHIPTLVTags.h +++ b/src/lib/core/CHIPTLVTags.h @@ -29,12 +29,59 @@ namespace chip { namespace TLV { -struct Tag +class Tag { - explicit constexpr Tag(uint64_t val) : mVal(val) {} - Tag() {} +public: + enum SpecialTagNumber : uint32_t + { + kContextTagMaxNum = UINT8_MAX, + kAnonymousTagNum, + kUnknownImplicitTagNum + }; + + Tag() = default; + constexpr bool operator==(const Tag & other) const { return mVal == other.mVal; } constexpr bool operator!=(const Tag & other) const { return mVal != other.mVal; } + +private: + explicit constexpr Tag(uint64_t val) : mVal(val) {} + + friend constexpr Tag ProfileTag(uint32_t profileId, uint32_t tagNum); + friend constexpr Tag ProfileTag(uint16_t vendorId, uint16_t profileNum, uint32_t tagNum); + friend constexpr Tag ContextTag(uint8_t tagNum); + friend constexpr Tag CommonTag(uint32_t tagNum); + friend constexpr Tag AnonymousTag(); + friend constexpr Tag UnknownImplicitTag(); + + // The following friend functions could be Tag class methods, but it turns out in some cases + // they may not be inlined and then passing the tag by argument/value results in smaller code + // than passing it by 'this' pointer. This can be worked around by applying 'always_inline' + // function attribute, but friend functions are likely a more portable solution. + + friend constexpr uint32_t ProfileIdFromTag(Tag tag); + friend constexpr uint16_t VendorIdFromTag(Tag tag); + friend constexpr uint16_t ProfileNumFromTag(Tag tag); + friend constexpr uint32_t TagNumFromTag(Tag tag); + + friend constexpr bool IsProfileTag(Tag tag); + friend constexpr bool IsContextTag(Tag tag); + friend constexpr bool IsSpecialTag(Tag tag); + + static constexpr uint32_t kProfileIdShift = 32; + static constexpr uint32_t kVendorIdShift = 48; + static constexpr uint32_t kProfileNumShift = 32; + static constexpr uint32_t kSpecialTagProfileId = 0xFFFFFFFF; + + // The storage of the tag value uses the following encoding: + // + // 63 47 31 + // +-------------------------------+-------------------------------+----------------------------------------------+ + // | Vendor id (bitwise-negated) | Profile num (bitwise-negated) | Tag number | + // +-------------------------------+-------------------------------+----------------------------------------------+ + // + // Vendor id and profile number are bitwise-negated in order to optimize the code size when + // using context tags, the most commonly used tags in the SDK. uint64_t mVal; }; @@ -50,20 +97,6 @@ enum TLVCommonProfiles kCommonProfileId = 0 }; -// TODO: Move to private namespace -enum TLVTagFields -{ - kProfileIdMask = 0xFFFFFFFF00000000ULL, - kProfileNumMask = 0x0000FFFF00000000ULL, - kVendorIdMask = 0xFFFF000000000000ULL, - kProfileIdShift = 32, - kVendorIdShift = 48, - kProfileNumShift = 32, - kTagNumMask = 0x00000000FFFFFFFFULL, - kSpecialTagMarker = 0xFFFFFFFF00000000ULL, - kContextTagMaxNum = UINT8_MAX -}; - // TODO: Move to private namespace enum class TLVTagControl : uint8_t { @@ -99,9 +132,9 @@ enum * @param[in] tagNum The profile-specific tag number assigned to the tag. * @return A 64-bit integer representing the tag. */ -inline constexpr Tag ProfileTag(uint32_t profileId, uint32_t tagNum) +constexpr Tag ProfileTag(uint32_t profileId, uint32_t tagNum) { - return Tag(((static_cast(profileId)) << kProfileIdShift) | tagNum); + return Tag((static_cast(~profileId) << Tag::kProfileIdShift) | tagNum); } /** @@ -112,21 +145,22 @@ inline constexpr Tag ProfileTag(uint32_t profileId, uint32_t tagNum) * @param[in] tagNum The profile-specific tag number assigned to the tag. * @return A 64-bit integer representing the tag. */ -inline constexpr Tag ProfileTag(uint16_t vendorId, uint16_t profileNum, uint32_t tagNum) +constexpr Tag ProfileTag(uint16_t vendorId, uint16_t profileNum, uint32_t tagNum) { - return Tag(((static_cast(vendorId)) << kVendorIdShift) | ((static_cast(profileNum)) << kProfileNumShift) | - tagNum); + constexpr uint32_t kVendorIdShift = Tag::kVendorIdShift - Tag::kProfileIdShift; + + return ProfileTag((static_cast(vendorId) << kVendorIdShift) | profileNum, tagNum); } /** - * Generates the API representation for of context-specific TLV tag + * Generates the API representation of a context-specific TLV tag * * @param[in] tagNum The context-specific tag number assigned to the tag. * @return A 64-bit integer representing the tag. */ -inline constexpr Tag ContextTag(uint8_t tagNum) +constexpr Tag ContextTag(uint8_t tagNum) { - return Tag(kSpecialTagMarker | tagNum); + return ProfileTag(Tag::kSpecialTagProfileId, tagNum); } /** @@ -135,7 +169,7 @@ inline constexpr Tag ContextTag(uint8_t tagNum) * @param[in] tagNum The common profile tag number assigned to the tag. * @return A 64-bit integer representing the tag. */ -inline constexpr Tag CommonTag(uint32_t tagNum) +constexpr Tag CommonTag(uint32_t tagNum) { return ProfileTag(kCommonProfileId, tagNum); } @@ -143,12 +177,18 @@ inline constexpr Tag CommonTag(uint32_t tagNum) /** * A value signifying a TLV element that has no tag (i.e. an anonymous element). */ -inline constexpr Tag AnonymousTag() +constexpr Tag AnonymousTag() { - return Tag(kSpecialTagMarker | 0x00000000FFFFFFFFULL); + return ProfileTag(Tag::kSpecialTagProfileId, Tag::kAnonymousTagNum); +} + +/** + * An invalid tag that represents a TLV element decoding error due to unknown implicit profile id. + */ +constexpr Tag UnknownImplicitTag() +{ + return ProfileTag(Tag::kSpecialTagProfileId, Tag::kUnknownImplicitTagNum); } -// TODO: Move to private namespace -static constexpr Tag UnknownImplicitTag(kSpecialTagMarker | 0x00000000FFFFFFFEULL); /** * Returns the profile id from a TLV tag @@ -158,9 +198,24 @@ static constexpr Tag UnknownImplicitTag(kSpecialTagMarker | 0x00000000FFFFFFFEUL * @param[in] tag The API representation of a profile-specific TLV tag. * @return The profile id. */ -inline constexpr uint32_t ProfileIdFromTag(Tag tag) +constexpr uint32_t ProfileIdFromTag(Tag tag) +{ + return ~static_cast(tag.mVal >> Tag::kProfileIdShift); +} + +/** + * Returns the vendor id from a TLV tag + * + * @note The behavior of this function is undefined if the supplied tag is not a profile-specific tag. + * + * @param[in] tag The API representation of a profile-specific TLV tag. + * @return The associated vendor id. + */ +constexpr uint16_t VendorIdFromTag(Tag tag) { - return static_cast((tag.mVal & kProfileIdMask) >> kProfileIdShift); + constexpr uint32_t kVendorIdShift = Tag::kVendorIdShift - Tag::kProfileIdShift; + + return static_cast(ProfileIdFromTag(tag) >> kVendorIdShift); } /** @@ -171,9 +226,9 @@ inline constexpr uint32_t ProfileIdFromTag(Tag tag) * @param[in] tag The API representation of a profile-specific TLV tag. * @return The associated profile number. */ -inline constexpr uint16_t ProfileNumFromTag(Tag tag) +constexpr uint16_t ProfileNumFromTag(Tag tag) { - return static_cast((tag.mVal & kProfileNumMask) >> kProfileNumShift); + return static_cast(ProfileIdFromTag(tag)); } /** @@ -187,44 +242,31 @@ inline constexpr uint16_t ProfileNumFromTag(Tag tag) * @param[in] tag The API representation of a profile-specific or context-specific TLV tag. * @return The associated tag number. */ -inline constexpr uint32_t TagNumFromTag(Tag tag) -{ - return static_cast(tag.mVal & kTagNumMask); -} - -/** - * Returns the vendor id from a TLV tag - * - * @note The behavior of this function is undefined if the supplied tag is not a profile-specific tag. - * - * @param[in] tag The API representation of a profile-specific TLV tag. - * @return The associated vendor id. - */ -inline constexpr uint16_t VendorIdFromTag(Tag tag) +constexpr uint32_t TagNumFromTag(Tag tag) { - return static_cast((tag.mVal & kVendorIdMask) >> kVendorIdShift); + return static_cast(tag.mVal); } /** * Returns true of the supplied tag is a profile-specific tag. */ -inline constexpr bool IsProfileTag(Tag tag) +constexpr bool IsProfileTag(Tag tag) { - return (tag.mVal & kProfileIdMask) != kSpecialTagMarker; + return ProfileIdFromTag(tag) != Tag::kSpecialTagProfileId; } /** * Returns true if the supplied tag is a context-specific tag. */ -inline constexpr bool IsContextTag(Tag tag) +constexpr bool IsContextTag(Tag tag) { - return (tag.mVal & kProfileIdMask) == kSpecialTagMarker && TagNumFromTag(tag) <= kContextTagMaxNum; + return ProfileIdFromTag(tag) == Tag::kSpecialTagProfileId && TagNumFromTag(tag) <= Tag::kContextTagMaxNum; } // TODO: move to private namespace -inline constexpr bool IsSpecialTag(Tag tag) +constexpr bool IsSpecialTag(Tag tag) { - return (tag.mVal & kProfileIdMask) == kSpecialTagMarker; + return ProfileIdFromTag(tag) == Tag::kSpecialTagProfileId; } } // namespace TLV diff --git a/src/lib/core/CHIPTLVWriter.cpp b/src/lib/core/CHIPTLVWriter.cpp index 3f9743e23464f4..8a1eb7021edb66 100644 --- a/src/lib/core/CHIPTLVWriter.cpp +++ b/src/lib/core/CHIPTLVWriter.cpp @@ -631,7 +631,7 @@ CHIP_ERROR TLVWriter::WriteElementHead(TLVElementType elemType, Tag tag, uint64_ if (IsSpecialTag(tag)) { - if (tagNum <= kContextTagMaxNum) + if (tagNum <= Tag::kContextTagMaxNum) { if (mContainerType != kTLVType_Structure && mContainerType != kTLVType_List) return CHIP_ERROR_INVALID_TLV_TAG; diff --git a/src/platform/Darwin/WiFi/NetworkCommissioningWiFiDriver.mm b/src/platform/Darwin/WiFi/NetworkCommissioningWiFiDriver.mm index 94a67373de41aa..a393e79996f9c9 100644 --- a/src/platform/Darwin/WiFi/NetworkCommissioningWiFiDriver.mm +++ b/src/platform/Darwin/WiFi/NetworkCommissioningWiFiDriver.mm @@ -93,7 +93,7 @@ WiFiSecurity GetWiFiSecurity(CWNetwork * network) } if ([network supportsSecurity:kCWSecurityWEP]) { - return WiFiSecurity::kWepPersonal; + return WiFiSecurity::kWep; } if ([network supportsSecurity:kCWSecurityWPAPersonal]) { diff --git a/src/platform/cc13x2_26x2/CC13X2_26X2Config.cpp b/src/platform/cc13x2_26x2/CC13X2_26X2Config.cpp index 9a9ea2dcd1268a..70abc0fc6f6812 100644 --- a/src/platform/cc13x2_26x2/CC13X2_26X2Config.cpp +++ b/src/platform/cc13x2_26x2/CC13X2_26X2Config.cpp @@ -44,61 +44,89 @@ namespace Internal { /* itemID and subID are limited to 10 bits, even though their types are uint16_t */ // Keys stored in the Chip-factory namespace -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_SerialNum = { { .systemID = kCC13X2_26X2ChipFactory_Sysid, - .itemID = 0x0001 } }; -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_MfrDeviceId = { { .systemID = kCC13X2_26X2ChipFactory_Sysid, - .itemID = 0x0002 } }; -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_MfrDeviceCert = { { .systemID = kCC13X2_26X2ChipFactory_Sysid, - .itemID = 0x0003 } }; -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_MfrDeviceICACerts = { { .systemID = kCC13X2_26X2ChipFactory_Sysid, - .itemID = 0x0004 } }; -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_MfrDevicePrivateKey = { { .systemID = kCC13X2_26X2ChipFactory_Sysid, - .itemID = 0x0005 } }; -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_HardwareVersion = { { .systemID = kCC13X2_26X2ChipFactory_Sysid, - .itemID = 0x0006 } }; -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_ManufacturingDate = { { .systemID = kCC13X2_26X2ChipFactory_Sysid, - .itemID = 0x0007 } }; -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_SetupPinCode = { { .systemID = kCC13X2_26X2ChipFactory_Sysid, - .itemID = 0x0008 } }; -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_SetupDiscriminator = { { .systemID = kCC13X2_26X2ChipFactory_Sysid, - .itemID = 0x0009 } }; -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_Spake2pIterationCount = { { .systemID = kCC13X2_26X2ChipFactory_Sysid, - .itemID = 0x000a } }; -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_Spake2pSalt = { { .systemID = kCC13X2_26X2ChipFactory_Sysid, - .itemID = 0x000b } }; -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_Spake2pVerifier = { { .systemID = kCC13X2_26X2ChipFactory_Sysid, - .itemID = 0x000c } }; -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_BootCount = { { .systemID = kCC13X2_26X2ChipFactory_Sysid, - .itemID = 0x000d } }; -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_TotalOperationalHours = { { .systemID = kCC13X2_26X2ChipFactory_Sysid, - .itemID = 0x000f } }; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_SerialNum = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipFactory, .subID = 0x0001 } +}; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_MfrDeviceId = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipFactory, .subID = 0x0002 } +}; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_MfrDeviceCert = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipFactory, .subID = 0x0003 } +}; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_MfrDeviceICACerts = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipFactory, .subID = 0x0004 } +}; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_MfrDevicePrivateKey = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipFactory, .subID = 0x0005 } +}; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_HardwareVersion = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipFactory, .subID = 0x0006 } +}; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_ManufacturingDate = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipFactory, .subID = 0x0007 } +}; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_SetupPinCode = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipFactory, .subID = 0x0008 } +}; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_SetupDiscriminator = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipFactory, .subID = 0x0009 } +}; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_Spake2pIterationCount = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipFactory, .subID = 0x000a } +}; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_Spake2pSalt = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipFactory, .subID = 0x000b } +}; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_Spake2pVerifier = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipFactory, .subID = 0x000c } +}; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_LifeTimeCounter = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipFactory, .subID = 0x0010 } +}; + +// Keys stored in the Chip-counters namespace +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_BootCount = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipCounters, .subID = 0x000d } +}; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_TotalOperationalHours = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipCounters, .subID = 0x000f } +}; // Keys stored in the Chip-config namespace -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_ServiceConfig = { { .systemID = kCC13X2_26X2ChipConfig_Sysid, - .itemID = 0x0012 } }; -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_PairedAccountId = { { .systemID = kCC13X2_26X2ChipConfig_Sysid, - .itemID = 0x0013 } }; -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_ServiceId = { { .systemID = kCC13X2_26X2ChipConfig_Sysid, - .itemID = 0x0014 } }; -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_LastUsedEpochKeyId = { { .systemID = kCC13X2_26X2ChipConfig_Sysid, - .itemID = 0x0017 } }; -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_FailSafeArmed = { { .systemID = kCC13X2_26X2ChipConfig_Sysid, - .itemID = 0x0018 } }; -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_WiFiStationSecType = { { .systemID = kCC13X2_26X2ChipConfig_Sysid, - .itemID = 0x0019 } }; -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_RegulatoryLocation = { { .systemID = kCC13X2_26X2ChipConfig_Sysid, - .itemID = 0x001a } }; -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_CountryCode = { { .systemID = kCC13X2_26X2ChipConfig_Sysid, - .itemID = 0x001b } }; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_ServiceConfig = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipConfig, .subID = 0x0012 } +}; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_PairedAccountId = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipConfig, .subID = 0x0013 } +}; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_ServiceId = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipConfig, .subID = 0x0014 } +}; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_LastUsedEpochKeyId = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipConfig, .subID = 0x00017 } +}; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_FailSafeArmed = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipConfig, .subID = 0x00018 } +}; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_WiFiStationSecType = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipConfig, .subID = 0x00019 } +}; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_RegulatoryLocation = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipConfig, .subID = 0x0001a } +}; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_CountryCode = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipConfig, .subID = 0x0001b } +}; // itemID 0x001c is unused (used to be breadcrumb). -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_UniqueId = { { .systemID = kCC13X2_26X2ChipConfig_Sysid, - .itemID = 0x001d } }; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_UniqueId = { + { .systemID = kCC13X2_26X2Matter_SysID, .itemID = kCC13X2_26X2Matter_ItemID_ChipConfig, .subID = 0x0001d } +}; /* Internal for the KVS interface. */ -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_KVS_key = { { .systemID = kCC13X2_26X2ChipFactory_Sysid, - .itemID = 0x001d } }; -const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_KVS_value = { { .systemID = kCC13X2_26X2ChipFactory_Sysid, - .itemID = 0x001e } }; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_KVS_key = { { .systemID = kCC13X2_26X2Matter_SysID, + .itemID = kCC13X2_26X2Matter_ItemID_ChipKVS_key } }; +const CC13X2_26X2Config::Key CC13X2_26X2Config::kConfigKey_KVS_value = { { .systemID = kCC13X2_26X2Matter_SysID, + .itemID = kCC13X2_26X2Matter_ItemID_ChipKVS_value } }; /* Static local variables */ static NVINTF_nvFuncts_t sNvoctpFps = { 0 }; @@ -389,43 +417,62 @@ CHIP_ERROR CC13X2_26X2Config::FactoryResetConfig(void) NVINTF_nvProxy_t nvProxy = { 0 }; uint8_t status = NVINTF_SUCCESS; + // Delete items with the config, counter, kvs_key and kvs_value itemIDs. Items with the factory + // itemIDs are not deleted. + intptr_t key = sNvoctpFps.lockNV(); /* Setup doNext call */ - nvProxy.sysid = kCC13X2_26X2ChipConfig_Sysid; - nvProxy.flag = NVINTF_DOSTART | NVINTF_DOSYSID | NVINTF_DODELETE; + nvProxy.sysid = kCC13X2_26X2Matter_SysID; + nvProxy.itemid = kCC13X2_26X2Matter_ItemID_ChipConfig; + nvProxy.flag = NVINTF_DOSTART | NVINTF_DOITMID | NVINTF_DODELETE; - /* Lock and wipe all items with sysid TIOP */ + /* Lock and wipe all items with config itemid */ do { status = sNvoctpFps.doNext(&nvProxy); } while (NVINTF_SUCCESS == status); /* check we ran out of elements */ - VerifyOrExit(status != NVINTF_NOTFOUND, err = CHIP_ERROR_PERSISTED_STORAGE_FAILED); + VerifyOrExit(status == NVINTF_NOTFOUND, err = CHIP_ERROR_PERSISTED_STORAGE_FAILED); - /* Setup doNext call. Sysid is the same here, but it doesn't necessarily have to be. Matching POSIX impl */ - nvProxy.sysid = kCC13X2_26X2ChipFactory_Sysid; - nvProxy.flag = NVINTF_DOSTART | NVINTF_DOSYSID | NVINTF_DODELETE; + /* Setup doNext call */ + nvProxy.sysid = kCC13X2_26X2Matter_SysID; + nvProxy.itemid = kCC13X2_26X2Matter_ItemID_ChipCounters; + nvProxy.flag = NVINTF_DOSTART | NVINTF_DOITMID | NVINTF_DODELETE; - /* Lock and wipe all items with sysid TIOP */ + /* Lock and wipe all items with counters itemid */ do { status = sNvoctpFps.doNext(&nvProxy); } while (NVINTF_SUCCESS == status); /* check we ran out of elements */ - VerifyOrExit(status != NVINTF_NOTFOUND, err = CHIP_ERROR_PERSISTED_STORAGE_FAILED); + VerifyOrExit(status == NVINTF_NOTFOUND, err = CHIP_ERROR_PERSISTED_STORAGE_FAILED); + + /* Setup doNext call */ + nvProxy.sysid = kCC13X2_26X2Matter_SysID; + nvProxy.itemid = kCC13X2_26X2Matter_ItemID_ChipKVS_key; + nvProxy.flag = NVINTF_DOSTART | NVINTF_DOITMID | NVINTF_DODELETE; - /* Setup doNext call. Sysid is the same here, but it doesn't necessarily have to be. Matching POSIX impl */ - nvProxy.sysid = kCC13X2_26X2ChipCounters_Sysid; - nvProxy.flag = NVINTF_DOSTART | NVINTF_DOSYSID | NVINTF_DODELETE; + /* Lock and wipe all items with kvs_key itemid */ + do + { + status = sNvoctpFps.doNext(&nvProxy); + } while (NVINTF_SUCCESS == status); + /* check we ran out of elements */ + VerifyOrExit(status == NVINTF_NOTFOUND, err = CHIP_ERROR_PERSISTED_STORAGE_FAILED); + + /* Setup doNext call */ + nvProxy.sysid = kCC13X2_26X2Matter_SysID; + nvProxy.itemid = kCC13X2_26X2Matter_ItemID_ChipKVS_value; + nvProxy.flag = NVINTF_DOSTART | NVINTF_DOITMID | NVINTF_DODELETE; - /* Lock and wipe all items with sysid TIOP */ + /* Lock and wipe all items with key_value itemid */ do { status = sNvoctpFps.doNext(&nvProxy); } while (NVINTF_SUCCESS == status); /* check we ran out of elements */ - VerifyOrExit(status != NVINTF_NOTFOUND, err = CHIP_ERROR_PERSISTED_STORAGE_FAILED); + VerifyOrExit(status == NVINTF_NOTFOUND, err = CHIP_ERROR_PERSISTED_STORAGE_FAILED); exit: sNvoctpFps.unlockNV(key); diff --git a/src/platform/cc13x2_26x2/CC13X2_26X2Config.h b/src/platform/cc13x2_26x2/CC13X2_26X2Config.h index 1c4bbfd5059256..f3e8191aeca011 100644 --- a/src/platform/cc13x2_26x2/CC13X2_26X2Config.h +++ b/src/platform/cc13x2_26x2/CC13X2_26X2Config.h @@ -38,11 +38,21 @@ class CC13X2_26X2Config struct Key; // TODO: Define a proper system ID in upstream driver - static constexpr uint16_t kNvinf_sysid_chip = (13); + static constexpr uint16_t kNvinf_sysid_chip = 13; - static const uint16_t kCC13X2_26X2ChipConfig_Sysid = kNvinf_sysid_chip; - static const uint16_t kCC13X2_26X2ChipFactory_Sysid = kNvinf_sysid_chip; - static const uint16_t kCC13X2_26X2ChipCounters_Sysid = kNvinf_sysid_chip; + static constexpr uint16_t kNVinf_itemid_chipConfig = 1; + static constexpr uint16_t kNVinf_itemid_chipFactory = 2; + static constexpr uint16_t kNVinf_itemid_chipCounters = 3; + static constexpr uint16_t kNVinf_itemid_chipKVS_key = 4; + static constexpr uint16_t kNVinf_itemid_chipKVS_value = 5; + + static const uint16_t kCC13X2_26X2Matter_SysID = kNvinf_sysid_chip; + + static const uint16_t kCC13X2_26X2Matter_ItemID_ChipConfig = kNVinf_itemid_chipConfig; + static const uint16_t kCC13X2_26X2Matter_ItemID_ChipFactory = kNVinf_itemid_chipFactory; + static const uint16_t kCC13X2_26X2Matter_ItemID_ChipCounters = kNVinf_itemid_chipCounters; + static const uint16_t kCC13X2_26X2Matter_ItemID_ChipKVS_key = kNVinf_itemid_chipKVS_key; + static const uint16_t kCC13X2_26X2Matter_ItemID_ChipKVS_value = kNVinf_itemid_chipKVS_value; // Key definitions for well-known keys. static const Key kConfigKey_SerialNum; @@ -70,6 +80,7 @@ class CC13X2_26X2Config static const Key kConfigKey_Spake2pVerifier; static const Key kConfigKey_BootCount; static const Key kConfigKey_TotalOperationalHours; + static const Key kConfigKey_LifeTimeCounter; static CHIP_ERROR Init(void); diff --git a/src/platform/cc13x2_26x2/ConfigurationManagerImpl.cpp b/src/platform/cc13x2_26x2/ConfigurationManagerImpl.cpp index 91b6e42f4d4991..7d420bab1c93e2 100644 --- a/src/platform/cc13x2_26x2/ConfigurationManagerImpl.cpp +++ b/src/platform/cc13x2_26x2/ConfigurationManagerImpl.cpp @@ -126,7 +126,7 @@ CHIP_ERROR ConfigurationManagerImpl::StoreTotalOperationalHours(uint32_t totalOp CHIP_ERROR ConfigurationManagerImpl::ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t & value) { - CC13X2_26X2Config::Key configKey{ { CC13X2_26X2Config::kCC13X2_26X2ChipCounters_Sysid, key } }; + CC13X2_26X2Config::Key configKey{ { CC13X2_26X2Config::kCC13X2_26X2Matter_SysID, key } }; CHIP_ERROR err = ReadConfigValue(configKey, value); if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) @@ -138,7 +138,7 @@ CHIP_ERROR ConfigurationManagerImpl::ReadPersistedStorageValue(::chip::Platform: CHIP_ERROR ConfigurationManagerImpl::WritePersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t value) { - CC13X2_26X2Config::Key configKey{ { CC13X2_26X2Config::kCC13X2_26X2ChipCounters_Sysid, key } }; + CC13X2_26X2Config::Key configKey{ { CC13X2_26X2Config::kCC13X2_26X2Matter_SysID, key } }; return WriteConfigValue(configKey, value); } diff --git a/src/platform/nrfconnect/FactoryDataParser.c b/src/platform/nrfconnect/FactoryDataParser.c index 64f412e7562bcd..19601887175bd6 100644 --- a/src/platform/nrfconnect/FactoryDataParser.c +++ b/src/platform/nrfconnect/FactoryDataParser.c @@ -40,6 +40,77 @@ static inline bool uint16_decode(zcbor_state_t * states, uint16_t * value) return false; } +static bool DecodeEntry(zcbor_state_t * states, void * buffer, size_t bufferSize, size_t * outlen) +{ + struct zcbor_string tempString; + int32_t tempInt = 0; + + // Try to decode entry as string + bool res = zcbor_tstr_decode(states, &tempString); + if (res) + { + if (bufferSize < tempString.len) + { + return false; + } + memcpy(buffer, tempString.value, tempString.len); + *outlen = tempString.len; + return res; + } + + // Try to decode entry as int32 + res = zcbor_int32_decode(states, &tempInt); + if (res) + { + if (bufferSize < sizeof(tempInt)) + { + return false; + } + memcpy(buffer, &tempInt, sizeof(tempInt)); + *outlen = sizeof(tempInt); + return res; + } + + return res; +} + +bool FindUserDataEntry(struct FactoryData * factoryData, const char * entry, void * buffer, size_t bufferSize, size_t * outlen) +{ + if ((!factoryData) || (!factoryData->user.data) || (!buffer) || (!outlen)) + { + return false; + } + + ZCBOR_STATE_D(states, MAX_FACTORY_DATA_NESTING_LEVEL - 1, factoryData->user.data, factoryData->user.len, 1); + + bool res = zcbor_map_start_decode(states); + bool keyFound = false; + struct zcbor_string currentString; + + while (res) + { + res = zcbor_tstr_decode(states, ¤tString); + + if (!res) + { + break; + } + + if (strncmp(entry, (const char *) currentString.value, currentString.len) == 0) + { + res = DecodeEntry(states, buffer, bufferSize, outlen); + keyFound = true; + break; + } + else + { + res = res && zcbor_any_skip(states, NULL); + } + } + + return res && keyFound && zcbor_list_map_end_force_decode(states); +} + bool ParseFactoryData(uint8_t * buffer, uint16_t bufferSize, struct FactoryData * factoryData) { memset(factoryData, 0, sizeof(*factoryData)); @@ -167,7 +238,9 @@ bool ParseFactoryData(uint8_t * buffer, uint16_t bufferSize, struct FactoryData } else if (strncmp("user", (const char *) currentString.value, currentString.len) == 0) { - res = res && zcbor_bstr_decode(states, (struct zcbor_string *) &factoryData->user); + factoryData->user.data = (void *) states->payload; + res = res && zcbor_any_skip(states, NULL); + factoryData->user.len = (void *) states->payload - factoryData->user.data; } else { diff --git a/src/platform/nrfconnect/FactoryDataParser.h b/src/platform/nrfconnect/FactoryDataParser.h index 9c87589560d469..b600371dde96ee 100644 --- a/src/platform/nrfconnect/FactoryDataParser.h +++ b/src/platform/nrfconnect/FactoryDataParser.h @@ -76,6 +76,20 @@ struct FactoryData */ bool ParseFactoryData(uint8_t * buffer, uint16_t bufferSize, struct FactoryData * factoryData); +/** + * @brief Tries to find an entry within the given factory data user data field. + * The parser parses only the uint32 type of ints. To read int-related objects the buffer size must be aligned to uint32. + * That means, to obtain uint8 or uint16 value users should provide the buffer with size at least sizeof(uint32_t). + * + * @param factoryData An address of object of factory data that contains user field filled. + * @param entry An entry name to be find out. + * @param buffer Output buffer to store found key value. + * @param bufferSize Size of buffer. That size should have size at least equal to expected key value. + * @param outlen Actual size of found user data field. + * @return true on success, false otherwise + */ +bool FindUserDataEntry(struct FactoryData * factoryData, const char * entry, void * buffer, size_t bufferSize, size_t * outlen); + #ifdef __cplusplus } #endif diff --git a/src/platform/nrfconnect/FactoryDataProvider.cpp b/src/platform/nrfconnect/FactoryDataProvider.cpp index ed3fd939bb3f22..cd52046c6de4f8 100644 --- a/src/platform/nrfconnect/FactoryDataProvider.cpp +++ b/src/platform/nrfconnect/FactoryDataProvider.cpp @@ -339,6 +339,32 @@ CHIP_ERROR FactoryDataProvider::GetEnableKey(MutableByteSpan & return CHIP_NO_ERROR; } +template +CHIP_ERROR FactoryDataProvider::GetUserData(MutableByteSpan & userData) +{ + ReturnErrorCodeIf(!mFactoryData.user.data, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + ReturnErrorCodeIf(userData.size() < mFactoryData.user.len, CHIP_ERROR_BUFFER_TOO_SMALL); + + memcpy(userData.data(), mFactoryData.user.data, mFactoryData.user.len); + + userData.reduce_size(mFactoryData.user.len); + + return CHIP_NO_ERROR; +} + +template +CHIP_ERROR FactoryDataProvider::GetUserKey(const char * userKey, void * buf, size_t & len) +{ + ReturnErrorCodeIf(!mFactoryData.user.data, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + ReturnErrorCodeIf(!buf, CHIP_ERROR_BUFFER_TOO_SMALL); + + bool success = FindUserDataEntry(&mFactoryData, userKey, buf, len, &len); + + ReturnErrorCodeIf(!success, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + + return CHIP_NO_ERROR; +} + // Fully instantiate the template class in whatever compilation unit includes this file. template class FactoryDataProvider; template class FactoryDataProvider; diff --git a/src/platform/nrfconnect/FactoryDataProvider.h b/src/platform/nrfconnect/FactoryDataProvider.h index a7111acf66ee27..3d46076a5a3669 100644 --- a/src/platform/nrfconnect/FactoryDataProvider.h +++ b/src/platform/nrfconnect/FactoryDataProvider.h @@ -111,6 +111,28 @@ class FactoryDataProvider : public chip::Credentials::DeviceAttestationCredentia // ===== Members functions that are platform-specific CHIP_ERROR GetEnableKey(MutableByteSpan & enableKey); + /** + * @brief Get the user data in CBOR format as MutableByteSpan + * + * @param userData MutableByteSpan object to obtain all user data in CBOR format + * @returns + * CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND if factory data does not contain user field, or the value cannot be read out. + * CHIP_ERROR_BUFFER_TOO_SMALL if provided MutableByteSpan is too small + */ + CHIP_ERROR GetUserData(MutableByteSpan & userData); + + /** + * @brief Try to find user data key and return its value + * + * @param userKey A key name to be found + * @param buf Buffer to store value of found key + * @param len Length of the buffer. This value will be updated to the actual value if the key is read. + * @returns + * CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND if factory data does not contain user field, or the value cannot be read out. + * CHIP_ERROR_BUFFER_TOO_SMALL if provided buffer length is too small + */ + CHIP_ERROR GetUserKey(const char * userKey, void * buf, size_t & len); + private: static constexpr uint16_t kFactoryDataPartitionSize = PM_FACTORY_DATA_SIZE; static constexpr uint32_t kFactoryDataPartitionAddress = PM_FACTORY_DATA_ADDRESS; diff --git a/src/platform/silabs/EFR32/CHIPCryptoPALPsaEfr32.cpp b/src/platform/silabs/EFR32/CHIPCryptoPALPsaEfr32.cpp index bcf252a86754de..184da071eeddce 100644 --- a/src/platform/silabs/EFR32/CHIPCryptoPALPsaEfr32.cpp +++ b/src/platform/silabs/EFR32/CHIPCryptoPALPsaEfr32.cpp @@ -1875,5 +1875,82 @@ CHIP_ERROR ExtractVIDPIDFromX509Cert(const ByteSpan & certificate, AttestationCe return error; } +namespace { +#if defined(MBEDTLS_X509_CRT_PARSE_C) +CHIP_ERROR ExtractRawSubjectFromX509Cert(const ByteSpan & certificate, MutableByteSpan & subject) +{ + CHIP_ERROR error = CHIP_NO_ERROR; + int result = 0; + uint8_t * p = nullptr; + size_t len = 0; + mbedtls_x509_crt mbedCertificate; + + ReturnErrorCodeIf(certificate.empty(), CHIP_ERROR_INVALID_ARGUMENT); + + mbedtls_x509_crt_init(&mbedCertificate); + result = mbedtls_x509_crt_parse(&mbedCertificate, Uint8::to_const_uchar(certificate.data()), certificate.size()); + VerifyOrExit(result == 0, error = CHIP_ERROR_INTERNAL); + + len = mbedCertificate.CHIP_CRYPTO_PAL_PRIVATE_X509(subject_raw).CHIP_CRYPTO_PAL_PRIVATE_X509(len); + p = mbedCertificate.CHIP_CRYPTO_PAL_PRIVATE_X509(subject_raw).CHIP_CRYPTO_PAL_PRIVATE_X509(p); + + VerifyOrExit(len <= subject.size(), error = CHIP_ERROR_BUFFER_TOO_SMALL); + memcpy(subject.data(), p, len); + subject.reduce_size(len); + +exit: + _log_mbedTLS_error(result); + mbedtls_x509_crt_free(&mbedCertificate); + + return error; +} +#endif // defined(MBEDTLS_X509_CRT_PARSE_C) +} // namespace + +CHIP_ERROR ReplaceCertIfResignedCertFound(const ByteSpan & referenceCertificate, const ByteSpan * candidateCertificates, + size_t candidateCertificatesCount, ByteSpan & outCertificate) +{ +#if defined(MBEDTLS_X509_CRT_PARSE_C) + constexpr size_t kMaxCertificateSubjectLength = 150; + uint8_t referenceSubjectBuf[kMaxCertificateSubjectLength]; + uint8_t referenceSKIDBuf[kSubjectKeyIdentifierLength]; + MutableByteSpan referenceSubject(referenceSubjectBuf); + MutableByteSpan referenceSKID(referenceSKIDBuf); + + outCertificate = referenceCertificate; + + ReturnErrorCodeIf(candidateCertificates == nullptr || candidateCertificatesCount == 0, CHIP_NO_ERROR); + + ReturnErrorOnFailure(ExtractRawSubjectFromX509Cert(referenceCertificate, referenceSubject)); + ReturnErrorOnFailure(ExtractSKIDFromX509Cert(referenceCertificate, referenceSKID)); + + for (size_t i = 0; i < candidateCertificatesCount; i++) + { + const ByteSpan candidateCertificate = candidateCertificates[i]; + uint8_t candidateSubjectBuf[kMaxCertificateSubjectLength]; + uint8_t candidateSKIDBuf[kSubjectKeyIdentifierLength]; + MutableByteSpan candidateSubject(candidateSubjectBuf); + MutableByteSpan candidateSKID(candidateSKIDBuf); + + ReturnErrorOnFailure(ExtractRawSubjectFromX509Cert(candidateCertificate, candidateSubject)); + ReturnErrorOnFailure(ExtractSKIDFromX509Cert(candidateCertificate, candidateSKID)); + + if (referenceSKID.data_equal(candidateSKID) && referenceSubject.data_equal(candidateSubject)) + { + outCertificate = candidateCertificate; + return CHIP_NO_ERROR; + } + } + + return CHIP_NO_ERROR; +#else + (void) referenceCertificate; + (void) candidateCertificates; + (void) candidateCertificatesCount; + (void) outCertificate; + return CHIP_ERROR_NOT_IMPLEMENTED; +#endif // defined(MBEDTLS_X509_CRT_PARSE_C) +} + } // namespace Crypto } // namespace chip diff --git a/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp b/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp index b63d617befcec8..98af04b7319a2f 100644 --- a/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp +++ b/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp @@ -203,7 +203,7 @@ chip::BitFlags SlWiFiDriver::ConvertSecuritytype(uint8_t security) } else if (security & WFX_SEC_WEP) { - securityType = WiFiSecurity::kWepPersonal; + securityType = WiFiSecurity::kWep; } else if (security & WFX_SEC_WPA) { diff --git a/third_party/ameba/mbedtls.cmake b/third_party/ameba/mbedtls.cmake index 454358141d5df9..107e29a591df08 100755 --- a/third_party/ameba/mbedtls.cmake +++ b/third_party/ameba/mbedtls.cmake @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.6) project(mbedtls) -set(dir "${sdk_root}/component/common/network/ssl/mbedtls-matter") +set(dir "${sdk_root}/component/common/application/matter/mbedtls") set(dir_mbedtlschip "${ameba_matter_root}/third_party/mbedtls/repo/library") list( diff --git a/third_party/libwebsockets/BUILD.gn b/third_party/libwebsockets/BUILD.gn new file mode 100644 index 00000000000000..8e759cc4dc601f --- /dev/null +++ b/third_party/libwebsockets/BUILD.gn @@ -0,0 +1,109 @@ +# 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. + +config("libwebsockets_config") { + include_dirs = [ + ".", + "repo/include", + ] + + cflags = [ + "-Wno-shadow", + "-Wno-unreachable-code", + "-Wno-format-nonliteral", + ] + + defines = [] +} + +source_set("libwebsockets") { + include_dirs = [ + "repo/lib/plat/windows", + "repo/lib/plat/freertos", + "repo/lib/plat/unix", + "repo/lib/secure-streams", + "repo/lib/event-libs", + "repo/lib/roles", + "repo/lib/roles/http", + "repo/lib/roles/h1", + "repo/lib/roles/h2", + "repo/lib/roles/ws", + "repo/lib/system/metrics", + "repo/lib/system/smd", + "repo/lib/system/async-dns", + "repo/lib/core", + "repo/lib/core-net", + ] + + sources = [ + "repo/lib/core-net/adopt.c", + "repo/lib/core-net/close.c", + "repo/lib/core-net/dummy-callback.c", + "repo/lib/core-net/network.c", + "repo/lib/core-net/output.c", + "repo/lib/core-net/pollfd.c", + "repo/lib/core-net/service.c", + "repo/lib/core-net/sorted-usec-list.c", + "repo/lib/core-net/vhost.c", + "repo/lib/core-net/wsi-timeout.c", + "repo/lib/core-net/wsi.c", + "repo/lib/core/alloc.c", + "repo/lib/core/buflist.c", + "repo/lib/core/context.c", + "repo/lib/core/libwebsockets.c", + "repo/lib/core/logs.c", + "repo/lib/core/lws_dll2.c", + "repo/lib/event-libs/poll/poll.c", + "repo/lib/misc/base64-decode.c", + "repo/lib/misc/sha-1.c", + "repo/lib/roles/h1/ops-h1.c", + "repo/lib/roles/http/date.c", + "repo/lib/roles/http/header.c", + "repo/lib/roles/http/parsers.c", + "repo/lib/roles/http/server/server.c", + "repo/lib/roles/listen/ops-listen.c", + "repo/lib/roles/pipe/ops-pipe.c", + "repo/lib/roles/raw-skt/ops-raw-skt.c", + "repo/lib/roles/ws/ops-ws.c", + "repo/lib/roles/ws/server-ws.c", + "repo/lib/system/system.c", + ] + + if (current_os == "freertos") { + sources += [ + "repo/lib/plat/freertos/freertos-fds.c", + "repo/lib/plat/freertos/freertos-init.c", + "repo/lib/plat/freertos/freertos-misc.c", + "repo/lib/plat/freertos/freertos-pipe.c", + "repo/lib/plat/freertos/freertos-service.c", + "repo/lib/plat/freertos/freertos-sockets.c", + ] + + cflags = [ "-DLWS_PLAT_FREERTOS" ] + } else { + sources += [ + "repo/lib/plat/unix/unix-caps.c", + "repo/lib/plat/unix/unix-fds.c", + "repo/lib/plat/unix/unix-init.c", + "repo/lib/plat/unix/unix-misc.c", + "repo/lib/plat/unix/unix-pipe.c", + "repo/lib/plat/unix/unix-service.c", + "repo/lib/plat/unix/unix-sockets.c", + ] + + cflags = [ "-DLWS_PLAT_UNIX" ] + } + + public_configs = [ ":libwebsockets_config" ] +} diff --git a/third_party/libwebsockets/lws_config.h b/third_party/libwebsockets/lws_config.h new file mode 100644 index 00000000000000..96ddcf8a6db7d9 --- /dev/null +++ b/third_party/libwebsockets/lws_config.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * 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 + +#define LWS_LIBRARY_VERSION "4.3.99" + +// +// Major individual features +// +#define LWS_WITH_NETWORK // "Compile with network-related code" - default: ON +#define LWS_ROLE_H1 // "Compile with support for http/1 (needed for ws)" - default: ON +#define LWS_ROLE_WS // "Compile with support for websockets" - default: ON +#define LWS_WITH_IPV6 // "Compile with support for ipv6" - default: OFF +#define LWS_UNIX_SOCK // "Compile with support for UNIX domain socket if OS supports it" - default: ON + +// +// Client / Server / Test Apps build control +// +#define LWS_WITHOUT_CLIENT // "Don't build the client part of the library" default - OFF + +// +// Extensions (permessage-deflate) +// +#define LWS_WITHOUT_EXTENSIONS // "Don't compile with extensions" - default: ON + +// +// Helpers + misc +// +#define LWS_WITHOUT_DAEMONIZE // "Don't build the daemonization api" - default: ON +#define LWS_LOGS_TIMESTAMP // "Timestamp at start of logs" - default: ON +#define LWS_LOG_TAG_LIFECYCLE // "Log tagged object lifecycle as NOTICE" - default: ON + +// +// Implied Options +// +#define LWS_WITH_POLL +#define LWS_MAX_SMP 1 + +#ifdef LWS_WITHOUT_DAEMONIZE +#define LWS_NO_DAEMONIZE +#endif + +#ifdef LWS_WITH_HTTP2 +#define LWS_ROLE_H2 +#endif + +#ifndef LWS_WITHOUT_SERVER +#define LWS_WITH_SERVER +#endif diff --git a/third_party/libwebsockets/lws_config_private.h b/third_party/libwebsockets/lws_config_private.h new file mode 100644 index 00000000000000..468bba9a126d4f --- /dev/null +++ b/third_party/libwebsockets/lws_config_private.h @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * 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 diff --git a/third_party/libwebsockets/repo b/third_party/libwebsockets/repo new file mode 160000 index 00000000000000..ec6d5ac6d58d92 --- /dev/null +++ b/third_party/libwebsockets/repo @@ -0,0 +1 @@ +Subproject commit ec6d5ac6d58d92ac8c1a3d769d076cabd6aa4ac1 diff --git a/third_party/mbedtls/repo b/third_party/mbedtls/repo index 0e0793f4acffee..a6ad7f47023b23 160000 --- a/third_party/mbedtls/repo +++ b/third_party/mbedtls/repo @@ -1 +1 @@ -Subproject commit 0e0793f4acffee35bbb2764fa58f63d9e2693e4e +Subproject commit a6ad7f47023b235fc8d02c3f2bbb5d5277c2f20f diff --git a/third_party/openthread/repo b/third_party/openthread/repo index 98e644d538ff2c..f2c02dfd180df8 160000 --- a/third_party/openthread/repo +++ b/third_party/openthread/repo @@ -1 +1 @@ -Subproject commit 98e644d538ff2c57e96c54bdd6e13df31c7d19ba +Subproject commit f2c02dfd180df84dd8f4f02260cc5e12339ea563 diff --git a/third_party/pigweed/repo b/third_party/pigweed/repo index ead209d3aa0982..39f72204df9c95 160000 --- a/third_party/pigweed/repo +++ b/third_party/pigweed/repo @@ -1 +1 @@ -Subproject commit ead209d3aa09821aa7549fbc8665ae68fe88d16f +Subproject commit 39f72204df9c95c23d1ad4ee34274a116e6aedd7 diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h index c29a4d426ea87d..bb5cf6a6e78b5d 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h @@ -622,7 +622,7 @@ enum class NetworkCommissioningFeature : uint32_t enum class WiFiSecurity : uint8_t { kUnencrypted = 0x1, - kWepPersonal = 0x2, + kWep = 0x2, kWpaPersonal = 0x4, kWpa2Personal = 0x8, kWpa3Personal = 0x10, diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp index 448310efafe87c..2d1476bdf79ff7 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp @@ -5241,6 +5241,129 @@ CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const Concre } // namespace Attributes namespace Events { +namespace WiredFaultChange { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kCurrent)), current)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kPrevious)), previous)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + ReturnErrorOnFailure(reader.EnterContainer(outer)); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + if (!TLV::IsContextTag(reader.GetTag())) + { + continue; + } + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kCurrent): + ReturnErrorOnFailure(DataModel::Decode(reader, current)); + break; + case to_underlying(Fields::kPrevious): + ReturnErrorOnFailure(DataModel::Decode(reader, previous)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace WiredFaultChange. +namespace BatFaultChange { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kCurrent)), current)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kPrevious)), previous)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + ReturnErrorOnFailure(reader.EnterContainer(outer)); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + if (!TLV::IsContextTag(reader.GetTag())) + { + continue; + } + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kCurrent): + ReturnErrorOnFailure(DataModel::Decode(reader, current)); + break; + case to_underlying(Fields::kPrevious): + ReturnErrorOnFailure(DataModel::Decode(reader, previous)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace BatFaultChange. +namespace BatChargeFaultChange { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kCurrent)), current)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kPrevious)), previous)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + ReturnErrorOnFailure(reader.EnterContainer(outer)); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + if (!TLV::IsContextTag(reader.GetTag())) + { + continue; + } + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kCurrent): + ReturnErrorOnFailure(DataModel::Decode(reader, current)); + break; + case to_underlying(Fields::kPrevious): + ReturnErrorOnFailure(DataModel::Decode(reader, previous)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace BatChargeFaultChange. } // namespace Events } // namespace PowerSource diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h index f6707991e0dfed..d9a23bfe1012e6 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h @@ -6375,6 +6375,116 @@ struct TypeInfo }; }; } // namespace Attributes +namespace Events { +namespace WiredFaultChange { +static constexpr PriorityLevel kPriorityLevel = PriorityLevel::Info; + +enum class Fields +{ + kCurrent = 0, + kPrevious = 1, +}; + +struct Type +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::WiredFaultChange::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::PowerSource::Id; } + static constexpr bool kIsFabricScoped = false; + + DataModel::List current; + DataModel::List previous; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +struct DecodableType +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::WiredFaultChange::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::PowerSource::Id; } + + DataModel::DecodableList current; + DataModel::DecodableList previous; + + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +} // namespace WiredFaultChange +namespace BatFaultChange { +static constexpr PriorityLevel kPriorityLevel = PriorityLevel::Info; + +enum class Fields +{ + kCurrent = 0, + kPrevious = 1, +}; + +struct Type +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::BatFaultChange::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::PowerSource::Id; } + static constexpr bool kIsFabricScoped = false; + + DataModel::List current; + DataModel::List previous; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +struct DecodableType +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::BatFaultChange::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::PowerSource::Id; } + + DataModel::DecodableList current; + DataModel::DecodableList previous; + + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +} // namespace BatFaultChange +namespace BatChargeFaultChange { +static constexpr PriorityLevel kPriorityLevel = PriorityLevel::Info; + +enum class Fields +{ + kCurrent = 0, + kPrevious = 1, +}; + +struct Type +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::BatChargeFaultChange::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::PowerSource::Id; } + static constexpr bool kIsFabricScoped = false; + + DataModel::List current; + DataModel::List previous; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +struct DecodableType +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::BatChargeFaultChange::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::PowerSource::Id; } + + DataModel::DecodableList current; + DataModel::DecodableList previous; + + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +} // namespace BatChargeFaultChange +} // namespace Events } // namespace PowerSource namespace GeneralCommissioning { namespace Structs { diff --git a/zzz_generated/app-common/app-common/zap-generated/enums.h b/zzz_generated/app-common/app-common/zap-generated/enums.h index f2d3e87a8a3812..5e0312ef23de4c 100644 --- a/zzz_generated/app-common/app-common/zap-generated/enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/enums.h @@ -962,8 +962,8 @@ enum EmberAfWiFiVersionType : uint8_t #define EMBER_AF_WI_FI_NETWORK_DIAGNOSTICS_FEATURE_ERROR_COUNTS_OFFSET (1) #define EMBER_AF_WI_FI_SECURITY_UNENCRYPTED (1) #define EMBER_AF_WI_FI_SECURITY_UNENCRYPTED_OFFSET (0) -#define EMBER_AF_WI_FI_SECURITY_WEP_PERSONAL (2) -#define EMBER_AF_WI_FI_SECURITY_WEP_PERSONAL_OFFSET (1) +#define EMBER_AF_WI_FI_SECURITY_WEP (2) +#define EMBER_AF_WI_FI_SECURITY_WEP_OFFSET (1) #define EMBER_AF_WI_FI_SECURITY_WPA_PERSONAL (4) #define EMBER_AF_WI_FI_SECURITY_WPA_PERSONAL_OFFSET (2) #define EMBER_AF_WI_FI_SECURITY_WPA2_PERSONAL (8) diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Events.h b/zzz_generated/app-common/app-common/zap-generated/ids/Events.h index 8dbc9ea7a323fb..e885f58360f248 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Events.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Events.h @@ -93,6 +93,24 @@ static constexpr EventId Id = 0x00000002; } // namespace Events } // namespace OtaSoftwareUpdateRequestor +namespace PowerSource { +namespace Events { + +namespace WiredFaultChange { +static constexpr EventId Id = 0x00000000; +} // namespace WiredFaultChange + +namespace BatFaultChange { +static constexpr EventId Id = 0x00000001; +} // namespace BatFaultChange + +namespace BatChargeFaultChange { +static constexpr EventId Id = 0x00000002; +} // namespace BatChargeFaultChange + +} // namespace Events +} // namespace PowerSource + namespace GeneralDiagnostics { namespace Events { diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index 845ea56ff454f9..8fbfa60a3baa13 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -2175,6 +2175,9 @@ class OtaSoftwareUpdateRequestorAnnounceOTAProvider : public ClusterCommand | * ClusterRevision | 0xFFFD | |------------------------------------------------------------------------------| | Events: | | +| * WiredFaultChange | 0x0000 | +| * BatFaultChange | 0x0001 | +| * BatChargeFaultChange | 0x0002 | \*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*\ @@ -9402,8 +9405,14 @@ void registerClusterPowerSource(Commands & commands, CredentialIssuerCommands * // // Events // - make_unique(Id, credsIssuerConfig), // - make_unique(Id, credsIssuerConfig), // + make_unique(Id, credsIssuerConfig), // + make_unique(Id, "wired-fault-change", Events::WiredFaultChange::Id, credsIssuerConfig), // + make_unique(Id, "bat-fault-change", Events::BatFaultChange::Id, credsIssuerConfig), // + make_unique(Id, "bat-charge-fault-change", Events::BatChargeFaultChange::Id, credsIssuerConfig), // + make_unique(Id, credsIssuerConfig), // + make_unique(Id, "wired-fault-change", Events::WiredFaultChange::Id, credsIssuerConfig), // + make_unique(Id, "bat-fault-change", Events::BatFaultChange::Id, credsIssuerConfig), // + make_unique(Id, "bat-charge-fault-change", Events::BatChargeFaultChange::Id, credsIssuerConfig), // }; commands.Register(clusterName, clusterCommands); diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp index 15e1dc60dc5ba4..5e4ec741353506 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -2771,6 +2771,78 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const PowerSource::Events::WiredFaultChange::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = DataModelLogger::LogValue("Current", indent + 1, value.current); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Event truncated due to invalid value for 'Current'"); + return err; + } + } + { + CHIP_ERROR err = DataModelLogger::LogValue("Previous", indent + 1, value.previous); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Event truncated due to invalid value for 'Previous'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const PowerSource::Events::BatFaultChange::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = DataModelLogger::LogValue("Current", indent + 1, value.current); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Event truncated due to invalid value for 'Current'"); + return err; + } + } + { + CHIP_ERROR err = DataModelLogger::LogValue("Previous", indent + 1, value.previous); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Event truncated due to invalid value for 'Previous'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const PowerSource::Events::BatChargeFaultChange::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = DataModelLogger::LogValue("Current", indent + 1, value.current); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Event truncated due to invalid value for 'Current'"); + return err; + } + } + { + CHIP_ERROR err = DataModelLogger::LogValue("Previous", indent + 1, value.previous); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Event truncated due to invalid value for 'Previous'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const GeneralDiagnostics::Events::HardwareFaultChange::DecodableType & value) { @@ -10571,6 +10643,27 @@ CHIP_ERROR DataModelLogger::LogEvent(const chip::app::EventHeader & header, chip } break; } + case PowerSource::Id: { + switch (header.mPath.mEventId) + { + case PowerSource::Events::WiredFaultChange::Id: { + chip::app::Clusters::PowerSource::Events::WiredFaultChange::DecodableType value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("WiredFaultChange", 1, value); + } + case PowerSource::Events::BatFaultChange::Id: { + chip::app::Clusters::PowerSource::Events::BatFaultChange::DecodableType value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("BatFaultChange", 1, value); + } + case PowerSource::Events::BatChargeFaultChange::Id: { + chip::app::Clusters::PowerSource::Events::BatChargeFaultChange::DecodableType value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("BatChargeFaultChange", 1, value); + } + } + break; + } case GeneralDiagnostics::Id: { switch (header.mPath.mEventId) { diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h index 1683e2255b9d41..a3a71f6bc63a46 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h @@ -165,6 +165,12 @@ static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::OtaSoftwareUpdateRequestor::Events::VersionApplied::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::OtaSoftwareUpdateRequestor::Events::DownloadError::DecodableType & value); +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::PowerSource::Events::WiredFaultChange::DecodableType & value); +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::PowerSource::Events::BatFaultChange::DecodableType & value); +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::PowerSource::Events::BatChargeFaultChange::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::GeneralDiagnostics::Events::HardwareFaultChange::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index d6f7eef25da072..a4c3223b511588 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -78695,7 +78695,7 @@ class TestGroupKeyManagementClusterSuite : public TestCommand { public: TestGroupKeyManagementClusterSuite(CredentialIssuerCommands * credsIssuerConfig) : - TestCommand("TestGroupKeyManagementCluster", 22, credsIssuerConfig) + TestCommand("TestGroupKeyManagementCluster", 29, credsIssuerConfig) { AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); AddArgument("cluster", &mCluster); @@ -78929,6 +78929,51 @@ class TestGroupKeyManagementClusterSuite : public TestCommand case 21: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND)); 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), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::DataModel::DecodableList< + chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::DecodableType> + value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + { + auto iter_0 = value.begin(); + VerifyOrReturn(CheckNextListItemDecodes("groupKeyMap", iter_0, 0)); + VerifyOrReturn(CheckValue("groupKeyMap[0].groupId", iter_0.GetValue().groupId, 258U)); + VerifyOrReturn(CheckValue("groupKeyMap[0].groupKeySetID", iter_0.GetValue().groupKeySetID, 418U)); + VerifyOrReturn(CheckValue("groupKeyMap[0].fabricIndex", iter_0.GetValue().fabricIndex, 1U)); + VerifyOrReturn(CheckNoMoreListItems("groupKeyMap", iter_0, 1)); + } + } + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::DataModel::DecodableList< + chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::DecodableType> + value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + { + auto iter_0 = value.begin(); + VerifyOrReturn(CheckNoMoreListItems("groupKeyMap", iter_0, 0)); + } + } + break; default: LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); } @@ -79227,6 +79272,133 @@ class TestGroupKeyManagementClusterSuite : public TestCommand ); } + case 22: { + LogStep(22, "KeySet Write 1"); + ListFreer listFreer; + chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value; + + value.groupKeySet.groupKeySetID = 417U; + value.groupKeySet.groupKeySecurityPolicy = + static_cast(0); + value.groupKeySet.epochKey0.SetNonNull(); + value.groupKeySet.epochKey0.Value() = chip::ByteSpan( + chip::Uint8::from_const_char( + "\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257garbage: not in length on purpose"), + 16); + value.groupKeySet.epochStartTime0.SetNonNull(); + value.groupKeySet.epochStartTime0.Value() = 1110000ULL; + value.groupKeySet.epochKey1.SetNonNull(); + value.groupKeySet.epochKey1.Value() = chip::ByteSpan( + chip::Uint8::from_const_char( + "\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277garbage: not in length on purpose"), + 16); + value.groupKeySet.epochStartTime1.SetNonNull(); + value.groupKeySet.epochStartTime1.Value() = 1110001ULL; + value.groupKeySet.epochKey2.SetNonNull(); + value.groupKeySet.epochKey2.Value() = chip::ByteSpan( + chip::Uint8::from_const_char( + "\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317garbage: not in length on purpose"), + 16); + value.groupKeySet.epochStartTime2.SetNonNull(); + value.groupKeySet.epochStartTime2.Value() = 1110002ULL; + + return SendCommand(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id, + GroupKeyManagement::Commands::KeySetWrite::Id, value, chip::NullOptional + + ); + } + case 23: { + LogStep(23, "KeySet Write 2"); + ListFreer listFreer; + chip::app::Clusters::GroupKeyManagement::Commands::KeySetWrite::Type value; + + value.groupKeySet.groupKeySetID = 418U; + value.groupKeySet.groupKeySecurityPolicy = + static_cast(1); + value.groupKeySet.epochKey0.SetNonNull(); + value.groupKeySet.epochKey0.Value() = chip::ByteSpan( + chip::Uint8::from_const_char( + "\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337garbage: not in length on purpose"), + 16); + value.groupKeySet.epochStartTime0.SetNonNull(); + value.groupKeySet.epochStartTime0.Value() = 2110000ULL; + value.groupKeySet.epochKey1.SetNonNull(); + value.groupKeySet.epochKey1.Value() = chip::ByteSpan( + chip::Uint8::from_const_char( + "\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357garbage: not in length on purpose"), + 16); + value.groupKeySet.epochStartTime1.SetNonNull(); + value.groupKeySet.epochStartTime1.Value() = 2110001ULL; + value.groupKeySet.epochKey2.SetNonNull(); + value.groupKeySet.epochKey2.Value() = chip::ByteSpan( + chip::Uint8::from_const_char( + "\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377garbage: not in length on purpose"), + 16); + value.groupKeySet.epochStartTime2.SetNonNull(); + value.groupKeySet.epochStartTime2.Value() = 2110002ULL; + + return SendCommand(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id, + GroupKeyManagement::Commands::KeySetWrite::Id, value, chip::NullOptional + + ); + } + case 24: { + LogStep(24, "Map Group 1 and Group 2 to KeySet 1 and group 2 to KeySet 2"); + ListFreer listFreer; + chip::app::DataModel::List value; + + { + auto * listHolder_0 = new ListHolder(3); + listFreer.add(listHolder_0); + + listHolder_0->mList[0].groupId = 257U; + listHolder_0->mList[0].groupKeySetID = 417U; + listHolder_0->mList[0].fabricIndex = 1U; + + listHolder_0->mList[1].groupId = 258U; + listHolder_0->mList[1].groupKeySetID = 418U; + listHolder_0->mList[1].fabricIndex = 1U; + + listHolder_0->mList[2].groupId = 258U; + listHolder_0->mList[2].groupKeySetID = 417U; + listHolder_0->mList[2].fabricIndex = 1U; + + value = chip::app::DataModel::List( + listHolder_0->mList, 3); + } + return WriteAttribute(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id, + GroupKeyManagement::Attributes::GroupKeyMap::Id, value, chip::NullOptional, chip::NullOptional); + } + case 25: { + LogStep(25, "Remove keyset 1"); + ListFreer listFreer; + chip::app::Clusters::GroupKeyManagement::Commands::KeySetRemove::Type value; + value.groupKeySetID = 417U; + return SendCommand(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id, + GroupKeyManagement::Commands::KeySetRemove::Id, value, chip::NullOptional + + ); + } + case 26: { + LogStep(26, "TH verifies GroupKeyMap entries for KeySet 1 have been removed"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id, + GroupKeyManagement::Attributes::GroupKeyMap::Id, true, chip::NullOptional); + } + case 27: { + LogStep(27, "Remove keyset 2"); + ListFreer listFreer; + chip::app::Clusters::GroupKeyManagement::Commands::KeySetRemove::Type value; + value.groupKeySetID = 418U; + return SendCommand(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id, + GroupKeyManagement::Commands::KeySetRemove::Id, value, chip::NullOptional + + ); + } + case 28: { + LogStep(28, "TH verifies GroupKeyMap entries for KeySet 2 have been removed"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(0), GroupKeyManagement::Id, + GroupKeyManagement::Attributes::GroupKeyMap::Id, true, chip::NullOptional); + } } return CHIP_NO_ERROR; } diff --git a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h index 7bb0ef4746c056..bbe21891c6e607 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h @@ -16338,6 +16338,9 @@ class SubscribeAttributePowerSourceConfigurationClusterRevision : public Subscri | * ClusterRevision | 0xFFFD | |------------------------------------------------------------------------------| | Events: | | +| * WiredFaultChange | 0x0000 | +| * BatFaultChange | 0x0001 | +| * BatChargeFaultChange | 0x0002 | \*----------------------------------------------------------------------------*/ /* 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 6e5987315647ea..896ae2a97537f1 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -127760,6 +127760,34 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { ChipLogProgress(chipTool, " ***** Test Step 21 : KeySet Read (also removed)\n"); err = TestKeySetReadAlsoRemoved_21(); break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : KeySet Write 1\n"); + err = TestKeySetWrite1_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : KeySet Write 2\n"); + err = TestKeySetWrite2_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Map Group 1 and Group 2 to KeySet 1 and group 2 to KeySet 2\n"); + err = TestMapGroup1AndGroup2ToKeySet1AndGroup2ToKeySet2_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Remove keyset 1\n"); + err = TestRemoveKeyset1_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : TH verifies GroupKeyMap entries for KeySet 1 have been removed\n"); + err = TestThVerifiesGroupKeyMapEntriesForKeySet1HaveBeenRemoved_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Remove keyset 2\n"); + err = TestRemoveKeyset2_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : TH verifies GroupKeyMap entries for KeySet 2 have been removed\n"); + err = TestThVerifiesGroupKeyMapEntriesForKeySet2HaveBeenRemoved_28(); + break; } if (CHIP_NO_ERROR != err) { @@ -127837,6 +127865,27 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { case 21: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND)); 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), 0)); + 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; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; } // Go on to the next test. @@ -127850,7 +127899,7 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 22; + const uint16_t mTestCount = 29; chip::Optional mNodeId; chip::Optional mCluster; @@ -128594,6 +128643,241 @@ class TestGroupKeyManagementCluster : public TestCommandBridge { return CHIP_NO_ERROR; } + + CHIP_ERROR TestKeySetWrite1_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device + endpointID:@(0) + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:417U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1110000ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:1110001ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:1110002ULL]; + + [cluster keySetWriteWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"KeySet Write 1 Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestKeySetWrite2_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device + endpointID:@(0) + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:418U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:2110000ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:2110001ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:2110002ULL]; + + [cluster keySetWriteWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"KeySet Write 2 Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMapGroup1AndGroup2ToKeySet1AndGroup2ToKeySet2_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device + endpointID:@(0) + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id groupKeyMapArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupId = [NSNumber numberWithUnsignedShort:257U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupKeySetID = [NSNumber numberWithUnsignedShort:417U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).fabricIndex = [NSNumber numberWithUnsignedChar:1U]; + + temp_0[1] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[1]).groupId = [NSNumber numberWithUnsignedShort:258U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[1]).groupKeySetID = [NSNumber numberWithUnsignedShort:418U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[1]).fabricIndex = [NSNumber numberWithUnsignedChar:1U]; + + temp_0[2] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[2]).groupId = [NSNumber numberWithUnsignedShort:258U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[2]).groupKeySetID = [NSNumber numberWithUnsignedShort:417U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[2]).fabricIndex = [NSNumber numberWithUnsignedChar:1U]; + + groupKeyMapArgument = temp_0; + } + [cluster writeAttributeGroupKeyMapWithValue:groupKeyMapArgument + completion:^(NSError * _Nullable err) { + NSLog(@"Map Group 1 and Group 2 to KeySet 1 and group 2 to KeySet 2 Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRemoveKeyset1_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device + endpointID:@(0) + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetRemoveParams alloc] init]; + params.groupKeySetID = [NSNumber numberWithUnsignedShort:417U]; + [cluster keySetRemoveWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Remove keyset 1 Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThVerifiesGroupKeyMapEntriesForKeySet1HaveBeenRemoved_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device + endpointID:@(0) + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster + readAttributeGroupKeyMapWithParams:params + completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"TH verifies GroupKeyMap entries for KeySet 1 have been removed Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn( + CheckValue("GroupKeyMap", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("GroupId", + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) actualValue[0]).groupId, 258U)); + VerifyOrReturn(CheckValue("GroupKeySetID", + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) actualValue[0]).groupKeySetID, + 418U)); + VerifyOrReturn(CheckValue("FabricIndex", + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) actualValue[0]).fabricIndex, + 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRemoveKeyset2_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device + endpointID:@(0) + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetRemoveParams alloc] init]; + params.groupKeySetID = [NSNumber numberWithUnsignedShort:418U]; + [cluster keySetRemoveWithParams:params + completion:^(NSError * _Nullable err) { + NSLog(@"Remove keyset 2 Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThVerifiesGroupKeyMapEntriesForKeySet2HaveBeenRemoved_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device + endpointID:@(0) + queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster + readAttributeGroupKeyMapWithParams:params + completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"TH verifies GroupKeyMap entries for KeySet 2 have been removed Error: %@", err); + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn( + CheckValue("GroupKeyMap", [actualValue count], static_cast(0))); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } }; class Test_TC_G_1_1 : public TestCommandBridge {