From e4ab6f47a1b8c0121b2d30f5c73e5f6a1f60e8b6 Mon Sep 17 00:00:00 2001 From: Kamil Kasperczyk <66371704+kkasperczyk-no@users.noreply.github.com> Date: Thu, 11 Mar 2021 15:17:03 +0100 Subject: [PATCH 01/39] [nrfconnect] Add script to checkout recommended nRF Connect SDK version. (#5292) The nRF Connect SDK recommended version changes from time to time and users may face problems to notice it and update to the supported one. * Added script allowing to check if current nRF Connect SDK version is the same as recommended one and also to update it to the recommended version. --- .github/workflows/examples-nrfconnect.yaml | 2 + .../.nrfconnect-recommended-revision | 1 + .../app/check-nrfconnect-version.cmake | 21 ++++ .../lighting-app/nrfconnect/CMakeLists.txt | 3 +- examples/lighting-app/nrfconnect/README.md | 50 ++++---- examples/lock-app/nrfconnect/CMakeLists.txt | 3 +- examples/lock-app/nrfconnect/README.md | 50 ++++---- .../pigweed-app/nrfconnect/CMakeLists.txt | 6 +- examples/pigweed-app/nrfconnect/README.md | 50 ++++---- examples/shell/nrfconnect/CMakeLists.txt | 3 +- scripts/setup/nrfconnect/update_ncs.py | 114 ++++++++++++++++++ 11 files changed, 219 insertions(+), 84 deletions(-) create mode 100644 config/nrfconnect/.nrfconnect-recommended-revision create mode 100644 config/nrfconnect/app/check-nrfconnect-version.cmake create mode 100755 scripts/setup/nrfconnect/update_ncs.py diff --git a/.github/workflows/examples-nrfconnect.yaml b/.github/workflows/examples-nrfconnect.yaml index 835dbadd1aeb85..00f6f024a3fbf8 100644 --- a/.github/workflows/examples-nrfconnect.yaml +++ b/.github/workflows/examples-nrfconnect.yaml @@ -40,6 +40,8 @@ jobs: with: fetch-depth: 0 submodules: true + - name: Update nRF Connect SDK revision to the currently recommended. + run: python3 scripts/setup/nrfconnect/update_ncs.py --update # https://github.com/project-chip/connectedhomeip/issues/3100 # - name: Initialize CodeQL # uses: github/codeql-action/init@v1 diff --git a/config/nrfconnect/.nrfconnect-recommended-revision b/config/nrfconnect/.nrfconnect-recommended-revision new file mode 100644 index 00000000000000..56e68719154e67 --- /dev/null +++ b/config/nrfconnect/.nrfconnect-recommended-revision @@ -0,0 +1 @@ +8e8c60897eac40f61db9f578ce521970fff8e4d2 diff --git a/config/nrfconnect/app/check-nrfconnect-version.cmake b/config/nrfconnect/app/check-nrfconnect-version.cmake new file mode 100644 index 00000000000000..a4e6a0cf294c4c --- /dev/null +++ b/config/nrfconnect/app/check-nrfconnect-version.cmake @@ -0,0 +1,21 @@ +# +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +find_package(Python3 REQUIRED) +add_custom_target(check-nrfconnect-version ALL + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../../.. + COMMAND ${Python3_EXECUTABLE} scripts/setup/nrfconnect/update_ncs.py --check --quiet || (exit 0) + USES_TERMINAL) diff --git a/examples/lighting-app/nrfconnect/CMakeLists.txt b/examples/lighting-app/nrfconnect/CMakeLists.txt index 32a65e7982ee08..bc46f101bc75c2 100644 --- a/examples/lighting-app/nrfconnect/CMakeLists.txt +++ b/examples/lighting-app/nrfconnect/CMakeLists.txt @@ -19,9 +19,10 @@ get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/third_party/connect get_filename_component(NRFCONNECT_COMMON ${CHIP_ROOT}/examples/platform/nrfconnect REALPATH) get_filename_component(LIGHTING_COMMON ${CHIP_ROOT}/examples/lighting-app/lighting-common REALPATH) -set(CONF_FILE ${CHIP_ROOT}/config/nrfconnect/app/sample-defaults.conf prj.conf) +include(${CHIP_ROOT}/config/nrfconnect/app/check-nrfconnect-version.cmake) # Load NCS/Zephyr build system +set(CONF_FILE ${CHIP_ROOT}/config/nrfconnect/app/sample-defaults.conf prj.conf) list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/nrfconnect/chip-module) find_package(Zephyr HINTS $ENV{ZEPHYR_BASE}) diff --git a/examples/lighting-app/nrfconnect/README.md b/examples/lighting-app/nrfconnect/README.md index 4faa0998da9576..80c0504569ec37 100644 --- a/examples/lighting-app/nrfconnect/README.md +++ b/examples/lighting-app/nrfconnect/README.md @@ -92,7 +92,9 @@ with other Thread devices in the network. ## Requirements -The application requires the nRF Connect SDK v1.5.0 to work correctly. +The application requires a specific revision of the nRF Connect SDK to work +correctly. See [Setting up the environment](#setting-up-the-environment) for +more information. @@ -176,9 +178,9 @@ using the following command: $ git submodule update --init -The example requires the nRF Connect SDK v1.5.0. You can either install it along -with the related tools directly on your system or use a Docker image that has -the tools pre-installed. +The example requires a specific revision of the nRF Connect SDK. You can either +install it along with the related tools directly on your system or use a Docker +image that has the tools pre-installed. If you are a macOS user, you won't be able to use the Docker container to flash the application onto a Nordic development kit due to @@ -220,13 +222,11 @@ To use the Docker container for setup, complete the following steps: - _-e RUNAS=\$(id -u)_ is needed to start the container session as the current user instead of root. -4. Check out or update the nRF Connect SDK to the recommended `v1.5.0` version - by running the following command in the Docker container: +4. Update the nRF Connect SDK to the most recent supported revision, by running + the following command: - $ setup --ncs v1.5.0 - /var/ncs repository is empty. Do you wish to check out nRF Connect SDK sources [v1.5.0]? [Y/N] y - ... - /var/chip repository is initialized, skipping... + $ cd /var/chip + $ python3 scripts/setup/nrfconnect/update_ncs.py --update Now you can proceed with the [Building](#building) instruction. @@ -239,23 +239,14 @@ To use the native shell for setup, complete the following steps: - [nRF Command Line Tools](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Command-Line-Tools) - [GN meta-build system](https://gn.googlesource.com/gn/) -2. Depending on whether you have the nRF Connect SDK installed: - - - Follow the - [guide](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/gs_assistant.html#) - in the nRF Connect SDK documentation to install the nRF Connect SDK - v1.5.0. Since command-line tools will be used for building the example, - installing SEGGER Embedded Studio is not required. - - - If you have an older version of the SDK installed, use the following - commands to update it to the recommended version. Replace - _nrfconnect-dir_ with the path to your nRF Connect SDK installation - directory. +2. If you do not have the nRF Connect SDK installed, follow the + [guide](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/gs_assistant.html#) + in the nRF Connect SDK documentation to install the latest stable nRF + Connect SDK version. Since command-line tools will be used for building the + example, installing SEGGER Embedded Studio is not required. - $ cd nrfconnect-dir/nrf - $ git fetch origin - $ git checkout v1.5.0 - $ west update + If you have the SDK already installed, continue to the next step and update + the nRF Connect SDK after initializing environment variables. 3. Initialize environment variables referred to by the CHIP and the nRF Connect SDK build scripts. Replace _nrfconnect-dir_ with the path to your nRF @@ -266,6 +257,13 @@ To use the native shell for setup, complete the following steps: $ export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb $ export GNUARMEMB_TOOLCHAIN_PATH=toolchain-dir +4. Update the nRF Connect SDK to the most recent supported revision by running + the following command (replace _chip-dir_ with the path to CHIP repository + directory): + + $ cd chip-dir + $ python3 scripts/setup/nrfconnect/update_ncs.py --update + Now you can proceed with the [Building](#building) instruction.
diff --git a/examples/lock-app/nrfconnect/CMakeLists.txt b/examples/lock-app/nrfconnect/CMakeLists.txt index b97d0ba9ebc4ac..3b51c837dc18d4 100644 --- a/examples/lock-app/nrfconnect/CMakeLists.txt +++ b/examples/lock-app/nrfconnect/CMakeLists.txt @@ -19,9 +19,10 @@ get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/third_party/connect get_filename_component(NRFCONNECT_COMMON ${CHIP_ROOT}/examples/platform/nrfconnect REALPATH) get_filename_component(LOCK_COMMON ${CHIP_ROOT}/examples/lock-app/lock-common REALPATH) -set(CONF_FILE ${CHIP_ROOT}/config/nrfconnect/app/sample-defaults.conf prj.conf) +include(${CHIP_ROOT}/config/nrfconnect/app/check-nrfconnect-version.cmake) # Load NCS/Zephyr build system +set(CONF_FILE ${CHIP_ROOT}/config/nrfconnect/app/sample-defaults.conf prj.conf) list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/nrfconnect/chip-module) find_package(Zephyr HINTS $ENV{ZEPHYR_BASE}) diff --git a/examples/lock-app/nrfconnect/README.md b/examples/lock-app/nrfconnect/README.md index 857136bd65e25a..814f0b9e2a3379 100644 --- a/examples/lock-app/nrfconnect/README.md +++ b/examples/lock-app/nrfconnect/README.md @@ -89,7 +89,9 @@ with other Thread devices in the network. ## Requirements -The application requires the nRF Connect SDK v1.5.0 to work correctly. +The application requires a specific revision of the nRF Connect SDK to work +correctly. See [Setting up the environment](#setting-up-the-environment) for +more information. @@ -176,9 +178,9 @@ using the following command: $ git submodule update --init -The example requires the nRF Connect SDK v1.5.0. You can either install it along -with the related tools directly on your system or use a Docker image that has -the tools pre-installed. +The example requires a specific revision of the nRF Connect SDK. You can either +install it along with the related tools directly on your system or use a Docker +image that has the tools pre-installed. If you are a macOS user, you won't be able to use the Docker container to flash the application onto a Nordic development kit due to @@ -220,13 +222,11 @@ To use the Docker container for setup, complete the following steps: - _-e RUNAS=\$(id -u)_ is needed to start the container session as the current user instead of root. -4. Check out or update the nRF Connect SDK to the recommended `v1.5.0` version - by running the following command in the Docker container: +4. Update the nRF Connect SDK to the most recent supported revision, by running + the following command: - $ setup --ncs v1.5.0 - /var/ncs repository is empty. Do you wish to check out nRF Connect SDK sources [v1.5.0]? [Y/N] y - ... - /var/chip repository is initialized, skipping... + $ cd /var/chip + $ python3 scripts/setup/nrfconnect/update_ncs.py --update Now you can proceed with the [Building](#building) instruction. @@ -239,23 +239,14 @@ To use the native shell for setup, complete the following steps: - [nRF Command Line Tools](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Command-Line-Tools) - [GN meta-build system](https://gn.googlesource.com/gn/) -2. Depending on whether you have the nRF Connect SDK installed: - - - Follow the - [guide](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/gs_assistant.html#) - in the nRF Connect SDK documentation to install the nRF Connect SDK - v1.5.0. Since command-line tools will be used for building the example, - installing SEGGER Embedded Studio is not required. - - - If you have an older version of the SDK installed, use the following - commands to update it to the recommended version. Replace - _nrfconnect-dir_ with the path to your nRF Connect SDK installation - directory. +2. If you do not have the nRF Connect SDK installed, follow the + [guide](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/gs_assistant.html#) + in the nRF Connect SDK documentation to install the latest stable nRF + Connect SDK version. Since command-line tools will be used for building the + example, installing SEGGER Embedded Studio is not required. - $ cd nrfconnect-dir/nrf - $ git fetch origin - $ git checkout v1.5.0 - $ west update + If you have the SDK already installed, continue to the next step and update + the nRF Connect SDK after initializing environment variables. 3. Initialize environment variables referred to by the CHIP and the nRF Connect SDK build scripts. Replace _nrfconnect-dir_ with the path to your nRF @@ -266,6 +257,13 @@ To use the native shell for setup, complete the following steps: $ export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb $ export GNUARMEMB_TOOLCHAIN_PATH=toolchain-dir +4. Update the nRF Connect SDK to the most recent supported revision by running + the following command (replace _chip-dir_ with the path to CHIP repository + directory): + + $ cd chip-dir + $ python3 scripts/setup/nrfconnect/update_ncs.py --update + Now you can proceed with the [Building](#building) instruction.
diff --git a/examples/pigweed-app/nrfconnect/CMakeLists.txt b/examples/pigweed-app/nrfconnect/CMakeLists.txt index bb956771c7ef5c..eaeb2e3b5140e8 100644 --- a/examples/pigweed-app/nrfconnect/CMakeLists.txt +++ b/examples/pigweed-app/nrfconnect/CMakeLists.txt @@ -19,13 +19,13 @@ get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/third_party/connect get_filename_component(NRFCONNECT_COMMON ${CHIP_ROOT}/examples/platform/nrfconnect REALPATH) set(PIGWEED_ROOT "${CHIP_ROOT}/third_party/pigweed/repo") -set(CONF_FILE ${CHIP_ROOT}/config/nrfconnect/app/sample-defaults.conf prj.conf) +include(${CHIP_ROOT}/config/nrfconnect/app/check-nrfconnect-version.cmake) +# Load NCS/Zephyr build system +set(CONF_FILE ${CHIP_ROOT}/config/nrfconnect/app/sample-defaults.conf prj.conf) if(${BOARD} STREQUAL "nrf52840dongle_nrf52840") list(INSERT OVERLAY_CONFIG 0 ${CHIP_ROOT}/config/nrfconnect/app/overlay-usb_support.conf) endif() - -# Load NCS/Zephyr build system list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/nrfconnect/chip-module) find_package(Zephyr HINTS $ENV{ZEPHYR_BASE}) diff --git a/examples/pigweed-app/nrfconnect/README.md b/examples/pigweed-app/nrfconnect/README.md index d41732a855c99b..00dc0ef929f59e 100644 --- a/examples/pigweed-app/nrfconnect/README.md +++ b/examples/pigweed-app/nrfconnect/README.md @@ -64,7 +64,9 @@ other cases. ## Requirements -The application requires the nRF Connect SDK v1.5.0 to work correctly. +The application requires a specific revision of the nRF Connect SDK to work +correctly. See [Setting up the environment](#setting-up-the-environment) for +more information. @@ -114,9 +116,9 @@ using the following command: $ git submodule update --init -The example requires the nRF Connect SDK v1.5.0. You can either install it along -with the related tools directly on your system or use a Docker image that has -the tools pre-installed. +The example requires a specific revision of the nRF Connect SDK. You can either +install it along with the related tools directly on your system or use a Docker +image that has the tools pre-installed. If you are a macOS user, you won't be able to use the Docker container to flash the application onto a Nordic development kit due to @@ -158,13 +160,11 @@ To use the Docker container for setup, complete the following steps: - _-e RUNAS=\$(id -u)_ is needed to start the container session as the current user instead of root. -4. Check out or update the nRF Connect SDK to the recommended `v1.5.0` version - by running the following command in the Docker container: +4. Update the nRF Connect SDK to the most recent supported revision, by running + the following command: - $ setup --ncs v1.5.0 - /var/ncs repository is empty. Do you wish to check out nRF Connect SDK sources [v1.5.0]? [Y/N] y - ... - /var/chip repository is initialized, skipping... + $ cd /var/chip + $ python3 scripts/setup/nrfconnect/update_ncs.py --update Now you can proceed with the [Building](#building) instruction. @@ -177,23 +177,14 @@ To use the native shell for setup, complete the following steps: - [nRF Command Line Tools](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Command-Line-Tools) - [GN meta-build system](https://gn.googlesource.com/gn/) -2. Depending on whether you have the nRF Connect SDK installed: - - - Follow the - [guide](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/gs_assistant.html#) - in the nRF Connect SDK documentation to install the nRF Connect SDK - v1.5.0. Since command-line tools will be used for building the example, - installing SEGGER Embedded Studio is not required. - - - If you have an older version of the SDK installed, use the following - commands to update it to the recommended version. Replace - _nrfconnect-dir_ with the path to your nRF Connect SDK installation - directory. +2. If you do not have the nRF Connect SDK installed, follow the + [guide](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/gs_assistant.html#) + in the nRF Connect SDK documentation to install the latest stable nRF + Connect SDK version. Since command-line tools will be used for building the + example, installing SEGGER Embedded Studio is not required. - $ cd nrfconnect-dir/nrf - $ git fetch origin - $ git checkout v1.5.0 - $ west update + If you have the SDK already installed, continue to the next step and update + the nRF Connect SDK after initializing environment variables. 3. Initialize environment variables referred to by the CHIP and the nRF Connect SDK build scripts. Replace _nrfconnect-dir_ with the path to your nRF @@ -204,6 +195,13 @@ To use the native shell for setup, complete the following steps: $ export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb $ export GNUARMEMB_TOOLCHAIN_PATH=toolchain-dir +4. Update the nRF Connect SDK to the most recent supported revision by running + the following command (replace _chip-dir_ with the path to CHIP repository + directory): + + $ cd chip-dir + $ python3 scripts/setup/nrfconnect/update_ncs.py --update + Now you can proceed with the [Building](#building) instruction.
diff --git a/examples/shell/nrfconnect/CMakeLists.txt b/examples/shell/nrfconnect/CMakeLists.txt index 117eef28b4f4ba..d1e95b9cdb4966 100644 --- a/examples/shell/nrfconnect/CMakeLists.txt +++ b/examples/shell/nrfconnect/CMakeLists.txt @@ -18,9 +18,10 @@ cmake_minimum_required(VERSION 3.13.1) get_filename_component(CHIP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/third_party/connectedhomeip REALPATH) get_filename_component(APP_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/.. REALPATH) -set(CONF_FILE ${CHIP_ROOT}/config/nrfconnect/app/sample-defaults.conf prj.conf) +include(${CHIP_ROOT}/config/nrfconnect/app/check-nrfconnect-version.cmake) # Load NCS/Zephyr build system +set(CONF_FILE ${CHIP_ROOT}/config/nrfconnect/app/sample-defaults.conf prj.conf) list(APPEND ZEPHYR_EXTRA_MODULES ${CHIP_ROOT}/config/nrfconnect/chip-module) find_package(Zephyr HINTS $ENV{ZEPHYR_BASE}) diff --git a/scripts/setup/nrfconnect/update_ncs.py b/scripts/setup/nrfconnect/update_ncs.py new file mode 100755 index 00000000000000..fdd2998bc33243 --- /dev/null +++ b/scripts/setup/nrfconnect/update_ncs.py @@ -0,0 +1,114 @@ +#!/usr/bin/env python3 + +# +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import argparse +import os +import subprocess +import sys + +def get_repository_commit_sha(repository_location): + command = ['git', '-C', repository_location, 'rev-parse', 'HEAD'] + process = subprocess.run(command, check=True, stdout=subprocess.PIPE) + return process.stdout.decode('ascii').strip() + +def update_ncs(repository_location, revision): + # Fetch sdk-nrf to the desired revision. + command = ['git', '-C', repository_location, 'fetch'] + subprocess.run(command, check=True) + + # Checkout sdk-nrf to the desired revision. + command = ['git', '-C', repository_location, 'checkout', revision] + subprocess.run(command, check=True) + + # Call west update command to update all projects and submodules used by sdk-nrf. + command = ['west', 'update', '-r'] + subprocess.run(command, check=True) + +def get_ncs_recommended_revision(): + chip_root = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.normpath('../../..'))) + + # Read recommended revision saved in the .nrfconnect-recommended-revision file. + try: + with open(os.path.join(chip_root, 'config/nrfconnect/.nrfconnect-recommended-revision'), 'r') as f: + return f.readline().strip() + except: + raise RuntimeError("Encountered problem when trying to read .nrfconnect-recommended-revision file.") + +def print_messages(messages : list, yellow_text : bool): + # Add colour formatting if yellow text was set + if yellow_text: + messages = [f"\33[33m{message}\x1b[0m" for message in messages] + + for message in messages: + print(message) + +def print_check_revision_warning_message(current_revision, recommended_revision): + current_revision_message = f"WARNING: Your current NCS revision ({current_revision})" + recommended_revision_message = f"differs from the recommended ({recommended_revision})." + allowed_message = "Please be aware that it may lead to encountering unexpected problems." + update_message = "Consider updating NCS to the recommended revision, by calling:" + call_command_message = os.path.abspath(__file__) + " --update" + + # Get the longest message lenght, to fit warning frame size. + longest_message_len = max([len(current_revision_message), len(recommended_revision_message), len(allowed_message), len(update_message), len(call_command_message)]) + + # To keep right frame shape the space characters are added to messages shorter than the longest one. + fmt = "# {:<%s}#" % (longest_message_len) + + print_messages([(longest_message_len+3)*'#', fmt.format(current_revision_message), fmt.format(recommended_revision_message), fmt.format(''), + fmt.format(allowed_message), fmt.format(update_message), fmt.format(call_command_message), (longest_message_len+3)*'#'], sys.stdout.isatty()) + +def main(): + + try: + zephyr_base = os.getenv("ZEPHYR_BASE") + if not zephyr_base: + raise RuntimeError("No ZEPHYR_BASE environment variable found, please set ZEPHYR_BASE to a zephyr repository path.") + + parser = argparse.ArgumentParser(description='Script helping to update nRF Connect SDK to currently recommended revision.') + parser.add_argument("-c", "--check", help="Check if your current nRF Connect SDK revision is the same as recommended one.", action="store_true") + parser.add_argument("-u", "--update", help="Update your nRF Connect SDK to currently recommended revision.", action="store_true") + parser.add_argument("-q", "--quiet", help="Don't print any message if the check succeeds.", action="store_true") + args = parser.parse_args() + + ncs_base = os.path.join(zephyr_base, '../nrf') + recommended_revision = get_ncs_recommended_revision() + + if args.check: + if not args.quiet: + print("Checking current nRF Connect SDK revision...") + + current_revision = get_repository_commit_sha(ncs_base) + + if current_revision != recommended_revision: + print_check_revision_warning_message(current_revision, recommended_revision) + sys.exit(1) + + if not args.quiet: + print("Your current version is up to date with the recommended one.") + + if args.update: + print("Updating nRF Connect SDK to recommended revision...") + update_ncs(ncs_base, recommended_revision) + + except (RuntimeError, subprocess.CalledProcessError) as e: + print(e) + sys.exit(1) + +if __name__ == '__main__': + main() From e6e4d67a049daeb9559bc670a018be33df381de6 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 11 Mar 2021 10:59:02 -0500 Subject: [PATCH 02/39] Switch pigweed repo to point to github (#5316) --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index fd9e0b53b12536..bc43cb1814727f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -28,7 +28,7 @@ branch = master [submodule "pigweed"] path = third_party/pigweed/repo - url = https://pigweed.googlesource.com/pigweed/pigweed + url = https://github.com/google/pigweed.git branch = master [submodule "openthread"] path = third_party/openthread/repo From d8a2d1f2e53dc57de4c480f9574121d32799c1e9 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Thu, 11 Mar 2021 08:20:44 -0800 Subject: [PATCH 03/39] [TE1]: Provide test interface in chip-shell to test CRMP. (#5228) --- examples/shell/README.md | 2 + examples/shell/nrfconnect/CHIPProjectConfig.h | 2 + examples/shell/shell_common/BUILD.gn | 6 + examples/shell/shell_common/cmd_ping.cpp | 482 ++++++++++++++++++ .../include/ChipShellCollection.h | 1 + examples/shell/standalone/main.cpp | 4 + src/messaging/tests/echo/echo_requester.cpp | 2 +- src/protocols/echo/Echo.h | 4 +- src/protocols/echo/EchoClient.cpp | 8 +- src/transport/SecureSessionMgr.cpp | 10 + src/transport/SecureSessionMgr.h | 7 + 11 files changed, 522 insertions(+), 6 deletions(-) create mode 100644 examples/shell/shell_common/cmd_ping.cpp diff --git a/examples/shell/README.md b/examples/shell/README.md index 696ab03dec36f4..47d79d0e72fff3 100644 --- a/examples/shell/README.md +++ b/examples/shell/README.md @@ -34,6 +34,7 @@ Done - [exit](#exit) - [help](#help) - [otcli](README_OTCLI.md) +- [ping](#ping) - [rand](#rand) - [version](#version) @@ -51,6 +52,7 @@ Display a list of all top-level commands supported and a brief description. base64 Base64 encode / decode utilities device Device Layer commands otcli Dispatch OpenThread CLI command + ping Using Echo Protocol to measure packet loss across network paths exit Exit the shell application help List out all top level commands version Output the software version diff --git a/examples/shell/nrfconnect/CHIPProjectConfig.h b/examples/shell/nrfconnect/CHIPProjectConfig.h index 31220b0ac0817c..34387950391ff5 100644 --- a/examples/shell/nrfconnect/CHIPProjectConfig.h +++ b/examples/shell/nrfconnect/CHIPProjectConfig.h @@ -33,3 +33,5 @@ // Enable support functions for parsing command-line arguments #define CHIP_CONFIG_ENABLE_ARG_PARSER 1 + +#define CHIP_DEVICE_CONFIG_DISABLE_SHELL_PING 1 diff --git a/examples/shell/shell_common/BUILD.gn b/examples/shell/shell_common/BUILD.gn index d11a5ae99a9e87..29674db404790e 100644 --- a/examples/shell/shell_common/BUILD.gn +++ b/examples/shell/shell_common/BUILD.gn @@ -36,12 +36,18 @@ static_library("shell_common") { "cmd_device.cpp", "cmd_misc.cpp", "cmd_otcli.cpp", + "cmd_ping.cpp", ] public_deps = [ "${chip_root}/src/lib", + "${chip_root}/src/lib/core", "${chip_root}/src/lib/shell", + "${chip_root}/src/lib/support", + "${chip_root}/src/platform", + "${chip_root}/src/protocols", "${chip_root}/src/setup_payload", + "${chip_root}/src/system", ] if (chip_enable_openthread && diff --git a/examples/shell/shell_common/cmd_ping.cpp b/examples/shell/shell_common/cmd_ping.cpp new file mode 100644 index 00000000000000..afb21bcaf6859b --- /dev/null +++ b/examples/shell/shell_common/cmd_ping.cpp @@ -0,0 +1,482 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace chip; +using namespace Shell; +using namespace Logging; + +constexpr size_t kMaxTcpActiveConnectionCount = 4; +constexpr size_t kMaxTcpPendingPackets = 4; +constexpr size_t kNetworkSleepTimeMsecs = (100 * 1000); +constexpr size_t kDecimalDigitsForUint64 = 20; + +namespace { + +class PingArguments +{ +public: + void Reset() + { + mMaxEchoCount = 3; + mEchoInterval = 1000; + mLastEchoTime = 0; + mEchoCount = 0; + mEchoRespCount = 0; + mWaitingForEchoResp = false; + mUsingTCP = false; + mUsingCRMP = true; + mEchoPort = CHIP_PORT; + } + + uint64_t GetLastEchoTime() const { return mLastEchoTime; } + void SetLastEchoTime(uint64_t value) { mLastEchoTime = value; } + + uint64_t GetEchoCount() const { return mEchoCount; } + void SetEchoCount(uint64_t value) { mEchoCount = value; } + void IncrementEchoCount() { mEchoCount++; } + + uint64_t GetEchoRespCount() const { return mEchoRespCount; } + void SetEchoRespCount(uint64_t value) { mEchoRespCount = value; } + void IncrementEchoRespCount() { mEchoRespCount++; } + + uint32_t GetMaxEchoCount() const { return mMaxEchoCount; } + void SetMaxEchoCount(uint32_t id) { mMaxEchoCount = id; } + + uint32_t GetEchoInterval() const { return mEchoInterval; } + void SetEchoInterval(uint32_t value) { mEchoInterval = value; } + + uint16_t GetEchoPort() const { return mEchoPort; } + void SetEchoPort(uint16_t value) { mEchoPort = value; } + + bool IsWaitingForEchoResp() const { return mWaitingForEchoResp; } + void SetWaitingForEchoResp(bool value) { mWaitingForEchoResp = value; } + + bool IsUsingTCP() const { return mUsingTCP; } + void SetUsingTCP(bool value) { mUsingTCP = value; } + + bool IsUsingCRMP() const { return mUsingCRMP; } + void SetUsingCRMP(bool value) { mUsingCRMP = value; } + +private: + // The last time a echo request was attempted to be sent. + uint64_t mLastEchoTime; + + // Count of the number of echo requests sent. + uint64_t mEchoCount; + + // Count of the number of echo responses received. + uint64_t mEchoRespCount; + + // Max value for the number of echo requests sent. + uint32_t mMaxEchoCount; + + // The CHIP Echo interval time in milliseconds. + uint32_t mEchoInterval; + + uint16_t mEchoPort; + + // True, if the echo client is waiting for an echo response + // after sending an echo request, false otherwise. + bool mWaitingForEchoResp; + + bool mUsingTCP; + bool mUsingCRMP; +} gPingArguments; + +constexpr Transport::AdminId gAdminId = 0; + +Protocols::Echo::EchoClient gEchoClient; +TransportMgr gUDPManager; +TransportMgr> gTCPManager; +Messaging::ExchangeManager gExchangeManager; +SecureSessionMgr gSessionManager; +Inet::IPAddress gDestAddr; + +bool EchoIntervalExpired(void) +{ + uint64_t now = System::Timer::GetCurrentEpoch(); + + return (now >= gPingArguments.GetLastEchoTime() + gPingArguments.GetEchoInterval()); +} + +CHIP_ERROR SendEchoRequest(streamer_t * stream) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + + Messaging::SendFlags sendFlags; + const char kRequestFormat[] = "Echo Message %" PRIu64 "\n"; + char requestData[(sizeof kRequestFormat) + kDecimalDigitsForUint64]; + snprintf(requestData, sizeof requestData, kRequestFormat, gPingArguments.GetEchoCount()); + System::PacketBufferHandle payloadBuf = MessagePacketBuffer::NewWithData(requestData, strlen(requestData)); + + if (gPingArguments.IsUsingCRMP()) + { + sendFlags.Set(Messaging::SendMessageFlags::kNone); + } + else + { + sendFlags.Set(Messaging::SendMessageFlags::kNoAutoRequestAck); + } + + if (payloadBuf.IsNull()) + { + streamer_printf(stream, "Unable to allocate packet buffer\n"); + return CHIP_ERROR_NO_MEMORY; + } + + gPingArguments.SetLastEchoTime(System::Timer::GetCurrentEpoch()); + + streamer_printf(stream, "\nSend echo request message to Node: %" PRIu64 "\n", kTestDeviceNodeId); + + err = gEchoClient.SendEchoRequest(std::move(payloadBuf), sendFlags); + + if (err == CHIP_NO_ERROR) + { + gPingArguments.SetWaitingForEchoResp(true); + gPingArguments.IncrementEchoCount(); + } + else + { + streamer_printf(stream, "Send echo request failed, err: %s\n", ErrorStr(err)); + } + + return err; +} + +CHIP_ERROR EstablishSecureSession(streamer_t * stream) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + + Optional peerAddr; + SecurePairingUsingTestSecret * testSecurePairingSecret = chip::Platform::New(); + VerifyOrExit(testSecurePairingSecret != nullptr, err = CHIP_ERROR_NO_MEMORY); + + if (gPingArguments.IsUsingTCP()) + { + peerAddr = Optional::Value(Transport::PeerAddress::TCP(gDestAddr, gPingArguments.GetEchoPort())); + } + else + { + peerAddr = Optional::Value( + Transport::PeerAddress::UDP(gDestAddr, gPingArguments.GetEchoPort(), INET_NULL_INTERFACEID)); + } + + // Attempt to connect to the peer. + err = gSessionManager.NewPairing(peerAddr, kTestDeviceNodeId, testSecurePairingSecret, + SecureSessionMgr::PairingDirection::kInitiator, gAdminId); + +exit: + if (err != CHIP_NO_ERROR) + { + streamer_printf(stream, "Establish secure session failed, err: %s\n", ErrorStr(err)); + gPingArguments.SetLastEchoTime(System::Timer::GetCurrentEpoch()); + } + else + { + streamer_printf(stream, "Establish secure session succeeded\n"); + } + + return err; +} + +void HandleEchoResponseReceived(Messaging::ExchangeContext * ec, System::PacketBufferHandle payload) +{ + uint32_t respTime = System::Timer::GetCurrentEpoch(); + uint32_t transitTime = respTime - gPingArguments.GetLastEchoTime(); + streamer_t * sout = streamer_get(); + + gPingArguments.SetWaitingForEchoResp(false); + gPingArguments.IncrementEchoRespCount(); + + streamer_printf(sout, "Echo Response: %" PRIu64 "/%" PRIu64 "(%.2f%%) len=%u time=%.3fms\n", gPingArguments.GetEchoRespCount(), + gPingArguments.GetEchoCount(), + static_cast(gPingArguments.GetEchoRespCount()) * 100 / gPingArguments.GetEchoCount(), + payload->DataLength(), static_cast(transitTime) / 1000); +} + +void DriveIO(streamer_t * stream) +{ + struct timeval sleepTime; + fd_set readFDs, writeFDs, exceptFDs; + int numFDs = 0; + int selectRes; + + sleepTime.tv_sec = 0; + sleepTime.tv_usec = kNetworkSleepTimeMsecs; + + FD_ZERO(&readFDs); + FD_ZERO(&writeFDs); + FD_ZERO(&exceptFDs); + + if (chip::DeviceLayer::SystemLayer.State() == chip::System::kLayerState_Initialized) + chip::DeviceLayer::SystemLayer.PrepareSelect(numFDs, &readFDs, &writeFDs, &exceptFDs, sleepTime); + + if (chip::DeviceLayer::InetLayer.State == chip::Inet::InetLayer::kState_Initialized) + chip::DeviceLayer::InetLayer.PrepareSelect(numFDs, &readFDs, &writeFDs, &exceptFDs, sleepTime); + + selectRes = select(numFDs, &readFDs, &writeFDs, &exceptFDs, &sleepTime); + if (selectRes < 0) + { + streamer_printf(stream, "Select failed: %s\n", chip::ErrorStr(chip::System::MapErrorPOSIX(errno))); + return; + } + + if (chip::DeviceLayer::SystemLayer.State() == chip::System::kLayerState_Initialized) + { + chip::DeviceLayer::SystemLayer.HandleSelectResult(selectRes, &readFDs, &writeFDs, &exceptFDs); + } + + if (chip::DeviceLayer::InetLayer.State == chip::Inet::InetLayer::kState_Initialized) + { + chip::DeviceLayer::InetLayer.HandleSelectResult(selectRes, &readFDs, &writeFDs, &exceptFDs); + } +} + +void StartPinging(streamer_t * stream, char * destination) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + + Transport::AdminPairingTable admins; + Transport::AdminPairingInfo * adminInfo = nullptr; + uint32_t maxEchoCount = 0; + + if (!Inet::IPAddress::FromString(destination, gDestAddr)) + { + streamer_printf(stream, "Invalid Echo Server IP address: %s\n", destination); + ExitNow(err = CHIP_ERROR_INVALID_ARGUMENT); + } + + adminInfo = admins.AssignAdminId(gAdminId, kTestControllerNodeId); + VerifyOrExit(adminInfo != nullptr, err = CHIP_ERROR_NO_MEMORY); + + err = gTCPManager.Init(Transport::TcpListenParameters(&DeviceLayer::InetLayer) + .SetAddressType(Inet::kIPAddressType_IPv4) + .SetListenPort(gPingArguments.GetEchoPort() + 1)); + VerifyOrExit(err == CHIP_NO_ERROR, streamer_printf(stream, "Failed to init TCP manager error: %s\r\n", ErrorStr(err))); + + err = gUDPManager.Init(Transport::UdpListenParameters(&DeviceLayer::InetLayer) + .SetAddressType(Inet::kIPAddressType_IPv4) + .SetListenPort(gPingArguments.GetEchoPort() + 1)); + VerifyOrExit(err == CHIP_NO_ERROR, streamer_printf(stream, "Failed to init UDP manager error: %s\r\n", ErrorStr(err))); + + if (gPingArguments.IsUsingTCP()) + { + err = gSessionManager.Init(kTestControllerNodeId, &DeviceLayer::SystemLayer, &gTCPManager, &admins); + SuccessOrExit(err); + + err = gExchangeManager.Init(kTestControllerNodeId, &gTCPManager, &gSessionManager); + SuccessOrExit(err); + } + else + { + err = gSessionManager.Init(kTestControllerNodeId, &DeviceLayer::SystemLayer, &gUDPManager, &admins); + SuccessOrExit(err); + + err = gExchangeManager.Init(kTestControllerNodeId, &gUDPManager, &gSessionManager); + SuccessOrExit(err); + } + + // Start the CHIP connection to the CHIP echo responder. + err = EstablishSecureSession(stream); + SuccessOrExit(err); + + // TODO: temprary create a SecureSessionHandle from node id to unblock end-to-end test. Complete solution is tracked in PR:4451 + err = gEchoClient.Init(&gExchangeManager, { kTestDeviceNodeId, 0, gAdminId }); + SuccessOrExit(err); + + // Arrange to get a callback whenever an Echo Response is received. + gEchoClient.SetEchoResponseReceived(HandleEchoResponseReceived); + + maxEchoCount = gPingArguments.GetMaxEchoCount(); + + // Connection has been established. Now send the EchoRequests. + for (unsigned int i = 0; i < maxEchoCount; i++) + { + err = SendEchoRequest(stream); + if (err != CHIP_NO_ERROR) + { + streamer_printf(stream, "Send request failed: %s\n", ErrorStr(err)); + break; + } + + // Wait for response until the Echo interval. + while (!EchoIntervalExpired()) + { + DriveIO(stream); + } + + // Check if expected response was received. + if (gPingArguments.IsWaitingForEchoResp()) + { + streamer_printf(stream, "No response received\n"); + gPingArguments.SetWaitingForEchoResp(false); + } + } + + gEchoClient.Shutdown(); + gExchangeManager.Shutdown(); + gSessionManager.Shutdown(); + +exit: + if ((err != CHIP_NO_ERROR)) + { + streamer_printf(stream, "Ping failed with error: %s\n", ErrorStr(err)); + } +} + +void PrintUsage(streamer_t * stream) +{ + streamer_printf(stream, "Usage: ping [options] \n\nOptions:\n"); + + streamer_printf(stream, + " -h print help information\n" + " -u use UDP (default)\n" + " -t use TCP\n" + " -p echo server port\n" + " -i ping interval time in seconds\n" + " -c stop after replies\n" + " -r <1|0> enalbe/disable CRMP\n"); +} + +int cmd_ping(int argc, char ** argv) +{ + streamer_t * sout = streamer_get(); + int ret = 0; + int optIndex = 0; + + gPingArguments.Reset(); + + while (optIndex < argc && argv[optIndex][0] == '-') + { + switch (argv[optIndex][1]) + { + case 'h': + PrintUsage(sout); + return 0; + case 'u': + gPingArguments.SetUsingTCP(false); + break; + case 't': + gPingArguments.SetUsingTCP(true); + break; + case 'i': + if (++optIndex >= argc || argv[optIndex][0] == '-') + { + streamer_printf(sout, "Invalid argument specified for -i\n"); + return -1; + } + else + { + gPingArguments.SetEchoInterval(atol(argv[optIndex]) * 1000); + } + break; + case 'c': + if (++optIndex >= argc || argv[optIndex][0] == '-') + { + streamer_printf(sout, "Invalid argument specified for -c\n"); + return -1; + } + else + { + gPingArguments.SetMaxEchoCount(atol(argv[optIndex])); + } + break; + case 'p': + if (++optIndex >= argc || argv[optIndex][0] == '-') + { + streamer_printf(sout, "Invalid argument specified for -c\n"); + return -1; + } + else + { + gPingArguments.SetEchoPort(atol(argv[optIndex])); + } + break; + case 'r': + if (++optIndex >= argc || argv[optIndex][0] == '-') + { + streamer_printf(sout, "Invalid argument specified for -r\n"); + return -1; + } + else + { + int arg = atoi(argv[optIndex]); + + if (arg == 0) + { + gPingArguments.SetUsingCRMP(false); + } + else if (arg == 1) + { + gPingArguments.SetUsingCRMP(true); + } + else + { + ret = -1; + } + } + break; + default: + ret = -1; + } + + optIndex++; + } + + if (optIndex >= argc) + { + streamer_printf(sout, "Missing IP address\n"); + ret = -1; + } + + if (ret == 0) + { + streamer_printf(sout, "IP address: %s\n", argv[optIndex]); + StartPinging(sout, argv[optIndex]); + } + + return ret; +} + +} // namespace + +static shell_command_t cmds_ping[] = { + { &cmd_ping, "ping", "Using Echo Protocol to measure packet loss across network paths" }, +}; + +void cmd_ping_init() +{ + shell_register(cmds_ping, ArraySize(cmds_ping)); +} diff --git a/examples/shell/shell_common/include/ChipShellCollection.h b/examples/shell/shell_common/include/ChipShellCollection.h index 3306a4cb03c0a2..1e837d71b4d888 100644 --- a/examples/shell/shell_common/include/ChipShellCollection.h +++ b/examples/shell/shell_common/include/ChipShellCollection.h @@ -24,4 +24,5 @@ void cmd_btp_init(void); void cmd_device_init(void); void cmd_misc_init(void); void cmd_otcli_init(void); +void cmd_ping_init(void); } diff --git a/examples/shell/standalone/main.cpp b/examples/shell/standalone/main.cpp index a6a14f3975e41b..9642f33c34963e 100644 --- a/examples/shell/standalone/main.cpp +++ b/examples/shell/standalone/main.cpp @@ -46,6 +46,10 @@ int main() cmd_btp_init(); cmd_otcli_init(); +#ifndef CHIP_DEVICE_CONFIG_DISABLE_SHELL_PING + cmd_ping_init(); +#endif + shell_task(nullptr); return 0; } diff --git a/src/messaging/tests/echo/echo_requester.cpp b/src/messaging/tests/echo/echo_requester.cpp index 275d39dc0d8921..9f0cc44e647b5c 100644 --- a/src/messaging/tests/echo/echo_requester.cpp +++ b/src/messaging/tests/echo/echo_requester.cpp @@ -103,7 +103,7 @@ CHIP_ERROR SendEchoRequest(void) printf("\nSend echo request message to Node: %" PRIu64 "\n", chip::kTestDeviceNodeId); - err = gEchoClient.SendEchoRequest(std::move(payloadBuf)); + err = gEchoClient.SendEchoRequest(std::move(payloadBuf), chip::Messaging::SendFlags(chip::Messaging::SendMessageFlags::kNone)); if (err == CHIP_NO_ERROR) { diff --git a/src/protocols/echo/Echo.h b/src/protocols/echo/Echo.h index cbf0abb6a7627c..271f512f8c48e2 100644 --- a/src/protocols/echo/Echo.h +++ b/src/protocols/echo/Echo.h @@ -87,14 +87,14 @@ class DLL_EXPORT EchoClient : public Messaging::ExchangeDelegate /** * Send an echo request to a CHIP node. * - * @param nodeId The destination's nodeId * @param payload A PacketBufferHandle with the payload. + * @param sendFlags Flags set by the application for the CHIP message being sent. * * @return CHIP_ERROR_NO_MEMORY if no ExchangeContext is available. * Other CHIP_ERROR codes as returned by the lower layers. * */ - CHIP_ERROR SendEchoRequest(System::PacketBufferHandle && payload); + CHIP_ERROR SendEchoRequest(System::PacketBufferHandle && payload, const Messaging::SendFlags & sendFlags); private: Messaging::ExchangeManager * mExchangeMgr = nullptr; diff --git a/src/protocols/echo/EchoClient.cpp b/src/protocols/echo/EchoClient.cpp index 70a9405bcb6bb1..6feeafeca94e80 100644 --- a/src/protocols/echo/EchoClient.cpp +++ b/src/protocols/echo/EchoClient.cpp @@ -50,9 +50,12 @@ void EchoClient::Shutdown() mExchangeCtx->Abort(); mExchangeCtx = nullptr; } + + OnEchoResponseReceived = nullptr; + mExchangeMgr = nullptr; } -CHIP_ERROR EchoClient::SendEchoRequest(System::PacketBufferHandle && payload) +CHIP_ERROR EchoClient::SendEchoRequest(System::PacketBufferHandle && payload, const Messaging::SendFlags & sendFlags) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -72,8 +75,7 @@ CHIP_ERROR EchoClient::SendEchoRequest(System::PacketBufferHandle && payload) } // Send an Echo Request message. Discard the exchange context if the send fails. - err = mExchangeCtx->SendMessage(MsgType::EchoRequest, std::move(payload), - Messaging::SendFlags(Messaging::SendMessageFlags::kNone)); + err = mExchangeCtx->SendMessage(MsgType::EchoRequest, std::move(payload), sendFlags); if (err != CHIP_NO_ERROR) { diff --git a/src/transport/SecureSessionMgr.cpp b/src/transport/SecureSessionMgr.cpp index 95219e5af0b098..8c4cad670ba81e 100644 --- a/src/transport/SecureSessionMgr.cpp +++ b/src/transport/SecureSessionMgr.cpp @@ -85,6 +85,16 @@ CHIP_ERROR SecureSessionMgr::Init(NodeId localNodeId, System::Layer * systemLaye return CHIP_NO_ERROR; } +void SecureSessionMgr::Shutdown() +{ + mState = State::kNotReady; + mLocalNodeId = kUndefinedNodeId; + mSystemLayer = nullptr; + mTransportMgr = nullptr; + mAdmins = nullptr; + mCB = nullptr; +} + Transport::Type SecureSessionMgr::GetTransportType(NodeId peerNodeId) { PeerConnectionState * state = mPeerConnections.FindPeerConnectionState(peerNodeId, nullptr); diff --git a/src/transport/SecureSessionMgr.h b/src/transport/SecureSessionMgr.h index 443262006894f9..eeef685420e596 100644 --- a/src/transport/SecureSessionMgr.h +++ b/src/transport/SecureSessionMgr.h @@ -270,6 +270,13 @@ class DLL_EXPORT SecureSessionMgr : public TransportMgrDelegate CHIP_ERROR Init(NodeId localNodeId, System::Layer * systemLayer, TransportMgrBase * transportMgr, Transport::AdminPairingTable * admins); + /** + * @brief + * Shutdown the Secure Session Manager. This terminates this instance + * of the object and reset it's state. + */ + void Shutdown(); + /** * @brief * Set local node ID From 8ea423ae5981596e67304ebc7b2e5072b48ba8c8 Mon Sep 17 00:00:00 2001 From: Kevin Schoedel <67607049+kpschoedel@users.noreply.github.com> Date: Thu, 11 Mar 2021 11:49:18 -0500 Subject: [PATCH 04/39] #### Problem (#5319) - `BitFlags.h` has relatively unsafe deprecated functions. - Some bit flags use `enum` rather than type-safe `enum class`. #### Summary of Changes - Removed deprecated `SetFlags()`, `ClearFlags()`, and `GetFlags()`, replacing uses with `BitFlags`. - BitFlags.h changes: - Default to use `std::underlying_type` rather than requiring it as a template parameter. - Added `BitFlags` operations to reduce uses of type-unsafe `Raw()` and `SetRaw()`: - Multi-argument constructors. - `operator FlagsEnum()`. - `ClearAll()`. - `HasAny()` and `HasAll()`, following the pattern of the existing `HasOnly()`. - Binary `&`. - Converted various bit flag types from `enum` to `enum class`: - BLEEndPoint::ConnectionStateFlags - BLEEndPoint::TimerStateFlags - BLEManagerImpl::Flags - Command::CommandPathFlags - Encoding::HexFlags - GenericConfigurationManagerImpl::Flags - GenericConnectivityManagerImpl_Thread::Flags - GenericConnectivityManagerImpl_WiFi::ConnectivityFlags - bdx::RangeControlFlags - bdx::StatusCode - bdx::TransferControlFlags - bdx::TransferRole Reland of 4b8d5582 (#5232) to a logic error in `*/BLEManagerImpl.cpp` and a large accidental deletion in `K32W/BLEManagerImpl.cpp`. --- src/app/Command.cpp | 18 +- src/app/Command.h | 25 +- .../tests/integration/chip_im_initiator.cpp | 4 +- .../tests/integration/chip_im_responder.cpp | 4 +- .../util/ember-compatibility-functions.cpp | 2 +- .../templates/chip/CHIPClusters-src.zapt | 2 +- src/ble/BLEEndPoint.cpp | 107 +++--- src/ble/BLEEndPoint.h | 36 +- src/ble/BtpEngine.cpp | 47 +-- src/ble/BtpEngine.h | 20 +- src/controller/CHIPClusters.cpp | 186 +++++----- src/credentials/CHIPCert.cpp | 39 +- src/credentials/CHIPCert.h | 64 ++-- src/credentials/CHIPCertFromX509.cpp | 3 +- src/credentials/CHIPCertToX509.cpp | 19 +- .../tests/CHIPCert_test_vectors.cpp | 6 +- src/credentials/tests/CHIPCert_test_vectors.h | 7 +- src/credentials/tests/TestChipCert.cpp | 114 +++--- .../GenericConfigurationManagerImpl.cpp | 47 ++- .../GenericConfigurationManagerImpl.h | 18 +- .../GenericConnectivityManagerImpl_Thread.cpp | 14 +- .../GenericConnectivityManagerImpl_Thread.h | 19 +- .../GenericConnectivityManagerImpl_WiFi.h | 10 +- src/lib/support/BitFlags.h | 233 ++++++++---- src/lib/support/BytesToHex.cpp | 6 +- src/lib/support/BytesToHex.h | 6 +- src/messaging/ExchangeContext.h | 4 +- src/messaging/Flags.h | 6 +- src/messaging/ReliableMessageContext.cpp | 4 +- src/messaging/ReliableMessageContext.h | 6 +- src/platform/EFR32/BLEManagerImpl.cpp | 39 +- src/platform/EFR32/BLEManagerImpl.h | 22 +- src/platform/ESP32/BLEManagerImpl.h | 36 +- .../ESP32/ConnectivityManagerImpl.cpp | 16 +- src/platform/ESP32/ConnectivityManagerImpl.h | 10 +- .../ESP32/bluedroid/BLEManagerImpl.cpp | 114 +++--- src/platform/ESP32/nimble/BLEManagerImpl.cpp | 74 ++-- src/platform/K32W/BLEManagerImpl.cpp | 56 ++- src/platform/K32W/BLEManagerImpl.h | 17 +- src/platform/Linux/BLEManagerImpl.cpp | 71 ++-- src/platform/Linux/BLEManagerImpl.h | 32 +- .../Linux/ConnectivityManagerImpl.cpp | 15 +- src/platform/Linux/ConnectivityManagerImpl.h | 4 +- src/platform/Linux/bluez/Helper.cpp | 2 +- src/platform/Zephyr/BLEManagerImpl.cpp | 42 +-- src/platform/Zephyr/BLEManagerImpl.h | 22 +- src/platform/cc13x2_26x2/BLEManagerImpl.cpp | 55 ++- src/platform/qpg6100/BLEManagerImpl.cpp | 52 +-- src/platform/qpg6100/BLEManagerImpl.h | 25 +- src/protocols/bdx/BdxMessages.cpp | 77 ++-- src/protocols/bdx/BdxMessages.h | 56 +-- src/protocols/bdx/BdxTransferSession.cpp | 341 +++++++++--------- src/protocols/bdx/BdxTransferSession.h | 30 +- src/protocols/bdx/tests/TestBdxMessages.cpp | 9 +- .../bdx/tests/TestBdxTransferSession.cpp | 180 ++++----- .../AdditionalDataPayloadGenerator.cpp | 2 +- .../AdditionalDataPayloadGenerator.h | 2 +- src/transport/raw/MessageHeader.cpp | 8 +- src/transport/raw/MessageHeader.h | 8 +- 59 files changed, 1293 insertions(+), 1200 deletions(-) diff --git a/src/app/Command.cpp b/src/app/Command.cpp index 110999635d5cf7..432e39b7075070 100644 --- a/src/app/Command.cpp +++ b/src/app/Command.cpp @@ -152,18 +152,10 @@ chip::TLV::TLVWriter & Command::CreateCommandDataElementTLVWriter() return mCommandDataWriter; } -CHIP_ERROR Command::AddCommand(chip::EndpointId aEndpintId, chip::GroupId aGroupId, chip::ClusterId aClusterId, - chip::CommandId aCommandId, uint8_t aFlags) +CHIP_ERROR Command::AddCommand(chip::EndpointId aEndpointId, chip::GroupId aGroupId, chip::ClusterId aClusterId, + chip::CommandId aCommandId, BitFlags aFlags) { - CommandParams commandParams; - - memset(&commandParams, 0, sizeof(CommandParams)); - - commandParams.EndpointId = aEndpintId; - commandParams.GroupId = aGroupId; - commandParams.ClusterId = aClusterId; - commandParams.CommandId = aCommandId; - commandParams.Flags = aFlags; + CommandParams commandParams(aEndpointId, aGroupId, aClusterId, aCommandId, aFlags); return AddCommand(commandParams); } @@ -191,12 +183,12 @@ CHIP_ERROR Command::AddCommand(CommandParams & aCommandParams) CommandDataElement::Builder commandDataElement = mInvokeCommandBuilder.GetCommandListBuilder().CreateCommandDataElementBuilder(); CommandPath::Builder commandPath = commandDataElement.CreateCommandPathBuilder(); - if (aCommandParams.Flags & kCommandPathFlag_EndpointIdValid) + if (aCommandParams.Flags.Has(CommandPathFlags::kEndpointIdValid)) { commandPath.EndpointId(aCommandParams.EndpointId); } - if (aCommandParams.Flags & kCommandPathFlag_GroupIdValid) + if (aCommandParams.Flags.Has(CommandPathFlags::kGroupIdValid)) { commandPath.GroupId(aCommandParams.GroupId); } diff --git a/src/app/Command.h b/src/app/Command.h index 19ebc7d0e43bd6..5103e05514831a 100644 --- a/src/app/Command.h +++ b/src/app/Command.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -59,25 +60,31 @@ class Command Sending, //< The invoke command message has sent out the invoke command }; + enum class CommandPathFlags : uint8_t + { + kEndpointIdValid = 0x01, /**< Set when the EndpointId field is valid */ + kGroupIdValid = 0x02, /**< Set when the GroupId field is valid */ + }; + /** * Encapsulates arguments to be passed into SendCommand(). * */ struct CommandParams { + CommandParams(chip::EndpointId endpointId, chip::GroupId groupId, chip::ClusterId clusterId, chip::CommandId commandId, + const BitFlags & flags) : + EndpointId(endpointId), + GroupId(groupId), ClusterId(clusterId), CommandId(commandId), Flags(flags) + {} + chip::EndpointId EndpointId; chip::GroupId GroupId; chip::ClusterId ClusterId; chip::CommandId CommandId; - uint8_t Flags; + BitFlags Flags; }; - enum CommandPathFlags - { - kCommandPathFlag_EndpointIdValid = 0x0001, /**< Set when the EndpointId field is valid */ - kCommandPathFlag_GroupIdValid = 0x0002, /**< Set when the GroupId field is valid */ - } CommandPathFlags; - /** * Initialize the Command object. Within the lifetime * of this instance, this method is invoked once after object @@ -110,7 +117,7 @@ class Command chip::TLV::TLVWriter & CreateCommandDataElementTLVWriter(); CHIP_ERROR AddCommand(chip::EndpointId aEndpintId, chip::GroupId aGroupId, chip::ClusterId aClusterId, - chip::CommandId aCommandId, uint8_t Flags); + chip::CommandId aCommandId, BitFlags Flags); CHIP_ERROR AddCommand(CommandParams & aCommandParams); CHIP_ERROR AddStatusCode(const uint16_t aGeneralCode, const uint32_t aProtocolId, const uint16_t aProtocolCode, const chip::ClusterId aClusterId); diff --git a/src/app/tests/integration/chip_im_initiator.cpp b/src/app/tests/integration/chip_im_initiator.cpp index c35de4bc95a86e..a536fa9e263ca9 100644 --- a/src/app/tests/integration/chip_im_initiator.cpp +++ b/src/app/tests/integration/chip_im_initiator.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -90,7 +90,7 @@ CHIP_ERROR SendCommandRequest(void) kTestGroupId, // GroupId kTestClusterId, // ClusterId kTestCommandId, // CommandId - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; // Add command data here diff --git a/src/app/tests/integration/chip_im_responder.cpp b/src/app/tests/integration/chip_im_responder.cpp index bde7daf7610907..f4f3d3dfcbb57f 100644 --- a/src/app/tests/integration/chip_im_responder.cpp +++ b/src/app/tests/integration/chip_im_responder.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,7 +60,7 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC kTestGroupId, // GroupId kTestClusterId, // ClusterId kTestCommandId, // CommandId - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; // Add command data here diff --git a/src/app/util/ember-compatibility-functions.cpp b/src/app/util/ember-compatibility-functions.cpp index 017d7a0d5df228..981ec253e6fffc 100644 --- a/src/app/util/ember-compatibility-functions.cpp +++ b/src/app/util/ember-compatibility-functions.cpp @@ -73,7 +73,7 @@ bool IMEmberAfSendDefaultResponseWithCallback(EmberAfStatus status) 0, // GroupId imCompatibilityEmberApsFrame.clusterId, imCompatibilityEmberAfCluster.commandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; chip::TLV::TLVType dummyType = chip::TLV::kTLVType_NotSpecified; chip::TLV::TLVWriter writer = currentCommandObject->CreateCommandDataElementTLVWriter(); diff --git a/src/app/zap-templates/templates/chip/CHIPClusters-src.zapt b/src/app/zap-templates/templates/chip/CHIPClusters-src.zapt index bcfa34eca00cb4..b06cb3c7832109 100644 --- a/src/app/zap-templates/templates/chip/CHIPClusters-src.zapt +++ b/src/app/zap-templates/templates/chip/CHIPClusters-src.zapt @@ -26,7 +26,7 @@ CHIP_ERROR {{asCamelCased clusterName false}}Cluster::{{asCamelCased name false} (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, k{{asCamelCased name false}}CommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); diff --git a/src/ble/BLEEndPoint.cpp b/src/ble/BLEEndPoint.cpp index 6abdb70877ffe8..aaf0d52c7aec3f 100644 --- a/src/ble/BLEEndPoint.cpp +++ b/src/ble/BLEEndPoint.cpp @@ -272,7 +272,7 @@ void BLEEndPoint::HandleSubscribeReceived() void BLEEndPoint::HandleSubscribeComplete() { ChipLogProgress(Ble, "subscribe complete, ep = %p", this); - SetFlag(mConnStateFlags, kConnState_GattOperationInFlight, false); + mConnStateFlags.Clear(ConnectionStateFlag::kGattOperationInFlight); BLE_ERROR err = DriveSending(); @@ -295,7 +295,7 @@ bool BLEEndPoint::IsConnected(uint8_t state) const bool BLEEndPoint::IsUnsubscribePending() const { - return (GetFlag(mTimerStateFlags, kTimerState_UnsubscribeTimerRunning)); + return mTimerStateFlags.Has(TimerStateFlag::kUnsubscribeTimerRunning); } void BLEEndPoint::Abort() @@ -392,7 +392,7 @@ void BLEEndPoint::FinalizeClose(uint8_t oldState, uint8_t flags, BLE_ERROR err) } else // Otherwise, try to signal close to remote device before end point releases BLE connection and frees itself. { - if (mRole == kBleRole_Central && GetFlag(mConnStateFlags, kConnState_DidBeginSubscribe)) + if (mRole == kBleRole_Central && mConnStateFlags.Has(ConnectionStateFlag::kDidBeginSubscribe)) { // Cancel send and receive-ack timers, if running. StopAckReceivedTimer(); @@ -420,10 +420,10 @@ void BLEEndPoint::FinalizeClose(uint8_t oldState, uint8_t flags, BLE_ERROR err) } // Mark unsubscribe GATT operation in progress. - SetFlag(mConnStateFlags, kConnState_GattOperationInFlight, true); + mConnStateFlags.Set(ConnectionStateFlag::kGattOperationInFlight); } } - else // mRole == kBleRole_Peripheral, OR GetFlag(mTimerStateFlags, kConnState_DidBeginSubscribe) == false... + else // mRole == kBleRole_Peripheral, OR mTimerStateFlags.Has(ConnectionStateFlag::kDidBeginSubscribe) == false... { Free(); } @@ -456,7 +456,7 @@ void BLEEndPoint::ReleaseBleConnection() { if (mConnObj != BLE_CONNECTION_UNINITIALIZED) { - if (GetFlag(mConnStateFlags, kConnState_AutoClose)) + if (mConnStateFlags.Has(ConnectionStateFlag::kAutoClose)) { ChipLogProgress(Ble, "Auto-closing end point's BLE connection."); mBle->mPlatformDelegate->CloseConnection(mConnObj); @@ -562,11 +562,10 @@ BLE_ERROR BLEEndPoint::Init(BleLayer * bleLayer, BLE_CONNECTION_OBJECT connObj, mRefCount = 1; // BLEEndPoint data members: - mConnObj = connObj; - mRole = role; - mConnStateFlags = 0; - mTimerStateFlags = 0; - SetFlag(mConnStateFlags, kConnState_AutoClose, autoClose); + mConnObj = connObj; + mRole = role; + mTimerStateFlags.ClearAll(); + mConnStateFlags.ClearAll().Set(ConnectionStateFlag::kAutoClose, autoClose); mLocalReceiveWindowSize = 0; mRemoteReceiveWindowSize = 0; mReceiveWindowMaxSize = 0; @@ -686,7 +685,7 @@ BLE_ERROR BLEEndPoint::Send(PacketBufferHandle data) bool BLEEndPoint::PrepareNextFragment(PacketBufferHandle && data, bool & sentAck) { // If we have a pending fragment acknowledgement to send, piggyback it on the fragment we're about to transmit. - if (GetFlag(mTimerStateFlags, kTimerState_SendAckTimerRunning)) + if (mTimerStateFlags.Has(TimerStateFlag::kSendAckTimerRunning)) { // Reset local receive window counter. mLocalReceiveWindowSize = mReceiveWindowMaxSize; @@ -818,10 +817,10 @@ BLE_ERROR BLEEndPoint::HandleHandshakeConfirmationReceived() err = BLE_ERROR_GATT_SUBSCRIBE_FAILED); // We just sent a GATT subscribe request, so make sure to attempt unsubscribe on close. - SetFlag(mConnStateFlags, kConnState_DidBeginSubscribe, true); + mConnStateFlags.Set(ConnectionStateFlag::kDidBeginSubscribe); // Mark GATT operation in progress for subscribe request. - SetFlag(mConnStateFlags, kConnState_GattOperationInFlight, true); + mConnStateFlags.Set(ConnectionStateFlag::kGattOperationInFlight); } else // (mRole == kBleRole_Peripheral), verified on Init { @@ -882,12 +881,12 @@ BLE_ERROR BLEEndPoint::HandleFragmentConfirmationReceived() // TODO Packet buffer high water mark optimization: if ack pending, but fragmenter state == complete, free fragmenter's // tx buf before sending ack. - if (GetFlag(mConnStateFlags, kConnState_StandAloneAckInFlight)) + if (mConnStateFlags.Has(ConnectionStateFlag::kStandAloneAckInFlight)) { // If confirmation was received for stand-alone ack, free its tx buffer. mAckToSend = nullptr; - SetFlag(mConnStateFlags, kConnState_StandAloneAckInFlight, false); + mConnStateFlags.Clear(ConnectionStateFlag::kStandAloneAckInFlight); } // If local receive window size has shrunk to or below immediate ack threshold, AND a message fragment is not @@ -922,12 +921,12 @@ BLE_ERROR BLEEndPoint::HandleGattSendConfirmationReceived() ChipLogDebugBleEndPoint(Ble, "entered HandleGattSendConfirmationReceived"); // Mark outstanding GATT operation as finished. - SetFlag(mConnStateFlags, kConnState_GattOperationInFlight, false); + mConnStateFlags.Clear(ConnectionStateFlag::kGattOperationInFlight); // If confirmation was for outbound portion of BTP connect handshake... - if (!GetFlag(mConnStateFlags, kConnState_CapabilitiesConfReceived)) + if (!mConnStateFlags.Has(ConnectionStateFlag::kCapabilitiesConfReceived)) { - SetFlag(mConnStateFlags, kConnState_CapabilitiesConfReceived, true); + mConnStateFlags.Set(ConnectionStateFlag::kCapabilitiesConfReceived); return HandleHandshakeConfirmationReceived(); } @@ -970,7 +969,7 @@ BLE_ERROR BLEEndPoint::DoSendStandAloneAck() mLocalReceiveWindowSize = mReceiveWindowMaxSize; ChipLogDebugBleEndPoint(Ble, "reset local rx window on stand-alone ack tx, size = %u", mLocalReceiveWindowSize); - SetFlag(mConnStateFlags, kConnState_StandAloneAckInFlight, true); + mConnStateFlags.Set(ConnectionStateFlag::kStandAloneAckInFlight); // Start ack received timer, if it's not already running. err = StartAckReceivedTimer(); @@ -989,12 +988,12 @@ BLE_ERROR BLEEndPoint::DriveSending() // If receiver's window is almost closed and we don't have an ack to send, OR we do have an ack to send but // receiver's window is completely empty, OR another GATT operation is in flight, awaiting confirmation... if ((mRemoteReceiveWindowSize <= BTP_WINDOW_NO_ACK_SEND_THRESHOLD && - !GetFlag(mTimerStateFlags, kTimerState_SendAckTimerRunning) && mAckToSend.IsNull()) || - (mRemoteReceiveWindowSize == 0) || (GetFlag(mConnStateFlags, kConnState_GattOperationInFlight))) + !mTimerStateFlags.Has(TimerStateFlag::kSendAckTimerRunning) && mAckToSend.IsNull()) || + (mRemoteReceiveWindowSize == 0) || (mConnStateFlags.Has(ConnectionStateFlag::kGattOperationInFlight))) { #ifdef CHIP_BLE_END_POINT_DEBUG_LOGGING_ENABLED if (mRemoteReceiveWindowSize <= BTP_WINDOW_NO_ACK_SEND_THRESHOLD && - !GetFlag(mTimerStateFlags, kTimerState_SendAckTimerRunning) && mAckToSend == NULL) + !mTimerStateFlags.Has(TimerStateFlag::kSendAckTimerRunning) && mAckToSend == NULL) { ChipLogDebugBleEndPoint(Ble, "NO SEND: receive window almost closed, and no ack to send"); } @@ -1004,7 +1003,7 @@ BLE_ERROR BLEEndPoint::DriveSending() ChipLogDebugBleEndPoint(Ble, "NO SEND: remote receive window closed"); } - if (GetFlag(mConnStateFlags, kConnState_GattOperationInFlight)) + if (mConnStateFlags.Has(ConnectionStateFlag::kGattOperationInFlight)) { ChipLogDebugBleEndPoint(Ble, "NO SEND: Gatt op in flight"); } @@ -1273,13 +1272,13 @@ BLE_ERROR BLEEndPoint::Receive(PacketBufferHandle data) } // If we're receiving the first inbound packet of a BLE transport connection handshake... - if (!GetFlag(mConnStateFlags, kConnState_CapabilitiesMsgReceived)) + if (!mConnStateFlags.Has(ConnectionStateFlag::kCapabilitiesMsgReceived)) { if (mRole == kBleRole_Central) // If we're a central receiving a capabilities response indication... { // Ensure end point's in the right state before continuing. VerifyOrExit(mState == kState_Connecting, err = BLE_ERROR_INCORRECT_STATE); - SetFlag(mConnStateFlags, kConnState_CapabilitiesMsgReceived, true); + mConnStateFlags.Set(ConnectionStateFlag::kCapabilitiesMsgReceived); err = HandleCapabilitiesResponseReceived(std::move(data)); SuccessOrExit(err); @@ -1288,7 +1287,7 @@ BLE_ERROR BLEEndPoint::Receive(PacketBufferHandle data) { // Ensure end point's in the right state before continuing. VerifyOrExit(mState == kState_Ready, err = BLE_ERROR_INCORRECT_STATE); - SetFlag(mConnStateFlags, kConnState_CapabilitiesMsgReceived, true); + mConnStateFlags.Set(ConnectionStateFlag::kCapabilitiesMsgReceived); err = HandleCapabilitiesRequestReceived(std::move(data)); @@ -1391,7 +1390,7 @@ BLE_ERROR BLEEndPoint::Receive(PacketBufferHandle data) if (mBtpEngine.HasUnackedData()) { if (mLocalReceiveWindowSize <= BLE_CONFIG_IMMEDIATE_ACK_WINDOW_THRESHOLD && - !GetFlag(mConnStateFlags, kConnState_GattOperationInFlight)) + !mConnStateFlags.Has(ConnectionStateFlag::kGattOperationInFlight)) { ChipLogDebugBleEndPoint(Ble, "sending immediate ack"); err = DriveStandAloneAck(); @@ -1446,14 +1445,14 @@ BLE_ERROR BLEEndPoint::Receive(PacketBufferHandle data) bool BLEEndPoint::SendWrite(PacketBufferHandle && buf) { - SetFlag(mConnStateFlags, kConnState_GattOperationInFlight, true); + mConnStateFlags.Set(ConnectionStateFlag::kGattOperationInFlight); return mBle->mPlatformDelegate->SendWriteRequest(mConnObj, &CHIP_BLE_SVC_ID, &mBle->CHIP_BLE_CHAR_1_ID, std::move(buf)); } bool BLEEndPoint::SendIndication(PacketBufferHandle && buf) { - SetFlag(mConnStateFlags, kConnState_GattOperationInFlight, true); + mConnStateFlags.Set(ConnectionStateFlag::kGattOperationInFlight); return mBle->mPlatformDelegate->SendIndication(mConnObj, &CHIP_BLE_SVC_ID, &mBle->CHIP_BLE_CHAR_2_ID, std::move(buf)); } @@ -1465,7 +1464,7 @@ BLE_ERROR BLEEndPoint::StartConnectTimer() timerErr = mBle->mSystemLayer->StartTimer(BLE_CONNECT_TIMEOUT_MS, HandleConnectTimeout, this); VerifyOrExit(timerErr == CHIP_SYSTEM_NO_ERROR, err = BLE_ERROR_START_TIMER_FAILED); - SetFlag(mTimerStateFlags, kTimerState_ConnectTimerRunning, true); + mTimerStateFlags.Set(TimerStateFlag::kConnectTimerRunning); exit: return err; @@ -1478,7 +1477,7 @@ BLE_ERROR BLEEndPoint::StartReceiveConnectionTimer() timerErr = mBle->mSystemLayer->StartTimer(BLE_CONNECT_TIMEOUT_MS, HandleReceiveConnectionTimeout, this); VerifyOrExit(timerErr == CHIP_SYSTEM_NO_ERROR, err = BLE_ERROR_START_TIMER_FAILED); - SetFlag(mTimerStateFlags, kTimerState_ReceiveConnectionTimerRunning, true); + mTimerStateFlags.Set(TimerStateFlag::kReceiveConnectionTimerRunning); exit: return err; @@ -1489,12 +1488,12 @@ BLE_ERROR BLEEndPoint::StartAckReceivedTimer() BLE_ERROR err = BLE_NO_ERROR; chip::System::Error timerErr; - if (!GetFlag(mTimerStateFlags, kTimerState_AckReceivedTimerRunning)) + if (!mTimerStateFlags.Has(TimerStateFlag::kAckReceivedTimerRunning)) { timerErr = mBle->mSystemLayer->StartTimer(BTP_ACK_RECEIVED_TIMEOUT_MS, HandleAckReceivedTimeout, this); VerifyOrExit(timerErr == CHIP_SYSTEM_NO_ERROR, err = BLE_ERROR_START_TIMER_FAILED); - SetFlag(mTimerStateFlags, kTimerState_AckReceivedTimerRunning, true); + mTimerStateFlags.Set(TimerStateFlag::kAckReceivedTimerRunning); } exit: @@ -1505,7 +1504,7 @@ BLE_ERROR BLEEndPoint::RestartAckReceivedTimer() { BLE_ERROR err = BLE_NO_ERROR; - VerifyOrExit(GetFlag(mTimerStateFlags, kTimerState_AckReceivedTimerRunning), err = BLE_ERROR_INCORRECT_STATE); + VerifyOrExit(mTimerStateFlags.Has(TimerStateFlag::kAckReceivedTimerRunning), err = BLE_ERROR_INCORRECT_STATE); StopAckReceivedTimer(); @@ -1523,13 +1522,13 @@ BLE_ERROR BLEEndPoint::StartSendAckTimer() ChipLogDebugBleEndPoint(Ble, "entered StartSendAckTimer"); - if (!GetFlag(mTimerStateFlags, kTimerState_SendAckTimerRunning)) + if (!mTimerStateFlags.Has(TimerStateFlag::kSendAckTimerRunning)) { ChipLogDebugBleEndPoint(Ble, "starting new SendAckTimer"); timerErr = mBle->mSystemLayer->StartTimer(BTP_ACK_SEND_TIMEOUT_MS, HandleSendAckTimeout, this); VerifyOrExit(timerErr == CHIP_SYSTEM_NO_ERROR, err = BLE_ERROR_START_TIMER_FAILED); - SetFlag(mTimerStateFlags, kTimerState_SendAckTimerRunning, true); + mTimerStateFlags.Set(TimerStateFlag::kSendAckTimerRunning); } exit: @@ -1543,7 +1542,7 @@ BLE_ERROR BLEEndPoint::StartUnsubscribeTimer() timerErr = mBle->mSystemLayer->StartTimer(BLE_UNSUBSCRIBE_TIMEOUT_MS, HandleUnsubscribeTimeout, this); VerifyOrExit(timerErr == CHIP_SYSTEM_NO_ERROR, err = BLE_ERROR_START_TIMER_FAILED); - SetFlag(mTimerStateFlags, kTimerState_UnsubscribeTimerRunning, true); + mTimerStateFlags.Set(TimerStateFlag::kUnsubscribeTimerRunning); exit: return err; @@ -1553,35 +1552,35 @@ void BLEEndPoint::StopConnectTimer() { // Cancel any existing connect timer. mBle->mSystemLayer->CancelTimer(HandleConnectTimeout, this); - SetFlag(mTimerStateFlags, kTimerState_ConnectTimerRunning, false); + mTimerStateFlags.Clear(TimerStateFlag::kConnectTimerRunning); } void BLEEndPoint::StopReceiveConnectionTimer() { // Cancel any existing receive connection timer. mBle->mSystemLayer->CancelTimer(HandleReceiveConnectionTimeout, this); - SetFlag(mTimerStateFlags, kTimerState_ReceiveConnectionTimerRunning, false); + mTimerStateFlags.Clear(TimerStateFlag::kReceiveConnectionTimerRunning); } void BLEEndPoint::StopAckReceivedTimer() { // Cancel any existing ack-received timer. mBle->mSystemLayer->CancelTimer(HandleAckReceivedTimeout, this); - SetFlag(mTimerStateFlags, kTimerState_AckReceivedTimerRunning, false); + mTimerStateFlags.Clear(TimerStateFlag::kAckReceivedTimerRunning); } void BLEEndPoint::StopSendAckTimer() { // Cancel any existing send-ack timer. mBle->mSystemLayer->CancelTimer(HandleSendAckTimeout, this); - SetFlag(mTimerStateFlags, kTimerState_SendAckTimerRunning, false); + mTimerStateFlags.Clear(TimerStateFlag::kSendAckTimerRunning); } void BLEEndPoint::StopUnsubscribeTimer() { // Cancel any existing unsubscribe timer. mBle->mSystemLayer->CancelTimer(HandleUnsubscribeTimeout, this); - SetFlag(mTimerStateFlags, kTimerState_UnsubscribeTimerRunning, false); + mTimerStateFlags.Clear(TimerStateFlag::kUnsubscribeTimerRunning); } void BLEEndPoint::HandleConnectTimeout(chip::System::Layer * systemLayer, void * appState, chip::System::Error err) @@ -1589,10 +1588,10 @@ void BLEEndPoint::HandleConnectTimeout(chip::System::Layer * systemLayer, void * BLEEndPoint * ep = static_cast(appState); // Check for event-based timer race condition. - if (GetFlag(ep->mTimerStateFlags, kTimerState_ConnectTimerRunning)) + if (ep->mTimerStateFlags.Has(TimerStateFlag::kConnectTimerRunning)) { ChipLogError(Ble, "connect handshake timed out, closing ep %p", ep); - SetFlag(ep->mTimerStateFlags, kTimerState_ConnectTimerRunning, false); + ep->mTimerStateFlags.Clear(TimerStateFlag::kConnectTimerRunning); ep->DoClose(kBleCloseFlag_AbortTransmission, BLE_ERROR_CONNECT_TIMED_OUT); } } @@ -1602,10 +1601,10 @@ void BLEEndPoint::HandleReceiveConnectionTimeout(chip::System::Layer * systemLay BLEEndPoint * ep = static_cast(appState); // Check for event-based timer race condition. - if (GetFlag(ep->mTimerStateFlags, kTimerState_ReceiveConnectionTimerRunning)) + if (ep->mTimerStateFlags.Has(TimerStateFlag::kReceiveConnectionTimerRunning)) { ChipLogError(Ble, "receive handshake timed out, closing ep %p", ep); - SetFlag(ep->mTimerStateFlags, kTimerState_ReceiveConnectionTimerRunning, false); + ep->mTimerStateFlags.Clear(TimerStateFlag::kReceiveConnectionTimerRunning); ep->DoClose(kBleCloseFlag_SuppressCallback | kBleCloseFlag_AbortTransmission, BLE_ERROR_RECEIVE_TIMED_OUT); } } @@ -1615,11 +1614,11 @@ void BLEEndPoint::HandleAckReceivedTimeout(chip::System::Layer * systemLayer, vo BLEEndPoint * ep = static_cast(appState); // Check for event-based timer race condition. - if (GetFlag(ep->mTimerStateFlags, kTimerState_AckReceivedTimerRunning)) + if (ep->mTimerStateFlags.Has(TimerStateFlag::kAckReceivedTimerRunning)) { ChipLogError(Ble, "ack recv timeout, closing ep %p", ep); ep->mBtpEngine.LogStateDebug(); - SetFlag(ep->mTimerStateFlags, kTimerState_AckReceivedTimerRunning, false); + ep->mTimerStateFlags.Clear(TimerStateFlag::kAckReceivedTimerRunning); ep->DoClose(kBleCloseFlag_AbortTransmission, BLE_ERROR_FRAGMENT_ACK_TIMED_OUT); } } @@ -1629,12 +1628,12 @@ void BLEEndPoint::HandleSendAckTimeout(chip::System::Layer * systemLayer, void * BLEEndPoint * ep = static_cast(appState); // Check for event-based timer race condition. - if (GetFlag(ep->mTimerStateFlags, kTimerState_SendAckTimerRunning)) + if (ep->mTimerStateFlags.Has(TimerStateFlag::kSendAckTimerRunning)) { - SetFlag(ep->mTimerStateFlags, kTimerState_SendAckTimerRunning, false); + ep->mTimerStateFlags.Clear(TimerStateFlag::kSendAckTimerRunning); // If previous stand-alone ack isn't still in flight... - if (!GetFlag(ep->mConnStateFlags, kConnState_StandAloneAckInFlight)) + if (!ep->mConnStateFlags.Has(ConnectionStateFlag::kStandAloneAckInFlight)) { BLE_ERROR sendErr = ep->DriveStandAloneAck(); @@ -1651,10 +1650,10 @@ void BLEEndPoint::HandleUnsubscribeTimeout(chip::System::Layer * systemLayer, vo BLEEndPoint * ep = static_cast(appState); // Check for event-based timer race condition. - if (GetFlag(ep->mTimerStateFlags, kTimerState_UnsubscribeTimerRunning)) + if (ep->mTimerStateFlags.Has(TimerStateFlag::kUnsubscribeTimerRunning)) { ChipLogError(Ble, "unsubscribe timed out, ble ep %p", ep); - SetFlag(ep->mTimerStateFlags, kTimerState_UnsubscribeTimerRunning, false); + ep->mTimerStateFlags.Clear(TimerStateFlag::kUnsubscribeTimerRunning); ep->HandleUnsubscribeComplete(); } } diff --git a/src/ble/BLEEndPoint.h b/src/ble/BLEEndPoint.h index 36daf0de7af5ff..cc1aa3a03119d7 100644 --- a/src/ble/BLEEndPoint.h +++ b/src/ble/BLEEndPoint.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * Copyright (c) 2014-2017 Nest Labs, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -107,26 +107,26 @@ class DLL_EXPORT BLEEndPoint : public BleLayerObject private: // Private data members: - enum ConnectionStateFlags + enum class ConnectionStateFlag : uint8_t { - kConnState_AutoClose = 0x01, // End point should close underlying BLE conn on BTP close. - kConnState_CapabilitiesConfReceived = 0x02, // GATT confirmation received for sent capabilities req/resp. - kConnState_CapabilitiesMsgReceived = 0x04, // Capabilities request or response message received. - kConnState_DidBeginSubscribe = 0x08, // GATT subscribe request sent; must unsubscribe on close. - kConnState_StandAloneAckInFlight = 0x10, // Stand-alone ack in flight, awaiting GATT confirmation. - kConnState_GattOperationInFlight = 0x20 // GATT write, indication, subscribe, or unsubscribe in flight, - // awaiting GATT confirmation. + kAutoClose = 0x01, // End point should close underlying BLE conn on BTP close. + kCapabilitiesConfReceived = 0x02, // GATT confirmation received for sent capabilities req/resp. + kCapabilitiesMsgReceived = 0x04, // Capabilities request or response message received. + kDidBeginSubscribe = 0x08, // GATT subscribe request sent; must unsubscribe on close. + kStandAloneAckInFlight = 0x10, // Stand-alone ack in flight, awaiting GATT confirmation. + kGattOperationInFlight = 0x20 // GATT write, indication, subscribe, or unsubscribe in flight, + // awaiting GATT confirmation. }; - enum TimerStateFlags + enum class TimerStateFlag : uint8_t { - kTimerState_ConnectTimerRunning = 0x01, // BTP connect completion timer running. - kTimerState_ReceiveConnectionTimerRunning = 0x02, // BTP receive connection completion timer running. - kTimerState_AckReceivedTimerRunning = 0x04, // Ack received timer running due to unacked sent fragment. - kTimerState_SendAckTimerRunning = 0x08, // Send ack timer running; indicates pending ack to send. - kTimerState_UnsubscribeTimerRunning = 0x10, // Unsubscribe completion timer running. + kConnectTimerRunning = 0x01, // BTP connect completion timer running. + kReceiveConnectionTimerRunning = 0x02, // BTP receive connection completion timer running. + kAckReceivedTimerRunning = 0x04, // Ack received timer running due to unacked sent fragment. + kSendAckTimerRunning = 0x08, // Send ack timer running; indicates pending ack to send. + kUnsubscribeTimerRunning = 0x10, // Unsubscribe completion timer running. #if CHIP_ENABLE_CHIPOBLE_TEST - kTimerState_UnderTestTimerRunnung = 0x80 // running throughput Tx test + kUnderTestTimerRunnung = 0x80 // running throughput Tx test #endif }; @@ -147,8 +147,8 @@ class DLL_EXPORT BLEEndPoint : public BleLayerObject BtpEngine mBtpEngine; BleRole mRole; - uint8_t mConnStateFlags; - uint8_t mTimerStateFlags; + BitFlags mConnStateFlags; + BitFlags mTimerStateFlags; SequenceNumber_t mLocalReceiveWindowSize; SequenceNumber_t mRemoteReceiveWindowSize; SequenceNumber_t mReceiveWindowMaxSize; diff --git a/src/ble/BtpEngine.cpp b/src/ble/BtpEngine.cpp index ef83b90a7133b7..4b62c98c2139e1 100644 --- a/src/ble/BtpEngine.cpp +++ b/src/ble/BtpEngine.cpp @@ -55,10 +55,10 @@ static inline void IncSeqNum(SequenceNumber_t & a_seq_num) a_seq_num = static_cast(0xff & ((a_seq_num) + 1)); } -static inline bool DidReceiveData(uint8_t rx_flags) +static inline bool DidReceiveData(BitFlags rx_flags) { - return (GetFlag(rx_flags, BtpEngine::kHeaderFlag_StartMessage) || GetFlag(rx_flags, BtpEngine::kHeaderFlag_ContinueMessage) || - GetFlag(rx_flags, BtpEngine::kHeaderFlag_EndMessage)); + return rx_flags.HasAny(BtpEngine::HeaderFlags::kStartMessage, BtpEngine::HeaderFlags::kContinueMessage, + BtpEngine::HeaderFlags::kEndMessage); } static void PrintBufDebug(const System::PacketBufferHandle & buf) @@ -213,7 +213,7 @@ BLE_ERROR BtpEngine::EncodeStandAloneAck(const PacketBufferHandle & data) characteristic = data->Start(); // Since there's no preexisting message payload, we can write BTP header without adjusting data start pointer. - characteristic[0] = kHeaderFlag_FragmentAck; + characteristic[0] = static_cast(HeaderFlags::kFragmentAck); // Acknowledge most recently received sequence number. characteristic[1] = GetAndRecordRxAckSeqNum(); @@ -245,8 +245,8 @@ BLE_ERROR BtpEngine::EncodeStandAloneAck(const PacketBufferHandle & data) BLE_ERROR BtpEngine::HandleCharacteristicReceived(System::PacketBufferHandle data, SequenceNumber_t & receivedAck, bool & didReceiveAck) { - BLE_ERROR err = BLE_NO_ERROR; - uint8_t rx_flags = 0; + BLE_ERROR err = BLE_NO_ERROR; + BitFlags rx_flags; // BLE data uses little-endian byte order. Encoding::LittleEndian::Reader reader(data->Start(), data->DataLength()); @@ -255,15 +255,15 @@ BLE_ERROR BtpEngine::HandleCharacteristicReceived(System::PacketBufferHandle dat mRxCharCount++; // Get header flags, always in first byte. - VerifyOrExit(reader.Read8(&rx_flags).StatusCode() == CHIP_NO_ERROR, err = BLE_ERROR_MESSAGE_INCOMPLETE); + VerifyOrExit(reader.Read8(rx_flags.RawStorage()).StatusCode() == CHIP_NO_ERROR, err = BLE_ERROR_MESSAGE_INCOMPLETE); #if CHIP_ENABLE_CHIPOBLE_TEST - if (GetFlag(rx_flags, kHeaderFlag_CommandMessage)) + if (rx_flags.Has(HeaderFlags::kCommandMessage)) SetRxPacketType(kType_Control); else SetRxPacketType(kType_Data); #endif - didReceiveAck = GetFlag(rx_flags, kHeaderFlag_FragmentAck); + didReceiveAck = rx_flags.Has(HeaderFlags::kFragmentAck); // Get ack number, if any. if (didReceiveAck) @@ -309,7 +309,7 @@ BLE_ERROR BtpEngine::HandleCharacteristicReceived(System::PacketBufferHandle dat Encoding::LittleEndian::Reader startReader(data->Start(), data->DataLength()); // Verify StartMessage header flag set. - VerifyOrExit(rx_flags & kHeaderFlag_StartMessage, err = BLE_ERROR_INVALID_BTP_HEADER_FLAGS); + VerifyOrExit(rx_flags.Has(HeaderFlags::kStartMessage), err = BLE_ERROR_INVALID_BTP_HEADER_FLAGS); VerifyOrExit(startReader.Read16(&mRxLength).StatusCode() == CHIP_NO_ERROR, err = BLE_ERROR_MESSAGE_INCOMPLETE); @@ -328,10 +328,10 @@ BLE_ERROR BtpEngine::HandleCharacteristicReceived(System::PacketBufferHandle dat else if (mRxState == kState_InProgress) { // Verify StartMessage header flag NOT set, since we're in the middle of receiving a message. - VerifyOrExit((rx_flags & kHeaderFlag_StartMessage) == 0, err = BLE_ERROR_INVALID_BTP_HEADER_FLAGS); + VerifyOrExit(!rx_flags.Has(HeaderFlags::kStartMessage), err = BLE_ERROR_INVALID_BTP_HEADER_FLAGS); // Verify ContinueMessage or EndMessage header flag set. - VerifyOrExit((rx_flags & kHeaderFlag_ContinueMessage) || (rx_flags & kHeaderFlag_EndMessage), + VerifyOrExit(rx_flags.HasAny(HeaderFlags::kContinueMessage, HeaderFlags::kEndMessage), err = BLE_ERROR_INVALID_BTP_HEADER_FLAGS); // Add received fragment to reassembled message buffer. @@ -348,7 +348,7 @@ BLE_ERROR BtpEngine::HandleCharacteristicReceived(System::PacketBufferHandle dat ExitNow(); } - if (rx_flags & kHeaderFlag_EndMessage) + if (rx_flags.Has(HeaderFlags::kEndMessage)) { // Trim remainder, if any, of the received packet buffer based on sender-specified length of reassembled message. int padding = mRxBuf->DataLength() - mRxLength; @@ -372,7 +372,7 @@ BLE_ERROR BtpEngine::HandleCharacteristicReceived(System::PacketBufferHandle dat mRxState = kState_Error; // Dump protocol engine state, plus header flags and received data length. - ChipLogError(Ble, "HandleCharacteristicReceived failed, err = %d, rx_flags = %u", err, rx_flags); + ChipLogError(Ble, "HandleCharacteristicReceived failed, err = %d, rx_flags = %u", err, rx_flags.Raw()); if (didReceiveAck) { ChipLogError(Ble, "With rx'd ack = %u", receivedAck); @@ -457,17 +457,16 @@ bool BtpEngine::HandleCharacteristicSend(System::PacketBufferHandle data, bool s characteristic -= header_size; mTxBuf->SetStart(characteristic); uint8_t cursor = 1; // first position past header flags byte - - characteristic[0] = kHeaderFlag_StartMessage; + BitFlags headerFlags(HeaderFlags::kStartMessage); #if CHIP_ENABLE_CHIPOBLE_TEST if (TxPacketType() == kType_Control) - SetFlag(characteristic[0], kHeaderFlag_CommandMessage, true); + headerFlags.Set(HeaderFlags::kCommandMessage); #endif if (send_ack) { - SetFlag(characteristic[0], kHeaderFlag_FragmentAck, true); + headerFlags.Set(HeaderFlags::kFragmentAck); characteristic[cursor++] = GetAndRecordRxAckSeqNum(); ChipLogDebugBtpEngine(Ble, "===> encoded piggybacked ack, ack_num = %u", characteristic[cursor - 1]); } @@ -480,7 +479,7 @@ bool BtpEngine::HandleCharacteristicSend(System::PacketBufferHandle data, bool s { mTxBuf->SetDataLength(static_cast(mTxLength + cursor)); mTxLength = 0; - SetFlag(characteristic[0], kHeaderFlag_EndMessage, true); + headerFlags.Set(HeaderFlags::kEndMessage); mTxState = kState_Complete; mTxPacketCount++; } @@ -490,6 +489,7 @@ bool BtpEngine::HandleCharacteristicSend(System::PacketBufferHandle data, bool s mTxLength = static_cast((mTxLength + cursor) - mTxFragmentSize); } + characteristic[0] = headerFlags.Raw(); ChipLogDebugBtpEngine(Ble, ">>> CHIPoBle preparing to send first fragment:"); PrintBufDebug(data); } @@ -510,16 +510,16 @@ bool BtpEngine::HandleCharacteristicSend(System::PacketBufferHandle data, bool s mTxBuf->SetStart(characteristic); uint8_t cursor = 1; // first position past header flags byte - characteristic[0] = kHeaderFlag_ContinueMessage; + BitFlags headerFlags(HeaderFlags::kContinueMessage); #if CHIP_ENABLE_CHIPOBLE_TEST if (TxPacketType() == kType_Control) - SetFlag(characteristic[0], kHeaderFlag_CommandMessage, true); + headerFlags.Set(HeaderFlags::kCommandMessage); #endif if (send_ack) { - SetFlag(characteristic[0], kHeaderFlag_FragmentAck, true); + headerFlags.Set(HeaderFlags::kFragmentAck); characteristic[cursor++] = GetAndRecordRxAckSeqNum(); ChipLogDebugBtpEngine(Ble, "===> encoded piggybacked ack, ack_num = %u", characteristic[cursor - 1]); } @@ -530,7 +530,7 @@ bool BtpEngine::HandleCharacteristicSend(System::PacketBufferHandle data, bool s { mTxBuf->SetDataLength(static_cast(mTxLength + cursor)); mTxLength = 0; - SetFlag(characteristic[0], kHeaderFlag_EndMessage, true); + headerFlags.Set(HeaderFlags::kEndMessage); mTxState = kState_Complete; mTxPacketCount++; } @@ -540,6 +540,7 @@ bool BtpEngine::HandleCharacteristicSend(System::PacketBufferHandle data, bool s mTxLength = static_cast((mTxLength + cursor) - mTxFragmentSize); } + characteristic[0] = headerFlags.Raw(); ChipLogDebugBtpEngine(Ble, ">>> CHIPoBle preparing to send additional fragment:"); PrintBufDebug(mTxBuf); } diff --git a/src/ble/BtpEngine.h b/src/ble/BtpEngine.h index 9b7a6c5c20e2e3..43dda04434ef49 100644 --- a/src/ble/BtpEngine.h +++ b/src/ble/BtpEngine.h @@ -87,16 +87,17 @@ class BtpEngine kState_Error = 3 } State_t; // [READ-ONLY] Current state - enum + // Masks for BTP fragment header flag bits. + enum class HeaderFlags : uint8_t { - kHeaderFlag_StartMessage = 0x01, - kHeaderFlag_ContinueMessage = 0x02, - kHeaderFlag_EndMessage = 0x04, - kHeaderFlag_FragmentAck = 0x08, + kStartMessage = 0x01, + kContinueMessage = 0x02, + kEndMessage = 0x04, + kFragmentAck = 0x08, #if CHIP_ENABLE_CHIPOBLE_TEST - kHeaderFlag_CommandMessage = 0x10, + kCommandMessage = 0x10, #endif - }; // Masks for BTP fragment header flag bits. + }; static const uint16_t sDefaultFragmentSize; static const uint16_t sMaxFragmentSize; @@ -129,7 +130,10 @@ class BtpEngine inline SequenceNumber_t SetRxPacketSeq(SequenceNumber_t seq) { return (mRxPacketSeq = seq); } inline SequenceNumber_t TxPacketSeq() { return mTxPacketSeq; } inline SequenceNumber_t RxPacketSeq() { return mRxPacketSeq; } - inline bool IsCommandPacket(const PacketBufferHandle & p) { return GetFlag(*(p->Start()), kHeaderFlag_CommandMessage); } + inline bool IsCommandPacket(const PacketBufferHandle & p) + { + return BitFlags(*(p->Start())).Has(HeaderFlags::kCommandMessage); + } inline void PushPacketTag(const PacketBufferHandle & p, PacketType_t type) { p->SetStart(p->Start() - sizeof(type)); diff --git a/src/controller/CHIPClusters.cpp b/src/controller/CHIPClusters.cpp index f6145a98e38df1..9a339244aeb899 100644 --- a/src/controller/CHIPClusters.cpp +++ b/src/controller/CHIPClusters.cpp @@ -114,7 +114,7 @@ CHIP_ERROR BarrierControlCluster::BarrierControlGoToPercent(Callback::Cancelable (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kBarrierControlGoToPercentCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -148,7 +148,7 @@ CHIP_ERROR BarrierControlCluster::BarrierControlStop(Callback::Cancelable * onSu (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kBarrierControlStopCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -227,7 +227,7 @@ CHIP_ERROR BasicCluster::MfgSpecificPing(Callback::Cancelable * onSuccessCallbac (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMfgSpecificPingCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -257,7 +257,7 @@ CHIP_ERROR BasicCluster::ResetToFactoryDefaults(Callback::Cancelable * onSuccess (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kResetToFactoryDefaultsCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -319,7 +319,7 @@ CHIP_ERROR BindingCluster::Bind(Callback::Cancelable * onSuccessCallback, Callba (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kBindCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -360,7 +360,7 @@ CHIP_ERROR BindingCluster::Unbind(Callback::Cancelable * onSuccessCallback, Call (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kUnbindCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -416,7 +416,7 @@ CHIP_ERROR ColorControlCluster::MoveColor(Callback::Cancelable * onSuccessCallba (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveColorCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -458,7 +458,7 @@ CHIP_ERROR ColorControlCluster::MoveColorTemperature(Callback::Cancelable * onSu (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveColorTemperatureCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -502,7 +502,7 @@ CHIP_ERROR ColorControlCluster::MoveHue(Callback::Cancelable * onSuccessCallback (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveHueCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -542,7 +542,7 @@ CHIP_ERROR ColorControlCluster::MoveSaturation(Callback::Cancelable * onSuccessC (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveSaturationCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -583,7 +583,7 @@ CHIP_ERROR ColorControlCluster::MoveToColor(Callback::Cancelable * onSuccessCall (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveToColorCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -626,7 +626,7 @@ CHIP_ERROR ColorControlCluster::MoveToColorTemperature(Callback::Cancelable * on (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveToColorTemperatureCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -667,7 +667,7 @@ CHIP_ERROR ColorControlCluster::MoveToHue(Callback::Cancelable * onSuccessCallba (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveToHueCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -710,7 +710,7 @@ CHIP_ERROR ColorControlCluster::MoveToHueAndSaturation(Callback::Cancelable * on (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveToHueAndSaturationCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -753,7 +753,7 @@ CHIP_ERROR ColorControlCluster::MoveToSaturation(Callback::Cancelable * onSucces (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveToSaturationCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -794,7 +794,7 @@ CHIP_ERROR ColorControlCluster::StepColor(Callback::Cancelable * onSuccessCallba (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kStepColorCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -838,7 +838,7 @@ CHIP_ERROR ColorControlCluster::StepColorTemperature(Callback::Cancelable * onSu (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kStepColorTemperatureCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -886,7 +886,7 @@ CHIP_ERROR ColorControlCluster::StepHue(Callback::Cancelable * onSuccessCallback (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kStepHueCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -929,7 +929,7 @@ CHIP_ERROR ColorControlCluster::StepSaturation(Callback::Cancelable * onSuccessC (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kStepSaturationCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -971,7 +971,7 @@ CHIP_ERROR ColorControlCluster::StopMoveStep(Callback::Cancelable * onSuccessCal (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kStopMoveStepCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -1610,7 +1610,7 @@ CHIP_ERROR ContentLaunchCluster::LaunchContent(Callback::Cancelable * onSuccessC (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kLaunchContentCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -1640,7 +1640,7 @@ CHIP_ERROR ContentLaunchCluster::LaunchURL(Callback::Cancelable * onSuccessCallb (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kLaunchURLCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -1687,7 +1687,7 @@ CHIP_ERROR DoorLockCluster::ClearAllPins(Callback::Cancelable * onSuccessCallbac (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kClearAllPinsCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -1717,7 +1717,7 @@ CHIP_ERROR DoorLockCluster::ClearAllRfids(Callback::Cancelable * onSuccessCallba (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kClearAllRfidsCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -1748,7 +1748,7 @@ CHIP_ERROR DoorLockCluster::ClearHolidaySchedule(Callback::Cancelable * onSucces (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kClearHolidayScheduleCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -1781,7 +1781,7 @@ CHIP_ERROR DoorLockCluster::ClearPin(Callback::Cancelable * onSuccessCallback, C (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kClearPinCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -1814,7 +1814,7 @@ CHIP_ERROR DoorLockCluster::ClearRfid(Callback::Cancelable * onSuccessCallback, (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kClearRfidCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -1847,7 +1847,7 @@ CHIP_ERROR DoorLockCluster::ClearWeekdaySchedule(Callback::Cancelable * onSucces (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kClearWeekdayScheduleCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -1883,7 +1883,7 @@ CHIP_ERROR DoorLockCluster::ClearYeardaySchedule(Callback::Cancelable * onSucces (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kClearYeardayScheduleCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -1919,7 +1919,7 @@ CHIP_ERROR DoorLockCluster::GetHolidaySchedule(Callback::Cancelable * onSuccessC (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetHolidayScheduleCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -1952,7 +1952,7 @@ CHIP_ERROR DoorLockCluster::GetLogRecord(Callback::Cancelable * onSuccessCallbac (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetLogRecordCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -1985,7 +1985,7 @@ CHIP_ERROR DoorLockCluster::GetPin(Callback::Cancelable * onSuccessCallback, Cal (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetPinCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2018,7 +2018,7 @@ CHIP_ERROR DoorLockCluster::GetRfid(Callback::Cancelable * onSuccessCallback, Ca (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetRfidCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2051,7 +2051,7 @@ CHIP_ERROR DoorLockCluster::GetUserType(Callback::Cancelable * onSuccessCallback (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetUserTypeCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2084,7 +2084,7 @@ CHIP_ERROR DoorLockCluster::GetWeekdaySchedule(Callback::Cancelable * onSuccessC (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetWeekdayScheduleCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2120,7 +2120,7 @@ CHIP_ERROR DoorLockCluster::GetYeardaySchedule(Callback::Cancelable * onSuccessC (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetYeardayScheduleCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2155,7 +2155,7 @@ CHIP_ERROR DoorLockCluster::LockDoor(Callback::Cancelable * onSuccessCallback, C (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kLockDoorCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2189,7 +2189,7 @@ CHIP_ERROR DoorLockCluster::SetHolidaySchedule(Callback::Cancelable * onSuccessC (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSetHolidayScheduleCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2229,7 +2229,7 @@ CHIP_ERROR DoorLockCluster::SetPin(Callback::Cancelable * onSuccessCallback, Cal (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSetPinCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2269,7 +2269,7 @@ CHIP_ERROR DoorLockCluster::SetRfid(Callback::Cancelable * onSuccessCallback, Ca (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSetRfidCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2309,7 +2309,7 @@ CHIP_ERROR DoorLockCluster::SetUserType(Callback::Cancelable * onSuccessCallback (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSetUserTypeCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2345,7 +2345,7 @@ CHIP_ERROR DoorLockCluster::SetWeekdaySchedule(Callback::Cancelable * onSuccessC (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSetWeekdayScheduleCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2391,7 +2391,7 @@ CHIP_ERROR DoorLockCluster::SetYeardaySchedule(Callback::Cancelable * onSuccessC (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSetYeardayScheduleCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2431,7 +2431,7 @@ CHIP_ERROR DoorLockCluster::UnlockDoor(Callback::Cancelable * onSuccessCallback, (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kUnlockDoorCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2464,7 +2464,7 @@ CHIP_ERROR DoorLockCluster::UnlockWithTimeout(Callback::Cancelable * onSuccessCa (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kUnlockWithTimeoutCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2556,7 +2556,7 @@ CHIP_ERROR GeneralCommissioningCluster::ArmFailSafe(Callback::Cancelable * onSuc (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kArmFailSafeCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2594,7 +2594,7 @@ CHIP_ERROR GeneralCommissioningCluster::CommissioningComplete(Callback::Cancelab (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kCommissioningCompleteCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2626,7 +2626,7 @@ CHIP_ERROR GeneralCommissioningCluster::SetFabric(Callback::Cancelable * onSucce (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSetFabricCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2707,7 +2707,7 @@ CHIP_ERROR GroupsCluster::AddGroup(Callback::Cancelable * onSuccessCallback, Cal (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kAddGroupCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2742,7 +2742,7 @@ CHIP_ERROR GroupsCluster::AddGroupIfIdentifying(Callback::Cancelable * onSuccess (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kAddGroupIfIdentifyingCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2778,7 +2778,7 @@ CHIP_ERROR GroupsCluster::GetGroupMembership(Callback::Cancelable * onSuccessCal (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetGroupMembershipCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2813,7 +2813,7 @@ CHIP_ERROR GroupsCluster::RemoveAllGroups(Callback::Cancelable * onSuccessCallba (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kRemoveAllGroupsCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2844,7 +2844,7 @@ CHIP_ERROR GroupsCluster::RemoveGroup(Callback::Cancelable * onSuccessCallback, (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kRemoveGroupCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2877,7 +2877,7 @@ CHIP_ERROR GroupsCluster::ViewGroup(Callback::Cancelable * onSuccessCallback, Ca (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kViewGroupCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -2996,7 +2996,7 @@ CHIP_ERROR IdentifyCluster::Identify(Callback::Cancelable * onSuccessCallback, C (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kIdentifyCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3028,7 +3028,7 @@ CHIP_ERROR IdentifyCluster::IdentifyQuery(Callback::Cancelable * onSuccessCallba (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kIdentifyQueryCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3091,7 +3091,7 @@ CHIP_ERROR LevelControlCluster::Move(Callback::Cancelable * onSuccessCallback, C (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3131,7 +3131,7 @@ CHIP_ERROR LevelControlCluster::MoveToLevel(Callback::Cancelable * onSuccessCall (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveToLevelCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3172,7 +3172,7 @@ CHIP_ERROR LevelControlCluster::MoveToLevelWithOnOff(Callback::Cancelable * onSu (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveToLevelWithOnOffCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3208,7 +3208,7 @@ CHIP_ERROR LevelControlCluster::MoveWithOnOff(Callback::Cancelable * onSuccessCa (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kMoveWithOnOffCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3244,7 +3244,7 @@ CHIP_ERROR LevelControlCluster::Step(Callback::Cancelable * onSuccessCallback, C (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kStepCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3286,7 +3286,7 @@ CHIP_ERROR LevelControlCluster::StepWithOnOff(Callback::Cancelable * onSuccessCa (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kStepWithOnOffCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3324,7 +3324,7 @@ CHIP_ERROR LevelControlCluster::Stop(Callback::Cancelable * onSuccessCallback, C (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kStopCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3358,7 +3358,7 @@ CHIP_ERROR LevelControlCluster::StopWithOnOff(Callback::Cancelable * onSuccessCa (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kStopWithOnOffCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3475,7 +3475,7 @@ CHIP_ERROR MediaPlaybackCluster::FastForwardRequest(Callback::Cancelable * onSuc (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kFastForwardRequestCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3505,7 +3505,7 @@ CHIP_ERROR MediaPlaybackCluster::NextRequest(Callback::Cancelable * onSuccessCal (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kNextRequestCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3535,7 +3535,7 @@ CHIP_ERROR MediaPlaybackCluster::PauseRequest(Callback::Cancelable * onSuccessCa (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kPauseRequestCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3565,7 +3565,7 @@ CHIP_ERROR MediaPlaybackCluster::PlayRequest(Callback::Cancelable * onSuccessCal (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kPlayRequestCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3595,7 +3595,7 @@ CHIP_ERROR MediaPlaybackCluster::PreviousRequest(Callback::Cancelable * onSucces (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kPreviousRequestCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3625,7 +3625,7 @@ CHIP_ERROR MediaPlaybackCluster::RewindRequest(Callback::Cancelable * onSuccessC (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kRewindRequestCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3656,7 +3656,7 @@ CHIP_ERROR MediaPlaybackCluster::SkipBackwardRequest(Callback::Cancelable * onSu (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSkipBackwardRequestCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3687,7 +3687,7 @@ CHIP_ERROR MediaPlaybackCluster::SkipForwardRequest(Callback::Cancelable * onSuc (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSkipForwardRequestCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3718,7 +3718,7 @@ CHIP_ERROR MediaPlaybackCluster::StartOverRequest(Callback::Cancelable * onSucce (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kStartOverRequestCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3748,7 +3748,7 @@ CHIP_ERROR MediaPlaybackCluster::StopRequest(Callback::Cancelable * onSuccessCal (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kStopRequestCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3805,7 +3805,7 @@ CHIP_ERROR NetworkCommissioningCluster::AddThreadNetwork(Callback::Cancelable * (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kAddThreadNetworkCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3844,7 +3844,7 @@ CHIP_ERROR NetworkCommissioningCluster::AddWiFiNetwork(Callback::Cancelable * on (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kAddWiFiNetworkCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3885,7 +3885,7 @@ CHIP_ERROR NetworkCommissioningCluster::DisableNetwork(Callback::Cancelable * on (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kDisableNetworkCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3924,7 +3924,7 @@ CHIP_ERROR NetworkCommissioningCluster::EnableNetwork(Callback::Cancelable * onS (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kEnableNetworkCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3963,7 +3963,7 @@ CHIP_ERROR NetworkCommissioningCluster::GetLastNetworkCommissioningResult(Callba (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetLastNetworkCommissioningResultCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -3998,7 +3998,7 @@ CHIP_ERROR NetworkCommissioningCluster::RemoveNetwork(Callback::Cancelable * onS (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kRemoveNetworkCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -4037,7 +4037,7 @@ CHIP_ERROR NetworkCommissioningCluster::ScanNetworks(Callback::Cancelable * onSu (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kScanNetworksCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -4077,7 +4077,7 @@ CHIP_ERROR NetworkCommissioningCluster::UpdateThreadNetwork(Callback::Cancelable (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kUpdateThreadNetworkCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -4116,7 +4116,7 @@ CHIP_ERROR NetworkCommissioningCluster::UpdateWiFiNetwork(Callback::Cancelable * (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kUpdateWiFiNetworkCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -4172,7 +4172,7 @@ CHIP_ERROR OnOffCluster::Off(Callback::Cancelable * onSuccessCallback, Callback: (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kOffCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -4202,7 +4202,7 @@ CHIP_ERROR OnOffCluster::On(Callback::Cancelable * onSuccessCallback, Callback:: (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kOnCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -4232,7 +4232,7 @@ CHIP_ERROR OnOffCluster::Toggle(Callback::Cancelable * onSuccessCallback, Callba (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kToggleCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -4301,7 +4301,7 @@ CHIP_ERROR ScenesCluster::AddScene(Callback::Cancelable * onSuccessCallback, Cal (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kAddSceneCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -4347,7 +4347,7 @@ CHIP_ERROR ScenesCluster::GetSceneMembership(Callback::Cancelable * onSuccessCal (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kGetSceneMembershipCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -4380,7 +4380,7 @@ CHIP_ERROR ScenesCluster::RecallScene(Callback::Cancelable * onSuccessCallback, (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kRecallSceneCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -4418,7 +4418,7 @@ CHIP_ERROR ScenesCluster::RemoveAllScenes(Callback::Cancelable * onSuccessCallba (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kRemoveAllScenesCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -4451,7 +4451,7 @@ CHIP_ERROR ScenesCluster::RemoveScene(Callback::Cancelable * onSuccessCallback, (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kRemoveSceneCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -4486,7 +4486,7 @@ CHIP_ERROR ScenesCluster::StoreScene(Callback::Cancelable * onSuccessCallback, C (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kStoreSceneCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -4521,7 +4521,7 @@ CHIP_ERROR ScenesCluster::ViewScene(Callback::Cancelable * onSuccessCallback, Ca (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kViewSceneCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); diff --git a/src/credentials/CHIPCert.cpp b/src/credentials/CHIPCert.cpp index 90246c40202657..b7800ec9976647 100644 --- a/src/credentials/CHIPCert.cpp +++ b/src/credentials/CHIPCert.cpp @@ -143,8 +143,7 @@ void ChipCertificateSet::Clear() mCertCount = 0; } -CHIP_ERROR ChipCertificateSet::LoadCert(const uint8_t * chipCert, uint32_t chipCertLen, - BitFlags decodeFlags) +CHIP_ERROR ChipCertificateSet::LoadCert(const uint8_t * chipCert, uint32_t chipCertLen, BitFlags decodeFlags) { CHIP_ERROR err; TLVReader reader; @@ -161,7 +160,7 @@ CHIP_ERROR ChipCertificateSet::LoadCert(const uint8_t * chipCert, uint32_t chipC return err; } -CHIP_ERROR ChipCertificateSet::LoadCert(TLVReader & reader, BitFlags decodeFlags) +CHIP_ERROR ChipCertificateSet::LoadCert(TLVReader & reader, BitFlags decodeFlags) { CHIP_ERROR err; ASN1Writer writer; // ASN1Writer is used to encode TBS portion of the certificate for the purpose of signature @@ -192,8 +191,7 @@ CHIP_ERROR ChipCertificateSet::LoadCert(TLVReader & reader, BitFlagsmCertFlags.Has(CertFlags::kExtPresent_SubjectKeyId) && - cert->mCertFlags.Has(CertFlags::kExtPresent_AuthKeyId), + VerifyOrExit(cert->mCertFlags.HasAll(CertFlags::kExtPresent_SubjectKeyId, CertFlags::kExtPresent_AuthKeyId), err = CHIP_ERROR_UNSUPPORTED_CERT_FORMAT); // Verify the cert was signed with ECDSA-SHA256. This is the only signature algorithm currently supported. @@ -248,8 +246,7 @@ CHIP_ERROR ChipCertificateSet::LoadCert(TLVReader & reader, BitFlags decodeFlags) +CHIP_ERROR ChipCertificateSet::LoadCerts(const uint8_t * chipCerts, uint32_t chipCertsLen, BitFlags decodeFlags) { CHIP_ERROR err; TLVReader reader; @@ -275,7 +272,7 @@ CHIP_ERROR ChipCertificateSet::LoadCerts(const uint8_t * chipCerts, uint32_t chi return err; } -CHIP_ERROR ChipCertificateSet::LoadCerts(TLVReader & reader, BitFlags decodeFlags) +CHIP_ERROR ChipCertificateSet::LoadCerts(TLVReader & reader, BitFlags decodeFlags) { CHIP_ERROR err; uint8_t initialCertCount = mCertCount; @@ -463,7 +460,7 @@ CHIP_ERROR ChipCertificateSet::VerifySignature(const ChipCertificateData * cert, } CHIP_ERROR ChipCertificateSet::ValidateCert(const ChipCertificateData * cert, ValidationContext & context, - BitFlags validateFlags, uint8_t depth) + BitFlags validateFlags, uint8_t depth) { CHIP_ERROR err = CHIP_NO_ERROR; ChipCertificateData * caCert = nullptr; @@ -499,19 +496,19 @@ CHIP_ERROR ChipCertificateSet::ValidateCert(const ChipCertificateData * cert, Va { // If a set of desired key usages has been specified, verify that the key usage extension exists // in the certificate and that the corresponding usages are supported. - if (context.mRequiredKeyUsages.Raw() != 0) + if (context.mRequiredKeyUsages.HasAny()) { VerifyOrExit(cert->mCertFlags.Has(CertFlags::kExtPresent_KeyUsage) && - cert->mKeyUsageFlags.Has(context.mRequiredKeyUsages.Raw()), + cert->mKeyUsageFlags.HasAll(context.mRequiredKeyUsages), err = CHIP_ERROR_CERT_USAGE_NOT_ALLOWED); } // If a set of desired key purposes has been specified, verify that the extended key usage extension // exists in the certificate and that the corresponding purposes are supported. - if (context.mRequiredKeyPurposes.Raw() != 0) + if (context.mRequiredKeyPurposes.HasAny()) { VerifyOrExit(cert->mCertFlags.Has(CertFlags::kExtPresent_ExtendedKeyUsage) && - cert->mKeyPurposeFlags.Has(context.mRequiredKeyPurposes.Raw()), + cert->mKeyPurposeFlags.HasAll(context.mRequiredKeyPurposes), err = CHIP_ERROR_CERT_USAGE_NOT_ALLOWED); } @@ -577,8 +574,8 @@ CHIP_ERROR ChipCertificateSet::ValidateCert(const ChipCertificateData * cert, Va } CHIP_ERROR ChipCertificateSet::FindValidCert(const ChipDN & subjectDN, const CertificateKeyId & subjectKeyId, - ValidationContext & context, BitFlags validateFlags, - uint8_t depth, ChipCertificateData *& cert) + ValidationContext & context, BitFlags validateFlags, uint8_t depth, + ChipCertificateData *& cert) { CHIP_ERROR err; @@ -646,9 +643,9 @@ void ChipCertificateData::Clear() mPubKeyCurveOID = 0; mPubKeyAlgoOID = 0; mSigAlgoOID = 0; - mCertFlags.SetRaw(0); - mKeyUsageFlags.SetRaw(0); - mKeyPurposeFlags.SetRaw(0); + mCertFlags.ClearAll(); + mKeyUsageFlags.ClearAll(); + mKeyPurposeFlags.ClearAll(); mPathLenConstraint = 0; mCertType = kCertType_NotSpecified; mSignature.R = nullptr; @@ -663,9 +660,9 @@ void ValidationContext::Reset() mEffectiveTime = 0; mTrustAnchor = nullptr; mSigningCert = nullptr; - mRequiredKeyUsages.SetRaw(0); - mRequiredKeyPurposes.SetRaw(0); - mValidateFlags.SetRaw(0); + mRequiredKeyUsages.ClearAll(); + mRequiredKeyPurposes.ClearAll(); + mValidateFlags.ClearAll(); mRequiredCertType = kCertType_NotSpecified; } diff --git a/src/credentials/CHIPCert.h b/src/credentials/CHIPCert.h index 4774efd31ef2e2..362d8ce825fee2 100644 --- a/src/credentials/CHIPCert.h +++ b/src/credentials/CHIPCert.h @@ -241,22 +241,22 @@ struct ChipCertificateData void Clear(); - ChipDN mSubjectDN; /**< Certificate Subject DN. */ - ChipDN mIssuerDN; /**< Certificate Issuer DN. */ - CertificateKeyId mSubjectKeyId; /**< Certificate Subject public key identifier. */ - CertificateKeyId mAuthKeyId; /**< Certificate Authority public key identifier. */ - uint32_t mNotBeforeTime; /**< Certificate validity: Not Before field. */ - uint32_t mNotAfterTime; /**< Certificate validity: Not After field. */ - const uint8_t * mPublicKey; /**< Pointer to the certificate public key. */ - uint8_t mPublicKeyLen; /**< Certificate public key length. */ - uint16_t mPubKeyCurveOID; /**< Public key Elliptic Curve CHIP OID. */ - uint16_t mPubKeyAlgoOID; /**< Public key algorithm CHIP OID. */ - uint16_t mSigAlgoOID; /**< Certificate signature algorithm CHIP OID. */ - BitFlags mCertFlags; /**< Certificate data flags. */ - BitFlags mKeyUsageFlags; /**< Certificate key usage extensions flags. */ - BitFlags mKeyPurposeFlags; /**< Certificate extended key usage extensions flags. */ - uint8_t mPathLenConstraint; /**< Basic constraint: path length. */ - uint8_t mCertType; /**< Certificate type. */ + ChipDN mSubjectDN; /**< Certificate Subject DN. */ + ChipDN mIssuerDN; /**< Certificate Issuer DN. */ + CertificateKeyId mSubjectKeyId; /**< Certificate Subject public key identifier. */ + CertificateKeyId mAuthKeyId; /**< Certificate Authority public key identifier. */ + uint32_t mNotBeforeTime; /**< Certificate validity: Not Before field. */ + uint32_t mNotAfterTime; /**< Certificate validity: Not After field. */ + const uint8_t * mPublicKey; /**< Pointer to the certificate public key. */ + uint8_t mPublicKeyLen; /**< Certificate public key length. */ + uint16_t mPubKeyCurveOID; /**< Public key Elliptic Curve CHIP OID. */ + uint16_t mPubKeyAlgoOID; /**< Public key algorithm CHIP OID. */ + uint16_t mSigAlgoOID; /**< Certificate signature algorithm CHIP OID. */ + BitFlags mCertFlags; /**< Certificate data flags. */ + BitFlags mKeyUsageFlags; /**< Certificate key usage extensions flags. */ + BitFlags mKeyPurposeFlags; /**< Certificate extended key usage extensions flags. */ + uint8_t mPathLenConstraint; /**< Basic constraint: path length. */ + uint8_t mCertType; /**< Certificate type. */ struct { const uint8_t * R; /**< Pointer to the R element of the signature, encoded as ASN.1 DER Integer. */ @@ -275,16 +275,16 @@ struct ChipCertificateData */ struct ValidationContext { - uint32_t mEffectiveTime; /**< Current CHIP Epoch UTC time. */ - const ChipCertificateData * mTrustAnchor; /**< Pointer to the Trust Anchor Certificate data structure. */ - const ChipCertificateData * mSigningCert; /**< Pointer to the Signing Certificate data structure. */ - BitFlags mRequiredKeyUsages; /**< Key usage extensions that should be present in the - validated certificate. */ - BitFlags mRequiredKeyPurposes; /**< Extended Key usage extensions that should be present - in the validated certificate. */ - BitFlags mValidateFlags; /**< Certificate validation flags, specifying how a certificate - should be validated. */ - uint8_t mRequiredCertType; /**< Required certificate type. */ + uint32_t mEffectiveTime; /**< Current CHIP Epoch UTC time. */ + const ChipCertificateData * mTrustAnchor; /**< Pointer to the Trust Anchor Certificate data structure. */ + const ChipCertificateData * mSigningCert; /**< Pointer to the Signing Certificate data structure. */ + BitFlags mRequiredKeyUsages; /**< Key usage extensions that should be present in the + validated certificate. */ + BitFlags mRequiredKeyPurposes; /**< Extended Key usage extensions that should be present + in the validated certificate. */ + BitFlags mValidateFlags; /**< Certificate validation flags, specifying how a certificate + should be validated. */ + uint8_t mRequiredCertType; /**< Required certificate type. */ void Reset(); }; @@ -350,7 +350,7 @@ class DLL_EXPORT ChipCertificateSet * * @return Returns a CHIP_ERROR on error, CHIP_NO_ERROR otherwise **/ - CHIP_ERROR LoadCert(const uint8_t * chipCert, uint32_t chipCertLen, BitFlags decodeFlags); + CHIP_ERROR LoadCert(const uint8_t * chipCert, uint32_t chipCertLen, BitFlags decodeFlags); /** * @brief Load CHIP certificate into set. @@ -363,7 +363,7 @@ class DLL_EXPORT ChipCertificateSet * * @return Returns a CHIP_ERROR on error, CHIP_NO_ERROR otherwise **/ - CHIP_ERROR LoadCert(chip::TLV::TLVReader & reader, BitFlags decodeFlags); + CHIP_ERROR LoadCert(chip::TLV::TLVReader & reader, BitFlags decodeFlags); /** * @brief Load CHIP certificates into set. @@ -377,7 +377,7 @@ class DLL_EXPORT ChipCertificateSet * * @return Returns a CHIP_ERROR on error, CHIP_NO_ERROR otherwise **/ - CHIP_ERROR LoadCerts(const uint8_t * chipCerts, uint32_t chipCertsLen, BitFlags decodeFlags); + CHIP_ERROR LoadCerts(const uint8_t * chipCerts, uint32_t chipCertsLen, BitFlags decodeFlags); /** * @brief Load CHIP certificates into set. @@ -391,7 +391,7 @@ class DLL_EXPORT ChipCertificateSet * * @return Returns a CHIP_ERROR on error, CHIP_NO_ERROR otherwise **/ - CHIP_ERROR LoadCerts(chip::TLV::TLVReader & reader, BitFlags decodeFlags); + CHIP_ERROR LoadCerts(chip::TLV::TLVReader & reader, BitFlags decodeFlags); /** * @brief Add trusted anchor key to the certificate set. @@ -505,7 +505,7 @@ class DLL_EXPORT ChipCertificateSet * @return Returns a CHIP_ERROR on validation or other error, CHIP_NO_ERROR otherwise **/ CHIP_ERROR FindValidCert(const ChipDN & subjectDN, const CertificateKeyId & subjectKeyId, ValidationContext & context, - BitFlags validateFlags, uint8_t depth, ChipCertificateData *& cert); + BitFlags validateFlags, uint8_t depth, ChipCertificateData *& cert); /** * @brief Validate CHIP certificate. @@ -518,7 +518,7 @@ class DLL_EXPORT ChipCertificateSet * @return Returns a CHIP_ERROR on validation or other error, CHIP_NO_ERROR otherwise **/ CHIP_ERROR ValidateCert(const ChipCertificateData * cert, ValidationContext & context, - BitFlags validateFlags, uint8_t depth); + BitFlags validateFlags, uint8_t depth); }; /** diff --git a/src/credentials/CHIPCertFromX509.cpp b/src/credentials/CHIPCertFromX509.cpp index 51cdbf863cee3c..4f8854911055c5 100644 --- a/src/credentials/CHIPCertFromX509.cpp +++ b/src/credentials/CHIPCertFromX509.cpp @@ -363,8 +363,7 @@ static CHIP_ERROR ConvertExtension(ASN1Reader & reader, TLVWriter & writer) VerifyOrExit(keyUsageBits <= UINT16_MAX, err = ASN1_ERROR_INVALID_ENCODING); // Check that only supported flags are set. - BitFlags keyUsageFlags; - keyUsageFlags.SetRaw(static_cast(keyUsageBits)); + BitFlags keyUsageFlags(static_cast(keyUsageBits)); VerifyOrExit(keyUsageFlags.HasOnly( KeyUsageFlags::kDigitalSignature, KeyUsageFlags::kNonRepudiation, KeyUsageFlags::kKeyEncipherment, KeyUsageFlags::kDataEncipherment, KeyUsageFlags::kKeyAgreement, KeyUsageFlags::kKeyCertSign, diff --git a/src/credentials/CHIPCertToX509.cpp b/src/credentials/CHIPCertToX509.cpp index bb6fe2ccbe4745..3a2c09c2a38edf 100644 --- a/src/credentials/CHIPCertToX509.cpp +++ b/src/credentials/CHIPCertToX509.cpp @@ -382,7 +382,6 @@ static CHIP_ERROR DecodeConvertKeyUsageExtension(TLVReader & reader, ASN1Writer { CHIP_ERROR err; uint64_t keyUsageBits; - BitFlags keyUsageFlags; certData.mCertFlags.Set(CertFlags::kExtPresent_KeyUsage); @@ -395,16 +394,18 @@ static CHIP_ERROR DecodeConvertKeyUsageExtension(TLVReader & reader, ASN1Writer VerifyOrExit(keyUsageBits <= UINT16_MAX, err = CHIP_ERROR_UNSUPPORTED_CERT_FORMAT); - keyUsageFlags.SetRaw(static_cast(keyUsageBits)); - VerifyOrExit(keyUsageFlags.HasOnly(KeyUsageFlags::kDigitalSignature, KeyUsageFlags::kNonRepudiation, - KeyUsageFlags::kKeyEncipherment, KeyUsageFlags::kDataEncipherment, - KeyUsageFlags::kKeyAgreement, KeyUsageFlags::kKeyCertSign, KeyUsageFlags::kCRLSign, - KeyUsageFlags::kEncipherOnly, KeyUsageFlags::kEncipherOnly), - err = CHIP_ERROR_UNSUPPORTED_CERT_FORMAT); + { + BitFlags keyUsageFlags(static_cast(keyUsageBits)); + VerifyOrExit(keyUsageFlags.HasOnly(KeyUsageFlags::kDigitalSignature, KeyUsageFlags::kNonRepudiation, + KeyUsageFlags::kKeyEncipherment, KeyUsageFlags::kDataEncipherment, + KeyUsageFlags::kKeyAgreement, KeyUsageFlags::kKeyCertSign, KeyUsageFlags::kCRLSign, + KeyUsageFlags::kEncipherOnly, KeyUsageFlags::kEncipherOnly), + err = CHIP_ERROR_UNSUPPORTED_CERT_FORMAT); - ASN1_ENCODE_BIT_STRING(static_cast(keyUsageBits)); + ASN1_ENCODE_BIT_STRING(static_cast(keyUsageBits)); - certData.mKeyUsageFlags = keyUsageFlags; + certData.mKeyUsageFlags = keyUsageFlags; + } exit: return err; diff --git a/src/credentials/tests/CHIPCert_test_vectors.cpp b/src/credentials/tests/CHIPCert_test_vectors.cpp index 36893894ef0d0a..2126f59ea033b1 100644 --- a/src/credentials/tests/CHIPCert_test_vectors.cpp +++ b/src/credentials/tests/CHIPCert_test_vectors.cpp @@ -46,7 +46,7 @@ extern const uint8_t gTestCerts[] = { extern const size_t gNumTestCerts = sizeof(gTestCerts) / sizeof(gTestCerts[0]); -CHIP_ERROR GetTestCert(uint8_t certType, BitFlags certLoadFlags, const uint8_t *& certData, +CHIP_ERROR GetTestCert(uint8_t certType, BitFlags certLoadFlags, const uint8_t *& certData, uint32_t & certDataLen) { CHIP_ERROR err; @@ -103,8 +103,8 @@ const char * GetTestCertName(uint8_t certType) return nullptr; } -CHIP_ERROR LoadTestCert(ChipCertificateSet & certSet, uint8_t certType, BitFlags certLoadFlags, - BitFlags decodeFlags) +CHIP_ERROR LoadTestCert(ChipCertificateSet & certSet, uint8_t certType, BitFlags certLoadFlags, + BitFlags decodeFlags) { CHIP_ERROR err; ChipCertificateData * cert; diff --git a/src/credentials/tests/CHIPCert_test_vectors.h b/src/credentials/tests/CHIPCert_test_vectors.h index 3a2169405a9b44..15cd65ffb87cf9 100644 --- a/src/credentials/tests/CHIPCert_test_vectors.h +++ b/src/credentials/tests/CHIPCert_test_vectors.h @@ -28,6 +28,7 @@ #include #include +#include #include namespace chip { @@ -58,11 +59,11 @@ enum class TestCertLoadFlags : uint8_t kSetAppDefinedCertType = 0x20, }; -extern CHIP_ERROR GetTestCert(uint8_t certType, BitFlags certLoadFlags, const uint8_t *& certData, +extern CHIP_ERROR GetTestCert(uint8_t certType, BitFlags certLoadFlags, const uint8_t *& certData, uint32_t & certDataLen); extern const char * GetTestCertName(uint8_t certType); -extern CHIP_ERROR LoadTestCert(ChipCertificateSet & certSet, uint8_t certType, BitFlags certLoadFlags, - BitFlags decodeFlags); +extern CHIP_ERROR LoadTestCert(ChipCertificateSet & certSet, uint8_t certType, BitFlags certLoadFlags, + BitFlags decodeFlags); extern const uint8_t gTestCerts[]; extern const size_t gNumTestCerts; diff --git a/src/credentials/tests/TestChipCert.cpp b/src/credentials/tests/TestChipCert.cpp index deeb94b8b590fb..92ffdc1d9556e0 100644 --- a/src/credentials/tests/TestChipCert.cpp +++ b/src/credentials/tests/TestChipCert.cpp @@ -48,59 +48,59 @@ enum // (in either CHIP or DER form), or to decode the certificates. }; -static const BitFlags sIgnoreNotBeforeFlag(CertValidateFlags::kIgnoreNotBefore); -static const BitFlags sIgnoreNotAfterFlag(CertValidateFlags::kIgnoreNotAfter); - -static const BitFlags sNullDecodeFlag; -static const BitFlags sGenTBSHashFlag(CertDecodeFlags::kGenerateTBSHash); -static const BitFlags sTrustAnchorFlag(CertDecodeFlags::kIsTrustAnchor); - -static const BitFlags sNullLoadFlag; -static const BitFlags sDerFormFlag(TestCertLoadFlags::kDERForm); -static const BitFlags sSupIsCAFlag(TestCertLoadFlags::kSuppressIsCA); -static const BitFlags sSupKeyUsageFlag(TestCertLoadFlags::kSuppressKeyUsage); -static const BitFlags sSupKeyCertSignFlag(TestCertLoadFlags::kSuppressKeyCertSign); -static const BitFlags sPathLenZeroFlag(TestCertLoadFlags::kSetPathLenConstZero); -static const BitFlags sAppDefCertTypeFlag(TestCertLoadFlags::kSetAppDefinedCertType); - -static const BitFlags sNullKPFlag; -static const BitFlags sSA(KeyPurposeFlags::kServerAuth); -static const BitFlags sCA(KeyPurposeFlags::kClientAuth); -static const BitFlags sCS(KeyPurposeFlags::kCodeSigning); -static const BitFlags sEP(KeyPurposeFlags::kEmailProtection); -static const BitFlags sTS(KeyPurposeFlags::kTimeStamping); -static const BitFlags sOS(KeyPurposeFlags::kOCSPSigning); -static const BitFlags sSAandCA(sSA.Raw() | sCA.Raw()); -static const BitFlags sSAandCS(sSA.Raw() | sCS.Raw()); -static const BitFlags sSAandEP(sSA.Raw() | sEP.Raw()); -static const BitFlags sSAandTS(sSA.Raw() | sTS.Raw()); - -static const BitFlags sNullKUFlag; -static const BitFlags sDS(KeyUsageFlags::kDigitalSignature); -static const BitFlags sNR(KeyUsageFlags::kNonRepudiation); -static const BitFlags sKE(KeyUsageFlags::kKeyEncipherment); -static const BitFlags sDE(KeyUsageFlags::kDataEncipherment); -static const BitFlags sKA(KeyUsageFlags::kKeyAgreement); -static const BitFlags sKC(KeyUsageFlags::kKeyCertSign); -static const BitFlags sCR(KeyUsageFlags::kCRLSign); -static const BitFlags sEO(KeyUsageFlags::kEncipherOnly); -static const BitFlags sDO(KeyUsageFlags::kDecipherOnly); -static const BitFlags sDSandNR(sDS.Raw() | sNR.Raw()); -static const BitFlags sDSandKE(sDS.Raw() | sKE.Raw()); -static const BitFlags sDSandDE(sDS.Raw() | sDE.Raw()); -static const BitFlags sDSandKA(sDS.Raw() | sKA.Raw()); -static const BitFlags sDSandKC(sDS.Raw() | sKC.Raw()); -static const BitFlags sDSandCR(sDS.Raw() | sCR.Raw()); -static const BitFlags sDSandEO(sDS.Raw() | sEO.Raw()); -static const BitFlags sDSandDO(sDS.Raw() | sDO.Raw()); -static const BitFlags sKCandDS(sKC.Raw() | sDS.Raw()); -static const BitFlags sKCandNR(sKC.Raw() | sNR.Raw()); -static const BitFlags sKCandKE(sKC.Raw() | sKE.Raw()); -static const BitFlags sKCandDE(sKC.Raw() | sDE.Raw()); -static const BitFlags sKCandKA(sKC.Raw() | sKA.Raw()); -static const BitFlags sKCandCR(sKC.Raw() | sCR.Raw()); -static const BitFlags sKCandEO(sKC.Raw() | sEO.Raw()); -static const BitFlags sKCandDO(sKC.Raw() | sDO.Raw()); +static const BitFlags sIgnoreNotBeforeFlag(CertValidateFlags::kIgnoreNotBefore); +static const BitFlags sIgnoreNotAfterFlag(CertValidateFlags::kIgnoreNotAfter); + +static const BitFlags sNullDecodeFlag; +static const BitFlags sGenTBSHashFlag(CertDecodeFlags::kGenerateTBSHash); +static const BitFlags sTrustAnchorFlag(CertDecodeFlags::kIsTrustAnchor); + +static const BitFlags sNullLoadFlag; +static const BitFlags sDerFormFlag(TestCertLoadFlags::kDERForm); +static const BitFlags sSupIsCAFlag(TestCertLoadFlags::kSuppressIsCA); +static const BitFlags sSupKeyUsageFlag(TestCertLoadFlags::kSuppressKeyUsage); +static const BitFlags sSupKeyCertSignFlag(TestCertLoadFlags::kSuppressKeyCertSign); +static const BitFlags sPathLenZeroFlag(TestCertLoadFlags::kSetPathLenConstZero); +static const BitFlags sAppDefCertTypeFlag(TestCertLoadFlags::kSetAppDefinedCertType); + +static const BitFlags sNullKPFlag; +static const BitFlags sSA(KeyPurposeFlags::kServerAuth); +static const BitFlags sCA(KeyPurposeFlags::kClientAuth); +static const BitFlags sCS(KeyPurposeFlags::kCodeSigning); +static const BitFlags sEP(KeyPurposeFlags::kEmailProtection); +static const BitFlags sTS(KeyPurposeFlags::kTimeStamping); +static const BitFlags sOS(KeyPurposeFlags::kOCSPSigning); +static const BitFlags sSAandCA(sSA, sCA); +static const BitFlags sSAandCS(sSA, sCS); +static const BitFlags sSAandEP(sSA, sEP); +static const BitFlags sSAandTS(sSA, sTS); + +static const BitFlags sNullKUFlag; +static const BitFlags sDS(KeyUsageFlags::kDigitalSignature); +static const BitFlags sNR(KeyUsageFlags::kNonRepudiation); +static const BitFlags sKE(KeyUsageFlags::kKeyEncipherment); +static const BitFlags sDE(KeyUsageFlags::kDataEncipherment); +static const BitFlags sKA(KeyUsageFlags::kKeyAgreement); +static const BitFlags sKC(KeyUsageFlags::kKeyCertSign); +static const BitFlags sCR(KeyUsageFlags::kCRLSign); +static const BitFlags sEO(KeyUsageFlags::kEncipherOnly); +static const BitFlags sDO(KeyUsageFlags::kDecipherOnly); +static const BitFlags sDSandNR(sDS, sNR); +static const BitFlags sDSandKE(sDS, sKE); +static const BitFlags sDSandDE(sDS, sDE); +static const BitFlags sDSandKA(sDS, sKA); +static const BitFlags sDSandKC(sDS, sKC); +static const BitFlags sDSandCR(sDS, sCR); +static const BitFlags sDSandEO(sDS, sEO); +static const BitFlags sDSandDO(sDS, sDO); +static const BitFlags sKCandDS(sKC, sDS); +static const BitFlags sKCandNR(sKC, sNR); +static const BitFlags sKCandKE(sKC, sKE); +static const BitFlags sKCandDE(sKC, sDE); +static const BitFlags sKCandKA(sKC, sKA); +static const BitFlags sKCandCR(sKC, sCR); +static const BitFlags sKCandEO(sKC, sEO); +static const BitFlags sKCandDO(sKC, sDO); static CHIP_ERROR LoadStandardCerts(ChipCertificateSet & certSet) { @@ -207,8 +207,8 @@ static void TestChipCert_CertValidation(nlTestSuite * inSuite, void * inContext) struct { uint8_t Type; - BitFlags DecodeFlags; - BitFlags LoadFlags; + BitFlags DecodeFlags; + BitFlags LoadFlags; } InputCerts[kMaxCertsPerTestCase]; }; @@ -475,8 +475,8 @@ static void TestChipCert_CertUsage(nlTestSuite * inSuite, void * inContext) struct UsageTestCase { uint8_t mCertIndex; - BitFlags mRequiredKeyUsages; - BitFlags mRequiredKeyPurposes; + BitFlags mRequiredKeyUsages; + BitFlags mRequiredKeyPurposes; CHIP_ERROR mExpectedResult; }; diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.cpp b/src/include/platform/internal/GenericConfigurationManagerImpl.cpp index 024d66371424bc..9cde2a4db75aad 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.cpp +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * Copyright (c) 2019-2020 Google LLC. * Copyright (c) 2018 Nest Labs, Inc. * @@ -50,15 +50,14 @@ namespace Internal { template CHIP_ERROR GenericConfigurationManagerImpl::_Init() { - mFlags = 0; - // Cache flags indicating whether the device is currently service provisioned, is a member of a fabric, // is paired to an account, and/or provisioned with operational credentials. - SetFlag(mFlags, kFlag_IsServiceProvisioned, Impl()->ConfigValueExists(ImplClass::kConfigKey_ServiceConfig)); - SetFlag(mFlags, kFlag_IsMemberOfFabric, Impl()->ConfigValueExists(ImplClass::kConfigKey_FabricId)); - SetFlag(mFlags, kFlag_IsPairedToAccount, Impl()->ConfigValueExists(ImplClass::kConfigKey_PairedAccountId)); - SetFlag(mFlags, kFlag_OperationalDeviceCredentialsProvisioned, - Impl()->ConfigValueExists(ImplClass::kConfigKey_OperationalDeviceCert)); + mFlags.ClearAll() + .Set(Flags::kIsServiceProvisioned, Impl()->ConfigValueExists(ImplClass::kConfigKey_ServiceConfig)) + .Set(Flags::kIsMemberOfFabric, Impl()->ConfigValueExists(ImplClass::kConfigKey_FabricId)) + .Set(Flags::kIsPairedToAccount, Impl()->ConfigValueExists(ImplClass::kConfigKey_PairedAccountId)) + .Set(Flags::kOperationalDeviceCredentialsProvisioned, + Impl()->ConfigValueExists(ImplClass::kConfigKey_OperationalDeviceCert)); #if CHIP_ENABLE_ROTATING_DEVICE_ID mLifetimePersistedCounter.Init(CHIP_CONFIG_LIFETIIME_PERSISTED_COUNTER_KEY); @@ -524,7 +523,7 @@ CHIP_ERROR GenericConfigurationManagerImpl::_ClearOperationalDeviceCr Impl()->ClearConfigValue(ImplClass::kConfigKey_OperationalDeviceICACerts); Impl()->ClearConfigValue(ImplClass::kConfigKey_OperationalDevicePrivateKey); - ClearFlag(mFlags, kFlag_OperationalDeviceCredentialsProvisioned); + mFlags.Clear(Flags::kOperationalDeviceCredentialsProvisioned); return CHIP_NO_ERROR; } @@ -532,19 +531,19 @@ CHIP_ERROR GenericConfigurationManagerImpl::_ClearOperationalDeviceCr template bool GenericConfigurationManagerImpl::_OperationalDeviceCredentialsProvisioned() { - return ::chip::GetFlag(mFlags, kFlag_OperationalDeviceCredentialsProvisioned); + return mFlags.Has(Flags::kOperationalDeviceCredentialsProvisioned); } template bool GenericConfigurationManagerImpl::UseManufacturerCredentialsAsOperational() { - return ::chip::GetFlag(mFlags, kFlag_UseManufacturerCredentialsAsOperational); + return mFlags.Has(Flags::kUseManufacturerCredentialsAsOperational); } template void GenericConfigurationManagerImpl::_UseManufacturerCredentialsAsOperational(bool val) { - SetFlag(mFlags, kFlag_UseManufacturerCredentialsAsOperational, val); + mFlags.Set(Flags::kUseManufacturerCredentialsAsOperational, val); } #endif // CHIP_DEVICE_CONFIG_ENABLE_JUST_IN_TIME_PROVISIONING @@ -627,11 +626,11 @@ CHIP_ERROR GenericConfigurationManagerImpl::_StoreFabricId(uint64_t f { err = Impl()->WriteConfigValue(ImplClass::kConfigKey_FabricId, fabricId); SuccessOrExit(err); - SetFlag(mFlags, kFlag_IsMemberOfFabric); + mFlags.Set(Flags::kIsMemberOfFabric); } else { - ClearFlag(mFlags, kFlag_IsMemberOfFabric); + mFlags.Clear(Flags::kIsMemberOfFabric); err = Impl()->ClearConfigValue(ImplClass::kConfigKey_FabricId); SuccessOrExit(err); } @@ -689,7 +688,7 @@ CHIP_ERROR GenericConfigurationManagerImpl::_StorePairedAccountId(con err = Impl()->WriteConfigValueStr(ImplClass::kConfigKey_PairedAccountId, accountId, accountIdLen); SuccessOrExit(err); - SetFlag(mFlags, kFlag_IsPairedToAccount, (accountId != nullptr && accountIdLen != 0)); + mFlags.Set(Flags::kIsPairedToAccount, (accountId != nullptr && accountIdLen != 0)); exit: return err; @@ -712,8 +711,8 @@ CHIP_ERROR GenericConfigurationManagerImpl::_StoreServiceProvisioning err = _StorePairedAccountId(accountId, accountIdLen); SuccessOrExit(err); - SetFlag(mFlags, kFlag_IsServiceProvisioned); - SetFlag(mFlags, kFlag_IsPairedToAccount, (accountId != nullptr && accountIdLen != 0)); + mFlags.Set(Flags::kIsServiceProvisioned); + mFlags.Set(Flags::kIsPairedToAccount, (accountId != nullptr && accountIdLen != 0)); exit: if (err != CHIP_NO_ERROR) @@ -721,8 +720,8 @@ CHIP_ERROR GenericConfigurationManagerImpl::_StoreServiceProvisioning Impl()->ClearConfigValue(ImplClass::kConfigKey_ServiceId); Impl()->ClearConfigValue(ImplClass::kConfigKey_ServiceConfig); Impl()->ClearConfigValue(ImplClass::kConfigKey_PairedAccountId); - ClearFlag(mFlags, kFlag_IsServiceProvisioned); - ClearFlag(mFlags, kFlag_IsPairedToAccount); + mFlags.Clear(Flags::kIsServiceProvisioned); + mFlags.Clear(Flags::kIsPairedToAccount); } return err; } @@ -757,8 +756,8 @@ CHIP_ERROR GenericConfigurationManagerImpl::_ClearServiceProvisioning PlatformMgr().PostEvent(&event); } - ClearFlag(mFlags, kFlag_IsServiceProvisioned); - ClearFlag(mFlags, kFlag_IsPairedToAccount); + mFlags.Clear(Flags::kIsServiceProvisioned); + mFlags.Clear(Flags::kIsPairedToAccount); return CHIP_NO_ERROR; } @@ -851,19 +850,19 @@ GenericConfigurationManagerImpl::_GetBLEDeviceIdentificationInfo(Ble: template bool GenericConfigurationManagerImpl::_IsServiceProvisioned() { - return ::chip::GetFlag(mFlags, kFlag_IsServiceProvisioned); + return mFlags.Has(Flags::kIsServiceProvisioned); } template bool GenericConfigurationManagerImpl::_IsMemberOfFabric() { - return ::chip::GetFlag(mFlags, kFlag_IsMemberOfFabric); + return mFlags.Has(Flags::kIsMemberOfFabric); } template bool GenericConfigurationManagerImpl::_IsPairedToAccount() { - return ::chip::GetFlag(mFlags, kFlag_IsPairedToAccount); + return mFlags.Has(Flags::kIsPairedToAccount); } template diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.h b/src/include/platform/internal/GenericConfigurationManagerImpl.h index 5632a933a10b32..15fb258d753c5e 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.h +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * Copyright (c) 2019-2020 Google LLC. * Copyright (c) 2018 Nest Labs, Inc. * @@ -25,6 +25,8 @@ #pragma once +#include + #if CHIP_ENABLE_ROTATING_DEVICE_ID #include #endif @@ -125,16 +127,16 @@ class GenericConfigurationManagerImpl void _LogDeviceConfig(); protected: - enum + enum class Flags : uint8_t { - kFlag_IsServiceProvisioned = 0x01, - kFlag_IsMemberOfFabric = 0x02, - kFlag_IsPairedToAccount = 0x04, - kFlag_OperationalDeviceCredentialsProvisioned = 0x08, - kFlag_UseManufacturerCredentialsAsOperational = 0x10, + kIsServiceProvisioned = 0x01, + kIsMemberOfFabric = 0x02, + kIsPairedToAccount = 0x04, + kOperationalDeviceCredentialsProvisioned = 0x08, + kUseManufacturerCredentialsAsOperational = 0x10, }; - uint8_t mFlags; + BitFlags mFlags; #if CHIP_ENABLE_ROTATING_DEVICE_ID chip::LifetimePersistedCounter mLifetimePersistedCounter; #endif diff --git a/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.cpp b/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.cpp index 62c83513d78280..da76c0cd184fa6 100644 --- a/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.cpp +++ b/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * Copyright (c) 2019 Nest Labs, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,7 +55,7 @@ void GenericConnectivityManagerImpl_Thread::_OnPlatformEvent(const Ch template ConnectivityManager::ThreadMode GenericConnectivityManagerImpl_Thread::_GetThreadMode() { - if (GetFlag(mFlags, kFlag_IsApplicationControlled)) + if (mFlags.Has(Flags::kIsApplicationControlled)) { return ConnectivityManager::kThreadMode_ApplicationControlled; } @@ -75,11 +75,11 @@ CHIP_ERROR GenericConnectivityManagerImpl_Thread::_SetThreadMode(Conn if (val == ConnectivityManager::kThreadMode_ApplicationControlled) { - SetFlag(mFlags, kFlag_IsApplicationControlled); + mFlags.Set(Flags::kIsApplicationControlled); } else { - ClearFlag(mFlags, kFlag_IsApplicationControlled); + mFlags.Clear(Flags::kIsApplicationControlled); err = ThreadStackMgrImpl().SetThreadEnabled(val == ConnectivityManager::kThreadMode_Enabled); SuccessOrExit(err); @@ -92,15 +92,15 @@ CHIP_ERROR GenericConnectivityManagerImpl_Thread::_SetThreadMode(Conn template void GenericConnectivityManagerImpl_Thread::UpdateServiceConnectivity() { - bool haveServiceConnectivity = false; + constexpr bool haveServiceConnectivity = false; // If service connectivity via Thread has changed, post an event signaling the change. - if (GetFlag(mFlags, kFlag_HaveServiceConnectivity) != haveServiceConnectivity) + if (mFlags.Has(Flags::kHaveServiceConnectivity) != haveServiceConnectivity) { ChipLogProgress(DeviceLayer, "ConnectivityManager: Service connectivity via Thread %s", (haveServiceConnectivity) ? "ESTABLISHED" : "LOST"); - SetFlag(mFlags, kFlag_HaveServiceConnectivity, haveServiceConnectivity); + mFlags.Set(Flags::kHaveServiceConnectivity, haveServiceConnectivity); { ChipDeviceEvent event; diff --git a/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.h b/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.h index 5cb683a9e1138b..cdf127104227b9 100644 --- a/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.h +++ b/src/include/platform/internal/GenericConnectivityManagerImpl_Thread.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * Copyright (c) 2019 Nest Labs, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,6 +25,9 @@ #pragma once #include +#include + +#include namespace chip { namespace DeviceLayer { @@ -73,13 +76,13 @@ class GenericConnectivityManagerImpl_Thread private: // ===== Private members reserved for use by this class only. - enum Flags + enum class Flags : uint8_t { - kFlag_HaveServiceConnectivity = 0x01, - kFlag_IsApplicationControlled = 0x02 + kHaveServiceConnectivity = 0x01, + kIsApplicationControlled = 0x02 }; - uint8_t mFlags; + BitFlags mFlags; ImplClass * Impl() { return static_cast(this); } }; @@ -87,7 +90,7 @@ class GenericConnectivityManagerImpl_Thread template inline void GenericConnectivityManagerImpl_Thread::_Init() { - mFlags = 0; + mFlags.ClearAll(); } template @@ -99,7 +102,7 @@ inline bool GenericConnectivityManagerImpl_Thread::_IsThreadEnabled() template inline bool GenericConnectivityManagerImpl_Thread::_IsThreadApplicationControlled() { - return GetFlag(mFlags, kFlag_IsApplicationControlled); + return mFlags.Has(Flags::kIsApplicationControlled); } template @@ -150,7 +153,7 @@ inline CHIP_ERROR GenericConnectivityManagerImpl_Thread::_SetThreadPo template inline bool GenericConnectivityManagerImpl_Thread::_HaveServiceConnectivityViaThread() { - return GetFlag(mFlags, kFlag_HaveServiceConnectivity); + return mFlags.Has(Flags::kHaveServiceConnectivity); } } // namespace Internal diff --git a/src/include/platform/internal/GenericConnectivityManagerImpl_WiFi.h b/src/include/platform/internal/GenericConnectivityManagerImpl_WiFi.h index fb10bbb62e6fe1..a363a4ac609e7f 100644 --- a/src/include/platform/internal/GenericConnectivityManagerImpl_WiFi.h +++ b/src/include/platform/internal/GenericConnectivityManagerImpl_WiFi.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -82,11 +82,11 @@ class GenericConnectivityManagerImpl_WiFi static const char * _WiFiAPStateToStr(ConnectivityManager::WiFiAPState state); protected: - enum Flags + enum class ConnectivityFlags : uint16_t { - kFlag_HaveIPv4InternetConnectivity = 0x0001, - kFlag_HaveIPv6InternetConnectivity = 0x0002, - kFlag_AwaitingConnectivity = 0x0010, + kHaveIPv4InternetConnectivity = 0x0001, + kHaveIPv6InternetConnectivity = 0x0002, + kAwaitingConnectivity = 0x0010, }; private: diff --git a/src/lib/support/BitFlags.h b/src/lib/support/BitFlags.h index 4d22b66c952b60..fb99ed9d7d9d45 100644 --- a/src/lib/support/BitFlags.h +++ b/src/lib/support/BitFlags.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * Copyright (c) 2013-2017 Nest Labs, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,6 +27,7 @@ #include +#include #include namespace chip { @@ -34,115 +35,217 @@ namespace chip { /** * Stores bit flags in a type safe manner. * + * @tparam FlagsEnum is an `enum` or (preferably) `enum class` type. * @tparam StorageType is the underlying storage type (like uint16_t, uint32_t etc.) - * @tparam FlagsEnum is the typesafe flags setting + * and defaults to the underlying storage type of `FlagsEnum`. */ -template +template > class BitFlags { public: static_assert(sizeof(StorageType) >= sizeof(FlagsEnum), "All flags should fit in the storage type"); + using IntegerType = StorageType; - BitFlags() {} - BitFlags(const BitFlags &) = default; + BitFlags() : mValue(0) {} + BitFlags(const BitFlags & other) = default; BitFlags & operator=(const BitFlags &) = default; - explicit BitFlags(FlagsEnum v) { Set(v); } + explicit BitFlags(FlagsEnum value) : mValue(static_cast(value)) {} + explicit BitFlags(IntegerType value) : mValue(value) {} - explicit BitFlags(StorageType value) { SetRaw(value); } + template + BitFlags(FlagsEnum flag, Args &&... args) : mValue(Or(flag, std::forward(args)...)) + {} + + template + BitFlags(const BitFlags & flags, Args &&... args) : mValue(Or(flags, std::forward(args)...)) + {} - BitFlags & Set(FlagsEnum v) + template + BitFlags(IntegerType value, Args &&... args) : mValue(value | Or(std::forward(args)...)) + {} + + /** + * Set flag(s). + * + * @param other Flag(s) to set. Any flags not set in @a other are unaffected. + */ + BitFlags & Set(const BitFlags & other) { - mValue = static_cast(mValue | static_cast(v)); + mValue |= other.mValue; return *this; } - BitFlags & Clear(FlagsEnum v) + /** + * Set flag(s). + * + * @param flag Typed flag(s) to set. Any flags not in @a v are unaffected. + */ + BitFlags & Set(FlagsEnum flag) { - mValue &= static_cast(~static_cast(v)); + mValue |= static_cast(flag); return *this; } - BitFlags & Set(FlagsEnum v, bool isSet) { return isSet ? Set(v) : Clear(v); } - - bool Has(FlagsEnum v) const { return (mValue & static_cast(v)) != 0; } - - bool Has(StorageType other) const { return (mValue & other) == other; } + /** + * Set or clear flag(s). + * + * @param flag Typed flag(s) to set or clear. Any flags not in @a flag are unaffected. + * @param isSet If true, set the flag; if false, clear it. + */ + BitFlags & Set(FlagsEnum flag, bool isSet) { return isSet ? Set(flag) : Clear(flag); } + + /** + * Clear flag(s). + * + * @param other Typed flag(s) to clear. Any flags not in @a other are unaffected. + */ + BitFlags & Clear(const BitFlags & other) + { + mValue &= ~other.mValue; + return *this; + } - BitFlags & Set(const BitFlags & other) + /** + * Clear flag(s). + * + * @param flag Typed flag(s) to clear. Any flags not in @a flag are unaffected. + */ + BitFlags & Clear(FlagsEnum flag) { - mValue |= other.mValue; + mValue &= static_cast(~static_cast(flag)); return *this; } - StorageType Raw() const { return mValue; } - BitFlags & SetRaw(StorageType value) + /** + * Clear all flags. + */ + BitFlags & ClearAll() { - mValue = value; + mValue = 0; return *this; } - /** Check that no flags outside the arguments are set.*/ + /** + * Check whether flag(s) are set. + * + * @param flag Flag(s) to test. + * @returns True if any flag in @a flag is set, otherwise false. + */ + bool Has(FlagsEnum flag) const { return (mValue & static_cast(flag)) != 0; } + + /** + * Check that no flags outside the arguments are set. + * + * @param args Flags to test. Arguments can be BitFlags, BitFlags, or FlagsEnum. + * @returns True if no flag is set other than those passed. + * False if any flag is set other than those passed. + * + * @note Flags passed need not be set; this test only requires that no *other* flags be set. + */ template bool HasOnly(Args &&... args) const { - return IsZeroAfterClearing(mValue, std::forward(args)...); + return (mValue & Or(std::forward(args)...)) == mValue; } -private: - StorageType mValue = 0; + /** + * Check that all given flags are set. + * + * @param args Flags to test. Arguments can be BitFlags, BitFlags, or FlagsEnum. + * @returns True if all given flags are set. + * False if any given flag is not set. + */ + template + bool HasAll(Args &&... args) const + { + const IntegerType all = Or(std::forward(args)...); + return (mValue & all) == all; + } + /** + * Check that at least one of the given flags is set. + * + * @param args Flags to test. Arguments can be BitFlags, BitFlags, or FlagsEnum. + * @returns True if all given flags are set. + * False if any given flag is not set. + */ template - static bool IsZeroAfterClearing(StorageType value, FlagsEnum flagToClear, Args &&... args) + bool HasAny(Args &&... args) const { - value &= static_cast(~static_cast(flagToClear)); - return IsZeroAfterClearing(value, std::forward(args)...); + return (mValue & Or(std::forward(args)...)) != 0; } - static bool IsZeroAfterClearing(StorageType value) { return value == 0; } -}; + /** + * Check that at least one flag is set. + * + * @returns True if any flag is set, false otherwise. + */ + bool HasAny() const { return mValue != 0; } + + /** + * Find the logical intersection of flags. + * + * @param lhs Some flags. + * @param rhs Some flags. + * @returns Flags set in both @a lhs and @a rhs. + * + * @note: A multi-argument `BitFlags` constructor serves the function of `operator|`. + */ + friend BitFlags operator&(BitFlags lhs, const BitFlags & rhs) + { + return BitFlags(lhs.mValue & rhs.mValue); + } -/** - * @deprecated Use typesafe BitFlags class instead. - */ -template -inline bool GetFlag(const FlagsT & inFlags, const FlagT inFlag) -{ - return (inFlags & static_cast(inFlag)) != 0; -} + /** + * Get the flags as the type FlagsEnum. + * + * @note This allows easily storing flags as a base FlagsEnum in a POD type, + * and enables equality comparisons. + */ + operator FlagsEnum() const { return static_cast(mValue); } + + /** + * Set and/or clear all flags with a value of the underlying storage type. + * + * @param value New storage value. + */ + BitFlags & SetRaw(IntegerType value) + { + mValue = value; + return *this; + } -/** - * @deprecated Use typesafe BitFlags class instead. - */ -template -inline void ClearFlag(FlagsT & inFlags, const FlagT inFlag) -{ - inFlags &= static_cast(~static_cast(inFlag)); -} + /** + * Get the flags as the underlying integer type. + * + * @note This is intended to be used only to store flags into a raw binary record. + */ + IntegerType Raw() const { return mValue; } -/** - * @deprecated Use typesafe BitFlags class instead. - */ -template -inline void SetFlag(FlagsT & inFlags, const FlagT inFlag) -{ - inFlags = static_cast(inFlags | static_cast(inFlag)); -} + /** + * Get the address of the flags as a pointer to the underlying integer type. + * + * @note This is intended to be used only to read flags from a raw binary record. + */ + StorageType * RawStorage() { return &mValue; } -/** - * @deprecated Use typesafe BitFlags class instead. - */ -template -inline void SetFlag(FlagsT & inFlags, const FlagT inFlag, const bool inValue) -{ - if (inValue) +private: + // Find the union of BitFlags and/or FlagsEnum values. + template + static constexpr IntegerType Or(FlagsEnum flag, Args &&... args) { - SetFlag(inFlags, inFlag); + return static_cast(flag) | Or(std::forward(args)...); } - else + template + static constexpr IntegerType Or(const BitFlags & flags, Args &&... args) { - ClearFlag(inFlags, inFlag); + return flags.mValue | Or(std::forward(args)...); } -} + static constexpr IntegerType Or(FlagsEnum value) { return static_cast(value); } + static constexpr IntegerType Or(const BitFlags & flags) { return flags.Raw(); } + + StorageType mValue = 0; +}; } // namespace chip diff --git a/src/lib/support/BytesToHex.cpp b/src/lib/support/BytesToHex.cpp index e1f40939c5f738..11b2714b891826 100644 --- a/src/lib/support/BytesToHex.cpp +++ b/src/lib/support/BytesToHex.cpp @@ -38,7 +38,7 @@ char NibbleToHex(uint8_t nibble, bool uppercase) } // namespace -CHIP_ERROR BytesToHex(const uint8_t * src_bytes, size_t src_size, char * dest_hex, size_t dest_size_max, HexFlags flags) +CHIP_ERROR BytesToHex(const uint8_t * src_bytes, size_t src_size, char * dest_hex, size_t dest_size_max, BitFlags flags) { if ((src_bytes == nullptr) || (dest_hex == nullptr)) { @@ -52,14 +52,14 @@ CHIP_ERROR BytesToHex(const uint8_t * src_bytes, size_t src_size, char * dest_he return CHIP_ERROR_INVALID_ARGUMENT; } - bool nul_terminate = (static_cast(flags) & static_cast(HexFlags::kNullTerminate)) != 0; + bool nul_terminate = flags.Has(HexFlags::kNullTerminate); size_t expected_output_size = (src_size * 2u) + (nul_terminate ? 1u : 0u); if (dest_size_max < expected_output_size) { return CHIP_ERROR_BUFFER_TOO_SMALL; } - bool uppercase = (static_cast(flags) & static_cast(HexFlags::kUppercase)) != 0; + bool uppercase = flags.Has(HexFlags::kUppercase); char * cursor = dest_hex; for (size_t byte_idx = 0; byte_idx < src_size; ++byte_idx) { diff --git a/src/lib/support/BytesToHex.h b/src/lib/support/BytesToHex.h index b62617b5250572..bbd20251840af4 100644 --- a/src/lib/support/BytesToHex.h +++ b/src/lib/support/BytesToHex.h @@ -18,13 +18,15 @@ #pragma once #include +#include + #include #include namespace chip { namespace Encoding { -enum HexFlags : int +enum class HexFlags : int { kNone = 0u, // Use uppercase A-F if set otherwise, lowercase a-f @@ -68,7 +70,7 @@ enum HexFlags : int * @return CHIP_NO_ERROR on success */ -CHIP_ERROR BytesToHex(const uint8_t * src_bytes, size_t src_size, char * dest_hex, size_t dest_size_max, HexFlags flags); +CHIP_ERROR BytesToHex(const uint8_t * src_bytes, size_t src_size, char * dest_hex, size_t dest_size_max, BitFlags flags); // Alias for Uppercase option, no null-termination inline CHIP_ERROR BytesToUppercaseHexBuffer(const uint8_t * src_bytes, size_t src_size, char * dest_hex_buf, size_t dest_size_max) diff --git a/src/messaging/ExchangeContext.h b/src/messaging/ExchangeContext.h index 2c9917aec2cda6..35e33d4f54255a 100644 --- a/src/messaging/ExchangeContext.h +++ b/src/messaging/ExchangeContext.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -205,7 +205,7 @@ class DLL_EXPORT ExchangeContext : public ReferenceCounted mFlags; // Internal state flags + BitFlags mFlags; // Internal state flags /** * Search for an existing exchange that the message applies to. diff --git a/src/messaging/Flags.h b/src/messaging/Flags.h index aafa7d8812ff2c..61d7dd827f2da8 100644 --- a/src/messaging/Flags.h +++ b/src/messaging/Flags.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,7 +55,7 @@ enum class MessageFlagValues : uint32_t kViaEphemeralUDPPort = 0x00040000, }; -using MessageFlags = BitFlags; +using MessageFlags = BitFlags; enum class SendMessageFlags : uint16_t { @@ -76,7 +76,7 @@ enum class SendMessageFlags : uint16_t kNoAutoRequestAck = 0x0400, }; -using SendFlags = BitFlags; +using SendFlags = BitFlags; } // namespace Messaging } // namespace chip diff --git a/src/messaging/ReliableMessageContext.cpp b/src/messaging/ReliableMessageContext.cpp index 577e9a8beed7ff..d1cefb95bf5823 100644 --- a/src/messaging/ReliableMessageContext.cpp +++ b/src/messaging/ReliableMessageContext.cpp @@ -181,7 +181,7 @@ CHIP_ERROR ReliableMessageContext::HandleRcvdAck(uint32_t AckMsgId) return err; } -CHIP_ERROR ReliableMessageContext::HandleNeedsAck(uint32_t MessageId, BitFlags MsgFlags) +CHIP_ERROR ReliableMessageContext::HandleNeedsAck(uint32_t MessageId, BitFlags MsgFlags) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -260,7 +260,7 @@ CHIP_ERROR ReliableMessageContext::SendStandaloneAckMessage() if (mExchange != nullptr) { err = mExchange->SendMessage(Protocols::SecureChannel::MsgType::StandaloneAck, std::move(msgBuf), - BitFlags{ SendMessageFlags::kNoAutoRequestAck }); + BitFlags{ SendMessageFlags::kNoAutoRequestAck }); } else { diff --git a/src/messaging/ReliableMessageContext.h b/src/messaging/ReliableMessageContext.h index 77c55dbf4ba075..57bf18e688ca07 100644 --- a/src/messaging/ReliableMessageContext.h +++ b/src/messaging/ReliableMessageContext.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -203,12 +203,12 @@ class ReliableMessageContext kFlagMsgRcvdFromPeer = 0x0080, }; - BitFlags mFlags; // Internal state flags + BitFlags mFlags; // Internal state flags void Retain(); void Release(); CHIP_ERROR HandleRcvdAck(uint32_t AckMsgId); - CHIP_ERROR HandleNeedsAck(uint32_t MessageId, BitFlags Flags); + CHIP_ERROR HandleNeedsAck(uint32_t MessageId, BitFlags Flags); private: friend class ReliableMessageMgr; diff --git a/src/platform/EFR32/BLEManagerImpl.cpp b/src/platform/EFR32/BLEManagerImpl.cpp index 85d44f32a1e858..82e040402e1c90 100644 --- a/src/platform/EFR32/BLEManagerImpl.cpp +++ b/src/platform/EFR32/BLEManagerImpl.cpp @@ -171,7 +171,7 @@ CHIP_ERROR BLEManagerImpl::_Init() CHIP_DEVICE_CONFIG_BLE_APP_TASK_PRIORITY, /* Priority at which the task is created. */ NULL); /* Variable to hold the task's data structure. */ - mFlags = CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART ? kFlag_AdvertisingEnabled : 0; + mFlags.ClearAll().Set(Flags::kAdvertisingEnabled, CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART); PlatformMgr().ScheduleWork(DriveBLEState, 0); exit: @@ -315,9 +315,9 @@ CHIP_ERROR BLEManagerImpl::_SetAdvertisingEnabled(bool val) VerifyOrExit(mServiceMode != ConnectivityManager::kCHIPoBLEServiceMode_NotSupported, err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); - if (GetFlag(mFlags, kFlag_AdvertisingEnabled) != val) + if (mFlags.Has(Flags::kAdvertisingEnabled) != val) { - SetFlag(mFlags, kFlag_AdvertisingEnabled, val); + mFlags.Set(Flags::kAdvertisingEnabled, val); PlatformMgr().ScheduleWork(DriveBLEState, 0); } @@ -331,9 +331,9 @@ CHIP_ERROR BLEManagerImpl::_SetFastAdvertisingEnabled(bool val) VerifyOrExit(mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_NotSupported, err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); - if (GetFlag(mFlags, kFlag_FastAdvertisingEnabled) != val) + if (mFlags.Has(Flags::kFastAdvertisingEnabled) != val) { - SetFlag(mFlags, kFlag_FastAdvertisingEnabled, val); + mFlags.Set(Flags::kFastAdvertisingEnabled, val); PlatformMgr().ScheduleWork(DriveBLEState, 0); } @@ -366,7 +366,7 @@ CHIP_ERROR BLEManagerImpl::_SetDeviceName(const char * deviceName) return CHIP_ERROR_INVALID_ARGUMENT; } strcpy(mDeviceName, deviceName); - SetFlag(mFlags, kFlag_DeviceNameSet, true); + mFlags.Set(Flags::kDeviceNameSet); ChipLogProgress(DeviceLayer, "Setting device name to : \"%s\"", deviceName); static_assert(kMaxDeviceNameLength <= UINT16_MAX, "deviceName length might not fit in a uint8_t"); ret = sl_bt_gatt_server_write_attribute_value(gattdb_device_name, 0, strlen(deviceName), (uint8_t *) deviceName); @@ -539,14 +539,14 @@ void BLEManagerImpl::DriveBLEState(void) CHIP_ERROR err = CHIP_NO_ERROR; // Check if BLE stack is initialized - VerifyOrExit(GetFlag(mFlags, kFlag_EFRBLEStackInitialized), /* */); + VerifyOrExit(mFlags.Has(Flags::kEFRBLEStackInitialized), /* */); // Start advertising if needed... - if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && GetFlag(mFlags, kFlag_AdvertisingEnabled)) + if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && mFlags.Has(Flags::kAdvertisingEnabled)) { // Start/re-start advertising if not already started, or if there is a pending change // to the advertising configuration. - if (!GetFlag(mFlags, kFlag_Advertising) || GetFlag(mFlags, kFlag_RestartAdvertising)) + if (!mFlags.Has(Flags::kAdvertising) || mFlags.Has(Flags::kRestartAdvertising)) { err = StartAdvertising(); SuccessOrExit(err); @@ -554,7 +554,7 @@ void BLEManagerImpl::DriveBLEState(void) } // Otherwise, stop advertising if it is enabled. - else if (GetFlag(mFlags, kFlag_Advertising)) + else if (mFlags.Has(Flags::kAdvertising)) { err = StopAdvertising(); SuccessOrExit(err); @@ -587,7 +587,7 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void) err = ConfigurationMgr().GetBLEDeviceIdentificationInfo(mDeviceIdInfo); SuccessOrExit(err); - if (!GetFlag(mFlags, kFlag_DeviceNameSet)) + if (!mFlags.Has(Flags::kDeviceNameSet)) { snprintf(mDeviceName, sizeof(mDeviceName), "%s%04" PRIX32, CHIP_DEVICE_CONFIG_BLE_DEVICE_NAME_PREFIX, (uint32_t) 0); @@ -685,10 +685,10 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) err = ConfigureAdvertisingData(); SuccessOrExit(err); - ClearFlag(mFlags, kFlag_RestartAdvertising); + mFlags.Clear(Flags::kRestartAdvertising); interval_min = interval_max = - ((numConnectionss == 0 && !ConfigurationMgr().IsPairedToAccount()) || GetFlag(mFlags, kFlag_FastAdvertisingEnabled)) + ((numConnectionss == 0 && !ConfigurationMgr().IsPairedToAccount()) || mFlags.Has(Flags::kFastAdvertisingEnabled)) ? CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL : CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL; @@ -700,7 +700,7 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) if (SL_STATUS_OK == ret) { - SetFlag(mFlags, kFlag_Advertising, true); + mFlags.Set(Flags::kAdvertising); } err = MapBLEError(ret); @@ -714,10 +714,9 @@ CHIP_ERROR BLEManagerImpl::StopAdvertising(void) CHIP_ERROR err = CHIP_NO_ERROR; sl_status_t ret; - if (GetFlag(mFlags, kFlag_Advertising)) + if (mFlags.Has(Flags::kAdvertising)) { - ClearFlag(mFlags, kFlag_Advertising); - ClearFlag(mFlags, kFlag_RestartAdvertising); + mFlags.Clear(Flags::kAdvertising).Clear(Flags::kRestartAdvertising); ret = sl_bt_advertiser_stop(advertising_set_handle); sl_bt_advertiser_delete_set(advertising_set_handle); @@ -754,7 +753,7 @@ void BLEManagerImpl::UpdateMtu(volatile sl_bt_msg_t * evt) void BLEManagerImpl::HandleBootEvent(void) { - SetFlag(mFlags, kFlag_EFRBLEStackInitialized, true); + mFlags.Set(Flags::kEFRBLEStackInitialized); PlatformMgr().ScheduleWork(DriveBLEState, 0); } @@ -768,7 +767,7 @@ void BLEManagerImpl::HandleConnectEvent(volatile sl_bt_msg_t * evt) AddConnection(connHandle, bondingHandle); - // SetFlag(mFlags, kFlag_RestartAdvertising, true); + // mFlags.Set(Flags::kRestartAdvertising); PlatformMgr().ScheduleWork(DriveBLEState, 0); } @@ -808,7 +807,7 @@ void BLEManagerImpl::HandleConnectionCloseEvent(volatile sl_bt_msg_t * evt) // Arrange to re-enable connectable advertising in case it was disabled due to the // maximum connection limit being reached. - SetFlag(mFlags, kFlag_RestartAdvertising, true); + mFlags.Set(Flags::kRestartAdvertising); PlatformMgr().ScheduleWork(DriveBLEState, 0); } } diff --git a/src/platform/EFR32/BLEManagerImpl.h b/src/platform/EFR32/BLEManagerImpl.h index 84cfc6d0c9b80c..3d1df68cbecfaa 100644 --- a/src/platform/EFR32/BLEManagerImpl.h +++ b/src/platform/EFR32/BLEManagerImpl.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * Copyright (c) 2019 Nest Labs, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -90,14 +90,14 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla // ===== Private members reserved for use by this class only. - enum + enum class Flags : uint16_t { - kFlag_AdvertisingEnabled = 0x0001, - kFlag_FastAdvertisingEnabled = 0x0002, - kFlag_Advertising = 0x0004, - kFlag_RestartAdvertising = 0x0008, - kFlag_EFRBLEStackInitialized = 0x0010, - kFlag_DeviceNameSet = 0x0020, + kAdvertisingEnabled = 0x0001, + kFastAdvertisingEnabled = 0x0002, + kAdvertising = 0x0004, + kRestartAdvertising = 0x0008, + kEFRBLEStackInitialized = 0x0010, + kDeviceNameSet = 0x0020, }; enum @@ -121,7 +121,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla CHIPoBLEConState mBleConnections[kMaxConnections]; uint8_t mIndConfId[kMaxConnections]; CHIPoBLEServiceMode mServiceMode; - uint16_t mFlags; + BitFlags mFlags; char mDeviceName[kMaxDeviceNameLength + 1]; // The advertising set handle allocated from Bluetooth stack. uint8_t advertising_set_handle = 0xff; @@ -182,12 +182,12 @@ inline BLEManager::CHIPoBLEServiceMode BLEManagerImpl::_GetCHIPoBLEServiceMode(v inline bool BLEManagerImpl::_IsAdvertisingEnabled(void) { - return GetFlag(mFlags, kFlag_AdvertisingEnabled); + return mFlags.Has(Flags::kAdvertisingEnabled); } inline bool BLEManagerImpl::_IsFastAdvertisingEnabled(void) { - return GetFlag(mFlags, kFlag_FastAdvertisingEnabled); + return mFlags.Has(Flags::kFastAdvertisingEnabled); } } // namespace Internal diff --git a/src/platform/ESP32/BLEManagerImpl.h b/src/platform/ESP32/BLEManagerImpl.h index 0cafee56d59a10..702a0ac37c310a 100644 --- a/src/platform/ESP32/BLEManagerImpl.h +++ b/src/platform/ESP32/BLEManagerImpl.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * Copyright (c) 2018 Nest Labs, Inc. * All rights reserved. * @@ -117,20 +117,20 @@ class BLEManagerImpl final : public BLEManager, // ===== Private members reserved for use by this class only. - enum + enum class Flags : uint16_t { - kFlag_AsyncInitCompleted = 0x0001, /**< One-time asynchronous initialization actions have been performed. */ - kFlag_ESPBLELayerInitialized = 0x0002, /**< The ESP BLE layer has been initialized. */ - kFlag_AppRegistered = 0x0004, /**< The CHIPoBLE application has been registered with the ESP BLE layer. */ - kFlag_AttrsRegistered = 0x0008, /**< The CHIPoBLE GATT attributes have been registered with the ESP BLE layer. */ - kFlag_GATTServiceStarted = 0x0010, /**< The CHIPoBLE GATT service has been started. */ - kFlag_AdvertisingConfigured = 0x0020, /**< CHIPoBLE advertising has been configured in the ESP BLE layer. */ - kFlag_Advertising = 0x0040, /**< The system is currently CHIPoBLE advertising. */ - kFlag_ControlOpInProgress = 0x0080, /**< An async control operation has been issued to the ESP BLE layer. */ - kFlag_AdvertisingEnabled = 0x0100, /**< The application has enabled CHIPoBLE advertising. */ - kFlag_FastAdvertisingEnabled = 0x0200, /**< The application has enabled fast advertising. */ - kFlag_UseCustomDeviceName = 0x0400, /**< The application has configured a custom BLE device name. */ - kFlag_AdvertisingRefreshNeeded = 0x0800, /**< The advertising configuration/state in ESP BLE layer needs to be updated. */ + kAsyncInitCompleted = 0x0001, /**< One-time asynchronous initialization actions have been performed. */ + kESPBLELayerInitialized = 0x0002, /**< The ESP BLE layer has been initialized. */ + kAppRegistered = 0x0004, /**< The CHIPoBLE application has been registered with the ESP BLE layer. */ + kAttrsRegistered = 0x0008, /**< The CHIPoBLE GATT attributes have been registered with the ESP BLE layer. */ + kGATTServiceStarted = 0x0010, /**< The CHIPoBLE GATT service has been started. */ + kAdvertisingConfigured = 0x0020, /**< CHIPoBLE advertising has been configured in the ESP BLE layer. */ + kAdvertising = 0x0040, /**< The system is currently CHIPoBLE advertising. */ + kControlOpInProgress = 0x0080, /**< An async control operation has been issued to the ESP BLE layer. */ + kAdvertisingEnabled = 0x0100, /**< The application has enabled CHIPoBLE advertising. */ + kFastAdvertisingEnabled = 0x0200, /**< The application has enabled fast advertising. */ + kUseCustomDeviceName = 0x0400, /**< The application has configured a custom BLE device name. */ + kAdvertisingRefreshNeeded = 0x0800, /**< The advertising configuration/state in ESP BLE layer needs to be updated. */ }; enum @@ -183,7 +183,7 @@ class BLEManagerImpl final : public BLEManager, uint16_t mRXCharAttrHandle; uint16_t mTXCharAttrHandle; uint16_t mTXCharCCCDAttrHandle; - uint16_t mFlags; + BitFlags mFlags; char mDeviceName[kMaxDeviceNameLength + 1]; void DriveBLEState(void); @@ -266,17 +266,17 @@ inline BLEManager::CHIPoBLEServiceMode BLEManagerImpl::_GetCHIPoBLEServiceMode(v inline bool BLEManagerImpl::_IsAdvertisingEnabled(void) { - return GetFlag(mFlags, kFlag_AdvertisingEnabled); + return mFlags.Has(Flags::kAdvertisingEnabled); } inline bool BLEManagerImpl::_IsFastAdvertisingEnabled(void) { - return GetFlag(mFlags, kFlag_FastAdvertisingEnabled); + return mFlags.Has(Flags::kFastAdvertisingEnabled); } inline bool BLEManagerImpl::_IsAdvertising(void) { - return GetFlag(mFlags, kFlag_Advertising); + return mFlags.Has(Flags::kAdvertising); } } // namespace Internal diff --git a/src/platform/ESP32/ConnectivityManagerImpl.cpp b/src/platform/ESP32/ConnectivityManagerImpl.cpp index 8c0aff5c4c43ee..caa48dedf5c276 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl.cpp +++ b/src/platform/ESP32/ConnectivityManagerImpl.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * Copyright (c) 2018 Nest Labs, Inc. * All rights reserved. * @@ -401,7 +401,7 @@ CHIP_ERROR ConnectivityManagerImpl::_Init() mWiFiAPState = kWiFiAPState_NotActive; mWiFiStationReconnectIntervalMS = CHIP_DEVICE_CONFIG_WIFI_STATION_RECONNECT_INTERVAL; mWiFiAPIdleTimeoutMS = CHIP_DEVICE_CONFIG_WIFI_AP_IDLE_TIMEOUT; - mFlags = 0; + mFlags.SetRaw(0); // TODO Initialize the Chip Addressing and Routing Module. @@ -902,10 +902,10 @@ void ConnectivityManagerImpl::DriveAPState(::chip::System::Layer * aLayer, void void ConnectivityManagerImpl::UpdateInternetConnectivityState(void) { - bool haveIPv4Conn = false; - bool haveIPv6Conn = false; - bool hadIPv4Conn = GetFlag(mFlags, kFlag_HaveIPv4InternetConnectivity); - bool hadIPv6Conn = GetFlag(mFlags, kFlag_HaveIPv6InternetConnectivity); + bool haveIPv4Conn = false; + bool haveIPv6Conn = false; + const bool hadIPv4Conn = mFlags.Has(ConnectivityFlags::kHaveIPv4InternetConnectivity); + const bool hadIPv6Conn = mFlags.Has(ConnectivityFlags::kHaveIPv6InternetConnectivity); IPAddress addr; // If the WiFi station is currently in the connected state... @@ -962,8 +962,8 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState(void) if (haveIPv4Conn != hadIPv4Conn || haveIPv6Conn != hadIPv6Conn) { // Update the current state. - SetFlag(mFlags, kFlag_HaveIPv4InternetConnectivity, haveIPv4Conn); - SetFlag(mFlags, kFlag_HaveIPv6InternetConnectivity, haveIPv6Conn); + mFlags.Set(ConnectivityFlags::kHaveIPv4InternetConnectivity, haveIPv4Conn) + .Set(ConnectivityFlags::kHaveIPv6InternetConnectivity, haveIPv6Conn); // Alert other components of the state change. ChipDeviceEvent event; diff --git a/src/platform/ESP32/ConnectivityManagerImpl.h b/src/platform/ESP32/ConnectivityManagerImpl.h index 2a532932fdbc1f..f698f3839e1d55 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl.h +++ b/src/platform/ESP32/ConnectivityManagerImpl.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * Copyright (c) 2018 Nest Labs, Inc. * All rights reserved. * @@ -28,6 +28,7 @@ #include #endif #include +#include #include "esp_event.h" @@ -67,6 +68,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, friend class ConnectivityManager; private: + using Flags = GenericConnectivityManagerImpl_WiFi::ConnectivityFlags; // ===== Members that implement the ConnectivityManager abstract interface. WiFiStationMode _GetWiFiStationMode(void); @@ -114,7 +116,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, WiFiAPState mWiFiAPState; uint32_t mWiFiStationReconnectIntervalMS; uint32_t mWiFiAPIdleTimeoutMS; - uint16_t mFlags; + BitFlags mFlags; void DriveStationState(void); void OnStationConnected(void); @@ -172,12 +174,12 @@ inline uint32_t ConnectivityManagerImpl::_GetWiFiAPIdleTimeoutMS(void) inline bool ConnectivityManagerImpl::_HaveIPv4InternetConnectivity(void) { - return ::chip::GetFlag(mFlags, kFlag_HaveIPv4InternetConnectivity); + return mFlags.Has(Flags::kHaveIPv4InternetConnectivity); } inline bool ConnectivityManagerImpl::_HaveIPv6InternetConnectivity(void) { - return ::chip::GetFlag(mFlags, kFlag_HaveIPv6InternetConnectivity); + return mFlags.Has(Flags::kHaveIPv6InternetConnectivity); } inline bool ConnectivityManagerImpl::_CanStartWiFiScan() diff --git a/src/platform/ESP32/bluedroid/BLEManagerImpl.cpp b/src/platform/ESP32/bluedroid/BLEManagerImpl.cpp index 82810b3bf2a7c0..55f9d021f37240 100644 --- a/src/platform/ESP32/bluedroid/BLEManagerImpl.cpp +++ b/src/platform/ESP32/bluedroid/BLEManagerImpl.cpp @@ -140,7 +140,7 @@ CHIP_ERROR BLEManagerImpl::_Init() mRXCharAttrHandle = 0; mTXCharAttrHandle = 0; mTXCharCCCDAttrHandle = 0; - mFlags = CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART ? kFlag_AdvertisingEnabled : 0; + mFlags.ClearAll().Set(Flags::kAdvertisingEnabled, CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART); memset(mDeviceName, 0, sizeof(mDeviceName)); PlatformMgr().ScheduleWork(DriveBLEState, 0); @@ -172,9 +172,9 @@ CHIP_ERROR BLEManagerImpl::_SetAdvertisingEnabled(bool val) VerifyOrExit(mServiceMode != ConnectivityManager::kCHIPoBLEServiceMode_NotSupported, err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); - if (GetFlag(mFlags, kFlag_AdvertisingEnabled) != val) + if (mFlags.Has(Flags::kAdvertisingEnabled) != val) { - SetFlag(mFlags, kFlag_AdvertisingEnabled, val); + mFlags.Set(Flags::kAdvertisingEnabled, val); PlatformMgr().ScheduleWork(DriveBLEState, 0); } @@ -188,9 +188,9 @@ CHIP_ERROR BLEManagerImpl::_SetFastAdvertisingEnabled(bool val) VerifyOrExit(mServiceMode != ConnectivityManager::kCHIPoBLEServiceMode_NotSupported, err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); - if (GetFlag(mFlags, kFlag_FastAdvertisingEnabled) != val) + if (mFlags.Has(Flags::kFastAdvertisingEnabled) != val) { - SetFlag(mFlags, kFlag_FastAdvertisingEnabled, val); + mFlags.Set(Flags::kFastAdvertisingEnabled, val); PlatformMgr().ScheduleWork(DriveBLEState, 0); } @@ -221,12 +221,12 @@ CHIP_ERROR BLEManagerImpl::_SetDeviceName(const char * deviceName) return CHIP_ERROR_INVALID_ARGUMENT; } strcpy(mDeviceName, deviceName); - SetFlag(mFlags, kFlag_UseCustomDeviceName); + mFlags.Set(Flags::kUseCustomDeviceName); } else { mDeviceName[0] = 0; - ClearFlag(mFlags, kFlag_UseCustomDeviceName); + mFlags.Clear(Flags::kUseCustomDeviceName); } return CHIP_NO_ERROR; } @@ -271,15 +271,15 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) #if CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED if (ConfigurationMgr().IsFullyProvisioned()) { - ClearFlag(mFlags, kFlag_AdvertisingEnabled); + mFlags.Clear(Flags::kAdvertisingEnabled); ChipLogProgress(DeviceLayer, "CHIPoBLE advertising disabled because device is fully provisioned"); } #endif // CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED // Force the advertising configuration to be refreshed to reflect new provisioning state. ChipLogProgress(DeviceLayer, "Updating advertising data"); - ClearFlag(mFlags, kFlag_AdvertisingConfigured); - SetFlag(mFlags, kFlag_AdvertisingRefreshNeeded); + mFlags.Clear(Flags::kAdvertisingConfigured); + mFlags.Set(Flags::kAdvertisingRefreshNeeded); DriveBLEState(); @@ -317,8 +317,8 @@ bool BLEManagerImpl::CloseConnection(BLE_CONNECTION_OBJECT conId) ReleaseConnectionState(conId); // Force a refresh of the advertising state. - SetFlag(mFlags, kFlag_AdvertisingRefreshNeeded); - ClearFlag(mFlags, kFlag_AdvertisingConfigured); + mFlags.Set(Flags::kAdvertisingRefreshNeeded); + mFlags.Clear(Flags::kAdvertisingConfigured); PlatformMgr().ScheduleWork(DriveBLEState, 0); return (err == CHIP_NO_ERROR); @@ -390,33 +390,33 @@ void BLEManagerImpl::DriveBLEState(void) CHIP_ERROR err = CHIP_NO_ERROR; // Perform any initialization actions that must occur after the Chip task is running. - if (!GetFlag(mFlags, kFlag_AsyncInitCompleted)) + if (!mFlags.Has(Flags::kAsyncInitCompleted)) { - SetFlag(mFlags, kFlag_AsyncInitCompleted); + mFlags.Set(Flags::kAsyncInitCompleted); // If CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED is enabled, // disable CHIPoBLE advertising if the device is fully provisioned. #if CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED if (ConfigurationMgr().IsFullyProvisioned()) { - ClearFlag(mFlags, kFlag_AdvertisingEnabled); + mFlags.Clear(Flags::kAdvertisingEnabled); ChipLogProgress(DeviceLayer, "CHIPoBLE advertising disabled because device is fully provisioned"); } #endif // CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED } // If there's already a control operation in progress, wait until it completes. - VerifyOrExit(!GetFlag(mFlags, kFlag_ControlOpInProgress), /* */); + VerifyOrExit(!mFlags.Has(Flags::kControlOpInProgress), /* */); // Initializes the ESP BLE layer if needed. - if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && !GetFlag(mFlags, kFlag_ESPBLELayerInitialized)) + if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && !mFlags.Has(Flags::kESPBLELayerInitialized)) { err = InitESPBleLayer(); SuccessOrExit(err); } // Register the CHIPoBLE application with the ESP BLE layer if needed. - if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && !GetFlag(mFlags, kFlag_AppRegistered)) + if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && !mFlags.Has(Flags::kAppRegistered)) { err = esp_ble_gatts_app_register(CHIPoBLEAppId); if (err != CHIP_NO_ERROR) @@ -425,13 +425,13 @@ void BLEManagerImpl::DriveBLEState(void) ExitNow(); } - SetFlag(mFlags, kFlag_ControlOpInProgress); + mFlags.Set(Flags::kControlOpInProgress); ExitNow(); } // Register the CHIPoBLE GATT attributes with the ESP BLE layer if needed. - if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && !GetFlag(mFlags, kFlag_AttrsRegistered)) + if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && !mFlags.Has(Flags::kAttrsRegistered)) { err = esp_ble_gatts_create_attr_tab(CHIPoBLEGATTAttrs, mAppIf, CHIPoBLEGATTAttrCount, 0); if (err != CHIP_NO_ERROR) @@ -440,13 +440,13 @@ void BLEManagerImpl::DriveBLEState(void) ExitNow(); } - SetFlag(mFlags, kFlag_ControlOpInProgress); + mFlags.Set(Flags::kControlOpInProgress); ExitNow(); } // Start the CHIPoBLE GATT service if needed. - if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && !GetFlag(mFlags, kFlag_GATTServiceStarted)) + if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && !mFlags.Has(Flags::kGATTServiceStarted)) { err = esp_ble_gatts_start_service(mServiceAttrHandle); if (err != CHIP_NO_ERROR) @@ -455,14 +455,14 @@ void BLEManagerImpl::DriveBLEState(void) ExitNow(); } - SetFlag(mFlags, kFlag_ControlOpInProgress); + mFlags.Set(Flags::kControlOpInProgress); ExitNow(); } // If the application has enabled CHIPoBLE and BLE advertising... if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && - GetFlag(mFlags, kFlag_AdvertisingEnabled) + mFlags.Has(Flags::kAdvertisingEnabled) #if CHIP_DEVICE_CONFIG_CHIPOBLE_SINGLE_CONNECTION // and no connections are active... && (_NumConnections() == 0) @@ -471,12 +471,12 @@ void BLEManagerImpl::DriveBLEState(void) { // Start/re-start advertising if not already advertising, or if the advertising state of the // ESP BLE layer needs to be refreshed. - if (!GetFlag(mFlags, kFlag_Advertising) || GetFlag(mFlags, kFlag_AdvertisingRefreshNeeded)) + if (!mFlags.Has(Flags::kAdvertising) || mFlags.Has(Flags::kAdvertisingRefreshNeeded)) { // Configure advertising data if it hasn't been done yet. This is an asynchronous step which // must complete before advertising can be started. When that happens, this method will // be called again, and execution will proceed to the code below. - if (!GetFlag(mFlags, kFlag_AdvertisingConfigured)) + if (!mFlags.Has(Flags::kAdvertisingConfigured)) { err = ConfigureAdvertisingData(); ExitNow(); @@ -491,7 +491,7 @@ void BLEManagerImpl::DriveBLEState(void) // Otherwise stop advertising if needed... else { - if (GetFlag(mFlags, kFlag_Advertising)) + if (mFlags.Has(Flags::kAdvertising)) { err = esp_ble_gap_stop_advertising(); if (err != CHIP_NO_ERROR) @@ -500,14 +500,14 @@ void BLEManagerImpl::DriveBLEState(void) ExitNow(); } - SetFlag(mFlags, kFlag_ControlOpInProgress); + mFlags.Set(Flags::kControlOpInProgress); ExitNow(); } } // Stop the CHIPoBLE GATT service if needed. - if (mServiceMode != ConnectivityManager::kCHIPoBLEServiceMode_Enabled && GetFlag(mFlags, kFlag_GATTServiceStarted)) + if (mServiceMode != ConnectivityManager::kCHIPoBLEServiceMode_Enabled && mFlags.Has(Flags::kGATTServiceStarted)) { // TODO: what to do about existing connections?? @@ -518,7 +518,7 @@ void BLEManagerImpl::DriveBLEState(void) ExitNow(); } - SetFlag(mFlags, kFlag_ControlOpInProgress); + mFlags.Set(Flags::kControlOpInProgress); ExitNow(); } @@ -535,7 +535,7 @@ CHIP_ERROR BLEManagerImpl::InitESPBleLayer(void) { CHIP_ERROR err = CHIP_NO_ERROR; - VerifyOrExit(!GetFlag(mFlags, kFlag_ESPBLELayerInitialized), /* */); + VerifyOrExit(!mFlags.Has(Flags::kESPBLELayerInitialized), /* */); // If the ESP Bluetooth controller has not been initialized... if (esp_bt_controller_get_status() == ESP_BT_CONTROLLER_STATUS_IDLE) @@ -615,7 +615,7 @@ CHIP_ERROR BLEManagerImpl::InitESPBleLayer(void) } SuccessOrExit(err); - SetFlag(mFlags, kFlag_ESPBLELayerInitialized); + mFlags.Set(Flags::kESPBLELayerInitialized); exit: return err; @@ -632,7 +632,7 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void) uint16_t discriminator; SuccessOrExit(err = ConfigurationMgr().GetSetupDiscriminator(discriminator)); - if (!GetFlag(mFlags, kFlag_UseCustomDeviceName)) + if (!mFlags.Has(Flags::kUseCustomDeviceName)) { snprintf(mDeviceName, sizeof(mDeviceName), "%s%04u", CHIP_DEVICE_CONFIG_BLE_DEVICE_NAME_PREFIX, discriminator); mDeviceName[kMaxDeviceNameLength] = 0; @@ -675,7 +675,7 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void) ExitNow(); } - SetFlag(mFlags, kFlag_ControlOpInProgress); + mFlags.Set(Flags::kControlOpInProgress); exit: return err; @@ -708,7 +708,7 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) // Advertise in fast mode if not fully provisioned and there are no CHIPoBLE connections, or // if the application has expressly requested fast advertising. advertParams.adv_int_min = advertParams.adv_int_max = - ((numCons == 0 && !ConfigurationMgr().IsFullyProvisioned()) || GetFlag(mFlags, kFlag_FastAdvertisingEnabled)) + ((numCons == 0 && !ConfigurationMgr().IsFullyProvisioned()) || mFlags.Has(Flags::kFastAdvertisingEnabled)) ? CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL : CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL; @@ -722,7 +722,7 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) ExitNow(); } - SetFlag(mFlags, kFlag_ControlOpInProgress); + mFlags.Set(Flags::kControlOpInProgress); exit: return err; @@ -734,7 +734,7 @@ void BLEManagerImpl::HandleGATTControlEvent(esp_gatts_cb_event_t event, esp_gatt bool controlOpComplete = false; // Ignore GATT control events that do not pertain to the CHIPoBLE application, except for ESP_GATTS_REG_EVT. - if (event != ESP_GATTS_REG_EVT && (!GetFlag(mFlags, kFlag_AppRegistered) || gatts_if != mAppIf)) + if (event != ESP_GATTS_REG_EVT && (!mFlags.Has(Flags::kAppRegistered) || gatts_if != mAppIf)) { ExitNow(); } @@ -754,7 +754,7 @@ void BLEManagerImpl::HandleGATTControlEvent(esp_gatts_cb_event_t event, esp_gatt // Save the 'interface type' assigned to the CHIPoBLE application by the ESP BLE layer. mAppIf = gatts_if; - SetFlag(mFlags, kFlag_AppRegistered); + mFlags.Set(Flags::kAppRegistered); controlOpComplete = true; } @@ -774,7 +774,7 @@ void BLEManagerImpl::HandleGATTControlEvent(esp_gatts_cb_event_t event, esp_gatt mTXCharAttrHandle = param->add_attr_tab.handles[kAttrIndex_TXCharValue]; mTXCharCCCDAttrHandle = param->add_attr_tab.handles[kAttrIndex_TXCharCCCDValue]; - SetFlag(mFlags, kFlag_AttrsRegistered); + mFlags.Set(Flags::kAttrsRegistered); controlOpComplete = true; break; @@ -789,7 +789,7 @@ void BLEManagerImpl::HandleGATTControlEvent(esp_gatts_cb_event_t event, esp_gatt ChipLogProgress(DeviceLayer, "CHIPoBLE GATT service started"); - SetFlag(mFlags, kFlag_GATTServiceStarted); + mFlags.Set(Flags::kGATTServiceStarted); controlOpComplete = true; break; @@ -804,7 +804,7 @@ void BLEManagerImpl::HandleGATTControlEvent(esp_gatts_cb_event_t event, esp_gatt ChipLogProgress(DeviceLayer, "CHIPoBLE GATT service stopped"); - ClearFlag(mFlags, kFlag_GATTServiceStarted); + mFlags.Clear(Flags::kGATTServiceStarted); controlOpComplete = true; break; @@ -826,7 +826,7 @@ void BLEManagerImpl::HandleGATTControlEvent(esp_gatts_cb_event_t event, esp_gatt } if (controlOpComplete) { - ClearFlag(mFlags, kFlag_ControlOpInProgress); + mFlags.Clear(Flags::kControlOpInProgress); PlatformMgr().ScheduleWork(DriveBLEState, 0); } } @@ -835,7 +835,7 @@ void BLEManagerImpl::HandleGATTCommEvent(esp_gatts_cb_event_t event, esp_gatt_if { // Ignore the event if the CHIPoBLE service hasn't been started, or if the event is for a different // BLE application. - if (!GetFlag(sInstance.mFlags, kFlag_GATTServiceStarted) || gatts_if != sInstance.mAppIf) + if (!sInstance.mFlags.Has(Flags::kGATTServiceStarted) || gatts_if != sInstance.mAppIf) { return; } @@ -850,8 +850,8 @@ void BLEManagerImpl::HandleGATTCommEvent(esp_gatts_cb_event_t event, esp_gatt_if // Receiving a connection stops the advertising processes. So force a refresh of the advertising // state. - SetFlag(mFlags, kFlag_AdvertisingRefreshNeeded); - ClearFlag(mFlags, kFlag_AdvertisingConfigured); + mFlags.Set(Flags::kAdvertisingRefreshNeeded); + mFlags.Clear(Flags::kAdvertisingConfigured); PlatformMgr().ScheduleWork(DriveBLEState, 0); break; @@ -1110,8 +1110,8 @@ void BLEManagerImpl::HandleDisconnect(esp_ble_gatts_cb_param_t * param) PlatformMgr().PostEvent(&event); // Force a refresh of the advertising state. - SetFlag(mFlags, kFlag_AdvertisingRefreshNeeded); - ClearFlag(mFlags, kFlag_AdvertisingConfigured); + mFlags.Set(Flags::kAdvertisingRefreshNeeded); + mFlags.Clear(Flags::kAdvertisingConfigured); PlatformMgr().ScheduleWork(DriveBLEState, 0); } } @@ -1212,8 +1212,8 @@ void BLEManagerImpl::HandleGAPEvent(esp_gap_ble_cb_event_t event, esp_ble_gap_cb ExitNow(err = ESP_ERR_INVALID_RESPONSE); } - SetFlag(sInstance.mFlags, kFlag_AdvertisingConfigured); - ClearFlag(sInstance.mFlags, kFlag_ControlOpInProgress); + sInstance.mFlags.Set(Flags::kAdvertisingConfigured); + sInstance.mFlags.Clear(Flags::kControlOpInProgress); break; @@ -1225,15 +1225,15 @@ void BLEManagerImpl::HandleGAPEvent(esp_gap_ble_cb_event_t event, esp_ble_gap_cb ExitNow(err = ESP_ERR_INVALID_RESPONSE); } - ClearFlag(sInstance.mFlags, kFlag_ControlOpInProgress); - ClearFlag(sInstance.mFlags, kFlag_AdvertisingRefreshNeeded); + sInstance.mFlags.Clear(Flags::kControlOpInProgress); + sInstance.mFlags.Clear(Flags::kAdvertisingRefreshNeeded); // Transition to the Advertising state... - if (!GetFlag(sInstance.mFlags, kFlag_Advertising)) + if (!sInstance.mFlags.Has(Flags::kAdvertising)) { ChipLogProgress(DeviceLayer, "CHIPoBLE advertising started"); - SetFlag(sInstance.mFlags, kFlag_Advertising); + sInstance.mFlags.Set(Flags::kAdvertising); // Post a CHIPoBLEAdvertisingChange(Started) event. { @@ -1254,13 +1254,13 @@ void BLEManagerImpl::HandleGAPEvent(esp_gap_ble_cb_event_t event, esp_ble_gap_cb ExitNow(err = ESP_ERR_INVALID_RESPONSE); } - ClearFlag(sInstance.mFlags, kFlag_ControlOpInProgress); - ClearFlag(sInstance.mFlags, kFlag_AdvertisingRefreshNeeded); + sInstance.mFlags.Clear(Flags::kControlOpInProgress); + sInstance.mFlags.Clear(Flags::kAdvertisingRefreshNeeded); // Transition to the not Advertising state... - if (GetFlag(sInstance.mFlags, kFlag_Advertising)) + if (sInstance.mFlags.Has(Flags::kAdvertising)) { - ClearFlag(sInstance.mFlags, kFlag_Advertising); + sInstance.mFlags.Clear(Flags::kAdvertising); ChipLogProgress(DeviceLayer, "CHIPoBLE advertising stopped"); diff --git a/src/platform/ESP32/nimble/BLEManagerImpl.cpp b/src/platform/ESP32/nimble/BLEManagerImpl.cpp index 1a6dddf8b63267..1960d9dab2e2fd 100644 --- a/src/platform/ESP32/nimble/BLEManagerImpl.cpp +++ b/src/platform/ESP32/nimble/BLEManagerImpl.cpp @@ -129,8 +129,8 @@ CHIP_ERROR BLEManagerImpl::_Init() mRXCharAttrHandle = 0; mTXCharCCCDAttrHandle = 0; - mFlags = CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART ? kFlag_AdvertisingEnabled : 0; - mNumGAPCons = 0; + mFlags.ClearAll().Set(Flags::kAdvertisingEnabled, CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART); + mNumGAPCons = 0; memset(mCons, 0, sizeof(mCons)); mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Enabled; memset(mDeviceName, 0, sizeof(mDeviceName)); @@ -164,9 +164,9 @@ CHIP_ERROR BLEManagerImpl::_SetAdvertisingEnabled(bool val) VerifyOrExit(mServiceMode != ConnectivityManager::kCHIPoBLEServiceMode_NotSupported, err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); - if (GetFlag(mFlags, kFlag_AdvertisingEnabled) != val) + if (mFlags.Has(Flags::kAdvertisingEnabled) != val) { - SetFlag(mFlags, kFlag_AdvertisingEnabled, val); + mFlags.Set(Flags::kAdvertisingEnabled, val); PlatformMgr().ScheduleWork(DriveBLEState, 0); } @@ -180,9 +180,9 @@ CHIP_ERROR BLEManagerImpl::_SetFastAdvertisingEnabled(bool val) VerifyOrExit(mServiceMode != ConnectivityManager::kCHIPoBLEServiceMode_NotSupported, err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); - if (GetFlag(mFlags, kFlag_FastAdvertisingEnabled) != val) + if (mFlags.Has(Flags::kFastAdvertisingEnabled) != val) { - SetFlag(mFlags, kFlag_FastAdvertisingEnabled, val); + mFlags.Set(Flags::kFastAdvertisingEnabled, val); PlatformMgr().ScheduleWork(DriveBLEState, 0); } @@ -212,12 +212,12 @@ CHIP_ERROR BLEManagerImpl::_SetDeviceName(const char * deviceName) return CHIP_ERROR_INVALID_ARGUMENT; } strcpy(mDeviceName, deviceName); - SetFlag(mFlags, kFlag_UseCustomDeviceName); + mFlags.Set(Flags::kUseCustomDeviceName); } else { mDeviceName[0] = 0; - ClearFlag(mFlags, kFlag_UseCustomDeviceName); + mFlags.Clear(Flags::kUseCustomDeviceName); } exit: @@ -265,15 +265,15 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) #if CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED if (ConfigurationMgr().IsFullyProvisioned()) { - ClearFlag(mFlags, kFlag_AdvertisingEnabled); + mFlags.Clear(Flags::kAdvertisingEnabled); ChipLogProgress(DeviceLayer, "CHIPoBLE advertising disabled because device is fully provisioned"); } #endif // CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED // Force the advertising configuration to be refreshed to reflect new provisioning state. ChipLogProgress(DeviceLayer, "Updating advertising data"); - ClearFlag(mFlags, kFlag_AdvertisingConfigured); - SetFlag(mFlags, kFlag_AdvertisingRefreshNeeded); + mFlags.Clear(Flags::kAdvertisingConfigured); + mFlags.Set(Flags::kAdvertisingRefreshNeeded); DriveBLEState(); break; @@ -309,8 +309,8 @@ bool BLEManagerImpl::CloseConnection(BLE_CONNECTION_OBJECT conId) } // Force a refresh of the advertising state. - SetFlag(mFlags, kFlag_AdvertisingRefreshNeeded); - ClearFlag(mFlags, kFlag_AdvertisingConfigured); + mFlags.Set(Flags::kAdvertisingRefreshNeeded); + mFlags.Clear(Flags::kAdvertisingConfigured); PlatformMgr().ScheduleWork(DriveBLEState, 0); return (err == CHIP_NO_ERROR); @@ -384,23 +384,23 @@ void BLEManagerImpl::DriveBLEState(void) CHIP_ERROR err = CHIP_NO_ERROR; // Perform any initialization actions that must occur after the Chip task is running. - if (!GetFlag(mFlags, kFlag_AsyncInitCompleted)) + if (!mFlags.Has(Flags::kAsyncInitCompleted)) { - SetFlag(mFlags, kFlag_AsyncInitCompleted); + mFlags.Set(Flags::kAsyncInitCompleted); // If CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED is enabled, // disable CHIPoBLE advertising if the device is fully provisioned. #if CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED if (ConfigurationMgr().IsFullyProvisioned()) { - ClearFlag(mFlags, kFlag_AdvertisingEnabled); + mFlags.Clear(Flags::kAdvertisingEnabled); ChipLogProgress(DeviceLayer, "CHIPoBLE advertising disabled because device is fully provisioned"); } #endif // CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED } // Initializes the ESP BLE layer if needed. - if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && !GetFlag(mFlags, kFlag_ESPBLELayerInitialized)) + if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && !mFlags.Has(Flags::kESPBLELayerInitialized)) { err = InitESPBleLayer(); SuccessOrExit(err); @@ -413,7 +413,7 @@ void BLEManagerImpl::DriveBLEState(void) // If the application has enabled CHIPoBLE and BLE advertising... if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && - GetFlag(mFlags, kFlag_AdvertisingEnabled) + mFlags.Has(Flags::kAdvertisingEnabled) #if CHIP_DEVICE_CONFIG_CHIPOBLE_SINGLE_CONNECTION // and no connections are active... && (_NumConnections() == 0) @@ -422,12 +422,12 @@ void BLEManagerImpl::DriveBLEState(void) { // Start/re-start advertising if not already advertising, or if the advertising state of the // ESP BLE layer needs to be refreshed. - if (!GetFlag(mFlags, kFlag_Advertising) || GetFlag(mFlags, kFlag_AdvertisingRefreshNeeded)) + if (!mFlags.Has(Flags::kAdvertising) || mFlags.Has(Flags::kAdvertisingRefreshNeeded)) { // Configure advertising data if it hasn't been done yet. This is an asynchronous step which // must complete before advertising can be started. When that happens, this method will // be called again, and execution will proceed to the code below. - if (!GetFlag(mFlags, kFlag_AdvertisingConfigured)) + if (!mFlags.Has(Flags::kAdvertisingConfigured)) { err = ConfigureAdvertisingData(); if (err != CHIP_NO_ERROR) @@ -446,13 +446,13 @@ void BLEManagerImpl::DriveBLEState(void) ExitNow(); } - ClearFlag(mFlags, kFlag_AdvertisingRefreshNeeded); + mFlags.Clear(Flags::kAdvertisingRefreshNeeded); // Transition to the Advertising state... - if (!GetFlag(mFlags, kFlag_Advertising)) + if (!mFlags.Has(Flags::kAdvertising)) { ChipLogProgress(DeviceLayer, "CHIPoBLE advertising started"); - SetFlag(mFlags, kFlag_Advertising); + mFlags.Set(Flags::kAdvertising); // Post a CHIPoBLEAdvertisingChange(Started) event. { @@ -468,7 +468,7 @@ void BLEManagerImpl::DriveBLEState(void) // Otherwise stop advertising if needed... else { - if (GetFlag(mFlags, kFlag_Advertising)) + if (mFlags.Has(Flags::kAdvertising)) { ret = ble_gap_adv_stop(); if (ret != 0) @@ -478,12 +478,12 @@ void BLEManagerImpl::DriveBLEState(void) ExitNow(); } - // ClearFlag(mFlags, kFlag_AdvertisingRefreshNeeded); + // mFlags.Clear(Flags::kAdvertisingRefreshNeeded); // Transition to the not Advertising state... - if (GetFlag(mFlags, kFlag_Advertising)) + if (mFlags.Has(Flags::kAdvertising)) { - ClearFlag(mFlags, kFlag_Advertising); + mFlags.Clear(Flags::kAdvertising); ChipLogProgress(DeviceLayer, "CHIPoBLE advertising stopped"); @@ -506,7 +506,7 @@ void BLEManagerImpl::DriveBLEState(void) } // Stop the CHIPoBLE GATT service if needed. - if (mServiceMode != ConnectivityManager::kCHIPoBLEServiceMode_Enabled && GetFlag(mFlags, kFlag_GATTServiceStarted)) + if (mServiceMode != ConnectivityManager::kCHIPoBLEServiceMode_Enabled && mFlags.Has(Flags::kGATTServiceStarted)) { // TODO: Not supported } @@ -528,8 +528,8 @@ void BLEManagerImpl::bleprph_on_sync(void) { int rc; - SetFlag(sInstance.mFlags, kFlag_ESPBLELayerInitialized); - SetFlag(sInstance.mFlags, kFlag_GATTServiceStarted); + sInstance.mFlags.Set(Flags::kESPBLELayerInitialized); + sInstance.mFlags.Set(Flags::kGATTServiceStarted); ESP_LOGI(TAG, "BLE host-controller synced"); uint8_t own_addr_type = BLE_OWN_ADDR_PUBLIC; @@ -554,7 +554,7 @@ CHIP_ERROR BLEManagerImpl::InitESPBleLayer(void) { CHIP_ERROR err = CHIP_NO_ERROR; - VerifyOrExit(!GetFlag(mFlags, kFlag_ESPBLELayerInitialized), /* */); + VerifyOrExit(!mFlags.Has(Flags::kESPBLELayerInitialized), /* */); for (int i = 0; i < kMaxConnections; i++) { @@ -609,7 +609,7 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void) uint16_t discriminator; SuccessOrExit(err = ConfigurationMgr().GetSetupDiscriminator(discriminator)); - if (!GetFlag(mFlags, kFlag_UseCustomDeviceName)) + if (!mFlags.Has(Flags::kUseCustomDeviceName)) { snprintf(mDeviceName, sizeof(mDeviceName), "%s%04u", CHIP_DEVICE_CONFIG_BLE_DEVICE_NAME_PREFIX, discriminator); mDeviceName[kMaxDeviceNameLength] = 0; @@ -809,8 +809,8 @@ CHIP_ERROR BLEManagerImpl::HandleGAPConnect(struct ble_gap_event * gapEvent) VerifyOrExit(err != CHIP_ERROR_NO_MEMORY, err = CHIP_NO_ERROR); SuccessOrExit(err); - SetFlag(mFlags, kFlag_AdvertisingRefreshNeeded); - ClearFlag(mFlags, kFlag_AdvertisingConfigured); + mFlags.Set(Flags::kAdvertisingRefreshNeeded); + mFlags.Clear(Flags::kAdvertisingConfigured); exit: return err; @@ -847,8 +847,8 @@ CHIP_ERROR BLEManagerImpl::HandleGAPDisconnect(struct ble_gap_event * gapEvent) // Force a reconfiguration of advertising in case we switched to non-connectable mode when // the BLE connection was established. - SetFlag(mFlags, kFlag_AdvertisingRefreshNeeded); - ClearFlag(mFlags, kFlag_AdvertisingConfigured); + mFlags.Set(Flags::kAdvertisingRefreshNeeded); + mFlags.Clear(Flags::kAdvertisingConfigured); return CHIP_NO_ERROR; } @@ -1025,7 +1025,7 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) } #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD - ClearFlag(mFlags, kFlag_AdvertisingRefreshNeeded); + mFlags.Clear(Flags::kAdvertisingRefreshNeeded); // Advertise connectable if we haven't reached the maximum number of connections. size_t numCons = _NumConnections(); diff --git a/src/platform/K32W/BLEManagerImpl.cpp b/src/platform/K32W/BLEManagerImpl.cpp index 4baa04054302cd..09c216c6e5a8e3 100644 --- a/src/platform/K32W/BLEManagerImpl.cpp +++ b/src/platform/K32W/BLEManagerImpl.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * Copyright (c) 2020 Nest Labs, Inc. * All rights reserved. * @@ -119,7 +119,6 @@ EventGroupHandle_t bleAppTaskLoopEvent; /* keep the device ID of the connected peer */ uint8_t device_id; -uint16_t mFlags; const uint8_t ShortUUID_CHIPoBLEService[] = { 0xAF, 0xFE }; const ChipBleUUID ChipUUID_CHIPoBLEChar_RX = { { 0x18, 0xEE, 0x2E, 0xF5, 0x26, 0x3D, 0x45, 0x59, 0x95, 0x9F, 0x4F, 0x9C, 0x42, 0x9F, @@ -140,7 +139,7 @@ CHIP_ERROR BLEManagerImpl::_Init() mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Enabled; // Check if BLE stack is initialized - VerifyOrExit(!GetFlag(mFlags, kFlag_K32WBLEStackInitialized), err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(!mFlags.Has(Flags::kK32WBLEStackInitialized), err = CHIP_ERROR_INCORRECT_STATE); // Initialize the Chip BleLayer. err = BleLayer::Init(this, this, &SystemLayer); @@ -194,8 +193,8 @@ CHIP_ERROR BLEManagerImpl::_Init() GattServer_RegisterHandlesForWriteNotifications(1, attChipRxHandle); - SetFlag(mFlags, kFlag_K32WBLEStackInitialized, true); - SetFlag(mFlags, kFlag_AdvertisingEnabled, CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART ? true : false); + mFlags.Set(Flags::kK32WBLEStackInitialized); + mFlags.Set(Flags::kAdvertisingEnabled, CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART ? true : false); PlatformMgr().ScheduleWork(DriveBLEState, 0); exit: @@ -218,12 +217,12 @@ uint16_t BLEManagerImpl::_NumConnections(void) bool BLEManagerImpl::_IsAdvertisingEnabled(void) { - return GetFlag(mFlags, kFlag_AdvertisingEnabled); + return mFlags.Has(Flags::kAdvertisingEnabled); } bool BLEManagerImpl::_IsFastAdvertisingEnabled(void) { - return GetFlag(mFlags, kFlag_FastAdvertisingEnabled); + return mFlags.Has(Flags::kFastAdvertisingEnabled); } bool BLEManagerImpl::RemoveConnection(uint8_t connectionHandle) @@ -308,9 +307,9 @@ CHIP_ERROR BLEManagerImpl::_SetAdvertisingEnabled(bool val) VerifyOrExit(mServiceMode != ConnectivityManager::kCHIPoBLEServiceMode_NotSupported, err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); - if (GetFlag(mFlags, kFlag_AdvertisingEnabled) != val) + if (mFlags.Has(Flags::kAdvertisingEnabled) != val) { - SetFlag(mFlags, kFlag_AdvertisingEnabled, val); + mFlags.Set(Flags::kAdvertisingEnabled, val); PlatformMgr().ScheduleWork(DriveBLEState, 0); } @@ -324,9 +323,9 @@ CHIP_ERROR BLEManagerImpl::_SetFastAdvertisingEnabled(bool val) VerifyOrExit(mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_NotSupported, err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); - if (GetFlag(mFlags, kFlag_FastAdvertisingEnabled) != val) + if (mFlags.Has(Flags::kFastAdvertisingEnabled) != val) { - SetFlag(mFlags, kFlag_FastAdvertisingEnabled, val); + mFlags.Set(Flags::kFastAdvertisingEnabled, val); PlatformMgr().ScheduleWork(DriveBLEState, 0); } @@ -358,13 +357,13 @@ CHIP_ERROR BLEManagerImpl::_SetDeviceName(const char * deviceName) } memset(mDeviceName, 0, kMaxDeviceNameLength); strcpy(mDeviceName, deviceName); - SetFlag(mFlags, kFlag_DeviceNameSet, true); + mFlags.Set(Flags::kDeviceNameSet); ChipLogProgress(DeviceLayer, "Setting device name to : \"%s\"", deviceName); } else { mDeviceName[0] = 0; - SetFlag(mFlags, kFlag_DeviceNameSet, false); + mFlags.Clear(Flags::kDeviceNameSet); } return CHIP_NO_ERROR; @@ -403,7 +402,7 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) case DeviceEventType::kServiceProvisioningChange: ChipLogProgress(DeviceLayer, "_OnPlatformEvent kServiceProvisioningChange"); - ClearFlag(mFlags, kFlag_AdvertisingEnabled); + mFlags.Clear(Flags::kAdvertisingEnabled); PlatformMgr().ScheduleWork(DriveBLEState, 0); break; #endif // CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED @@ -764,7 +763,7 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void) return chipErr; } - if (!GetFlag(mFlags, kFlag_DeviceNameSet)) + if (!mFlags.Has(Flags::kDeviceNameSet)) { memset(mDeviceName, 0, kMaxDeviceNameLength); snprintf(mDeviceName, kMaxDeviceNameLength, "%s%04u", CHIP_DEVICE_CONFIG_BLE_DEVICE_NAME_PREFIX, discriminator); @@ -809,8 +808,7 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void) scanRsp.aAdStructures = scan_rsp_data; /**************** Prepare advertising parameters *************************************/ - advInterval = - ((NumConnections() == 0 && !ConfigurationMgr().IsPairedToAccount()) || GetFlag(mFlags, kFlag_FastAdvertisingEnabled)) + advInterval = ((NumConnections() == 0 && !ConfigurationMgr().IsPairedToAccount()) || mFlags.Has(Flags::kFastAdvertisingEnabled)) ? (CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL * 3) : CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL; @@ -839,8 +837,8 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void) CHIP_ERROR BLEManagerImpl::StartAdvertising(void) { - SetFlag(mFlags, kFlag_Advertising, true); - ClearFlag(mFlags, kFlag_RestartAdvertising); + mFlags.Set(Flags::kAdvertising); + mFlags.Clear(Flags::kRestartAdvertising); return ConfigureAdvertisingData(); } @@ -849,10 +847,10 @@ CHIP_ERROR BLEManagerImpl::StopAdvertising(void) { ble_err_t err; - if (GetFlag(mFlags, kFlag_Advertising)) + if (mFlags.Has(Flags::kAdvertising)) { - ClearFlag(mFlags, kFlag_Advertising); - ClearFlag(mFlags, kFlag_RestartAdvertising); + mFlags.Clear(Flags::kAdvertising); + mFlags.Clear(Flags::kRestartAdvertising); err = blekw_stop_advertising(); if (err != BLE_OK) @@ -869,29 +867,29 @@ void BLEManagerImpl::DriveBLEState(void) CHIP_ERROR err = CHIP_NO_ERROR; // Check if BLE stack is initialized - VerifyOrExit(GetFlag(mFlags, kFlag_K32WBLEStackInitialized), /* */); + VerifyOrExit(mFlags.Has(Flags::kK32WBLEStackInitialized), /* */); #if CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED if (ConfigurationMgr().IsFullyProvisioned()) { - ClearFlag(mFlags, kFlag_AdvertisingEnabled); + mFlags.Clear(Flags::kAdvertisingEnabled); ChipLogProgress(DeviceLayer, "CHIPoBLE advertising disabled because device is fully provisioned"); } #endif // CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED // Start advertising if needed... - if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && GetFlag(mFlags, kFlag_AdvertisingEnabled)) + if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && mFlags.Has(Flags::kAdvertisingEnabled)) { // Start/re-start advertising if not already started, or if there is a pending change // to the advertising configuration. - if (!GetFlag(mFlags, kFlag_Advertising) || GetFlag(mFlags, kFlag_RestartAdvertising)) + if (!mFlags.Has(Flags::kAdvertising) || mFlags.Has(Flags::kRestartAdvertising)) { err = StartAdvertising(); SuccessOrExit(err); } } // Otherwise, stop advertising if it is enabled. - else if (GetFlag(mFlags, kFlag_Advertising)) + else if (mFlags.Has(Flags::kAdvertising)) { err = StopAdvertising(); SuccessOrExit(err); @@ -977,7 +975,7 @@ void BLEManagerImpl::HandleConnectEvent(blekw_msg_t * msg) device_id = device_id_loc; blekw_start_connection_timeout(); sInstance.AddConnection(device_id_loc); - SetFlag(mFlags, kFlag_RestartAdvertising, true); + mFlags.Set(Flags::kRestartAdvertising); PlatformMgr().ScheduleWork(DriveBLEState, 0); } @@ -994,7 +992,7 @@ void BLEManagerImpl::HandleConnectionCloseEvent(blekw_msg_t * msg) event.CHIPoBLEConnectionError.Reason = BLE_ERROR_REMOTE_DEVICE_DISCONNECTED; PlatformMgr().PostEvent(&event); - SetFlag(mFlags, kFlag_RestartAdvertising, true); + mFlags.Set(Flags::kRestartAdvertising); PlatformMgr().ScheduleWork(DriveBLEState, 0); } } diff --git a/src/platform/K32W/BLEManagerImpl.h b/src/platform/K32W/BLEManagerImpl.h index 22e632a1567a1f..c31b9fb200c3ba 100644 --- a/src/platform/K32W/BLEManagerImpl.h +++ b/src/platform/K32W/BLEManagerImpl.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * Copyright (c) 2020 Nest Labs, Inc. * All rights reserved. * @@ -107,15 +107,16 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla // ===== Private members reserved for use by this class only. - enum + enum class Flags : uint8_t { - kFlag_AdvertisingEnabled = 0x0001, - kFlag_FastAdvertisingEnabled = 0x0002, - kFlag_Advertising = 0x0004, - kFlag_RestartAdvertising = 0x0008, - kFlag_K32WBLEStackInitialized = 0x0010, - kFlag_DeviceNameSet = 0x0020, + kAdvertisingEnabled = 0x0001, + kFastAdvertisingEnabled = 0x0002, + kAdvertising = 0x0004, + kRestartAdvertising = 0x0008, + kK32WBLEStackInitialized = 0x0010, + kDeviceNameSet = 0x0020, }; + BitFlags mFlags; enum { diff --git a/src/platform/Linux/BLEManagerImpl.cpp b/src/platform/Linux/BLEManagerImpl.cpp index 803d31efa70b85..e1a60696143a50 100644 --- a/src/platform/Linux/BLEManagerImpl.cpp +++ b/src/platform/Linux/BLEManagerImpl.cpp @@ -69,8 +69,8 @@ CHIP_ERROR BLEManagerImpl::_Init() SuccessOrExit(err); mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Enabled; - mFlags = (CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART && !mIsCentral) ? kFlag_AdvertisingEnabled : 0; - mAppState = nullptr; + mFlags.ClearAll().Set(Flags::kAdvertisingEnabled, CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART && !mIsCentral); + mAppState = nullptr; memset(mDeviceName, 0, sizeof(mDeviceName)); @@ -103,9 +103,9 @@ CHIP_ERROR BLEManagerImpl::_SetAdvertisingEnabled(bool val) { CHIP_ERROR err = CHIP_NO_ERROR; - if (GetFlag(mFlags, kFlag_AdvertisingEnabled) != val) + if (mFlags.Has(Flags::kAdvertisingEnabled) != val) { - SetFlag(mFlags, kFlag_AdvertisingEnabled, val); + mFlags.Set(Flags::kAdvertisingEnabled, val); } PlatformMgr().ScheduleWork(DriveBLEState, 0); @@ -119,9 +119,9 @@ CHIP_ERROR BLEManagerImpl::_SetFastAdvertisingEnabled(bool val) VerifyOrExit(mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_NotSupported, err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); - if (GetFlag(mFlags, kFlag_FastAdvertisingEnabled) != val) + if (mFlags.Has(Flags::kFastAdvertisingEnabled) != val) { - SetFlag(mFlags, kFlag_FastAdvertisingEnabled, val); + mFlags.Set(Flags::kFastAdvertisingEnabled, val); PlatformMgr().ScheduleWork(DriveBLEState, 0); } @@ -150,7 +150,7 @@ CHIP_ERROR BLEManagerImpl::_SetDeviceName(const char * deviceName) { VerifyOrExit(strlen(deviceName) < kMaxDeviceNameLength, err = CHIP_ERROR_INVALID_ARGUMENT); strcpy(mDeviceName, deviceName); - SetFlag(mFlags, kFlag_UseCustomDeviceName); + mFlags.Set(Flags::kUseCustomDeviceName); } else { @@ -158,7 +158,7 @@ CHIP_ERROR BLEManagerImpl::_SetDeviceName(const char * deviceName) SuccessOrExit(err = ConfigurationMgr().GetSetupDiscriminator(discriminator)); snprintf(mDeviceName, sizeof(mDeviceName), "%s%04u", CHIP_DEVICE_CONFIG_BLE_DEVICE_NAME_PREFIX, discriminator); mDeviceName[kMaxDeviceNameLength] = 0; - ClearFlag(mFlags, kFlag_UseCustomDeviceName); + mFlags.Clear(Flags::kUseCustomDeviceName); } exit: @@ -240,13 +240,13 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) #if CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED if (ConfigurationMgr().IsFullyProvisioned()) { - ClearFlag(mFlags, kFlag_AdvertisingEnabled); + mFlags.Clear(Flags::kAdvertisingEnabled); ChipLogProgress(DeviceLayer, "CHIPoBLE advertising disabled because device is fully provisioned"); } #endif // CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED // Force the advertising configuration to be refreshed to reflect new provisioning state. - ClearFlag(mFlags, kFlag_AdvertisingConfigured); + mFlags.Clear(Flags::kAdvertisingConfigured); DriveBLEState(); break; @@ -284,38 +284,35 @@ void BLEManagerImpl::HandlePlatformSpecificBLEEvent(const ChipDeviceEvent * apEv break; case DeviceEventType::kPlatformLinuxBLEPeripheralAdvConfiguredComplete: VerifyOrExit(apEvent->Platform.BLEPeripheralAdvConfiguredComplete.mIsSuccess, err = CHIP_ERROR_INCORRECT_STATE); - SetFlag(sInstance.mFlags, kFlag_AdvertisingConfigured); - ClearFlag(sInstance.mFlags, kFlag_ControlOpInProgress); + sInstance.mFlags.Set(Flags::kAdvertisingConfigured).Clear(Flags::kControlOpInProgress); controlOpComplete = true; ChipLogProgress(DeviceLayer, "CHIPoBLE advertising config complete"); break; case DeviceEventType::kPlatformLinuxBLEPeripheralAdvStartComplete: VerifyOrExit(apEvent->Platform.BLEPeripheralAdvStartComplete.mIsSuccess, err = CHIP_ERROR_INCORRECT_STATE); - ClearFlag(sInstance.mFlags, kFlag_ControlOpInProgress); - ClearFlag(sInstance.mFlags, kFlag_AdvertisingRefreshNeeded); + sInstance.mFlags.Clear(Flags::kControlOpInProgress).Clear(Flags::kAdvertisingRefreshNeeded); - if (!GetFlag(sInstance.mFlags, kFlag_Advertising)) + if (!sInstance.mFlags.Has(Flags::kAdvertising)) { - SetFlag(sInstance.mFlags, kFlag_Advertising); + sInstance.mFlags.Set(Flags::kAdvertising); } break; case DeviceEventType::kPlatformLinuxBLEPeripheralAdvStopComplete: VerifyOrExit(apEvent->Platform.BLEPeripheralAdvStopComplete.mIsSuccess, err = CHIP_ERROR_INCORRECT_STATE); - ClearFlag(sInstance.mFlags, kFlag_ControlOpInProgress); - ClearFlag(sInstance.mFlags, kFlag_AdvertisingRefreshNeeded); + sInstance.mFlags.Clear(Flags::kControlOpInProgress).Clear(Flags::kAdvertisingRefreshNeeded); // Transition to the not Advertising state... - if (GetFlag(sInstance.mFlags, kFlag_Advertising)) + if (sInstance.mFlags.Has(Flags::kAdvertising)) { - ClearFlag(sInstance.mFlags, kFlag_Advertising); + sInstance.mFlags.Clear(Flags::kAdvertising); ChipLogProgress(DeviceLayer, "CHIPoBLE advertising stopped"); } break; case DeviceEventType::kPlatformLinuxBLEPeripheralRegisterAppComplete: VerifyOrExit(apEvent->Platform.BLEPeripheralRegisterAppComplete.mIsSuccess, err = CHIP_ERROR_INCORRECT_STATE); - SetFlag(mFlags, kFlag_AppRegistered); + mFlags.Set(Flags::kAppRegistered); controlOpComplete = true; break; default: @@ -327,12 +324,12 @@ void BLEManagerImpl::HandlePlatformSpecificBLEEvent(const ChipDeviceEvent * apEv { ChipLogError(DeviceLayer, "Disabling CHIPoBLE service due to error: %s", ErrorStr(err)); mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Disabled; - ClearFlag(sInstance.mFlags, kFlag_ControlOpInProgress); + sInstance.mFlags.Clear(Flags::kControlOpInProgress); } if (controlOpComplete) { - ClearFlag(mFlags, kFlag_ControlOpInProgress); + mFlags.Clear(Flags::kControlOpInProgress); DriveBLEState(); } } @@ -542,16 +539,16 @@ void BLEManagerImpl::DriveBLEState() CHIP_ERROR err = CHIP_NO_ERROR; // Perform any initialization actions that must occur after the Chip task is running. - if (!GetFlag(mFlags, kFlag_AsyncInitCompleted)) + if (!mFlags.Has(Flags::kAsyncInitCompleted)) { - SetFlag(mFlags, kFlag_AsyncInitCompleted); + mFlags.Set(Flags::kAsyncInitCompleted); // If CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED is enabled, // disable CHIPoBLE advertising if the device is fully provisioned. #if CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED if (ConfigurationMgr().IsFullyProvisioned()) { - ClearFlag(mFlags, kFlag_AdvertisingEnabled); + mFlags.Clear(Flags::kAdvertisingEnabled); ChipLogProgress(DeviceLayer, "CHIPoBLE advertising disabled because device is fully provisioned"); } #endif // CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED @@ -559,35 +556,35 @@ void BLEManagerImpl::DriveBLEState() } // If there's already a control operation in progress, wait until it completes. - VerifyOrExit(!GetFlag(mFlags, kFlag_ControlOpInProgress), /* */); + VerifyOrExit(!mFlags.Has(Flags::kControlOpInProgress), /* */); // Initializes the Bluez BLE layer if needed. - if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && !GetFlag(mFlags, kFlag_BluezBLELayerInitialized)) + if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && !mFlags.Has(Flags::kBluezBLELayerInitialized)) { err = InitBluezBleLayer(mIsCentral, nullptr, mBLEAdvConfig, mpEndpoint); SuccessOrExit(err); - SetFlag(mFlags, kFlag_BluezBLELayerInitialized); + mFlags.Set(Flags::kBluezBLELayerInitialized); } // Register the CHIPoBLE application with the Bluez BLE layer if needed. - if (!mIsCentral && mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && !GetFlag(mFlags, kFlag_AppRegistered)) + if (!mIsCentral && mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && !mFlags.Has(Flags::kAppRegistered)) { err = BluezGattsAppRegister(mpEndpoint); - SetFlag(mFlags, kFlag_ControlOpInProgress); + mFlags.Set(Flags::kControlOpInProgress); ExitNow(); } // If the application has enabled CHIPoBLE and BLE advertising... - if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && GetFlag(mFlags, kFlag_AdvertisingEnabled)) + if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && mFlags.Has(Flags::kAdvertisingEnabled)) { // Start/re-start advertising if not already advertising, or if the advertising state of the // Bluez BLE layer needs to be refreshed. - if (!GetFlag(mFlags, kFlag_Advertising) || GetFlag(mFlags, kFlag_AdvertisingRefreshNeeded)) + if (!mFlags.Has(Flags::kAdvertising) || mFlags.Has(Flags::kAdvertisingRefreshNeeded)) { // Configure advertising data if it hasn't been done yet. This is an asynchronous step which // must complete before advertising can be started. When that happens, this method will // be called again, and execution will proceed to the code below. - if (!GetFlag(mFlags, kFlag_AdvertisingConfigured)) + if (!mFlags.Has(Flags::kAdvertisingConfigured)) { err = BluezAdvertisementSetup(mpEndpoint); ExitNow(); @@ -597,7 +594,7 @@ void BLEManagerImpl::DriveBLEState() err = StartBLEAdvertising(); SuccessOrExit(err); - SetFlag(sInstance.mFlags, kFlag_Advertising); + sInstance.mFlags.Set(Flags::kAdvertising); ExitNow(); } } @@ -605,11 +602,11 @@ void BLEManagerImpl::DriveBLEState() // Otherwise stop advertising if needed... else { - if (GetFlag(mFlags, kFlag_Advertising)) + if (mFlags.Has(Flags::kAdvertising)) { err = StopBLEAdvertising(); SuccessOrExit(err); - SetFlag(mFlags, kFlag_ControlOpInProgress); + mFlags.Set(Flags::kControlOpInProgress); ExitNow(); } diff --git a/src/platform/Linux/BLEManagerImpl.h b/src/platform/Linux/BLEManagerImpl.h index 318202f3491c8d..7e9f5672baeb00 100644 --- a/src/platform/Linux/BLEManagerImpl.h +++ b/src/platform/Linux/BLEManagerImpl.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -163,18 +163,18 @@ class BLEManagerImpl final : public BLEManager, static BLEManagerImpl sInstance; // ===== Private members reserved for use by this class only. - enum + enum class Flags : uint16_t { - kFlag_AsyncInitCompleted = 0x0001, /**< One-time asynchronous initialization actions have been performed. */ - kFlag_BluezBLELayerInitialized = 0x0002, /**< The Bluez layer has been initialized. */ - kFlag_AppRegistered = 0x0004, /**< The CHIPoBLE application has been registered with the Bluez layer. */ - kFlag_AdvertisingConfigured = 0x0008, /**< CHIPoBLE advertising has been configured in the Bluez layer. */ - kFlag_Advertising = 0x0010, /**< The system is currently CHIPoBLE advertising. */ - kFlag_ControlOpInProgress = 0x0020, /**< An async control operation has been issued to the ESP BLE layer. */ - kFlag_AdvertisingEnabled = 0x0040, /**< The application has enabled CHIPoBLE advertising. */ - kFlag_FastAdvertisingEnabled = 0x0080, /**< The application has enabled fast advertising. */ - kFlag_UseCustomDeviceName = 0x0100, /**< The application has configured a custom BLE device name. */ - kFlag_AdvertisingRefreshNeeded = 0x0200, /**< The advertising configuration/state in BLE layer needs to be updated. */ + kAsyncInitCompleted = 0x0001, /**< One-time asynchronous initialization actions have been performed. */ + kBluezBLELayerInitialized = 0x0002, /**< The Bluez layer has been initialized. */ + kAppRegistered = 0x0004, /**< The CHIPoBLE application has been registered with the Bluez layer. */ + kAdvertisingConfigured = 0x0008, /**< CHIPoBLE advertising has been configured in the Bluez layer. */ + kAdvertising = 0x0010, /**< The system is currently CHIPoBLE advertising. */ + kControlOpInProgress = 0x0020, /**< An async control operation has been issued to the ESP BLE layer. */ + kAdvertisingEnabled = 0x0040, /**< The application has enabled CHIPoBLE advertising. */ + kFastAdvertisingEnabled = 0x0080, /**< The application has enabled fast advertising. */ + kUseCustomDeviceName = 0x0100, /**< The application has configured a custom BLE device name. */ + kAdvertisingRefreshNeeded = 0x0200, /**< The advertising configuration/state in BLE layer needs to be updated. */ }; enum @@ -196,7 +196,7 @@ class BLEManagerImpl final : public BLEManager, CHIPoBLEServiceMode mServiceMode; BLEAdvConfig mBLEAdvConfig; BLEScanConfig mBLEScanConfig; - uint16_t mFlags; + BitFlags mFlags; char mDeviceName[kMaxDeviceNameLength + 1]; bool mIsCentral = false; BluezEndpoint * mpEndpoint = nullptr; @@ -237,17 +237,17 @@ inline BLEManager::CHIPoBLEServiceMode BLEManagerImpl::_GetCHIPoBLEServiceMode() inline bool BLEManagerImpl::_IsAdvertisingEnabled() { - return GetFlag(mFlags, kFlag_AdvertisingEnabled); + return mFlags.Has(Flags::kAdvertisingEnabled); } inline bool BLEManagerImpl::_IsFastAdvertisingEnabled() { - return GetFlag(mFlags, kFlag_FastAdvertisingEnabled); + return mFlags.Has(Flags::kFastAdvertisingEnabled); } inline bool BLEManagerImpl::_IsAdvertising() { - return GetFlag(mFlags, kFlag_Advertising); + return mFlags.Has(Flags::kAdvertising); } } // namespace Internal diff --git a/src/platform/Linux/ConnectivityManagerImpl.cpp b/src/platform/Linux/ConnectivityManagerImpl.cpp index 8426e65380f5d5..f73e0dc8a4259e 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.cpp +++ b/src/platform/Linux/ConnectivityManagerImpl.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * Copyright (c) 2019 Nest Labs, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -256,17 +256,18 @@ void ConnectivityManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) #if CHIP_DEVICE_CONFIG_ENABLE_WPA -uint16_t ConnectivityManagerImpl::mConnectivityFlag; +BitFlags::ConnectivityFlags> + ConnectivityManagerImpl::mConnectivityFlag; struct GDBusWpaSupplicant ConnectivityManagerImpl::mWpaSupplicant; bool ConnectivityManagerImpl::_HaveIPv4InternetConnectivity() { - return ((mConnectivityFlag & kFlag_HaveIPv4InternetConnectivity) != 0); + return mConnectivityFlag.Has(ConnectivityFlags::kHaveIPv4InternetConnectivity); } bool ConnectivityManagerImpl::_HaveIPv6InternetConnectivity() { - return ((mConnectivityFlag & kFlag_HaveIPv6InternetConnectivity) != 0); + return mConnectivityFlag.Has(ConnectivityFlags::kHaveIPv6InternetConnectivity); } ConnectivityManager::WiFiStationMode ConnectivityManagerImpl::_GetWiFiStationMode() @@ -327,8 +328,8 @@ bool ConnectivityManagerImpl::_IsWiFiStationConnected() state = wpa_fi_w1_wpa_supplicant1_interface_get_state(mWpaSupplicant.iface); if (g_strcmp0(state, "completed") == 0) { - SetFlag(mConnectivityFlag, kFlag_HaveIPv4InternetConnectivity, true); - SetFlag(mConnectivityFlag, kFlag_HaveIPv6InternetConnectivity, true); + mConnectivityFlag.Set(ConnectivityFlags::kHaveIPv4InternetConnectivity) + .Set(ConnectivityFlags::kHaveIPv6InternetConnectivity); ret = true; } @@ -620,7 +621,7 @@ void ConnectivityManagerImpl::_OnWpaProxyReady(GObject * source_object, GAsyncRe void ConnectivityManagerImpl::StartWiFiManagement() { - mConnectivityFlag = 0; + mConnectivityFlag.ClearAll(); mWpaSupplicant.state = GDBusWpaSupplicant::INIT; mWpaSupplicant.scanState = GDBusWpaSupplicant::WIFI_SCANNING_IDLE; mWpaSupplicant.proxy = nullptr; diff --git a/src/platform/Linux/ConnectivityManagerImpl.h b/src/platform/Linux/ConnectivityManagerImpl.h index fbcd9e052897a2..f381470e11db2f 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.h +++ b/src/platform/Linux/ConnectivityManagerImpl.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * Copyright (c) 2018 Nest Labs, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -148,7 +148,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, static void _OnWpaInterfaceReady(GObject * source_object, GAsyncResult * res, gpointer user_data); static void _OnWpaInterfaceProxyReady(GObject * source_object, GAsyncResult * res, gpointer user_data); - static uint16_t mConnectivityFlag; + static BitFlags mConnectivityFlag; static struct GDBusWpaSupplicant mWpaSupplicant; #endif diff --git a/src/platform/Linux/bluez/Helper.cpp b/src/platform/Linux/bluez/Helper.cpp index 701feea6c6b61f..0f452ec4a19a44 100644 --- a/src/platform/Linux/bluez/Helper.cpp +++ b/src/platform/Linux/bluez/Helper.cpp @@ -1192,7 +1192,7 @@ static void UpdateAdditionalDataCharacteristic(BluezGattCharacteristic1 * charac char serialNumber[ConfigurationManager::kMaxSerialNumberLength + 1]; size_t serialNumberSize = 0; uint16_t lifetimeCounter = 0; - BitFlags additionalDataFields; + BitFlags additionalDataFields; #if CHIP_ENABLE_ROTATING_DEVICE_ID err = ConfigurationMgr().GetSerialNumber(serialNumber, sizeof(serialNumber), serialNumberSize); diff --git a/src/platform/Zephyr/BLEManagerImpl.cpp b/src/platform/Zephyr/BLEManagerImpl.cpp index 7396d486c882e0..7da119a618f21e 100644 --- a/src/platform/Zephyr/BLEManagerImpl.cpp +++ b/src/platform/Zephyr/BLEManagerImpl.cpp @@ -92,8 +92,8 @@ CHIP_ERROR BLEManagerImpl::_Init() CHIP_ERROR err; mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Enabled; - mFlags = CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART ? kFlag_AdvertisingEnabled : 0; - mGAPConns = 0; + mFlags.ClearAll().Set(Flags::kAdvertisingEnabled, CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART); + mGAPConns = 0; memset(mSubscribedConns, 0, sizeof(mSubscribedConns)); @@ -128,16 +128,16 @@ void BLEManagerImpl::DriveBLEState() ChipLogDetail(DeviceLayer, "In DriveBLEState"); // Perform any initialization actions that must occur after the CHIP task is running. - if (!GetFlag(mFlags, kFlag_AsyncInitCompleted)) + if (!mFlags.Has(Flags::kAsyncInitCompleted)) { - SetFlag(mFlags, kFlag_AsyncInitCompleted); + mFlags.Set(Flags::kAsyncInitCompleted); // If CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED is enabled, // disable CHIPoBLE advertising if the device is fully provisioned. #if CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED if (ConfigurationMgr().IsFullyProvisioned()) { - ClearFlag(mFlags, kFlag_AdvertisingEnabled); + mFlags.Clear(Flags::kAdvertisingEnabled); ChipLogProgress(DeviceLayer, "CHIPoBLE advertising disabled because device is fully provisioned"); } #endif // CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED @@ -145,7 +145,7 @@ void BLEManagerImpl::DriveBLEState() // If the application has enabled CHIPoBLE and BLE advertising... if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && - GetFlag(mFlags, kFlag_AdvertisingEnabled) + mFlags.Has(Flags::kAdvertisingEnabled) #if CHIP_DEVICE_CONFIG_CHIPOBLE_SINGLE_CONNECTION // and no connections are active... && (NumConnections() == 0) @@ -154,7 +154,7 @@ void BLEManagerImpl::DriveBLEState() { // Start/re-start advertising if not already advertising, or if the // advertising state needs to be refreshed. - if (!GetFlag(mFlags, kFlag_Advertising) || GetFlag(mFlags, kFlag_AdvertisingRefreshNeeded)) + if (!mFlags.Has(Flags::kAdvertising) || mFlags.Has(Flags::kAdvertisingRefreshNeeded)) { err = StartAdvertising(); SuccessOrExit(err); @@ -204,7 +204,7 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) // If necessary, inform the ThreadStackManager that CHIPoBLE advertising is about to start. #if CHIP_DEVICE_CONFIG_ENABLE_THREAD - if (!GetFlag(mFlags, kFlag_Advertising)) + if (!mFlags.Has(Flags::kAdvertising)) { ThreadStackMgr().OnCHIPoBLEAdvertisingStart(); } @@ -225,11 +225,11 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) VerifyOrExit(err == CHIP_NO_ERROR, err = MapErrorZephyr(err)); // Transition to the Advertising state... - if (!GetFlag(mFlags, kFlag_Advertising)) + if (!mFlags.Has(Flags::kAdvertising)) { ChipLogProgress(DeviceLayer, "CHIPoBLE advertising started"); - SetFlag(mFlags, kFlag_Advertising); + mFlags.Set(Flags::kAdvertising); // Post a CHIPoBLEAdvertisingChange(Started) event. { @@ -255,9 +255,9 @@ CHIP_ERROR BLEManagerImpl::StopAdvertising(void) VerifyOrExit(err == CHIP_NO_ERROR, err = MapErrorZephyr(err)); // Transition to the not Advertising state... - if (GetFlag(mFlags, kFlag_Advertising)) + if (mFlags.Has(Flags::kAdvertising)) { - ClearFlag(mFlags, kFlag_Advertising); + mFlags.Clear(Flags::kAdvertising); ChipLogProgress(DeviceLayer, "CHIPoBLE advertising stopped"); @@ -305,11 +305,11 @@ CHIP_ERROR BLEManagerImpl::_SetAdvertisingEnabled(bool val) VerifyOrExit(mServiceMode != ConnectivityManager::kCHIPoBLEServiceMode_NotSupported, err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); - if (GetFlag(mFlags, kFlag_AdvertisingEnabled) != val) + if (mFlags.Has(Flags::kAdvertisingEnabled) != val) { ChipLogDetail(DeviceLayer, "SetAdvertisingEnabled(%s)", val ? "true" : "false"); - SetFlag(mFlags, kFlag_AdvertisingEnabled, val); + mFlags.Set(Flags::kAdvertisingEnabled, val); PlatformMgr().ScheduleWork(DriveBLEState, 0); } @@ -323,11 +323,11 @@ CHIP_ERROR BLEManagerImpl::_SetFastAdvertisingEnabled(bool val) VerifyOrExit(mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_NotSupported, err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); - if (GetFlag(mFlags, kFlag_FastAdvertisingEnabled) != val) + if (mFlags.Has(Flags::kFastAdvertisingEnabled) != val) { ChipLogDetail(DeviceLayer, "SetFastAdvertisingEnabled(%s)", val ? "true" : "false"); - SetFlag(mFlags, kFlag_FastAdvertisingEnabled, val); + mFlags.Set(Flags::kFastAdvertisingEnabled, val); PlatformMgr().ScheduleWork(DriveBLEState, 0); } @@ -372,7 +372,7 @@ CHIP_ERROR BLEManagerImpl::HandleGAPConnect(const ChipDeviceEvent * event) ChipLogProgress(DeviceLayer, "Current number of connections: %" PRIu16 "/%" PRIu16, NumConnections(), CONFIG_BT_MAX_CONN); - SetFlag(mFlags, kFlag_AdvertisingRefreshNeeded); + mFlags.Set(Flags::kAdvertisingRefreshNeeded); PlatformMgr().ScheduleWork(DriveBLEState, 0); bt_conn_unref(connEvent->BtConn); @@ -418,7 +418,7 @@ CHIP_ERROR BLEManagerImpl::HandleGAPDisconnect(const ChipDeviceEvent * event) // Force a reconfiguration of advertising in case we switched to non-connectable mode when // the BLE connection was established. - SetFlag(mFlags, kFlag_AdvertisingRefreshNeeded); + mFlags.Set(Flags::kAdvertisingRefreshNeeded); PlatformMgr().ScheduleWork(DriveBLEState, 0); return CHIP_NO_ERROR; @@ -530,13 +530,13 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) #if CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED if (ConfigurationMgr().IsFullyProvisioned()) { - ClearFlag(mFlags, kFlag_AdvertisingEnabled); + mFlags.Clear(Flags::kAdvertisingEnabled); ChipLogProgress(DeviceLayer, "CHIPoBLE advertising disabled because device is fully provisioned"); } #endif // CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED // Force the advertising state to be refreshed to reflect new provisioning state. - SetFlag(mFlags, kFlag_AdvertisingRefreshNeeded); + mFlags.Set(Flags::kAdvertisingRefreshNeeded); DriveBLEState(); @@ -674,7 +674,7 @@ bool BLEManagerImpl::UnsetSubscribed(bt_conn * conn) uint32_t BLEManagerImpl::GetAdvertisingInterval() { - return (NumConnections() == 0 && !ConfigurationMgr().IsFullyProvisioned()) || GetFlag(mFlags, kFlag_FastAdvertisingEnabled) + return (NumConnections() == 0 && !ConfigurationMgr().IsFullyProvisioned()) || mFlags.Has(Flags::kFastAdvertisingEnabled) ? CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL : CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL; } diff --git a/src/platform/Zephyr/BLEManagerImpl.h b/src/platform/Zephyr/BLEManagerImpl.h index d7fe37fa9d04b7..957613781f0a7d 100644 --- a/src/platform/Zephyr/BLEManagerImpl.h +++ b/src/platform/Zephyr/BLEManagerImpl.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -93,19 +93,19 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla // ===== Private members reserved for use by this class only. - enum + enum class Flags : uint8_t { - kFlag_AsyncInitCompleted = 0x0001, /**< One-time asynchronous initialization actions have been performed. */ - kFlag_AdvertisingEnabled = 0x0002, /**< The application has enabled CHIPoBLE advertising. */ - kFlag_FastAdvertisingEnabled = 0x0004, /**< The application has enabled fast advertising. */ - kFlag_Advertising = 0x0008, /**< The system is currently CHIPoBLE advertising. */ - kFlag_AdvertisingRefreshNeeded = + kAsyncInitCompleted = 0x0001, /**< One-time asynchronous initialization actions have been performed. */ + kAdvertisingEnabled = 0x0002, /**< The application has enabled CHIPoBLE advertising. */ + kFastAdvertisingEnabled = 0x0004, /**< The application has enabled fast advertising. */ + kAdvertising = 0x0008, /**< The system is currently CHIPoBLE advertising. */ + kAdvertisingRefreshNeeded = 0x0010, /**< The advertising state/configuration has changed, but the SoftDevice has yet to be updated. */ }; struct ServiceData; - uint16_t mFlags; + BitFlags mFlags; uint16_t mGAPConns; CHIPoBLEServiceMode mServiceMode; bool mSubscribedConns[CONFIG_BT_MAX_CONN]; @@ -182,17 +182,17 @@ inline BLEManager::CHIPoBLEServiceMode BLEManagerImpl::_GetCHIPoBLEServiceMode(v inline bool BLEManagerImpl::_IsAdvertisingEnabled(void) { - return GetFlag(mFlags, kFlag_AdvertisingEnabled); + return mFlags.Has(Flags::kAdvertisingEnabled); } inline bool BLEManagerImpl::_IsFastAdvertisingEnabled(void) { - return GetFlag(mFlags, kFlag_FastAdvertisingEnabled); + return mFlags.Has(Flags::kFastAdvertisingEnabled); } inline bool BLEManagerImpl::_IsAdvertising(void) { - return GetFlag(mFlags, kFlag_Advertising); + return mFlags.Has(Flags::kAdvertising); } } // namespace Internal diff --git a/src/platform/cc13x2_26x2/BLEManagerImpl.cpp b/src/platform/cc13x2_26x2/BLEManagerImpl.cpp index a5476acc3ed394..d844c9a8537910 100644 --- a/src/platform/cc13x2_26x2/BLEManagerImpl.cpp +++ b/src/platform/cc13x2_26x2/BLEManagerImpl.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * Copyright (c) 2019 Nest Labs, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -113,7 +113,7 @@ CHIP_ERROR BLEManagerImpl::_Init(void) /* Register BLE Stack assert handler */ RegisterAssertCback(AssertHandler); - mFlags = CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART ? kFlag_AdvertisingEnabled : 0; + mFlags.ClearAll().Set(Flags::kAdvertisingEnabled, CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART); mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Enabled; OnChipBleConnectReceived = HandleIncomingBleConnection; @@ -137,13 +137,13 @@ CHIP_ERROR BLEManagerImpl::_SetCHIPoBLEServiceMode(BLEManager::CHIPoBLEServiceMo bool BLEManagerImpl::_IsAdvertisingEnabled(void) { - return GetFlag(mFlags, kFlag_AdvertisingEnabled); + return mFlags.Has(Flags::kAdvertisingEnabled); } /* Post event to app processing loop to begin CHIP advertising */ CHIP_ERROR BLEManagerImpl::_SetAdvertisingEnabled(bool val) { - SetFlag(mFlags, kFlag_AdvertisingEnabled, val); + mFlags.Set(Flags::kAdvertisingEnabled, val); /* Send event to process state change request */ return DriveBLEState(); @@ -151,16 +151,16 @@ CHIP_ERROR BLEManagerImpl::_SetAdvertisingEnabled(bool val) bool BLEManagerImpl::_IsFastAdvertisingEnabled(void) { - return GetFlag(mFlags, kFlag_FastAdvertisingEnabled); + return mFlags.Has(Flags::kFastAdvertisingEnabled); } CHIP_ERROR BLEManagerImpl::_SetFastAdvertisingEnabled(bool val) { CHIP_ERROR ret = CHIP_NO_ERROR; - if (!GetFlag(mFlags, kFlag_FastAdvertisingEnabled)) + if (!mFlags.Has(Flags::kFastAdvertisingEnabled)) { - SetFlag(mFlags, kFlag_FastAdvertisingEnabled, val); + mFlags.Set(Flags::kFastAdvertisingEnabled, val); /* Send event to process state change request */ ret = DriveBLEState(); @@ -170,7 +170,7 @@ CHIP_ERROR BLEManagerImpl::_SetFastAdvertisingEnabled(bool val) bool BLEManagerImpl::_IsAdvertising(void) { - return GetFlag(mFlags, kFlag_Advertising); + return mFlags.Has(Flags::kAdvertising); } CHIP_ERROR BLEManagerImpl::_GetDeviceName(char * buf, size_t bufSize) @@ -197,7 +197,7 @@ CHIP_ERROR BLEManagerImpl::_SetDeviceName(const char * deviceName) { strncpy(mDeviceName, deviceName, strlen(deviceName)); - SetFlag(mFlags, kFlag_BLEStackGATTNameUpdate, true); + mFlags.Set(Flags::kBLEStackGATTNameUpdate); ret = DriveBLEState(); } @@ -409,7 +409,7 @@ void BLEManagerImpl::AdvInit(void) ConfigurationMgr().GetBLEDeviceIdentificationInfo(mDeviceIdInfo); // Verify device name was not already set - if (!GetFlag(sInstance.mFlags, kFlag_BLEStackGATTNameSet)) + if (!sInstance.mFlags.Has(Flags::kBLEStackGATTNameSet)) { /* Default device name is CHIP- */ deviceDiscriminator = mDeviceIdInfo.GetDeviceDiscriminator(); @@ -758,13 +758,13 @@ void BLEManagerImpl::ProcessEvtHdrMsg(QueuedEvt_t * pMsg) /* Advertising flag set, either advertising or fast adv is enabled: Do nothing */ /* Advertising flag not set, neither advertising nor fast adv is enabled: do nothing */ /* Advertising flag not set, either advertising or fast adv is enabled: Turn on */ - if (!GetFlag(sInstance.mFlags, kFlag_Advertising)) + if (!sInstance.mFlags.Has(Flags::kAdvertising)) { BLEMGR_LOG("BLEMGR: BLE Process Application Message: Not advertising"); - if (GetFlag(sInstance.mFlags, kFlag_AdvertisingEnabled)) + if (sInstance.mFlags.Has(Flags::kAdvertisingEnabled)) { - ClearFlag(sInstance.mFlags, kFlag_FastAdvertisingEnabled); + sInstance.mFlags.Clear(Flags::kFastAdvertisingEnabled); BLEMGR_LOG("BLEMGR: BLE Process Application Message: Slow Advertising Enabled"); // Send notification to thread manager that CHIPoBLE advertising is starting @@ -780,11 +780,11 @@ void BLEManagerImpl::ProcessEvtHdrMsg(QueuedEvt_t * pMsg) // Start advertisement timer Util_startClock(&sInstance.clkAdvTimeout); - SetFlag(sInstance.mFlags, kFlag_Advertising, true); + sInstance.mFlags.Set(Flags::kAdvertising); } - else if (GetFlag(sInstance.mFlags, kFlag_FastAdvertisingEnabled)) + else if (sInstance.mFlags.Has(Flags::kFastAdvertisingEnabled)) { - ClearFlag(sInstance.mFlags, kFlag_AdvertisingEnabled); + sInstance.mFlags.Clear(Flags::kAdvertisingEnabled); BLEMGR_LOG("BLEMGR: BLE Process Application Message: Fast Advertising Enabled"); @@ -795,28 +795,27 @@ void BLEManagerImpl::ProcessEvtHdrMsg(QueuedEvt_t * pMsg) // Enable legacy advertising for set #1 status = (bStatus_t) GapAdv_enable(sInstance.advHandleLegacy, GAP_ADV_ENABLE_OPTIONS_USE_MAX, 0); assert(status == SUCCESS); - SetFlag(sInstance.mFlags, kFlag_Advertising, true); + sInstance.mFlags.Set(Flags::kAdvertising); } } /* Advertising flag set, neither advertising nor fast adv is enabled: Turn off*/ - else if (!GetFlag(sInstance.mFlags, kFlag_AdvertisingEnabled) && - !GetFlag(sInstance.mFlags, kFlag_FastAdvertisingEnabled)) + else if (!sInstance.mFlags.Has(Flags::kAdvertisingEnabled) && !sInstance.mFlags.Has(Flags::kFastAdvertisingEnabled)) { BLEMGR_LOG("BLEMGR: BLE Process Application Message: Advertising disables"); // Stop advertising GapAdv_disable(sInstance.advHandleLegacy); - ClearFlag(sInstance.mFlags, kFlag_Advertising); + sInstance.mFlags.Clear(Flags::kAdvertising); Util_stopClock(&sInstance.clkAdvTimeout); } } - if (GetFlag(sInstance.mFlags, kFlag_BLEStackGATTNameUpdate)) + if (sInstance.mFlags.Has(Flags::kBLEStackGATTNameUpdate)) { - ClearFlag(sInstance.mFlags, kFlag_BLEStackGATTNameUpdate); + sInstance.mFlags.Clear(Flags::kBLEStackGATTNameUpdate); // Indicate that Device name has been set externally - SetFlag(mFlags, kFlag_BLEStackGATTNameSet, true); + mFlags.Set(Flags::kBLEStackGATTNameSet); // Set the Device Name characteristic in the GAP GATT Service GGS_SetParameter(GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, sInstance.mDeviceName); @@ -1026,7 +1025,7 @@ void BLEManagerImpl::ProcessGapMessage(gapEventHdr_t * pMsg) AdvInit(); - SetFlag(sInstance.mFlags, kFlag_BLEStackInitialized, true); + sInstance.mFlags.Set(Flags::kBLEStackInitialized); /* Trigger post-initialization state update */ DriveBLEState(); @@ -1060,13 +1059,13 @@ void BLEManagerImpl::ProcessGapMessage(gapEventHdr_t * pMsg) if (numActive < MAX_NUM_BLE_CONNS) { // Start advertising since there is room for more connections. Advertisements stop automatically following connection. - ClearFlag(sInstance.mFlags, kFlag_Advertising); + sInstance.mFlags.Clear(Flags::kAdvertising); } else { // Stop advertising since there is no room for more connections BLEMGR_LOG("BLEMGR: BLE event GAP_LINK_ESTABLISHED_EVENT: MAX connections"); - ClearFlag(sInstance.mFlags, kFlag_FastAdvertisingEnabled | kFlag_AdvertisingEnabled | kFlag_Advertising); + sInstance.mFlags.Clear(Flags::kFastAdvertisingEnabled).Clear(Flags::kAdvertisingEnabled.Clear(Flags::kAdvertising); } /* Stop advertisement timeout timer */ @@ -1686,11 +1685,11 @@ void BLEManagerImpl::AdvTimeoutHandler(uintptr_t arg) { BLEMGR_LOG("BLEMGR: AdvTimeoutHandler"); - if (GetFlag(sInstance.mFlags, kFlag_AdvertisingEnabled)) + if (sInstance.mFlags.Has(Flags::kAdvertisingEnabled)) { BLEMGR_LOG("BLEMGR: AdvTimeoutHandler ble adv 15 minute timeout"); - SetFlag(sInstance.mFlags, kFlag_AdvertisingEnabled, false); + sInstance.mFlags.Clear(Flags::kAdvertisingEnabled); /* Send event to process state change request */ DriveBLEState(); diff --git a/src/platform/qpg6100/BLEManagerImpl.cpp b/src/platform/qpg6100/BLEManagerImpl.cpp index b831e9bf71d2db..5c55c2841b4e68 100644 --- a/src/platform/qpg6100/BLEManagerImpl.cpp +++ b/src/platform/qpg6100/BLEManagerImpl.cpp @@ -68,8 +68,8 @@ CHIP_ERROR BLEManagerImpl::_Init() CHIP_ERROR err; mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Enabled; - mFlags = CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART ? kFlag_AdvertisingEnabled : 0; - mNumGAPCons = 0; + mFlags.ClearAll().Set(Flags::kAdvertisingEnabled, CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART); + mNumGAPCons = 0; for (int i = 0; i < kMaxConnections; i++) { mSubscribedConIds[i] = BLE_CONNECTION_UNINITIALIZED; @@ -115,9 +115,9 @@ CHIP_ERROR BLEManagerImpl::_SetAdvertisingEnabled(bool val) VerifyOrExit(mServiceMode != ConnectivityManager::kCHIPoBLEServiceMode_NotSupported, err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); - if (GetFlag(mFlags, kFlag_AdvertisingEnabled) != val) + if (mFlags.Has(Flags::kAdvertisingEnabled) != val) { - SetFlag(mFlags, kFlag_AdvertisingEnabled, val); + mFlags.Set(Flags::kAdvertisingEnabled, val); PlatformMgr().ScheduleWork(DriveBLEState, 0); } @@ -131,9 +131,9 @@ CHIP_ERROR BLEManagerImpl::_SetFastAdvertisingEnabled(bool val) VerifyOrExit(mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_NotSupported, err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); - if (GetFlag(mFlags, kFlag_FastAdvertisingEnabled) != val) + if (mFlags.Has(Flags::kFastAdvertisingEnabled) != val) { - SetFlag(mFlags, kFlag_FastAdvertisingEnabled, val); + mFlags.Set(Flags::kFastAdvertisingEnabled, val); PlatformMgr().ScheduleWork(DriveBLEState, 0); } @@ -209,13 +209,13 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) #if CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED if (ConfigurationMgr().IsFullyProvisioned()) { - ClearFlag(mFlags, kFlag_AdvertisingEnabled); + mFlags.Clear(Flags::kAdvertisingEnabled); ChipLogProgress(DeviceLayer, "CHIPoBLE advertising disabled because device is fully provisioned"); } #endif // CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED // Force the advertising state to be refreshed to reflect new provisioning state. - SetFlag(mFlags, kFlag_AdvertisingRefreshNeeded); + mFlags.Set(Flags::kAdvertisingRefreshNeeded); DriveBLEState(); @@ -353,16 +353,16 @@ void BLEManagerImpl::DriveBLEState(void) CHIP_ERROR err = CHIP_NO_ERROR; // Perform any initialization actions that must occur after the CHIP task is running. - if (!GetFlag(mFlags, kFlag_AsyncInitCompleted)) + if (!mFlags.Has(Flags::kAsyncInitCompleted)) { - SetFlag(mFlags, kFlag_AsyncInitCompleted); + mFlags.Set(Flags::kAsyncInitCompleted); // If CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED is enabled, // disable CHIPoBLE advertising if the device is fully provisioned. #if CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED if (ConfigurationMgr().IsFullyProvisioned()) { - ClearFlag(mFlags, kFlag_AdvertisingEnabled); + mFlags.Clear(Flags::kAdvertisingEnabled); ChipLogProgress(DeviceLayer, "CHIPoBLE advertising disabled because device is fully provisioned"); } #endif // CHIP_DEVICE_CONFIG_CHIPOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED @@ -370,7 +370,7 @@ void BLEManagerImpl::DriveBLEState(void) // If the application has enabled CHIPoBLE and BLE advertising... if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_Enabled && - GetFlag(mFlags, kFlag_AdvertisingEnabled) + mFlags.Has(Flags::kAdvertisingEnabled) #if CHIP_DEVICE_CONFIG_CHIPOBLE_SINGLE_CONNECTION // and no connections are active... && (mNumGAPCons == 0) @@ -379,7 +379,7 @@ void BLEManagerImpl::DriveBLEState(void) { // Start/re-start BLE advertising if not already advertising, or if the // advertising state of the underlying stack needs to be refreshed. - if (!GetFlag(mFlags, kFlag_Advertising) || GetFlag(mFlags, kFlag_AdvertisingRefreshNeeded)) + if (!mFlags.Has(Flags::kAdvertising) || mFlags.Has(Flags::kAdvertisingRefreshNeeded)) { err = StartAdvertising(); SuccessOrExit(err); @@ -415,7 +415,7 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void) err = ConfigurationMgr().GetBLEDeviceIdentificationInfo(mDeviceIdInfo); SuccessOrExit(err); - if (!GetFlag(mFlags, kFlag_DeviceNameSet)) + if (!mFlags.Has(Flags::kDeviceNameSet)) { snprintf(mDeviceName, sizeof(mDeviceName), "%s%04" PRIX32, CHIP_DEVICE_CONFIG_BLE_DEVICE_NAME_PREFIX, (uint32_t) 0); @@ -474,9 +474,9 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) err = ConfigureAdvertisingData(); SuccessOrExit(err); - SetFlag(mFlags, kFlag_Advertising, true); + mFlags.Set(Flags::kAdvertising); - interval = ((mNumGAPCons == 0 && !ConfigurationMgr().IsPairedToAccount()) || GetFlag(mFlags, kFlag_FastAdvertisingEnabled)) + interval = ((mNumGAPCons == 0 && !ConfigurationMgr().IsPairedToAccount()) || mFlags.Has(Flags::kFastAdvertisingEnabled)) ? CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL : CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL; @@ -498,9 +498,9 @@ CHIP_ERROR BLEManagerImpl::StopAdvertising(void) SuccessOrExit(err); // Transition to the not Advertising state... - if (GetFlag(mFlags, kFlag_Advertising)) + if (mFlags.Has(Flags::kAdvertising)) { - ClearFlag(mFlags, kFlag_Advertising); + mFlags.Clear(Flags::kAdvertising); ChipLogProgress(DeviceLayer, "CHIPoBLE advertising stopped"); @@ -648,14 +648,14 @@ void BLEManagerImpl::HandleDmMsg(qvCHIP_Ble_DmEvt_t * pDmEvt) ExitNow(); } - ClearFlag(sInstance.mFlags, kFlag_AdvertisingRefreshNeeded); + sInstance.mFlags.Clear(Flags::kAdvertisingRefreshNeeded); // Transition to the Advertising state... - if (!GetFlag(sInstance.mFlags, kFlag_Advertising)) + if (!sInstance.mFlags.Has(Flags::kAdvertising)) { ChipLogProgress(DeviceLayer, "CHIPoBLE advertising started"); - SetFlag(sInstance.mFlags, kFlag_Advertising, true); + sInstance.mFlags.Set(Flags::kAdvertising); // Post a CHIPoBLEAdvertisingChange(Started) event. { @@ -674,12 +674,12 @@ void BLEManagerImpl::HandleDmMsg(qvCHIP_Ble_DmEvt_t * pDmEvt) ExitNow(); } - ClearFlag(sInstance.mFlags, kFlag_AdvertisingRefreshNeeded); + sInstance.mFlags.Clear(Flags::kAdvertisingRefreshNeeded); // Transition to the not Advertising state... - if (GetFlag(sInstance.mFlags, kFlag_Advertising)) + if (sInstance.mFlags.Has(Flags::kAdvertising)) { - ClearFlag(sInstance.mFlags, kFlag_Advertising); + sInstance.mFlags.Clear(Flags::kAdvertising); ChipLogProgress(DeviceLayer, "CHIPoBLE advertising stopped"); @@ -706,7 +706,7 @@ void BLEManagerImpl::HandleDmMsg(qvCHIP_Ble_DmEvt_t * pDmEvt) // Receiving a connection stops the advertising processes. So force a refresh of the advertising // state. - SetFlag(mFlags, kFlag_AdvertisingRefreshNeeded); + mFlags.Set(Flags::kAdvertisingRefreshNeeded); PlatformMgr().ScheduleWork(DriveBLEState, 0); break; } @@ -742,7 +742,7 @@ void BLEManagerImpl::HandleDmMsg(qvCHIP_Ble_DmEvt_t * pDmEvt) PlatformMgr().PostEvent(&event); } - SetFlag(mFlags, kFlag_AdvertisingRefreshNeeded); + mFlags.Set(Flags::kAdvertisingRefreshNeeded); PlatformMgr().ScheduleWork(DriveBLEState, 0); break; } diff --git a/src/platform/qpg6100/BLEManagerImpl.h b/src/platform/qpg6100/BLEManagerImpl.h index dd08bab188e90e..8de51c449f6d52 100644 --- a/src/platform/qpg6100/BLEManagerImpl.h +++ b/src/platform/qpg6100/BLEManagerImpl.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -87,15 +87,14 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla // ===== Private members reserved for use by this class only. - enum + enum class Flags : uint16_t { - kFlag_AsyncInitCompleted = 0x0001, /**< One-time asynchronous initialization actions have been performed. */ - kFlag_AdvertisingEnabled = 0x0002, /**< The application has enabled CHIPoBLE advertising. */ - kFlag_FastAdvertisingEnabled = 0x0004, /**< The application has enabled fast advertising. */ - kFlag_Advertising = 0x0008, /**< The system is currently CHIPoBLE advertising. */ - kFlag_AdvertisingRefreshNeeded = - 0x0010, /**< The advertising state/configuration state in the BLE layer needs to be updated. */ - kFlag_DeviceNameSet = 0x0020, + kAsyncInitCompleted = 0x0001, /**< One-time asynchronous initialization actions have been performed. */ + kAdvertisingEnabled = 0x0002, /**< The application has enabled CHIPoBLE advertising. */ + kFastAdvertisingEnabled = 0x0004, /**< The application has enabled fast advertising. */ + kAdvertising = 0x0008, /**< The system is currently CHIPoBLE advertising. */ + kAdvertisingRefreshNeeded = 0x0010, /**< The advertising state/configuration state in the BLE layer needs to be updated. */ + kDeviceNameSet = 0x0020, }; enum @@ -106,7 +105,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla }; CHIPoBLEServiceMode mServiceMode; - uint16_t mFlags; + BitFlags mFlags; char mDeviceName[kMaxDeviceNameLength + 1]; uint16_t mNumGAPCons; uint16_t mSubscribedConIds[kMaxConnections]; @@ -173,17 +172,17 @@ inline BLEManager::CHIPoBLEServiceMode BLEManagerImpl::_GetCHIPoBLEServiceMode(v inline bool BLEManagerImpl::_IsAdvertisingEnabled(void) { - return GetFlag(mFlags, kFlag_AdvertisingEnabled); + return mFlags.Has(Flags::kAdvertisingEnabled); } inline bool BLEManagerImpl::_IsFastAdvertisingEnabled(void) { - return GetFlag(mFlags, kFlag_FastAdvertisingEnabled); + return mFlags.Has(Flags::kFastAdvertisingEnabled); } inline bool BLEManagerImpl::_IsAdvertising(void) { - return GetFlag(mFlags, kFlag_Advertising); + return mFlags.Has(Flags::kAdvertising); } } // namespace Internal diff --git a/src/protocols/bdx/BdxMessages.cpp b/src/protocols/bdx/BdxMessages.cpp index b64c7b899b7593..bd9bf780c52d86 100644 --- a/src/protocols/bdx/BdxMessages.cpp +++ b/src/protocols/bdx/BdxMessages.cpp @@ -42,18 +42,16 @@ using namespace chip::Encoding::LittleEndian; // the size of the message (even if the message is incomplete or filled out incorrectly). BufferWriter & TransferInit::WriteToBuffer(BufferWriter & aBuffer) const { - uint8_t proposedTransferCtl = 0; - bool widerange = (StartOffset > std::numeric_limits::max()) || (MaxLength > std::numeric_limits::max()); + const BitFlags proposedTransferCtl(Version & kVersionMask, TransferCtlOptions); + const bool widerange = + (StartOffset > std::numeric_limits::max()) || (MaxLength > std::numeric_limits::max()); - proposedTransferCtl |= Version & kVersionMask; - proposedTransferCtl = proposedTransferCtl | TransferCtlOptions.Raw(); + BitFlags rangeCtlFlags; + rangeCtlFlags.Set(RangeControlFlags::kDefLen, MaxLength > 0); + rangeCtlFlags.Set(RangeControlFlags::kStartOffset, StartOffset > 0); + rangeCtlFlags.Set(RangeControlFlags::kWiderange, widerange); - BitFlags rangeCtlFlags; - rangeCtlFlags.Set(kRange_DefLen, MaxLength > 0); - rangeCtlFlags.Set(kRange_StartOffset, StartOffset > 0); - rangeCtlFlags.Set(kRange_Widerange, widerange); - - aBuffer.Put(proposedTransferCtl); + aBuffer.Put(proposedTransferCtl.Raw()); aBuffer.Put(rangeCtlFlags.Raw()); aBuffer.Put16(MaxBlockSize); @@ -98,22 +96,20 @@ CHIP_ERROR TransferInit::Parse(System::PacketBufferHandle aBuffer) { CHIP_ERROR err = CHIP_NO_ERROR; uint8_t proposedTransferCtl; - uint8_t rangeCtl; uint32_t tmpUint32Value = 0; // Used for reading non-wide length and offset fields uint8_t * bufStart = aBuffer->Start(); Reader bufReader(bufStart, aBuffer->DataLength()); - BitFlags rangeCtlFlags; + BitFlags rangeCtlFlags; - SuccessOrExit(bufReader.Read8(&proposedTransferCtl).Read8(&rangeCtl).Read16(&MaxBlockSize).StatusCode()); + SuccessOrExit(bufReader.Read8(&proposedTransferCtl).Read8(rangeCtlFlags.RawStorage()).Read16(&MaxBlockSize).StatusCode()); Version = proposedTransferCtl & kVersionMask; TransferCtlOptions.SetRaw(static_cast(proposedTransferCtl & ~kVersionMask)); - rangeCtlFlags.SetRaw(rangeCtl); StartOffset = 0; - if (rangeCtlFlags.Has(kRange_StartOffset)) + if (rangeCtlFlags.Has(RangeControlFlags::kStartOffset)) { - if (rangeCtlFlags.Has(kRange_Widerange)) + if (rangeCtlFlags.Has(RangeControlFlags::kWiderange)) { SuccessOrExit(bufReader.Read64(&StartOffset).StatusCode()); } @@ -125,9 +121,9 @@ CHIP_ERROR TransferInit::Parse(System::PacketBufferHandle aBuffer) } MaxLength = 0; - if (rangeCtlFlags.Has(kRange_DefLen)) + if (rangeCtlFlags.Has(RangeControlFlags::kDefLen)) { - if (rangeCtlFlags.Has(kRange_Widerange)) + if (rangeCtlFlags.Has(RangeControlFlags::kWiderange)) { SuccessOrExit(bufReader.Read64(&MaxLength).StatusCode()); } @@ -189,7 +185,7 @@ bool TransferInit::operator==(const TransferInit & another) const metadataMatches = (memcmp(Metadata, another.Metadata, MetadataLength) == 0); } - return ((Version == another.Version) && (TransferCtlOptions.Raw() == another.TransferCtlOptions.Raw()) && + return ((Version == another.Version) && (TransferCtlOptions == another.TransferCtlOptions) && (StartOffset == another.StartOffset) && (MaxLength == another.MaxLength) && (MaxBlockSize == another.MaxBlockSize) && fileDesMatches && metadataMatches); } @@ -198,12 +194,9 @@ bool TransferInit::operator==(const TransferInit & another) const // the size of the message (even if the message is incomplete or filled out incorrectly). Encoding::LittleEndian::BufferWriter & SendAccept::WriteToBuffer(Encoding::LittleEndian::BufferWriter & aBuffer) const { - uint8_t transferCtl = 0; - - transferCtl |= Version & kVersionMask; - transferCtl = transferCtl | TransferCtlFlags.Raw(); + const BitFlags transferCtl(Version & kVersionMask, TransferCtlFlags); - aBuffer.Put(transferCtl); + aBuffer.Put(transferCtl.Raw()); aBuffer.Put16(MaxBlockSize); if (Metadata != nullptr) @@ -266,7 +259,7 @@ bool SendAccept::operator==(const SendAccept & another) const metadataMatches = (memcmp(Metadata, another.Metadata, MetadataLength) == 0); } - return ((Version == another.Version) && (TransferCtlFlags.Raw() == another.TransferCtlFlags.Raw()) && + return ((Version == another.Version) && (TransferCtlFlags == another.TransferCtlFlags) && (MaxBlockSize == another.MaxBlockSize) && metadataMatches); } @@ -274,18 +267,15 @@ bool SendAccept::operator==(const SendAccept & another) const // the size of the message (even if the message is incomplete or filled out incorrectly). Encoding::LittleEndian::BufferWriter & ReceiveAccept::WriteToBuffer(Encoding::LittleEndian::BufferWriter & aBuffer) const { - uint8_t transferCtl = 0; - bool widerange = (StartOffset > std::numeric_limits::max()) || (Length > std::numeric_limits::max()); - - transferCtl |= Version & kVersionMask; - transferCtl = transferCtl | TransferCtlFlags.Raw(); + const BitFlags transferCtlFlags(Version & kVersionMask, TransferCtlFlags); + const bool widerange = (StartOffset > std::numeric_limits::max()) || (Length > std::numeric_limits::max()); - BitFlags rangeCtlFlags; - rangeCtlFlags.Set(kRange_DefLen, Length > 0); - rangeCtlFlags.Set(kRange_StartOffset, StartOffset > 0); - rangeCtlFlags.Set(kRange_Widerange, widerange); + BitFlags rangeCtlFlags; + rangeCtlFlags.Set(RangeControlFlags::kDefLen, Length > 0); + rangeCtlFlags.Set(RangeControlFlags::kStartOffset, StartOffset > 0); + rangeCtlFlags.Set(RangeControlFlags::kWiderange, widerange); - aBuffer.Put(transferCtl); + aBuffer.Put(transferCtlFlags.Raw()); aBuffer.Put(rangeCtlFlags.Raw()); aBuffer.Put16(MaxBlockSize); @@ -324,25 +314,22 @@ CHIP_ERROR ReceiveAccept::Parse(System::PacketBufferHandle aBuffer) { CHIP_ERROR err = CHIP_NO_ERROR; uint8_t transferCtl = 0; - uint8_t rangeCtl = 0; uint32_t tmpUint32Value = 0; // Used for reading non-wide length and offset fields uint8_t * bufStart = aBuffer->Start(); Reader bufReader(bufStart, aBuffer->DataLength()); - BitFlags rangeCtlFlags; + BitFlags rangeCtlFlags; - SuccessOrExit(bufReader.Read8(&transferCtl).Read8(&rangeCtl).Read16(&MaxBlockSize).StatusCode()); + SuccessOrExit(bufReader.Read8(&transferCtl).Read8(rangeCtlFlags.RawStorage()).Read16(&MaxBlockSize).StatusCode()); Version = transferCtl & kVersionMask; // Only one of these values should be set. It is up to the caller to verify this. TransferCtlFlags.SetRaw(static_cast(transferCtl & ~kVersionMask)); - rangeCtlFlags.SetRaw(rangeCtl); - StartOffset = 0; - if (rangeCtlFlags.Has(kRange_StartOffset)) + if (rangeCtlFlags.Has(RangeControlFlags::kStartOffset)) { - if (rangeCtlFlags.Has(kRange_Widerange)) + if (rangeCtlFlags.Has(RangeControlFlags::kWiderange)) { SuccessOrExit(bufReader.Read64(&StartOffset).StatusCode()); } @@ -354,9 +341,9 @@ CHIP_ERROR ReceiveAccept::Parse(System::PacketBufferHandle aBuffer) } Length = 0; - if (rangeCtlFlags.Has(kRange_DefLen)) + if (rangeCtlFlags.Has(RangeControlFlags::kDefLen)) { - if (rangeCtlFlags.Has(kRange_Widerange)) + if (rangeCtlFlags.Has(RangeControlFlags::kWiderange)) { SuccessOrExit(bufReader.Read64(&Length).StatusCode()); } @@ -406,7 +393,7 @@ bool ReceiveAccept::operator==(const ReceiveAccept & another) const metadataMatches = (memcmp(Metadata, another.Metadata, MetadataLength) == 0); } - return ((Version == another.Version) && (TransferCtlFlags.Raw() == another.TransferCtlFlags.Raw()) && + return ((Version == another.Version) && (TransferCtlFlags == another.TransferCtlFlags) && (StartOffset == another.StartOffset) && (MaxBlockSize == another.MaxBlockSize) && (Length == another.Length) && metadataMatches); } diff --git a/src/protocols/bdx/BdxMessages.h b/src/protocols/bdx/BdxMessages.h index 6dabe6b978e6b3..ccef89f494c372 100644 --- a/src/protocols/bdx/BdxMessages.h +++ b/src/protocols/bdx/BdxMessages.h @@ -45,39 +45,39 @@ enum class MessageType : uint8_t BlockAckEOF = 0x14, }; -enum StatusCode : uint16_t +enum class StatusCode : uint16_t { - kStatus_None = 0x0000, - kStatus_Overflow = 0x0011, - kStatus_LengthTooLarge = 0x0012, - kStatus_LengthTooShort = 0x0013, - kStatus_LengthMismatch = 0x0014, - kStatus_LengthRequired = 0x0015, - kStatus_BadMessageContents = 0x0016, - kStatus_BadBlockCounter = 0x0017, - kStatus_TransferFailedUnknownError = 0x001F, - kStatus_ServerBadState = 0x0020, - kStatus_FailureToSend = 0x0021, - kStatus_TransferMethodNotSupported = 0x0050, - kStatus_FileDesignatorUnknown = 0x0051, - kStatus_StartOffsetNotSupported = 0x0052, - kStatus_VersionNotSupported = 0x0053, - kStatus_Unknown = 0x005F, + kNone = 0x0000, + kOverflow = 0x0011, + kLengthTooLarge = 0x0012, + kLengthTooShort = 0x0013, + kLengthMismatch = 0x0014, + kLengthRequired = 0x0015, + kBadMessageContents = 0x0016, + kBadBlockCounter = 0x0017, + kTransferFailedUnknownError = 0x001F, + kServerBadState = 0x0020, + kFailureToSend = 0x0021, + kTransferMethodNotSupported = 0x0050, + kFileDesignatorUnknown = 0x0051, + kStartOffsetNotSupported = 0x0052, + kVersionNotSupported = 0x0053, + kUnknown = 0x005F, }; -enum TransferControlFlags : uint8_t +enum class TransferControlFlags : uint8_t { // first 4 bits reserved for version - kControl_SenderDrive = (1U << 4), - kControl_ReceiverDrive = (1U << 5), - kControl_Async = (1U << 6), + kSenderDrive = (1U << 4), + kReceiverDrive = (1U << 5), + kAsync = (1U << 6), }; -enum RangeControlFlags : uint8_t +enum class RangeControlFlags : uint8_t { - kRange_DefLen = (1U), - kRange_StartOffset = (1U << 1), - kRange_Widerange = (1U << 4), + kDefLen = (1U), + kStartOffset = (1U << 1), + kWiderange = (1U << 4), }; /** @@ -136,7 +136,7 @@ struct TransferInit : public BdxMessage bool operator==(const TransferInit &) const; // Proposed Transfer Control (required) - BitFlags TransferCtlOptions; + BitFlags TransferCtlOptions; uint8_t Version = 0; ///< The highest version supported by the sender // All required @@ -175,7 +175,7 @@ struct SendAccept : public BdxMessage bool operator==(const SendAccept &) const; // Transfer Control (required, only one should be set) - BitFlags TransferCtlFlags; + BitFlags TransferCtlFlags; uint8_t Version = 0; ///< The agreed upon version for the transfer (required) uint16_t MaxBlockSize = 0; ///< Chosen max block size to use in transfer (required) @@ -206,7 +206,7 @@ struct ReceiveAccept : public BdxMessage bool operator==(const ReceiveAccept &) const; // Transfer Control (required, only one should be set) - BitFlags TransferCtlFlags; + BitFlags TransferCtlFlags; // All required uint8_t Version = 0; ///< The agreed upon version for the transfer diff --git a/src/protocols/bdx/BdxTransferSession.cpp b/src/protocols/bdx/BdxTransferSession.cpp index cea58bfbea2284..57245c5f280b8c 100644 --- a/src/protocols/bdx/BdxTransferSession.cpp +++ b/src/protocols/bdx/BdxTransferSession.cpp @@ -67,12 +67,12 @@ namespace bdx { TransferSession::TransferSession() { - mSuppportedXferOpts.SetRaw(0); + mSuppportedXferOpts.ClearAll(); } void TransferSession::PollOutput(OutputEvent & event, uint64_t curTimeMs) { - event = OutputEvent(kNone); + event = OutputEvent(OutputEventType::kNone); if (mShouldInitTimeoutStart) { @@ -82,60 +82,60 @@ void TransferSession::PollOutput(OutputEvent & event, uint64_t curTimeMs) if (mAwaitingResponse && ((curTimeMs - mTimeoutStartTimeMs) >= mTimeoutMs)) { - event = OutputEvent(kTransferTimeout); - mState = kErrorState; + event = OutputEvent(OutputEventType::kTransferTimeout); + mState = TransferState::kErrorState; mAwaitingResponse = false; return; } switch (mPendingOutput) { - case kNone: - event = OutputEvent(kNone); + case OutputEventType::kNone: + event = OutputEvent(OutputEventType::kNone); break; - case kInternalError: - event = OutputEvent::StatusReportEvent(kInternalError, mStatusReportData); + case OutputEventType::kInternalError: + event = OutputEvent::StatusReportEvent(OutputEventType::kInternalError, mStatusReportData); break; - case kStatusReceived: - event = OutputEvent::StatusReportEvent(kStatusReceived, mStatusReportData); + case OutputEventType::kStatusReceived: + event = OutputEvent::StatusReportEvent(OutputEventType::kStatusReceived, mStatusReportData); break; - case kMsgToSend: - event = OutputEvent(kMsgToSend); + case OutputEventType::kMsgToSend: + event = OutputEvent(OutputEventType::kMsgToSend); event.MsgData = std::move(mPendingMsgHandle); mTimeoutStartTimeMs = curTimeMs; break; - case kInitReceived: + case OutputEventType::kInitReceived: event = OutputEvent::TransferInitEvent(mTransferRequestData, std::move(mPendingMsgHandle)); break; - case kAcceptReceived: + case OutputEventType::kAcceptReceived: event = OutputEvent::TransferAcceptEvent(mTransferAcceptData, std::move(mPendingMsgHandle)); break; - case kQueryReceived: - event = OutputEvent(kQueryReceived); + case OutputEventType::kQueryReceived: + event = OutputEvent(OutputEventType::kQueryReceived); break; - case kBlockReceived: + case OutputEventType::kBlockReceived: event = OutputEvent::BlockDataEvent(mBlockEventData, std::move(mPendingMsgHandle)); break; - case kAckReceived: - event = OutputEvent(kAckReceived); + case OutputEventType::kAckReceived: + event = OutputEvent(OutputEventType::kAckReceived); break; - case kAckEOFReceived: - event = OutputEvent(kAckEOFReceived); + case OutputEventType::kAckEOFReceived: + event = OutputEvent(OutputEventType::kAckEOFReceived); break; default: - event = OutputEvent(kNone); + event = OutputEvent(OutputEventType::kNone); break; } // If there's no other pending output but an error occured or was received, then continue to output the error. // This ensures that when the TransferSession encounters an error and needs to send a StatusReport, both a kMsgToSend and a // kInternalError output event will be emitted. - if (event.EventType == kNone && mState == kErrorState) + if (event.EventType == OutputEventType::kNone && mState == TransferState::kErrorState) { - event = OutputEvent::StatusReportEvent(kInternalError, mStatusReportData); + event = OutputEvent::StatusReportEvent(OutputEventType::kInternalError, mStatusReportData); } - mPendingOutput = kNone; + mPendingOutput = OutputEventType::kNone; } CHIP_ERROR TransferSession::StartTransfer(TransferRole role, const TransferInitData & initData, uint32_t timeoutMs) @@ -144,50 +144,50 @@ CHIP_ERROR TransferSession::StartTransfer(TransferRole role, const TransferInitD MessageType msgType; TransferInit initMsg; - VerifyOrExit(mState == kUnitialized, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mState == TransferState::kUnitialized, err = CHIP_ERROR_INCORRECT_STATE); mRole = role; mTimeoutMs = timeoutMs; // Set transfer parameters. They may be overridden later by an Accept message - mSuppportedXferOpts.SetRaw(initData.TransferCtlFlagsRaw); + mSuppportedXferOpts = initData.TransferCtlFlags; mMaxSupportedBlockSize = initData.MaxBlockSize; mStartOffset = initData.StartOffset; mTransferLength = initData.Length; // Prepare TransferInit message - initMsg.TransferCtlOptions.SetRaw(initData.TransferCtlFlagsRaw); - initMsg.Version = kBdxVersion; - initMsg.MaxBlockSize = mMaxSupportedBlockSize; - initMsg.StartOffset = mStartOffset; - initMsg.MaxLength = mTransferLength; - initMsg.FileDesignator = initData.FileDesignator; - initMsg.FileDesLength = initData.FileDesLength; - initMsg.Metadata = initData.Metadata; - initMsg.MetadataLength = initData.MetadataLength; + initMsg.TransferCtlOptions = initData.TransferCtlFlags; + initMsg.Version = kBdxVersion; + initMsg.MaxBlockSize = mMaxSupportedBlockSize; + initMsg.StartOffset = mStartOffset; + initMsg.MaxLength = mTransferLength; + initMsg.FileDesignator = initData.FileDesignator; + initMsg.FileDesLength = initData.FileDesLength; + initMsg.Metadata = initData.Metadata; + initMsg.MetadataLength = initData.MetadataLength; err = WriteToPacketBuffer(initMsg, mPendingMsgHandle); SuccessOrExit(err); - msgType = (mRole == kRole_Sender) ? MessageType::SendInit : MessageType::ReceiveInit; + msgType = (mRole == TransferRole::kSender) ? MessageType::SendInit : MessageType::ReceiveInit; err = AttachHeader(msgType, mPendingMsgHandle); SuccessOrExit(err); - mState = kAwaitingAccept; + mState = TransferState::kAwaitingAccept; mAwaitingResponse = true; - mPendingOutput = kMsgToSend; + mPendingOutput = OutputEventType::kMsgToSend; exit: return err; } -CHIP_ERROR TransferSession::WaitForTransfer(TransferRole role, BitFlags xferControlOpts, +CHIP_ERROR TransferSession::WaitForTransfer(TransferRole role, BitFlags xferControlOpts, uint16_t maxBlockSize, uint32_t timeoutMs) { CHIP_ERROR err = CHIP_NO_ERROR; - VerifyOrExit(mState == kUnitialized, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mState == TransferState::kUnitialized, err = CHIP_ERROR_INCORRECT_STATE); // Used to determine compatibility with any future TransferInit parameters mRole = role; @@ -195,7 +195,7 @@ CHIP_ERROR TransferSession::WaitForTransfer(TransferRole role, BitFlags proposedControlOpts; + const BitFlags proposedControlOpts(mTransferRequestData.TransferCtlFlags); - VerifyOrExit(mState == kNegotiateTransferParams, err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(mPendingOutput == kNone, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mState == TransferState::kNegotiateTransferParams, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mPendingOutput == OutputEventType::kNone, err = CHIP_ERROR_INCORRECT_STATE); // Don't allow a Control method that wasn't supported by the initiator // MaxBlockSize can't be larger than the proposed value - proposedControlOpts.SetRaw(mTransferRequestData.TransferCtlFlagsRaw); VerifyOrExit(proposedControlOpts.Has(acceptData.ControlMode), err = CHIP_ERROR_INVALID_ARGUMENT); VerifyOrExit(acceptData.MaxBlockSize <= mTransferRequestData.MaxBlockSize, err = CHIP_ERROR_INVALID_ARGUMENT); mTransferMaxBlockSize = acceptData.MaxBlockSize; - if (mRole == kRole_Sender) + if (mRole == TransferRole::kSender) { mStartOffset = acceptData.StartOffset; mTransferLength = acceptData.Length; @@ -254,12 +253,12 @@ CHIP_ERROR TransferSession::AcceptTransfer(const TransferAcceptData & acceptData SuccessOrExit(err); } - mPendingOutput = kMsgToSend; + mPendingOutput = OutputEventType::kMsgToSend; - mState = kTransferInProgress; + mState = TransferState::kTransferInProgress; - if ((mRole == kRole_Receiver && mControlMode == kControl_SenderDrive) || - (mRole == kRole_Sender && mControlMode == kControl_ReceiverDrive)) + if ((mRole == TransferRole::kReceiver && mControlMode == TransferControlFlags::kSenderDrive) || + (mRole == TransferRole::kSender && mControlMode == TransferControlFlags::kReceiverDrive)) { mAwaitingResponse = true; } @@ -273,9 +272,9 @@ CHIP_ERROR TransferSession::PrepareBlockQuery() CHIP_ERROR err = CHIP_NO_ERROR; BlockQuery queryMsg; - VerifyOrExit(mState == kTransferInProgress, err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(mRole == kRole_Receiver, err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(mPendingOutput == kNone, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mState == TransferState::kTransferInProgress, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mRole == TransferRole::kReceiver, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mPendingOutput == OutputEventType::kNone, err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(!mAwaitingResponse, err = CHIP_ERROR_INCORRECT_STATE); queryMsg.BlockCounter = mNextQueryNum; @@ -286,7 +285,7 @@ CHIP_ERROR TransferSession::PrepareBlockQuery() err = AttachHeader(MessageType::BlockQuery, mPendingMsgHandle); SuccessOrExit(err); - mPendingOutput = kMsgToSend; + mPendingOutput = OutputEventType::kMsgToSend; mAwaitingResponse = true; mLastQueryNum = mNextQueryNum++; @@ -301,9 +300,9 @@ CHIP_ERROR TransferSession::PrepareBlock(const BlockData & inData) DataBlock blockMsg; MessageType msgType; - VerifyOrExit(mState == kTransferInProgress, err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(mRole == kRole_Sender, err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(mPendingOutput == kNone, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mState == TransferState::kTransferInProgress, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mRole == TransferRole::kSender, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mPendingOutput == OutputEventType::kNone, err = CHIP_ERROR_INCORRECT_STATE); VerifyOrExit(!mAwaitingResponse, err = CHIP_ERROR_INCORRECT_STATE); // Verify non-zero data is provided and is no longer than MaxBlockSize (BlockEOF may contain 0 length data) @@ -320,11 +319,11 @@ CHIP_ERROR TransferSession::PrepareBlock(const BlockData & inData) err = AttachHeader(msgType, mPendingMsgHandle); SuccessOrExit(err); - mPendingOutput = kMsgToSend; + mPendingOutput = OutputEventType::kMsgToSend; if (msgType == MessageType::BlockEOF) { - mState = kAwaitingEOFAck; + mState = TransferState::kAwaitingEOFAck; } mAwaitingResponse = true; @@ -340,12 +339,13 @@ CHIP_ERROR TransferSession::PrepareBlockAck() CounterMessage ackMsg; MessageType msgType; - VerifyOrExit(mRole == kRole_Receiver, err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit((mState == kTransferInProgress) || (mState == kReceivedEOF), err = CHIP_ERROR_INCORRECT_STATE); - VerifyOrExit(mPendingOutput == kNone, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mRole == TransferRole::kReceiver, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit((mState == TransferState::kTransferInProgress) || (mState == TransferState::kReceivedEOF), + err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mPendingOutput == OutputEventType::kNone, err = CHIP_ERROR_INCORRECT_STATE); ackMsg.BlockCounter = mLastBlockNum; - msgType = (mState == kReceivedEOF) ? MessageType::BlockAckEOF : MessageType::BlockAck; + msgType = (mState == TransferState::kReceivedEOF) ? MessageType::BlockAckEOF : MessageType::BlockAck; err = WriteToPacketBuffer(ackMsg, mPendingMsgHandle); SuccessOrExit(err); @@ -353,9 +353,9 @@ CHIP_ERROR TransferSession::PrepareBlockAck() err = AttachHeader(msgType, mPendingMsgHandle); SuccessOrExit(err); - if (mState == kTransferInProgress) + if (mState == TransferState::kTransferInProgress) { - if (mControlMode == kControl_SenderDrive) + if (mControlMode == TransferControlFlags::kSenderDrive) { // In Sender Drive, a BlockAck is implied to also be a query for the next Block, so expect to receive a Block // message. @@ -363,13 +363,13 @@ CHIP_ERROR TransferSession::PrepareBlockAck() mAwaitingResponse = true; } } - else if (mState == kReceivedEOF) + else if (mState == TransferState::kReceivedEOF) { - mState = kTransferDone; + mState = TransferState::kTransferDone; mAwaitingResponse = false; } - mPendingOutput = kMsgToSend; + mPendingOutput = OutputEventType::kMsgToSend; exit: return err; @@ -379,7 +379,8 @@ CHIP_ERROR TransferSession::AbortTransfer(StatusCode reason) { CHIP_ERROR err = CHIP_NO_ERROR; - VerifyOrExit((mState != kUnitialized) && (mState != kTransferDone) && (mState != kErrorState), + VerifyOrExit((mState != TransferState::kUnitialized) && (mState != TransferState::kTransferDone) && + (mState != TransferState::kErrorState), err = CHIP_ERROR_INCORRECT_STATE); PrepareStatusReport(reason); @@ -390,9 +391,9 @@ CHIP_ERROR TransferSession::AbortTransfer(StatusCode reason) void TransferSession::Reset() { - mPendingOutput = kNone; - mState = kUnitialized; - mSuppportedXferOpts.SetRaw(0); + mPendingOutput = OutputEventType::kNone; + mState = TransferState::kUnitialized; + mSuppportedXferOpts.ClearAll(); mTransferVersion = 0; mMaxSupportedBlockSize = 0; mStartOffset = 0; @@ -452,7 +453,7 @@ CHIP_ERROR TransferSession::HandleBdxMessage(PayloadHeader & header, System::Pac MessageType msgType = static_cast(header.GetMessageType()); VerifyOrExit(!msg.IsNull(), err = CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrExit(mPendingOutput == kNone, err = CHIP_ERROR_INCORRECT_STATE); + VerifyOrExit(mPendingOutput == OutputEventType::kNone, err = CHIP_ERROR_INCORRECT_STATE); switch (msgType) { @@ -501,7 +502,7 @@ CHIP_ERROR TransferSession::HandleStatusReportMessage(PayloadHeader & header, Sy { VerifyOrReturnError(!msg.IsNull(), CHIP_ERROR_INVALID_ARGUMENT); - mState = kErrorState; + mState = TransferState::kErrorState; mAwaitingResponse = false; uint16_t generalCode = 0; @@ -511,9 +512,9 @@ CHIP_ERROR TransferSession::HandleStatusReportMessage(PayloadHeader & header, Sy ReturnErrorOnFailure(reader.Read16(&generalCode).Read32(&protocolId).Read16(&protocolCode).StatusCode()); VerifyOrReturnError((protocolId == Protocols::kProtocol_BDX), CHIP_ERROR_INVALID_MESSAGE_TYPE); - mStatusReportData.StatusCode = protocolCode; + mStatusReportData.statusCode = static_cast(protocolCode); - mPendingOutput = kStatusReceived; + mPendingOutput = OutputEventType::kStatusReceived; return CHIP_NO_ERROR; } @@ -523,19 +524,19 @@ void TransferSession::HandleTransferInit(MessageType msgType, System::PacketBuff CHIP_ERROR err = CHIP_NO_ERROR; TransferInit transferInit; - VerifyOrExit(mState == kAwaitingInitMsg, PrepareStatusReport(kStatus_ServerBadState)); + VerifyOrExit(mState == TransferState::kAwaitingInitMsg, PrepareStatusReport(StatusCode::kServerBadState)); - if (mRole == kRole_Sender) + if (mRole == TransferRole::kSender) { - VerifyOrExit(msgType == MessageType::ReceiveInit, PrepareStatusReport(kStatus_ServerBadState)); + VerifyOrExit(msgType == MessageType::ReceiveInit, PrepareStatusReport(StatusCode::kServerBadState)); } else { - VerifyOrExit(msgType == MessageType::SendInit, PrepareStatusReport(kStatus_ServerBadState)); + VerifyOrExit(msgType == MessageType::SendInit, PrepareStatusReport(StatusCode::kServerBadState)); } err = transferInit.Parse(msgData.Retain()); - VerifyOrExit(err == CHIP_NO_ERROR, PrepareStatusReport(kStatus_BadMessageContents)); + VerifyOrExit(err == CHIP_NO_ERROR, PrepareStatusReport(StatusCode::kBadMessageContents)); ResolveTransferControlOptions(transferInit.TransferCtlOptions); mTransferVersion = ::chip::min(kBdxVersion, transferInit.Version); @@ -546,19 +547,19 @@ void TransferSession::HandleTransferInit(MessageType msgType, System::PacketBuff mTransferLength = transferInit.MaxLength; // Store the Request data to share with the caller for verification - mTransferRequestData.TransferCtlFlagsRaw = transferInit.TransferCtlOptions.Raw(), - mTransferRequestData.MaxBlockSize = transferInit.MaxBlockSize; - mTransferRequestData.StartOffset = transferInit.StartOffset; - mTransferRequestData.Length = transferInit.MaxLength; - mTransferRequestData.FileDesignator = transferInit.FileDesignator; - mTransferRequestData.FileDesLength = transferInit.FileDesLength; - mTransferRequestData.Metadata = transferInit.Metadata; - mTransferRequestData.MetadataLength = transferInit.MetadataLength; + mTransferRequestData.TransferCtlFlags = transferInit.TransferCtlOptions; + mTransferRequestData.MaxBlockSize = transferInit.MaxBlockSize; + mTransferRequestData.StartOffset = transferInit.StartOffset; + mTransferRequestData.Length = transferInit.MaxLength; + mTransferRequestData.FileDesignator = transferInit.FileDesignator; + mTransferRequestData.FileDesLength = transferInit.FileDesLength; + mTransferRequestData.Metadata = transferInit.Metadata; + mTransferRequestData.MetadataLength = transferInit.MetadataLength; mPendingMsgHandle = std::move(msgData); - mPendingOutput = kInitReceived; + mPendingOutput = OutputEventType::kInitReceived; - mState = kNegotiateTransferParams; + mState = TransferState::kNegotiateTransferParams; exit: return; @@ -569,11 +570,11 @@ void TransferSession::HandleReceiveAccept(System::PacketBufferHandle msgData) CHIP_ERROR err = CHIP_NO_ERROR; ReceiveAccept rcvAcceptMsg; - VerifyOrExit(mRole == kRole_Receiver, PrepareStatusReport(kStatus_ServerBadState)); - VerifyOrExit(mState == kAwaitingAccept, PrepareStatusReport(kStatus_ServerBadState)); + VerifyOrExit(mRole == TransferRole::kReceiver, PrepareStatusReport(StatusCode::kServerBadState)); + VerifyOrExit(mState == TransferState::kAwaitingAccept, PrepareStatusReport(StatusCode::kServerBadState)); err = rcvAcceptMsg.Parse(msgData.Retain()); - VerifyOrExit(err == CHIP_NO_ERROR, PrepareStatusReport(kStatus_BadMessageContents)); + VerifyOrExit(err == CHIP_NO_ERROR, PrepareStatusReport(StatusCode::kBadMessageContents)); // Verify that Accept parameters are compatible with the original proposed parameters err = VerifyProposedMode(rcvAcceptMsg.TransferCtlFlags); @@ -593,10 +594,10 @@ void TransferSession::HandleReceiveAccept(System::PacketBufferHandle msgData) mTransferAcceptData.MetadataLength = rcvAcceptMsg.MetadataLength; mPendingMsgHandle = std::move(msgData); - mPendingOutput = kAcceptReceived; + mPendingOutput = OutputEventType::kAcceptReceived; - mAwaitingResponse = (mControlMode == kControl_SenderDrive); - mState = kTransferInProgress; + mAwaitingResponse = (mControlMode == TransferControlFlags::kSenderDrive); + mState = TransferState::kTransferInProgress; exit: return; @@ -607,11 +608,11 @@ void TransferSession::HandleSendAccept(System::PacketBufferHandle msgData) CHIP_ERROR err = CHIP_NO_ERROR; SendAccept sendAcceptMsg; - VerifyOrExit(mRole == kRole_Sender, PrepareStatusReport(kStatus_ServerBadState)); - VerifyOrExit(mState == kAwaitingAccept, PrepareStatusReport(kStatus_ServerBadState)); + VerifyOrExit(mRole == TransferRole::kSender, PrepareStatusReport(StatusCode::kServerBadState)); + VerifyOrExit(mState == TransferState::kAwaitingAccept, PrepareStatusReport(StatusCode::kServerBadState)); err = sendAcceptMsg.Parse(msgData.Retain()); - VerifyOrExit(err == CHIP_NO_ERROR, PrepareStatusReport(kStatus_BadMessageContents)); + VerifyOrExit(err == CHIP_NO_ERROR, PrepareStatusReport(StatusCode::kBadMessageContents)); // Verify that Accept parameters are compatible with the original proposed parameters err = VerifyProposedMode(sendAcceptMsg.TransferCtlFlags); @@ -629,10 +630,10 @@ void TransferSession::HandleSendAccept(System::PacketBufferHandle msgData) mTransferAcceptData.MetadataLength = sendAcceptMsg.MetadataLength; mPendingMsgHandle = std::move(msgData); - mPendingOutput = kAcceptReceived; + mPendingOutput = OutputEventType::kAcceptReceived; - mAwaitingResponse = (mControlMode == kControl_ReceiverDrive); - mState = kTransferInProgress; + mAwaitingResponse = (mControlMode == TransferControlFlags::kReceiverDrive); + mState = TransferState::kTransferInProgress; exit: return; @@ -643,16 +644,16 @@ void TransferSession::HandleBlockQuery(System::PacketBufferHandle msgData) CHIP_ERROR err = CHIP_NO_ERROR; BlockQuery query; - VerifyOrExit(mRole == kRole_Sender, PrepareStatusReport(kStatus_ServerBadState)); - VerifyOrExit(mState == kTransferInProgress, PrepareStatusReport(kStatus_ServerBadState)); - VerifyOrExit(mAwaitingResponse, PrepareStatusReport(kStatus_ServerBadState)); + VerifyOrExit(mRole == TransferRole::kSender, PrepareStatusReport(StatusCode::kServerBadState)); + VerifyOrExit(mState == TransferState::kTransferInProgress, PrepareStatusReport(StatusCode::kServerBadState)); + VerifyOrExit(mAwaitingResponse, PrepareStatusReport(StatusCode::kServerBadState)); err = query.Parse(std::move(msgData)); - VerifyOrExit(err == CHIP_NO_ERROR, PrepareStatusReport(kStatus_BadMessageContents)); + VerifyOrExit(err == CHIP_NO_ERROR, PrepareStatusReport(StatusCode::kBadMessageContents)); - VerifyOrExit(query.BlockCounter == mNextBlockNum, PrepareStatusReport(kStatus_BadBlockCounter)); + VerifyOrExit(query.BlockCounter == mNextBlockNum, PrepareStatusReport(StatusCode::kBadBlockCounter)); - mPendingOutput = kQueryReceived; + mPendingOutput = OutputEventType::kQueryReceived; mAwaitingResponse = false; mLastQueryNum = query.BlockCounter; @@ -666,20 +667,20 @@ void TransferSession::HandleBlock(System::PacketBufferHandle msgData) CHIP_ERROR err = CHIP_NO_ERROR; Block blockMsg; - VerifyOrExit(mRole == kRole_Receiver, PrepareStatusReport(kStatus_ServerBadState)); - VerifyOrExit(mState == kTransferInProgress, PrepareStatusReport(kStatus_ServerBadState)); - VerifyOrExit(mAwaitingResponse, PrepareStatusReport(kStatus_ServerBadState)); + VerifyOrExit(mRole == TransferRole::kReceiver, PrepareStatusReport(StatusCode::kServerBadState)); + VerifyOrExit(mState == TransferState::kTransferInProgress, PrepareStatusReport(StatusCode::kServerBadState)); + VerifyOrExit(mAwaitingResponse, PrepareStatusReport(StatusCode::kServerBadState)); err = blockMsg.Parse(msgData.Retain()); - VerifyOrExit(err == CHIP_NO_ERROR, PrepareStatusReport(kStatus_BadMessageContents)); + VerifyOrExit(err == CHIP_NO_ERROR, PrepareStatusReport(StatusCode::kBadMessageContents)); - VerifyOrExit(blockMsg.BlockCounter == mLastQueryNum, PrepareStatusReport(kStatus_BadBlockCounter)); + VerifyOrExit(blockMsg.BlockCounter == mLastQueryNum, PrepareStatusReport(StatusCode::kBadBlockCounter)); VerifyOrExit((blockMsg.DataLength > 0) && (blockMsg.DataLength <= mTransferMaxBlockSize), - PrepareStatusReport(kStatus_BadMessageContents)); + PrepareStatusReport(StatusCode::kBadMessageContents)); if (IsTransferLengthDefinite()) { - VerifyOrExit(mNumBytesProcessed + blockMsg.DataLength <= mTransferLength, PrepareStatusReport(kStatus_LengthMismatch)); + VerifyOrExit(mNumBytesProcessed + blockMsg.DataLength <= mTransferLength, PrepareStatusReport(StatusCode::kLengthMismatch)); } mBlockEventData.Data = blockMsg.Data; @@ -687,7 +688,7 @@ void TransferSession::HandleBlock(System::PacketBufferHandle msgData) mBlockEventData.IsEof = false; mPendingMsgHandle = std::move(msgData); - mPendingOutput = kBlockReceived; + mPendingOutput = OutputEventType::kBlockReceived; mNumBytesProcessed += blockMsg.DataLength; mLastBlockNum = blockMsg.BlockCounter; @@ -703,28 +704,28 @@ void TransferSession::HandleBlockEOF(System::PacketBufferHandle msgData) CHIP_ERROR err = CHIP_NO_ERROR; BlockEOF blockEOFMsg; - VerifyOrExit(mRole == kRole_Receiver, PrepareStatusReport(kStatus_ServerBadState)); - VerifyOrExit(mState == kTransferInProgress, PrepareStatusReport(kStatus_ServerBadState)); - VerifyOrExit(mAwaitingResponse, PrepareStatusReport(kStatus_ServerBadState)); + VerifyOrExit(mRole == TransferRole::kReceiver, PrepareStatusReport(StatusCode::kServerBadState)); + VerifyOrExit(mState == TransferState::kTransferInProgress, PrepareStatusReport(StatusCode::kServerBadState)); + VerifyOrExit(mAwaitingResponse, PrepareStatusReport(StatusCode::kServerBadState)); err = blockEOFMsg.Parse(msgData.Retain()); - VerifyOrExit(err == CHIP_NO_ERROR, PrepareStatusReport(kStatus_BadMessageContents)); + VerifyOrExit(err == CHIP_NO_ERROR, PrepareStatusReport(StatusCode::kBadMessageContents)); - VerifyOrExit(blockEOFMsg.BlockCounter == mLastQueryNum, PrepareStatusReport(kStatus_BadBlockCounter)); - VerifyOrExit(blockEOFMsg.DataLength <= mTransferMaxBlockSize, PrepareStatusReport(kStatus_BadMessageContents)); + VerifyOrExit(blockEOFMsg.BlockCounter == mLastQueryNum, PrepareStatusReport(StatusCode::kBadBlockCounter)); + VerifyOrExit(blockEOFMsg.DataLength <= mTransferMaxBlockSize, PrepareStatusReport(StatusCode::kBadMessageContents)); mBlockEventData.Data = blockEOFMsg.Data; mBlockEventData.Length = blockEOFMsg.DataLength; mBlockEventData.IsEof = true; mPendingMsgHandle = std::move(msgData); - mPendingOutput = kBlockReceived; + mPendingOutput = OutputEventType::kBlockReceived; mNumBytesProcessed += blockEOFMsg.DataLength; mLastBlockNum = blockEOFMsg.BlockCounter; mAwaitingResponse = false; - mState = kReceivedEOF; + mState = TransferState::kReceivedEOF; exit: return; @@ -735,19 +736,19 @@ void TransferSession::HandleBlockAck(System::PacketBufferHandle msgData) CHIP_ERROR err = CHIP_NO_ERROR; BlockAck ackMsg; - VerifyOrExit(mRole == kRole_Sender, PrepareStatusReport(kStatus_ServerBadState)); - VerifyOrExit(mState == kTransferInProgress, PrepareStatusReport(kStatus_ServerBadState)); - VerifyOrExit(mAwaitingResponse, PrepareStatusReport(kStatus_ServerBadState)); + VerifyOrExit(mRole == TransferRole::kSender, PrepareStatusReport(StatusCode::kServerBadState)); + VerifyOrExit(mState == TransferState::kTransferInProgress, PrepareStatusReport(StatusCode::kServerBadState)); + VerifyOrExit(mAwaitingResponse, PrepareStatusReport(StatusCode::kServerBadState)); err = ackMsg.Parse(std::move(msgData)); - VerifyOrExit(err == CHIP_NO_ERROR, PrepareStatusReport(kStatus_BadMessageContents)); - VerifyOrExit(ackMsg.BlockCounter == mLastBlockNum, PrepareStatusReport(kStatus_BadBlockCounter)); + VerifyOrExit(err == CHIP_NO_ERROR, PrepareStatusReport(StatusCode::kBadMessageContents)); + VerifyOrExit(ackMsg.BlockCounter == mLastBlockNum, PrepareStatusReport(StatusCode::kBadBlockCounter)); - mPendingOutput = kAckReceived; + mPendingOutput = OutputEventType::kAckReceived; // In Receiver Drive, the Receiver can send a BlockAck to indicate receipt of the message and reset the timeout. // In this case, the Sender should wait to receive a BlockQuery next. - mAwaitingResponse = (mControlMode == kControl_ReceiverDrive); + mAwaitingResponse = (mControlMode == TransferControlFlags::kReceiverDrive); exit: return; @@ -758,75 +759,75 @@ void TransferSession::HandleBlockAckEOF(System::PacketBufferHandle msgData) CHIP_ERROR err = CHIP_NO_ERROR; BlockAckEOF ackMsg; - VerifyOrExit(mRole == kRole_Sender, PrepareStatusReport(kStatus_ServerBadState)); - VerifyOrExit(mState == kAwaitingEOFAck, PrepareStatusReport(kStatus_ServerBadState)); - VerifyOrExit(mAwaitingResponse, PrepareStatusReport(kStatus_ServerBadState)); + VerifyOrExit(mRole == TransferRole::kSender, PrepareStatusReport(StatusCode::kServerBadState)); + VerifyOrExit(mState == TransferState::kAwaitingEOFAck, PrepareStatusReport(StatusCode::kServerBadState)); + VerifyOrExit(mAwaitingResponse, PrepareStatusReport(StatusCode::kServerBadState)); err = ackMsg.Parse(std::move(msgData)); - VerifyOrExit(err == CHIP_NO_ERROR, PrepareStatusReport(kStatus_BadMessageContents)); - VerifyOrExit(ackMsg.BlockCounter == mLastBlockNum, PrepareStatusReport(kStatus_BadBlockCounter)); + VerifyOrExit(err == CHIP_NO_ERROR, PrepareStatusReport(StatusCode::kBadMessageContents)); + VerifyOrExit(ackMsg.BlockCounter == mLastBlockNum, PrepareStatusReport(StatusCode::kBadBlockCounter)); - mPendingOutput = kAckEOFReceived; + mPendingOutput = OutputEventType::kAckEOFReceived; mAwaitingResponse = false; - mState = kTransferDone; + mState = TransferState::kTransferDone; exit: return; } -void TransferSession::ResolveTransferControlOptions(const BitFlags & proposed) +void TransferSession::ResolveTransferControlOptions(const BitFlags & proposed) { // Must specify at least one synchronous option - if (!proposed.Has(kControl_SenderDrive) && !proposed.Has(kControl_ReceiverDrive)) + // + if (!proposed.HasAny(TransferControlFlags::kSenderDrive, TransferControlFlags::kReceiverDrive)) { - PrepareStatusReport(kStatus_TransferMethodNotSupported); + PrepareStatusReport(StatusCode::kTransferMethodNotSupported); return; } // Ensure there are options supported by both nodes. Async gets priority. // If there is only one common option, choose that one. Otherwise the application must pick. - BitFlags commonOpts; - commonOpts.SetRaw(proposed.Raw() & mSuppportedXferOpts.Raw()); - if (commonOpts.Raw() == 0) + const BitFlags commonOpts(proposed & mSuppportedXferOpts); + if (!commonOpts.HasAny()) { - PrepareStatusReport(kStatus_TransferMethodNotSupported); + PrepareStatusReport(StatusCode::kTransferMethodNotSupported); } - else if (commonOpts.HasOnly(kControl_Async)) + else if (commonOpts.HasOnly(TransferControlFlags::kAsync)) { - mControlMode = kControl_Async; + mControlMode = TransferControlFlags::kAsync; } - else if (commonOpts.HasOnly(kControl_ReceiverDrive)) + else if (commonOpts.HasOnly(TransferControlFlags::kReceiverDrive)) { - mControlMode = kControl_ReceiverDrive; + mControlMode = TransferControlFlags::kReceiverDrive; } - else if (commonOpts.HasOnly(kControl_SenderDrive)) + else if (commonOpts.HasOnly(TransferControlFlags::kSenderDrive)) { - mControlMode = kControl_SenderDrive; + mControlMode = TransferControlFlags::kSenderDrive; } } -CHIP_ERROR TransferSession::VerifyProposedMode(const BitFlags & proposed) +CHIP_ERROR TransferSession::VerifyProposedMode(const BitFlags & proposed) { TransferControlFlags mode; // Must specify only one mode in Accept messages - if (proposed.HasOnly(kControl_Async)) + if (proposed.HasOnly(TransferControlFlags::kAsync)) { - mode = kControl_Async; + mode = TransferControlFlags::kAsync; } - else if (proposed.HasOnly(kControl_ReceiverDrive)) + else if (proposed.HasOnly(TransferControlFlags::kReceiverDrive)) { - mode = kControl_ReceiverDrive; + mode = TransferControlFlags::kReceiverDrive; } - else if (proposed.HasOnly(kControl_SenderDrive)) + else if (proposed.HasOnly(TransferControlFlags::kSenderDrive)) { - mode = kControl_SenderDrive; + mode = TransferControlFlags::kSenderDrive; } else { - PrepareStatusReport(kStatus_BadMessageContents); + PrepareStatusReport(StatusCode::kBadMessageContents); return CHIP_ERROR_INTERNAL; } @@ -837,7 +838,7 @@ CHIP_ERROR TransferSession::VerifyProposedMode(const BitFlags(Protocols::Common::StatusCode::Failure)); bbuf.Put32(Protocols::kProtocol_BDX); - bbuf.Put16(mStatusReportData.StatusCode); + bbuf.Put16(static_cast(mStatusReportData.statusCode)); mPendingMsgHandle = bbuf.Finalize(); if (mPendingMsgHandle.IsNull()) { - mPendingOutput = kInternalError; + mPendingOutput = OutputEventType::kInternalError; } else { CHIP_ERROR err = AttachHeader(Protocols::Common::MsgType::StatusReport, mPendingMsgHandle); VerifyOrReturn(err == CHIP_NO_ERROR); - mPendingOutput = kMsgToSend; + mPendingOutput = OutputEventType::kMsgToSend; } - mState = kErrorState; + mState = TransferState::kErrorState; mAwaitingResponse = false; // Prevent triggering timeout } @@ -879,7 +880,7 @@ bool TransferSession::IsTransferLengthDefinite() TransferSession::OutputEvent TransferSession::OutputEvent::TransferInitEvent(TransferInitData data, System::PacketBufferHandle msg) { - OutputEvent event(kInitReceived); + OutputEvent event(OutputEventType::kInitReceived); event.MsgData = std::move(msg); event.transferInitData = data; return event; @@ -891,7 +892,7 @@ TransferSession::OutputEvent TransferSession::OutputEvent::TransferInitEvent(Tra */ TransferSession::OutputEvent TransferSession::OutputEvent::TransferAcceptEvent(TransferAcceptData data) { - OutputEvent event(kAcceptReceived); + OutputEvent event(OutputEventType::kAcceptReceived); event.transferAcceptData = data; return event; } @@ -909,7 +910,7 @@ TransferSession::OutputEvent TransferSession::OutputEvent::TransferAcceptEvent(T TransferSession::OutputEvent TransferSession::OutputEvent::BlockDataEvent(BlockData data, System::PacketBufferHandle msg) { - OutputEvent event(kBlockReceived); + OutputEvent event(OutputEventType::kBlockReceived); event.MsgData = std::move(msg); event.blockdata = data; return event; diff --git a/src/protocols/bdx/BdxTransferSession.h b/src/protocols/bdx/BdxTransferSession.h index e3b583146511e0..871f38b75fe770 100644 --- a/src/protocols/bdx/BdxTransferSession.h +++ b/src/protocols/bdx/BdxTransferSession.h @@ -15,16 +15,16 @@ namespace chip { namespace bdx { -enum TransferRole : uint8_t +enum class TransferRole : uint8_t { - kRole_Receiver = 0, - kRole_Sender = 1, + kReceiver = 0, + kSender = 1, }; class DLL_EXPORT TransferSession { public: - enum OutputEventType : uint16_t + enum class OutputEventType : uint16_t { kNone = 0, kMsgToSend, @@ -41,7 +41,7 @@ class DLL_EXPORT TransferSession struct TransferInitData { - uint8_t TransferCtlFlagsRaw = 0; + TransferControlFlags TransferCtlFlags; uint16_t MaxBlockSize = 0; uint64_t StartOffset = 0; @@ -70,7 +70,7 @@ class DLL_EXPORT TransferSession struct StatusReportData { - uint16_t StatusCode; + StatusCode statusCode; }; struct BlockData @@ -99,8 +99,8 @@ class DLL_EXPORT TransferSession StatusReportData statusData; }; - OutputEvent() : EventType(kNone) { statusData = { kStatus_None }; } - OutputEvent(OutputEventType type) : EventType(type) { statusData = { kStatus_None }; } + OutputEvent() : EventType(OutputEventType::kNone) { statusData = { StatusCode::kNone }; } + OutputEvent(OutputEventType type) : EventType(type) { statusData = { StatusCode::kNone }; } static OutputEvent TransferInitEvent(TransferInitData data, System::PacketBufferHandle msg); static OutputEvent TransferAcceptEvent(TransferAcceptData data); @@ -160,7 +160,7 @@ class DLL_EXPORT TransferSession * @return CHIP_ERROR Result of initialization. May also indicate if the TransferSession object is unable to handle this * request. */ - CHIP_ERROR WaitForTransfer(TransferRole role, BitFlags xferControlOpts, uint16_t maxBlockSize, + CHIP_ERROR WaitForTransfer(TransferRole role, BitFlags xferControlOpts, uint16_t maxBlockSize, uint32_t timeoutMs); /** @@ -252,7 +252,7 @@ class DLL_EXPORT TransferSession TransferSession(); private: - enum TransferState : uint8_t + enum class TransferState : uint8_t { kUnitialized, kAwaitingInitMsg, @@ -282,23 +282,23 @@ class DLL_EXPORT TransferSession * Used when handling a TransferInit message. Determines if there are any compatible Transfer control modes between the two * transfer peers. */ - void ResolveTransferControlOptions(const BitFlags & proposed); + void ResolveTransferControlOptions(const BitFlags & proposed); /** * @brief * Used when handling an Accept message. Verifies that the chosen control mode is compatible with the orignal supported modes. */ - CHIP_ERROR VerifyProposedMode(const BitFlags & proposed); + CHIP_ERROR VerifyProposedMode(const BitFlags & proposed); void PrepareStatusReport(StatusCode code); bool IsTransferLengthDefinite(); - OutputEventType mPendingOutput = kNone; - TransferState mState = kUnitialized; + OutputEventType mPendingOutput = OutputEventType::kNone; + TransferState mState = TransferState::kUnitialized; TransferRole mRole; // Indicate supported options pre- transfer accept - BitFlags mSuppportedXferOpts; + BitFlags mSuppportedXferOpts; uint16_t mMaxSupportedBlockSize = 0; // Used to govern transfer once it has been accepted diff --git a/src/protocols/bdx/tests/TestBdxMessages.cpp b/src/protocols/bdx/tests/TestBdxMessages.cpp index bd618afaad2d7f..3fd9b4dbbb3183 100644 --- a/src/protocols/bdx/tests/TestBdxMessages.cpp +++ b/src/protocols/bdx/tests/TestBdxMessages.cpp @@ -43,8 +43,7 @@ void TestTransferInitMessage(nlTestSuite * inSuite, void * inContext) { TransferInit testMsg; - testMsg.TransferCtlOptions.SetRaw(0); - testMsg.TransferCtlOptions.Set(kControl_ReceiverDrive, true); + testMsg.TransferCtlOptions.ClearAll().Set(TransferControlFlags::kReceiverDrive, true); testMsg.Version = 1; // Make sure MaxLength is greater than UINT32_MAX to test widerange being set @@ -69,8 +68,7 @@ void TestSendAcceptMessage(nlTestSuite * inSuite, void * inContext) SendAccept testMsg; testMsg.Version = 1; - testMsg.TransferCtlFlags.SetRaw(0); - testMsg.TransferCtlFlags.Set(kControl_ReceiverDrive, true); + testMsg.TransferCtlFlags.ClearAll().Set(TransferControlFlags::kReceiverDrive, true); testMsg.MaxBlockSize = 256; uint8_t fakeData[5] = { 7, 6, 5, 4, 3 }; @@ -85,8 +83,7 @@ void TestReceiveAcceptMessage(nlTestSuite * inSuite, void * inContext) ReceiveAccept testMsg; testMsg.Version = 1; - testMsg.TransferCtlFlags.SetRaw(0); - testMsg.TransferCtlFlags.Set(kControl_ReceiverDrive, true); + testMsg.TransferCtlFlags.ClearAll().Set(TransferControlFlags::kReceiverDrive, true); // Make sure Length is greater than UINT32_MAX to test widerange being set testMsg.Length = static_cast(std::numeric_limits::max()) + 1; diff --git a/src/protocols/bdx/tests/TestBdxTransferSession.cpp b/src/protocols/bdx/tests/TestBdxTransferSession.cpp index ab362a5e59a2eb..8ee740b6a12b73 100644 --- a/src/protocols/bdx/tests/TestBdxTransferSession.cpp +++ b/src/protocols/bdx/tests/TestBdxTransferSession.cpp @@ -115,9 +115,9 @@ void VerifyStatusReport(nlTestSuite * inSuite, void * inContext, const System::P CHIP_ERROR err = CHIP_NO_ERROR; uint16_t headerSize = 0; PayloadHeader payloadHeader; - uint16_t generalCode = 0; - uint32_t protocolId = 0; - uint16_t protocolCode = 0; + uint16_t generalCode = 0; + uint32_t protocolId = 0; + BitFlags protocolCode; if (msg.IsNull()) { @@ -136,7 +136,7 @@ void VerifyStatusReport(nlTestSuite * inSuite, void * inContext, const System::P } Encoding::LittleEndian::Reader reader(msg->Start(), msg->DataLength()); - err = reader.Skip(headerSize).Read16(&generalCode).Read32(&protocolId).Read16(&protocolCode).StatusCode(); + err = reader.Skip(headerSize).Read16(&generalCode).Read32(&protocolId).Read16(protocolCode.RawStorage()).StatusCode(); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); NL_TEST_ASSERT(inSuite, generalCode == static_cast(Protocols::Common::StatusCode::Failure)); NL_TEST_ASSERT(inSuite, protocolId == Protocols::kProtocol_BDX); @@ -147,19 +147,19 @@ void VerifyNoMoreOutput(nlTestSuite * inSuite, void * inContext, TransferSession { TransferSession::OutputEvent event; transferSession.PollOutput(event, kNoAdvanceTime); - NL_TEST_ASSERT(inSuite, event.EventType == TransferSession::kNone); + NL_TEST_ASSERT(inSuite, event.EventType == TransferSession::OutputEventType::kNone); } // Helper method for initializing two TransferSession objects, generating a TransferInit message, and passing it to a responding // TransferSession. void SendAndVerifyTransferInit(nlTestSuite * inSuite, void * inContext, TransferSession::OutputEvent & outEvent, uint32_t timeoutMs, TransferSession & initiator, TransferRole initiatorRole, TransferSession::TransferInitData initData, - TransferSession & responder, BitFlags & responderControlOpts, + TransferSession & responder, BitFlags & responderControlOpts, uint16_t responderMaxBlock) { CHIP_ERROR err = CHIP_NO_ERROR; - TransferRole responderRole = (initiatorRole == kRole_Sender) ? kRole_Receiver : kRole_Sender; - MessageType expectedInitMsg = (initiatorRole == kRole_Sender) ? MessageType::SendInit : MessageType::ReceiveInit; + TransferRole responderRole = (initiatorRole == TransferRole::kSender) ? TransferRole::kReceiver : TransferRole::kSender; + MessageType expectedInitMsg = (initiatorRole == TransferRole::kSender) ? MessageType::SendInit : MessageType::ReceiveInit; // Initializer responder to wait for transfer err = responder.WaitForTransfer(responderRole, responderControlOpts, responderMaxBlock, timeoutMs); @@ -170,7 +170,7 @@ void SendAndVerifyTransferInit(nlTestSuite * inSuite, void * inContext, Transfer err = initiator.StartTransfer(initiatorRole, initData, timeoutMs); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); initiator.PollOutput(outEvent, kNoAdvanceTime); - NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::kMsgToSend); + NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::OutputEventType::kMsgToSend); VerifyBdxMessageType(inSuite, inContext, outEvent.MsgData, expectedInitMsg); VerifyNoMoreOutput(inSuite, inContext, initiator); @@ -179,14 +179,15 @@ void SendAndVerifyTransferInit(nlTestSuite * inSuite, void * inContext, Transfer NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); responder.PollOutput(outEvent, kNoAdvanceTime); VerifyNoMoreOutput(inSuite, inContext, responder); - NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::kInitReceived); - NL_TEST_ASSERT(inSuite, outEvent.transferInitData.TransferCtlFlagsRaw == initData.TransferCtlFlagsRaw); + NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::OutputEventType::kInitReceived); + NL_TEST_ASSERT(inSuite, outEvent.transferInitData.TransferCtlFlags == initData.TransferCtlFlags); NL_TEST_ASSERT(inSuite, outEvent.transferInitData.MaxBlockSize == initData.MaxBlockSize); NL_TEST_ASSERT(inSuite, outEvent.transferInitData.StartOffset == initData.StartOffset); NL_TEST_ASSERT(inSuite, outEvent.transferInitData.Length == initData.Length); NL_TEST_ASSERT(inSuite, outEvent.transferInitData.FileDesignator != nullptr); NL_TEST_ASSERT(inSuite, outEvent.transferInitData.FileDesLength == initData.FileDesLength); - if (outEvent.EventType == TransferSession::kInitReceived && outEvent.transferInitData.FileDesignator != nullptr) + if (outEvent.EventType == TransferSession::OutputEventType::kInitReceived && + outEvent.transferInitData.FileDesignator != nullptr) { NL_TEST_ASSERT( inSuite, @@ -223,7 +224,7 @@ void SendAndVerifyAcceptMsg(nlTestSuite * inSuite, void * inContext, TransferSes CHIP_ERROR err = CHIP_NO_ERROR; // If the node sending the Accept message is also the one that will send Blocks, then this should be a ReceiveAccept message. - MessageType expectedMsg = (acceptSenderRole == kRole_Sender) ? MessageType::ReceiveAccept : MessageType::SendAccept; + MessageType expectedMsg = (acceptSenderRole == TransferRole::kSender) ? MessageType::ReceiveAccept : MessageType::SendAccept; err = acceptSender.AcceptTransfer(acceptData); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); @@ -231,7 +232,7 @@ void SendAndVerifyAcceptMsg(nlTestSuite * inSuite, void * inContext, TransferSes // Verify Sender emits ReceiveAccept message for sending acceptSender.PollOutput(outEvent, kNoAdvanceTime); VerifyNoMoreOutput(inSuite, inContext, acceptSender); - NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::kMsgToSend); + NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::OutputEventType::kMsgToSend); VerifyBdxMessageType(inSuite, inContext, outEvent.MsgData, expectedMsg); // Pass Accept message to acceptReceiver @@ -243,7 +244,7 @@ void SendAndVerifyAcceptMsg(nlTestSuite * inSuite, void * inContext, TransferSes // Transfer at this point. acceptReceiver.PollOutput(outEvent, kNoAdvanceTime); VerifyNoMoreOutput(inSuite, inContext, acceptReceiver); - NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::kAcceptReceived); + NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::OutputEventType::kAcceptReceived); NL_TEST_ASSERT(inSuite, outEvent.transferAcceptData.ControlMode == acceptData.ControlMode); NL_TEST_ASSERT(inSuite, outEvent.transferAcceptData.MaxBlockSize == acceptData.MaxBlockSize); NL_TEST_ASSERT(inSuite, outEvent.transferAcceptData.StartOffset == acceptData.StartOffset); @@ -277,7 +278,7 @@ void SendAndVerifyQuery(nlTestSuite * inSuite, void * inContext, TransferSession CHIP_ERROR err = querySender.PrepareBlockQuery(); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); querySender.PollOutput(outEvent, kNoAdvanceTime); - NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::kMsgToSend); + NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::OutputEventType::kMsgToSend); VerifyBdxMessageType(inSuite, inContext, outEvent.MsgData, MessageType::BlockQuery); VerifyNoMoreOutput(inSuite, inContext, querySender); @@ -285,7 +286,7 @@ void SendAndVerifyQuery(nlTestSuite * inSuite, void * inContext, TransferSession err = queryReceiver.HandleMessageReceived(std::move(outEvent.MsgData), kNoAdvanceTime); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); queryReceiver.PollOutput(outEvent, kNoAdvanceTime); - NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::kQueryReceived); + NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::OutputEventType::kQueryReceived); VerifyNoMoreOutput(inSuite, inContext, queryReceiver); } @@ -320,7 +321,7 @@ void SendAndVerifyArbitraryBlock(nlTestSuite * inSuite, void * inContext, Transf err = sender.PrepareBlock(blockData); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); sender.PollOutput(outEvent, kNoAdvanceTime); - NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::kMsgToSend); + NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::OutputEventType::kMsgToSend); VerifyBdxMessageType(inSuite, inContext, outEvent.MsgData, expected); VerifyNoMoreOutput(inSuite, inContext, sender); @@ -328,9 +329,9 @@ void SendAndVerifyArbitraryBlock(nlTestSuite * inSuite, void * inContext, Transf err = receiver.HandleMessageReceived(std::move(outEvent.MsgData), kNoAdvanceTime); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); receiver.PollOutput(outEvent, kNoAdvanceTime); - NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::kBlockReceived); + NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::OutputEventType::kBlockReceived); NL_TEST_ASSERT(inSuite, outEvent.blockdata.Data != nullptr); - if (outEvent.EventType == TransferSession::kBlockReceived && outEvent.blockdata.Data != nullptr) + if (outEvent.EventType == TransferSession::OutputEventType::kBlockReceived && outEvent.blockdata.Data != nullptr) { NL_TEST_ASSERT(inSuite, !memcmp(fakeBlockData, outEvent.blockdata.Data, outEvent.blockdata.Length)); } @@ -342,14 +343,14 @@ void SendAndVerifyBlockAck(nlTestSuite * inSuite, void * inContext, TransferSess TransferSession::OutputEvent & outEvent, bool expectEOF) { TransferSession::OutputEventType expectedEventType = - expectEOF ? TransferSession::kAckEOFReceived : TransferSession::kAckReceived; + expectEOF ? TransferSession::OutputEventType::kAckEOFReceived : TransferSession::OutputEventType::kAckReceived; MessageType expectedMsgType = expectEOF ? MessageType::BlockAckEOF : MessageType::BlockAck; // Verify PrepareBlockAck() outputs message to send CHIP_ERROR err = ackSender.PrepareBlockAck(); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); ackSender.PollOutput(outEvent, kNoAdvanceTime); - NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::kMsgToSend); + NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::OutputEventType::kMsgToSend); VerifyBdxMessageType(inSuite, inContext, outEvent.MsgData, expectedMsgType); VerifyNoMoreOutput(inSuite, inContext, ackSender); @@ -379,21 +380,21 @@ void TestInitiatingReceiverReceiverDrive(nlTestSuite * inSuite, void * inContext uint32_t timeoutMs = 1000 * 24; // Chosen specifically for this test - TransferControlFlags driveMode = kControl_ReceiverDrive; + TransferControlFlags driveMode = TransferControlFlags::kReceiverDrive; // ReceiveInit parameters TransferSession::TransferInitData initOptions; - initOptions.TransferCtlFlagsRaw = driveMode; - initOptions.MaxBlockSize = proposedBlockSize; - char testFileDes[9] = { "test.txt" }; - initOptions.FileDesLength = static_cast(strlen(testFileDes)); - initOptions.FileDesignator = reinterpret_cast(testFileDes); + initOptions.TransferCtlFlags = driveMode; + initOptions.MaxBlockSize = proposedBlockSize; + char testFileDes[9] = { "test.txt" }; + initOptions.FileDesLength = static_cast(strlen(testFileDes)); + initOptions.FileDesignator = reinterpret_cast(testFileDes); // Initialize respondingSender and pass ReceiveInit message - BitFlags senderOpts; + BitFlags senderOpts; senderOpts.Set(driveMode); - SendAndVerifyTransferInit(inSuite, inContext, outEvent, timeoutMs, initiatingReceiver, kRole_Receiver, initOptions, + SendAndVerifyTransferInit(inSuite, inContext, outEvent, timeoutMs, initiatingReceiver, TransferRole::kReceiver, initOptions, respondingSender, senderOpts, proposedBlockSize); // Test metadata for Accept message @@ -413,7 +414,7 @@ void TestInitiatingReceiverReceiverDrive(nlTestSuite * inSuite, void * inContext acceptData.Metadata = tlvBuf; acceptData.MetadataLength = metadataSize; - SendAndVerifyAcceptMsg(inSuite, inContext, outEvent, respondingSender, kRole_Sender, acceptData, initiatingReceiver, + SendAndVerifyAcceptMsg(inSuite, inContext, outEvent, respondingSender, TransferRole::kSender, acceptData, initiatingReceiver, initOptions); // Verify that MaxBlockSize was chosen correctly @@ -473,14 +474,14 @@ void TestInitiatingSenderSenderDrive(nlTestSuite * inSuite, void * inContext) TransferSession initiatingSender; TransferSession respondingReceiver; - TransferControlFlags driveMode = kControl_SenderDrive; + TransferControlFlags driveMode = TransferControlFlags::kSenderDrive; // Chosen arbitrarily for this test uint16_t transferBlockSize = 10; uint32_t timeoutMs = 1000 * 24; // Initialize respondingReceiver - BitFlags receiverOpts; + BitFlags receiverOpts; receiverOpts.Set(driveMode); // Test metadata for TransferInit message @@ -493,15 +494,15 @@ void TestInitiatingSenderSenderDrive(nlTestSuite * inSuite, void * inContext) // Initialize struct with TransferInit parameters TransferSession::TransferInitData initOptions; - initOptions.TransferCtlFlagsRaw = driveMode; - initOptions.MaxBlockSize = transferBlockSize; - char testFileDes[9] = { "test.txt" }; - initOptions.FileDesLength = static_cast(strlen(testFileDes)); - initOptions.FileDesignator = reinterpret_cast(testFileDes); - initOptions.Metadata = tlvBuf; - initOptions.MetadataLength = metadataSize; - - SendAndVerifyTransferInit(inSuite, inContext, outEvent, timeoutMs, initiatingSender, kRole_Sender, initOptions, + initOptions.TransferCtlFlags = driveMode; + initOptions.MaxBlockSize = transferBlockSize; + char testFileDes[9] = { "test.txt" }; + initOptions.FileDesLength = static_cast(strlen(testFileDes)); + initOptions.FileDesignator = reinterpret_cast(testFileDes); + initOptions.Metadata = tlvBuf; + initOptions.MetadataLength = metadataSize; + + SendAndVerifyTransferInit(inSuite, inContext, outEvent, timeoutMs, initiatingSender, TransferRole::kSender, initOptions, respondingReceiver, receiverOpts, transferBlockSize); // Verify parsed TLV metadata matches the original @@ -519,7 +520,7 @@ void TestInitiatingSenderSenderDrive(nlTestSuite * inSuite, void * inContext) acceptData.Metadata = nullptr; acceptData.MetadataLength = 0; - SendAndVerifyAcceptMsg(inSuite, inContext, outEvent, respondingReceiver, kRole_Receiver, acceptData, initiatingSender, + SendAndVerifyAcceptMsg(inSuite, inContext, outEvent, respondingReceiver, TransferRole::kReceiver, acceptData, initiatingSender, initOptions); // Test multiple Block -> BlockAck -> Block @@ -542,28 +543,28 @@ void TestBadAcceptMessageFields(nlTestSuite * inSuite, void * inContext) TransferSession respondingSender; uint16_t maxBlockSize = 64; - TransferControlFlags driveMode = kControl_ReceiverDrive; + TransferControlFlags driveMode = TransferControlFlags::kReceiverDrive; uint64_t commonLength = 0; uint64_t commonOffset = 0; uint32_t timeoutMs = 1000 * 24; // Initialize struct with TransferInit parameters TransferSession::TransferInitData initOptions; - initOptions.TransferCtlFlagsRaw = driveMode; - initOptions.MaxBlockSize = maxBlockSize; - initOptions.StartOffset = commonOffset; - initOptions.Length = commonLength; - char testFileDes[9] = { "test.txt" }; // arbitrary file designator - initOptions.FileDesLength = static_cast(strlen(testFileDes)); - initOptions.FileDesignator = reinterpret_cast(testFileDes); - initOptions.Metadata = nullptr; - initOptions.MetadataLength = 0; + initOptions.TransferCtlFlags = driveMode; + initOptions.MaxBlockSize = maxBlockSize; + initOptions.StartOffset = commonOffset; + initOptions.Length = commonLength; + char testFileDes[9] = { "test.txt" }; // arbitrary file designator + initOptions.FileDesLength = static_cast(strlen(testFileDes)); + initOptions.FileDesignator = reinterpret_cast(testFileDes); + initOptions.Metadata = nullptr; + initOptions.MetadataLength = 0; // Responder parameters - BitFlags responderControl; + BitFlags responderControl; responderControl.Set(driveMode); - SendAndVerifyTransferInit(inSuite, inContext, outEvent, timeoutMs, initiatingReceiver, kRole_Receiver, initOptions, + SendAndVerifyTransferInit(inSuite, inContext, outEvent, timeoutMs, initiatingReceiver, TransferRole::kReceiver, initOptions, respondingSender, responderControl, maxBlockSize); // Verify AcceptTransfer() returns error for choosing larger max block size @@ -577,7 +578,8 @@ void TestBadAcceptMessageFields(nlTestSuite * inSuite, void * inContext) // Verify AcceptTransfer() returns error for choosing unsupported transfer control mode TransferSession::TransferAcceptData acceptData2; - acceptData2.ControlMode = (driveMode == kControl_ReceiverDrive) ? kControl_SenderDrive : kControl_ReceiverDrive; + acceptData2.ControlMode = (driveMode == TransferControlFlags::kReceiverDrive) ? TransferControlFlags::kSenderDrive + : TransferControlFlags::kReceiverDrive; acceptData2.MaxBlockSize = maxBlockSize; acceptData2.StartOffset = commonOffset; acceptData2.Length = commonLength; @@ -598,17 +600,17 @@ void TestTimeout(nlTestSuite * inSuite, void * inContext) // Initialize struct with arbitrary TransferInit parameters TransferSession::TransferInitData initOptions; - initOptions.TransferCtlFlagsRaw = kControl_ReceiverDrive; - initOptions.MaxBlockSize = 64; - initOptions.StartOffset = 0; - initOptions.Length = 0; - char testFileDes[9] = { "test.txt" }; // arbitrary file designator - initOptions.FileDesLength = static_cast(strlen(testFileDes)); - initOptions.FileDesignator = reinterpret_cast(testFileDes); - initOptions.Metadata = nullptr; - initOptions.MetadataLength = 0; - - TransferRole role = kRole_Receiver; + initOptions.TransferCtlFlags = TransferControlFlags::kReceiverDrive; + initOptions.MaxBlockSize = 64; + initOptions.StartOffset = 0; + initOptions.Length = 0; + char testFileDes[9] = { "test.txt" }; // arbitrary file designator + initOptions.FileDesLength = static_cast(strlen(testFileDes)); + initOptions.FileDesignator = reinterpret_cast(testFileDes); + initOptions.Metadata = nullptr; + initOptions.MetadataLength = 0; + + TransferRole role = TransferRole::kReceiver; // Verify initiator outputs respective Init message (depending on role) after StartTransfer() err = initiator.StartTransfer(role, initOptions, timeoutMs); @@ -616,13 +618,13 @@ void TestTimeout(nlTestSuite * inSuite, void * inContext) // First PollOutput() should output the TransferInit message initiator.PollOutput(outEvent, startTimeMs); - NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::kMsgToSend); - MessageType expectedInitMsg = (role == kRole_Sender) ? MessageType::SendInit : MessageType::ReceiveInit; + NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::OutputEventType::kMsgToSend); + MessageType expectedInitMsg = (role == TransferRole::kSender) ? MessageType::SendInit : MessageType::ReceiveInit; VerifyBdxMessageType(inSuite, inContext, outEvent.MsgData, expectedInitMsg); // Second PollOutput() with no call to HandleMessageReceived() should result in a timeout. initiator.PollOutput(outEvent, endTimeMs); - NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::kTransferTimeout); + NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::OutputEventType::kTransferTimeout); } // Test that sending the same block twice (with same block counter) results in a StatusReport message with BadBlockCounter. Also @@ -645,21 +647,21 @@ void TestDuplicateBlockError(nlTestSuite * inSuite, void * inContext) uint32_t timeoutMs = 1000 * 24; // Chosen specifically for this test - TransferControlFlags driveMode = kControl_ReceiverDrive; + TransferControlFlags driveMode = TransferControlFlags::kReceiverDrive; // ReceiveInit parameters TransferSession::TransferInitData initOptions; - initOptions.TransferCtlFlagsRaw = driveMode; - initOptions.MaxBlockSize = blockSize; - char testFileDes[9] = { "test.txt" }; - initOptions.FileDesLength = static_cast(strlen(testFileDes)); - initOptions.FileDesignator = reinterpret_cast(testFileDes); + initOptions.TransferCtlFlags = driveMode; + initOptions.MaxBlockSize = blockSize; + char testFileDes[9] = { "test.txt" }; + initOptions.FileDesLength = static_cast(strlen(testFileDes)); + initOptions.FileDesignator = reinterpret_cast(testFileDes); // Initialize respondingSender and pass ReceiveInit message - BitFlags senderOpts; + BitFlags senderOpts; senderOpts.Set(driveMode); - SendAndVerifyTransferInit(inSuite, inContext, outEvent, timeoutMs, initiatingReceiver, kRole_Receiver, initOptions, + SendAndVerifyTransferInit(inSuite, inContext, outEvent, timeoutMs, initiatingReceiver, TransferRole::kReceiver, initOptions, respondingSender, senderOpts, blockSize); // Compose ReceiveAccept parameters struct and give to respondingSender @@ -671,7 +673,7 @@ void TestDuplicateBlockError(nlTestSuite * inSuite, void * inContext) acceptData.Metadata = nullptr; acceptData.MetadataLength = 0; - SendAndVerifyAcceptMsg(inSuite, inContext, outEvent, respondingSender, kRole_Sender, acceptData, initiatingReceiver, + SendAndVerifyAcceptMsg(inSuite, inContext, outEvent, respondingSender, TransferRole::kSender, acceptData, initiatingReceiver, initOptions); SendAndVerifyQuery(inSuite, inContext, respondingSender, initiatingReceiver, outEvent); @@ -685,7 +687,7 @@ void TestDuplicateBlockError(nlTestSuite * inSuite, void * inContext) err = respondingSender.PrepareBlock(blockData); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); respondingSender.PollOutput(eventWithBlock, kNoAdvanceTime); - NL_TEST_ASSERT(inSuite, eventWithBlock.EventType == TransferSession::kMsgToSend); + NL_TEST_ASSERT(inSuite, eventWithBlock.EventType == TransferSession::OutputEventType::kMsgToSend); VerifyBdxMessageType(inSuite, inContext, eventWithBlock.MsgData, MessageType::Block); VerifyNoMoreOutput(inSuite, inContext, respondingSender); System::PacketBufferHandle blockCopy = @@ -695,7 +697,7 @@ void TestDuplicateBlockError(nlTestSuite * inSuite, void * inContext) err = initiatingReceiver.HandleMessageReceived(std::move(eventWithBlock.MsgData), kNoAdvanceTime); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); initiatingReceiver.PollOutput(outEvent, kNoAdvanceTime); - NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::kBlockReceived); + NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::OutputEventType::kBlockReceived); NL_TEST_ASSERT(inSuite, outEvent.blockdata.Data != nullptr); VerifyNoMoreOutput(inSuite, inContext, initiatingReceiver); @@ -705,30 +707,30 @@ void TestDuplicateBlockError(nlTestSuite * inSuite, void * inContext) err = initiatingReceiver.HandleMessageReceived(std::move(blockCopy), kNoAdvanceTime); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); initiatingReceiver.PollOutput(outEvent, kNoAdvanceTime); - NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::kMsgToSend); + NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::OutputEventType::kMsgToSend); System::PacketBufferHandle statusReportMsg = outEvent.MsgData.Retain(); - VerifyStatusReport(inSuite, inContext, std::move(outEvent.MsgData), kStatus_BadBlockCounter); + VerifyStatusReport(inSuite, inContext, std::move(outEvent.MsgData), StatusCode::kBadBlockCounter); // All subsequent PollOutput() calls should return kInternalError for (int i = 0; i < 5; ++i) { initiatingReceiver.PollOutput(outEvent, kNoAdvanceTime); - NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::kInternalError); - NL_TEST_ASSERT(inSuite, outEvent.statusData.StatusCode == kStatus_BadBlockCounter); + NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::OutputEventType::kInternalError); + NL_TEST_ASSERT(inSuite, outEvent.statusData.statusCode == StatusCode::kBadBlockCounter); } err = respondingSender.HandleMessageReceived(std::move(statusReportMsg), kNoAdvanceTime); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); respondingSender.PollOutput(outEvent, kNoAdvanceTime); - NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::kStatusReceived); - NL_TEST_ASSERT(inSuite, outEvent.statusData.StatusCode == kStatus_BadBlockCounter); + NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::OutputEventType::kStatusReceived); + NL_TEST_ASSERT(inSuite, outEvent.statusData.statusCode == StatusCode::kBadBlockCounter); // All subsequent PollOutput() calls should return kInternalError for (int i = 0; i < 5; ++i) { respondingSender.PollOutput(outEvent, kNoAdvanceTime); - NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::kInternalError); - NL_TEST_ASSERT(inSuite, outEvent.statusData.StatusCode == kStatus_BadBlockCounter); + NL_TEST_ASSERT(inSuite, outEvent.EventType == TransferSession::OutputEventType::kInternalError); + NL_TEST_ASSERT(inSuite, outEvent.statusData.statusCode == StatusCode::kBadBlockCounter); } } diff --git a/src/setup_payload/AdditionalDataPayloadGenerator.cpp b/src/setup_payload/AdditionalDataPayloadGenerator.cpp index 5e6d99024dca23..341c0e6c26de9d 100644 --- a/src/setup_payload/AdditionalDataPayloadGenerator.cpp +++ b/src/setup_payload/AdditionalDataPayloadGenerator.cpp @@ -44,7 +44,7 @@ using namespace chip::Encoding::LittleEndian; CHIP_ERROR AdditionalDataPayloadGenerator::generateAdditionalDataPayload(uint16_t lifetimeCounter, const char * serialNumberBuffer, size_t serialNumberBufferSize, PacketBufferHandle & bufferHandle, - BitFlags additionalDataFields) + BitFlags additionalDataFields) { CHIP_ERROR err = CHIP_NO_ERROR; System::PacketBufferTLVWriter writer; diff --git a/src/setup_payload/AdditionalDataPayloadGenerator.h b/src/setup_payload/AdditionalDataPayloadGenerator.h index 6b48edaad3f10e..652b2676c5dc43 100644 --- a/src/setup_payload/AdditionalDataPayloadGenerator.h +++ b/src/setup_payload/AdditionalDataPayloadGenerator.h @@ -71,7 +71,7 @@ class AdditionalDataPayloadGenerator */ CHIP_ERROR generateAdditionalDataPayload(uint16_t lifetimeCounter, const char * serialNumberBuffer, size_t serialNumberBufferSize, chip::System::PacketBufferHandle & bufferHandle, - BitFlags additionalDataFields); + BitFlags additionalDataFields); // Generate Device Rotating ID /** * Generate additional data payload (i.e. TLV encoded). diff --git a/src/transport/raw/MessageHeader.cpp b/src/transport/raw/MessageHeader.cpp index 8a95a74a04f51b..9e05324cbacd53 100644 --- a/src/transport/raw/MessageHeader.cpp +++ b/src/transport/raw/MessageHeader.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -319,9 +319,9 @@ CHIP_ERROR PacketHeader::EncodeBeforeData(const System::PacketBufferHandle & buf CHIP_ERROR PayloadHeader::Encode(uint8_t * data, uint16_t size, uint16_t * encode_size) const { - CHIP_ERROR err = CHIP_NO_ERROR; - uint8_t * p = data; - uint8_t header = mExchangeFlags.Raw(); + CHIP_ERROR err = CHIP_NO_ERROR; + uint8_t * p = data; + const uint8_t header = mExchangeFlags.Raw(); VerifyOrExit(size >= EncodeSizeBytes(), err = CHIP_ERROR_INVALID_ARGUMENT); diff --git a/src/transport/raw/MessageHeader.h b/src/transport/raw/MessageHeader.h index 3a7feca0b02e0c..dfe8d8cabdca18 100644 --- a/src/transport/raw/MessageHeader.h +++ b/src/transport/raw/MessageHeader.h @@ -1,6 +1,6 @@ /* * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2020-2021 Project CHIP Authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -95,9 +95,9 @@ enum class FlagValues : uint16_t }; -using Flags = BitFlags; -using ExFlags = BitFlags; -using InternalFlags = BitFlags; +using Flags = BitFlags; +using ExFlags = BitFlags; +using InternalFlags = BitFlags; // Header is a 16-bit value of the form // | 4 bit | 4 bit |8 bit Security Flags| From f800b9d1c6d9fcbc4f75d3fcc4b7808c0e575f65 Mon Sep 17 00:00:00 2001 From: jimlyall-q <77050348+jimlyall-q@users.noreply.github.com> Date: Thu, 11 Mar 2021 17:50:34 +0100 Subject: [PATCH 05/39] [QPG6100] Add lighting app to CI build tests (#5318) * Updated lighting app and tidy up * Add lighting app to CI --- .github/workflows/examples-qpg6100.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/examples-qpg6100.yaml b/.github/workflows/examples-qpg6100.yaml index a73fb30ef4067b..03a4258e388ad7 100644 --- a/.github/workflows/examples-qpg6100.yaml +++ b/.github/workflows/examples-qpg6100.yaml @@ -47,6 +47,9 @@ jobs: - name: Build example QPG6100 Lock App run: scripts/examples/gn_build_example.sh examples/lock-app/qpg6100 out/lock_app_debug + - name: Build example QPG6100 Lighting App + run: scripts/examples/gn_build_example.sh + examples/lighting-app/qpg6100 out/lighting_app_debug - name: Binary artifact suffix id: outsuffix uses: haya14busa/action-cond@v1.0.0 @@ -62,6 +65,7 @@ jobs: steps.outsuffix.outputs.value }} path: | out/lock_app_debug/chip-qpg6100-lock-example.out + out/lighting_app_debug/chip-qpg6100-lighting-example.out - name: Remove third_party binaries for CodeQL Analysis run: find out -type d -name "third_party" -exec rm -rf {} + - name: Perform CodeQL Analysis From 01c7acb032ec409d24cf0625588cd188e76b4a0c Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Thu, 11 Mar 2021 17:50:55 +0100 Subject: [PATCH 06/39] Followup #1 for #5244. Always add 'chip.ble' modules even if ble is natively disabled (#5312) --- examples/bridge-app/linux/main.cpp | 2 +- examples/lighting-app/linux/main.cpp | 2 +- src/controller/python/BUILD.gn | 22 ++++++---------------- src/controller/python/build-chip-wheel.py | 6 ++---- 4 files changed, 10 insertions(+), 22 deletions(-) diff --git a/examples/bridge-app/linux/main.cpp b/examples/bridge-app/linux/main.cpp index fc5d18a6150bdb..7857436a76cc2c 100644 --- a/examples/bridge-app/linux/main.cpp +++ b/examples/bridge-app/linux/main.cpp @@ -168,7 +168,7 @@ int main(int argc, char * argv[]) chip::DeviceLayer::ConnectivityMgr().SetBLEDeviceName(nullptr); // Use default device name (CHIP-XXXX) -#ifdef CONFIG_NETWORK_BLE +#if CONFIG_NETWORK_LAYER_BLE chip::DeviceLayer::Internal::BLEMgrImpl().ConfigureBle(LinuxDeviceOptions::GetInstance().mBleDevice, false); #endif diff --git a/examples/lighting-app/linux/main.cpp b/examples/lighting-app/linux/main.cpp index 509db8f3ccc874..b34a4bc174634f 100644 --- a/examples/lighting-app/linux/main.cpp +++ b/examples/lighting-app/linux/main.cpp @@ -168,7 +168,7 @@ int main(int argc, char * argv[]) chip::DeviceLayer::ConnectivityMgr().SetBLEDeviceName(nullptr); // Use default device name (CHIP-XXXX) -#ifdef CONFIG_NETWORK_BLE +#if CONFIG_NETWORK_LAYER_BLE chip::DeviceLayer::Internal::BLEMgrImpl().ConfigureBle(LinuxDeviceOptions::GetInstance().mBleDevice, false); #endif diff --git a/src/controller/python/BUILD.gn b/src/controller/python/BUILD.gn index 8c42fb16d5a884..3f483339ae4b48 100644 --- a/src/controller/python/BUILD.gn +++ b/src/controller/python/BUILD.gn @@ -100,6 +100,12 @@ pw_python_action("python") { "chip/ChipStack.py", "chip/ChipUtility.py", "chip/__init__.py", + "chip/ble/__init__.py", + "chip/ble/commissioning/__init__.py", + "chip/ble/get_adapters.py", + "chip/ble/library_handle.py", + "chip/ble/scan_devices.py", + "chip/ble/types.py", "chip/configuration/__init__.py", "chip/exceptions/__init__.py", "chip/internal/__init__.py", @@ -123,22 +129,6 @@ pw_python_action("python") { }, ] - if (chip_enable_ble) { - _py_manifest_files += [ - { - src_dir = "." - sources = [ - "chip/ble/__init__.py", - "chip/ble/commissioning/__init__.py", - "chip/ble/get_adapters.py", - "chip/ble/library_handle.py", - "chip/ble/scan_devices.py", - "chip/ble/types.py", - ] - }, - ] - } - _py_manifest_file = "${target_gen_dir}/${target_name}.py_manifest.json" inputs = [] diff --git a/src/controller/python/build-chip-wheel.py b/src/controller/python/build-chip-wheel.py index cabec7a450ea17..9b038946835c4c 100644 --- a/src/controller/python/build-chip-wheel.py +++ b/src/controller/python/build-chip-wheel.py @@ -126,6 +126,8 @@ def finalize_options(self): # packages=[ 'chip', + 'chip.ble', + 'chip.ble.commissioning', 'chip.configuration', 'chip.exceptions', 'chip.internal', @@ -134,10 +136,6 @@ def finalize_options(self): 'chip.tlv', ] - if os.path.isdir(os.path.join(tmpDir, 'chip', 'ble')): - packages += ['chip.ble'] - packages += ['chip.ble.commissioning'] - # Invoke the setuptools 'bdist_wheel' command to generate a wheel containing # the CHIP python packages, shared libraries and scripts. setup( From 70449a4de56584b8645b85457f72bc0752c09332 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 11 Mar 2021 14:47:35 -0500 Subject: [PATCH 07/39] Fix mac build by including errno.h (#5323) https://github.com/project-chip/connectedhomeip/pull/5228 is using errno but not including the header. --- examples/shell/shell_common/cmd_ping.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/shell/shell_common/cmd_ping.cpp b/examples/shell/shell_common/cmd_ping.cpp index afb21bcaf6859b..adc2a7302ca8b9 100644 --- a/examples/shell/shell_common/cmd_ping.cpp +++ b/examples/shell/shell_common/cmd_ping.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include From 8382413a7e21145fcad910c605fb6e91a35989a8 Mon Sep 17 00:00:00 2001 From: Sagar Dhawan Date: Thu, 11 Mar 2021 12:13:59 -0800 Subject: [PATCH 08/39] Fix default branch name for pigweed (#5325) --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index bc43cb1814727f..0cb36b7aed6680 100644 --- a/.gitmodules +++ b/.gitmodules @@ -29,7 +29,7 @@ [submodule "pigweed"] path = third_party/pigweed/repo url = https://github.com/google/pigweed.git - branch = master + branch = main [submodule "openthread"] path = third_party/openthread/repo url = https://github.com/openthread/openthread.git From a4a102051149d7c5061f17684ac0450a5c72d387 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Thu, 11 Mar 2021 21:25:21 +0100 Subject: [PATCH 09/39] Update Basic Cluster to align with CHIP spec (#5183) * Update Basic Cluster to align with CHIP spec The currently implemented Basic Cluster is pulled unmodified from the ZCL spec and does not align with the CHIP defined Basic Cluster. - update XML - regenerate artifacts issue #2877 Update Basic Cluster to align with CHIP spec * update all except cluster id to match current spec * Fix SoftwareVersion type and UserLabel label * Set basic cluster ID to 0x0028 * Update .zap files * Update the ZAP templates to support writable attributes string * Add support for string types (0x41, 0x42, 0x43, 0x44) in CHIPClientCallbacks * Update the gen/ files Co-authored-by: Kevin Schoedel --- .../all-clusters-common/all-clusters-app.zap | 1393 ++++---- .../gen/CHIPClientCallbacks.cpp | 92 +- .../gen/CHIPClientCallbacks.h | 2 + .../gen/CHIPClustersObjc.h | 34 +- .../gen/CHIPClustersObjc.mm | 397 ++- .../gen/IMClusterCommandHandler.cpp | 5 - .../all-clusters-common/gen/attribute-id.h | 55 +- .../gen/call-command-handler.cpp | 4 - .../all-clusters-common/gen/callback.h | 6 - .../gen/client-command-macro.h | 36 +- .../all-clusters-common/gen/cluster-id.h | 6 +- .../all-clusters-common/gen/command-id.h | 10 +- .../all-clusters-common/gen/endpoint_config.h | 306 +- .../all-clusters-common/gen/print-cluster.h | 14 +- .../bridge-app/bridge-common/bridge-app.zap | 279 +- .../bridge-common/gen/CHIPClientCallbacks.cpp | 92 +- .../bridge-common/gen/CHIPClientCallbacks.h | 2 + .../bridge-common/gen/CHIPClustersObjc.h | 26 +- .../bridge-common/gen/CHIPClustersObjc.mm | 187 +- .../gen/IMClusterCommandHandler.cpp | 27 - .../bridge-common/gen/attribute-id.h | 61 +- .../gen/call-command-handler.cpp | 23 +- .../bridge-app/bridge-common/gen/callback.h | 6 - .../bridge-common/gen/client-command-macro.h | 45 +- .../bridge-app/bridge-common/gen/cluster-id.h | 9 +- .../bridge-app/bridge-common/gen/command-id.h | 13 +- .../bridge-common/gen/endpoint_config.h | 229 +- .../bridge-app/bridge-common/gen/gen_config.h | 2 +- .../bridge-common/gen/print-cluster.h | 21 +- examples/chip-tool/chip-tool.zap | 542 ++-- .../chip-tool/commands/clusters/Commands.h | 454 ++- .../chip-tool/gen/CHIPClientCallbacks.cpp | 92 +- examples/chip-tool/gen/CHIPClientCallbacks.h | 2 + examples/chip-tool/gen/CHIPClustersObjc.h | 34 +- examples/chip-tool/gen/CHIPClustersObjc.mm | 397 ++- examples/chip-tool/gen/attribute-id.h | 55 +- examples/chip-tool/gen/client-command-macro.h | 36 +- examples/chip-tool/gen/cluster-id.h | 6 +- examples/chip-tool/gen/command-id.h | 10 +- examples/chip-tool/gen/endpoint_config.h | 49 +- examples/chip-tool/gen/print-cluster.h | 14 +- examples/chip-tool/templates/commands.zapt | 44 +- examples/chip-tool/templates/helper.js | 86 +- .../gen/CHIPClientCallbacks.cpp | 92 +- .../lighting-common/gen/CHIPClientCallbacks.h | 2 + .../lighting-common/gen/CHIPClustersObjc.h | 23 + .../lighting-common/gen/CHIPClustersObjc.mm | 415 ++- .../lighting-common/gen/attribute-id.h | 61 +- .../gen/call-command-handler.cpp | 5 + .../lighting-common/gen/callback-stub.cpp | 8 + .../lighting-common/gen/callback.h | 76 + .../gen/client-command-macro.h | 45 +- .../lighting-common/gen/cluster-id.h | 9 +- .../lighting-common/gen/command-id.h | 13 +- .../lighting-common/gen/endpoint_config.h | 113 +- .../lighting-common/gen/gen_config.h | 6 + .../lighting-common/gen/print-cluster.h | 21 +- .../lighting-common/lighting-app.zap | 182 +- .../lock-common/gen/CHIPClientCallbacks.cpp | 92 +- .../lock-common/gen/CHIPClientCallbacks.h | 2 + .../lock-common/gen/CHIPClustersObjc.h | 23 + .../lock-common/gen/CHIPClustersObjc.mm | 415 ++- .../lock-app/lock-common/gen/attribute-id.h | 61 +- .../lock-common/gen/call-command-handler.cpp | 5 + .../lock-common/gen/callback-stub.cpp | 8 + examples/lock-app/lock-common/gen/callback.h | 76 + .../lock-common/gen/client-command-macro.h | 45 +- .../lock-app/lock-common/gen/cluster-id.h | 9 +- .../lock-app/lock-common/gen/command-id.h | 13 +- .../lock-common/gen/endpoint_config.h | 103 +- .../lock-app/lock-common/gen/gen_config.h | 6 + .../lock-app/lock-common/gen/print-cluster.h | 21 +- examples/lock-app/lock-common/lock-app.zap | 354 +- .../esp32/main/gen/CHIPClientCallbacks.cpp | 92 +- .../esp32/main/gen/CHIPClientCallbacks.h | 2 + .../esp32/main/gen/CHIPClustersObjc.h | 17 +- .../esp32/main/gen/CHIPClustersObjc.mm | 326 +- .../main/gen/IMClusterCommandHandler.cpp | 27 - .../esp32/main/gen/attribute-id.h | 61 +- .../esp32/main/gen/call-command-handler.cpp | 24 +- .../esp32/main/gen/callback.h | 6 - .../esp32/main/gen/client-command-macro.h | 45 +- .../esp32/main/gen/cluster-id.h | 9 +- .../esp32/main/gen/command-id.h | 13 +- .../esp32/main/gen/endpoint_config.h | 104 +- .../esp32/main/gen/print-cluster.h | 21 +- .../esp32/main/temperature-measurement.zap | 193 +- .../tv-common/gen/CHIPClientCallbacks.cpp | 92 +- .../tv-common/gen/CHIPClientCallbacks.h | 2 + .../tv-app/tv-common/gen/CHIPClustersObjc.h | 45 +- .../tv-app/tv-common/gen/CHIPClustersObjc.mm | 426 ++- .../tv-common/gen/IMClusterCommandHandler.cpp | 27 - examples/tv-app/tv-common/gen/attribute-id.h | 55 +- .../tv-common/gen/call-command-handler.cpp | 23 +- examples/tv-app/tv-common/gen/callback.h | 6 - .../tv-common/gen/client-command-macro.h | 36 +- examples/tv-app/tv-common/gen/cluster-id.h | 6 +- examples/tv-app/tv-common/gen/command-id.h | 10 +- .../tv-app/tv-common/gen/endpoint_config.h | 205 +- examples/tv-app/tv-common/gen/print-cluster.h | 14 +- examples/tv-app/tv-common/tv-app.zap | 185 +- src/app/chip-zcl-zpro-codec-api.h | 120 +- src/app/encoder.cpp | 380 ++- src/app/zap-templates/common/StringHelper.js | 31 +- .../app/CHIPClientCallbacks-src.zapt | 88 +- .../templates/app/CHIPClientCallbacks.zapt | 2 + .../templates/chip/CHIPClusters-src.zapt | 2 +- .../templates/chip/CHIPClusters.zapt | 2 +- .../templates/chip/CHIPClustersObjc-src.zapt | 88 +- .../templates/chip/CHIPClustersObjc.zapt | 4 +- .../chip/chip-zcl-zpro-codec-api.zapt | 2 +- .../templates/chip/encoder-src.zapt | 39 +- .../zap-templates/templates/chip/helper.js | 50 +- ...-ChipDeviceController-ClusterCommands.zapt | 4 +- .../chip/python-chip-ChipCluster.zapt | 4 +- .../zcl/application-basic-cluster.xml | 6 +- .../zap-templates/zcl/clusters-extensions.xml | 2 +- .../zcl/data-model/silabs/general.xml | 50 +- .../zcl/data-model/silabs/ta.xml | 2 +- src/controller/CHIPClusters.cpp | 127 +- src/controller/CHIPClusters.h | 44 +- src/controller/controller-clusters.zap | 787 ++--- .../ChipDeviceController-ClusterCommands.cpp | 47 +- src/controller/python/chip/ChipCluster.py | 76 +- src/darwin/Framework/CHIP/chip-tool.zap | 1195 +++++-- .../CHIP/gen/CHIPClientCallbacks.cpp | 160 +- .../Framework/CHIP/gen/CHIPClientCallbacks.h | 9 + .../Framework/CHIP/gen/CHIPClustersObjc.h | 122 +- .../Framework/CHIP/gen/CHIPClustersObjc.mm | 2863 ++++++++++++----- .../CHIP/gen/IMClusterCommandHandler.cpp | 204 ++ src/darwin/Framework/CHIP/gen/attribute-id.h | 55 +- .../CHIP/gen/call-command-handler.cpp | 160 + .../Framework/CHIP/gen/callback-stub.cpp | 40 + src/darwin/Framework/CHIP/gen/callback.h | 436 +++ .../Framework/CHIP/gen/client-command-macro.h | 36 +- src/darwin/Framework/CHIP/gen/cluster-id.h | 6 +- src/darwin/Framework/CHIP/gen/command-id.h | 10 +- .../Framework/CHIP/gen/endpoint_config.h | 120 +- src/darwin/Framework/CHIP/gen/gen_config.h | 25 + src/darwin/Framework/CHIP/gen/print-cluster.h | 14 +- 140 files changed, 12834 insertions(+), 4157 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 49f08bd885a779..1bf684669b1ab8 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -1,5 +1,5 @@ { - "writeTime": "Mon Mar 08 2021 19:19:42 GMT+0100 (Central European Standard Time)", + "writeTime": "Thu Mar 11 2021 17:27:52 GMT+0100 (Central European Standard Time)", "featureLevel": 11, "creator": "zap", "keyValuePairs": [ @@ -38,103 +38,30 @@ "deviceTypeProfileId": null, "clusters": [ { - "name": "Basic", - "code": 0, + "name": "Identify", + "code": 3, "mfgCode": null, - "define": "BASIC_CLUSTER", + "define": "IDENTIFY_CLUSTER", "side": "client", "enabled": 0, "commands": [ { - "name": "ResetToFactoryDefaults", + "name": "Identify", "code": 0, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 1 - } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Basic", - "code": 0, - "mfgCode": null, - "define": "BASIC_CLUSTER", - "side": "server", - "enabled": 1, - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ZCL version", - "code": 0, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x08", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 }, { - "name": "power source", - "code": 7, + "name": "IdentifyQuery", + "code": 1, "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 + "source": "client", + "incoming": 1, + "outgoing": 1 } ], - "commands": [] - }, - { - "name": "Identify", - "code": 3, - "mfgCode": null, - "define": "IDENTIFY_CLUSTER", - "side": "client", - "enabled": 0, "attributes": [ { "name": "cluster revision", @@ -151,24 +78,6 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [ - { - "name": "Identify", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "IdentifyQuery", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } ] }, { @@ -228,6 +137,23 @@ "define": "GROUPS_CLUSTER", "side": "client", "enabled": 0, + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], "commands": [ { "name": "AddGroup", @@ -277,23 +203,6 @@ "incoming": 1, "outgoing": 1 } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } ] }, { @@ -303,38 +212,6 @@ "define": "GROUPS_CLUSTER", "side": "server", "enabled": 0, - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "name support", - "code": 0, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ], "commands": [ { "name": "AddGroupResponse", @@ -368,6 +245,38 @@ "incoming": 1, "outgoing": 1 } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "name support", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } ] }, { @@ -460,6 +369,56 @@ "define": "SCENES_CLUSTER", "side": "server", "enabled": 0, + "commands": [ + { + "name": "AddSceneResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ViewSceneResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveSceneResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveAllScenesResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "StoreSceneResponse", + "code": 4, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetSceneMembershipResponse", + "code": 6, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], "attributes": [ { "name": "cluster revision", @@ -551,56 +510,6 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [ - { - "name": "AddSceneResponse", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "ViewSceneResponse", - "code": 1, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "RemoveSceneResponse", - "code": 2, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "RemoveAllScenesResponse", - "code": 3, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "StoreSceneResponse", - "code": 4, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "GetSceneMembershipResponse", - "code": 6, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - } ] }, { @@ -702,23 +611,6 @@ "define": "LEVEL_CONTROL_CLUSTER", "side": "client", "enabled": 0, - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ], "commands": [ { "name": "MoveToLevel", @@ -784,6 +676,23 @@ "incoming": 1, "outgoing": 1 } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } ] }, { @@ -796,31 +705,273 @@ "commands": [], "attributes": [ { - "name": "cluster revision", - "code": 65533, + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "current level", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "StartUp", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ShutDown", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "Leave", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "InteractionModelVersion", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorName", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorID", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductName", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductID", + "code": 4, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UserLabel", + "code": 5, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Location", + "code": 6, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersion", + "code": 7, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersionString", + "code": 8, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersion", + "code": 9, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "3", + "defaultValue": "0x00", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "current level", - "code": 0, + "name": "SoftwareVersionString", + "code": 10, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, + "defaultValue": "", + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -834,23 +985,6 @@ "define": "DOOR_LOCK_CLUSTER", "side": "client", "enabled": 0, - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ], "commands": [ { "name": "LockDoor", @@ -1036,6 +1170,23 @@ "incoming": 1, "outgoing": 1 } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } ] }, { @@ -1045,6 +1196,24 @@ "define": "DOOR_LOCK_CLUSTER", "side": "server", "enabled": 0, + "commands": [ + { + "name": "LockDoorResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "UnlockDoorResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], "attributes": [ { "name": "cluster revision", @@ -1481,33 +1650,33 @@ "maxInterval": 65344, "reportableChange": 0 } - ], + ] + }, + { + "name": "Barrier Control", + "code": 259, + "mfgCode": null, + "define": "BARRIER_CONTROL_CLUSTER", + "side": "client", + "enabled": 0, "commands": [ { - "name": "LockDoorResponse", + "name": "BarrierControlGoToPercent", "code": 0, "mfgCode": null, - "source": "server", + "source": "client", "incoming": 1, "outgoing": 1 }, { - "name": "UnlockDoorResponse", + "name": "BarrierControlStop", "code": 1, "mfgCode": null, - "source": "server", + "source": "client", "incoming": 1, "outgoing": 1 } - ] - }, - { - "name": "Barrier Control", - "code": 259, - "mfgCode": null, - "define": "BARRIER_CONTROL_CLUSTER", - "side": "client", - "enabled": 0, + ], "attributes": [ { "name": "cluster revision", @@ -1524,24 +1693,6 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [ - { - "name": "BarrierControlGoToPercent", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "BarrierControlStop", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } ] }, { @@ -1637,23 +1788,6 @@ "define": "COLOR_CONTROL_CLUSTER", "side": "client", "enabled": 0, - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ], "commands": [ { "name": "MoveToHue", @@ -1767,6 +1901,23 @@ "incoming": 1, "outgoing": 1 } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } ] }, { @@ -2818,105 +2969,6 @@ "deviceTypeCode": 0, "deviceTypeProfileId": 259, "clusters": [ - { - "name": "Basic", - "code": 0, - "mfgCode": null, - "define": "BASIC_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [ - { - "name": "ResetToFactoryDefaults", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "MfgSpecificPing", - "code": 0, - "mfgCode": "4098", - "source": "client", - "incoming": 1, - "outgoing": 0 - } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Basic", - "code": 0, - "mfgCode": null, - "define": "BASIC_CLUSTER", - "side": "server", - "enabled": 1, - "commands": [], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ZCL version", - "code": 0, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x08", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "power source", - "code": 7, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, { "name": "Identify", "code": 3, @@ -2961,22 +3013,12 @@ ] }, { - "name": "Identify", - "code": 3, - "mfgCode": null, - "define": "IDENTIFY_CLUSTER", - "side": "server", - "enabled": 1, - "commands": [ - { - "name": "IdentifyQueryResponse", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - } - ], + "name": "Identify", + "code": 3, + "mfgCode": null, + "define": "IDENTIFY_CLUSTER", + "side": "server", + "enabled": 1, "attributes": [ { "name": "cluster revision", @@ -3008,6 +3050,16 @@ "maxInterval": 65344, "reportableChange": 0 } + ], + "commands": [ + { + "name": "IdentifyQueryResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } ] }, { @@ -3017,6 +3069,23 @@ "define": "GROUPS_CLUSTER", "side": "client", "enabled": 0, + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], "commands": [ { "name": "AddGroup", @@ -3066,23 +3135,6 @@ "incoming": 1, "outgoing": 1 } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } ] }, { @@ -3517,104 +3569,355 @@ "outgoing": 1 }, { - "name": "Stop", + "name": "Stop", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "MoveToLevelWithOnOff", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "MoveWithOnOff", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "StepWithOnOff", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "StopWithOnOff", + "code": 7, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Level Control", + "code": 8, + "mfgCode": null, + "define": "LEVEL_CONTROL_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "current level", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "MfgSpecificPing", + "code": 0, + "mfgCode": "4098", + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "StartUp", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ShutDown", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "Leave", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "InteractionModelVersion", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorName", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorID", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductName", "code": 3, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 }, { - "name": "MoveToLevelWithOnOff", + "name": "ProductID", "code": 4, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 }, { - "name": "MoveWithOnOff", + "name": "UserLabel", "code": 5, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 }, { - "name": "StepWithOnOff", + "name": "Location", "code": 6, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 }, { - "name": "StopWithOnOff", + "name": "HardwareVersion", "code": 7, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } - ], - "attributes": [ + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, { - "name": "cluster revision", - "code": 65533, + "name": "HardwareVersionString", + "code": 8, "mfgCode": null, - "side": "client", + "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "3", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - } - ] - }, - { - "name": "Level Control", - "code": 8, - "mfgCode": null, - "define": "LEVEL_CONTROL_CLUSTER", - "side": "server", - "enabled": 1, - "attributes": [ + }, { - "name": "cluster revision", - "code": 65533, + "name": "SoftwareVersion", + "code": 9, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "3", + "defaultValue": "0x00", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "current level", - "code": 0, + "name": "SoftwareVersionString", + "code": 10, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, + "defaultValue": "", + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [] + ] }, { "name": "General Commissioning", @@ -3755,23 +4058,6 @@ "define": "DOOR_LOCK_CLUSTER", "side": "client", "enabled": 0, - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ], "commands": [ { "name": "LockDoor", @@ -3957,6 +4243,23 @@ "incoming": 1, "outgoing": 1 } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } ] }, { @@ -4558,23 +4861,6 @@ "define": "COLOR_CONTROL_CLUSTER", "side": "client", "enabled": 0, - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ], "commands": [ { "name": "MoveToHue", @@ -4688,6 +4974,23 @@ "incoming": 1, "outgoing": 1 } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } ] }, { @@ -5473,6 +5776,7 @@ "define": "TEMP_MEASUREMENT_CLUSTER", "side": "client", "enabled": 0, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -5489,8 +5793,7 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [] + ] }, { "name": "Temperature Measurement", @@ -5620,6 +5923,24 @@ "define": "IAS_ZONE_CLUSTER", "side": "server", "enabled": 1, + "commands": [ + { + "name": "ZoneStatusChangeNotification", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ZoneEnrollRequest", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], "attributes": [ { "name": "cluster revision", @@ -5711,24 +6032,6 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [ - { - "name": "ZoneStatusChangeNotification", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "ZoneEnrollRequest", - "code": 1, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - } ] }, { @@ -6225,23 +6528,6 @@ "define": "CONTENT_LAUNCH_CLUSTER", "side": "server", "enabled": 1, - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0001", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ], "commands": [ { "name": "LaunchContentResponse", @@ -6259,6 +6545,23 @@ "incoming": 1, "outgoing": 1 } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } ] } ] diff --git a/examples/all-clusters-app/all-clusters-common/gen/CHIPClientCallbacks.cpp b/examples/all-clusters-app/all-clusters-common/gen/CHIPClientCallbacks.cpp index f5f88af110c2c7..fc5ea3b1b8a7c6 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/CHIPClientCallbacks.cpp +++ b/examples/all-clusters-app/all-clusters-common/gen/CHIPClientCallbacks.cpp @@ -272,10 +272,6 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag case 0x38: // semi / Semi-precision case 0x39: // single / Single precision case 0x3A: // double / Double precision - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string case 0x48: // array / Array case 0x49: // struct / Structure case 0x50: // set / Set @@ -289,6 +285,48 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag return true; } + case 0x41: // octstr / Octet string + case 0x42: // string / Character string + { + // Short Strings must contains at least one byte for the length + CHECK_MESSAGE_LENGTH(1); + uint8_t length = chip::Encoding::Read8(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + + case 0x43: // octstr16 / Long octet string + case 0x44: // string16 / Long character string + { + // Long Strings must contains at least two bytes for the length + CHECK_MESSAGE_LENGTH(2); + uint16_t length = chip::Encoding::LittleEndian::Read16(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFFFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFFFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + case 0x08: // data8 / 8-bit data case 0x18: // map8 / 8-bit bitmap case 0x20: // uint8 / Unsigned 8-bit integer @@ -696,10 +734,6 @@ bool emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * message, uin case 0x38: // semi / Semi-precision case 0x39: // single / Single precision case 0x3A: // double / Double precision - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string case 0x48: // array / Array case 0x49: // struct / Structure case 0x50: // set / Set @@ -710,6 +744,48 @@ bool emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * message, uin return true; } + case 0x41: // octstr / Octet string + case 0x42: // string / Character string + { + // Short Strings must contains at least one byte for the length + CHECK_MESSAGE_LENGTH(1); + uint8_t length = chip::Encoding::Read8(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onReportCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + + case 0x43: // octstr16 / Long octet string + case 0x44: // string16 / Long character string + { + // Long Strings must contains at least two bytes for the length + CHECK_MESSAGE_LENGTH(2); + uint16_t length = chip::Encoding::LittleEndian::Read16(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFFFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFFFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onReportCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + case 0x08: // data8 / 8-bit data case 0x18: // map8 / 8-bit bitmap case 0x20: // uint8 / Unsigned 8-bit integer diff --git a/examples/all-clusters-app/all-clusters-common/gen/CHIPClientCallbacks.h b/examples/all-clusters-app/all-clusters-common/gen/CHIPClientCallbacks.h index 14a3742f090e8f..d028079f799d79 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/CHIPClientCallbacks.h +++ b/examples/all-clusters-app/all-clusters-common/gen/CHIPClientCallbacks.h @@ -20,6 +20,7 @@ #pragma once #include +#include // Global Response Callbacks typedef void (*DefaultSuccessCallback)(void * context); @@ -33,6 +34,7 @@ typedef void (*Int32uAttributeCallback)(void * context, uint32_t value); typedef void (*Int32sAttributeCallback)(void * context, int32_t value); typedef void (*Int64uAttributeCallback)(void * context, uint64_t value); typedef void (*Int64sAttributeCallback)(void * context, int64_t value); +typedef void (*StringAttributeCallback)(void * context, const chip::ByteSpan value); typedef void (*ReadReportingConfigurationReportedCallback)(void * context, uint16_t minInterval, uint16_t maxInterval); typedef void (*ReadReportingConfigurationReceivedCallback)(void * context, uint16_t timeout); diff --git a/examples/all-clusters-app/all-clusters-common/gen/CHIPClustersObjc.h b/examples/all-clusters-app/all-clusters-common/gen/CHIPClustersObjc.h index 2060cb3e7bfdb9..f518ac99918a2d 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/CHIPClustersObjc.h +++ b/examples/all-clusters-app/all-clusters-common/gen/CHIPClustersObjc.h @@ -83,10 +83,20 @@ NS_ASSUME_NONNULL_BEGIN @interface CHIPBasic : CHIPCluster - (void)mfgSpecificPing:(ResponseHandler)completionHandler; -- (void)resetToFactoryDefaults:(ResponseHandler)completionHandler; -- (void)readAttributeZclVersion:(ResponseHandler)completionHandler; -- (void)readAttributePowerSource:(ResponseHandler)completionHandler; +- (void)readAttributeInteractionModelVersion:(ResponseHandler)completionHandler; +- (void)readAttributeVendorName:(ResponseHandler)completionHandler; +- (void)readAttributeVendorID:(ResponseHandler)completionHandler; +- (void)readAttributeProductName:(ResponseHandler)completionHandler; +- (void)readAttributeProductID:(ResponseHandler)completionHandler; +- (void)readAttributeUserLabel:(ResponseHandler)completionHandler; +- (void)writeAttributeUserLabel:(NSString *)value completionHandler:(ResponseHandler)completionHandler; +- (void)readAttributeLocation:(ResponseHandler)completionHandler; +- (void)writeAttributeLocation:(NSString *)value completionHandler:(ResponseHandler)completionHandler; +- (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler; +- (void)readAttributeHardwareVersionString:(ResponseHandler)completionHandler; +- (void)readAttributeSoftwareVersion:(ResponseHandler)completionHandler; +- (void)readAttributeSoftwareVersionString:(ResponseHandler)completionHandler; - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler; @end @@ -323,7 +333,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)getUserType:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler; - (void)getWeekdaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler; - (void)getYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler; -- (void)lockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandler; +- (void)lockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHandler; - (void)setHolidaySchedule:(uint8_t)scheduleId localStartTime:(uint32_t)localStartTime localEndTime:(uint32_t)localEndTime @@ -332,12 +342,12 @@ NS_ASSUME_NONNULL_BEGIN - (void)setPin:(uint16_t)userId userStatus:(uint8_t)userStatus userType:(uint8_t)userType - pin:(char *)pin + pin:(NSString *)pin completionHandler:(ResponseHandler)completionHandler; - (void)setRfid:(uint16_t)userId userStatus:(uint8_t)userStatus userType:(uint8_t)userType - id:(char *)id + id:(NSString *)id completionHandler:(ResponseHandler)completionHandler; - (void)setUserType:(uint16_t)userId userType:(uint8_t)userType completionHandler:(ResponseHandler)completionHandler; - (void)setWeekdaySchedule:(uint8_t)scheduleId @@ -353,8 +363,8 @@ NS_ASSUME_NONNULL_BEGIN localStartTime:(uint32_t)localStartTime localEndTime:(uint32_t)localEndTime completionHandler:(ResponseHandler)completionHandler; -- (void)unlockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandler; -- (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(char *)pin completionHandler:(ResponseHandler)completionHandler; +- (void)unlockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHandler; +- (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(NSString *)pin completionHandler:(ResponseHandler)completionHandler; - (void)readAttributeLockState:(ResponseHandler)completionHandler; - (void)configureAttributeLockState:(uint16_t)minInterval @@ -397,8 +407,10 @@ NS_ASSUME_NONNULL_BEGIN */ @interface CHIPGroups : CHIPCluster -- (void)addGroup:(uint16_t)groupId groupName:(char *)groupName completionHandler:(ResponseHandler)completionHandler; -- (void)addGroupIfIdentifying:(uint16_t)groupId groupName:(char *)groupName completionHandler:(ResponseHandler)completionHandler; +- (void)addGroup:(uint16_t)groupId groupName:(NSString *)groupName completionHandler:(ResponseHandler)completionHandler; +- (void)addGroupIfIdentifying:(uint16_t)groupId + groupName:(NSString *)groupName + completionHandler:(ResponseHandler)completionHandler; - (void)getGroupMembership:(uint8_t)groupCount groupList:(uint16_t)groupList completionHandler:(ResponseHandler)completionHandler; - (void)removeAllGroups:(ResponseHandler)completionHandler; - (void)removeGroup:(uint16_t)groupId completionHandler:(ResponseHandler)completionHandler; @@ -545,7 +557,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)addScene:(uint16_t)groupId sceneId:(uint8_t)sceneId transitionTime:(uint16_t)transitionTime - sceneName:(char *)sceneName + sceneName:(NSString *)sceneName clusterId:(uint16_t)clusterId length:(uint8_t)length value:(uint8_t)value diff --git a/examples/all-clusters-app/all-clusters-common/gen/CHIPClustersObjc.mm b/examples/all-clusters-app/all-clusters-common/gen/CHIPClustersObjc.mm index 4651649bf3207f..48568b1104c636 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/CHIPClustersObjc.mm +++ b/examples/all-clusters-app/all-clusters-common/gen/CHIPClustersObjc.mm @@ -89,26 +89,38 @@ static void CallbackFn(void * context, uint8_t status) dispatch_queue_t mQueue; }; -class CHIPUnsupportedAttributeCallbackBridge : public Callback::Callback { +class CHIPStringAttributeCallbackBridge : public Callback::Callback { public: - CHIPUnsupportedAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) - : Callback::Callback(CallbackFn, this) + CHIPStringAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool octetString, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mOctetString(octetString) + , mKeepAlive(keepAlive) { } - ~CHIPUnsupportedAttributeCallbackBridge() {}; + ~CHIPStringAttributeCallbackBridge() {}; - static void CallbackFn(void * context) + static void CallbackFn(void * context, chip::ByteSpan value) { - CHIPUnsupportedAttributeCallbackBridge * callback = reinterpret_cast(context); + CHIPStringAttributeCallbackBridge * callback = reinterpret_cast(context); if (callback && callback->mQueue) { dispatch_async(callback->mQueue, ^{ - NSError * error = [NSError errorWithDomain:CHIPErrorDomain - code:CHIPErrorCodeUndefinedError - userInfo:@ { NSLocalizedDescriptionKey : @"Unsupported attribute type" }]; - callback->mHandler(error, nil); - callback->Cancel(); - delete callback; + if (callback->mOctetString) { + NSData * data = [NSData dataWithBytes:value.data() length:value.size()]; + callback->mHandler(nil, @ { @"value" : data }); + } else { + NSString * str = [[NSString alloc] initWithBytes:value.data() + length:value.size() + encoding:NSUTF8StringEncoding]; + callback->mHandler(nil, @ { @"value" : str }); + } + + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } }); } }; @@ -116,6 +128,8 @@ static void CallbackFn(void * context) private: ResponseHandler mHandler; dispatch_queue_t mQueue; + bool mOctetString; + bool mKeepAlive; }; class CHIPBooleanAttributeCallbackBridge : public Callback::Callback { @@ -246,6 +260,38 @@ static void CallbackFn(void * context, uint16_t value) bool mKeepAlive; }; +class CHIPInt32uAttributeCallbackBridge : public Callback::Callback { +public: + CHIPInt32uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mKeepAlive(keepAlive) + { + } + + ~CHIPInt32uAttributeCallbackBridge() {}; + + static void CallbackFn(void * context, uint32_t value) + { + CHIPInt32uAttributeCallbackBridge * callback = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedLong:value] }); + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; + bool mKeepAlive; +}; + class CHIPInt16sAttributeCallbackBridge : public Callback::Callback { public: CHIPInt16sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) @@ -321,8 +367,8 @@ @implementation CHIPApplicationBasic - (void)readAttributeVendorName:(ResponseHandler)completionHandler { - CHIPUnsupportedAttributeCallbackBridge * onSuccess - = new CHIPUnsupportedAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], true); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -368,8 +414,8 @@ - (void)readAttributeVendorId:(ResponseHandler)completionHandler - (void)readAttributeApplicationName:(ResponseHandler)completionHandler { - CHIPUnsupportedAttributeCallbackBridge * onSuccess - = new CHIPUnsupportedAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], true); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -415,8 +461,8 @@ - (void)readAttributeProductId:(ResponseHandler)completionHandler - (void)readAttributeApplicationId:(ResponseHandler)completionHandler { - CHIPUnsupportedAttributeCallbackBridge * onSuccess - = new CHIPUnsupportedAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], true); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -714,7 +760,149 @@ - (void)mfgSpecificPing:(ResponseHandler)completionHandler completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)resetToFactoryDefaults:(ResponseHandler)completionHandler + +- (void)readAttributeInteractionModelVersion:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeInteractionModelVersion(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeVendorName:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeVendorID:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeVendorID(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeProductName:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeProductName(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeProductID:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeProductID(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeUserLabel:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeUserLabel(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)writeAttributeUserLabel:(NSString *)value completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -729,7 +917,9 @@ - (void)resetToFactoryDefaults:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ResetToFactoryDefaults(onSuccess->Cancel(), onFailure->Cancel()); + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + CHIP_ERROR err = self.cppCluster.WriteAttributeUserLabel( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -737,9 +927,10 @@ - (void)resetToFactoryDefaults:(ResponseHandler)completionHandler } } -- (void)readAttributeZclVersion:(ResponseHandler)completionHandler +- (void)readAttributeLocation:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -752,7 +943,7 @@ - (void)readAttributeZclVersion:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeZclVersion(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeLocation(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -760,9 +951,105 @@ - (void)readAttributeZclVersion:(ResponseHandler)completionHandler } } -- (void)readAttributePowerSource:(ResponseHandler)completionHandler +- (void)writeAttributeLocation:(NSString *)value completionHandler:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + CHIP_ERROR err = self.cppCluster.WriteAttributeLocation( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeHardwareVersionString:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeSoftwareVersion:(ResponseHandler)completionHandler +{ + CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeSoftwareVersionString:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -775,7 +1062,7 @@ - (void)readAttributePowerSource:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePowerSource(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1603,8 +1890,8 @@ - (void)readAttributeDriftCompensation:(ResponseHandler)completionHandler - (void)readAttributeCompensationText:(ResponseHandler)completionHandler { - CHIPUnsupportedAttributeCallbackBridge * onSuccess - = new CHIPUnsupportedAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3382,7 +3669,7 @@ - (void)getYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completio completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)lockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandler +- (void)lockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHandler { CHIPDoorLockClusterLockDoorResponseCallbackBridge * onSuccess = new CHIPDoorLockClusterLockDoorResponseCallbackBridge(completionHandler, [self callbackQueue]); @@ -3398,7 +3685,9 @@ - (void)lockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandle return; } - CHIP_ERROR err = self.cppCluster.LockDoor(onSuccess->Cancel(), onFailure->Cancel(), pin); + CHIP_ERROR err = self.cppCluster.LockDoor(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3435,7 +3724,7 @@ - (void)setHolidaySchedule:(uint8_t)scheduleId - (void)setPin:(uint16_t)userId userStatus:(uint8_t)userStatus userType:(uint8_t)userType - pin:(char *)pin + pin:(NSString *)pin completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); @@ -3451,7 +3740,9 @@ - (void)setPin:(uint16_t)userId return; } - CHIP_ERROR err = self.cppCluster.SetPin(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, pin); + CHIP_ERROR err = self.cppCluster.SetPin(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3461,7 +3752,7 @@ - (void)setPin:(uint16_t)userId - (void)setRfid:(uint16_t)userId userStatus:(uint8_t)userStatus userType:(uint8_t)userType - id:(char *)id + id:(NSString *)id completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); @@ -3477,7 +3768,9 @@ - (void)setRfid:(uint16_t)userId return; } - CHIP_ERROR err = self.cppCluster.SetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, id); + CHIP_ERROR err = self.cppCluster.SetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, + chip::ByteSpan((const uint8_t *) [id dataUsingEncoding:NSUTF8StringEncoding].bytes, + [id lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3563,7 +3856,7 @@ - (void)setYeardaySchedule:(uint8_t)scheduleId completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)unlockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandler +- (void)unlockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHandler { CHIPDoorLockClusterUnlockDoorResponseCallbackBridge * onSuccess = new CHIPDoorLockClusterUnlockDoorResponseCallbackBridge(completionHandler, [self callbackQueue]); @@ -3579,14 +3872,16 @@ - (void)unlockDoor:(char *)pin completionHandler:(ResponseHandler)completionHand return; } - CHIP_ERROR err = self.cppCluster.UnlockDoor(onSuccess->Cancel(), onFailure->Cancel(), pin); + CHIP_ERROR err = self.cppCluster.UnlockDoor(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(char *)pin completionHandler:(ResponseHandler)completionHandler +- (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(NSString *)pin completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -3601,7 +3896,9 @@ - (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(char *)pin completionH return; } - CHIP_ERROR err = self.cppCluster.UnlockWithTimeout(onSuccess->Cancel(), onFailure->Cancel(), timeoutInSeconds, pin); + CHIP_ERROR err = self.cppCluster.UnlockWithTimeout(onSuccess->Cancel(), onFailure->Cancel(), timeoutInSeconds, + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3838,8 +4135,8 @@ - (void)setFabric:(NSData *)fabricId - (void)readAttributeFabricId:(ResponseHandler)completionHandler { - CHIPUnsupportedAttributeCallbackBridge * onSuccess - = new CHIPUnsupportedAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], true); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3942,7 +4239,7 @@ @implementation CHIPGroups return &_cppCluster; } -- (void)addGroup:(uint16_t)groupId groupName:(char *)groupName completionHandler:(ResponseHandler)completionHandler +- (void)addGroup:(uint16_t)groupId groupName:(NSString *)groupName completionHandler:(ResponseHandler)completionHandler { CHIPGroupsClusterAddGroupResponseCallbackBridge * onSuccess = new CHIPGroupsClusterAddGroupResponseCallbackBridge(completionHandler, [self callbackQueue]); @@ -3958,14 +4255,16 @@ - (void)addGroup:(uint16_t)groupId groupName:(char *)groupName completionHandler return; } - CHIP_ERROR err = self.cppCluster.AddGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId, groupName); + CHIP_ERROR err = self.cppCluster.AddGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId, + chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes, + [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)addGroupIfIdentifying:(uint16_t)groupId groupName:(char *)groupName completionHandler:(ResponseHandler)completionHandler +- (void)addGroupIfIdentifying:(uint16_t)groupId groupName:(NSString *)groupName completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -3980,7 +4279,9 @@ - (void)addGroupIfIdentifying:(uint16_t)groupId groupName:(char *)groupName comp return; } - CHIP_ERROR err = self.cppCluster.AddGroupIfIdentifying(onSuccess->Cancel(), onFailure->Cancel(), groupId, groupName); + CHIP_ERROR err = self.cppCluster.AddGroupIfIdentifying(onSuccess->Cancel(), onFailure->Cancel(), groupId, + chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes, + [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5248,7 +5549,7 @@ @implementation CHIPScenes - (void)addScene:(uint16_t)groupId sceneId:(uint8_t)sceneId transitionTime:(uint16_t)transitionTime - sceneName:(char *)sceneName + sceneName:(NSString *)sceneName clusterId:(uint16_t)clusterId length:(uint8_t)length value:(uint8_t)value @@ -5268,8 +5569,10 @@ - (void)addScene:(uint16_t)groupId return; } - CHIP_ERROR err = self.cppCluster.AddScene( - onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime, sceneName, clusterId, length, value); + CHIP_ERROR err = self.cppCluster.AddScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime, + chip::ByteSpan((const uint8_t *) [sceneName dataUsingEncoding:NSUTF8StringEncoding].bytes, + [sceneName lengthOfBytesUsingEncoding:NSUTF8StringEncoding]), + clusterId, length, value); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; diff --git a/examples/all-clusters-app/all-clusters-common/gen/IMClusterCommandHandler.cpp b/examples/all-clusters-app/all-clusters-common/gen/IMClusterCommandHandler.cpp index 419f6f93e19f53..fd7bc5747c3040 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/IMClusterCommandHandler.cpp +++ b/examples/all-clusters-app/all-clusters-common/gen/IMClusterCommandHandler.cpp @@ -96,11 +96,6 @@ void DispatchServerCommand(app::Command * command, CommandId commandId, Endpoint { switch (commandId) { - case ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID: { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - emberAfBasicClusterResetToFactoryDefaultsCallback(); - break; - } default: { // Unrecognized command ID, error status will apply. // TODO: Encode response for command not found diff --git a/examples/all-clusters-app/all-clusters-common/gen/attribute-id.h b/examples/all-clusters-app/all-clusters-common/gen/attribute-id.h index 3ab0310a83cce7..8c8757f826ca7f 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/attribute-id.h +++ b/examples/all-clusters-app/all-clusters-common/gen/attribute-id.h @@ -26,30 +26,6 @@ #define ZCL_REPORTING_STATUS_CLIENT_ATTRIBUTE_ID (0xFFFE) #define ZCL_REPORTING_STATUS_SERVER_ATTRIBUTE_ID (0xFFFE) -// Attribute ids for cluster: Basic - -// Client attributes - -// Server attributes -#define ZCL_VERSION_ATTRIBUTE_ID (0x0000) -#define ZCL_APPLICATION_VERSION_ATTRIBUTE_ID (0x0001) -#define ZCL_STACK_VERSION_ATTRIBUTE_ID (0x0002) -#define ZCL_HW_VERSION_ATTRIBUTE_ID (0x0003) -#define ZCL_MANUFACTURER_NAME_ATTRIBUTE_ID (0x0004) -#define ZCL_MODEL_IDENTIFIER_ATTRIBUTE_ID (0x0005) -#define ZCL_DATE_CODE_ATTRIBUTE_ID (0x0006) -#define ZCL_POWER_SOURCE_ATTRIBUTE_ID (0x0007) -#define ZCL_GENERIC_DEVICE_CLASS_ATTRIBUTE_ID (0x0008) -#define ZCL_GENERIC_DEVICE_TYPE_ATTRIBUTE_ID (0x0009) -#define ZCL_PRODUCT_CODE_ATTRIBUTE_ID (0x000A) -#define ZCL_PRODUCT_URL_ATTRIBUTE_ID (0x000B) -#define ZCL_LOCATION_DESCRIPTION_ATTRIBUTE_ID (0x0010) -#define ZCL_PHYSICAL_ENVIRONMENT_ATTRIBUTE_ID (0x0011) -#define ZCL_DEVICE_ENABLED_ATTRIBUTE_ID (0x0012) -#define ZCL_ALARM_MASK_ATTRIBUTE_ID (0x0013) -#define ZCL_DISABLE_LOCAL_CONFIG_ATTRIBUTE_ID (0x0014) -#define ZCL_SW_BUILD_ID_ATTRIBUTE_ID (0x4000) - // Attribute ids for cluster: Power Configuration // Client attributes @@ -384,6 +360,29 @@ #define ZCL_KEEPALIVE_BASE_ATTRIBUTE_ID (0x0000) #define ZCL_KEEPALIVE_JITTER_ATTRIBUTE_ID (0x0001) +// Attribute ids for cluster: Basic + +// Client attributes + +// Server attributes +#define ZCL_INTERACTION_MODEL_VERSION_ATTRIBUTE_ID (0x0000) +#define ZCL_VENDOR_NAME_ATTRIBUTE_ID (0x0001) +#define ZCL_VENDOR_ID_ATTRIBUTE_ID (0x0002) +#define ZCL_PRODUCT_NAME_ATTRIBUTE_ID (0x0003) +#define ZCL_PRODUCT_ID_ATTRIBUTE_ID (0x0004) +#define ZCL_USER_LABEL_ATTRIBUTE_ID (0x0005) +#define ZCL_LOCATION_ATTRIBUTE_ID (0x0006) +#define ZCL_HARDWARE_VERSION_ATTRIBUTE_ID (0x0007) +#define ZCL_HARDWARE_VERSION_STRING_ATTRIBUTE_ID (0x0008) +#define ZCL_SOFTWARE_VERSION_ATTRIBUTE_ID (0x0009) +#define ZCL_SOFTWARE_VERSION_STRING_ATTRIBUTE_ID (0x000A) +#define ZCL_MANUFACTURING_DATE_ATTRIBUTE_ID (0x000B) +#define ZCL_PART_NUMBER_ATTRIBUTE_ID (0x000C) +#define ZCL_PRODUCT_URL_ATTRIBUTE_ID (0x000D) +#define ZCL_PRODUCT_LABEL_ATTRIBUTE_ID (0x000E) +#define ZCL_SERIAL_NUMBER_ATTRIBUTE_ID (0x000F) +#define ZCL_LOCAL_CONFIG_DISABLED_ATTRIBUTE_ID (0x0010) + // Attribute ids for cluster: General Commissioning // Client attributes @@ -1104,10 +1103,10 @@ // Client attributes // Server attributes -#define ZCL_VENDOR_NAME_ATTRIBUTE_ID (0x0000) -#define ZCL_VENDOR_ID_ATTRIBUTE_ID (0x0001) +#define ZCL_APPLICATION_VENDOR_NAME_ATTRIBUTE_ID (0x0000) +#define ZCL_APPLICATION_VENDOR_ID_ATTRIBUTE_ID (0x0001) #define ZCL_APPLICATION_NAME_ATTRIBUTE_ID (0x0002) -#define ZCL_PRODUCT_ID_ATTRIBUTE_ID (0x0003) +#define ZCL_APPLICATION_PRODUCT_ID_ATTRIBUTE_ID (0x0003) #define ZCL_APPLICATION_ID_ATTRIBUTE_ID (0x0005) #define ZCL_CATALOG_VENDOR_ID_ATTRIBUTE_ID (0x0006) #define ZCL_APPLICATION_STATUS_ATTRIBUTE_ID (0x0007) @@ -3839,7 +3838,7 @@ #define ZCL_PRICE_TRAILING_DIGIT_ATTRIBUTE_ID (0x0021) #define ZCL_PRICE_ATTRIBUTE_ID (0x0022) #define ZCL_GOOD_ID_ATTRIBUTE_ID (0x0030) -#define ZCL_SERIAL_NUMBER_ATTRIBUTE_ID (0x0031) +#define ZCL_PAYMENT_SERIAL_NUMBER_ATTRIBUTE_ID (0x0031) #define ZCL_PAYMENT_TIMESTAMP_ATTRIBUTE_ID (0x0032) #define ZCL_TRANS_ID_ATTRIBUTE_ID (0x0033) #define ZCL_TRANS_STATUS_ATTRIBUTE_ID (0x0034) diff --git a/examples/all-clusters-app/all-clusters-common/gen/call-command-handler.cpp b/examples/all-clusters-app/all-clusters-common/gen/call-command-handler.cpp index 36af8206486d4b..f34585d1e0e626 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/call-command-handler.cpp +++ b/examples/all-clusters-app/all-clusters-common/gen/call-command-handler.cpp @@ -196,10 +196,6 @@ EmberAfStatus emberAfBasicClusterServerCommandParse(EmberAfClusterCommand * cmd) { switch (cmd->commandId) { - case ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID: { - wasHandled = emberAfBasicClusterResetToFactoryDefaultsCallback(); - break; - } default: { // Unrecognized command ID, error status will apply. break; diff --git a/examples/all-clusters-app/all-clusters-common/gen/callback.h b/examples/all-clusters-app/all-clusters-common/gen/callback.h index 9865389e510885..d58578441f7b5d 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/callback.h +++ b/examples/all-clusters-app/all-clusters-common/gen/callback.h @@ -1386,12 +1386,6 @@ bool emberAfBarrierControlClusterBarrierControlStopCallback(); bool emberAfBasicClusterMfgSpecificPingCallback(); -/** - * @brief Basic Cluster ResetToFactoryDefaults Command callback - */ - -bool emberAfBasicClusterResetToFactoryDefaultsCallback(); - /** * @brief Binding Cluster Bind Command callback * @param nodeId diff --git a/examples/all-clusters-app/all-clusters-common/gen/client-command-macro.h b/examples/all-clusters-app/all-clusters-common/gen/client-command-macro.h index c4f2f0a4a2a4f2..f72c96f951dcff 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/client-command-macro.h +++ b/examples/all-clusters-app/all-clusters-common/gen/client-command-macro.h @@ -256,15 +256,6 @@ emberAfFillExternalBuffer(mask, clusterId, ZCL_DISCOVER_ATTRIBUTES_EXTENDED_RESPONSE_COMMAND_ID, "ub", discoveryComplete, \ extendedDiscoverAttributesInfoRecords, extendedDiscoverAttributesInfoRecordsLen); -/** @brief Command description for ResetToFactoryDefaults - * - * Command: ResetToFactoryDefaults - */ -#define emberAfFillCommandBasicClusterResetToFactoryDefaults() \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID, "", ); - /** @brief Command description for Identify * * Command: Identify @@ -1795,6 +1786,33 @@ totalNumberOfNonEmptyProxyTableEntries, gpdSrcId, startIndex, gpdIeee, entriesCount, endpoint, \ proxyTableEntries, proxyTableEntriesLen, index); +/** @brief Command description for StartUp + * + * Command: StartUp + */ +#define emberAfFillCommandBasicClusterStartUp() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_START_UP_COMMAND_ID, "", ); + +/** @brief Command description for ShutDown + * + * Command: ShutDown + */ +#define emberAfFillCommandBasicClusterShutDown() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SHUT_DOWN_COMMAND_ID, "", ); + +/** @brief Command description for Leave + * + * Command: Leave + */ +#define emberAfFillCommandBasicClusterLeave() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_LEAVE_COMMAND_ID, "", ); + /** @brief Command description for SetFabric * * Command: SetFabric diff --git a/examples/all-clusters-app/all-clusters-common/gen/cluster-id.h b/examples/all-clusters-app/all-clusters-common/gen/cluster-id.h index 2069290df636a7..d77da915200ab4 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/cluster-id.h +++ b/examples/all-clusters-app/all-clusters-common/gen/cluster-id.h @@ -20,9 +20,6 @@ // Prevent multiple inclusion #pragma once -// Definitions for cluster: Basic -#define ZCL_BASIC_CLUSTER_ID (0x0000) - // Definitions for cluster: Power Configuration #define ZCL_POWER_CONFIG_CLUSTER_ID (0x0001) @@ -83,6 +80,9 @@ // Definitions for cluster: Keep-Alive #define ZCL_KEEPALIVE_CLUSTER_ID (0x0025) +// Definitions for cluster: Basic +#define ZCL_BASIC_CLUSTER_ID (0x0028) + // Definitions for cluster: General Commissioning #define ZCL_GENERAL_COMMISSIONING_CLUSTER_ID (0x0030) diff --git a/examples/all-clusters-app/all-clusters-common/gen/command-id.h b/examples/all-clusters-app/all-clusters-common/gen/command-id.h index 655425d5d43d35..adc2b1c6f32733 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/command-id.h +++ b/examples/all-clusters-app/all-clusters-common/gen/command-id.h @@ -45,10 +45,6 @@ #define ZCL_DISCOVER_ATTRIBUTES_EXTENDED_COMMAND_ID (0x15) #define ZCL_DISCOVER_ATTRIBUTES_EXTENDED_RESPONSE_COMMAND_ID (0x16) -// Commands for cluster: Basic -#define ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID (0x00) -#define ZCL_MFG_SPECIFIC_PING_COMMAND_ID (0x00) - // Commands for cluster: Identify #define ZCL_IDENTIFY_COMMAND_ID (0x00) #define ZCL_IDENTIFY_QUERY_RESPONSE_COMMAND_ID (0x00) @@ -226,6 +222,12 @@ #define ZCL_GP_PROXY_TABLE_RESPONSE_COMMAND_ID (0x0B) #define ZCL_GP_PROXY_TABLE_REQUEST_COMMAND_ID (0x0B) +// Commands for cluster: Basic +#define ZCL_START_UP_COMMAND_ID (0x00) +#define ZCL_MFG_SPECIFIC_PING_COMMAND_ID (0x00) +#define ZCL_SHUT_DOWN_COMMAND_ID (0x01) +#define ZCL_LEAVE_COMMAND_ID (0x02) + // Commands for cluster: General Commissioning #define ZCL_SET_FABRIC_COMMAND_ID (0x00) #define ZCL_SET_FABRIC_RESPONSE_COMMAND_ID (0x01) diff --git a/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h b/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h index 3775b356ce564f..202d80c95d0291 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h +++ b/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h @@ -26,10 +26,32 @@ #if BIGENDIAN_CPU #define GENERATED_DEFAULTS \ { \ - /* 0 */ 1, 'o', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - /* Default for cluster: "General Commissioning", attribute: "FabricId". side: server, big-endian */ /* 8 */ \ + /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "VendorName". side: server, big-endian */ /* 32 */ 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "ProductName". side: server, big-endian */ /* 64 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "UserLabel". side: server, big-endian */ /* 96 */ 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "Location". side: server, big-endian */ /* 112 */ 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "HardwareVersionString". side: server, big-endian */ /* 176 */ 0x00, 0x00, \ + 0x00, 0x00, /* Default for cluster: "Basic", attribute: "SoftwareVersion". side: server, big-endian */ /* 180 */ 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "SoftwareVersionString". side: server, big-endian */ /* 244 */ 1, 'o', \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "General Commissioning", attribute: "FabricId". side: server, big-endian */ /* 252 */ \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - /* Default for cluster: "General Commissioning", attribute: "Breadcrumb". side: server, big-endian */ /* 16 */ \ + /* Default for cluster: "General Commissioning", attribute: "Breadcrumb". side: server, big-endian */ /* 260 */ \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ @@ -44,28 +66,73 @@ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - /* Default for cluster: "Color Control", attribute: "compensation text". side: server, big-endian */ /* 270 */ \ + /* Default for cluster: "Color Control", attribute: "compensation text". side: server, big-endian */ /* 514 */ \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - /* Default for cluster: "IAS Zone", attribute: "IAS CIE address". side: server, big-endian */ /* 278 */ 0x00, 0x00, \ + /* Default for cluster: "IAS Zone", attribute: "IAS CIE address". side: server, big-endian */ /* 522 */ 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - /* Default for cluster: "Application Basic", attribute: "vendor name". side: server, big-endian */ /* 310 */ \ + /* Default for cluster: "Application Basic", attribute: "vendor name". side: server, big-endian */ /* 554 */ \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, /* Default for cluster: "Application Basic", attribute: "application name". side: server, big-endian */ \ - /* 342 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* 586 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Application Basic", attribute: "application id". side: server, big-endian */ /* 618 */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - 0x00, /* Default for cluster: "Application Basic", attribute: "application id". side: server, big-endian */ \ + /* Default for cluster: "Basic", attribute: "VendorName". side: server, big-endian */ /* 650 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "ProductName". side: server, big-endian */ /* 682 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "UserLabel". side: server, big-endian */ /* 714 */ 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "Location". side: server, big-endian */ /* 730 */ 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "HardwareVersionString". side: server, big-endian */ /* 794 */ 0x00, 0x00, \ + 0x00, 0x00, /* Default for cluster: "Basic", attribute: "SoftwareVersion". side: server, big-endian */ /* 798 */ 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, /* Default for cluster: "Basic", attribute: "SoftwareVersionString". side: server, big-endian */ \ } #else // !BIGENDIAN_CPU #define GENERATED_DEFAULTS \ { \ - /* 0 */ 1, 'o', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - /* Default for cluster: "General Commissioning", attribute: "FabricId". side: server, little-endian */ /* 8 */ \ + /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "VendorName". side: server, little-endian */ /* 32 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "ProductName". side: server, little-endian */ /* 64 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "UserLabel". side: server, little-endian */ /* 96 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "Location". side: server, little-endian */ /* 112 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "HardwareVersionString". side: server, little-endian */ /* 176 */ \ + 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "SoftwareVersion". side: server, little-endian */ /* 180 */ 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "SoftwareVersionString". side: server, little-endian */ /* 244 */ 1, 'o', \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "General Commissioning", attribute: "FabricId". side: server, little-endian */ /* 252 */ \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, /* Default for cluster: "General Commissioning", attribute: "Breadcrumb". side: server, little-endian */ \ - /* 16 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* 260 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ @@ -80,22 +147,45 @@ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, /* Default for cluster: "Color Control", attribute: "compensation text". side: server, little-endian */ \ - /* 270 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - /* Default for cluster: "IAS Zone", attribute: "IAS CIE address". side: server, little-endian */ /* 278 */ 0x00, 0x00, \ + /* 514 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "IAS Zone", attribute: "IAS CIE address". side: server, little-endian */ /* 522 */ 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - /* Default for cluster: "Application Basic", attribute: "vendor name". side: server, little-endian */ /* 310 */ \ + /* Default for cluster: "Application Basic", attribute: "vendor name". side: server, little-endian */ /* 554 */ \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, /* Default for cluster: "Application Basic", attribute: "application name". side: server, little-endian */ \ - /* 342 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* 586 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, /* Default for cluster: "Application Basic", attribute: "application id". side: server, little-endian */ \ + /* 618 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "VendorName". side: server, little-endian */ /* 650 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "ProductName". side: server, little-endian */ /* 682 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "UserLabel". side: server, little-endian */ /* 714 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "Location". side: server, little-endian */ /* 730 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "HardwareVersionString". side: server, little-endian */ /* 794 */ \ + 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "SoftwareVersion". side: server, little-endian */ /* 798 */ 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, \ + 0x00, /* Default for cluster: "Basic", attribute: "SoftwareVersionString". side: server, little-endian */ \ } #endif // BIGENDIAN_CPU -#define GENERATED_DEFAULTS_COUNT (7) +#define GENERATED_DEFAULTS_COUNT (21) #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ @@ -115,13 +205,10 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 108 +#define GENERATED_ATTRIBUTE_COUNT 126 #define GENERATED_ATTRIBUTES \ { \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 3 } }, /* Basic (server): cluster revision */ \ - { 0x0000, ZAP_TYPE(INT8U), 1, 0, { (uint8_t *) 0x08 } }, /* Basic (server): ZCL version */ \ - { 0x0007, ZAP_TYPE(ENUM8), 1, 0, { (uint8_t *) 0x00 } }, /* Basic (server): power source */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 2 } }, /* Identify (server): cluster revision */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 2 } }, /* Identify (server): cluster revision */ \ { \ 0x0000, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), { (uint8_t *) 0x0000 } \ }, /* Identify (server): identify time */ \ @@ -138,12 +225,48 @@ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 3 } }, /* Level Control (server): cluster revision */ \ { 0x0000, ZAP_TYPE(INT8U), 1, 0, { (uint8_t *) 0x00 } }, /* Level Control (server): current level */ \ { \ - 0x0000, ZAP_TYPE(OCTET_STRING), 8, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(0) } \ + 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 3 } \ + }, /* Basic (server): cluster revision */ \ + { \ + 0x0000, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } \ + }, /* Basic (server): InteractionModelVersion */ \ + { \ + 0x0001, ZAP_TYPE(CHAR_STRING), 32, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(0) } \ + }, /* Basic (server): VendorName */ \ + { 0x0002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } }, /* Basic (server): VendorID */ \ + { \ + 0x0003, ZAP_TYPE(CHAR_STRING), 32, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(32) } \ + }, /* Basic (server): ProductName */ \ + { 0x0004, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } }, /* Basic (server): ProductID */ \ + { 0x0005, \ + ZAP_TYPE(CHAR_STRING), \ + 32, \ + ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(64) } }, /* Basic (server): UserLabel */ \ + { 0x0006, \ + ZAP_TYPE(CHAR_STRING), \ + 16, \ + ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(96) } }, /* Basic (server): Location */ \ + { \ + 0x0007, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0x00 } \ + }, /* Basic (server): HardwareVersion */ \ + { \ + 0x0008, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(112) } \ + }, /* Basic (server): HardwareVersionString */ \ + { \ + 0x0009, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(176) } \ + }, /* Basic (server): SoftwareVersion */ \ + { \ + 0x000A, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(180) } \ + }, /* Basic (server): SoftwareVersionString */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* General Commissioning (server): cluster revision */ \ + { \ + 0x0000, ZAP_TYPE(OCTET_STRING), 8, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(244) } \ }, /* General Commissioning (server): FabricId */ \ { \ - 0x0001, ZAP_TYPE(INT64U), 8, ZAP_ATTRIBUTE_MASK(WRITABLE), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(8) } \ + 0x0001, ZAP_TYPE(INT64U), 8, ZAP_ATTRIBUTE_MASK(WRITABLE), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(252) } \ }, /* General Commissioning (server): Breadcrumb */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* General Commissioning (server): cluster revision */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 3 } }, /* Door Lock (server): cluster revision */ \ { 0x0000, ZAP_TYPE(ENUM8), 1, 0, { (uint8_t *) 2 } }, /* Door Lock (server): lock state */ \ { 0x0001, ZAP_TYPE(ENUM8), 1, 0, { (uint8_t *) 0 } }, /* Door Lock (server): lock type */ \ @@ -161,7 +284,7 @@ { 0x0004, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x607D } }, /* Color Control (server): current y */ \ { 0x0005, ZAP_TYPE(ENUM8), 1, 0, { (uint8_t *) 0 } }, /* Color Control (server): drift compensation */ \ { \ - 0x0006, ZAP_TYPE(CHAR_STRING), 254, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(16) } \ + 0x0006, ZAP_TYPE(CHAR_STRING), 254, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(260) } \ }, /* Color Control (server): compensation text */ \ { 0x0007, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x00FA } }, /* Color Control (server): color temperature */ \ { 0x0008, ZAP_TYPE(ENUM8), 1, 0, { (uint8_t *) 0x01 } }, /* Color Control (server): color mode */ \ @@ -243,33 +366,66 @@ { 0x0001, ZAP_TYPE(ENUM16), 2, 0, { (uint8_t *) 0 } }, /* IAS Zone (server): zone type */ \ { 0x0002, ZAP_TYPE(BITMAP16), 2, 0, { (uint8_t *) 0x0000 } }, /* IAS Zone (server): zone status */ \ { \ - 0x0010, ZAP_TYPE(IEEE_ADDRESS), 8, ZAP_ATTRIBUTE_MASK(WRITABLE), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(270) } \ + 0x0010, ZAP_TYPE(IEEE_ADDRESS), 8, ZAP_ATTRIBUTE_MASK(WRITABLE), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(514) } \ }, /* IAS Zone (server): IAS CIE address */ \ { 0x0011, ZAP_TYPE(INT8U), 1, 0, { (uint8_t *) 0xff } }, /* IAS Zone (server): Zone ID */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Low Power (server): cluster revision */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Application Basic (server): cluster revision */ \ { \ - 0x0000, ZAP_TYPE(OCTET_STRING), 32, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(278) } \ + 0x0000, ZAP_TYPE(OCTET_STRING), 32, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(522) } \ }, /* Application Basic (server): vendor name */ \ { 0x0001, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0 } }, /* Application Basic (server): vendor id */ \ { \ - 0x0002, ZAP_TYPE(OCTET_STRING), 32, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(310) } \ - }, /* Application Basic (server): application name */ \ - { 0x0003, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0 } }, /* Application Basic (server): product id */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Application Basic (server): cluster revision */ \ + 0x0002, ZAP_TYPE(OCTET_STRING), 32, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(554) } \ + }, /* Application Basic (server): application name */ \ + { 0x0003, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0 } }, /* Application Basic (server): product id */ \ { \ - 0x0005, ZAP_TYPE(OCTET_STRING), 32, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(342) } \ + 0x0005, ZAP_TYPE(OCTET_STRING), 32, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(586) } \ }, /* Application Basic (server): application id */ \ { 0x0006, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0 } }, /* Application Basic (server): catalog vendor id */ \ { 0x0007, ZAP_TYPE(ENUM8), 1, 0, { (uint8_t *) 0x01 } }, /* Application Basic (server): application satus */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Binding (server): cluster revision */ \ - { 0x0000, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0 } }, /* Media Playback (server): current state */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Media Playback (server): cluster revision */ \ + { 0x0000, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0 } }, /* Media Playback (server): current state */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Content Launch (server): cluster revision */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 3 } }, /* Basic (server): cluster revision */ \ - { 0x0000, ZAP_TYPE(INT8U), 1, 0, { (uint8_t *) 0x08 } }, /* Basic (server): ZCL version */ \ - { 0x0007, ZAP_TYPE(ENUM8), 1, 0, { (uint8_t *) 0x00 } }, /* Basic (server): power source */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 2 } }, /* On/off (server): cluster revision */ \ { 0x0000, ZAP_TYPE(BOOLEAN), 1, 0, { (uint8_t *) 0x00 } }, /* On/off (server): on/off */ \ + { \ + 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 3 } \ + }, /* Basic (server): cluster revision */ \ + { \ + 0x0000, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } \ + }, /* Basic (server): InteractionModelVersion */ \ + { \ + 0x0001, ZAP_TYPE(CHAR_STRING), 32, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(618) } \ + }, /* Basic (server): VendorName */ \ + { 0x0002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } }, /* Basic (server): VendorID */ \ + { \ + 0x0003, ZAP_TYPE(CHAR_STRING), 32, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(650) } \ + }, /* Basic (server): ProductName */ \ + { 0x0004, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } }, /* Basic (server): ProductID */ \ + { 0x0005, \ + ZAP_TYPE(CHAR_STRING), \ + 32, \ + ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(682) } }, /* Basic (server): UserLabel */ \ + { 0x0006, \ + ZAP_TYPE(CHAR_STRING), \ + 16, \ + ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(714) } }, /* Basic (server): Location */ \ + { \ + 0x0007, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0x00 } \ + }, /* Basic (server): HardwareVersion */ \ + { \ + 0x0008, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(730) } \ + }, /* Basic (server): HardwareVersionString */ \ + { \ + 0x0009, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(794) } \ + }, /* Basic (server): SoftwareVersion */ \ + { \ + 0x000A, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(798) } \ + }, /* Basic (server): SoftwareVersionString */ \ } // This is an array of EmberAfCluster structures. @@ -309,87 +465,91 @@ #define GENERATED_CLUSTER_COUNT 19 #define GENERATED_CLUSTERS \ { \ - { 0x0000, ZAP_ATTRIBUTE_INDEX(0), 3, 4, ZAP_CLUSTER_MASK(SERVER), NULL }, /* Endpoint: 1, Cluster: Basic (server) */ \ - { 0x0003, \ - ZAP_ATTRIBUTE_INDEX(3), \ - 2, \ - 4, \ - ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION) | ZAP_CLUSTER_MASK(ATTRIBUTE_CHANGED_FUNCTION), \ - chipFuncArrayIdentifyServer }, /* Endpoint: 1, Cluster: Identify (server) */ \ + { 0x0003, \ + ZAP_ATTRIBUTE_INDEX(0), \ + 2, \ + 4, \ + ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION) | ZAP_CLUSTER_MASK(ATTRIBUTE_CHANGED_FUNCTION), \ + chipFuncArrayIdentifyServer }, /* Endpoint: 1, Cluster: Identify (server) */ \ { 0x0004, \ - ZAP_ATTRIBUTE_INDEX(5), \ + ZAP_ATTRIBUTE_INDEX(2), \ 2, \ 3, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayGroupsServer }, /* Endpoint: 1, Cluster: Groups (server) */ \ { 0x0005, \ - ZAP_ATTRIBUTE_INDEX(7), \ + ZAP_ATTRIBUTE_INDEX(4), \ 6, \ 8, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayScenesServer }, /* Endpoint: 1, Cluster: Scenes (server) */ \ { 0x0006, \ - ZAP_ATTRIBUTE_INDEX(13), \ + ZAP_ATTRIBUTE_INDEX(10), \ 2, \ 3, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayOnOffServer }, /* Endpoint: 1, Cluster: On/off (server) */ \ { 0x0008, \ - ZAP_ATTRIBUTE_INDEX(15), \ + ZAP_ATTRIBUTE_INDEX(12), \ 2, \ 3, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayLevelControlServer }, /* Endpoint: 1, Cluster: Level Control (server) */ \ { \ - 0x0030, ZAP_ATTRIBUTE_INDEX(17), 3, 18, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0028, ZAP_ATTRIBUTE_INDEX(14), 12, 254, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 1, Cluster: Basic (server) */ \ + { \ + 0x0030, ZAP_ATTRIBUTE_INDEX(26), 3, 18, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: General Commissioning (server) */ \ { 0x0101, \ - ZAP_ATTRIBUTE_INDEX(20), \ + ZAP_ATTRIBUTE_INDEX(29), \ 4, \ 5, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(ATTRIBUTE_CHANGED_FUNCTION), \ chipFuncArrayDoorLockServer }, /* Endpoint: 1, Cluster: Door Lock (server) */ \ { \ - 0x0103, ZAP_ATTRIBUTE_INDEX(24), 5, 7, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0103, ZAP_ATTRIBUTE_INDEX(33), 5, 7, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Barrier Control (server) */ \ { 0x0300, \ - ZAP_ATTRIBUTE_INDEX(29), \ + ZAP_ATTRIBUTE_INDEX(38), \ 51, \ 336, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayColorControlServer }, /* Endpoint: 1, Cluster: Color Control (server) */ \ { \ - 0x0402, ZAP_ATTRIBUTE_INDEX(80), 4, 8, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0402, ZAP_ATTRIBUTE_INDEX(89), 4, 8, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Temperature Measurement (server) */ \ { 0x0500, \ - ZAP_ATTRIBUTE_INDEX(84), \ + ZAP_ATTRIBUTE_INDEX(93), \ 6, \ 16, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION) | ZAP_CLUSTER_MASK(PRE_ATTRIBUTE_CHANGED_FUNCTION) | \ ZAP_CLUSTER_MASK(MESSAGE_SENT_FUNCTION), \ chipFuncArrayIasZoneServer }, /* Endpoint: 1, Cluster: IAS Zone (server) */ \ { \ - 0x0508, ZAP_ATTRIBUTE_INDEX(90), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0508, ZAP_ATTRIBUTE_INDEX(99), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Low Power (server) */ \ { \ - 0x050D, ZAP_ATTRIBUTE_INDEX(91), 8, 105, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x050D, ZAP_ATTRIBUTE_INDEX(100), 8, 105, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Application Basic (server) */ \ { \ - 0xF000, ZAP_ATTRIBUTE_INDEX(99), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0xF000, ZAP_ATTRIBUTE_INDEX(108), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Binding (server) */ \ { \ - 0xF001, ZAP_ATTRIBUTE_INDEX(100), 2, 4, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0xF001, ZAP_ATTRIBUTE_INDEX(109), 2, 4, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Media Playback (server) */ \ { \ - 0xF002, ZAP_ATTRIBUTE_INDEX(102), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0xF002, ZAP_ATTRIBUTE_INDEX(111), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Content Launch (server) */ \ - { 0x0000, ZAP_ATTRIBUTE_INDEX(103), 3, 4, ZAP_CLUSTER_MASK(SERVER), NULL }, /* Endpoint: 2, Cluster: Basic (server) */ \ { 0x0006, \ - ZAP_ATTRIBUTE_INDEX(106), \ + ZAP_ATTRIBUTE_INDEX(112), \ 2, \ 3, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayOnOffServer }, /* Endpoint: 2, Cluster: On/off (server) */ \ + { \ + 0x0028, ZAP_ATTRIBUTE_INDEX(114), 12, 254, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 2, Cluster: Basic (server) */ \ } #define ZAP_CLUSTER_INDEX(index) ((EmberAfCluster *) (&generatedClusters[index])) @@ -397,17 +557,17 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 17, 530 }, { ZAP_CLUSTER_INDEX(17), 2, 7 }, \ + { ZAP_CLUSTER_INDEX(0), 17, 780 }, { ZAP_CLUSTER_INDEX(17), 2, 257 }, \ } // Largest attribute size is needed for various buffers #define ATTRIBUTE_LARGEST (254) // Total size of singleton attributes -#define ATTRIBUTE_SINGLETONS_SIZE (0) +#define ATTRIBUTE_SINGLETONS_SIZE (508) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (537) +#define ATTRIBUTE_MAX_SIZE (1037) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (2) @@ -451,17 +611,10 @@ // Array of EmberAfCommandMetadata structs. #define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask -#define EMBER_AF_GENERATED_COMMAND_COUNT (111) +#define EMBER_AF_GENERATED_COMMAND_COUNT (115) #define GENERATED_COMMANDS \ { \ - { 0x0000, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Basic (server): MfgSpecificPing */ \ - { \ - 0x0000, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) | ZAP_COMMAND_MASK(OUTGOING_SERVER) \ - }, /* Basic (server): ResetToFactoryDefaults */ \ - { \ - 0x0000, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) | ZAP_COMMAND_MASK(OUTGOING_SERVER) \ - }, /* Basic (server): ResetToFactoryDefaults */ \ - { 0x0003, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Identify (server): Identify */ \ + { 0x0003, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Identify (server): Identify */ \ { 0x0003, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Identify (server): IdentifyQueryResponse */ \ { 0x0003, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Identify (server): IdentifyQuery */ \ { 0x0004, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Groups (server): AddGroup */ \ @@ -501,6 +654,13 @@ { 0x0008, 0x05, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Level Control (server): MoveWithOnOff */ \ { 0x0008, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Level Control (server): StepWithOnOff */ \ { 0x0008, 0x07, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Level Control (server): StopWithOnOff */ \ + { 0x0028, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Basic (server): MfgSpecificPing */ \ + { 0x0028, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): StartUp */ \ + { 0x0028, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): StartUp */ \ + { 0x0028, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): ShutDown */ \ + { 0x0028, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): ShutDown */ \ + { 0x0028, 0x02, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): Leave */ \ + { 0x0028, 0x02, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): Leave */ \ { 0x0030, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* General Commissioning (server): SetFabric */ \ { 0x0030, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* General Commissioning (server): SetFabricResponse */ \ { 0x0030, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* General Commissioning (server): ArmFailSafe */ \ @@ -624,7 +784,7 @@ #define GENERATED_COMMAND_MANUFACTURER_CODE_COUNT (1) #define GENERATED_COMMAND_MANUFACTURER_CODES \ { \ - { 0, 4098 }, \ + { 40, 4098 }, \ } // This is an array of EmberAfManufacturerCodeEntry structures for clusters. diff --git a/examples/all-clusters-app/all-clusters-common/gen/print-cluster.h b/examples/all-clusters-app/all-clusters-common/gen/print-cluster.h index 1ea31513afebcd..bd08d38a581506 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/print-cluster.h +++ b/examples/all-clusters-app/all-clusters-common/gen/print-cluster.h @@ -24,12 +24,6 @@ // to the "EmberAfClusterName" defined in the ZCL header. // The names of clusters that are not present, are removed. -#if defined(ZCL_USING_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_BASIC_CLUSTER_CLIENT) -#define CHIP_PRINTCLUSTER_BASIC_CLUSTER { ZCL_BASIC_CLUSTER_ID, 0, "Basic" }, -#else -#define CHIP_PRINTCLUSTER_BASIC_CLUSTER -#endif - #if defined(ZCL_USING_POWER_CONFIG_CLUSTER_SERVER) || defined(ZCL_USING_POWER_CONFIG_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_POWER_CONFIG_CLUSTER { ZCL_POWER_CONFIG_CLUSTER_ID, 1, "Power Configuration" }, #else @@ -150,6 +144,12 @@ #define CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER #endif +#if defined(ZCL_USING_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_BASIC_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_BASIC_CLUSTER { ZCL_BASIC_CLUSTER_ID, 40, "Basic" }, +#else +#define CHIP_PRINTCLUSTER_BASIC_CLUSTER +#endif + #if defined(ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER { ZCL_GENERAL_COMMISSIONING_CLUSTER_ID, 48, "General Commissioning" }, #else @@ -790,7 +790,6 @@ #endif #define CLUSTER_IDS_TO_NAMES \ - CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_POWER_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DEVICE_TEMP_CLUSTER \ CHIP_PRINTCLUSTER_IDENTIFY_CLUSTER \ @@ -811,6 +810,7 @@ CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER \ CHIP_PRINTCLUSTER_GREEN_POWER_CLUSTER \ CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER \ + CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DOOR_LOCK_CLUSTER \ diff --git a/examples/bridge-app/bridge-common/bridge-app.zap b/examples/bridge-app/bridge-common/bridge-app.zap index 96ea807e80cb84..405d0aa5359b17 100644 --- a/examples/bridge-app/bridge-common/bridge-app.zap +++ b/examples/bridge-app/bridge-common/bridge-app.zap @@ -39,7 +39,7 @@ "clusters": [ { "name": "Basic", - "code": 0, + "code": 40, "mfgCode": null, "define": "BASIC_CLUSTER", "side": "client", @@ -53,7 +53,7 @@ "side": "client", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, "defaultValue": "3", "reportable": 0, @@ -65,12 +65,37 @@ }, { "name": "Basic", - "code": 0, + "code": 40, "mfgCode": null, "define": "BASIC_CLUSTER", "side": "server", - "enabled": 0, - "commands": [], + "enabled": 1, + "commands": [ + { + "name": "StartUp", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ShutDown", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "Leave", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], "attributes": [ { "name": "cluster revision", @@ -79,7 +104,7 @@ "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, "defaultValue": "3", "reportable": 0, @@ -88,34 +113,169 @@ "reportableChange": 0 }, { - "name": "ZCL version", + "name": "InteractionModelVersion", "code": 0, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "0x08", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "power source", + "name": "VendorName", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorID", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductName", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductID", + "code": 4, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UserLabel", + "code": 5, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Location", + "code": 6, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersion", "code": 7, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, "defaultValue": "0x00", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 + }, + { + "name": "HardwareVersionString", + "code": 8, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersion", + "code": 9, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersionString", + "code": 10, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 } ] }, @@ -828,7 +988,7 @@ "clusters": [ { "name": "Basic", - "code": 0, + "code": 40, "mfgCode": null, "define": "BASIC_CLUSTER", "side": "client", @@ -854,12 +1014,37 @@ }, { "name": "Basic", - "code": 0, + "code": 40, "mfgCode": null, "define": "BASIC_CLUSTER", "side": "server", - "enabled": 0, - "commands": [], + "enabled": 1, + "commands": [ + { + "name": "StartUp", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ShutDown", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "Leave", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], "attributes": [ { "name": "cluster revision", @@ -877,7 +1062,7 @@ "reportableChange": 0 }, { - "name": "ZCL version", + "name": "InteractionModelVersion", "code": 0, "mfgCode": null, "side": "server", @@ -885,14 +1070,14 @@ "storageOption": "RAM", "singleton": 1, "bounded": 0, - "defaultValue": "0x08", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "application version", + "name": "VendorName", "code": 1, "mfgCode": null, "side": "server", @@ -900,14 +1085,14 @@ "storageOption": "RAM", "singleton": 1, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "stack version", + "name": "VendorID", "code": 2, "mfgCode": null, "side": "server", @@ -915,14 +1100,14 @@ "storageOption": "RAM", "singleton": 1, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "hardware version", + "name": "ProductName", "code": 3, "mfgCode": null, "side": "server", @@ -930,14 +1115,14 @@ "storageOption": "RAM", "singleton": 1, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "manufacturer name", + "name": "ProductID", "code": 4, "mfgCode": null, "side": "server", @@ -952,7 +1137,7 @@ "reportableChange": 0 }, { - "name": "model identifier", + "name": "UserLabel", "code": 5, "mfgCode": null, "side": "server", @@ -967,7 +1152,7 @@ "reportableChange": 0 }, { - "name": "date code", + "name": "Location", "code": 6, "mfgCode": null, "side": "server", @@ -982,7 +1167,7 @@ "reportableChange": 0 }, { - "name": "power source", + "name": "HardwareVersion", "code": 7, "mfgCode": null, "side": "server", @@ -997,7 +1182,7 @@ "reportableChange": 0 }, { - "name": "generic device class", + "name": "HardwareVersionString", "code": 8, "mfgCode": null, "side": "server", @@ -1005,14 +1190,14 @@ "storageOption": "RAM", "singleton": 1, "bounded": 0, - "defaultValue": "0xFF", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "generic device type", + "name": "SoftwareVersion", "code": 9, "mfgCode": null, "side": "server", @@ -1020,14 +1205,14 @@ "storageOption": "RAM", "singleton": 1, "bounded": 0, - "defaultValue": "0xFF", + "defaultValue": "0x00", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "product code", + "name": "SoftwareVersionString", "code": 10, "mfgCode": null, "side": "server", @@ -1040,36 +1225,6 @@ "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - }, - { - "name": "product url", - "code": 11, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "sw build id", - "code": 16384, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 } ] }, diff --git a/examples/bridge-app/bridge-common/gen/CHIPClientCallbacks.cpp b/examples/bridge-app/bridge-common/gen/CHIPClientCallbacks.cpp index f5f88af110c2c7..fc5ea3b1b8a7c6 100644 --- a/examples/bridge-app/bridge-common/gen/CHIPClientCallbacks.cpp +++ b/examples/bridge-app/bridge-common/gen/CHIPClientCallbacks.cpp @@ -272,10 +272,6 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag case 0x38: // semi / Semi-precision case 0x39: // single / Single precision case 0x3A: // double / Double precision - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string case 0x48: // array / Array case 0x49: // struct / Structure case 0x50: // set / Set @@ -289,6 +285,48 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag return true; } + case 0x41: // octstr / Octet string + case 0x42: // string / Character string + { + // Short Strings must contains at least one byte for the length + CHECK_MESSAGE_LENGTH(1); + uint8_t length = chip::Encoding::Read8(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + + case 0x43: // octstr16 / Long octet string + case 0x44: // string16 / Long character string + { + // Long Strings must contains at least two bytes for the length + CHECK_MESSAGE_LENGTH(2); + uint16_t length = chip::Encoding::LittleEndian::Read16(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFFFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFFFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + case 0x08: // data8 / 8-bit data case 0x18: // map8 / 8-bit bitmap case 0x20: // uint8 / Unsigned 8-bit integer @@ -696,10 +734,6 @@ bool emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * message, uin case 0x38: // semi / Semi-precision case 0x39: // single / Single precision case 0x3A: // double / Double precision - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string case 0x48: // array / Array case 0x49: // struct / Structure case 0x50: // set / Set @@ -710,6 +744,48 @@ bool emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * message, uin return true; } + case 0x41: // octstr / Octet string + case 0x42: // string / Character string + { + // Short Strings must contains at least one byte for the length + CHECK_MESSAGE_LENGTH(1); + uint8_t length = chip::Encoding::Read8(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onReportCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + + case 0x43: // octstr16 / Long octet string + case 0x44: // string16 / Long character string + { + // Long Strings must contains at least two bytes for the length + CHECK_MESSAGE_LENGTH(2); + uint16_t length = chip::Encoding::LittleEndian::Read16(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFFFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFFFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onReportCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + case 0x08: // data8 / 8-bit data case 0x18: // map8 / 8-bit bitmap case 0x20: // uint8 / Unsigned 8-bit integer diff --git a/examples/bridge-app/bridge-common/gen/CHIPClientCallbacks.h b/examples/bridge-app/bridge-common/gen/CHIPClientCallbacks.h index 14a3742f090e8f..d028079f799d79 100644 --- a/examples/bridge-app/bridge-common/gen/CHIPClientCallbacks.h +++ b/examples/bridge-app/bridge-common/gen/CHIPClientCallbacks.h @@ -20,6 +20,7 @@ #pragma once #include +#include // Global Response Callbacks typedef void (*DefaultSuccessCallback)(void * context); @@ -33,6 +34,7 @@ typedef void (*Int32uAttributeCallback)(void * context, uint32_t value); typedef void (*Int32sAttributeCallback)(void * context, int32_t value); typedef void (*Int64uAttributeCallback)(void * context, uint64_t value); typedef void (*Int64sAttributeCallback)(void * context, int64_t value); +typedef void (*StringAttributeCallback)(void * context, const chip::ByteSpan value); typedef void (*ReadReportingConfigurationReportedCallback)(void * context, uint16_t minInterval, uint16_t maxInterval); typedef void (*ReadReportingConfigurationReceivedCallback)(void * context, uint16_t timeout); diff --git a/examples/bridge-app/bridge-common/gen/CHIPClustersObjc.h b/examples/bridge-app/bridge-common/gen/CHIPClustersObjc.h index 6321b004fc72f7..e41b61bf809bd4 100644 --- a/examples/bridge-app/bridge-common/gen/CHIPClustersObjc.h +++ b/examples/bridge-app/bridge-common/gen/CHIPClustersObjc.h @@ -48,21 +48,19 @@ NS_ASSUME_NONNULL_BEGIN */ @interface CHIPBasic : CHIPCluster -- (void)resetToFactoryDefaults:(ResponseHandler)completionHandler; - -- (void)readAttributeZclVersion:(ResponseHandler)completionHandler; -- (void)readAttributeApplicationVersion:(ResponseHandler)completionHandler; -- (void)readAttributeStackVersion:(ResponseHandler)completionHandler; +- (void)readAttributeInteractionModelVersion:(ResponseHandler)completionHandler; +- (void)readAttributeVendorName:(ResponseHandler)completionHandler; +- (void)readAttributeVendorID:(ResponseHandler)completionHandler; +- (void)readAttributeProductName:(ResponseHandler)completionHandler; +- (void)readAttributeProductID:(ResponseHandler)completionHandler; +- (void)readAttributeUserLabel:(ResponseHandler)completionHandler; +- (void)writeAttributeUserLabel:(NSString *)value completionHandler:(ResponseHandler)completionHandler; +- (void)readAttributeLocation:(ResponseHandler)completionHandler; +- (void)writeAttributeLocation:(NSString *)value completionHandler:(ResponseHandler)completionHandler; - (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler; -- (void)readAttributeManufacturerName:(ResponseHandler)completionHandler; -- (void)readAttributeModelIdentifier:(ResponseHandler)completionHandler; -- (void)readAttributeDateCode:(ResponseHandler)completionHandler; -- (void)readAttributePowerSource:(ResponseHandler)completionHandler; -- (void)readAttributeGenericDeviceClass:(ResponseHandler)completionHandler; -- (void)readAttributeGenericDeviceType:(ResponseHandler)completionHandler; -- (void)readAttributeProductCode:(ResponseHandler)completionHandler; -- (void)readAttributeProductUrl:(ResponseHandler)completionHandler; -- (void)readAttributeSwBuildId:(ResponseHandler)completionHandler; +- (void)readAttributeHardwareVersionString:(ResponseHandler)completionHandler; +- (void)readAttributeSoftwareVersion:(ResponseHandler)completionHandler; +- (void)readAttributeSoftwareVersionString:(ResponseHandler)completionHandler; - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler; @end diff --git a/examples/bridge-app/bridge-common/gen/CHIPClustersObjc.mm b/examples/bridge-app/bridge-common/gen/CHIPClustersObjc.mm index 98ddbecdf8e85a..f58335756438ca 100644 --- a/examples/bridge-app/bridge-common/gen/CHIPClustersObjc.mm +++ b/examples/bridge-app/bridge-common/gen/CHIPClustersObjc.mm @@ -89,26 +89,38 @@ static void CallbackFn(void * context, uint8_t status) dispatch_queue_t mQueue; }; -class CHIPUnsupportedAttributeCallbackBridge : public Callback::Callback { +class CHIPStringAttributeCallbackBridge : public Callback::Callback { public: - CHIPUnsupportedAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) - : Callback::Callback(CallbackFn, this) + CHIPStringAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool octetString, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mOctetString(octetString) + , mKeepAlive(keepAlive) { } - ~CHIPUnsupportedAttributeCallbackBridge() {}; + ~CHIPStringAttributeCallbackBridge() {}; - static void CallbackFn(void * context) + static void CallbackFn(void * context, chip::ByteSpan value) { - CHIPUnsupportedAttributeCallbackBridge * callback = reinterpret_cast(context); + CHIPStringAttributeCallbackBridge * callback = reinterpret_cast(context); if (callback && callback->mQueue) { dispatch_async(callback->mQueue, ^{ - NSError * error = [NSError errorWithDomain:CHIPErrorDomain - code:CHIPErrorCodeUndefinedError - userInfo:@ { NSLocalizedDescriptionKey : @"Unsupported attribute type" }]; - callback->mHandler(error, nil); - callback->Cancel(); - delete callback; + if (callback->mOctetString) { + NSData * data = [NSData dataWithBytes:value.data() length:value.size()]; + callback->mHandler(nil, @ { @"value" : data }); + } else { + NSString * str = [[NSString alloc] initWithBytes:value.data() + length:value.size() + encoding:NSUTF8StringEncoding]; + callback->mHandler(nil, @ { @"value" : str }); + } + + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } }); } }; @@ -116,6 +128,8 @@ static void CallbackFn(void * context) private: ResponseHandler mHandler; dispatch_queue_t mQueue; + bool mOctetString; + bool mKeepAlive; }; class CHIPBooleanAttributeCallbackBridge : public Callback::Callback { @@ -246,6 +260,38 @@ static void CallbackFn(void * context, uint16_t value) bool mKeepAlive; }; +class CHIPInt32uAttributeCallbackBridge : public Callback::Callback { +public: + CHIPInt32uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mKeepAlive(keepAlive) + { + } + + ~CHIPInt32uAttributeCallbackBridge() {}; + + static void CallbackFn(void * context, uint32_t value) + { + CHIPInt32uAttributeCallbackBridge * callback = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedLong:value] }); + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; + bool mKeepAlive; +}; + class CHIPInt16sAttributeCallbackBridge : public Callback::Callback { public: CHIPInt16sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) @@ -319,32 +365,9 @@ @implementation CHIPBasic return &_cppCluster; } -- (void)resetToFactoryDefaults:(ResponseHandler)completionHandler +- (void)readAttributeInteractionModelVersion:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); - if (!onSuccess) { - completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); - if (!onFailure) { - delete onSuccess; - completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - CHIP_ERROR err = self.cppCluster.ResetToFactoryDefaults(onSuccess->Cancel(), onFailure->Cancel()); - if (err != CHIP_NO_ERROR) { - delete onSuccess; - delete onFailure; - completionHandler([CHIPError errorForCHIPErrorCode:err], nil); - } -} - -- (void)readAttributeZclVersion:(ResponseHandler)completionHandler -{ - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -357,7 +380,7 @@ - (void)readAttributeZclVersion:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeZclVersion(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeInteractionModelVersion(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -365,9 +388,10 @@ - (void)readAttributeZclVersion:(ResponseHandler)completionHandler } } -- (void)readAttributeApplicationVersion:(ResponseHandler)completionHandler +- (void)readAttributeVendorName:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -380,7 +404,7 @@ - (void)readAttributeApplicationVersion:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeApplicationVersion(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -388,9 +412,9 @@ - (void)readAttributeApplicationVersion:(ResponseHandler)completionHandler } } -- (void)readAttributeStackVersion:(ResponseHandler)completionHandler +- (void)readAttributeVendorID:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -403,7 +427,7 @@ - (void)readAttributeStackVersion:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeStackVersion(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeVendorID(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -411,9 +435,10 @@ - (void)readAttributeStackVersion:(ResponseHandler)completionHandler } } -- (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler +- (void)readAttributeProductName:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -426,7 +451,7 @@ - (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeProductName(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -434,10 +459,9 @@ - (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler } } -- (void)readAttributeManufacturerName:(ResponseHandler)completionHandler +- (void)readAttributeProductID:(ResponseHandler)completionHandler { - CHIPUnsupportedAttributeCallbackBridge * onSuccess - = new CHIPUnsupportedAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -450,7 +474,7 @@ - (void)readAttributeManufacturerName:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeManufacturerName(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeProductID(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -458,10 +482,10 @@ - (void)readAttributeManufacturerName:(ResponseHandler)completionHandler } } -- (void)readAttributeModelIdentifier:(ResponseHandler)completionHandler +- (void)readAttributeUserLabel:(ResponseHandler)completionHandler { - CHIPUnsupportedAttributeCallbackBridge * onSuccess - = new CHIPUnsupportedAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -474,7 +498,7 @@ - (void)readAttributeModelIdentifier:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeModelIdentifier(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeUserLabel(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -482,10 +506,9 @@ - (void)readAttributeModelIdentifier:(ResponseHandler)completionHandler } } -- (void)readAttributeDateCode:(ResponseHandler)completionHandler +- (void)writeAttributeUserLabel:(NSString *)value completionHandler:(ResponseHandler)completionHandler { - CHIPUnsupportedAttributeCallbackBridge * onSuccess - = new CHIPUnsupportedAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -498,7 +521,9 @@ - (void)readAttributeDateCode:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeDateCode(onSuccess->Cancel(), onFailure->Cancel()); + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + CHIP_ERROR err = self.cppCluster.WriteAttributeUserLabel( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -506,9 +531,10 @@ - (void)readAttributeDateCode:(ResponseHandler)completionHandler } } -- (void)readAttributePowerSource:(ResponseHandler)completionHandler +- (void)readAttributeLocation:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -521,7 +547,7 @@ - (void)readAttributePowerSource:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePowerSource(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeLocation(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -529,9 +555,9 @@ - (void)readAttributePowerSource:(ResponseHandler)completionHandler } } -- (void)readAttributeGenericDeviceClass:(ResponseHandler)completionHandler +- (void)writeAttributeLocation:(NSString *)value completionHandler:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -544,7 +570,9 @@ - (void)readAttributeGenericDeviceClass:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeGenericDeviceClass(onSuccess->Cancel(), onFailure->Cancel()); + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + CHIP_ERROR err = self.cppCluster.WriteAttributeLocation( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -552,9 +580,9 @@ - (void)readAttributeGenericDeviceClass:(ResponseHandler)completionHandler } } -- (void)readAttributeGenericDeviceType:(ResponseHandler)completionHandler +- (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -567,7 +595,7 @@ - (void)readAttributeGenericDeviceType:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeGenericDeviceType(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersion(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -575,10 +603,10 @@ - (void)readAttributeGenericDeviceType:(ResponseHandler)completionHandler } } -- (void)readAttributeProductCode:(ResponseHandler)completionHandler +- (void)readAttributeHardwareVersionString:(ResponseHandler)completionHandler { - CHIPUnsupportedAttributeCallbackBridge * onSuccess - = new CHIPUnsupportedAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -591,7 +619,7 @@ - (void)readAttributeProductCode:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeProductCode(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -599,10 +627,9 @@ - (void)readAttributeProductCode:(ResponseHandler)completionHandler } } -- (void)readAttributeProductUrl:(ResponseHandler)completionHandler +- (void)readAttributeSoftwareVersion:(ResponseHandler)completionHandler { - CHIPUnsupportedAttributeCallbackBridge * onSuccess - = new CHIPUnsupportedAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -615,7 +642,7 @@ - (void)readAttributeProductUrl:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeProductUrl(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersion(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -623,10 +650,10 @@ - (void)readAttributeProductUrl:(ResponseHandler)completionHandler } } -- (void)readAttributeSwBuildId:(ResponseHandler)completionHandler +- (void)readAttributeSoftwareVersionString:(ResponseHandler)completionHandler { - CHIPUnsupportedAttributeCallbackBridge * onSuccess - = new CHIPUnsupportedAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -639,7 +666,7 @@ - (void)readAttributeSwBuildId:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeSwBuildId(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; diff --git a/examples/bridge-app/bridge-common/gen/IMClusterCommandHandler.cpp b/examples/bridge-app/bridge-common/gen/IMClusterCommandHandler.cpp index b08b0bc9b45077..e5c62ee3c4c594 100644 --- a/examples/bridge-app/bridge-common/gen/IMClusterCommandHandler.cpp +++ b/examples/bridge-app/bridge-common/gen/IMClusterCommandHandler.cpp @@ -39,30 +39,6 @@ namespace app { namespace clusters { -namespace Basic { - -void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv) -{ - { - switch (commandId) - { - case ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID: { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - emberAfBasicClusterResetToFactoryDefaultsCallback(); - break; - } - default: { - // Unrecognized command ID, error status will apply. - // TODO: Encode response for command not found - ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_BASIC_CLUSTER_ID); - break; - } - } - } -} - -} // namespace Basic - namespace LevelControl { void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv) @@ -373,9 +349,6 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId); switch (aClusterId) { - case ZCL_BASIC_CLUSTER_ID: - clusters::Basic::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); - break; case ZCL_LEVEL_CONTROL_CLUSTER_ID: clusters::LevelControl::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; diff --git a/examples/bridge-app/bridge-common/gen/attribute-id.h b/examples/bridge-app/bridge-common/gen/attribute-id.h index 8802797f112bd6..8c8757f826ca7f 100644 --- a/examples/bridge-app/bridge-common/gen/attribute-id.h +++ b/examples/bridge-app/bridge-common/gen/attribute-id.h @@ -26,30 +26,6 @@ #define ZCL_REPORTING_STATUS_CLIENT_ATTRIBUTE_ID (0xFFFE) #define ZCL_REPORTING_STATUS_SERVER_ATTRIBUTE_ID (0xFFFE) -// Attribute ids for cluster: Basic - -// Client attributes - -// Server attributes -#define ZCL_VERSION_ATTRIBUTE_ID (0x0000) -#define ZCL_APPLICATION_VERSION_ATTRIBUTE_ID (0x0001) -#define ZCL_STACK_VERSION_ATTRIBUTE_ID (0x0002) -#define ZCL_HW_VERSION_ATTRIBUTE_ID (0x0003) -#define ZCL_MANUFACTURER_NAME_ATTRIBUTE_ID (0x0004) -#define ZCL_MODEL_IDENTIFIER_ATTRIBUTE_ID (0x0005) -#define ZCL_DATE_CODE_ATTRIBUTE_ID (0x0006) -#define ZCL_POWER_SOURCE_ATTRIBUTE_ID (0x0007) -#define ZCL_GENERIC_DEVICE_CLASS_ATTRIBUTE_ID (0x0008) -#define ZCL_GENERIC_DEVICE_TYPE_ATTRIBUTE_ID (0x0009) -#define ZCL_PRODUCT_CODE_ATTRIBUTE_ID (0x000A) -#define ZCL_PRODUCT_URL_ATTRIBUTE_ID (0x000B) -#define ZCL_LOCATION_DESCRIPTION_ATTRIBUTE_ID (0x0010) -#define ZCL_PHYSICAL_ENVIRONMENT_ATTRIBUTE_ID (0x0011) -#define ZCL_DEVICE_ENABLED_ATTRIBUTE_ID (0x0012) -#define ZCL_ALARM_MASK_ATTRIBUTE_ID (0x0013) -#define ZCL_DISABLE_LOCAL_CONFIG_ATTRIBUTE_ID (0x0014) -#define ZCL_SW_BUILD_ID_ATTRIBUTE_ID (0x4000) - // Attribute ids for cluster: Power Configuration // Client attributes @@ -384,6 +360,29 @@ #define ZCL_KEEPALIVE_BASE_ATTRIBUTE_ID (0x0000) #define ZCL_KEEPALIVE_JITTER_ATTRIBUTE_ID (0x0001) +// Attribute ids for cluster: Basic + +// Client attributes + +// Server attributes +#define ZCL_INTERACTION_MODEL_VERSION_ATTRIBUTE_ID (0x0000) +#define ZCL_VENDOR_NAME_ATTRIBUTE_ID (0x0001) +#define ZCL_VENDOR_ID_ATTRIBUTE_ID (0x0002) +#define ZCL_PRODUCT_NAME_ATTRIBUTE_ID (0x0003) +#define ZCL_PRODUCT_ID_ATTRIBUTE_ID (0x0004) +#define ZCL_USER_LABEL_ATTRIBUTE_ID (0x0005) +#define ZCL_LOCATION_ATTRIBUTE_ID (0x0006) +#define ZCL_HARDWARE_VERSION_ATTRIBUTE_ID (0x0007) +#define ZCL_HARDWARE_VERSION_STRING_ATTRIBUTE_ID (0x0008) +#define ZCL_SOFTWARE_VERSION_ATTRIBUTE_ID (0x0009) +#define ZCL_SOFTWARE_VERSION_STRING_ATTRIBUTE_ID (0x000A) +#define ZCL_MANUFACTURING_DATE_ATTRIBUTE_ID (0x000B) +#define ZCL_PART_NUMBER_ATTRIBUTE_ID (0x000C) +#define ZCL_PRODUCT_URL_ATTRIBUTE_ID (0x000D) +#define ZCL_PRODUCT_LABEL_ATTRIBUTE_ID (0x000E) +#define ZCL_SERIAL_NUMBER_ATTRIBUTE_ID (0x000F) +#define ZCL_LOCAL_CONFIG_DISABLED_ATTRIBUTE_ID (0x0010) + // Attribute ids for cluster: General Commissioning // Client attributes @@ -1093,15 +1092,21 @@ // Server attributes #define ZCL_MAX_DURATION_ATTRIBUTE_ID (0x0000) +// Attribute ids for cluster: Low Power + +// Client attributes + +// Server attributes + // Attribute ids for cluster: Application Basic // Client attributes // Server attributes -#define ZCL_VENDOR_NAME_ATTRIBUTE_ID (0x0000) -#define ZCL_VENDOR_ID_ATTRIBUTE_ID (0x0001) +#define ZCL_APPLICATION_VENDOR_NAME_ATTRIBUTE_ID (0x0000) +#define ZCL_APPLICATION_VENDOR_ID_ATTRIBUTE_ID (0x0001) #define ZCL_APPLICATION_NAME_ATTRIBUTE_ID (0x0002) -#define ZCL_PRODUCT_ID_ATTRIBUTE_ID (0x0003) +#define ZCL_APPLICATION_PRODUCT_ID_ATTRIBUTE_ID (0x0003) #define ZCL_APPLICATION_ID_ATTRIBUTE_ID (0x0005) #define ZCL_CATALOG_VENDOR_ID_ATTRIBUTE_ID (0x0006) #define ZCL_APPLICATION_STATUS_ATTRIBUTE_ID (0x0007) @@ -3833,7 +3838,7 @@ #define ZCL_PRICE_TRAILING_DIGIT_ATTRIBUTE_ID (0x0021) #define ZCL_PRICE_ATTRIBUTE_ID (0x0022) #define ZCL_GOOD_ID_ATTRIBUTE_ID (0x0030) -#define ZCL_SERIAL_NUMBER_ATTRIBUTE_ID (0x0031) +#define ZCL_PAYMENT_SERIAL_NUMBER_ATTRIBUTE_ID (0x0031) #define ZCL_PAYMENT_TIMESTAMP_ATTRIBUTE_ID (0x0032) #define ZCL_TRANS_ID_ATTRIBUTE_ID (0x0033) #define ZCL_TRANS_STATUS_ATTRIBUTE_ID (0x0034) diff --git a/examples/bridge-app/bridge-common/gen/call-command-handler.cpp b/examples/bridge-app/bridge-common/gen/call-command-handler.cpp index d1a86ac8a37a67..8a3306f30630b6 100644 --- a/examples/bridge-app/bridge-common/gen/call-command-handler.cpp +++ b/examples/bridge-app/bridge-common/gen/call-command-handler.cpp @@ -72,7 +72,8 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd) switch (cmd->apsFrame->clusterId) { case ZCL_BASIC_CLUSTER_ID: - result = emberAfBasicClusterServerCommandParse(cmd); + // No commands are enabled for cluster Basic + result = status(false, true, cmd->mfgSpecific); break; case ZCL_LEVEL_CONTROL_CLUSTER_ID: result = emberAfLevelControlClusterServerCommandParse(cmd); @@ -90,26 +91,6 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd) // Cluster specific command parsing -EmberAfStatus emberAfBasicClusterServerCommandParse(EmberAfClusterCommand * cmd) -{ - bool wasHandled = false; - - if (!cmd->mfgSpecific) - { - switch (cmd->commandId) - { - case ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID: { - wasHandled = emberAfBasicClusterResetToFactoryDefaultsCallback(); - break; - } - default: { - // Unrecognized command ID, error status will apply. - break; - } - } - } - return status(wasHandled, true, cmd->mfgSpecific); -} EmberAfStatus emberAfLevelControlClusterServerCommandParse(EmberAfClusterCommand * cmd) { bool wasHandled = false; diff --git a/examples/bridge-app/bridge-common/gen/callback.h b/examples/bridge-app/bridge-common/gen/callback.h index 6b284ee368dc37..26742ee65aad54 100644 --- a/examples/bridge-app/bridge-common/gen/callback.h +++ b/examples/bridge-app/bridge-common/gen/callback.h @@ -271,12 +271,6 @@ void emberAfOnOffClusterServerTickCallback(chip::EndpointId endpoint); // Cluster Commands Callback -/** - * @brief Basic Cluster ResetToFactoryDefaults Command callback - */ - -bool emberAfBasicClusterResetToFactoryDefaultsCallback(); - /** * @brief Level Control Cluster Move Command callback * @param moveMode diff --git a/examples/bridge-app/bridge-common/gen/client-command-macro.h b/examples/bridge-app/bridge-common/gen/client-command-macro.h index 97de7f69cfff1d..f72c96f951dcff 100644 --- a/examples/bridge-app/bridge-common/gen/client-command-macro.h +++ b/examples/bridge-app/bridge-common/gen/client-command-macro.h @@ -256,15 +256,6 @@ emberAfFillExternalBuffer(mask, clusterId, ZCL_DISCOVER_ATTRIBUTES_EXTENDED_RESPONSE_COMMAND_ID, "ub", discoveryComplete, \ extendedDiscoverAttributesInfoRecords, extendedDiscoverAttributesInfoRecordsLen); -/** @brief Command description for ResetToFactoryDefaults - * - * Command: ResetToFactoryDefaults - */ -#define emberAfFillCommandBasicClusterResetToFactoryDefaults() \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID, "", ); - /** @brief Command description for Identify * * Command: Identify @@ -1795,6 +1786,33 @@ totalNumberOfNonEmptyProxyTableEntries, gpdSrcId, startIndex, gpdIeee, entriesCount, endpoint, \ proxyTableEntries, proxyTableEntriesLen, index); +/** @brief Command description for StartUp + * + * Command: StartUp + */ +#define emberAfFillCommandBasicClusterStartUp() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_START_UP_COMMAND_ID, "", ); + +/** @brief Command description for ShutDown + * + * Command: ShutDown + */ +#define emberAfFillCommandBasicClusterShutDown() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SHUT_DOWN_COMMAND_ID, "", ); + +/** @brief Command description for Leave + * + * Command: Leave + */ +#define emberAfFillCommandBasicClusterLeave() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_LEAVE_COMMAND_ID, "", ); + /** @brief Command description for SetFabric * * Command: SetFabric @@ -2964,6 +2982,15 @@ \ ZCL_SQUAWK_COMMAND_ID, "u", squawkInfo); +/** @brief Command description for Sleep + * + * Command: Sleep + */ +#define emberAfFillCommandLow \ + PowerClusterSleep() emberAfFillExternalBuffer(mask, \ + \ + ZCL_SLEEP_COMMAND_ID, "", ); + /** @brief Command description for MatchProtocolAddress * * Command: MatchProtocolAddress diff --git a/examples/bridge-app/bridge-common/gen/cluster-id.h b/examples/bridge-app/bridge-common/gen/cluster-id.h index 99de14e2586034..d77da915200ab4 100644 --- a/examples/bridge-app/bridge-common/gen/cluster-id.h +++ b/examples/bridge-app/bridge-common/gen/cluster-id.h @@ -20,9 +20,6 @@ // Prevent multiple inclusion #pragma once -// Definitions for cluster: Basic -#define ZCL_BASIC_CLUSTER_ID (0x0000) - // Definitions for cluster: Power Configuration #define ZCL_POWER_CONFIG_CLUSTER_ID (0x0001) @@ -83,6 +80,9 @@ // Definitions for cluster: Keep-Alive #define ZCL_KEEPALIVE_CLUSTER_ID (0x0025) +// Definitions for cluster: Basic +#define ZCL_BASIC_CLUSTER_ID (0x0028) + // Definitions for cluster: General Commissioning #define ZCL_GENERAL_COMMISSIONING_CLUSTER_ID (0x0030) @@ -239,6 +239,9 @@ // Definitions for cluster: IAS WD #define ZCL_IAS_WD_CLUSTER_ID (0x0502) +// Definitions for cluster: Low Power +#define ZCL_LOW_POWER_CLUSTER_ID (0x0508) + // Definitions for cluster: Application Basic #define ZCL_APPLICATION_BASIC_CLUSTER_ID (0x050D) diff --git a/examples/bridge-app/bridge-common/gen/command-id.h b/examples/bridge-app/bridge-common/gen/command-id.h index d31a267c6254af..adc2b1c6f32733 100644 --- a/examples/bridge-app/bridge-common/gen/command-id.h +++ b/examples/bridge-app/bridge-common/gen/command-id.h @@ -45,10 +45,6 @@ #define ZCL_DISCOVER_ATTRIBUTES_EXTENDED_COMMAND_ID (0x15) #define ZCL_DISCOVER_ATTRIBUTES_EXTENDED_RESPONSE_COMMAND_ID (0x16) -// Commands for cluster: Basic -#define ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID (0x00) -#define ZCL_MFG_SPECIFIC_PING_COMMAND_ID (0x00) - // Commands for cluster: Identify #define ZCL_IDENTIFY_COMMAND_ID (0x00) #define ZCL_IDENTIFY_QUERY_RESPONSE_COMMAND_ID (0x00) @@ -226,6 +222,12 @@ #define ZCL_GP_PROXY_TABLE_RESPONSE_COMMAND_ID (0x0B) #define ZCL_GP_PROXY_TABLE_REQUEST_COMMAND_ID (0x0B) +// Commands for cluster: Basic +#define ZCL_START_UP_COMMAND_ID (0x00) +#define ZCL_MFG_SPECIFIC_PING_COMMAND_ID (0x00) +#define ZCL_SHUT_DOWN_COMMAND_ID (0x01) +#define ZCL_LEAVE_COMMAND_ID (0x02) + // Commands for cluster: General Commissioning #define ZCL_SET_FABRIC_COMMAND_ID (0x00) #define ZCL_SET_FABRIC_RESPONSE_COMMAND_ID (0x01) @@ -369,6 +371,9 @@ #define ZCL_START_WARNING_COMMAND_ID (0x00) #define ZCL_SQUAWK_COMMAND_ID (0x01) +// Commands for cluster: Low Power +#define ZCL_SLEEP_COMMAND_ID (0x00) + // Commands for cluster: Generic Tunnel #define ZCL_MATCH_PROTOCOL_ADDRESS_COMMAND_ID (0x00) #define ZCL_MATCH_PROTOCOL_ADDRESS_RESPONSE_COMMAND_ID (0x00) diff --git a/examples/bridge-app/bridge-common/gen/endpoint_config.h b/examples/bridge-app/bridge-common/gen/endpoint_config.h index 9a456798226f46..b1860457e022a7 100644 --- a/examples/bridge-app/bridge-common/gen/endpoint_config.h +++ b/examples/bridge-app/bridge-common/gen/endpoint_config.h @@ -26,16 +26,106 @@ #if BIGENDIAN_CPU #define GENERATED_DEFAULTS \ { \ + /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "VendorName". side: server, big-endian */ /* 32 */ 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "ProductName". side: server, big-endian */ /* 64 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "UserLabel". side: server, big-endian */ /* 96 */ 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "Location". side: server, big-endian */ /* 112 */ 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "HardwareVersionString". side: server, big-endian */ /* 176 */ 0x00, 0x00, \ + 0x00, 0x00, /* Default for cluster: "Basic", attribute: "SoftwareVersion". side: server, big-endian */ /* 180 */ 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "SoftwareVersionString". side: server, big-endian */ /* 244 */ 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "VendorName". side: server, big-endian */ /* 276 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "ProductName". side: server, big-endian */ /* 308 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "UserLabel". side: server, big-endian */ /* 340 */ 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "Location". side: server, big-endian */ /* 356 */ 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "HardwareVersionString". side: server, big-endian */ /* 420 */ 0x00, 0x00, \ + 0x00, 0x00, /* Default for cluster: "Basic", attribute: "SoftwareVersion". side: server, big-endian */ /* 424 */ 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, /* Default for cluster: "Basic", attribute: "SoftwareVersionString". side: server, big-endian */ \ } #else // !BIGENDIAN_CPU #define GENERATED_DEFAULTS \ { \ + /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "VendorName". side: server, little-endian */ /* 32 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "ProductName". side: server, little-endian */ /* 64 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "UserLabel". side: server, little-endian */ /* 96 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "Location". side: server, little-endian */ /* 112 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "HardwareVersionString". side: server, little-endian */ /* 176 */ \ + 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "SoftwareVersion". side: server, little-endian */ /* 180 */ 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "SoftwareVersionString". side: server, little-endian */ /* 244 */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "VendorName". side: server, little-endian */ /* 276 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "ProductName". side: server, little-endian */ /* 308 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "UserLabel". side: server, little-endian */ /* 340 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "Location". side: server, little-endian */ /* 356 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "HardwareVersionString". side: server, little-endian */ /* 420 */ \ + 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "SoftwareVersion". side: server, little-endian */ /* 424 */ 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, \ + 0x00, /* Default for cluster: "Basic", attribute: "SoftwareVersionString". side: server, little-endian */ \ } #endif // BIGENDIAN_CPU -#define GENERATED_DEFAULTS_COUNT (0) +#define GENERATED_DEFAULTS_COUNT (14) #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ @@ -55,18 +145,49 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 29 +#define GENERATED_ATTRIBUTE_COUNT 50 #define GENERATED_ATTRIBUTES \ { \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 3 } }, /* Basic (server): cluster revision */ \ - { 0x0000, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0x08 } }, /* Basic (server): ZCL version */ \ - { \ - 0x0007, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0x00 } \ - }, /* Basic (server): power source */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 2 } }, /* On/off (server): cluster revision */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 2 } }, /* On/off (server): cluster revision */ \ { 0x0000, ZAP_TYPE(BOOLEAN), 1, 0, { (uint8_t *) 0x00 } }, /* On/off (server): on/off */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 3 } }, /* Level Control (server): cluster revision */ \ { 0x0000, ZAP_TYPE(INT8U), 1, 0, { (uint8_t *) 0x00 } }, /* Level Control (server): current level */ \ + { \ + 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 3 } \ + }, /* Basic (server): cluster revision */ \ + { \ + 0x0000, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } \ + }, /* Basic (server): InteractionModelVersion */ \ + { \ + 0x0001, ZAP_TYPE(CHAR_STRING), 32, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(0) } \ + }, /* Basic (server): VendorName */ \ + { 0x0002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } }, /* Basic (server): VendorID */ \ + { \ + 0x0003, ZAP_TYPE(CHAR_STRING), 32, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(32) } \ + }, /* Basic (server): ProductName */ \ + { 0x0004, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } }, /* Basic (server): ProductID */ \ + { 0x0005, \ + ZAP_TYPE(CHAR_STRING), \ + 32, \ + ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(64) } }, /* Basic (server): UserLabel */ \ + { 0x0006, \ + ZAP_TYPE(CHAR_STRING), \ + 16, \ + ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(96) } }, /* Basic (server): Location */ \ + { \ + 0x0007, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0x00 } \ + }, /* Basic (server): HardwareVersion */ \ + { \ + 0x0008, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(112) } \ + }, /* Basic (server): HardwareVersionString */ \ + { \ + 0x0009, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(176) } \ + }, /* Basic (server): SoftwareVersion */ \ + { \ + 0x000A, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(180) } \ + }, /* Basic (server): SoftwareVersionString */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 2 } }, /* On/off (server): cluster revision */ \ { 0x0000, ZAP_TYPE(BOOLEAN), 1, 0, { (uint8_t *) 0x00 } }, /* On/off (server): on/off */ \ { \ @@ -85,7 +206,43 @@ }, /* Level Control (server): options */ \ { \ 0x4000, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(WRITABLE), { (uint8_t *) 0 } \ - }, /* Level Control (server): start up current level */ \ + }, /* Level Control (server): start up current level */ \ + { \ + 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 3 } \ + }, /* Basic (server): cluster revision */ \ + { \ + 0x0000, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } \ + }, /* Basic (server): InteractionModelVersion */ \ + { \ + 0x0001, ZAP_TYPE(CHAR_STRING), 32, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(244) } \ + }, /* Basic (server): VendorName */ \ + { 0x0002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } }, /* Basic (server): VendorID */ \ + { \ + 0x0003, ZAP_TYPE(CHAR_STRING), 32, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(276) } \ + }, /* Basic (server): ProductName */ \ + { 0x0004, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } }, /* Basic (server): ProductID */ \ + { 0x0005, \ + ZAP_TYPE(CHAR_STRING), \ + 32, \ + ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(308) } }, /* Basic (server): UserLabel */ \ + { 0x0006, \ + ZAP_TYPE(CHAR_STRING), \ + 16, \ + ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(340) } }, /* Basic (server): Location */ \ + { \ + 0x0007, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0x00 } \ + }, /* Basic (server): HardwareVersion */ \ + { \ + 0x0008, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(356) } \ + }, /* Basic (server): HardwareVersionString */ \ + { \ + 0x0009, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(420) } \ + }, /* Basic (server): SoftwareVersion */ \ + { \ + 0x000A, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(424) } \ + }, /* Basic (server): SoftwareVersionString */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 2 } }, /* On/off (server): cluster revision */ \ { 0x0000, ZAP_TYPE(BOOLEAN), 1, 0, { (uint8_t *) 0x00 } }, /* On/off (server): on/off */ \ { \ @@ -120,42 +277,49 @@ }; #define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask -#define GENERATED_CLUSTER_COUNT 7 +#define GENERATED_CLUSTER_COUNT 8 #define GENERATED_CLUSTERS \ { \ - { 0x0000, ZAP_ATTRIBUTE_INDEX(0), 3, 4, ZAP_CLUSTER_MASK(SERVER), NULL }, /* Endpoint: 0, Cluster: Basic (server) */ \ - { 0x0006, \ - ZAP_ATTRIBUTE_INDEX(3), \ - 2, \ - 3, \ - ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ - chipFuncArrayOnOffServer }, /* Endpoint: 1, Cluster: On/off (server) */ \ + { \ + 0x0006, \ + ZAP_ATTRIBUTE_INDEX(0), \ + 2, \ + 3, \ + ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ + chipFuncArrayOnOffServer \ + }, /* Endpoint: 1, Cluster: On/off (server) */ \ { 0x0008, \ - ZAP_ATTRIBUTE_INDEX(5), \ + ZAP_ATTRIBUTE_INDEX(2), \ 2, \ 3, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayLevelControlServer }, /* Endpoint: 1, Cluster: Level Control (server) */ \ + { \ + 0x0028, ZAP_ATTRIBUTE_INDEX(4), 12, 254, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 1, Cluster: Basic (server) */ \ { 0x0006, \ - ZAP_ATTRIBUTE_INDEX(7), \ + ZAP_ATTRIBUTE_INDEX(16), \ 6, \ 9, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayOnOffServer }, /* Endpoint: 2, Cluster: On/off (server) */ \ { 0x0008, \ - ZAP_ATTRIBUTE_INDEX(13), \ + ZAP_ATTRIBUTE_INDEX(22), \ 5, \ 7, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayLevelControlServer }, /* Endpoint: 2, Cluster: Level Control (server) */ \ + { \ + 0x0028, ZAP_ATTRIBUTE_INDEX(27), 12, 254, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 2, Cluster: Basic (server) */ \ { 0x0006, \ - ZAP_ATTRIBUTE_INDEX(18), \ + ZAP_ATTRIBUTE_INDEX(39), \ 6, \ 9, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayOnOffServer }, /* Endpoint: 3, Cluster: On/off (server) */ \ { 0x0008, \ - ZAP_ATTRIBUTE_INDEX(24), \ + ZAP_ATTRIBUTE_INDEX(45), \ 5, \ 7, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ @@ -167,18 +331,18 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 1, 4 }, { ZAP_CLUSTER_INDEX(1), 2, 6 }, { ZAP_CLUSTER_INDEX(3), 2, 16 }, \ - { ZAP_CLUSTER_INDEX(5), 2, 16 }, \ + { ZAP_CLUSTER_INDEX(0), 0, 0 }, { ZAP_CLUSTER_INDEX(0), 3, 260 }, { ZAP_CLUSTER_INDEX(3), 3, 270 }, \ + { ZAP_CLUSTER_INDEX(6), 2, 16 }, \ } // Largest attribute size is needed for various buffers -#define ATTRIBUTE_LARGEST (3) +#define ATTRIBUTE_LARGEST (64) // Total size of singleton attributes -#define ATTRIBUTE_SINGLETONS_SIZE (4) +#define ATTRIBUTE_SINGLETONS_SIZE (508) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (42) +#define ATTRIBUTE_MAX_SIZE (546) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (4) @@ -222,11 +386,10 @@ // Array of EmberAfCommandMetadata structs. #define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask -#define EMBER_AF_GENERATED_COMMAND_COUNT (40) +#define EMBER_AF_GENERATED_COMMAND_COUNT (45) #define GENERATED_COMMANDS \ { \ - { 0x0000, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Basic (server): ResetToFactoryDefaults */ \ - { 0x0006, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* On/off (server): Off */ \ + { 0x0006, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* On/off (server): Off */ \ { 0x0006, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* On/off (server): Off */ \ { 0x0006, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* On/off (server): Off */ \ { 0x0006, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* On/off (server): On */ \ @@ -265,6 +428,12 @@ { 0x0008, 0x07, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Level Control (server): StopWithOnOff */ \ { 0x0008, 0x07, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Level Control (server): StopWithOnOff */ \ { 0x0008, 0x07, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Level Control (server): StopWithOnOff */ \ + { 0x0028, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): StartUp */ \ + { 0x0028, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): StartUp */ \ + { 0x0028, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): ShutDown */ \ + { 0x0028, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): ShutDown */ \ + { 0x0028, 0x02, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): Leave */ \ + { 0x0028, 0x02, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): Leave */ \ } // Array of EmberAfManufacturerCodeEntry structures for commands. diff --git a/examples/bridge-app/bridge-common/gen/gen_config.h b/examples/bridge-app/bridge-common/gen/gen_config.h index 5aa3207d2e5f3d..3f145a50331b91 100644 --- a/examples/bridge-app/bridge-common/gen/gen_config.h +++ b/examples/bridge-app/bridge-common/gen/gen_config.h @@ -29,7 +29,7 @@ #define EMBER_APS_UNICAST_MESSAGE_COUNT 10 /**** Cluster endpoint counts ****/ -#define EMBER_AF_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT (2) #define EMBER_AF_LEVEL_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (3) #define EMBER_AF_ON_OFF_CLUSTER_SERVER_ENDPOINT_COUNT (3) diff --git a/examples/bridge-app/bridge-common/gen/print-cluster.h b/examples/bridge-app/bridge-common/gen/print-cluster.h index 86a2a27beec86b..bd08d38a581506 100644 --- a/examples/bridge-app/bridge-common/gen/print-cluster.h +++ b/examples/bridge-app/bridge-common/gen/print-cluster.h @@ -24,12 +24,6 @@ // to the "EmberAfClusterName" defined in the ZCL header. // The names of clusters that are not present, are removed. -#if defined(ZCL_USING_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_BASIC_CLUSTER_CLIENT) -#define CHIP_PRINTCLUSTER_BASIC_CLUSTER { ZCL_BASIC_CLUSTER_ID, 0, "Basic" }, -#else -#define CHIP_PRINTCLUSTER_BASIC_CLUSTER -#endif - #if defined(ZCL_USING_POWER_CONFIG_CLUSTER_SERVER) || defined(ZCL_USING_POWER_CONFIG_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_POWER_CONFIG_CLUSTER { ZCL_POWER_CONFIG_CLUSTER_ID, 1, "Power Configuration" }, #else @@ -150,6 +144,12 @@ #define CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER #endif +#if defined(ZCL_USING_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_BASIC_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_BASIC_CLUSTER { ZCL_BASIC_CLUSTER_ID, 40, "Basic" }, +#else +#define CHIP_PRINTCLUSTER_BASIC_CLUSTER +#endif + #if defined(ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER { ZCL_GENERAL_COMMISSIONING_CLUSTER_ID, 48, "General Commissioning" }, #else @@ -526,6 +526,12 @@ #define CHIP_PRINTCLUSTER_IAS_WD_CLUSTER #endif +#if defined(ZCL_USING_LOW_POWER_CLUSTER_SERVER) || defined(ZCL_USING_LOW_POWER_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER { ZCL_LOW_POWER_CLUSTER_ID, 1288, "Low Power" }, +#else +#define CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER +#endif + #if defined(ZCL_USING_APPLICATION_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_APPLICATION_BASIC_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_APPLICATION_BASIC_CLUSTER { ZCL_APPLICATION_BASIC_CLUSTER_ID, 1293, "Application Basic" }, #else @@ -784,7 +790,6 @@ #endif #define CLUSTER_IDS_TO_NAMES \ - CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_POWER_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DEVICE_TEMP_CLUSTER \ CHIP_PRINTCLUSTER_IDENTIFY_CLUSTER \ @@ -805,6 +810,7 @@ CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER \ CHIP_PRINTCLUSTER_GREEN_POWER_CLUSTER \ CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER \ + CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DOOR_LOCK_CLUSTER \ @@ -857,6 +863,7 @@ CHIP_PRINTCLUSTER_IAS_ZONE_CLUSTER \ CHIP_PRINTCLUSTER_IAS_ACE_CLUSTER \ CHIP_PRINTCLUSTER_IAS_WD_CLUSTER \ + CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER \ CHIP_PRINTCLUSTER_APPLICATION_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_GENERIC_TUNNEL_CLUSTER \ CHIP_PRINTCLUSTER_BACNET_PROTOCOL_TUNNEL_CLUSTER \ diff --git a/examples/chip-tool/chip-tool.zap b/examples/chip-tool/chip-tool.zap index 251ee0f5ffb216..55a9cdbb4cf495 100644 --- a/examples/chip-tool/chip-tool.zap +++ b/examples/chip-tool/chip-tool.zap @@ -1,5 +1,5 @@ { - "writeTime": "Mon Mar 08 2021 19:20:08 GMT+0100 (Central European Standard Time)", + "writeTime": "Thu Mar 11 2021 18:15:06 GMT+0100 (Central European Standard Time)", "featureLevel": 11, "creator": "zap", "keyValuePairs": [ @@ -38,15 +38,15 @@ "deviceTypeProfileId": 259, "clusters": [ { - "name": "Basic", - "code": 0, + "name": "Identify", + "code": 3, "mfgCode": null, - "define": "BASIC_CLUSTER", + "define": "IDENTIFY_CLUSTER", "side": "client", "enabled": 1, "commands": [ { - "name": "ResetToFactoryDefaults", + "name": "Identify", "code": 0, "mfgCode": null, "source": "client", @@ -54,95 +54,14 @@ "outgoing": 1 }, { - "name": "MfgSpecificPing", - "code": 0, - "mfgCode": "4098", + "name": "IdentifyQuery", + "code": 1, + "mfgCode": null, "source": "client", - "incoming": 0, + "incoming": 1, "outgoing": 1 } ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Basic", - "code": 0, - "mfgCode": null, - "define": "BASIC_CLUSTER", - "side": "server", - "enabled": 0, - "commands": [], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ZCL version", - "code": 0, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x08", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "power source", - "code": 7, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Identify", - "code": 3, - "mfgCode": null, - "define": "IDENTIFY_CLUSTER", - "side": "client", - "enabled": 1, "attributes": [ { "name": "cluster revision", @@ -159,24 +78,6 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [ - { - "name": "Identify", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "IdentifyQuery", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } ] }, { @@ -835,6 +736,257 @@ } ] }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "client", + "enabled": 1, + "commands": [ + { + "name": "MfgSpecificPing", + "code": 0, + "mfgCode": "4098", + "source": "client", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [ + { + "name": "StartUp", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 0 + }, + { + "name": "ShutDown", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 0 + }, + { + "name": "Leave", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "InteractionModelVersion", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorName", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorID", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductName", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductID", + "code": 4, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UserLabel", + "code": 5, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Location", + "code": 6, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersion", + "code": 7, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersionString", + "code": 8, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersion", + "code": 9, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersionString", + "code": 10, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, { "name": "General Commissioning", "code": 48, @@ -893,6 +1045,32 @@ "define": "GENERAL_COMMISSIONING_CLUSTER", "side": "server", "enabled": 0, + "commands": [ + { + "name": "SetFabricResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ArmFailSafeResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "CommissioningCompleteResponse", + "code": 7, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], "attributes": [ { "name": "cluster revision", @@ -939,32 +1117,6 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [ - { - "name": "SetFabricResponse", - "code": 1, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "ArmFailSafeResponse", - "code": 3, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "CommissioningCompleteResponse", - "code": 7, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - } ] }, { @@ -1832,6 +1984,23 @@ "define": "BARRIER_CONTROL_CLUSTER", "side": "client", "enabled": 1, + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], "commands": [ { "name": "BarrierControlGoToPercent", @@ -1849,23 +2018,6 @@ "incoming": 1, "outgoing": 1 } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0001", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } ] }, { @@ -1961,23 +2113,6 @@ "define": "COLOR_CONTROL_CLUSTER", "side": "client", "enabled": 1, - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ], "commands": [ { "name": "MoveToHue", @@ -2091,6 +2226,23 @@ "incoming": 1, "outgoing": 1 } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } ] }, { @@ -3535,6 +3687,16 @@ "define": "MEDIA_PLAYBACK_CLUSTER", "side": "server", "enabled": 0, + "commands": [ + { + "name": "Playback", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], "attributes": [ { "name": "cluster revision", @@ -3566,16 +3728,6 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [ - { - "name": "Playback", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - } ] }, { @@ -3585,23 +3737,6 @@ "define": "CONTENT_LAUNCH_CLUSTER", "side": "client", "enabled": 1, - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0001", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ], "commands": [ { "name": "LaunchContent", @@ -3619,6 +3754,23 @@ "incoming": 1, "outgoing": 1 } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } ] }, { diff --git a/examples/chip-tool/commands/clusters/Commands.h b/examples/chip-tool/commands/clusters/Commands.h index d13563c3074682..4f407a3f30c322 100644 --- a/examples/chip-tool/commands/clusters/Commands.h +++ b/examples/chip-tool/commands/clusters/Commands.h @@ -25,7 +25,6 @@ #include "gen/CHIPClientCallbacks.h" #include #include -#include static void OnDefaultSuccessResponse(void * context) { @@ -43,12 +42,6 @@ static void OnDefaultFailureResponse(void * context, uint8_t status) command->SetCommandExitStatus(false); } -typedef void (*UnsupportedAttributeCallback)(void * context); -static void OnUnsupportedAttributeResponse(void * context) -{ - ChipLogError(chipTool, "Unsupported attribute Response. This should never happen !"); -} - static void OnBooleanAttributeResponse(void * context, bool value) { ChipLogProgress(chipTool, "Boolean attribute Response: %d", value); @@ -73,9 +66,9 @@ static void OnInt16uAttributeResponse(void * context, uint16_t value) command->SetCommandExitStatus(true); } -static void OnInt16sAttributeResponse(void * context, int16_t value) +static void OnInt32uAttributeResponse(void * context, uint32_t value) { - ChipLogProgress(chipTool, "Int16s attribute Response: %" PRId16, value); + ChipLogProgress(chipTool, "Int32u attribute Response: %" PRIu32, value); ModelCommand * command = reinterpret_cast(context); command->SetCommandExitStatus(true); @@ -89,6 +82,27 @@ static void OnInt64uAttributeResponse(void * context, uint64_t value) command->SetCommandExitStatus(true); } +static void OnInt16sAttributeResponse(void * context, int16_t value) +{ + ChipLogProgress(chipTool, "Int16s attribute Response: %" PRId16, value); + + ModelCommand * command = reinterpret_cast(context); + command->SetCommandExitStatus(true); +} + +static void OnStringAttributeResponse(void * context, const chip::ByteSpan value) +{ + char * str = (char *) malloc(value.size() * sizeof(char)); + memmove(str, value.data(), value.size()); + str[value.size()] = '\0'; + free(str); + + ChipLogProgress(chipTool, "String attribute Response: %s (%" PRIu16 ")", str, strlen(str)); + + ModelCommand * command = reinterpret_cast(context); + command->SetCommandExitStatus(true); +} + static void OnContentLaunchClusterLaunchContentResponse(void * context, uint8_t contentLaunchStatus) { ChipLogProgress(chipTool, "ContentLaunchClusterLaunchContentResponse"); @@ -414,7 +428,7 @@ static void OnScenesClusterViewSceneResponse(void * context, uint16_t groupId, u |---------------------------------------------------------------------+--------| | ApplicationBasic | 0x050D | | BarrierControl | 0x0103 | -| Basic | 0x0000 | +| Basic | 0x0028 | | Binding | 0xF000 | | ColorControl | 0x0300 | | ContentLaunch | 0xF002 | @@ -432,7 +446,7 @@ static void OnScenesClusterViewSceneResponse(void * context, uint16_t groupId, u constexpr chip::ClusterId kApplicationBasicClusterId = 0x050D; constexpr chip::ClusterId kBarrierControlClusterId = 0x0103; -constexpr chip::ClusterId kBasicClusterId = 0x0000; +constexpr chip::ClusterId kBasicClusterId = 0x0028; constexpr chip::ClusterId kBindingClusterId = 0xF000; constexpr chip::ClusterId kColorControlClusterId = 0x0300; constexpr chip::ClusterId kContentLaunchClusterId = 0xF002; @@ -509,8 +523,8 @@ class ReadApplicationBasicVendorName : public ModelCommand } private: - chip::Callback::Callback * onSuccessCallback = - new chip::Callback::Callback(OnUnsupportedAttributeResponse, this); + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnStringAttributeResponse, this); chip::Callback::Callback * onFailureCallback = new chip::Callback::Callback(OnDefaultFailureResponse, this); }; @@ -565,8 +579,8 @@ class ReadApplicationBasicApplicationName : public ModelCommand } private: - chip::Callback::Callback * onSuccessCallback = - new chip::Callback::Callback(OnUnsupportedAttributeResponse, this); + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnStringAttributeResponse, this); chip::Callback::Callback * onFailureCallback = new chip::Callback::Callback(OnDefaultFailureResponse, this); }; @@ -621,8 +635,8 @@ class ReadApplicationBasicApplicationId : public ModelCommand } private: - chip::Callback::Callback * onSuccessCallback = - new chip::Callback::Callback(OnUnsupportedAttributeResponse, this); + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnStringAttributeResponse, this); chip::Callback::Callback * onFailureCallback = new chip::Callback::Callback(OnDefaultFailureResponse, this); }; @@ -944,15 +958,23 @@ class ReadBarrierControlClusterRevision : public ModelCommand }; /*----------------------------------------------------------------------------*\ -| Cluster Basic | 0x0000 | +| Cluster Basic | 0x0028 | |------------------------------------------------------------------------------| | Commands: | | | * MfgSpecificPing | 0x00 | -| * ResetToFactoryDefaults | 0x00 | |------------------------------------------------------------------------------| | Attributes: | | -| * ZclVersion | 0x0000 | -| * PowerSource | 0x0007 | +| * InteractionModelVersion | 0x0000 | +| * VendorName | 0x0001 | +| * VendorID | 0x0002 | +| * ProductName | 0x0003 | +| * ProductID | 0x0004 | +| * UserLabel | 0x0005 | +| * Location | 0x0006 | +| * HardwareVersion | 0x0007 | +| * HardwareVersionString | 0x0008 | +| * SoftwareVersion | 0x0009 | +| * SoftwareVersionString | 0x000A | | * ClusterRevision | 0xFFFD | \*----------------------------------------------------------------------------*/ @@ -966,7 +988,7 @@ class BasicMfgSpecificPing : public ModelCommand CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override { - ChipLogProgress(chipTool, "Sending cluster (0x0000) command (0x00) on endpoint %" PRIu16, endpointId); + ChipLogProgress(chipTool, "Sending cluster (0x0028) command (0x00) on endpoint %" PRIu16, endpointId); chip::Controller::BasicCluster cluster; cluster.Associate(device, endpointId); @@ -981,20 +1003,20 @@ class BasicMfgSpecificPing : public ModelCommand }; /* - * Command ResetToFactoryDefaults + * Discover Attributes */ -class BasicResetToFactoryDefaults : public ModelCommand +class DiscoverBasicAttributes : public ModelCommand { public: - BasicResetToFactoryDefaults() : ModelCommand("reset-to-factory-defaults") { ModelCommand::AddArguments(); } + DiscoverBasicAttributes() : ModelCommand("discover") { ModelCommand::AddArguments(); } CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override { - ChipLogProgress(chipTool, "Sending cluster (0x0000) command (0x00) on endpoint %" PRIu16, endpointId); + ChipLogProgress(chipTool, "Sending cluster (0x0000) command (0x0C) on endpoint %" PRIu16, endpointId); chip::Controller::BasicCluster cluster; cluster.Associate(device, endpointId); - return cluster.ResetToFactoryDefaults(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + return cluster.DiscoverAttributes(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); } private: @@ -1005,20 +1027,191 @@ class BasicResetToFactoryDefaults : public ModelCommand }; /* - * Discover Attributes + * Attribute InteractionModelVersion */ -class DiscoverBasicAttributes : public ModelCommand +class ReadBasicInteractionModelVersion : public ModelCommand { public: - DiscoverBasicAttributes() : ModelCommand("discover") { ModelCommand::AddArguments(); } + ReadBasicInteractionModelVersion() : ModelCommand("read") + { + AddArgument("attr-name", "interaction-model-version"); + ModelCommand::AddArguments(); + } CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override { - ChipLogProgress(chipTool, "Sending cluster (0x0000) command (0x0C) on endpoint %" PRIu16, endpointId); + ChipLogProgress(chipTool, "Sending cluster (0x0028) command (0x00) on endpoint %" PRIu16, endpointId); chip::Controller::BasicCluster cluster; cluster.Associate(device, endpointId); - return cluster.DiscoverAttributes(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + return cluster.ReadAttributeInteractionModelVersion(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnInt16uAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +/* + * Attribute VendorName + */ +class ReadBasicVendorName : public ModelCommand +{ +public: + ReadBasicVendorName() : ModelCommand("read") + { + AddArgument("attr-name", "vendor-name"); + ModelCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0028) command (0x00) on endpoint %" PRIu16, endpointId); + + chip::Controller::BasicCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeVendorName(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnStringAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +/* + * Attribute VendorID + */ +class ReadBasicVendorID : public ModelCommand +{ +public: + ReadBasicVendorID() : ModelCommand("read") + { + AddArgument("attr-name", "vendor-id"); + ModelCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0028) command (0x00) on endpoint %" PRIu16, endpointId); + + chip::Controller::BasicCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeVendorID(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnInt16uAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +/* + * Attribute ProductName + */ +class ReadBasicProductName : public ModelCommand +{ +public: + ReadBasicProductName() : ModelCommand("read") + { + AddArgument("attr-name", "product-name"); + ModelCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0028) command (0x00) on endpoint %" PRIu16, endpointId); + + chip::Controller::BasicCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeProductName(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnStringAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +/* + * Attribute ProductID + */ +class ReadBasicProductID : public ModelCommand +{ +public: + ReadBasicProductID() : ModelCommand("read") + { + AddArgument("attr-name", "product-id"); + ModelCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0028) command (0x00) on endpoint %" PRIu16, endpointId); + + chip::Controller::BasicCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeProductID(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnInt16uAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +/* + * Attribute UserLabel + */ +class ReadBasicUserLabel : public ModelCommand +{ +public: + ReadBasicUserLabel() : ModelCommand("read") + { + AddArgument("attr-name", "user-label"); + ModelCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0028) command (0x00) on endpoint %" PRIu16, endpointId); + + chip::Controller::BasicCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeUserLabel(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnStringAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +class WriteBasicUserLabel : public ModelCommand +{ +public: + WriteBasicUserLabel() : ModelCommand("write") + { + AddArgument("attr-name", "user-label"); + AddArgument("attr-value", &mValue); + ModelCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0028) command (0x01) on endpoint %" PRIu16, endpointId); + + chip::Controller::BasicCluster cluster; + cluster.Associate(device, endpointId); + return cluster.WriteAttributeUserLabel(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), + chip::ByteSpan(chip::Uint8::from_char(mValue), strlen(mValue))); } private: @@ -1026,60 +1219,173 @@ class DiscoverBasicAttributes : public ModelCommand new chip::Callback::Callback(OnDefaultSuccessResponse, this); chip::Callback::Callback * onFailureCallback = new chip::Callback::Callback(OnDefaultFailureResponse, this); + char * mValue; }; /* - * Attribute ZclVersion + * Attribute Location */ -class ReadBasicZclVersion : public ModelCommand +class ReadBasicLocation : public ModelCommand { public: - ReadBasicZclVersion() : ModelCommand("read") + ReadBasicLocation() : ModelCommand("read") { - AddArgument("attr-name", "zcl-version"); + AddArgument("attr-name", "location"); ModelCommand::AddArguments(); } CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override { - ChipLogProgress(chipTool, "Sending cluster (0x0000) command (0x00) on endpoint %" PRIu16, endpointId); + ChipLogProgress(chipTool, "Sending cluster (0x0028) command (0x00) on endpoint %" PRIu16, endpointId); chip::Controller::BasicCluster cluster; cluster.Associate(device, endpointId); - return cluster.ReadAttributeZclVersion(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + return cluster.ReadAttributeLocation(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); } private: - chip::Callback::Callback * onSuccessCallback = - new chip::Callback::Callback(OnInt8uAttributeResponse, this); + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnStringAttributeResponse, this); chip::Callback::Callback * onFailureCallback = new chip::Callback::Callback(OnDefaultFailureResponse, this); }; +class WriteBasicLocation : public ModelCommand +{ +public: + WriteBasicLocation() : ModelCommand("write") + { + AddArgument("attr-name", "location"); + AddArgument("attr-value", &mValue); + ModelCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0028) command (0x01) on endpoint %" PRIu16, endpointId); + + chip::Controller::BasicCluster cluster; + cluster.Associate(device, endpointId); + return cluster.WriteAttributeLocation(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), + chip::ByteSpan(chip::Uint8::from_char(mValue), strlen(mValue))); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnDefaultSuccessResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); + char * mValue; +}; + /* - * Attribute PowerSource + * Attribute HardwareVersion */ -class ReadBasicPowerSource : public ModelCommand +class ReadBasicHardwareVersion : public ModelCommand { public: - ReadBasicPowerSource() : ModelCommand("read") + ReadBasicHardwareVersion() : ModelCommand("read") { - AddArgument("attr-name", "power-source"); + AddArgument("attr-name", "hardware-version"); ModelCommand::AddArguments(); } CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override { - ChipLogProgress(chipTool, "Sending cluster (0x0000) command (0x00) on endpoint %" PRIu16, endpointId); + ChipLogProgress(chipTool, "Sending cluster (0x0028) command (0x00) on endpoint %" PRIu16, endpointId); chip::Controller::BasicCluster cluster; cluster.Associate(device, endpointId); - return cluster.ReadAttributePowerSource(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + return cluster.ReadAttributeHardwareVersion(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); } private: - chip::Callback::Callback * onSuccessCallback = - new chip::Callback::Callback(OnInt8uAttributeResponse, this); + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnInt16uAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +/* + * Attribute HardwareVersionString + */ +class ReadBasicHardwareVersionString : public ModelCommand +{ +public: + ReadBasicHardwareVersionString() : ModelCommand("read") + { + AddArgument("attr-name", "hardware-version-string"); + ModelCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0028) command (0x00) on endpoint %" PRIu16, endpointId); + + chip::Controller::BasicCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeHardwareVersionString(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnStringAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +/* + * Attribute SoftwareVersion + */ +class ReadBasicSoftwareVersion : public ModelCommand +{ +public: + ReadBasicSoftwareVersion() : ModelCommand("read") + { + AddArgument("attr-name", "software-version"); + ModelCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0028) command (0x00) on endpoint %" PRIu16, endpointId); + + chip::Controller::BasicCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeSoftwareVersion(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnInt32uAttributeResponse, this); + chip::Callback::Callback * onFailureCallback = + new chip::Callback::Callback(OnDefaultFailureResponse, this); +}; + +/* + * Attribute SoftwareVersionString + */ +class ReadBasicSoftwareVersionString : public ModelCommand +{ +public: + ReadBasicSoftwareVersionString() : ModelCommand("read") + { + AddArgument("attr-name", "software-version-string"); + ModelCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x0028) command (0x00) on endpoint %" PRIu16, endpointId); + + chip::Controller::BasicCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttributeSoftwareVersionString(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); + } + +private: + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnStringAttributeResponse, this); chip::Callback::Callback * onFailureCallback = new chip::Callback::Callback(OnDefaultFailureResponse, this); }; @@ -1098,7 +1404,7 @@ class ReadBasicClusterRevision : public ModelCommand CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override { - ChipLogProgress(chipTool, "Sending cluster (0x0000) command (0x00) on endpoint %" PRIu16, endpointId); + ChipLogProgress(chipTool, "Sending cluster (0x0028) command (0x00) on endpoint %" PRIu16, endpointId); chip::Controller::BasicCluster cluster; cluster.Associate(device, endpointId); @@ -2218,8 +2524,8 @@ class ReadColorControlCompensationText : public ModelCommand } private: - chip::Callback::Callback * onSuccessCallback = - new chip::Callback::Callback(OnUnsupportedAttributeResponse, this); + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnStringAttributeResponse, this); chip::Callback::Callback * onFailureCallback = new chip::Callback::Callback(OnDefaultFailureResponse, this); }; @@ -4424,7 +4730,8 @@ class DoorLockLockDoor : public ModelCommand chip::Controller::DoorLockCluster cluster; cluster.Associate(device, endpointId); - return cluster.LockDoor(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mPin); + return cluster.LockDoor(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), + chip::ByteSpan(chip::Uint8::from_char(mPin), strlen(mPin))); } private: @@ -4493,7 +4800,8 @@ class DoorLockSetPin : public ModelCommand chip::Controller::DoorLockCluster cluster; cluster.Associate(device, endpointId); - return cluster.SetPin(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mUserId, mUserStatus, mUserType, mPin); + return cluster.SetPin(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mUserId, mUserStatus, mUserType, + chip::ByteSpan(chip::Uint8::from_char(mPin), strlen(mPin))); } private: @@ -4528,7 +4836,8 @@ class DoorLockSetRfid : public ModelCommand chip::Controller::DoorLockCluster cluster; cluster.Associate(device, endpointId); - return cluster.SetRfid(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mUserId, mUserStatus, mUserType, mId); + return cluster.SetRfid(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mUserId, mUserStatus, mUserType, + chip::ByteSpan(chip::Uint8::from_char(mId), strlen(mId))); } private: @@ -4671,7 +4980,8 @@ class DoorLockUnlockDoor : public ModelCommand chip::Controller::DoorLockCluster cluster; cluster.Associate(device, endpointId); - return cluster.UnlockDoor(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mPin); + return cluster.UnlockDoor(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), + chip::ByteSpan(chip::Uint8::from_char(mPin), strlen(mPin))); } private: @@ -4701,7 +5011,8 @@ class DoorLockUnlockWithTimeout : public ModelCommand chip::Controller::DoorLockCluster cluster; cluster.Associate(device, endpointId); - return cluster.UnlockWithTimeout(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mTimeoutInSeconds, mPin); + return cluster.UnlockWithTimeout(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mTimeoutInSeconds, + chip::ByteSpan(chip::Uint8::from_char(mPin), strlen(mPin))); } private: @@ -5048,8 +5359,8 @@ class ReadGeneralCommissioningFabricId : public ModelCommand } private: - chip::Callback::Callback * onSuccessCallback = - new chip::Callback::Callback(OnUnsupportedAttributeResponse, this); + chip::Callback::Callback * onSuccessCallback = + new chip::Callback::Callback(OnStringAttributeResponse, this); chip::Callback::Callback * onFailureCallback = new chip::Callback::Callback(OnDefaultFailureResponse, this); }; @@ -5172,7 +5483,8 @@ class GroupsAddGroup : public ModelCommand chip::Controller::GroupsCluster cluster; cluster.Associate(device, endpointId); - return cluster.AddGroup(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mGroupId, mGroupName); + return cluster.AddGroup(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mGroupId, + chip::ByteSpan(chip::Uint8::from_char(mGroupName), strlen(mGroupName))); } private: @@ -5203,7 +5515,8 @@ class GroupsAddGroupIfIdentifying : public ModelCommand chip::Controller::GroupsCluster cluster; cluster.Associate(device, endpointId); - return cluster.AddGroupIfIdentifying(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mGroupId, mGroupName); + return cluster.AddGroupIfIdentifying(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mGroupId, + chip::ByteSpan(chip::Uint8::from_char(mGroupName), strlen(mGroupName))); } private: @@ -6657,7 +6970,8 @@ class ScenesAddScene : public ModelCommand chip::Controller::ScenesCluster cluster; cluster.Associate(device, endpointId); return cluster.AddScene(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mGroupId, mSceneId, mTransitionTime, - mSceneName, mClusterId, mLength, mValue); + chip::ByteSpan(chip::Uint8::from_char(mSceneName), strlen(mSceneName)), mClusterId, mLength, + mValue); } private: @@ -7275,8 +7589,22 @@ void registerClusterBasic(Commands & commands) const char * clusterName = "Basic"; commands_list clusterCommands = { - make_unique(), make_unique(), make_unique(), - make_unique(), make_unique(), make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), }; commands.Register(clusterName, clusterCommands); diff --git a/examples/chip-tool/gen/CHIPClientCallbacks.cpp b/examples/chip-tool/gen/CHIPClientCallbacks.cpp index 952cbc6ee063c2..71fe6c668cc75d 100644 --- a/examples/chip-tool/gen/CHIPClientCallbacks.cpp +++ b/examples/chip-tool/gen/CHIPClientCallbacks.cpp @@ -272,10 +272,6 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag case 0x38: // semi / Semi-precision case 0x39: // single / Single precision case 0x3A: // double / Double precision - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string case 0x48: // array / Array case 0x49: // struct / Structure case 0x50: // set / Set @@ -289,6 +285,48 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag return true; } + case 0x41: // octstr / Octet string + case 0x42: // string / Character string + { + // Short Strings must contains at least one byte for the length + CHECK_MESSAGE_LENGTH(1); + uint8_t length = chip::Encoding::Read8(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + + case 0x43: // octstr16 / Long octet string + case 0x44: // string16 / Long character string + { + // Long Strings must contains at least two bytes for the length + CHECK_MESSAGE_LENGTH(2); + uint16_t length = chip::Encoding::LittleEndian::Read16(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFFFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFFFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + case 0x08: // data8 / 8-bit data case 0x18: // map8 / 8-bit bitmap case 0x20: // uint8 / Unsigned 8-bit integer @@ -1489,10 +1527,6 @@ bool emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * message, uin case 0x38: // semi / Semi-precision case 0x39: // single / Single precision case 0x3A: // double / Double precision - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string case 0x48: // array / Array case 0x49: // struct / Structure case 0x50: // set / Set @@ -1503,6 +1537,48 @@ bool emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * message, uin return true; } + case 0x41: // octstr / Octet string + case 0x42: // string / Character string + { + // Short Strings must contains at least one byte for the length + CHECK_MESSAGE_LENGTH(1); + uint8_t length = chip::Encoding::Read8(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onReportCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + + case 0x43: // octstr16 / Long octet string + case 0x44: // string16 / Long character string + { + // Long Strings must contains at least two bytes for the length + CHECK_MESSAGE_LENGTH(2); + uint16_t length = chip::Encoding::LittleEndian::Read16(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFFFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFFFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onReportCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + case 0x08: // data8 / 8-bit data case 0x18: // map8 / 8-bit bitmap case 0x20: // uint8 / Unsigned 8-bit integer diff --git a/examples/chip-tool/gen/CHIPClientCallbacks.h b/examples/chip-tool/gen/CHIPClientCallbacks.h index ae3e2fc5a99091..00c37b8efd445a 100644 --- a/examples/chip-tool/gen/CHIPClientCallbacks.h +++ b/examples/chip-tool/gen/CHIPClientCallbacks.h @@ -20,6 +20,7 @@ #pragma once #include +#include // Global Response Callbacks typedef void (*DefaultSuccessCallback)(void * context); @@ -33,6 +34,7 @@ typedef void (*Int32uAttributeCallback)(void * context, uint32_t value); typedef void (*Int32sAttributeCallback)(void * context, int32_t value); typedef void (*Int64uAttributeCallback)(void * context, uint64_t value); typedef void (*Int64sAttributeCallback)(void * context, int64_t value); +typedef void (*StringAttributeCallback)(void * context, const chip::ByteSpan value); typedef void (*ReadReportingConfigurationReportedCallback)(void * context, uint16_t minInterval, uint16_t maxInterval); typedef void (*ReadReportingConfigurationReceivedCallback)(void * context, uint16_t timeout); diff --git a/examples/chip-tool/gen/CHIPClustersObjc.h b/examples/chip-tool/gen/CHIPClustersObjc.h index d1a3997dbb5eda..847dc97c76ec21 100644 --- a/examples/chip-tool/gen/CHIPClustersObjc.h +++ b/examples/chip-tool/gen/CHIPClustersObjc.h @@ -83,10 +83,20 @@ NS_ASSUME_NONNULL_BEGIN @interface CHIPBasic : CHIPCluster - (void)mfgSpecificPing:(ResponseHandler)completionHandler; -- (void)resetToFactoryDefaults:(ResponseHandler)completionHandler; -- (void)readAttributeZclVersion:(ResponseHandler)completionHandler; -- (void)readAttributePowerSource:(ResponseHandler)completionHandler; +- (void)readAttributeInteractionModelVersion:(ResponseHandler)completionHandler; +- (void)readAttributeVendorName:(ResponseHandler)completionHandler; +- (void)readAttributeVendorID:(ResponseHandler)completionHandler; +- (void)readAttributeProductName:(ResponseHandler)completionHandler; +- (void)readAttributeProductID:(ResponseHandler)completionHandler; +- (void)readAttributeUserLabel:(ResponseHandler)completionHandler; +- (void)writeAttributeUserLabel:(NSString *)value completionHandler:(ResponseHandler)completionHandler; +- (void)readAttributeLocation:(ResponseHandler)completionHandler; +- (void)writeAttributeLocation:(NSString *)value completionHandler:(ResponseHandler)completionHandler; +- (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler; +- (void)readAttributeHardwareVersionString:(ResponseHandler)completionHandler; +- (void)readAttributeSoftwareVersion:(ResponseHandler)completionHandler; +- (void)readAttributeSoftwareVersionString:(ResponseHandler)completionHandler; - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler; @end @@ -323,7 +333,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)getUserType:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler; - (void)getWeekdaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler; - (void)getYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler; -- (void)lockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandler; +- (void)lockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHandler; - (void)setHolidaySchedule:(uint8_t)scheduleId localStartTime:(uint32_t)localStartTime localEndTime:(uint32_t)localEndTime @@ -332,12 +342,12 @@ NS_ASSUME_NONNULL_BEGIN - (void)setPin:(uint16_t)userId userStatus:(uint8_t)userStatus userType:(uint8_t)userType - pin:(char *)pin + pin:(NSString *)pin completionHandler:(ResponseHandler)completionHandler; - (void)setRfid:(uint16_t)userId userStatus:(uint8_t)userStatus userType:(uint8_t)userType - id:(char *)id + id:(NSString *)id completionHandler:(ResponseHandler)completionHandler; - (void)setUserType:(uint16_t)userId userType:(uint8_t)userType completionHandler:(ResponseHandler)completionHandler; - (void)setWeekdaySchedule:(uint8_t)scheduleId @@ -353,8 +363,8 @@ NS_ASSUME_NONNULL_BEGIN localStartTime:(uint32_t)localStartTime localEndTime:(uint32_t)localEndTime completionHandler:(ResponseHandler)completionHandler; -- (void)unlockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandler; -- (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(char *)pin completionHandler:(ResponseHandler)completionHandler; +- (void)unlockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHandler; +- (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(NSString *)pin completionHandler:(ResponseHandler)completionHandler; - (void)readAttributeLockState:(ResponseHandler)completionHandler; - (void)configureAttributeLockState:(uint16_t)minInterval @@ -397,8 +407,10 @@ NS_ASSUME_NONNULL_BEGIN */ @interface CHIPGroups : CHIPCluster -- (void)addGroup:(uint16_t)groupId groupName:(char *)groupName completionHandler:(ResponseHandler)completionHandler; -- (void)addGroupIfIdentifying:(uint16_t)groupId groupName:(char *)groupName completionHandler:(ResponseHandler)completionHandler; +- (void)addGroup:(uint16_t)groupId groupName:(NSString *)groupName completionHandler:(ResponseHandler)completionHandler; +- (void)addGroupIfIdentifying:(uint16_t)groupId + groupName:(NSString *)groupName + completionHandler:(ResponseHandler)completionHandler; - (void)getGroupMembership:(uint8_t)groupCount groupList:(uint16_t)groupList completionHandler:(ResponseHandler)completionHandler; - (void)removeAllGroups:(ResponseHandler)completionHandler; - (void)removeGroup:(uint16_t)groupId completionHandler:(ResponseHandler)completionHandler; @@ -529,7 +541,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)addScene:(uint16_t)groupId sceneId:(uint8_t)sceneId transitionTime:(uint16_t)transitionTime - sceneName:(char *)sceneName + sceneName:(NSString *)sceneName clusterId:(uint16_t)clusterId length:(uint8_t)length value:(uint8_t)value diff --git a/examples/chip-tool/gen/CHIPClustersObjc.mm b/examples/chip-tool/gen/CHIPClustersObjc.mm index 28dab3dc3915c8..cd60722f9897d6 100644 --- a/examples/chip-tool/gen/CHIPClustersObjc.mm +++ b/examples/chip-tool/gen/CHIPClustersObjc.mm @@ -89,26 +89,38 @@ static void CallbackFn(void * context, uint8_t status) dispatch_queue_t mQueue; }; -class CHIPUnsupportedAttributeCallbackBridge : public Callback::Callback { +class CHIPStringAttributeCallbackBridge : public Callback::Callback { public: - CHIPUnsupportedAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) - : Callback::Callback(CallbackFn, this) + CHIPStringAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool octetString, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mOctetString(octetString) + , mKeepAlive(keepAlive) { } - ~CHIPUnsupportedAttributeCallbackBridge() {}; + ~CHIPStringAttributeCallbackBridge() {}; - static void CallbackFn(void * context) + static void CallbackFn(void * context, chip::ByteSpan value) { - CHIPUnsupportedAttributeCallbackBridge * callback = reinterpret_cast(context); + CHIPStringAttributeCallbackBridge * callback = reinterpret_cast(context); if (callback && callback->mQueue) { dispatch_async(callback->mQueue, ^{ - NSError * error = [NSError errorWithDomain:CHIPErrorDomain - code:CHIPErrorCodeUndefinedError - userInfo:@ { NSLocalizedDescriptionKey : @"Unsupported attribute type" }]; - callback->mHandler(error, nil); - callback->Cancel(); - delete callback; + if (callback->mOctetString) { + NSData * data = [NSData dataWithBytes:value.data() length:value.size()]; + callback->mHandler(nil, @ { @"value" : data }); + } else { + NSString * str = [[NSString alloc] initWithBytes:value.data() + length:value.size() + encoding:NSUTF8StringEncoding]; + callback->mHandler(nil, @ { @"value" : str }); + } + + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } }); } }; @@ -116,6 +128,8 @@ static void CallbackFn(void * context) private: ResponseHandler mHandler; dispatch_queue_t mQueue; + bool mOctetString; + bool mKeepAlive; }; class CHIPBooleanAttributeCallbackBridge : public Callback::Callback { @@ -246,6 +260,38 @@ static void CallbackFn(void * context, uint16_t value) bool mKeepAlive; }; +class CHIPInt32uAttributeCallbackBridge : public Callback::Callback { +public: + CHIPInt32uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mKeepAlive(keepAlive) + { + } + + ~CHIPInt32uAttributeCallbackBridge() {}; + + static void CallbackFn(void * context, uint32_t value) + { + CHIPInt32uAttributeCallbackBridge * callback = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedLong:value] }); + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; + bool mKeepAlive; +}; + class CHIPInt16sAttributeCallbackBridge : public Callback::Callback { public: CHIPInt16sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) @@ -1599,8 +1645,8 @@ @implementation CHIPApplicationBasic - (void)readAttributeVendorName:(ResponseHandler)completionHandler { - CHIPUnsupportedAttributeCallbackBridge * onSuccess - = new CHIPUnsupportedAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], true); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -1646,8 +1692,8 @@ - (void)readAttributeVendorId:(ResponseHandler)completionHandler - (void)readAttributeApplicationName:(ResponseHandler)completionHandler { - CHIPUnsupportedAttributeCallbackBridge * onSuccess - = new CHIPUnsupportedAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], true); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -1693,8 +1739,8 @@ - (void)readAttributeProductId:(ResponseHandler)completionHandler - (void)readAttributeApplicationId:(ResponseHandler)completionHandler { - CHIPUnsupportedAttributeCallbackBridge * onSuccess - = new CHIPUnsupportedAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], true); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -1992,7 +2038,149 @@ - (void)mfgSpecificPing:(ResponseHandler)completionHandler completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)resetToFactoryDefaults:(ResponseHandler)completionHandler + +- (void)readAttributeInteractionModelVersion:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeInteractionModelVersion(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeVendorName:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeVendorID:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeVendorID(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeProductName:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeProductName(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeProductID:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeProductID(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeUserLabel:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeUserLabel(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)writeAttributeUserLabel:(NSString *)value completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2007,7 +2195,9 @@ - (void)resetToFactoryDefaults:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ResetToFactoryDefaults(onSuccess->Cancel(), onFailure->Cancel()); + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + CHIP_ERROR err = self.cppCluster.WriteAttributeUserLabel( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2015,9 +2205,10 @@ - (void)resetToFactoryDefaults:(ResponseHandler)completionHandler } } -- (void)readAttributeZclVersion:(ResponseHandler)completionHandler +- (void)readAttributeLocation:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2030,7 +2221,7 @@ - (void)readAttributeZclVersion:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeZclVersion(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeLocation(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2038,9 +2229,105 @@ - (void)readAttributeZclVersion:(ResponseHandler)completionHandler } } -- (void)readAttributePowerSource:(ResponseHandler)completionHandler +- (void)writeAttributeLocation:(NSString *)value completionHandler:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + CHIP_ERROR err = self.cppCluster.WriteAttributeLocation( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeHardwareVersionString:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeSoftwareVersion:(ResponseHandler)completionHandler +{ + CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeSoftwareVersionString:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2053,7 +2340,7 @@ - (void)readAttributePowerSource:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePowerSource(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2881,8 +3168,8 @@ - (void)readAttributeDriftCompensation:(ResponseHandler)completionHandler - (void)readAttributeCompensationText:(ResponseHandler)completionHandler { - CHIPUnsupportedAttributeCallbackBridge * onSuccess - = new CHIPUnsupportedAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4674,7 +4961,7 @@ - (void)getYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completio completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)lockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandler +- (void)lockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHandler { CHIPDoorLockClusterLockDoorResponseCallbackBridge * onSuccess = new CHIPDoorLockClusterLockDoorResponseCallbackBridge(completionHandler, [self callbackQueue]); @@ -4690,7 +4977,9 @@ - (void)lockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandle return; } - CHIP_ERROR err = self.cppCluster.LockDoor(onSuccess->Cancel(), onFailure->Cancel(), pin); + CHIP_ERROR err = self.cppCluster.LockDoor(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4728,7 +5017,7 @@ - (void)setHolidaySchedule:(uint8_t)scheduleId - (void)setPin:(uint16_t)userId userStatus:(uint8_t)userStatus userType:(uint8_t)userType - pin:(char *)pin + pin:(NSString *)pin completionHandler:(ResponseHandler)completionHandler { CHIPDoorLockClusterSetPinResponseCallbackBridge * onSuccess @@ -4745,7 +5034,9 @@ - (void)setPin:(uint16_t)userId return; } - CHIP_ERROR err = self.cppCluster.SetPin(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, pin); + CHIP_ERROR err = self.cppCluster.SetPin(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4755,7 +5046,7 @@ - (void)setPin:(uint16_t)userId - (void)setRfid:(uint16_t)userId userStatus:(uint8_t)userStatus userType:(uint8_t)userType - id:(char *)id + id:(NSString *)id completionHandler:(ResponseHandler)completionHandler { CHIPDoorLockClusterSetRfidResponseCallbackBridge * onSuccess @@ -4772,7 +5063,9 @@ - (void)setRfid:(uint16_t)userId return; } - CHIP_ERROR err = self.cppCluster.SetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, id); + CHIP_ERROR err = self.cppCluster.SetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, + chip::ByteSpan((const uint8_t *) [id dataUsingEncoding:NSUTF8StringEncoding].bytes, + [id lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4861,7 +5154,7 @@ - (void)setYeardaySchedule:(uint8_t)scheduleId completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)unlockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandler +- (void)unlockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHandler { CHIPDoorLockClusterUnlockDoorResponseCallbackBridge * onSuccess = new CHIPDoorLockClusterUnlockDoorResponseCallbackBridge(completionHandler, [self callbackQueue]); @@ -4877,14 +5170,16 @@ - (void)unlockDoor:(char *)pin completionHandler:(ResponseHandler)completionHand return; } - CHIP_ERROR err = self.cppCluster.UnlockDoor(onSuccess->Cancel(), onFailure->Cancel(), pin); + CHIP_ERROR err = self.cppCluster.UnlockDoor(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(char *)pin completionHandler:(ResponseHandler)completionHandler +- (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(NSString *)pin completionHandler:(ResponseHandler)completionHandler { CHIPDoorLockClusterUnlockWithTimeoutResponseCallbackBridge * onSuccess = new CHIPDoorLockClusterUnlockWithTimeoutResponseCallbackBridge(completionHandler, [self callbackQueue]); @@ -4900,7 +5195,9 @@ - (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(char *)pin completionH return; } - CHIP_ERROR err = self.cppCluster.UnlockWithTimeout(onSuccess->Cancel(), onFailure->Cancel(), timeoutInSeconds, pin); + CHIP_ERROR err = self.cppCluster.UnlockWithTimeout(onSuccess->Cancel(), onFailure->Cancel(), timeoutInSeconds, + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5137,8 +5434,8 @@ - (void)setFabric:(NSData *)fabricId - (void)readAttributeFabricId:(ResponseHandler)completionHandler { - CHIPUnsupportedAttributeCallbackBridge * onSuccess - = new CHIPUnsupportedAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], true); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -5241,7 +5538,7 @@ @implementation CHIPGroups return &_cppCluster; } -- (void)addGroup:(uint16_t)groupId groupName:(char *)groupName completionHandler:(ResponseHandler)completionHandler +- (void)addGroup:(uint16_t)groupId groupName:(NSString *)groupName completionHandler:(ResponseHandler)completionHandler { CHIPGroupsClusterAddGroupResponseCallbackBridge * onSuccess = new CHIPGroupsClusterAddGroupResponseCallbackBridge(completionHandler, [self callbackQueue]); @@ -5257,14 +5554,16 @@ - (void)addGroup:(uint16_t)groupId groupName:(char *)groupName completionHandler return; } - CHIP_ERROR err = self.cppCluster.AddGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId, groupName); + CHIP_ERROR err = self.cppCluster.AddGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId, + chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes, + [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)addGroupIfIdentifying:(uint16_t)groupId groupName:(char *)groupName completionHandler:(ResponseHandler)completionHandler +- (void)addGroupIfIdentifying:(uint16_t)groupId groupName:(NSString *)groupName completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -5279,7 +5578,9 @@ - (void)addGroupIfIdentifying:(uint16_t)groupId groupName:(char *)groupName comp return; } - CHIP_ERROR err = self.cppCluster.AddGroupIfIdentifying(onSuccess->Cancel(), onFailure->Cancel(), groupId, groupName); + CHIP_ERROR err = self.cppCluster.AddGroupIfIdentifying(onSuccess->Cancel(), onFailure->Cancel(), groupId, + chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes, + [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6373,7 +6674,7 @@ @implementation CHIPScenes - (void)addScene:(uint16_t)groupId sceneId:(uint8_t)sceneId transitionTime:(uint16_t)transitionTime - sceneName:(char *)sceneName + sceneName:(NSString *)sceneName clusterId:(uint16_t)clusterId length:(uint8_t)length value:(uint8_t)value @@ -6393,8 +6694,10 @@ - (void)addScene:(uint16_t)groupId return; } - CHIP_ERROR err = self.cppCluster.AddScene( - onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime, sceneName, clusterId, length, value); + CHIP_ERROR err = self.cppCluster.AddScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime, + chip::ByteSpan((const uint8_t *) [sceneName dataUsingEncoding:NSUTF8StringEncoding].bytes, + [sceneName lengthOfBytesUsingEncoding:NSUTF8StringEncoding]), + clusterId, length, value); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; diff --git a/examples/chip-tool/gen/attribute-id.h b/examples/chip-tool/gen/attribute-id.h index 3ab0310a83cce7..8c8757f826ca7f 100644 --- a/examples/chip-tool/gen/attribute-id.h +++ b/examples/chip-tool/gen/attribute-id.h @@ -26,30 +26,6 @@ #define ZCL_REPORTING_STATUS_CLIENT_ATTRIBUTE_ID (0xFFFE) #define ZCL_REPORTING_STATUS_SERVER_ATTRIBUTE_ID (0xFFFE) -// Attribute ids for cluster: Basic - -// Client attributes - -// Server attributes -#define ZCL_VERSION_ATTRIBUTE_ID (0x0000) -#define ZCL_APPLICATION_VERSION_ATTRIBUTE_ID (0x0001) -#define ZCL_STACK_VERSION_ATTRIBUTE_ID (0x0002) -#define ZCL_HW_VERSION_ATTRIBUTE_ID (0x0003) -#define ZCL_MANUFACTURER_NAME_ATTRIBUTE_ID (0x0004) -#define ZCL_MODEL_IDENTIFIER_ATTRIBUTE_ID (0x0005) -#define ZCL_DATE_CODE_ATTRIBUTE_ID (0x0006) -#define ZCL_POWER_SOURCE_ATTRIBUTE_ID (0x0007) -#define ZCL_GENERIC_DEVICE_CLASS_ATTRIBUTE_ID (0x0008) -#define ZCL_GENERIC_DEVICE_TYPE_ATTRIBUTE_ID (0x0009) -#define ZCL_PRODUCT_CODE_ATTRIBUTE_ID (0x000A) -#define ZCL_PRODUCT_URL_ATTRIBUTE_ID (0x000B) -#define ZCL_LOCATION_DESCRIPTION_ATTRIBUTE_ID (0x0010) -#define ZCL_PHYSICAL_ENVIRONMENT_ATTRIBUTE_ID (0x0011) -#define ZCL_DEVICE_ENABLED_ATTRIBUTE_ID (0x0012) -#define ZCL_ALARM_MASK_ATTRIBUTE_ID (0x0013) -#define ZCL_DISABLE_LOCAL_CONFIG_ATTRIBUTE_ID (0x0014) -#define ZCL_SW_BUILD_ID_ATTRIBUTE_ID (0x4000) - // Attribute ids for cluster: Power Configuration // Client attributes @@ -384,6 +360,29 @@ #define ZCL_KEEPALIVE_BASE_ATTRIBUTE_ID (0x0000) #define ZCL_KEEPALIVE_JITTER_ATTRIBUTE_ID (0x0001) +// Attribute ids for cluster: Basic + +// Client attributes + +// Server attributes +#define ZCL_INTERACTION_MODEL_VERSION_ATTRIBUTE_ID (0x0000) +#define ZCL_VENDOR_NAME_ATTRIBUTE_ID (0x0001) +#define ZCL_VENDOR_ID_ATTRIBUTE_ID (0x0002) +#define ZCL_PRODUCT_NAME_ATTRIBUTE_ID (0x0003) +#define ZCL_PRODUCT_ID_ATTRIBUTE_ID (0x0004) +#define ZCL_USER_LABEL_ATTRIBUTE_ID (0x0005) +#define ZCL_LOCATION_ATTRIBUTE_ID (0x0006) +#define ZCL_HARDWARE_VERSION_ATTRIBUTE_ID (0x0007) +#define ZCL_HARDWARE_VERSION_STRING_ATTRIBUTE_ID (0x0008) +#define ZCL_SOFTWARE_VERSION_ATTRIBUTE_ID (0x0009) +#define ZCL_SOFTWARE_VERSION_STRING_ATTRIBUTE_ID (0x000A) +#define ZCL_MANUFACTURING_DATE_ATTRIBUTE_ID (0x000B) +#define ZCL_PART_NUMBER_ATTRIBUTE_ID (0x000C) +#define ZCL_PRODUCT_URL_ATTRIBUTE_ID (0x000D) +#define ZCL_PRODUCT_LABEL_ATTRIBUTE_ID (0x000E) +#define ZCL_SERIAL_NUMBER_ATTRIBUTE_ID (0x000F) +#define ZCL_LOCAL_CONFIG_DISABLED_ATTRIBUTE_ID (0x0010) + // Attribute ids for cluster: General Commissioning // Client attributes @@ -1104,10 +1103,10 @@ // Client attributes // Server attributes -#define ZCL_VENDOR_NAME_ATTRIBUTE_ID (0x0000) -#define ZCL_VENDOR_ID_ATTRIBUTE_ID (0x0001) +#define ZCL_APPLICATION_VENDOR_NAME_ATTRIBUTE_ID (0x0000) +#define ZCL_APPLICATION_VENDOR_ID_ATTRIBUTE_ID (0x0001) #define ZCL_APPLICATION_NAME_ATTRIBUTE_ID (0x0002) -#define ZCL_PRODUCT_ID_ATTRIBUTE_ID (0x0003) +#define ZCL_APPLICATION_PRODUCT_ID_ATTRIBUTE_ID (0x0003) #define ZCL_APPLICATION_ID_ATTRIBUTE_ID (0x0005) #define ZCL_CATALOG_VENDOR_ID_ATTRIBUTE_ID (0x0006) #define ZCL_APPLICATION_STATUS_ATTRIBUTE_ID (0x0007) @@ -3839,7 +3838,7 @@ #define ZCL_PRICE_TRAILING_DIGIT_ATTRIBUTE_ID (0x0021) #define ZCL_PRICE_ATTRIBUTE_ID (0x0022) #define ZCL_GOOD_ID_ATTRIBUTE_ID (0x0030) -#define ZCL_SERIAL_NUMBER_ATTRIBUTE_ID (0x0031) +#define ZCL_PAYMENT_SERIAL_NUMBER_ATTRIBUTE_ID (0x0031) #define ZCL_PAYMENT_TIMESTAMP_ATTRIBUTE_ID (0x0032) #define ZCL_TRANS_ID_ATTRIBUTE_ID (0x0033) #define ZCL_TRANS_STATUS_ATTRIBUTE_ID (0x0034) diff --git a/examples/chip-tool/gen/client-command-macro.h b/examples/chip-tool/gen/client-command-macro.h index c4f2f0a4a2a4f2..f72c96f951dcff 100644 --- a/examples/chip-tool/gen/client-command-macro.h +++ b/examples/chip-tool/gen/client-command-macro.h @@ -256,15 +256,6 @@ emberAfFillExternalBuffer(mask, clusterId, ZCL_DISCOVER_ATTRIBUTES_EXTENDED_RESPONSE_COMMAND_ID, "ub", discoveryComplete, \ extendedDiscoverAttributesInfoRecords, extendedDiscoverAttributesInfoRecordsLen); -/** @brief Command description for ResetToFactoryDefaults - * - * Command: ResetToFactoryDefaults - */ -#define emberAfFillCommandBasicClusterResetToFactoryDefaults() \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID, "", ); - /** @brief Command description for Identify * * Command: Identify @@ -1795,6 +1786,33 @@ totalNumberOfNonEmptyProxyTableEntries, gpdSrcId, startIndex, gpdIeee, entriesCount, endpoint, \ proxyTableEntries, proxyTableEntriesLen, index); +/** @brief Command description for StartUp + * + * Command: StartUp + */ +#define emberAfFillCommandBasicClusterStartUp() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_START_UP_COMMAND_ID, "", ); + +/** @brief Command description for ShutDown + * + * Command: ShutDown + */ +#define emberAfFillCommandBasicClusterShutDown() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SHUT_DOWN_COMMAND_ID, "", ); + +/** @brief Command description for Leave + * + * Command: Leave + */ +#define emberAfFillCommandBasicClusterLeave() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_LEAVE_COMMAND_ID, "", ); + /** @brief Command description for SetFabric * * Command: SetFabric diff --git a/examples/chip-tool/gen/cluster-id.h b/examples/chip-tool/gen/cluster-id.h index 2069290df636a7..d77da915200ab4 100644 --- a/examples/chip-tool/gen/cluster-id.h +++ b/examples/chip-tool/gen/cluster-id.h @@ -20,9 +20,6 @@ // Prevent multiple inclusion #pragma once -// Definitions for cluster: Basic -#define ZCL_BASIC_CLUSTER_ID (0x0000) - // Definitions for cluster: Power Configuration #define ZCL_POWER_CONFIG_CLUSTER_ID (0x0001) @@ -83,6 +80,9 @@ // Definitions for cluster: Keep-Alive #define ZCL_KEEPALIVE_CLUSTER_ID (0x0025) +// Definitions for cluster: Basic +#define ZCL_BASIC_CLUSTER_ID (0x0028) + // Definitions for cluster: General Commissioning #define ZCL_GENERAL_COMMISSIONING_CLUSTER_ID (0x0030) diff --git a/examples/chip-tool/gen/command-id.h b/examples/chip-tool/gen/command-id.h index 655425d5d43d35..adc2b1c6f32733 100644 --- a/examples/chip-tool/gen/command-id.h +++ b/examples/chip-tool/gen/command-id.h @@ -45,10 +45,6 @@ #define ZCL_DISCOVER_ATTRIBUTES_EXTENDED_COMMAND_ID (0x15) #define ZCL_DISCOVER_ATTRIBUTES_EXTENDED_RESPONSE_COMMAND_ID (0x16) -// Commands for cluster: Basic -#define ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID (0x00) -#define ZCL_MFG_SPECIFIC_PING_COMMAND_ID (0x00) - // Commands for cluster: Identify #define ZCL_IDENTIFY_COMMAND_ID (0x00) #define ZCL_IDENTIFY_QUERY_RESPONSE_COMMAND_ID (0x00) @@ -226,6 +222,12 @@ #define ZCL_GP_PROXY_TABLE_RESPONSE_COMMAND_ID (0x0B) #define ZCL_GP_PROXY_TABLE_REQUEST_COMMAND_ID (0x0B) +// Commands for cluster: Basic +#define ZCL_START_UP_COMMAND_ID (0x00) +#define ZCL_MFG_SPECIFIC_PING_COMMAND_ID (0x00) +#define ZCL_SHUT_DOWN_COMMAND_ID (0x01) +#define ZCL_LEAVE_COMMAND_ID (0x02) + // Commands for cluster: General Commissioning #define ZCL_SET_FABRIC_COMMAND_ID (0x00) #define ZCL_SET_FABRIC_RESPONSE_COMMAND_ID (0x01) diff --git a/examples/chip-tool/gen/endpoint_config.h b/examples/chip-tool/gen/endpoint_config.h index 2b8eb4cef7440f..482e761307e597 100644 --- a/examples/chip-tool/gen/endpoint_config.h +++ b/examples/chip-tool/gen/endpoint_config.h @@ -58,10 +58,7 @@ #define GENERATED_ATTRIBUTE_COUNT 16 #define GENERATED_ATTRIBUTES \ { \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), { (uint8_t *) 3 } }, /* Basic (client): cluster revision */ \ - { \ - 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), { (uint8_t *) 2 } \ - }, /* Identify (client): cluster revision */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), { (uint8_t *) 2 } }, /* Identify (client): cluster revision */ \ { \ 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), { (uint8_t *) 3 } \ }, /* Groups (client): cluster revision */ \ @@ -74,6 +71,9 @@ { \ 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), { (uint8_t *) 3 } \ }, /* Level Control (client): cluster revision */ \ + { \ + 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT) | ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 3 } \ + }, /* Basic (client): cluster revision */ \ { \ 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), { (uint8_t *) 0x0001 } \ }, /* General Commissioning (client): cluster revision */ \ @@ -116,16 +116,14 @@ #define GENERATED_CLUSTER_COUNT 16 #define GENERATED_CLUSTERS \ { \ - { 0x0000, ZAP_ATTRIBUTE_INDEX(0), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: Basic (client) */ \ - { \ - 0x0003, ZAP_ATTRIBUTE_INDEX(1), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ - }, /* Endpoint: 1, Cluster: Identify (client) */ \ - { 0x0004, ZAP_ATTRIBUTE_INDEX(2), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: Groups (client) */ \ - { 0x0005, ZAP_ATTRIBUTE_INDEX(3), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: Scenes (client) */ \ - { 0x0006, ZAP_ATTRIBUTE_INDEX(4), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: On/off (client) */ \ + { 0x0003, ZAP_ATTRIBUTE_INDEX(0), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: Identify (client) */ \ + { 0x0004, ZAP_ATTRIBUTE_INDEX(1), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: Groups (client) */ \ + { 0x0005, ZAP_ATTRIBUTE_INDEX(2), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: Scenes (client) */ \ + { 0x0006, ZAP_ATTRIBUTE_INDEX(3), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: On/off (client) */ \ { \ - 0x0008, ZAP_ATTRIBUTE_INDEX(5), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0008, ZAP_ATTRIBUTE_INDEX(4), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Level Control (client) */ \ + { 0x0028, ZAP_ATTRIBUTE_INDEX(5), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: Basic (client) */ \ { \ 0x0030, ZAP_ATTRIBUTE_INDEX(6), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: General Commissioning (client) */ \ @@ -170,7 +168,7 @@ #define ATTRIBUTE_LARGEST (2) // Total size of singleton attributes -#define ATTRIBUTE_SINGLETONS_SIZE (0) +#define ATTRIBUTE_SINGLETONS_SIZE (2) // Total size of attribute storage #define ATTRIBUTE_MAX_SIZE (32) @@ -217,14 +215,10 @@ // Array of EmberAfCommandMetadata structs. #define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask -#define EMBER_AF_GENERATED_COMMAND_COUNT (127) +#define EMBER_AF_GENERATED_COMMAND_COUNT (129) #define GENERATED_COMMANDS \ { \ - { 0x0000, 0x00, ZAP_COMMAND_MASK(OUTGOING_CLIENT) }, /* Basic (client): MfgSpecificPing */ \ - { \ - 0x0000, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) | ZAP_COMMAND_MASK(OUTGOING_CLIENT) \ - }, /* Basic (client): ResetToFactoryDefaults */ \ - { 0x0003, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Identify (client): Identify */ \ + { 0x0003, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Identify (client): Identify */ \ { 0x0003, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Identify (client): IdentifyQueryResponse */ \ { 0x0003, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Identify (client): IdentifyQuery */ \ { 0x0004, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Groups (client): AddGroup */ \ @@ -261,6 +255,10 @@ { 0x0008, 0x05, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Level Control (client): MoveWithOnOff */ \ { 0x0008, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Level Control (client): StepWithOnOff */ \ { 0x0008, 0x07, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Level Control (client): StopWithOnOff */ \ + { 0x0028, 0x00, ZAP_COMMAND_MASK(OUTGOING_CLIENT) }, /* Basic (client): MfgSpecificPing */ \ + { 0x0028, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (client): StartUp */ \ + { 0x0028, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (client): ShutDown */ \ + { 0x0028, 0x02, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (client): Leave */ \ { 0x0030, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* General Commissioning (client): SetFabric */ \ { 0x0030, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* General Commissioning (client): SetFabricResponse */ \ { 0x0030, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* General Commissioning (client): ArmFailSafe */ \ @@ -440,7 +438,7 @@ #define GENERATED_COMMAND_MANUFACTURER_CODE_COUNT (1) #define GENERATED_COMMAND_MANUFACTURER_CODES \ { \ - { 0, 4098 }, \ + { 37, 4098 }, \ } // This is an array of EmberAfManufacturerCodeEntry structures for clusters. @@ -465,16 +463,7 @@ #define ZRD(x) EMBER_ZCL_REPORTING_DIRECTION_##x #define ZAP_REPORT_DIRECTION(x) ZRD(x) -// Use this macro to check if Reporting plugin is included -#define EMBER_AF_PLUGIN_REPORTING -// User options for plugin Reporting -#define EMBER_AF_PLUGIN_REPORTING_TABLE_SIZE (1) -#define EMBER_AF_PLUGIN_REPORTING_ENABLE_GROUP_BOUND_REPORTS - -#define EMBER_AF_GENERATED_REPORTING_CONFIG_DEFAULTS_TABLE_SIZE (1) +#define EMBER_AF_GENERATED_REPORTING_CONFIG_DEFAULTS_TABLE_SIZE (0) #define EMBER_AF_GENERATED_REPORTING_CONFIG_DEFAULTS \ { \ - { \ - ZAP_REPORT_DIRECTION(REPORTED), 0x0001, 0x0000, 0xFFFD, ZAP_CLUSTER_MASK(CLIENT), 0x0000, { { 0, 65344, 0 } } \ - }, /* Reporting for cluster: "Basic", attribute: "cluster revision". side: client */ \ } diff --git a/examples/chip-tool/gen/print-cluster.h b/examples/chip-tool/gen/print-cluster.h index 1ea31513afebcd..bd08d38a581506 100644 --- a/examples/chip-tool/gen/print-cluster.h +++ b/examples/chip-tool/gen/print-cluster.h @@ -24,12 +24,6 @@ // to the "EmberAfClusterName" defined in the ZCL header. // The names of clusters that are not present, are removed. -#if defined(ZCL_USING_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_BASIC_CLUSTER_CLIENT) -#define CHIP_PRINTCLUSTER_BASIC_CLUSTER { ZCL_BASIC_CLUSTER_ID, 0, "Basic" }, -#else -#define CHIP_PRINTCLUSTER_BASIC_CLUSTER -#endif - #if defined(ZCL_USING_POWER_CONFIG_CLUSTER_SERVER) || defined(ZCL_USING_POWER_CONFIG_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_POWER_CONFIG_CLUSTER { ZCL_POWER_CONFIG_CLUSTER_ID, 1, "Power Configuration" }, #else @@ -150,6 +144,12 @@ #define CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER #endif +#if defined(ZCL_USING_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_BASIC_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_BASIC_CLUSTER { ZCL_BASIC_CLUSTER_ID, 40, "Basic" }, +#else +#define CHIP_PRINTCLUSTER_BASIC_CLUSTER +#endif + #if defined(ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER { ZCL_GENERAL_COMMISSIONING_CLUSTER_ID, 48, "General Commissioning" }, #else @@ -790,7 +790,6 @@ #endif #define CLUSTER_IDS_TO_NAMES \ - CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_POWER_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DEVICE_TEMP_CLUSTER \ CHIP_PRINTCLUSTER_IDENTIFY_CLUSTER \ @@ -811,6 +810,7 @@ CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER \ CHIP_PRINTCLUSTER_GREEN_POWER_CLUSTER \ CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER \ + CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DOOR_LOCK_CLUSTER \ diff --git a/examples/chip-tool/templates/commands.zapt b/examples/chip-tool/templates/commands.zapt index d59fb1ee790dc1..2f4623a48fc177 100644 --- a/examples/chip-tool/templates/commands.zapt +++ b/examples/chip-tool/templates/commands.zapt @@ -7,7 +7,6 @@ #include "ModelCommand.h" #include "gen/CHIPClientCallbacks.h" #include -#include #include static void OnDefaultSuccessResponse(void * context) @@ -26,12 +25,6 @@ static void OnDefaultFailureResponse(void * context, uint8_t status) command->SetCommandExitStatus(false); } -typedef void (*UnsupportedAttributeCallback)(void * context); -static void OnUnsupportedAttributeResponse(void * context) -{ - ChipLogError(chipTool, "Unsupported attribute Response. This should never happen !"); -} - static void OnBooleanAttributeResponse(void * context, bool value) { ChipLogProgress(chipTool, "Boolean attribute Response: %d", value); @@ -56,9 +49,9 @@ static void OnInt16uAttributeResponse(void * context, uint16_t value) command->SetCommandExitStatus(true); } -static void OnInt16sAttributeResponse(void * context, int16_t value) +static void OnInt32uAttributeResponse(void * context, uint32_t value) { - ChipLogProgress(chipTool, "Int16s attribute Response: %" PRId16, value); + ChipLogProgress(chipTool, "Int32u attribute Response: %" PRIu32, value); ModelCommand * command = reinterpret_cast(context); command->SetCommandExitStatus(true); @@ -72,6 +65,27 @@ static void OnInt64uAttributeResponse(void * context, uint64_t value) command->SetCommandExitStatus(true); } +static void OnInt16sAttributeResponse(void * context, int16_t value) +{ + ChipLogProgress(chipTool, "Int16s attribute Response: %" PRId16, value); + + ModelCommand * command = reinterpret_cast(context); + command->SetCommandExitStatus(true); +} + +static void OnStringAttributeResponse(void * context, const chip::ByteSpan value) +{ + char * str = (char *)malloc(value.size() * sizeof(char)); + memmove(str, value.data(), value.size()); + str[value.size()] = '\0'; + free(str); + + ChipLogProgress(chipTool, "String attribute Response: %s (%" PRIu16 ")", str, strlen(str)); + + ModelCommand * command = reinterpret_cast(context); + command->SetCommandExitStatus(true); +} + {{#all_user_clusters}} {{#if (isClient side) }} {{#if (user_cluster_has_enabled_command name side)}} @@ -129,7 +143,7 @@ public: chip::Controller::{{asCamelCased parent.name false}}Cluster cluster; cluster.Associate(device, endpointId); - return cluster.{{asCamelCased name false}}(onSuccessCallback->Cancel(), onFailureCallback->Cancel(){{#chip_server_cluster_command_arguments}}, {{#if (isByteString type)}} chip::ByteSpan(chip::Uint8::from_char(m{{asCamelCased label false}}), strlen(m{{asCamelCased label false}})){{else}}m{{asCamelCased label false}}{{/if}}{{/chip_server_cluster_command_arguments}}); + return cluster.{{asCamelCased name false}}(onSuccessCallback->Cancel(), onFailureCallback->Cancel(){{#chip_server_cluster_command_arguments}}, {{#if (isString type)}} chip::ByteSpan(chip::Uint8::from_char(m{{asCamelCased label false}}), strlen(m{{asCamelCased label false}})){{else}}m{{asCamelCased label false}}{{/if}}{{/chip_server_cluster_command_arguments}}); } private: @@ -209,7 +223,11 @@ public: Write{{asCamelCased parent.name false}}{{asCamelCased name false}}(): ModelCommand("write") { AddArgument("attr-name", "{{asDelimitedCommand (asCamelCased name)}}"); + {{#if (isString type)}} + AddArgument("attr-value", &mValue); + {{else}} AddArgument("attr-value", {{asTypeMinValue type}}, {{asTypeMaxValue type}}, &mValue); + {{/if}} ModelCommand::AddArguments(); } @@ -219,13 +237,17 @@ public: chip::Controller::{{asCamelCased parent.name false}}Cluster cluster; cluster.Associate(device, endpointId); - return cluster.WriteAttribute{{asCamelCased name false}}(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mValue); + return cluster.WriteAttribute{{asCamelCased name false}}(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), {{#if (isString type)}} chip::ByteSpan(chip::Uint8::from_char(mValue), strlen(mValue)){{else}}mValue{{/if}}); } private: chip::Callback::Callback * onSuccessCallback = new chip::Callback::Callback(OnDefaultSuccessResponse, this); chip::Callback::Callback * onFailureCallback = new chip::Callback::Callback(OnDefaultFailureResponse, this); + {{#if (isString type)}} + char * mValue; + {{else}} {{chipType}} mValue; + {{/if}} }; {{/if}} diff --git a/examples/chip-tool/templates/helper.js b/examples/chip-tool/templates/helper.js index 71a2c7ef73ec9b..8028578770d4f9 100644 --- a/examples/chip-tool/templates/helper.js +++ b/examples/chip-tool/templates/helper.js @@ -55,81 +55,6 @@ function hasSpecificResponse(commandName) return templateUtil.templatePromise(this.global, promise); } -function asCallbackAttributeType(attributeType) -{ - switch (parseInt(attributeType)) { - case 0x00: // nodata / No data - case 0x0A: // data24 / 24-bit data - case 0x0C: // data40 / 40-bit data - case 0x0D: // data48 / 48-bit data - case 0x0E: // data56 / 56-bit data - case 0x1A: // map24 / 24-bit bitmap - case 0x1C: // map40 / 40-bit bitmap - case 0x1D: // map48 / 48-bit bitmap - case 0x1E: // map56 / 56-bit bitmap - case 0x22: // uint24 / Unsigned 24-bit integer - case 0x24: // uint40 / Unsigned 40-bit integer - case 0x25: // uint48 / Unsigned 48-bit integer - case 0x26: // uint56 / Unsigned 56-bit integer - case 0x2A: // int24 / Signed 24-bit integer - case 0x2C: // int40 / Signed 40-bit integer - case 0x2D: // int48 / Signed 48-bit integer - case 0x2E: // int56 / Signed 56-bit integer - case 0x38: // semi / Semi-precision - case 0x39: // single / Single precision - case 0x3A: // double / Double precision - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string - case 0x48: // array / Array - case 0x49: // struct / Structure - case 0x50: // set / Set - case 0x51: // bag / Bag - case 0xE0: // ToD / Time of day - return 'Unsupported'; - case 0x08: // data8 / 8-bit data - case 0x18: // map8 / 8-bit bitmap - case 0x20: // uint8 / Unsigned 8-bit integer - case 0x30: // enum8 / 8-bit enumeration - return 'Int8u'; - case 0x09: // data16 / 16-bit data - case 0x19: // map16 / 16-bit bitmap - case 0x21: // uint16 / Unsigned 16-bit integer - case 0x31: // enum16 / 16-bit enumeration - case 0xE8: // clusterId / Cluster ID - case 0xE9: // attribId / Attribute ID - case 0xEA: // bacOID / BACnet OID - case 0xF1: // key128 / 128-bit security key - case 0xFF: // unk / Unknown - return 'Int16u'; - case 0x0B: // data32 / 32-bit data - case 0x1B: // map32 / 32-bit bitmap - case 0x23: // uint32 / Unsigned 32-bit integer - case 0xE1: // date / Date - case 0xE2: // UTC / UTCTime - return 'Int32u'; - case 0x0F: // data64 / 64-bit data - case 0x1F: // map64 / 64-bit bitmap - case 0x27: // uint64 / Unsigned 64-bit integer - case 0xF0: // EUI64 / IEEE address - return 'Int64u'; - case 0x10: // bool / Boolean - return 'Boolean'; - case 0x28: // int8 / Signed 8-bit integer - return 'Int8s'; - case 0x29: // int16 / Signed 16-bit integer - return 'Int16s'; - case 0x2B: // int32 / Signed 32-bit integer - return 'Int32s'; - case 0x2F: // int64 / Signed 64-bit integer - return 'Int64s'; - default: - error = 'Unhandled attribute type ' + attributeType; - throw error; - } -} - function asDelimitedCommand(name) { return name.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase(); @@ -203,9 +128,8 @@ function isStrEndsWith(str, substr) // // Module exports // -exports.hasSpecificResponse = hasSpecificResponse; -exports.asCallbackAttributeType = asCallbackAttributeType; -exports.asDelimitedCommand = asDelimitedCommand; -exports.asTypeMinValue = asTypeMinValue; -exports.asTypeMaxValue = asTypeMaxValue; -exports.isStrEndsWith = isStrEndsWith; +exports.hasSpecificResponse = hasSpecificResponse; +exports.asDelimitedCommand = asDelimitedCommand; +exports.asTypeMinValue = asTypeMinValue; +exports.asTypeMaxValue = asTypeMaxValue; +exports.isStrEndsWith = isStrEndsWith; diff --git a/examples/lighting-app/lighting-common/gen/CHIPClientCallbacks.cpp b/examples/lighting-app/lighting-common/gen/CHIPClientCallbacks.cpp index f5f88af110c2c7..fc5ea3b1b8a7c6 100644 --- a/examples/lighting-app/lighting-common/gen/CHIPClientCallbacks.cpp +++ b/examples/lighting-app/lighting-common/gen/CHIPClientCallbacks.cpp @@ -272,10 +272,6 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag case 0x38: // semi / Semi-precision case 0x39: // single / Single precision case 0x3A: // double / Double precision - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string case 0x48: // array / Array case 0x49: // struct / Structure case 0x50: // set / Set @@ -289,6 +285,48 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag return true; } + case 0x41: // octstr / Octet string + case 0x42: // string / Character string + { + // Short Strings must contains at least one byte for the length + CHECK_MESSAGE_LENGTH(1); + uint8_t length = chip::Encoding::Read8(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + + case 0x43: // octstr16 / Long octet string + case 0x44: // string16 / Long character string + { + // Long Strings must contains at least two bytes for the length + CHECK_MESSAGE_LENGTH(2); + uint16_t length = chip::Encoding::LittleEndian::Read16(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFFFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFFFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + case 0x08: // data8 / 8-bit data case 0x18: // map8 / 8-bit bitmap case 0x20: // uint8 / Unsigned 8-bit integer @@ -696,10 +734,6 @@ bool emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * message, uin case 0x38: // semi / Semi-precision case 0x39: // single / Single precision case 0x3A: // double / Double precision - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string case 0x48: // array / Array case 0x49: // struct / Structure case 0x50: // set / Set @@ -710,6 +744,48 @@ bool emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * message, uin return true; } + case 0x41: // octstr / Octet string + case 0x42: // string / Character string + { + // Short Strings must contains at least one byte for the length + CHECK_MESSAGE_LENGTH(1); + uint8_t length = chip::Encoding::Read8(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onReportCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + + case 0x43: // octstr16 / Long octet string + case 0x44: // string16 / Long character string + { + // Long Strings must contains at least two bytes for the length + CHECK_MESSAGE_LENGTH(2); + uint16_t length = chip::Encoding::LittleEndian::Read16(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFFFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFFFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onReportCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + case 0x08: // data8 / 8-bit data case 0x18: // map8 / 8-bit bitmap case 0x20: // uint8 / Unsigned 8-bit integer diff --git a/examples/lighting-app/lighting-common/gen/CHIPClientCallbacks.h b/examples/lighting-app/lighting-common/gen/CHIPClientCallbacks.h index 14a3742f090e8f..d028079f799d79 100644 --- a/examples/lighting-app/lighting-common/gen/CHIPClientCallbacks.h +++ b/examples/lighting-app/lighting-common/gen/CHIPClientCallbacks.h @@ -20,6 +20,7 @@ #pragma once #include +#include // Global Response Callbacks typedef void (*DefaultSuccessCallback)(void * context); @@ -33,6 +34,7 @@ typedef void (*Int32uAttributeCallback)(void * context, uint32_t value); typedef void (*Int32sAttributeCallback)(void * context, int32_t value); typedef void (*Int64uAttributeCallback)(void * context, uint64_t value); typedef void (*Int64sAttributeCallback)(void * context, int64_t value); +typedef void (*StringAttributeCallback)(void * context, const chip::ByteSpan value); typedef void (*ReadReportingConfigurationReportedCallback)(void * context, uint16_t minInterval, uint16_t maxInterval); typedef void (*ReadReportingConfigurationReceivedCallback)(void * context, uint16_t timeout); diff --git a/examples/lighting-app/lighting-common/gen/CHIPClustersObjc.h b/examples/lighting-app/lighting-common/gen/CHIPClustersObjc.h index d10700ceb47cda..459e4c51fe8a09 100644 --- a/examples/lighting-app/lighting-common/gen/CHIPClustersObjc.h +++ b/examples/lighting-app/lighting-common/gen/CHIPClustersObjc.h @@ -42,6 +42,29 @@ NS_ASSUME_NONNULL_BEGIN @end +/** + * Cluster Basic + * + */ +@interface CHIPBasic : CHIPCluster + +- (void)readAttributeInteractionModelVersion:(ResponseHandler)completionHandler; +- (void)readAttributeVendorName:(ResponseHandler)completionHandler; +- (void)readAttributeVendorID:(ResponseHandler)completionHandler; +- (void)readAttributeProductName:(ResponseHandler)completionHandler; +- (void)readAttributeProductID:(ResponseHandler)completionHandler; +- (void)readAttributeUserLabel:(ResponseHandler)completionHandler; +- (void)writeAttributeUserLabel:(NSString *)value completionHandler:(ResponseHandler)completionHandler; +- (void)readAttributeLocation:(ResponseHandler)completionHandler; +- (void)writeAttributeLocation:(NSString *)value completionHandler:(ResponseHandler)completionHandler; +- (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler; +- (void)readAttributeHardwareVersionString:(ResponseHandler)completionHandler; +- (void)readAttributeSoftwareVersion:(ResponseHandler)completionHandler; +- (void)readAttributeSoftwareVersionString:(ResponseHandler)completionHandler; +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler; + +@end + /** * Cluster Level Control * diff --git a/examples/lighting-app/lighting-common/gen/CHIPClustersObjc.mm b/examples/lighting-app/lighting-common/gen/CHIPClustersObjc.mm index a1394c1d0ea092..d554b9bd8ca244 100644 --- a/examples/lighting-app/lighting-common/gen/CHIPClustersObjc.mm +++ b/examples/lighting-app/lighting-common/gen/CHIPClustersObjc.mm @@ -89,26 +89,38 @@ static void CallbackFn(void * context, uint8_t status) dispatch_queue_t mQueue; }; -class CHIPUnsupportedAttributeCallbackBridge : public Callback::Callback { +class CHIPStringAttributeCallbackBridge : public Callback::Callback { public: - CHIPUnsupportedAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) - : Callback::Callback(CallbackFn, this) + CHIPStringAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool octetString, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mOctetString(octetString) + , mKeepAlive(keepAlive) { } - ~CHIPUnsupportedAttributeCallbackBridge() {}; + ~CHIPStringAttributeCallbackBridge() {}; - static void CallbackFn(void * context) + static void CallbackFn(void * context, chip::ByteSpan value) { - CHIPUnsupportedAttributeCallbackBridge * callback = reinterpret_cast(context); + CHIPStringAttributeCallbackBridge * callback = reinterpret_cast(context); if (callback && callback->mQueue) { dispatch_async(callback->mQueue, ^{ - NSError * error = [NSError errorWithDomain:CHIPErrorDomain - code:CHIPErrorCodeUndefinedError - userInfo:@ { NSLocalizedDescriptionKey : @"Unsupported attribute type" }]; - callback->mHandler(error, nil); - callback->Cancel(); - delete callback; + if (callback->mOctetString) { + NSData * data = [NSData dataWithBytes:value.data() length:value.size()]; + callback->mHandler(nil, @ { @"value" : data }); + } else { + NSString * str = [[NSString alloc] initWithBytes:value.data() + length:value.size() + encoding:NSUTF8StringEncoding]; + callback->mHandler(nil, @ { @"value" : str }); + } + + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } }); } }; @@ -116,6 +128,8 @@ static void CallbackFn(void * context) private: ResponseHandler mHandler; dispatch_queue_t mQueue; + bool mOctetString; + bool mKeepAlive; }; class CHIPBooleanAttributeCallbackBridge : public Callback::Callback { @@ -246,6 +260,38 @@ static void CallbackFn(void * context, uint16_t value) bool mKeepAlive; }; +class CHIPInt32uAttributeCallbackBridge : public Callback::Callback { +public: + CHIPInt32uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mKeepAlive(keepAlive) + { + } + + ~CHIPInt32uAttributeCallbackBridge() {}; + + static void CallbackFn(void * context, uint32_t value) + { + CHIPInt32uAttributeCallbackBridge * callback = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedLong:value] }); + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; + bool mKeepAlive; +}; + class CHIPInt16sAttributeCallbackBridge : public Callback::Callback { public: CHIPInt16sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) @@ -308,6 +354,351 @@ - (instancetype)initWithDevice:(CHIPDevice *)device endpoint:(EndpointId)endpoin } @end +@interface CHIPBasic () +@property (readonly) Controller::BasicCluster cppCluster; +@end + +@implementation CHIPBasic + +- (Controller::ClusterBase *)getCluster +{ + return &_cppCluster; +} + +- (void)readAttributeInteractionModelVersion:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeInteractionModelVersion(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeVendorName:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeVendorID:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeVendorID(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeProductName:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeProductName(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeProductID:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeProductID(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeUserLabel:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeUserLabel(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)writeAttributeUserLabel:(NSString *)value completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + CHIP_ERROR err = self.cppCluster.WriteAttributeUserLabel( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeLocation:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeLocation(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)writeAttributeLocation:(NSString *)value completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + CHIP_ERROR err = self.cppCluster.WriteAttributeLocation( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeHardwareVersionString:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeSoftwareVersion:(ResponseHandler)completionHandler +{ + CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeSoftwareVersionString:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +@end + @interface CHIPLevelControl () @property (readonly) Controller::LevelControlCluster cppCluster; @end diff --git a/examples/lighting-app/lighting-common/gen/attribute-id.h b/examples/lighting-app/lighting-common/gen/attribute-id.h index 8802797f112bd6..8c8757f826ca7f 100644 --- a/examples/lighting-app/lighting-common/gen/attribute-id.h +++ b/examples/lighting-app/lighting-common/gen/attribute-id.h @@ -26,30 +26,6 @@ #define ZCL_REPORTING_STATUS_CLIENT_ATTRIBUTE_ID (0xFFFE) #define ZCL_REPORTING_STATUS_SERVER_ATTRIBUTE_ID (0xFFFE) -// Attribute ids for cluster: Basic - -// Client attributes - -// Server attributes -#define ZCL_VERSION_ATTRIBUTE_ID (0x0000) -#define ZCL_APPLICATION_VERSION_ATTRIBUTE_ID (0x0001) -#define ZCL_STACK_VERSION_ATTRIBUTE_ID (0x0002) -#define ZCL_HW_VERSION_ATTRIBUTE_ID (0x0003) -#define ZCL_MANUFACTURER_NAME_ATTRIBUTE_ID (0x0004) -#define ZCL_MODEL_IDENTIFIER_ATTRIBUTE_ID (0x0005) -#define ZCL_DATE_CODE_ATTRIBUTE_ID (0x0006) -#define ZCL_POWER_SOURCE_ATTRIBUTE_ID (0x0007) -#define ZCL_GENERIC_DEVICE_CLASS_ATTRIBUTE_ID (0x0008) -#define ZCL_GENERIC_DEVICE_TYPE_ATTRIBUTE_ID (0x0009) -#define ZCL_PRODUCT_CODE_ATTRIBUTE_ID (0x000A) -#define ZCL_PRODUCT_URL_ATTRIBUTE_ID (0x000B) -#define ZCL_LOCATION_DESCRIPTION_ATTRIBUTE_ID (0x0010) -#define ZCL_PHYSICAL_ENVIRONMENT_ATTRIBUTE_ID (0x0011) -#define ZCL_DEVICE_ENABLED_ATTRIBUTE_ID (0x0012) -#define ZCL_ALARM_MASK_ATTRIBUTE_ID (0x0013) -#define ZCL_DISABLE_LOCAL_CONFIG_ATTRIBUTE_ID (0x0014) -#define ZCL_SW_BUILD_ID_ATTRIBUTE_ID (0x4000) - // Attribute ids for cluster: Power Configuration // Client attributes @@ -384,6 +360,29 @@ #define ZCL_KEEPALIVE_BASE_ATTRIBUTE_ID (0x0000) #define ZCL_KEEPALIVE_JITTER_ATTRIBUTE_ID (0x0001) +// Attribute ids for cluster: Basic + +// Client attributes + +// Server attributes +#define ZCL_INTERACTION_MODEL_VERSION_ATTRIBUTE_ID (0x0000) +#define ZCL_VENDOR_NAME_ATTRIBUTE_ID (0x0001) +#define ZCL_VENDOR_ID_ATTRIBUTE_ID (0x0002) +#define ZCL_PRODUCT_NAME_ATTRIBUTE_ID (0x0003) +#define ZCL_PRODUCT_ID_ATTRIBUTE_ID (0x0004) +#define ZCL_USER_LABEL_ATTRIBUTE_ID (0x0005) +#define ZCL_LOCATION_ATTRIBUTE_ID (0x0006) +#define ZCL_HARDWARE_VERSION_ATTRIBUTE_ID (0x0007) +#define ZCL_HARDWARE_VERSION_STRING_ATTRIBUTE_ID (0x0008) +#define ZCL_SOFTWARE_VERSION_ATTRIBUTE_ID (0x0009) +#define ZCL_SOFTWARE_VERSION_STRING_ATTRIBUTE_ID (0x000A) +#define ZCL_MANUFACTURING_DATE_ATTRIBUTE_ID (0x000B) +#define ZCL_PART_NUMBER_ATTRIBUTE_ID (0x000C) +#define ZCL_PRODUCT_URL_ATTRIBUTE_ID (0x000D) +#define ZCL_PRODUCT_LABEL_ATTRIBUTE_ID (0x000E) +#define ZCL_SERIAL_NUMBER_ATTRIBUTE_ID (0x000F) +#define ZCL_LOCAL_CONFIG_DISABLED_ATTRIBUTE_ID (0x0010) + // Attribute ids for cluster: General Commissioning // Client attributes @@ -1093,15 +1092,21 @@ // Server attributes #define ZCL_MAX_DURATION_ATTRIBUTE_ID (0x0000) +// Attribute ids for cluster: Low Power + +// Client attributes + +// Server attributes + // Attribute ids for cluster: Application Basic // Client attributes // Server attributes -#define ZCL_VENDOR_NAME_ATTRIBUTE_ID (0x0000) -#define ZCL_VENDOR_ID_ATTRIBUTE_ID (0x0001) +#define ZCL_APPLICATION_VENDOR_NAME_ATTRIBUTE_ID (0x0000) +#define ZCL_APPLICATION_VENDOR_ID_ATTRIBUTE_ID (0x0001) #define ZCL_APPLICATION_NAME_ATTRIBUTE_ID (0x0002) -#define ZCL_PRODUCT_ID_ATTRIBUTE_ID (0x0003) +#define ZCL_APPLICATION_PRODUCT_ID_ATTRIBUTE_ID (0x0003) #define ZCL_APPLICATION_ID_ATTRIBUTE_ID (0x0005) #define ZCL_CATALOG_VENDOR_ID_ATTRIBUTE_ID (0x0006) #define ZCL_APPLICATION_STATUS_ATTRIBUTE_ID (0x0007) @@ -3833,7 +3838,7 @@ #define ZCL_PRICE_TRAILING_DIGIT_ATTRIBUTE_ID (0x0021) #define ZCL_PRICE_ATTRIBUTE_ID (0x0022) #define ZCL_GOOD_ID_ATTRIBUTE_ID (0x0030) -#define ZCL_SERIAL_NUMBER_ATTRIBUTE_ID (0x0031) +#define ZCL_PAYMENT_SERIAL_NUMBER_ATTRIBUTE_ID (0x0031) #define ZCL_PAYMENT_TIMESTAMP_ATTRIBUTE_ID (0x0032) #define ZCL_TRANS_ID_ATTRIBUTE_ID (0x0033) #define ZCL_TRANS_STATUS_ATTRIBUTE_ID (0x0034) diff --git a/examples/lighting-app/lighting-common/gen/call-command-handler.cpp b/examples/lighting-app/lighting-common/gen/call-command-handler.cpp index 375d024913ed75..4680bec8290107 100644 --- a/examples/lighting-app/lighting-common/gen/call-command-handler.cpp +++ b/examples/lighting-app/lighting-common/gen/call-command-handler.cpp @@ -28,6 +28,7 @@ using namespace chip; +EmberAfStatus emberAfBasicClusterServerCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfLevelControlClusterServerCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfNetworkCommissioningClusterServerCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfOnOffClusterServerCommandParse(EmberAfClusterCommand * cmd); @@ -71,6 +72,10 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd) { switch (cmd->apsFrame->clusterId) { + case ZCL_BASIC_CLUSTER_ID: + // No commands are enabled for cluster Basic + result = status(false, true, cmd->mfgSpecific); + break; case ZCL_LEVEL_CONTROL_CLUSTER_ID: result = emberAfLevelControlClusterServerCommandParse(cmd); break; diff --git a/examples/lighting-app/lighting-common/gen/callback-stub.cpp b/examples/lighting-app/lighting-common/gen/callback-stub.cpp index b090552dc58782..f40262e72697b7 100644 --- a/examples/lighting-app/lighting-common/gen/callback-stub.cpp +++ b/examples/lighting-app/lighting-common/gen/callback-stub.cpp @@ -27,6 +27,9 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) { switch (clusterId) { + case ZCL_BASIC_CLUSTER_ID: + emberAfBasicClusterInitCallback(endpoint); + break; case ZCL_LEVEL_CONTROL_CLUSTER_ID: emberAfLevelControlClusterInitCallback(endpoint); break; @@ -42,6 +45,11 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) } } +void __attribute__((weak)) emberAfBasicClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} void __attribute__((weak)) emberAfLevelControlClusterInitCallback(EndpointId endpoint) { // To prevent warning diff --git a/examples/lighting-app/lighting-common/gen/callback.h b/examples/lighting-app/lighting-common/gen/callback.h index 28a6fbb92ac753..dfac28f4dfce71 100644 --- a/examples/lighting-app/lighting-common/gen/callback.h +++ b/examples/lighting-app/lighting-common/gen/callback.h @@ -37,6 +37,14 @@ void emberAfClusterInitCallback(chip::EndpointId endpoint, chip::ClusterId clust // Cluster Init Functions +/** @brief Basic Cluster Init + * + * Cluster Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfBasicClusterInitCallback(chip::EndpointId endpoint); + /** @brief Level Control Cluster Init * * Cluster Init @@ -63,6 +71,74 @@ void emberAfOnOffClusterInitCallback(chip::EndpointId endpoint); // Cluster Server/Client Init Functions +// +// Basic Cluster server +// + +/** @brief Basic Cluster Server Init + * + * Server Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfBasicClusterServerInitCallback(chip::EndpointId endpoint); + +/** @brief Basic Cluster Server Attribute Changed + * + * Server Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + */ +void emberAfBasicClusterServerAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId); + +/** @brief Basic Cluster Server Manufacturer Specific Attribute Changed + * + * Server Manufacturer Specific Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + * @param manufacturerCode Manufacturer Code of the attribute that changed + */ +void emberAfBasicClusterServerManufacturerSpecificAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId, + uint16_t manufacturerCode); + +/** @brief Basic Cluster Server Message Sent + * + * Server Message Sent + * + * @param type The type of message sent + * @param indexOrDestination The destination or address to which the message was sent + * @param apsFrame The APS frame for the message + * @param msgLen The length of the message + * @param message The message that was sent + * @param status The status of the sent message + */ +void emberAfBasicClusterServerMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); + +/** @brief Basic Cluster Server Pre Attribute Changed + * + * server Pre Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute to be changed + * @param attributeType Attribute type + * @param size Attribute size + * @param value Attribute value + */ +EmberAfStatus emberAfBasicClusterServerPreAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId, + EmberAfAttributeType attributeType, uint8_t size, + uint8_t * value); + +/** @brief Basic Cluster Server Tick + * + * server Tick + * + * @param endpoint Endpoint that is being served + */ +void emberAfBasicClusterServerTickCallback(chip::EndpointId endpoint); + // // Level Control Cluster server // diff --git a/examples/lighting-app/lighting-common/gen/client-command-macro.h b/examples/lighting-app/lighting-common/gen/client-command-macro.h index 97de7f69cfff1d..f72c96f951dcff 100644 --- a/examples/lighting-app/lighting-common/gen/client-command-macro.h +++ b/examples/lighting-app/lighting-common/gen/client-command-macro.h @@ -256,15 +256,6 @@ emberAfFillExternalBuffer(mask, clusterId, ZCL_DISCOVER_ATTRIBUTES_EXTENDED_RESPONSE_COMMAND_ID, "ub", discoveryComplete, \ extendedDiscoverAttributesInfoRecords, extendedDiscoverAttributesInfoRecordsLen); -/** @brief Command description for ResetToFactoryDefaults - * - * Command: ResetToFactoryDefaults - */ -#define emberAfFillCommandBasicClusterResetToFactoryDefaults() \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID, "", ); - /** @brief Command description for Identify * * Command: Identify @@ -1795,6 +1786,33 @@ totalNumberOfNonEmptyProxyTableEntries, gpdSrcId, startIndex, gpdIeee, entriesCount, endpoint, \ proxyTableEntries, proxyTableEntriesLen, index); +/** @brief Command description for StartUp + * + * Command: StartUp + */ +#define emberAfFillCommandBasicClusterStartUp() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_START_UP_COMMAND_ID, "", ); + +/** @brief Command description for ShutDown + * + * Command: ShutDown + */ +#define emberAfFillCommandBasicClusterShutDown() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SHUT_DOWN_COMMAND_ID, "", ); + +/** @brief Command description for Leave + * + * Command: Leave + */ +#define emberAfFillCommandBasicClusterLeave() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_LEAVE_COMMAND_ID, "", ); + /** @brief Command description for SetFabric * * Command: SetFabric @@ -2964,6 +2982,15 @@ \ ZCL_SQUAWK_COMMAND_ID, "u", squawkInfo); +/** @brief Command description for Sleep + * + * Command: Sleep + */ +#define emberAfFillCommandLow \ + PowerClusterSleep() emberAfFillExternalBuffer(mask, \ + \ + ZCL_SLEEP_COMMAND_ID, "", ); + /** @brief Command description for MatchProtocolAddress * * Command: MatchProtocolAddress diff --git a/examples/lighting-app/lighting-common/gen/cluster-id.h b/examples/lighting-app/lighting-common/gen/cluster-id.h index 99de14e2586034..d77da915200ab4 100644 --- a/examples/lighting-app/lighting-common/gen/cluster-id.h +++ b/examples/lighting-app/lighting-common/gen/cluster-id.h @@ -20,9 +20,6 @@ // Prevent multiple inclusion #pragma once -// Definitions for cluster: Basic -#define ZCL_BASIC_CLUSTER_ID (0x0000) - // Definitions for cluster: Power Configuration #define ZCL_POWER_CONFIG_CLUSTER_ID (0x0001) @@ -83,6 +80,9 @@ // Definitions for cluster: Keep-Alive #define ZCL_KEEPALIVE_CLUSTER_ID (0x0025) +// Definitions for cluster: Basic +#define ZCL_BASIC_CLUSTER_ID (0x0028) + // Definitions for cluster: General Commissioning #define ZCL_GENERAL_COMMISSIONING_CLUSTER_ID (0x0030) @@ -239,6 +239,9 @@ // Definitions for cluster: IAS WD #define ZCL_IAS_WD_CLUSTER_ID (0x0502) +// Definitions for cluster: Low Power +#define ZCL_LOW_POWER_CLUSTER_ID (0x0508) + // Definitions for cluster: Application Basic #define ZCL_APPLICATION_BASIC_CLUSTER_ID (0x050D) diff --git a/examples/lighting-app/lighting-common/gen/command-id.h b/examples/lighting-app/lighting-common/gen/command-id.h index d31a267c6254af..adc2b1c6f32733 100644 --- a/examples/lighting-app/lighting-common/gen/command-id.h +++ b/examples/lighting-app/lighting-common/gen/command-id.h @@ -45,10 +45,6 @@ #define ZCL_DISCOVER_ATTRIBUTES_EXTENDED_COMMAND_ID (0x15) #define ZCL_DISCOVER_ATTRIBUTES_EXTENDED_RESPONSE_COMMAND_ID (0x16) -// Commands for cluster: Basic -#define ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID (0x00) -#define ZCL_MFG_SPECIFIC_PING_COMMAND_ID (0x00) - // Commands for cluster: Identify #define ZCL_IDENTIFY_COMMAND_ID (0x00) #define ZCL_IDENTIFY_QUERY_RESPONSE_COMMAND_ID (0x00) @@ -226,6 +222,12 @@ #define ZCL_GP_PROXY_TABLE_RESPONSE_COMMAND_ID (0x0B) #define ZCL_GP_PROXY_TABLE_REQUEST_COMMAND_ID (0x0B) +// Commands for cluster: Basic +#define ZCL_START_UP_COMMAND_ID (0x00) +#define ZCL_MFG_SPECIFIC_PING_COMMAND_ID (0x00) +#define ZCL_SHUT_DOWN_COMMAND_ID (0x01) +#define ZCL_LEAVE_COMMAND_ID (0x02) + // Commands for cluster: General Commissioning #define ZCL_SET_FABRIC_COMMAND_ID (0x00) #define ZCL_SET_FABRIC_RESPONSE_COMMAND_ID (0x01) @@ -369,6 +371,9 @@ #define ZCL_START_WARNING_COMMAND_ID (0x00) #define ZCL_SQUAWK_COMMAND_ID (0x01) +// Commands for cluster: Low Power +#define ZCL_SLEEP_COMMAND_ID (0x00) + // Commands for cluster: Generic Tunnel #define ZCL_MATCH_PROTOCOL_ADDRESS_COMMAND_ID (0x00) #define ZCL_MATCH_PROTOCOL_ADDRESS_RESPONSE_COMMAND_ID (0x00) diff --git a/examples/lighting-app/lighting-common/gen/endpoint_config.h b/examples/lighting-app/lighting-common/gen/endpoint_config.h index 7246b726413757..f82aab447d96cc 100644 --- a/examples/lighting-app/lighting-common/gen/endpoint_config.h +++ b/examples/lighting-app/lighting-common/gen/endpoint_config.h @@ -26,16 +26,61 @@ #if BIGENDIAN_CPU #define GENERATED_DEFAULTS \ { \ + /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "VendorName". side: server, big-endian */ /* 32 */ 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "ProductName". side: server, big-endian */ /* 64 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "UserLabel". side: server, big-endian */ /* 96 */ 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "Location". side: server, big-endian */ /* 112 */ 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "HardwareVersionString". side: server, big-endian */ /* 176 */ 0x00, 0x00, \ + 0x00, 0x00, /* Default for cluster: "Basic", attribute: "SoftwareVersion". side: server, big-endian */ /* 180 */ 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, /* Default for cluster: "Basic", attribute: "SoftwareVersionString". side: server, big-endian */ \ } #else // !BIGENDIAN_CPU #define GENERATED_DEFAULTS \ { \ + /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "VendorName". side: server, little-endian */ /* 32 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "ProductName". side: server, little-endian */ /* 64 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "UserLabel". side: server, little-endian */ /* 96 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "Location". side: server, little-endian */ /* 112 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "HardwareVersionString". side: server, little-endian */ /* 176 */ \ + 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "SoftwareVersion". side: server, little-endian */ /* 180 */ 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, \ + 0x00, /* Default for cluster: "Basic", attribute: "SoftwareVersionString". side: server, little-endian */ \ } #endif // BIGENDIAN_CPU -#define GENERATED_DEFAULTS_COUNT (0) +#define GENERATED_DEFAULTS_COUNT (7) #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ @@ -55,13 +100,49 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 5 +#define GENERATED_ATTRIBUTE_COUNT 17 #define GENERATED_ATTRIBUTES \ { \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 2 } }, /* On/off (server): cluster revision */ \ - { 0x0000, ZAP_TYPE(BOOLEAN), 1, 0, { (uint8_t *) 0x00 } }, /* On/off (server): on/off */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 3 } }, /* Level Control (server): cluster revision */ \ - { 0x0000, ZAP_TYPE(INT8U), 1, 0, { (uint8_t *) 0x00 } }, /* Level Control (server): current level */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 2 } }, /* On/off (server): cluster revision */ \ + { 0x0000, ZAP_TYPE(BOOLEAN), 1, 0, { (uint8_t *) 0x00 } }, /* On/off (server): on/off */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 3 } }, /* Level Control (server): cluster revision */ \ + { 0x0000, ZAP_TYPE(INT8U), 1, 0, { (uint8_t *) 0x00 } }, /* Level Control (server): current level */ \ + { \ + 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 3 } \ + }, /* Basic (server): cluster revision */ \ + { \ + 0x0000, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } \ + }, /* Basic (server): InteractionModelVersion */ \ + { \ + 0x0001, ZAP_TYPE(CHAR_STRING), 32, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(0) } \ + }, /* Basic (server): VendorName */ \ + { 0x0002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } }, /* Basic (server): VendorID */ \ + { \ + 0x0003, ZAP_TYPE(CHAR_STRING), 32, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(32) } \ + }, /* Basic (server): ProductName */ \ + { 0x0004, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } }, /* Basic (server): ProductID */ \ + { 0x0005, \ + ZAP_TYPE(CHAR_STRING), \ + 32, \ + ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(64) } }, /* Basic (server): UserLabel */ \ + { 0x0006, \ + ZAP_TYPE(CHAR_STRING), \ + 16, \ + ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(96) } }, /* Basic (server): Location */ \ + { \ + 0x0007, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0x00 } \ + }, /* Basic (server): HardwareVersion */ \ + { \ + 0x0008, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(112) } \ + }, /* Basic (server): HardwareVersionString */ \ + { \ + 0x0009, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(176) } \ + }, /* Basic (server): SoftwareVersion */ \ + { \ + 0x000A, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(180) } \ + }, /* Basic (server): SoftwareVersionString */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Network Commissioning (server): cluster revision */ \ } @@ -78,7 +159,7 @@ }; #define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask -#define GENERATED_CLUSTER_COUNT 3 +#define GENERATED_CLUSTER_COUNT 4 #define GENERATED_CLUSTERS \ { \ { \ @@ -96,7 +177,10 @@ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayLevelControlServer }, /* Endpoint: 1, Cluster: Level Control (server) */ \ { \ - 0xAAAA, ZAP_ATTRIBUTE_INDEX(4), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0028, ZAP_ATTRIBUTE_INDEX(4), 12, 254, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 1, Cluster: Basic (server) */ \ + { \ + 0xAAAA, ZAP_ATTRIBUTE_INDEX(16), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Network Commissioning (server) */ \ } @@ -105,17 +189,17 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 3, 8 }, \ + { ZAP_CLUSTER_INDEX(0), 4, 262 }, \ } // Largest attribute size is needed for various buffers -#define ATTRIBUTE_LARGEST (3) +#define ATTRIBUTE_LARGEST (64) // Total size of singleton attributes -#define ATTRIBUTE_SINGLETONS_SIZE (0) +#define ATTRIBUTE_SINGLETONS_SIZE (254) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (8) +#define ATTRIBUTE_MAX_SIZE (262) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (1) @@ -159,7 +243,7 @@ // Array of EmberAfCommandMetadata structs. #define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask -#define EMBER_AF_GENERATED_COMMAND_COUNT (28) +#define EMBER_AF_GENERATED_COMMAND_COUNT (31) #define GENERATED_COMMANDS \ { \ { 0x0006, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* On/off (server): Off */ \ @@ -173,6 +257,9 @@ { 0x0008, 0x05, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Level Control (server): MoveWithOnOff */ \ { 0x0008, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Level Control (server): StepWithOnOff */ \ { 0x0008, 0x07, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Level Control (server): StopWithOnOff */ \ + { 0x0028, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): StartUp */ \ + { 0x0028, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): ShutDown */ \ + { 0x0028, 0x02, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): Leave */ \ { 0xAAAA, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): ScanNetworks */ \ { 0xAAAA, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): ScanNetworksResponse */ \ { 0xAAAA, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): AddWiFiNetwork */ \ diff --git a/examples/lighting-app/lighting-common/gen/gen_config.h b/examples/lighting-app/lighting-common/gen/gen_config.h index 9bd486c1a9ba92..524f4fb920a18d 100644 --- a/examples/lighting-app/lighting-common/gen/gen_config.h +++ b/examples/lighting-app/lighting-common/gen/gen_config.h @@ -29,12 +29,18 @@ #define EMBER_APS_UNICAST_MESSAGE_COUNT 10 /**** Cluster endpoint counts ****/ +#define EMBER_AF_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_LEVEL_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_NETWORK_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_ON_OFF_CLUSTER_SERVER_ENDPOINT_COUNT (1) /**** Cluster Plugins ****/ +// Use this macro to check if the server side of the Basic cluster is included +#define ZCL_USING_BASIC_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_BASIC_SERVER +#define EMBER_AF_PLUGIN_BASIC + // Use this macro to check if the server side of the Level Control cluster is included #define ZCL_USING_LEVEL_CONTROL_CLUSTER_SERVER #define EMBER_AF_PLUGIN_LEVEL_CONTROL_SERVER diff --git a/examples/lighting-app/lighting-common/gen/print-cluster.h b/examples/lighting-app/lighting-common/gen/print-cluster.h index 86a2a27beec86b..bd08d38a581506 100644 --- a/examples/lighting-app/lighting-common/gen/print-cluster.h +++ b/examples/lighting-app/lighting-common/gen/print-cluster.h @@ -24,12 +24,6 @@ // to the "EmberAfClusterName" defined in the ZCL header. // The names of clusters that are not present, are removed. -#if defined(ZCL_USING_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_BASIC_CLUSTER_CLIENT) -#define CHIP_PRINTCLUSTER_BASIC_CLUSTER { ZCL_BASIC_CLUSTER_ID, 0, "Basic" }, -#else -#define CHIP_PRINTCLUSTER_BASIC_CLUSTER -#endif - #if defined(ZCL_USING_POWER_CONFIG_CLUSTER_SERVER) || defined(ZCL_USING_POWER_CONFIG_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_POWER_CONFIG_CLUSTER { ZCL_POWER_CONFIG_CLUSTER_ID, 1, "Power Configuration" }, #else @@ -150,6 +144,12 @@ #define CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER #endif +#if defined(ZCL_USING_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_BASIC_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_BASIC_CLUSTER { ZCL_BASIC_CLUSTER_ID, 40, "Basic" }, +#else +#define CHIP_PRINTCLUSTER_BASIC_CLUSTER +#endif + #if defined(ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER { ZCL_GENERAL_COMMISSIONING_CLUSTER_ID, 48, "General Commissioning" }, #else @@ -526,6 +526,12 @@ #define CHIP_PRINTCLUSTER_IAS_WD_CLUSTER #endif +#if defined(ZCL_USING_LOW_POWER_CLUSTER_SERVER) || defined(ZCL_USING_LOW_POWER_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER { ZCL_LOW_POWER_CLUSTER_ID, 1288, "Low Power" }, +#else +#define CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER +#endif + #if defined(ZCL_USING_APPLICATION_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_APPLICATION_BASIC_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_APPLICATION_BASIC_CLUSTER { ZCL_APPLICATION_BASIC_CLUSTER_ID, 1293, "Application Basic" }, #else @@ -784,7 +790,6 @@ #endif #define CLUSTER_IDS_TO_NAMES \ - CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_POWER_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DEVICE_TEMP_CLUSTER \ CHIP_PRINTCLUSTER_IDENTIFY_CLUSTER \ @@ -805,6 +810,7 @@ CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER \ CHIP_PRINTCLUSTER_GREEN_POWER_CLUSTER \ CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER \ + CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DOOR_LOCK_CLUSTER \ @@ -857,6 +863,7 @@ CHIP_PRINTCLUSTER_IAS_ZONE_CLUSTER \ CHIP_PRINTCLUSTER_IAS_ACE_CLUSTER \ CHIP_PRINTCLUSTER_IAS_WD_CLUSTER \ + CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER \ CHIP_PRINTCLUSTER_APPLICATION_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_GENERIC_TUNNEL_CLUSTER \ CHIP_PRINTCLUSTER_BACNET_PROTOCOL_TUNNEL_CLUSTER \ diff --git a/examples/lighting-app/lighting-common/lighting-app.zap b/examples/lighting-app/lighting-common/lighting-app.zap index 699ae3fdc7c314..79094c919ddd3b 100644 --- a/examples/lighting-app/lighting-common/lighting-app.zap +++ b/examples/lighting-app/lighting-common/lighting-app.zap @@ -39,7 +39,7 @@ "clusters": [ { "name": "Basic", - "code": 0, + "code": 40, "mfgCode": null, "define": "BASIC_CLUSTER", "side": "client", @@ -53,7 +53,7 @@ "side": "client", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, "defaultValue": "3", "reportable": 0, @@ -65,12 +65,37 @@ }, { "name": "Basic", - "code": 0, + "code": 40, "mfgCode": null, "define": "BASIC_CLUSTER", "side": "server", - "enabled": 0, - "commands": [], + "enabled": 1, + "commands": [ + { + "name": "StartUp", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ShutDown", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "Leave", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], "attributes": [ { "name": "cluster revision", @@ -79,7 +104,7 @@ "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, "defaultValue": "3", "reportable": 0, @@ -88,34 +113,169 @@ "reportableChange": 0 }, { - "name": "ZCL version", + "name": "InteractionModelVersion", "code": 0, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorName", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorID", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductName", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductID", + "code": 4, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, "bounded": 0, - "defaultValue": "0x08", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "power source", + "name": "UserLabel", + "code": 5, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Location", + "code": 6, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersion", "code": 7, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersionString", + "code": 8, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersion", + "code": 9, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, "bounded": 0, "defaultValue": "0x00", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 + }, + { + "name": "SoftwareVersionString", + "code": 10, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 } ] }, diff --git a/examples/lock-app/lock-common/gen/CHIPClientCallbacks.cpp b/examples/lock-app/lock-common/gen/CHIPClientCallbacks.cpp index f5f88af110c2c7..fc5ea3b1b8a7c6 100644 --- a/examples/lock-app/lock-common/gen/CHIPClientCallbacks.cpp +++ b/examples/lock-app/lock-common/gen/CHIPClientCallbacks.cpp @@ -272,10 +272,6 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag case 0x38: // semi / Semi-precision case 0x39: // single / Single precision case 0x3A: // double / Double precision - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string case 0x48: // array / Array case 0x49: // struct / Structure case 0x50: // set / Set @@ -289,6 +285,48 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag return true; } + case 0x41: // octstr / Octet string + case 0x42: // string / Character string + { + // Short Strings must contains at least one byte for the length + CHECK_MESSAGE_LENGTH(1); + uint8_t length = chip::Encoding::Read8(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + + case 0x43: // octstr16 / Long octet string + case 0x44: // string16 / Long character string + { + // Long Strings must contains at least two bytes for the length + CHECK_MESSAGE_LENGTH(2); + uint16_t length = chip::Encoding::LittleEndian::Read16(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFFFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFFFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + case 0x08: // data8 / 8-bit data case 0x18: // map8 / 8-bit bitmap case 0x20: // uint8 / Unsigned 8-bit integer @@ -696,10 +734,6 @@ bool emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * message, uin case 0x38: // semi / Semi-precision case 0x39: // single / Single precision case 0x3A: // double / Double precision - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string case 0x48: // array / Array case 0x49: // struct / Structure case 0x50: // set / Set @@ -710,6 +744,48 @@ bool emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * message, uin return true; } + case 0x41: // octstr / Octet string + case 0x42: // string / Character string + { + // Short Strings must contains at least one byte for the length + CHECK_MESSAGE_LENGTH(1); + uint8_t length = chip::Encoding::Read8(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onReportCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + + case 0x43: // octstr16 / Long octet string + case 0x44: // string16 / Long character string + { + // Long Strings must contains at least two bytes for the length + CHECK_MESSAGE_LENGTH(2); + uint16_t length = chip::Encoding::LittleEndian::Read16(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFFFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFFFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onReportCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + case 0x08: // data8 / 8-bit data case 0x18: // map8 / 8-bit bitmap case 0x20: // uint8 / Unsigned 8-bit integer diff --git a/examples/lock-app/lock-common/gen/CHIPClientCallbacks.h b/examples/lock-app/lock-common/gen/CHIPClientCallbacks.h index 14a3742f090e8f..d028079f799d79 100644 --- a/examples/lock-app/lock-common/gen/CHIPClientCallbacks.h +++ b/examples/lock-app/lock-common/gen/CHIPClientCallbacks.h @@ -20,6 +20,7 @@ #pragma once #include +#include // Global Response Callbacks typedef void (*DefaultSuccessCallback)(void * context); @@ -33,6 +34,7 @@ typedef void (*Int32uAttributeCallback)(void * context, uint32_t value); typedef void (*Int32sAttributeCallback)(void * context, int32_t value); typedef void (*Int64uAttributeCallback)(void * context, uint64_t value); typedef void (*Int64sAttributeCallback)(void * context, int64_t value); +typedef void (*StringAttributeCallback)(void * context, const chip::ByteSpan value); typedef void (*ReadReportingConfigurationReportedCallback)(void * context, uint16_t minInterval, uint16_t maxInterval); typedef void (*ReadReportingConfigurationReceivedCallback)(void * context, uint16_t timeout); diff --git a/examples/lock-app/lock-common/gen/CHIPClustersObjc.h b/examples/lock-app/lock-common/gen/CHIPClustersObjc.h index 9c9644fb00fb7a..acd8add7e83adf 100644 --- a/examples/lock-app/lock-common/gen/CHIPClustersObjc.h +++ b/examples/lock-app/lock-common/gen/CHIPClustersObjc.h @@ -42,6 +42,29 @@ NS_ASSUME_NONNULL_BEGIN @end +/** + * Cluster Basic + * + */ +@interface CHIPBasic : CHIPCluster + +- (void)readAttributeInteractionModelVersion:(ResponseHandler)completionHandler; +- (void)readAttributeVendorName:(ResponseHandler)completionHandler; +- (void)readAttributeVendorID:(ResponseHandler)completionHandler; +- (void)readAttributeProductName:(ResponseHandler)completionHandler; +- (void)readAttributeProductID:(ResponseHandler)completionHandler; +- (void)readAttributeUserLabel:(ResponseHandler)completionHandler; +- (void)writeAttributeUserLabel:(NSString *)value completionHandler:(ResponseHandler)completionHandler; +- (void)readAttributeLocation:(ResponseHandler)completionHandler; +- (void)writeAttributeLocation:(NSString *)value completionHandler:(ResponseHandler)completionHandler; +- (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler; +- (void)readAttributeHardwareVersionString:(ResponseHandler)completionHandler; +- (void)readAttributeSoftwareVersion:(ResponseHandler)completionHandler; +- (void)readAttributeSoftwareVersionString:(ResponseHandler)completionHandler; +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler; + +@end + /** * Cluster On/off * diff --git a/examples/lock-app/lock-common/gen/CHIPClustersObjc.mm b/examples/lock-app/lock-common/gen/CHIPClustersObjc.mm index 2438c14e74d4a2..2877d11c507428 100644 --- a/examples/lock-app/lock-common/gen/CHIPClustersObjc.mm +++ b/examples/lock-app/lock-common/gen/CHIPClustersObjc.mm @@ -89,26 +89,38 @@ static void CallbackFn(void * context, uint8_t status) dispatch_queue_t mQueue; }; -class CHIPUnsupportedAttributeCallbackBridge : public Callback::Callback { +class CHIPStringAttributeCallbackBridge : public Callback::Callback { public: - CHIPUnsupportedAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) - : Callback::Callback(CallbackFn, this) + CHIPStringAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool octetString, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mOctetString(octetString) + , mKeepAlive(keepAlive) { } - ~CHIPUnsupportedAttributeCallbackBridge() {}; + ~CHIPStringAttributeCallbackBridge() {}; - static void CallbackFn(void * context) + static void CallbackFn(void * context, chip::ByteSpan value) { - CHIPUnsupportedAttributeCallbackBridge * callback = reinterpret_cast(context); + CHIPStringAttributeCallbackBridge * callback = reinterpret_cast(context); if (callback && callback->mQueue) { dispatch_async(callback->mQueue, ^{ - NSError * error = [NSError errorWithDomain:CHIPErrorDomain - code:CHIPErrorCodeUndefinedError - userInfo:@ { NSLocalizedDescriptionKey : @"Unsupported attribute type" }]; - callback->mHandler(error, nil); - callback->Cancel(); - delete callback; + if (callback->mOctetString) { + NSData * data = [NSData dataWithBytes:value.data() length:value.size()]; + callback->mHandler(nil, @ { @"value" : data }); + } else { + NSString * str = [[NSString alloc] initWithBytes:value.data() + length:value.size() + encoding:NSUTF8StringEncoding]; + callback->mHandler(nil, @ { @"value" : str }); + } + + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } }); } }; @@ -116,6 +128,8 @@ static void CallbackFn(void * context) private: ResponseHandler mHandler; dispatch_queue_t mQueue; + bool mOctetString; + bool mKeepAlive; }; class CHIPBooleanAttributeCallbackBridge : public Callback::Callback { @@ -246,6 +260,38 @@ static void CallbackFn(void * context, uint16_t value) bool mKeepAlive; }; +class CHIPInt32uAttributeCallbackBridge : public Callback::Callback { +public: + CHIPInt32uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mKeepAlive(keepAlive) + { + } + + ~CHIPInt32uAttributeCallbackBridge() {}; + + static void CallbackFn(void * context, uint32_t value) + { + CHIPInt32uAttributeCallbackBridge * callback = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedLong:value] }); + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; + bool mKeepAlive; +}; + class CHIPInt16sAttributeCallbackBridge : public Callback::Callback { public: CHIPInt16sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) @@ -308,6 +354,351 @@ - (instancetype)initWithDevice:(CHIPDevice *)device endpoint:(EndpointId)endpoin } @end +@interface CHIPBasic () +@property (readonly) Controller::BasicCluster cppCluster; +@end + +@implementation CHIPBasic + +- (Controller::ClusterBase *)getCluster +{ + return &_cppCluster; +} + +- (void)readAttributeInteractionModelVersion:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeInteractionModelVersion(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeVendorName:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeVendorID:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeVendorID(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeProductName:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeProductName(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeProductID:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeProductID(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeUserLabel:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeUserLabel(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)writeAttributeUserLabel:(NSString *)value completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + CHIP_ERROR err = self.cppCluster.WriteAttributeUserLabel( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeLocation:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeLocation(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)writeAttributeLocation:(NSString *)value completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + CHIP_ERROR err = self.cppCluster.WriteAttributeLocation( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeHardwareVersionString:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeSoftwareVersion:(ResponseHandler)completionHandler +{ + CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeSoftwareVersionString:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +@end + @interface CHIPOnOff () @property (readonly) Controller::OnOffCluster cppCluster; @end diff --git a/examples/lock-app/lock-common/gen/attribute-id.h b/examples/lock-app/lock-common/gen/attribute-id.h index 8802797f112bd6..8c8757f826ca7f 100644 --- a/examples/lock-app/lock-common/gen/attribute-id.h +++ b/examples/lock-app/lock-common/gen/attribute-id.h @@ -26,30 +26,6 @@ #define ZCL_REPORTING_STATUS_CLIENT_ATTRIBUTE_ID (0xFFFE) #define ZCL_REPORTING_STATUS_SERVER_ATTRIBUTE_ID (0xFFFE) -// Attribute ids for cluster: Basic - -// Client attributes - -// Server attributes -#define ZCL_VERSION_ATTRIBUTE_ID (0x0000) -#define ZCL_APPLICATION_VERSION_ATTRIBUTE_ID (0x0001) -#define ZCL_STACK_VERSION_ATTRIBUTE_ID (0x0002) -#define ZCL_HW_VERSION_ATTRIBUTE_ID (0x0003) -#define ZCL_MANUFACTURER_NAME_ATTRIBUTE_ID (0x0004) -#define ZCL_MODEL_IDENTIFIER_ATTRIBUTE_ID (0x0005) -#define ZCL_DATE_CODE_ATTRIBUTE_ID (0x0006) -#define ZCL_POWER_SOURCE_ATTRIBUTE_ID (0x0007) -#define ZCL_GENERIC_DEVICE_CLASS_ATTRIBUTE_ID (0x0008) -#define ZCL_GENERIC_DEVICE_TYPE_ATTRIBUTE_ID (0x0009) -#define ZCL_PRODUCT_CODE_ATTRIBUTE_ID (0x000A) -#define ZCL_PRODUCT_URL_ATTRIBUTE_ID (0x000B) -#define ZCL_LOCATION_DESCRIPTION_ATTRIBUTE_ID (0x0010) -#define ZCL_PHYSICAL_ENVIRONMENT_ATTRIBUTE_ID (0x0011) -#define ZCL_DEVICE_ENABLED_ATTRIBUTE_ID (0x0012) -#define ZCL_ALARM_MASK_ATTRIBUTE_ID (0x0013) -#define ZCL_DISABLE_LOCAL_CONFIG_ATTRIBUTE_ID (0x0014) -#define ZCL_SW_BUILD_ID_ATTRIBUTE_ID (0x4000) - // Attribute ids for cluster: Power Configuration // Client attributes @@ -384,6 +360,29 @@ #define ZCL_KEEPALIVE_BASE_ATTRIBUTE_ID (0x0000) #define ZCL_KEEPALIVE_JITTER_ATTRIBUTE_ID (0x0001) +// Attribute ids for cluster: Basic + +// Client attributes + +// Server attributes +#define ZCL_INTERACTION_MODEL_VERSION_ATTRIBUTE_ID (0x0000) +#define ZCL_VENDOR_NAME_ATTRIBUTE_ID (0x0001) +#define ZCL_VENDOR_ID_ATTRIBUTE_ID (0x0002) +#define ZCL_PRODUCT_NAME_ATTRIBUTE_ID (0x0003) +#define ZCL_PRODUCT_ID_ATTRIBUTE_ID (0x0004) +#define ZCL_USER_LABEL_ATTRIBUTE_ID (0x0005) +#define ZCL_LOCATION_ATTRIBUTE_ID (0x0006) +#define ZCL_HARDWARE_VERSION_ATTRIBUTE_ID (0x0007) +#define ZCL_HARDWARE_VERSION_STRING_ATTRIBUTE_ID (0x0008) +#define ZCL_SOFTWARE_VERSION_ATTRIBUTE_ID (0x0009) +#define ZCL_SOFTWARE_VERSION_STRING_ATTRIBUTE_ID (0x000A) +#define ZCL_MANUFACTURING_DATE_ATTRIBUTE_ID (0x000B) +#define ZCL_PART_NUMBER_ATTRIBUTE_ID (0x000C) +#define ZCL_PRODUCT_URL_ATTRIBUTE_ID (0x000D) +#define ZCL_PRODUCT_LABEL_ATTRIBUTE_ID (0x000E) +#define ZCL_SERIAL_NUMBER_ATTRIBUTE_ID (0x000F) +#define ZCL_LOCAL_CONFIG_DISABLED_ATTRIBUTE_ID (0x0010) + // Attribute ids for cluster: General Commissioning // Client attributes @@ -1093,15 +1092,21 @@ // Server attributes #define ZCL_MAX_DURATION_ATTRIBUTE_ID (0x0000) +// Attribute ids for cluster: Low Power + +// Client attributes + +// Server attributes + // Attribute ids for cluster: Application Basic // Client attributes // Server attributes -#define ZCL_VENDOR_NAME_ATTRIBUTE_ID (0x0000) -#define ZCL_VENDOR_ID_ATTRIBUTE_ID (0x0001) +#define ZCL_APPLICATION_VENDOR_NAME_ATTRIBUTE_ID (0x0000) +#define ZCL_APPLICATION_VENDOR_ID_ATTRIBUTE_ID (0x0001) #define ZCL_APPLICATION_NAME_ATTRIBUTE_ID (0x0002) -#define ZCL_PRODUCT_ID_ATTRIBUTE_ID (0x0003) +#define ZCL_APPLICATION_PRODUCT_ID_ATTRIBUTE_ID (0x0003) #define ZCL_APPLICATION_ID_ATTRIBUTE_ID (0x0005) #define ZCL_CATALOG_VENDOR_ID_ATTRIBUTE_ID (0x0006) #define ZCL_APPLICATION_STATUS_ATTRIBUTE_ID (0x0007) @@ -3833,7 +3838,7 @@ #define ZCL_PRICE_TRAILING_DIGIT_ATTRIBUTE_ID (0x0021) #define ZCL_PRICE_ATTRIBUTE_ID (0x0022) #define ZCL_GOOD_ID_ATTRIBUTE_ID (0x0030) -#define ZCL_SERIAL_NUMBER_ATTRIBUTE_ID (0x0031) +#define ZCL_PAYMENT_SERIAL_NUMBER_ATTRIBUTE_ID (0x0031) #define ZCL_PAYMENT_TIMESTAMP_ATTRIBUTE_ID (0x0032) #define ZCL_TRANS_ID_ATTRIBUTE_ID (0x0033) #define ZCL_TRANS_STATUS_ATTRIBUTE_ID (0x0034) diff --git a/examples/lock-app/lock-common/gen/call-command-handler.cpp b/examples/lock-app/lock-common/gen/call-command-handler.cpp index 5c9bdd76005c89..730d7b2f96ff87 100644 --- a/examples/lock-app/lock-common/gen/call-command-handler.cpp +++ b/examples/lock-app/lock-common/gen/call-command-handler.cpp @@ -28,6 +28,7 @@ using namespace chip; +EmberAfStatus emberAfBasicClusterServerCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfOnOffClusterServerCommandParse(EmberAfClusterCommand * cmd); static EmberAfStatus status(bool wasHandled, bool clusterExists, bool mfgSpecific) @@ -69,6 +70,10 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd) { switch (cmd->apsFrame->clusterId) { + case ZCL_BASIC_CLUSTER_ID: + // No commands are enabled for cluster Basic + result = status(false, true, cmd->mfgSpecific); + break; case ZCL_ON_OFF_CLUSTER_ID: result = emberAfOnOffClusterServerCommandParse(cmd); break; diff --git a/examples/lock-app/lock-common/gen/callback-stub.cpp b/examples/lock-app/lock-common/gen/callback-stub.cpp index 7673db7643259b..3c6022fe4e04d8 100644 --- a/examples/lock-app/lock-common/gen/callback-stub.cpp +++ b/examples/lock-app/lock-common/gen/callback-stub.cpp @@ -27,6 +27,9 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) { switch (clusterId) { + case ZCL_BASIC_CLUSTER_ID: + emberAfBasicClusterInitCallback(endpoint); + break; case ZCL_ON_OFF_CLUSTER_ID: emberAfOnOffClusterInitCallback(endpoint); break; @@ -36,6 +39,11 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) } } +void __attribute__((weak)) emberAfBasicClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} void __attribute__((weak)) emberAfOnOffClusterInitCallback(EndpointId endpoint) { // To prevent warning diff --git a/examples/lock-app/lock-common/gen/callback.h b/examples/lock-app/lock-common/gen/callback.h index fe0caa9bb35762..367f192b93dac0 100644 --- a/examples/lock-app/lock-common/gen/callback.h +++ b/examples/lock-app/lock-common/gen/callback.h @@ -37,6 +37,14 @@ void emberAfClusterInitCallback(chip::EndpointId endpoint, chip::ClusterId clust // Cluster Init Functions +/** @brief Basic Cluster Init + * + * Cluster Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfBasicClusterInitCallback(chip::EndpointId endpoint); + /** @brief On/off Cluster Init * * Cluster Init @@ -47,6 +55,74 @@ void emberAfOnOffClusterInitCallback(chip::EndpointId endpoint); // Cluster Server/Client Init Functions +// +// Basic Cluster server +// + +/** @brief Basic Cluster Server Init + * + * Server Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfBasicClusterServerInitCallback(chip::EndpointId endpoint); + +/** @brief Basic Cluster Server Attribute Changed + * + * Server Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + */ +void emberAfBasicClusterServerAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId); + +/** @brief Basic Cluster Server Manufacturer Specific Attribute Changed + * + * Server Manufacturer Specific Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + * @param manufacturerCode Manufacturer Code of the attribute that changed + */ +void emberAfBasicClusterServerManufacturerSpecificAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId, + uint16_t manufacturerCode); + +/** @brief Basic Cluster Server Message Sent + * + * Server Message Sent + * + * @param type The type of message sent + * @param indexOrDestination The destination or address to which the message was sent + * @param apsFrame The APS frame for the message + * @param msgLen The length of the message + * @param message The message that was sent + * @param status The status of the sent message + */ +void emberAfBasicClusterServerMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, EmberStatus status); + +/** @brief Basic Cluster Server Pre Attribute Changed + * + * server Pre Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute to be changed + * @param attributeType Attribute type + * @param size Attribute size + * @param value Attribute value + */ +EmberAfStatus emberAfBasicClusterServerPreAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId, + EmberAfAttributeType attributeType, uint8_t size, + uint8_t * value); + +/** @brief Basic Cluster Server Tick + * + * server Tick + * + * @param endpoint Endpoint that is being served + */ +void emberAfBasicClusterServerTickCallback(chip::EndpointId endpoint); + // // On/off Cluster server // diff --git a/examples/lock-app/lock-common/gen/client-command-macro.h b/examples/lock-app/lock-common/gen/client-command-macro.h index 97de7f69cfff1d..f72c96f951dcff 100644 --- a/examples/lock-app/lock-common/gen/client-command-macro.h +++ b/examples/lock-app/lock-common/gen/client-command-macro.h @@ -256,15 +256,6 @@ emberAfFillExternalBuffer(mask, clusterId, ZCL_DISCOVER_ATTRIBUTES_EXTENDED_RESPONSE_COMMAND_ID, "ub", discoveryComplete, \ extendedDiscoverAttributesInfoRecords, extendedDiscoverAttributesInfoRecordsLen); -/** @brief Command description for ResetToFactoryDefaults - * - * Command: ResetToFactoryDefaults - */ -#define emberAfFillCommandBasicClusterResetToFactoryDefaults() \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID, "", ); - /** @brief Command description for Identify * * Command: Identify @@ -1795,6 +1786,33 @@ totalNumberOfNonEmptyProxyTableEntries, gpdSrcId, startIndex, gpdIeee, entriesCount, endpoint, \ proxyTableEntries, proxyTableEntriesLen, index); +/** @brief Command description for StartUp + * + * Command: StartUp + */ +#define emberAfFillCommandBasicClusterStartUp() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_START_UP_COMMAND_ID, "", ); + +/** @brief Command description for ShutDown + * + * Command: ShutDown + */ +#define emberAfFillCommandBasicClusterShutDown() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SHUT_DOWN_COMMAND_ID, "", ); + +/** @brief Command description for Leave + * + * Command: Leave + */ +#define emberAfFillCommandBasicClusterLeave() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_LEAVE_COMMAND_ID, "", ); + /** @brief Command description for SetFabric * * Command: SetFabric @@ -2964,6 +2982,15 @@ \ ZCL_SQUAWK_COMMAND_ID, "u", squawkInfo); +/** @brief Command description for Sleep + * + * Command: Sleep + */ +#define emberAfFillCommandLow \ + PowerClusterSleep() emberAfFillExternalBuffer(mask, \ + \ + ZCL_SLEEP_COMMAND_ID, "", ); + /** @brief Command description for MatchProtocolAddress * * Command: MatchProtocolAddress diff --git a/examples/lock-app/lock-common/gen/cluster-id.h b/examples/lock-app/lock-common/gen/cluster-id.h index 99de14e2586034..d77da915200ab4 100644 --- a/examples/lock-app/lock-common/gen/cluster-id.h +++ b/examples/lock-app/lock-common/gen/cluster-id.h @@ -20,9 +20,6 @@ // Prevent multiple inclusion #pragma once -// Definitions for cluster: Basic -#define ZCL_BASIC_CLUSTER_ID (0x0000) - // Definitions for cluster: Power Configuration #define ZCL_POWER_CONFIG_CLUSTER_ID (0x0001) @@ -83,6 +80,9 @@ // Definitions for cluster: Keep-Alive #define ZCL_KEEPALIVE_CLUSTER_ID (0x0025) +// Definitions for cluster: Basic +#define ZCL_BASIC_CLUSTER_ID (0x0028) + // Definitions for cluster: General Commissioning #define ZCL_GENERAL_COMMISSIONING_CLUSTER_ID (0x0030) @@ -239,6 +239,9 @@ // Definitions for cluster: IAS WD #define ZCL_IAS_WD_CLUSTER_ID (0x0502) +// Definitions for cluster: Low Power +#define ZCL_LOW_POWER_CLUSTER_ID (0x0508) + // Definitions for cluster: Application Basic #define ZCL_APPLICATION_BASIC_CLUSTER_ID (0x050D) diff --git a/examples/lock-app/lock-common/gen/command-id.h b/examples/lock-app/lock-common/gen/command-id.h index d31a267c6254af..adc2b1c6f32733 100644 --- a/examples/lock-app/lock-common/gen/command-id.h +++ b/examples/lock-app/lock-common/gen/command-id.h @@ -45,10 +45,6 @@ #define ZCL_DISCOVER_ATTRIBUTES_EXTENDED_COMMAND_ID (0x15) #define ZCL_DISCOVER_ATTRIBUTES_EXTENDED_RESPONSE_COMMAND_ID (0x16) -// Commands for cluster: Basic -#define ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID (0x00) -#define ZCL_MFG_SPECIFIC_PING_COMMAND_ID (0x00) - // Commands for cluster: Identify #define ZCL_IDENTIFY_COMMAND_ID (0x00) #define ZCL_IDENTIFY_QUERY_RESPONSE_COMMAND_ID (0x00) @@ -226,6 +222,12 @@ #define ZCL_GP_PROXY_TABLE_RESPONSE_COMMAND_ID (0x0B) #define ZCL_GP_PROXY_TABLE_REQUEST_COMMAND_ID (0x0B) +// Commands for cluster: Basic +#define ZCL_START_UP_COMMAND_ID (0x00) +#define ZCL_MFG_SPECIFIC_PING_COMMAND_ID (0x00) +#define ZCL_SHUT_DOWN_COMMAND_ID (0x01) +#define ZCL_LEAVE_COMMAND_ID (0x02) + // Commands for cluster: General Commissioning #define ZCL_SET_FABRIC_COMMAND_ID (0x00) #define ZCL_SET_FABRIC_RESPONSE_COMMAND_ID (0x01) @@ -369,6 +371,9 @@ #define ZCL_START_WARNING_COMMAND_ID (0x00) #define ZCL_SQUAWK_COMMAND_ID (0x01) +// Commands for cluster: Low Power +#define ZCL_SLEEP_COMMAND_ID (0x00) + // Commands for cluster: Generic Tunnel #define ZCL_MATCH_PROTOCOL_ADDRESS_COMMAND_ID (0x00) #define ZCL_MATCH_PROTOCOL_ADDRESS_RESPONSE_COMMAND_ID (0x00) diff --git a/examples/lock-app/lock-common/gen/endpoint_config.h b/examples/lock-app/lock-common/gen/endpoint_config.h index 41d5eeb70c4a20..07daefdf20ddf5 100644 --- a/examples/lock-app/lock-common/gen/endpoint_config.h +++ b/examples/lock-app/lock-common/gen/endpoint_config.h @@ -26,16 +26,61 @@ #if BIGENDIAN_CPU #define GENERATED_DEFAULTS \ { \ + /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "VendorName". side: server, big-endian */ /* 32 */ 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "ProductName". side: server, big-endian */ /* 64 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "UserLabel". side: server, big-endian */ /* 96 */ 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "Location". side: server, big-endian */ /* 112 */ 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "HardwareVersionString". side: server, big-endian */ /* 176 */ 0x00, 0x00, \ + 0x00, 0x00, /* Default for cluster: "Basic", attribute: "SoftwareVersion". side: server, big-endian */ /* 180 */ 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, /* Default for cluster: "Basic", attribute: "SoftwareVersionString". side: server, big-endian */ \ } #else // !BIGENDIAN_CPU #define GENERATED_DEFAULTS \ { \ + /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "VendorName". side: server, little-endian */ /* 32 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "ProductName". side: server, little-endian */ /* 64 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "UserLabel". side: server, little-endian */ /* 96 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "Location". side: server, little-endian */ /* 112 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "HardwareVersionString". side: server, little-endian */ /* 176 */ \ + 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "SoftwareVersion". side: server, little-endian */ /* 180 */ 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, \ + 0x00, /* Default for cluster: "Basic", attribute: "SoftwareVersionString". side: server, little-endian */ \ } #endif // BIGENDIAN_CPU -#define GENERATED_DEFAULTS_COUNT (0) +#define GENERATED_DEFAULTS_COUNT (7) #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ @@ -55,11 +100,47 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 2 +#define GENERATED_ATTRIBUTE_COUNT 14 #define GENERATED_ATTRIBUTES \ { \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 2 } }, /* On/off (server): cluster revision */ \ { 0x0000, ZAP_TYPE(BOOLEAN), 1, 0, { (uint8_t *) 0x00 } }, /* On/off (server): on/off */ \ + { \ + 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 3 } \ + }, /* Basic (server): cluster revision */ \ + { \ + 0x0000, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } \ + }, /* Basic (server): InteractionModelVersion */ \ + { \ + 0x0001, ZAP_TYPE(CHAR_STRING), 32, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(0) } \ + }, /* Basic (server): VendorName */ \ + { 0x0002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } }, /* Basic (server): VendorID */ \ + { \ + 0x0003, ZAP_TYPE(CHAR_STRING), 32, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(32) } \ + }, /* Basic (server): ProductName */ \ + { 0x0004, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } }, /* Basic (server): ProductID */ \ + { 0x0005, \ + ZAP_TYPE(CHAR_STRING), \ + 32, \ + ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(64) } }, /* Basic (server): UserLabel */ \ + { 0x0006, \ + ZAP_TYPE(CHAR_STRING), \ + 16, \ + ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(96) } }, /* Basic (server): Location */ \ + { \ + 0x0007, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0x00 } \ + }, /* Basic (server): HardwareVersion */ \ + { \ + 0x0008, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(112) } \ + }, /* Basic (server): HardwareVersionString */ \ + { \ + 0x0009, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(176) } \ + }, /* Basic (server): SoftwareVersion */ \ + { \ + 0x000A, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(180) } \ + }, /* Basic (server): SoftwareVersionString */ \ } // This is an array of EmberAfCluster structures. @@ -72,7 +153,7 @@ }; #define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask -#define GENERATED_CLUSTER_COUNT 1 +#define GENERATED_CLUSTER_COUNT 2 #define GENERATED_CLUSTERS \ { \ { \ @@ -83,6 +164,9 @@ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayOnOffServer \ }, /* Endpoint: 1, Cluster: On/off (server) */ \ + { \ + 0x0028, ZAP_ATTRIBUTE_INDEX(2), 12, 254, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 1, Cluster: Basic (server) */ \ } #define ZAP_CLUSTER_INDEX(index) ((EmberAfCluster *) (&generatedClusters[index])) @@ -90,17 +174,17 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 1, 3 }, \ + { ZAP_CLUSTER_INDEX(0), 2, 257 }, \ } // Largest attribute size is needed for various buffers -#define ATTRIBUTE_LARGEST (3) +#define ATTRIBUTE_LARGEST (64) // Total size of singleton attributes -#define ATTRIBUTE_SINGLETONS_SIZE (0) +#define ATTRIBUTE_SINGLETONS_SIZE (254) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (3) +#define ATTRIBUTE_MAX_SIZE (257) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (1) @@ -144,12 +228,15 @@ // Array of EmberAfCommandMetadata structs. #define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask -#define EMBER_AF_GENERATED_COMMAND_COUNT (3) +#define EMBER_AF_GENERATED_COMMAND_COUNT (6) #define GENERATED_COMMANDS \ { \ { 0x0006, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* On/off (server): Off */ \ { 0x0006, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* On/off (server): On */ \ { 0x0006, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* On/off (server): Toggle */ \ + { 0x0028, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): StartUp */ \ + { 0x0028, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): ShutDown */ \ + { 0x0028, 0x02, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): Leave */ \ } // Array of EmberAfManufacturerCodeEntry structures for commands. diff --git a/examples/lock-app/lock-common/gen/gen_config.h b/examples/lock-app/lock-common/gen/gen_config.h index b5f0621684ee4a..d4f918b37c702f 100644 --- a/examples/lock-app/lock-common/gen/gen_config.h +++ b/examples/lock-app/lock-common/gen/gen_config.h @@ -29,10 +29,16 @@ #define EMBER_APS_UNICAST_MESSAGE_COUNT 10 /**** Cluster endpoint counts ****/ +#define EMBER_AF_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_ON_OFF_CLUSTER_SERVER_ENDPOINT_COUNT (1) /**** Cluster Plugins ****/ +// Use this macro to check if the server side of the Basic cluster is included +#define ZCL_USING_BASIC_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_BASIC_SERVER +#define EMBER_AF_PLUGIN_BASIC + // Use this macro to check if the server side of the On/off cluster is included #define ZCL_USING_ON_OFF_CLUSTER_SERVER #define EMBER_AF_PLUGIN_ON_OFF_SERVER diff --git a/examples/lock-app/lock-common/gen/print-cluster.h b/examples/lock-app/lock-common/gen/print-cluster.h index 86a2a27beec86b..bd08d38a581506 100644 --- a/examples/lock-app/lock-common/gen/print-cluster.h +++ b/examples/lock-app/lock-common/gen/print-cluster.h @@ -24,12 +24,6 @@ // to the "EmberAfClusterName" defined in the ZCL header. // The names of clusters that are not present, are removed. -#if defined(ZCL_USING_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_BASIC_CLUSTER_CLIENT) -#define CHIP_PRINTCLUSTER_BASIC_CLUSTER { ZCL_BASIC_CLUSTER_ID, 0, "Basic" }, -#else -#define CHIP_PRINTCLUSTER_BASIC_CLUSTER -#endif - #if defined(ZCL_USING_POWER_CONFIG_CLUSTER_SERVER) || defined(ZCL_USING_POWER_CONFIG_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_POWER_CONFIG_CLUSTER { ZCL_POWER_CONFIG_CLUSTER_ID, 1, "Power Configuration" }, #else @@ -150,6 +144,12 @@ #define CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER #endif +#if defined(ZCL_USING_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_BASIC_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_BASIC_CLUSTER { ZCL_BASIC_CLUSTER_ID, 40, "Basic" }, +#else +#define CHIP_PRINTCLUSTER_BASIC_CLUSTER +#endif + #if defined(ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER { ZCL_GENERAL_COMMISSIONING_CLUSTER_ID, 48, "General Commissioning" }, #else @@ -526,6 +526,12 @@ #define CHIP_PRINTCLUSTER_IAS_WD_CLUSTER #endif +#if defined(ZCL_USING_LOW_POWER_CLUSTER_SERVER) || defined(ZCL_USING_LOW_POWER_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER { ZCL_LOW_POWER_CLUSTER_ID, 1288, "Low Power" }, +#else +#define CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER +#endif + #if defined(ZCL_USING_APPLICATION_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_APPLICATION_BASIC_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_APPLICATION_BASIC_CLUSTER { ZCL_APPLICATION_BASIC_CLUSTER_ID, 1293, "Application Basic" }, #else @@ -784,7 +790,6 @@ #endif #define CLUSTER_IDS_TO_NAMES \ - CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_POWER_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DEVICE_TEMP_CLUSTER \ CHIP_PRINTCLUSTER_IDENTIFY_CLUSTER \ @@ -805,6 +810,7 @@ CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER \ CHIP_PRINTCLUSTER_GREEN_POWER_CLUSTER \ CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER \ + CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DOOR_LOCK_CLUSTER \ @@ -857,6 +863,7 @@ CHIP_PRINTCLUSTER_IAS_ZONE_CLUSTER \ CHIP_PRINTCLUSTER_IAS_ACE_CLUSTER \ CHIP_PRINTCLUSTER_IAS_WD_CLUSTER \ + CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER \ CHIP_PRINTCLUSTER_APPLICATION_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_GENERIC_TUNNEL_CLUSTER \ CHIP_PRINTCLUSTER_BACNET_PROTOCOL_TUNNEL_CLUSTER \ diff --git a/examples/lock-app/lock-common/lock-app.zap b/examples/lock-app/lock-common/lock-app.zap index 5d20290ec1aff6..807263df93c371 100644 --- a/examples/lock-app/lock-common/lock-app.zap +++ b/examples/lock-app/lock-common/lock-app.zap @@ -1,6 +1,6 @@ { - "writeTime": "Wed Nov 18 2020 11:03:31 GMT+0100 (Central European Standard Time)", - "featureLevel": 4, + "writeTime": "Tue Mar 02 2021 13:36:08 GMT-0500 (Eastern Standard Time)", + "featureLevel": 11, "creator": "zap", "keyValuePairs": [ { @@ -34,91 +34,9 @@ { "name": "Anonymous Endpoint Type", "deviceTypeName": "CBA-onofflight", - "deviceTypeCode": "0x0100", - "deviceTypeProfileId": "0x109", + "deviceTypeCode": 256, + "deviceTypeProfileId": 265, "clusters": [ - { - "name": "Basic", - "code": 0, - "mfgCode": null, - "define": "BASIC_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Basic", - "code": 0, - "mfgCode": null, - "define": "BASIC_CLUSTER", - "side": "server", - "enabled": 0, - "commands": [], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ZCL version", - "code": 0, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x08", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "power source", - "code": 7, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, { "name": "Power Configuration", "code": 1, @@ -152,6 +70,7 @@ "define": "POWER_CONFIG_CLUSTER", "side": "server", "enabled": 0, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -198,8 +117,7 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [] + ] }, { "name": "Device Temperature Configuration", @@ -208,6 +126,7 @@ "define": "DEVICE_TEMP_CLUSTER", "side": "client", "enabled": 0, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -224,8 +143,7 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [] + ] }, { "name": "Device Temperature Configuration", @@ -234,7 +152,6 @@ "define": "DEVICE_TEMP_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "cluster revision", @@ -266,7 +183,8 @@ "maxInterval": 65344, "reportableChange": 0 } - ] + ], + "commands": [] }, { "name": "Identify", @@ -801,7 +719,6 @@ "define": "ON_OFF_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "cluster revision", @@ -833,7 +750,8 @@ "maxInterval": 65344, "reportableChange": 0 } - ] + ], + "commands": [] }, { "name": "Alarms", @@ -1360,6 +1278,248 @@ } ] }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "StartUp", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ShutDown", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "Leave", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "InteractionModelVersion", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorName", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorID", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductName", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductID", + "code": 4, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UserLabel", + "code": 5, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Location", + "code": 6, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersion", + "code": 7, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersionString", + "code": 8, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersion", + "code": 9, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersionString", + "code": 10, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, { "name": "Occupancy Sensing", "code": 1030, @@ -1393,7 +1553,6 @@ "define": "OCCUPANCY_SENSING_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "cluster revision", @@ -1455,7 +1614,8 @@ "maxInterval": 65344, "reportableChange": 0 } - ] + ], + "commands": [] } ] } @@ -1469,4 +1629,4 @@ "networkId": 0 } ] -} +} \ No newline at end of file diff --git a/examples/temperature-measurement-app/esp32/main/gen/CHIPClientCallbacks.cpp b/examples/temperature-measurement-app/esp32/main/gen/CHIPClientCallbacks.cpp index f5f88af110c2c7..fc5ea3b1b8a7c6 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/CHIPClientCallbacks.cpp +++ b/examples/temperature-measurement-app/esp32/main/gen/CHIPClientCallbacks.cpp @@ -272,10 +272,6 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag case 0x38: // semi / Semi-precision case 0x39: // single / Single precision case 0x3A: // double / Double precision - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string case 0x48: // array / Array case 0x49: // struct / Structure case 0x50: // set / Set @@ -289,6 +285,48 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag return true; } + case 0x41: // octstr / Octet string + case 0x42: // string / Character string + { + // Short Strings must contains at least one byte for the length + CHECK_MESSAGE_LENGTH(1); + uint8_t length = chip::Encoding::Read8(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + + case 0x43: // octstr16 / Long octet string + case 0x44: // string16 / Long character string + { + // Long Strings must contains at least two bytes for the length + CHECK_MESSAGE_LENGTH(2); + uint16_t length = chip::Encoding::LittleEndian::Read16(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFFFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFFFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + case 0x08: // data8 / 8-bit data case 0x18: // map8 / 8-bit bitmap case 0x20: // uint8 / Unsigned 8-bit integer @@ -696,10 +734,6 @@ bool emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * message, uin case 0x38: // semi / Semi-precision case 0x39: // single / Single precision case 0x3A: // double / Double precision - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string case 0x48: // array / Array case 0x49: // struct / Structure case 0x50: // set / Set @@ -710,6 +744,48 @@ bool emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * message, uin return true; } + case 0x41: // octstr / Octet string + case 0x42: // string / Character string + { + // Short Strings must contains at least one byte for the length + CHECK_MESSAGE_LENGTH(1); + uint8_t length = chip::Encoding::Read8(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onReportCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + + case 0x43: // octstr16 / Long octet string + case 0x44: // string16 / Long character string + { + // Long Strings must contains at least two bytes for the length + CHECK_MESSAGE_LENGTH(2); + uint16_t length = chip::Encoding::LittleEndian::Read16(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFFFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFFFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onReportCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + case 0x08: // data8 / 8-bit data case 0x18: // map8 / 8-bit bitmap case 0x20: // uint8 / Unsigned 8-bit integer diff --git a/examples/temperature-measurement-app/esp32/main/gen/CHIPClientCallbacks.h b/examples/temperature-measurement-app/esp32/main/gen/CHIPClientCallbacks.h index 14a3742f090e8f..d028079f799d79 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/CHIPClientCallbacks.h +++ b/examples/temperature-measurement-app/esp32/main/gen/CHIPClientCallbacks.h @@ -20,6 +20,7 @@ #pragma once #include +#include // Global Response Callbacks typedef void (*DefaultSuccessCallback)(void * context); @@ -33,6 +34,7 @@ typedef void (*Int32uAttributeCallback)(void * context, uint32_t value); typedef void (*Int32sAttributeCallback)(void * context, int32_t value); typedef void (*Int64uAttributeCallback)(void * context, uint64_t value); typedef void (*Int64sAttributeCallback)(void * context, int64_t value); +typedef void (*StringAttributeCallback)(void * context, const chip::ByteSpan value); typedef void (*ReadReportingConfigurationReportedCallback)(void * context, uint16_t minInterval, uint16_t maxInterval); typedef void (*ReadReportingConfigurationReceivedCallback)(void * context, uint16_t timeout); diff --git a/examples/temperature-measurement-app/esp32/main/gen/CHIPClustersObjc.h b/examples/temperature-measurement-app/esp32/main/gen/CHIPClustersObjc.h index 6f791a019dcfe9..29ae867de27ec3 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/CHIPClustersObjc.h +++ b/examples/temperature-measurement-app/esp32/main/gen/CHIPClustersObjc.h @@ -48,10 +48,19 @@ NS_ASSUME_NONNULL_BEGIN */ @interface CHIPBasic : CHIPCluster -- (void)resetToFactoryDefaults:(ResponseHandler)completionHandler; - -- (void)readAttributeZclVersion:(ResponseHandler)completionHandler; -- (void)readAttributePowerSource:(ResponseHandler)completionHandler; +- (void)readAttributeInteractionModelVersion:(ResponseHandler)completionHandler; +- (void)readAttributeVendorName:(ResponseHandler)completionHandler; +- (void)readAttributeVendorID:(ResponseHandler)completionHandler; +- (void)readAttributeProductName:(ResponseHandler)completionHandler; +- (void)readAttributeProductID:(ResponseHandler)completionHandler; +- (void)readAttributeUserLabel:(ResponseHandler)completionHandler; +- (void)writeAttributeUserLabel:(NSString *)value completionHandler:(ResponseHandler)completionHandler; +- (void)readAttributeLocation:(ResponseHandler)completionHandler; +- (void)writeAttributeLocation:(NSString *)value completionHandler:(ResponseHandler)completionHandler; +- (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler; +- (void)readAttributeHardwareVersionString:(ResponseHandler)completionHandler; +- (void)readAttributeSoftwareVersion:(ResponseHandler)completionHandler; +- (void)readAttributeSoftwareVersionString:(ResponseHandler)completionHandler; - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler; @end diff --git a/examples/temperature-measurement-app/esp32/main/gen/CHIPClustersObjc.mm b/examples/temperature-measurement-app/esp32/main/gen/CHIPClustersObjc.mm index 86769dea3883f7..6329098398a2fa 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/CHIPClustersObjc.mm +++ b/examples/temperature-measurement-app/esp32/main/gen/CHIPClustersObjc.mm @@ -89,26 +89,38 @@ static void CallbackFn(void * context, uint8_t status) dispatch_queue_t mQueue; }; -class CHIPUnsupportedAttributeCallbackBridge : public Callback::Callback { +class CHIPStringAttributeCallbackBridge : public Callback::Callback { public: - CHIPUnsupportedAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) - : Callback::Callback(CallbackFn, this) + CHIPStringAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool octetString, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mOctetString(octetString) + , mKeepAlive(keepAlive) { } - ~CHIPUnsupportedAttributeCallbackBridge() {}; + ~CHIPStringAttributeCallbackBridge() {}; - static void CallbackFn(void * context) + static void CallbackFn(void * context, chip::ByteSpan value) { - CHIPUnsupportedAttributeCallbackBridge * callback = reinterpret_cast(context); + CHIPStringAttributeCallbackBridge * callback = reinterpret_cast(context); if (callback && callback->mQueue) { dispatch_async(callback->mQueue, ^{ - NSError * error = [NSError errorWithDomain:CHIPErrorDomain - code:CHIPErrorCodeUndefinedError - userInfo:@ { NSLocalizedDescriptionKey : @"Unsupported attribute type" }]; - callback->mHandler(error, nil); - callback->Cancel(); - delete callback; + if (callback->mOctetString) { + NSData * data = [NSData dataWithBytes:value.data() length:value.size()]; + callback->mHandler(nil, @ { @"value" : data }); + } else { + NSString * str = [[NSString alloc] initWithBytes:value.data() + length:value.size() + encoding:NSUTF8StringEncoding]; + callback->mHandler(nil, @ { @"value" : str }); + } + + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } }); } }; @@ -116,6 +128,8 @@ static void CallbackFn(void * context) private: ResponseHandler mHandler; dispatch_queue_t mQueue; + bool mOctetString; + bool mKeepAlive; }; class CHIPBooleanAttributeCallbackBridge : public Callback::Callback { @@ -246,6 +260,38 @@ static void CallbackFn(void * context, uint16_t value) bool mKeepAlive; }; +class CHIPInt32uAttributeCallbackBridge : public Callback::Callback { +public: + CHIPInt32uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mKeepAlive(keepAlive) + { + } + + ~CHIPInt32uAttributeCallbackBridge() {}; + + static void CallbackFn(void * context, uint32_t value) + { + CHIPInt32uAttributeCallbackBridge * callback = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedLong:value] }); + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; + bool mKeepAlive; +}; + class CHIPInt16sAttributeCallbackBridge : public Callback::Callback { public: CHIPInt16sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) @@ -319,7 +365,148 @@ @implementation CHIPBasic return &_cppCluster; } -- (void)resetToFactoryDefaults:(ResponseHandler)completionHandler +- (void)readAttributeInteractionModelVersion:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeInteractionModelVersion(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeVendorName:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeVendorID:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeVendorID(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeProductName:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeProductName(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeProductID:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeProductID(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeUserLabel:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeUserLabel(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)writeAttributeUserLabel:(NSString *)value completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -334,7 +521,105 @@ - (void)resetToFactoryDefaults:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ResetToFactoryDefaults(onSuccess->Cancel(), onFailure->Cancel()); + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + CHIP_ERROR err = self.cppCluster.WriteAttributeUserLabel( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeLocation:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeLocation(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)writeAttributeLocation:(NSString *)value completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + CHIP_ERROR err = self.cppCluster.WriteAttributeLocation( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeHardwareVersionString:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -342,9 +627,9 @@ - (void)resetToFactoryDefaults:(ResponseHandler)completionHandler } } -- (void)readAttributeZclVersion:(ResponseHandler)completionHandler +- (void)readAttributeSoftwareVersion:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -357,7 +642,7 @@ - (void)readAttributeZclVersion:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeZclVersion(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersion(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -365,9 +650,10 @@ - (void)readAttributeZclVersion:(ResponseHandler)completionHandler } } -- (void)readAttributePowerSource:(ResponseHandler)completionHandler +- (void)readAttributeSoftwareVersionString:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -380,7 +666,7 @@ - (void)readAttributePowerSource:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePowerSource(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; diff --git a/examples/temperature-measurement-app/esp32/main/gen/IMClusterCommandHandler.cpp b/examples/temperature-measurement-app/esp32/main/gen/IMClusterCommandHandler.cpp index a0006c7c102da4..c9e33667ccf5ea 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/IMClusterCommandHandler.cpp +++ b/examples/temperature-measurement-app/esp32/main/gen/IMClusterCommandHandler.cpp @@ -39,30 +39,6 @@ namespace app { namespace clusters { -namespace Basic { - -void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv) -{ - { - switch (commandId) - { - case ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID: { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - emberAfBasicClusterResetToFactoryDefaultsCallback(); - break; - } - default: { - // Unrecognized command ID, error status will apply. - // TODO: Encode response for command not found - ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_BASIC_CLUSTER_ID); - break; - } - } - } -} - -} // namespace Basic - } // namespace clusters void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aCommandId, chip::EndpointId aEndPointId, @@ -73,9 +49,6 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId); switch (aClusterId) { - case ZCL_BASIC_CLUSTER_ID: - clusters::Basic::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); - break; default: // Unrecognized cluster ID, error status will apply. // TODO: Encode response for Cluster not found diff --git a/examples/temperature-measurement-app/esp32/main/gen/attribute-id.h b/examples/temperature-measurement-app/esp32/main/gen/attribute-id.h index 8802797f112bd6..8c8757f826ca7f 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/attribute-id.h +++ b/examples/temperature-measurement-app/esp32/main/gen/attribute-id.h @@ -26,30 +26,6 @@ #define ZCL_REPORTING_STATUS_CLIENT_ATTRIBUTE_ID (0xFFFE) #define ZCL_REPORTING_STATUS_SERVER_ATTRIBUTE_ID (0xFFFE) -// Attribute ids for cluster: Basic - -// Client attributes - -// Server attributes -#define ZCL_VERSION_ATTRIBUTE_ID (0x0000) -#define ZCL_APPLICATION_VERSION_ATTRIBUTE_ID (0x0001) -#define ZCL_STACK_VERSION_ATTRIBUTE_ID (0x0002) -#define ZCL_HW_VERSION_ATTRIBUTE_ID (0x0003) -#define ZCL_MANUFACTURER_NAME_ATTRIBUTE_ID (0x0004) -#define ZCL_MODEL_IDENTIFIER_ATTRIBUTE_ID (0x0005) -#define ZCL_DATE_CODE_ATTRIBUTE_ID (0x0006) -#define ZCL_POWER_SOURCE_ATTRIBUTE_ID (0x0007) -#define ZCL_GENERIC_DEVICE_CLASS_ATTRIBUTE_ID (0x0008) -#define ZCL_GENERIC_DEVICE_TYPE_ATTRIBUTE_ID (0x0009) -#define ZCL_PRODUCT_CODE_ATTRIBUTE_ID (0x000A) -#define ZCL_PRODUCT_URL_ATTRIBUTE_ID (0x000B) -#define ZCL_LOCATION_DESCRIPTION_ATTRIBUTE_ID (0x0010) -#define ZCL_PHYSICAL_ENVIRONMENT_ATTRIBUTE_ID (0x0011) -#define ZCL_DEVICE_ENABLED_ATTRIBUTE_ID (0x0012) -#define ZCL_ALARM_MASK_ATTRIBUTE_ID (0x0013) -#define ZCL_DISABLE_LOCAL_CONFIG_ATTRIBUTE_ID (0x0014) -#define ZCL_SW_BUILD_ID_ATTRIBUTE_ID (0x4000) - // Attribute ids for cluster: Power Configuration // Client attributes @@ -384,6 +360,29 @@ #define ZCL_KEEPALIVE_BASE_ATTRIBUTE_ID (0x0000) #define ZCL_KEEPALIVE_JITTER_ATTRIBUTE_ID (0x0001) +// Attribute ids for cluster: Basic + +// Client attributes + +// Server attributes +#define ZCL_INTERACTION_MODEL_VERSION_ATTRIBUTE_ID (0x0000) +#define ZCL_VENDOR_NAME_ATTRIBUTE_ID (0x0001) +#define ZCL_VENDOR_ID_ATTRIBUTE_ID (0x0002) +#define ZCL_PRODUCT_NAME_ATTRIBUTE_ID (0x0003) +#define ZCL_PRODUCT_ID_ATTRIBUTE_ID (0x0004) +#define ZCL_USER_LABEL_ATTRIBUTE_ID (0x0005) +#define ZCL_LOCATION_ATTRIBUTE_ID (0x0006) +#define ZCL_HARDWARE_VERSION_ATTRIBUTE_ID (0x0007) +#define ZCL_HARDWARE_VERSION_STRING_ATTRIBUTE_ID (0x0008) +#define ZCL_SOFTWARE_VERSION_ATTRIBUTE_ID (0x0009) +#define ZCL_SOFTWARE_VERSION_STRING_ATTRIBUTE_ID (0x000A) +#define ZCL_MANUFACTURING_DATE_ATTRIBUTE_ID (0x000B) +#define ZCL_PART_NUMBER_ATTRIBUTE_ID (0x000C) +#define ZCL_PRODUCT_URL_ATTRIBUTE_ID (0x000D) +#define ZCL_PRODUCT_LABEL_ATTRIBUTE_ID (0x000E) +#define ZCL_SERIAL_NUMBER_ATTRIBUTE_ID (0x000F) +#define ZCL_LOCAL_CONFIG_DISABLED_ATTRIBUTE_ID (0x0010) + // Attribute ids for cluster: General Commissioning // Client attributes @@ -1093,15 +1092,21 @@ // Server attributes #define ZCL_MAX_DURATION_ATTRIBUTE_ID (0x0000) +// Attribute ids for cluster: Low Power + +// Client attributes + +// Server attributes + // Attribute ids for cluster: Application Basic // Client attributes // Server attributes -#define ZCL_VENDOR_NAME_ATTRIBUTE_ID (0x0000) -#define ZCL_VENDOR_ID_ATTRIBUTE_ID (0x0001) +#define ZCL_APPLICATION_VENDOR_NAME_ATTRIBUTE_ID (0x0000) +#define ZCL_APPLICATION_VENDOR_ID_ATTRIBUTE_ID (0x0001) #define ZCL_APPLICATION_NAME_ATTRIBUTE_ID (0x0002) -#define ZCL_PRODUCT_ID_ATTRIBUTE_ID (0x0003) +#define ZCL_APPLICATION_PRODUCT_ID_ATTRIBUTE_ID (0x0003) #define ZCL_APPLICATION_ID_ATTRIBUTE_ID (0x0005) #define ZCL_CATALOG_VENDOR_ID_ATTRIBUTE_ID (0x0006) #define ZCL_APPLICATION_STATUS_ATTRIBUTE_ID (0x0007) @@ -3833,7 +3838,7 @@ #define ZCL_PRICE_TRAILING_DIGIT_ATTRIBUTE_ID (0x0021) #define ZCL_PRICE_ATTRIBUTE_ID (0x0022) #define ZCL_GOOD_ID_ATTRIBUTE_ID (0x0030) -#define ZCL_SERIAL_NUMBER_ATTRIBUTE_ID (0x0031) +#define ZCL_PAYMENT_SERIAL_NUMBER_ATTRIBUTE_ID (0x0031) #define ZCL_PAYMENT_TIMESTAMP_ATTRIBUTE_ID (0x0032) #define ZCL_TRANS_ID_ATTRIBUTE_ID (0x0033) #define ZCL_TRANS_STATUS_ATTRIBUTE_ID (0x0034) diff --git a/examples/temperature-measurement-app/esp32/main/gen/call-command-handler.cpp b/examples/temperature-measurement-app/esp32/main/gen/call-command-handler.cpp index 82d19ea4353c59..edceae46501114 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/call-command-handler.cpp +++ b/examples/temperature-measurement-app/esp32/main/gen/call-command-handler.cpp @@ -71,7 +71,8 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd) switch (cmd->apsFrame->clusterId) { case ZCL_BASIC_CLUSTER_ID: - result = emberAfBasicClusterServerCommandParse(cmd); + // No commands are enabled for cluster Basic + result = status(false, true, cmd->mfgSpecific); break; case ZCL_TEMP_MEASUREMENT_CLUSTER_ID: // No commands are enabled for cluster Temperature Measurement @@ -86,24 +87,3 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd) } // Cluster specific command parsing - -EmberAfStatus emberAfBasicClusterServerCommandParse(EmberAfClusterCommand * cmd) -{ - bool wasHandled = false; - - if (!cmd->mfgSpecific) - { - switch (cmd->commandId) - { - case ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID: { - wasHandled = emberAfBasicClusterResetToFactoryDefaultsCallback(); - break; - } - default: { - // Unrecognized command ID, error status will apply. - break; - } - } - } - return status(wasHandled, true, cmd->mfgSpecific); -} diff --git a/examples/temperature-measurement-app/esp32/main/gen/callback.h b/examples/temperature-measurement-app/esp32/main/gen/callback.h index c76cbccf4dd9ae..b999d830984c88 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/callback.h +++ b/examples/temperature-measurement-app/esp32/main/gen/callback.h @@ -196,12 +196,6 @@ void emberAfTemperatureMeasurementClusterServerTickCallback(chip::EndpointId end // Cluster Commands Callback -/** - * @brief Basic Cluster ResetToFactoryDefaults Command callback - */ - -bool emberAfBasicClusterResetToFactoryDefaultsCallback(); - // // Non-Cluster Related Callbacks // diff --git a/examples/temperature-measurement-app/esp32/main/gen/client-command-macro.h b/examples/temperature-measurement-app/esp32/main/gen/client-command-macro.h index 97de7f69cfff1d..f72c96f951dcff 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/client-command-macro.h +++ b/examples/temperature-measurement-app/esp32/main/gen/client-command-macro.h @@ -256,15 +256,6 @@ emberAfFillExternalBuffer(mask, clusterId, ZCL_DISCOVER_ATTRIBUTES_EXTENDED_RESPONSE_COMMAND_ID, "ub", discoveryComplete, \ extendedDiscoverAttributesInfoRecords, extendedDiscoverAttributesInfoRecordsLen); -/** @brief Command description for ResetToFactoryDefaults - * - * Command: ResetToFactoryDefaults - */ -#define emberAfFillCommandBasicClusterResetToFactoryDefaults() \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID, "", ); - /** @brief Command description for Identify * * Command: Identify @@ -1795,6 +1786,33 @@ totalNumberOfNonEmptyProxyTableEntries, gpdSrcId, startIndex, gpdIeee, entriesCount, endpoint, \ proxyTableEntries, proxyTableEntriesLen, index); +/** @brief Command description for StartUp + * + * Command: StartUp + */ +#define emberAfFillCommandBasicClusterStartUp() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_START_UP_COMMAND_ID, "", ); + +/** @brief Command description for ShutDown + * + * Command: ShutDown + */ +#define emberAfFillCommandBasicClusterShutDown() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SHUT_DOWN_COMMAND_ID, "", ); + +/** @brief Command description for Leave + * + * Command: Leave + */ +#define emberAfFillCommandBasicClusterLeave() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_LEAVE_COMMAND_ID, "", ); + /** @brief Command description for SetFabric * * Command: SetFabric @@ -2964,6 +2982,15 @@ \ ZCL_SQUAWK_COMMAND_ID, "u", squawkInfo); +/** @brief Command description for Sleep + * + * Command: Sleep + */ +#define emberAfFillCommandLow \ + PowerClusterSleep() emberAfFillExternalBuffer(mask, \ + \ + ZCL_SLEEP_COMMAND_ID, "", ); + /** @brief Command description for MatchProtocolAddress * * Command: MatchProtocolAddress diff --git a/examples/temperature-measurement-app/esp32/main/gen/cluster-id.h b/examples/temperature-measurement-app/esp32/main/gen/cluster-id.h index 99de14e2586034..d77da915200ab4 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/cluster-id.h +++ b/examples/temperature-measurement-app/esp32/main/gen/cluster-id.h @@ -20,9 +20,6 @@ // Prevent multiple inclusion #pragma once -// Definitions for cluster: Basic -#define ZCL_BASIC_CLUSTER_ID (0x0000) - // Definitions for cluster: Power Configuration #define ZCL_POWER_CONFIG_CLUSTER_ID (0x0001) @@ -83,6 +80,9 @@ // Definitions for cluster: Keep-Alive #define ZCL_KEEPALIVE_CLUSTER_ID (0x0025) +// Definitions for cluster: Basic +#define ZCL_BASIC_CLUSTER_ID (0x0028) + // Definitions for cluster: General Commissioning #define ZCL_GENERAL_COMMISSIONING_CLUSTER_ID (0x0030) @@ -239,6 +239,9 @@ // Definitions for cluster: IAS WD #define ZCL_IAS_WD_CLUSTER_ID (0x0502) +// Definitions for cluster: Low Power +#define ZCL_LOW_POWER_CLUSTER_ID (0x0508) + // Definitions for cluster: Application Basic #define ZCL_APPLICATION_BASIC_CLUSTER_ID (0x050D) diff --git a/examples/temperature-measurement-app/esp32/main/gen/command-id.h b/examples/temperature-measurement-app/esp32/main/gen/command-id.h index d31a267c6254af..adc2b1c6f32733 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/command-id.h +++ b/examples/temperature-measurement-app/esp32/main/gen/command-id.h @@ -45,10 +45,6 @@ #define ZCL_DISCOVER_ATTRIBUTES_EXTENDED_COMMAND_ID (0x15) #define ZCL_DISCOVER_ATTRIBUTES_EXTENDED_RESPONSE_COMMAND_ID (0x16) -// Commands for cluster: Basic -#define ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID (0x00) -#define ZCL_MFG_SPECIFIC_PING_COMMAND_ID (0x00) - // Commands for cluster: Identify #define ZCL_IDENTIFY_COMMAND_ID (0x00) #define ZCL_IDENTIFY_QUERY_RESPONSE_COMMAND_ID (0x00) @@ -226,6 +222,12 @@ #define ZCL_GP_PROXY_TABLE_RESPONSE_COMMAND_ID (0x0B) #define ZCL_GP_PROXY_TABLE_REQUEST_COMMAND_ID (0x0B) +// Commands for cluster: Basic +#define ZCL_START_UP_COMMAND_ID (0x00) +#define ZCL_MFG_SPECIFIC_PING_COMMAND_ID (0x00) +#define ZCL_SHUT_DOWN_COMMAND_ID (0x01) +#define ZCL_LEAVE_COMMAND_ID (0x02) + // Commands for cluster: General Commissioning #define ZCL_SET_FABRIC_COMMAND_ID (0x00) #define ZCL_SET_FABRIC_RESPONSE_COMMAND_ID (0x01) @@ -369,6 +371,9 @@ #define ZCL_START_WARNING_COMMAND_ID (0x00) #define ZCL_SQUAWK_COMMAND_ID (0x01) +// Commands for cluster: Low Power +#define ZCL_SLEEP_COMMAND_ID (0x00) + // Commands for cluster: Generic Tunnel #define ZCL_MATCH_PROTOCOL_ADDRESS_COMMAND_ID (0x00) #define ZCL_MATCH_PROTOCOL_ADDRESS_RESPONSE_COMMAND_ID (0x00) diff --git a/examples/temperature-measurement-app/esp32/main/gen/endpoint_config.h b/examples/temperature-measurement-app/esp32/main/gen/endpoint_config.h index ea331701181607..f701c1c4199df8 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/endpoint_config.h +++ b/examples/temperature-measurement-app/esp32/main/gen/endpoint_config.h @@ -26,16 +26,61 @@ #if BIGENDIAN_CPU #define GENERATED_DEFAULTS \ { \ + /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "VendorName". side: server, big-endian */ /* 32 */ 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "ProductName". side: server, big-endian */ /* 64 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "UserLabel". side: server, big-endian */ /* 96 */ 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "Location". side: server, big-endian */ /* 112 */ 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "HardwareVersionString". side: server, big-endian */ /* 176 */ 0x00, 0x00, \ + 0x00, 0x00, /* Default for cluster: "Basic", attribute: "SoftwareVersion". side: server, big-endian */ /* 180 */ 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, /* Default for cluster: "Basic", attribute: "SoftwareVersionString". side: server, big-endian */ \ } #else // !BIGENDIAN_CPU #define GENERATED_DEFAULTS \ { \ + /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "VendorName". side: server, little-endian */ /* 32 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "ProductName". side: server, little-endian */ /* 64 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "UserLabel". side: server, little-endian */ /* 96 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "Location". side: server, little-endian */ /* 112 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "HardwareVersionString". side: server, little-endian */ /* 176 */ \ + 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "SoftwareVersion". side: server, little-endian */ /* 180 */ 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, \ + 0x00, /* Default for cluster: "Basic", attribute: "SoftwareVersionString". side: server, little-endian */ \ } #endif // BIGENDIAN_CPU -#define GENERATED_DEFAULTS_COUNT (0) +#define GENERATED_DEFAULTS_COUNT (7) #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ @@ -55,12 +100,43 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 7 +#define GENERATED_ATTRIBUTE_COUNT 16 #define GENERATED_ATTRIBUTES \ { \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 3 } }, /* Basic (server): cluster revision */ \ - { 0x0000, ZAP_TYPE(INT8U), 1, 0, { (uint8_t *) 0x08 } }, /* Basic (server): ZCL version */ \ - { 0x0007, ZAP_TYPE(ENUM8), 1, 0, { (uint8_t *) 0x00 } }, /* Basic (server): power source */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 3 } }, /* Basic (server): cluster revision */ \ + { \ + 0x0000, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } \ + }, /* Basic (server): InteractionModelVersion */ \ + { \ + 0x0001, ZAP_TYPE(CHAR_STRING), 32, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(0) } \ + }, /* Basic (server): VendorName */ \ + { 0x0002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } }, /* Basic (server): VendorID */ \ + { \ + 0x0003, ZAP_TYPE(CHAR_STRING), 32, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(32) } \ + }, /* Basic (server): ProductName */ \ + { 0x0004, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } }, /* Basic (server): ProductID */ \ + { 0x0005, \ + ZAP_TYPE(CHAR_STRING), \ + 32, \ + ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(64) } }, /* Basic (server): UserLabel */ \ + { 0x0006, \ + ZAP_TYPE(CHAR_STRING), \ + 16, \ + ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(96) } }, /* Basic (server): Location */ \ + { \ + 0x0007, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0x00 } \ + }, /* Basic (server): HardwareVersion */ \ + { \ + 0x0008, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(112) } \ + }, /* Basic (server): HardwareVersionString */ \ + { \ + 0x0009, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(176) } \ + }, /* Basic (server): SoftwareVersion */ \ + { \ + 0x000A, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(180) } \ + }, /* Basic (server): SoftwareVersionString */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 3 } }, /* Temperature Measurement (server): cluster revision */ \ { 0x0000, ZAP_TYPE(INT16S), 2, 0, { (uint8_t *) 0x8000 } }, /* Temperature Measurement (server): measured value */ \ { 0x0001, ZAP_TYPE(INT16S), 2, 0, { (uint8_t *) 0x8000 } }, /* Temperature Measurement (server): min measured value */ \ @@ -77,9 +153,9 @@ #define GENERATED_CLUSTER_COUNT 2 #define GENERATED_CLUSTERS \ { \ - { 0x0000, ZAP_ATTRIBUTE_INDEX(0), 3, 4, ZAP_CLUSTER_MASK(SERVER), NULL }, /* Endpoint: 1, Cluster: Basic (server) */ \ + { 0x0028, ZAP_ATTRIBUTE_INDEX(0), 12, 254, ZAP_CLUSTER_MASK(SERVER), NULL }, /* Endpoint: 1, Cluster: Basic (server) */ \ { \ - 0x0402, ZAP_ATTRIBUTE_INDEX(3), 4, 8, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0402, ZAP_ATTRIBUTE_INDEX(12), 4, 8, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Temperature Measurement (server) */ \ } @@ -88,17 +164,17 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 2, 12 }, \ + { ZAP_CLUSTER_INDEX(0), 2, 262 }, \ } // Largest attribute size is needed for various buffers -#define ATTRIBUTE_LARGEST (3) +#define ATTRIBUTE_LARGEST (64) // Total size of singleton attributes -#define ATTRIBUTE_SINGLETONS_SIZE (0) +#define ATTRIBUTE_SINGLETONS_SIZE (254) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (12) +#define ATTRIBUTE_MAX_SIZE (262) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (1) @@ -142,10 +218,12 @@ // Array of EmberAfCommandMetadata structs. #define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask -#define EMBER_AF_GENERATED_COMMAND_COUNT (1) +#define EMBER_AF_GENERATED_COMMAND_COUNT (3) #define GENERATED_COMMANDS \ { \ - { 0x0000, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Basic (server): ResetToFactoryDefaults */ \ + { 0x0028, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): StartUp */ \ + { 0x0028, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): ShutDown */ \ + { 0x0028, 0x02, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): Leave */ \ } // Array of EmberAfManufacturerCodeEntry structures for commands. diff --git a/examples/temperature-measurement-app/esp32/main/gen/print-cluster.h b/examples/temperature-measurement-app/esp32/main/gen/print-cluster.h index 86a2a27beec86b..bd08d38a581506 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/print-cluster.h +++ b/examples/temperature-measurement-app/esp32/main/gen/print-cluster.h @@ -24,12 +24,6 @@ // to the "EmberAfClusterName" defined in the ZCL header. // The names of clusters that are not present, are removed. -#if defined(ZCL_USING_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_BASIC_CLUSTER_CLIENT) -#define CHIP_PRINTCLUSTER_BASIC_CLUSTER { ZCL_BASIC_CLUSTER_ID, 0, "Basic" }, -#else -#define CHIP_PRINTCLUSTER_BASIC_CLUSTER -#endif - #if defined(ZCL_USING_POWER_CONFIG_CLUSTER_SERVER) || defined(ZCL_USING_POWER_CONFIG_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_POWER_CONFIG_CLUSTER { ZCL_POWER_CONFIG_CLUSTER_ID, 1, "Power Configuration" }, #else @@ -150,6 +144,12 @@ #define CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER #endif +#if defined(ZCL_USING_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_BASIC_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_BASIC_CLUSTER { ZCL_BASIC_CLUSTER_ID, 40, "Basic" }, +#else +#define CHIP_PRINTCLUSTER_BASIC_CLUSTER +#endif + #if defined(ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER { ZCL_GENERAL_COMMISSIONING_CLUSTER_ID, 48, "General Commissioning" }, #else @@ -526,6 +526,12 @@ #define CHIP_PRINTCLUSTER_IAS_WD_CLUSTER #endif +#if defined(ZCL_USING_LOW_POWER_CLUSTER_SERVER) || defined(ZCL_USING_LOW_POWER_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER { ZCL_LOW_POWER_CLUSTER_ID, 1288, "Low Power" }, +#else +#define CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER +#endif + #if defined(ZCL_USING_APPLICATION_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_APPLICATION_BASIC_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_APPLICATION_BASIC_CLUSTER { ZCL_APPLICATION_BASIC_CLUSTER_ID, 1293, "Application Basic" }, #else @@ -784,7 +790,6 @@ #endif #define CLUSTER_IDS_TO_NAMES \ - CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_POWER_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DEVICE_TEMP_CLUSTER \ CHIP_PRINTCLUSTER_IDENTIFY_CLUSTER \ @@ -805,6 +810,7 @@ CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER \ CHIP_PRINTCLUSTER_GREEN_POWER_CLUSTER \ CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER \ + CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DOOR_LOCK_CLUSTER \ @@ -857,6 +863,7 @@ CHIP_PRINTCLUSTER_IAS_ZONE_CLUSTER \ CHIP_PRINTCLUSTER_IAS_ACE_CLUSTER \ CHIP_PRINTCLUSTER_IAS_WD_CLUSTER \ + CHIP_PRINTCLUSTER_LOW_POWER_CLUSTER \ CHIP_PRINTCLUSTER_APPLICATION_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_GENERIC_TUNNEL_CLUSTER \ CHIP_PRINTCLUSTER_BACNET_PROTOCOL_TUNNEL_CLUSTER \ diff --git a/examples/temperature-measurement-app/esp32/main/temperature-measurement.zap b/examples/temperature-measurement-app/esp32/main/temperature-measurement.zap index 6ced702b8317bb..2342fb2bfdee06 100644 --- a/examples/temperature-measurement-app/esp32/main/temperature-measurement.zap +++ b/examples/temperature-measurement-app/esp32/main/temperature-measurement.zap @@ -39,21 +39,12 @@ "clusters": [ { "name": "Basic", - "code": 0, + "code": 40, "mfgCode": null, "define": "BASIC_CLUSTER", "side": "client", "enabled": 0, - "commands": [ - { - "name": "ResetToFactoryDefaults", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - } - ], + "commands": [], "attributes": [ { "name": "cluster revision", @@ -62,7 +53,7 @@ "side": "client", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, "defaultValue": "3", "reportable": 0, @@ -74,11 +65,37 @@ }, { "name": "Basic", - "code": 0, + "code": 40, "mfgCode": null, "define": "BASIC_CLUSTER", "side": "server", "enabled": 1, + "commands": [ + { + "name": "StartUp", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ShutDown", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "Leave", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], "attributes": [ { "name": "cluster revision", @@ -87,7 +104,7 @@ "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, "defaultValue": "3", "reportable": 0, @@ -96,37 +113,171 @@ "reportableChange": 0 }, { - "name": "ZCL version", + "name": "InteractionModelVersion", "code": 0, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorName", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, "bounded": 0, - "defaultValue": "0x08", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "power source", + "name": "VendorID", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductName", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductID", + "code": 4, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UserLabel", + "code": 5, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Location", + "code": 6, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersion", "code": 7, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, "defaultValue": "0x00", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 + }, + { + "name": "HardwareVersionString", + "code": 8, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersion", + "code": 9, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersionString", + "code": 10, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 } - ], - "commands": [] + ] }, { "name": "Power Configuration", diff --git a/examples/tv-app/tv-common/gen/CHIPClientCallbacks.cpp b/examples/tv-app/tv-common/gen/CHIPClientCallbacks.cpp index 7aacff9156a886..c4a6c900db7c1b 100644 --- a/examples/tv-app/tv-common/gen/CHIPClientCallbacks.cpp +++ b/examples/tv-app/tv-common/gen/CHIPClientCallbacks.cpp @@ -272,10 +272,6 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag case 0x38: // semi / Semi-precision case 0x39: // single / Single precision case 0x3A: // double / Double precision - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string case 0x48: // array / Array case 0x49: // struct / Structure case 0x50: // set / Set @@ -289,6 +285,48 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag return true; } + case 0x41: // octstr / Octet string + case 0x42: // string / Character string + { + // Short Strings must contains at least one byte for the length + CHECK_MESSAGE_LENGTH(1); + uint8_t length = chip::Encoding::Read8(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + + case 0x43: // octstr16 / Long octet string + case 0x44: // string16 / Long character string + { + // Long Strings must contains at least two bytes for the length + CHECK_MESSAGE_LENGTH(2); + uint16_t length = chip::Encoding::LittleEndian::Read16(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFFFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFFFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + case 0x08: // data8 / 8-bit data case 0x18: // map8 / 8-bit bitmap case 0x20: // uint8 / Unsigned 8-bit integer @@ -738,10 +776,6 @@ bool emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * message, uin case 0x38: // semi / Semi-precision case 0x39: // single / Single precision case 0x3A: // double / Double precision - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string case 0x48: // array / Array case 0x49: // struct / Structure case 0x50: // set / Set @@ -752,6 +786,48 @@ bool emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * message, uin return true; } + case 0x41: // octstr / Octet string + case 0x42: // string / Character string + { + // Short Strings must contains at least one byte for the length + CHECK_MESSAGE_LENGTH(1); + uint8_t length = chip::Encoding::Read8(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onReportCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + + case 0x43: // octstr16 / Long octet string + case 0x44: // string16 / Long character string + { + // Long Strings must contains at least two bytes for the length + CHECK_MESSAGE_LENGTH(2); + uint16_t length = chip::Encoding::LittleEndian::Read16(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFFFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFFFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onReportCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + case 0x08: // data8 / 8-bit data case 0x18: // map8 / 8-bit bitmap case 0x20: // uint8 / Unsigned 8-bit integer diff --git a/examples/tv-app/tv-common/gen/CHIPClientCallbacks.h b/examples/tv-app/tv-common/gen/CHIPClientCallbacks.h index 83df5b3e318751..2fc3557cf7582d 100644 --- a/examples/tv-app/tv-common/gen/CHIPClientCallbacks.h +++ b/examples/tv-app/tv-common/gen/CHIPClientCallbacks.h @@ -20,6 +20,7 @@ #pragma once #include +#include // Global Response Callbacks typedef void (*DefaultSuccessCallback)(void * context); @@ -33,6 +34,7 @@ typedef void (*Int32uAttributeCallback)(void * context, uint32_t value); typedef void (*Int32sAttributeCallback)(void * context, int32_t value); typedef void (*Int64uAttributeCallback)(void * context, uint64_t value); typedef void (*Int64sAttributeCallback)(void * context, int64_t value); +typedef void (*StringAttributeCallback)(void * context, const chip::ByteSpan value); typedef void (*ReadReportingConfigurationReportedCallback)(void * context, uint16_t minInterval, uint16_t maxInterval); typedef void (*ReadReportingConfigurationReceivedCallback)(void * context, uint16_t timeout); diff --git a/examples/tv-app/tv-common/gen/CHIPClustersObjc.h b/examples/tv-app/tv-common/gen/CHIPClustersObjc.h index f01449b319bb23..e4f190ad7e7068 100644 --- a/examples/tv-app/tv-common/gen/CHIPClustersObjc.h +++ b/examples/tv-app/tv-common/gen/CHIPClustersObjc.h @@ -99,10 +99,19 @@ NS_ASSUME_NONNULL_BEGIN */ @interface CHIPBasic : CHIPCluster -- (void)resetToFactoryDefaults:(ResponseHandler)completionHandler; - -- (void)readAttributeZclVersion:(ResponseHandler)completionHandler; -- (void)readAttributePowerSource:(ResponseHandler)completionHandler; +- (void)readAttributeInteractionModelVersion:(ResponseHandler)completionHandler; +- (void)readAttributeVendorName:(ResponseHandler)completionHandler; +- (void)readAttributeVendorID:(ResponseHandler)completionHandler; +- (void)readAttributeProductName:(ResponseHandler)completionHandler; +- (void)readAttributeProductID:(ResponseHandler)completionHandler; +- (void)readAttributeUserLabel:(ResponseHandler)completionHandler; +- (void)writeAttributeUserLabel:(NSString *)value completionHandler:(ResponseHandler)completionHandler; +- (void)readAttributeLocation:(ResponseHandler)completionHandler; +- (void)writeAttributeLocation:(NSString *)value completionHandler:(ResponseHandler)completionHandler; +- (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler; +- (void)readAttributeHardwareVersionString:(ResponseHandler)completionHandler; +- (void)readAttributeSoftwareVersion:(ResponseHandler)completionHandler; +- (void)readAttributeSoftwareVersionString:(ResponseHandler)completionHandler; - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler; @end @@ -496,7 +505,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)getUserType:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler; - (void)getWeekdaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler; - (void)getYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler; -- (void)lockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandler; +- (void)lockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHandler; - (void)setHolidaySchedule:(uint8_t)scheduleId localStartTime:(uint32_t)localStartTime localEndTime:(uint32_t)localEndTime @@ -505,12 +514,12 @@ NS_ASSUME_NONNULL_BEGIN - (void)setPin:(uint16_t)userId userStatus:(uint8_t)userStatus userType:(uint8_t)userType - pin:(char *)pin + pin:(NSString *)pin completionHandler:(ResponseHandler)completionHandler; - (void)setRfid:(uint16_t)userId userStatus:(uint8_t)userStatus userType:(uint8_t)userType - id:(char *)id + id:(NSString *)id completionHandler:(ResponseHandler)completionHandler; - (void)setUserType:(uint16_t)userId userType:(uint8_t)userType completionHandler:(ResponseHandler)completionHandler; - (void)setWeekdaySchedule:(uint8_t)scheduleId @@ -526,8 +535,8 @@ NS_ASSUME_NONNULL_BEGIN localStartTime:(uint32_t)localStartTime localEndTime:(uint32_t)localEndTime completionHandler:(ResponseHandler)completionHandler; -- (void)unlockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandler; -- (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(char *)pin completionHandler:(ResponseHandler)completionHandler; +- (void)unlockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHandler; +- (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(NSString *)pin completionHandler:(ResponseHandler)completionHandler; - (void)readAttributeLockState:(ResponseHandler)completionHandler; - (void)configureAttributeLockState:(uint16_t)minInterval @@ -560,7 +569,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)getUserType:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler; - (void)getWeekdaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler; - (void)getYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler; -- (void)lockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandler; +- (void)lockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHandler; - (void)setHolidaySchedule:(uint8_t)scheduleId localStartTime:(uint32_t)localStartTime localEndTime:(uint32_t)localEndTime @@ -569,12 +578,12 @@ NS_ASSUME_NONNULL_BEGIN - (void)setPin:(uint16_t)userId userStatus:(uint8_t)userStatus userType:(uint8_t)userType - pin:(char *)pin + pin:(NSString *)pin completionHandler:(ResponseHandler)completionHandler; - (void)setRfid:(uint16_t)userId userStatus:(uint8_t)userStatus userType:(uint8_t)userType - id:(char *)id + id:(NSString *)id completionHandler:(ResponseHandler)completionHandler; - (void)setUserType:(uint16_t)userId userType:(uint8_t)userType completionHandler:(ResponseHandler)completionHandler; - (void)setWeekdaySchedule:(uint8_t)scheduleId @@ -590,8 +599,8 @@ NS_ASSUME_NONNULL_BEGIN localStartTime:(uint32_t)localStartTime localEndTime:(uint32_t)localEndTime completionHandler:(ResponseHandler)completionHandler; -- (void)unlockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandler; -- (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(char *)pin completionHandler:(ResponseHandler)completionHandler; +- (void)unlockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHandler; +- (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(NSString *)pin completionHandler:(ResponseHandler)completionHandler; - (void)readAttributeLockState:(ResponseHandler)completionHandler; - (void)configureAttributeLockState:(uint16_t)minInterval @@ -610,8 +619,10 @@ NS_ASSUME_NONNULL_BEGIN */ @interface CHIPGroups : CHIPCluster -- (void)addGroup:(uint16_t)groupId groupName:(char *)groupName completionHandler:(ResponseHandler)completionHandler; -- (void)addGroupIfIdentifying:(uint16_t)groupId groupName:(char *)groupName completionHandler:(ResponseHandler)completionHandler; +- (void)addGroup:(uint16_t)groupId groupName:(NSString *)groupName completionHandler:(ResponseHandler)completionHandler; +- (void)addGroupIfIdentifying:(uint16_t)groupId + groupName:(NSString *)groupName + completionHandler:(ResponseHandler)completionHandler; - (void)getGroupMembership:(uint8_t)groupCount groupList:(uint16_t)groupList completionHandler:(ResponseHandler)completionHandler; - (void)removeAllGroups:(ResponseHandler)completionHandler; - (void)removeGroup:(uint16_t)groupId completionHandler:(ResponseHandler)completionHandler; @@ -758,7 +769,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)addScene:(uint16_t)groupId sceneId:(uint8_t)sceneId transitionTime:(uint16_t)transitionTime - sceneName:(char *)sceneName + sceneName:(NSString *)sceneName clusterId:(uint16_t)clusterId length:(uint8_t)length value:(uint8_t)value diff --git a/examples/tv-app/tv-common/gen/CHIPClustersObjc.mm b/examples/tv-app/tv-common/gen/CHIPClustersObjc.mm index 76ef09f67e5dc0..6647078a096242 100644 --- a/examples/tv-app/tv-common/gen/CHIPClustersObjc.mm +++ b/examples/tv-app/tv-common/gen/CHIPClustersObjc.mm @@ -89,26 +89,38 @@ static void CallbackFn(void * context, uint8_t status) dispatch_queue_t mQueue; }; -class CHIPUnsupportedAttributeCallbackBridge : public Callback::Callback { +class CHIPStringAttributeCallbackBridge : public Callback::Callback { public: - CHIPUnsupportedAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) - : Callback::Callback(CallbackFn, this) + CHIPStringAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool octetString, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mOctetString(octetString) + , mKeepAlive(keepAlive) { } - ~CHIPUnsupportedAttributeCallbackBridge() {}; + ~CHIPStringAttributeCallbackBridge() {}; - static void CallbackFn(void * context) + static void CallbackFn(void * context, chip::ByteSpan value) { - CHIPUnsupportedAttributeCallbackBridge * callback = reinterpret_cast(context); + CHIPStringAttributeCallbackBridge * callback = reinterpret_cast(context); if (callback && callback->mQueue) { dispatch_async(callback->mQueue, ^{ - NSError * error = [NSError errorWithDomain:CHIPErrorDomain - code:CHIPErrorCodeUndefinedError - userInfo:@ { NSLocalizedDescriptionKey : @"Unsupported attribute type" }]; - callback->mHandler(error, nil); - callback->Cancel(); - delete callback; + if (callback->mOctetString) { + NSData * data = [NSData dataWithBytes:value.data() length:value.size()]; + callback->mHandler(nil, @ { @"value" : data }); + } else { + NSString * str = [[NSString alloc] initWithBytes:value.data() + length:value.size() + encoding:NSUTF8StringEncoding]; + callback->mHandler(nil, @ { @"value" : str }); + } + + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } }); } }; @@ -116,6 +128,8 @@ static void CallbackFn(void * context) private: ResponseHandler mHandler; dispatch_queue_t mQueue; + bool mOctetString; + bool mKeepAlive; }; class CHIPBooleanAttributeCallbackBridge : public Callback::Callback { @@ -246,6 +260,38 @@ static void CallbackFn(void * context, uint16_t value) bool mKeepAlive; }; +class CHIPInt32uAttributeCallbackBridge : public Callback::Callback { +public: + CHIPInt32uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mKeepAlive(keepAlive) + { + } + + ~CHIPInt32uAttributeCallbackBridge() {}; + + static void CallbackFn(void * context, uint32_t value) + { + CHIPInt32uAttributeCallbackBridge * callback = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedLong:value] }); + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; + bool mKeepAlive; +}; + class CHIPInt16sAttributeCallbackBridge : public Callback::Callback { public: CHIPInt16sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) @@ -379,8 +425,8 @@ @implementation CHIPApplicationBasic - (void)readAttributeVendorName:(ResponseHandler)completionHandler { - CHIPUnsupportedAttributeCallbackBridge * onSuccess - = new CHIPUnsupportedAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], true); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -426,8 +472,8 @@ - (void)readAttributeVendorId:(ResponseHandler)completionHandler - (void)readAttributeApplicationName:(ResponseHandler)completionHandler { - CHIPUnsupportedAttributeCallbackBridge * onSuccess - = new CHIPUnsupportedAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], true); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -473,8 +519,8 @@ - (void)readAttributeProductId:(ResponseHandler)completionHandler - (void)readAttributeApplicationId:(ResponseHandler)completionHandler { - CHIPUnsupportedAttributeCallbackBridge * onSuccess - = new CHIPUnsupportedAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], true); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -923,7 +969,148 @@ @implementation CHIPBasic return &_cppCluster; } -- (void)resetToFactoryDefaults:(ResponseHandler)completionHandler +- (void)readAttributeInteractionModelVersion:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeInteractionModelVersion(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeVendorName:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeVendorID:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeVendorID(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeProductName:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeProductName(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeProductID:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeProductID(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeUserLabel:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeUserLabel(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)writeAttributeUserLabel:(NSString *)value completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -938,7 +1125,9 @@ - (void)resetToFactoryDefaults:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ResetToFactoryDefaults(onSuccess->Cancel(), onFailure->Cancel()); + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + CHIP_ERROR err = self.cppCluster.WriteAttributeUserLabel( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -946,9 +1135,10 @@ - (void)resetToFactoryDefaults:(ResponseHandler)completionHandler } } -- (void)readAttributeZclVersion:(ResponseHandler)completionHandler +- (void)readAttributeLocation:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -961,7 +1151,7 @@ - (void)readAttributeZclVersion:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeZclVersion(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeLocation(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -969,9 +1159,105 @@ - (void)readAttributeZclVersion:(ResponseHandler)completionHandler } } -- (void)readAttributePowerSource:(ResponseHandler)completionHandler +- (void)writeAttributeLocation:(NSString *)value completionHandler:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + CHIP_ERROR err = self.cppCluster.WriteAttributeLocation( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeHardwareVersionString:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeSoftwareVersion:(ResponseHandler)completionHandler +{ + CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersion(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeSoftwareVersionString:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -984,7 +1270,7 @@ - (void)readAttributePowerSource:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePowerSource(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1723,8 +2009,8 @@ - (void)readAttributeDriftCompensation:(ResponseHandler)completionHandler - (void)readAttributeCompensationText:(ResponseHandler)completionHandler { - CHIPUnsupportedAttributeCallbackBridge * onSuccess - = new CHIPUnsupportedAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3806,8 +4092,8 @@ - (void)readAttributeDriftCompensation:(ResponseHandler)completionHandler - (void)readAttributeCompensationText:(ResponseHandler)completionHandler { - CHIPUnsupportedAttributeCallbackBridge * onSuccess - = new CHIPUnsupportedAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -5585,7 +5871,7 @@ - (void)getYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completio completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)lockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandler +- (void)lockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHandler { CHIPDoorLockClusterLockDoorResponseCallbackBridge * onSuccess = new CHIPDoorLockClusterLockDoorResponseCallbackBridge(completionHandler, [self callbackQueue]); @@ -5601,7 +5887,9 @@ - (void)lockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandle return; } - CHIP_ERROR err = self.cppCluster.LockDoor(onSuccess->Cancel(), onFailure->Cancel(), pin); + CHIP_ERROR err = self.cppCluster.LockDoor(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5638,7 +5926,7 @@ - (void)setHolidaySchedule:(uint8_t)scheduleId - (void)setPin:(uint16_t)userId userStatus:(uint8_t)userStatus userType:(uint8_t)userType - pin:(char *)pin + pin:(NSString *)pin completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); @@ -5654,7 +5942,9 @@ - (void)setPin:(uint16_t)userId return; } - CHIP_ERROR err = self.cppCluster.SetPin(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, pin); + CHIP_ERROR err = self.cppCluster.SetPin(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5664,7 +5954,7 @@ - (void)setPin:(uint16_t)userId - (void)setRfid:(uint16_t)userId userStatus:(uint8_t)userStatus userType:(uint8_t)userType - id:(char *)id + id:(NSString *)id completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); @@ -5680,7 +5970,9 @@ - (void)setRfid:(uint16_t)userId return; } - CHIP_ERROR err = self.cppCluster.SetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, id); + CHIP_ERROR err = self.cppCluster.SetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, + chip::ByteSpan((const uint8_t *) [id dataUsingEncoding:NSUTF8StringEncoding].bytes, + [id lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5766,7 +6058,7 @@ - (void)setYeardaySchedule:(uint8_t)scheduleId completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)unlockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandler +- (void)unlockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHandler { CHIPDoorLockClusterUnlockDoorResponseCallbackBridge * onSuccess = new CHIPDoorLockClusterUnlockDoorResponseCallbackBridge(completionHandler, [self callbackQueue]); @@ -5782,14 +6074,16 @@ - (void)unlockDoor:(char *)pin completionHandler:(ResponseHandler)completionHand return; } - CHIP_ERROR err = self.cppCluster.UnlockDoor(onSuccess->Cancel(), onFailure->Cancel(), pin); + CHIP_ERROR err = self.cppCluster.UnlockDoor(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(char *)pin completionHandler:(ResponseHandler)completionHandler +- (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(NSString *)pin completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -5804,7 +6098,9 @@ - (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(char *)pin completionH return; } - CHIP_ERROR err = self.cppCluster.UnlockWithTimeout(onSuccess->Cancel(), onFailure->Cancel(), timeoutInSeconds, pin); + CHIP_ERROR err = self.cppCluster.UnlockWithTimeout(onSuccess->Cancel(), onFailure->Cancel(), timeoutInSeconds, + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6267,7 +6563,7 @@ - (void)getYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completio completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)lockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandler +- (void)lockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHandler { CHIPDoorLockClusterLockDoorResponseCallbackBridge * onSuccess = new CHIPDoorLockClusterLockDoorResponseCallbackBridge(completionHandler, [self callbackQueue]); @@ -6283,7 +6579,9 @@ - (void)lockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandle return; } - CHIP_ERROR err = self.cppCluster.LockDoor(onSuccess->Cancel(), onFailure->Cancel(), pin); + CHIP_ERROR err = self.cppCluster.LockDoor(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6320,7 +6618,7 @@ - (void)setHolidaySchedule:(uint8_t)scheduleId - (void)setPin:(uint16_t)userId userStatus:(uint8_t)userStatus userType:(uint8_t)userType - pin:(char *)pin + pin:(NSString *)pin completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); @@ -6336,7 +6634,9 @@ - (void)setPin:(uint16_t)userId return; } - CHIP_ERROR err = self.cppCluster.SetPin(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, pin); + CHIP_ERROR err = self.cppCluster.SetPin(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6346,7 +6646,7 @@ - (void)setPin:(uint16_t)userId - (void)setRfid:(uint16_t)userId userStatus:(uint8_t)userStatus userType:(uint8_t)userType - id:(char *)id + id:(NSString *)id completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); @@ -6362,7 +6662,9 @@ - (void)setRfid:(uint16_t)userId return; } - CHIP_ERROR err = self.cppCluster.SetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, id); + CHIP_ERROR err = self.cppCluster.SetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, + chip::ByteSpan((const uint8_t *) [id dataUsingEncoding:NSUTF8StringEncoding].bytes, + [id lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6448,7 +6750,7 @@ - (void)setYeardaySchedule:(uint8_t)scheduleId completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)unlockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandler +- (void)unlockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHandler { CHIPDoorLockClusterUnlockDoorResponseCallbackBridge * onSuccess = new CHIPDoorLockClusterUnlockDoorResponseCallbackBridge(completionHandler, [self callbackQueue]); @@ -6464,14 +6766,16 @@ - (void)unlockDoor:(char *)pin completionHandler:(ResponseHandler)completionHand return; } - CHIP_ERROR err = self.cppCluster.UnlockDoor(onSuccess->Cancel(), onFailure->Cancel(), pin); + CHIP_ERROR err = self.cppCluster.UnlockDoor(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(char *)pin completionHandler:(ResponseHandler)completionHandler +- (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(NSString *)pin completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -6486,7 +6790,9 @@ - (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(char *)pin completionH return; } - CHIP_ERROR err = self.cppCluster.UnlockWithTimeout(onSuccess->Cancel(), onFailure->Cancel(), timeoutInSeconds, pin); + CHIP_ERROR err = self.cppCluster.UnlockWithTimeout(onSuccess->Cancel(), onFailure->Cancel(), timeoutInSeconds, + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -6641,7 +6947,7 @@ @implementation CHIPGroups return &_cppCluster; } -- (void)addGroup:(uint16_t)groupId groupName:(char *)groupName completionHandler:(ResponseHandler)completionHandler +- (void)addGroup:(uint16_t)groupId groupName:(NSString *)groupName completionHandler:(ResponseHandler)completionHandler { CHIPGroupsClusterAddGroupResponseCallbackBridge * onSuccess = new CHIPGroupsClusterAddGroupResponseCallbackBridge(completionHandler, [self callbackQueue]); @@ -6657,14 +6963,16 @@ - (void)addGroup:(uint16_t)groupId groupName:(char *)groupName completionHandler return; } - CHIP_ERROR err = self.cppCluster.AddGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId, groupName); + CHIP_ERROR err = self.cppCluster.AddGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId, + chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes, + [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)addGroupIfIdentifying:(uint16_t)groupId groupName:(char *)groupName completionHandler:(ResponseHandler)completionHandler +- (void)addGroupIfIdentifying:(uint16_t)groupId groupName:(NSString *)groupName completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -6679,7 +6987,9 @@ - (void)addGroupIfIdentifying:(uint16_t)groupId groupName:(char *)groupName comp return; } - CHIP_ERROR err = self.cppCluster.AddGroupIfIdentifying(onSuccess->Cancel(), onFailure->Cancel(), groupId, groupName); + CHIP_ERROR err = self.cppCluster.AddGroupIfIdentifying(onSuccess->Cancel(), onFailure->Cancel(), groupId, + chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes, + [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -7947,7 +8257,7 @@ @implementation CHIPScenes - (void)addScene:(uint16_t)groupId sceneId:(uint8_t)sceneId transitionTime:(uint16_t)transitionTime - sceneName:(char *)sceneName + sceneName:(NSString *)sceneName clusterId:(uint16_t)clusterId length:(uint8_t)length value:(uint8_t)value @@ -7967,8 +8277,10 @@ - (void)addScene:(uint16_t)groupId return; } - CHIP_ERROR err = self.cppCluster.AddScene( - onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime, sceneName, clusterId, length, value); + CHIP_ERROR err = self.cppCluster.AddScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime, + chip::ByteSpan((const uint8_t *) [sceneName dataUsingEncoding:NSUTF8StringEncoding].bytes, + [sceneName lengthOfBytesUsingEncoding:NSUTF8StringEncoding]), + clusterId, length, value); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; diff --git a/examples/tv-app/tv-common/gen/IMClusterCommandHandler.cpp b/examples/tv-app/tv-common/gen/IMClusterCommandHandler.cpp index be0aac53c0fdb7..ebe9a25774f085 100644 --- a/examples/tv-app/tv-common/gen/IMClusterCommandHandler.cpp +++ b/examples/tv-app/tv-common/gen/IMClusterCommandHandler.cpp @@ -89,30 +89,6 @@ void DispatchServerCommand(app::Command * command, CommandId commandId, Endpoint } // namespace BarrierControl -namespace Basic { - -void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv) -{ - { - switch (commandId) - { - case ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID: { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - emberAfBasicClusterResetToFactoryDefaultsCallback(); - break; - } - default: { - // Unrecognized command ID, error status will apply. - // TODO: Encode response for command not found - ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_BASIC_CLUSTER_ID); - break; - } - } - } -} - -} // namespace Basic - namespace ColorControl { void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv) @@ -2386,9 +2362,6 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC case ZCL_BARRIER_CONTROL_CLUSTER_ID: clusters::BarrierControl::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; - case ZCL_BASIC_CLUSTER_ID: - clusters::Basic::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); - break; case ZCL_COLOR_CONTROL_CLUSTER_ID: clusters::ColorControl::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; diff --git a/examples/tv-app/tv-common/gen/attribute-id.h b/examples/tv-app/tv-common/gen/attribute-id.h index 3ab0310a83cce7..8c8757f826ca7f 100644 --- a/examples/tv-app/tv-common/gen/attribute-id.h +++ b/examples/tv-app/tv-common/gen/attribute-id.h @@ -26,30 +26,6 @@ #define ZCL_REPORTING_STATUS_CLIENT_ATTRIBUTE_ID (0xFFFE) #define ZCL_REPORTING_STATUS_SERVER_ATTRIBUTE_ID (0xFFFE) -// Attribute ids for cluster: Basic - -// Client attributes - -// Server attributes -#define ZCL_VERSION_ATTRIBUTE_ID (0x0000) -#define ZCL_APPLICATION_VERSION_ATTRIBUTE_ID (0x0001) -#define ZCL_STACK_VERSION_ATTRIBUTE_ID (0x0002) -#define ZCL_HW_VERSION_ATTRIBUTE_ID (0x0003) -#define ZCL_MANUFACTURER_NAME_ATTRIBUTE_ID (0x0004) -#define ZCL_MODEL_IDENTIFIER_ATTRIBUTE_ID (0x0005) -#define ZCL_DATE_CODE_ATTRIBUTE_ID (0x0006) -#define ZCL_POWER_SOURCE_ATTRIBUTE_ID (0x0007) -#define ZCL_GENERIC_DEVICE_CLASS_ATTRIBUTE_ID (0x0008) -#define ZCL_GENERIC_DEVICE_TYPE_ATTRIBUTE_ID (0x0009) -#define ZCL_PRODUCT_CODE_ATTRIBUTE_ID (0x000A) -#define ZCL_PRODUCT_URL_ATTRIBUTE_ID (0x000B) -#define ZCL_LOCATION_DESCRIPTION_ATTRIBUTE_ID (0x0010) -#define ZCL_PHYSICAL_ENVIRONMENT_ATTRIBUTE_ID (0x0011) -#define ZCL_DEVICE_ENABLED_ATTRIBUTE_ID (0x0012) -#define ZCL_ALARM_MASK_ATTRIBUTE_ID (0x0013) -#define ZCL_DISABLE_LOCAL_CONFIG_ATTRIBUTE_ID (0x0014) -#define ZCL_SW_BUILD_ID_ATTRIBUTE_ID (0x4000) - // Attribute ids for cluster: Power Configuration // Client attributes @@ -384,6 +360,29 @@ #define ZCL_KEEPALIVE_BASE_ATTRIBUTE_ID (0x0000) #define ZCL_KEEPALIVE_JITTER_ATTRIBUTE_ID (0x0001) +// Attribute ids for cluster: Basic + +// Client attributes + +// Server attributes +#define ZCL_INTERACTION_MODEL_VERSION_ATTRIBUTE_ID (0x0000) +#define ZCL_VENDOR_NAME_ATTRIBUTE_ID (0x0001) +#define ZCL_VENDOR_ID_ATTRIBUTE_ID (0x0002) +#define ZCL_PRODUCT_NAME_ATTRIBUTE_ID (0x0003) +#define ZCL_PRODUCT_ID_ATTRIBUTE_ID (0x0004) +#define ZCL_USER_LABEL_ATTRIBUTE_ID (0x0005) +#define ZCL_LOCATION_ATTRIBUTE_ID (0x0006) +#define ZCL_HARDWARE_VERSION_ATTRIBUTE_ID (0x0007) +#define ZCL_HARDWARE_VERSION_STRING_ATTRIBUTE_ID (0x0008) +#define ZCL_SOFTWARE_VERSION_ATTRIBUTE_ID (0x0009) +#define ZCL_SOFTWARE_VERSION_STRING_ATTRIBUTE_ID (0x000A) +#define ZCL_MANUFACTURING_DATE_ATTRIBUTE_ID (0x000B) +#define ZCL_PART_NUMBER_ATTRIBUTE_ID (0x000C) +#define ZCL_PRODUCT_URL_ATTRIBUTE_ID (0x000D) +#define ZCL_PRODUCT_LABEL_ATTRIBUTE_ID (0x000E) +#define ZCL_SERIAL_NUMBER_ATTRIBUTE_ID (0x000F) +#define ZCL_LOCAL_CONFIG_DISABLED_ATTRIBUTE_ID (0x0010) + // Attribute ids for cluster: General Commissioning // Client attributes @@ -1104,10 +1103,10 @@ // Client attributes // Server attributes -#define ZCL_VENDOR_NAME_ATTRIBUTE_ID (0x0000) -#define ZCL_VENDOR_ID_ATTRIBUTE_ID (0x0001) +#define ZCL_APPLICATION_VENDOR_NAME_ATTRIBUTE_ID (0x0000) +#define ZCL_APPLICATION_VENDOR_ID_ATTRIBUTE_ID (0x0001) #define ZCL_APPLICATION_NAME_ATTRIBUTE_ID (0x0002) -#define ZCL_PRODUCT_ID_ATTRIBUTE_ID (0x0003) +#define ZCL_APPLICATION_PRODUCT_ID_ATTRIBUTE_ID (0x0003) #define ZCL_APPLICATION_ID_ATTRIBUTE_ID (0x0005) #define ZCL_CATALOG_VENDOR_ID_ATTRIBUTE_ID (0x0006) #define ZCL_APPLICATION_STATUS_ATTRIBUTE_ID (0x0007) @@ -3839,7 +3838,7 @@ #define ZCL_PRICE_TRAILING_DIGIT_ATTRIBUTE_ID (0x0021) #define ZCL_PRICE_ATTRIBUTE_ID (0x0022) #define ZCL_GOOD_ID_ATTRIBUTE_ID (0x0030) -#define ZCL_SERIAL_NUMBER_ATTRIBUTE_ID (0x0031) +#define ZCL_PAYMENT_SERIAL_NUMBER_ATTRIBUTE_ID (0x0031) #define ZCL_PAYMENT_TIMESTAMP_ATTRIBUTE_ID (0x0032) #define ZCL_TRANS_ID_ATTRIBUTE_ID (0x0033) #define ZCL_TRANS_STATUS_ATTRIBUTE_ID (0x0034) diff --git a/examples/tv-app/tv-common/gen/call-command-handler.cpp b/examples/tv-app/tv-common/gen/call-command-handler.cpp index 2619593ba40fdc..3d358720f8341a 100644 --- a/examples/tv-app/tv-common/gen/call-command-handler.cpp +++ b/examples/tv-app/tv-common/gen/call-command-handler.cpp @@ -105,7 +105,8 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd) result = emberAfBarrierControlClusterServerCommandParse(cmd); break; case ZCL_BASIC_CLUSTER_ID: - result = emberAfBasicClusterServerCommandParse(cmd); + // No commands are enabled for cluster Basic + result = status(false, true, cmd->mfgSpecific); break; case ZCL_COLOR_CONTROL_CLUSTER_ID: result = emberAfColorControlClusterServerCommandParse(cmd); @@ -187,26 +188,6 @@ EmberAfStatus emberAfBarrierControlClusterServerCommandParse(EmberAfClusterComma } return status(wasHandled, true, cmd->mfgSpecific); } -EmberAfStatus emberAfBasicClusterServerCommandParse(EmberAfClusterCommand * cmd) -{ - bool wasHandled = false; - - if (!cmd->mfgSpecific) - { - switch (cmd->commandId) - { - case ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID: { - wasHandled = emberAfBasicClusterResetToFactoryDefaultsCallback(); - break; - } - default: { - // Unrecognized command ID, error status will apply. - break; - } - } - } - return status(wasHandled, true, cmd->mfgSpecific); -} EmberAfStatus emberAfColorControlClusterServerCommandParse(EmberAfClusterCommand * cmd) { bool wasHandled = false; diff --git a/examples/tv-app/tv-common/gen/callback.h b/examples/tv-app/tv-common/gen/callback.h index 01fb095464b618..887dabe4bc7ba0 100644 --- a/examples/tv-app/tv-common/gen/callback.h +++ b/examples/tv-app/tv-common/gen/callback.h @@ -1434,12 +1434,6 @@ bool emberAfBarrierControlClusterBarrierControlGoToPercentCallback(uint8_t perce bool emberAfBarrierControlClusterBarrierControlStopCallback(); -/** - * @brief Basic Cluster ResetToFactoryDefaults Command callback - */ - -bool emberAfBasicClusterResetToFactoryDefaultsCallback(); - /** * @brief Color Control Cluster MoveColor Command callback * @param rateX diff --git a/examples/tv-app/tv-common/gen/client-command-macro.h b/examples/tv-app/tv-common/gen/client-command-macro.h index c4f2f0a4a2a4f2..f72c96f951dcff 100644 --- a/examples/tv-app/tv-common/gen/client-command-macro.h +++ b/examples/tv-app/tv-common/gen/client-command-macro.h @@ -256,15 +256,6 @@ emberAfFillExternalBuffer(mask, clusterId, ZCL_DISCOVER_ATTRIBUTES_EXTENDED_RESPONSE_COMMAND_ID, "ub", discoveryComplete, \ extendedDiscoverAttributesInfoRecords, extendedDiscoverAttributesInfoRecordsLen); -/** @brief Command description for ResetToFactoryDefaults - * - * Command: ResetToFactoryDefaults - */ -#define emberAfFillCommandBasicClusterResetToFactoryDefaults() \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID, "", ); - /** @brief Command description for Identify * * Command: Identify @@ -1795,6 +1786,33 @@ totalNumberOfNonEmptyProxyTableEntries, gpdSrcId, startIndex, gpdIeee, entriesCount, endpoint, \ proxyTableEntries, proxyTableEntriesLen, index); +/** @brief Command description for StartUp + * + * Command: StartUp + */ +#define emberAfFillCommandBasicClusterStartUp() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_START_UP_COMMAND_ID, "", ); + +/** @brief Command description for ShutDown + * + * Command: ShutDown + */ +#define emberAfFillCommandBasicClusterShutDown() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SHUT_DOWN_COMMAND_ID, "", ); + +/** @brief Command description for Leave + * + * Command: Leave + */ +#define emberAfFillCommandBasicClusterLeave() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_LEAVE_COMMAND_ID, "", ); + /** @brief Command description for SetFabric * * Command: SetFabric diff --git a/examples/tv-app/tv-common/gen/cluster-id.h b/examples/tv-app/tv-common/gen/cluster-id.h index 2069290df636a7..d77da915200ab4 100644 --- a/examples/tv-app/tv-common/gen/cluster-id.h +++ b/examples/tv-app/tv-common/gen/cluster-id.h @@ -20,9 +20,6 @@ // Prevent multiple inclusion #pragma once -// Definitions for cluster: Basic -#define ZCL_BASIC_CLUSTER_ID (0x0000) - // Definitions for cluster: Power Configuration #define ZCL_POWER_CONFIG_CLUSTER_ID (0x0001) @@ -83,6 +80,9 @@ // Definitions for cluster: Keep-Alive #define ZCL_KEEPALIVE_CLUSTER_ID (0x0025) +// Definitions for cluster: Basic +#define ZCL_BASIC_CLUSTER_ID (0x0028) + // Definitions for cluster: General Commissioning #define ZCL_GENERAL_COMMISSIONING_CLUSTER_ID (0x0030) diff --git a/examples/tv-app/tv-common/gen/command-id.h b/examples/tv-app/tv-common/gen/command-id.h index 655425d5d43d35..adc2b1c6f32733 100644 --- a/examples/tv-app/tv-common/gen/command-id.h +++ b/examples/tv-app/tv-common/gen/command-id.h @@ -45,10 +45,6 @@ #define ZCL_DISCOVER_ATTRIBUTES_EXTENDED_COMMAND_ID (0x15) #define ZCL_DISCOVER_ATTRIBUTES_EXTENDED_RESPONSE_COMMAND_ID (0x16) -// Commands for cluster: Basic -#define ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID (0x00) -#define ZCL_MFG_SPECIFIC_PING_COMMAND_ID (0x00) - // Commands for cluster: Identify #define ZCL_IDENTIFY_COMMAND_ID (0x00) #define ZCL_IDENTIFY_QUERY_RESPONSE_COMMAND_ID (0x00) @@ -226,6 +222,12 @@ #define ZCL_GP_PROXY_TABLE_RESPONSE_COMMAND_ID (0x0B) #define ZCL_GP_PROXY_TABLE_REQUEST_COMMAND_ID (0x0B) +// Commands for cluster: Basic +#define ZCL_START_UP_COMMAND_ID (0x00) +#define ZCL_MFG_SPECIFIC_PING_COMMAND_ID (0x00) +#define ZCL_SHUT_DOWN_COMMAND_ID (0x01) +#define ZCL_LEAVE_COMMAND_ID (0x02) + // Commands for cluster: General Commissioning #define ZCL_SET_FABRIC_COMMAND_ID (0x00) #define ZCL_SET_FABRIC_RESPONSE_COMMAND_ID (0x01) diff --git a/examples/tv-app/tv-common/gen/endpoint_config.h b/examples/tv-app/tv-common/gen/endpoint_config.h index 2f2e27ffcb2aae..5e0cee004c1e61 100644 --- a/examples/tv-app/tv-common/gen/endpoint_config.h +++ b/examples/tv-app/tv-common/gen/endpoint_config.h @@ -27,6 +27,27 @@ #define GENERATED_DEFAULTS \ { \ /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "VendorName". side: server, big-endian */ /* 32 */ 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "ProductName". side: server, big-endian */ /* 64 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "UserLabel". side: server, big-endian */ /* 96 */ 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "Location". side: server, big-endian */ /* 112 */ 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "HardwareVersionString". side: server, big-endian */ /* 176 */ 0x00, 0x00, \ + 0x00, 0x00, /* Default for cluster: "Basic", attribute: "SoftwareVersion". side: server, big-endian */ /* 180 */ 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "SoftwareVersionString". side: server, big-endian */ /* 244 */ 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ @@ -39,17 +60,18 @@ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - /* Default for cluster: "Color Control", attribute: "compensation text". side: server, big-endian */ /* 254 */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Color Control", attribute: "compensation text". side: server, big-endian */ /* 498 */ \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - /* Default for cluster: "IAS Zone", attribute: "IAS CIE address". side: server, big-endian */ /* 262 */ 0x00, 0x00, \ + /* Default for cluster: "IAS Zone", attribute: "IAS CIE address". side: server, big-endian */ /* 506 */ 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - /* Default for cluster: "Application Basic", attribute: "vendor name". side: server, big-endian */ /* 294 */ \ + /* Default for cluster: "Application Basic", attribute: "vendor name". side: server, big-endian */ /* 538 */ \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, /* Default for cluster: "Application Basic", attribute: "application name". side: server, big-endian */ \ - /* 326 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* 570 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, /* Default for cluster: "Application Basic", attribute: "application id". side: server, big-endian */ \ } @@ -58,6 +80,29 @@ #define GENERATED_DEFAULTS \ { \ /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "VendorName". side: server, little-endian */ /* 32 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "ProductName". side: server, little-endian */ /* 64 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "UserLabel". side: server, little-endian */ /* 96 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "Location". side: server, little-endian */ /* 112 */ 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "HardwareVersionString". side: server, little-endian */ /* 176 */ \ + 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "SoftwareVersion". side: server, little-endian */ /* 180 */ 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "Basic", attribute: "SoftwareVersionString". side: server, little-endian */ /* 244 */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ @@ -72,22 +117,22 @@ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, /* Default for cluster: "Color Control", attribute: "compensation text". side: server, little-endian */ \ - /* 254 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - /* Default for cluster: "IAS Zone", attribute: "IAS CIE address". side: server, little-endian */ /* 262 */ 0x00, 0x00, \ + /* 498 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* Default for cluster: "IAS Zone", attribute: "IAS CIE address". side: server, little-endian */ /* 506 */ 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - /* Default for cluster: "Application Basic", attribute: "vendor name". side: server, little-endian */ /* 294 */ \ + /* Default for cluster: "Application Basic", attribute: "vendor name". side: server, little-endian */ /* 538 */ \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, /* Default for cluster: "Application Basic", attribute: "application name". side: server, little-endian */ \ - /* 326 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + /* 570 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, /* Default for cluster: "Application Basic", attribute: "application id". side: server, little-endian */ \ } #endif // BIGENDIAN_CPU -#define GENERATED_DEFAULTS_COUNT (5) +#define GENERATED_DEFAULTS_COUNT (12) #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ @@ -107,15 +152,10 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 102 +#define GENERATED_ATTRIBUTE_COUNT 111 #define GENERATED_ATTRIBUTES \ { \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 3 } }, /* Basic (server): cluster revision */ \ - { 0x0000, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0x08 } }, /* Basic (server): ZCL version */ \ - { \ - 0x0007, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0x00 } \ - }, /* Basic (server): power source */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 2 } }, /* Identify (server): cluster revision */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 2 } }, /* Identify (server): cluster revision */ \ { \ 0x0000, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), { (uint8_t *) 0x0000 } \ }, /* Identify (server): identify time */ \ @@ -131,6 +171,42 @@ { 0x0000, ZAP_TYPE(BOOLEAN), 1, 0, { (uint8_t *) 0x00 } }, /* On/off (server): on/off */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 3 } }, /* Level Control (server): cluster revision */ \ { 0x0000, ZAP_TYPE(INT8U), 1, 0, { (uint8_t *) 0x00 } }, /* Level Control (server): current level */ \ + { \ + 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 3 } \ + }, /* Basic (server): cluster revision */ \ + { \ + 0x0000, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } \ + }, /* Basic (server): InteractionModelVersion */ \ + { \ + 0x0001, ZAP_TYPE(CHAR_STRING), 32, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(0) } \ + }, /* Basic (server): VendorName */ \ + { 0x0002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } }, /* Basic (server): VendorID */ \ + { \ + 0x0003, ZAP_TYPE(CHAR_STRING), 32, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(32) } \ + }, /* Basic (server): ProductName */ \ + { 0x0004, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0 } }, /* Basic (server): ProductID */ \ + { 0x0005, \ + ZAP_TYPE(CHAR_STRING), \ + 32, \ + ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(64) } }, /* Basic (server): UserLabel */ \ + { 0x0006, \ + ZAP_TYPE(CHAR_STRING), \ + 16, \ + ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(96) } }, /* Basic (server): Location */ \ + { \ + 0x0007, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 0x00 } \ + }, /* Basic (server): HardwareVersion */ \ + { \ + 0x0008, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(112) } \ + }, /* Basic (server): HardwareVersionString */ \ + { \ + 0x0009, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(176) } \ + }, /* Basic (server): SoftwareVersion */ \ + { \ + 0x000A, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(180) } \ + }, /* Basic (server): SoftwareVersionString */ \ { \ 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), { (uint8_t *) 3 } \ }, /* Door Lock (client): cluster revision */ \ @@ -157,7 +233,7 @@ { 0x0004, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x607D } }, /* Color Control (server): current y */ \ { 0x0005, ZAP_TYPE(ENUM8), 1, 0, { (uint8_t *) 0 } }, /* Color Control (server): drift compensation */ \ { \ - 0x0006, ZAP_TYPE(CHAR_STRING), 254, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(0) } \ + 0x0006, ZAP_TYPE(CHAR_STRING), 254, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(244) } \ }, /* Color Control (server): compensation text */ \ { 0x0007, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x00FA } }, /* Color Control (server): color temperature */ \ { 0x0008, ZAP_TYPE(ENUM8), 1, 0, { (uint8_t *) 0x01 } }, /* Color Control (server): color mode */ \ @@ -239,26 +315,26 @@ { 0x0001, ZAP_TYPE(ENUM16), 2, 0, { (uint8_t *) 0 } }, /* IAS Zone (server): zone type */ \ { 0x0002, ZAP_TYPE(BITMAP16), 2, 0, { (uint8_t *) 0x0000 } }, /* IAS Zone (server): zone status */ \ { \ - 0x0010, ZAP_TYPE(IEEE_ADDRESS), 8, ZAP_ATTRIBUTE_MASK(WRITABLE), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(254) } \ + 0x0010, ZAP_TYPE(IEEE_ADDRESS), 8, ZAP_ATTRIBUTE_MASK(WRITABLE), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(498) } \ }, /* IAS Zone (server): IAS CIE address */ \ { 0x0011, ZAP_TYPE(INT8U), 1, 0, { (uint8_t *) 0xff } }, /* IAS Zone (server): Zone ID */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Low Power (server): cluster revision */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Application Basic (server): cluster revision */ \ { \ - 0x0000, ZAP_TYPE(OCTET_STRING), 32, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(262) } \ + 0x0000, ZAP_TYPE(OCTET_STRING), 32, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(506) } \ }, /* Application Basic (server): vendor name */ \ { 0x0001, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0 } }, /* Application Basic (server): vendor id */ \ { \ - 0x0002, ZAP_TYPE(OCTET_STRING), 32, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(294) } \ - }, /* Application Basic (server): application name */ \ - { 0x0003, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0 } }, /* Application Basic (server): product id */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Application Basic (server): cluster revision */ \ + 0x0002, ZAP_TYPE(OCTET_STRING), 32, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(538) } \ + }, /* Application Basic (server): application name */ \ + { 0x0003, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0 } }, /* Application Basic (server): product id */ \ { \ - 0x0005, ZAP_TYPE(OCTET_STRING), 32, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(326) } \ + 0x0005, ZAP_TYPE(OCTET_STRING), 32, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(570) } \ }, /* Application Basic (server): application id */ \ { 0x0006, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0 } }, /* Application Basic (server): catalog vendor id */ \ { 0x0007, ZAP_TYPE(ENUM8), 1, 0, { (uint8_t *) 0x01 } }, /* Application Basic (server): application satus */ \ - { 0x0000, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0 } }, /* Media Playback (server): current state */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Media Playback (server): cluster revision */ \ + { 0x0000, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0 } }, /* Media Playback (server): current state */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Content Launch (server): cluster revision */ \ } @@ -299,82 +375,84 @@ #define GENERATED_CLUSTER_COUNT 18 #define GENERATED_CLUSTERS \ { \ - { 0x0000, ZAP_ATTRIBUTE_INDEX(0), 3, 4, ZAP_CLUSTER_MASK(SERVER), NULL }, /* Endpoint: 1, Cluster: Basic (server) */ \ - { 0x0003, \ - ZAP_ATTRIBUTE_INDEX(3), \ - 2, \ - 4, \ - ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION) | ZAP_CLUSTER_MASK(ATTRIBUTE_CHANGED_FUNCTION), \ - chipFuncArrayIdentifyServer }, /* Endpoint: 1, Cluster: Identify (server) */ \ + { 0x0003, \ + ZAP_ATTRIBUTE_INDEX(0), \ + 2, \ + 4, \ + ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION) | ZAP_CLUSTER_MASK(ATTRIBUTE_CHANGED_FUNCTION), \ + chipFuncArrayIdentifyServer }, /* Endpoint: 1, Cluster: Identify (server) */ \ { 0x0004, \ - ZAP_ATTRIBUTE_INDEX(5), \ + ZAP_ATTRIBUTE_INDEX(2), \ 2, \ 3, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayGroupsServer }, /* Endpoint: 1, Cluster: Groups (server) */ \ { 0x0005, \ - ZAP_ATTRIBUTE_INDEX(7), \ + ZAP_ATTRIBUTE_INDEX(4), \ 6, \ 8, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayScenesServer }, /* Endpoint: 1, Cluster: Scenes (server) */ \ { 0x0006, \ - ZAP_ATTRIBUTE_INDEX(13), \ + ZAP_ATTRIBUTE_INDEX(10), \ 2, \ 3, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayOnOffServer }, /* Endpoint: 1, Cluster: On/off (server) */ \ { 0x0008, \ - ZAP_ATTRIBUTE_INDEX(15), \ + ZAP_ATTRIBUTE_INDEX(12), \ 2, \ 3, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayLevelControlServer }, /* Endpoint: 1, Cluster: Level Control (server) */ \ { \ - 0x0101, ZAP_ATTRIBUTE_INDEX(17), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0028, ZAP_ATTRIBUTE_INDEX(14), 12, 254, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 1, Cluster: Basic (server) */ \ + { \ + 0x0101, ZAP_ATTRIBUTE_INDEX(26), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Door Lock (client) */ \ { 0x0101, \ - ZAP_ATTRIBUTE_INDEX(18), \ + ZAP_ATTRIBUTE_INDEX(27), \ 4, \ 5, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(ATTRIBUTE_CHANGED_FUNCTION), \ chipFuncArrayDoorLockServer }, /* Endpoint: 1, Cluster: Door Lock (server) */ \ { \ - 0x0103, ZAP_ATTRIBUTE_INDEX(22), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0103, ZAP_ATTRIBUTE_INDEX(31), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Barrier Control (client) */ \ { \ - 0x0103, ZAP_ATTRIBUTE_INDEX(23), 5, 7, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0103, ZAP_ATTRIBUTE_INDEX(32), 5, 7, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Barrier Control (server) */ \ { \ - 0x0300, ZAP_ATTRIBUTE_INDEX(28), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0300, ZAP_ATTRIBUTE_INDEX(37), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Color Control (client) */ \ { 0x0300, \ - ZAP_ATTRIBUTE_INDEX(29), \ + ZAP_ATTRIBUTE_INDEX(38), \ 51, \ 336, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayColorControlServer }, /* Endpoint: 1, Cluster: Color Control (server) */ \ { \ - 0x0402, ZAP_ATTRIBUTE_INDEX(80), 4, 8, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0402, ZAP_ATTRIBUTE_INDEX(89), 4, 8, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Temperature Measurement (server) */ \ { 0x0500, \ - ZAP_ATTRIBUTE_INDEX(84), \ + ZAP_ATTRIBUTE_INDEX(93), \ 6, \ 16, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION) | ZAP_CLUSTER_MASK(PRE_ATTRIBUTE_CHANGED_FUNCTION) | \ ZAP_CLUSTER_MASK(MESSAGE_SENT_FUNCTION), \ chipFuncArrayIasZoneServer }, /* Endpoint: 1, Cluster: IAS Zone (server) */ \ { \ - 0x0508, ZAP_ATTRIBUTE_INDEX(90), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0508, ZAP_ATTRIBUTE_INDEX(99), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Low Power (server) */ \ { \ - 0x050D, ZAP_ATTRIBUTE_INDEX(91), 8, 105, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x050D, ZAP_ATTRIBUTE_INDEX(100), 8, 105, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Application Basic (server) */ \ { \ - 0xF001, ZAP_ATTRIBUTE_INDEX(99), 2, 4, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0xF001, ZAP_ATTRIBUTE_INDEX(108), 2, 4, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Media Playback (server) */ \ { \ - 0xF002, ZAP_ATTRIBUTE_INDEX(101), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0xF002, ZAP_ATTRIBUTE_INDEX(110), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Content Launch (server) */ \ } @@ -383,17 +461,17 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 18, 516 }, \ + { ZAP_CLUSTER_INDEX(0), 18, 766 }, \ } // Largest attribute size is needed for various buffers #define ATTRIBUTE_LARGEST (254) // Total size of singleton attributes -#define ATTRIBUTE_SINGLETONS_SIZE (4) +#define ATTRIBUTE_SINGLETONS_SIZE (254) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (516) +#define ATTRIBUTE_MAX_SIZE (766) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (1) @@ -437,19 +515,17 @@ // Array of EmberAfCommandMetadata structs. #define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask -#define EMBER_AF_GENERATED_COMMAND_COUNT (139) +#define EMBER_AF_GENERATED_COMMAND_COUNT (141) #define GENERATED_COMMANDS \ { \ - { 0x0000, 0x00, \ - ZAP_COMMAND_MASK(INCOMING_SERVER) | ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Basic (server): ResetToFactoryDefaults */ \ - { 0x0003, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Identify (server): Identify */ \ - { 0x0003, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Identify (server): IdentifyQueryResponse */ \ - { 0x0003, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Identify (server): IdentifyQuery */ \ - { 0x0004, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Groups (server): AddGroup */ \ - { 0x0004, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Groups (server): AddGroupResponse */ \ - { 0x0004, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Groups (server): ViewGroup */ \ - { 0x0004, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Groups (server): ViewGroupResponse */ \ - { 0x0004, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Groups (server): GetGroupMembership */ \ + { 0x0003, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Identify (server): Identify */ \ + { 0x0003, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Identify (server): IdentifyQueryResponse */ \ + { 0x0003, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Identify (server): IdentifyQuery */ \ + { 0x0004, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Groups (server): AddGroup */ \ + { 0x0004, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Groups (server): AddGroupResponse */ \ + { 0x0004, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Groups (server): ViewGroup */ \ + { 0x0004, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Groups (server): ViewGroupResponse */ \ + { 0x0004, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Groups (server): GetGroupMembership */ \ { 0x0004, 0x02, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Groups (server): GetGroupMembershipResponse */ \ { 0x0004, 0x03, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Groups (server): RemoveGroup */ \ { 0x0004, 0x03, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Groups (server): RemoveGroupResponse */ \ @@ -479,6 +555,9 @@ { 0x0008, 0x05, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Level Control (server): MoveWithOnOff */ \ { 0x0008, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Level Control (server): StepWithOnOff */ \ { 0x0008, 0x07, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Level Control (server): StopWithOnOff */ \ + { 0x0028, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): StartUp */ \ + { 0x0028, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): ShutDown */ \ + { 0x0028, 0x02, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): Leave */ \ { 0x0101, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Door Lock (client): LockDoor */ \ { 0x0101, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Door Lock (client): LockDoorResponse */ \ { 0x0101, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Door Lock (server): LockDoor */ \ diff --git a/examples/tv-app/tv-common/gen/print-cluster.h b/examples/tv-app/tv-common/gen/print-cluster.h index 1ea31513afebcd..bd08d38a581506 100644 --- a/examples/tv-app/tv-common/gen/print-cluster.h +++ b/examples/tv-app/tv-common/gen/print-cluster.h @@ -24,12 +24,6 @@ // to the "EmberAfClusterName" defined in the ZCL header. // The names of clusters that are not present, are removed. -#if defined(ZCL_USING_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_BASIC_CLUSTER_CLIENT) -#define CHIP_PRINTCLUSTER_BASIC_CLUSTER { ZCL_BASIC_CLUSTER_ID, 0, "Basic" }, -#else -#define CHIP_PRINTCLUSTER_BASIC_CLUSTER -#endif - #if defined(ZCL_USING_POWER_CONFIG_CLUSTER_SERVER) || defined(ZCL_USING_POWER_CONFIG_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_POWER_CONFIG_CLUSTER { ZCL_POWER_CONFIG_CLUSTER_ID, 1, "Power Configuration" }, #else @@ -150,6 +144,12 @@ #define CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER #endif +#if defined(ZCL_USING_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_BASIC_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_BASIC_CLUSTER { ZCL_BASIC_CLUSTER_ID, 40, "Basic" }, +#else +#define CHIP_PRINTCLUSTER_BASIC_CLUSTER +#endif + #if defined(ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER { ZCL_GENERAL_COMMISSIONING_CLUSTER_ID, 48, "General Commissioning" }, #else @@ -790,7 +790,6 @@ #endif #define CLUSTER_IDS_TO_NAMES \ - CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_POWER_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DEVICE_TEMP_CLUSTER \ CHIP_PRINTCLUSTER_IDENTIFY_CLUSTER \ @@ -811,6 +810,7 @@ CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER \ CHIP_PRINTCLUSTER_GREEN_POWER_CLUSTER \ CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER \ + CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DOOR_LOCK_CLUSTER \ diff --git a/examples/tv-app/tv-common/tv-app.zap b/examples/tv-app/tv-common/tv-app.zap index 0b35602653138e..af07b1a7dc06a0 100644 --- a/examples/tv-app/tv-common/tv-app.zap +++ b/examples/tv-app/tv-common/tv-app.zap @@ -39,21 +39,12 @@ "clusters": [ { "name": "Basic", - "code": 0, + "code": 40, "mfgCode": null, "define": "BASIC_CLUSTER", "side": "client", "enabled": 0, - "commands": [ - { - "name": "ResetToFactoryDefaults", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } - ], + "commands": [], "attributes": [ { "name": "cluster revision", @@ -74,12 +65,37 @@ }, { "name": "Basic", - "code": 0, + "code": 40, "mfgCode": null, "define": "BASIC_CLUSTER", "side": "server", "enabled": 1, - "commands": [], + "commands": [ + { + "name": "StartUp", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ShutDown", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "Leave", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], "attributes": [ { "name": "cluster revision", @@ -97,7 +113,7 @@ "reportableChange": 0 }, { - "name": "ZCL version", + "name": "InteractionModelVersion", "code": 0, "mfgCode": null, "side": "server", @@ -105,14 +121,104 @@ "storageOption": "RAM", "singleton": 1, "bounded": 0, - "defaultValue": "0x08", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "power source", + "name": "VendorName", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorID", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductName", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductID", + "code": 4, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UserLabel", + "code": 5, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Location", + "code": 6, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersion", "code": 7, "mfgCode": null, "side": "server", @@ -125,6 +231,51 @@ "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 + }, + { + "name": "HardwareVersionString", + "code": 8, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersion", + "code": 9, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersionString", + "code": 10, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 } ] }, @@ -3283,4 +3434,4 @@ "networkId": 1 } ] -} \ No newline at end of file +} diff --git a/src/app/chip-zcl-zpro-codec-api.h b/src/app/chip-zcl-zpro-codec-api.h index d80a5e99869c5d..437fd961591507 100644 --- a/src/app/chip-zcl-zpro-codec-api.h +++ b/src/app/chip-zcl-zpro-codec-api.h @@ -30,7 +30,7 @@ |---------------------------------------------------------------------+--------| | ApplicationBasic | 0x050D | | BarrierControl | 0x0103 | -| Basic | 0x0000 | +| Basic | 0x0028 | | Binding | 0xF000 | | ColorControl | 0x0300 | | ContentLaunch | 0xF002 | @@ -200,15 +200,23 @@ chip::System::PacketBufferHandle encodeBarrierControlClusterReadClusterRevisionA chip::EndpointId destinationEndpoint); /*----------------------------------------------------------------------------*\ -| Cluster Basic | 0x0000 | +| Cluster Basic | 0x0028 | |------------------------------------------------------------------------------| | Commands: | | | * MfgSpecificPing | 0x00 | -| * ResetToFactoryDefaults | 0x00 | |------------------------------------------------------------------------------| | Attributes: | | -| * ZclVersion | 0x0000 | -| * PowerSource | 0x0007 | +| * InteractionModelVersion | 0x0000 | +| * VendorName | 0x0001 | +| * VendorID | 0x0002 | +| * ProductName | 0x0003 | +| * ProductID | 0x0004 | +| * UserLabel | 0x0005 | +| * Location | 0x0006 | +| * HardwareVersion | 0x0007 | +| * HardwareVersionString | 0x0008 | +| * SoftwareVersion | 0x0009 | +| * SoftwareVersionString | 0x000A | | * ClusterRevision | 0xFFFD | \*----------------------------------------------------------------------------*/ @@ -220,28 +228,94 @@ chip::System::PacketBufferHandle encodeBasicClusterMfgSpecificPingCommand(uint8_ /** * @brief - * Encode an ResetToFactoryDefaults command for Basic server into buffer including the APS frame + * Encode a Basic server discover command into buffer including the APS frame */ -chip::System::PacketBufferHandle encodeBasicClusterResetToFactoryDefaultsCommand(uint8_t seqNum, - chip::EndpointId destinationEndpoint); +chip::System::PacketBufferHandle encodeBasicClusterDiscoverAttributes(uint8_t seqNum, chip::EndpointId destinationEndpoint); /** * @brief - * Encode a Basic server discover command into buffer including the APS frame + * Encode a Basic server read command for the InteractionModelVersion attribute into buffer including the APS frame */ -chip::System::PacketBufferHandle encodeBasicClusterDiscoverAttributes(uint8_t seqNum, chip::EndpointId destinationEndpoint); +chip::System::PacketBufferHandle encodeBasicClusterReadInteractionModelVersionAttribute(uint8_t seqNum, + chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Basic server read command for the VendorName attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle encodeBasicClusterReadVendorNameAttribute(uint8_t seqNum, chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Basic server read command for the VendorID attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle encodeBasicClusterReadVendorIDAttribute(uint8_t seqNum, chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Basic server read command for the ProductName attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle encodeBasicClusterReadProductNameAttribute(uint8_t seqNum, chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Basic server read command for the ProductID attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle encodeBasicClusterReadProductIDAttribute(uint8_t seqNum, chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Basic server read command for the UserLabel attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle encodeBasicClusterReadUserLabelAttribute(uint8_t seqNum, chip::EndpointId destinationEndpoint); /** * @brief - * Encode a Basic server read command for the ZCL version attribute into buffer including the APS frame + * Encode a Basic server write command for the UserLabel attribute into buffer including the APS frame */ -chip::System::PacketBufferHandle encodeBasicClusterReadZclVersionAttribute(uint8_t seqNum, chip::EndpointId destinationEndpoint); +chip::System::PacketBufferHandle encodeBasicClusterWriteUserLabelAttribute(uint8_t seqNum, chip::EndpointId destinationEndpoint, + chip::ByteSpan userLabel); /** * @brief - * Encode a Basic server read command for the power source attribute into buffer including the APS frame + * Encode a Basic server read command for the Location attribute into buffer including the APS frame */ -chip::System::PacketBufferHandle encodeBasicClusterReadPowerSourceAttribute(uint8_t seqNum, chip::EndpointId destinationEndpoint); +chip::System::PacketBufferHandle encodeBasicClusterReadLocationAttribute(uint8_t seqNum, chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Basic server write command for the Location attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle encodeBasicClusterWriteLocationAttribute(uint8_t seqNum, chip::EndpointId destinationEndpoint, + chip::ByteSpan location); + +/** + * @brief + * Encode a Basic server read command for the HardwareVersion attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle encodeBasicClusterReadHardwareVersionAttribute(uint8_t seqNum, + chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Basic server read command for the HardwareVersionString attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle encodeBasicClusterReadHardwareVersionStringAttribute(uint8_t seqNum, + chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Basic server read command for the SoftwareVersion attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle encodeBasicClusterReadSoftwareVersionAttribute(uint8_t seqNum, + chip::EndpointId destinationEndpoint); + +/** + * @brief + * Encode a Basic server read command for the SoftwareVersionString attribute into buffer including the APS frame + */ +chip::System::PacketBufferHandle encodeBasicClusterReadSoftwareVersionStringAttribute(uint8_t seqNum, + chip::EndpointId destinationEndpoint); /** * @brief @@ -1166,7 +1240,7 @@ chip::System::PacketBufferHandle encodeDoorLockClusterGetYeardayScheduleCommand( * Encode an LockDoor command for Door Lock server into buffer including the APS frame */ chip::System::PacketBufferHandle encodeDoorLockClusterLockDoorCommand(uint8_t seqNum, chip::EndpointId destinationEndpoint, - char * pin); + chip::ByteSpan pin); /** * @brief @@ -1182,7 +1256,7 @@ encodeDoorLockClusterSetHolidayScheduleCommand(uint8_t seqNum, chip::EndpointId */ chip::System::PacketBufferHandle encodeDoorLockClusterSetPinCommand(uint8_t seqNum, chip::EndpointId destinationEndpoint, uint16_t userId, uint8_t userStatus, uint8_t userType, - char * pin); + chip::ByteSpan pin); /** * @brief @@ -1190,7 +1264,7 @@ chip::System::PacketBufferHandle encodeDoorLockClusterSetPinCommand(uint8_t seqN */ chip::System::PacketBufferHandle encodeDoorLockClusterSetRfidCommand(uint8_t seqNum, chip::EndpointId destinationEndpoint, uint16_t userId, uint8_t userStatus, uint8_t userType, - char * id); + chip::ByteSpan id); /** * @brief @@ -1222,14 +1296,14 @@ chip::System::PacketBufferHandle encodeDoorLockClusterSetYeardayScheduleCommand( * Encode an UnlockDoor command for Door Lock server into buffer including the APS frame */ chip::System::PacketBufferHandle encodeDoorLockClusterUnlockDoorCommand(uint8_t seqNum, chip::EndpointId destinationEndpoint, - char * pin); + chip::ByteSpan pin); /** * @brief * Encode an UnlockWithTimeout command for Door Lock server into buffer including the APS frame */ chip::System::PacketBufferHandle encodeDoorLockClusterUnlockWithTimeoutCommand(uint8_t seqNum, chip::EndpointId destinationEndpoint, - uint16_t timeoutInSeconds, char * pin); + uint16_t timeoutInSeconds, chip::ByteSpan pin); /** * @brief @@ -1366,7 +1440,7 @@ encodeGeneralCommissioningClusterReadClusterRevisionAttribute(uint8_t seqNum, ch * Encode an AddGroup command for Groups server into buffer including the APS frame */ chip::System::PacketBufferHandle encodeGroupsClusterAddGroupCommand(uint8_t seqNum, chip::EndpointId destinationEndpoint, - uint16_t groupId, char * groupName); + uint16_t groupId, chip::ByteSpan groupName); /** * @brief @@ -1374,7 +1448,7 @@ chip::System::PacketBufferHandle encodeGroupsClusterAddGroupCommand(uint8_t seqN */ chip::System::PacketBufferHandle encodeGroupsClusterAddGroupIfIdentifyingCommand(uint8_t seqNum, chip::EndpointId destinationEndpoint, - uint16_t groupId, char * groupName); + uint16_t groupId, chip::ByteSpan groupName); /** * @brief @@ -1978,8 +2052,8 @@ chip::System::PacketBufferHandle encodeOnOffClusterReadClusterRevisionAttribute( */ chip::System::PacketBufferHandle encodeScenesClusterAddSceneCommand(uint8_t seqNum, chip::EndpointId destinationEndpoint, uint16_t groupId, uint8_t sceneId, uint16_t transitionTime, - char * sceneName, chip::ClusterId clusterId, uint8_t length, - uint8_t value); + chip::ByteSpan sceneName, chip::ClusterId clusterId, + uint8_t length, uint8_t value); /** * @brief diff --git a/src/app/encoder.cpp b/src/app/encoder.cpp index 8aa59ee982f8e1..bee0afea08dbc8 100644 --- a/src/app/encoder.cpp +++ b/src/app/encoder.cpp @@ -101,7 +101,7 @@ uint16_t encodeApsFrame(uint8_t * buffer, uint16_t buf_length, EmberApsFrame * a |---------------------------------------------------------------------+--------| | ApplicationBasic | 0x050D | | BarrierControl | 0x0103 | -| Basic | 0x0000 | +| Basic | 0x0028 | | Binding | 0xF000 | | ColorControl | 0x0300 | | ContentLaunch | 0xF002 | @@ -151,9 +151,8 @@ uint16_t encodeApsFrame(uint8_t * buffer, uint16_t buf_length, EmberApsFrame * a #define ZCL_BARRIER_CONTROL_GO_TO_PERCENT_COMMAND_ID (0x00) #define ZCL_BARRIER_CONTROL_STOP_COMMAND_ID (0x01) -#define BASIC_CLUSTER_ID 0x0000 +#define BASIC_CLUSTER_ID 0x0028 #define ZCL_MFG_SPECIFIC_PING_COMMAND_ID (0x00) -#define ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID (0x00) #define BINDING_CLUSTER_ID 0xF000 #define ZCL_BIND_COMMAND_ID (0x00) @@ -417,6 +416,7 @@ PacketBufferHandle encodeBarrierControlClusterBarrierControlGoToPercentCommand(u uint8_t percentOpen) { COMMAND_HEADER("BarrierControlGoToPercent", BARRIER_CONTROL_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand).Put8(seqNum).Put8(ZCL_BARRIER_CONTROL_GO_TO_PERCENT_COMMAND_ID).Put8(percentOpen); COMMAND_FOOTER(); } @@ -489,15 +489,23 @@ PacketBufferHandle encodeBarrierControlClusterReadClusterRevisionAttribute(uint8 } /*----------------------------------------------------------------------------*\ -| Cluster Basic | 0x0000 | +| Cluster Basic | 0x0028 | |------------------------------------------------------------------------------| | Commands: | | | * MfgSpecificPing | 0x00 | -| * ResetToFactoryDefaults | 0x00 | |------------------------------------------------------------------------------| | Attributes: | | -| * ZclVersion | 0x0000 | -| * PowerSource | 0x0007 | +| * InteractionModelVersion | 0x0000 | +| * VendorName | 0x0001 | +| * VendorID | 0x0002 | +| * ProductName | 0x0003 | +| * ProductID | 0x0004 | +| * UserLabel | 0x0005 | +| * Location | 0x0006 | +| * HardwareVersion | 0x0007 | +| * HardwareVersionString | 0x0008 | +| * SoftwareVersion | 0x0009 | +| * SoftwareVersionString | 0x000A | | * ClusterRevision | 0xFFFD | \*----------------------------------------------------------------------------*/ @@ -511,43 +519,164 @@ PacketBufferHandle encodeBasicClusterMfgSpecificPingCommand(uint8_t seqNum, Endp COMMAND_FOOTER(); } +PacketBufferHandle encodeBasicClusterDiscoverAttributes(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("DiscoverBasicAttributes", BASIC_CLUSTER_ID); + buf.Put8(kFrameControlGlobalCommand).Put8(seqNum).Put8(ZCL_DISCOVER_ATTRIBUTES_COMMAND_ID).Put16(0x0000).Put8(0xFF); + COMMAND_FOOTER(); +} + /* - * Command ResetToFactoryDefaults + * Attribute InteractionModelVersion */ -PacketBufferHandle encodeBasicClusterResetToFactoryDefaultsCommand(uint8_t seqNum, EndpointId destinationEndpoint) +PacketBufferHandle encodeBasicClusterReadInteractionModelVersionAttribute(uint8_t seqNum, EndpointId destinationEndpoint) { - COMMAND_HEADER("ResetToFactoryDefaults", BASIC_CLUSTER_ID); - buf.Put8(kFrameControlClusterSpecificCommand).Put8(seqNum).Put8(ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID); + COMMAND_HEADER("ReadBasicInteractionModelVersion", BASIC_CLUSTER_ID); + buf.Put8(kFrameControlGlobalCommand).Put8(seqNum).Put8(ZCL_READ_ATTRIBUTES_COMMAND_ID).Put16(0x0000); COMMAND_FOOTER(); } -PacketBufferHandle encodeBasicClusterDiscoverAttributes(uint8_t seqNum, EndpointId destinationEndpoint) +/* + * Attribute VendorName + */ +PacketBufferHandle encodeBasicClusterReadVendorNameAttribute(uint8_t seqNum, EndpointId destinationEndpoint) { - COMMAND_HEADER("DiscoverBasicAttributes", BASIC_CLUSTER_ID); - buf.Put8(kFrameControlGlobalCommand).Put8(seqNum).Put8(ZCL_DISCOVER_ATTRIBUTES_COMMAND_ID).Put16(0x0000).Put8(0xFF); + COMMAND_HEADER("ReadBasicVendorName", BASIC_CLUSTER_ID); + buf.Put8(kFrameControlGlobalCommand).Put8(seqNum).Put8(ZCL_READ_ATTRIBUTES_COMMAND_ID).Put16(0x0001); COMMAND_FOOTER(); } /* - * Attribute ZclVersion + * Attribute VendorID */ -PacketBufferHandle encodeBasicClusterReadZclVersionAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +PacketBufferHandle encodeBasicClusterReadVendorIDAttribute(uint8_t seqNum, EndpointId destinationEndpoint) { - COMMAND_HEADER("ReadBasicZclVersion", BASIC_CLUSTER_ID); - buf.Put8(kFrameControlGlobalCommand).Put8(seqNum).Put8(ZCL_READ_ATTRIBUTES_COMMAND_ID).Put16(0x0000); + COMMAND_HEADER("ReadBasicVendorID", BASIC_CLUSTER_ID); + buf.Put8(kFrameControlGlobalCommand).Put8(seqNum).Put8(ZCL_READ_ATTRIBUTES_COMMAND_ID).Put16(0x0002); + COMMAND_FOOTER(); +} + +/* + * Attribute ProductName + */ +PacketBufferHandle encodeBasicClusterReadProductNameAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("ReadBasicProductName", BASIC_CLUSTER_ID); + buf.Put8(kFrameControlGlobalCommand).Put8(seqNum).Put8(ZCL_READ_ATTRIBUTES_COMMAND_ID).Put16(0x0003); + COMMAND_FOOTER(); +} + +/* + * Attribute ProductID + */ +PacketBufferHandle encodeBasicClusterReadProductIDAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("ReadBasicProductID", BASIC_CLUSTER_ID); + buf.Put8(kFrameControlGlobalCommand).Put8(seqNum).Put8(ZCL_READ_ATTRIBUTES_COMMAND_ID).Put16(0x0004); COMMAND_FOOTER(); } /* - * Attribute PowerSource + * Attribute UserLabel */ -PacketBufferHandle encodeBasicClusterReadPowerSourceAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +PacketBufferHandle encodeBasicClusterReadUserLabelAttribute(uint8_t seqNum, EndpointId destinationEndpoint) { - COMMAND_HEADER("ReadBasicPowerSource", BASIC_CLUSTER_ID); + COMMAND_HEADER("ReadBasicUserLabel", BASIC_CLUSTER_ID); + buf.Put8(kFrameControlGlobalCommand).Put8(seqNum).Put8(ZCL_READ_ATTRIBUTES_COMMAND_ID).Put16(0x0005); + COMMAND_FOOTER(); +} + +PacketBufferHandle encodeBasicClusterWriteUserLabelAttribute(uint8_t seqNum, EndpointId destinationEndpoint, + chip::ByteSpan userLabel) +{ + COMMAND_HEADER("WriteBasicUserLabel", BASIC_CLUSTER_ID); + size_t userLabelStrLen = userLabel.size(); + if (!CanCastTo(userLabelStrLen)) + { + ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, userLabelStrLen); + return PacketBufferHandle(); + } + + buf.Put8(kFrameControlGlobalCommand) + .Put8(seqNum) + .Put8(ZCL_WRITE_ATTRIBUTES_COMMAND_ID) + .Put16(0x0005) + .Put8(66) + .Put(static_cast(userLabelStrLen)) + .Put(userLabel.data(), userLabelStrLen); + COMMAND_FOOTER(); +} + +/* + * Attribute Location + */ +PacketBufferHandle encodeBasicClusterReadLocationAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("ReadBasicLocation", BASIC_CLUSTER_ID); + buf.Put8(kFrameControlGlobalCommand).Put8(seqNum).Put8(ZCL_READ_ATTRIBUTES_COMMAND_ID).Put16(0x0006); + COMMAND_FOOTER(); +} + +PacketBufferHandle encodeBasicClusterWriteLocationAttribute(uint8_t seqNum, EndpointId destinationEndpoint, chip::ByteSpan location) +{ + COMMAND_HEADER("WriteBasicLocation", BASIC_CLUSTER_ID); + size_t locationStrLen = location.size(); + if (!CanCastTo(locationStrLen)) + { + ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, locationStrLen); + return PacketBufferHandle(); + } + + buf.Put8(kFrameControlGlobalCommand) + .Put8(seqNum) + .Put8(ZCL_WRITE_ATTRIBUTES_COMMAND_ID) + .Put16(0x0006) + .Put8(66) + .Put(static_cast(locationStrLen)) + .Put(location.data(), locationStrLen); + COMMAND_FOOTER(); +} + +/* + * Attribute HardwareVersion + */ +PacketBufferHandle encodeBasicClusterReadHardwareVersionAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("ReadBasicHardwareVersion", BASIC_CLUSTER_ID); buf.Put8(kFrameControlGlobalCommand).Put8(seqNum).Put8(ZCL_READ_ATTRIBUTES_COMMAND_ID).Put16(0x0007); COMMAND_FOOTER(); } +/* + * Attribute HardwareVersionString + */ +PacketBufferHandle encodeBasicClusterReadHardwareVersionStringAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("ReadBasicHardwareVersionString", BASIC_CLUSTER_ID); + buf.Put8(kFrameControlGlobalCommand).Put8(seqNum).Put8(ZCL_READ_ATTRIBUTES_COMMAND_ID).Put16(0x0008); + COMMAND_FOOTER(); +} + +/* + * Attribute SoftwareVersion + */ +PacketBufferHandle encodeBasicClusterReadSoftwareVersionAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("ReadBasicSoftwareVersion", BASIC_CLUSTER_ID); + buf.Put8(kFrameControlGlobalCommand).Put8(seqNum).Put8(ZCL_READ_ATTRIBUTES_COMMAND_ID).Put16(0x0009); + COMMAND_FOOTER(); +} + +/* + * Attribute SoftwareVersionString + */ +PacketBufferHandle encodeBasicClusterReadSoftwareVersionStringAttribute(uint8_t seqNum, EndpointId destinationEndpoint) +{ + COMMAND_HEADER("ReadBasicSoftwareVersionString", BASIC_CLUSTER_ID); + buf.Put8(kFrameControlGlobalCommand).Put8(seqNum).Put8(ZCL_READ_ATTRIBUTES_COMMAND_ID).Put16(0x000A); + COMMAND_FOOTER(); +} + /* * Attribute ClusterRevision */ @@ -576,6 +705,7 @@ PacketBufferHandle encodeBindingClusterBindCommand(uint8_t seqNum, EndpointId de chip::GroupId groupId, chip::EndpointId endpointId, chip::ClusterId clusterId) { COMMAND_HEADER("Bind", BINDING_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_BIND_COMMAND_ID) @@ -593,6 +723,7 @@ PacketBufferHandle encodeBindingClusterUnbindCommand(uint8_t seqNum, EndpointId chip::GroupId groupId, chip::EndpointId endpointId, chip::ClusterId clusterId) { COMMAND_HEADER("Unbind", BINDING_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_UNBIND_COMMAND_ID) @@ -700,6 +831,7 @@ PacketBufferHandle encodeColorControlClusterMoveColorCommand(uint8_t seqNum, End int16_t rateY, uint8_t optionsMask, uint8_t optionsOverride) { COMMAND_HEADER("MoveColor", COLOR_CONTROL_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_MOVE_COLOR_COMMAND_ID) @@ -720,6 +852,7 @@ PacketBufferHandle encodeColorControlClusterMoveColorTemperatureCommand(uint8_t uint8_t optionsOverride) { COMMAND_HEADER("MoveColorTemperature", COLOR_CONTROL_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_MOVE_COLOR_TEMPERATURE_COMMAND_ID) @@ -739,6 +872,7 @@ PacketBufferHandle encodeColorControlClusterMoveHueCommand(uint8_t seqNum, Endpo uint8_t rate, uint8_t optionsMask, uint8_t optionsOverride) { COMMAND_HEADER("MoveHue", COLOR_CONTROL_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_MOVE_HUE_COMMAND_ID) @@ -756,6 +890,7 @@ PacketBufferHandle encodeColorControlClusterMoveSaturationCommand(uint8_t seqNum uint8_t rate, uint8_t optionsMask, uint8_t optionsOverride) { COMMAND_HEADER("MoveSaturation", COLOR_CONTROL_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_MOVE_SATURATION_COMMAND_ID) @@ -774,6 +909,7 @@ PacketBufferHandle encodeColorControlClusterMoveToColorCommand(uint8_t seqNum, E uint8_t optionsOverride) { COMMAND_HEADER("MoveToColor", COLOR_CONTROL_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_MOVE_TO_COLOR_COMMAND_ID) @@ -793,6 +929,7 @@ PacketBufferHandle encodeColorControlClusterMoveToColorTemperatureCommand(uint8_ uint8_t optionsMask, uint8_t optionsOverride) { COMMAND_HEADER("MoveToColorTemperature", COLOR_CONTROL_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_MOVE_TO_COLOR_TEMPERATURE_COMMAND_ID) @@ -811,6 +948,7 @@ PacketBufferHandle encodeColorControlClusterMoveToHueCommand(uint8_t seqNum, End uint8_t optionsOverride) { COMMAND_HEADER("MoveToHue", COLOR_CONTROL_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_MOVE_TO_HUE_COMMAND_ID) @@ -830,6 +968,7 @@ PacketBufferHandle encodeColorControlClusterMoveToHueAndSaturationCommand(uint8_ uint8_t optionsMask, uint8_t optionsOverride) { COMMAND_HEADER("MoveToHueAndSaturation", COLOR_CONTROL_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_MOVE_TO_HUE_AND_SATURATION_COMMAND_ID) @@ -849,6 +988,7 @@ PacketBufferHandle encodeColorControlClusterMoveToSaturationCommand(uint8_t seqN uint8_t optionsMask, uint8_t optionsOverride) { COMMAND_HEADER("MoveToSaturation", COLOR_CONTROL_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_MOVE_TO_SATURATION_COMMAND_ID) @@ -867,6 +1007,7 @@ PacketBufferHandle encodeColorControlClusterStepColorCommand(uint8_t seqNum, End uint8_t optionsOverride) { COMMAND_HEADER("StepColor", COLOR_CONTROL_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_STEP_COLOR_COMMAND_ID) @@ -888,6 +1029,7 @@ PacketBufferHandle encodeColorControlClusterStepColorTemperatureCommand(uint8_t uint8_t optionsOverride) { COMMAND_HEADER("StepColorTemperature", COLOR_CONTROL_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_STEP_COLOR_TEMPERATURE_COMMAND_ID) @@ -909,6 +1051,7 @@ PacketBufferHandle encodeColorControlClusterStepHueCommand(uint8_t seqNum, Endpo uint8_t optionsOverride) { COMMAND_HEADER("StepHue", COLOR_CONTROL_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_STEP_HUE_COMMAND_ID) @@ -928,6 +1071,7 @@ PacketBufferHandle encodeColorControlClusterStepSaturationCommand(uint8_t seqNum uint8_t optionsOverride) { COMMAND_HEADER("StepSaturation", COLOR_CONTROL_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_STEP_SATURATION_COMMAND_ID) @@ -946,6 +1090,7 @@ PacketBufferHandle encodeColorControlClusterStopMoveStepCommand(uint8_t seqNum, uint8_t optionsOverride) { COMMAND_HEADER("StopMoveStep", COLOR_CONTROL_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_STOP_MOVE_STEP_COMMAND_ID) @@ -1835,6 +1980,7 @@ PacketBufferHandle encodeDoorLockClusterClearHolidayScheduleCommand(uint8_t seqN uint8_t scheduleId) { COMMAND_HEADER("ClearHolidaySchedule", DOOR_LOCK_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand).Put8(seqNum).Put8(ZCL_CLEAR_HOLIDAY_SCHEDULE_COMMAND_ID).Put8(scheduleId); COMMAND_FOOTER(); } @@ -1845,6 +1991,7 @@ PacketBufferHandle encodeDoorLockClusterClearHolidayScheduleCommand(uint8_t seqN PacketBufferHandle encodeDoorLockClusterClearPinCommand(uint8_t seqNum, EndpointId destinationEndpoint, uint16_t userId) { COMMAND_HEADER("ClearPin", DOOR_LOCK_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand).Put8(seqNum).Put8(ZCL_CLEAR_PIN_COMMAND_ID).Put16(userId); COMMAND_FOOTER(); } @@ -1855,6 +2002,7 @@ PacketBufferHandle encodeDoorLockClusterClearPinCommand(uint8_t seqNum, Endpoint PacketBufferHandle encodeDoorLockClusterClearRfidCommand(uint8_t seqNum, EndpointId destinationEndpoint, uint16_t userId) { COMMAND_HEADER("ClearRfid", DOOR_LOCK_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand).Put8(seqNum).Put8(ZCL_CLEAR_RFID_COMMAND_ID).Put16(userId); COMMAND_FOOTER(); } @@ -1866,6 +2014,7 @@ PacketBufferHandle encodeDoorLockClusterClearWeekdayScheduleCommand(uint8_t seqN uint8_t scheduleId, uint16_t userId) { COMMAND_HEADER("ClearWeekdaySchedule", DOOR_LOCK_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_CLEAR_WEEKDAY_SCHEDULE_COMMAND_ID) @@ -1881,6 +2030,7 @@ PacketBufferHandle encodeDoorLockClusterClearYeardayScheduleCommand(uint8_t seqN uint8_t scheduleId, uint16_t userId) { COMMAND_HEADER("ClearYeardaySchedule", DOOR_LOCK_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_CLEAR_YEARDAY_SCHEDULE_COMMAND_ID) @@ -1896,6 +2046,7 @@ PacketBufferHandle encodeDoorLockClusterGetHolidayScheduleCommand(uint8_t seqNum uint8_t scheduleId) { COMMAND_HEADER("GetHolidaySchedule", DOOR_LOCK_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand).Put8(seqNum).Put8(ZCL_GET_HOLIDAY_SCHEDULE_COMMAND_ID).Put8(scheduleId); COMMAND_FOOTER(); } @@ -1906,6 +2057,7 @@ PacketBufferHandle encodeDoorLockClusterGetHolidayScheduleCommand(uint8_t seqNum PacketBufferHandle encodeDoorLockClusterGetLogRecordCommand(uint8_t seqNum, EndpointId destinationEndpoint, uint16_t logIndex) { COMMAND_HEADER("GetLogRecord", DOOR_LOCK_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand).Put8(seqNum).Put8(ZCL_GET_LOG_RECORD_COMMAND_ID).Put16(logIndex); COMMAND_FOOTER(); } @@ -1916,6 +2068,7 @@ PacketBufferHandle encodeDoorLockClusterGetLogRecordCommand(uint8_t seqNum, Endp PacketBufferHandle encodeDoorLockClusterGetPinCommand(uint8_t seqNum, EndpointId destinationEndpoint, uint16_t userId) { COMMAND_HEADER("GetPin", DOOR_LOCK_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand).Put8(seqNum).Put8(ZCL_GET_PIN_COMMAND_ID).Put16(userId); COMMAND_FOOTER(); } @@ -1926,6 +2079,7 @@ PacketBufferHandle encodeDoorLockClusterGetPinCommand(uint8_t seqNum, EndpointId PacketBufferHandle encodeDoorLockClusterGetRfidCommand(uint8_t seqNum, EndpointId destinationEndpoint, uint16_t userId) { COMMAND_HEADER("GetRfid", DOOR_LOCK_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand).Put8(seqNum).Put8(ZCL_GET_RFID_COMMAND_ID).Put16(userId); COMMAND_FOOTER(); } @@ -1936,6 +2090,7 @@ PacketBufferHandle encodeDoorLockClusterGetRfidCommand(uint8_t seqNum, EndpointI PacketBufferHandle encodeDoorLockClusterGetUserTypeCommand(uint8_t seqNum, EndpointId destinationEndpoint, uint16_t userId) { COMMAND_HEADER("GetUserType", DOOR_LOCK_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand).Put8(seqNum).Put8(ZCL_GET_USER_TYPE_COMMAND_ID).Put16(userId); COMMAND_FOOTER(); } @@ -1947,6 +2102,7 @@ PacketBufferHandle encodeDoorLockClusterGetWeekdayScheduleCommand(uint8_t seqNum uint8_t scheduleId, uint16_t userId) { COMMAND_HEADER("GetWeekdaySchedule", DOOR_LOCK_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_GET_WEEKDAY_SCHEDULE_COMMAND_ID) @@ -1962,6 +2118,7 @@ PacketBufferHandle encodeDoorLockClusterGetYeardayScheduleCommand(uint8_t seqNum uint8_t scheduleId, uint16_t userId) { COMMAND_HEADER("GetYeardaySchedule", DOOR_LOCK_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_GET_YEARDAY_SCHEDULE_COMMAND_ID) @@ -1973,20 +2130,21 @@ PacketBufferHandle encodeDoorLockClusterGetYeardayScheduleCommand(uint8_t seqNum /* * Command LockDoor */ -PacketBufferHandle encodeDoorLockClusterLockDoorCommand(uint8_t seqNum, EndpointId destinationEndpoint, char * pin) +PacketBufferHandle encodeDoorLockClusterLockDoorCommand(uint8_t seqNum, EndpointId destinationEndpoint, chip::ByteSpan pin) { COMMAND_HEADER("LockDoor", DOOR_LOCK_CLUSTER_ID); - size_t pinStrLen = strlen(pin); + size_t pinStrLen = pin.size(); if (!CanCastTo(pinStrLen)) { ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, pinStrLen); return PacketBufferHandle(); } + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_LOCK_DOOR_COMMAND_ID) .Put(static_cast(pinStrLen)) - .Put(pin); + .Put(pin.data(), pin.size()); COMMAND_FOOTER(); } @@ -1998,6 +2156,7 @@ PacketBufferHandle encodeDoorLockClusterSetHolidayScheduleCommand(uint8_t seqNum uint32_t localEndTime, uint8_t operatingModeDuringHoliday) { COMMAND_HEADER("SetHolidaySchedule", DOOR_LOCK_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_SET_HOLIDAY_SCHEDULE_COMMAND_ID) @@ -2012,15 +2171,17 @@ PacketBufferHandle encodeDoorLockClusterSetHolidayScheduleCommand(uint8_t seqNum * Command SetPin */ PacketBufferHandle encodeDoorLockClusterSetPinCommand(uint8_t seqNum, EndpointId destinationEndpoint, uint16_t userId, - uint8_t userStatus, uint8_t userType, char * pin) + uint8_t userStatus, uint8_t userType, chip::ByteSpan pin) { COMMAND_HEADER("SetPin", DOOR_LOCK_CLUSTER_ID); - size_t pinStrLen = strlen(pin); + + size_t pinStrLen = pin.size(); if (!CanCastTo(pinStrLen)) { ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, pinStrLen); return PacketBufferHandle(); } + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_SET_PIN_COMMAND_ID) @@ -2028,7 +2189,7 @@ PacketBufferHandle encodeDoorLockClusterSetPinCommand(uint8_t seqNum, EndpointId .Put8(userStatus) .Put8(userType) .Put(static_cast(pinStrLen)) - .Put(pin); + .Put(pin.data(), pin.size()); COMMAND_FOOTER(); } @@ -2036,15 +2197,17 @@ PacketBufferHandle encodeDoorLockClusterSetPinCommand(uint8_t seqNum, EndpointId * Command SetRfid */ PacketBufferHandle encodeDoorLockClusterSetRfidCommand(uint8_t seqNum, EndpointId destinationEndpoint, uint16_t userId, - uint8_t userStatus, uint8_t userType, char * id) + uint8_t userStatus, uint8_t userType, chip::ByteSpan id) { COMMAND_HEADER("SetRfid", DOOR_LOCK_CLUSTER_ID); - size_t idStrLen = strlen(id); + + size_t idStrLen = id.size(); if (!CanCastTo(idStrLen)) { ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, idStrLen); return PacketBufferHandle(); } + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_SET_RFID_COMMAND_ID) @@ -2052,7 +2215,7 @@ PacketBufferHandle encodeDoorLockClusterSetRfidCommand(uint8_t seqNum, EndpointI .Put8(userStatus) .Put8(userType) .Put(static_cast(idStrLen)) - .Put(id); + .Put(id.data(), id.size()); COMMAND_FOOTER(); } @@ -2063,6 +2226,7 @@ PacketBufferHandle encodeDoorLockClusterSetUserTypeCommand(uint8_t seqNum, Endpo uint8_t userType) { COMMAND_HEADER("SetUserType", DOOR_LOCK_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand).Put8(seqNum).Put8(ZCL_SET_USER_TYPE_COMMAND_ID).Put16(userId).Put8(userType); COMMAND_FOOTER(); } @@ -2076,6 +2240,7 @@ PacketBufferHandle encodeDoorLockClusterSetWeekdayScheduleCommand(uint8_t seqNum uint8_t endMinute) { COMMAND_HEADER("SetWeekdaySchedule", DOOR_LOCK_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_SET_WEEKDAY_SCHEDULE_COMMAND_ID) @@ -2097,6 +2262,7 @@ PacketBufferHandle encodeDoorLockClusterSetYeardayScheduleCommand(uint8_t seqNum uint32_t localEndTime) { COMMAND_HEADER("SetYeardaySchedule", DOOR_LOCK_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_SET_YEARDAY_SCHEDULE_COMMAND_ID) @@ -2110,20 +2276,21 @@ PacketBufferHandle encodeDoorLockClusterSetYeardayScheduleCommand(uint8_t seqNum /* * Command UnlockDoor */ -PacketBufferHandle encodeDoorLockClusterUnlockDoorCommand(uint8_t seqNum, EndpointId destinationEndpoint, char * pin) +PacketBufferHandle encodeDoorLockClusterUnlockDoorCommand(uint8_t seqNum, EndpointId destinationEndpoint, chip::ByteSpan pin) { COMMAND_HEADER("UnlockDoor", DOOR_LOCK_CLUSTER_ID); - size_t pinStrLen = strlen(pin); + size_t pinStrLen = pin.size(); if (!CanCastTo(pinStrLen)) { ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, pinStrLen); return PacketBufferHandle(); } + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_UNLOCK_DOOR_COMMAND_ID) .Put(static_cast(pinStrLen)) - .Put(pin); + .Put(pin.data(), pin.size()); COMMAND_FOOTER(); } @@ -2131,21 +2298,23 @@ PacketBufferHandle encodeDoorLockClusterUnlockDoorCommand(uint8_t seqNum, Endpoi * Command UnlockWithTimeout */ PacketBufferHandle encodeDoorLockClusterUnlockWithTimeoutCommand(uint8_t seqNum, EndpointId destinationEndpoint, - uint16_t timeoutInSeconds, char * pin) + uint16_t timeoutInSeconds, chip::ByteSpan pin) { COMMAND_HEADER("UnlockWithTimeout", DOOR_LOCK_CLUSTER_ID); - size_t pinStrLen = strlen(pin); + + size_t pinStrLen = pin.size(); if (!CanCastTo(pinStrLen)) { ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, pinStrLen); return PacketBufferHandle(); } + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_UNLOCK_WITH_TIMEOUT_COMMAND_ID) .Put16(timeoutInSeconds) .Put(static_cast(pinStrLen)) - .Put(pin); + .Put(pin.data(), pin.size()); COMMAND_FOOTER(); } @@ -2233,6 +2402,7 @@ PacketBufferHandle encodeGeneralCommissioningClusterArmFailSafeCommand(uint8_t s uint32_t timeoutMs) { COMMAND_HEADER("ArmFailSafe", GENERAL_COMMISSIONING_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_ARM_FAIL_SAFE_COMMAND_ID) @@ -2260,22 +2430,26 @@ PacketBufferHandle encodeGeneralCommissioningClusterSetFabricCommand(uint8_t seq uint64_t breadcrumb, uint32_t timeoutMs) { COMMAND_HEADER("SetFabric", GENERAL_COMMISSIONING_CLUSTER_ID); - if (!CanCastTo(fabricId.size())) + size_t fabricIdStrLen = fabricId.size(); + if (!CanCastTo(fabricIdStrLen)) { - ChipLogError(Zcl, "Error encoding %s command. String too long: %zu", kName, fabricId.size()); + ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, fabricIdStrLen); return PacketBufferHandle(); } - if (!CanCastTo(fabricSecret.size())) + + size_t fabricSecretStrLen = fabricSecret.size(); + if (!CanCastTo(fabricSecretStrLen)) { - ChipLogError(Zcl, "Error encoding %s command. String too long: %zu", kName, fabricSecret.size()); + ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, fabricSecretStrLen); return PacketBufferHandle(); } + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_SET_FABRIC_COMMAND_ID) - .Put(static_cast(fabricId.size())) + .Put(static_cast(fabricIdStrLen)) .Put(fabricId.data(), fabricId.size()) - .Put(static_cast(fabricSecret.size())) + .Put(static_cast(fabricSecretStrLen)) .Put(fabricSecret.data(), fabricSecret.size()) .Put64(breadcrumb) .Put32(timeoutMs); @@ -2352,21 +2526,23 @@ PacketBufferHandle encodeGeneralCommissioningClusterReadClusterRevisionAttribute * Command AddGroup */ PacketBufferHandle encodeGroupsClusterAddGroupCommand(uint8_t seqNum, EndpointId destinationEndpoint, uint16_t groupId, - char * groupName) + chip::ByteSpan groupName) { COMMAND_HEADER("AddGroup", GROUPS_CLUSTER_ID); - size_t groupNameStrLen = strlen(groupName); + + size_t groupNameStrLen = groupName.size(); if (!CanCastTo(groupNameStrLen)) { ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, groupNameStrLen); return PacketBufferHandle(); } + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_ADD_GROUP_COMMAND_ID) .Put16(groupId) .Put(static_cast(groupNameStrLen)) - .Put(groupName); + .Put(groupName.data(), groupName.size()); COMMAND_FOOTER(); } @@ -2374,21 +2550,23 @@ PacketBufferHandle encodeGroupsClusterAddGroupCommand(uint8_t seqNum, EndpointId * Command AddGroupIfIdentifying */ PacketBufferHandle encodeGroupsClusterAddGroupIfIdentifyingCommand(uint8_t seqNum, EndpointId destinationEndpoint, uint16_t groupId, - char * groupName) + chip::ByteSpan groupName) { COMMAND_HEADER("AddGroupIfIdentifying", GROUPS_CLUSTER_ID); - size_t groupNameStrLen = strlen(groupName); + + size_t groupNameStrLen = groupName.size(); if (!CanCastTo(groupNameStrLen)) { ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, groupNameStrLen); return PacketBufferHandle(); } + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_ADD_GROUP_IF_IDENTIFYING_COMMAND_ID) .Put16(groupId) .Put(static_cast(groupNameStrLen)) - .Put(groupName); + .Put(groupName.data(), groupName.size()); COMMAND_FOOTER(); } @@ -2399,6 +2577,7 @@ PacketBufferHandle encodeGroupsClusterGetGroupMembershipCommand(uint8_t seqNum, uint16_t groupList) { COMMAND_HEADER("GetGroupMembership", GROUPS_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_GET_GROUP_MEMBERSHIP_COMMAND_ID) @@ -2423,6 +2602,7 @@ PacketBufferHandle encodeGroupsClusterRemoveAllGroupsCommand(uint8_t seqNum, End PacketBufferHandle encodeGroupsClusterRemoveGroupCommand(uint8_t seqNum, EndpointId destinationEndpoint, uint16_t groupId) { COMMAND_HEADER("RemoveGroup", GROUPS_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand).Put8(seqNum).Put8(ZCL_REMOVE_GROUP_COMMAND_ID).Put16(groupId); COMMAND_FOOTER(); } @@ -2433,6 +2613,7 @@ PacketBufferHandle encodeGroupsClusterRemoveGroupCommand(uint8_t seqNum, Endpoin PacketBufferHandle encodeGroupsClusterViewGroupCommand(uint8_t seqNum, EndpointId destinationEndpoint, uint16_t groupId) { COMMAND_HEADER("ViewGroup", GROUPS_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand).Put8(seqNum).Put8(ZCL_VIEW_GROUP_COMMAND_ID).Put16(groupId); COMMAND_FOOTER(); } @@ -2576,6 +2757,7 @@ PacketBufferHandle encodeIasZoneClusterReadClusterRevisionAttribute(uint8_t seqN PacketBufferHandle encodeIdentifyClusterIdentifyCommand(uint8_t seqNum, EndpointId destinationEndpoint, uint16_t identifyTime) { COMMAND_HEADER("Identify", IDENTIFY_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand).Put8(seqNum).Put8(ZCL_IDENTIFY_COMMAND_ID).Put16(identifyTime); COMMAND_FOOTER(); } @@ -2655,6 +2837,7 @@ PacketBufferHandle encodeLevelControlClusterMoveCommand(uint8_t seqNum, Endpoint uint8_t rate, uint8_t optionMask, uint8_t optionOverride) { COMMAND_HEADER("Move", LEVEL_CONTROL_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_MOVE_COMMAND_ID) @@ -2672,6 +2855,7 @@ PacketBufferHandle encodeLevelControlClusterMoveToLevelCommand(uint8_t seqNum, E uint16_t transitionTime, uint8_t optionMask, uint8_t optionOverride) { COMMAND_HEADER("MoveToLevel", LEVEL_CONTROL_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_MOVE_TO_LEVEL_COMMAND_ID) @@ -2689,6 +2873,7 @@ PacketBufferHandle encodeLevelControlClusterMoveToLevelWithOnOffCommand(uint8_t uint8_t level, uint16_t transitionTime) { COMMAND_HEADER("MoveToLevelWithOnOff", LEVEL_CONTROL_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_MOVE_TO_LEVEL_WITH_ON_OFF_COMMAND_ID) @@ -2704,6 +2889,7 @@ PacketBufferHandle encodeLevelControlClusterMoveWithOnOffCommand(uint8_t seqNum, uint8_t rate) { COMMAND_HEADER("MoveWithOnOff", LEVEL_CONTROL_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand).Put8(seqNum).Put8(ZCL_MOVE_WITH_ON_OFF_COMMAND_ID).Put8(moveMode).Put8(rate); COMMAND_FOOTER(); } @@ -2716,6 +2902,7 @@ PacketBufferHandle encodeLevelControlClusterStepCommand(uint8_t seqNum, Endpoint uint8_t optionOverride) { COMMAND_HEADER("Step", LEVEL_CONTROL_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_STEP_COMMAND_ID) @@ -2734,6 +2921,7 @@ PacketBufferHandle encodeLevelControlClusterStepWithOnOffCommand(uint8_t seqNum, uint8_t stepSize, uint16_t transitionTime) { COMMAND_HEADER("StepWithOnOff", LEVEL_CONTROL_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_STEP_WITH_ON_OFF_COMMAND_ID) @@ -2750,6 +2938,7 @@ PacketBufferHandle encodeLevelControlClusterStopCommand(uint8_t seqNum, Endpoint uint8_t optionOverride) { COMMAND_HEADER("Stop", LEVEL_CONTROL_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand).Put8(seqNum).Put8(ZCL_STOP_COMMAND_ID).Put8(optionMask).Put8(optionOverride); COMMAND_FOOTER(); } @@ -3018,15 +3207,17 @@ PacketBufferHandle encodeNetworkCommissioningClusterAddThreadNetworkCommand(uint uint32_t timeoutMs) { COMMAND_HEADER("AddThreadNetwork", NETWORK_COMMISSIONING_CLUSTER_ID); - if (!CanCastTo(operationalDataset.size())) + size_t operationalDatasetStrLen = operationalDataset.size(); + if (!CanCastTo(operationalDatasetStrLen)) { - ChipLogError(Zcl, "Error encoding %s command. String too long: %zu", kName, operationalDataset.size()); + ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, operationalDatasetStrLen); return PacketBufferHandle(); } + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_ADD_THREAD_NETWORK_COMMAND_ID) - .Put(static_cast(operationalDataset.size())) + .Put(static_cast(operationalDatasetStrLen)) .Put(operationalDataset.data(), operationalDataset.size()) .Put64(breadcrumb) .Put32(timeoutMs); @@ -3041,22 +3232,26 @@ PacketBufferHandle encodeNetworkCommissioningClusterAddWiFiNetworkCommand(uint8_ uint64_t breadcrumb, uint32_t timeoutMs) { COMMAND_HEADER("AddWiFiNetwork", NETWORK_COMMISSIONING_CLUSTER_ID); - if (!CanCastTo(ssid.size())) + size_t ssidStrLen = ssid.size(); + if (!CanCastTo(ssidStrLen)) { - ChipLogError(Zcl, "Error encoding %s command. String too long: %zu", kName, ssid.size()); + ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, ssidStrLen); return PacketBufferHandle(); } - if (!CanCastTo(credentials.size())) + + size_t credentialsStrLen = credentials.size(); + if (!CanCastTo(credentialsStrLen)) { - ChipLogError(Zcl, "Error encoding %s command. String too long: %zu", kName, credentials.size()); + ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, credentialsStrLen); return PacketBufferHandle(); } + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_ADD_WI_FI_NETWORK_COMMAND_ID) - .Put(static_cast(ssid.size())) + .Put(static_cast(ssidStrLen)) .Put(ssid.data(), ssid.size()) - .Put(static_cast(credentials.size())) + .Put(static_cast(credentialsStrLen)) .Put(credentials.data(), credentials.size()) .Put64(breadcrumb) .Put32(timeoutMs); @@ -3071,15 +3266,17 @@ PacketBufferHandle encodeNetworkCommissioningClusterDisableNetworkCommand(uint8_ uint32_t timeoutMs) { COMMAND_HEADER("DisableNetwork", NETWORK_COMMISSIONING_CLUSTER_ID); - if (!CanCastTo(networkID.size())) + size_t networkIDStrLen = networkID.size(); + if (!CanCastTo(networkIDStrLen)) { - ChipLogError(Zcl, "Error encoding %s command. String too long: %zu", kName, networkID.size()); + ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, networkIDStrLen); return PacketBufferHandle(); } + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_DISABLE_NETWORK_COMMAND_ID) - .Put(static_cast(networkID.size())) + .Put(static_cast(networkIDStrLen)) .Put(networkID.data(), networkID.size()) .Put64(breadcrumb) .Put32(timeoutMs); @@ -3094,15 +3291,17 @@ PacketBufferHandle encodeNetworkCommissioningClusterEnableNetworkCommand(uint8_t uint32_t timeoutMs) { COMMAND_HEADER("EnableNetwork", NETWORK_COMMISSIONING_CLUSTER_ID); - if (!CanCastTo(networkID.size())) + size_t networkIDStrLen = networkID.size(); + if (!CanCastTo(networkIDStrLen)) { - ChipLogError(Zcl, "Error encoding %s command. String too long: %zu", kName, networkID.size()); + ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, networkIDStrLen); return PacketBufferHandle(); } + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_ENABLE_NETWORK_COMMAND_ID) - .Put(static_cast(networkID.size())) + .Put(static_cast(networkIDStrLen)) .Put(networkID.data(), networkID.size()) .Put64(breadcrumb) .Put32(timeoutMs); @@ -3117,6 +3316,7 @@ PacketBufferHandle encodeNetworkCommissioningClusterGetLastNetworkCommissioningR uint32_t timeoutMs) { COMMAND_HEADER("GetLastNetworkCommissioningResult", NETWORK_COMMISSIONING_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID) @@ -3132,15 +3332,17 @@ PacketBufferHandle encodeNetworkCommissioningClusterRemoveNetworkCommand(uint8_t uint32_t timeoutMs) { COMMAND_HEADER("RemoveNetwork", NETWORK_COMMISSIONING_CLUSTER_ID); - if (!CanCastTo(networkID.size())) + size_t networkIDStrLen = networkID.size(); + if (!CanCastTo(networkIDStrLen)) { - ChipLogError(Zcl, "Error encoding %s command. String too long: %zu", kName, networkID.size()); + ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, networkIDStrLen); return PacketBufferHandle(); } + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_REMOVE_NETWORK_COMMAND_ID) - .Put(static_cast(networkID.size())) + .Put(static_cast(networkIDStrLen)) .Put(networkID.data(), networkID.size()) .Put64(breadcrumb) .Put32(timeoutMs); @@ -3155,15 +3357,17 @@ PacketBufferHandle encodeNetworkCommissioningClusterScanNetworksCommand(uint8_t uint32_t timeoutMs) { COMMAND_HEADER("ScanNetworks", NETWORK_COMMISSIONING_CLUSTER_ID); - if (!CanCastTo(ssid.size())) + size_t ssidStrLen = ssid.size(); + if (!CanCastTo(ssidStrLen)) { - ChipLogError(Zcl, "Error encoding %s command. String too long: %zu", kName, ssid.size()); + ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, ssidStrLen); return PacketBufferHandle(); } + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_SCAN_NETWORKS_COMMAND_ID) - .Put(static_cast(ssid.size())) + .Put(static_cast(ssidStrLen)) .Put(ssid.data(), ssid.size()) .Put64(breadcrumb) .Put32(timeoutMs); @@ -3178,15 +3382,17 @@ PacketBufferHandle encodeNetworkCommissioningClusterUpdateThreadNetworkCommand(u uint64_t breadcrumb, uint32_t timeoutMs) { COMMAND_HEADER("UpdateThreadNetwork", NETWORK_COMMISSIONING_CLUSTER_ID); - if (!CanCastTo(operationalDataset.size())) + size_t operationalDatasetStrLen = operationalDataset.size(); + if (!CanCastTo(operationalDatasetStrLen)) { - ChipLogError(Zcl, "Error encoding %s command. String too long: %zu", kName, operationalDataset.size()); + ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, operationalDatasetStrLen); return PacketBufferHandle(); } + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID) - .Put(static_cast(operationalDataset.size())) + .Put(static_cast(operationalDatasetStrLen)) .Put(operationalDataset.data(), operationalDataset.size()) .Put64(breadcrumb) .Put32(timeoutMs); @@ -3201,22 +3407,26 @@ PacketBufferHandle encodeNetworkCommissioningClusterUpdateWiFiNetworkCommand(uin uint64_t breadcrumb, uint32_t timeoutMs) { COMMAND_HEADER("UpdateWiFiNetwork", NETWORK_COMMISSIONING_CLUSTER_ID); - if (!CanCastTo(ssid.size())) + size_t ssidStrLen = ssid.size(); + if (!CanCastTo(ssidStrLen)) { - ChipLogError(Zcl, "Error encoding %s command. String too long: %zu", kName, ssid.size()); + ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, ssidStrLen); return PacketBufferHandle(); } - if (!CanCastTo(credentials.size())) + + size_t credentialsStrLen = credentials.size(); + if (!CanCastTo(credentialsStrLen)) { - ChipLogError(Zcl, "Error encoding %s command. String too long: %zu", kName, credentials.size()); + ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, credentialsStrLen); return PacketBufferHandle(); } + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID) - .Put(static_cast(ssid.size())) + .Put(static_cast(ssidStrLen)) .Put(ssid.data(), ssid.size()) - .Put(static_cast(credentials.size())) + .Put(static_cast(credentialsStrLen)) .Put(credentials.data(), credentials.size()) .Put64(breadcrumb) .Put32(timeoutMs); @@ -3350,16 +3560,18 @@ PacketBufferHandle encodeOnOffClusterReadClusterRevisionAttribute(uint8_t seqNum * Command AddScene */ PacketBufferHandle encodeScenesClusterAddSceneCommand(uint8_t seqNum, EndpointId destinationEndpoint, uint16_t groupId, - uint8_t sceneId, uint16_t transitionTime, char * sceneName, + uint8_t sceneId, uint16_t transitionTime, chip::ByteSpan sceneName, chip::ClusterId clusterId, uint8_t length, uint8_t value) { COMMAND_HEADER("AddScene", SCENES_CLUSTER_ID); - size_t sceneNameStrLen = strlen(sceneName); + + size_t sceneNameStrLen = sceneName.size(); if (!CanCastTo(sceneNameStrLen)) { ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, sceneNameStrLen); return PacketBufferHandle(); } + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_ADD_SCENE_COMMAND_ID) @@ -3367,7 +3579,7 @@ PacketBufferHandle encodeScenesClusterAddSceneCommand(uint8_t seqNum, EndpointId .Put8(sceneId) .Put16(transitionTime) .Put(static_cast(sceneNameStrLen)) - .Put(sceneName) + .Put(sceneName.data(), sceneName.size()) .Put16(clusterId) .Put8(length) .Put8(value); @@ -3380,6 +3592,7 @@ PacketBufferHandle encodeScenesClusterAddSceneCommand(uint8_t seqNum, EndpointId PacketBufferHandle encodeScenesClusterGetSceneMembershipCommand(uint8_t seqNum, EndpointId destinationEndpoint, uint16_t groupId) { COMMAND_HEADER("GetSceneMembership", SCENES_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand).Put8(seqNum).Put8(ZCL_GET_SCENE_MEMBERSHIP_COMMAND_ID).Put16(groupId); COMMAND_FOOTER(); } @@ -3391,6 +3604,7 @@ PacketBufferHandle encodeScenesClusterRecallSceneCommand(uint8_t seqNum, Endpoin uint8_t sceneId, uint16_t transitionTime) { COMMAND_HEADER("RecallScene", SCENES_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand) .Put8(seqNum) .Put8(ZCL_RECALL_SCENE_COMMAND_ID) @@ -3406,6 +3620,7 @@ PacketBufferHandle encodeScenesClusterRecallSceneCommand(uint8_t seqNum, Endpoin PacketBufferHandle encodeScenesClusterRemoveAllScenesCommand(uint8_t seqNum, EndpointId destinationEndpoint, uint16_t groupId) { COMMAND_HEADER("RemoveAllScenes", SCENES_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand).Put8(seqNum).Put8(ZCL_REMOVE_ALL_SCENES_COMMAND_ID).Put16(groupId); COMMAND_FOOTER(); } @@ -3417,6 +3632,7 @@ PacketBufferHandle encodeScenesClusterRemoveSceneCommand(uint8_t seqNum, Endpoin uint8_t sceneId) { COMMAND_HEADER("RemoveScene", SCENES_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand).Put8(seqNum).Put8(ZCL_REMOVE_SCENE_COMMAND_ID).Put16(groupId).Put8(sceneId); COMMAND_FOOTER(); } @@ -3428,6 +3644,7 @@ PacketBufferHandle encodeScenesClusterStoreSceneCommand(uint8_t seqNum, Endpoint uint8_t sceneId) { COMMAND_HEADER("StoreScene", SCENES_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand).Put8(seqNum).Put8(ZCL_STORE_SCENE_COMMAND_ID).Put16(groupId).Put8(sceneId); COMMAND_FOOTER(); } @@ -3439,6 +3656,7 @@ PacketBufferHandle encodeScenesClusterViewSceneCommand(uint8_t seqNum, EndpointI uint8_t sceneId) { COMMAND_HEADER("ViewScene", SCENES_CLUSTER_ID); + buf.Put8(kFrameControlClusterSpecificCommand).Put8(seqNum).Put8(ZCL_VIEW_SCENE_COMMAND_ID).Put16(groupId).Put8(sceneId); COMMAND_FOOTER(); } diff --git a/src/app/zap-templates/common/StringHelper.js b/src/app/zap-templates/common/StringHelper.js index 030082bdf9585b..b3bc6f57a1d6a3 100644 --- a/src/app/zap-templates/common/StringHelper.js +++ b/src/app/zap-templates/common/StringHelper.js @@ -15,40 +15,41 @@ * limitations under the License. */ -const stringShortTypes = [ 'CHAR_STRING', 'OCTET_STRING' ]; -const stringLongTypes = [ 'LONG_CHAR_STRING', 'LONG_OCTET_STRING' ]; -const stringBytesTypes = [ 'OCTET_STRING', 'LONG_OCTET_STRING' ]; +const characterStringTypes = [ 'CHAR_STRING', 'LONG_CHAR_STRING' ]; +const octetStringTypes = [ 'OCTET_STRING', 'LONG_OCTET_STRING' ]; +const stringShortTypes = [ 'CHAR_STRING', 'OCTET_STRING' ]; +const stringLongTypes = [ 'LONG_CHAR_STRING', 'LONG_OCTET_STRING' ]; -function isShortString(type) +function isString(type) { - return stringShortTypes.includes(type); + return isCharString(type) || isOctetString(type); } -function isLongString(type) +function isCharString(type) { - return stringLongTypes.includes(type); + return characterStringTypes.includes(type.toUpperCase()); } -function isByteString(type) +function isOctetString(type) { - return stringBytesTypes.includes(type); + return octetStringTypes.includes(type.toUpperCase()); } -function isString(type) +function isShortString(type) { - return isShortString(type) || isLongString(type); + return stringShortTypes.includes(type.toUpperCase()); } -function isCharString(type) +function isLongString(type) { - return isString(type) && !isByteString(type); + return stringLongTypes.includes(type.toUpperCase()); } // // Module exports // exports.isString = isString; +exports.isCharString = isCharString; +exports.isOctetString = isOctetString; exports.isShortString = isShortString; exports.isLongString = isLongString; -exports.isByteString = isByteString; -exports.isCharString = isCharString; diff --git a/src/app/zap-templates/templates/app/CHIPClientCallbacks-src.zapt b/src/app/zap-templates/templates/app/CHIPClientCallbacks-src.zapt index 6316465286a44b..947b71108d30b7 100644 --- a/src/app/zap-templates/templates/app/CHIPClientCallbacks-src.zapt +++ b/src/app/zap-templates/templates/app/CHIPClientCallbacks-src.zapt @@ -253,10 +253,6 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag case 0x38: // semi / Semi-precision case 0x39: // single / Single precision case 0x3A: // double / Double precision - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string case 0x48: // array / Array case 0x49: // struct / Structure case 0x50: // set / Set @@ -269,6 +265,46 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag return true; } + case 0x41: // octstr / Octet string + case 0x42: // string / Character string + { + // Short Strings must contains at least one byte for the length + CHECK_MESSAGE_LENGTH(1); + uint8_t length = chip::Encoding::Read8(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + + case 0x43: // octstr16 / Long octet string + case 0x44: // string16 / Long character string + { + // Long Strings must contains at least two bytes for the length + CHECK_MESSAGE_LENGTH(2); + uint16_t length = chip::Encoding::LittleEndian::Read16(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFFFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFFFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + case 0x08: // data8 / 8-bit data case 0x18: // map8 / 8-bit bitmap case 0x20: // uint8 / Unsigned 8-bit integer @@ -704,10 +740,6 @@ bool emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * message, uin case 0x38: // semi / Semi-precision case 0x39: // single / Single precision case 0x3A: // double / Double precision - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string case 0x48: // array / Array case 0x49: // struct / Structure case 0x50: // set / Set @@ -718,6 +750,46 @@ bool emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * message, uin return true; } + case 0x41: // octstr / Octet string + case 0x42: // string / Character string + { + // Short Strings must contains at least one byte for the length + CHECK_MESSAGE_LENGTH(1); + uint8_t length = chip::Encoding::Read8(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = Callback::Callback::FromCancelable(onReportCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + + case 0x43: // octstr16 / Long octet string + case 0x44: // string16 / Long character string + { + // Long Strings must contains at least two bytes for the length + CHECK_MESSAGE_LENGTH(2); + uint16_t length = chip::Encoding::LittleEndian::Read16(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFFFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFFFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = Callback::Callback::FromCancelable(onReportCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + case 0x08: // data8 / 8-bit data case 0x18: // map8 / 8-bit bitmap case 0x20: // uint8 / Unsigned 8-bit integer diff --git a/src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt b/src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt index a0804d8ae0fbb7..898af4c7f9f866 100644 --- a/src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt +++ b/src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt @@ -3,6 +3,7 @@ #pragma once #include +#include // Global Response Callbacks typedef void (*DefaultSuccessCallback)(void * context); @@ -16,6 +17,7 @@ typedef void (*Int32uAttributeCallback)(void * context, uint32_t value); typedef void (*Int32sAttributeCallback)(void * context, int32_t value); typedef void (*Int64uAttributeCallback)(void * context, uint64_t value); typedef void (*Int64sAttributeCallback)(void * context, int64_t value); +typedef void (*StringAttributeCallback)(void * context, const chip::ByteSpan value); typedef void (*ReadReportingConfigurationReportedCallback)(void* context, uint16_t minInterval, uint16_t maxInterval); typedef void (*ReadReportingConfigurationReceivedCallback)(void* context, uint16_t timeout); diff --git a/src/app/zap-templates/templates/chip/CHIPClusters-src.zapt b/src/app/zap-templates/templates/chip/CHIPClusters-src.zapt index b06cb3c7832109..62126b5d3a84ed 100644 --- a/src/app/zap-templates/templates/chip/CHIPClusters-src.zapt +++ b/src/app/zap-templates/templates/chip/CHIPClusters-src.zapt @@ -77,7 +77,7 @@ CHIP_ERROR {{asCamelCased parent.name false}}Cluster::ReadAttribute{{asCamelCase } {{#if (isWritableAttribute)}} -CHIP_ERROR {{asCamelCased parent.name false}}Cluster::WriteAttribute{{asCamelCased name false}}(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, {{asUnderlyingZclType type}} value) +CHIP_ERROR {{asCamelCased parent.name false}}Cluster::WriteAttribute{{asCamelCased name false}}(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, {{chipType}} value) { uint8_t seqNum = mDevice->GetNextSequenceNumber(); System::PacketBufferHandle encodedCommand = encode{{asCamelCased parent.name false}}ClusterWrite{{asCamelCased name false}}Attribute(seqNum, mEndpoint, value); diff --git a/src/app/zap-templates/templates/chip/CHIPClusters.zapt b/src/app/zap-templates/templates/chip/CHIPClusters.zapt index 01da2a2a10a95f..0d3e1084562240 100644 --- a/src/app/zap-templates/templates/chip/CHIPClusters.zapt +++ b/src/app/zap-templates/templates/chip/CHIPClusters.zapt @@ -35,7 +35,7 @@ public: {{/chip_server_cluster_attributes}} {{#chip_server_cluster_attributes}} {{#if (isWritableAttribute)}} - CHIP_ERROR WriteAttribute{{asCamelCased name false}}(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, {{asUnderlyingZclType type}} value); + CHIP_ERROR WriteAttribute{{asCamelCased name false}}(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, {{chipType}} value); {{/if}} {{/chip_server_cluster_attributes}} {{#chip_server_cluster_attributes}} diff --git a/src/app/zap-templates/templates/chip/CHIPClustersObjc-src.zapt b/src/app/zap-templates/templates/chip/CHIPClustersObjc-src.zapt index 32c269f7a3a91d..4a0ec37eae11f7 100644 --- a/src/app/zap-templates/templates/chip/CHIPClustersObjc-src.zapt +++ b/src/app/zap-templates/templates/chip/CHIPClustersObjc-src.zapt @@ -70,24 +70,40 @@ private: dispatch_queue_t mQueue; }; -class CHIPUnsupportedAttributeCallbackBridge : public Callback::Callback { +class CHIPStringAttributeCallbackBridge : public Callback::Callback { public: - CHIPUnsupportedAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) - : Callback::Callback(CallbackFn, this) + CHIPStringAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool octetString, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mOctetString(octetString) + , mKeepAlive(keepAlive) { } - ~CHIPUnsupportedAttributeCallbackBridge() {}; + ~CHIPStringAttributeCallbackBridge() {}; - static void CallbackFn(void * context) + static void CallbackFn(void * context, chip::ByteSpan value) { - CHIPUnsupportedAttributeCallbackBridge * callback = reinterpret_cast(context); + CHIPStringAttributeCallbackBridge * callback = reinterpret_cast(context); if (callback && callback->mQueue) { dispatch_async(callback->mQueue, ^{ - NSError* error = [NSError errorWithDomain:CHIPErrorDomain code:CHIPErrorCodeUndefinedError userInfo:@{NSLocalizedDescriptionKey:@"Unsupported attribute type"}]; - callback->mHandler(error, nil); - callback->Cancel(); - delete callback; + if (callback->mOctetString) + { + NSData *data = [NSData dataWithBytes: value.data() length: value.size()]; + callback->mHandler(nil, @{ @"value": data }); + } + else + { + NSString * str = [[NSString alloc] initWithBytes:value.data() length:value.size() encoding:NSUTF8StringEncoding]; + callback->mHandler(nil, @{ @"value": str }); + } + + if (!callback->mKeepAlive) + { + callback->Cancel(); + delete callback; + } }); } }; @@ -95,6 +111,8 @@ public: private: ResponseHandler mHandler; dispatch_queue_t mQueue; + bool mOctetString; + bool mKeepAlive; }; class CHIPBooleanAttributeCallbackBridge : public Callback::Callback { @@ -229,6 +247,39 @@ private: bool mKeepAlive; }; +class CHIPInt32uAttributeCallbackBridge : public Callback::Callback { +public: + CHIPInt32uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mKeepAlive(keepAlive) + { + } + + ~CHIPInt32uAttributeCallbackBridge() {}; + + static void CallbackFn(void * context, uint32_t value) + { + CHIPInt32uAttributeCallbackBridge * callback = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @{ @"value": [NSNumber numberWithUnsignedLong:value] }); + if (!callback->mKeepAlive) + { + callback->Cancel(); + delete callback; + } + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; + bool mKeepAlive; +}; + class CHIPInt16sAttributeCallbackBridge : public Callback::Callback { public: CHIPInt16sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) @@ -360,7 +411,7 @@ private: {{#chip_server_cluster_commands}} {{#if (zcl_command_arguments_count this.id)}} -- (void){{asCamelCased name}}:{{#chip_server_cluster_command_arguments}}{{#if (isFirstElement index)}}{{else}}{{asCamelCased label}}:{{/if}}({{#if (isByteString type)}}NSData *{{else}}{{asBasicType chipType}}{{/if}}){{asCamelCased label}} {{/chip_server_cluster_command_arguments}}completionHandler:(ResponseHandler)completionHandler +- (void){{asCamelCased name}}:{{#chip_server_cluster_command_arguments}}{{#if (isFirstElement index)}}{{else}}{{asCamelCased label}}:{{/if}}({{asObjectiveCBasicType type}}){{asCamelCased label}} {{/chip_server_cluster_command_arguments}}completionHandler:(ResponseHandler)completionHandler {{else}} - (void){{asCamelCased name}}:(ResponseHandler)completionHandler {{/if}} @@ -382,7 +433,7 @@ private: return; } - CHIP_ERROR err = self.cppCluster.{{asCamelCased name false}}(onSuccess->Cancel(), onFailure->Cancel(){{#chip_server_cluster_command_arguments}}, {{#if (isByteString type)}}chip::ByteSpan((const uint8_t*){{asCamelCased label}}.bytes, {{asCamelCased label}}.length){{else}}{{asCamelCased label}}{{/if}}{{/chip_server_cluster_command_arguments}}); + CHIP_ERROR err = self.cppCluster.{{asCamelCased name false}}(onSuccess->Cancel(), onFailure->Cancel(){{#chip_server_cluster_command_arguments}}, {{#if (isOctetString type)}}chip::ByteSpan((const uint8_t*){{asCamelCased label}}.bytes, {{asCamelCased label}}.length){{else if (isCharString type)}}chip::ByteSpan((const uint8_t*)[{{asCamelCased label}} dataUsingEncoding:NSUTF8StringEncoding].bytes, [{{asCamelCased label}} lengthOfBytesUsingEncoding:NSUTF8StringEncoding]){{else}}{{asCamelCased label}}{{/if}}{{/chip_server_cluster_command_arguments}}); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -394,7 +445,7 @@ private: {{#chip_server_cluster_attributes}} - (void)readAttribute{{asCamelCased name false}}:(ResponseHandler)completionHandler { - CHIP{{asCallbackAttributeType atomicTypeId}}AttributeCallbackBridge * onSuccess = new CHIP{{asCallbackAttributeType atomicTypeId}}AttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIP{{asCallbackAttributeType atomicTypeId}}AttributeCallbackBridge * onSuccess = new CHIP{{asCallbackAttributeType atomicTypeId}}AttributeCallbackBridge(completionHandler, [self callbackQueue]{{#if (isString type)}},{{#if (isOctetString type)}}true{{else}}false{{/if}}{{/if}}); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -416,7 +467,7 @@ private: } {{#if (isWritableAttribute)}} -- (void)writeAttribute{{asCamelCased name false}}:({{asUnderlyingZclType type}})value completionHandler:(ResponseHandler)completionHandler +- (void)writeAttribute{{asCamelCased name false}}:({{asObjectiveCBasicType type}})value completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -431,7 +482,14 @@ private: return; } + {{#if (isOctetString type)}} + CHIP_ERROR err = self.cppCluster.WriteAttribute{{asCamelCased name false}}(onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t*)value.bytes, value.length)); + {{else if (isCharString type)}} + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + CHIP_ERROR err = self.cppCluster.WriteAttribute{{asCamelCased name false}}(onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t*)data.bytes, data.length)); + {{else}} CHIP_ERROR err = self.cppCluster.WriteAttribute{{asCamelCased name false}}(onSuccess->Cancel(), onFailure->Cancel(), value); + {{/if}} if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -467,7 +525,7 @@ private: - (void) reportAttribute{{asCamelCased name false}}:(ResponseHandler)reportHandler { - CHIP{{asCallbackAttributeType atomicTypeId}}AttributeCallbackBridge * onReport = new CHIP{{asCallbackAttributeType atomicTypeId}}AttributeCallbackBridge(reportHandler, [self callbackQueue], true); + CHIP{{asCallbackAttributeType atomicTypeId}}AttributeCallbackBridge * onReport = new CHIP{{asCallbackAttributeType atomicTypeId}}AttributeCallbackBridge(reportHandler, [self callbackQueue]{{#if (isString type)}},{{#if (isOctetString type)}}true{{else}}false{{/if}}{{/if}}, true); if (!onReport) { reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; diff --git a/src/app/zap-templates/templates/chip/CHIPClustersObjc.zapt b/src/app/zap-templates/templates/chip/CHIPClustersObjc.zapt index 45d3b6bebe984a..9ef083ab1fce28 100644 --- a/src/app/zap-templates/templates/chip/CHIPClustersObjc.zapt +++ b/src/app/zap-templates/templates/chip/CHIPClustersObjc.zapt @@ -34,7 +34,7 @@ NS_ASSUME_NONNULL_BEGIN {{#chip_server_cluster_commands}} {{#if (zcl_command_arguments_count this.id)}} -- (void){{asCamelCased name}}:{{#chip_server_cluster_command_arguments}}{{#if (isFirstElement index)}}{{else}}{{asCamelCased label}}:{{/if}}({{#if (isByteString type)}}NSData *{{else}}{{asBasicType chipType}}{{/if}}){{asCamelCased label}} {{/chip_server_cluster_command_arguments}}completionHandler:(ResponseHandler)completionHandler; +- (void){{asCamelCased name}}:{{#chip_server_cluster_command_arguments}}{{#if (isFirstElement index)}}{{else}}{{asCamelCased label}}:{{/if}}({{asObjectiveCBasicType type}}){{asCamelCased label}} {{/chip_server_cluster_command_arguments}}completionHandler:(ResponseHandler)completionHandler; {{else}} - (void){{asCamelCased name}}:(ResponseHandler)completionHandler; {{/if}} @@ -43,7 +43,7 @@ NS_ASSUME_NONNULL_BEGIN {{#chip_server_cluster_attributes}} - (void)readAttribute{{asCamelCased name false}}:(ResponseHandler)completionHandler; {{#if (isWritableAttribute)}} -- (void)writeAttribute{{asCamelCased name false}}:({{asUnderlyingZclType type}})value completionHandler:(ResponseHandler)completionHandler; +- (void)writeAttribute{{asCamelCased name false}}:({{asObjectiveCBasicType type}})value completionHandler:(ResponseHandler)completionHandler; {{/if}} {{#if (isReportableAttribute)}} - (void) configureAttribute{{asCamelCased name false}}:(uint16_t)minInterval maxInterval:(uint16_t)maxInterval{{#unless (isDiscreteType)}} change:({{chipType}})change{{/unless}} completionHandler:(ResponseHandler)completionHandler; diff --git a/src/app/zap-templates/templates/chip/chip-zcl-zpro-codec-api.zapt b/src/app/zap-templates/templates/chip/chip-zcl-zpro-codec-api.zapt index e4f285ae489085..fe9d388fa6ada9 100644 --- a/src/app/zap-templates/templates/chip/chip-zcl-zpro-codec-api.zapt +++ b/src/app/zap-templates/templates/chip/chip-zcl-zpro-codec-api.zapt @@ -39,7 +39,7 @@ chip::System::PacketBufferHandle encode{{asCamelCased parent.name false}}Cluster * @brief * Encode a {{parent.name}} server write command for the {{name}} attribute into buffer including the APS frame */ -chip::System::PacketBufferHandle encode{{asCamelCased parent.name false}}ClusterWrite{{asCamelCased name false}}Attribute(uint8_t seqNum, chip::EndpointId destinationEndpoint, {{asUnderlyingZclType type}} {{asCamelCased name}}); +chip::System::PacketBufferHandle encode{{asCamelCased parent.name false}}ClusterWrite{{asCamelCased name false}}Attribute(uint8_t seqNum, chip::EndpointId destinationEndpoint, {{chipType}} {{asCamelCased name}}); {{/if}} {{#if (isReportableAttribute)}} diff --git a/src/app/zap-templates/templates/chip/encoder-src.zapt b/src/app/zap-templates/templates/chip/encoder-src.zapt index 7cc96d217d086c..eccb51867fa7f4 100644 --- a/src/app/zap-templates/templates/chip/encoder-src.zapt +++ b/src/app/zap-templates/templates/chip/encoder-src.zapt @@ -125,20 +125,15 @@ PacketBufferHandle encode{{asCamelCased clusterName false}}Cluster{{asType name} { COMMAND_HEADER("{{asType name}}", {{parent.define}}_ID); {{#chip_server_cluster_command_arguments}} - {{#if (isByteString type)}} - if (!CanCastTo({{asCamelCased label}}.size())) - { - ChipLogError(Zcl, "Error encoding %s command. String too long: %zu", kName, {{asCamelCased label}}.size()); - return PacketBufferHandle(); - } - {{else if (isString type)}} - size_t {{asCamelCased label}}StrLen = strlen({{asCamelCased label}}); - if (!CanCastTo({{asCamelCased label}}StrLen)) + {{#if (isString type)}} + size_t {{asCamelCased label}}StrLen = {{asCamelCased label}}.size(); + if (!CanCastTo<{{#if (isShortString type)}}uint8_t{{else}}uint16_t{{/if}}>({{asCamelCased label}}StrLen)) { ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, {{asCamelCased label}}StrLen); return PacketBufferHandle(); } {{/if}} + {{/chip_server_cluster_command_arguments}} buf {{#if (isManufacturerSpecificCommand)}} @@ -150,12 +145,9 @@ PacketBufferHandle encode{{asCamelCased clusterName false}}Cluster{{asType name} .Put8(seqNum) .Put8(ZCL_{{asDelimitedMacro name}}_COMMAND_ID) {{#chip_server_cluster_command_arguments}} - {{#if (isByteString type)}} - .Put(static_cast({{asCamelCased label}}.size())) + {{#if (isString type)}} + .Put(static_cast<{{#if (isShortString type)}}uint8_t{{else}}uint16_t{{/if}}>({{asCamelCased label}}StrLen)) .Put({{asCamelCased label}}.data(), {{asCamelCased label}}.size()) - {{else if (isString type)}} - .Put(static_cast({{asCamelCased label}}StrLen)) - .Put({{asCamelCased label}}) {{else if (isSignedType)}} .Put{{chipTypePutLength}}(static_cast<{{chipTypePutCastType}}>({{asCamelCased label}})) {{else}} @@ -193,15 +185,30 @@ PacketBufferHandle encode{{asCamelCased parent.name false}}ClusterRead{{asCamelC } {{#if (isWritableAttribute)}} -PacketBufferHandle encode{{asCamelCased parent.name false}}ClusterWrite{{asCamelCased name false}}Attribute(uint8_t seqNum, EndpointId destinationEndpoint, {{asUnderlyingZclType type}} {{asCamelCased name}}) +PacketBufferHandle encode{{asCamelCased parent.name false}}ClusterWrite{{asCamelCased name false}}Attribute(uint8_t seqNum, EndpointId destinationEndpoint, {{chipType}} {{asCamelCased name}}) { COMMAND_HEADER("Write{{asCamelCased parent.name false}}{{asCamelCased name false}}", {{parent.define}}_ID); + {{#if (isString type)}} + size_t {{asCamelCased name}}StrLen = {{asCamelCased name}}.size(); + if (!CanCastTo<{{#if (isShortString type)}}uint8_t{{else}}uint16_t{{/if}}>({{asCamelCased name}}StrLen)) + { + ChipLogError(Zcl, "Error encoding %s command. String too long: %d", kName, {{asCamelCased name}}StrLen); + return PacketBufferHandle(); + } + + {{/if}} buf.Put8(kFrameControlGlobalCommand) .Put8(seqNum) .Put8(ZCL_WRITE_ATTRIBUTES_COMMAND_ID) .Put16({{asHex attributeCode 4}}) .Put8({{atomicTypeId}}) - .Put{{chipTypePutLength}}(static_cast<{{chipTypePutCastType}}>({{asCamelCased name}})); + {{#if (isString type)}} + .Put(static_cast<{{#if (isShortString type)}}uint8_t{{else}}uint16_t{{/if}}>({{asCamelCased name}}StrLen)) + .Put({{asCamelCased name}}.data(), {{asCamelCased name }}StrLen) + {{else}} + .Put{{chipTypePutLength}}(static_cast<{{chipTypePutCastType}}>({{asCamelCased name}})) + {{/if}} + ; COMMAND_FOOTER(); } diff --git a/src/app/zap-templates/templates/chip/helper.js b/src/app/zap-templates/templates/chip/helper.js index 2e6871597314ac..98166fea264c94 100644 --- a/src/app/zap-templates/templates/chip/helper.js +++ b/src/app/zap-templates/templates/chip/helper.js @@ -47,7 +47,7 @@ function asPutLength(zclType) case 'uint64_t': return type.replace(/[^0-9]/g, ''); default: - throw error = 'Unhandled type: ' + zclType; + throw error = 'asPutLength: Unhandled type: ' + zclType; } } @@ -66,7 +66,7 @@ function asPutCastType(zclType) case 'uint64_t': return type; default: - throw error = 'Unhandled type: ' + zclType; + throw error = 'asPutCastType: Unhandled type: ' + zclType; } } @@ -161,13 +161,9 @@ function chip_server_cluster_command_arguments(options) { return Promise.all(args.map(arg => collectItem.call(this, arg, pkgId))).then(items => items.flat()).then(items => { return Promise.all(items.map(item => { - if (StringHelper.isByteString(item.type)) { + if (StringHelper.isString(item.type)) { item.chipType = 'chip::ByteSpan'; return item; - } else if (StringHelper.isString(item.type)) { - // Enhanced the command argument with 'chipType' for conveniences. - item.chipType = 'char *'; - return item; } return zclHelper.asUnderlyingZclType.call(this, item.type, options).then(zclType => { @@ -248,6 +244,13 @@ function getAttributes(pkgId, options) // Enhanced the attribute with 'atomidId', 'discrete', chipType properties for convenience. att.atomicTypeId = atomic.atomicId; att.discrete = atomic.discrete; + + if (StringHelper.isString(att.type)) { + // Enhanced the command argument with 'chipType' for conveniences. + att.chipType = 'chip::ByteSpan'; + return att; + } + return zclHelper.asUnderlyingZclType.call(this, att.type, options).then(zclType => { att.chipType = zclType; return att; @@ -285,8 +288,10 @@ function chip_server_cluster_attributes(options) let isWritable = !!sameAttributes.find(att2 => att2.writable); let isReportable = !!sameAttributes.find(att2 => att2.reportable.included); if (isWritable || isReportable) { - att.chipTypePutLength = asPutLength(att.chipType); - att.chipTypePutCastType = asPutCastType(att.chipType); + if (!StringHelper.isString(att.type)) { + att.chipTypePutLength = asPutLength(att.chipType); + att.chipTypePutCastType = asPutCastType(att.chipType); + } att.writable = isWritable; att.reportable.included = isReportable; } @@ -449,16 +454,20 @@ function asCallbackAttributeType(attributeType) case 0x38: // semi / Semi-precision case 0x39: // single / Single precision case 0x3A: // double / Double precision - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string case 0x48: // array / Array case 0x49: // struct / Structure case 0x50: // set / Set case 0x51: // bag / Bag case 0xE0: // ToD / Time of day + case 0xEA: // bacOID / BACnet OID + case 0xF1: // key128 / 128-bit security key + case 0xFF: // unk / Unknown return 'Unsupported'; + case 0x41: // octstr / Octet string + case 0x42: // string / Character string + case 0x43: // octstr16 / Long octet string + case 0x44: // string16 / Long character string + return 'String'; case 0x08: // data8 / 8-bit data case 0x18: // map8 / 8-bit bitmap case 0x20: // uint8 / Unsigned 8-bit integer @@ -470,9 +479,6 @@ function asCallbackAttributeType(attributeType) case 0x31: // enum16 / 16-bit enumeration case 0xE8: // clusterId / Cluster ID case 0xE9: // attribId / Attribute ID - case 0xEA: // bacOID / BACnet OID - case 0xF1: // key128 / 128-bit security key - case 0xFF: // unk / Unknown return 'Int16u'; case 0x0B: // data32 / 32-bit data case 0x1B: // map32 / 32-bit bitmap @@ -501,6 +507,17 @@ function asCallbackAttributeType(attributeType) } } +function asObjectiveCBasicType(type) +{ + if (StringHelper.isOctetString(type)) { + return 'NSData *'; + } else if (StringHelper.isCharString(type)) { + return 'NSString *'; + } else { + return ChipTypesHelper.asBasicType(this.chipType); + } +} + function asObjectiveCNumberType(label, type) { function fn(pkgId) @@ -548,6 +565,7 @@ exports.chip_server_clusters = chip_server_clusters; exports.chip_server_cluster_commands = chip_server_cluster_commands; exports.chip_server_cluster_command_arguments = chip_server_cluster_command_arguments exports.asBasicType = ChipTypesHelper.asBasicType; +exports.asObjectiveCBasicType = asObjectiveCBasicType; exports.asObjectiveCNumberType = asObjectiveCNumberType; exports.isSignedType = isSignedType; exports.isDiscreteType = isDiscreteType; diff --git a/src/app/zap-templates/templates/chip/python-ChipDeviceController-ClusterCommands.zapt b/src/app/zap-templates/templates/chip/python-ChipDeviceController-ClusterCommands.zapt index c2bf73b40e3036..a886acf593ee60 100644 --- a/src/app/zap-templates/templates/chip/python-ChipDeviceController-ClusterCommands.zapt +++ b/src/app/zap-templates/templates/chip/python-ChipDeviceController-ClusterCommands.zapt @@ -18,13 +18,13 @@ extern "C" { {{#chip_server_clusters}} // Cluster {{asCamelCased name false}} {{#chip_server_cluster_commands}} -CHIP_ERROR chip_ime_AppendCommand_{{asCamelCased clusterName false}}_{{asCamelCased name false}}(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId{{#chip_server_cluster_command_arguments}}, {{#if (isByteString type)}}const uint8_t * {{asCamelCased label}}, uint32_t {{asCamelCased label}}_Len{{else}}{{chipType}} {{asCamelCased label}}{{/if}}{{/chip_server_cluster_command_arguments}}) +CHIP_ERROR chip_ime_AppendCommand_{{asCamelCased clusterName false}}_{{asCamelCased name false}}(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId{{#chip_server_cluster_command_arguments}}, {{#if (isString type)}}const uint8_t * {{asCamelCased label}}, uint32_t {{asCamelCased label}}_Len{{else}}{{chipType}} {{asCamelCased label}}{{/if}}{{/chip_server_cluster_command_arguments}}) { VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); chip::Controller::{{asCamelCased clusterName false}}Cluster cluster{{asCamelCased clusterName false}}; (void) ZCLgroupId; cluster{{asCamelCased clusterName false}}.Associate(device, ZCLendpointId); - return cluster{{asCamelCased clusterName false}}.{{asCamelCased name false}}(nullptr, nullptr{{#chip_server_cluster_command_arguments}}, {{#if (isByteString type)}}chip::ByteSpan({{asCamelCased label}}, {{asCamelCased label}}_Len){{else}}{{asCamelCased label}}{{/if}} + return cluster{{asCamelCased clusterName false}}.{{asCamelCased name false}}(nullptr, nullptr{{#chip_server_cluster_command_arguments}}, {{#if (isString type)}}chip::ByteSpan({{asCamelCased label}}, {{asCamelCased label}}_Len){{else}}{{asCamelCased label}}{{/if}} {{/chip_server_cluster_command_arguments}}); } {{/chip_server_cluster_commands}} diff --git a/src/app/zap-templates/templates/chip/python-chip-ChipCluster.zapt b/src/app/zap-templates/templates/chip/python-chip-ChipCluster.zapt index e123dffbad8c69..58c363138e6ad2 100644 --- a/src/app/zap-templates/templates/chip/python-chip-ChipCluster.zapt +++ b/src/app/zap-templates/templates/chip/python-chip-ChipCluster.zapt @@ -47,7 +47,7 @@ class ChipCluster: {{/chip_server_cluster_command_arguments}} self._ChipStack.Call( lambda: self._chipLib.chip_ime_AppendCommand_{{asCamelCased clusterName false}}_{{asCamelCased name false}}( - device, ZCLendpoint, ZCLgroupid{{#chip_server_cluster_command_arguments}}, {{asCamelCased label}}{{#if (isByteString type)}}, len({{asCamelCased label}}){{/if}}{{/chip_server_cluster_command_arguments}} + device, ZCLendpoint, ZCLgroupid{{#chip_server_cluster_command_arguments}}, {{asCamelCased label}}{{#if (isString type)}}, len({{asCamelCased label}}){{/if}}{{/chip_server_cluster_command_arguments}} ) ) @@ -59,7 +59,7 @@ class ChipCluster: # Cluster {{asCamelCased name false}} {{#chip_server_cluster_commands}} # Cluster {{asCamelCased clusterName false}} Command {{asCamelCased name false}} - self._chipLib.chip_ime_AppendCommand_{{asCamelCased clusterName false}}_{{asCamelCased name false}}.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16{{#chip_server_cluster_command_arguments}}{{#if (isByteString type)}}, ctypes.c_char_p, ctypes.c_uint32{{else}}, ctypes.{{asPythonCType chipType}}{{/if}}{{/chip_server_cluster_command_arguments}}] + self._chipLib.chip_ime_AppendCommand_{{asCamelCased clusterName false}}_{{asCamelCased name false}}.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16{{#chip_server_cluster_command_arguments}}{{#if (isString type)}}, ctypes.c_char_p, ctypes.c_uint32{{else}}, ctypes.{{asPythonCType chipType}}{{/if}}{{/chip_server_cluster_command_arguments}}] self._chipLib.chip_ime_AppendCommand_{{asCamelCased clusterName false}}_{{asCamelCased name false}}.restype = ctypes.c_uint32 {{/chip_server_cluster_commands}} {{/chip_server_clusters}} diff --git a/src/app/zap-templates/zcl/application-basic-cluster.xml b/src/app/zap-templates/zcl/application-basic-cluster.xml index 36e4c8e097169d..232e79c4d2e0a4 100644 --- a/src/app/zap-templates/zcl/application-basic-cluster.xml +++ b/src/app/zap-templates/zcl/application-basic-cluster.xml @@ -24,10 +24,10 @@ limitations under the License. true true This cluster provides information about an application running on a TV or media player device which is represented as an endpoint. - vendor name - vendor id + vendor name + vendor id application name - product id + product id application id catalog vendor id application satus diff --git a/src/app/zap-templates/zcl/clusters-extensions.xml b/src/app/zap-templates/zcl/clusters-extensions.xml index eff6e76f56fc5c..4dab11082ed374 100644 --- a/src/app/zap-templates/zcl/clusters-extensions.xml +++ b/src/app/zap-templates/zcl/clusters-extensions.xml @@ -16,7 +16,7 @@ limitations under the License. --> - + diff --git a/src/app/zap-templates/zcl/data-model/silabs/general.xml b/src/app/zap-templates/zcl/data-model/silabs/general.xml index 367ac8a5bde356..6ed1b74310dae1 100644 --- a/src/app/zap-templates/zcl/data-model/silabs/general.xml +++ b/src/app/zap-templates/zcl/data-model/silabs/general.xml @@ -170,32 +170,38 @@ limitations under the License. Basic General - Attributes for determining basic information about a device, setting user device information such as location, and enabling a device. - 0x0000 + Attributes for determining basic information about a device, and setting user device information such as location. + 0x0028 BASIC_CLUSTER true true - ZCL version - - application version - stack version - hardware version - manufacturer name - model identifier - date code - power source - generic device class - generic device type - product code - product url - location description - physical environment - device enabled - alarm mask - disable local config - - Command that resets all attribute values to factory default. + + InteractionModelVersion + VendorName + VendorID + ProductName + ProductID + UserLabel + Location + HardwareVersion + HardwareVersionString + SoftwareVersion + SoftwareVersionString + ManufacturingDate + PartNumber + ProductURL + ProductLabel + SerialNumber + LocalConfigDisabled + + The StartUp event SHALL be emitted by a Node as soon as reasonable after completing a boot or reboot process. + + + The ShutDown event SHOULD be emitted by a Node prior to any orderly shutdown sequence on a best-effort basis. + + + The Leave event SHOULD be emitted by a Node prior to permanently leaving the Fabric. diff --git a/src/app/zap-templates/zcl/data-model/silabs/ta.xml b/src/app/zap-templates/zcl/data-model/silabs/ta.xml index 891da751d1ffa8..3bf68176499edf 100644 --- a/src/app/zap-templates/zcl/data-model/silabs/ta.xml +++ b/src/app/zap-templates/zcl/data-model/silabs/ta.xml @@ -742,7 +742,7 @@ limitations under the License. price trailing digit price good id - serial number + serial number timestamp trans id trans status diff --git a/src/controller/CHIPClusters.cpp b/src/controller/CHIPClusters.cpp index 9a339244aeb899..4223e0e023e415 100644 --- a/src/controller/CHIPClusters.cpp +++ b/src/controller/CHIPClusters.cpp @@ -249,55 +249,109 @@ CHIP_ERROR BasicCluster::MfgSpecificPing(Callback::Cancelable * onSuccessCallbac #endif } -CHIP_ERROR BasicCluster::ResetToFactoryDefaults(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) +// Basic Cluster Attributes +CHIP_ERROR BasicCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { -#ifdef CHIP_APP_USE_INTERACTION_MODEL - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - (void) onSuccessCallback; - (void) onFailureCallback; + uint8_t seqNum = mDevice->GetNextSequenceNumber(); + System::PacketBufferHandle encodedCommand = encodeBasicClusterDiscoverAttributes(seqNum, mEndpoint); + return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); +} +CHIP_ERROR BasicCluster::ReadAttributeInteractionModelVersion(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + uint8_t seqNum = mDevice->GetNextSequenceNumber(); + System::PacketBufferHandle encodedCommand = encodeBasicClusterReadInteractionModelVersionAttribute(seqNum, mEndpoint); + return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); +} - app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kResetToFactoryDefaultsCommandId, - (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; - app::Command * ZCLcommand = mDevice->GetCommandSender(); +CHIP_ERROR BasicCluster::ReadAttributeVendorName(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) +{ + uint8_t seqNum = mDevice->GetNextSequenceNumber(); + System::PacketBufferHandle encodedCommand = encodeBasicClusterReadVendorNameAttribute(seqNum, mEndpoint); + return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); +} - TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); +CHIP_ERROR BasicCluster::ReadAttributeVendorID(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) +{ + uint8_t seqNum = mDevice->GetNextSequenceNumber(); + System::PacketBufferHandle encodedCommand = encodeBasicClusterReadVendorIDAttribute(seqNum, mEndpoint); + return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); +} - TLV::TLVType dummyType = TLV::kTLVType_NotSpecified; - ReturnErrorOnFailure(writer.StartContainer(TLV::AnonymousTag, TLV::kTLVType_Structure, dummyType)); +CHIP_ERROR BasicCluster::ReadAttributeProductName(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + uint8_t seqNum = mDevice->GetNextSequenceNumber(); + System::PacketBufferHandle encodedCommand = encodeBasicClusterReadProductNameAttribute(seqNum, mEndpoint); + return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); +} - // Command takes no arguments. +CHIP_ERROR BasicCluster::ReadAttributeProductID(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) +{ + uint8_t seqNum = mDevice->GetNextSequenceNumber(); + System::PacketBufferHandle encodedCommand = encodeBasicClusterReadProductIDAttribute(seqNum, mEndpoint); + return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); +} - ReturnErrorOnFailure(writer.EndContainer(dummyType)); - ReturnErrorOnFailure(writer.Finalize()); - ReturnErrorOnFailure(ZCLcommand->AddCommand(cmdParams)); +CHIP_ERROR BasicCluster::ReadAttributeUserLabel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) +{ + uint8_t seqNum = mDevice->GetNextSequenceNumber(); + System::PacketBufferHandle encodedCommand = encodeBasicClusterReadUserLabelAttribute(seqNum, mEndpoint); + return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); +} - return mDevice->SendCommands(); -#else +CHIP_ERROR BasicCluster::WriteAttributeUserLabel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, + chip::ByteSpan value) +{ uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterResetToFactoryDefaultsCommand(seqNum, mEndpoint); + System::PacketBufferHandle encodedCommand = encodeBasicClusterWriteUserLabelAttribute(seqNum, mEndpoint, value); return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); -#endif } -// Basic Cluster Attributes -CHIP_ERROR BasicCluster::DiscoverAttributes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) +CHIP_ERROR BasicCluster::ReadAttributeLocation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterDiscoverAttributes(seqNum, mEndpoint); + System::PacketBufferHandle encodedCommand = encodeBasicClusterReadLocationAttribute(seqNum, mEndpoint); return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); } -CHIP_ERROR BasicCluster::ReadAttributeZclVersion(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) + +CHIP_ERROR BasicCluster::WriteAttributeLocation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, + chip::ByteSpan value) { uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterReadZclVersionAttribute(seqNum, mEndpoint); + System::PacketBufferHandle encodedCommand = encodeBasicClusterWriteLocationAttribute(seqNum, mEndpoint, value); return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); } -CHIP_ERROR BasicCluster::ReadAttributePowerSource(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) +CHIP_ERROR BasicCluster::ReadAttributeHardwareVersion(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) { uint8_t seqNum = mDevice->GetNextSequenceNumber(); - System::PacketBufferHandle encodedCommand = encodeBasicClusterReadPowerSourceAttribute(seqNum, mEndpoint); + System::PacketBufferHandle encodedCommand = encodeBasicClusterReadHardwareVersionAttribute(seqNum, mEndpoint); + return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); +} + +CHIP_ERROR BasicCluster::ReadAttributeHardwareVersionString(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + uint8_t seqNum = mDevice->GetNextSequenceNumber(); + System::PacketBufferHandle encodedCommand = encodeBasicClusterReadHardwareVersionStringAttribute(seqNum, mEndpoint); + return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); +} + +CHIP_ERROR BasicCluster::ReadAttributeSoftwareVersion(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + uint8_t seqNum = mDevice->GetNextSequenceNumber(); + System::PacketBufferHandle encodedCommand = encodeBasicClusterReadSoftwareVersionAttribute(seqNum, mEndpoint); + return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); +} + +CHIP_ERROR BasicCluster::ReadAttributeSoftwareVersionString(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + uint8_t seqNum = mDevice->GetNextSequenceNumber(); + System::PacketBufferHandle encodedCommand = encodeBasicClusterReadSoftwareVersionStringAttribute(seqNum, mEndpoint); return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); } @@ -2147,7 +2201,8 @@ CHIP_ERROR DoorLockCluster::GetYeardaySchedule(Callback::Cancelable * onSuccessC #endif } -CHIP_ERROR DoorLockCluster::LockDoor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, char * pin) +CHIP_ERROR DoorLockCluster::LockDoor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, + chip::ByteSpan pin) { #ifdef CHIP_APP_USE_INTERACTION_MODEL VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); @@ -2221,7 +2276,7 @@ CHIP_ERROR DoorLockCluster::SetHolidaySchedule(Callback::Cancelable * onSuccessC } CHIP_ERROR DoorLockCluster::SetPin(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t userId, uint8_t userStatus, uint8_t userType, char * pin) + uint16_t userId, uint8_t userStatus, uint8_t userType, chip::ByteSpan pin) { #ifdef CHIP_APP_USE_INTERACTION_MODEL VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); @@ -2261,7 +2316,7 @@ CHIP_ERROR DoorLockCluster::SetPin(Callback::Cancelable * onSuccessCallback, Cal } CHIP_ERROR DoorLockCluster::SetRfid(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t userId, uint8_t userStatus, uint8_t userType, char * id) + uint16_t userId, uint8_t userStatus, uint8_t userType, chip::ByteSpan id) { #ifdef CHIP_APP_USE_INTERACTION_MODEL VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); @@ -2423,7 +2478,7 @@ CHIP_ERROR DoorLockCluster::SetYeardaySchedule(Callback::Cancelable * onSuccessC } CHIP_ERROR DoorLockCluster::UnlockDoor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - char * pin) + chip::ByteSpan pin) { #ifdef CHIP_APP_USE_INTERACTION_MODEL VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); @@ -2456,7 +2511,7 @@ CHIP_ERROR DoorLockCluster::UnlockDoor(Callback::Cancelable * onSuccessCallback, } CHIP_ERROR DoorLockCluster::UnlockWithTimeout(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t timeoutInSeconds, char * pin) + uint16_t timeoutInSeconds, chip::ByteSpan pin) { #ifdef CHIP_APP_USE_INTERACTION_MODEL VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); @@ -2699,7 +2754,7 @@ CHIP_ERROR GeneralCommissioningCluster::ReadAttributeClusterRevision(Callback::C // Groups Cluster Commands CHIP_ERROR GroupsCluster::AddGroup(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId, char * groupName) + uint16_t groupId, chip::ByteSpan groupName) { #ifdef CHIP_APP_USE_INTERACTION_MODEL VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); @@ -2734,7 +2789,7 @@ CHIP_ERROR GroupsCluster::AddGroup(Callback::Cancelable * onSuccessCallback, Cal } CHIP_ERROR GroupsCluster::AddGroupIfIdentifying(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId, char * groupName) + uint16_t groupId, chip::ByteSpan groupName) { #ifdef CHIP_APP_USE_INTERACTION_MODEL VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); @@ -3428,7 +3483,7 @@ CHIP_ERROR LowPowerCluster::Sleep(Callback::Cancelable * onSuccessCallback, Call (void) onFailureCallback; app::Command::CommandParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kSleepCommandId, - (chip::app::Command::kCommandPathFlag_EndpointIdValid) }; + (chip::app::Command::CommandPathFlags::kEndpointIdValid) }; app::Command * ZCLcommand = mDevice->GetCommandSender(); TLV::TLVWriter writer = ZCLcommand->CreateCommandDataElementTLVWriter(); @@ -4292,7 +4347,7 @@ CHIP_ERROR OnOffCluster::ReadAttributeClusterRevision(Callback::Cancelable * onS // Scenes Cluster Commands CHIP_ERROR ScenesCluster::AddScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId, uint8_t sceneId, uint16_t transitionTime, char * sceneName, + uint16_t groupId, uint8_t sceneId, uint16_t transitionTime, chip::ByteSpan sceneName, chip::ClusterId clusterId, uint8_t length, uint8_t value) { #ifdef CHIP_APP_USE_INTERACTION_MODEL diff --git a/src/controller/CHIPClusters.h b/src/controller/CHIPClusters.h index cb960d4d7944f9..751dd903f0064f 100644 --- a/src/controller/CHIPClusters.h +++ b/src/controller/CHIPClusters.h @@ -29,7 +29,7 @@ namespace Controller { constexpr ClusterId kApplicationBasicClusterId = 0x050D; constexpr ClusterId kBarrierControlClusterId = 0x0103; -constexpr ClusterId kBasicClusterId = 0x0000; +constexpr ClusterId kBasicClusterId = 0x0028; constexpr ClusterId kBindingClusterId = 0xF000; constexpr ClusterId kColorControlClusterId = 0x0300; constexpr ClusterId kContentLaunchClusterId = 0xF002; @@ -96,17 +96,31 @@ class DLL_EXPORT BasicCluster : public ClusterBase // Cluster Commands CHIP_ERROR MfgSpecificPing(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR ResetToFactoryDefaults(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); // Cluster Attributes CHIP_ERROR DiscoverAttributes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR ReadAttributeZclVersion(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR ReadAttributePowerSource(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeInteractionModelVersion(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeVendorName(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeVendorID(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeProductName(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeProductID(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeUserLabel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeLocation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeHardwareVersion(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeHardwareVersionString(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeSoftwareVersion(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR ReadAttributeSoftwareVersionString(Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback); CHIP_ERROR ReadAttributeClusterRevision(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); + CHIP_ERROR WriteAttributeUserLabel(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, + chip::ByteSpan value); + CHIP_ERROR WriteAttributeLocation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, + chip::ByteSpan value); private: - static constexpr CommandId kMfgSpecificPingCommandId = 0x00; - static constexpr CommandId kResetToFactoryDefaultsCommandId = 0x00; + static constexpr CommandId kMfgSpecificPingCommandId = 0x00; }; class DLL_EXPORT BindingCluster : public ClusterBase @@ -337,14 +351,14 @@ class DLL_EXPORT DoorLockCluster : public ClusterBase uint8_t scheduleId, uint16_t userId); CHIP_ERROR GetYeardaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t scheduleId, uint16_t userId); - CHIP_ERROR LockDoor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, char * pin); + CHIP_ERROR LockDoor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, chip::ByteSpan pin); CHIP_ERROR SetHolidaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t scheduleId, uint32_t localStartTime, uint32_t localEndTime, uint8_t operatingModeDuringHoliday); CHIP_ERROR SetPin(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t userId, - uint8_t userStatus, uint8_t userType, char * pin); + uint8_t userStatus, uint8_t userType, chip::ByteSpan pin); CHIP_ERROR SetRfid(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t userId, - uint8_t userStatus, uint8_t userType, char * id); + uint8_t userStatus, uint8_t userType, chip::ByteSpan id); CHIP_ERROR SetUserType(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t userId, uint8_t userType); CHIP_ERROR SetWeekdaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, @@ -352,9 +366,9 @@ class DLL_EXPORT DoorLockCluster : public ClusterBase uint8_t endHour, uint8_t endMinute); CHIP_ERROR SetYeardaySchedule(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t scheduleId, uint16_t userId, uint32_t localStartTime, uint32_t localEndTime); - CHIP_ERROR UnlockDoor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, char * pin); + CHIP_ERROR UnlockDoor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, chip::ByteSpan pin); CHIP_ERROR UnlockWithTimeout(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t timeoutInSeconds, char * pin); + uint16_t timeoutInSeconds, chip::ByteSpan pin); // Cluster Attributes CHIP_ERROR DiscoverAttributes(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); @@ -427,9 +441,9 @@ class DLL_EXPORT GroupsCluster : public ClusterBase // Cluster Commands CHIP_ERROR AddGroup(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t groupId, - char * groupName); + chip::ByteSpan groupName); CHIP_ERROR AddGroupIfIdentifying(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t groupId, char * groupName); + uint16_t groupId, chip::ByteSpan groupName); CHIP_ERROR GetGroupMembership(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t groupCount, uint16_t groupList); CHIP_ERROR RemoveAllGroups(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); @@ -660,8 +674,8 @@ class DLL_EXPORT ScenesCluster : public ClusterBase // Cluster Commands CHIP_ERROR AddScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t groupId, - uint8_t sceneId, uint16_t transitionTime, char * sceneName, chip::ClusterId clusterId, uint8_t length, - uint8_t value); + uint8_t sceneId, uint16_t transitionTime, chip::ByteSpan sceneName, chip::ClusterId clusterId, + uint8_t length, uint8_t value); CHIP_ERROR GetSceneMembership(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t groupId); CHIP_ERROR RecallScene(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint16_t groupId, diff --git a/src/controller/controller-clusters.zap b/src/controller/controller-clusters.zap index a7167fd91457c3..6ee591f40574dd 100644 --- a/src/controller/controller-clusters.zap +++ b/src/controller/controller-clusters.zap @@ -1,5 +1,5 @@ { - "writeTime": "Mon Mar 08 2021 19:19:29 GMT+0100 (Central European Standard Time)", + "writeTime": "Thu Mar 11 2021 17:28:29 GMT+0100 (Central European Standard Time)", "featureLevel": 11, "creator": "zap", "keyValuePairs": [ @@ -37,97 +37,6 @@ "deviceTypeCode": null, "deviceTypeProfileId": null, "clusters": [ - { - "name": "Basic", - "code": 0, - "mfgCode": null, - "define": "BASIC_CLUSTER", - "side": "client", - "enabled": 0, - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ], - "commands": [ - { - "name": "ResetToFactoryDefaults", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } - ] - }, - { - "name": "Basic", - "code": 0, - "mfgCode": null, - "define": "BASIC_CLUSTER", - "side": "server", - "enabled": 1, - "commands": [], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ZCL version", - "code": 0, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x08", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "power source", - "code": 7, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, { "name": "Identify", "code": 3, @@ -228,6 +137,23 @@ "define": "GROUPS_CLUSTER", "side": "client", "enabled": 0, + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], "commands": [ { "name": "AddGroup", @@ -277,23 +203,6 @@ "incoming": 1, "outgoing": 1 } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } ] }, { @@ -1045,6 +954,24 @@ "define": "DOOR_LOCK_CLUSTER", "side": "server", "enabled": 0, + "commands": [ + { + "name": "LockDoorResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "UnlockDoorResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], "attributes": [ { "name": "cluster revision", @@ -1481,33 +1408,33 @@ "maxInterval": 65344, "reportableChange": 0 } - ], + ] + }, + { + "name": "Barrier Control", + "code": 259, + "mfgCode": null, + "define": "BARRIER_CONTROL_CLUSTER", + "side": "client", + "enabled": 0, "commands": [ { - "name": "LockDoorResponse", + "name": "BarrierControlGoToPercent", "code": 0, "mfgCode": null, - "source": "server", + "source": "client", "incoming": 1, "outgoing": 1 }, { - "name": "UnlockDoorResponse", + "name": "BarrierControlStop", "code": 1, "mfgCode": null, - "source": "server", + "source": "client", "incoming": 1, "outgoing": 1 } - ] - }, - { - "name": "Barrier Control", - "code": 259, - "mfgCode": null, - "define": "BARRIER_CONTROL_CLUSTER", - "side": "client", - "enabled": 0, + ], "attributes": [ { "name": "cluster revision", @@ -1524,24 +1451,6 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [ - { - "name": "BarrierControlGoToPercent", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "BarrierControlStop", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } ] }, { @@ -1776,6 +1685,7 @@ "define": "COLOR_CONTROL_CLUSTER", "side": "server", "enabled": 0, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -2542,8 +2452,7 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [] + ] }, { "name": "Temperature Measurement", @@ -2819,15 +2728,15 @@ "deviceTypeProfileId": 259, "clusters": [ { - "name": "Basic", - "code": 0, + "name": "Identify", + "code": 3, "mfgCode": null, - "define": "BASIC_CLUSTER", + "define": "IDENTIFY_CLUSTER", "side": "client", "enabled": 0, "commands": [ { - "name": "ResetToFactoryDefaults", + "name": "Identify", "code": 0, "mfgCode": null, "source": "client", @@ -2835,12 +2744,12 @@ "outgoing": 1 }, { - "name": "MfgSpecificPing", - "code": 0, - "mfgCode": "4098", + "name": "IdentifyQuery", + "code": 1, + "mfgCode": null, "source": "client", "incoming": 1, - "outgoing": 0 + "outgoing": 1 } ], "attributes": [ @@ -2853,7 +2762,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "2", "reportable": 0, "minInterval": 0, "maxInterval": 65344, @@ -2862,13 +2771,12 @@ ] }, { - "name": "Basic", - "code": 0, + "name": "Identify", + "code": 3, "mfgCode": null, - "define": "BASIC_CLUSTER", + "define": "IDENTIFY_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "cluster revision", @@ -2879,14 +2787,14 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "2", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "ZCL version", + "name": "identify time", "code": 0, "mfgCode": null, "side": "server", @@ -2894,39 +2802,51 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x08", + "defaultValue": "0x0000", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - }, + } + ], + "commands": [ { - "name": "power source", - "code": 7, + "name": "IdentifyQueryResponse", + "code": 0, "mfgCode": null, - "side": "server", + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ] + }, + { + "name": "Groups", + "code": 4, + "mfgCode": null, + "define": "GROUPS_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "3", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 } - ] - }, - { - "name": "Identify", - "code": 3, - "mfgCode": null, - "define": "IDENTIFY_CLUSTER", - "side": "client", - "enabled": 0, + ], "commands": [ { - "name": "Identify", + "name": "AddGroup", "code": 0, "mfgCode": null, "source": "client", @@ -2934,100 +2854,7 @@ "outgoing": 1 }, { - "name": "IdentifyQuery", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "2", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Identify", - "code": 3, - "mfgCode": null, - "define": "IDENTIFY_CLUSTER", - "side": "server", - "enabled": 1, - "commands": [ - { - "name": "IdentifyQueryResponse", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "2", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "identify time", - "code": 0, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Groups", - "code": 4, - "mfgCode": null, - "define": "GROUPS_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [ - { - "name": "AddGroup", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "ViewGroup", + "name": "ViewGroup", "code": 1, "mfgCode": null, "source": "client", @@ -3066,23 +2893,6 @@ "incoming": 1, "outgoing": 1 } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } ] }, { @@ -3491,23 +3301,6 @@ "define": "LEVEL_CONTROL_CLUSTER", "side": "client", "enabled": 0, - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ], "commands": [ { "name": "MoveToLevel", @@ -3573,6 +3366,23 @@ "incoming": 1, "outgoing": 1 } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } ] }, { @@ -3616,6 +3426,257 @@ } ] }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "MfgSpecificPing", + "code": 0, + "mfgCode": "4098", + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "StartUp", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ShutDown", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "Leave", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "InteractionModelVersion", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorName", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorID", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductName", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductID", + "code": 4, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UserLabel", + "code": 5, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Location", + "code": 6, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersion", + "code": 7, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersionString", + "code": 8, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersion", + "code": 9, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersionString", + "code": 10, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, { "name": "General Commissioning", "code": 48, @@ -3966,6 +4027,24 @@ "define": "DOOR_LOCK_CLUSTER", "side": "server", "enabled": 1, + "commands": [ + { + "name": "LockDoorResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "UnlockDoorResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], "attributes": [ { "name": "cluster revision", @@ -4402,33 +4481,33 @@ "maxInterval": 65344, "reportableChange": 0 } - ], + ] + }, + { + "name": "Barrier Control", + "code": 259, + "mfgCode": null, + "define": "BARRIER_CONTROL_CLUSTER", + "side": "client", + "enabled": 0, "commands": [ { - "name": "LockDoorResponse", + "name": "BarrierControlGoToPercent", "code": 0, "mfgCode": null, - "source": "server", + "source": "client", "incoming": 1, "outgoing": 1 }, { - "name": "UnlockDoorResponse", + "name": "BarrierControlStop", "code": 1, "mfgCode": null, - "source": "server", + "source": "client", "incoming": 1, "outgoing": 1 } - ] - }, - { - "name": "Barrier Control", - "code": 259, - "mfgCode": null, - "define": "BARRIER_CONTROL_CLUSTER", - "side": "client", - "enabled": 0, + ], "attributes": [ { "name": "cluster revision", @@ -4445,24 +4524,6 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [ - { - "name": "BarrierControlGoToPercent", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "BarrierControlStop", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } ] }, { @@ -4472,7 +4533,6 @@ "define": "BARRIER_CONTROL_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "cluster revision", @@ -4549,7 +4609,8 @@ "maxInterval": 65344, "reportableChange": 0 } - ] + ], + "commands": [] }, { "name": "Color Control", @@ -5738,6 +5799,16 @@ "define": "LOW_POWER_CLUSTER", "side": "client", "enabled": 0, + "commands": [ + { + "name": "Sleep", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 + } + ], "attributes": [ { "name": "cluster revision", @@ -5754,16 +5825,6 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [ - { - "name": "Sleep", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 - } ] }, { @@ -6055,23 +6116,6 @@ "define": "NETWORK_COMMISSIONING_CLUSTER", "side": "server", "enabled": 1, - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0001", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ], "commands": [ { "name": "ScanNetworksResponse", @@ -6137,6 +6181,23 @@ "incoming": 1, "outgoing": 1 } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } ] }, { diff --git a/src/controller/python/ChipDeviceController-ClusterCommands.cpp b/src/controller/python/ChipDeviceController-ClusterCommands.cpp index d5a5dc4ff2b077..a1000edc91bf19 100644 --- a/src/controller/python/ChipDeviceController-ClusterCommands.cpp +++ b/src/controller/python/ChipDeviceController-ClusterCommands.cpp @@ -67,15 +67,6 @@ CHIP_ERROR chip_ime_AppendCommand_Basic_MfgSpecificPing(chip::Controller::Device clusterBasic.Associate(device, ZCLendpointId); return clusterBasic.MfgSpecificPing(nullptr, nullptr); } -CHIP_ERROR chip_ime_AppendCommand_Basic_ResetToFactoryDefaults(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, - chip::GroupId ZCLgroupId) -{ - VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); - chip::Controller::BasicCluster clusterBasic; - (void) ZCLgroupId; - clusterBasic.Associate(device, ZCLendpointId); - return clusterBasic.ResetToFactoryDefaults(nullptr, nullptr); -} // End of Cluster Basic // Cluster Binding @@ -402,13 +393,13 @@ CHIP_ERROR chip_ime_AppendCommand_DoorLock_GetYeardaySchedule(chip::Controller:: return clusterDoorLock.GetYeardaySchedule(nullptr, nullptr, scheduleId, userId); } CHIP_ERROR chip_ime_AppendCommand_DoorLock_LockDoor(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, - chip::GroupId ZCLgroupId, char * pin) + chip::GroupId ZCLgroupId, const uint8_t * pin, uint32_t pin_Len) { VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); chip::Controller::DoorLockCluster clusterDoorLock; (void) ZCLgroupId; clusterDoorLock.Associate(device, ZCLendpointId); - return clusterDoorLock.LockDoor(nullptr, nullptr, pin); + return clusterDoorLock.LockDoor(nullptr, nullptr, chip::ByteSpan(pin, pin_Len)); } CHIP_ERROR chip_ime_AppendCommand_DoorLock_SetHolidaySchedule(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId, uint8_t scheduleId, uint32_t localStartTime, @@ -423,23 +414,23 @@ CHIP_ERROR chip_ime_AppendCommand_DoorLock_SetHolidaySchedule(chip::Controller:: } CHIP_ERROR chip_ime_AppendCommand_DoorLock_SetPin(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId, uint16_t userId, uint8_t userStatus, uint8_t userType, - char * pin) + const uint8_t * pin, uint32_t pin_Len) { VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); chip::Controller::DoorLockCluster clusterDoorLock; (void) ZCLgroupId; clusterDoorLock.Associate(device, ZCLendpointId); - return clusterDoorLock.SetPin(nullptr, nullptr, userId, userStatus, userType, pin); + return clusterDoorLock.SetPin(nullptr, nullptr, userId, userStatus, userType, chip::ByteSpan(pin, pin_Len)); } CHIP_ERROR chip_ime_AppendCommand_DoorLock_SetRfid(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId, uint16_t userId, uint8_t userStatus, uint8_t userType, - char * id) + const uint8_t * id, uint32_t id_Len) { VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); chip::Controller::DoorLockCluster clusterDoorLock; (void) ZCLgroupId; clusterDoorLock.Associate(device, ZCLendpointId); - return clusterDoorLock.SetRfid(nullptr, nullptr, userId, userStatus, userType, id); + return clusterDoorLock.SetRfid(nullptr, nullptr, userId, userStatus, userType, chip::ByteSpan(id, id_Len)); } CHIP_ERROR chip_ime_AppendCommand_DoorLock_SetUserType(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId, uint16_t userId, uint8_t userType) @@ -473,22 +464,23 @@ CHIP_ERROR chip_ime_AppendCommand_DoorLock_SetYeardaySchedule(chip::Controller:: return clusterDoorLock.SetYeardaySchedule(nullptr, nullptr, scheduleId, userId, localStartTime, localEndTime); } CHIP_ERROR chip_ime_AppendCommand_DoorLock_UnlockDoor(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, - chip::GroupId ZCLgroupId, char * pin) + chip::GroupId ZCLgroupId, const uint8_t * pin, uint32_t pin_Len) { VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); chip::Controller::DoorLockCluster clusterDoorLock; (void) ZCLgroupId; clusterDoorLock.Associate(device, ZCLendpointId); - return clusterDoorLock.UnlockDoor(nullptr, nullptr, pin); + return clusterDoorLock.UnlockDoor(nullptr, nullptr, chip::ByteSpan(pin, pin_Len)); } CHIP_ERROR chip_ime_AppendCommand_DoorLock_UnlockWithTimeout(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, - chip::GroupId ZCLgroupId, uint16_t timeoutInSeconds, char * pin) + chip::GroupId ZCLgroupId, uint16_t timeoutInSeconds, + const uint8_t * pin, uint32_t pin_Len) { VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); chip::Controller::DoorLockCluster clusterDoorLock; (void) ZCLgroupId; clusterDoorLock.Associate(device, ZCLendpointId); - return clusterDoorLock.UnlockWithTimeout(nullptr, nullptr, timeoutInSeconds, pin); + return clusterDoorLock.UnlockWithTimeout(nullptr, nullptr, timeoutInSeconds, chip::ByteSpan(pin, pin_Len)); } // End of Cluster DoorLock @@ -530,22 +522,24 @@ CHIP_ERROR chip_ime_AppendCommand_GeneralCommissioning_SetFabric(chip::Controlle // Cluster Groups CHIP_ERROR chip_ime_AppendCommand_Groups_AddGroup(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, - chip::GroupId ZCLgroupId, uint16_t groupId, char * groupName) + chip::GroupId ZCLgroupId, uint16_t groupId, const uint8_t * groupName, + uint32_t groupName_Len) { VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); chip::Controller::GroupsCluster clusterGroups; (void) ZCLgroupId; clusterGroups.Associate(device, ZCLendpointId); - return clusterGroups.AddGroup(nullptr, nullptr, groupId, groupName); + return clusterGroups.AddGroup(nullptr, nullptr, groupId, chip::ByteSpan(groupName, groupName_Len)); } CHIP_ERROR chip_ime_AppendCommand_Groups_AddGroupIfIdentifying(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, - chip::GroupId ZCLgroupId, uint16_t groupId, char * groupName) + chip::GroupId ZCLgroupId, uint16_t groupId, + const uint8_t * groupName, uint32_t groupName_Len) { VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); chip::Controller::GroupsCluster clusterGroups; (void) ZCLgroupId; clusterGroups.Associate(device, ZCLendpointId); - return clusterGroups.AddGroupIfIdentifying(nullptr, nullptr, groupId, groupName); + return clusterGroups.AddGroupIfIdentifying(nullptr, nullptr, groupId, chip::ByteSpan(groupName, groupName_Len)); } CHIP_ERROR chip_ime_AppendCommand_Groups_GetGroupMembership(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId, uint8_t groupCount, uint16_t groupList) @@ -940,14 +934,15 @@ CHIP_ERROR chip_ime_AppendCommand_OnOff_Toggle(chip::Controller::Device * device // Cluster Scenes CHIP_ERROR chip_ime_AppendCommand_Scenes_AddScene(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId, uint16_t groupId, uint8_t sceneId, - uint16_t transitionTime, char * sceneName, chip::ClusterId clusterId, - uint8_t length, uint8_t value) + uint16_t transitionTime, const uint8_t * sceneName, uint32_t sceneName_Len, + chip::ClusterId clusterId, uint8_t length, uint8_t value) { VerifyOrReturnError(device != nullptr, CHIP_ERROR_INVALID_ARGUMENT); chip::Controller::ScenesCluster clusterScenes; (void) ZCLgroupId; clusterScenes.Associate(device, ZCLendpointId); - return clusterScenes.AddScene(nullptr, nullptr, groupId, sceneId, transitionTime, sceneName, clusterId, length, value); + return clusterScenes.AddScene(nullptr, nullptr, groupId, sceneId, transitionTime, chip::ByteSpan(sceneName, sceneName_Len), + clusterId, length, value); } CHIP_ERROR chip_ime_AppendCommand_Scenes_GetSceneMembership(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, chip::GroupId ZCLgroupId, uint16_t groupId) diff --git a/src/controller/python/chip/ChipCluster.py b/src/controller/python/chip/ChipCluster.py index d644614f8e15b3..fb981a5cc796ff 100644 --- a/src/controller/python/chip/ChipCluster.py +++ b/src/controller/python/chip/ChipCluster.py @@ -47,8 +47,6 @@ def ListClusters(self): "Basic": { "MfgSpecificPing": { }, - "ResetToFactoryDefaults": { - }, }, "Binding": { "Bind": { @@ -211,7 +209,7 @@ def ListClusters(self): "userId": "int", }, "LockDoor": { - "pin": "str", + "pin": "bytes", }, "SetHolidaySchedule": { "scheduleId": "int", @@ -223,13 +221,13 @@ def ListClusters(self): "userId": "int", "userStatus": "int", "userType": "int", - "pin": "str", + "pin": "bytes", }, "SetRfid": { "userId": "int", "userStatus": "int", "userType": "int", - "id": "str", + "id": "bytes", }, "SetUserType": { "userId": "int", @@ -251,11 +249,11 @@ def ListClusters(self): "localEndTime": "int", }, "UnlockDoor": { - "pin": "str", + "pin": "bytes", }, "UnlockWithTimeout": { "timeoutInSeconds": "int", - "pin": "str", + "pin": "bytes", }, }, "GeneralCommissioning": { @@ -276,11 +274,11 @@ def ListClusters(self): "Groups": { "AddGroup": { "groupId": "int", - "groupName": "str", + "groupName": "bytes", }, "AddGroupIfIdentifying": { "groupId": "int", - "groupName": "str", + "groupName": "bytes", }, "GetGroupMembership": { "groupCount": "int", @@ -430,7 +428,7 @@ def ListClusters(self): "groupId": "int", "sceneId": "int", "transitionTime": "int", - "sceneName": "str", + "sceneName": "bytes", "clusterId": "int", "length": "int", "value": "int", @@ -490,13 +488,6 @@ def ClusterBasic_CommandMfgSpecificPing(self, device: ctypes.c_void_p, ZCLendpoi ) ) - def ClusterBasic_CommandResetToFactoryDefaults(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): - self._ChipStack.Call( - lambda: self._chipLib.chip_ime_AppendCommand_Basic_ResetToFactoryDefaults( - device, ZCLendpoint, ZCLgroupid - ) - ) - def ClusterBinding_CommandBind(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, nodeId: int, groupId: int, endpointId: int, clusterId: int): self._ChipStack.Call( lambda: self._chipLib.chip_ime_AppendCommand_Binding_Bind( @@ -721,11 +712,11 @@ def ClusterDoorLock_CommandGetYeardaySchedule(self, device: ctypes.c_void_p, ZCL ) ) - def ClusterDoorLock_CommandLockDoor(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, pin: str): + def ClusterDoorLock_CommandLockDoor(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, pin: bytes): pin = pin.encode("utf-8") + b'\x00' self._ChipStack.Call( lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_LockDoor( - device, ZCLendpoint, ZCLgroupid, pin + device, ZCLendpoint, ZCLgroupid, pin, len(pin) ) ) @@ -736,19 +727,19 @@ def ClusterDoorLock_CommandSetHolidaySchedule(self, device: ctypes.c_void_p, ZCL ) ) - def ClusterDoorLock_CommandSetPin(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, userId: int, userStatus: int, userType: int, pin: str): + def ClusterDoorLock_CommandSetPin(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, userId: int, userStatus: int, userType: int, pin: bytes): pin = pin.encode("utf-8") + b'\x00' self._ChipStack.Call( lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_SetPin( - device, ZCLendpoint, ZCLgroupid, userId, userStatus, userType, pin + device, ZCLendpoint, ZCLgroupid, userId, userStatus, userType, pin, len(pin) ) ) - def ClusterDoorLock_CommandSetRfid(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, userId: int, userStatus: int, userType: int, id: str): + def ClusterDoorLock_CommandSetRfid(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, userId: int, userStatus: int, userType: int, id: bytes): id = id.encode("utf-8") + b'\x00' self._ChipStack.Call( lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_SetRfid( - device, ZCLendpoint, ZCLgroupid, userId, userStatus, userType, id + device, ZCLendpoint, ZCLgroupid, userId, userStatus, userType, id, len(id) ) ) @@ -773,19 +764,19 @@ def ClusterDoorLock_CommandSetYeardaySchedule(self, device: ctypes.c_void_p, ZCL ) ) - def ClusterDoorLock_CommandUnlockDoor(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, pin: str): + def ClusterDoorLock_CommandUnlockDoor(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, pin: bytes): pin = pin.encode("utf-8") + b'\x00' self._ChipStack.Call( lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_UnlockDoor( - device, ZCLendpoint, ZCLgroupid, pin + device, ZCLendpoint, ZCLgroupid, pin, len(pin) ) ) - def ClusterDoorLock_CommandUnlockWithTimeout(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, timeoutInSeconds: int, pin: str): + def ClusterDoorLock_CommandUnlockWithTimeout(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, timeoutInSeconds: int, pin: bytes): pin = pin.encode("utf-8") + b'\x00' self._ChipStack.Call( lambda: self._chipLib.chip_ime_AppendCommand_DoorLock_UnlockWithTimeout( - device, ZCLendpoint, ZCLgroupid, timeoutInSeconds, pin + device, ZCLendpoint, ZCLgroupid, timeoutInSeconds, pin, len(pin) ) ) @@ -810,19 +801,19 @@ def ClusterGeneralCommissioning_CommandSetFabric(self, device: ctypes.c_void_p, ) ) - def ClusterGroups_CommandAddGroup(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, groupId: int, groupName: str): + def ClusterGroups_CommandAddGroup(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, groupId: int, groupName: bytes): groupName = groupName.encode("utf-8") + b'\x00' self._ChipStack.Call( lambda: self._chipLib.chip_ime_AppendCommand_Groups_AddGroup( - device, ZCLendpoint, ZCLgroupid, groupId, groupName + device, ZCLendpoint, ZCLgroupid, groupId, groupName, len(groupName) ) ) - def ClusterGroups_CommandAddGroupIfIdentifying(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, groupId: int, groupName: str): + def ClusterGroups_CommandAddGroupIfIdentifying(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, groupId: int, groupName: bytes): groupName = groupName.encode("utf-8") + b'\x00' self._ChipStack.Call( lambda: self._chipLib.chip_ime_AppendCommand_Groups_AddGroupIfIdentifying( - device, ZCLendpoint, ZCLgroupid, groupId, groupName + device, ZCLendpoint, ZCLgroupid, groupId, groupName, len(groupName) ) ) @@ -1085,11 +1076,11 @@ def ClusterOnOff_CommandToggle(self, device: ctypes.c_void_p, ZCLendpoint: int, ) ) - def ClusterScenes_CommandAddScene(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, groupId: int, sceneId: int, transitionTime: int, sceneName: str, clusterId: int, length: int, value: int): + def ClusterScenes_CommandAddScene(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, groupId: int, sceneId: int, transitionTime: int, sceneName: bytes, clusterId: int, length: int, value: int): sceneName = sceneName.encode("utf-8") + b'\x00' self._ChipStack.Call( lambda: self._chipLib.chip_ime_AppendCommand_Scenes_AddScene( - device, ZCLendpoint, ZCLgroupid, groupId, sceneId, transitionTime, sceneName, clusterId, length, value + device, ZCLendpoint, ZCLgroupid, groupId, sceneId, transitionTime, sceneName, len(sceneName), clusterId, length, value ) ) @@ -1149,9 +1140,6 @@ def InitLib(self, chipLib): # Cluster Basic Command MfgSpecificPing self._chipLib.chip_ime_AppendCommand_Basic_MfgSpecificPing.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] self._chipLib.chip_ime_AppendCommand_Basic_MfgSpecificPing.restype = ctypes.c_uint32 - # Cluster Basic Command ResetToFactoryDefaults - self._chipLib.chip_ime_AppendCommand_Basic_ResetToFactoryDefaults.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] - self._chipLib.chip_ime_AppendCommand_Basic_ResetToFactoryDefaults.restype = ctypes.c_uint32 # Cluster Binding # Cluster Binding Command Bind self._chipLib.chip_ime_AppendCommand_Binding_Bind.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint64, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint16] @@ -1253,16 +1241,16 @@ def InitLib(self, chipLib): self._chipLib.chip_ime_AppendCommand_DoorLock_GetYeardaySchedule.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint16] self._chipLib.chip_ime_AppendCommand_DoorLock_GetYeardaySchedule.restype = ctypes.c_uint32 # Cluster DoorLock Command LockDoor - self._chipLib.chip_ime_AppendCommand_DoorLock_LockDoor.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_char_p] + self._chipLib.chip_ime_AppendCommand_DoorLock_LockDoor.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_char_p, ctypes.c_uint32] self._chipLib.chip_ime_AppendCommand_DoorLock_LockDoor.restype = ctypes.c_uint32 # Cluster DoorLock Command SetHolidaySchedule self._chipLib.chip_ime_AppendCommand_DoorLock_SetHolidaySchedule.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint32, ctypes.c_uint32, ctypes.c_uint8] self._chipLib.chip_ime_AppendCommand_DoorLock_SetHolidaySchedule.restype = ctypes.c_uint32 # Cluster DoorLock Command SetPin - self._chipLib.chip_ime_AppendCommand_DoorLock_SetPin.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_char_p] + self._chipLib.chip_ime_AppendCommand_DoorLock_SetPin.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_char_p, ctypes.c_uint32] self._chipLib.chip_ime_AppendCommand_DoorLock_SetPin.restype = ctypes.c_uint32 # Cluster DoorLock Command SetRfid - self._chipLib.chip_ime_AppendCommand_DoorLock_SetRfid.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_char_p] + self._chipLib.chip_ime_AppendCommand_DoorLock_SetRfid.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_char_p, ctypes.c_uint32] self._chipLib.chip_ime_AppendCommand_DoorLock_SetRfid.restype = ctypes.c_uint32 # Cluster DoorLock Command SetUserType self._chipLib.chip_ime_AppendCommand_DoorLock_SetUserType.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16, ctypes.c_uint8] @@ -1274,10 +1262,10 @@ def InitLib(self, chipLib): self._chipLib.chip_ime_AppendCommand_DoorLock_SetYeardaySchedule.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint32, ctypes.c_uint32] self._chipLib.chip_ime_AppendCommand_DoorLock_SetYeardaySchedule.restype = ctypes.c_uint32 # Cluster DoorLock Command UnlockDoor - self._chipLib.chip_ime_AppendCommand_DoorLock_UnlockDoor.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_char_p] + self._chipLib.chip_ime_AppendCommand_DoorLock_UnlockDoor.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_char_p, ctypes.c_uint32] self._chipLib.chip_ime_AppendCommand_DoorLock_UnlockDoor.restype = ctypes.c_uint32 # Cluster DoorLock Command UnlockWithTimeout - self._chipLib.chip_ime_AppendCommand_DoorLock_UnlockWithTimeout.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16, ctypes.c_char_p] + self._chipLib.chip_ime_AppendCommand_DoorLock_UnlockWithTimeout.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16, ctypes.c_char_p, ctypes.c_uint32] self._chipLib.chip_ime_AppendCommand_DoorLock_UnlockWithTimeout.restype = ctypes.c_uint32 # Cluster GeneralCommissioning # Cluster GeneralCommissioning Command ArmFailSafe @@ -1291,10 +1279,10 @@ def InitLib(self, chipLib): self._chipLib.chip_ime_AppendCommand_GeneralCommissioning_SetFabric.restype = ctypes.c_uint32 # Cluster Groups # Cluster Groups Command AddGroup - self._chipLib.chip_ime_AppendCommand_Groups_AddGroup.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16, ctypes.c_char_p] + self._chipLib.chip_ime_AppendCommand_Groups_AddGroup.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16, ctypes.c_char_p, ctypes.c_uint32] self._chipLib.chip_ime_AppendCommand_Groups_AddGroup.restype = ctypes.c_uint32 # Cluster Groups Command AddGroupIfIdentifying - self._chipLib.chip_ime_AppendCommand_Groups_AddGroupIfIdentifying.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16, ctypes.c_char_p] + self._chipLib.chip_ime_AppendCommand_Groups_AddGroupIfIdentifying.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16, ctypes.c_char_p, ctypes.c_uint32] self._chipLib.chip_ime_AppendCommand_Groups_AddGroupIfIdentifying.restype = ctypes.c_uint32 # Cluster Groups Command GetGroupMembership self._chipLib.chip_ime_AppendCommand_Groups_GetGroupMembership.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint16] @@ -1416,7 +1404,7 @@ def InitLib(self, chipLib): self._chipLib.chip_ime_AppendCommand_OnOff_Toggle.restype = ctypes.c_uint32 # Cluster Scenes # Cluster Scenes Command AddScene - self._chipLib.chip_ime_AppendCommand_Scenes_AddScene.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_char_p, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint8] + self._chipLib.chip_ime_AppendCommand_Scenes_AddScene.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_char_p, ctypes.c_uint32, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint8] self._chipLib.chip_ime_AppendCommand_Scenes_AddScene.restype = ctypes.c_uint32 # Cluster Scenes Command GetSceneMembership self._chipLib.chip_ime_AppendCommand_Scenes_GetSceneMembership.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16] diff --git a/src/darwin/Framework/CHIP/chip-tool.zap b/src/darwin/Framework/CHIP/chip-tool.zap index 0bba747ba84333..55a9cdbb4cf495 100644 --- a/src/darwin/Framework/CHIP/chip-tool.zap +++ b/src/darwin/Framework/CHIP/chip-tool.zap @@ -1,5 +1,5 @@ { - "writeTime": "Sat Feb 20 2021 16:22:34 GMT+0800 (China Standard Time)", + "writeTime": "Thu Mar 11 2021 18:15:06 GMT+0100 (Central European Standard Time)", "featureLevel": 11, "creator": "zap", "keyValuePairs": [ @@ -19,9 +19,15 @@ "package": [ { "pathRelativity": "relativeToZap", - "path": "../../../../app/zap-templates/zcl/zcl.json", + "path": "../../../src/app/zap-templates/zcl/zcl.json", "version": "ZCL Test Data", "type": "zcl-properties" + }, + { + "pathRelativity": "relativeToZap", + "path": "../../../src/app/zap-templates/app-templates.json", + "version": "chip-v1", + "type": "gen-templates-json" } ], "endpointTypes": [ @@ -32,15 +38,15 @@ "deviceTypeProfileId": 259, "clusters": [ { - "name": "Basic", - "code": 0, + "name": "Identify", + "code": 3, "mfgCode": null, - "define": "BASIC_CLUSTER", + "define": "IDENTIFY_CLUSTER", "side": "client", "enabled": 1, "commands": [ { - "name": "ResetToFactoryDefaults", + "name": "Identify", "code": 0, "mfgCode": null, "source": "client", @@ -48,95 +54,14 @@ "outgoing": 1 }, { - "name": "MfgSpecificPing", - "code": 0, - "mfgCode": "4098", + "name": "IdentifyQuery", + "code": 1, + "mfgCode": null, "source": "client", - "incoming": 0, + "incoming": 1, "outgoing": 1 } ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Basic", - "code": 0, - "mfgCode": null, - "define": "BASIC_CLUSTER", - "side": "server", - "enabled": 0, - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ZCL version", - "code": 0, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x08", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "power source", - "code": 7, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ], - "commands": [] - }, - { - "name": "Identify", - "code": 3, - "mfgCode": null, - "define": "IDENTIFY_CLUSTER", - "side": "client", - "enabled": 1, "attributes": [ { "name": "cluster revision", @@ -153,24 +78,6 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [ - { - "name": "Identify", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "IdentifyQuery", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } ] }, { @@ -830,96 +737,479 @@ ] }, { - "name": "Door Lock", - "code": 257, + "name": "Basic", + "code": 40, "mfgCode": null, - "define": "DOOR_LOCK_CLUSTER", + "define": "BASIC_CLUSTER", "side": "client", "enabled": 1, "commands": [ { - "name": "LockDoor", + "name": "MfgSpecificPing", "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "UnlockDoor", - "code": 1, - "mfgCode": null, + "mfgCode": "4098", "source": "client", - "incoming": 1, + "incoming": 0, "outgoing": 1 - }, + } + ], + "attributes": [ { - "name": "UnlockWithTimeout", - "code": 3, + "name": "cluster revision", + "code": 65533, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [ { - "name": "GetLogRecord", - "code": 4, + "name": "StartUp", + "code": 0, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 + "source": "server", + "incoming": 0, + "outgoing": 0 }, { - "name": "SetPin", - "code": 5, + "name": "ShutDown", + "code": 1, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 + "source": "server", + "incoming": 0, + "outgoing": 0 }, { - "name": "GetPin", - "code": 6, + "name": "Leave", + "code": 2, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, + "source": "server", + "incoming": 0, + "outgoing": 0 + } + ], + "attributes": [ { - "name": "ClearPin", - "code": 7, + "name": "cluster revision", + "code": 65533, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 }, { - "name": "ClearAllPins", - "code": 8, + "name": "InteractionModelVersion", + "code": 0, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 }, { - "name": "SetWeekdaySchedule", - "code": 11, + "name": "VendorName", + "code": 1, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 }, { - "name": "GetWeekdaySchedule", - "code": 12, + "name": "VendorID", + "code": 2, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 }, { - "name": "ClearWeekdaySchedule", - "code": 13, + "name": "ProductName", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductID", + "code": 4, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UserLabel", + "code": 5, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Location", + "code": 6, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersion", + "code": 7, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersionString", + "code": 8, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersion", + "code": 9, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersionString", + "code": 10, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "General Commissioning", + "code": 48, + "mfgCode": null, + "define": "GENERAL_COMMISSIONING_CLUSTER", + "side": "client", + "enabled": 1, + "commands": [ + { + "name": "SetFabric", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ArmFailSafe", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "CommissioningComplete", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "General Commissioning", + "code": 48, + "mfgCode": null, + "define": "GENERAL_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [ + { + "name": "SetFabricResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ArmFailSafeResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "CommissioningCompleteResponse", + "code": 7, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FabricId", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "o", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Breadcrumb", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Door Lock", + "code": 257, + "mfgCode": null, + "define": "DOOR_LOCK_CLUSTER", + "side": "client", + "enabled": 1, + "commands": [ + { + "name": "LockDoor", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "UnlockDoor", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "UnlockWithTimeout", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetLogRecord", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetPin", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetPin", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ClearPin", + "code": 7, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ClearAllPins", + "code": 8, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetWeekdaySchedule", + "code": 11, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetWeekdaySchedule", + "code": 12, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ClearWeekdaySchedule", + "code": 13, "mfgCode": null, "source": "client", "incoming": 1, @@ -1694,6 +1984,23 @@ "define": "BARRIER_CONTROL_CLUSTER", "side": "client", "enabled": 1, + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], "commands": [ { "name": "BarrierControlGoToPercent", @@ -1711,23 +2018,6 @@ "incoming": 1, "outgoing": 1 } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0001", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } ] }, { @@ -2827,16 +3117,230 @@ "reportableChange": 0 }, { - "name": "tolerance", - "code": 3, + "name": "tolerance", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "IAS Zone", + "code": 1280, + "mfgCode": null, + "define": "IAS_ZONE_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "ZoneEnrollResponse", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "2", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "IAS Zone", + "code": 1280, + "mfgCode": null, + "define": "IAS_ZONE_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [ + { + "name": "ZoneStatusChangeNotification", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ZoneEnrollRequest", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "2", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "zone state", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "zone type", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "zone status", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "IAS CIE address", + "code": 16, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Zone ID", + "code": 17, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xff", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Low Power", + "code": 1288, + "mfgCode": null, + "define": "LOW_POWER_CLUSTER", + "side": "client", + "enabled": 1, + "commands": [ + { + "name": "Sleep", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Low Power", + "code": 1288, + "mfgCode": null, + "define": "LOW_POWER_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, "mfgCode": null, "side": "server", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", - "reportable": 1, + "defaultValue": "0x0001", + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -2844,22 +3348,13 @@ ] }, { - "name": "IAS Zone", - "code": 1280, + "name": "Application Basic", + "code": 1293, "mfgCode": null, - "define": "IAS_ZONE_CLUSTER", + "define": "APPLICATION_BASIC_CLUSTER", "side": "client", - "enabled": 0, - "commands": [ - { - "name": "ZoneEnrollResponse", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } - ], + "enabled": 1, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -2870,7 +3365,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "2", + "defaultValue": "0x0001", "reportable": 0, "minInterval": 0, "maxInterval": 65344, @@ -2879,12 +3374,13 @@ ] }, { - "name": "IAS Zone", - "code": 1280, + "name": "Application Basic", + "code": 1293, "mfgCode": null, - "define": "IAS_ZONE_CLUSTER", + "define": "APPLICATION_BASIC_CLUSTER", "side": "server", "enabled": 0, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -2895,14 +3391,14 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "2", + "defaultValue": "0x0001", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "zone state", + "name": "vendor name", "code": 0, "mfgCode": null, "side": "server", @@ -2910,14 +3406,14 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "zone type", + "name": "vendor id", "code": 1, "mfgCode": null, "side": "server", @@ -2932,7 +3428,7 @@ "reportableChange": 0 }, { - "name": "zone status", + "name": "application name", "code": 2, "mfgCode": null, "side": "server", @@ -2940,15 +3436,15 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "IAS CIE address", - "code": 16, + "name": "product id", + "code": 3, "mfgCode": null, "side": "server", "included": 1, @@ -2962,53 +3458,109 @@ "reportableChange": 0 }, { - "name": "Zone ID", - "code": 17, + "name": "application id", + "code": 5, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0xff", + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "catalog vendor id", + "code": 6, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "application satus", + "code": 7, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 } - ], + ] + }, + { + "name": "Binding", + "code": 61440, + "mfgCode": null, + "define": "BINDING_CLUSTER", + "side": "client", + "enabled": 1, "commands": [ { - "name": "ZoneStatusChangeNotification", + "name": "Bind", "code": 0, "mfgCode": null, - "source": "server", + "source": "client", "incoming": 1, "outgoing": 1 }, { - "name": "ZoneEnrollRequest", + "name": "Unbind", "code": 1, "mfgCode": null, - "source": "server", + "source": "client", "incoming": 1, "outgoing": 1 } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } ] }, { - "name": "Network Commissioning", - "code": 43690, + "name": "Binding", + "code": 61440, "mfgCode": null, - "define": "NETWORK_COMMISSIONING_CLUSTER", - "side": "client", + "define": "BINDING_CLUSTER", + "side": "server", "enabled": 0, + "commands": [], "attributes": [ { "name": "cluster revision", "code": 65533, "mfgCode": null, - "side": "client", + "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -3019,10 +3571,18 @@ "maxInterval": 65344, "reportableChange": 0 } - ], + ] + }, + { + "name": "Media Playback", + "code": 61441, + "mfgCode": null, + "define": "MEDIA_PLAYBACK_CLUSTER", + "side": "client", + "enabled": 1, "commands": [ { - "name": "ScanNetworks", + "name": "PlayRequest", "code": 0, "mfgCode": null, "source": "client", @@ -3030,7 +3590,15 @@ "outgoing": 1 }, { - "name": "AddWiFiNetwork", + "name": "PauseRequest", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "StopRequest", "code": 2, "mfgCode": null, "source": "client", @@ -3038,130 +3606,91 @@ "outgoing": 1 }, { - "name": "UpdateWiFiNetwork", - "code": 4, + "name": "StartOverRequest", + "code": 3, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 1 }, { - "name": "AddThreadNetwork", - "code": 6, + "name": "PreviousRequest", + "code": 4, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 1 }, { - "name": "UpdateThreadNetwork", - "code": 8, + "name": "NextRequest", + "code": 5, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 1 }, { - "name": "RemoveNetwork", - "code": 10, + "name": "RewindRequest", + "code": 6, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 1 }, { - "name": "EnableNetwork", - "code": 12, + "name": "FastForwardRequest", + "code": 7, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 1 }, { - "name": "DisableNetwork", - "code": 14, + "name": "SkipForwardRequest", + "code": 8, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 1 }, { - "name": "GetLastNetworkCommissioningResult", - "code": 16, + "name": "SkipBackwardRequest", + "code": 9, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 1 } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } ] }, { - "name": "Network Commissioning", - "code": 43690, + "name": "Media Playback", + "code": 61441, "mfgCode": null, - "define": "NETWORK_COMMISSIONING_CLUSTER", + "define": "MEDIA_PLAYBACK_CLUSTER", "side": "server", "enabled": 0, "commands": [ { - "name": "ScanNetworksResponse", - "code": 1, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "AddWiFiNetworkResponse", - "code": 3, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "UpdateWiFiNetworkResponse", - "code": 5, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "AddThreadNetworkResponse", - "code": 7, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "UpdateThreadNetworkResponse", - "code": 9, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "RemoveNetworkResponse", - "code": 11, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "EnableNetworkResponse", - "code": 13, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "DisableNetworkResponse", - "code": 15, + "name": "Playback", + "code": 0, "mfgCode": null, "source": "server", "incoming": 1, @@ -3183,19 +3712,34 @@ "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 + }, + { + "name": "current state", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 } ] }, { - "name": "Binding", - "code": 61440, + "name": "Content Launch", + "code": 61442, "mfgCode": null, - "define": "BINDING_CLUSTER", + "define": "CONTENT_LAUNCH_CLUSTER", "side": "client", "enabled": 1, "commands": [ { - "name": "Bind", + "name": "LaunchContent", "code": 0, "mfgCode": null, "source": "client", @@ -3203,7 +3747,7 @@ "outgoing": 1 }, { - "name": "Unbind", + "name": "LaunchURL", "code": 1, "mfgCode": null, "source": "client", @@ -3230,12 +3774,30 @@ ] }, { - "name": "Binding", - "code": 61440, + "name": "Content Launch", + "code": 61442, "mfgCode": null, - "define": "BINDING_CLUSTER", + "define": "CONTENT_LAUNCH_CLUSTER", "side": "server", "enabled": 0, + "commands": [ + { + "name": "LaunchContentResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "LaunchURLResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], "attributes": [ { "name": "cluster revision", @@ -3252,8 +3814,7 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [] + ] } ] } diff --git a/src/darwin/Framework/CHIP/gen/CHIPClientCallbacks.cpp b/src/darwin/Framework/CHIP/gen/CHIPClientCallbacks.cpp index 58b3d84f2d05a3..71fe6c668cc75d 100644 --- a/src/darwin/Framework/CHIP/gen/CHIPClientCallbacks.cpp +++ b/src/darwin/Framework/CHIP/gen/CHIPClientCallbacks.cpp @@ -272,10 +272,6 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag case 0x38: // semi / Semi-precision case 0x39: // single / Single precision case 0x3A: // double / Double precision - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string case 0x48: // array / Array case 0x49: // struct / Structure case 0x50: // set / Set @@ -289,6 +285,48 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag return true; } + case 0x41: // octstr / Octet string + case 0x42: // string / Character string + { + // Short Strings must contains at least one byte for the length + CHECK_MESSAGE_LENGTH(1); + uint8_t length = chip::Encoding::Read8(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + + case 0x43: // octstr16 / Long octet string + case 0x44: // string16 / Long character string + { + // Long Strings must contains at least two bytes for the length + CHECK_MESSAGE_LENGTH(2); + uint16_t length = chip::Encoding::LittleEndian::Read16(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFFFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFFFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + case 0x08: // data8 / 8-bit data case 0x18: // map8 / 8-bit bitmap case 0x20: // uint8 / Unsigned 8-bit integer @@ -648,6 +686,32 @@ bool emberAfDiscoverCommandsReceivedResponseCallback(ClusterId clusterId, uint16 return true; } +bool emberAfContentLaunchClusterLaunchContentResponseCallback(uint8_t contentLaunchStatus) +{ + ChipLogProgress(Zcl, "LaunchContentResponse:"); + ChipLogProgress(Zcl, " contentLaunchStatus: %" PRIu8 "", contentLaunchStatus); + + GET_RESPONSE_CALLBACKS("ContentLaunchClusterLaunchContentResponseCallback"); + + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, contentLaunchStatus); + return true; +} + +bool emberAfContentLaunchClusterLaunchURLResponseCallback(uint8_t contentLaunchStatus) +{ + ChipLogProgress(Zcl, "LaunchURLResponse:"); + ChipLogProgress(Zcl, " contentLaunchStatus: %" PRIu8 "", contentLaunchStatus); + + GET_RESPONSE_CALLBACKS("ContentLaunchClusterLaunchURLResponseCallback"); + + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, contentLaunchStatus); + return true; +} + bool emberAfDoorLockClusterClearAllPinsResponseCallback(uint8_t status) { ChipLogProgress(Zcl, "ClearAllPinsResponse:"); @@ -1132,6 +1196,48 @@ bool emberAfDoorLockClusterUnlockWithTimeoutResponseCallback(uint8_t status) return true; } +bool emberAfGeneralCommissioningClusterArmFailSafeResponseCallback(uint8_t errorCode, uint8_t * debugText) +{ + ChipLogProgress(Zcl, "ArmFailSafeResponse:"); + ChipLogProgress(Zcl, " errorCode: %" PRIu8 "", errorCode); + ChipLogProgress(Zcl, " debugText: %s", debugText); + + GET_RESPONSE_CALLBACKS("GeneralCommissioningClusterArmFailSafeResponseCallback"); + + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, errorCode, debugText); + return true; +} + +bool emberAfGeneralCommissioningClusterCommissioningCompleteResponseCallback(uint8_t errorCode, uint8_t * debugText) +{ + ChipLogProgress(Zcl, "CommissioningCompleteResponse:"); + ChipLogProgress(Zcl, " errorCode: %" PRIu8 "", errorCode); + ChipLogProgress(Zcl, " debugText: %s", debugText); + + GET_RESPONSE_CALLBACKS("GeneralCommissioningClusterCommissioningCompleteResponseCallback"); + + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, errorCode, debugText); + return true; +} + +bool emberAfGeneralCommissioningClusterSetFabricResponseCallback(uint8_t errorCode, uint8_t * debugText) +{ + ChipLogProgress(Zcl, "SetFabricResponse:"); + ChipLogProgress(Zcl, " errorCode: %" PRIu8 "", errorCode); + ChipLogProgress(Zcl, " debugText: %s", debugText); + + GET_RESPONSE_CALLBACKS("GeneralCommissioningClusterSetFabricResponseCallback"); + + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, errorCode, debugText); + return true; +} + bool emberAfGroupsClusterAddGroupResponseCallback(uint8_t status, uint16_t groupId) { ChipLogProgress(Zcl, "AddGroupResponse:"); @@ -1421,10 +1527,6 @@ bool emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * message, uin case 0x38: // semi / Semi-precision case 0x39: // single / Single precision case 0x3A: // double / Double precision - case 0x41: // octstr / Octet string - case 0x42: // string / Character string - case 0x43: // octstr16 / Long octet string - case 0x44: // string16 / Long character string case 0x48: // array / Array case 0x49: // struct / Structure case 0x50: // set / Set @@ -1435,6 +1537,48 @@ bool emberAfReportAttributesCallback(ClusterId clusterId, uint8_t * message, uin return true; } + case 0x41: // octstr / Octet string + case 0x42: // string / Character string + { + // Short Strings must contains at least one byte for the length + CHECK_MESSAGE_LENGTH(1); + uint8_t length = chip::Encoding::Read8(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onReportCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + + case 0x43: // octstr16 / Long octet string + case 0x44: // string16 / Long character string + { + // Long Strings must contains at least two bytes for the length + CHECK_MESSAGE_LENGTH(2); + uint16_t length = chip::Encoding::LittleEndian::Read16(message); + ChipLogProgress(Zcl, " length: 0x%02x", length); + + // When the length is set to 0xFFFF, it represents a non-value. In this case the data field is zero length. + if (length == 0xFFFF) + { + length = 0; + } + + CHECK_MESSAGE_LENGTH(length); + Callback::Callback * cb = + Callback::Callback::FromCancelable(onReportCallback); + cb->mCall(cb->mContext, chip::ByteSpan(message, length)); + break; + } + case 0x08: // data8 / 8-bit data case 0x18: // map8 / 8-bit bitmap case 0x20: // uint8 / Unsigned 8-bit integer diff --git a/src/darwin/Framework/CHIP/gen/CHIPClientCallbacks.h b/src/darwin/Framework/CHIP/gen/CHIPClientCallbacks.h index 3e88cfc5aaef88..00c37b8efd445a 100644 --- a/src/darwin/Framework/CHIP/gen/CHIPClientCallbacks.h +++ b/src/darwin/Framework/CHIP/gen/CHIPClientCallbacks.h @@ -20,6 +20,7 @@ #pragma once #include +#include // Global Response Callbacks typedef void (*DefaultSuccessCallback)(void * context); @@ -33,10 +34,13 @@ typedef void (*Int32uAttributeCallback)(void * context, uint32_t value); typedef void (*Int32sAttributeCallback)(void * context, int32_t value); typedef void (*Int64uAttributeCallback)(void * context, uint64_t value); typedef void (*Int64sAttributeCallback)(void * context, int64_t value); +typedef void (*StringAttributeCallback)(void * context, const chip::ByteSpan value); typedef void (*ReadReportingConfigurationReportedCallback)(void * context, uint16_t minInterval, uint16_t maxInterval); typedef void (*ReadReportingConfigurationReceivedCallback)(void * context, uint16_t timeout); // Cluster Specific Response Callbacks +typedef void (*ContentLaunchClusterLaunchContentResponseCallback)(void * context, uint8_t contentLaunchStatus); +typedef void (*ContentLaunchClusterLaunchURLResponseCallback)(void * context, uint8_t contentLaunchStatus); typedef void (*DoorLockClusterClearAllPinsResponseCallback)(void * context); typedef void (*DoorLockClusterClearAllRfidsResponseCallback)(void * context); typedef void (*DoorLockClusterClearHolidayScheduleResponseCallback)(void * context); @@ -68,12 +72,17 @@ typedef void (*DoorLockClusterSetWeekdayScheduleResponseCallback)(void * context typedef void (*DoorLockClusterSetYeardayScheduleResponseCallback)(void * context); typedef void (*DoorLockClusterUnlockDoorResponseCallback)(void * context); typedef void (*DoorLockClusterUnlockWithTimeoutResponseCallback)(void * context); +typedef void (*GeneralCommissioningClusterArmFailSafeResponseCallback)(void * context, uint8_t errorCode, uint8_t * debugText); +typedef void (*GeneralCommissioningClusterCommissioningCompleteResponseCallback)(void * context, uint8_t errorCode, + uint8_t * debugText); +typedef void (*GeneralCommissioningClusterSetFabricResponseCallback)(void * context, uint8_t errorCode, uint8_t * debugText); typedef void (*GroupsClusterAddGroupResponseCallback)(void * context, uint16_t groupId); typedef void (*GroupsClusterGetGroupMembershipResponseCallback)(void * context, uint8_t capacity, uint8_t groupCount, /* TYPE WARNING: array array defaults to */ uint8_t * groupList); typedef void (*GroupsClusterRemoveGroupResponseCallback)(void * context, uint16_t groupId); typedef void (*GroupsClusterViewGroupResponseCallback)(void * context, uint16_t groupId, uint8_t * groupName); typedef void (*IdentifyClusterIdentifyQueryResponseCallback)(void * context, uint16_t timeout); +typedef void (*MediaPlaybackClusterPlaybackCallback)(void * context); typedef void (*ScenesClusterAddSceneResponseCallback)(void * context, uint16_t groupId, uint8_t sceneId); typedef void (*ScenesClusterGetSceneMembershipResponseCallback)(void * context, uint8_t capacity, uint16_t groupId, uint8_t sceneCount, diff --git a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h index adfa1de1e1dd32..847dc97c76ec21 100644 --- a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h +++ b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h @@ -42,6 +42,23 @@ NS_ASSUME_NONNULL_BEGIN @end +/** + * Cluster Application Basic + * + */ +@interface CHIPApplicationBasic : CHIPCluster + +- (void)readAttributeVendorName:(ResponseHandler)completionHandler; +- (void)readAttributeVendorId:(ResponseHandler)completionHandler; +- (void)readAttributeApplicationName:(ResponseHandler)completionHandler; +- (void)readAttributeProductId:(ResponseHandler)completionHandler; +- (void)readAttributeApplicationId:(ResponseHandler)completionHandler; +- (void)readAttributeCatalogVendorId:(ResponseHandler)completionHandler; +- (void)readAttributeApplicationSatus:(ResponseHandler)completionHandler; +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler; + +@end + /** * Cluster Barrier Control * @@ -66,10 +83,20 @@ NS_ASSUME_NONNULL_BEGIN @interface CHIPBasic : CHIPCluster - (void)mfgSpecificPing:(ResponseHandler)completionHandler; -- (void)resetToFactoryDefaults:(ResponseHandler)completionHandler; -- (void)readAttributeZclVersion:(ResponseHandler)completionHandler; -- (void)readAttributePowerSource:(ResponseHandler)completionHandler; +- (void)readAttributeInteractionModelVersion:(ResponseHandler)completionHandler; +- (void)readAttributeVendorName:(ResponseHandler)completionHandler; +- (void)readAttributeVendorID:(ResponseHandler)completionHandler; +- (void)readAttributeProductName:(ResponseHandler)completionHandler; +- (void)readAttributeProductID:(ResponseHandler)completionHandler; +- (void)readAttributeUserLabel:(ResponseHandler)completionHandler; +- (void)writeAttributeUserLabel:(NSString *)value completionHandler:(ResponseHandler)completionHandler; +- (void)readAttributeLocation:(ResponseHandler)completionHandler; +- (void)writeAttributeLocation:(NSString *)value completionHandler:(ResponseHandler)completionHandler; +- (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler; +- (void)readAttributeHardwareVersionString:(ResponseHandler)completionHandler; +- (void)readAttributeSoftwareVersion:(ResponseHandler)completionHandler; +- (void)readAttributeSoftwareVersionString:(ResponseHandler)completionHandler; - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler; @end @@ -273,6 +300,19 @@ NS_ASSUME_NONNULL_BEGIN @end +/** + * Cluster Content Launch + * + */ +@interface CHIPContentLaunch : CHIPCluster + +- (void)launchContent:(ResponseHandler)completionHandler; +- (void)launchURL:(ResponseHandler)completionHandler; + +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler; + +@end + /** * Cluster Door Lock * @@ -293,7 +333,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)getUserType:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler; - (void)getWeekdaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler; - (void)getYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler; -- (void)lockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandler; +- (void)lockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHandler; - (void)setHolidaySchedule:(uint8_t)scheduleId localStartTime:(uint32_t)localStartTime localEndTime:(uint32_t)localEndTime @@ -302,12 +342,12 @@ NS_ASSUME_NONNULL_BEGIN - (void)setPin:(uint16_t)userId userStatus:(uint8_t)userStatus userType:(uint8_t)userType - pin:(char *)pin + pin:(NSString *)pin completionHandler:(ResponseHandler)completionHandler; - (void)setRfid:(uint16_t)userId userStatus:(uint8_t)userStatus userType:(uint8_t)userType - id:(char *)id + id:(NSString *)id completionHandler:(ResponseHandler)completionHandler; - (void)setUserType:(uint16_t)userId userType:(uint8_t)userType completionHandler:(ResponseHandler)completionHandler; - (void)setWeekdaySchedule:(uint8_t)scheduleId @@ -323,8 +363,8 @@ NS_ASSUME_NONNULL_BEGIN localStartTime:(uint32_t)localStartTime localEndTime:(uint32_t)localEndTime completionHandler:(ResponseHandler)completionHandler; -- (void)unlockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandler; -- (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(char *)pin completionHandler:(ResponseHandler)completionHandler; +- (void)unlockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHandler; +- (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(NSString *)pin completionHandler:(ResponseHandler)completionHandler; - (void)readAttributeLockState:(ResponseHandler)completionHandler; - (void)configureAttributeLockState:(uint16_t)minInterval @@ -337,14 +377,40 @@ NS_ASSUME_NONNULL_BEGIN @end +/** + * Cluster General Commissioning + * + */ +@interface CHIPGeneralCommissioning : CHIPCluster + +- (void)armFailSafe:(uint16_t)expiryLengthSeconds + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)commissioningComplete:(ResponseHandler)completionHandler; +- (void)setFabric:(NSData *)fabricId + fabricSecret:(NSData *)fabricSecret + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; + +- (void)readAttributeFabricId:(ResponseHandler)completionHandler; +- (void)readAttributeBreadcrumb:(ResponseHandler)completionHandler; +- (void)writeAttributeBreadcrumb:(uint64_t)value completionHandler:(ResponseHandler)completionHandler; +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler; + +@end + /** * Cluster Groups * */ @interface CHIPGroups : CHIPCluster -- (void)addGroup:(uint16_t)groupId groupName:(char *)groupName completionHandler:(ResponseHandler)completionHandler; -- (void)addGroupIfIdentifying:(uint16_t)groupId groupName:(char *)groupName completionHandler:(ResponseHandler)completionHandler; +- (void)addGroup:(uint16_t)groupId groupName:(NSString *)groupName completionHandler:(ResponseHandler)completionHandler; +- (void)addGroupIfIdentifying:(uint16_t)groupId + groupName:(NSString *)groupName + completionHandler:(ResponseHandler)completionHandler; - (void)getGroupMembership:(uint8_t)groupCount groupList:(uint16_t)groupList completionHandler:(ResponseHandler)completionHandler; - (void)removeAllGroups:(ResponseHandler)completionHandler; - (void)removeGroup:(uint16_t)groupId completionHandler:(ResponseHandler)completionHandler; @@ -413,6 +479,40 @@ NS_ASSUME_NONNULL_BEGIN @end +/** + * Cluster Low Power + * + */ +@interface CHIPLowPower : CHIPCluster + +- (void)sleep:(ResponseHandler)completionHandler; + +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler; + +@end + +/** + * Cluster Media Playback + * + */ +@interface CHIPMediaPlayback : CHIPCluster + +- (void)fastForwardRequest:(ResponseHandler)completionHandler; +- (void)nextRequest:(ResponseHandler)completionHandler; +- (void)pauseRequest:(ResponseHandler)completionHandler; +- (void)playRequest:(ResponseHandler)completionHandler; +- (void)previousRequest:(ResponseHandler)completionHandler; +- (void)rewindRequest:(ResponseHandler)completionHandler; +- (void)skipBackwardRequest:(ResponseHandler)completionHandler; +- (void)skipForwardRequest:(ResponseHandler)completionHandler; +- (void)startOverRequest:(ResponseHandler)completionHandler; +- (void)stopRequest:(ResponseHandler)completionHandler; + +- (void)readAttributeCurrentState:(ResponseHandler)completionHandler; +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler; + +@end + /** * Cluster On/off * @@ -441,7 +541,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)addScene:(uint16_t)groupId sceneId:(uint8_t)sceneId transitionTime:(uint16_t)transitionTime - sceneName:(char *)sceneName + sceneName:(NSString *)sceneName clusterId:(uint16_t)clusterId length:(uint8_t)length value:(uint8_t)value diff --git a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm index 3c869a7540b9ca..cd60722f9897d6 100644 --- a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm +++ b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm @@ -89,26 +89,38 @@ static void CallbackFn(void * context, uint8_t status) dispatch_queue_t mQueue; }; -class CHIPUnsupportedAttributeCallbackBridge : public Callback::Callback { +class CHIPStringAttributeCallbackBridge : public Callback::Callback { public: - CHIPUnsupportedAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) - : Callback::Callback(CallbackFn, this) + CHIPStringAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool octetString, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mOctetString(octetString) + , mKeepAlive(keepAlive) { } - ~CHIPUnsupportedAttributeCallbackBridge() {}; + ~CHIPStringAttributeCallbackBridge() {}; - static void CallbackFn(void * context) + static void CallbackFn(void * context, chip::ByteSpan value) { - CHIPUnsupportedAttributeCallbackBridge * callback = reinterpret_cast(context); + CHIPStringAttributeCallbackBridge * callback = reinterpret_cast(context); if (callback && callback->mQueue) { dispatch_async(callback->mQueue, ^{ - NSError * error = [NSError errorWithDomain:CHIPErrorDomain - code:CHIPErrorCodeUndefinedError - userInfo:@ { NSLocalizedDescriptionKey : @"Unsupported attribute type" }]; - callback->mHandler(error, nil); - callback->Cancel(); - delete callback; + if (callback->mOctetString) { + NSData * data = [NSData dataWithBytes:value.data() length:value.size()]; + callback->mHandler(nil, @ { @"value" : data }); + } else { + NSString * str = [[NSString alloc] initWithBytes:value.data() + length:value.size() + encoding:NSUTF8StringEncoding]; + callback->mHandler(nil, @ { @"value" : str }); + } + + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } }); } }; @@ -116,6 +128,8 @@ static void CallbackFn(void * context) private: ResponseHandler mHandler; dispatch_queue_t mQueue; + bool mOctetString; + bool mKeepAlive; }; class CHIPBooleanAttributeCallbackBridge : public Callback::Callback { @@ -246,6 +260,38 @@ static void CallbackFn(void * context, uint16_t value) bool mKeepAlive; }; +class CHIPInt32uAttributeCallbackBridge : public Callback::Callback { +public: + CHIPInt32uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mKeepAlive(keepAlive) + { + } + + ~CHIPInt32uAttributeCallbackBridge() {}; + + static void CallbackFn(void * context, uint32_t value) + { + CHIPInt32uAttributeCallbackBridge * callback = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedLong:value] }); + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; + bool mKeepAlive; +}; + class CHIPInt16sAttributeCallbackBridge : public Callback::Callback { public: CHIPInt16sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) @@ -278,6 +324,70 @@ static void CallbackFn(void * context, int16_t value) bool mKeepAlive; }; +class CHIPContentLaunchClusterLaunchContentResponseCallbackBridge + : public Callback::Callback { +public: + CHIPContentLaunchClusterLaunchContentResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + { + } + + ~CHIPContentLaunchClusterLaunchContentResponseCallbackBridge() {}; + + static void CallbackFn(void * context, uint8_t contentLaunchStatus) + { + CHIPContentLaunchClusterLaunchContentResponseCallbackBridge * callback + = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @ { + @"contentLaunchStatus" : [NSNumber numberWithUnsignedChar:contentLaunchStatus], + }); + callback->Cancel(); + delete callback; + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; +}; + +class CHIPContentLaunchClusterLaunchURLResponseCallbackBridge + : public Callback::Callback { +public: + CHIPContentLaunchClusterLaunchURLResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + { + } + + ~CHIPContentLaunchClusterLaunchURLResponseCallbackBridge() {}; + + static void CallbackFn(void * context, uint8_t contentLaunchStatus) + { + CHIPContentLaunchClusterLaunchURLResponseCallbackBridge * callback + = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @ { + @"contentLaunchStatus" : [NSNumber numberWithUnsignedChar:contentLaunchStatus], + }); + callback->Cancel(); + delete callback; + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; +}; + class CHIPDoorLockClusterClearAllPinsResponseCallbackBridge : public Callback::Callback { public: @@ -1000,6 +1110,105 @@ static void CallbackFn(void * context) dispatch_queue_t mQueue; }; +class CHIPGeneralCommissioningClusterArmFailSafeResponseCallbackBridge + : public Callback::Callback { +public: + CHIPGeneralCommissioningClusterArmFailSafeResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + { + } + + ~CHIPGeneralCommissioningClusterArmFailSafeResponseCallbackBridge() {}; + + static void CallbackFn(void * context, uint8_t errorCode, uint8_t * debugText) + { + CHIPGeneralCommissioningClusterArmFailSafeResponseCallbackBridge * callback + = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @ { + @"errorCode" : [NSNumber numberWithUnsignedChar:errorCode], + @"debugText" : [NSString stringWithFormat:@"%s", debugText], + }); + callback->Cancel(); + delete callback; + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; +}; + +class CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallbackBridge + : public Callback::Callback { +public: + CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + { + } + + ~CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallbackBridge() {}; + + static void CallbackFn(void * context, uint8_t errorCode, uint8_t * debugText) + { + CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallbackBridge * callback + = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @ { + @"errorCode" : [NSNumber numberWithUnsignedChar:errorCode], + @"debugText" : [NSString stringWithFormat:@"%s", debugText], + }); + callback->Cancel(); + delete callback; + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; +}; + +class CHIPGeneralCommissioningClusterSetFabricResponseCallbackBridge + : public Callback::Callback { +public: + CHIPGeneralCommissioningClusterSetFabricResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + { + } + + ~CHIPGeneralCommissioningClusterSetFabricResponseCallbackBridge() {}; + + static void CallbackFn(void * context, uint8_t errorCode, uint8_t * debugText) + { + CHIPGeneralCommissioningClusterSetFabricResponseCallbackBridge * callback + = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @ { + @"errorCode" : [NSNumber numberWithUnsignedChar:errorCode], + @"debugText" : [NSString stringWithFormat:@"%s", debugText], + }); + callback->Cancel(); + delete callback; + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; +}; + class CHIPGroupsClusterAddGroupResponseCallbackBridge : public Callback::Callback { public: CHIPGroupsClusterAddGroupResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) @@ -1162,6 +1371,35 @@ static void CallbackFn(void * context, uint16_t timeout) dispatch_queue_t mQueue; }; +class CHIPMediaPlaybackClusterPlaybackCallbackBridge : public Callback::Callback { +public: + CHIPMediaPlaybackClusterPlaybackCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + { + } + + ~CHIPMediaPlaybackClusterPlaybackCallbackBridge() {}; + + static void CallbackFn(void * context) + { + CHIPMediaPlaybackClusterPlaybackCallbackBridge * callback + = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @ {}); + callback->Cancel(); + delete callback; + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; +}; + class CHIPScenesClusterAddSceneResponseCallbackBridge : public Callback::Callback { public: CHIPScenesClusterAddSceneResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue) @@ -1394,20 +1632,21 @@ - (instancetype)initWithDevice:(CHIPDevice *)device endpoint:(EndpointId)endpoin } @end -@interface CHIPBarrierControl () -@property (readonly) Controller::BarrierControlCluster cppCluster; +@interface CHIPApplicationBasic () +@property (readonly) Controller::ApplicationBasicCluster cppCluster; @end -@implementation CHIPBarrierControl +@implementation CHIPApplicationBasic - (Controller::ClusterBase *)getCluster { return &_cppCluster; } -- (void)barrierControlGoToPercent:(uint8_t)percentOpen completionHandler:(ResponseHandler)completionHandler +- (void)readAttributeVendorName:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], true); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -1420,16 +1659,17 @@ - (void)barrierControlGoToPercent:(uint8_t)percentOpen completionHandler:(Respon return; } - CHIP_ERROR err = self.cppCluster.BarrierControlGoToPercent(onSuccess->Cancel(), onFailure->Cancel(), percentOpen); + CHIP_ERROR err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)barrierControlStop:(ResponseHandler)completionHandler + +- (void)readAttributeVendorId:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -1442,7 +1682,7 @@ - (void)barrierControlStop:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.BarrierControlStop(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeVendorId(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1450,9 +1690,10 @@ - (void)barrierControlStop:(ResponseHandler)completionHandler } } -- (void)readAttributeBarrierMovingState:(ResponseHandler)completionHandler +- (void)readAttributeApplicationName:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], true); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -1465,7 +1706,7 @@ - (void)readAttributeBarrierMovingState:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierMovingState(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeApplicationName(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1473,7 +1714,7 @@ - (void)readAttributeBarrierMovingState:(ResponseHandler)completionHandler } } -- (void)readAttributeBarrierSafetyStatus:(ResponseHandler)completionHandler +- (void)readAttributeProductId:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -1488,7 +1729,7 @@ - (void)readAttributeBarrierSafetyStatus:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierSafetyStatus(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeProductId(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1496,9 +1737,10 @@ - (void)readAttributeBarrierSafetyStatus:(ResponseHandler)completionHandler } } -- (void)readAttributeBarrierCapabilities:(ResponseHandler)completionHandler +- (void)readAttributeApplicationId:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], true); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -1511,7 +1753,7 @@ - (void)readAttributeBarrierCapabilities:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierCapabilities(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeApplicationId(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1519,7 +1761,30 @@ - (void)readAttributeBarrierCapabilities:(ResponseHandler)completionHandler } } -- (void)readAttributeBarrierPosition:(ResponseHandler)completionHandler +- (void)readAttributeCatalogVendorId:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeCatalogVendorId(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeApplicationSatus:(ResponseHandler)completionHandler { CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -1534,7 +1799,7 @@ - (void)readAttributeBarrierPosition:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierPosition(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeApplicationSatus(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1567,18 +1832,18 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler @end -@interface CHIPBasic () -@property (readonly) Controller::BasicCluster cppCluster; +@interface CHIPBarrierControl () +@property (readonly) Controller::BarrierControlCluster cppCluster; @end -@implementation CHIPBasic +@implementation CHIPBarrierControl - (Controller::ClusterBase *)getCluster { return &_cppCluster; } -- (void)mfgSpecificPing:(ResponseHandler)completionHandler +- (void)barrierControlGoToPercent:(uint8_t)percentOpen completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -1593,14 +1858,14 @@ - (void)mfgSpecificPing:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.MfgSpecificPing(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.BarrierControlGoToPercent(onSuccess->Cancel(), onFailure->Cancel(), percentOpen); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)resetToFactoryDefaults:(ResponseHandler)completionHandler +- (void)barrierControlStop:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -1615,7 +1880,7 @@ - (void)resetToFactoryDefaults:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ResetToFactoryDefaults(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.BarrierControlStop(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1623,7 +1888,7 @@ - (void)resetToFactoryDefaults:(ResponseHandler)completionHandler } } -- (void)readAttributeZclVersion:(ResponseHandler)completionHandler +- (void)readAttributeBarrierMovingState:(ResponseHandler)completionHandler { CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -1638,7 +1903,7 @@ - (void)readAttributeZclVersion:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeZclVersion(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierMovingState(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1646,9 +1911,9 @@ - (void)readAttributeZclVersion:(ResponseHandler)completionHandler } } -- (void)readAttributePowerSource:(ResponseHandler)completionHandler +- (void)readAttributeBarrierSafetyStatus:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -1661,7 +1926,7 @@ - (void)readAttributePowerSource:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePowerSource(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierSafetyStatus(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1669,9 +1934,9 @@ - (void)readAttributePowerSource:(ResponseHandler)completionHandler } } -- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler +- (void)readAttributeBarrierCapabilities:(ResponseHandler)completionHandler { - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -1684,7 +1949,7 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierCapabilities(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1692,26 +1957,9 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler } } -@end - -@interface CHIPBinding () -@property (readonly) Controller::BindingCluster cppCluster; -@end - -@implementation CHIPBinding - -- (Controller::ClusterBase *)getCluster +- (void)readAttributeBarrierPosition:(ResponseHandler)completionHandler { - return &_cppCluster; -} - -- (void)bind:(uint64_t)nodeId - groupId:(uint16_t)groupId - endpointId:(uint8_t)endpointId - clusterId:(uint16_t)clusterId - completionHandler:(ResponseHandler)completionHandler -{ - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -1724,20 +1972,17 @@ - (void)bind:(uint64_t)nodeId return; } - CHIP_ERROR err = self.cppCluster.Bind(onSuccess->Cancel(), onFailure->Cancel(), nodeId, groupId, endpointId, clusterId); + CHIP_ERROR err = self.cppCluster.ReadAttributeBarrierPosition(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)unbind:(uint64_t)nodeId - groupId:(uint16_t)groupId - endpointId:(uint8_t)endpointId - clusterId:(uint16_t)clusterId - completionHandler:(ResponseHandler)completionHandler + +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -1750,7 +1995,7 @@ - (void)unbind:(uint64_t)nodeId return; } - CHIP_ERROR err = self.cppCluster.Unbind(onSuccess->Cancel(), onFailure->Cancel(), nodeId, groupId, endpointId, clusterId); + CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1758,9 +2003,22 @@ - (void)unbind:(uint64_t)nodeId } } -- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler +@end + +@interface CHIPBasic () +@property (readonly) Controller::BasicCluster cppCluster; +@end + +@implementation CHIPBasic + +- (Controller::ClusterBase *)getCluster { - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + return &_cppCluster; +} + +- (void)mfgSpecificPing:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -1773,7 +2031,7 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.MfgSpecificPing(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -1781,26 +2039,9 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler } } -@end - -@interface CHIPColorControl () -@property (readonly) Controller::ColorControlCluster cppCluster; -@end - -@implementation CHIPColorControl - -- (Controller::ClusterBase *)getCluster -{ - return &_cppCluster; -} - -- (void)moveColor:(int16_t)rateX - rateY:(int16_t)rateY - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - completionHandler:(ResponseHandler)completionHandler +- (void)readAttributeInteractionModelVersion:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -1813,23 +2054,18 @@ - (void)moveColor:(int16_t)rateX return; } - CHIP_ERROR err - = self.cppCluster.MoveColor(onSuccess->Cancel(), onFailure->Cancel(), rateX, rateY, optionsMask, optionsOverride); + CHIP_ERROR err = self.cppCluster.ReadAttributeInteractionModelVersion(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)moveColorTemperature:(uint8_t)moveMode - rate:(uint16_t)rate - colorTemperatureMinimum:(uint16_t)colorTemperatureMinimum - colorTemperatureMaximum:(uint16_t)colorTemperatureMaximum - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - completionHandler:(ResponseHandler)completionHandler + +- (void)readAttributeVendorName:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -1842,21 +2078,17 @@ - (void)moveColorTemperature:(uint8_t)moveMode return; } - CHIP_ERROR err = self.cppCluster.MoveColorTemperature(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, - colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride); + CHIP_ERROR err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)moveHue:(uint8_t)moveMode - rate:(uint8_t)rate - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - completionHandler:(ResponseHandler)completionHandler + +- (void)readAttributeVendorID:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -1869,21 +2101,18 @@ - (void)moveHue:(uint8_t)moveMode return; } - CHIP_ERROR err - = self.cppCluster.MoveHue(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride); + CHIP_ERROR err = self.cppCluster.ReadAttributeVendorID(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)moveSaturation:(uint8_t)moveMode - rate:(uint8_t)rate - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - completionHandler:(ResponseHandler)completionHandler + +- (void)readAttributeProductName:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -1896,22 +2125,17 @@ - (void)moveSaturation:(uint8_t)moveMode return; } - CHIP_ERROR err - = self.cppCluster.MoveSaturation(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride); + CHIP_ERROR err = self.cppCluster.ReadAttributeProductName(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)moveToColor:(uint16_t)colorX - colorY:(uint16_t)colorY - transitionTime:(uint16_t)transitionTime - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - completionHandler:(ResponseHandler)completionHandler + +- (void)readAttributeProductID:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -1924,21 +2148,18 @@ - (void)moveToColor:(uint16_t)colorX return; } - CHIP_ERROR err = self.cppCluster.MoveToColor( - onSuccess->Cancel(), onFailure->Cancel(), colorX, colorY, transitionTime, optionsMask, optionsOverride); + CHIP_ERROR err = self.cppCluster.ReadAttributeProductID(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)moveToColorTemperature:(uint16_t)colorTemperature - transitionTime:(uint16_t)transitionTime - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - completionHandler:(ResponseHandler)completionHandler + +- (void)readAttributeUserLabel:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -1951,20 +2172,15 @@ - (void)moveToColorTemperature:(uint16_t)colorTemperature return; } - CHIP_ERROR err = self.cppCluster.MoveToColorTemperature( - onSuccess->Cancel(), onFailure->Cancel(), colorTemperature, transitionTime, optionsMask, optionsOverride); + CHIP_ERROR err = self.cppCluster.ReadAttributeUserLabel(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)moveToHue:(uint8_t)hue - direction:(uint8_t)direction - transitionTime:(uint16_t)transitionTime - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - completionHandler:(ResponseHandler)completionHandler + +- (void)writeAttributeUserLabel:(NSString *)value completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -1979,22 +2195,20 @@ - (void)moveToHue:(uint8_t)hue return; } - CHIP_ERROR err = self.cppCluster.MoveToHue( - onSuccess->Cancel(), onFailure->Cancel(), hue, direction, transitionTime, optionsMask, optionsOverride); + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + CHIP_ERROR err = self.cppCluster.WriteAttributeUserLabel( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)moveToHueAndSaturation:(uint8_t)hue - saturation:(uint8_t)saturation - transitionTime:(uint16_t)transitionTime - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - completionHandler:(ResponseHandler)completionHandler + +- (void)readAttributeLocation:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2007,19 +2221,15 @@ - (void)moveToHueAndSaturation:(uint8_t)hue return; } - CHIP_ERROR err = self.cppCluster.MoveToHueAndSaturation( - onSuccess->Cancel(), onFailure->Cancel(), hue, saturation, transitionTime, optionsMask, optionsOverride); + CHIP_ERROR err = self.cppCluster.ReadAttributeLocation(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)moveToSaturation:(uint8_t)saturation - transitionTime:(uint16_t)transitionTime - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - completionHandler:(ResponseHandler)completionHandler + +- (void)writeAttributeLocation:(NSString *)value completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2034,22 +2244,19 @@ - (void)moveToSaturation:(uint8_t)saturation return; } - CHIP_ERROR err = self.cppCluster.MoveToSaturation( - onSuccess->Cancel(), onFailure->Cancel(), saturation, transitionTime, optionsMask, optionsOverride); + NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding]; + CHIP_ERROR err = self.cppCluster.WriteAttributeLocation( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length)); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)stepColor:(int16_t)stepX - stepY:(int16_t)stepY - transitionTime:(uint16_t)transitionTime - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - completionHandler:(ResponseHandler)completionHandler + +- (void)readAttributeHardwareVersion:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2062,24 +2269,18 @@ - (void)stepColor:(int16_t)stepX return; } - CHIP_ERROR err = self.cppCluster.StepColor( - onSuccess->Cancel(), onFailure->Cancel(), stepX, stepY, transitionTime, optionsMask, optionsOverride); + CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersion(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)stepColorTemperature:(uint8_t)stepMode - stepSize:(uint16_t)stepSize - transitionTime:(uint16_t)transitionTime - colorTemperatureMinimum:(uint16_t)colorTemperatureMinimum - colorTemperatureMaximum:(uint16_t)colorTemperatureMaximum - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - completionHandler:(ResponseHandler)completionHandler + +- (void)readAttributeHardwareVersionString:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2092,22 +2293,17 @@ - (void)stepColorTemperature:(uint8_t)stepMode return; } - CHIP_ERROR err = self.cppCluster.StepColorTemperature(onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, - transitionTime, colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride); + CHIP_ERROR err = self.cppCluster.ReadAttributeHardwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)stepHue:(uint8_t)stepMode - stepSize:(uint8_t)stepSize - transitionTime:(uint8_t)transitionTime - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - completionHandler:(ResponseHandler)completionHandler + +- (void)readAttributeSoftwareVersion:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2120,22 +2316,18 @@ - (void)stepHue:(uint8_t)stepMode return; } - CHIP_ERROR err = self.cppCluster.StepHue( - onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, optionsOverride); + CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersion(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)stepSaturation:(uint8_t)stepMode - stepSize:(uint8_t)stepSize - transitionTime:(uint8_t)transitionTime - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - completionHandler:(ResponseHandler)completionHandler + +- (void)readAttributeSoftwareVersionString:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2148,19 +2340,17 @@ - (void)stepSaturation:(uint8_t)stepMode return; } - CHIP_ERROR err = self.cppCluster.StepSaturation( - onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, optionsOverride); + CHIP_ERROR err = self.cppCluster.ReadAttributeSoftwareVersionString(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)stopMoveStep:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - completionHandler:(ResponseHandler)completionHandler + +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2173,7 +2363,7 @@ - (void)stopMoveStep:(uint8_t)optionsMask return; } - CHIP_ERROR err = self.cppCluster.StopMoveStep(onSuccess->Cancel(), onFailure->Cancel(), optionsMask, optionsOverride); + CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2181,9 +2371,26 @@ - (void)stopMoveStep:(uint8_t)optionsMask } } -- (void)readAttributeCurrentHue:(ResponseHandler)completionHandler +@end + +@interface CHIPBinding () +@property (readonly) Controller::BindingCluster cppCluster; +@end + +@implementation CHIPBinding + +- (Controller::ClusterBase *)getCluster { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + return &_cppCluster; +} + +- (void)bind:(uint64_t)nodeId + groupId:(uint16_t)groupId + endpointId:(uint8_t)endpointId + clusterId:(uint16_t)clusterId + completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2196,18 +2403,18 @@ - (void)readAttributeCurrentHue:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentHue(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.Bind(onSuccess->Cancel(), onFailure->Cancel(), nodeId, groupId, endpointId, clusterId); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)configureAttributeCurrentHue:(uint16_t)minInterval - maxInterval:(uint16_t)maxInterval - change:(uint8_t)change - completionHandler:(ResponseHandler)completionHandler +- (void)unbind:(uint64_t)nodeId + groupId:(uint16_t)groupId + endpointId:(uint8_t)endpointId + clusterId:(uint16_t)clusterId + completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2222,8 +2429,7 @@ - (void)configureAttributeCurrentHue:(uint16_t)minInterval return; } - CHIP_ERROR err - = self.cppCluster.ConfigureAttributeCurrentHue(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + CHIP_ERROR err = self.cppCluster.Unbind(onSuccess->Cancel(), onFailure->Cancel(), nodeId, groupId, endpointId, clusterId); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2231,24 +2437,1080 @@ - (void)configureAttributeCurrentHue:(uint16_t)minInterval } } -- (void)reportAttributeCurrentHue:(ResponseHandler)reportHandler +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onReport = new CHIPInt8uAttributeCallbackBridge(reportHandler, [self callbackQueue], true); - if (!onReport) { - reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentHue(onReport->Cancel()); + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { - delete onReport; - reportHandler([CHIPError errorForCHIPErrorCode:err], nil); + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)readAttributeCurrentSaturation:(ResponseHandler)completionHandler -{ - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); +@end + +@interface CHIPColorControl () +@property (readonly) Controller::ColorControlCluster cppCluster; +@end + +@implementation CHIPColorControl + +- (Controller::ClusterBase *)getCluster +{ + return &_cppCluster; +} + +- (void)moveColor:(int16_t)rateX + rateY:(int16_t)rateY + optionsMask:(uint8_t)optionsMask + optionsOverride:(uint8_t)optionsOverride + completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err + = self.cppCluster.MoveColor(onSuccess->Cancel(), onFailure->Cancel(), rateX, rateY, optionsMask, optionsOverride); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)moveColorTemperature:(uint8_t)moveMode + rate:(uint16_t)rate + colorTemperatureMinimum:(uint16_t)colorTemperatureMinimum + colorTemperatureMaximum:(uint16_t)colorTemperatureMaximum + optionsMask:(uint8_t)optionsMask + optionsOverride:(uint8_t)optionsOverride + completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.MoveColorTemperature(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, + colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)moveHue:(uint8_t)moveMode + rate:(uint8_t)rate + optionsMask:(uint8_t)optionsMask + optionsOverride:(uint8_t)optionsOverride + completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err + = self.cppCluster.MoveHue(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)moveSaturation:(uint8_t)moveMode + rate:(uint8_t)rate + optionsMask:(uint8_t)optionsMask + optionsOverride:(uint8_t)optionsOverride + completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err + = self.cppCluster.MoveSaturation(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)moveToColor:(uint16_t)colorX + colorY:(uint16_t)colorY + transitionTime:(uint16_t)transitionTime + optionsMask:(uint8_t)optionsMask + optionsOverride:(uint8_t)optionsOverride + completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.MoveToColor( + onSuccess->Cancel(), onFailure->Cancel(), colorX, colorY, transitionTime, optionsMask, optionsOverride); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)moveToColorTemperature:(uint16_t)colorTemperature + transitionTime:(uint16_t)transitionTime + optionsMask:(uint8_t)optionsMask + optionsOverride:(uint8_t)optionsOverride + completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.MoveToColorTemperature( + onSuccess->Cancel(), onFailure->Cancel(), colorTemperature, transitionTime, optionsMask, optionsOverride); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)moveToHue:(uint8_t)hue + direction:(uint8_t)direction + transitionTime:(uint16_t)transitionTime + optionsMask:(uint8_t)optionsMask + optionsOverride:(uint8_t)optionsOverride + completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.MoveToHue( + onSuccess->Cancel(), onFailure->Cancel(), hue, direction, transitionTime, optionsMask, optionsOverride); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)moveToHueAndSaturation:(uint8_t)hue + saturation:(uint8_t)saturation + transitionTime:(uint16_t)transitionTime + optionsMask:(uint8_t)optionsMask + optionsOverride:(uint8_t)optionsOverride + completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.MoveToHueAndSaturation( + onSuccess->Cancel(), onFailure->Cancel(), hue, saturation, transitionTime, optionsMask, optionsOverride); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)moveToSaturation:(uint8_t)saturation + transitionTime:(uint16_t)transitionTime + optionsMask:(uint8_t)optionsMask + optionsOverride:(uint8_t)optionsOverride + completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.MoveToSaturation( + onSuccess->Cancel(), onFailure->Cancel(), saturation, transitionTime, optionsMask, optionsOverride); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)stepColor:(int16_t)stepX + stepY:(int16_t)stepY + transitionTime:(uint16_t)transitionTime + optionsMask:(uint8_t)optionsMask + optionsOverride:(uint8_t)optionsOverride + completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.StepColor( + onSuccess->Cancel(), onFailure->Cancel(), stepX, stepY, transitionTime, optionsMask, optionsOverride); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)stepColorTemperature:(uint8_t)stepMode + stepSize:(uint16_t)stepSize + transitionTime:(uint16_t)transitionTime + colorTemperatureMinimum:(uint16_t)colorTemperatureMinimum + colorTemperatureMaximum:(uint16_t)colorTemperatureMaximum + optionsMask:(uint8_t)optionsMask + optionsOverride:(uint8_t)optionsOverride + completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.StepColorTemperature(onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, + transitionTime, colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)stepHue:(uint8_t)stepMode + stepSize:(uint8_t)stepSize + transitionTime:(uint8_t)transitionTime + optionsMask:(uint8_t)optionsMask + optionsOverride:(uint8_t)optionsOverride + completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.StepHue( + onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, optionsOverride); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)stepSaturation:(uint8_t)stepMode + stepSize:(uint8_t)stepSize + transitionTime:(uint8_t)transitionTime + optionsMask:(uint8_t)optionsMask + optionsOverride:(uint8_t)optionsOverride + completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.StepSaturation( + onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, optionsOverride); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)stopMoveStep:(uint8_t)optionsMask + optionsOverride:(uint8_t)optionsOverride + completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.StopMoveStep(onSuccess->Cancel(), onFailure->Cancel(), optionsMask, optionsOverride); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeCurrentHue:(ResponseHandler)completionHandler +{ + CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentHue(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)configureAttributeCurrentHue:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + change:(uint8_t)change + completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err + = self.cppCluster.ConfigureAttributeCurrentHue(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)reportAttributeCurrentHue:(ResponseHandler)reportHandler +{ + CHIPInt8uAttributeCallbackBridge * onReport = new CHIPInt8uAttributeCallbackBridge(reportHandler, [self callbackQueue], true); + if (!onReport) { + reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentHue(onReport->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onReport; + reportHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeCurrentSaturation:(ResponseHandler)completionHandler +{ + CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentSaturation(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)configureAttributeCurrentSaturation:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + change:(uint8_t)change + completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ConfigureAttributeCurrentSaturation( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)reportAttributeCurrentSaturation:(ResponseHandler)reportHandler +{ + CHIPInt8uAttributeCallbackBridge * onReport = new CHIPInt8uAttributeCallbackBridge(reportHandler, [self callbackQueue], true); + if (!onReport) { + reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentSaturation(onReport->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onReport; + reportHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeRemainingTime:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeRemainingTime(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeCurrentX:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentX(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)configureAttributeCurrentX:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + change:(uint16_t)change + completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err + = self.cppCluster.ConfigureAttributeCurrentX(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)reportAttributeCurrentX:(ResponseHandler)reportHandler +{ + CHIPInt16uAttributeCallbackBridge * onReport = new CHIPInt16uAttributeCallbackBridge(reportHandler, [self callbackQueue], true); + if (!onReport) { + reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentX(onReport->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onReport; + reportHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeCurrentY:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentY(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)configureAttributeCurrentY:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + change:(uint16_t)change + completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err + = self.cppCluster.ConfigureAttributeCurrentY(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)reportAttributeCurrentY:(ResponseHandler)reportHandler +{ + CHIPInt16uAttributeCallbackBridge * onReport = new CHIPInt16uAttributeCallbackBridge(reportHandler, [self callbackQueue], true); + if (!onReport) { + reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentY(onReport->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onReport; + reportHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeDriftCompensation:(ResponseHandler)completionHandler +{ + CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeDriftCompensation(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeCompensationText:(ResponseHandler)completionHandler +{ + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], false); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeCompensationText(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeColorTemperature:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeColorTemperature(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)configureAttributeColorTemperature:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + change:(uint16_t)change + completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ConfigureAttributeColorTemperature( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)reportAttributeColorTemperature:(ResponseHandler)reportHandler +{ + CHIPInt16uAttributeCallbackBridge * onReport = new CHIPInt16uAttributeCallbackBridge(reportHandler, [self callbackQueue], true); + if (!onReport) { + reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReportAttributeColorTemperature(onReport->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onReport; + reportHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeColorMode:(ResponseHandler)completionHandler +{ + CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeColorMode(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeColorControlOptions:(ResponseHandler)completionHandler +{ + CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeColorControlOptions(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)writeAttributeColorControlOptions:(uint8_t)value completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.WriteAttributeColorControlOptions(onSuccess->Cancel(), onFailure->Cancel(), value); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeNumberOfPrimaries:(ResponseHandler)completionHandler +{ + CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeNumberOfPrimaries(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributePrimary1X:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributePrimary1X(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributePrimary1Y:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributePrimary1Y(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributePrimary1Intensity:(ResponseHandler)completionHandler +{ + CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributePrimary1Intensity(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributePrimary2X:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributePrimary2X(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributePrimary2Y:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributePrimary2Y(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributePrimary2Intensity:(ResponseHandler)completionHandler +{ + CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributePrimary2Intensity(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributePrimary3X:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributePrimary3X(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributePrimary3Y:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2261,7 +3523,7 @@ - (void)readAttributeCurrentSaturation:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentSaturation(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributePrimary3Y(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2269,12 +3531,9 @@ - (void)readAttributeCurrentSaturation:(ResponseHandler)completionHandler } } -- (void)configureAttributeCurrentSaturation:(uint16_t)minInterval - maxInterval:(uint16_t)maxInterval - change:(uint8_t)change - completionHandler:(ResponseHandler)completionHandler +- (void)readAttributePrimary3Intensity:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2287,8 +3546,7 @@ - (void)configureAttributeCurrentSaturation:(uint16_t)minInterval return; } - CHIP_ERROR err = self.cppCluster.ConfigureAttributeCurrentSaturation( - onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + CHIP_ERROR err = self.cppCluster.ReadAttributePrimary3Intensity(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2296,22 +3554,7 @@ - (void)configureAttributeCurrentSaturation:(uint16_t)minInterval } } -- (void)reportAttributeCurrentSaturation:(ResponseHandler)reportHandler -{ - CHIPInt8uAttributeCallbackBridge * onReport = new CHIPInt8uAttributeCallbackBridge(reportHandler, [self callbackQueue], true); - if (!onReport) { - reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentSaturation(onReport->Cancel()); - if (err != CHIP_NO_ERROR) { - delete onReport; - reportHandler([CHIPError errorForCHIPErrorCode:err], nil); - } -} - -- (void)readAttributeRemainingTime:(ResponseHandler)completionHandler +- (void)readAttributePrimary4X:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2326,7 +3569,7 @@ - (void)readAttributeRemainingTime:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeRemainingTime(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributePrimary4X(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2334,7 +3577,7 @@ - (void)readAttributeRemainingTime:(ResponseHandler)completionHandler } } -- (void)readAttributeCurrentX:(ResponseHandler)completionHandler +- (void)readAttributePrimary4Y:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2349,7 +3592,7 @@ - (void)readAttributeCurrentX:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentX(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributePrimary4Y(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2357,12 +3600,9 @@ - (void)readAttributeCurrentX:(ResponseHandler)completionHandler } } -- (void)configureAttributeCurrentX:(uint16_t)minInterval - maxInterval:(uint16_t)maxInterval - change:(uint16_t)change - completionHandler:(ResponseHandler)completionHandler +- (void)readAttributePrimary4Intensity:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2375,8 +3615,7 @@ - (void)configureAttributeCurrentX:(uint16_t)minInterval return; } - CHIP_ERROR err - = self.cppCluster.ConfigureAttributeCurrentX(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + CHIP_ERROR err = self.cppCluster.ReadAttributePrimary4Intensity(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2384,22 +3623,30 @@ - (void)configureAttributeCurrentX:(uint16_t)minInterval } } -- (void)reportAttributeCurrentX:(ResponseHandler)reportHandler +- (void)readAttributePrimary5X:(ResponseHandler)completionHandler { - CHIPInt16uAttributeCallbackBridge * onReport = new CHIPInt16uAttributeCallbackBridge(reportHandler, [self callbackQueue], true); - if (!onReport) { - reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentX(onReport->Cancel()); + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributePrimary5X(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { - delete onReport; - reportHandler([CHIPError errorForCHIPErrorCode:err], nil); + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)readAttributeCurrentY:(ResponseHandler)completionHandler +- (void)readAttributePrimary5Y:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2414,7 +3661,7 @@ - (void)readAttributeCurrentY:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentY(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributePrimary5Y(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2422,12 +3669,9 @@ - (void)readAttributeCurrentY:(ResponseHandler)completionHandler } } -- (void)configureAttributeCurrentY:(uint16_t)minInterval - maxInterval:(uint16_t)maxInterval - change:(uint16_t)change - completionHandler:(ResponseHandler)completionHandler +- (void)readAttributePrimary5Intensity:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2440,8 +3684,7 @@ - (void)configureAttributeCurrentY:(uint16_t)minInterval return; } - CHIP_ERROR err - = self.cppCluster.ConfigureAttributeCurrentY(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + CHIP_ERROR err = self.cppCluster.ReadAttributePrimary5Intensity(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2449,24 +3692,32 @@ - (void)configureAttributeCurrentY:(uint16_t)minInterval } } -- (void)reportAttributeCurrentY:(ResponseHandler)reportHandler +- (void)readAttributePrimary6X:(ResponseHandler)completionHandler { - CHIPInt16uAttributeCallbackBridge * onReport = new CHIPInt16uAttributeCallbackBridge(reportHandler, [self callbackQueue], true); - if (!onReport) { - reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentY(onReport->Cancel()); + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributePrimary6X(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { - delete onReport; - reportHandler([CHIPError errorForCHIPErrorCode:err], nil); + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)readAttributeDriftCompensation:(ResponseHandler)completionHandler +- (void)readAttributePrimary6Y:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2479,7 +3730,7 @@ - (void)readAttributeDriftCompensation:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeDriftCompensation(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributePrimary6Y(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2487,10 +3738,9 @@ - (void)readAttributeDriftCompensation:(ResponseHandler)completionHandler } } -- (void)readAttributeCompensationText:(ResponseHandler)completionHandler +- (void)readAttributePrimary6Intensity:(ResponseHandler)completionHandler { - CHIPUnsupportedAttributeCallbackBridge * onSuccess - = new CHIPUnsupportedAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2503,7 +3753,7 @@ - (void)readAttributeCompensationText:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCompensationText(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributePrimary6Intensity(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2511,7 +3761,7 @@ - (void)readAttributeCompensationText:(ResponseHandler)completionHandler } } -- (void)readAttributeColorTemperature:(ResponseHandler)completionHandler +- (void)readAttributeWhitePointX:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2526,7 +3776,7 @@ - (void)readAttributeColorTemperature:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorTemperature(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeWhitePointX(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2534,10 +3784,7 @@ - (void)readAttributeColorTemperature:(ResponseHandler)completionHandler } } -- (void)configureAttributeColorTemperature:(uint16_t)minInterval - maxInterval:(uint16_t)maxInterval - change:(uint16_t)change - completionHandler:(ResponseHandler)completionHandler +- (void)writeAttributeWhitePointX:(uint16_t)value completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2552,8 +3799,7 @@ - (void)configureAttributeColorTemperature:(uint16_t)minInterval return; } - CHIP_ERROR err = self.cppCluster.ConfigureAttributeColorTemperature( - onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + CHIP_ERROR err = self.cppCluster.WriteAttributeWhitePointX(onSuccess->Cancel(), onFailure->Cancel(), value); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2561,24 +3807,9 @@ - (void)configureAttributeColorTemperature:(uint16_t)minInterval } } -- (void)reportAttributeColorTemperature:(ResponseHandler)reportHandler -{ - CHIPInt16uAttributeCallbackBridge * onReport = new CHIPInt16uAttributeCallbackBridge(reportHandler, [self callbackQueue], true); - if (!onReport) { - reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - CHIP_ERROR err = self.cppCluster.ReportAttributeColorTemperature(onReport->Cancel()); - if (err != CHIP_NO_ERROR) { - delete onReport; - reportHandler([CHIPError errorForCHIPErrorCode:err], nil); - } -} - -- (void)readAttributeColorMode:(ResponseHandler)completionHandler +- (void)readAttributeWhitePointY:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2591,7 +3822,7 @@ - (void)readAttributeColorMode:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorMode(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeWhitePointY(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2599,9 +3830,9 @@ - (void)readAttributeColorMode:(ResponseHandler)completionHandler } } -- (void)readAttributeColorControlOptions:(ResponseHandler)completionHandler +- (void)writeAttributeWhitePointY:(uint16_t)value completionHandler:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2614,7 +3845,7 @@ - (void)readAttributeColorControlOptions:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorControlOptions(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.WriteAttributeWhitePointY(onSuccess->Cancel(), onFailure->Cancel(), value); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2622,9 +3853,9 @@ - (void)readAttributeColorControlOptions:(ResponseHandler)completionHandler } } -- (void)writeAttributeColorControlOptions:(uint8_t)value completionHandler:(ResponseHandler)completionHandler +- (void)readAttributeColorPointRX:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2637,7 +3868,7 @@ - (void)writeAttributeColorControlOptions:(uint8_t)value completionHandler:(Resp return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorControlOptions(onSuccess->Cancel(), onFailure->Cancel(), value); + CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointRX(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2645,9 +3876,9 @@ - (void)writeAttributeColorControlOptions:(uint8_t)value completionHandler:(Resp } } -- (void)readAttributeNumberOfPrimaries:(ResponseHandler)completionHandler +- (void)writeAttributeColorPointRX:(uint16_t)value completionHandler:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2660,7 +3891,7 @@ - (void)readAttributeNumberOfPrimaries:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeNumberOfPrimaries(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointRX(onSuccess->Cancel(), onFailure->Cancel(), value); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2668,7 +3899,7 @@ - (void)readAttributeNumberOfPrimaries:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary1X:(ResponseHandler)completionHandler +- (void)readAttributeColorPointRY:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2683,7 +3914,7 @@ - (void)readAttributePrimary1X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary1X(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointRY(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2691,9 +3922,9 @@ - (void)readAttributePrimary1X:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary1Y:(ResponseHandler)completionHandler +- (void)writeAttributeColorPointRY:(uint16_t)value completionHandler:(ResponseHandler)completionHandler { - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2706,7 +3937,7 @@ - (void)readAttributePrimary1Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary1Y(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointRY(onSuccess->Cancel(), onFailure->Cancel(), value); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2714,7 +3945,7 @@ - (void)readAttributePrimary1Y:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary1Intensity:(ResponseHandler)completionHandler +- (void)readAttributeColorPointRIntensity:(ResponseHandler)completionHandler { CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2729,7 +3960,7 @@ - (void)readAttributePrimary1Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary1Intensity(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointRIntensity(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2737,9 +3968,9 @@ - (void)readAttributePrimary1Intensity:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary2X:(ResponseHandler)completionHandler +- (void)writeAttributeColorPointRIntensity:(uint8_t)value completionHandler:(ResponseHandler)completionHandler { - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2752,7 +3983,7 @@ - (void)readAttributePrimary2X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary2X(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointRIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2760,7 +3991,7 @@ - (void)readAttributePrimary2X:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary2Y:(ResponseHandler)completionHandler +- (void)readAttributeColorPointGX:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2775,7 +4006,7 @@ - (void)readAttributePrimary2Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary2Y(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointGX(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2783,9 +4014,9 @@ - (void)readAttributePrimary2Y:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary2Intensity:(ResponseHandler)completionHandler +- (void)writeAttributeColorPointGX:(uint16_t)value completionHandler:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2798,7 +4029,7 @@ - (void)readAttributePrimary2Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary2Intensity(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointGX(onSuccess->Cancel(), onFailure->Cancel(), value); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2806,7 +4037,7 @@ - (void)readAttributePrimary2Intensity:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary3X:(ResponseHandler)completionHandler +- (void)readAttributeColorPointGY:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2821,7 +4052,7 @@ - (void)readAttributePrimary3X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary3X(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointGY(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2829,9 +4060,9 @@ - (void)readAttributePrimary3X:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary3Y:(ResponseHandler)completionHandler +- (void)writeAttributeColorPointGY:(uint16_t)value completionHandler:(ResponseHandler)completionHandler { - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2844,7 +4075,7 @@ - (void)readAttributePrimary3Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary3Y(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointGY(onSuccess->Cancel(), onFailure->Cancel(), value); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2852,7 +4083,7 @@ - (void)readAttributePrimary3Y:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary3Intensity:(ResponseHandler)completionHandler +- (void)readAttributeColorPointGIntensity:(ResponseHandler)completionHandler { CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2867,7 +4098,7 @@ - (void)readAttributePrimary3Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary3Intensity(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointGIntensity(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2875,9 +4106,9 @@ - (void)readAttributePrimary3Intensity:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary4X:(ResponseHandler)completionHandler +- (void)writeAttributeColorPointGIntensity:(uint8_t)value completionHandler:(ResponseHandler)completionHandler { - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2890,7 +4121,7 @@ - (void)readAttributePrimary4X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary4X(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointGIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2898,7 +4129,7 @@ - (void)readAttributePrimary4X:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary4Y:(ResponseHandler)completionHandler +- (void)readAttributeColorPointBX:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2913,7 +4144,7 @@ - (void)readAttributePrimary4Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary4Y(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointBX(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2921,9 +4152,9 @@ - (void)readAttributePrimary4Y:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary4Intensity:(ResponseHandler)completionHandler +- (void)writeAttributeColorPointBX:(uint16_t)value completionHandler:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2936,7 +4167,7 @@ - (void)readAttributePrimary4Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary4Intensity(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointBX(onSuccess->Cancel(), onFailure->Cancel(), value); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2944,7 +4175,7 @@ - (void)readAttributePrimary4Intensity:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary5X:(ResponseHandler)completionHandler +- (void)readAttributeColorPointBY:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2959,7 +4190,7 @@ - (void)readAttributePrimary5X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary5X(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointBY(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2967,9 +4198,9 @@ - (void)readAttributePrimary5X:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary5Y:(ResponseHandler)completionHandler +- (void)writeAttributeColorPointBY:(uint16_t)value completionHandler:(ResponseHandler)completionHandler { - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -2982,7 +4213,7 @@ - (void)readAttributePrimary5Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary5Y(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointBY(onSuccess->Cancel(), onFailure->Cancel(), value); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2990,7 +4221,7 @@ - (void)readAttributePrimary5Y:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary5Intensity:(ResponseHandler)completionHandler +- (void)readAttributeColorPointBIntensity:(ResponseHandler)completionHandler { CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -3005,7 +4236,7 @@ - (void)readAttributePrimary5Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary5Intensity(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointBIntensity(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3013,9 +4244,9 @@ - (void)readAttributePrimary5Intensity:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary6X:(ResponseHandler)completionHandler +- (void)writeAttributeColorPointBIntensity:(uint8_t)value completionHandler:(ResponseHandler)completionHandler { - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3028,7 +4259,7 @@ - (void)readAttributePrimary6X:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary6X(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointBIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3036,7 +4267,7 @@ - (void)readAttributePrimary6X:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary6Y:(ResponseHandler)completionHandler +- (void)readAttributeEnhancedCurrentHue:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -3051,7 +4282,7 @@ - (void)readAttributePrimary6Y:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary6Y(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeEnhancedCurrentHue(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3059,7 +4290,7 @@ - (void)readAttributePrimary6Y:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary6Intensity:(ResponseHandler)completionHandler +- (void)readAttributeEnhancedColorMode:(ResponseHandler)completionHandler { CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -3074,7 +4305,7 @@ - (void)readAttributePrimary6Intensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePrimary6Intensity(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeEnhancedColorMode(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3082,9 +4313,9 @@ - (void)readAttributePrimary6Intensity:(ResponseHandler)completionHandler } } -- (void)readAttributeWhitePointX:(ResponseHandler)completionHandler +- (void)readAttributeColorLoopActive:(ResponseHandler)completionHandler { - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3097,7 +4328,7 @@ - (void)readAttributeWhitePointX:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeWhitePointX(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeColorLoopActive(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3105,9 +4336,9 @@ - (void)readAttributeWhitePointX:(ResponseHandler)completionHandler } } -- (void)writeAttributeWhitePointX:(uint16_t)value completionHandler:(ResponseHandler)completionHandler +- (void)readAttributeColorLoopDirection:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3120,7 +4351,7 @@ - (void)writeAttributeWhitePointX:(uint16_t)value completionHandler:(ResponseHan return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeWhitePointX(onSuccess->Cancel(), onFailure->Cancel(), value); + CHIP_ERROR err = self.cppCluster.ReadAttributeColorLoopDirection(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3128,7 +4359,7 @@ - (void)writeAttributeWhitePointX:(uint16_t)value completionHandler:(ResponseHan } } -- (void)readAttributeWhitePointY:(ResponseHandler)completionHandler +- (void)readAttributeColorLoopTime:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -3143,7 +4374,7 @@ - (void)readAttributeWhitePointY:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeWhitePointY(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeColorLoopTime(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3151,9 +4382,9 @@ - (void)readAttributeWhitePointY:(ResponseHandler)completionHandler } } -- (void)writeAttributeWhitePointY:(uint16_t)value completionHandler:(ResponseHandler)completionHandler +- (void)readAttributeColorCapabilities:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3166,7 +4397,7 @@ - (void)writeAttributeWhitePointY:(uint16_t)value completionHandler:(ResponseHan return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeWhitePointY(onSuccess->Cancel(), onFailure->Cancel(), value); + CHIP_ERROR err = self.cppCluster.ReadAttributeColorCapabilities(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3174,7 +4405,7 @@ - (void)writeAttributeWhitePointY:(uint16_t)value completionHandler:(ResponseHan } } -- (void)readAttributeColorPointRX:(ResponseHandler)completionHandler +- (void)readAttributeColorTempPhysicalMin:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -3189,7 +4420,7 @@ - (void)readAttributeColorPointRX:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointRX(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeColorTempPhysicalMin(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3197,9 +4428,9 @@ - (void)readAttributeColorPointRX:(ResponseHandler)completionHandler } } -- (void)writeAttributeColorPointRX:(uint16_t)value completionHandler:(ResponseHandler)completionHandler +- (void)readAttributeColorTempPhysicalMax:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3212,7 +4443,7 @@ - (void)writeAttributeColorPointRX:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointRX(onSuccess->Cancel(), onFailure->Cancel(), value); + CHIP_ERROR err = self.cppCluster.ReadAttributeColorTempPhysicalMax(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3220,7 +4451,7 @@ - (void)writeAttributeColorPointRX:(uint16_t)value completionHandler:(ResponseHa } } -- (void)readAttributeColorPointRY:(ResponseHandler)completionHandler +- (void)readAttributeCoupleColorTempToLevelMinMireds:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -3235,7 +4466,7 @@ - (void)readAttributeColorPointRY:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointRY(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeCoupleColorTempToLevelMinMireds(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3243,9 +4474,9 @@ - (void)readAttributeColorPointRY:(ResponseHandler)completionHandler } } -- (void)writeAttributeColorPointRY:(uint16_t)value completionHandler:(ResponseHandler)completionHandler +- (void)readAttributeStartUpColorTemperatureMireds:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3258,7 +4489,7 @@ - (void)writeAttributeColorPointRY:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointRY(onSuccess->Cancel(), onFailure->Cancel(), value); + CHIP_ERROR err = self.cppCluster.ReadAttributeStartUpColorTemperatureMireds(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3266,9 +4497,9 @@ - (void)writeAttributeColorPointRY:(uint16_t)value completionHandler:(ResponseHa } } -- (void)readAttributeColorPointRIntensity:(ResponseHandler)completionHandler +- (void)writeAttributeStartUpColorTemperatureMireds:(uint16_t)value completionHandler:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3281,7 +4512,7 @@ - (void)readAttributeColorPointRIntensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointRIntensity(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.WriteAttributeStartUpColorTemperatureMireds(onSuccess->Cancel(), onFailure->Cancel(), value); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3289,9 +4520,9 @@ - (void)readAttributeColorPointRIntensity:(ResponseHandler)completionHandler } } -- (void)writeAttributeColorPointRIntensity:(uint8_t)value completionHandler:(ResponseHandler)completionHandler +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3304,7 +4535,7 @@ - (void)writeAttributeColorPointRIntensity:(uint8_t)value completionHandler:(Res return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointRIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); + CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3312,9 +4543,23 @@ - (void)writeAttributeColorPointRIntensity:(uint8_t)value completionHandler:(Res } } -- (void)readAttributeColorPointGX:(ResponseHandler)completionHandler +@end + +@interface CHIPContentLaunch () +@property (readonly) Controller::ContentLaunchCluster cppCluster; +@end + +@implementation CHIPContentLaunch + +- (Controller::ClusterBase *)getCluster { - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + return &_cppCluster; +} + +- (void)launchContent:(ResponseHandler)completionHandler +{ + CHIPContentLaunchClusterLaunchContentResponseCallbackBridge * onSuccess + = new CHIPContentLaunchClusterLaunchContentResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3327,17 +4572,17 @@ - (void)readAttributeColorPointGX:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointGX(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.LaunchContent(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)writeAttributeColorPointGX:(uint16_t)value completionHandler:(ResponseHandler)completionHandler +- (void)launchURL:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPContentLaunchClusterLaunchURLResponseCallbackBridge * onSuccess + = new CHIPContentLaunchClusterLaunchURLResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3350,7 +4595,7 @@ - (void)writeAttributeColorPointGX:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointGX(onSuccess->Cancel(), onFailure->Cancel(), value); + CHIP_ERROR err = self.cppCluster.LaunchURL(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3358,7 +4603,7 @@ - (void)writeAttributeColorPointGX:(uint16_t)value completionHandler:(ResponseHa } } -- (void)readAttributeColorPointGY:(ResponseHandler)completionHandler +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -3373,7 +4618,7 @@ - (void)readAttributeColorPointGY:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointGY(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -3381,9 +4626,23 @@ - (void)readAttributeColorPointGY:(ResponseHandler)completionHandler } } -- (void)writeAttributeColorPointGY:(uint16_t)value completionHandler:(ResponseHandler)completionHandler +@end + +@interface CHIPDoorLock () +@property (readonly) Controller::DoorLockCluster cppCluster; +@end + +@implementation CHIPDoorLock + +- (Controller::ClusterBase *)getCluster { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + return &_cppCluster; +} + +- (void)clearAllPins:(ResponseHandler)completionHandler +{ + CHIPDoorLockClusterClearAllPinsResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterClearAllPinsResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3396,17 +4655,17 @@ - (void)writeAttributeColorPointGY:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointGY(onSuccess->Cancel(), onFailure->Cancel(), value); + CHIP_ERROR err = self.cppCluster.ClearAllPins(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)readAttributeColorPointGIntensity:(ResponseHandler)completionHandler +- (void)clearAllRfids:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDoorLockClusterClearAllRfidsResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterClearAllRfidsResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3419,17 +4678,17 @@ - (void)readAttributeColorPointGIntensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointGIntensity(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ClearAllRfids(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)writeAttributeColorPointGIntensity:(uint8_t)value completionHandler:(ResponseHandler)completionHandler +- (void)clearHolidaySchedule:(uint8_t)scheduleId completionHandler:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDoorLockClusterClearHolidayScheduleResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterClearHolidayScheduleResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3442,17 +4701,17 @@ - (void)writeAttributeColorPointGIntensity:(uint8_t)value completionHandler:(Res return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointGIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); + CHIP_ERROR err = self.cppCluster.ClearHolidaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)readAttributeColorPointBX:(ResponseHandler)completionHandler +- (void)clearPin:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler { - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDoorLockClusterClearPinResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterClearPinResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3465,17 +4724,17 @@ - (void)readAttributeColorPointBX:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointBX(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ClearPin(onSuccess->Cancel(), onFailure->Cancel(), userId); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)writeAttributeColorPointBX:(uint16_t)value completionHandler:(ResponseHandler)completionHandler +- (void)clearRfid:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDoorLockClusterClearRfidResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterClearRfidResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3488,17 +4747,17 @@ - (void)writeAttributeColorPointBX:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointBX(onSuccess->Cancel(), onFailure->Cancel(), value); + CHIP_ERROR err = self.cppCluster.ClearRfid(onSuccess->Cancel(), onFailure->Cancel(), userId); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)readAttributeColorPointBY:(ResponseHandler)completionHandler +- (void)clearWeekdaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler { - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDoorLockClusterClearWeekdayScheduleResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterClearWeekdayScheduleResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3511,17 +4770,17 @@ - (void)readAttributeColorPointBY:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointBY(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ClearWeekdaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)writeAttributeColorPointBY:(uint16_t)value completionHandler:(ResponseHandler)completionHandler +- (void)clearYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDoorLockClusterClearYeardayScheduleResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterClearYeardayScheduleResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3534,17 +4793,17 @@ - (void)writeAttributeColorPointBY:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointBY(onSuccess->Cancel(), onFailure->Cancel(), value); + CHIP_ERROR err = self.cppCluster.ClearYeardaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)readAttributeColorPointBIntensity:(ResponseHandler)completionHandler +- (void)getHolidaySchedule:(uint8_t)scheduleId completionHandler:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDoorLockClusterGetHolidayScheduleResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterGetHolidayScheduleResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3557,17 +4816,17 @@ - (void)readAttributeColorPointBIntensity:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorPointBIntensity(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.GetHolidaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)writeAttributeColorPointBIntensity:(uint8_t)value completionHandler:(ResponseHandler)completionHandler +- (void)getLogRecord:(uint16_t)logIndex completionHandler:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDoorLockClusterGetLogRecordResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterGetLogRecordResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3580,17 +4839,17 @@ - (void)writeAttributeColorPointBIntensity:(uint8_t)value completionHandler:(Res return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeColorPointBIntensity(onSuccess->Cancel(), onFailure->Cancel(), value); + CHIP_ERROR err = self.cppCluster.GetLogRecord(onSuccess->Cancel(), onFailure->Cancel(), logIndex); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)readAttributeEnhancedCurrentHue:(ResponseHandler)completionHandler +- (void)getPin:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler { - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDoorLockClusterGetPinResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterGetPinResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3603,17 +4862,17 @@ - (void)readAttributeEnhancedCurrentHue:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeEnhancedCurrentHue(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.GetPin(onSuccess->Cancel(), onFailure->Cancel(), userId); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)readAttributeEnhancedColorMode:(ResponseHandler)completionHandler +- (void)getRfid:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDoorLockClusterGetRfidResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterGetRfidResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3626,17 +4885,17 @@ - (void)readAttributeEnhancedColorMode:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeEnhancedColorMode(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.GetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)readAttributeColorLoopActive:(ResponseHandler)completionHandler +- (void)getUserType:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDoorLockClusterGetUserTypeResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterGetUserTypeResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3649,17 +4908,17 @@ - (void)readAttributeColorLoopActive:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorLoopActive(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.GetUserType(onSuccess->Cancel(), onFailure->Cancel(), userId); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)readAttributeColorLoopDirection:(ResponseHandler)completionHandler +- (void)getWeekdaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDoorLockClusterGetWeekdayScheduleResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterGetWeekdayScheduleResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3672,17 +4931,17 @@ - (void)readAttributeColorLoopDirection:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorLoopDirection(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.GetWeekdaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)readAttributeColorLoopTime:(ResponseHandler)completionHandler +- (void)getYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler { - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDoorLockClusterGetYeardayScheduleResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterGetYeardayScheduleResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3695,17 +4954,17 @@ - (void)readAttributeColorLoopTime:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorLoopTime(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.GetYeardaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)readAttributeColorCapabilities:(ResponseHandler)completionHandler +- (void)lockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHandler { - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDoorLockClusterLockDoorResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterLockDoorResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3718,17 +4977,23 @@ - (void)readAttributeColorCapabilities:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorCapabilities(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.LockDoor(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)readAttributeColorTempPhysicalMin:(ResponseHandler)completionHandler +- (void)setHolidaySchedule:(uint8_t)scheduleId + localStartTime:(uint32_t)localStartTime + localEndTime:(uint32_t)localEndTime + operatingModeDuringHoliday:(uint8_t)operatingModeDuringHoliday + completionHandler:(ResponseHandler)completionHandler { - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDoorLockClusterSetHolidayScheduleResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterSetHolidayScheduleResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3741,17 +5006,22 @@ - (void)readAttributeColorTempPhysicalMin:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorTempPhysicalMin(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.SetHolidaySchedule( + onSuccess->Cancel(), onFailure->Cancel(), scheduleId, localStartTime, localEndTime, operatingModeDuringHoliday); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)readAttributeColorTempPhysicalMax:(ResponseHandler)completionHandler +- (void)setPin:(uint16_t)userId + userStatus:(uint8_t)userStatus + userType:(uint8_t)userType + pin:(NSString *)pin + completionHandler:(ResponseHandler)completionHandler { - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDoorLockClusterSetPinResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterSetPinResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3764,17 +5034,23 @@ - (void)readAttributeColorTempPhysicalMax:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeColorTempPhysicalMax(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.SetPin(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)readAttributeCoupleColorTempToLevelMinMireds:(ResponseHandler)completionHandler +- (void)setRfid:(uint16_t)userId + userStatus:(uint8_t)userStatus + userType:(uint8_t)userType + id:(NSString *)id + completionHandler:(ResponseHandler)completionHandler { - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDoorLockClusterSetRfidResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterSetRfidResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3787,17 +5063,19 @@ - (void)readAttributeCoupleColorTempToLevelMinMireds:(ResponseHandler)completion return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCoupleColorTempToLevelMinMireds(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.SetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, + chip::ByteSpan((const uint8_t *) [id dataUsingEncoding:NSUTF8StringEncoding].bytes, + [id lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)readAttributeStartUpColorTemperatureMireds:(ResponseHandler)completionHandler +- (void)setUserType:(uint16_t)userId userType:(uint8_t)userType completionHandler:(ResponseHandler)completionHandler { - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDoorLockClusterSetUserTypeResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterSetUserTypeResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3810,17 +5088,24 @@ - (void)readAttributeStartUpColorTemperatureMireds:(ResponseHandler)completionHa return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeStartUpColorTemperatureMireds(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.SetUserType(onSuccess->Cancel(), onFailure->Cancel(), userId, userType); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)writeAttributeStartUpColorTemperatureMireds:(uint16_t)value completionHandler:(ResponseHandler)completionHandler +- (void)setWeekdaySchedule:(uint8_t)scheduleId + userId:(uint16_t)userId + daysMask:(uint8_t)daysMask + startHour:(uint8_t)startHour + startMinute:(uint8_t)startMinute + endHour:(uint8_t)endHour + endMinute:(uint8_t)endMinute + completionHandler:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDoorLockClusterSetWeekdayScheduleResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterSetWeekdayScheduleResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3833,17 +5118,22 @@ - (void)writeAttributeStartUpColorTemperatureMireds:(uint16_t)value completionHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeStartUpColorTemperatureMireds(onSuccess->Cancel(), onFailure->Cancel(), value); + CHIP_ERROR err = self.cppCluster.SetWeekdaySchedule( + onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId, daysMask, startHour, startMinute, endHour, endMinute); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler +- (void)setYeardaySchedule:(uint8_t)scheduleId + userId:(uint16_t)userId + localStartTime:(uint32_t)localStartTime + localEndTime:(uint32_t)localEndTime + completionHandler:(ResponseHandler)completionHandler { - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDoorLockClusterSetYeardayScheduleResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterSetYeardayScheduleResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3856,31 +5146,18 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.SetYeardaySchedule( + onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId, localStartTime, localEndTime); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -@end - -@interface CHIPDoorLock () -@property (readonly) Controller::DoorLockCluster cppCluster; -@end - -@implementation CHIPDoorLock - -- (Controller::ClusterBase *)getCluster -{ - return &_cppCluster; -} - -- (void)clearAllPins:(ResponseHandler)completionHandler +- (void)unlockDoor:(NSString *)pin completionHandler:(ResponseHandler)completionHandler { - CHIPDoorLockClusterClearAllPinsResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterClearAllPinsResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDoorLockClusterUnlockDoorResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterUnlockDoorResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3893,17 +5170,19 @@ - (void)clearAllPins:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ClearAllPins(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.UnlockDoor(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)clearAllRfids:(ResponseHandler)completionHandler +- (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(NSString *)pin completionHandler:(ResponseHandler)completionHandler { - CHIPDoorLockClusterClearAllRfidsResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterClearAllRfidsResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDoorLockClusterUnlockWithTimeoutResponseCallbackBridge * onSuccess + = new CHIPDoorLockClusterUnlockWithTimeoutResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3916,17 +5195,19 @@ - (void)clearAllRfids:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ClearAllRfids(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.UnlockWithTimeout(onSuccess->Cancel(), onFailure->Cancel(), timeoutInSeconds, + chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes, + [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)clearHolidaySchedule:(uint8_t)scheduleId completionHandler:(ResponseHandler)completionHandler + +- (void)readAttributeLockState:(ResponseHandler)completionHandler { - CHIPDoorLockClusterClearHolidayScheduleResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterClearHolidayScheduleResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3939,17 +5220,19 @@ - (void)clearHolidaySchedule:(uint8_t)scheduleId completionHandler:(ResponseHand return; } - CHIP_ERROR err = self.cppCluster.ClearHolidaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId); + CHIP_ERROR err = self.cppCluster.ReadAttributeLockState(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)clearPin:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler + +- (void)configureAttributeLockState:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + completionHandler:(ResponseHandler)completionHandler { - CHIPDoorLockClusterClearPinResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterClearPinResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -3962,40 +5245,33 @@ - (void)clearPin:(uint16_t)userId completionHandler:(ResponseHandler)completionH return; } - CHIP_ERROR err = self.cppCluster.ClearPin(onSuccess->Cancel(), onFailure->Cancel(), userId); + CHIP_ERROR err + = self.cppCluster.ConfigureAttributeLockState(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)clearRfid:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler -{ - CHIPDoorLockClusterClearRfidResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterClearRfidResponseCallbackBridge(completionHandler, [self callbackQueue]); - if (!onSuccess) { - completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); - if (!onFailure) { - delete onSuccess; - completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); +- (void)reportAttributeLockState:(ResponseHandler)reportHandler +{ + CHIPInt8uAttributeCallbackBridge * onReport = new CHIPInt8uAttributeCallbackBridge(reportHandler, [self callbackQueue], true); + if (!onReport) { + reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; } - CHIP_ERROR err = self.cppCluster.ClearRfid(onSuccess->Cancel(), onFailure->Cancel(), userId); + CHIP_ERROR err = self.cppCluster.ReportAttributeLockState(onReport->Cancel()); if (err != CHIP_NO_ERROR) { - delete onSuccess; - delete onFailure; - completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + delete onReport; + reportHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)clearWeekdaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler + +- (void)readAttributeLockType:(ResponseHandler)completionHandler { - CHIPDoorLockClusterClearWeekdayScheduleResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterClearWeekdayScheduleResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4008,17 +5284,18 @@ - (void)clearWeekdaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId complet return; } - CHIP_ERROR err = self.cppCluster.ClearWeekdaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + CHIP_ERROR err = self.cppCluster.ReadAttributeLockType(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)clearYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler + +- (void)readAttributeActuatorEnabled:(ResponseHandler)completionHandler { - CHIPDoorLockClusterClearYeardayScheduleResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterClearYeardayScheduleResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPBooleanAttributeCallbackBridge * onSuccess + = new CHIPBooleanAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4031,17 +5308,17 @@ - (void)clearYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId complet return; } - CHIP_ERROR err = self.cppCluster.ClearYeardaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + CHIP_ERROR err = self.cppCluster.ReadAttributeActuatorEnabled(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)getHolidaySchedule:(uint8_t)scheduleId completionHandler:(ResponseHandler)completionHandler + +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler { - CHIPDoorLockClusterGetHolidayScheduleResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterGetHolidayScheduleResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4054,17 +5331,34 @@ - (void)getHolidaySchedule:(uint8_t)scheduleId completionHandler:(ResponseHandle return; } - CHIP_ERROR err = self.cppCluster.GetHolidaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId); + CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)getLogRecord:(uint16_t)logIndex completionHandler:(ResponseHandler)completionHandler + +@end + +@interface CHIPGeneralCommissioning () +@property (readonly) Controller::GeneralCommissioningCluster cppCluster; +@end + +@implementation CHIPGeneralCommissioning + +- (Controller::ClusterBase *)getCluster { - CHIPDoorLockClusterGetLogRecordResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterGetLogRecordResponseCallbackBridge(completionHandler, [self callbackQueue]); + return &_cppCluster; +} + +- (void)armFailSafe:(uint16_t)expiryLengthSeconds + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPGeneralCommissioningClusterArmFailSafeResponseCallbackBridge * onSuccess + = new CHIPGeneralCommissioningClusterArmFailSafeResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4077,17 +5371,18 @@ - (void)getLogRecord:(uint16_t)logIndex completionHandler:(ResponseHandler)compl return; } - CHIP_ERROR err = self.cppCluster.GetLogRecord(onSuccess->Cancel(), onFailure->Cancel(), logIndex); + CHIP_ERROR err + = self.cppCluster.ArmFailSafe(onSuccess->Cancel(), onFailure->Cancel(), expiryLengthSeconds, breadcrumb, timeoutMs); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)getPin:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler +- (void)commissioningComplete:(ResponseHandler)completionHandler { - CHIPDoorLockClusterGetPinResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterGetPinResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallbackBridge * onSuccess + = new CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4100,17 +5395,21 @@ - (void)getPin:(uint16_t)userId completionHandler:(ResponseHandler)completionHan return; } - CHIP_ERROR err = self.cppCluster.GetPin(onSuccess->Cancel(), onFailure->Cancel(), userId); + CHIP_ERROR err = self.cppCluster.CommissioningComplete(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)getRfid:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler +- (void)setFabric:(NSData *)fabricId + fabricSecret:(NSData *)fabricSecret + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler { - CHIPDoorLockClusterGetRfidResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterGetRfidResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPGeneralCommissioningClusterSetFabricResponseCallbackBridge * onSuccess + = new CHIPGeneralCommissioningClusterSetFabricResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4123,17 +5422,20 @@ - (void)getRfid:(uint16_t)userId completionHandler:(ResponseHandler)completionHa return; } - CHIP_ERROR err = self.cppCluster.GetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId); + CHIP_ERROR err = self.cppCluster.SetFabric(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) fabricId.bytes, fabricId.length), + chip::ByteSpan((const uint8_t *) fabricSecret.bytes, fabricSecret.length), breadcrumb, timeoutMs); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)getUserType:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler + +- (void)readAttributeFabricId:(ResponseHandler)completionHandler { - CHIPDoorLockClusterGetUserTypeResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterGetUserTypeResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPStringAttributeCallbackBridge * onSuccess + = new CHIPStringAttributeCallbackBridge(completionHandler, [self callbackQueue], true); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4146,17 +5448,17 @@ - (void)getUserType:(uint16_t)userId completionHandler:(ResponseHandler)completi return; } - CHIP_ERROR err = self.cppCluster.GetUserType(onSuccess->Cancel(), onFailure->Cancel(), userId); + CHIP_ERROR err = self.cppCluster.ReadAttributeFabricId(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)getWeekdaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler + +- (void)readAttributeBreadcrumb:(ResponseHandler)completionHandler { - CHIPDoorLockClusterGetWeekdayScheduleResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterGetWeekdayScheduleResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt64uAttributeCallbackBridge * onSuccess = new CHIPInt64uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4169,17 +5471,17 @@ - (void)getWeekdaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completio return; } - CHIP_ERROR err = self.cppCluster.GetWeekdaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + CHIP_ERROR err = self.cppCluster.ReadAttributeBreadcrumb(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)getYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completionHandler:(ResponseHandler)completionHandler + +- (void)writeAttributeBreadcrumb:(uint64_t)value completionHandler:(ResponseHandler)completionHandler { - CHIPDoorLockClusterGetYeardayScheduleResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterGetYeardayScheduleResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4192,17 +5494,17 @@ - (void)getYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId completio return; } - CHIP_ERROR err = self.cppCluster.GetYeardaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId); + CHIP_ERROR err = self.cppCluster.WriteAttributeBreadcrumb(onSuccess->Cancel(), onFailure->Cancel(), value); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)lockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandler + +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler { - CHIPDoorLockClusterLockDoorResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterLockDoorResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4215,21 +5517,31 @@ - (void)lockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandle return; } - CHIP_ERROR err = self.cppCluster.LockDoor(onSuccess->Cancel(), onFailure->Cancel(), pin); + CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)setHolidaySchedule:(uint8_t)scheduleId - localStartTime:(uint32_t)localStartTime - localEndTime:(uint32_t)localEndTime - operatingModeDuringHoliday:(uint8_t)operatingModeDuringHoliday - completionHandler:(ResponseHandler)completionHandler + +@end + +@interface CHIPGroups () +@property (readonly) Controller::GroupsCluster cppCluster; +@end + +@implementation CHIPGroups + +- (Controller::ClusterBase *)getCluster { - CHIPDoorLockClusterSetHolidayScheduleResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterSetHolidayScheduleResponseCallbackBridge(completionHandler, [self callbackQueue]); + return &_cppCluster; +} + +- (void)addGroup:(uint16_t)groupId groupName:(NSString *)groupName completionHandler:(ResponseHandler)completionHandler +{ + CHIPGroupsClusterAddGroupResponseCallbackBridge * onSuccess + = new CHIPGroupsClusterAddGroupResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4242,22 +5554,18 @@ - (void)setHolidaySchedule:(uint8_t)scheduleId return; } - CHIP_ERROR err = self.cppCluster.SetHolidaySchedule( - onSuccess->Cancel(), onFailure->Cancel(), scheduleId, localStartTime, localEndTime, operatingModeDuringHoliday); + CHIP_ERROR err = self.cppCluster.AddGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId, + chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes, + [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)setPin:(uint16_t)userId - userStatus:(uint8_t)userStatus - userType:(uint8_t)userType - pin:(char *)pin - completionHandler:(ResponseHandler)completionHandler +- (void)addGroupIfIdentifying:(uint16_t)groupId groupName:(NSString *)groupName completionHandler:(ResponseHandler)completionHandler { - CHIPDoorLockClusterSetPinResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterSetPinResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4270,21 +5578,19 @@ - (void)setPin:(uint16_t)userId return; } - CHIP_ERROR err = self.cppCluster.SetPin(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, pin); + CHIP_ERROR err = self.cppCluster.AddGroupIfIdentifying(onSuccess->Cancel(), onFailure->Cancel(), groupId, + chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes, + [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding])); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)setRfid:(uint16_t)userId - userStatus:(uint8_t)userStatus - userType:(uint8_t)userType - id:(char *)id - completionHandler:(ResponseHandler)completionHandler +- (void)getGroupMembership:(uint8_t)groupCount groupList:(uint16_t)groupList completionHandler:(ResponseHandler)completionHandler { - CHIPDoorLockClusterSetRfidResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterSetRfidResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPGroupsClusterGetGroupMembershipResponseCallbackBridge * onSuccess + = new CHIPGroupsClusterGetGroupMembershipResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4297,17 +5603,16 @@ - (void)setRfid:(uint16_t)userId return; } - CHIP_ERROR err = self.cppCluster.SetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType, id); + CHIP_ERROR err = self.cppCluster.GetGroupMembership(onSuccess->Cancel(), onFailure->Cancel(), groupCount, groupList); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)setUserType:(uint16_t)userId userType:(uint8_t)userType completionHandler:(ResponseHandler)completionHandler +- (void)removeAllGroups:(ResponseHandler)completionHandler { - CHIPDoorLockClusterSetUserTypeResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterSetUserTypeResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4320,24 +5625,17 @@ - (void)setUserType:(uint16_t)userId userType:(uint8_t)userType completionHandle return; } - CHIP_ERROR err = self.cppCluster.SetUserType(onSuccess->Cancel(), onFailure->Cancel(), userId, userType); + CHIP_ERROR err = self.cppCluster.RemoveAllGroups(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)setWeekdaySchedule:(uint8_t)scheduleId - userId:(uint16_t)userId - daysMask:(uint8_t)daysMask - startHour:(uint8_t)startHour - startMinute:(uint8_t)startMinute - endHour:(uint8_t)endHour - endMinute:(uint8_t)endMinute - completionHandler:(ResponseHandler)completionHandler +- (void)removeGroup:(uint16_t)groupId completionHandler:(ResponseHandler)completionHandler { - CHIPDoorLockClusterSetWeekdayScheduleResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterSetWeekdayScheduleResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPGroupsClusterRemoveGroupResponseCallbackBridge * onSuccess + = new CHIPGroupsClusterRemoveGroupResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4350,22 +5648,17 @@ - (void)setWeekdaySchedule:(uint8_t)scheduleId return; } - CHIP_ERROR err = self.cppCluster.SetWeekdaySchedule( - onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId, daysMask, startHour, startMinute, endHour, endMinute); + CHIP_ERROR err = self.cppCluster.RemoveGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)setYeardaySchedule:(uint8_t)scheduleId - userId:(uint16_t)userId - localStartTime:(uint32_t)localStartTime - localEndTime:(uint32_t)localEndTime - completionHandler:(ResponseHandler)completionHandler +- (void)viewGroup:(uint16_t)groupId completionHandler:(ResponseHandler)completionHandler { - CHIPDoorLockClusterSetYeardayScheduleResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterSetYeardayScheduleResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPGroupsClusterViewGroupResponseCallbackBridge * onSuccess + = new CHIPGroupsClusterViewGroupResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4378,18 +5671,17 @@ - (void)setYeardaySchedule:(uint8_t)scheduleId return; } - CHIP_ERROR err = self.cppCluster.SetYeardaySchedule( - onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId, localStartTime, localEndTime); + CHIP_ERROR err = self.cppCluster.ViewGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)unlockDoor:(char *)pin completionHandler:(ResponseHandler)completionHandler + +- (void)readAttributeNameSupport:(ResponseHandler)completionHandler { - CHIPDoorLockClusterUnlockDoorResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterUnlockDoorResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4402,17 +5694,17 @@ - (void)unlockDoor:(char *)pin completionHandler:(ResponseHandler)completionHand return; } - CHIP_ERROR err = self.cppCluster.UnlockDoor(onSuccess->Cancel(), onFailure->Cancel(), pin); + CHIP_ERROR err = self.cppCluster.ReadAttributeNameSupport(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(char *)pin completionHandler:(ResponseHandler)completionHandler + +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler { - CHIPDoorLockClusterUnlockWithTimeoutResponseCallbackBridge * onSuccess - = new CHIPDoorLockClusterUnlockWithTimeoutResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4425,7 +5717,7 @@ - (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(char *)pin completionH return; } - CHIP_ERROR err = self.cppCluster.UnlockWithTimeout(onSuccess->Cancel(), onFailure->Cancel(), timeoutInSeconds, pin); + CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4433,9 +5725,22 @@ - (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(char *)pin completionH } } -- (void)readAttributeLockState:(ResponseHandler)completionHandler +@end + +@interface CHIPIdentify () +@property (readonly) Controller::IdentifyCluster cppCluster; +@end + +@implementation CHIPIdentify + +- (Controller::ClusterBase *)getCluster +{ + return &_cppCluster; +} + +- (void)identify:(uint16_t)identifyTime completionHandler:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4448,19 +5753,17 @@ - (void)readAttributeLockState:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeLockState(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.Identify(onSuccess->Cancel(), onFailure->Cancel(), identifyTime); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)configureAttributeLockState:(uint16_t)minInterval - maxInterval:(uint16_t)maxInterval - completionHandler:(ResponseHandler)completionHandler +- (void)identifyQuery:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPIdentifyClusterIdentifyQueryResponseCallbackBridge * onSuccess + = new CHIPIdentifyClusterIdentifyQueryResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4473,8 +5776,7 @@ - (void)configureAttributeLockState:(uint16_t)minInterval return; } - CHIP_ERROR err - = self.cppCluster.ConfigureAttributeLockState(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval); + CHIP_ERROR err = self.cppCluster.IdentifyQuery(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4482,24 +5784,9 @@ - (void)configureAttributeLockState:(uint16_t)minInterval } } -- (void)reportAttributeLockState:(ResponseHandler)reportHandler -{ - CHIPInt8uAttributeCallbackBridge * onReport = new CHIPInt8uAttributeCallbackBridge(reportHandler, [self callbackQueue], true); - if (!onReport) { - reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - CHIP_ERROR err = self.cppCluster.ReportAttributeLockState(onReport->Cancel()); - if (err != CHIP_NO_ERROR) { - delete onReport; - reportHandler([CHIPError errorForCHIPErrorCode:err], nil); - } -} - -- (void)readAttributeLockType:(ResponseHandler)completionHandler +- (void)readAttributeIdentifyTime:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4512,7 +5799,7 @@ - (void)readAttributeLockType:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeLockType(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeIdentifyTime(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4520,10 +5807,9 @@ - (void)readAttributeLockType:(ResponseHandler)completionHandler } } -- (void)readAttributeActuatorEnabled:(ResponseHandler)completionHandler +- (void)writeAttributeIdentifyTime:(uint16_t)value completionHandler:(ResponseHandler)completionHandler { - CHIPBooleanAttributeCallbackBridge * onSuccess - = new CHIPBooleanAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4536,7 +5822,7 @@ - (void)readAttributeActuatorEnabled:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeActuatorEnabled(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.WriteAttributeIdentifyTime(onSuccess->Cancel(), onFailure->Cancel(), value); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4569,21 +5855,24 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler @end -@interface CHIPGroups () -@property (readonly) Controller::GroupsCluster cppCluster; +@interface CHIPLevelControl () +@property (readonly) Controller::LevelControlCluster cppCluster; @end -@implementation CHIPGroups +@implementation CHIPLevelControl - (Controller::ClusterBase *)getCluster { return &_cppCluster; } -- (void)addGroup:(uint16_t)groupId groupName:(char *)groupName completionHandler:(ResponseHandler)completionHandler +- (void)move:(uint8_t)moveMode + rate:(uint8_t)rate + optionMask:(uint8_t)optionMask + optionOverride:(uint8_t)optionOverride + completionHandler:(ResponseHandler)completionHandler { - CHIPGroupsClusterAddGroupResponseCallbackBridge * onSuccess - = new CHIPGroupsClusterAddGroupResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4596,14 +5885,18 @@ - (void)addGroup:(uint16_t)groupId groupName:(char *)groupName completionHandler return; } - CHIP_ERROR err = self.cppCluster.AddGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId, groupName); + CHIP_ERROR err = self.cppCluster.Move(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionMask, optionOverride); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)addGroupIfIdentifying:(uint16_t)groupId groupName:(char *)groupName completionHandler:(ResponseHandler)completionHandler +- (void)moveToLevel:(uint8_t)level + transitionTime:(uint16_t)transitionTime + optionMask:(uint8_t)optionMask + optionOverride:(uint8_t)optionOverride + completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -4618,17 +5911,19 @@ - (void)addGroupIfIdentifying:(uint16_t)groupId groupName:(char *)groupName comp return; } - CHIP_ERROR err = self.cppCluster.AddGroupIfIdentifying(onSuccess->Cancel(), onFailure->Cancel(), groupId, groupName); + CHIP_ERROR err + = self.cppCluster.MoveToLevel(onSuccess->Cancel(), onFailure->Cancel(), level, transitionTime, optionMask, optionOverride); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)getGroupMembership:(uint8_t)groupCount groupList:(uint16_t)groupList completionHandler:(ResponseHandler)completionHandler +- (void)moveToLevelWithOnOff:(uint8_t)level + transitionTime:(uint16_t)transitionTime + completionHandler:(ResponseHandler)completionHandler { - CHIPGroupsClusterGetGroupMembershipResponseCallbackBridge * onSuccess - = new CHIPGroupsClusterGetGroupMembershipResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4641,14 +5936,14 @@ - (void)getGroupMembership:(uint8_t)groupCount groupList:(uint16_t)groupList com return; } - CHIP_ERROR err = self.cppCluster.GetGroupMembership(onSuccess->Cancel(), onFailure->Cancel(), groupCount, groupList); + CHIP_ERROR err = self.cppCluster.MoveToLevelWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), level, transitionTime); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)removeAllGroups:(ResponseHandler)completionHandler +- (void)moveWithOnOff:(uint8_t)moveMode rate:(uint8_t)rate completionHandler:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -4663,17 +5958,21 @@ - (void)removeAllGroups:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.RemoveAllGroups(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.MoveWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)removeGroup:(uint16_t)groupId completionHandler:(ResponseHandler)completionHandler +- (void)step:(uint8_t)stepMode + stepSize:(uint8_t)stepSize + transitionTime:(uint16_t)transitionTime + optionMask:(uint8_t)optionMask + optionOverride:(uint8_t)optionOverride + completionHandler:(ResponseHandler)completionHandler { - CHIPGroupsClusterRemoveGroupResponseCallbackBridge * onSuccess - = new CHIPGroupsClusterRemoveGroupResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4686,17 +5985,20 @@ - (void)removeGroup:(uint16_t)groupId completionHandler:(ResponseHandler)complet return; } - CHIP_ERROR err = self.cppCluster.RemoveGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId); + CHIP_ERROR err = self.cppCluster.Step( + onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionMask, optionOverride); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)viewGroup:(uint16_t)groupId completionHandler:(ResponseHandler)completionHandler +- (void)stepWithOnOff:(uint8_t)stepMode + stepSize:(uint8_t)stepSize + transitionTime:(uint16_t)transitionTime + completionHandler:(ResponseHandler)completionHandler { - CHIPGroupsClusterViewGroupResponseCallbackBridge * onSuccess - = new CHIPGroupsClusterViewGroupResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4709,17 +6011,16 @@ - (void)viewGroup:(uint16_t)groupId completionHandler:(ResponseHandler)completio return; } - CHIP_ERROR err = self.cppCluster.ViewGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId); + CHIP_ERROR err = self.cppCluster.StepWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)readAttributeNameSupport:(ResponseHandler)completionHandler +- (void)stop:(uint8_t)optionMask optionOverride:(uint8_t)optionOverride completionHandler:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4732,17 +6033,16 @@ - (void)readAttributeNameSupport:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeNameSupport(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.Stop(onSuccess->Cancel(), onFailure->Cancel(), optionMask, optionOverride); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler +- (void)stopWithOnOff:(ResponseHandler)completionHandler { - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4755,7 +6055,7 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.StopWithOnOff(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4763,22 +6063,9 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler } } -@end - -@interface CHIPIdentify () -@property (readonly) Controller::IdentifyCluster cppCluster; -@end - -@implementation CHIPIdentify - -- (Controller::ClusterBase *)getCluster -{ - return &_cppCluster; -} - -- (void)identify:(uint16_t)identifyTime completionHandler:(ResponseHandler)completionHandler +- (void)readAttributeCurrentLevel:(ResponseHandler)completionHandler { - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4791,17 +6078,20 @@ - (void)identify:(uint16_t)identifyTime completionHandler:(ResponseHandler)compl return; } - CHIP_ERROR err = self.cppCluster.Identify(onSuccess->Cancel(), onFailure->Cancel(), identifyTime); + CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentLevel(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)identifyQuery:(ResponseHandler)completionHandler + +- (void)configureAttributeCurrentLevel:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + change:(uint8_t)change + completionHandler:(ResponseHandler)completionHandler { - CHIPIdentifyClusterIdentifyQueryResponseCallbackBridge * onSuccess - = new CHIPIdentifyClusterIdentifyQueryResponseCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -4814,7 +6104,8 @@ - (void)identifyQuery:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.IdentifyQuery(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ConfigureAttributeCurrentLevel( + onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4822,7 +6113,22 @@ - (void)identifyQuery:(ResponseHandler)completionHandler } } -- (void)readAttributeIdentifyTime:(ResponseHandler)completionHandler +- (void)reportAttributeCurrentLevel:(ResponseHandler)reportHandler +{ + CHIPInt8uAttributeCallbackBridge * onReport = new CHIPInt8uAttributeCallbackBridge(reportHandler, [self callbackQueue], true); + if (!onReport) { + reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentLevel(onReport->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onReport; + reportHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -4837,7 +6143,7 @@ - (void)readAttributeIdentifyTime:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeIdentifyTime(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4845,7 +6151,20 @@ - (void)readAttributeIdentifyTime:(ResponseHandler)completionHandler } } -- (void)writeAttributeIdentifyTime:(uint16_t)value completionHandler:(ResponseHandler)completionHandler +@end + +@interface CHIPLowPower () +@property (readonly) Controller::LowPowerCluster cppCluster; +@end + +@implementation CHIPLowPower + +- (Controller::ClusterBase *)getCluster +{ + return &_cppCluster; +} + +- (void)sleep:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -4860,7 +6179,7 @@ - (void)writeAttributeIdentifyTime:(uint16_t)value completionHandler:(ResponseHa return; } - CHIP_ERROR err = self.cppCluster.WriteAttributeIdentifyTime(onSuccess->Cancel(), onFailure->Cancel(), value); + CHIP_ERROR err = self.cppCluster.Sleep(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -4893,22 +6212,18 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler @end -@interface CHIPLevelControl () -@property (readonly) Controller::LevelControlCluster cppCluster; +@interface CHIPMediaPlayback () +@property (readonly) Controller::MediaPlaybackCluster cppCluster; @end -@implementation CHIPLevelControl +@implementation CHIPMediaPlayback - (Controller::ClusterBase *)getCluster { return &_cppCluster; } -- (void)move:(uint8_t)moveMode - rate:(uint8_t)rate - optionMask:(uint8_t)optionMask - optionOverride:(uint8_t)optionOverride - completionHandler:(ResponseHandler)completionHandler +- (void)fastForwardRequest:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -4923,18 +6238,14 @@ - (void)move:(uint8_t)moveMode return; } - CHIP_ERROR err = self.cppCluster.Move(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionMask, optionOverride); + CHIP_ERROR err = self.cppCluster.FastForwardRequest(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)moveToLevel:(uint8_t)level - transitionTime:(uint16_t)transitionTime - optionMask:(uint8_t)optionMask - optionOverride:(uint8_t)optionOverride - completionHandler:(ResponseHandler)completionHandler +- (void)nextRequest:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -4949,17 +6260,14 @@ - (void)moveToLevel:(uint8_t)level return; } - CHIP_ERROR err - = self.cppCluster.MoveToLevel(onSuccess->Cancel(), onFailure->Cancel(), level, transitionTime, optionMask, optionOverride); + CHIP_ERROR err = self.cppCluster.NextRequest(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)moveToLevelWithOnOff:(uint8_t)level - transitionTime:(uint16_t)transitionTime - completionHandler:(ResponseHandler)completionHandler +- (void)pauseRequest:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -4974,14 +6282,14 @@ - (void)moveToLevelWithOnOff:(uint8_t)level return; } - CHIP_ERROR err = self.cppCluster.MoveToLevelWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), level, transitionTime); + CHIP_ERROR err = self.cppCluster.PauseRequest(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)moveWithOnOff:(uint8_t)moveMode rate:(uint8_t)rate completionHandler:(ResponseHandler)completionHandler +- (void)playRequest:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -4996,19 +6304,14 @@ - (void)moveWithOnOff:(uint8_t)moveMode rate:(uint8_t)rate completionHandler:(Re return; } - CHIP_ERROR err = self.cppCluster.MoveWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate); + CHIP_ERROR err = self.cppCluster.PlayRequest(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)step:(uint8_t)stepMode - stepSize:(uint8_t)stepSize - transitionTime:(uint16_t)transitionTime - optionMask:(uint8_t)optionMask - optionOverride:(uint8_t)optionOverride - completionHandler:(ResponseHandler)completionHandler +- (void)previousRequest:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -5023,18 +6326,14 @@ - (void)step:(uint8_t)stepMode return; } - CHIP_ERROR err = self.cppCluster.Step( - onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionMask, optionOverride); + CHIP_ERROR err = self.cppCluster.PreviousRequest(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)stepWithOnOff:(uint8_t)stepMode - stepSize:(uint8_t)stepSize - transitionTime:(uint16_t)transitionTime - completionHandler:(ResponseHandler)completionHandler +- (void)rewindRequest:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -5049,14 +6348,14 @@ - (void)stepWithOnOff:(uint8_t)stepMode return; } - CHIP_ERROR err = self.cppCluster.StepWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime); + CHIP_ERROR err = self.cppCluster.RewindRequest(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)stop:(uint8_t)optionMask optionOverride:(uint8_t)optionOverride completionHandler:(ResponseHandler)completionHandler +- (void)skipBackwardRequest:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -5071,14 +6370,14 @@ - (void)stop:(uint8_t)optionMask optionOverride:(uint8_t)optionOverride completi return; } - CHIP_ERROR err = self.cppCluster.Stop(onSuccess->Cancel(), onFailure->Cancel(), optionMask, optionOverride); + CHIP_ERROR err = self.cppCluster.SkipBackwardRequest(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } -- (void)stopWithOnOff:(ResponseHandler)completionHandler +- (void)skipForwardRequest:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -5093,17 +6392,16 @@ - (void)stopWithOnOff:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.StopWithOnOff(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.SkipForwardRequest(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)readAttributeCurrentLevel:(ResponseHandler)completionHandler +- (void)startOverRequest:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -5116,18 +6414,14 @@ - (void)readAttributeCurrentLevel:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentLevel(onSuccess->Cancel(), onFailure->Cancel()); + CHIP_ERROR err = self.cppCluster.StartOverRequest(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } - -- (void)configureAttributeCurrentLevel:(uint16_t)minInterval - maxInterval:(uint16_t)maxInterval - change:(uint8_t)change - completionHandler:(ResponseHandler)completionHandler +- (void)stopRequest:(ResponseHandler)completionHandler { CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -5142,8 +6436,7 @@ - (void)configureAttributeCurrentLevel:(uint16_t)minInterval return; } - CHIP_ERROR err = self.cppCluster.ConfigureAttributeCurrentLevel( - onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change); + CHIP_ERROR err = self.cppCluster.StopRequest(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -5151,18 +6444,26 @@ - (void)configureAttributeCurrentLevel:(uint16_t)minInterval } } -- (void)reportAttributeCurrentLevel:(ResponseHandler)reportHandler +- (void)readAttributeCurrentState:(ResponseHandler)completionHandler { - CHIPInt8uAttributeCallbackBridge * onReport = new CHIPInt8uAttributeCallbackBridge(reportHandler, [self callbackQueue], true); - if (!onReport) { - reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentLevel(onReport->Cancel()); + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentState(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { - delete onReport; - reportHandler([CHIPError errorForCHIPErrorCode:err], nil); + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); } } @@ -5373,7 +6674,7 @@ @implementation CHIPScenes - (void)addScene:(uint16_t)groupId sceneId:(uint8_t)sceneId transitionTime:(uint16_t)transitionTime - sceneName:(char *)sceneName + sceneName:(NSString *)sceneName clusterId:(uint16_t)clusterId length:(uint8_t)length value:(uint8_t)value @@ -5393,8 +6694,10 @@ - (void)addScene:(uint16_t)groupId return; } - CHIP_ERROR err = self.cppCluster.AddScene( - onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime, sceneName, clusterId, length, value); + CHIP_ERROR err = self.cppCluster.AddScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime, + chip::ByteSpan((const uint8_t *) [sceneName dataUsingEncoding:NSUTF8StringEncoding].bytes, + [sceneName lengthOfBytesUsingEncoding:NSUTF8StringEncoding]), + clusterId, length, value); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; diff --git a/src/darwin/Framework/CHIP/gen/IMClusterCommandHandler.cpp b/src/darwin/Framework/CHIP/gen/IMClusterCommandHandler.cpp index 047d74d2cea5a2..34ae5803a13185 100644 --- a/src/darwin/Framework/CHIP/gen/IMClusterCommandHandler.cpp +++ b/src/darwin/Framework/CHIP/gen/IMClusterCommandHandler.cpp @@ -39,6 +39,77 @@ namespace app { namespace clusters { +namespace ContentLaunch { + +void DispatchClientCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv) +{ + { + switch (commandId) + { + case ZCL_LAUNCH_CONTENT_RESPONSE_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + uint8_t contentLaunchStatus; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.Get(contentLaunchStatus); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfContentLaunchClusterLaunchContentResponseCallback(contentLaunchStatus); + break; + } + case ZCL_LAUNCH_URL_RESPONSE_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + uint8_t contentLaunchStatus; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.Get(contentLaunchStatus); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfContentLaunchClusterLaunchURLResponseCallback(contentLaunchStatus); + break; + } + default: { + // Unrecognized command ID, error status will apply. + // TODO: Encode response for command not found + ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_CONTENT_LAUNCH_CLUSTER_ID); + break; + } + } + } +} + +} // namespace ContentLaunch + namespace DoorLock { void DispatchClientCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv) @@ -771,6 +842,115 @@ void DispatchClientCommand(app::Command * command, CommandId commandId, Endpoint } // namespace DoorLock +namespace GeneralCommissioning { + +void DispatchClientCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv) +{ + { + switch (commandId) + { + case ZCL_ARM_FAIL_SAFE_RESPONSE_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + uint8_t errorCode; + const uint8_t * debugText; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.Get(errorCode); + break; + case 1: + TLVError = dataTlv.GetDataPtr(debugText); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfGeneralCommissioningClusterArmFailSafeResponseCallback(errorCode, const_cast(debugText)); + break; + } + case ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + uint8_t errorCode; + const uint8_t * debugText; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.Get(errorCode); + break; + case 1: + TLVError = dataTlv.GetDataPtr(debugText); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfGeneralCommissioningClusterCommissioningCompleteResponseCallback(errorCode, const_cast(debugText)); + break; + } + case ZCL_SET_FABRIC_RESPONSE_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + uint8_t errorCode; + const uint8_t * debugText; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.Get(errorCode); + break; + case 1: + TLVError = dataTlv.GetDataPtr(debugText); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfGeneralCommissioningClusterSetFabricResponseCallback(errorCode, const_cast(debugText)); + break; + } + default: { + // Unrecognized command ID, error status will apply. + // TODO: Encode response for command not found + ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_GENERAL_COMMISSIONING_CLUSTER_ID); + break; + } + } + } +} + +} // namespace GeneralCommissioning + namespace Groups { void DispatchClientCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv) @@ -964,6 +1144,30 @@ void DispatchClientCommand(app::Command * command, CommandId commandId, Endpoint } // namespace Identify +namespace MediaPlayback { + +void DispatchClientCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv) +{ + { + switch (commandId) + { + case ZCL_PLAYBACK_COMMAND_ID: { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfMediaPlaybackClusterPlaybackCallback(); + break; + } + default: { + // Unrecognized command ID, error status will apply. + // TODO: Encode response for command not found + ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_MEDIA_PLAYBACK_CLUSTER_ID); + break; + } + } + } +} + +} // namespace MediaPlayback + namespace Scenes { void DispatchClientCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv) diff --git a/src/darwin/Framework/CHIP/gen/attribute-id.h b/src/darwin/Framework/CHIP/gen/attribute-id.h index 3ab0310a83cce7..8c8757f826ca7f 100644 --- a/src/darwin/Framework/CHIP/gen/attribute-id.h +++ b/src/darwin/Framework/CHIP/gen/attribute-id.h @@ -26,30 +26,6 @@ #define ZCL_REPORTING_STATUS_CLIENT_ATTRIBUTE_ID (0xFFFE) #define ZCL_REPORTING_STATUS_SERVER_ATTRIBUTE_ID (0xFFFE) -// Attribute ids for cluster: Basic - -// Client attributes - -// Server attributes -#define ZCL_VERSION_ATTRIBUTE_ID (0x0000) -#define ZCL_APPLICATION_VERSION_ATTRIBUTE_ID (0x0001) -#define ZCL_STACK_VERSION_ATTRIBUTE_ID (0x0002) -#define ZCL_HW_VERSION_ATTRIBUTE_ID (0x0003) -#define ZCL_MANUFACTURER_NAME_ATTRIBUTE_ID (0x0004) -#define ZCL_MODEL_IDENTIFIER_ATTRIBUTE_ID (0x0005) -#define ZCL_DATE_CODE_ATTRIBUTE_ID (0x0006) -#define ZCL_POWER_SOURCE_ATTRIBUTE_ID (0x0007) -#define ZCL_GENERIC_DEVICE_CLASS_ATTRIBUTE_ID (0x0008) -#define ZCL_GENERIC_DEVICE_TYPE_ATTRIBUTE_ID (0x0009) -#define ZCL_PRODUCT_CODE_ATTRIBUTE_ID (0x000A) -#define ZCL_PRODUCT_URL_ATTRIBUTE_ID (0x000B) -#define ZCL_LOCATION_DESCRIPTION_ATTRIBUTE_ID (0x0010) -#define ZCL_PHYSICAL_ENVIRONMENT_ATTRIBUTE_ID (0x0011) -#define ZCL_DEVICE_ENABLED_ATTRIBUTE_ID (0x0012) -#define ZCL_ALARM_MASK_ATTRIBUTE_ID (0x0013) -#define ZCL_DISABLE_LOCAL_CONFIG_ATTRIBUTE_ID (0x0014) -#define ZCL_SW_BUILD_ID_ATTRIBUTE_ID (0x4000) - // Attribute ids for cluster: Power Configuration // Client attributes @@ -384,6 +360,29 @@ #define ZCL_KEEPALIVE_BASE_ATTRIBUTE_ID (0x0000) #define ZCL_KEEPALIVE_JITTER_ATTRIBUTE_ID (0x0001) +// Attribute ids for cluster: Basic + +// Client attributes + +// Server attributes +#define ZCL_INTERACTION_MODEL_VERSION_ATTRIBUTE_ID (0x0000) +#define ZCL_VENDOR_NAME_ATTRIBUTE_ID (0x0001) +#define ZCL_VENDOR_ID_ATTRIBUTE_ID (0x0002) +#define ZCL_PRODUCT_NAME_ATTRIBUTE_ID (0x0003) +#define ZCL_PRODUCT_ID_ATTRIBUTE_ID (0x0004) +#define ZCL_USER_LABEL_ATTRIBUTE_ID (0x0005) +#define ZCL_LOCATION_ATTRIBUTE_ID (0x0006) +#define ZCL_HARDWARE_VERSION_ATTRIBUTE_ID (0x0007) +#define ZCL_HARDWARE_VERSION_STRING_ATTRIBUTE_ID (0x0008) +#define ZCL_SOFTWARE_VERSION_ATTRIBUTE_ID (0x0009) +#define ZCL_SOFTWARE_VERSION_STRING_ATTRIBUTE_ID (0x000A) +#define ZCL_MANUFACTURING_DATE_ATTRIBUTE_ID (0x000B) +#define ZCL_PART_NUMBER_ATTRIBUTE_ID (0x000C) +#define ZCL_PRODUCT_URL_ATTRIBUTE_ID (0x000D) +#define ZCL_PRODUCT_LABEL_ATTRIBUTE_ID (0x000E) +#define ZCL_SERIAL_NUMBER_ATTRIBUTE_ID (0x000F) +#define ZCL_LOCAL_CONFIG_DISABLED_ATTRIBUTE_ID (0x0010) + // Attribute ids for cluster: General Commissioning // Client attributes @@ -1104,10 +1103,10 @@ // Client attributes // Server attributes -#define ZCL_VENDOR_NAME_ATTRIBUTE_ID (0x0000) -#define ZCL_VENDOR_ID_ATTRIBUTE_ID (0x0001) +#define ZCL_APPLICATION_VENDOR_NAME_ATTRIBUTE_ID (0x0000) +#define ZCL_APPLICATION_VENDOR_ID_ATTRIBUTE_ID (0x0001) #define ZCL_APPLICATION_NAME_ATTRIBUTE_ID (0x0002) -#define ZCL_PRODUCT_ID_ATTRIBUTE_ID (0x0003) +#define ZCL_APPLICATION_PRODUCT_ID_ATTRIBUTE_ID (0x0003) #define ZCL_APPLICATION_ID_ATTRIBUTE_ID (0x0005) #define ZCL_CATALOG_VENDOR_ID_ATTRIBUTE_ID (0x0006) #define ZCL_APPLICATION_STATUS_ATTRIBUTE_ID (0x0007) @@ -3839,7 +3838,7 @@ #define ZCL_PRICE_TRAILING_DIGIT_ATTRIBUTE_ID (0x0021) #define ZCL_PRICE_ATTRIBUTE_ID (0x0022) #define ZCL_GOOD_ID_ATTRIBUTE_ID (0x0030) -#define ZCL_SERIAL_NUMBER_ATTRIBUTE_ID (0x0031) +#define ZCL_PAYMENT_SERIAL_NUMBER_ATTRIBUTE_ID (0x0031) #define ZCL_PAYMENT_TIMESTAMP_ATTRIBUTE_ID (0x0032) #define ZCL_TRANS_ID_ATTRIBUTE_ID (0x0033) #define ZCL_TRANS_STATUS_ATTRIBUTE_ID (0x0034) diff --git a/src/darwin/Framework/CHIP/gen/call-command-handler.cpp b/src/darwin/Framework/CHIP/gen/call-command-handler.cpp index ed3fae9d0ad456..560795f42a1b16 100644 --- a/src/darwin/Framework/CHIP/gen/call-command-handler.cpp +++ b/src/darwin/Framework/CHIP/gen/call-command-handler.cpp @@ -28,14 +28,19 @@ using namespace chip; +EmberAfStatus emberAfApplicationBasicClusterClientCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfBarrierControlClusterClientCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfBasicClusterClientCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfBindingClusterClientCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfColorControlClusterClientCommandParse(EmberAfClusterCommand * cmd); +EmberAfStatus emberAfContentLaunchClusterClientCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfDoorLockClusterClientCommandParse(EmberAfClusterCommand * cmd); +EmberAfStatus emberAfGeneralCommissioningClusterClientCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfGroupsClusterClientCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfIdentifyClusterClientCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfLevelControlClusterClientCommandParse(EmberAfClusterCommand * cmd); +EmberAfStatus emberAfLowPowerClusterClientCommandParse(EmberAfClusterCommand * cmd); +EmberAfStatus emberAfMediaPlaybackClusterClientCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfOnOffClusterClientCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfScenesClusterClientCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfTemperatureMeasurementClusterClientCommandParse(EmberAfClusterCommand * cmd); @@ -69,6 +74,10 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd) { switch (cmd->apsFrame->clusterId) { + case ZCL_APPLICATION_BASIC_CLUSTER_ID: + // No commands are enabled for cluster Application Basic + result = status(false, true, cmd->mfgSpecific); + break; case ZCL_BARRIER_CONTROL_CLUSTER_ID: // No commands are enabled for cluster Barrier Control result = status(false, true, cmd->mfgSpecific); @@ -85,9 +94,15 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd) // No commands are enabled for cluster Color Control result = status(false, true, cmd->mfgSpecific); break; + case ZCL_CONTENT_LAUNCH_CLUSTER_ID: + result = emberAfContentLaunchClusterClientCommandParse(cmd); + break; case ZCL_DOOR_LOCK_CLUSTER_ID: result = emberAfDoorLockClusterClientCommandParse(cmd); break; + case ZCL_GENERAL_COMMISSIONING_CLUSTER_ID: + result = emberAfGeneralCommissioningClusterClientCommandParse(cmd); + break; case ZCL_GROUPS_CLUSTER_ID: result = emberAfGroupsClusterClientCommandParse(cmd); break; @@ -98,6 +113,13 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd) // No commands are enabled for cluster Level Control result = status(false, true, cmd->mfgSpecific); break; + case ZCL_LOW_POWER_CLUSTER_ID: + // No commands are enabled for cluster Low Power + result = status(false, true, cmd->mfgSpecific); + break; + case ZCL_MEDIA_PLAYBACK_CLUSTER_ID: + result = emberAfMediaPlaybackClusterClientCommandParse(cmd); + break; case ZCL_ON_OFF_CLUSTER_ID: // No commands are enabled for cluster On/off result = status(false, true, cmd->mfgSpecific); @@ -129,6 +151,48 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd) // Cluster specific command parsing +EmberAfStatus emberAfContentLaunchClusterClientCommandParse(EmberAfClusterCommand * cmd) +{ + bool wasHandled = false; + + if (!cmd->mfgSpecific) + { + switch (cmd->commandId) + { + case ZCL_LAUNCH_CONTENT_RESPONSE_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t contentLaunchStatus; + + if (cmd->bufLen < payloadOffset + 1) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + contentLaunchStatus = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfContentLaunchClusterLaunchContentResponseCallback(contentLaunchStatus); + break; + } + case ZCL_LAUNCH_URL_RESPONSE_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t contentLaunchStatus; + + if (cmd->bufLen < payloadOffset + 1) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + contentLaunchStatus = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfContentLaunchClusterLaunchURLResponseCallback(contentLaunchStatus); + break; + } + default: { + // Unrecognized command ID, error status will apply. + break; + } + } + } + return status(wasHandled, true, cmd->mfgSpecific); +} EmberAfStatus emberAfDoorLockClusterClientCommandParse(EmberAfClusterCommand * cmd) { bool wasHandled = false; @@ -644,6 +708,82 @@ EmberAfStatus emberAfDoorLockClusterClientCommandParse(EmberAfClusterCommand * c } return status(wasHandled, true, cmd->mfgSpecific); } +EmberAfStatus emberAfGeneralCommissioningClusterClientCommandParse(EmberAfClusterCommand * cmd) +{ + bool wasHandled = false; + + if (!cmd->mfgSpecific) + { + switch (cmd->commandId) + { + case ZCL_ARM_FAIL_SAFE_RESPONSE_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t errorCode; + uint8_t * debugText; + + if (cmd->bufLen < payloadOffset + 1) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + errorCode = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 1); + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + debugText = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfGeneralCommissioningClusterArmFailSafeResponseCallback(errorCode, debugText); + break; + } + case ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t errorCode; + uint8_t * debugText; + + if (cmd->bufLen < payloadOffset + 1) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + errorCode = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 1); + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + debugText = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfGeneralCommissioningClusterCommissioningCompleteResponseCallback(errorCode, debugText); + break; + } + case ZCL_SET_FABRIC_RESPONSE_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t errorCode; + uint8_t * debugText; + + if (cmd->bufLen < payloadOffset + 1) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + errorCode = emberAfGetInt8u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 1); + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + debugText = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfGeneralCommissioningClusterSetFabricResponseCallback(errorCode, debugText); + break; + } + default: { + // Unrecognized command ID, error status will apply. + break; + } + } + } + return status(wasHandled, true, cmd->mfgSpecific); +} EmberAfStatus emberAfGroupsClusterClientCommandParse(EmberAfClusterCommand * cmd) { bool wasHandled = false; @@ -779,6 +919,26 @@ EmberAfStatus emberAfIdentifyClusterClientCommandParse(EmberAfClusterCommand * c } return status(wasHandled, true, cmd->mfgSpecific); } +EmberAfStatus emberAfMediaPlaybackClusterClientCommandParse(EmberAfClusterCommand * cmd) +{ + bool wasHandled = false; + + if (!cmd->mfgSpecific) + { + switch (cmd->commandId) + { + case ZCL_PLAYBACK_COMMAND_ID: { + wasHandled = emberAfMediaPlaybackClusterPlaybackCallback(); + break; + } + default: { + // Unrecognized command ID, error status will apply. + break; + } + } + } + return status(wasHandled, true, cmd->mfgSpecific); +} EmberAfStatus emberAfScenesClusterClientCommandParse(EmberAfClusterCommand * cmd) { bool wasHandled = false; diff --git a/src/darwin/Framework/CHIP/gen/callback-stub.cpp b/src/darwin/Framework/CHIP/gen/callback-stub.cpp index c5dde3074847cc..a3ba44051be597 100644 --- a/src/darwin/Framework/CHIP/gen/callback-stub.cpp +++ b/src/darwin/Framework/CHIP/gen/callback-stub.cpp @@ -27,6 +27,9 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) { switch (clusterId) { + case ZCL_APPLICATION_BASIC_CLUSTER_ID: + emberAfApplicationBasicClusterInitCallback(endpoint); + break; case ZCL_BARRIER_CONTROL_CLUSTER_ID: emberAfBarrierControlClusterInitCallback(endpoint); break; @@ -39,9 +42,15 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) case ZCL_COLOR_CONTROL_CLUSTER_ID: emberAfColorControlClusterInitCallback(endpoint); break; + case ZCL_CONTENT_LAUNCH_CLUSTER_ID: + emberAfContentLaunchClusterInitCallback(endpoint); + break; case ZCL_DOOR_LOCK_CLUSTER_ID: emberAfDoorLockClusterInitCallback(endpoint); break; + case ZCL_GENERAL_COMMISSIONING_CLUSTER_ID: + emberAfGeneralCommissioningClusterInitCallback(endpoint); + break; case ZCL_GROUPS_CLUSTER_ID: emberAfGroupsClusterInitCallback(endpoint); break; @@ -51,6 +60,12 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) case ZCL_LEVEL_CONTROL_CLUSTER_ID: emberAfLevelControlClusterInitCallback(endpoint); break; + case ZCL_LOW_POWER_CLUSTER_ID: + emberAfLowPowerClusterInitCallback(endpoint); + break; + case ZCL_MEDIA_PLAYBACK_CLUSTER_ID: + emberAfMediaPlaybackClusterInitCallback(endpoint); + break; case ZCL_ON_OFF_CLUSTER_ID: emberAfOnOffClusterInitCallback(endpoint); break; @@ -66,6 +81,11 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) } } +void __attribute__((weak)) emberAfApplicationBasicClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} void __attribute__((weak)) emberAfBarrierControlClusterInitCallback(EndpointId endpoint) { // To prevent warning @@ -86,11 +106,21 @@ void __attribute__((weak)) emberAfColorControlClusterInitCallback(EndpointId end // To prevent warning (void) endpoint; } +void __attribute__((weak)) emberAfContentLaunchClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} void __attribute__((weak)) emberAfDoorLockClusterInitCallback(EndpointId endpoint) { // To prevent warning (void) endpoint; } +void __attribute__((weak)) emberAfGeneralCommissioningClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} void __attribute__((weak)) emberAfGroupsClusterInitCallback(EndpointId endpoint) { // To prevent warning @@ -106,6 +136,16 @@ void __attribute__((weak)) emberAfLevelControlClusterInitCallback(EndpointId end // To prevent warning (void) endpoint; } +void __attribute__((weak)) emberAfLowPowerClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfMediaPlaybackClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} void __attribute__((weak)) emberAfOnOffClusterInitCallback(EndpointId endpoint) { // To prevent warning diff --git a/src/darwin/Framework/CHIP/gen/callback.h b/src/darwin/Framework/CHIP/gen/callback.h index 9dc9bcfd343b51..37b17a35d7093d 100644 --- a/src/darwin/Framework/CHIP/gen/callback.h +++ b/src/darwin/Framework/CHIP/gen/callback.h @@ -37,6 +37,14 @@ void emberAfClusterInitCallback(chip::EndpointId endpoint, chip::ClusterId clust // Cluster Init Functions +/** @brief Application Basic Cluster Init + * + * Cluster Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfApplicationBasicClusterInitCallback(chip::EndpointId endpoint); + /** @brief Barrier Control Cluster Init * * Cluster Init @@ -69,6 +77,14 @@ void emberAfBindingClusterInitCallback(chip::EndpointId endpoint); */ void emberAfColorControlClusterInitCallback(chip::EndpointId endpoint); +/** @brief Content Launch Cluster Init + * + * Cluster Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfContentLaunchClusterInitCallback(chip::EndpointId endpoint); + /** @brief Door Lock Cluster Init * * Cluster Init @@ -77,6 +93,14 @@ void emberAfColorControlClusterInitCallback(chip::EndpointId endpoint); */ void emberAfDoorLockClusterInitCallback(chip::EndpointId endpoint); +/** @brief General Commissioning Cluster Init + * + * Cluster Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfGeneralCommissioningClusterInitCallback(chip::EndpointId endpoint); + /** @brief Groups Cluster Init * * Cluster Init @@ -101,6 +125,22 @@ void emberAfIdentifyClusterInitCallback(chip::EndpointId endpoint); */ void emberAfLevelControlClusterInitCallback(chip::EndpointId endpoint); +/** @brief Low Power Cluster Init + * + * Cluster Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfLowPowerClusterInitCallback(chip::EndpointId endpoint); + +/** @brief Media Playback Cluster Init + * + * Cluster Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfMediaPlaybackClusterInitCallback(chip::EndpointId endpoint); + /** @brief On/off Cluster Init * * Cluster Init @@ -127,6 +167,77 @@ void emberAfTemperatureMeasurementClusterInitCallback(chip::EndpointId endpoint) // Cluster Server/Client Init Functions +// +// Application Basic Cluster client +// + +/** @brief Application Basic Cluster Client Init + * + * Client Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfApplicationBasicClusterClientInitCallback(chip::EndpointId endpoint); + +/** @brief Application Basic Cluster Client Attribute Changed + * + * Client Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + */ +void emberAfApplicationBasicClusterClientAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId); + +/** @brief Application Basic Cluster Client Manufacturer Specific Attribute Changed + * + * Client Manufacturer Specific Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + * @param manufacturerCode Manufacturer Code of the attribute that changed + */ +void emberAfApplicationBasicClusterClientManufacturerSpecificAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + uint16_t manufacturerCode); + +/** @brief Application Basic Cluster Client Message Sent + * + * Client Message Sent + * + * @param type The type of message sent + * @param indexOrDestination The destination or address to which the message was sent + * @param apsFrame The APS frame for the message + * @param msgLen The length of the message + * @param message The message that was sent + * @param status The status of the sent message + */ +void emberAfApplicationBasicClusterClientMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); + +/** @brief Application Basic Cluster Client Pre Attribute Changed + * + * client Pre Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute to be changed + * @param attributeType Attribute type + * @param size Attribute size + * @param value Attribute value + */ +EmberAfStatus emberAfApplicationBasicClusterClientPreAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + EmberAfAttributeType attributeType, uint8_t size, + uint8_t * value); + +/** @brief Application Basic Cluster Client Tick + * + * client Tick + * + * @param endpoint Endpoint that is being served + */ +void emberAfApplicationBasicClusterClientTickCallback(chip::EndpointId endpoint); + // // Barrier Control Cluster client // @@ -406,6 +517,76 @@ EmberAfStatus emberAfColorControlClusterClientPreAttributeChangedCallback(chip:: */ void emberAfColorControlClusterClientTickCallback(chip::EndpointId endpoint); +// +// Content Launch Cluster client +// + +/** @brief Content Launch Cluster Client Init + * + * Client Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfContentLaunchClusterClientInitCallback(chip::EndpointId endpoint); + +/** @brief Content Launch Cluster Client Attribute Changed + * + * Client Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + */ +void emberAfContentLaunchClusterClientAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId); + +/** @brief Content Launch Cluster Client Manufacturer Specific Attribute Changed + * + * Client Manufacturer Specific Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + * @param manufacturerCode Manufacturer Code of the attribute that changed + */ +void emberAfContentLaunchClusterClientManufacturerSpecificAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + uint16_t manufacturerCode); + +/** @brief Content Launch Cluster Client Message Sent + * + * Client Message Sent + * + * @param type The type of message sent + * @param indexOrDestination The destination or address to which the message was sent + * @param apsFrame The APS frame for the message + * @param msgLen The length of the message + * @param message The message that was sent + * @param status The status of the sent message + */ +void emberAfContentLaunchClusterClientMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); + +/** @brief Content Launch Cluster Client Pre Attribute Changed + * + * client Pre Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute to be changed + * @param attributeType Attribute type + * @param size Attribute size + * @param value Attribute value + */ +EmberAfStatus emberAfContentLaunchClusterClientPreAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId, + EmberAfAttributeType attributeType, uint8_t size, + uint8_t * value); + +/** @brief Content Launch Cluster Client Tick + * + * client Tick + * + * @param endpoint Endpoint that is being served + */ +void emberAfContentLaunchClusterClientTickCallback(chip::EndpointId endpoint); + // // Door Lock Cluster client // @@ -476,6 +657,77 @@ EmberAfStatus emberAfDoorLockClusterClientPreAttributeChangedCallback(chip::Endp */ void emberAfDoorLockClusterClientTickCallback(chip::EndpointId endpoint); +// +// General Commissioning Cluster client +// + +/** @brief General Commissioning Cluster Client Init + * + * Client Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfGeneralCommissioningClusterClientInitCallback(chip::EndpointId endpoint); + +/** @brief General Commissioning Cluster Client Attribute Changed + * + * Client Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + */ +void emberAfGeneralCommissioningClusterClientAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId); + +/** @brief General Commissioning Cluster Client Manufacturer Specific Attribute Changed + * + * Client Manufacturer Specific Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + * @param manufacturerCode Manufacturer Code of the attribute that changed + */ +void emberAfGeneralCommissioningClusterClientManufacturerSpecificAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + uint16_t manufacturerCode); + +/** @brief General Commissioning Cluster Client Message Sent + * + * Client Message Sent + * + * @param type The type of message sent + * @param indexOrDestination The destination or address to which the message was sent + * @param apsFrame The APS frame for the message + * @param msgLen The length of the message + * @param message The message that was sent + * @param status The status of the sent message + */ +void emberAfGeneralCommissioningClusterClientMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); + +/** @brief General Commissioning Cluster Client Pre Attribute Changed + * + * client Pre Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute to be changed + * @param attributeType Attribute type + * @param size Attribute size + * @param value Attribute value + */ +EmberAfStatus emberAfGeneralCommissioningClusterClientPreAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + EmberAfAttributeType attributeType, uint8_t size, + uint8_t * value); + +/** @brief General Commissioning Cluster Client Tick + * + * client Tick + * + * @param endpoint Endpoint that is being served + */ +void emberAfGeneralCommissioningClusterClientTickCallback(chip::EndpointId endpoint); + // // Groups Cluster client // @@ -686,6 +938,146 @@ EmberAfStatus emberAfLevelControlClusterClientPreAttributeChangedCallback(chip:: */ void emberAfLevelControlClusterClientTickCallback(chip::EndpointId endpoint); +// +// Low Power Cluster client +// + +/** @brief Low Power Cluster Client Init + * + * Client Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfLowPowerClusterClientInitCallback(chip::EndpointId endpoint); + +/** @brief Low Power Cluster Client Attribute Changed + * + * Client Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + */ +void emberAfLowPowerClusterClientAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId); + +/** @brief Low Power Cluster Client Manufacturer Specific Attribute Changed + * + * Client Manufacturer Specific Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + * @param manufacturerCode Manufacturer Code of the attribute that changed + */ +void emberAfLowPowerClusterClientManufacturerSpecificAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + uint16_t manufacturerCode); + +/** @brief Low Power Cluster Client Message Sent + * + * Client Message Sent + * + * @param type The type of message sent + * @param indexOrDestination The destination or address to which the message was sent + * @param apsFrame The APS frame for the message + * @param msgLen The length of the message + * @param message The message that was sent + * @param status The status of the sent message + */ +void emberAfLowPowerClusterClientMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); + +/** @brief Low Power Cluster Client Pre Attribute Changed + * + * client Pre Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute to be changed + * @param attributeType Attribute type + * @param size Attribute size + * @param value Attribute value + */ +EmberAfStatus emberAfLowPowerClusterClientPreAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId, + EmberAfAttributeType attributeType, uint8_t size, + uint8_t * value); + +/** @brief Low Power Cluster Client Tick + * + * client Tick + * + * @param endpoint Endpoint that is being served + */ +void emberAfLowPowerClusterClientTickCallback(chip::EndpointId endpoint); + +// +// Media Playback Cluster client +// + +/** @brief Media Playback Cluster Client Init + * + * Client Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfMediaPlaybackClusterClientInitCallback(chip::EndpointId endpoint); + +/** @brief Media Playback Cluster Client Attribute Changed + * + * Client Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + */ +void emberAfMediaPlaybackClusterClientAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId); + +/** @brief Media Playback Cluster Client Manufacturer Specific Attribute Changed + * + * Client Manufacturer Specific Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + * @param manufacturerCode Manufacturer Code of the attribute that changed + */ +void emberAfMediaPlaybackClusterClientManufacturerSpecificAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + uint16_t manufacturerCode); + +/** @brief Media Playback Cluster Client Message Sent + * + * Client Message Sent + * + * @param type The type of message sent + * @param indexOrDestination The destination or address to which the message was sent + * @param apsFrame The APS frame for the message + * @param msgLen The length of the message + * @param message The message that was sent + * @param status The status of the sent message + */ +void emberAfMediaPlaybackClusterClientMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); + +/** @brief Media Playback Cluster Client Pre Attribute Changed + * + * client Pre Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute to be changed + * @param attributeType Attribute type + * @param size Attribute size + * @param value Attribute value + */ +EmberAfStatus emberAfMediaPlaybackClusterClientPreAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId, + EmberAfAttributeType attributeType, uint8_t size, + uint8_t * value); + +/** @brief Media Playback Cluster Client Tick + * + * client Tick + * + * @param endpoint Endpoint that is being served + */ +void emberAfMediaPlaybackClusterClientTickCallback(chip::EndpointId endpoint); + // // On/off Cluster client // @@ -897,6 +1289,20 @@ void emberAfTemperatureMeasurementClusterClientTickCallback(chip::EndpointId end // Cluster Commands Callback +/** + * @brief Content Launch Cluster LaunchContentResponse Command callback + * @param contentLaunchStatus + */ + +bool emberAfContentLaunchClusterLaunchContentResponseCallback(uint8_t contentLaunchStatus); + +/** + * @brief Content Launch Cluster LaunchURLResponse Command callback + * @param contentLaunchStatus + */ + +bool emberAfContentLaunchClusterLaunchURLResponseCallback(uint8_t contentLaunchStatus); + /** * @brief Door Lock Cluster ClearAllPinsResponse Command callback * @param status @@ -1091,6 +1497,30 @@ bool emberAfDoorLockClusterUnlockDoorResponseCallback(uint8_t status); bool emberAfDoorLockClusterUnlockWithTimeoutResponseCallback(uint8_t status); +/** + * @brief General Commissioning Cluster ArmFailSafeResponse Command callback + * @param errorCode + * @param debugText + */ + +bool emberAfGeneralCommissioningClusterArmFailSafeResponseCallback(uint8_t errorCode, uint8_t * debugText); + +/** + * @brief General Commissioning Cluster CommissioningCompleteResponse Command callback + * @param errorCode + * @param debugText + */ + +bool emberAfGeneralCommissioningClusterCommissioningCompleteResponseCallback(uint8_t errorCode, uint8_t * debugText); + +/** + * @brief General Commissioning Cluster SetFabricResponse Command callback + * @param errorCode + * @param debugText + */ + +bool emberAfGeneralCommissioningClusterSetFabricResponseCallback(uint8_t errorCode, uint8_t * debugText); + /** * @brief Groups Cluster AddGroupResponse Command callback * @param status @@ -1133,6 +1563,12 @@ bool emberAfGroupsClusterViewGroupResponseCallback(uint8_t status, uint16_t grou bool emberAfIdentifyClusterIdentifyQueryResponseCallback(uint16_t timeout); +/** + * @brief Media Playback Cluster Playback Command callback + */ + +bool emberAfMediaPlaybackClusterPlaybackCallback(); + /** * @brief Scenes Cluster AddSceneResponse Command callback * @param status diff --git a/src/darwin/Framework/CHIP/gen/client-command-macro.h b/src/darwin/Framework/CHIP/gen/client-command-macro.h index c4f2f0a4a2a4f2..f72c96f951dcff 100644 --- a/src/darwin/Framework/CHIP/gen/client-command-macro.h +++ b/src/darwin/Framework/CHIP/gen/client-command-macro.h @@ -256,15 +256,6 @@ emberAfFillExternalBuffer(mask, clusterId, ZCL_DISCOVER_ATTRIBUTES_EXTENDED_RESPONSE_COMMAND_ID, "ub", discoveryComplete, \ extendedDiscoverAttributesInfoRecords, extendedDiscoverAttributesInfoRecordsLen); -/** @brief Command description for ResetToFactoryDefaults - * - * Command: ResetToFactoryDefaults - */ -#define emberAfFillCommandBasicClusterResetToFactoryDefaults() \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID, "", ); - /** @brief Command description for Identify * * Command: Identify @@ -1795,6 +1786,33 @@ totalNumberOfNonEmptyProxyTableEntries, gpdSrcId, startIndex, gpdIeee, entriesCount, endpoint, \ proxyTableEntries, proxyTableEntriesLen, index); +/** @brief Command description for StartUp + * + * Command: StartUp + */ +#define emberAfFillCommandBasicClusterStartUp() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_START_UP_COMMAND_ID, "", ); + +/** @brief Command description for ShutDown + * + * Command: ShutDown + */ +#define emberAfFillCommandBasicClusterShutDown() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SHUT_DOWN_COMMAND_ID, "", ); + +/** @brief Command description for Leave + * + * Command: Leave + */ +#define emberAfFillCommandBasicClusterLeave() \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_LEAVE_COMMAND_ID, "", ); + /** @brief Command description for SetFabric * * Command: SetFabric diff --git a/src/darwin/Framework/CHIP/gen/cluster-id.h b/src/darwin/Framework/CHIP/gen/cluster-id.h index 2069290df636a7..d77da915200ab4 100644 --- a/src/darwin/Framework/CHIP/gen/cluster-id.h +++ b/src/darwin/Framework/CHIP/gen/cluster-id.h @@ -20,9 +20,6 @@ // Prevent multiple inclusion #pragma once -// Definitions for cluster: Basic -#define ZCL_BASIC_CLUSTER_ID (0x0000) - // Definitions for cluster: Power Configuration #define ZCL_POWER_CONFIG_CLUSTER_ID (0x0001) @@ -83,6 +80,9 @@ // Definitions for cluster: Keep-Alive #define ZCL_KEEPALIVE_CLUSTER_ID (0x0025) +// Definitions for cluster: Basic +#define ZCL_BASIC_CLUSTER_ID (0x0028) + // Definitions for cluster: General Commissioning #define ZCL_GENERAL_COMMISSIONING_CLUSTER_ID (0x0030) diff --git a/src/darwin/Framework/CHIP/gen/command-id.h b/src/darwin/Framework/CHIP/gen/command-id.h index 655425d5d43d35..adc2b1c6f32733 100644 --- a/src/darwin/Framework/CHIP/gen/command-id.h +++ b/src/darwin/Framework/CHIP/gen/command-id.h @@ -45,10 +45,6 @@ #define ZCL_DISCOVER_ATTRIBUTES_EXTENDED_COMMAND_ID (0x15) #define ZCL_DISCOVER_ATTRIBUTES_EXTENDED_RESPONSE_COMMAND_ID (0x16) -// Commands for cluster: Basic -#define ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID (0x00) -#define ZCL_MFG_SPECIFIC_PING_COMMAND_ID (0x00) - // Commands for cluster: Identify #define ZCL_IDENTIFY_COMMAND_ID (0x00) #define ZCL_IDENTIFY_QUERY_RESPONSE_COMMAND_ID (0x00) @@ -226,6 +222,12 @@ #define ZCL_GP_PROXY_TABLE_RESPONSE_COMMAND_ID (0x0B) #define ZCL_GP_PROXY_TABLE_REQUEST_COMMAND_ID (0x0B) +// Commands for cluster: Basic +#define ZCL_START_UP_COMMAND_ID (0x00) +#define ZCL_MFG_SPECIFIC_PING_COMMAND_ID (0x00) +#define ZCL_SHUT_DOWN_COMMAND_ID (0x01) +#define ZCL_LEAVE_COMMAND_ID (0x02) + // Commands for cluster: General Commissioning #define ZCL_SET_FABRIC_COMMAND_ID (0x00) #define ZCL_SET_FABRIC_RESPONSE_COMMAND_ID (0x01) diff --git a/src/darwin/Framework/CHIP/gen/endpoint_config.h b/src/darwin/Framework/CHIP/gen/endpoint_config.h index 9046160fc9582f..482e761307e597 100644 --- a/src/darwin/Framework/CHIP/gen/endpoint_config.h +++ b/src/darwin/Framework/CHIP/gen/endpoint_config.h @@ -55,13 +55,10 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 11 +#define GENERATED_ATTRIBUTE_COUNT 16 #define GENERATED_ATTRIBUTES \ { \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), { (uint8_t *) 3 } }, /* Basic (client): cluster revision */ \ - { \ - 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), { (uint8_t *) 2 } \ - }, /* Identify (client): cluster revision */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), { (uint8_t *) 2 } }, /* Identify (client): cluster revision */ \ { \ 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), { (uint8_t *) 3 } \ }, /* Groups (client): cluster revision */ \ @@ -74,6 +71,12 @@ { \ 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), { (uint8_t *) 3 } \ }, /* Level Control (client): cluster revision */ \ + { \ + 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT) | ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 3 } \ + }, /* Basic (client): cluster revision */ \ + { \ + 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), { (uint8_t *) 0x0001 } \ + }, /* General Commissioning (client): cluster revision */ \ { \ 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), { (uint8_t *) 3 } \ }, /* Door Lock (client): cluster revision */ \ @@ -86,9 +89,21 @@ { \ 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), { (uint8_t *) 3 } \ }, /* Temperature Measurement (client): cluster revision */ \ + { \ + 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), { (uint8_t *) 0x0001 } \ + }, /* Low Power (client): cluster revision */ \ + { \ + 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), { (uint8_t *) 0x0001 } \ + }, /* Application Basic (client): cluster revision */ \ { \ 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), { (uint8_t *) 0x0001 } \ }, /* Binding (client): cluster revision */ \ + { \ + 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), { (uint8_t *) 0x0001 } \ + }, /* Media Playback (client): cluster revision */ \ + { \ + 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), { (uint8_t *) 0x0001 } \ + }, /* Content Launch (client): cluster revision */ \ } // This is an array of EmberAfCluster structures. @@ -98,34 +113,47 @@ #define GENERATED_FUNCTION_ARRAYS #define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask -#define GENERATED_CLUSTER_COUNT 11 +#define GENERATED_CLUSTER_COUNT 16 #define GENERATED_CLUSTERS \ { \ - { 0x0000, ZAP_ATTRIBUTE_INDEX(0), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: Basic (client) */ \ - { \ - 0x0003, ZAP_ATTRIBUTE_INDEX(1), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ - }, /* Endpoint: 1, Cluster: Identify (client) */ \ - { 0x0004, ZAP_ATTRIBUTE_INDEX(2), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: Groups (client) */ \ - { 0x0005, ZAP_ATTRIBUTE_INDEX(3), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: Scenes (client) */ \ - { 0x0006, ZAP_ATTRIBUTE_INDEX(4), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: On/off (client) */ \ + { 0x0003, ZAP_ATTRIBUTE_INDEX(0), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: Identify (client) */ \ + { 0x0004, ZAP_ATTRIBUTE_INDEX(1), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: Groups (client) */ \ + { 0x0005, ZAP_ATTRIBUTE_INDEX(2), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: Scenes (client) */ \ + { 0x0006, ZAP_ATTRIBUTE_INDEX(3), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: On/off (client) */ \ { \ - 0x0008, ZAP_ATTRIBUTE_INDEX(5), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0008, ZAP_ATTRIBUTE_INDEX(4), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Level Control (client) */ \ + { 0x0028, ZAP_ATTRIBUTE_INDEX(5), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: Basic (client) */ \ { \ - 0x0101, ZAP_ATTRIBUTE_INDEX(6), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0030, ZAP_ATTRIBUTE_INDEX(6), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + }, /* Endpoint: 1, Cluster: General Commissioning (client) */ \ + { \ + 0x0101, ZAP_ATTRIBUTE_INDEX(7), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Door Lock (client) */ \ { \ - 0x0103, ZAP_ATTRIBUTE_INDEX(7), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0103, ZAP_ATTRIBUTE_INDEX(8), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Barrier Control (client) */ \ { \ - 0x0300, ZAP_ATTRIBUTE_INDEX(8), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0300, ZAP_ATTRIBUTE_INDEX(9), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Color Control (client) */ \ { \ - 0x0402, ZAP_ATTRIBUTE_INDEX(9), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0402, ZAP_ATTRIBUTE_INDEX(10), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Temperature Measurement (client) */ \ { \ - 0xF000, ZAP_ATTRIBUTE_INDEX(10), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0508, ZAP_ATTRIBUTE_INDEX(11), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + }, /* Endpoint: 1, Cluster: Low Power (client) */ \ + { \ + 0x050D, ZAP_ATTRIBUTE_INDEX(12), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + }, /* Endpoint: 1, Cluster: Application Basic (client) */ \ + { \ + 0xF000, ZAP_ATTRIBUTE_INDEX(13), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Binding (client) */ \ + { \ + 0xF001, ZAP_ATTRIBUTE_INDEX(14), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + }, /* Endpoint: 1, Cluster: Media Playback (client) */ \ + { \ + 0xF002, ZAP_ATTRIBUTE_INDEX(15), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + }, /* Endpoint: 1, Cluster: Content Launch (client) */ \ } #define ZAP_CLUSTER_INDEX(index) ((EmberAfCluster *) (&generatedClusters[index])) @@ -133,17 +161,17 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 11, 22 }, \ + { ZAP_CLUSTER_INDEX(0), 16, 32 }, \ } // Largest attribute size is needed for various buffers #define ATTRIBUTE_LARGEST (2) // Total size of singleton attributes -#define ATTRIBUTE_SINGLETONS_SIZE (0) +#define ATTRIBUTE_SINGLETONS_SIZE (2) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (22) +#define ATTRIBUTE_MAX_SIZE (32) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (1) @@ -187,14 +215,10 @@ // Array of EmberAfCommandMetadata structs. #define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask -#define EMBER_AF_GENERATED_COMMAND_COUNT (105) +#define EMBER_AF_GENERATED_COMMAND_COUNT (129) #define GENERATED_COMMANDS \ { \ - { 0x0000, 0x00, ZAP_COMMAND_MASK(OUTGOING_CLIENT) }, /* Basic (client): MfgSpecificPing */ \ - { \ - 0x0000, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) | ZAP_COMMAND_MASK(OUTGOING_CLIENT) \ - }, /* Basic (client): ResetToFactoryDefaults */ \ - { 0x0003, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Identify (client): Identify */ \ + { 0x0003, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Identify (client): Identify */ \ { 0x0003, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Identify (client): IdentifyQueryResponse */ \ { 0x0003, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Identify (client): IdentifyQuery */ \ { 0x0004, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Groups (client): AddGroup */ \ @@ -231,6 +255,17 @@ { 0x0008, 0x05, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Level Control (client): MoveWithOnOff */ \ { 0x0008, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Level Control (client): StepWithOnOff */ \ { 0x0008, 0x07, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Level Control (client): StopWithOnOff */ \ + { 0x0028, 0x00, ZAP_COMMAND_MASK(OUTGOING_CLIENT) }, /* Basic (client): MfgSpecificPing */ \ + { 0x0028, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (client): StartUp */ \ + { 0x0028, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (client): ShutDown */ \ + { 0x0028, 0x02, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (client): Leave */ \ + { 0x0030, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* General Commissioning (client): SetFabric */ \ + { 0x0030, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* General Commissioning (client): SetFabricResponse */ \ + { 0x0030, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* General Commissioning (client): ArmFailSafe */ \ + { 0x0030, 0x03, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* General Commissioning (client): ArmFailSafeResponse */ \ + { 0x0030, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* General Commissioning (client): CommissioningComplete */ \ + { 0x0030, 0x07, \ + ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* General Commissioning (client): CommissioningCompleteResponse */ \ { 0x0101, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Door Lock (client): LockDoor */ \ { 0x0101, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Door Lock (client): LockDoorResponse */ \ { 0x0101, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Door Lock (client): UnlockDoor */ \ @@ -379,15 +414,31 @@ { \ 0x0300, 0x4C, ZAP_COMMAND_MASK(INCOMING_CLIENT) | ZAP_COMMAND_MASK(OUTGOING_CLIENT) \ }, /* Color Control (client): StepColorTemperature */ \ + { 0x0508, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Low Power (client): Sleep */ \ { 0xF000, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Binding (client): Bind */ \ { 0xF000, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Binding (client): Unbind */ \ + { 0xF001, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Media Playback (client): PlayRequest */ \ + { 0xF001, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Media Playback (client): Playback */ \ + { 0xF001, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Media Playback (client): PauseRequest */ \ + { 0xF001, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Media Playback (client): StopRequest */ \ + { 0xF001, 0x03, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Media Playback (client): StartOverRequest */ \ + { 0xF001, 0x04, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Media Playback (client): PreviousRequest */ \ + { 0xF001, 0x05, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Media Playback (client): NextRequest */ \ + { 0xF001, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Media Playback (client): RewindRequest */ \ + { 0xF001, 0x07, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Media Playback (client): FastForwardRequest */ \ + { 0xF001, 0x08, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Media Playback (client): SkipForwardRequest */ \ + { 0xF001, 0x09, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Media Playback (client): SkipBackwardRequest */ \ + { 0xF002, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Content Launch (client): LaunchContent */ \ + { 0xF002, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Content Launch (client): LaunchContentResponse */ \ + { 0xF002, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Content Launch (client): LaunchURL */ \ + { 0xF002, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Content Launch (client): LaunchURLResponse */ \ } // Array of EmberAfManufacturerCodeEntry structures for commands. #define GENERATED_COMMAND_MANUFACTURER_CODE_COUNT (1) #define GENERATED_COMMAND_MANUFACTURER_CODES \ { \ - { 0, 4098 }, \ + { 37, 4098 }, \ } // This is an array of EmberAfManufacturerCodeEntry structures for clusters. @@ -412,16 +463,7 @@ #define ZRD(x) EMBER_ZCL_REPORTING_DIRECTION_##x #define ZAP_REPORT_DIRECTION(x) ZRD(x) -// Use this macro to check if Reporting plugin is included -#define EMBER_AF_PLUGIN_REPORTING -// User options for plugin Reporting -#define EMBER_AF_PLUGIN_REPORTING_TABLE_SIZE (1) -#define EMBER_AF_PLUGIN_REPORTING_ENABLE_GROUP_BOUND_REPORTS - -#define EMBER_AF_GENERATED_REPORTING_CONFIG_DEFAULTS_TABLE_SIZE (1) +#define EMBER_AF_GENERATED_REPORTING_CONFIG_DEFAULTS_TABLE_SIZE (0) #define EMBER_AF_GENERATED_REPORTING_CONFIG_DEFAULTS \ { \ - { \ - ZAP_REPORT_DIRECTION(REPORTED), 0x0001, 0x0000, 0xFFFD, ZAP_CLUSTER_MASK(CLIENT), 0x0000, { { 0, 65344, 0 } } \ - }, /* Reporting for cluster: "Basic", attribute: "cluster revision". side: client */ \ } diff --git a/src/darwin/Framework/CHIP/gen/gen_config.h b/src/darwin/Framework/CHIP/gen/gen_config.h index 7c77a362d398ce..ce12b688583f4c 100644 --- a/src/darwin/Framework/CHIP/gen/gen_config.h +++ b/src/darwin/Framework/CHIP/gen/gen_config.h @@ -29,20 +29,29 @@ #define EMBER_APS_UNICAST_MESSAGE_COUNT 10 /**** Cluster endpoint counts ****/ +#define EMBER_AF_APPLICATION_BASIC_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_BARRIER_CONTROL_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_BASIC_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_BINDING_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_COLOR_CONTROL_CLUSTER_CLIENT_ENDPOINT_COUNT (1) +#define EMBER_AF_CONTENT_LAUNCH_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_DOOR_LOCK_CLUSTER_CLIENT_ENDPOINT_COUNT (1) +#define EMBER_AF_GENERAL_COMMISSIONING_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_GROUPS_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_IDENTIFY_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_LEVEL_CONTROL_CLUSTER_CLIENT_ENDPOINT_COUNT (1) +#define EMBER_AF_LOW_POWER_CLUSTER_CLIENT_ENDPOINT_COUNT (1) +#define EMBER_AF_MEDIA_PLAYBACK_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_ON_OFF_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_SCENES_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_TEMP_MEASUREMENT_CLUSTER_CLIENT_ENDPOINT_COUNT (1) /**** Cluster Plugins ****/ +// Use this macro to check if the client side of the Application Basic cluster is included +#define ZCL_USING_APPLICATION_BASIC_CLUSTER_CLIENT +#define EMBER_AF_PLUGIN_APPLICATION_BASIC_CLIENT + // Use this macro to check if the client side of the Barrier Control cluster is included #define ZCL_USING_BARRIER_CONTROL_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_BARRIER_CONTROL_CLIENT @@ -59,10 +68,18 @@ #define ZCL_USING_COLOR_CONTROL_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_COLOR_CONTROL_CLIENT +// Use this macro to check if the client side of the Content Launch cluster is included +#define ZCL_USING_CONTENT_LAUNCH_CLUSTER_CLIENT +#define EMBER_AF_PLUGIN_CONTENT_LAUNCH_CLIENT + // Use this macro to check if the client side of the Door Lock cluster is included #define ZCL_USING_DOOR_LOCK_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_DOOR_LOCK_CLIENT +// Use this macro to check if the client side of the General Commissioning cluster is included +#define ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_CLIENT +#define EMBER_AF_PLUGIN_GENERAL_COMMISSIONING_CLIENT + // Use this macro to check if the client side of the Groups cluster is included #define ZCL_USING_GROUPS_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_GROUPS_CLIENT @@ -75,6 +92,14 @@ #define ZCL_USING_LEVEL_CONTROL_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_LEVEL_CONTROL_CLIENT +// Use this macro to check if the client side of the Low Power cluster is included +#define ZCL_USING_LOW_POWER_CLUSTER_CLIENT +#define EMBER_AF_PLUGIN_LOW_POWER_CLIENT + +// Use this macro to check if the client side of the Media Playback cluster is included +#define ZCL_USING_MEDIA_PLAYBACK_CLUSTER_CLIENT +#define EMBER_AF_PLUGIN_MEDIA_PLAYBACK_CLIENT + // Use this macro to check if the client side of the On/off cluster is included #define ZCL_USING_ON_OFF_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_ON_OFF_CLIENT diff --git a/src/darwin/Framework/CHIP/gen/print-cluster.h b/src/darwin/Framework/CHIP/gen/print-cluster.h index 1ea31513afebcd..bd08d38a581506 100644 --- a/src/darwin/Framework/CHIP/gen/print-cluster.h +++ b/src/darwin/Framework/CHIP/gen/print-cluster.h @@ -24,12 +24,6 @@ // to the "EmberAfClusterName" defined in the ZCL header. // The names of clusters that are not present, are removed. -#if defined(ZCL_USING_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_BASIC_CLUSTER_CLIENT) -#define CHIP_PRINTCLUSTER_BASIC_CLUSTER { ZCL_BASIC_CLUSTER_ID, 0, "Basic" }, -#else -#define CHIP_PRINTCLUSTER_BASIC_CLUSTER -#endif - #if defined(ZCL_USING_POWER_CONFIG_CLUSTER_SERVER) || defined(ZCL_USING_POWER_CONFIG_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_POWER_CONFIG_CLUSTER { ZCL_POWER_CONFIG_CLUSTER_ID, 1, "Power Configuration" }, #else @@ -150,6 +144,12 @@ #define CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER #endif +#if defined(ZCL_USING_BASIC_CLUSTER_SERVER) || defined(ZCL_USING_BASIC_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_BASIC_CLUSTER { ZCL_BASIC_CLUSTER_ID, 40, "Basic" }, +#else +#define CHIP_PRINTCLUSTER_BASIC_CLUSTER +#endif + #if defined(ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER { ZCL_GENERAL_COMMISSIONING_CLUSTER_ID, 48, "General Commissioning" }, #else @@ -790,7 +790,6 @@ #endif #define CLUSTER_IDS_TO_NAMES \ - CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_POWER_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DEVICE_TEMP_CLUSTER \ CHIP_PRINTCLUSTER_IDENTIFY_CLUSTER \ @@ -811,6 +810,7 @@ CHIP_PRINTCLUSTER_POLL_CONTROL_CLUSTER \ CHIP_PRINTCLUSTER_GREEN_POWER_CLUSTER \ CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER \ + CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DOOR_LOCK_CLUSTER \ From 0b19aa2330fb5ca7ccfb6d2a53a6f49accf131bd Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 11 Mar 2021 17:45:49 -0500 Subject: [PATCH 10/39] Remove unnecessary "sys/" from errno.h include. (#5326) Looks like it's not needed, and most systems' manpages say to just include . --- examples/shell/shell_common/cmd_ping.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/shell/shell_common/cmd_ping.cpp b/examples/shell/shell_common/cmd_ping.cpp index adc2a7302ca8b9..bb0101c38b7a42 100644 --- a/examples/shell/shell_common/cmd_ping.cpp +++ b/examples/shell/shell_common/cmd_ping.cpp @@ -15,9 +15,9 @@ * limitations under the License. */ +#include #include #include -#include #include #include From cdc40883dfd5cfeee8b2b06791060d58f4430cfa Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Fri, 12 Mar 2021 07:06:32 -0800 Subject: [PATCH 11/39] Fix build error when setting up Ubuntu 20.10 64-bit server OS on RP4 (#5339) --- docs/BUILDING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/BUILDING.md b/docs/BUILDING.md index 3ccc65e6862ca7..f44a18f8e26efc 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -43,7 +43,7 @@ On Debian-based Linux distributions such as Ubuntu, these dependencies can be satisfied with the following: ``` -sudo apt-get install git gcc g++ python pkg-config libssl-dev libdbus-1-dev libglib2.0-dev libavahi-client-dev ninja-build python3-venv python3-dev unzip +sudo apt-get install git gcc g++ python pkg-config libssl-dev libdbus-1-dev libglib2.0-dev libavahi-client-dev ninja-build python3-venv python3-dev python3-pip unzip ``` #### How to install prerequisites on macOS From 18b484fd68c22f92d4f8adea8e7158b1ceec306d Mon Sep 17 00:00:00 2001 From: doru91 Date: Fri, 12 Mar 2021 17:12:06 +0200 Subject: [PATCH 12/39] [K32W] Fix memory allocation (#5242) * [K32W] Fix memory allocation We had to fix the alloc/free pointers because OpenThread API changed. Signed-off-by: Doru Gucea * Restyled by clang-format * [K32W] Fix possible buffer overflow Signed-off-by: Doru Gucea Co-authored-by: Restyled.io --- examples/lock-app/k32w/main/main.cpp | 8 +++--- .../k32w/app/support/FreeRtosMbedtlsUtils.c | 14 ---------- src/platform/K32W/ThreadStackManagerImpl.cpp | 27 +++++++++++++++++++ src/platform/K32W/k32w-chip-mbedtls-config.h | 4 --- 4 files changed, 32 insertions(+), 21 deletions(-) diff --git a/examples/lock-app/k32w/main/main.cpp b/examples/lock-app/k32w/main/main.cpp index c3445cc4e1ade8..edb5667c360af3 100644 --- a/examples/lock-app/k32w/main/main.cpp +++ b/examples/lock-app/k32w/main/main.cpp @@ -22,10 +22,10 @@ #include "openthread/platform/logging.h" #include "openthread/platform/uart.h" +#include #include #include #include -#include #include #include @@ -43,8 +43,6 @@ using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; using namespace ::chip::Logging; -extern "C" void * pvPortCallocRtos(size_t num, size_t size); - #include typedef void (*InitFunc)(void); @@ -54,6 +52,8 @@ extern InitFunc __init_array_end; /* needed for FreeRtos Heap 4 */ uint8_t __attribute__((section(".heap"))) ucHeap[0xF000]; +extern "C" void * pvPortCallocRtos(size_t num, size_t size); + extern "C" void main_task(void const * argument) { CHIP_ERROR ret = CHIP_ERROR_MAX; @@ -65,6 +65,8 @@ extern "C" void main_task(void const * argument) (*pFunc)(); } + mbedtls_platform_set_calloc_free(pvPortCallocRtos, vPortFree); + /* Used for HW initializations */ otSysInit(0, NULL); diff --git a/examples/platform/k32w/app/support/FreeRtosMbedtlsUtils.c b/examples/platform/k32w/app/support/FreeRtosMbedtlsUtils.c index a8ff80fda1cfe4..56a0449bdb3957 100644 --- a/examples/platform/k32w/app/support/FreeRtosMbedtlsUtils.c +++ b/examples/platform/k32w/app/support/FreeRtosMbedtlsUtils.c @@ -64,17 +64,3 @@ void freertos_mbedtls_mutex_free(void) { mbedtls_threading_free_alt(); } - -void * pvPortCallocRtos(size_t num, size_t size) -{ - size_t totalAllocSize = (size_t)(num * size); - - void * p = pvPortMalloc(totalAllocSize); - - if (p) - { - memset(p, 0, totalAllocSize); - } - - return p; -} diff --git a/src/platform/K32W/ThreadStackManagerImpl.cpp b/src/platform/K32W/ThreadStackManagerImpl.cpp index fc317af3eeb059..8180cbac7b98d9 100644 --- a/src/platform/K32W/ThreadStackManagerImpl.cpp +++ b/src/platform/K32W/ThreadStackManagerImpl.cpp @@ -90,3 +90,30 @@ extern "C" void otSysEventSignalPending(void) BaseType_t yieldRequired = ThreadStackMgrImpl().SignalThreadActivityPendingFromISR(); portYIELD_FROM_ISR(yieldRequired); } + +extern "C" void * pvPortCallocRtos(size_t num, size_t size) +{ + size_t totalAllocSize = (size_t)(num * size); + + if (size && totalAllocSize / size != num) + return nullptr; + + void * p = pvPortMalloc(totalAllocSize); + + if (p) + { + memset(p, 0, totalAllocSize); + } + + return p; +} + +extern "C" void * otPlatCAlloc(size_t aNum, size_t aSize) +{ + return pvPortCallocRtos(aNum, aSize); +} + +extern "C" void otPlatFree(void * aPtr) +{ + return vPortFree(aPtr); +} diff --git a/src/platform/K32W/k32w-chip-mbedtls-config.h b/src/platform/K32W/k32w-chip-mbedtls-config.h index 4afbc9f9e041b1..a2c927285b1e29 100644 --- a/src/platform/K32W/k32w-chip-mbedtls-config.h +++ b/src/platform/K32W/k32w-chip-mbedtls-config.h @@ -224,11 +224,7 @@ #if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) #include "FreeRTOS.h" -extern void * pvPortCallocRtos(size_t num, size_t size); /*Calloc for HEAP3.*/ - #define MBEDTLS_PLATFORM_MEMORY -#define MBEDTLS_PLATFORM_STD_CALLOC pvPortCallocRtos -#define MBEDTLS_PLATFORM_STD_FREE vPortFree #endif /* USE_RTOS*/ /**************************** KSDK end ****************************************/ From 193b28e805aa3b6f690e74b7a3ad10f3d162abce Mon Sep 17 00:00:00 2001 From: Justin Wood Date: Fri, 12 Mar 2021 12:02:50 -0800 Subject: [PATCH 13/39] Update .pullapprove.yml --- .pullapprove.yml | 52 ++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/.pullapprove.yml b/.pullapprove.yml index f38bee57d49cfe..1990f7fbfc3be9 100644 --- a/.pullapprove.yml +++ b/.pullapprove.yml @@ -82,7 +82,7 @@ groups: reviewers: teams: [reviewers-apple] reviews: - request: 2 + request: 1 shared-reviewers-comcast: type: optional conditions: @@ -90,7 +90,7 @@ groups: reviewers: teams: [reviewers-comcast] reviews: - request: 2 + request: 1 shared-reviewers-google: type: optional conditions: @@ -98,7 +98,7 @@ groups: reviewers: teams: [reviewers-google] reviews: - request: 2 + request: 1 shared-reviewers-nordic: type: optional conditions: @@ -106,7 +106,7 @@ groups: reviewers: teams: [reviewers-nordic] reviews: - request: 2 + request: 1 shared-reviewers-samsung: type: optional conditions: @@ -114,7 +114,7 @@ groups: reviewers: teams: [reviewers-samsung] reviews: - request: 2 + request: 1 shared-reviewers-silabs: type: optional conditions: @@ -122,7 +122,7 @@ groups: reviewers: teams: [reviewers-silabs] reviews: - request: 2 + request: 1 ############################################################ # Base Required Reviewers @@ -150,7 +150,7 @@ groups: teams: - codeowners-android reviews: - request: 2 + request: 1 codeowners-app: type: optional @@ -160,7 +160,7 @@ groups: teams: - codeowners-app reviews: - request: 2 + request: 1 codeowners-ble: type: optional @@ -170,7 +170,7 @@ groups: teams: - codeowners-ble reviews: - request: 2 + request: 1 codeowners-controller: type: optional @@ -180,7 +180,7 @@ groups: teams: - codeowners-controller reviews: - request: 2 + request: 1 codeowners-darwin: type: optional @@ -190,7 +190,7 @@ groups: teams: - codeowners-darwin reviews: - request: 2 + request: 1 codeowners-crypto: type: optional @@ -200,7 +200,7 @@ groups: teams: - codeowners-crypto reviews: - request: 2 + request: 1 codeowners-inet: type: optional @@ -230,7 +230,7 @@ groups: teams: - codeowners-protocols reviews: - request: 2 + request: 1 codeowners-shell: type: optional @@ -240,7 +240,7 @@ groups: teams: - codeowners-shell reviews: - request: 2 + request: 1 codeowners-support: type: optional @@ -250,7 +250,7 @@ groups: teams: - codeowners-support reviews: - request: 2 + request: 1 codeowners-platform: type: optional @@ -260,7 +260,7 @@ groups: teams: - codeowners-platform reviews: - request: 2 + request: 1 codeowners-qrcode: type: optional @@ -270,7 +270,7 @@ groups: teams: - codeowners-qrcode reviews: - request: 2 + request: 1 codeowners-setup-payload: type: optional @@ -280,7 +280,7 @@ groups: teams: - codeowners-setup-payload reviews: - request: 2 + request: 1 codeowners-system: type: optional @@ -290,7 +290,7 @@ groups: teams: - codeowners-system reviews: - request: 2 + request: 1 codeowners-test-driver: type: optional @@ -300,7 +300,7 @@ groups: teams: - codeowners-test-driver reviews: - request: 2 + request: 1 codeowners-github: type: optional @@ -310,7 +310,7 @@ groups: teams: - codeowners-github reviews: - request: 2 + request: 1 codeowners-vscode: type: optional @@ -330,7 +330,7 @@ groups: teams: - codeowners-integrations reviews: - request: 2 + request: 1 codeowners-transport: type: optional @@ -340,7 +340,7 @@ groups: teams: - codeowners-transport reviews: - request: 2 + request: 1 codeowners-scripts: type: optional @@ -350,7 +350,7 @@ groups: teams: - codeowners-scripts reviews: - request: 2 + request: 1 codeowners-documentation: type: optional @@ -360,7 +360,7 @@ groups: teams: - codeowners-documentation reviews: - request: 2 + request: 1 codeowners-gn: type: optional @@ -370,4 +370,4 @@ groups: teams: - codeowners-gn reviews: - request: 2 + request: 1 From bf217495ed4373712dbf816f84e19112400e85b2 Mon Sep 17 00:00:00 2001 From: jrhees-cae <61466710+jrhees-cae@users.noreply.github.com> Date: Fri, 12 Mar 2021 13:18:06 -0700 Subject: [PATCH 14/39] [nrfconnect] Change BLE advertisement flag to Limited Discovery (#5350) --- src/platform/Zephyr/BLEManagerImpl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/Zephyr/BLEManagerImpl.cpp b/src/platform/Zephyr/BLEManagerImpl.cpp index 7da119a618f21e..e1845a7acad9a0 100644 --- a/src/platform/Zephyr/BLEManagerImpl.cpp +++ b/src/platform/Zephyr/BLEManagerImpl.cpp @@ -186,7 +186,7 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) CHIP_ERROR err; const char * deviceName = bt_get_name(); - const uint8_t advFlags = BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR; + const uint8_t advFlags = BT_LE_AD_LIMITED | BT_LE_AD_NO_BREDR; bt_le_adv_param advParams = BT_LE_ADV_PARAM_INIT(BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_ONE_TIME, GetAdvertisingInterval(), CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL, nullptr); From 571f843781604564d25945b6c1a15b795209d073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Kr=C3=B3lik?= <66667989+Damian-Nordic@users.noreply.github.com> Date: Fri, 12 Mar 2021 21:18:23 +0100 Subject: [PATCH 15/39] [mdns] Fix Resolver initialization (#5347) ChipMdnsInit() call has recently been moved to ServiceAdvertiser::Start, hence the function is never called on the mDNS resolver side. Call the initialization function when necessary. --- src/lib/mdns/Discovery_ImplPlatform.cpp | 34 ++++++++++++------------- src/lib/mdns/Discovery_ImplPlatform.h | 2 ++ 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/lib/mdns/Discovery_ImplPlatform.cpp b/src/lib/mdns/Discovery_ImplPlatform.cpp index eb712430482f2f..1724591a1b03cb 100644 --- a/src/lib/mdns/Discovery_ImplPlatform.cpp +++ b/src/lib/mdns/Discovery_ImplPlatform.cpp @@ -57,24 +57,28 @@ constexpr uint64_t kUndefinedNodeId = 0; namespace chip { namespace Mdns { -DiscoveryImplPlatform::DiscoveryImplPlatform() -{ - mCommissionInstanceName = GetRandU64(); -} +DiscoveryImplPlatform DiscoveryImplPlatform::sManager; -CHIP_ERROR DiscoveryImplPlatform::Start(Inet::InetLayer * inetLayer, uint16_t port) +DiscoveryImplPlatform::DiscoveryImplPlatform() = default; + +CHIP_ERROR DiscoveryImplPlatform::Init() { - CHIP_ERROR error = CHIP_NO_ERROR; if (!mMdnsInitialized) { ReturnErrorOnFailure(ChipMdnsInit(HandleMdnsInit, HandleMdnsError, this)); - mMdnsInitialized = true; - } - else - { - error = ChipMdnsStopPublish(); + mCommissionInstanceName = GetRandU64(); + mMdnsInitialized = true; } + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiscoveryImplPlatform::Start(Inet::InetLayer * inetLayer, uint16_t port) +{ + ReturnErrorOnFailure(Init()); + + CHIP_ERROR error = ChipMdnsStopPublish(); + if (error != CHIP_NO_ERROR) { ChipLogError(Discovery, "Failed to initialize platform mdns: %s", ErrorStr(error)); @@ -280,6 +284,8 @@ CHIP_ERROR DiscoveryImplPlatform::SetResolverDelegate(ResolverDelegate * delegat CHIP_ERROR DiscoveryImplPlatform::ResolveNodeId(uint64_t nodeId, uint64_t fabricId, Inet::IPAddressType type) { + ReturnErrorOnFailure(Init()); + MdnsService service; snprintf(service.mName, sizeof(service.mName), "%" PRIX64 "-%" PRIX64, nodeId, fabricId); @@ -357,12 +363,6 @@ void DiscoveryImplPlatform::HandleNodeIdResolve(void * context, MdnsService * re DiscoveryImplPlatform & DiscoveryImplPlatform::GetInstance() { - // TODO: Clean Mdns initialization order - // Previously sManager was a global object, but DiscoveryImplPlatform constructor calls - // platform-specific ChipMdnsInit() which for Linux initializes MdnsAvahi global object - // and that may lead to improper initialization, since the order in which global objects' - // constructors are called is undefined. - static DiscoveryImplPlatform sManager; return sManager; } diff --git a/src/lib/mdns/Discovery_ImplPlatform.h b/src/lib/mdns/Discovery_ImplPlatform.h index 1bc367f836b350..c05e227d5cb4ce 100644 --- a/src/lib/mdns/Discovery_ImplPlatform.h +++ b/src/lib/mdns/Discovery_ImplPlatform.h @@ -30,6 +30,8 @@ namespace Mdns { class DiscoveryImplPlatform : public ServiceAdvertiser, public Resolver { public: + CHIP_ERROR Init(); + CHIP_ERROR Start(Inet::InetLayer * inetLayer, uint16_t port) override; /// Advertises the CHIP node as an operational node From 44014022e996aaf7ccfbb894d3a793e509af870b Mon Sep 17 00:00:00 2001 From: Kamil Kasperczyk <66371704+kkasperczyk-no@users.noreply.github.com> Date: Fri, 12 Mar 2021 21:18:45 +0100 Subject: [PATCH 16/39] Integrated SRP client API with the existing mDNS API. (#5343) The SRP and mDNS protocols should have some common layer and API. For now it seems to be reasonable to make SRP client to behave as mDNS implementation for Thread devices, so some integration is necessary in order to reuse existing mDNS code. * Replaced chip_mdns_advertiser and chip_enable_mdns arguments, with one - chip_mdns acting as both of them. * Added implementation of SetupHostname() method for Thread devices. * Added MdnsImpl for the OpenThread platform. * Expanded AddSrpService method by possibility to pass text entries. * Added ifdef to not call AdvertiseCommissioning for Thread devices, as they are not able to do that in unprovisioned state. * Added ThreadStackManager method for getting device EUI64. * Added starting mdns server to the Server.cpp InitServer() method, as it was removed in the https://github.com/project-chip/connectedhomeip/pull/5154 for platforms other than ESP32. --- config/nrfconnect/chip-module/CMakeLists.txt | 4 ++ src/app/server/Mdns.cpp | 5 ++ src/app/server/Server.cpp | 5 ++ src/include/platform/ThreadStackManager.h | 19 ++++- .../GenericConfigurationManagerImpl.h | 1 + src/lib/mdns/BUILD.gn | 17 +---- src/lib/mdns/Discovery_ImplPlatform.cpp | 19 ++++- src/lib/mdns/platform/Mdns.h | 7 +- src/platform/BUILD.gn | 13 ++-- src/platform/Linux/ThreadStackManagerImpl.cpp | 5 ++ src/platform/Linux/ThreadStackManagerImpl.h | 2 + ...nericThreadStackManagerImpl_OpenThread.cpp | 62 +++++++++++++++-- ...GenericThreadStackManagerImpl_OpenThread.h | 13 +++- src/platform/OpenThread/MdnsImpl.cpp | 69 +++++++++++++++++++ src/platform/device.gni | 7 +- src/platform/tests/BUILD.gn | 2 +- 16 files changed, 213 insertions(+), 37 deletions(-) create mode 100644 src/platform/OpenThread/MdnsImpl.cpp diff --git a/config/nrfconnect/chip-module/CMakeLists.txt b/config/nrfconnect/chip-module/CMakeLists.txt index 84be44e590f69d..3feee96fec1b69 100644 --- a/config/nrfconnect/chip-module/CMakeLists.txt +++ b/config/nrfconnect/chip-module/CMakeLists.txt @@ -202,6 +202,10 @@ chip_gn_arg_bool ("chip_inet_config_enable_dns_resolver" CONFIG_CHIP_BUILD_TE chip_gn_arg_bool ("chip_build_libshell" CONFIG_CHIP_LIB_SHELL) chip_gn_arg_bool ("chip_build_pw_rpc_lib" CONFIG_CHIP_PW_RPC) +if (CONFIG_CHIP_ENABLE_DNSSD_SRP) + chip_gn_arg_string("chip_mdns" "platform") +endif() + if (CHIP_PROJECT_CONFIG) chip_gn_arg_string("chip_project_config_include" ${CHIP_PROJECT_CONFIG}) chip_gn_arg_string("chip_system_project_config_include" ${CHIP_PROJECT_CONFIG}) diff --git a/src/app/server/Mdns.cpp b/src/app/server/Mdns.cpp index 19dd9f0513072f..59984bdc514de0 100644 --- a/src/app/server/Mdns.cpp +++ b/src/app/server/Mdns.cpp @@ -142,7 +142,12 @@ void StartServer() } else { +// TODO: Thread devices are not able to advertise using mDNS before being provisioned, +// so configuraton should be added to enable commissioning advertising based on supported +// Rendezvous methods. +#if !CHIP_DEVICE_CONFIG_ENABLE_THREAD err = app::Mdns::AdvertiseCommisioning(); +#endif } if (err != CHIP_NO_ERROR) diff --git a/src/app/server/Server.cpp b/src/app/server/Server.cpp index 5e8699356fa9f0..fa10c5446d3a2f 100644 --- a/src/app/server/Server.cpp +++ b/src/app/server/Server.cpp @@ -531,6 +531,11 @@ void InitServer(AppDelegate * delegate) #endif } +// Starting mDNS server only for Thread devices due to problem reported in issue #5076. +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + app::Mdns::StartServer(); +#endif + exit: if (err != CHIP_NO_ERROR) { diff --git a/src/include/platform/ThreadStackManager.h b/src/include/platform/ThreadStackManager.h index 71fc2f7dbcf3a8..45b1651b0af80f 100644 --- a/src/include/platform/ThreadStackManager.h +++ b/src/include/platform/ThreadStackManager.h @@ -24,6 +24,11 @@ #pragma once namespace chip { + +namespace Mdns { +struct TextEntry; +} + namespace DeviceLayer { class PlatformManagerImpl; @@ -74,6 +79,7 @@ class ThreadStackManager CHIP_ERROR GetAndLogThreadTopologyMinimal(); CHIP_ERROR GetAndLogThreadTopologyFull(); CHIP_ERROR GetPrimary802154MACAddress(uint8_t * buf); + CHIP_ERROR GetFactoryAssignedEUI64(uint8_t (&buf)[8]); CHIP_ERROR GetExternalIPv6Address(chip::Inet::IPAddress & addr); CHIP_ERROR JoinerStart(); @@ -82,8 +88,8 @@ class ThreadStackManager CHIP_ERROR SetThreadEnabled(bool val); #if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT - CHIP_ERROR AddSrpService(const char * aInstanceName, const char * aName, uint16_t aPort, uint32_t aLeaseInterval, - uint32_t aKeyLeaseInterval); + CHIP_ERROR AddSrpService(const char * aInstanceName, const char * aName, uint16_t aPort, chip::Mdns::TextEntry * aTxtEntries, + size_t aTxtEntiresSize, uint32_t aLeaseInterval, uint32_t aKeyLeaseInterval); CHIP_ERROR RemoveSrpService(const char * aInstanceName, const char * aName); CHIP_ERROR SetupSrpHost(const char * aHostName); #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT @@ -227,9 +233,11 @@ inline CHIP_ERROR ThreadStackManager::SetThreadEnabled(bool val) #if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT inline CHIP_ERROR ThreadStackManager::AddSrpService(const char * aInstanceName, const char * aName, uint16_t aPort, + chip::Mdns::TextEntry * aTxtEntries, size_t aTxtEntiresSize, uint32_t aLeaseInterval = 0, uint32_t aKeyLeaseInterval = 0) { - return static_cast(this)->_AddSrpService(aInstanceName, aName, aPort, aLeaseInterval, aKeyLeaseInterval); + return static_cast(this)->_AddSrpService(aInstanceName, aName, aPort, aTxtEntries, aTxtEntiresSize, aLeaseInterval, + aKeyLeaseInterval); } inline CHIP_ERROR ThreadStackManager::RemoveSrpService(const char * aInstanceName, const char * aName) @@ -333,6 +341,11 @@ inline CHIP_ERROR ThreadStackManager::GetPrimary802154MACAddress(uint8_t * buf) return static_cast(this)->_GetPrimary802154MACAddress(buf); } +inline CHIP_ERROR ThreadStackManager::GetFactoryAssignedEUI64(uint8_t (&buf)[8]) +{ + return static_cast(this)->_GetFactoryAssignedEUI64(buf); +} + inline CHIP_ERROR ThreadStackManager::GetExternalIPv6Address(chip::Inet::IPAddress & addr) { return static_cast(this)->_GetExternalIPv6Address(addr); diff --git a/src/include/platform/internal/GenericConfigurationManagerImpl.h b/src/include/platform/internal/GenericConfigurationManagerImpl.h index 15fb258d753c5e..44e410beb39151 100644 --- a/src/include/platform/internal/GenericConfigurationManagerImpl.h +++ b/src/include/platform/internal/GenericConfigurationManagerImpl.h @@ -66,6 +66,7 @@ class GenericConfigurationManagerImpl CHIP_ERROR _GetPrimaryWiFiMACAddress(uint8_t * buf); CHIP_ERROR _StorePrimaryWiFiMACAddress(const uint8_t * buf); CHIP_ERROR _GetPrimary802154MACAddress(uint8_t * buf); + CHIP_ERROR _GetFactoryAssignedEUI64(uint8_t (&buf)[8]); CHIP_ERROR _StorePrimary802154MACAddress(const uint8_t * buf); CHIP_ERROR _GetManufacturingDate(uint16_t & year, uint8_t & month, uint8_t & dayOfMonth); CHIP_ERROR _StoreManufacturingDate(const char * mfgDate, size_t mfgDateLen); diff --git a/src/lib/mdns/BUILD.gn b/src/lib/mdns/BUILD.gn index da0e39b03a8a34..327828e8086bfb 100644 --- a/src/lib/mdns/BUILD.gn +++ b/src/lib/mdns/BUILD.gn @@ -15,11 +15,6 @@ import("//build_overrides/chip.gni") import("${chip_root}/src/platform/device.gni") -declare_args() { - # Set up what advertiser to use for mDNS advertisement - chip_mdns_advertiser = "minimal" -} - source_set("platform_header") { sources = [ "platform/Mdns.h" ] } @@ -33,24 +28,18 @@ static_library("mdns") { sources = [ "Advertiser.h" ] - if (chip_enable_mdns) { - _chip_mdns_advertiser = chip_mdns_advertiser - } else { - _chip_mdns_advertiser = "none" - } - - if (_chip_mdns_advertiser == "none") { + if (chip_mdns == "none") { sources += [ "Advertiser_ImplNone.cpp", "Resolver_ImplNone.cpp", ] - } else if (_chip_mdns_advertiser == "minimal") { + } else if (chip_mdns == "minimal") { sources += [ "Advertiser_ImplMinimalMdns.cpp", "Resolver_ImplNone.cpp", ] public_deps += [ "${chip_root}/src/lib/mdns/minimal" ] - } else if (_chip_mdns_advertiser == "platform") { + } else if (chip_mdns == "platform") { sources += [ "Discovery_ImplPlatform.cpp", "Discovery_ImplPlatform.h", diff --git a/src/lib/mdns/Discovery_ImplPlatform.cpp b/src/lib/mdns/Discovery_ImplPlatform.cpp index 1724591a1b03cb..ab35b586a137db 100644 --- a/src/lib/mdns/Discovery_ImplPlatform.cpp +++ b/src/lib/mdns/Discovery_ImplPlatform.cpp @@ -83,6 +83,13 @@ CHIP_ERROR DiscoveryImplPlatform::Start(Inet::InetLayer * inetLayer, uint16_t po { ChipLogError(Discovery, "Failed to initialize platform mdns: %s", ErrorStr(error)); } + + error = SetupHostname(); + if (error != CHIP_NO_ERROR) + { + ChipLogError(Discovery, "Failed to setup mdns hostname: %s", ErrorStr(error)); + } + return error; } @@ -141,6 +148,13 @@ CHIP_ERROR DiscoveryImplPlatform::GenerateRotatingDeviceId(char rotatingDeviceId CHIP_ERROR DiscoveryImplPlatform::SetupHostname() { +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + static char hostname[17]; // Hostname is 64-bit EUI-64 expressed as a 16-character hexadecimal string. + uint8_t eui64[8]; + chip::DeviceLayer::ThreadStackMgr().GetFactoryAssignedEUI64(eui64); + snprintf(hostname, sizeof(hostname), "%02X%02X%02X%02X%02X%02X%02X%02X", eui64[0], eui64[1], eui64[2], eui64[3], eui64[4], + eui64[5], eui64[6], eui64[7]); +#else uint8_t mac[6]; // 6 byte wifi mac char hostname[13]; // Hostname will be the hex representation of mac. @@ -149,6 +163,8 @@ CHIP_ERROR DiscoveryImplPlatform::SetupHostname() { snprintf(&hostname[i * 2], sizeof(hostname) - i * 2, "%02X", mac[i]); } +#endif + ReturnErrorOnFailure(ChipMdnsSetHostname(hostname)); return CHIP_NO_ERROR; @@ -255,7 +271,8 @@ CHIP_ERROR DiscoveryImplPlatform::Advertise(const OperationalAdvertisingParamete mOperationalAdvertisingParams = params; // TODO: There may be multilple device/fabrid ids after multi-admin. - snprintf(service.mName, sizeof(service.mName), "%" PRIX64 "-%" PRIX64, params.GetNodeId(), params.GetFabricId()); + snprintf(service.mName, sizeof(service.mName), "%08X%08X-%08X%08X", (uint32_t)(params.GetNodeId() >> 32), + (uint32_t)(params.GetNodeId()), (uint32_t)(params.GetFabricId() >> 32), (uint32_t)(params.GetFabricId())); strncpy(service.mType, "_chip", sizeof(service.mType)); service.mProtocol = MdnsServiceProtocol::kMdnsProtocolTcp; service.mPort = CHIP_PORT; diff --git a/src/lib/mdns/platform/Mdns.h b/src/lib/mdns/platform/Mdns.h index b93e21c03d2e5b..a6ecf46cf96200 100644 --- a/src/lib/mdns/platform/Mdns.h +++ b/src/lib/mdns/platform/Mdns.h @@ -35,9 +35,10 @@ namespace chip { namespace Mdns { -static constexpr uint8_t kMdnsNameMaxSize = 33; -static constexpr uint8_t kMdnsTypeMaxSize = 32; -static constexpr uint16_t kMdnsTextMaxSize = 64; +static constexpr uint8_t kMdnsNameMaxSize = 33; +static constexpr uint8_t kMdnsProtocolTextMaxSize = 8; +static constexpr uint8_t kMdnsTypeMaxSize = 32; +static constexpr uint16_t kMdnsTextMaxSize = 64; enum class MdnsServiceProtocol : uint8_t { diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index 4b924b5f4f403e..e5451ade0b54ee 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -30,7 +30,7 @@ if (chip_enable_openthread) { } } -if (chip_device_platform == "linux" && chip_enable_mdns) { +if (chip_device_platform == "linux" && chip_mdns != "none") { pkg_config("avahi_client_config") { packages = [ "avahi-client" ] } @@ -75,7 +75,7 @@ if (chip_device_platform != "none") { defines += [ "CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE=${chip_enable_ble}" ] } - if (chip_enable_mdns) { + if (chip_mdns != "none") { defines += [ "CHIP_DEVICE_CONFIG_ENABLE_MDNS=1" ] } @@ -241,7 +241,7 @@ if (chip_device_platform != "none" && chip_device_platform != "external") { "${chip_root}/src:includes", ] - if (chip_enable_mdns) { + if (chip_mdns != "none") { public_deps += [ "${chip_root}/src/lib/mdns:platform_header" ] } @@ -494,7 +494,7 @@ if (chip_device_platform != "none" && chip_device_platform != "external") { "Linux/bluez/Types.h", ] - if (chip_enable_mdns) { + if (chip_mdns != "none") { sources += [ "Linux/MdnsImpl.cpp", "Linux/MdnsImpl.h", @@ -595,6 +595,11 @@ if (chip_device_platform != "none" && chip_device_platform != "external") { } } + if (chip_enable_openthread && chip_mdns == "platform" && + chip_device_platform != "linux") { + sources += [ "OpenThread/MdnsImpl.cpp" ] + } + allow_circular_includes_from = [ "${chip_root}/src/lib/support" ] } } else if (chip_device_platform == "external") { diff --git a/src/platform/Linux/ThreadStackManagerImpl.cpp b/src/platform/Linux/ThreadStackManagerImpl.cpp index f2bea4af05b1a0..b4f755f1ab0c98 100644 --- a/src/platform/Linux/ThreadStackManagerImpl.cpp +++ b/src/platform/Linux/ThreadStackManagerImpl.cpp @@ -441,6 +441,11 @@ CHIP_ERROR ThreadStackManagerImpl::_GetPrimary802154MACAddress(uint8_t * buf) return OTBR_TO_CHIP_ERROR(error); } +CHIP_ERROR ThreadStackManagerImpl::_GetFactoryAssignedEUI64(uint8_t (&buf)[8]) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + CHIP_ERROR ThreadStackManagerImpl::_GetExternalIPv6Address(chip::Inet::IPAddress & addr) { return CHIP_ERROR_NOT_IMPLEMENTED; diff --git a/src/platform/Linux/ThreadStackManagerImpl.h b/src/platform/Linux/ThreadStackManagerImpl.h index 2d7bdadd3c2b45..0f286c3b65a94e 100644 --- a/src/platform/Linux/ThreadStackManagerImpl.h +++ b/src/platform/Linux/ThreadStackManagerImpl.h @@ -86,6 +86,8 @@ class ThreadStackManagerImpl : public ThreadStackManager CHIP_ERROR _GetPrimary802154MACAddress(uint8_t * buf); + CHIP_ERROR _GetFactoryAssignedEUI64(uint8_t (&buf)[8]); + CHIP_ERROR _GetExternalIPv6Address(chip::Inet::IPAddress & addr); CHIP_ERROR _JoinerStart(); diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp index f51f76ac9dd8a5..cd9200440416fe 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp @@ -80,6 +80,19 @@ void GenericThreadStackManagerImpl_OpenThread::OnOpenThreadStateChang event.ThreadStateChange.NetDataChanged = (flags & OT_CHANGED_THREAD_NETDATA) != 0; event.ThreadStateChange.ChildNodesChanged = (flags & (OT_CHANGED_THREAD_CHILD_ADDED | OT_CHANGED_THREAD_CHILD_REMOVED)) != 0; event.ThreadStateChange.OpenThread.Flags = flags; + +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT + if (event.ThreadStateChange.AddressChanged) + { + const otSrpClientHostInfo * hostInfo = + otSrpClientGetHostInfo(static_cast(context)->Impl()->OTInstance()); + if (hostInfo && hostInfo->mName) + { + static_cast(context)->Impl()->_SetupSrpHost(hostInfo->mName); + } + } +#endif + PlatformMgr().PostEvent(&event); } @@ -817,6 +830,15 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_GetPrimary80215 return CHIP_NO_ERROR; }; +template +CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_GetFactoryAssignedEUI64(uint8_t (&buf)[8]) +{ + otExtAddress extendedAddr; + otLinkGetFactoryAssignedIeeeEui64(mOTInst, &extendedAddr); + memcpy(buf, extendedAddr.m8, sizeof(extendedAddr.m8)); + return CHIP_NO_ERROR; +}; + template CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_GetExternalIPv6Address(chip::Inet::IPAddress & addr) { @@ -875,7 +897,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::DoInit(otInstanc // state change occurs. Note that we reference the OnOpenThreadStateChange method // on the concrete implementation class so that that class can override the default // method implementation if it chooses to. - otErr = otSetStateChangedCallback(otInst, ImplClass::OnOpenThreadStateChange, NULL); + otErr = otSetStateChangedCallback(otInst, ImplClass::OnOpenThreadStateChange, this); VerifyOrExit(otErr == OT_ERROR_NONE, err = MapOpenThreadError(otErr)); // Enable automatic assignment of Thread advertised addresses. @@ -1116,7 +1138,8 @@ void GenericThreadStackManagerImpl_OpenThread::OnSrpClientStateChange template CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_AddSrpService(const char * aInstanceName, const char * aName, - uint16_t aPort, uint32_t aLeaseInterval, + uint16_t aPort, chip::Mdns::TextEntry * aTxtEntries, + size_t aTxtEntiresSize, uint32_t aLeaseInterval, uint32_t aKeyLeaseInterval) { CHIP_ERROR error = CHIP_NO_ERROR; @@ -1158,6 +1181,29 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_AddSrpService(c srpService->mService.mPort = aPort; + // Check if there are some optional text entries to add. + if (aTxtEntries && aTxtEntiresSize != 0) + { + VerifyOrExit(aTxtEntiresSize <= SrpClient::kMaxTxtEntriesNumber, error = CHIP_ERROR_INVALID_LIST_LENGTH); + + srpService->mService.mNumTxtEntries = static_cast(aTxtEntiresSize); + + for (uint8_t entryId = 0; entryId < aTxtEntiresSize; entryId++) + { + VerifyOrExit(aTxtEntries[entryId].mDataSize <= SrpClient::kMaxTxtValueSize, error = CHIP_ERROR_BUFFER_TOO_SMALL); + VerifyOrExit((strlen(aTxtEntries[entryId].mKey) + 1) <= SrpClient::kMaxTxtKeySize, error = CHIP_ERROR_BUFFER_TOO_SMALL); + + srpService->mTxtEntries[entryId].mValueLength = static_cast(aTxtEntries[entryId].mDataSize); + memcpy(&(srpService->mTxtValueBuffers[entryId][0]), aTxtEntries[entryId].mData, aTxtEntries[entryId].mDataSize); + srpService->mTxtEntries[entryId].mValue = &(srpService->mTxtValueBuffers[entryId][0]); + + memcpy(&(srpService->mTxtKeyBuffers[entryId][0]), aTxtEntries[entryId].mKey, strlen(aTxtEntries[entryId].mKey) + 1); + srpService->mTxtEntries[entryId].mKey = &(srpService->mTxtKeyBuffers[entryId][0]); + } + + srpService->mService.mTxtEntries = srpService->mTxtEntries; + } + error = MapOpenThreadError(otSrpClientAddService(mOTInst, &(srpService->mService))); exit: @@ -1214,11 +1260,13 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_SetupSrpHost(co error = MapOpenThreadError(otSrpClientSetHostName(mOTInst, aHostName)); SuccessOrExit(error); - error = ThreadStackMgr().GetExternalIPv6Address(hostAddress); - SuccessOrExit(error); - - memcpy(&mSrpClient.mHostAddress.mFields.m32, hostAddress.Addr, sizeof(hostAddress.Addr)); - error = MapOpenThreadError(otSrpClientSetHostAddresses(mOTInst, &mSrpClient.mHostAddress, 1)); + // Check if device has any external IPv6 assigned. If not, host will be set without IPv6 addresses + // and updated later on. + if (ThreadStackMgr().GetExternalIPv6Address(hostAddress) == CHIP_NO_ERROR) + { + memcpy(&mSrpClient.mHostAddress.mFields.m32, hostAddress.Addr, sizeof(hostAddress.Addr)); + error = MapOpenThreadError(otSrpClientSetHostAddresses(mOTInst, &mSrpClient.mHostAddress, 1)); + } exit: Impl()->UnlockThreadStack(); diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h index b6b7972a25e7af..e53614122ca0ee 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h @@ -32,6 +32,8 @@ #include #endif +#include + namespace chip { namespace DeviceLayer { @@ -87,13 +89,14 @@ class GenericThreadStackManagerImpl_OpenThread CHIP_ERROR _GetAndLogThreadTopologyMinimal(void); CHIP_ERROR _GetAndLogThreadTopologyFull(void); CHIP_ERROR _GetPrimary802154MACAddress(uint8_t * buf); + CHIP_ERROR _GetFactoryAssignedEUI64(uint8_t (&buf)[8]); CHIP_ERROR _GetExternalIPv6Address(chip::Inet::IPAddress & addr); void _OnWoBLEAdvertisingStart(void); void _OnWoBLEAdvertisingStop(void); #if CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT - CHIP_ERROR _AddSrpService(const char * aInstanceName, const char * aName, uint16_t aPort, uint32_t aLeaseInterval, - uint32_t aKeyLeaseInterval); + CHIP_ERROR _AddSrpService(const char * aInstanceName, const char * aName, uint16_t aPort, chip::Mdns::TextEntry * aTxtEntries, + size_t aTxtEntiresSize, uint32_t aLeaseInterval, uint32_t aKeyLeaseInterval); CHIP_ERROR _RemoveSrpService(const char * aInstanceName, const char * aName); CHIP_ERROR _SetupSrpHost(const char * aHostName); #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT @@ -122,12 +125,18 @@ class GenericThreadStackManagerImpl_OpenThread static constexpr uint8_t kMaxInstanceNameSize = 64; static constexpr uint8_t kMaxNameSize = 16; static constexpr uint8_t kMaxHostNameSize = 32; + static constexpr uint8_t kMaxTxtEntriesNumber = 4; + static constexpr uint8_t kMaxTxtValueSize = 255; + static constexpr uint8_t kMaxTxtKeySize = 16; struct Service { otSrpClientService mService; char mInstanceName[kMaxInstanceNameSize]; char mName[kMaxNameSize]; + otDnsTxtEntry mTxtEntries[kMaxTxtEntriesNumber]; + uint8_t mTxtValueBuffers[kMaxTxtEntriesNumber][kMaxTxtValueSize]; + char mTxtKeyBuffers[kMaxTxtEntriesNumber][kMaxTxtKeySize]; }; char mHostName[kMaxHostNameSize]; diff --git a/src/platform/OpenThread/MdnsImpl.cpp b/src/platform/OpenThread/MdnsImpl.cpp new file mode 100644 index 00000000000000..4652512968f5a8 --- /dev/null +++ b/src/platform/OpenThread/MdnsImpl.cpp @@ -0,0 +1,69 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "lib/mdns/platform/Mdns.h" + +#include + +using namespace ::chip::DeviceLayer; + +namespace chip { +namespace Mdns { + +CHIP_ERROR ChipMdnsInit(MdnsAsyncReturnCallback initCallback, MdnsAsyncReturnCallback errorCallback, void * context) +{ + // Intentionally empty + return CHIP_NO_ERROR; +} + +CHIP_ERROR ChipMdnsSetHostname(const char * hostname) +{ + return ThreadStackMgr().SetupSrpHost(hostname); +} + +const char * GetProtocolString(MdnsServiceProtocol protocol) +{ + return protocol == MdnsServiceProtocol::kMdnsProtocolUdp ? "_udp" : "_tcp"; +} + +CHIP_ERROR ChipMdnsPublishService(const MdnsService * service) +{ + char serviceType[kMdnsTypeMaxSize + kMdnsProtocolTextMaxSize + 1]; + snprintf(serviceType, sizeof(serviceType), "%s.%s", service->mType, GetProtocolString(service->mProtocol)); + + return ThreadStackMgr().AddSrpService(service->mName, serviceType, service->mPort, service->mTextEntries, + service->mTextEntrySize); +} + +CHIP_ERROR ChipMdnsStopPublish() +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR ChipMdnsBrowse(const char * type, MdnsServiceProtocol protocol, Inet::IPAddressType addressType, + Inet::InterfaceId interface, MdnsBrowseCallback callback, void * context) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR ChipMdnsResolve(MdnsService * browseResult, Inet::InterfaceId interface, MdnsResolveCallback callback, void * context) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +} // namespace Mdns +} // namespace chip diff --git a/src/platform/device.gni b/src/platform/device.gni index 57821d110aaa02..7cb8bb41059f60 100644 --- a/src/platform/device.gni +++ b/src/platform/device.gni @@ -46,8 +46,11 @@ declare_args() { (chip_device_platform == "linux" || chip_device_platform == "darwin" || chip_device_platform == "cc13x2_26x2") - chip_enable_mdns = - chip_device_platform == "linux" || chip_device_platform == "esp32" + if (chip_device_platform == "linux" || chip_device_platform == "esp32") { + chip_mdns = "minimal" + } else { + chip_mdns = "none" + } } _chip_device_layer = "none" diff --git a/src/platform/tests/BUILD.gn b/src/platform/tests/BUILD.gn index 86265048090fba..538e95ed89ec79 100644 --- a/src/platform/tests/BUILD.gn +++ b/src/platform/tests/BUILD.gn @@ -32,7 +32,7 @@ if (chip_device_platform != "none") { test_sources += [ "TestPlatformMgr.cpp" ] } - if (chip_enable_mdns && chip_enable_happy_tests && + if (chip_mdns != "none" && chip_enable_happy_tests && chip_device_platform == "linux") { test_sources += [ "TestMdns.cpp" ] } From cf7aa2df3d78def5b8a4e37709d58828c0d28f67 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Mon, 15 Mar 2021 09:40:44 -0700 Subject: [PATCH 17/39] Fix failing to make network commissioning on RP4 (#5358) --- docs/BUILDING.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/docs/BUILDING.md b/docs/BUILDING.md index f44a18f8e26efc..20fc97747009ba 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -86,6 +86,38 @@ sudo apt-get install pi-bluetooth You need to reboot your RPi after install `pi-bluetooth`. +By default, wpa_supplicant is not allowed to update (overwrite) configuration, +if you want chip app to be able to store the configuration changes permanently, +we need to make the following changes. + +1. Edit the dbus-fi.w1.wpa_supplicant1.service file to use configuration file + instead. + +``` +sudo nano /etc/systemd/system/dbus-fi.w1.wpa_supplicant1.service +``` + +Change the wpa_supplicant start parameters to: + +``` +ExecStart=/sbin/wpa_supplicant -u -s -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf +``` + +2. Add the wpa-supplicant configuration file + +``` +sudo nano /etc/wpa_supplicant/wpa_supplicant.conf +``` + +And add the following content to the file: + +``` +ctrl_interface=DIR=/run/wpa_supplicant +update_config=1 +``` + +Finally, reboot your RPi. + ### Build Preparation Before running any other build command, the `scripts/activate.sh` environment From d36c06df01d33cee4d124bfc836aa8ca65632201 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Tue, 16 Mar 2021 09:49:19 -0400 Subject: [PATCH 18/39] Rename persistent storage APIs to be more unique (#5366) * Rename OnValue/OnStatus to OnPersistentStorageValue and OnPersistentStorageStatus * Rename SetDelegfate to SetStorageDelegate * Add missed rename for storage delegate * Rename set/get/delete key with a sync/async prefix * Fix typo * Update one more name in the python contriller delegate --- .../chip-tool/config/PersistentStorage.cpp | 14 +++--- examples/chip-tool/config/PersistentStorage.h | 10 ++-- src/app/server/RendezvousServer.cpp | 2 +- src/app/server/Server.cpp | 12 ++--- src/controller/CHIPDeviceController.cpp | 18 +++---- src/controller/CHIPDeviceController.h | 4 +- .../java/AndroidDeviceControllerWrapper.cpp | 48 ++++++++++--------- .../java/AndroidDeviceControllerWrapper.h | 10 ++-- .../ChipDeviceController-StorageDelegate.cpp | 20 ++++---- .../ChipDeviceController-StorageDelegate.h | 10 ++-- .../python/chip/internal/CommissionerImpl.cpp | 22 ++++----- .../Framework/CHIP/CHIPDeviceController.mm | 4 +- .../CHIPPersistentStorageDelegateBridge.h | 10 ++-- .../CHIPPersistentStorageDelegateBridge.mm | 18 +++---- src/lib/core/CHIPPersistentStorageDelegate.h | 22 ++++----- src/transport/AdminPairingTable.cpp | 6 +-- src/transport/StorablePeerConnection.cpp | 6 +-- 17 files changed, 119 insertions(+), 117 deletions(-) diff --git a/examples/chip-tool/config/PersistentStorage.cpp b/examples/chip-tool/config/PersistentStorage.cpp index 1ae0466abeb879..2170fd3b254fcd 100644 --- a/examples/chip-tool/config/PersistentStorage.cpp +++ b/examples/chip-tool/config/PersistentStorage.cpp @@ -53,11 +53,11 @@ CHIP_ERROR PersistentStorage::Init() return err; } -void PersistentStorage::SetDelegate(PersistentStorageResultDelegate * delegate) {} +void PersistentStorage::SetStorageDelegate(PersistentStorageResultDelegate * delegate) {} -void PersistentStorage::GetKeyValue(const char * key) {} +void PersistentStorage::AsyncGetKeyValue(const char * key) {} -CHIP_ERROR PersistentStorage::GetKeyValue(const char * key, char * value, uint16_t & size) +CHIP_ERROR PersistentStorage::SyncGetKeyValue(const char * key, char * value, uint16_t & size) { CHIP_ERROR err = CHIP_NO_ERROR; std::string iniValue; @@ -79,7 +79,7 @@ CHIP_ERROR PersistentStorage::GetKeyValue(const char * key, char * value, uint16 return err; } -void PersistentStorage::SetKeyValue(const char * key, const char * value) +void PersistentStorage::AsyncSetKeyValue(const char * key, const char * value) { auto section = mConfig.sections[kDefaultSectionName]; section[key] = std::string(value); @@ -88,7 +88,7 @@ void PersistentStorage::SetKeyValue(const char * key, const char * value) CommitConfig(); } -void PersistentStorage::DeleteKeyValue(const char * key) +void PersistentStorage::AsyncDeleteKeyValue(const char * key) { auto section = mConfig.sections[kDefaultSectionName]; section.erase(key); @@ -126,7 +126,7 @@ uint16_t PersistentStorage::GetListenPort() char value[6]; uint16_t size = static_cast(sizeof(value)); - err = GetKeyValue(kPortKey, value, size); + err = SyncGetKeyValue(kPortKey, value, size); if (CHIP_NO_ERROR == err) { uint16_t tmpValue; @@ -148,7 +148,7 @@ LogCategory PersistentStorage::GetLoggingLevel() char value[9]; uint16_t size = static_cast(sizeof(value)); - err = GetKeyValue(kLoggingKey, value, size); + err = SyncGetKeyValue(kLoggingKey, value, size); if (CHIP_NO_ERROR == err) { if (strcasecmp(value, "none") == 0) diff --git a/examples/chip-tool/config/PersistentStorage.h b/examples/chip-tool/config/PersistentStorage.h index edef1cdf94678c..85fc73fc394885 100644 --- a/examples/chip-tool/config/PersistentStorage.h +++ b/examples/chip-tool/config/PersistentStorage.h @@ -28,11 +28,11 @@ class PersistentStorage : public chip::PersistentStorageDelegate CHIP_ERROR Init(); /////////// PersistentStorageDelegate Interface ///////// - void SetDelegate(chip::PersistentStorageResultDelegate * delegate) override; - void GetKeyValue(const char * key) override; - CHIP_ERROR GetKeyValue(const char * key, char * value, uint16_t & size) override; - void SetKeyValue(const char * key, const char * value) override; - void DeleteKeyValue(const char * key) override; + void SetStorageDelegate(chip::PersistentStorageResultDelegate * delegate) override; + void AsyncGetKeyValue(const char * key) override; + CHIP_ERROR SyncGetKeyValue(const char * key, char * value, uint16_t & size) override; + void AsyncSetKeyValue(const char * key, const char * value) override; + void AsyncDeleteKeyValue(const char * key) override; uint16_t GetListenPort(); chip::Logging::LogCategory GetLoggingLevel(); diff --git a/src/app/server/RendezvousServer.cpp b/src/app/server/RendezvousServer.cpp index f8b8ff991d14f2..2e7fd5aa761a1c 100644 --- a/src/app/server/RendezvousServer.cpp +++ b/src/app/server/RendezvousServer.cpp @@ -74,7 +74,7 @@ void RendezvousServer::OnRendezvousComplete() ChipLogError(AppServer, "Failed to store the connection state")); uint16_t nextKeyId = mRendezvousSession.GetNextKeyId(); - mStorage->SetKeyValue(kStorablePeerConnectionCountKey, &nextKeyId, sizeof(nextKeyId)); + mStorage->SyncSetKeyValue(kStorablePeerConnectionCountKey, &nextKeyId, sizeof(nextKeyId)); } void RendezvousServer::OnRendezvousStatusUpdate(Status status, CHIP_ERROR err) diff --git a/src/app/server/Server.cpp b/src/app/server/Server.cpp index fa10c5446d3a2f..b34bd6068a7e64 100644 --- a/src/app/server/Server.cpp +++ b/src/app/server/Server.cpp @@ -72,35 +72,35 @@ constexpr bool useTestPairing() class ServerStorageDelegate : public PersistentStorageDelegate { - void SetDelegate(PersistentStorageResultDelegate * delegate) override + void SetStorageDelegate(PersistentStorageResultDelegate * delegate) override { ChipLogError(AppServer, "ServerStorageDelegate does not support async operations"); chipDie(); } - void GetKeyValue(const char * key) override + void AsyncGetKeyValue(const char * key) override { ChipLogError(AppServer, "ServerStorageDelegate does not support async operations"); chipDie(); } - void SetKeyValue(const char * key, const char * value) override + void AsyncSetKeyValue(const char * key, const char * value) override { ChipLogError(AppServer, "ServerStorageDelegate does not support async operations"); chipDie(); } - CHIP_ERROR GetKeyValue(const char * key, void * buffer, uint16_t & size) override + CHIP_ERROR SyncGetKeyValue(const char * key, void * buffer, uint16_t & size) override { return PersistedStorage::KeyValueStoreMgr().Get(key, buffer, size); } - CHIP_ERROR SetKeyValue(const char * key, const void * value, uint16_t size) override + CHIP_ERROR SyncSetKeyValue(const char * key, const void * value, uint16_t size) override { return PersistedStorage::KeyValueStoreMgr().Put(key, value, size); } - void DeleteKeyValue(const char * key) override { PersistedStorage::KeyValueStoreMgr().Delete(key); } + void AsyncDeleteKeyValue(const char * key) override { PersistedStorage::KeyValueStoreMgr().Delete(key); } }; ServerStorageDelegate gServerStorage; diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index d9117daf281cc3..92b954f4346128 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -126,7 +126,7 @@ CHIP_ERROR DeviceController::Init(NodeId localDeviceId, PersistentStorageDelegat if (mStorageDelegate != nullptr) { - mStorageDelegate->SetDelegate(this); + mStorageDelegate->SetStorageDelegate(this); } mTransportMgr = chip::Platform::New(); @@ -193,7 +193,7 @@ CHIP_ERROR DeviceController::Shutdown() if (mStorageDelegate != nullptr) { - mStorageDelegate->SetDelegate(nullptr); + mStorageDelegate->SetStorageDelegate(nullptr); mStorageDelegate = nullptr; } @@ -287,7 +287,7 @@ CHIP_ERROR DeviceController::GetDevice(NodeId deviceId, Device ** out_device) VerifyOrExit(buffer != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT); PERSISTENT_KEY_OP(static_cast(0), kPairedDeviceListKeyPrefix, key, - err = mStorageDelegate->GetKeyValue(key, buffer, size)); + err = mStorageDelegate->SyncGetKeyValue(key, buffer, size)); SuccessOrExit(err); VerifyOrExit(size <= max_size, err = CHIP_ERROR_INVALID_DEVICE_DESCRIPTOR); @@ -306,7 +306,7 @@ CHIP_ERROR DeviceController::GetDevice(NodeId deviceId, Device ** out_device) uint16_t size = sizeof(deviceInfo.inner); PERSISTENT_KEY_OP(deviceId, kPairedDeviceKeyPrefix, key, - err = mStorageDelegate->GetKeyValue(key, Uint8::to_char(deviceInfo.inner), size)); + err = mStorageDelegate->SyncGetKeyValue(key, Uint8::to_char(deviceInfo.inner), size)); SuccessOrExit(err); VerifyOrExit(size <= sizeof(deviceInfo.inner), err = CHIP_ERROR_INVALID_DEVICE_DESCRIPTOR); @@ -485,9 +485,9 @@ CHIP_ERROR DeviceController::SetPairedDeviceList(const char * serialized) return err; } -void DeviceController::OnValue(const char * key, const char * value) {} +void DeviceController::OnPersistentStorageValue(const char * key, const char * value) {} -void DeviceController::OnStatus(const char * key, Operation op, CHIP_ERROR err) {} +void DeviceController::OnPersistentStorageStatus(const char * key, Operation op, CHIP_ERROR err) {} DeviceCommissioner::DeviceCommissioner() { @@ -671,7 +671,7 @@ CHIP_ERROR DeviceCommissioner::UnpairDevice(NodeId remoteDeviceId) if (mStorageDelegate != nullptr) { - PERSISTENT_KEY_OP(remoteDeviceId, kPairedDeviceKeyPrefix, key, mStorageDelegate->DeleteKeyValue(key)); + PERSISTENT_KEY_OP(remoteDeviceId, kPairedDeviceKeyPrefix, key, mStorageDelegate->AsyncDeleteKeyValue(key)); } mPairedDevices.Remove(remoteDeviceId); @@ -733,7 +733,7 @@ void DeviceCommissioner::OnRendezvousComplete() SerializedDevice serialized; device->Serialize(serialized); PERSISTENT_KEY_OP(device->GetDeviceId(), kPairedDeviceKeyPrefix, key, - mStorageDelegate->SetKeyValue(key, Uint8::to_const_char(serialized.inner))); + mStorageDelegate->AsyncSetKeyValue(key, Uint8::to_const_char(serialized.inner))); } RendezvousCleanup(CHIP_NO_ERROR); @@ -796,7 +796,7 @@ void DeviceCommissioner::PersistDeviceList() if (value != nullptr && requiredSize <= size) { PERSISTENT_KEY_OP(static_cast(0), kPairedDeviceListKeyPrefix, key, - mStorageDelegate->SetKeyValue(key, value)); + mStorageDelegate->AsyncSetKeyValue(key, value)); mPairedDevicesUpdated = false; } chip::Platform::MemoryFree(serialized); diff --git a/src/controller/CHIPDeviceController.h b/src/controller/CHIPDeviceController.h index 1e9c75c2cf514f..98cf13955eda79 100644 --- a/src/controller/CHIPDeviceController.h +++ b/src/controller/CHIPDeviceController.h @@ -213,8 +213,8 @@ class DLL_EXPORT DeviceController : public SecureSessionMgrDelegate, public Pers void OnConnectionExpired(SecureSessionHandle session, SecureSessionMgr * mgr) override; //////////// PersistentStorageResultDelegate Implementation /////////////// - void OnValue(const char * key, const char * value) override; - void OnStatus(const char * key, Operation op, CHIP_ERROR err) override; + void OnPersistentStorageValue(const char * key, const char * value) override; + void OnPersistentStorageStatus(const char * key, Operation op, CHIP_ERROR err) override; void ReleaseAllDevices(); diff --git a/src/controller/java/AndroidDeviceControllerWrapper.cpp b/src/controller/java/AndroidDeviceControllerWrapper.cpp index 0ea3b104066286..e9b2d26440a3b0 100644 --- a/src/controller/java/AndroidDeviceControllerWrapper.cpp +++ b/src/controller/java/AndroidDeviceControllerWrapper.cpp @@ -284,19 +284,19 @@ void AndroidDeviceControllerWrapper::OnMessage(chip::System::PacketBufferHandle void AndroidDeviceControllerWrapper::OnStatusChange(void) {} -void AndroidDeviceControllerWrapper::SetDelegate(PersistentStorageResultDelegate * delegate) +void AndroidDeviceControllerWrapper::SetStorageDelegate(PersistentStorageResultDelegate * delegate) { mStorageResultDelegate = delegate; } -void AndroidDeviceControllerWrapper::GetKeyValue(const char * key) +void AndroidDeviceControllerWrapper::AsyncGetKeyValue(const char * key) { - jstring keyString = NULL; - jstring valueString = NULL; - const char * valueChars = nullptr; - CHIP_ERROR err = CHIP_NO_ERROR; - jclass storageCls = GetPersistentStorageClass(); - jmethodID method = GetJavaEnv()->GetStaticMethodID(storageCls, "getKeyValue", "(Ljava/lang/String;)Ljava/lang/String;"); + jstring keyString = NULL; + jstring valueString = NULL; + const char * valueChars = nullptr; + CHIP_ERROR err = CHIP_NO_ERROR; + jclass storageCls = GetPersistentStorageClass(); + jmethodID method = GetJavaEnv()->GetStaticMethodID(storageCls, "getKeyValue", "(Ljava/lang/String;)Ljava/lang/String;"); GetJavaEnv()->ExceptionClear(); @@ -308,26 +308,27 @@ void AndroidDeviceControllerWrapper::GetKeyValue(const char * key) if (mStorageResultDelegate) { valueChars = GetJavaEnv()->GetStringUTFChars(valueString, 0); - mStorageResultDelegate->OnValue(key, valueChars); + mStorageResultDelegate->OnPersistentStorageValue(key, valueChars); } exit: GetJavaEnv()->ExceptionClear(); - if (valueChars != nullptr) { + if (valueChars != nullptr) + { GetJavaEnv()->ReleaseStringUTFChars(valueString, valueChars); } GetJavaEnv()->DeleteLocalRef(keyString); GetJavaEnv()->DeleteLocalRef(valueString); } -CHIP_ERROR AndroidDeviceControllerWrapper::GetKeyValue(const char * key, char * value, uint16_t & size) +CHIP_ERROR AndroidDeviceControllerWrapper::SyncGetKeyValue(const char * key, char * value, uint16_t & size) { - jstring keyString = NULL; - jstring valueString = NULL; - const char * valueChars = nullptr; - CHIP_ERROR err = CHIP_NO_ERROR; - jclass storageCls = GetPersistentStorageClass(); - jmethodID method = GetJavaEnv()->GetStaticMethodID(storageCls, "getKeyValue", "(Ljava/lang/String;)Ljava/lang/String;"); + jstring keyString = NULL; + jstring valueString = NULL; + const char * valueChars = nullptr; + CHIP_ERROR err = CHIP_NO_ERROR; + jclass storageCls = GetPersistentStorageClass(); + jmethodID method = GetJavaEnv()->GetStaticMethodID(storageCls, "getKeyValue", "(Ljava/lang/String;)Ljava/lang/String;"); GetJavaEnv()->ExceptionClear(); @@ -341,7 +342,7 @@ CHIP_ERROR AndroidDeviceControllerWrapper::GetKeyValue(const char * key, char * if (value != nullptr) { valueChars = GetJavaEnv()->GetStringUTFChars(valueString, 0); - size = strlcpy(value, GetJavaEnv()->GetStringUTFChars(valueString, 0), size); + size = strlcpy(value, GetJavaEnv()->GetStringUTFChars(valueString, 0), size); } else { @@ -357,7 +358,8 @@ CHIP_ERROR AndroidDeviceControllerWrapper::GetKeyValue(const char * key, char * exit: GetJavaEnv()->ExceptionClear(); - if (valueChars != nullptr) { + if (valueChars != nullptr) + { GetJavaEnv()->ReleaseStringUTFChars(valueString, valueChars); } GetJavaEnv()->DeleteLocalRef(keyString); @@ -365,7 +367,7 @@ CHIP_ERROR AndroidDeviceControllerWrapper::GetKeyValue(const char * key, char * return err; } -void AndroidDeviceControllerWrapper::SetKeyValue(const char * key, const char * value) +void AndroidDeviceControllerWrapper::AsyncSetKeyValue(const char * key, const char * value) { jclass storageCls = GetPersistentStorageClass(); jmethodID method = GetJavaEnv()->GetStaticMethodID(storageCls, "setKeyValue", "(Ljava/lang/String;Ljava/lang/String;)V"); @@ -385,7 +387,7 @@ void AndroidDeviceControllerWrapper::SetKeyValue(const char * key, const char * if (mStorageResultDelegate) { - mStorageResultDelegate->OnStatus(key, PersistentStorageResultDelegate::Operation::kSET, CHIP_NO_ERROR); + mStorageResultDelegate->OnPersistentStorageStatus(key, PersistentStorageResultDelegate::Operation::kSET, CHIP_NO_ERROR); } exit: @@ -394,7 +396,7 @@ void AndroidDeviceControllerWrapper::SetKeyValue(const char * key, const char * GetJavaEnv()->DeleteLocalRef(valueString); } -void AndroidDeviceControllerWrapper::DeleteKeyValue(const char * key) +void AndroidDeviceControllerWrapper::AsyncDeleteKeyValue(const char * key) { jclass storageCls = GetPersistentStorageClass(); jmethodID method = GetJavaEnv()->GetStaticMethodID(storageCls, "deleteKeyValue", "(Ljava/lang/String;)V"); @@ -411,7 +413,7 @@ void AndroidDeviceControllerWrapper::DeleteKeyValue(const char * key) if (mStorageResultDelegate) { - mStorageResultDelegate->OnStatus(key, PersistentStorageResultDelegate::Operation::kDELETE, CHIP_NO_ERROR); + mStorageResultDelegate->OnPersistentStorageStatus(key, PersistentStorageResultDelegate::Operation::kDELETE, CHIP_NO_ERROR); } exit: diff --git a/src/controller/java/AndroidDeviceControllerWrapper.h b/src/controller/java/AndroidDeviceControllerWrapper.h index 5d5b2a12416825..7f8f7ffd0fa235 100644 --- a/src/controller/java/AndroidDeviceControllerWrapper.h +++ b/src/controller/java/AndroidDeviceControllerWrapper.h @@ -56,11 +56,11 @@ class AndroidDeviceControllerWrapper : public chip::Controller::DevicePairingDel void OnStatusChange(void) override; // PersistentStorageDelegate implementation - void SetDelegate(chip::PersistentStorageResultDelegate * delegate) override; - void GetKeyValue(const char * key) override; - CHIP_ERROR GetKeyValue(const char * key, char * value, uint16_t & size) override; - void SetKeyValue(const char * key, const char * value) override; - void DeleteKeyValue(const char * key) override; + void SetStorageDelegate(chip::PersistentStorageResultDelegate * delegate) override; + void AsyncGetKeyValue(const char * key) override; + CHIP_ERROR SyncGetKeyValue(const char * key, char * value, uint16_t & size) override; + void AsyncSetKeyValue(const char * key, const char * value) override; + void AsyncDeleteKeyValue(const char * key) override; jlong ToJNIHandle() { diff --git a/src/controller/python/ChipDeviceController-StorageDelegate.cpp b/src/controller/python/ChipDeviceController-StorageDelegate.cpp index d71d199c2f99fe..9873263a775c68 100644 --- a/src/controller/python/ChipDeviceController-StorageDelegate.cpp +++ b/src/controller/python/ChipDeviceController-StorageDelegate.cpp @@ -29,24 +29,24 @@ namespace chip { namespace Controller { -void PythonPersistentStorageDelegate::SetDelegate(PersistentStorageResultDelegate * delegate) +void PythonPersistentStorageDelegate::SetStorageDelegate(PersistentStorageResultDelegate * delegate) { mDelegate = delegate; } -void PythonPersistentStorageDelegate::GetKeyValue(const char * key) +void PythonPersistentStorageDelegate::AsyncGetKeyValue(const char * key) { auto val = mStorage.find(key); if (val == mStorage.end()) { - mDelegate->OnStatus(key, PersistentStorageResultDelegate::Operation::kGET, CHIP_ERROR_KEY_NOT_FOUND); + mDelegate->OnPersistentStorageStatus(key, PersistentStorageResultDelegate::Operation::kGET, CHIP_ERROR_KEY_NOT_FOUND); return; } - mDelegate->OnValue(key, val->second.c_str()); + mDelegate->OnPersistentStorageValue(key, val->second.c_str()); } -CHIP_ERROR PythonPersistentStorageDelegate::GetKeyValue(const char * key, char * value, uint16_t & size) +CHIP_ERROR PythonPersistentStorageDelegate::SyncGetKeyValue(const char * key, char * value, uint16_t & size) { auto val = mStorage.find(key); if (val == mStorage.end()) @@ -79,17 +79,17 @@ CHIP_ERROR PythonPersistentStorageDelegate::GetKeyValue(const char * key, char * return CHIP_NO_ERROR; } -void PythonPersistentStorageDelegate::SetKeyValue(const char * key, const char * value) +void PythonPersistentStorageDelegate::AsyncSetKeyValue(const char * key, const char * value) { mStorage[key] = value; - ChipLogDetail(Controller, "SetKeyValue: %s=%s", key, value); - mDelegate->OnStatus(key, PersistentStorageResultDelegate::Operation::kSET, CHIP_NO_ERROR); + ChipLogDetail(Controller, "AsyncSetKeyValue: %s=%s", key, value); + mDelegate->OnPersistentStorageStatus(key, PersistentStorageResultDelegate::Operation::kSET, CHIP_NO_ERROR); } -void PythonPersistentStorageDelegate::DeleteKeyValue(const char * key) +void PythonPersistentStorageDelegate::AsyncDeleteKeyValue(const char * key) { mStorage.erase(key); - mDelegate->OnStatus(key, PersistentStorageResultDelegate::Operation::kDELETE, CHIP_NO_ERROR); + mDelegate->OnPersistentStorageStatus(key, PersistentStorageResultDelegate::Operation::kDELETE, CHIP_NO_ERROR); } } // namespace Controller diff --git a/src/controller/python/ChipDeviceController-StorageDelegate.h b/src/controller/python/ChipDeviceController-StorageDelegate.h index ee4a5a0165f4f4..9a1da8aadd39e3 100644 --- a/src/controller/python/ChipDeviceController-StorageDelegate.h +++ b/src/controller/python/ChipDeviceController-StorageDelegate.h @@ -36,11 +36,11 @@ class PythonPersistentStorageDelegate : public PersistentStorageDelegate { public: PythonPersistentStorageDelegate() {} - void SetDelegate(PersistentStorageResultDelegate * delegate) override; - void GetKeyValue(const char * key) override; - CHIP_ERROR GetKeyValue(const char * key, char * value, uint16_t & size) override; - void SetKeyValue(const char * key, const char * value) override; - void DeleteKeyValue(const char * key) override; + void SetStorageDelegate(PersistentStorageResultDelegate * delegate) override; + void AsyncGetKeyValue(const char * key) override; + CHIP_ERROR SyncGetKeyValue(const char * key, char * value, uint16_t & size) override; + void AsyncSetKeyValue(const char * key, const char * value) override; + void AsyncDeleteKeyValue(const char * key) override; private: PersistentStorageResultDelegate * mDelegate; diff --git a/src/controller/python/chip/internal/CommissionerImpl.cpp b/src/controller/python/chip/internal/CommissionerImpl.cpp index e03594b6b816d6..071ab7e43b0c0b 100644 --- a/src/controller/python/chip/internal/CommissionerImpl.cpp +++ b/src/controller/python/chip/internal/CommissionerImpl.cpp @@ -28,51 +28,51 @@ namespace { class ServerStorageDelegate : public chip::PersistentStorageDelegate { public: - void SetDelegate(chip::PersistentStorageResultDelegate * delegate) override { mAsyncDelegate = delegate; } + void SetStorageDelegate(chip::PersistentStorageResultDelegate * delegate) override { mAsyncDelegate = delegate; } - void GetKeyValue(const char * key) override + void AsyncGetKeyValue(const char * key) override { // TODO: Async Get/Set are implemented synchronously here. // We need to figure out a standard way to implement this - this implementation // was based on an example that just returned and that seemed even less useful. uint8_t buffer[kMaxKeyValueSize]; uint16_t bufferSize = sizeof(buffer) - 1; - CHIP_ERROR err = GetKeyValue(key, buffer, bufferSize); + CHIP_ERROR err = SyncGetKeyValue(key, buffer, bufferSize); if (err == CHIP_NO_ERROR) { buffer[bufferSize] = 0; - mAsyncDelegate->OnValue(key, reinterpret_cast(buffer)); + mAsyncDelegate->OnPersistentStorageValue(key, reinterpret_cast(buffer)); } else { - mAsyncDelegate->OnStatus(key, chip::PersistentStorageResultDelegate::Operation::kGET, err); + mAsyncDelegate->OnPersistentStorageStatus(key, chip::PersistentStorageResultDelegate::Operation::kGET, err); } } - void SetKeyValue(const char * key, const char * value) override + void AsyncSetKeyValue(const char * key, const char * value) override { - CHIP_ERROR err = SetKeyValue(key, value, strlen(value)); + CHIP_ERROR err = SyncSetKeyValue(key, value, strlen(value)); if (err != CHIP_NO_ERROR) { - mAsyncDelegate->OnStatus(key, chip::PersistentStorageResultDelegate::Operation::kSET, err); + mAsyncDelegate->OnPersistentStorageStatus(key, chip::PersistentStorageResultDelegate::Operation::kSET, err); } } CHIP_ERROR - GetKeyValue(const char * key, void * buffer, uint16_t & size) override + SyncGetKeyValue(const char * key, void * buffer, uint16_t & size) override { return chip::DeviceLayer::PersistedStorage::KeyValueStoreMgr().Get(key, buffer, size); } - CHIP_ERROR SetKeyValue(const char * key, const void * value, uint16_t size) override + CHIP_ERROR SyncSetKeyValue(const char * key, const void * value, uint16_t size) override { return chip::DeviceLayer::PersistedStorage::KeyValueStoreMgr().Put(key, value, size); } - void DeleteKeyValue(const char * key) override { chip::DeviceLayer::PersistedStorage::KeyValueStoreMgr().Delete(key); } + void AsyncDeleteKeyValue(const char * key) override { chip::DeviceLayer::PersistedStorage::KeyValueStoreMgr().Delete(key); } private: static constexpr size_t kMaxKeyValueSize = 1024; diff --git a/src/darwin/Framework/CHIP/CHIPDeviceController.mm b/src/darwin/Framework/CHIP/CHIPDeviceController.mm index 35132172d03404..469d7b41064686 100644 --- a/src/darwin/Framework/CHIP/CHIPDeviceController.mm +++ b/src/darwin/Framework/CHIP/CHIPDeviceController.mm @@ -167,11 +167,11 @@ - (NSNumber *)_getControllerNodeId uint16_t idStringLen = 32; char deviceIdString[idStringLen]; if (CHIP_NO_ERROR - != _persistentStorageDelegateBridge->GetKeyValue(CHIP_COMMISSIONER_DEVICE_ID_KEY, deviceIdString, idStringLen)) { + != _persistentStorageDelegateBridge->SyncGetKeyValue(CHIP_COMMISSIONER_DEVICE_ID_KEY, deviceIdString, idStringLen)) { _localDeviceId = arc4random(); _localDeviceId = _localDeviceId << 32 | arc4random(); CHIP_LOG_ERROR("Assigned %llx node ID to the controller", _localDeviceId); - _persistentStorageDelegateBridge->SetKeyValue( + _persistentStorageDelegateBridge->AsyncSetKeyValue( CHIP_COMMISSIONER_DEVICE_ID_KEY, [[NSString stringWithFormat:@"%llx", _localDeviceId] UTF8String]); } else { NSScanner * scanner = [NSScanner scannerWithString:[NSString stringWithUTF8String:deviceIdString]]; diff --git a/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.h b/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.h index 58941447e1487c..144ff0a80ae4c6 100644 --- a/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.h +++ b/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.h @@ -30,15 +30,15 @@ class CHIPPersistentStorageDelegateBridge : public chip::PersistentStorageDelega void setFrameworkDelegate(id delegate, dispatch_queue_t queue); - void SetDelegate(chip::PersistentStorageResultDelegate * delegate) override; + void SetStorageDelegate(chip::PersistentStorageResultDelegate * delegate) override; - void GetKeyValue(const char * key) override; + void AsyncGetKeyValue(const char * key) override; - CHIP_ERROR GetKeyValue(const char * key, char * value, uint16_t & size) override; + CHIP_ERROR SyncGetKeyValue(const char * key, char * value, uint16_t & size) override; - void SetKeyValue(const char * key, const char * value) override; + void AsyncSetKeyValue(const char * key, const char * value) override; - void DeleteKeyValue(const char * key) override; + void AsyncDeleteKeyValue(const char * key) override; private: id mDelegate; diff --git a/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.mm b/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.mm index dcbe4a3298b7f5..0222ef3fd42b03 100644 --- a/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.mm +++ b/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.mm @@ -39,7 +39,7 @@ }); } -void CHIPPersistentStorageDelegateBridge::SetDelegate(chip::PersistentStorageResultDelegate * delegate) +void CHIPPersistentStorageDelegateBridge::SetStorageDelegate(chip::PersistentStorageResultDelegate * delegate) { dispatch_async(mWorkQueue, ^{ if (delegate) { @@ -49,7 +49,7 @@ chip::PersistentStorageResultDelegate * callback = mCallback; if (callback) { dispatch_async(mWorkQueue, ^{ - callback->OnValue([key UTF8String], [value UTF8String]); + callback->OnPeristentStorageValue([key UTF8String], [value UTF8String]); }); } }; @@ -58,7 +58,7 @@ chip::PersistentStorageResultDelegate * callback = mCallback; if (callback) { dispatch_async(mWorkQueue, ^{ - callback->OnStatus([key UTF8String], chip::PersistentStorageResultDelegate::Operation::kSET, + callback->OnPeristentStorageStatus([key UTF8String], chip::PersistentStorageResultDelegate::Operation::kSET, [CHIPError errorToCHIPErrorCode:status]); }); } @@ -68,8 +68,8 @@ chip::PersistentStorageResultDelegate * callback = mCallback; if (callback) { dispatch_async(mWorkQueue, ^{ - callback->OnStatus([key UTF8String], chip::PersistentStorageResultDelegate::Operation::kDELETE, - [CHIPError errorToCHIPErrorCode:status]); + callback->OnPeristentStorageStatus([key UTF8String], + chip::PersistentStorageResultDelegate::Operation::kDELETE, [CHIPError errorToCHIPErrorCode:status]); }); } }; @@ -82,7 +82,7 @@ }); } -void CHIPPersistentStorageDelegateBridge::GetKeyValue(const char * key) +void CHIPPersistentStorageDelegateBridge::AsyncGetKeyValue(const char * key) { NSString * keyString = [NSString stringWithUTF8String:key]; dispatch_async(mWorkQueue, ^{ @@ -103,7 +103,7 @@ }); } -CHIP_ERROR CHIPPersistentStorageDelegateBridge::GetKeyValue(const char * key, char * value, uint16_t & size) +CHIP_ERROR CHIPPersistentStorageDelegateBridge::SyncGetKeyValue(const char * key, char * value, uint16_t & size) { __block CHIP_ERROR error = CHIP_NO_ERROR; NSString * keyString = [NSString stringWithUTF8String:key]; @@ -138,7 +138,7 @@ return error; } -void CHIPPersistentStorageDelegateBridge::SetKeyValue(const char * key, const char * value) +void CHIPPersistentStorageDelegateBridge::AsyncSetKeyValue(const char * key, const char * value) { NSString * keyString = [NSString stringWithUTF8String:key]; NSString * valueString = [NSString stringWithUTF8String:value]; @@ -159,7 +159,7 @@ }); } -void CHIPPersistentStorageDelegateBridge::DeleteKeyValue(const char * key) +void CHIPPersistentStorageDelegateBridge::AsyncDeleteKeyValue(const char * key) { NSString * keyString = [NSString stringWithUTF8String:key]; dispatch_async(mWorkQueue, ^{ diff --git a/src/lib/core/CHIPPersistentStorageDelegate.h b/src/lib/core/CHIPPersistentStorageDelegate.h index 4e922acaaabe0f..f94b9f10cca6a5 100644 --- a/src/lib/core/CHIPPersistentStorageDelegate.h +++ b/src/lib/core/CHIPPersistentStorageDelegate.h @@ -38,12 +38,12 @@ class DLL_EXPORT PersistentStorageResultDelegate /** * @brief * Called when a value is returned from the storage. - * This is useful for GetKeyValue() API call. + * This is useful for AsyncGetKeyValue() API call. * * @param[in] key Key for which the value is being returned * @param[in] value Value or nullptr if not found. */ - virtual void OnValue(const char * key, const char * value) = 0; + virtual void OnPersistentStorageValue(const char * key, const char * value) = 0; /** * @brief @@ -53,7 +53,7 @@ class DLL_EXPORT PersistentStorageResultDelegate * @param[in] op Operation that was being performed on the key * @param[in] result CHIP_NO_ERROR or corresponding error code */ - virtual void OnStatus(const char * key, Operation op, CHIP_ERROR result) = 0; + virtual void OnPersistentStorageStatus(const char * key, Operation op, CHIP_ERROR result) = 0; }; class DLL_EXPORT PersistentStorageDelegate @@ -68,7 +68,7 @@ class DLL_EXPORT PersistentStorageDelegate * * @param[in] delegate The callback object */ - virtual void SetDelegate(PersistentStorageResultDelegate * delegate) = 0; + virtual void SetStorageDelegate(PersistentStorageResultDelegate * delegate) = 0; /** * @brief @@ -76,7 +76,7 @@ class DLL_EXPORT PersistentStorageDelegate * * @param[in] key Key to lookup */ - virtual void GetKeyValue(const char * key) = 0; + virtual void AsyncGetKeyValue(const char * key) = 0; /** * @brief @@ -95,7 +95,7 @@ class DLL_EXPORT PersistentStorageDelegate * The output size could be larger than input value. In * such cases, the user should allocate the buffer large * enough (>= output size), and call the API again. In this - * case GetKeyValue will place as many bytes as it can in + * case SyncGetKeyValue will place as many bytes as it can in * the buffer and return CHIP_ERROR_NO_MEMORY. * * If value is null, the input size is treated as 0. @@ -104,7 +104,7 @@ class DLL_EXPORT PersistentStorageDelegate * @return CHIP_ERROR_NO_MEMORY if the input buffer is not big enough for * the value. */ - virtual CHIP_ERROR GetKeyValue(const char * key, char * value, uint16_t & size) { return CHIP_ERROR_NOT_IMPLEMENTED; } + virtual CHIP_ERROR SyncGetKeyValue(const char * key, char * value, uint16_t & size) { return CHIP_ERROR_NOT_IMPLEMENTED; } /** * @brief @@ -121,7 +121,7 @@ class DLL_EXPORT PersistentStorageDelegate * such cases, the user should allocate the buffer large * enough (>= output length), and call the API again. */ - virtual CHIP_ERROR GetKeyValue(const char * key, void * buffer, uint16_t & size) { return CHIP_ERROR_NOT_IMPLEMENTED; } + virtual CHIP_ERROR SyncGetKeyValue(const char * key, void * buffer, uint16_t & size) { return CHIP_ERROR_NOT_IMPLEMENTED; } /** * @brief @@ -130,7 +130,7 @@ class DLL_EXPORT PersistentStorageDelegate * @param[in] key Key to be set * @param[in] value Value to be set */ - virtual void SetKeyValue(const char * key, const char * value) = 0; + virtual void AsyncSetKeyValue(const char * key, const char * value) = 0; /** * @brief @@ -140,7 +140,7 @@ class DLL_EXPORT PersistentStorageDelegate * @param[in] value Value to be set * @param[in] size Size of the Value */ - virtual CHIP_ERROR SetKeyValue(const char * key, const void * value, uint16_t size) { return CHIP_ERROR_NOT_IMPLEMENTED; } + virtual CHIP_ERROR SyncSetKeyValue(const char * key, const void * value, uint16_t size) { return CHIP_ERROR_NOT_IMPLEMENTED; } /** * @brief @@ -148,7 +148,7 @@ class DLL_EXPORT PersistentStorageDelegate * * @param[in] key Key to be deleted */ - virtual void DeleteKeyValue(const char * key) = 0; + virtual void AsyncDeleteKeyValue(const char * key) = 0; }; } // namespace chip diff --git a/src/transport/AdminPairingTable.cpp b/src/transport/AdminPairingTable.cpp index 50fefd0afd640d..e3a7de9117f4bc 100644 --- a/src/transport/AdminPairingTable.cpp +++ b/src/transport/AdminPairingTable.cpp @@ -37,7 +37,7 @@ CHIP_ERROR AdminPairingInfo::StoreIntoKVS(PersistentStorageDelegate & kvs) info.mNodeId = Encoding::LittleEndian::HostSwap64(mNodeId); info.mAdmin = Encoding::LittleEndian::HostSwap16(mAdmin); - return kvs.SetKeyValue(key, &info, sizeof(info)); + return kvs.SyncSetKeyValue(key, &info, sizeof(info)); } CHIP_ERROR AdminPairingInfo::FetchFromKVS(PersistentStorageDelegate & kvs) @@ -48,7 +48,7 @@ CHIP_ERROR AdminPairingInfo::FetchFromKVS(PersistentStorageDelegate & kvs) StorableAdminPairingInfo info; uint16_t size = sizeof(info); - ReturnErrorOnFailure(kvs.GetKeyValue(key, &info, size)); + ReturnErrorOnFailure(kvs.SyncGetKeyValue(key, &info, size)); mNodeId = Encoding::LittleEndian::HostSwap64(info.mNodeId); AdminId id = Encoding::LittleEndian::HostSwap16(info.mAdmin); @@ -62,7 +62,7 @@ CHIP_ERROR AdminPairingInfo::DeleteFromKVS(PersistentStorageDelegate & kvs, Admi char key[KeySize()]; ReturnErrorOnFailure(GenerateKey(id, key, sizeof(key))); - kvs.DeleteKeyValue(key); + kvs.AsyncDeleteKeyValue(key); return CHIP_NO_ERROR; } diff --git a/src/transport/StorablePeerConnection.cpp b/src/transport/StorablePeerConnection.cpp index f5ba0a733d7f04..5d5feb8b83f78b 100644 --- a/src/transport/StorablePeerConnection.cpp +++ b/src/transport/StorablePeerConnection.cpp @@ -34,7 +34,7 @@ CHIP_ERROR StorablePeerConnection::StoreIntoKVS(PersistentStorageDelegate & kvs) char key[KeySize()]; ReturnErrorOnFailure(GenerateKey(mKeyId, key, sizeof(key))); - return kvs.SetKeyValue(key, &mSession, sizeof(mSession)); + return kvs.SyncSetKeyValue(key, &mSession, sizeof(mSession)); } CHIP_ERROR StorablePeerConnection::FetchFromKVS(PersistentStorageDelegate & kvs, uint16_t keyId) @@ -43,7 +43,7 @@ CHIP_ERROR StorablePeerConnection::FetchFromKVS(PersistentStorageDelegate & kvs, ReturnErrorOnFailure(GenerateKey(keyId, key, sizeof(key))); uint16_t size = sizeof(mSession); - return kvs.GetKeyValue(key, &mSession, size); + return kvs.SyncGetKeyValue(key, &mSession, size); } CHIP_ERROR StorablePeerConnection::DeleteFromKVS(PersistentStorageDelegate & kvs, uint16_t keyId) @@ -51,7 +51,7 @@ CHIP_ERROR StorablePeerConnection::DeleteFromKVS(PersistentStorageDelegate & kvs char key[KeySize()]; ReturnErrorOnFailure(GenerateKey(keyId, key, sizeof(key))); - kvs.DeleteKeyValue(key); + kvs.AsyncDeleteKeyValue(key); return CHIP_NO_ERROR; } From 83a834148efb015a0bf14027478cf24739235525 Mon Sep 17 00:00:00 2001 From: doru91 Date: Tue, 16 Mar 2021 15:49:52 +0200 Subject: [PATCH 19/39] [K32W] Add CI for NXP K32W (#5365) * [K32W] Add CI for NXP K32W Signed-off-by: Doru Gucea * [K32W] CI Tool: Clean up DOcker image Signed-off-by: Doru Gucea --- .../docker/images/chip-build-k32w/Dockerfile | 19 +++++++++++++++++++ .../docker/images/chip-build-k32w/build.sh | 1 + .../docker/images/chip-build-k32w/run.sh | 1 + .../docker/images/chip-build-k32w/version | 1 + 4 files changed, 22 insertions(+) create mode 100644 integrations/docker/images/chip-build-k32w/Dockerfile create mode 120000 integrations/docker/images/chip-build-k32w/build.sh create mode 120000 integrations/docker/images/chip-build-k32w/run.sh create mode 120000 integrations/docker/images/chip-build-k32w/version diff --git a/integrations/docker/images/chip-build-k32w/Dockerfile b/integrations/docker/images/chip-build-k32w/Dockerfile new file mode 100644 index 00000000000000..911bb4088dacc5 --- /dev/null +++ b/integrations/docker/images/chip-build-k32w/Dockerfile @@ -0,0 +1,19 @@ +ARG VERSION=latest +FROM connectedhomeip/chip-build:${VERSION} + +# Setup the K32W SDK +RUN set -x \ + && apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y wget unzip \ + && rm -rf /var/lib/apt/lists/ \ + && mkdir -p /opt/sdk \ + && cd /opt/sdk \ + && wget https://mcuxpresso.nxp.com/eclipse/sdk/2.6.2/plugins/com.nxp.mcuxpresso.sdk.sdk_2.x_k32w061dk6_2.6.2.201911251446.jar \ + && unzip com.nxp.mcuxpresso.sdk.sdk_2.x_k32w061dk6_2.6.2.201911251446.jar \ + && rm -rf com.nxp.mcuxpresso.sdk.sdk_2.x_k32w061dk6_2.6.2.201911251446.jar \ + && cd sdks \ + && unzip bea4b051e4c58da8d3bff93011a97d1d.zip \ + && rm -rf bea4b051e4c58da8d3bff93011a97d1d.zip \ + && : # last line + +ENV K32W061_SDK_ROOT=/opt/sdk/sdks diff --git a/integrations/docker/images/chip-build-k32w/build.sh b/integrations/docker/images/chip-build-k32w/build.sh new file mode 120000 index 00000000000000..fcb4d4ee75d531 --- /dev/null +++ b/integrations/docker/images/chip-build-k32w/build.sh @@ -0,0 +1 @@ +../../build.sh \ No newline at end of file diff --git a/integrations/docker/images/chip-build-k32w/run.sh b/integrations/docker/images/chip-build-k32w/run.sh new file mode 120000 index 00000000000000..ccbd3501b330d9 --- /dev/null +++ b/integrations/docker/images/chip-build-k32w/run.sh @@ -0,0 +1 @@ +../../run.sh \ No newline at end of file diff --git a/integrations/docker/images/chip-build-k32w/version b/integrations/docker/images/chip-build-k32w/version new file mode 120000 index 00000000000000..a4280acd348e7f --- /dev/null +++ b/integrations/docker/images/chip-build-k32w/version @@ -0,0 +1 @@ +../chip-build/version \ No newline at end of file From a0dd7afe5d8c52dee91e86435c8156a80170ad55 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Tue, 16 Mar 2021 06:50:31 -0700 Subject: [PATCH 20/39] Use SecureSessionHandle to indicate if the peer's group key message counter is not synchronized. (#5368) --- src/messaging/ExchangeMgr.cpp | 2 +- src/transport/SecureSessionMgr.cpp | 10 +++++++--- src/transport/SecureSessionMgr.h | 5 +++++ src/transport/raw/MessageHeader.h | 26 ++------------------------ 4 files changed, 15 insertions(+), 28 deletions(-) diff --git a/src/messaging/ExchangeMgr.cpp b/src/messaging/ExchangeMgr.cpp index ba544d1965c279..bec3eb946eeb8c 100644 --- a/src/messaging/ExchangeMgr.cpp +++ b/src/messaging/ExchangeMgr.cpp @@ -233,7 +233,7 @@ void ExchangeManager::OnMessageReceived(const PacketHeader & packetHeader, const UnsolicitedMessageHandler * matchingUMH = nullptr; bool sendAckAndCloseExchange = false; - if (!IsMsgCounterSyncMessage(payloadHeader) && packetHeader.IsPeerGroupMsgIdNotSynchronized()) + if (!IsMsgCounterSyncMessage(payloadHeader) && session.IsPeerGroupMsgIdNotSynchronized()) { Transport::PeerConnectionState * state = mSessionMgr->GetPeerConnectionState(session); VerifyOrReturn(state != nullptr); diff --git a/src/transport/SecureSessionMgr.cpp b/src/transport/SecureSessionMgr.cpp index 8c4cad670ba81e..74d92154a54f4b 100644 --- a/src/transport/SecureSessionMgr.cpp +++ b/src/transport/SecureSessionMgr.cpp @@ -327,6 +327,7 @@ void SecureSessionMgr::OnMessageReceived(const PacketHeader & packetHeader, cons PacketBufferHandle origMsg; PayloadHeader payloadHeader; + bool peerGroupMsgIdNotSynchronized = false; Transport::AdminPairingInfo * admin = nullptr; VerifyOrExit(!msg.IsNull(), ChipLogError(Inet, "Secure transport received NULL packet, discarding")); @@ -375,14 +376,17 @@ void SecureSessionMgr::OnMessageReceived(const PacketHeader & packetHeader, cons // For all group messages, Set flag if peer group key message counter is not synchronized. if (ChipKeyId::IsAppGroupKey(packetHeader.GetEncryptionKeyID())) { - const_cast(packetHeader).SetPeerGroupMsgIdNotSynchronized(true); + peerGroupMsgIdNotSynchronized = true; } } if (mCB != nullptr) { - mCB->OnMessageReceived(packetHeader, payloadHeader, { state->GetPeerNodeId(), state->GetPeerKeyID(), state->GetAdminId() }, - std::move(msg), this); + SecureSessionHandle session(state->GetPeerNodeId(), state->GetPeerKeyID(), state->GetAdminId()); + + session.SetPeerGroupMsgIdNotSynchronized(peerGroupMsgIdNotSynchronized); + + mCB->OnMessageReceived(packetHeader, payloadHeader, session, std::move(msg), this); } exit: diff --git a/src/transport/SecureSessionMgr.h b/src/transport/SecureSessionMgr.h index eeef685420e596..64d4e57d6c4eb0 100644 --- a/src/transport/SecureSessionMgr.h +++ b/src/transport/SecureSessionMgr.h @@ -57,6 +57,9 @@ class SecureSessionHandle Transport::AdminId GetAdminId() const { return mAdmin; } void SetAdminId(Transport::AdminId adminId) { mAdmin = adminId; } + bool IsPeerGroupMsgIdNotSynchronized() const { return mPeerGroupMsgIdNotSynchronized; } + void SetPeerGroupMsgIdNotSynchronized(bool value) { mPeerGroupMsgIdNotSynchronized = value; } + bool operator==(const SecureSessionHandle & that) const { return mPeerNodeId == that.mPeerNodeId && mPeerKeyId == that.mPeerKeyId && mAdmin == that.mAdmin; @@ -74,6 +77,8 @@ class SecureSessionHandle // to identify an approach that'll allow looking up the corresponding information for // such sessions. Transport::AdminId mAdmin; + + bool mPeerGroupMsgIdNotSynchronized = false; }; /** diff --git a/src/transport/raw/MessageHeader.h b/src/transport/raw/MessageHeader.h index dfe8d8cabdca18..f6d93a1d4618b6 100644 --- a/src/transport/raw/MessageHeader.h +++ b/src/transport/raw/MessageHeader.h @@ -73,12 +73,6 @@ enum class ExFlagValues : uint8_t kExchangeFlag_VendorIdPresent = 0x10, }; -enum class InternalFlagValues : uint8_t -{ - // Header flag indicates that the peer's group key message counter is not synchronized. - kPeerGroupMsgIdNotSynchronized = 0x01, -}; - enum class FlagValues : uint16_t { /// Header flag specifying that a destination node id is included in the header. @@ -95,9 +89,8 @@ enum class FlagValues : uint16_t }; -using Flags = BitFlags; -using ExFlags = BitFlags; -using InternalFlags = BitFlags; +using Flags = BitFlags; +using ExFlags = BitFlags; // Header is a 16-bit value of the form // | 4 bit | 4 bit |8 bit Security Flags| @@ -149,12 +142,6 @@ class PacketHeader /** Check if it's a secure session control message. */ bool IsSecureSessionControlMsg() const { return mFlags.Has(Header::FlagValues::kSecureSessionControlMessage); } - /** Check if the peer's group key message counter is not synchronized. */ - bool IsPeerGroupMsgIdNotSynchronized() const - { - return mInternalFlags.Has(Header::InternalFlagValues::kPeerGroupMsgIdNotSynchronized); - } - Header::EncryptionType GetEncryptionType() const { return mEncryptionType; } PacketHeader & SetSecureSessionControlMsg(bool value) @@ -163,12 +150,6 @@ class PacketHeader return *this; } - PacketHeader & SetPeerGroupMsgIdNotSynchronized(bool value) - { - mInternalFlags.Set(Header::InternalFlagValues::kPeerGroupMsgIdNotSynchronized, value); - return *this; - } - PacketHeader & SetSourceNodeId(NodeId id) { mSourceNodeId.SetValue(id); @@ -328,9 +309,6 @@ class PacketHeader /// Message flags read from the message. Header::Flags mFlags; - /// Message flags not encoded into the packet sent over wire. - Header::InternalFlags mInternalFlags; - /// Represents encryption type used for encrypting current packet Header::EncryptionType mEncryptionType = Header::EncryptionType::kAESCCMTagLen16; }; From 3c8e38ba4e518122b09fa34a78f63752d7b5beb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Kr=C3=B3lik?= <66667989+Damian-Nordic@users.noreply.github.com> Date: Tue, 16 Mar 2021 14:50:59 +0100 Subject: [PATCH 21/39] [bluez] Fix UnsubscribeCharacteristic (#5380) Fix a copy and paste error in UnsubscribeCharacteristic which would call ...start_notify() instead of stop_notify() Bluez function. As a result an application such as Python CHIP controller was unable to commission multiple devices in a single run. --- src/platform/Linux/bluez/Helper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/Linux/bluez/Helper.cpp b/src/platform/Linux/bluez/Helper.cpp index 0f452ec4a19a44..bb61299009ea08 100644 --- a/src/platform/Linux/bluez/Helper.cpp +++ b/src/platform/Linux/bluez/Helper.cpp @@ -1705,7 +1705,7 @@ static gboolean UnsubscribeCharacteristicImpl(BluezConnection * connection) VerifyOrExit(connection != nullptr, ChipLogError(DeviceLayer, "BluezConnection is NULL in %s", __func__)); VerifyOrExit(connection->mpC2 != nullptr, ChipLogError(DeviceLayer, "C2 is NULL in %s", __func__)); - bluez_gatt_characteristic1_call_start_notify(connection->mpC2, nullptr, UnsubscribeCharacteristicDone, connection); + bluez_gatt_characteristic1_call_stop_notify(connection->mpC2, nullptr, UnsubscribeCharacteristicDone, connection); exit: return G_SOURCE_REMOVE; From a079680d0c7b14a2aefb28c75839e2c3a0b26c12 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Tue, 16 Mar 2021 06:51:16 -0700 Subject: [PATCH 22/39] Clear any pending timer after SecureSessionMgr is shut down (#5361) --- src/transport/SecureSessionMgr.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/transport/SecureSessionMgr.cpp b/src/transport/SecureSessionMgr.cpp index 74d92154a54f4b..d8d749f9bd9d7a 100644 --- a/src/transport/SecureSessionMgr.cpp +++ b/src/transport/SecureSessionMgr.cpp @@ -87,6 +87,8 @@ CHIP_ERROR SecureSessionMgr::Init(NodeId localNodeId, System::Layer * systemLaye void SecureSessionMgr::Shutdown() { + CancelExpiryTimer(); + mState = State::kNotReady; mLocalNodeId = kUndefinedNodeId; mSystemLayer = nullptr; From c715269933b93843d58a4d6854245c4b4b2002e5 Mon Sep 17 00:00:00 2001 From: Kevin Schoedel <67607049+kpschoedel@users.noreply.github.com> Date: Tue, 16 Mar 2021 09:53:04 -0400 Subject: [PATCH 23/39] Support chained buffers in PacketBufferHandle::CloneData() (#5355) * Support chained buffers in PacketBufferHandle::CloneData() #### Problem It's sometimes useful to clone an entire packet buffer chain (e.g. #5309). (If cloning only a single buffer is necessary, `NewWithData(buffer->Start(), buffer->DataLength(), 0, buffer->ReservedSize())` will do the job.) #### Summary of Changes Support chained buffers in `PacketBufferHandle::CloneData()`. Fixes #5348 - Support CloneData with chained buffers in PacketBufferHandle * Restyled by clang-format * review fix Co-authored-by: Restyled.io --- src/system/SystemPacketBuffer.cpp | 30 +++++-- src/system/SystemPacketBuffer.h | 11 +-- src/system/tests/TestSystemPacketBuffer.cpp | 86 +++++++++++++++++++++ 3 files changed, 114 insertions(+), 13 deletions(-) diff --git a/src/system/SystemPacketBuffer.cpp b/src/system/SystemPacketBuffer.cpp index e02c3aa371bd4f..ab9a56d4e41cd4 100644 --- a/src/system/SystemPacketBuffer.cpp +++ b/src/system/SystemPacketBuffer.cpp @@ -605,14 +605,34 @@ PacketBufferHandle PacketBufferHandle::PopHead() return PacketBufferHandle(head); } -PacketBufferHandle PacketBufferHandle::CloneData(uint16_t aAdditionalSize, uint16_t aReservedSize) +PacketBufferHandle PacketBufferHandle::CloneData() { - if (!mBuffer->Next().IsNull()) + PacketBufferHandle cloneHead; + + for (PacketBuffer * original = mBuffer; original != nullptr; original = static_cast(original->next)) { - // We do not clone an entire chain. - return PacketBufferHandle(); + uint16_t originalDataSize = original->MaxDataLength(); + uint16_t originalReservedSize = original->ReservedSize(); + PacketBufferHandle clone = PacketBufferHandle::New(originalDataSize, originalReservedSize); + if (clone.IsNull()) + { + return PacketBufferHandle(); + } + clone.mBuffer->tot_len = clone.mBuffer->len = original->len; + memcpy(reinterpret_cast(clone.mBuffer) + PacketBuffer::kStructureSize, + reinterpret_cast(original) + PacketBuffer::kStructureSize, originalDataSize + originalReservedSize); + + if (cloneHead.IsNull()) + { + cloneHead = std::move(clone); + } + else + { + cloneHead->AddToEnd(std::move(clone)); + } } - return NewWithData(mBuffer->Start(), mBuffer->DataLength(), aAdditionalSize, aReservedSize); + + return cloneHead; } } // namespace System diff --git a/src/system/SystemPacketBuffer.h b/src/system/SystemPacketBuffer.h index 4847e11ef82da6..aec29136f4e48b 100644 --- a/src/system/SystemPacketBuffer.h +++ b/src/system/SystemPacketBuffer.h @@ -598,16 +598,11 @@ class DLL_EXPORT PacketBufferHandle uint16_t aReservedSize = PacketBuffer::kDefaultHeaderReserve); /** - * Creates a copy of the data in this packet. + * Creates a copy of a packet buffer (or chain). * - * Does NOT support chained buffers. - * - * @param[in] aAdditionalSize Size of additional application data space after the initial contents. - * @param[in] aReservedSize Number of octets to reserve for protocol headers. - * - * @returns empty handle on allocation failure. + * @returns empty handle on allocation failure. Otherwise, the returned buffer has the same sizes and contents as the original. */ - PacketBufferHandle CloneData(uint16_t aAdditionalSize = 0, uint16_t aReservedSize = PacketBuffer::kDefaultHeaderReserve); + PacketBufferHandle CloneData(); /** * Perform an implementation-defined check on the validity of a PacketBufferHandle. diff --git a/src/system/tests/TestSystemPacketBuffer.cpp b/src/system/tests/TestSystemPacketBuffer.cpp index 2dbe1ecbb804bb..cf39fd1060b57a 100644 --- a/src/system/tests/TestSystemPacketBuffer.cpp +++ b/src/system/tests/TestSystemPacketBuffer.cpp @@ -67,6 +67,14 @@ using ::chip::System::pbuf; #define TO_LWIP_PBUF(x) (reinterpret_cast(reinterpret_cast(x))) #define OF_LWIP_PBUF(x) (reinterpret_cast(reinterpret_cast(x))) +namespace { +void ScrambleData(uint8_t * start, uint16_t length) +{ + for (uint16_t i = 0; i < length; ++i) + ++start[i]; +} +} // namespace + /* * An instance of this class created for the test suite. * It is a friend class of `PacketBuffer` and `PacketBufferHandle` because some tests @@ -120,6 +128,7 @@ class PacketBufferTest static void CheckHandleHold(nlTestSuite * inSuite, void * inContext); static void CheckHandleAdvance(nlTestSuite * inSuite, void * inContext); static void CheckHandleRightSize(nlTestSuite * inSuite, void * inContext); + static void CheckHandleCloneData(nlTestSuite * inSuite, void * inContext); static void CheckPacketBufferWriter(nlTestSuite * inSuite, void * inContext); static void CheckBuildFreeList(nlTestSuite * inSuite, void * inContext); @@ -1707,6 +1716,82 @@ void PacketBufferTest::CheckHandleRightSize(nlTestSuite * inSuite, void * inCont #endif // CHIP_SYSTEM_PACKETBUFFER_HAS_RIGHT_SIZE } +void PacketBufferTest::CheckHandleCloneData(nlTestSuite * inSuite, void * inContext) +{ + struct TestContext * const theContext = static_cast(inContext); + PacketBufferTest * const test = theContext->test; + NL_TEST_ASSERT(inSuite, test->mContext == theContext); + + uint8_t lPayload[2 * PacketBuffer::kMaxSizeWithoutReserve]; + for (size_t i = 0; i < sizeof(lPayload); ++i) + { + lPayload[i] = static_cast(random()); + } + + for (auto & config_1 : test->configurations) + { + for (auto & config_2 : test->configurations) + { + if (&config_1 == &config_2) + { + continue; + } + + test->PrepareTestBuffer(&config_1); + test->PrepareTestBuffer(&config_2); + + const uint8_t * payload_1 = lPayload; + memcpy(config_1.handle->Start(), payload_1, config_1.handle->MaxDataLength()); + config_1.handle->SetDataLength(config_1.handle->MaxDataLength()); + + const uint8_t * payload_2 = lPayload + config_1.handle->MaxDataLength(); + memcpy(config_2.handle->Start(), payload_2, config_2.handle->MaxDataLength()); + config_2.handle->SetDataLength(config_2.handle->MaxDataLength()); + + // Clone single buffer. + PacketBufferHandle clone_1 = config_1.handle.CloneData(); + NL_TEST_ASSERT(inSuite, !clone_1.IsNull()); + NL_TEST_ASSERT(inSuite, clone_1->DataLength() == config_1.handle->DataLength()); + NL_TEST_ASSERT(inSuite, memcmp(clone_1->Start(), payload_1, clone_1->DataLength()) == 0); + if (clone_1->DataLength()) + { + // Verify that modifying the clone does not affect the original. + ScrambleData(clone_1->Start(), clone_1->DataLength()); + NL_TEST_ASSERT(inSuite, memcmp(clone_1->Start(), payload_1, clone_1->DataLength()) != 0); + NL_TEST_ASSERT(inSuite, memcmp(config_1.handle->Start(), payload_1, config_1.handle->DataLength()) == 0); + } + + // Clone buffer chain. + config_1.handle->AddToEnd(config_2.handle.Retain()); + NL_TEST_ASSERT(inSuite, config_1.handle->HasChainedBuffer()); + clone_1 = config_1.handle.CloneData(); + PacketBufferHandle clone_1_next = clone_1->Next(); + NL_TEST_ASSERT(inSuite, !clone_1.IsNull()); + NL_TEST_ASSERT(inSuite, clone_1->HasChainedBuffer()); + NL_TEST_ASSERT(inSuite, clone_1->DataLength() == config_1.handle->DataLength()); + NL_TEST_ASSERT(inSuite, clone_1->TotalLength() == config_1.handle->TotalLength()); + NL_TEST_ASSERT(inSuite, clone_1_next->DataLength() == config_2.handle->DataLength()); + NL_TEST_ASSERT(inSuite, memcmp(clone_1->Start(), payload_1, clone_1->DataLength()) == 0); + NL_TEST_ASSERT(inSuite, memcmp(clone_1_next->Start(), payload_2, clone_1_next->DataLength()) == 0); + if (clone_1->DataLength()) + { + ScrambleData(clone_1->Start(), clone_1->DataLength()); + NL_TEST_ASSERT(inSuite, memcmp(clone_1->Start(), payload_1, clone_1->DataLength()) != 0); + NL_TEST_ASSERT(inSuite, memcmp(config_1.handle->Start(), payload_1, config_1.handle->DataLength()) == 0); + } + if (clone_1_next->DataLength()) + { + ScrambleData(clone_1_next->Start(), clone_1_next->DataLength()); + NL_TEST_ASSERT(inSuite, memcmp(clone_1_next->Start(), payload_2, clone_1_next->DataLength()) != 0); + NL_TEST_ASSERT(inSuite, memcmp(config_2.handle->Start(), payload_2, config_2.handle->DataLength()) == 0); + } + + config_1.handle = nullptr; + config_2.handle = nullptr; + } + } +} + void PacketBufferTest::CheckPacketBufferWriter(nlTestSuite * inSuite, void * inContext) { struct TestContext * const theContext = static_cast(inContext); @@ -1773,6 +1858,7 @@ const nlTest sTests[] = NL_TEST_DEF("PacketBuffer::HandleHold", PacketBufferTest::CheckHandleHold), NL_TEST_DEF("PacketBuffer::HandleAdvance", PacketBufferTest::CheckHandleAdvance), NL_TEST_DEF("PacketBuffer::HandleRightSize", PacketBufferTest::CheckHandleRightSize), + NL_TEST_DEF("PacketBuffer::HandleCloneData", PacketBufferTest::CheckHandleCloneData), NL_TEST_DEF("PacketBuffer::PacketBufferWriter", PacketBufferTest::CheckPacketBufferWriter), NL_TEST_SENTINEL() From 43bb0012ad6154497358023073111410ec4099de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Kr=C3=B3lik?= <66667989+Damian-Nordic@users.noreply.github.com> Date: Tue, 16 Mar 2021 15:15:10 +0100 Subject: [PATCH 24/39] [controller] Remove deprecated controller interface (#5392) Now that all controller applications have been migrated to the new CHIP controller interface, the deprecated controller classes can be removed. --- .../Rendezvous/RendezvousSessionGeneral.dot | 6 +- .../dots/Rendezvous/RendezvousSessionInit.dot | 4 +- src/controller/BUILD.gn | 2 - .../CHIPDeviceController_deprecated.cpp | 245 ------------------ .../CHIPDeviceController_deprecated.h | 219 ---------------- src/controller/python/BUILD.gn | 5 - 6 files changed, 5 insertions(+), 476 deletions(-) delete mode 100644 src/controller/CHIPDeviceController_deprecated.cpp delete mode 100644 src/controller/CHIPDeviceController_deprecated.h diff --git a/docs/dots/Rendezvous/RendezvousSessionGeneral.dot b/docs/dots/Rendezvous/RendezvousSessionGeneral.dot index d3b11452904216..8578363c69a3d0 100644 --- a/docs/dots/Rendezvous/RendezvousSessionGeneral.dot +++ b/docs/dots/Rendezvous/RendezvousSessionGeneral.dot @@ -6,7 +6,7 @@ digraph RendezvousSession subgraph cluster_controller { label=<Controller> - ChipDeviceController [shape=record label=<{ChipDeviceController|RendezvousSessionDelegate}>, URL="@ref chip::DeviceController::ChipDeviceController"] + DeviceCommissioner [shape=record label=<{DeviceCommissioner|RendezvousSessionDelegate}>, URL="@ref chip::Controller::DeviceCommissioner"] } # This section represents device-only elements @@ -29,9 +29,9 @@ digraph RendezvousSession # Main relationships ############################# RendezvousParameters [shape=ellipse, URL="@ref chip::RendezvousParameters"] - RendezvousParameters -> { ChipDeviceController, RendezvousDeviceDelegate} [arrowhead=none] + RendezvousParameters -> { DeviceCommissioner, RendezvousDeviceDelegate} [arrowhead=none] - {ChipDeviceController, RendezvousDeviceDelegate} -> RendezvousSession + {DeviceCommissioner, RendezvousDeviceDelegate} -> RendezvousSession RendezvousSession -> TransportBle RendezvousSession -> TransportInet [style=dashed, color=gray] } diff --git a/docs/dots/Rendezvous/RendezvousSessionInit.dot b/docs/dots/Rendezvous/RendezvousSessionInit.dot index 0751ef5ea006d5..79983ce6e1aa1a 100644 --- a/docs/dots/Rendezvous/RendezvousSessionInit.dot +++ b/docs/dots/Rendezvous/RendezvousSessionInit.dot @@ -7,7 +7,7 @@ digraph RendezvousSession label=<Controller> node [fillcolor="white:gray", gradientangle=90] - ChipDeviceController [shape=record label=<{ChipDeviceController|RendezvousSessionDelegate}>, URL="@ref chip::DeviceController::ChipDeviceController"] + DeviceCommissioner [shape=record label=<{DeviceCommissioner|RendezvousSessionDelegate}>, URL="@ref chip::Controller::DeviceCommissioner"] } # This section represents device-only elements @@ -66,7 +66,7 @@ digraph RendezvousSession ############################# # Main relationships ############################# - {ChipDeviceController, RendezvousDeviceDelegate} -> RendezvousSession + {DeviceCommissioner, RendezvousDeviceDelegate} -> RendezvousSession RendezvousSession -> HasDiscriminator diff --git a/src/controller/BUILD.gn b/src/controller/BUILD.gn index 455cb2befe73bd..88a835ab848981 100644 --- a/src/controller/BUILD.gn +++ b/src/controller/BUILD.gn @@ -29,8 +29,6 @@ static_library("controller") { "CHIPDevice.h", "CHIPDeviceController.cpp", "CHIPDeviceController.h", - "CHIPDeviceController_deprecated.cpp", - "CHIPDeviceController_deprecated.h", "DeviceAddressUpdater.cpp", "DeviceAddressUpdater.h", ] diff --git a/src/controller/CHIPDeviceController_deprecated.cpp b/src/controller/CHIPDeviceController_deprecated.cpp deleted file mode 100644 index c1368d9575bf15..00000000000000 --- a/src/controller/CHIPDeviceController_deprecated.cpp +++ /dev/null @@ -1,245 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2013-2017 Nest Labs, Inc. - * 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. - */ - -/** - * @file - * Implementation of CHIP Device Controller, a common class - * that implements discovery, pairing and provisioning of CHIP - * devices. - * - */ - -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS -#endif -#ifndef __STDC_FORMAT_MACROS -#define __STDC_FORMAT_MACROS -#endif - -// module header, comes first -#include - -#if CONFIG_DEVICE_LAYER -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -using namespace chip::Inet; -using namespace chip::System; -using namespace chip::Controller; - -namespace chip { -namespace DeviceController { - -using namespace chip::Encoding; - -ChipDeviceController::ChipDeviceController() -{ - mState = kState_NotInitialized; - AppState = nullptr; - mCurReqMsg = nullptr; - mOnError = nullptr; - mOnNewConnection = nullptr; - mListenPort = CHIP_PORT; - mLocalDeviceId = kUndefinedNodeId; - mRemoteDeviceId = kUndefinedNodeId; - mDevice = nullptr; - mPairingWithoutSecurity = false; - CHIP_ZERO_AT(mOnComplete); -} - -ChipDeviceController::~ChipDeviceController() {} - -CHIP_ERROR ChipDeviceController::Init(NodeId localNodeId, DevicePairingDelegate * pairingDelegate, - PersistentStorageDelegate * storageDelegate) -{ - return mCommissioner.Init(localNodeId, storageDelegate, pairingDelegate); -} - -CHIP_ERROR ChipDeviceController::Init(NodeId localNodeId, System::Layer * systemLayer, InetLayer * inetLayer, - DevicePairingDelegate * pairingDelegate, PersistentStorageDelegate * storageDelegate) -{ - return mCommissioner.Init(localNodeId, storageDelegate, pairingDelegate, systemLayer, inetLayer); -} - -CHIP_ERROR ChipDeviceController::Shutdown() -{ - return mCommissioner.Shutdown(); -} - -CHIP_ERROR ChipDeviceController::ConnectDevice(NodeId remoteDeviceId, RendezvousParameters & params, void * appReqState, - NewConnectionHandler onConnected, MessageReceiveHandler onMessageReceived, - ErrorHandler onError) -{ - CHIP_ERROR err = mCommissioner.PairDevice(remoteDeviceId, params); - SuccessOrExit(err); - - mState = kState_Initialized; - mRemoteDeviceId = remoteDeviceId; - mAppReqState = appReqState; - mOnNewConnection = onConnected; - - mOnComplete.Response = onMessageReceived; - mOnError = onError; - - // TODO: Should call mOnNewConnected when rendezvous completed - mOnNewConnection(this, nullptr, mAppReqState); - -exit: - return err; -} - -CHIP_ERROR ChipDeviceController::ConnectDeviceWithoutSecurePairing(NodeId remoteDeviceId, const Transport::PeerAddress & deviceAddr, - void * appReqState, NewConnectionHandler onConnected, - MessageReceiveHandler onMessageReceived, ErrorHandler onError) -{ - CHIP_ERROR err = mCommissioner.PairTestDeviceWithoutSecurity(remoteDeviceId, deviceAddr, mSerializedTestDevice); - SuccessOrExit(err); - - mPairingWithoutSecurity = true; - - mState = kState_Initialized; - mRemoteDeviceId = remoteDeviceId; - mAppReqState = appReqState; - mOnNewConnection = onConnected; - - mOnComplete.Response = onMessageReceived; - mOnError = onError; - - if (mOnNewConnection) - { - mOnNewConnection(this, nullptr, mAppReqState); - } - -exit: - return err; -} - -CHIP_ERROR ChipDeviceController::SetUdpListenPort(uint16_t listenPort) -{ - if (mState != kState_Initialized) - return CHIP_ERROR_INCORRECT_STATE; - mListenPort = listenPort; - return CHIP_NO_ERROR; -} - -CHIP_ERROR ChipDeviceController::ServiceEvents() -{ - return mCommissioner.ServiceEvents(); -} - -CHIP_ERROR ChipDeviceController::ServiceEventSignal() -{ - return mCommissioner.ServiceEventSignal(); -} - -bool ChipDeviceController::IsConnected() const -{ - return mState == kState_Initialized; -} - -bool ChipDeviceController::GetIpAddress(Inet::IPAddress & addr) -{ - if (!IsConnected()) - return false; - - if (mDevice == nullptr) - InitDevice(); - - uint16_t port; - return mDevice != nullptr && mDevice->GetAddress(addr, port); -} - -CHIP_ERROR ChipDeviceController::DisconnectDevice() -{ - if (mDevice != nullptr) - { - mCommissioner.ReleaseDevice(mDevice); - mDevice = nullptr; - } - - return CHIP_NO_ERROR; -} - -CHIP_ERROR ChipDeviceController::SendMessage(void * appReqState, PacketBufferHandle buffer, NodeId peerDevice) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - - VerifyOrExit(!buffer.IsNull(), err = CHIP_ERROR_INVALID_ARGUMENT); - - mAppReqState = appReqState; - - if (peerDevice != kUndefinedNodeId) - { - mRemoteDeviceId = peerDevice; - } - VerifyOrExit(mRemoteDeviceId != kUndefinedNodeId, err = CHIP_ERROR_INCORRECT_STATE); - - if (mDevice == nullptr) - { - SuccessOrExit(InitDevice()); - } - - VerifyOrExit(mDevice != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT); - mDevice->SetDelegate(this); - - err = mDevice->SendMessage(std::move(buffer)); - -exit: - - return err; -} - -CHIP_ERROR ChipDeviceController::SetDevicePairingDelegate(DevicePairingDelegate * pairingDelegate) -{ - mCommissioner.SetDevicePairingDelegate(pairingDelegate); - return CHIP_NO_ERROR; -} - -void ChipDeviceController::OnMessage(System::PacketBufferHandle msgBuf) -{ - if (mOnComplete.Response != nullptr) - { - mOnComplete.Response(this, mAppReqState, std::move(msgBuf)); - } -} - -CHIP_ERROR ChipDeviceController::InitDevice() -{ - return mPairingWithoutSecurity ? mCommissioner.GetDevice(mRemoteDeviceId, mSerializedTestDevice, &mDevice) - : mCommissioner.GetDevice(mRemoteDeviceId, &mDevice); -} - -} // namespace DeviceController -} // namespace chip diff --git a/src/controller/CHIPDeviceController_deprecated.h b/src/controller/CHIPDeviceController_deprecated.h deleted file mode 100644 index 2542c4952fc072..00000000000000 --- a/src/controller/CHIPDeviceController_deprecated.h +++ /dev/null @@ -1,219 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2013-2017 Nest Labs, Inc. - * 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. - */ - -/** - * @file - * Declaration of CHIP Device Controller, a common class - * that implements connecting and messaging and will later - * be expanded to support discovery, pairing and - * provisioning of CHIP devices. - * - */ - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace chip { -namespace DeviceController { - -constexpr uint16_t kPacketCacheMaxSize = 16; - -class ChipDeviceController; - -typedef void (*NewConnectionHandler)(ChipDeviceController * deviceController, const Transport::PeerConnectionState * state, - void * appReqState); -typedef void (*CompleteHandler)(ChipDeviceController * deviceController, void * appReqState); -typedef void (*ErrorHandler)(ChipDeviceController * deviceController, void * appReqState, CHIP_ERROR err, - const Inet::IPPacketInfo * pktInfo); -typedef void (*MessageReceiveHandler)(ChipDeviceController * deviceController, void * appReqState, - System::PacketBufferHandle payload); - -class DLL_EXPORT ChipDeviceController : public Controller::DeviceStatusDelegate -{ - friend class ChipDeviceControllerCallback; - -public: - ChipDeviceController(); - ~ChipDeviceController(); - - void * AppState; - - /** - * Init function to be used when there exists a device layer that takes care of initializing - * System::Layer and InetLayer. - */ - CHIP_ERROR Init(NodeId localDeviceId, Controller::DevicePairingDelegate * pairingDelegate = nullptr, - PersistentStorageDelegate * storageDelegate = nullptr); - /** - * Init function to be used when already-initialized System::Layer and InetLayer are available. - */ - CHIP_ERROR Init(NodeId localDeviceId, System::Layer * systemLayer, Inet::InetLayer * inetLayer, - Controller::DevicePairingDelegate * pairingDelegate = nullptr, - PersistentStorageDelegate * storageDelegate = nullptr); - CHIP_ERROR Shutdown(); - - CHIP_ERROR SetUdpListenPort(uint16_t listenPort); - - chip::Controller::DeviceController * GetDeviceController() { return &mCommissioner; } - - // ----- Connection Management ----- - /** - * @brief - * Connect to a CHIP device with the provided Rendezvous connection parameters - * - * @param[in] remoteDeviceId The remote device Id. - * @param[in] params The Rendezvous connection parameters - * @param[in] appReqState Application specific context to be passed back when a message is received or on error - * @param[in] onConnected Callback for when the connection is established - * @param[in] onMessageReceived Callback for when a message is received - * @param[in] onError Callback for when an error occurs - * - * @return CHIP_ERROR The connection status - */ - [[deprecated("Available until controller apps move to DeviceController/DeviceCommissioner API")]] CHIP_ERROR - ConnectDevice(NodeId remoteDeviceId, RendezvousParameters & params, void * appReqState, NewConnectionHandler onConnected, - MessageReceiveHandler onMessageReceived, ErrorHandler onError); - - /** - * @brief - * Connect to a CHIP device at a given address and an optional port. This is a test only API - * that bypasses Rendezvous and Secure Pairing process. - * - * @param[in] remoteDeviceId The remote device Id. - * @param[in] deviceAddr The address of the requested Device - * @param[in] appReqState Application specific context to be passed back when a message is received or on error - * @param[in] onConnected Callback for when the connection is established - * @param[in] onMessageReceived Callback for when a message is received - * @param[in] onError Callback for when an error occurs - * @return CHIP_ERROR The connection status - */ - [[deprecated("Available until Rendezvous is implemented")]] CHIP_ERROR - ConnectDeviceWithoutSecurePairing(NodeId remoteDeviceId, const Transport::PeerAddress & deviceAddr, void * appReqState, - NewConnectionHandler onConnected, MessageReceiveHandler onMessageReceived, - ErrorHandler onError); - - /** - * @brief - * Disconnect from a connected device - * - * @return CHIP_ERROR If the device was disconnected successfully - */ - CHIP_ERROR DisconnectDevice(); - - /** - * @brief - * Check if there's an active connection - * - * @return bool If there is an active connection - */ - bool IsConnected() const; - - /** - * @brief - * Get IP Address of the peer if the connection is active - * - * @return bool If IP Address was returned - */ - bool GetIpAddress(Inet::IPAddress & addr); - - // ----- Messaging ----- - /** - * @brief - * Send a message to a connected CHIP device - * - * @param[in] appReqState Application specific context to be passed back when a message is received or on error - * @param[in] buffer The Data Buffer to trasmit to the device - * @param[in] peerDevice Device ID of the peer device - * @return CHIP_ERROR The return status - */ - CHIP_ERROR SendMessage(void * appReqState, System::PacketBufferHandle buffer, NodeId peerDevice = kUndefinedNodeId); - - // ----- IO ----- - /** - * @brief - * Start the event loop task within the CHIP stack - * @return CHIP_ERROR The return status - */ - CHIP_ERROR ServiceEvents(); - - /** - * @brief - * Allow the CHIP Stack to process any pending events - * This can be called in an event handler loop to tigger callbacks within the CHIP stack - * @return CHIP_ERROR The return status - */ - CHIP_ERROR ServiceEventSignal(); - - // ----- Pairing ----- - /** - * @brief - * Set device pairing delegate after init, pass nullptr remove device delegate. - * @return CHIP_ERROR The return status - */ - CHIP_ERROR SetDevicePairingDelegate(Controller::DevicePairingDelegate * pairingDelegate); - - //////////// DeviceStatusDelegate Implementation /////////////// - void OnMessage(System::PacketBufferHandle msg) override; - -private: - CHIP_ERROR InitDevice(); - - enum - { - kState_NotInitialized = 0, - kState_Initialized = 1 - } mState; - - Controller::DeviceCommissioner mCommissioner; - Controller::Device * mDevice; - - void * mAppReqState; - - union - { - CompleteHandler General; - MessageReceiveHandler Response; - } mOnComplete; - - ErrorHandler mOnError; - NewConnectionHandler mOnNewConnection; - System::PacketBuffer * mCurReqMsg; - - NodeId mLocalDeviceId; - NodeId mRemoteDeviceId; - uint16_t mListenPort; - - Controller::SerializedDevice mSerializedTestDevice; - bool mPairingWithoutSecurity; - - void ClearRequestState(); - void ClearOpState(); -}; - -} // namespace DeviceController -} // namespace chip diff --git a/src/controller/python/BUILD.gn b/src/controller/python/BUILD.gn index 3f483339ae4b48..f621c16568dd5e 100644 --- a/src/controller/python/BUILD.gn +++ b/src/controller/python/BUILD.gn @@ -30,11 +30,6 @@ config("controller_wno_deprecate") { cflags = [ "-Wno-deprecated-declarations" ] } -config("includes") { - include_dirs = - [ "${chip_root}/src/controller/CHIPDeviceController_deprecated.h" ] -} - shared_library("ChipDeviceCtrl") { output_name = "_ChipDeviceCtrl" output_dir = "${target_out_dir}/chip" From 7135a4c69a23dda96652944bbc504613210836eb Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Tue, 16 Mar 2021 22:17:26 +0800 Subject: [PATCH 25/39] Remove unused sources and interfaces (#5362) Network Provisioning Server is not used. This commit removes the sources and interfaces. --- src/include/platform/ConnectivityManager.h | 6 - src/include/platform/ThreadStackManager.h | 4 - .../GenericNetworkProvisioningServerImpl.cpp | 1103 ----------------- .../GenericNetworkProvisioningServerImpl.h | 126 -- .../internal/NetworkProvisioningServer.h | 105 -- src/platform/BUILD.gn | 4 - src/platform/EFR32/BLEManagerImpl.h | 2 +- src/platform/EFR32/ConfigurationManagerImpl.h | 5 - .../EFR32/NetworkProvisioningServerImpl.cpp | 41 - .../EFR32/NetworkProvisioningServerImpl.h | 79 -- src/platform/ESP32/BLEManagerImpl.h | 2 +- src/platform/ESP32/ConfigurationManagerImpl.h | 5 - src/platform/ESP32/ConnectivityManagerImpl.h | 8 - .../ESP32/NetworkProvisioningServerImpl.cpp | 364 ------ .../ESP32/NetworkProvisioningServerImpl.h | 96 -- src/platform/K32W/BLEManagerImpl.h | 2 +- src/platform/K32W/ConfigurationManagerImpl.h | 5 - .../K32W/NetworkProvisioningServerImpl.cpp | 41 - .../K32W/NetworkProvisioningServerImpl.h | 80 -- src/platform/qpg6100/BLEManagerImpl.h | 2 +- 20 files changed, 4 insertions(+), 2076 deletions(-) delete mode 100644 src/include/platform/internal/GenericNetworkProvisioningServerImpl.cpp delete mode 100644 src/include/platform/internal/GenericNetworkProvisioningServerImpl.h delete mode 100644 src/include/platform/internal/NetworkProvisioningServer.h delete mode 100644 src/platform/EFR32/NetworkProvisioningServerImpl.cpp delete mode 100644 src/platform/EFR32/NetworkProvisioningServerImpl.h delete mode 100644 src/platform/ESP32/NetworkProvisioningServerImpl.cpp delete mode 100644 src/platform/ESP32/NetworkProvisioningServerImpl.h delete mode 100644 src/platform/K32W/NetworkProvisioningServerImpl.cpp delete mode 100644 src/platform/K32W/NetworkProvisioningServerImpl.h diff --git a/src/include/platform/ConnectivityManager.h b/src/include/platform/ConnectivityManager.h index 1a785673d60d56..2d8a5c186cd8da 100644 --- a/src/include/platform/ConnectivityManager.h +++ b/src/include/platform/ConnectivityManager.h @@ -35,9 +35,6 @@ class BLEEndPoint; namespace DeviceLayer { namespace Internal { -class NetworkProvisioningServerImpl; -template -class GenericNetworkProvisioningServerImpl; template class GenericPlatformManagerImpl; template @@ -200,9 +197,6 @@ class ConnectivityManager friend class Internal::GenericPlatformManagerImpl_FreeRTOS; template friend class Internal::GenericPlatformManagerImpl_POSIX; - friend class Internal::NetworkProvisioningServerImpl; - template - friend class Internal::GenericNetworkProvisioningServerImpl; CHIP_ERROR Init(); void OnPlatformEvent(const ChipDeviceEvent * event); diff --git a/src/include/platform/ThreadStackManager.h b/src/include/platform/ThreadStackManager.h index 45b1651b0af80f..16596fa307cba3 100644 --- a/src/include/platform/ThreadStackManager.h +++ b/src/include/platform/ThreadStackManager.h @@ -53,8 +53,6 @@ template class GenericThreadStackManagerImpl_OpenThread_LwIP; template class GenericThreadStackManagerImpl_FreeRTOS; -template -class GenericNetworkProvisioningServerImpl; } // namespace Internal /** @@ -117,8 +115,6 @@ class ThreadStackManager friend class Internal::GenericThreadStackManagerImpl_OpenThread_LwIP; template friend class Internal::GenericThreadStackManagerImpl_FreeRTOS; - template - friend class Internal::GenericNetworkProvisioningServerImpl; void OnPlatformEvent(const ChipDeviceEvent * event); bool IsThreadEnabled(); diff --git a/src/include/platform/internal/GenericNetworkProvisioningServerImpl.cpp b/src/include/platform/internal/GenericNetworkProvisioningServerImpl.cpp deleted file mode 100644 index 9b85f798dcf661..00000000000000 --- a/src/include/platform/internal/GenericNetworkProvisioningServerImpl.cpp +++ /dev/null @@ -1,1103 +0,0 @@ -/* - * - * Copyright (c) 2020-2021 Project CHIP Authors - * Copyright (c) 2018 Nest Labs, Inc. - * 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. - */ - -/** - * @file - * Contains non-inline method definitions for the - * GenericNetworkProvisioningServerImpl<> template. - */ - -#ifndef GENERIC_NETWORK_PROVISIONING_SERVER_IMPL_CPP -#define GENERIC_NETWORK_PROVISIONING_SERVER_IMPL_CPP - -#include -#include -#include -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD -#include -#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD - -namespace chip { -namespace DeviceLayer { -namespace Internal { - -using namespace ::chip::TLV; - -using Profiles::kChipProfile_Common; -using Profiles::kChipProfile_NetworkProvisioning; - -namespace { - -const char sLogPrefix[] = "NetworkProvisioningServer: "; - -} // unnamed namespace - -// Fully instantiate the generic implementation class in whatever compilation unit includes this file. -template class GenericNetworkProvisioningServerImpl; - -template -void GenericNetworkProvisioningServerImpl::_StartPendingScan() -{ - CHIP_ERROR err = CHIP_NO_ERROR; - - // Do nothing if there's no pending ScanNetworks request outstanding, or if a scan is already in progress. - if (mState != kState_ScanNetworks_Pending) - { - ExitNow(); - } - - switch (mScanNetworkType) - { -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - - case kNetworkType_WiFi: - - // Defer the scan if the Connection Manager says the system is in a state - // where a WiFi scan cannot be started (e.g. if the system is connecting to - // an AP and can't scan and connect at the same time). The Connection Manager - // is responsible for calling this method again when the system is read to scan. - if (!ConnectivityMgr().CanStartWiFiScan()) - { - ExitNow(); - } - - mState = kState_ScanNetworks_InProgress; - - // Delegate to the implementation subclass to initiate the WiFi scan operation. - err = Impl()->InitiateWiFiScan(); - SuccessOrExit(err); - - break; - -#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - - case kNetworkType_Thread: - - // TODO: implement this - ExitNow(err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); - - break; - -#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD - - default: - ExitNow(err = CHIP_ERROR_INCORRECT_STATE); - } - -exit: - // If an error occurred, send a Internal Error back to the requestor. - if (err != CHIP_NO_ERROR) - { - SendStatusReport(kChipProfile_Common, kStatus_InternalError, err); - mState = kState_Idle; - } -} - -template -void GenericNetworkProvisioningServerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) -{ -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - - // Handle a change in Internet connectivity... - if (event->Type == DeviceEventType::kInternetConnectivityChange) - { - // If a TestConnectivity operation is in progress for WiFi, re-evaluate the state - // connectivity now. - ContinueWiFiConnectivityTest(); - } - -#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - - // Define some short-hands for various interesting event conditions. - const bool threadConnChanged = (event->Type == DeviceEventType::kThreadConnectivityChange && - event->ThreadConnectivityChange.Result != kConnectivity_NoChange); - const bool threadRoleChanged = (event->Type == DeviceEventType::kThreadStateChange && event->ThreadStateChange.RoleChanged); - const bool threadChildrenChanged = - (event->Type == DeviceEventType::kThreadStateChange && event->ThreadStateChange.ChildNodesChanged); - - // If the state of the Thread interface changed, OR if the Thread role changed, OR - // if there was a change to the set of child nodes... - if (threadConnChanged || threadRoleChanged || threadChildrenChanged) - { - // If a TestConnectivity operation is in progress for Thread, re-evaluate the state - // connectivity now. - ContinueThreadConnectivityTest(); - } - -#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD -} - -template -CHIP_ERROR GenericNetworkProvisioningServerImpl::HandleScanNetworks(uint8_t networkType) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - bool isAppControlled = false; - - VerifyOrExit(mState == kState_Idle, err = CHIP_ERROR_INCORRECT_STATE); - - switch (networkType) - { -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - - case kNetworkType_WiFi: - isAppControlled = ConnectivityMgr().IsWiFiStationApplicationControlled(); - break; - -#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - - case kNetworkType_Thread: - isAppControlled = ConnectivityMgr().IsThreadApplicationControlled(); - break; - -#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD - - default: - err = SendStatusReport(kChipProfile_NetworkProvisioning, kStatusCode_UnsupportedNetworkType); - ExitNow(); - } - - // Reject the request if the application is currently in control of the requested network. - if (isAppControlled) - { - err = SendStatusReport(kChipProfile_Common, kStatus_NotAvailable); - ExitNow(); - } - - // Enter the ScanNetworks Pending state and delegate to the implementation class to start the scan. - mState = kState_ScanNetworks_Pending; - mScanNetworkType = networkType; - Impl()->StartPendingScan(); - -exit: - return err; -} - -template -CHIP_ERROR GenericNetworkProvisioningServerImpl::DoInit() -{ - CHIP_ERROR err; - - // Call init on the server base class. - err = ServerBaseClass::Init(&::chip::DeviceLayer::ExchangeMgr); - SuccessOrExit(err); - - // Set the pointer to the delegate object. - SetDelegate(this); - - mState = kState_Idle; - mScanNetworkType = kNetworkType_NotSpecified; - -exit: - return err; -} - -template -CHIP_ERROR GenericNetworkProvisioningServerImpl::HandleAddNetwork(PacketBuffer * networkInfoTLV) -{ - return HandleAddUpdateNetwork(networkInfoTLV, false); -} - -template -CHIP_ERROR GenericNetworkProvisioningServerImpl::HandleUpdateNetwork(PacketBuffer * networkInfoTLV) -{ - return HandleAddUpdateNetwork(networkInfoTLV, true); -} - -template -CHIP_ERROR GenericNetworkProvisioningServerImpl::HandleAddUpdateNetwork(PacketBuffer * networkInfoTLV, bool isUpdate) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - DeviceNetworkInfo netInfo; - uint32_t netId; - - VerifyOrExit(mState == kState_Idle, err = CHIP_ERROR_INCORRECT_STATE); - - // Parse the supplied network configuration info. - { - TLV::TLVReader reader; - reader.Init(networkInfoTLV); - err = netInfo.Decode(reader); - SuccessOrExit(err); - } - - // Discard the request buffer. - PacketBuffer::Free(networkInfoTLV); - networkInfoTLV = NULL; - - switch (netInfo.NetworkType) - { -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - - case kNetworkType_WiFi: - - // If updating the provision, verify that the specified network is provisioned. - if (isUpdate && !ConnectivityMgr().IsWiFiStationProvisioned()) - { - err = SendStatusReport(kChipProfile_NetworkProvisioning, kStatusCode_UnknownNetwork); - ExitNow(); - } - - // Reject the request if the application is currently in control of the WiFi station. - if (ConnectivityMgr().IsWiFiStationApplicationControlled()) - { - err = SendStatusReport(kChipProfile_Common, kStatus_NotAvailable); - ExitNow(); - } - - // If updating the provision... - if (isUpdate) - { - DeviceNetworkInfo existingNetInfo; - - // Delegate to the implementation subclass to get the existing station provision. - err = Impl()->GetWiFiStationProvision(existingNetInfo, true); - SuccessOrExit(err); - - // Override the existing provision with values specified in the update. - err = netInfo.MergeTo(existingNetInfo); - SuccessOrExit(err); - memcpy(&netInfo, &existingNetInfo, sizeof(existingNetInfo)); - } - - // Check the validity of the new provision. If not acceptable, respond to the requestor - // with an appropriate StatusReport. - { - uint32_t statusProfileId; - uint16_t statusCode; - err = Impl()->ValidateWiFiStationProvision(netInfo, statusProfileId, statusCode); - if (err != CHIP_NO_ERROR) - { - err = SendStatusReport(statusProfileId, statusCode, err); - ExitNow(); - } - } - - // If the WiFi station is not already configured, disable the station interface. This - // ensures that the device will not automatically connect to the new network until an - // EnableNetwork request is received. - if (!ConnectivityMgr().IsWiFiStationProvisioned()) - { - err = ConnectivityMgr().SetWiFiStationMode(ConnectivityManager::kWiFiStationMode_Disabled); - SuccessOrExit(err); - } - - // Delegate to the implementation subclass to set the WiFi station provision. - err = Impl()->SetWiFiStationProvision(netInfo); - SuccessOrExit(err); - - // Tell the ConnectivityManager there's been a change to the station provision. - ConnectivityMgr().OnWiFiStationProvisionChange(); - - netId = kWiFiStationNetworkId; - - break; - -#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - - case kNetworkType_Thread: - - // If updating the provision, verify that the Thread network is provisioned. - if (isUpdate && !ThreadStackMgr().IsThreadProvisioned()) - { - err = SendStatusReport(kChipProfile_NetworkProvisioning, kStatusCode_UnknownNetwork); - ExitNow(); - } - - // Reject the request if the application is currently in control of the Thread network. - if (ConnectivityMgr().IsThreadApplicationControlled()) - { - err = SendStatusReport(kChipProfile_Common, kStatus_NotAvailable); - ExitNow(); - } - - // Check the validity of the supplied Thread parameters. If not acceptable, respond to - // the requestor with an appropriate StatusReport. - { - uint32_t statusProfileId; - uint16_t statusCode; - err = Impl()->ValidateThreadProvision(isUpdate, netInfo, statusProfileId, statusCode); - if (err != CHIP_NO_ERROR) - { - err = SendStatusReport(statusProfileId, statusCode, err); - ExitNow(); - } - } - - // Apply suitable defaults for any parameters not supplied by the client. - err = Impl()->SetThreadProvisionDefaults(isUpdate, netInfo); - SuccessOrExit(err); - - // Store the Thread provision. - err = ThreadStackMgr().SetThreadProvision(netInfo); - SuccessOrExit(err); - - netId = kThreadNetworkId; - - break; - -#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD - - default: - - ChipLogProgress(DeviceLayer, "%sUnsupported network type: %d", sLogPrefix, netInfo.NetworkType); - err = SendStatusReport(kChipProfile_NetworkProvisioning, kStatusCode_UnsupportedNetworkType, CHIP_ERROR_INVALID_ARGUMENT); - ExitNow(); - } - - // Send an AddNetworkComplete message back to the requestor. - SendAddNetworkComplete(netId); - -exit: - PacketBuffer::Free(networkInfoTLV); - return err; -} - -template -CHIP_ERROR GenericNetworkProvisioningServerImpl::HandleRemoveNetwork(uint32_t networkId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - - VerifyOrExit(mState == kState_Idle, err = CHIP_ERROR_INCORRECT_STATE); - - switch (networkId) - { -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - - case kWiFiStationNetworkId: - - // Verify that the specified network exists. - if (!ConnectivityMgr().IsWiFiStationProvisioned()) - { - goto sendUnknownNetworkResp; - } - - // Reject the request if the application is currently in control of the WiFi station. - if (ConnectivityMgr().IsWiFiStationApplicationControlled()) - { - err = SendStatusReport(kChipProfile_Common, kStatus_NotAvailable); - ExitNow(); - } - - // Delegate to the implementation subclass to clear the WiFi station provision. - err = Impl()->ClearWiFiStationProvision(); - SuccessOrExit(err); - - // Tell the ConnectivityManager there's been a change to the station provision. - ConnectivityMgr().OnWiFiStationProvisionChange(); - - break; - -#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - - case kThreadNetworkId: - - // Verify that the specified network exists. - if (!ThreadStackMgr().IsThreadProvisioned()) - { - goto sendUnknownNetworkResp; - } - - // Reject the request if the application is currently in control of the Thread network. - if (ConnectivityMgr().IsThreadApplicationControlled()) - { - err = SendStatusReport(kChipProfile_Common, kStatus_NotAvailable); - ExitNow(); - } - - // Clear the Thread provision. - ThreadStackMgr().ErasePersistentInfo(); - - break; - -#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD - - default: - sendUnknownNetworkResp: - - err = SendStatusReport(kChipProfile_NetworkProvisioning, kStatusCode_UnknownNetwork); - ExitNow(); - } - - // Respond with a Success response. - err = SendSuccessResponse(); - SuccessOrExit(err); - -exit: - return err; -} - -template -CHIP_ERROR GenericNetworkProvisioningServerImpl::HandleGetNetworks(uint8_t flags) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - DeviceNetworkInfo netInfo[2]; - PacketBuffer * respBuf = NULL; - uint8_t resultCount = 0; - const bool includeCredentials = (flags & kGetNetwork_IncludeCredentials) != 0; - - VerifyOrExit(mState == kState_Idle, err = CHIP_ERROR_INCORRECT_STATE); - -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - - // Delegate to the implementation subclass to get the WiFi station provision. - err = Impl()->GetWiFiStationProvision(netInfo[resultCount], includeCredentials); - if (err == CHIP_NO_ERROR) - { - resultCount++; - } - else if (err != CHIP_ERROR_INCORRECT_STATE) - { - ExitNow(); - } - -#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - - // Delegate to the implementation subclass to get the Thread provision. - err = ThreadStackMgr().GetThreadProvision(netInfo[resultCount], includeCredentials); - if (err == CHIP_NO_ERROR) - { - resultCount++; - } - else if (err != CHIP_ERROR_INCORRECT_STATE) - { - ExitNow(); - } - -#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD - - // Allocate a buffer to hold the response. - respBuf = PacketBufferHandle::New(PacketBuffer::kMaxSize); - VerifyOrExit(respBuf != NULL, err = CHIP_ERROR_NO_MEMORY); - - // Encode the GetNetworks response data. - { - TLVWriter writer; - - writer.Init(respBuf); - - err = DeviceNetworkInfo::EncodeArray(writer, netInfo, resultCount); - SuccessOrExit(err); - - err = writer.Finalize(); - SuccessOrExit(err); - } - - // Send the response. - err = SendGetNetworksComplete(resultCount, respBuf); - respBuf = NULL; - SuccessOrExit(err); - -exit: - PacketBuffer::Free(respBuf); - return err; -} - -template -CHIP_ERROR GenericNetworkProvisioningServerImpl::HandleEnableNetwork(uint32_t networkId) -{ - return HandleEnableDisableNetwork(networkId, true); -} - -template -CHIP_ERROR GenericNetworkProvisioningServerImpl::HandleDisableNetwork(uint32_t networkId) -{ - return HandleEnableDisableNetwork(networkId, false); -} - -template -CHIP_ERROR GenericNetworkProvisioningServerImpl::HandleEnableDisableNetwork(uint32_t networkId, bool enable) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - - VerifyOrExit(mState == kState_Idle, err = CHIP_ERROR_INCORRECT_STATE); - - switch (networkId) - { -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - - case kWiFiStationNetworkId: - - // Verify that the specified network exists. - if (!ConnectivityMgr().IsWiFiStationProvisioned()) - { - goto sendUnknownNetworkResp; - } - - // Reject the request if the application is currently in control of the WiFi station. - if (ConnectivityMgr().IsWiFiStationApplicationControlled()) - { - err = SendStatusReport(kChipProfile_Common, kStatus_NotAvailable); - ExitNow(); - } - - // Tell the ConnectivityManager to enable/disable the WiFi station interface. - // Note that any effects of chaning the WiFi station mode happen asynchronously with this call. - err = ConnectivityMgr().SetWiFiStationMode((enable) ? ConnectivityManager::kWiFiStationMode_Enabled - : ConnectivityManager::kWiFiStationMode_Disabled); - SuccessOrExit(err); - - break; - -#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - - case kThreadNetworkId: - - // Verify that the specified network exists. - if (!ThreadStackMgr().IsThreadProvisioned()) - { - goto sendUnknownNetworkResp; - } - - // Reject the request if the application is currently in control of the Thread network. - if (ConnectivityMgr().IsThreadApplicationControlled()) - { - err = SendStatusReport(kChipProfile_Common, kStatus_NotAvailable); - ExitNow(); - } - - // Tell the ConnectivityManager to enable/disable the Thread network interface. - // Note that any effects of changing the Thread mode happen asynchronously with this call. - err = ThreadStackMgr().SetThreadEnabled(enable); - SuccessOrExit(err); - - break; - -#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD - - default: - sendUnknownNetworkResp: - - err = SendStatusReport(kChipProfile_NetworkProvisioning, kStatusCode_UnknownNetwork); - ExitNow(); - } - - // Respond with a Success response. - err = SendSuccessResponse(); - SuccessOrExit(err); - -exit: - return err; -} - -template -CHIP_ERROR GenericNetworkProvisioningServerImpl::HandleTestConnectivity(uint32_t networkId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - - VerifyOrExit(mState == kState_Idle, err = CHIP_ERROR_INCORRECT_STATE); - - switch (networkId) - { -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - - case kWiFiStationNetworkId: - - // Verify that the specified network exists. - if (!ConnectivityMgr().IsWiFiStationProvisioned()) - { - goto sendUnknownNetworkResp; - } - - // Reject the request if the application is currently in control of the WiFi station. - if (ConnectivityMgr().IsWiFiStationApplicationControlled()) - { - err = SendStatusReport(kChipProfile_Common, kStatus_NotAvailable); - ExitNow(); - } - - // Tell the ConnectivityManager to enable the WiFi station interface if it hasn't been done already. - // Note that any effects of enabling the WiFi station interface (e.g. connecting to an AP) happen - // asynchronously with this call. - err = ConnectivityMgr().SetWiFiStationMode(ConnectivityManager::kWiFiStationMode_Enabled); - SuccessOrExit(err); - - // Record that we're waiting for the WiFi station interface to establish connectivity - // with the Internet and arm a timer that will generate an error if connectivity isn't established - // within a certain amount of time. - mState = kState_TestConnectivity_WaitWiFiConnectivity; - SystemLayer.StartTimer(CHIP_DEVICE_CONFIG_WIFI_CONNECTIVITY_TIMEOUT, HandleConnectivityTestTimeOut, NULL); - - // Go check for connectivity now. - Impl()->ContinueWiFiConnectivityTest(); - - break; - -#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - - case kThreadNetworkId: - - // Verify that the specified network exists. - if (!ThreadStackMgr().IsThreadProvisioned()) - { - goto sendUnknownNetworkResp; - } - - // If the Thread interface is NOT already enabled... - if (!ThreadStackMgr().IsThreadEnabled()) - { - // Reject the request if the application is currently in control of the Thread network. - if (ConnectivityMgr().IsThreadApplicationControlled()) - { - err = SendStatusReport(kChipProfile_Common, kStatus_NotAvailable); - ExitNow(); - } - - // Enable the Thread interface. - err = ThreadStackMgr().SetThreadEnabled(true); - SuccessOrExit(err); - } - - // Record that we're waiting to establish Thread connectivity and arm a timer that will - // generate an error if connectivity isn't established within a certain amount of time. - mState = kState_TestConnectivity_WaitThreadConnectivity; - SystemLayer.StartTimer(CHIP_DEVICE_CONFIG_THREAD_CONNECTIVITY_TIMEOUT, HandleConnectivityTestTimeOut, NULL); - - // Go check for connectivity now. - Impl()->ContinueThreadConnectivityTest(); - - break; - -#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD - - default: - sendUnknownNetworkResp: - - err = SendStatusReport(kChipProfile_NetworkProvisioning, kStatusCode_UnknownNetwork); - ExitNow(); - } - -exit: - return err; -} - -template -CHIP_ERROR GenericNetworkProvisioningServerImpl::HandleSetRendezvousMode(uint16_t rendezvousMode) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - - VerifyOrExit(mState == kState_Idle, err = CHIP_ERROR_INCORRECT_STATE); - - // Fail with Common:UnsupportedMessage if any unsupported modes were specified. - { - const uint16_t kSupportedModes = 0 -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP - | kRendezvousMode_EnableWiFiRendezvousNetwork -#endif -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - | kRendezvousMode_EnableThreadRendezvous -#endif - ; - - if ((rendezvousMode & ~kSupportedModes) != 0) - { - err = SendStatusReport(kChipProfile_Common, kStatus_UnsupportedMessage); - ExitNow(); - } - } - -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP - - // If the request is to start the WiFi "rendezvous network" (a.k.a. the WiFi AP interface)... - if ((rendezvousMode & kRendezvousMode_EnableWiFiRendezvousNetwork) != 0) - { - // Reject the request if the application is currently in control of the WiFi AP - // OR if the AP interface has been expressly disabled by the application. - const ConnectivityManager::WiFiAPMode apMode = ConnectivityMgr().GetWiFiAPMode(); - if (apMode == ConnectivityManager::kWiFiAPMode_ApplicationControlled || apMode == ConnectivityManager::kWiFiAPMode_Disabled) - { - err = SendStatusReport(kChipProfile_Common, kStatus_NotAvailable); - ExitNow(); - } - - // Otherwise, request the ConnectivityManager to demand start the WiFi AP interface. - // If the interface is already active this will have no immediate effect, except if the - // interface is in the "demand" mode, in which case this will serve to extend the - // active time. - ConnectivityMgr().DemandStartWiFiAP(); - } - - // Otherwise the request is to stop the WiFi rendezvous network, so request the ConnectivityManager - // to stop the AP interface if it has been demand started. This will have no effect if the - // interface is already stopped, or if the application has expressly enabled the interface. - else - { - ConnectivityMgr().StopOnDemandWiFiAP(); - } - -#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP - -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - - // If the request is to enable Thread "rendezvous"--i.e. enable Thread joinable mode... - if ((rendezvousMode & kRendezvousMode_EnableWiFiRendezvousNetwork) != 0) - { - // Reject the request if the application is currently in control of the Thread Network - // OR if the Thread interface has been expressly disabled by the application - // OR if the Thread network has not been provisioned. - const ConnectivityManager::ThreadMode threadMode = ConnectivityMgr().GetThreadMode(); - if (threadMode == ConnectivityManager::kThreadMode_ApplicationControlled || - threadMode == ConnectivityManager::kThreadMode_Disabled || !ThreadStackMgr().IsThreadProvisioned()) - { - err = SendStatusReport(kChipProfile_Common, kStatus_NotAvailable); - ExitNow(); - } - - // TODO: implement this - ExitNow(err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); - } - - // Otherwise the request is to stop the Thread rendezvous... - else - { - - // TODO: implement this - ExitNow(err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); - } - -#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD - - // Respond with a Success response. - err = SendSuccessResponse(); - SuccessOrExit(err); - -exit: - return err; -} - -template -bool GenericNetworkProvisioningServerImpl::IsPairedToAccount() const -{ - return ConfigurationMgr().IsServiceProvisioned() && ConfigurationMgr().IsPairedToAccount(); -} - -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - -template -CHIP_ERROR GenericNetworkProvisioningServerImpl::ValidateWiFiStationProvision(const DeviceNetworkInfo & netInfo, - uint32_t & statusProfileId, - uint16_t & statusCode) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - - if (netInfo.NetworkType != kNetworkType_WiFi) - { - ChipLogProgress(DeviceLayer, "%sUnsupported WiFi station network type: %d", sLogPrefix, netInfo.NetworkType); - statusProfileId = kChipProfile_NetworkProvisioning; - statusCode = kStatusCode_UnsupportedNetworkType; - ExitNow(err = CHIP_ERROR_INVALID_ARGUMENT); - } - - if (netInfo.WiFiSSID[0] == 0) - { - ChipLogProgress(DeviceLayer, "%sMissing WiFi station SSID", sLogPrefix); - statusProfileId = kChipProfile_NetworkProvisioning; - statusCode = kStatusCode_InvalidNetworkConfiguration; - ExitNow(err = CHIP_ERROR_INVALID_ARGUMENT); - } - - if (netInfo.WiFiMode != kWiFiMode_Managed) - { - if (netInfo.WiFiMode == kWiFiMode_NotSpecified) - { - ChipLogProgress(DeviceLayer, "%sMissing WiFi station mode", sLogPrefix); - } - else - { - ChipLogProgress(DeviceLayer, "%sUnsupported WiFi station mode: %d", sLogPrefix, netInfo.WiFiMode); - } - statusProfileId = kChipProfile_NetworkProvisioning; - statusCode = kStatusCode_InvalidNetworkConfiguration; - ExitNow(err = CHIP_ERROR_INVALID_ARGUMENT); - } - - if (netInfo.WiFiRole != kWiFiRole_Station) - { - if (netInfo.WiFiRole == kWiFiRole_NotSpecified) - { - ChipLogProgress(DeviceLayer, "%sMissing WiFi station role", sLogPrefix); - } - else - { - ChipLogProgress(DeviceLayer, "%sUnsupported WiFi station role: %d", sLogPrefix, netInfo.WiFiRole); - } - statusProfileId = kChipProfile_NetworkProvisioning; - statusCode = kStatusCode_InvalidNetworkConfiguration; - ExitNow(err = CHIP_ERROR_INVALID_ARGUMENT); - } - - // Defer to the implementation class to determine if the proposed security type is supported. - if (!ImplClass::IsSupportedWiFiSecurityType(netInfo.WiFiSecurityType)) - { - ChipLogProgress(DeviceLayer, "%sUnsupported WiFi station security type: %d", sLogPrefix, netInfo.WiFiSecurityType); - statusProfileId = kChipProfile_NetworkProvisioning; - statusCode = kStatusCode_UnsupportedWiFiSecurityType; - ExitNow(err = CHIP_ERROR_INVALID_ARGUMENT); - } - - if (netInfo.WiFiSecurityType != kWiFiSecurityType_None && netInfo.WiFiKeyLen == 0) - { - ChipLogProgress(DeviceLayer, "%sMissing WiFi Key", sLogPrefix); - statusProfileId = kChipProfile_NetworkProvisioning; - statusCode = kStatusCode_InvalidNetworkConfiguration; - ExitNow(err = CHIP_ERROR_INVALID_ARGUMENT); - } - -exit: - return err; -} - -#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - -template -CHIP_ERROR -GenericNetworkProvisioningServerImpl::ValidateThreadProvision(bool isUpdate, const DeviceNetworkInfo & netInfo, - uint32_t & statusProfileId, uint16_t & statusCode) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - - // Verify a valid Thread channel was specified. - if (netInfo.ThreadChannel != kThreadChannel_NotSpecified) - { - if (netInfo.ThreadChannel < 11 && netInfo.ThreadChannel > 26) - { - statusProfileId = kChipProfile_NetworkProvisioning; - statusCode = kStatusCode_InvalidNetworkConfiguration; - ExitNow(err = CHIP_ERROR_INVALID_ARGUMENT); - } - } - -exit: - return err; -} - -template -CHIP_ERROR GenericNetworkProvisioningServerImpl::SetThreadProvisionDefaults(bool isUpdate, DeviceNetworkInfo & netInfo) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - - // Generate unique values for any Thread parameters not supplied by the client. - - // If extended PAN id was not specified, generate a random one. - if (!netInfo.FieldPresent.ThreadExtendedPANId) - { - err = Platform::Security::GetSecureRandomData(netInfo.ThreadExtendedPANId, NetworkInfo::kThreadExtendedPANIdLength); - SuccessOrExit(err); - netInfo.FieldPresent.ThreadExtendedPANId = true; - } - - // If network name was not specified, generate a default one. If the device is a member of a - // Chip fabric, base part of the name on the fabric id. - if (netInfo.ThreadNetworkName[0] == 0) - { - uint16_t nameSuffix = (::chip::DeviceLayer::FabricState.FabricId != kFabricIdNotSpecified) - ? (uint16_t)::chip::DeviceLayer::FabricState.FabricId - : Encoding::BigEndian::Get16(&netInfo.ThreadExtendedPANId[6]); - snprintf(netInfo.ThreadNetworkName, sizeof(netInfo.ThreadNetworkName), "%s%04X", - CHIP_DEVICE_CONFIG_DEFAULT_THREAD_NETWORK_NAME_PREFIX, nameSuffix); - } - - // If a mesh prefix was not specified, generate one based on the extended PAN id. - if (!netInfo.FieldPresent.ThreadMeshPrefix) - { - memset(netInfo.ThreadMeshPrefix, 0, sizeof(netInfo.ThreadMeshPrefix)); - netInfo.ThreadMeshPrefix[0] = 0xFD; // IPv6 ULA prefix - memcpy(&netInfo.ThreadMeshPrefix[1], netInfo.ThreadExtendedPANId, 5); - netInfo.FieldPresent.ThreadMeshPrefix = true; - } - - // If the master key was not specified, generate a random key. - if (!netInfo.FieldPresent.ThreadMasterKey) - { - err = Platform::Security::GetSecureRandomData(netInfo.ThreadMasterKey, NetworkInfo::kThreadMasterKeyLength); - SuccessOrExit(err); - netInfo.FieldPresent.ThreadMasterKey = true; - } - - // If a PSKc was not specified, generate a random PSKc. - if (!netInfo.FieldPresent.ThreadPSKc) - { - err = Platform::Security::GetSecureRandomData(netInfo.ThreadPSKc, NetworkInfo::kThreadPSKcLength); - SuccessOrExit(err); - netInfo.FieldPresent.ThreadPSKc = true; - } - - // If a PAN Id was not specified, generate a random Id. - if (netInfo.ThreadPANId == kThreadPANId_NotSpecified) - { - uint16_t randPANId; - err = Platform::Security::GetSecureRandomData((uint8_t *) &randPANId, sizeof(randPANId)); - SuccessOrExit(err); - netInfo.ThreadPANId = randPANId; - } - - // If Thread channel not present, choose a random one. - if (netInfo.ThreadChannel == kThreadChannel_NotSpecified) - { - err = Platform::Security::GetSecureRandomData((uint8_t *) &netInfo.ThreadChannel, sizeof(netInfo.ThreadChannel)); - SuccessOrExit(err); - netInfo.ThreadChannel = (netInfo.ThreadChannel % 0xF) + 11; // Convert value to 11 thru 26 - } - -exit: - return err; -} - -#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD - -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - -template -void GenericNetworkProvisioningServerImpl::ContinueWiFiConnectivityTest(void) -{ - // If waiting for Internet connectivity to be established ... - if (mState == kState_TestConnectivity_WaitWiFiConnectivity) - { - // Check for IPv4 Internet connectivity. If available... - if (ConnectivityMgr().HaveIPv4InternetConnectivity()) - { - // TODO: perform positive test of connectivity to the Internet by pinging/connecting to - // a well-known external server. - - // Send a Success result to the client. - HandleConnectivityTestSuccess(); - } - - // Otherwise, arrange to return an appropriate error when the connectivity test times out. - else - { - // TODO: Elaborate on the nature of the connectivity failure. Ideally the status - // code would distinguish the following types of failures: - // - Inability to connect to the local WiFi AP - // - Lack of a suitable local address (RFC1918 for IPv4; Global address for IPv6) - // - Lack of a default router - // - Lack of a DNS server - // - Inability to contact an external server. - mTestConnectivityResult.mStatusProfileId = kChipProfile_NetworkProvisioning; - mTestConnectivityResult.mStatusCode = kStatusCode_TestNetworkFailed; - } - } -} - -#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION - -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - -template -void GenericNetworkProvisioningServerImpl::ContinueThreadConnectivityTest(void) -{ - // If waiting for Thread connectivity to be established... - if (mState == kState_TestConnectivity_WaitThreadConnectivity) - { - // Check for connectivity to the Thread mesh. In this context, connectivity means - // that this node knows of (i.e. has in its Thread neighbor table) another node - // which is acting as a Thread router. If connectivity exists, send a Success - // result to the client. - if (ThreadStackMgr().HaveMeshConnectivity()) - { - // TODO: perform positive test of connectivity to peer router node. - - // Send a Success result to the client. - HandleConnectivityTestSuccess(); - } - - // If connectivity doesn't exist arrange to return an appropriate error when the - // connectivity test times out. - else - { - // TODO: Elaborate on the nature of the connectivity failure. Ideally the status - // code would distinguish the following types of failures: - // - Lack of a peer router detected in the Mesh (for end nodes, this means - // lack of a parent router). - // - Inability to contact/ping the peer router. - mTestConnectivityResult.mStatusProfileId = kChipProfile_NetworkProvisioning; - mTestConnectivityResult.mStatusCode = kStatusCode_NoRouterAvailable; - } - } -} - -#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD - -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION || CHIP_DEVICE_CONFIG_ENABLE_THREAD - -template -void GenericNetworkProvisioningServerImpl::HandleConnectivityTestSuccess(void) -{ - // Reset the state. - mState = kState_Idle; - SystemLayer.CancelTimer(HandleConnectivityTestTimeOut, NULL); - - // Verify that the TestConnectivity request is still outstanding and if so, - // send a Success response to the client - if (GetCurrentOp() == kMsgType_TestConnectivity) - { - SendSuccessResponse(); - } -} - -template -void GenericNetworkProvisioningServerImpl::HandleConnectivityTestTimeOut(::chip::System::Layer * aLayer, - void * aAppState, ::chip::System::Error aError) -{ - GenericNetworkProvisioningServerImpl * self = &NetworkProvisioningSvrImpl(); - - if (self->mState == kState_TestConnectivity_WaitWiFiConnectivity || - self->mState == kState_TestConnectivity_WaitThreadConnectivity) - { - const bool testingWiFi = (self->mState == kState_TestConnectivity_WaitWiFiConnectivity); - - ChipLogProgress(DeviceLayer, "%sTime out waiting for %s connectivity", sLogPrefix, (testingWiFi) ? "Internet" : "Thread"); - - // Reset the state. - self->mState = kState_Idle; - SystemLayer.CancelTimer(HandleConnectivityTestTimeOut, NULL); - - // Verify that the TestConnectivity request is still outstanding; if so, send a StatusReport - // to the client contain an appropriate error. - if (self->GetCurrentOp() == kMsgType_TestConnectivity) - { - self->SendStatusReport(self->mTestConnectivityResult.mStatusProfileId, self->mTestConnectivityResult.mStatusCode); - } - } -} - -#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION || CHIP_DEVICE_CONFIG_ENABLE_THREAD - -} // namespace Internal -} // namespace DeviceLayer -} // namespace chip - -#endif // GENERIC_NETWORK_PROVISIONING_SERVER_IMPL_CPP diff --git a/src/include/platform/internal/GenericNetworkProvisioningServerImpl.h b/src/include/platform/internal/GenericNetworkProvisioningServerImpl.h deleted file mode 100644 index 947806313cfacc..00000000000000 --- a/src/include/platform/internal/GenericNetworkProvisioningServerImpl.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2018 Nest Labs, Inc. - * 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 - -namespace chip { -namespace DeviceLayer { -namespace Internal { - -class NetworkProvisioningServerImpl; -class DeviceNetworkInfo; - -template -class GenericNetworkProvisioningServerImpl : public ::chip::Profiles::NetworkProvisioning::NetworkProvisioningServer, - public ::chip::Profiles::NetworkProvisioning::NetworkProvisioningDelegate -{ -protected: - using ServerBaseClass = ::chip::Profiles::NetworkProvisioning::NetworkProvisioningServer; - using NetworkInfo = ::chip::DeviceLayer::Internal::DeviceNetworkInfo; - using NetworkType_t = ::chip::Profiles::NetworkProvisioning::NetworkType; - using PacketBuffer = ::chip::System::PacketBuffer; - using WiFiSecurityType_t = ::chip::Profiles::NetworkProvisioning::WiFiSecurityType; - - // ===== Members that implement the NetworkProvisioningServer abstract interface - - NetworkProvisioningDelegate * _GetDelegate(void); - void _StartPendingScan(void); - bool _ScanInProgress(void); - void _OnPlatformEvent(const ChipDeviceEvent * event); - - // ===== Members that override virtual methods on NetworkProvisioningDelegate - - CHIP_ERROR HandleScanNetworks(uint8_t networkType) override; - CHIP_ERROR HandleAddNetwork(PacketBuffer * networkInfoTLV) override; - CHIP_ERROR HandleUpdateNetwork(PacketBuffer * networkInfoTLV) override; - CHIP_ERROR HandleRemoveNetwork(uint32_t networkId) override; - CHIP_ERROR HandleGetNetworks(uint8_t flags) override; - CHIP_ERROR HandleEnableNetwork(uint32_t networkId) override; - CHIP_ERROR HandleDisableNetwork(uint32_t networkId) override; - CHIP_ERROR HandleTestConnectivity(uint32_t networkId) override; - CHIP_ERROR HandleSetRendezvousMode(uint16_t rendezvousMode) override; - - // ===== Members that override virtual methods on NetworkProvisioningServer - - bool IsPairedToAccount(void) const override; - - // ===== Members for use by the NetworkProvisioningServer implementation - // (both generic and platform-specific). - - enum State - { - kState_Idle = 0x00, - kState_ScanNetworks_Pending = 0x01, - kState_ScanNetworks_InProgress = 0x02, - kState_TestConnectivity_WaitWiFiConnectivity = 0x03, - kState_TestConnectivity_WaitThreadConnectivity = 0x03, - }; - - uint8_t mState; - uint8_t mScanNetworkType; - struct - { - uint32_t mStatusProfileId; - uint16_t mStatusCode; - } mTestConnectivityResult; - - CHIP_ERROR DoInit(void); - int16_t GetCurrentOp(void) const; - CHIP_ERROR HandleAddUpdateNetwork(PacketBuffer * networkInfoTLV, bool add); - CHIP_ERROR HandleEnableDisableNetwork(uint32_t networkId, bool enable); - CHIP_ERROR ValidateWiFiStationProvision(const DeviceNetworkInfo & netInfo, uint32_t & statusProfileId, uint16_t & statusCode); - CHIP_ERROR ValidateThreadProvision(bool isUpdate, const DeviceNetworkInfo & netInfo, uint32_t & statusProfileId, - uint16_t & statusCode); - CHIP_ERROR SetThreadProvisionDefaults(bool isUpdate, DeviceNetworkInfo & netInfo); - void ContinueWiFiConnectivityTest(void); - void ContinueThreadConnectivityTest(void); - void HandleConnectivityTestSuccess(void); - static void HandleConnectivityTestTimeOut(::chip::System::Layer * aLayer, void * aAppState, ::chip::System::Error aError); - -private: - ImplClass * Impl() { return static_cast(this); } -}; - -// Instruct the compiler to instantiate the template only when explicitly told to do so. -extern template class GenericNetworkProvisioningServerImpl; - -template -inline ::chip::Profiles::NetworkProvisioning::NetworkProvisioningDelegate * -GenericNetworkProvisioningServerImpl::_GetDelegate(void) -{ - return this; -} - -template -inline int16_t GenericNetworkProvisioningServerImpl::GetCurrentOp() const -{ - return (mCurOp != NULL) ? mCurOpType : -1; -} - -template -inline bool GenericNetworkProvisioningServerImpl::_ScanInProgress(void) -{ - return mState == kState_ScanNetworks_InProgress; -} - -} // namespace Internal -} // namespace DeviceLayer -} // namespace chip diff --git a/src/include/platform/internal/NetworkProvisioningServer.h b/src/include/platform/internal/NetworkProvisioningServer.h deleted file mode 100644 index f5135a853fc923..00000000000000 --- a/src/include/platform/internal/NetworkProvisioningServer.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2018 Nest Labs, Inc. - * 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 - -namespace chip { -namespace DeviceLayer { -namespace Internal { - -class NetworkProvisioningServerImpl; - -/** - * Provides network provisioning services for a CHIP Device. - */ -class NetworkProvisioningServer -{ - using ImplClass = NetworkProvisioningServerImpl; - -public: - // Members for internal use by components within the CHIP Device Layer. - - CHIP_ERROR Init(void); - // NetworkProvisioningDelegate * GetDelegate(void); - void StartPendingScan(void); - bool ScanInProgress(void); - void OnPlatformEvent(const CHIPDeviceEvent * event); - -protected: - // Construction/destruction limited to subclasses. - NetworkProvisioningServer() = default; - ~NetworkProvisioningServer() = default; - - // No copy, move or assignment. - NetworkProvisioningServer(const NetworkProvisioningServer &) = delete; - NetworkProvisioningServer(const NetworkProvisioningServer &&) = delete; - NetworkProvisioningServer & operator=(const NetworkProvisioningServer &) = delete; -}; - -/** - * Returns a reference to the public interface of the NetworkProvisioningServer singleton object. - * - * Internal components should use this to access features of the NetworkProvisioningServer object - * that are common to all platforms. - */ -extern NetworkProvisioningServer & NetworkProvisioningSvr(); - -} // namespace Internal -} // namespace DeviceLayer -} // namespace chip - -/* Include a header file containing the implementation of the NetworkProvisioningServer - * object for the selected platform. - */ -#ifdef EXTERNAL_NETWORKPROVISIONINGSERVERIMPL_HEADER -#include EXTERNAL_NETWORKPROVISIONINGSERVERIMPL_HEADER -#elif defined(CHIP_DEVICE_LAYER_TARGET) -#define NETWORKPROVISIONINGSERVERIMPL_HEADER -#include NETWORKPROVISIONINGSERVERIMPL_HEADER -#endif // defined(CHIP_DEVICE_LAYER_TARGET) - -namespace chip { -namespace DeviceLayer { -namespace Internal { - -inline CHIP_ERROR NetworkProvisioningServer::Init(void) -{ - return static_cast(this)->_Init(); -} - -inline void NetworkProvisioningServer::StartPendingScan(void) -{ - static_cast(this)->_StartPendingScan(); -} - -inline bool NetworkProvisioningServer::ScanInProgress(void) -{ - return static_cast(this)->_ScanInProgress(); -} - -inline void NetworkProvisioningServer::OnPlatformEvent(const CHIPDeviceEvent * event) -{ - static_cast(this)->_OnPlatformEvent(event); -} - -} // namespace Internal -} // namespace DeviceLayer -} // namespace chip diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index e5451ade0b54ee..784e7fde2a3bbe 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -206,13 +206,11 @@ if (chip_device_platform != "none" && chip_device_platform != "external") { "../include/platform/internal/GenericConnectivityManagerImpl_NoWiFi.h", "../include/platform/internal/GenericConnectivityManagerImpl_Thread.h", "../include/platform/internal/GenericConnectivityManagerImpl_WiFi.h", - "../include/platform/internal/GenericNetworkProvisioningServerImpl.h", "../include/platform/internal/GenericPlatformManagerImpl.h", "../include/platform/internal/GenericPlatformManagerImpl_FreeRTOS.h", "../include/platform/internal/GenericPlatformManagerImpl_POSIX.h", "../include/platform/internal/GenericSoftwareUpdateManagerImpl.h", "../include/platform/internal/GenericSoftwareUpdateManagerImpl_BDX.h", - "../include/platform/internal/NetworkProvisioningServer.h", "../include/platform/internal/testing/ConfigUnitTest.h", "GeneralUtils.cpp", "Globals.cpp", @@ -406,7 +404,6 @@ if (chip_device_platform != "none" && chip_device_platform != "external") { "ESP32/Logging.cpp", "ESP32/LwIPCoreLock.cpp", "ESP32/MdnsImpl.cpp", - "ESP32/NetworkProvisioningServerImpl.h", "ESP32/PlatformManagerImpl.cpp", "ESP32/PlatformManagerImpl.h", "ESP32/ServiceProvisioning.cpp", @@ -437,7 +434,6 @@ if (chip_device_platform != "none" && chip_device_platform != "external") { "K32W/KeyValueStoreManagerImpl.cpp", "K32W/KeyValueStoreManagerImpl.h", "K32W/Logging.cpp", - "K32W/NetworkProvisioningServerImpl.h", "K32W/PlatformManagerImpl.cpp", "K32W/PlatformManagerImpl.h", "K32W/SoftwareUpdateManagerImpl.h", diff --git a/src/platform/EFR32/BLEManagerImpl.h b/src/platform/EFR32/BLEManagerImpl.h index 3d1df68cbecfaa..a185e1ba99ddfa 100644 --- a/src/platform/EFR32/BLEManagerImpl.h +++ b/src/platform/EFR32/BLEManagerImpl.h @@ -36,7 +36,7 @@ namespace Internal { using namespace chip::Ble; /** - * Concrete implementation of the NetworkProvisioningServer singleton object for the EFR32 platforms. + * Concrete implementation of the BLEManager singleton object for the EFR32 platforms. */ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePlatformDelegate, private BleApplicationDelegate { diff --git a/src/platform/EFR32/ConfigurationManagerImpl.h b/src/platform/EFR32/ConfigurationManagerImpl.h index f28e9a22169098..f40246a579888a 100644 --- a/src/platform/EFR32/ConfigurationManagerImpl.h +++ b/src/platform/EFR32/ConfigurationManagerImpl.h @@ -31,10 +31,6 @@ namespace chip { namespace DeviceLayer { -namespace Internal { -class NetworkProvisioningServerImpl; -} - /** * Concrete implementation of the ConfigurationManager singleton object for the EFR32 platform. */ @@ -66,7 +62,6 @@ class ConfigurationManagerImpl final : public ConfigurationManager, // ===== Members for internal use by the following friends. - friend class Internal::NetworkProvisioningServerImpl; friend ConfigurationManager & ConfigurationMgr(void); friend ConfigurationManagerImpl & ConfigurationMgrImpl(void); diff --git a/src/platform/EFR32/NetworkProvisioningServerImpl.cpp b/src/platform/EFR32/NetworkProvisioningServerImpl.cpp deleted file mode 100644 index db311ec66faed4..00000000000000 --- a/src/platform/EFR32/NetworkProvisioningServerImpl.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Nest Labs, Inc. - * - * 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. - */ -/* this file behaves like a config.h, comes first */ -#include - -#include - -#include -#include -#include -#include - -namespace chip { -namespace DeviceLayer { -namespace Internal { - -NetworkProvisioningServerImpl NetworkProvisioningServerImpl::sInstance; - -CHIP_ERROR NetworkProvisioningServerImpl::_Init(void) -{ - return GenericNetworkProvisioningServerImpl::DoInit(); -} - -} // namespace Internal -} // namespace DeviceLayer -} // namespace chip diff --git a/src/platform/EFR32/NetworkProvisioningServerImpl.h b/src/platform/EFR32/NetworkProvisioningServerImpl.h deleted file mode 100644 index 19f71ed2e22f4e..00000000000000 --- a/src/platform/EFR32/NetworkProvisioningServerImpl.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Nest Labs, Inc. - * - * 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 DeviceLayer { -namespace Internal { - -/** - * Concrete implementation of the NetworkProvisioningServer singleton object for the - * Silicon Labs EFR32 platforms. - */ -class NetworkProvisioningServerImpl final : public NetworkProvisioningServer, - public Internal::GenericNetworkProvisioningServerImpl -{ - // Allow the NetworkProvisioningServer interface class to delegate method calls to - // the implementation methods provided by this class. - friend class Internal::NetworkProvisioningServer; - - // Allow the GenericNetworkProvisioningServerImpl base class to access helper methods - // and types defined on this class. - friend class Internal::GenericNetworkProvisioningServerImpl; - -private: - // ===== Members that implement the NetworkProvisioningServer public interface. - - CHIP_ERROR _Init(void); - - // ===== Members for internal use by the following friends. - - friend ::chip::DeviceLayer::Internal::NetworkProvisioningServer & NetworkProvisioningSvr(void); - friend NetworkProvisioningServerImpl & NetworkProvisioningSvrImpl(void); - - static NetworkProvisioningServerImpl sInstance; -}; - -/** - * Returns a reference to the public interface of the NetworkProvisioningServer singleton object. - * - * Internal components should use this to access features of the NetworkProvisioningServer object - * that are common to all platforms. - */ -inline NetworkProvisioningServer & NetworkProvisioningSvr(void) -{ - return NetworkProvisioningServerImpl::sInstance; -} - -/** - * Returns the platform-specific implementation of the NetworkProvisioningServer singleton object. - * - * Internal components can use this to gain access to features of the NetworkProvisioningServer - * that are specific to the ESP32 platform. - */ -inline NetworkProvisioningServerImpl & NetworkProvisioningSvrImpl(void) -{ - return NetworkProvisioningServerImpl::sInstance; -} - -} // namespace Internal -} // namespace DeviceLayer -} // namespace chip diff --git a/src/platform/ESP32/BLEManagerImpl.h b/src/platform/ESP32/BLEManagerImpl.h index 702a0ac37c310a..317daff518af79 100644 --- a/src/platform/ESP32/BLEManagerImpl.h +++ b/src/platform/ESP32/BLEManagerImpl.h @@ -60,7 +60,7 @@ namespace DeviceLayer { namespace Internal { /** - * Concrete implementation of the NetworkProvisioningServer singleton object for the ESP32 platform. + * Concrete implementation of the BLEManager singleton object for the ESP32 platform. */ class BLEManagerImpl final : public BLEManager, private Ble::BleLayer, diff --git a/src/platform/ESP32/ConfigurationManagerImpl.h b/src/platform/ESP32/ConfigurationManagerImpl.h index 162ff0bc6157a7..71c30b809de453 100644 --- a/src/platform/ESP32/ConfigurationManagerImpl.h +++ b/src/platform/ESP32/ConfigurationManagerImpl.h @@ -38,10 +38,6 @@ namespace chip { namespace DeviceLayer { -namespace Internal { -class NetworkProvisioningServerImpl; -} - /** * Concrete implementation of the ConfigurationManager singleton object for the ESP32 platform. */ @@ -78,7 +74,6 @@ class ConfigurationManagerImpl final : public ConfigurationManager, // ===== Members for internal use by the following friends. - friend class Internal::NetworkProvisioningServerImpl; friend ConfigurationManager & ConfigurationMgr(void); friend ConfigurationManagerImpl & ConfigurationMgrImpl(void); diff --git a/src/platform/ESP32/ConnectivityManagerImpl.h b/src/platform/ESP32/ConnectivityManagerImpl.h index f698f3839e1d55..9e41eb9161a7f3 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl.h +++ b/src/platform/ESP32/ConnectivityManagerImpl.h @@ -41,14 +41,6 @@ namespace DeviceLayer { class PlatformManagerImpl; -namespace Internal { - -class NetworkProvisioningServerImpl; -template -class GenericNetworkProvisioningServerImpl; - -} // namespace Internal - /** * Concrete implementation of the ConnectivityManager singleton object for the ESP32 platform. */ diff --git a/src/platform/ESP32/NetworkProvisioningServerImpl.cpp b/src/platform/ESP32/NetworkProvisioningServerImpl.cpp deleted file mode 100644 index 62ef89d160361f..00000000000000 --- a/src/platform/ESP32/NetworkProvisioningServerImpl.cpp +++ /dev/null @@ -1,364 +0,0 @@ -/* - * - * Copyright (c) 2020-2021 Project CHIP Authors - * Copyright (c) 2018 Nest Labs, Inc. - * 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. - */ -/* this file behaves like a config.h, comes first */ -#include - -#include -#include - -#include -#include -#include -#include - -#include "esp_event.h" -#include "esp_wifi.h" - -using namespace ::chip; -using namespace ::chip::TLV; - -using Profiles::kChipProfile_Common; - -namespace chip { -namespace DeviceLayer { -namespace Internal { - -NetworkProvisioningServerImpl NetworkProvisioningServerImpl::sInstance; - -CHIP_ERROR NetworkProvisioningServerImpl::_Init(void) -{ - return GenericNetworkProvisioningServerImpl::DoInit(); -} - -void NetworkProvisioningServerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) -{ - CHIP_ERROR err; - - // Handle ESP system events... - if (event->Type == DeviceEventType::kESPSystemEvent) - { - switch (event->Platform.ESPSystemEvent.event_id) - { - case SYSTEM_EVENT_SCAN_DONE: - ChipLogProgress(DeviceLayer, "SYSTEM_EVENT_SCAN_DONE"); - HandleScanDone(); - break; - default: - break; - } - } - - // Handle a change in WiFi connectivity... - else if (event->Type == DeviceEventType::kWiFiConnectivityChange) - { - // Whenever WiFi connectivity is established, update the persisted WiFi - // station security type to match that used by the connected AP. - if (event->WiFiConnectivityChange.Result == kConnectivity_Established) - { - wifi_ap_record_t ap_info; - - err = esp_wifi_sta_get_ap_info(&ap_info); - SuccessOrExit(err); - - WiFiSecurityType secType = ESP32Utils::WiFiAuthModeToChipWiFiSecurityType(ap_info.authmode); - - err = ConfigurationMgrImpl().UpdateWiFiStationSecurityType(secType); - SuccessOrExit(err); - } - } - - // Propagate the event to the GenericNetworkProvisioningServerImpl<> base class so - // that it can take action on specific events. - GenericImplClass::_OnPlatformEvent(event); - -exit: - return; -} - -CHIP_ERROR NetworkProvisioningServerImpl::GetWiFiStationProvision(NetworkInfo & netInfo, bool includeCredentials) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - wifi_config_t stationConfig; - - netInfo.Reset(); - - err = esp_wifi_get_config(WIFI_IF_STA, &stationConfig); - SuccessOrExit(err); - - VerifyOrExit(stationConfig.sta.ssid[0] != 0, err = CHIP_ERROR_INCORRECT_STATE); - - netInfo.NetworkId = kWiFiStationNetworkId; - netInfo.FieldPresent.NetworkId = true; - netInfo.NetworkType = kNetworkType_WiFi; - memcpy(netInfo.WiFiSSID, stationConfig.sta.ssid, min(strlen((char *) stationConfig.sta.ssid) + 1, sizeof(netInfo.WiFiSSID))); - netInfo.WiFiMode = kWiFiMode_Managed; - netInfo.WiFiRole = kWiFiRole_Station; - - err = ConfigurationMgrImpl().GetWiFiStationSecurityType(netInfo.WiFiSecurityType); - if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) - { - err = CHIP_NO_ERROR; - } - SuccessOrExit(err); - - if (includeCredentials) - { - netInfo.WiFiKeyLen = min(strlen((char *) stationConfig.sta.password), sizeof(netInfo.WiFiKey)); - memcpy(netInfo.WiFiKey, stationConfig.sta.password, netInfo.WiFiKeyLen); - } - -exit: - return err; -} - -CHIP_ERROR NetworkProvisioningServerImpl::SetWiFiStationProvision(const NetworkInfo & netInfo) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - wifi_config_t wifiConfig; - - // Ensure that ESP station mode is enabled. This is required before esp_wifi_set_config(ESP_IF_WIFI_STA,...) - // can be called. - err = ESP32Utils::EnableStationMode(); - SuccessOrExit(err); - - // Initialize an ESP wifi_config_t structure based on the new provision information. - memset(&wifiConfig, 0, sizeof(wifiConfig)); - memcpy(wifiConfig.sta.ssid, netInfo.WiFiSSID, min(strlen(netInfo.WiFiSSID) + 1, sizeof(wifiConfig.sta.ssid))); - memcpy(wifiConfig.sta.password, netInfo.WiFiKey, min((size_t) netInfo.WiFiKeyLen, sizeof(wifiConfig.sta.password))); - if (netInfo.WiFiSecurityType == kWiFiSecurityType_NotSpecified) - { - wifiConfig.sta.scan_method = WIFI_ALL_CHANNEL_SCAN; - } - else - { - wifiConfig.sta.scan_method = WIFI_FAST_SCAN; - wifiConfig.sta.threshold.rssi = 0; - switch (netInfo.WiFiSecurityType) - { - case kWiFiSecurityType_None: - wifiConfig.sta.threshold.authmode = WIFI_AUTH_OPEN; - break; - case kWiFiSecurityType_WEP: - wifiConfig.sta.threshold.authmode = WIFI_AUTH_WEP; - break; - case kWiFiSecurityType_WPAPersonal: - wifiConfig.sta.threshold.authmode = WIFI_AUTH_WPA_PSK; - break; - case kWiFiSecurityType_WPA2Personal: - wifiConfig.sta.threshold.authmode = WIFI_AUTH_WPA2_PSK; - break; - case kWiFiSecurityType_WPA2Enterprise: - wifiConfig.sta.threshold.authmode = WIFI_AUTH_WPA2_ENTERPRISE; - break; - default: - ExitNow(err = CHIP_ERROR_INVALID_ARGUMENT); - } - } - wifiConfig.sta.sort_method = WIFI_CONNECT_AP_BY_SIGNAL; - - // Configure the ESP WiFi interface. - err = esp_wifi_set_config(WIFI_IF_STA, &wifiConfig); - if (err != ESP_OK) - { - ChipLogError(DeviceLayer, "esp_wifi_set_config() failed: %s", chip::ErrorStr(err)); - } - SuccessOrExit(err); - - // Store the WiFi Station security type separately in NVS. This is necessary because the ESP wifi API - // does not provide a way to query the configured WiFi auth mode. - err = ConfigurationMgrImpl().UpdateWiFiStationSecurityType(netInfo.WiFiSecurityType); - SuccessOrExit(err); - - ChipLogProgress(DeviceLayer, "WiFi station provision set (SSID: %s)", netInfo.WiFiSSID); - -exit: - return err; -} - -CHIP_ERROR NetworkProvisioningServerImpl::ClearWiFiStationProvision(void) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - wifi_config_t stationConfig; - - // Clear the ESP WiFi station configuration. - memset(&stationConfig, 0, sizeof(stationConfig)); - esp_wifi_set_config(WIFI_IF_STA, &stationConfig); - - // Clear the persisted WiFi station security type. - ConfigurationMgrImpl().UpdateWiFiStationSecurityType(kWiFiSecurityType_NotSpecified); - - return err; -} - -CHIP_ERROR NetworkProvisioningServerImpl::InitiateWiFiScan(void) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - wifi_scan_config_t scanConfig; - - // Initiate an active scan using the default dwell times. Configure the scan to return hidden networks. - memset(&scanConfig, 0, sizeof(scanConfig)); - scanConfig.show_hidden = 1; - scanConfig.scan_type = WIFI_SCAN_TYPE_ACTIVE; - err = esp_wifi_scan_start(&scanConfig, false); - SuccessOrExit(err); - -#if CHIP_DEVICE_CONFIG_WIFI_SCAN_COMPLETION_TIMEOUT - // Arm timer in case we never get the scan done event. - SystemLayer.StartTimer(CHIP_DEVICE_CONFIG_WIFI_SCAN_COMPLETION_TIMEOUT, HandleScanTimeOut, NULL); -#endif // CHIP_DEVICE_CONFIG_WIFI_SCAN_COMPLETION_TIMEOUT - -exit: - return err; -} - -void NetworkProvisioningServerImpl::HandleScanDone() -{ - CHIP_ERROR err; - wifi_ap_record_t * scanResults = NULL; - uint16_t scanResultCount; - uint16_t encodedResultCount; - - // If we receive a SCAN DONE event for a scan that we didn't initiate, simply ignore it. - VerifyOrExit(mState == kState_ScanNetworks_InProgress, err = CHIP_NO_ERROR); - - mState = kState_Idle; - -#if CHIP_DEVICE_CONFIG_WIFI_SCAN_COMPLETION_TIMEOUT - // Cancel the scan timeout timer. - SystemLayer.CancelTimer(HandleScanTimeOut, NULL); -#endif // CHIP_DEVICE_CONFIG_WIFI_SCAN_COMPLETION_TIMEOUT - - // Determine the number of scan results found. - err = esp_wifi_scan_get_ap_num(&scanResultCount); - SuccessOrExit(err); - - // Only return up to CHIP_DEVICE_CONFIG_MAX_SCAN_NETWORKS_RESULTS. - scanResultCount = min(scanResultCount, (uint16_t) CHIP_DEVICE_CONFIG_MAX_SCAN_NETWORKS_RESULTS); - - // Allocate a buffer to hold the scan results array. - scanResults = (wifi_ap_record_t *) chip::Platform::MemoryAlloc(scanResultCount * sizeof(wifi_ap_record_t)); - VerifyOrExit(scanResults != NULL, err = CHIP_ERROR_NO_MEMORY); - - // Collect the scan results from the ESP WiFi driver. Note that this also *frees* - // the internal copy of the results. - err = esp_wifi_scan_get_ap_records(&scanResultCount, scanResults); - SuccessOrExit(err); - - // If the ScanNetworks request is still outstanding... - if (GetCurrentOp() == kMsgType_ScanNetworks) - { - System::PacketBufferTLVWriter writer; - TLVType outerContainerType; - - // Sort results by rssi. - qsort(scanResults, scanResultCount, sizeof(*scanResults), ESP32Utils::OrderScanResultsByRSSI); - - // Allocate a packet buffer to hold the encoded scan results. - PacketBufferHandle respBuf = - System::PacketBufferHandle::New(PacketBuffer::kMaxSize - 1, System::PacketBuffer::kDefaultHeaderReserve + 1); - VerifyOrExit(!respBuf.IsNull(), err = CHIP_ERROR_NO_MEMORY); - - // Encode the list of scan results into the response buffer. If the encoded size of all - // the results exceeds the size of the buffer, encode only what will fit. - writer.Init(std::move(respBuf)); - err = writer.StartContainer(AnonymousTag, kTLVType_Array, outerContainerType); - SuccessOrExit(err); - for (encodedResultCount = 0; encodedResultCount < scanResultCount; encodedResultCount++) - { - NetworkInfo netInfo; - const wifi_ap_record_t & scanResult = scanResults[encodedResultCount]; - - netInfo.Reset(); - netInfo.NetworkType = kNetworkType_WiFi; - memcpy(netInfo.WiFiSSID, scanResult.ssid, - min(strlen((char *) scanResult.ssid) + 1, (size_t) NetworkInfo::kMaxWiFiSSIDLength)); - netInfo.WiFiSSID[NetworkInfo::kMaxWiFiSSIDLength] = 0; - netInfo.WiFiMode = kWiFiMode_Managed; - netInfo.WiFiRole = kWiFiRole_Station; - netInfo.WiFiSecurityType = ESP32Utils::WiFiAuthModeToChipWiFiSecurityType(scanResult.authmode); - netInfo.WirelessSignalStrength = scanResult.rssi; - - { - chip::TLV::TLVWriter savePoint = writer; - err = netInfo.Encode(writer); - if (err == CHIP_ERROR_BUFFER_TOO_SMALL) - { - writer = savePoint; - break; - } - } - SuccessOrExit(err); - } - err = writer.EndContainer(outerContainerType); - SuccessOrExit(err); - err = writer.Finalize(&respBuf); - SuccessOrExit(err); - - // Send the scan results to the requestor. Note that this method takes ownership of the - // buffer, success or fail. - err = SendNetworkScanComplete(encodedResultCount, std::move(respBuf)); - SuccessOrExit(err); - } - -exit: - // If an error occurred and we haven't yet responded, send a Internal Error back to the - // requestor. - if (err != CHIP_NO_ERROR && GetCurrentOp() == kMsgType_ScanNetworks) - { - SendStatusReport(kChipProfile_Common, kStatus_InternalError, err); - } - - // Tell the ConnectivityManager that the WiFi scan is now done. This allows it to continue - // any activities that were deferred while the scan was in progress. - ConnectivityMgr().OnWiFiScanDone(); -} - -#if CHIP_DEVICE_CONFIG_WIFI_SCAN_COMPLETION_TIMEOUT - -void NetworkProvisioningServerImpl::HandleScanTimeOut(::chip::System::Layer * aLayer, void * aAppState, - ::chip::System::Error aError) -{ - ChipLogError(DeviceLayer, "WiFi scan timed out"); - - // Reset the state. - sInstance.mState = kState_Idle; - - // Verify that the ScanNetworks request is still outstanding; if so, send a - // Common:InternalError StatusReport to the client. - if (sInstance.GetCurrentOp() == kMsgType_ScanNetworks) - { - sInstance.SendStatusReport(kChipProfile_Common, kStatus_InternalError, CHIP_ERROR_TIMEOUT); - } - - // Tell the ConnectivityManager that the WiFi scan is now done. - ConnectivityMgr().OnWiFiScanDone(); -} - -#endif // CHIP_DEVICE_CONFIG_WIFI_SCAN_COMPLETION_TIMEOUT - -bool NetworkProvisioningServerImpl::IsSupportedWiFiSecurityType(WiFiSecurityType_t wifiSecType) -{ - return (wifiSecType == kWiFiSecurityType_None || wifiSecType == kWiFiSecurityType_WEP || - wifiSecType == kWiFiSecurityType_WPAPersonal || wifiSecType == kWiFiSecurityType_WPA2Personal || - wifiSecType == kWiFiSecurityType_WPA2Enterprise); -} - -} // namespace Internal -} // namespace DeviceLayer -} // namespace chip diff --git a/src/platform/ESP32/NetworkProvisioningServerImpl.h b/src/platform/ESP32/NetworkProvisioningServerImpl.h deleted file mode 100644 index 179be4978fe826..00000000000000 --- a/src/platform/ESP32/NetworkProvisioningServerImpl.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2018 Nest Labs, Inc. - * 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 - -namespace chip { -namespace DeviceLayer { -namespace Internal { - -/** - * Concrete implementation of the NetworkProvisioningServer singleton object for the ESP32 platform. - */ -class NetworkProvisioningServerImpl final : public NetworkProvisioningServer, - public GenericNetworkProvisioningServerImpl -{ -private: - using GenericImplClass = GenericNetworkProvisioningServerImpl; - - // Allow the NetworkProvisioningServer interface class to delegate method calls to - // the implementation methods provided by this class. - friend class ::chip::DeviceLayer::Internal::NetworkProvisioningServer; - - // Allow the GenericNetworkProvisioningServerImpl base class to access helper methods - // and types defined on this class. - friend class GenericNetworkProvisioningServerImpl; - - // ===== Members that implement the NetworkProvisioningServer public interface. - - CHIP_ERROR _Init(void); - void _OnPlatformEvent(const ChipDeviceEvent * event); - - // NOTE: Other public interface methods are implemented by GenericNetworkProvisioningServerImpl<>. - - // ===== Members used by GenericNetworkProvisioningServerImpl<> to invoke platform-specific - // operations. - - CHIP_ERROR GetWiFiStationProvision(NetworkInfo & netInfo, bool includeCredentials); - CHIP_ERROR SetWiFiStationProvision(const NetworkInfo & netInfo); - CHIP_ERROR ClearWiFiStationProvision(void); - CHIP_ERROR InitiateWiFiScan(void); - void HandleScanDone(void); - static NetworkProvisioningServerImpl & Instance(void); - static void HandleScanTimeOut(::chip::System::Layer * aLayer, void * aAppState, ::chip::System::Error aError); - static bool IsSupportedWiFiSecurityType(WiFiSecurityType_t wifiSecType); - - // ===== Members for internal use by the following friends. - - friend ::chip::DeviceLayer::Internal::NetworkProvisioningServer & NetworkProvisioningSvr(void); - friend NetworkProvisioningServerImpl & NetworkProvisioningSvrImpl(void); - - static NetworkProvisioningServerImpl sInstance; -}; - -/** - * Returns a reference to the public interface of the NetworkProvisioningServer singleton object. - * - * Internal components should use this to access features of the NetworkProvisioningServer object - * that are common to all platforms. - */ -inline NetworkProvisioningServer & NetworkProvisioningSvr(void) -{ - return NetworkProvisioningServerImpl::sInstance; -} - -/** - * Returns the platform-specific implementation of the NetworkProvisioningServer singleton object. - * - * Internal components can use this to gain access to features of the NetworkProvisioningServer - * that are specific to the ESP32 platform. - */ -inline NetworkProvisioningServerImpl & NetworkProvisioningSvrImpl(void) -{ - return NetworkProvisioningServerImpl::sInstance; -} - -} // namespace Internal -} // namespace DeviceLayer -} // namespace chip diff --git a/src/platform/K32W/BLEManagerImpl.h b/src/platform/K32W/BLEManagerImpl.h index c31b9fb200c3ba..7ae4e60226f775 100644 --- a/src/platform/K32W/BLEManagerImpl.h +++ b/src/platform/K32W/BLEManagerImpl.h @@ -52,7 +52,7 @@ namespace Internal { using namespace chip::Ble; /** - * Concrete implementation of the NetworkProvisioningServer singleton object for the K32W platforms. + * Concrete implementation of the BLEManager singleton object for the K32W platforms. */ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePlatformDelegate, private BleApplicationDelegate { diff --git a/src/platform/K32W/ConfigurationManagerImpl.h b/src/platform/K32W/ConfigurationManagerImpl.h index 220581efc83120..eb0f1c1e06943a 100644 --- a/src/platform/K32W/ConfigurationManagerImpl.h +++ b/src/platform/K32W/ConfigurationManagerImpl.h @@ -31,10 +31,6 @@ namespace chip { namespace DeviceLayer { -namespace Internal { -class NetworkProvisioningServerImpl; -} - /** * Concrete implementation of the ConfigurationManager singleton object for the K32W platform. */ @@ -66,7 +62,6 @@ class ConfigurationManagerImpl final : public ConfigurationManager, // ===== Members for internal use by the following friends. - friend class Internal::NetworkProvisioningServerImpl; friend ConfigurationManager & ConfigurationMgr(void); friend ConfigurationManagerImpl & ConfigurationMgrImpl(void); diff --git a/src/platform/K32W/NetworkProvisioningServerImpl.cpp b/src/platform/K32W/NetworkProvisioningServerImpl.cpp deleted file mode 100644 index 936dad31fe8de5..00000000000000 --- a/src/platform/K32W/NetworkProvisioningServerImpl.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Nest Labs, Inc. - * 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. - */ -/* this file behaves like a config.h, comes first */ -#include - -#include -#include - -#include -#include - -namespace chip { -namespace DeviceLayer { -namespace Internal { - -NetworkProvisioningServerImpl NetworkProvisioningServerImpl::sInstance; - -CHIP_ERROR NetworkProvisioningServerImpl::_Init(void) -{ - return GenericNetworkProvisioningServerImpl::DoInit(); -} - -} // namespace Internal -} // namespace DeviceLayer -} // namespace chip diff --git a/src/platform/K32W/NetworkProvisioningServerImpl.h b/src/platform/K32W/NetworkProvisioningServerImpl.h deleted file mode 100644 index 2e17e451ddc2b2..00000000000000 --- a/src/platform/K32W/NetworkProvisioningServerImpl.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Nest Labs, Inc. - * 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 - -namespace chip { -namespace DeviceLayer { -namespace Internal { - -/** - * Concrete implementation of the NetworkProvisioningServer singleton object for the - * NXP K32W platforms. - */ -class NetworkProvisioningServerImpl final : public NetworkProvisioningServer, - public Internal::GenericNetworkProvisioningServerImpl -{ - // Allow the NetworkProvisioningServer interface class to delegate method calls to - // the implementation methods provided by this class. - friend class ::chip::DeviceLayer::Internal::NetworkProvisioningServer; - - // Allow the GenericNetworkProvisioningServerImpl base class to access helper methods - // and types defined on this class. - friend class GenericNetworkProvisioningServerImpl; - -private: - // ===== Members that implement the NetworkProvisioningServer public interface. - - CHIP_ERROR _Init(void); - - // ===== Members for internal use by the following friends. - - friend ::chip::DeviceLayer::Internal::NetworkProvisioningServer & NetworkProvisioningSvr(void); - friend NetworkProvisioningServerImpl & NetworkProvisioningSvrImpl(void); - - static NetworkProvisioningServerImpl sInstance; -}; - -/** - * Returns a reference to the public interface of the NetworkProvisioningServer singleton object. - * - * Internal components should use this to access features of the NetworkProvisioningServer object - * that are common to all platforms. - */ -inline NetworkProvisioningServer & NetworkProvisioningSvr(void) -{ - return NetworkProvisioningServerImpl::sInstance; -} - -/** - * Returns the platform-specific implementation of the NetworkProvisioningServer singleton object. - * - * Internal components can use this to gain access to features of the NetworkProvisioningServer - * that are specific to the K32W platform. - */ -inline NetworkProvisioningServerImpl & NetworkProvisioningSvrImpl(void) -{ - return NetworkProvisioningServerImpl::sInstance; -} - -} // namespace Internal -} // namespace DeviceLayer -} // namespace chip diff --git a/src/platform/qpg6100/BLEManagerImpl.h b/src/platform/qpg6100/BLEManagerImpl.h index 8de51c449f6d52..483e85a748456a 100644 --- a/src/platform/qpg6100/BLEManagerImpl.h +++ b/src/platform/qpg6100/BLEManagerImpl.h @@ -34,7 +34,7 @@ namespace Internal { using namespace chip::Ble; /** - * Concrete implementation of the NetworkProvisioningServer singleton object for the platform. + * Concrete implementation of the BLEManager singleton object for the platform. */ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePlatformDelegate, private BleApplicationDelegate { From 4485ebeaf3bef9868ce80092c4249ffd50d5925a Mon Sep 17 00:00:00 2001 From: doru91 Date: Tue, 16 Mar 2021 16:18:01 +0200 Subject: [PATCH 26/39] [K32W] Add lighting application (#5290) * [K32W] Add lighting application Signed-off-by: Doru Gucea * Restyled by clang-format * Restyled by prettier-markdown * [K32W] Fix review comments Signed-off-by: Doru Gucea * Restyled by clang-format * [K32W] Remove unneeded code Signed-off-by: Doru Gucea Co-authored-by: Restyled.io --- docs/guides/nxp_k32w_android_commissioning.md | 27 +- examples/lighting-app/k32w/.gn | 28 + examples/lighting-app/k32w/BUILD.gn | 95 +++ examples/lighting-app/k32w/README.md | 186 ++++++ examples/lighting-app/k32w/args.gni | 19 + examples/lighting-app/k32w/build_overrides | 1 + examples/lighting-app/k32w/data.bin | Bin 0 -> 4652 bytes examples/lighting-app/k32w/main/AppTask.cpp | 561 ++++++++++++++++++ .../k32w/main/LightingManager.cpp | 233 ++++++++ .../lighting-app/k32w/main/ZclCallbacks.cpp | 67 +++ .../lighting-app/k32w/main/include/AppEvent.h | 55 ++ .../lighting-app/k32w/main/include/AppTask.h | 88 +++ .../k32w/main/include/LightingManager.h | 83 +++ .../k32w/main/include/app_config.h | 53 ++ examples/lighting-app/k32w/main/main.cpp | 149 +++++ .../k32w/third_party/connectedhomeip | 1 + examples/lock-app/k32w/BUILD.gn | 2 +- examples/lock-app/k32w/main/AppTask.cpp | 16 +- ...lock-example.ld => chip-k32w061-linker.ld} | 0 .../k32w/doc/images/nxp_hw_connectivity.JPG | Bin 61368 -> 67243 bytes 20 files changed, 1642 insertions(+), 22 deletions(-) create mode 100644 examples/lighting-app/k32w/.gn create mode 100644 examples/lighting-app/k32w/BUILD.gn create mode 100644 examples/lighting-app/k32w/README.md create mode 100644 examples/lighting-app/k32w/args.gni create mode 120000 examples/lighting-app/k32w/build_overrides create mode 100644 examples/lighting-app/k32w/data.bin create mode 100644 examples/lighting-app/k32w/main/AppTask.cpp create mode 100644 examples/lighting-app/k32w/main/LightingManager.cpp create mode 100644 examples/lighting-app/k32w/main/ZclCallbacks.cpp create mode 100644 examples/lighting-app/k32w/main/include/AppEvent.h create mode 100644 examples/lighting-app/k32w/main/include/AppTask.h create mode 100644 examples/lighting-app/k32w/main/include/LightingManager.h create mode 100644 examples/lighting-app/k32w/main/include/app_config.h create mode 100644 examples/lighting-app/k32w/main/main.cpp create mode 120000 examples/lighting-app/k32w/third_party/connectedhomeip rename examples/platform/k32w/app/ldscripts/{chip-k32w061-lock-example.ld => chip-k32w061-linker.ld} (100%) diff --git a/docs/guides/nxp_k32w_android_commissioning.md b/docs/guides/nxp_k32w_android_commissioning.md index d63a6a428d4be2..6cad0ef4310309 100644 --- a/docs/guides/nxp_k32w_android_commissioning.md +++ b/docs/guides/nxp_k32w_android_commissioning.md @@ -3,8 +3,8 @@ This article describes how to use [CHIPTool](../../src/android/CHIPTool/README.md) for Android smartphones to commission an NXP K32W061 DK6 running -[NXP K32W Lock Example Application](../../examples/lock-app/k32w/README.md) onto -a CHIP-enabled Thread network. +[NXP K32W Lock/Light Example Application](../../examples/lock-light-app/k32w/README.md) +onto a CHIP-enabled Thread network.
@@ -12,7 +12,7 @@ a CHIP-enabled Thread network. - [Requirements](#requirements) - [Building and programming OpenThread RCP firmware](#building-rcp-firmware) - [Configuring PC as Thread Border Router](#configuring-pc) -- [Building and programming NXP K32W Lock Example Application](#building-example) +- [Building and programming NXP K32W Lock/Light Example Application](#building-example) - [Building and installing Android CHIPTool](#building-chiptool) - [Forming a Thread network on the Border Router](#form-thread) - [Preparing accessory device](#preparing-accessory) @@ -45,7 +45,7 @@ with a spare Wi-Fi card and an device. The following diagram shows the connectivity between network components required -to allow communication between devices running the CHIPTool and Lock +to allow communication between devices running the CHIPTool and Lock/Light applications: ![nxp_hw_connectivity](../../examples/platform/k32w/doc/images/nxp_hw_connectivity.JPG) @@ -306,11 +306,15 @@ To make your PC work as a Thread Border Router, complete the following tasks: -## Building and programming NXP K32W Lock Example Application +## Building and programming NXP K32W Lock/Light Example Application See [NXP K32W Lock Example Application README](../../examples/lock-app/k32w/README.md) -to learn how to build and program the example onto an K32W061 DK6. +to learn how to build and program the lock example onto an K32W061 DK6. + +See +[NXP K32W Light Example Application README](../../examples/lighting-app/k32w/README.md) +to learn how to build and program the light example onto an K32W061 DK6.
@@ -442,10 +446,11 @@ following steps: 2. Verify that the text box on the screen is not empty and contains the IPv6 address of the accessory device. -3. Tap the following buttons to change the lock state: +3. Tap the following buttons to change the lock/light state: - - _ON_ and _OFF_ buttons lock and unlock the door, respectively. - - _TOGGLE_ changes the lock state to the opposite. + - _ON_ and _OFF_ buttons lock/turn on and unlock/turn off the door/light + bulb, respectively. + - _TOGGLE_ changes the lock/light state to the opposite. -The _LED D3_ on the device turns on or off based on the changes of the lock -state. +The _LED D3_ on the device turns on or off based on the changes of the +lock/light state. diff --git a/examples/lighting-app/k32w/.gn b/examples/lighting-app/k32w/.gn new file mode 100644 index 00000000000000..3d48789e30ab3d --- /dev/null +++ b/examples/lighting-app/k32w/.gn @@ -0,0 +1,28 @@ +# Copyright (c) 2020 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") + +# The location of the build configuration file. +buildconfig = "${build_root}/config/BUILDCONFIG.gn" + +# CHIP uses angle bracket includes. +check_system_includes = true + +default_args = { + target_cpu = "arm" + target_os = "freertos" + + import("//args.gni") +} diff --git a/examples/lighting-app/k32w/BUILD.gn b/examples/lighting-app/k32w/BUILD.gn new file mode 100644 index 00000000000000..53eb8fa4b9804f --- /dev/null +++ b/examples/lighting-app/k32w/BUILD.gn @@ -0,0 +1,95 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build_overrides/chip.gni") +import("//build_overrides/k32w_sdk.gni") +import("//build_overrides/openthread.gni") + +import("${k32w_sdk_build_root}/k32w_executable.gni") +import("${k32w_sdk_build_root}/k32w_sdk.gni") + +assert(current_os == "freertos") + +k32w_platform_dir = "${chip_root}/examples/platform/k32w" + +k32w_sdk("sdk") { + include_dirs = [ + "main/include", + "main", + "${k32w_platform_dir}/app/project_include", + "${k32w_platform_dir}/app/support", + "${chip_root}/examples/lighting-app/lighting-common", + "${chip_root}/src/app/util", + "${chip_root}/src/app/server", + "${k32w_platform_dir}/util/include", + ] + + sources = [ + "${k32w_platform_dir}/app/project_include/CHIPProjectConfig.h", + "${k32w_platform_dir}/app/project_include/FreeRTOSConfig.h", + "${k32w_platform_dir}/app/project_include/OpenThreadConfig.h", + "main/include/app_config.h", + ] + + public_deps = + [ "${chip_root}/third_party/openthread/platforms:libopenthread-platform" ] + + defines = [] + if (is_debug) { + defines += [ "BUILD_RELEASE=0" ] + } else { + defines += [ "BUILD_RELEASE=1" ] + } +} + +k32w_executable("light_app") { + output_name = "chip-k32w061-light-example" + + sources = [ + "${k32w_platform_dir}/util/LEDWidget.cpp", + "${k32w_platform_dir}/util/include/LEDWidget.h", + "main/AppTask.cpp", + "main/LightingManager.cpp", + "main/ZclCallbacks.cpp", + "main/include/AppEvent.h", + "main/include/AppTask.h", + "main/include/LightingManager.h", + "main/main.cpp", + ] + + deps = [ + ":sdk", + "${chip_root}/examples/common/QRCode", + "${chip_root}/examples/lighting-app/lighting-common", + "${chip_root}/src/lib", + "${chip_root}/third_party/mbedtls:mbedtls", + "${k32w_platform_dir}/app/support:freertos_mbedtls_utils", + "${openthread_root}:libopenthread-cli-ftd", + "${openthread_root}:libopenthread-ftd", + ] + + output_dir = root_out_dir + + ldscript = "${k32w_platform_dir}/app/ldscripts/chip-k32w061-linker.ld" + + ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ] +} + +group("k32w") { + deps = [ ":light_app" ] +} + +group("default") { + deps = [ ":k32w" ] +} diff --git a/examples/lighting-app/k32w/README.md b/examples/lighting-app/k32w/README.md new file mode 100644 index 00000000000000..a7ef3fac3deaca --- /dev/null +++ b/examples/lighting-app/k32w/README.md @@ -0,0 +1,186 @@ +# CHIP K32W061 Lighting Example Application + +The Project CHIP K32W061 Lighting Example demonstrates how to remotely control a +light bulb. The light bulb is simulated using one of the LEDs from the expansion +board. It uses buttons to test turn on/turn off of the light bulb. You can use +this example as a reference for creating your own application. + +The example is based on +[Project CHIP](https://github.com/project-chip/connectedhomeip) and the NXP K32W +SDK, and supports remote access and control of a light bulb over a low-power, +802.15.4 Thread network. + +The example behaves as a Project CHIP accessory, that is a device that can be +paired into an existing Project CHIP network and can be controlled by this +network. + +
+ +- [CHIP K32W Lighting Example Application](#chip-k32w-lighting-example-application) - +- [Introduction](#introduction) + - [Bluetooth LE Advertising](#bluetooth-le-advertising) + - [Bluetooth LE Rendezvous](#bluetooth-le-rendezvous) +- [Device UI](#device-ui) +- [Building](#building) +- [Flashing and debugging](#flashdebug) +- [Testing the example](#testing-the-example) + +
+ + + +## Introduction + +![K32W061 DK6](../../platform/k32w/doc/images/k32w-dk6.jpg) + +The K32W lighting example application provides a working demonstration of a +light bulb device, built using the Project CHIP codebase and the NXP K32W061 +SDK. The example supports remote access (e.g.: using CHIP Tool from a mobile +phone) and control of a light bulb over a low-power, 802.15.4 Thread network. It +is capable of being paired into an existing Project CHIP network along with +other Project CHIP-enabled devices. + +The example targets the +[NXP K32W061 DK6](https://www.nxp.com/products/wireless/thread/k32w061-41-high-performance-secure-and-ultra-low-power-mcu-for-zigbeethread-and-bluetooth-le-5-0-with-built-in-nfc-option:K32W061_41) +development kit, but is readily adaptable to other K32W-based hardware. + +The CHIP device that runs the lighting application is controlled by the CHIP +controller device over the Thread protocol. By default, the CHIP device has +Thread disabled, and it should be paired over Bluetooth LE with the CHIP +controller and obtain configuration from it. The actions required before +establishing full communication are described below. + +The example also comes with a test mode, which allows to start Thread with the +default settings by pressing a button. However, this mode does not guarantee +that the device will be able to communicate with the CHIP controller and other +devices. + +### Bluetooth LE Advertising + +In this example, to commission the device onto a Project CHIP network, it must +be discoverable over Bluetooth LE. Bluetooth LE advertising is started +automatically when the device is powered up. + +### Bluetooth LE Rendezvous + +In this example, the commissioning procedure (called rendezvous) is done over +Bluetooth LE between a CHIP device and the CHIP controller, where the controller +has the commissioner role. + +To start the rendezvous, the controller must get the commissioning information +from the CHIP device. The data payload is encoded within a QR code, printed to +the UART console. + +### Thread Provisioning + +Last part of the rendezvous procedure, the provisioning operation involves +sending the Thread network credentials from the CHIP controller to the CHIP +device. As a result, device is able to join the Thread network and communicate +with other Thread devices in the network. + +## Device UI + +The example application provides a simple UI that depicts the state of the +device and offers basic user control. This UI is implemented via the +general-purpose LEDs and buttons built in to the OM15082 Expansion board +attached to the DK6 board. + +**LED D2** shows the overall state of the device and its connectivity. Four +states are depicted: + +- _Short Flash On (50ms on/950ms off)_ — The device is in an + unprovisioned (unpaired) state and is waiting for a commissioning + application to connect. + +* _Rapid Even Flashing (100ms on/100ms off)_ — The device is in an + unprovisioned state and a commissioning application is connected via BLE. + +- _Short Flash Off (950ms on/50ms off)_ — The device is full + provisioned, but does not yet have full network (Thread) or service + connectivity. + +* _Solid On_ — The device is fully provisioned and has full network and + service connectivity. + +**LED D3** shows the state of the simulated light bulb. When the LED is lit the +light bulb is on; when not lit, the light bulb is off. + +**Button SW2** can be used to change the state of the simulated light bulb. This +can be used to mimic a user manually operating a switch. The button behaves as a +toggle, swapping the state every time it is pressed. + +**Button SW3** can be used to reset the device to a default state. Pressing and +holding Button SW3 for 6 seconds initiates a factory reset. After an initial +period of 3 seconds, LED2 D2 and D3 will flash in unison to signal the pending +reset. Holding the button past 6 seconds will cause the device to reset its +persistent configuration and initiate a reboot. The reset action can be +cancelled by releasing the button at any point before the 6 second limit. + +**Button SW4** can be used for joining a predefined Thread network advertised by +a Border Router. Default parameters for a Thread network are hard-coded and are +being used if this button is pressed. + +The remaining two LEDs (D1/D2) and button (SW1) are unused. + + + +## Building + +In order to build the Project CHIP example, we recommend using a Linux +distribution (the demo-application was compiled on Ubuntu 20.04). + +- Download [K32W061 SDK 2.6.2 for Project CHIP](https://mcuxpresso.nxp.com/). + Creating an nxp.com account is required before being able to download the + SDK. Once the account is created, login and follow the steps for downloading + SDK_2.6.2_K32W061DK6. The SDK Builder UI selection should be similar with + the one from the image below. + ![MCUXpresso SDK Download](../../platform/k32w/doc/images/mcux-sdk-download.JPG) + +- Start building the application + +``` +user@ubuntu:~/Desktop/git/connectedhomeip$ export K32W061_SDK_ROOT=/home/user/Desktop/SDK_2.6.2_K32W061DK6/ +user@ubuntu:~/Desktop/git/connectedhomeip$ ./third_party/k32w_sdk/mr2_fixes/patch_k32w_mr2_sdk.sh +user@ubuntu:~/Desktop/git/connectedhomeip$ source ./scripts/activate.sh +user@ubuntu:~/Desktop/git/connectedhomeip/third_party/openthread/repo$ cd examples/lighting-app/k32w/ +user@ubuntu:~/Desktop/git/connectedhomeip/examples/lighting-app/k32w$ gn gen out/debug --args="k32w_sdk_root=\"${K32W061_SDK_ROOT}\" is_debug=true" +user@ubuntu:~/Desktop/git/connectedhomeip/examples/lightin-app/k32w$ ninja -C out/debug +user@ubuntu:~/Desktop/git/connectedhomeip/examples/lighting-app/k32w$ $K32W061_SDK_ROOT/tools/imagetool/sign_images.sh out/debug/ +``` + +Note that "patch_k32w_mr2_sdk.sh" script must be run for patching the K32W061 +SDK 2.6.2. + +In case signing errors are encountered when running the "sign_images.sh" script +install the recommanded packages (python version > 3, pip3, pycrypto, +pycryptodome): + +``` +user@ubuntu:~$ python3 --version +Python 3.8.2 +user@ubuntu:~$ pip3 --version +pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8) +user@ubuntu:~$ pip3 list | grep -i pycrypto +pycrypto 2.6.1 +pycryptodome 3.9.8 +``` + +The resulting output file can be found in out/debug/chip-k32w061-light-example. + + + +## Flashing and debugging + +Program the firmware using the official +[OpenThread Flash Instructions](https://github.com/openthread/openthread/blob/master/examples/platforms/k32w/k32w061/README.md#flash-binaries). + +All you have to do is to replace the Openthread binaries from the above +documentation with _out/debug/chip-k32w061-light-example.bin_ if DK6Programmer +is used or with _out/debug/chip-k32w061-light-example_ if MCUXpresso is used. + +## Testing the example + +The app can be deployed against any generic OpenThread Border Router. See the +guide +[Commissioning NXP K32W using Android CHIPTool](../../../docs/guides/nxp_k32w_android_commissioning.md) +for step-by-step instructions. diff --git a/examples/lighting-app/k32w/args.gni b/examples/lighting-app/k32w/args.gni new file mode 100644 index 00000000000000..0644c7a12cc68d --- /dev/null +++ b/examples/lighting-app/k32w/args.gni @@ -0,0 +1,19 @@ +# Copyright (c) 2020 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/chip.gni") +import("${chip_root}/examples/platform/k32w/args.gni") + +# SDK target. This is overriden to add our SDK app_config.h & defines. +k32w_sdk_target = get_label_info(":sdk", "label_no_toolchain") diff --git a/examples/lighting-app/k32w/build_overrides b/examples/lighting-app/k32w/build_overrides new file mode 120000 index 00000000000000..194ee0b812dc3d --- /dev/null +++ b/examples/lighting-app/k32w/build_overrides @@ -0,0 +1 @@ +../../build_overrides/ \ No newline at end of file diff --git a/examples/lighting-app/k32w/data.bin b/examples/lighting-app/k32w/data.bin new file mode 100644 index 0000000000000000000000000000000000000000..a7e527741c54078d1e4e5aa633ac3b0a2a4df2cd GIT binary patch literal 4652 zcmeIuu?+wq3t6l7qw328NnZi` literal 0 HcmV?d00001 diff --git a/examples/lighting-app/k32w/main/AppTask.cpp b/examples/lighting-app/k32w/main/AppTask.cpp new file mode 100644 index 00000000000000..5b736050723c60 --- /dev/null +++ b/examples/lighting-app/k32w/main/AppTask.cpp @@ -0,0 +1,561 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2021 Google LLC. + * 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 "AppTask.h" +#include "AppEvent.h" +#include "Server.h" +#include "support/ErrorStr.h" + +#include "QRCodeUtil.h" +#include +#include + +#include "attribute-storage.h" +#include "gen/attribute-id.h" +#include "gen/attribute-type.h" +#include "gen/cluster-id.h" + +#include "Keyboard.h" +#include "LED.h" +#include "LEDWidget.h" +#include "TimersManager.h" +#include "app_config.h" + +#define FACTORY_RESET_TRIGGER_TIMEOUT 6000 +#define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000 +#define APP_TASK_STACK_SIZE (4096) +#define APP_TASK_PRIORITY 2 +#define APP_EVENT_QUEUE_SIZE 10 + +TimerHandle_t sFunctionTimer; // FreeRTOS app sw timer. + +static QueueHandle_t sAppEventQueue; + +static LEDWidget sStatusLED; +static LEDWidget sLightLED; + +static bool sIsThreadProvisioned = false; +static bool sIsThreadEnabled = false; +static bool sHaveBLEConnections = false; +static bool sHaveServiceConnectivity = false; + +static uint32_t eventMask = 0; + +using namespace ::chip::DeviceLayer; + +AppTask AppTask::sAppTask; + +int AppTask::StartAppTask() +{ + int err = CHIP_NO_ERROR; + + sAppEventQueue = xQueueCreate(APP_EVENT_QUEUE_SIZE, sizeof(AppEvent)); + if (sAppEventQueue == NULL) + { + err = CHIP_ERROR_MAX; + K32W_LOG("Failed to allocate app event queue"); + assert(err == CHIP_NO_ERROR); + } + + return err; +} + +int AppTask::Init() +{ + CHIP_ERROR err = CHIP_NO_ERROR; + + // Init ZCL Data Model and start server + InitServer(); + + // QR code will be used with CHIP Tool + PrintQRCode(chip::RendezvousInformationFlags::kBLE); + + TMR_Init(); + + /* HW init leds */ + LED_Init(); + + /* start with all LEDS turnedd off */ + sStatusLED.Init(SYSTEM_STATE_LED); + + sLightLED.Init(LIGHT_STATE_LED); + sLightLED.Set(LightingMgr().IsTurnedOff()); + + /* intialize the Keyboard and button press calback */ + KBD_Init(KBD_Callback); + + // Create FreeRTOS sw timer for Function Selection. + sFunctionTimer = xTimerCreate("FnTmr", // Just a text name, not used by the RTOS kernel + 1, // == default timer period (mS) + false, // no timer reload (==one-shot) + (void *) this, // init timer id = app task obj context + TimerEventHandler // timer callback handler + ); + if (sFunctionTimer == NULL) + { + K32W_LOG("app_timer_create() failed"); + assert(err == CHIP_NO_ERROR); + } + + err = LightingMgr().Init(); + if (err != CHIP_NO_ERROR) + { + K32W_LOG("LightingMgr().Init() failed"); + assert(err == CHIP_NO_ERROR); + } + + LightingMgr().SetCallbacks(ActionInitiated, ActionCompleted); + + // Print the current software version + char currentFirmwareRev[ConfigurationManager::kMaxFirmwareRevisionLength + 1] = { 0 }; + size_t currentFirmwareRevLen; + err = ConfigurationMgr().GetFirmwareRevision(currentFirmwareRev, sizeof(currentFirmwareRev), currentFirmwareRevLen); + if (err != CHIP_NO_ERROR) + { + K32W_LOG("Get version error"); + assert(err == CHIP_NO_ERROR); + } + + K32W_LOG("Current Firmware Version: %s", currentFirmwareRev); + + return err; +} + +void AppTask::AppTaskMain(void * pvParameter) +{ + int err; + AppEvent event; + + err = sAppTask.Init(); + if (err != CHIP_NO_ERROR) + { + K32W_LOG("AppTask.Init() failed"); + assert(err == CHIP_NO_ERROR); + } + + while (true) + { + BaseType_t eventReceived = xQueueReceive(sAppEventQueue, &event, pdMS_TO_TICKS(10)); + while (eventReceived == pdTRUE) + { + sAppTask.DispatchEvent(&event); + eventReceived = xQueueReceive(sAppEventQueue, &event, 0); + } + + // Collect connectivity and configuration state from the CHIP stack. Because the + // CHIP event loop is being run in a separate task, the stack must be locked + // while these values are queried. However we use a non-blocking lock request + // (TryLockChipStack()) to avoid blocking other UI activities when the CHIP + // task is busy (e.g. with a long crypto operation). + if (PlatformMgr().TryLockChipStack()) + { + sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned(); + sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled(); + sHaveBLEConnections = (ConnectivityMgr().NumBLEConnections() != 0); + sHaveServiceConnectivity = ConnectivityMgr().HaveServiceConnectivity(); + PlatformMgr().UnlockChipStack(); + } + + // Update the status LED if factory reset has not been initiated. + // + // If system has "full connectivity", keep the LED On constantly. + // + // If thread and service provisioned, but not attached to the thread network yet OR no + // connectivity to the service OR subscriptions are not fully established + // THEN blink the LED Off for a short period of time. + // + // If the system has ble connection(s) uptill the stage above, THEN blink the LEDs at an even + // rate of 100ms. + // + // Otherwise, blink the LED ON for a very short time. + if (sAppTask.mFunction != kFunction_FactoryReset) + { + if (sHaveServiceConnectivity) + { + sStatusLED.Set(true); + } + else if (sIsThreadProvisioned && sIsThreadEnabled) + { + sStatusLED.Blink(950, 50); + } + else if (sHaveBLEConnections) + { + sStatusLED.Blink(100, 100); + } + else + { + sStatusLED.Blink(50, 950); + } + } + + sStatusLED.Animate(); + sLightLED.Animate(); + + HandleKeyboard(); + } +} + +void AppTask::ButtonEventHandler(uint8_t pin_no, uint8_t button_action) +{ + if ((pin_no != RESET_BUTTON) && (pin_no != LIGHT_BUTTON) && (pin_no != JOIN_BUTTON)) + { + return; + } + + AppEvent button_event; + button_event.Type = AppEvent::kEventType_Button; + button_event.ButtonEvent.PinNo = pin_no; + button_event.ButtonEvent.Action = button_action; + + if (pin_no == RESET_BUTTON) + { + button_event.Handler = ResetActionEventHandler; + } + else if (pin_no == LIGHT_BUTTON) + { + button_event.Handler = LightActionEventHandler; + } + else if (pin_no == JOIN_BUTTON) + { + button_event.Handler = JoinHandler; + } + + sAppTask.PostEvent(&button_event); +} + +void AppTask::KBD_Callback(uint8_t events) +{ + eventMask = eventMask | (uint32_t)(1 << events); +} + +void AppTask::HandleKeyboard(void) +{ + uint8_t keyEvent = 0xFF; + uint8_t pos = 0; + + while (eventMask) + { + for (pos = 0; pos < (8 * sizeof(eventMask)); pos++) + { + if (eventMask & (1 << pos)) + { + keyEvent = pos; + eventMask = eventMask & ~(1 << pos); + break; + } + } + + switch (keyEvent) + { + case gKBD_EventPB1_c: + ButtonEventHandler(RESET_BUTTON, RESET_BUTTON_PUSH); + break; + case gKBD_EventPB2_c: + ButtonEventHandler(LIGHT_BUTTON, LIGHT_BUTTON_PUSH); + break; + case gKBD_EventPB3_c: + ButtonEventHandler(JOIN_BUTTON, JOIN_BUTTON_PUSH); + break; + default: + break; + } + } +} + +void AppTask::TimerEventHandler(TimerHandle_t xTimer) +{ + AppEvent event; + event.Type = AppEvent::kEventType_Timer; + event.TimerEvent.Context = (void *) xTimer; + event.Handler = FunctionTimerEventHandler; + sAppTask.PostEvent(&event); +} + +void AppTask::FunctionTimerEventHandler(AppEvent * aEvent) +{ + if (aEvent->Type != AppEvent::kEventType_Timer) + return; + + K32W_LOG("Device will factory reset..."); + + // Actually trigger Factory Reset + ConfigurationMgr().InitiateFactoryReset(); +} + +void AppTask::ResetActionEventHandler(AppEvent * aEvent) +{ + if (aEvent->ButtonEvent.PinNo != RESET_BUTTON) + return; + + if (sAppTask.mResetTimerActive) + { + sAppTask.CancelTimer(); + sAppTask.mFunction = kFunction_NoneSelected; + + /* restore initial state for the LED indicating Lighting state */ + if (LightingMgr().IsTurnedOff()) + { + sLightLED.Set(false); + } + else + { + sLightLED.Set(true); + } + + K32W_LOG("Factory Reset was cancelled!"); + } + else + { + uint32_t resetTimeout = FACTORY_RESET_TRIGGER_TIMEOUT; + + if (sAppTask.mFunction != kFunction_NoneSelected) + { + K32W_LOG("Another function is scheduled. Could not initiate Factory Reset!"); + return; + } + + K32W_LOG("Factory Reset Triggered. Push the RESET button within %u ms to cancel!", resetTimeout); + sAppTask.mFunction = kFunction_FactoryReset; + + /* LEDs will start blinking to signal that a Factory Reset was scheduled */ + sStatusLED.Set(false); + sLightLED.Set(false); + + sStatusLED.Blink(500); + sLightLED.Blink(500); + + sAppTask.StartTimer(FACTORY_RESET_TRIGGER_TIMEOUT); + } +} + +void AppTask::LightActionEventHandler(AppEvent * aEvent) +{ + LightingManager::Action_t action; + int err = CHIP_NO_ERROR; + int32_t actor = 0; + bool initiated = false; + + if (sAppTask.mFunction != kFunction_NoneSelected) + { + K32W_LOG("Another function is scheduled. Could not initiate ON/OFF Light command!"); + return; + } + + if (aEvent->Type == AppEvent::kEventType_TurnOn) + { + action = static_cast(aEvent->LightEvent.Action); + actor = aEvent->LightEvent.Actor; + } + else if (aEvent->Type == AppEvent::kEventType_Button) + { + if (LightingMgr().IsTurnedOff()) + { + action = LightingManager::TURNON_ACTION; + } + else + { + action = LightingManager::TURNOFF_ACTION; + } + } + else + { + err = CHIP_ERROR_MAX; + } + + if (err == CHIP_NO_ERROR) + { + initiated = LightingMgr().InitiateAction(actor, action); + + if (!initiated) + { + K32W_LOG("Action is already in progress or active."); + } + } +} + +void AppTask::ThreadStart() +{ + chip::DeviceLayer::Internal::DeviceNetworkInfo networkInfo; + + memset(networkInfo.ThreadNetworkName, 0, chip::DeviceLayer::Internal::kMaxThreadNetworkNameLength + 1); + memcpy(networkInfo.ThreadNetworkName, "OpenThread", 10); + + networkInfo.ThreadExtendedPANId[0] = 0xde; + networkInfo.ThreadExtendedPANId[1] = 0xad; + networkInfo.ThreadExtendedPANId[2] = 0x00; + networkInfo.ThreadExtendedPANId[3] = 0xbe; + networkInfo.ThreadExtendedPANId[4] = 0xef; + networkInfo.ThreadExtendedPANId[5] = 0x00; + networkInfo.ThreadExtendedPANId[6] = 0xca; + networkInfo.ThreadExtendedPANId[7] = 0xfe; + + networkInfo.ThreadMasterKey[0] = 0x00; + networkInfo.ThreadMasterKey[1] = 0x11; + networkInfo.ThreadMasterKey[2] = 0x22; + networkInfo.ThreadMasterKey[3] = 0x33; + networkInfo.ThreadMasterKey[4] = 0x44; + networkInfo.ThreadMasterKey[5] = 0x55; + networkInfo.ThreadMasterKey[6] = 0x66; + networkInfo.ThreadMasterKey[7] = 0x77; + networkInfo.ThreadMasterKey[8] = 0x88; + networkInfo.ThreadMasterKey[9] = 0x99; + networkInfo.ThreadMasterKey[10] = 0xAA; + networkInfo.ThreadMasterKey[11] = 0xBB; + networkInfo.ThreadMasterKey[12] = 0xCC; + networkInfo.ThreadMasterKey[13] = 0xDD; + networkInfo.ThreadMasterKey[14] = 0xEE; + networkInfo.ThreadMasterKey[15] = 0xFF; + + networkInfo.ThreadPANId = 0xabcd; + networkInfo.ThreadChannel = 15; + + networkInfo.FieldPresent.ThreadExtendedPANId = true; + networkInfo.FieldPresent.ThreadMeshPrefix = false; + networkInfo.FieldPresent.ThreadPSKc = false; + networkInfo.NetworkId = 0; + networkInfo.FieldPresent.NetworkId = true; + + ThreadStackMgr().SetThreadEnabled(false); + ThreadStackMgr().SetThreadProvision(networkInfo); + ThreadStackMgr().SetThreadEnabled(true); +} + +void AppTask::JoinHandler(AppEvent * aEvent) +{ + if (aEvent->ButtonEvent.PinNo != JOIN_BUTTON) + return; + + if (sAppTask.mFunction != kFunction_NoneSelected) + { + K32W_LOG("Another function is scheduled. Could not initiate Thread Join!"); + return; + } + + /* hard-code Thread Commissioning Parameters for the moment. + * In a future PR, these parameters will be sent via BLE. + */ + ThreadStart(); +} + +void AppTask::CancelTimer() +{ + if (xTimerStop(sFunctionTimer, 0) == pdFAIL) + { + K32W_LOG("app timer stop() failed"); + } + + mResetTimerActive = false; +} + +void AppTask::StartTimer(uint32_t aTimeoutInMs) +{ + if (xTimerIsTimerActive(sFunctionTimer)) + { + K32W_LOG("app timer already started!"); + CancelTimer(); + } + + // timer is not active, change its period to required value (== restart). + // FreeRTOS- Block for a maximum of 100 ticks if the change period command + // cannot immediately be sent to the timer command queue. + if (xTimerChangePeriod(sFunctionTimer, aTimeoutInMs / portTICK_PERIOD_MS, 100) != pdPASS) + { + K32W_LOG("app timer start() failed"); + } + + mResetTimerActive = true; +} + +void AppTask::ActionInitiated(LightingManager::Action_t aAction, int32_t aActor) +{ + // start flashing the LEDs rapidly to indicate action initiation. + if (aAction == LightingManager::TURNON_ACTION) + { + K32W_LOG("Turn on Action has been initiated") + } + else if (aAction == LightingManager::TURNOFF_ACTION) + { + K32W_LOG("Turn off Action has been initiated") + } + + sAppTask.mFunction = kFunctionTurnOnTurnOff; +} + +void AppTask::ActionCompleted(LightingManager::Action_t aAction) +{ + // Turn on the light LED if in a TURNON state OR + // Turn off the light LED if in a TURNOFF state. + if (aAction == LightingManager::TURNON_ACTION) + { + K32W_LOG("Turn on action has been completed") + sLightLED.Set(true); + } + else if (aAction == LightingManager::TURNOFF_ACTION) + { + K32W_LOG("Turn off action has been completed") + sLightLED.Set(false); + } + + sAppTask.mFunction = kFunction_NoneSelected; +} + +void AppTask::PostTurnOnActionRequest(int32_t aActor, LightingManager::Action_t aAction) +{ + AppEvent event; + event.Type = AppEvent::kEventType_TurnOn; + event.LightEvent.Actor = aActor; + event.LightEvent.Action = aAction; + event.Handler = LightActionEventHandler; + PostEvent(&event); +} + +void AppTask::PostEvent(const AppEvent * aEvent) +{ + if (sAppEventQueue != NULL) + { + if (!xQueueSend(sAppEventQueue, aEvent, 1)) + { + K32W_LOG("Failed to post event to app task event queue"); + } + } +} + +void AppTask::DispatchEvent(AppEvent * aEvent) +{ + if (aEvent->Handler) + { + aEvent->Handler(aEvent); + } + else + { + K32W_LOG("Event received with no handler. Dropping event."); + } +} + +void AppTask::UpdateClusterState(void) +{ + uint8_t newValue = !LightingMgr().IsTurnedOff(); + + // write the new on/off value + EmberAfStatus status = emberAfWriteAttribute(1, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID, CLUSTER_MASK_SERVER, + (uint8_t *) &newValue, ZCL_BOOLEAN_ATTRIBUTE_TYPE); + if (status != EMBER_ZCL_STATUS_SUCCESS) + { + ChipLogError(NotSpecified, "ERR: updating on/off %x", status); + } +} diff --git a/examples/lighting-app/k32w/main/LightingManager.cpp b/examples/lighting-app/k32w/main/LightingManager.cpp new file mode 100644 index 00000000000000..5cfca552007ba5 --- /dev/null +++ b/examples/lighting-app/k32w/main/LightingManager.cpp @@ -0,0 +1,233 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2019 Google LLC. + * 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 "LightingManager.h" + +#include "AppTask.h" +#include "FreeRTOS.h" + +#include "app_config.h" + +LightingManager LightingManager::sLight; + +TimerHandle_t sLightTimer; // FreeRTOS app sw timer. + +int LightingManager::Init() +{ + int err = CHIP_NO_ERROR; + + // Create FreeRTOS sw timer for light timer. + + sLightTimer = xTimerCreate("LightTmr", // Just a text name, not used by the RTOS kernel + 1, // == default timer period (mS) + false, // no timer reload (==one-shot) + (void *) this, // init timer id = light obj context + TimerEventHandler // timer callback handler + ); + + if (sLightTimer == NULL) + { + K32W_LOG("light timer create failed"); + assert(0); + } + + mState = kState_TurnOffCompleted; + mAutoTurnOnTimerArmed = false; + mAutoTurnOn = false; + mAutoTurnOnDuration = 0; + + return err; +} + +void LightingManager::SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB) +{ + mActionInitiated_CB = aActionInitiated_CB; + mActionCompleted_CB = aActionCompleted_CB; +} + +bool LightingManager::IsActionInProgress() +{ + return (mState == kState_TurnOnInitiated || mState == kState_TurnOffInitiated) ? true : false; +} + +bool LightingManager::IsTurnedOff() +{ + return (mState == kState_TurnOffCompleted) ? true : false; +} + +void LightingManager::EnableAutoTurnOn(bool aOn) +{ + mAutoTurnOn = aOn; +} + +void LightingManager::SetAutoTurnOnDuration(uint32_t aDurationInSecs) +{ + mAutoTurnOnDuration = aDurationInSecs; +} + +bool LightingManager::InitiateAction(int32_t aActor, Action_t aAction) +{ + bool action_initiated = false; + State_t new_state; + + // Initiate ON/OFF Action only when the previous one is complete. + if (mState == kState_TurnOnCompleted && aAction == TURNOFF_ACTION) + { + action_initiated = true; + + new_state = kState_TurnOffInitiated; + } + else if (mState == kState_TurnOffCompleted && aAction == TURNON_ACTION) + { + action_initiated = true; + + new_state = kState_TurnOnInitiated; + } + + if (action_initiated) + { + if (mAutoTurnOnTimerArmed && new_state == kState_TurnOnInitiated) + { + // If auto turnon timer has been armed and someone initiates turn on the ligth, + // cancel the timer and continue as normal. + mAutoTurnOnTimerArmed = false; + + CancelTimer(); + } + + StartTimer(ACTUATOR_MOVEMENT_PERIOS_MS); + + // Since the timer started successfully, update the state and trigger callback + mState = new_state; + + if (mActionInitiated_CB) + { + mActionInitiated_CB(aAction, aActor); + } + } + + return action_initiated; +} + +void LightingManager::StartTimer(uint32_t aTimeoutMs) +{ + if (xTimerIsTimerActive(sLightTimer)) + { + K32W_LOG("light timer already started!"); + // appError(err); + CancelTimer(); + } + + // timer is not active, change its period to required value. + // This also causes the timer to start. FreeRTOS- Block for a maximum of + // 100 ticks if the change period command cannot immediately be sent to the + // timer command queue. + if (xTimerChangePeriod(sLightTimer, aTimeoutMs / portTICK_PERIOD_MS, 100) != pdPASS) + { + K32W_LOG("light timer start() failed"); + // appError(err); + } +} + +void LightingManager::CancelTimer(void) +{ + if (xTimerStop(sLightTimer, 0) == pdFAIL) + { + K32W_LOG("light timer stop() failed"); + // appError(err); + } +} + +void LightingManager::TimerEventHandler(TimerHandle_t xTimer) +{ + // Get light obj context from timer id. + LightingManager * light = static_cast(pvTimerGetTimerID(xTimer)); + + // The timer event handler will be called in the context of the timer task + // once sLightTimer expires. Post an event to apptask queue with the actual handler + // so that the event can be handled in the context of the apptask. + AppEvent event; + event.Type = AppEvent::kEventType_Timer; + event.TimerEvent.Context = light; + + if (light->mAutoTurnOnTimerArmed) + { + event.Handler = AutoReTurnOnTimerEventHandler; + GetAppTask().PostEvent(&event); + } + else + { + event.Handler = ActuatorMovementTimerEventHandler; + GetAppTask().PostEvent(&event); + } +} + +void LightingManager::AutoReTurnOnTimerEventHandler(AppEvent * aEvent) +{ + LightingManager * light = static_cast(aEvent->TimerEvent.Context); + int32_t actor = 0; + + // Make sure auto light timer is still armed. + if (!light->mAutoTurnOnTimerArmed) + { + return; + } + + light->mAutoTurnOnTimerArmed = false; + + K32W_LOG("Auto Turn On has been triggered!"); + + light->InitiateAction(actor, TURNON_ACTION); +} + +void LightingManager::ActuatorMovementTimerEventHandler(AppEvent * aEvent) +{ + Action_t actionCompleted = INVALID_ACTION; + + LightingManager * light = static_cast(aEvent->TimerEvent.Context); + + if (light->mState == kState_TurnOnInitiated) + { + light->mState = kState_TurnOnCompleted; + actionCompleted = TURNON_ACTION; + } + else if (light->mState == kState_TurnOffInitiated) + { + light->mState = kState_TurnOffCompleted; + actionCompleted = TURNOFF_ACTION; + } + + if (actionCompleted != INVALID_ACTION) + { + if (light->mActionCompleted_CB) + { + light->mActionCompleted_CB(actionCompleted); + } + + if (light->mAutoTurnOn && actionCompleted == TURNOFF_ACTION) + { + // Start the timer for auto turn on + light->StartTimer(light->mAutoTurnOnDuration * 1000); + + light->mAutoTurnOnTimerArmed = true; + + K32W_LOG("Auto Turn On enabled. Will be triggered in %u seconds", light->mAutoTurnOnDuration); + } + } +} diff --git a/examples/lighting-app/k32w/main/ZclCallbacks.cpp b/examples/lighting-app/k32w/main/ZclCallbacks.cpp new file mode 100644 index 00000000000000..a0896a6a390101 --- /dev/null +++ b/examples/lighting-app/k32w/main/ZclCallbacks.cpp @@ -0,0 +1,67 @@ +/* + * + * Copyright (c) 2021 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 + +#include "AppTask.h" +#include "LightingManager.h" + +#include "af.h" +#include "gen/attribute-id.h" +#include "gen/cluster-id.h" +#include + +using namespace ::chip; + +void emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t mask, + uint16_t manufacturerCode, uint8_t type, uint8_t size, uint8_t * value) +{ + if (clusterId != ZCL_ON_OFF_CLUSTER_ID) + { + ChipLogProgress(Zcl, "Unknown cluster ID: %d", clusterId); + return; + } + + if (attributeId != ZCL_ON_OFF_ATTRIBUTE_ID) + { + ChipLogProgress(Zcl, "Unknown attribute ID: %d", attributeId); + return; + } + + LightingMgr().InitiateAction(0, *value ? LightingManager::TURNON_ACTION : LightingManager::TURNOFF_ACTION); +} + +/** @brief OnOff Cluster Init + * + * This function is called when a specific cluster is initialized. It gives the + * application an opportunity to take care of cluster initialization procedures. + * It is called exactly once for each endpoint where cluster is present. + * + * @param endpoint Ver.: always + * + * TODO Issue #3841 + * emberAfOnOffClusterInitCallback happens before the stack initialize the cluster + * attributes to the default value. + * The logic here expects something similar to the deprecated Plugins callback + * emberAfPluginOnOffClusterServerPostInitCallback. + * + */ +void emberAfOnOffClusterInitCallback(EndpointId endpoint) +{ + GetAppTask().UpdateClusterState(); +} diff --git a/examples/lighting-app/k32w/main/include/AppEvent.h b/examples/lighting-app/k32w/main/include/AppEvent.h new file mode 100644 index 00000000000000..820d44bc68e98f --- /dev/null +++ b/examples/lighting-app/k32w/main/include/AppEvent.h @@ -0,0 +1,55 @@ +/* + * + * Copyright (c) 2021 Nest Labs, Inc. + * 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 + +struct AppEvent; +typedef void (*EventHandler)(AppEvent *); + +struct AppEvent +{ + enum AppEventTypes + { + kEventType_Button = 0, + kEventType_Timer, + kEventType_TurnOn, + kEventType_Install, + }; + + uint16_t Type; + + union + { + struct + { + uint8_t PinNo; + uint8_t Action; + } ButtonEvent; + struct + { + void * Context; + } TimerEvent; + struct + { + uint8_t Action; + int32_t Actor; + } LightEvent; + }; + + EventHandler Handler; +}; diff --git a/examples/lighting-app/k32w/main/include/AppTask.h b/examples/lighting-app/k32w/main/include/AppTask.h new file mode 100644 index 00000000000000..98f2c124b08a7b --- /dev/null +++ b/examples/lighting-app/k32w/main/include/AppTask.h @@ -0,0 +1,88 @@ +/* + * + * Copyright (c) 2021 Google LLC. + * 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 +#include + +#include "AppEvent.h" +#include "LightingManager.h" + +#include + +#include "FreeRTOS.h" +#include "timers.h" + +class AppTask +{ +public: + int StartAppTask(); + static void AppTaskMain(void * pvParameter); + + void PostTurnOnActionRequest(int32_t aActor, LightingManager::Action_t aAction); + void PostEvent(const AppEvent * event); + + void UpdateClusterState(void); + +private: + friend AppTask & GetAppTask(void); + + int Init(); + + static void ActionInitiated(LightingManager::Action_t aAction, int32_t aActor); + static void ActionCompleted(LightingManager::Action_t aAction); + + void CancelTimer(void); + + void DispatchEvent(AppEvent * event); + + static void FunctionTimerEventHandler(AppEvent * aEvent); + static void KBD_Callback(uint8_t events); + static void HandleKeyboard(void); + static void JoinHandler(AppEvent * aEvent); + static void LightActionEventHandler(AppEvent * aEvent); + static void ResetActionEventHandler(AppEvent * aEvent); + static void InstallEventHandler(AppEvent * aEvent); + + static void ButtonEventHandler(uint8_t pin_no, uint8_t button_action); + static void TimerEventHandler(TimerHandle_t xTimer); + + static void ThreadStart(); + void StartTimer(uint32_t aTimeoutInMs); + + enum Function_t + { + kFunction_NoneSelected = 0, + kFunction_SoftwareUpdate = 0, + kFunction_FactoryReset, + kFunctionTurnOnTurnOff, + + kFunction_Invalid + } Function; + + Function_t mFunction; + bool mResetTimerActive; + + static AppTask sAppTask; +}; + +inline AppTask & GetAppTask(void) +{ + return AppTask::sAppTask; +} diff --git a/examples/lighting-app/k32w/main/include/LightingManager.h b/examples/lighting-app/k32w/main/include/LightingManager.h new file mode 100644 index 00000000000000..19f6699071ba6d --- /dev/null +++ b/examples/lighting-app/k32w/main/include/LightingManager.h @@ -0,0 +1,83 @@ +/* + * + * Copyright (c) 2021 Google LLC. + * 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 +#include + +#include "AppEvent.h" + +#include "FreeRTOS.h" +#include "timers.h" // provides FreeRTOS timer support + +class LightingManager +{ +public: + enum Action_t + { + TURNON_ACTION = 0, + TURNOFF_ACTION, + + INVALID_ACTION + } Action; + + enum State_t + { + kState_TurnOnInitiated = 0, + kState_TurnOnCompleted, + kState_TurnOffInitiated, + kState_TurnOffCompleted, + } State; + + int Init(); + bool IsTurnedOff(); + void EnableAutoTurnOn(bool aOn); + void SetAutoTurnOnDuration(uint32_t aDurationInSecs); + bool IsActionInProgress(); + bool InitiateAction(int32_t aActor, Action_t aAction); + + typedef void (*Callback_fn_initiated)(Action_t, int32_t aActor); + typedef void (*Callback_fn_completed)(Action_t); + void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); + +private: + friend LightingManager & LightingMgr(void); + State_t mState; + + Callback_fn_initiated mActionInitiated_CB; + Callback_fn_completed mActionCompleted_CB; + + bool mAutoTurnOn; + uint32_t mAutoTurnOnDuration; + bool mAutoTurnOnTimerArmed; + + void CancelTimer(void); + void StartTimer(uint32_t aTimeoutMs); + + static void TimerEventHandler(TimerHandle_t xTimer); + static void AutoReTurnOnTimerEventHandler(AppEvent * aEvent); + static void ActuatorMovementTimerEventHandler(AppEvent * aEvent); + + static LightingManager sLight; +}; + +inline LightingManager & LightingMgr(void) +{ + return LightingManager::sLight; +} diff --git a/examples/lighting-app/k32w/main/include/app_config.h b/examples/lighting-app/k32w/main/include/app_config.h new file mode 100644 index 00000000000000..abffcc96c30e98 --- /dev/null +++ b/examples/lighting-app/k32w/main/include/app_config.h @@ -0,0 +1,53 @@ +/* + * + * Copyright (c) 2021 Google LLC. + * 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 "LED.h" + +#pragma once + +// ---- Light Example App Config ---- + +#define RESET_BUTTON 1 +#define LIGHT_BUTTON 2 +#define JOIN_BUTTON 3 + +#define RESET_BUTTON_PUSH 1 +#define LIGHT_BUTTON_PUSH 2 +#define JOIN_BUTTON_PUSH 3 + +#define APP_BUTTON_PUSH 1 + +#define SYSTEM_STATE_LED LED1 +#define LIGHT_STATE_LED LED2 + +// Time it takes for the light to switch on/off +#define ACTUATOR_MOVEMENT_PERIOS_MS 50 + +// ---- Light Example SWU Config ---- +#define SWU_INTERVAl_WINDOW_MIN_MS (23 * 60 * 60 * 1000) // 23 hours +#define SWU_INTERVAl_WINDOW_MAX_MS (24 * 60 * 60 * 1000) // 24 hours + +// ---- Thread Polling Config ---- +#define THREAD_ACTIVE_POLLING_INTERVAL_MS 100 +#define THREAD_INACTIVE_POLLING_INTERVAL_MS 1000 + +#if K32W_LOG_ENABLED +#define K32W_LOG(...) otPlatLog(OT_LOG_LEVEL_NONE, OT_LOG_REGION_API, ##__VA_ARGS__); +#else +#define K32W_LOG(...) +#endif diff --git a/examples/lighting-app/k32w/main/main.cpp b/examples/lighting-app/k32w/main/main.cpp new file mode 100644 index 00000000000000..abdb0429018807 --- /dev/null +++ b/examples/lighting-app/k32w/main/main.cpp @@ -0,0 +1,149 @@ +/* + * + * Copyright (c) 2021 Google LLC. + * 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. + */ + +// ================================================================================ +// Main Code +// ================================================================================ + +#include "openthread/platform/logging.h" +#include "openthread/platform/uart.h" +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "FreeRtosMbedtlsUtils.h" +#include "app_config.h" + +#include "radio.h" + +using namespace ::chip; +using namespace ::chip::Inet; +using namespace ::chip::DeviceLayer; +using namespace ::chip::Logging; + +extern "C" void * pvPortCallocRtos(size_t num, size_t size); + +#include + +typedef void (*InitFunc)(void); +extern InitFunc __init_array_start; +extern InitFunc __init_array_end; + +/* needed for FreeRtos Heap 4 */ +uint8_t __attribute__((section(".heap"))) ucHeap[0xF000]; + +extern "C" void main_task(void const * argument) +{ + CHIP_ERROR ret = CHIP_ERROR_MAX; + + /* Call C++ constructors */ + InitFunc * pFunc = &__init_array_start; + for (; pFunc < &__init_array_end; ++pFunc) + { + (*pFunc)(); + } + + mbedtls_platform_set_calloc_free(pvPortCallocRtos, vPortFree); + + /* Used for HW initializations */ + otSysInit(0, NULL); + + /* UART needs to be enabled so early for getting the Weave Init Logs. + * Otherwise, some logs are lost because the UART gets enabled later + * during the initialization of the Thread stack */ + otPlatUartEnable(); + + K32W_LOG("Welcome to NXP Lighting Demo App"); + + /* Mbedtls Threading support is needed because both + * Thread and Weave tasks are using it */ + freertos_mbedtls_mutex_init(); + + // Init Chip memory management before the stack + chip::Platform::MemoryInit(); + + ret = PlatformMgr().InitChipStack(); + if (ret != CHIP_NO_ERROR) + { + K32W_LOG("Error during PlatformMgr().InitWeaveStack()"); + goto exit; + } + + ret = ThreadStackMgr().InitThreadStack(); + if (ret != CHIP_NO_ERROR) + { + K32W_LOG("Error during ThreadStackMgr().InitThreadStack()"); + goto exit; + } + + ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice); + if (ret != CHIP_NO_ERROR) + { + goto exit; + } + + // Configure the Thread polling behavior for the device. + { + ConnectivityManager::ThreadPollingConfig pollingConfig; + pollingConfig.Clear(); + pollingConfig.ActivePollingIntervalMS = THREAD_ACTIVE_POLLING_INTERVAL_MS; + pollingConfig.InactivePollingIntervalMS = THREAD_INACTIVE_POLLING_INTERVAL_MS; + + ret = ConnectivityMgr().SetThreadPollingConfig(pollingConfig); + if (ret != CHIP_NO_ERROR) + { + K32W_LOG("Error during ConnectivityMgr().SetThreadPollingConfig(pollingConfig)"); + goto exit; + } + } + + ret = PlatformMgr().StartEventLoopTask(); + if (ret != CHIP_NO_ERROR) + { + K32W_LOG("Error during PlatformMgr().StartEventLoopTask();"); + goto exit; + } + + // Start OpenThread task + ret = ThreadStackMgrImpl().StartThreadTask(); + if (ret != CHIP_NO_ERROR) + { + K32W_LOG("Error during ThreadStackMgrImpl().StartThreadTask()"); + goto exit; + } + + ret = GetAppTask().StartAppTask(); + if (ret != CHIP_NO_ERROR) + { + K32W_LOG("Error during GetAppTask().StartAppTask()"); + goto exit; + } + + GetAppTask().AppTaskMain(NULL); + +exit: + return; +} diff --git a/examples/lighting-app/k32w/third_party/connectedhomeip b/examples/lighting-app/k32w/third_party/connectedhomeip new file mode 120000 index 00000000000000..c866b86874994d --- /dev/null +++ b/examples/lighting-app/k32w/third_party/connectedhomeip @@ -0,0 +1 @@ +../../../.. \ No newline at end of file diff --git a/examples/lock-app/k32w/BUILD.gn b/examples/lock-app/k32w/BUILD.gn index f1f749898aba7d..c4097877df62b2 100644 --- a/examples/lock-app/k32w/BUILD.gn +++ b/examples/lock-app/k32w/BUILD.gn @@ -81,7 +81,7 @@ k32w_executable("lock_app") { output_dir = root_out_dir - ldscript = "${k32w_platform_dir}/app/ldscripts/chip-k32w061-lock-example.ld" + ldscript = "${k32w_platform_dir}/app/ldscripts/chip-k32w061-linker.ld" ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ] } diff --git a/examples/lock-app/k32w/main/AppTask.cpp b/examples/lock-app/k32w/main/AppTask.cpp index 670dc3e6d1829c..f5d1cfbb7b83c9 100644 --- a/examples/lock-app/k32w/main/AppTask.cpp +++ b/examples/lock-app/k32w/main/AppTask.cpp @@ -36,11 +36,8 @@ #include "TimersManager.h" #include "app_config.h" -#define FACTORY_RESET_TRIGGER_TIMEOUT 6000 -#define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000 -#define APP_TASK_STACK_SIZE (4096) -#define APP_TASK_PRIORITY 2 -#define APP_EVENT_QUEUE_SIZE 10 +constexpr uint32_t kFactoryResetTriggerTimeout = 6000; +constexpr uint8_t kAppEventQueueSize = 10; TimerHandle_t sFunctionTimer; // FreeRTOS app sw timer. @@ -65,12 +62,11 @@ int AppTask::StartAppTask() { int err = CHIP_NO_ERROR; - sAppEventQueue = xQueueCreate(APP_EVENT_QUEUE_SIZE, sizeof(AppEvent)); + sAppEventQueue = xQueueCreate(kAppEventQueueSize, sizeof(AppEvent)); if (sAppEventQueue == NULL) { - err = CHIP_ERROR_MAX; K32W_LOG("Failed to allocate app event queue"); - assert(err == CHIP_NO_ERROR); + assert(false); } return err; @@ -329,7 +325,7 @@ void AppTask::ResetActionEventHandler(AppEvent * aEvent) } else { - uint32_t resetTimeout = FACTORY_RESET_TRIGGER_TIMEOUT; + uint32_t resetTimeout = kFactoryResetTriggerTimeout; if (sAppTask.mFunction != kFunction_NoneSelected) { @@ -347,7 +343,7 @@ void AppTask::ResetActionEventHandler(AppEvent * aEvent) sStatusLED.Blink(500); sLockLED.Blink(500); - sAppTask.StartTimer(FACTORY_RESET_TRIGGER_TIMEOUT); + sAppTask.StartTimer(kFactoryResetTriggerTimeout); } } diff --git a/examples/platform/k32w/app/ldscripts/chip-k32w061-lock-example.ld b/examples/platform/k32w/app/ldscripts/chip-k32w061-linker.ld similarity index 100% rename from examples/platform/k32w/app/ldscripts/chip-k32w061-lock-example.ld rename to examples/platform/k32w/app/ldscripts/chip-k32w061-linker.ld diff --git a/examples/platform/k32w/doc/images/nxp_hw_connectivity.JPG b/examples/platform/k32w/doc/images/nxp_hw_connectivity.JPG index ad373d4f120527316c2698284a5877412de87d29..80e19b30dfc6efad9b5431c80fc08413a5f35caa 100644 GIT binary patch literal 67243 zcmeFZ1z23omNvQx5G+7Q0>L3jAZT#+;2{JEZoz39cL_9s;1(c2AZT!Rx8N4EvEc4b zrcsu9zOCE%fgjJynhf`S6P zN4@~WGQoXmcaS*%C@BF<003YDXedI!J!I|)@^f{03!fAoZKM? zFp$?CAkRgS2_WA=zG426`+fXI;5P!l5%`V3Zv=iL@P8r#uk0LMSWO&3PR<}BTWVPs z6Ehv*TFJ8sNqR(i5&;N*t{!1Q}g9`v+V*WM%uO0?w`X4C%_AvfW>`T9G{*AzI z1b!p%8-d>l{3`;SFF82`Uvdd@yrkyf7Ubp@03a|ql0T+N3FhPET04Km1 z`ECT*0@Q#k^12CNhCKU&2f=x6>FjJT$j)x-#Aak_XKco1VrRqdZe-8S!S<3J5EgT{ zH!=a6Ia3>(S%7Rs7!Dg-8K^;~A`F^5N-ve{rOYfra-NQ6YMyW2nRtRt1WXykL~*f& z-38rk>}|}Pji}vitZkhH-9>2rQoA5B|Hox^8c|_KQ*%MpS2BMqfjkqT`I|0oZf=gT z5gHd4kg1@#kvWgCsVNVuu@RRkD+hn^~LLnAtizA<^Jqr(yrA(*IpDkr4e|=zj=5(ne$%K`BQwBWJT$$Rzql zbF;qWV&!=G?q9k98waO=F#Dg%3A6tJ#y=?f->dn53N2A#QxidxKXkWq{Hu61Gl&0L zYg>av{{uJsuf`(3`)dX%1=$6$u&{*L|51T|kH}xHAbTM4zQ6ZZ>Q7V@8sHuQ3Mv5#q7$G(#wyW~ z(ak>soPRq|?xCWg-^akj!p1=ssD23CLqSEohlYxdj)n|vqIe^}2ha%6A3fucxc^wi z2!qDq3FpV?3`|+hER$u0t12?B^(;F=P~ zKY~M5js|CbEhy*9+KzpVdHpO>h8hFSMPjCD^#;5eb%*C^2*1~b0D8}cbsx(FG#3@y ziza+;v4qcDt|9=b)C2_JTMju9p_(-$hio~GA%G(ycDQVjSXEit=`r@!wL$1r=D)28 z2C@0zfB-Uv6%oJ>t=22bsC^cO+gk}|Z+7Vqqj%NEJ@6nAb_9T8i~!a=#cEpk5x~f1 zHUd~;F}#hEJ&%73_n~h1&uEc(qlkq7#2)HXDUKR)|9i2ekzz1`ZOA3gQv^UedYAnP z0i*@9MP+Z5CjEP{Q$1AIL_f$esA{Pv3ipGBIp*hJ8q^BK-vTACyp5466-qV+Q%)9V(EmknJxB zV5Sr4t_$_V@qN~oQ!R;^d`Np^RE-x0v*W9SP6@NWQ(JDHO} z0Bmqb1}8S-_ZB_h@6q!nGH&k+GU-EppiZV&wN|#)@DcIZ>;1sGuVso?PvJqXR$1Mx z^*s+_yG>;tx_YBA(3^NJ%|7!OT$?V?Cfc6cFm7F>L*LR=TLb!LEeTS85Hw9uXV1!iIF#~63=&rCwB3O#BeSx`IHgH?^0VYEVO zjFHctW9xDC#py(rd93Wk?5l3&4T0+f{X$aI_C9s-Zz=2)h)(q=-u#q8y>je3 z511u`xJ26HmuJRkR{J(fziphV3d15`uhwO@h(-&p)T1F%8x2&Z^&eC+$=BL(s7kWg zZ=QKJGib-uivpt~wSBCZSPWE3tG7(BaCgd#mlhXI3_Y29T^=aHSqr~=|3QS z6k+nZ3KYMqQsvuLJM`#H;rhW%V}<*$^;zNjz_;)GFnej6@mQIwIFJyP7PFJ8S2hGL zXE??LXW_2bUg%Qbm*;PRa?Po~r~6%x?X0-7mSiM>9nnU6sLg{@Kl*NuoWb%bEy zyPEHx6V(k9q>p91b&rP~9_-g#)1-L*4gthy=R>Bg4DSfgy=;8GTRl;c2L3-unqsSB z#M`NuN3f)tlAmuWq9xOOEJU6_qKpjGb1w&079%qSg92b+eIX^2n}oXejXmYIx;yt7 zQRgj733(SOTAQ<@Zmg@@zzBfIhyD_*S2yP36`avnYt8>~U6}-pay7LIT`;gckgM==%W5HK6?|YNx9#U>=b{bMH`eukI$E7H0KDa?TH8;2C^bPAYhxCE_ znzutJnpXtjp!?GvQi~{I(T3E72F~L3VcX5kfIIxW1ANbI%YXVI;#ZQ70I0o&ua^+O zHC8FbrB{L8r6WJlB?9Oy)RQM-=ph)&%EQ~Gvvs1Ik+z3 zuf;BZJ=(~oZ`AJ|rsI;4f9Ktq-v_|>g`J-_>rq&}&17=njWu*_xJ?O_G5iG674ceX z)G=)6{FoDM;q$p7M(Pd&Vm*N$#3{dW_^24(=$^p2H90_7Bz!vVkt?Fysu!L7UZeez ztdrpK-c-li1#L-6SMaZRS%L5x$-LR&76&NBpkdPyOM`1|)=ug}-t&rI)P5^3e#P0+ zbPF)y>5{BPNzF9U2WL%ao$m56dq8eXMug|z5QDQ^T9W81ws2Ejil=2)7DIQx?+oqdYH8i2>lVg6 z5}-C+Ox6OyHc5t0?u;_Bud^$-Ly7R$e5a=0jaVlqo1 zF0c}!(Tv`w(I+z`xO2xlRYxA=f2&=vrI8d@ld|kJXuvQ||9Ke2yP%VCww+HHb*kB- zhimQw`|<0s&XK01??SKU-^Qy-TsxP(JyH&`z2(a>)LoQ+5ar-a-%hOcnb6M{PkeKo zXITE|Mje8^+wi`w^0b=l*y*vIO+n+wjt}+26dy~v!a8n1JZ6Woy3N)IK)gZVkYqSh z*L_$zwlh9fe>#GcdQ?)*cs32=ko~j}0pLFxI_yc{gFh*2tQaMN_J4WP>Hl1!M{W3n z>BV-^F6~kC&gJIo$=5Xqz`P17ofTGJn?P2NO5F2P2u?UL#cJ)WPN*Qbz`Lk)<93RZ zjM2HPWmipwqoe=)l3_gl#bY{K4JORqHG437cPio7Es0$&7)}iS*%O<90OU}!Q1SjqIg}?wbx4_P*Y(0x z!_lM9&id;kzD%PhCX2D*AHz3FaSdK(D>cL`TtqhPTw9|zrf3=-KMm)hpzXL0_f)Eh z58D`;9NXxA3~iZp5I~3E zdQ>ReSu583bm0y`Kz(hi<}`^o%6O^3x#*o!7vxf72aX&2I_<6bxOu~k)553K;d8^+ zkHj8%7tjjRXAXnCnt9-7H%OR&;G#vnJAN7{tdb3aQ;)Aq?7LWZSKzn=q-@YleO9y?8pN_bea;MT-$w!}C#7QOzbE zi>ue$t5KM3uBw@AZhgto!iJm;SLYyrX;t>SdkTl(gkuB{SlXnLF{=Y|YSBjgrd0ijuzdKL_n2Eo$*QKJ{R%pY<$H z7B9LJc`4f9**(zfz{~jV7hOFfs<*TFL3BaJabB#+Co_K->u1gGK+X(kFsEVG>uigZ zc!5osK8and%A>y+P@@ zjJo6c0jHf*rn%9=c?|Jn9O@DqYWAFh3oj#p67X$d*!Txr53vp$WnAq+>)MxJEZocq z;^(x>#2NDWSH72xw$QbC*qpaM1eJoxLpHk0!z=D_VjKkVU*r|<9Y5J8$?jjcnCW9n z6}QlKFIbfx6*kN(;@xMh$r%+dyeEUj?yLJAy?lxxHnRG8cHU)A$8I{=zAahRxb2F3 z%?u5UM+%1Tc2QL?99K$EJlwAT}&hJfYzNOzU>m+L3lU)Vf9;|Wu_J&eQ^E;r63iP4{CT9`(*EndGvw(1)d`NCb7y9uz6vs>#5m+YG$ z-EZBL-0=4C@6e|FczJrT1G50ic{+wK{$Q-1JLQ>Fr{_@N3Kih)r4oPB$7O)Y5JF2F zBh6YPg#bQm+PzLQ(qD*J{x&G2bIh}L@?&)8XATf9uZMB-i`;t|$`gbDurH7?~3K8 zkCfMgZ##CY?3o9ADBP(!;M7NunKRwTtOKvNH$qb6P>Gkwed2a>AhVFlW%$I6*eoyn zVsEyo2?10#CVPVixzo^ZB}ZVZCfVQyv*vQ++51{+X966Lucs)9Y$UVPrLlOcn`@fS z(Nv&Knr_Qf_jhWDPD1FaCz86yKy5~kl4CmY>So@E=w_f2=B8inY$!R}uz>SRx_Gi; zI$T*=hDLe|bU}K6%zdXpE543*QEiZ4@l%~UV5jqm7MB}nluF-hq|oWG2=ki`OgS#4m z!D_j6-`Vi;KFYiI2|q}S(r}iJrt2ziOx^CQuFnp1Z-}^V3SVo?9|qd7`A}QV?8pPv zudJi6$P`%udR??{hIniaFU$fu19pgU0@pkGGrK_0W*?+3)*WKMMtLw#3 zqj@7IQ5SF0zxI&-PH@U>Il|ICtbI53n?PY9vZ@;SU!HK;XRX7V>dx zlQEYUBy)3xSCcoF_FtEdBU^KIcB@z^aZ#nJp{(+j`%v2z0pmCFxAM>H9URk_ZyN2g z<7;XSh2ZIfNO!%dT{4t0{T?!5!28oq6nWTha1{~2cj{7`(noi3Vr%hMhUcV6Zt<0b z!K`6kQos`xapa`@ACe~FF{INo;S>A`Sa32xaCUJP^A%^6)eYaz;5Wn%-A%^dVt}PT zwB}x>t(s@&=qyUCQV19~1Uwf%{~UKWuzyb?|Wn7SzY>wBYrX5Jo_#(YQH2r&B=_g9s z@h0t~Oqt2*Uz02Fwb#$%Ox`V4Scu!FqqIl*HR>GvuNXcQP>7()%$K_Om1e(T(>;r-#2bm0lC+``_0d)7Yt}_G>*0*GV0CIza;L@e`>1cV` zRkbO#N@%KluN&?`bdo}W;=2?x1R&~)04}y6?NNKX>{q9?$hoT`oX|YRml*+AXhVim zTJNq6k8-;}HaNC{n3>iljJ~AEdlh8f_N)6+hd-3naiIs?W!w1!!;S~K1zDr|-aiO1 zrg&=YZ?{GqdJ%ezAB3c}NC;N>U>>q?(dvEJe~C6kq3ArGnN@TUvJRzV+xN3iH%(_x2fVrs5kt&QT@VpKd{QhV5hZh?izJ9-F9;KF zTPZgCAp4=HhG?xM&UTfAVv~0K97gzLSw=xE2E@*Dq6?A3iMc%O7?FDfF8pL}6N(#- z061V&3_Q%2!%~q$LWykVTI*lh6Dz+t@xSdv|CJh4!lB-zjR2lSJwSTquOVBtdBPU- zKLs}fv&w6AzXdeLnkuu$lU*p?YVqF|%Bf_EzKfmUYuJXcQ}c2UKL(LDLv^+059-tx zjN%zW`mY1*u_#xnY#AaaXLLhmO;w(`Sw9Xy5@dSTQ<^82yHa(>M9B?S)JZ}zfkyoC zntFt;KbT%(p^~TGswdupk&fp>5NUR5G~_&_D||?;FWTpA5CcoP8zEPFi|Nugea~5q zS{-K`qS&4Va%b5a=Mb``q6(eYA^sx=i~!|Taae?E|3onw^yB$2G}mkq%`p6bwqF25PyWa_Ahv7 zdh8{(cT0J${_%jo-T!$HcfF~v2%_|Enfa;41V5d)_^;$t@yn%A2z_)cTuc?&F0g8U8oORSS)pzKIAS%w(LZQ zM9u=1nfhXRrYSw7i4UdDD?GHkVCP(iHDTuLMfl4@tU8$?#mBxc(~~woO-(Mak70zc zvKYw6YweX-CrO{^+G-O&KD~#5G44#r-bobAO(qk77K1A@{herr_{twuq@_Bj%)c0u zHG8A+0vQjbnG@w6Wk}^WPFiaUCv-C6Ct*O1`AQXGr$Jwmx$=VTyJGRZ8BA?o4^5SY zx1Rea-9Cv$o5vJGpIhj{)MAH|I-U}xQ5$l;z&M!tI7Ci3Y!Jtp@pE6v=fzpAxL~bx z46pnX!I#hC0wplY2|wEii!Ar0*G0DXw<{)UObSp}WB)vG*DKgWi@eofy*tRxot>5{ za?cr7G_lG7J#eTxMg9aNc|TF`lN8zQ7p8z;L6Z)aZIhr~4|Q4lyVkGzi63@(QGLs{ zQN-ab9Xx2>hn$pAM!31)Mtr$&Q(kXFvtfzyb1evu{n)pp?iFF&4wZ#Z)YoejHI=g` z{fPP!9x1rCnZxy$Un7lqH3E2lg#ci>nuIxuA`AJ;-N*W+u{k^yC5Z$da#NoeWmE9I zBvF~o)thvFd7O{udJf5kouW3?P8PA*(Nu?;KOV3-&x%-a7S)hE5c2Jzv-dbJEbot% zsgT^IdD&l)>?c~?55A~9xeVQvuWbT*xsKA;U72V+>-4pVz8jMfblTNuLVa*_Nvm`t z4b}7bOxsgW_#vC=r9bLtfwj{?B?WBm=Ik5LE`(Z8knwvx+JD3ei~X5Dc2C$tKBws_ zk>Q%M@z!e^?DLtsSL2M|LxF!x%!93#Vpq>ZpCN!+ySo>m&Ci==&;5~1^y3w(8{|MX z_B9XH?ydwjch` zcKPte1F3Bycnl2d5dUAqq)^*Mne^oOx?6ExUH-E3vU-e~mKefwFtO4~v>YPJ?9Tb_ zEnN&8cTcc}{A1F21EBCH;$GNfxgFAVevD*(pq>6_I_IIs!$GKUc8dt*J5hNAP%%|L zf)U~~0Xb3RUcAATM#968qlN(fZBUANz0M!5e~SPlO_2@xp&mt=Fm@%v2~N<8J8!jU zaijd}+-KKka5hD=1W)wbQ(f{=K0W3EjHFoFv0*Cm{h0G0&vF%bP+3iG23J%-)R-7g zz6Z6&q3>4CwR~l^nazglO^_^K(%|*enkD4AvHq8Bag?zqJm#a9l;kn2h5s=R(PsU%iIpABWAs97_vdw#Ch7%-i6MWjS!vt+1*E7 z=Na5$N6}!VJYDe>>FUs5?`4ffTCiCChxo~zi>U}K7iX`Z%-E%!LwGXnxXkx#TznEK zTvtmye~dSIIN5l++2vYt?oj-h6Tv1n3YRUDg*4TB5OQ4He@P}5$ej1Rv|8g!aZc!DO%e>6N1k09$aBg4 z)wylOMNuw83&md<>-i7fqxB&?3_bPDqv9&pYx?H!G>h6XhDYD6=S;7(-Y17Y(xsc+ zf0FvV(5-bTVa>OD;#TY~qfpB#-p$aYrPA7?#o(Al_E4sSmil@#G}C37EFtEaRY)hk zzvHcI%*LbYRyC#C^FT3Tm=;}SNZ@(#L@81FLWAdp&c_gw<=M7E z-5tS&qM0u>Rs+_Bw$I+Ny!2BD3ZW|1Q{NR~D4MU2`QPhy z#%DYA!Uwt`C-g!(M@6JV&AC>pZ$`a8!_TP`pJEdW<_l~QTeNzb)rQi)D3HqAF1CQ= z>fU9fpZXVt_(^D@-X%M)R9AgF+*cy%M*ssSEfaR+3kLhMZj9Cz;j1E6*-WrS(XgBl z7X#g``$|Y2`e5xCXXpA&0gHJ&VW4`HGHMA#3+Xm*j78M5 z;tA>#UDw}WlE>`;-JY7-(vn^33Vm>#bV4356;j}N$In0H(TSSR&$_+PTSdxaiaQM4 zKcm8a9^$$lM=dvIMr`H+Fh@yZ4sUC6r>M^AKvl1M%l%|rRCoPc%hh@&l=O}@?9?Bd1l^Si8_=_`AaabN22{K{J8B$w}{7Tw%*Z3tV70DIp~6~(7o)# z=enQ)W?}%HmVv>4xK&}iC~TNOSGS}1iV>=m*|w=fawYYc#6JCW+NFo2aI;X`@vv6< z1U853$<&hOa=yoNw~?4l#eLIp(d+n={1a>Nrxu&0ec%F-;0=Une7( zT~GFLvCkA(m=_+q{jp_vtbSKHmz+|1wd-W%-$u(BiLCq`E<^`tA4T8ZC){N%Hakf=X`Yf_@wsACD*Z1~V-A~{o zf&o#TQJB*M#q6Q`x9aFw=DI1oyRRcBvZU8<^J%xHhfwb^Yj%;c2V38ofmVhwJ8Zo9 zt8UQYDNcNGn;os5oT8W-8sR;=KX)K62N+>D?hwUX#`?(BVzM3(3#|X=Ht6vB|6nuT{;< zkb$6RTK=)#2eqS#(2b|Ir`VG*7|W$VPnMcCkAR4(AoPOi2!aLa`(f33PF#<47I6)Z z#VP4;)Db`*3ly@)^AsMOny7qNfb13Vpw@FzWKVdd{JJ!L1^>$J^bYH@iZtQL8oHz5 z6S1{#J89=V2tbzJrCROX*xp$&uP*KzD#1x>yC?^}r9g5&{I|^3BGL*~Od_$$2PVQX z-BT(@(g#5+&BkUewJjk=^`Zu=Rz;cb)%MbzDS{7^U;}rC3N3X?I5(=g;6cg7pC5}u zG#Q;vX_rdeMb8{}rJ;w;hI`){&Ek6ov~F`uE;NZZ1y)g$H!2UB2$y%~nWo+}LO<0^ zCZ3=w++<=1W6U>_!-n`N{Ti)S@{LJTbn}__;^(^u>8qhCx00kq^#j?^P( zI(~`7Z8jy%BNR>Pjb9*(LQ$&*)fhqCg*HAmRyg7fpLT2HYs-6AFP%P)I6uM1+g4m5 znnF*CkWVm5^K#^<&2bnp;V)iKY^&LWQ{8^khdiwBw2aA4%{<0sOEGbA`+6YuLqigO zO?HDhA?Wq#-Yte*0aurWJwwE_fL>w$o4ND3B8-u#!W}r?2+!Ip+eZ^SL8RjHUs`uat9Ui_GBH9P@`f0=sHy2t@TZt zQ}~ffM8oa^(@}q5+N+Pyfsb<)J&i)2DeHQB441FR7brr7AmNm>ftZtwnN_v#Ugx<6nG)$z|&U(8R#40vN9;Ksn z+w&uD@mN`X@y>HbVNry~r-rcS7s%DqIYCvsW4(H=+aq$tt$xQt*m;Y;C=EGb=?y?m z8>Z^vam8lYzqZHpH`~1o{ezQIW~pOy$;&EJD7`s4e3A!TsA5pjK=)o|`8|1!eKioSNbzaN8uGGGO03-E*{BZw|kf zDb5_szVuOgmby)o3aVz*(wCWgN$bJ3*vS#wL%5*5&C5$_cy3eOP@GEc!J_C#9P{H~ z$Wi`wCnD$*w+QEnP@xcV5m_2zQ{)N@0&wPd26>>V*du+qa9w*L5<6jYI_Ji3V~i_^ zT*N(5tuH3i+)S-Z1AeNhNZGCG5w$U2E%!q|lfTDvsKKLZWlyGr6JcXH z4ojq*2PTz!ILdy~JOuU9RX#f!)+y@r)ct4Fdc26->wSzl>`ISiZ%X*knSb65NsRG#4Nts^H5o-~VrU6Y&Ra|x;t6V{)fTNge8k;f$ zg&4L)C*h=W(4kUQ4XyGlrKPVRsIxQhByCppSKsr)&oeSxz{Olo(uNC}(7v+=SB&U+_ zfUHQm&t<1+;ruj>3ccgEtXW`EzlFuw-YMpXpX4ciMpO94MnwlXT3Jqpo3FDK%+MhK zjCAtM?C!YYOMm5-2KZR&p{!SF4QD_!p@a&F%1OW`E#S7RdZ`=r=n^7w%S?>yq{1%a z+U^!|(EXD4Rh5{vma48Gl2qyLmwGYtSck70j&j1hz-D$1W?#y~Wvw+dH6p}O$v!@i z0d~OIEBRF`ho!n~lQT$q>A--(dt(Y;cWc$@)H>55B(Qc%jrK68p*k~V>o?!^vIk?e@UxaLoaU}uRW@<*j7 z0b8E-7|NwO=84NTRB{bBN&%^T=X;OjX?y!yLbXydr;YPhU!3rFiEYy_=4Rp~-;Xe} z!SJhMqNaHi$E;AkjD1{`sZC~r@~3Q=|{F7Z9Eg+ZkHEDw|)(44!2w= zBoUIhxR+ahv=Ha!?c^qs4=P#WJuQnHmkV%R@^wfix5zuoDKFQYXhZ->u8THQi)DJN zrlZzX-t6s3*?xT#w^Q*BO7>>PV_ClUHTu@PT=(@gBgEEZCn38-%6DiJ+f`t!eU|-f ze`j7!S=NR_qw>s~Ac0NFtBd?Y>!opP^U9{EpMK6SXiOveJ;NixNm_9N?W&EHx9koN zkYxWFJ~Bk2_ZR_45O!aJUr(^DPtlc6<(7rrm~VM-%)VL`x?ca1wBX;SLs3=U_uwhh z=u6W<*xEfodqa$Ec?Lgj5?hPpnV||j1*n2ab0Vq`d93e}qg95+7l9Z%!-L#Q-upFa zb`D_ka)X6tSbFl%aRJfhs5qf{KFCu#H43%keGH9|tsSSumrdfGwWLNpHBevmmF^MJ zZDD%#FaG17xiZS^0xipPcCW%kT`ipql-!0yV`;i2v#-9K?xo~^@`XnoY|!VPlhx6t z()P)}^Z-xRN8W$NZpHj-Nk0l(e0q^`Qq5|R`M8T@W5Xtg0}Tz zl9J-jXR~{~L_Au(v(R{k@Nm>2K*TTfWc>15$*zv($LynpwA>z-l`nP3VRD_?GS=b! zJ3sN69tvet+G2UWNMRM16|!awrTU|;?8&GnQYua3I_ja|ApHeBM)H?$F$XwAJV^oA z4)aH7lU=EMLR-zn0_j+hOb)wg`MBtWGj4O3jGS99b#FZ?if17Cv9@dLlfx=61VEte zo?jIqUFFSa72=T5Xzenm*>7fUT$=1A{Lm70tmJTS5A8Yp0LMsp08IvT&m)GT{rhI& z;}JY1tx}@nfZ<46lOsJiW98`B&}wIcb0Z6>A@68-qPpWR{I)h)TYQt`sj3ka1DhKp zqJ3D$_;-zv?bqttJR6HuRJWhg9wLC*TKJbPaq_3gO)+b)MHiQJ$$+M)DS#+It|US)2kT zJL(nz6L^zM;sRUXK{zq^S~PmOzN+}m!Qz{intF(+P$H2?XR_(zw(TgD+HHL;9ed|Z z)wdhfRa3=hP{T`mS(W8s((Tk|P=X|G5hLqt8AMP%|vozJ^TN?qfw zBUbUM!%PQ}baj$L9Lc_Tay>ljwS4xwf~Ao>`pg^9$Yh#R$t`Z#Q# zbZYs2Y(A)5iZXYjdvs0)BWY~yfMmyEn4*liM%$Z#zM)ZJ_E)vHH-^a+d$l*8A|ns0 zXld3itb zSc!b8rll#Wr|SbV@;Q7fe?gg(Il-M1)$T(8Wj`!-Vbpzh@~I}4gw}Gv#L^lsk#;uM zYS0XJ_++!N8g6wB(FurB_tz?Gj$GPKh@To0uXo?y(4;;^KAkM?*S+vz+BwpfvJvyM zGprtDNMAR}Qp96J0*iI9q3?`x;V`6sTl=<`|Cv*& z;FJnwY0f}yGfXF-@K^3ao%WaRR*fNa2TB@fv5Q#vHEZ)NmIKB#$xl^AGvfzedqq4p z%1HV5_F8DQX1dFDWsa*H7_bw~hcIjxp{I_nne{)$A^~jRa+|Y2f)BYzUuleSrp=F$TxmX3x=; zLNy4ptNEGlx7BaBY1Bv7TR3AI0m*W2hpN>lbhs)~B&V9C#vDXB;Z0J1qTN_SZM;jf z>RZZp6nNoQJAkB+f$~KJU<(qnyTL!tPMEo{z7d;w{BwT0R$#bV-n&2x6daLnsHrXhkzn&j1yHah;aX=OC)|g(e8}I8_0oJ(LRDOXz)X;;4A*jYB z)WfDkg7D|t?H%joI+V|Mb1Augj)rFyCHHCHaDWm?-!Vk>t0`^s8X zL@nY_whs|-+e5w>J`+?bw_Fi0dzYwS!w~`q&KP6iCaKoWsd@bIK^8CH%kGhI_u1r| zNsIQa;`b9D)QD0gsuh>Y_65jLKD@s+u59wKJ1-4&B|ut;+=pWE8e_ll+~#U+RVbl! zvVho1OfQbNdAxM0!kY&#S9vnF-mPXvul zKdhHh@z=opEK4?4r#}e5pv|CAn*qjN7Y%x@)bs#@W^noh_r543%=1kG1cY&Jt>eU# zoi9$qrd@dg6A|>n?$#o;|4qllr8Ie$9i2Vxo}@eXhW7(`JWRBR-C0F_sa4jNv|?%U z$LM&3x|;Qk%YkTz#hj~ zl{+@OIy1BEq1Cd$C$d-oVvE)V*My&BnTT(lwPi3yWJ+#b)`-Ba|zr za2Rd2M@>!O5OP`Mz2JT1^fQ=M2PK(`X3s7;+?Dbb0!X1`#?LlzA8yk~tEYV4SRT{$ z&iSeJv$`H=pDS#`S46fWl{u_4gK|+}g7sNUKThvvQ!N&G7$Y51nK6#9sL?D<)KmAG zskRxj;`Q~E{q4r4(0*c;XdT)3*8u<*<65}OpnVp%`v>cG9+b>u# z&x3=;#F4Kny(HaOwB&4F8nTg1NdIma$K7-D&8UkK_JJ6YmNc5@T}Y7gw~Ep-UTsbp zdx@n`;DCFWY~D)n3sHuGmkl4E#t~-bg>mKMsC1s%jGe_(YAXtsJv|c z%`IPl*u(KuKQL)Uini>jYTf|l8vyV^5vOSW+rmi7r^hl2T5wKxTMIo|-VBSf%@Q0` zgKYzzV<)(Rg#MY;X42!vXWz`%K)OJ&&{E)(}2YGy}R?eTz;? z4k*J7Oa1G+5%(UgnHLDlQ(&Me2HR^oM|_lvh7JLnXujoO=X8SmyFy^RsadrN1EpNCa>k; z+xRFFBt5j(dc*343%DojBb$P*5*aNi8#lbB@iY@VN3usT+J7wRw_?8|5aDdm4HjEp z9ELqd?xxcm`1~(ZoBz&FLREc@c3cHqQQf-ulU31oWEK0qTFI`&7_oY_QQx|a#}Pm~ z8|@A6;sUWi-9@(-r14ZU0=f7GqiZCExYwn5xN>l|)wO#*jVpYAe(Gwf{L_F2O>Eu{ zz1f{%#S7Z))<5qtJ#K9;z0@;23Y|mNT!sKXE6?fT+x6kMgT3vZ)ujE_ zRR+lLxtVvLMfFxHX%p0k#y!^{RgQE@E3%LJm9hS7#+})Z#3XDSeqON54pFkE(I%CZ z6onl*N($qX7yFaE^l=)5l4R6?V{V49W+NvJ_^M=z`s91LSO)*12m7*M(cw=h&weA3t+9m+!>f52A zzd*XUK=F$ zZ;$3;?=N23r_%i~9AB0L4 zybIrrt;RdPG}W{m@OF((P1)IK6)m>=KFAPMY}_!8V#xL)k}z;N`F3DdWOsP~7Ich# zsNFDD3=?5Jw0XikYC(q5MxJQz85!76R>dqY_$4RP?ob=KKj@wig-J)b)ROKURmZtX z*M@F|H1@;Bui=jJYsceh-Icc-OB6KyJ&Mia&cU&owE-WxSwEBGWlKyee^@OQvC2s~ zrewBJ)2unRo~*goFP9l&ENkKVENt!GFW_S@G06qtn7(_ZR0Y)f3@1gByQ=wpnNoFV zxo8~~dy7NlSynvf7w@>Vrb8ER+nQE=RF$MD|0=47bJ^Xcxpb#A`;Rb8={z50SsZVx z&AHpj)dzOJu>LHY+e=^l%GmEY1>TczIL}-6&5pF`)|nnv^@`Kik}@IVl@Cmr;^yXM z#UTpyMk`8Gs-tTYETzja{VzZC$uqC7mMqz89#aN2J5`5WQ#fPJ!i&lfA*nl`aZCk`ch!` zowFgvmMCSCd{u-1b-en_kbai6=e^D)&(%_rE#{{k3j*~?i&{}#8XzOD%+f^rXY1N> zbni`1d-8{*O{vH)Cs#(R3-KTPaF)1f+u%EVZIXZU<2v~hwbx2jPobp7w`NBj&g!pK>Y zpxptd9OFkIr=slQbtBxDKd(Cob-l))eOyI7WLNb}#cay~rE(lgBl%YDVdAaHNrxS} ztVgpo_8n83?>(qZBI^szwR#BE($u}YX0|hHTBOEzxuftwI*;{gqRnest?W-enfS># z_`bnV`|+coVanf`iohUyq1@;^WQ^lcYYL5#1Ou@KYCex=hYs{iXkb>6EQ;6bDZ$+H zZZhJ{@M!-L*r4fUSf{3^Y)F$xuC6SORQ@2%>#-Ls8LlR_m^}+3PI^`FvR%uWxW=k| zFkEuHJky=415VWlE@pTm$6z+QK|;|>IUCZmtTZl6uso>w4nER4_C0=+I$^G#+&{U( z57mcyBjZ>sxCEweAzoD-`7}zk@#Hz@3wli^&N^C**eRZf0{4#23m>``s4zvQu6|Ck zIvZX62eYWxA9g>sQCzzg=XVgQ6co5N%=gb2%(T88-?bR2nvGEChwG}GhoLiD_y7F< zQU((nPtY?oO800XdWGLON~c0G`mt?zyqVcq#|sR~Up=TJnk=Hv^oEa+{)N8Z5I+wy zmIhYw#)G$_Fja@o4uRXr{yqGgf)L_c2`H?sV2AX668D*U^t>Tj25s)4Jlf{S>R1W! zYfYZ3B4|ZZ(c$_9>_CXC2HM1s0b+G@z7u2&m@|F>rH^@qO3WlrA$UCGF({Sg&d||7 zcrokT%*l`ZFH<@Fxf0J+2maMaAqSlXmz^CQ{cM=!Xz|Y%oS80f`|NTxo07C zdOyt*HqGadA**C>bkdfv+}%lIsCw<`lIA0{g@IGNASQ`JJ$T{@J^^2V?OC&?yo_UG z5$r}T`R9*h+_^NBQFkEC%3tbOqZt8UN#}&E=nB!rUqkmfzKJZgwb7eCP!=|c44M)a zGcrt4Q=JsCEBQ7%f|vP!vG>+tQSNQK@E|HmD&450ARyh0h?EE;C?KtLcMLg%fRX|N zio(zx(%miH9YZ%WFTp zd8vX5Yez@BKI&AXYUb4IcN7pBLcF&(6FY(`lCzDf?&|pcNQgd5!KGeI>Ox5_nblYy zP@_vHA$60waut=sds(+ntxH(kRlnjo4C1n!(R;11Ybl^yEG=zj^9uXjhvuHd}$j#+s%J$J)Nbe^Y%Q(J8x;%W?=& zg-B|eX15&>O!Z%{tW{Uwu5X3H`#+Udx8SkX&=Zp|jz=uPKZr=PPTCjprUcxgWJ?~8 zrcv%>vK&wvwEMDYRhZqbqH`u!6;Hq=-#B)1vtl&;?au(APW^M1rSFbWTRK;Ubhm%f z_e=2>dtpD$c_xJ?Qx0dMu31N!G|ecDxVjlkt>OlD(TC>SFF^=rw%gPL6@z%8eeJxJGVNQeu{9iO$R^~oxB&C{LT zt*^&tPw-+`A|$@uyfvk^kg zRpe^CHx^IQO#X1K)EhW@|3b#q1lS>E06WAQ+X7^Go0U1~m^T+Gzp*w7A#~o_$OM08 zm+=aU#1jQd;dUiH>Gv>_mC&`uJDcY1urkevES_wi%Ymn!cY_42W?yt08^g;01D zz$K-IYOgnpj-i9wSQEW8*i6r$HQ>yS2v>Kl=D$niZGm0Zct}+?yhEhmn66 zqvB>xHS@Il-m|yNu};wm)IGB`p-bVUo|7T4HqPxp|CMA3SgOb`5Pdq9#!!*H}FIMPc$Kd(HWWryd;!D^+(o=xujMImXnd}_hR;vmUQehnF zdxo2Nl@U`D%g#damM@~-i+0&X-+DQ?Vrg1ZhO!V*ofbY9NMLywFa08lW}|Q4m>pHD zSInExk}L&O>3K<@hOdW4+s;N+QG;IeS=;^QZk7}pz6vdFGfE5|Da0$S;+dT_OGzY} z4YzoBk9WMjJ~PH=SkV+^2v#Z#%}lraw3$c|9B1{W#n_gi+_W}M4qpI`U-zdPkr9mC zz$z<5fOk#}ui_hm>)jDun0PoX>>ueS#eX8*)EKMaQeje!{{>S2B4c~&#_GNACVryy zCl6`{(K?JIzd$KX*ysI#0frh%7OT{l`wL_PJ9g5tTxz<3HrQ#_xzRBheEcyh;YFnf zYfLMfxiM*s5?74UhS0Hx>MLair2*Tlr1EnQGO--4GJqr$l=_Fa1_4mzDOkkFF(Jz( znScr-3={Vaz-Edezd-NFTEWMhn{YG_@a>Q3*gKG0z`V;(gDutaV%ZwtC*~xW0|0|& z2JA+KBMi;i4=A>yCzf@`9d9wqYql0)Y*R7g*(GFckUUf4l+w+r31gWh9va?sw5gKpC~! zgiZvHe+M5mwP6BhyGqu7d$jbw|2D-IU|kmgRlo-61G&yu3xFDA5|(L| zaX~8T@&EFhi~8q_yLXD(^$5Xmli&gG)$kXH)eKmm9KZj*Ck%5h8CdbDS^!Aa;$nzV zVfy`k^F?7Bu#j`Sswm?=Fv0=~#s>TXopS;E*j4d%QhmZ zSSB0><#~4fHrTCOORS3!FBOxoSxo|JAu5jY_OQ1ml_k{qs<<5SG>;?xEeO{Sv_i2s z*=>wOwHcW{m*DbMc%mWZ5+UuQPV`(?F=DULyDp;IF^*GSK`j6(QX2ME@n-4Pt@FHx1HYM;XcG6xiP42CJ;=GUu8TP&|T>3tvA zx^vT@3F?33D&=EEF)RpZFK&!JYJaS>E=OIZU($5;**I{Yt5NK|G1v4Jyp@}H<2LGs zoe^pyq)0WRR==@_RATzRwmOa2fUINp48N!Ap0-oD4kQGlk*94>ug2zxe`#R|ikm@l#u34j0Z~X-#_2y|a#7=*2@6-%`Aa`r3MeQ!s z0FSxYSKyU}PH=1{8rCVSgZUwsqvQ+cc!&hR@Ct|ur<0B-r z-E@U7xLgUop8@xA&URsV1sEv}59;Yxg}C~-cO-NBkmy&BtW^OdEG;trf?ege0$hZ~ z3=W=?MLILOQ?slMarK%=Hn$G^>l!^h&Gf`df>V!dxy=%-b>F;;M^wE)by8$V7bv{y z+1YucK#x!_ROB|TGN_^$|q#MwH2i&r7Kc}upm{l z!cekp7w&;fZgneI`ekJE6ib$b%m(=o3v<=q@TvRZ%ONb#Vb|~S94xy*) zgvgxZ2kR3kCSUHwZfUCP+YxOv)KYbCy5IdCPV%!nnLk2v{7vPz#w%NEPq*z5=Rrw( zN0EGK>$FM6?=@1zJnj@eQTJrTdyrj_8JU=o`)b%4-FSJ9zpfhVk*2rp z`CaE}D-Yr`H!AX4xZ!s@8=|h@jl?xyRy`tKU1VdKxP*?je)X4>0TEkp4`fZhk5V|k zOhu@$;Bl|RY!-9{e}qYsId}EsBzsP`&D{>*p3o0Or4G0S4`A|q%w*k4^$Uipw2Cjyz%*Wx& zoc~_bx~AA#ga4HtE%B5%2m$SV_DW!3U} zlk4}Z{Y^NfN=1vRjV)TA^M$EBpWVrCvIfhCIQOhhR1oPRz#p0GYhzzllqcURw9kw( ze$i-U4t{|<0O{{3kZ2HT=7aiVmrnA+HQwN|klf`k?V1-0Cp3?2O7beRj3>$V@!u_+ z83g%!Y0r|x{Up4?;F0$cVNcTapx%=*u_&9f*PQy^#c|=*x(mXKt)el)O<7;E)}0^> z@hv}pkzlJzJiw+Vex6pQ%3gFQa(XB9(1)u9vYg*Url;V+@@mGQ_f#?NN2A@c6U5HX z@rrAflfarlneFrROpBeF&*7JJf`$fFak#UdAYWnKv$1z8FgY?3-H6ThztNwoXQ7(Q+td#p5ei*H7d{mZYqxq>@lBMOkAIssr*9&+r zmYm11uGVBvd7R$sG#oc37Bxn_#`|KmaK93D_F>?gbgp$4)aj?nNc|)M-NGH{Z0zXh zkdsGqCi(x0hdpxaT$6jFa$9P>XrJmyur(52b zlc~D35iTCM6Ci$Qc}5w3rdep~di~XtHX`y5G>XUfQ0irLot(=0_UlQ%KwLj+*2F&( zEpwZ9p4AEve1rYyAXU0MSIYn1h&;0X{?;~UJp3v~t2w(Z8FE@R1FAg)PuO-JN%lEM zHG~5$PL3U36q#{_LDd1RGjtZOW0->hlpAR=p`gJg)Xj)Y zy+^cJ#m1%rJSUOsYs^M9%%Vo3-IAA@X4xyn#Iu$n&NJvRMUQ3w1))nD^GD>L`0A3a z3A$o8)zOi?s?s+qP_Pf|Rs4^fW}CgkTy5+;Oqn?M&6+pZT}>=K!9hZ2?3|u>ZIjnSpHqEL7-v)Ffu9s^t9Zu6Mu3Zy&hfpPrqRNE)4Smu?h$X6 z+-TS;xu{w$OgqDtYzdw>;`7+J?08uQ2tRR&(D>mM9;hq$XKDRkAOWvGAOYAvA%Xu) z1^Vx*9Z#4)c=bEl9^0bXbn(!-PnrYPBQg%&i^4`e2hyf%upTkw;#EK)>{xwr!C~;S zz5({^ogqU01h6%J?etF}+Mk~kYYA0GKDr%SEDNmP)B-lUvU$FrWpNBnuW;}&?JEo@ zwV?(jHP@R~dg>oi)azu3d&hQJ6HanogmwsKe$;y0O7Zn{&&avllPvJVhQ9Ku5Ai}M zLLt=dkx>8Bk)I>FJ7G!AyL^T7=WkZPCfZKb;h!N1`%8y!&N?2!$!wNUG^3`<6cN0m zkWVlR-Wl(S*8MlaYw5%-?k0@cb~orZ#c1Y+4PYM25z3ll^z zuOnUWui%5!d#b(r&t&e=Yns&h*P?;BU6T%|bre>3!tmS!W zm4#F3*uG>xPrf?dw3i+}`ue$aEq%I`O8#Zb$4xgssCTzs!S-emi8d- zt6ZOav^$xs7jH|_{j<~tEb{deG2T2oy;0FDdJ0b7k@`*7rA>k6QUx8k{&Lu!w2O>` zG|N|AcH@4dftc7QCxPO$YALb~_lS(?>CIa2+9b?Jcc5`sA#YuJ3MkYAw?=>xmr_qNcYoTU={!F;V)3#Nf{2#SvqU1-`w8qr z%L}>VlD+an+qc2XD|;e4*LO>arh*@kB(``kbBcjTJ!O{%DXc_vOp(Kd;hLJBNtqc{ zTW-b)9?7H#V}hUWPRXjtVuV)`#fCT(k7+s53j6@o8Yu0DH(##)wut!Qg7P|dRz7Pz zt_2tL{u8^`pL9eRL4B=f&Bn~Ielmmn& z*+h#=oR;guq@*KDBjI=j1L+8MUcJ>Tj6n$@A8eaM?bL3bb41}z{58MI_o4Lx(Sk}^ z!Dc^;rdy)_GroSncxI8BCH_`_%=10b6^DKv6Z(SfoB}5NZ7t6jtMyYuf!&$Hj(S55 zI%9R=NIcOK$qCJb73iq!4}P}Pf_Y_Y*118Va<$s0k*~XZ>WS-bsP{QIkO-cCaw;oJ ztG|+dAm~{!e>r0~X91r&^$aagldBzPIig8AY=(d4c^WTCPh8QI1`XYLjWVdo>NOeG z*}_7i!M&HwTXo;XBv0sx#gCMf9y?lWS`ih5JJtFB3L^X!pZPCk*R zzimfoe&d6~6IW*XYo0qT%e{+eMb}HNB*t|`m+B=8-=AU3eIq2bH?dBhq~xI6MjY$1 zYvvkqjyfSxS#N-9a#^`oad}Y*p9=@YhIr-7|cXPKf zm8bt^{C4f1pTB!z)(~Of7|H( zW*+xfBe~!H|M$8`p;Zsc9PsCuyb9a^p2=2c82iZQ<-pk~0HgoS7o)%FH}8z57lQvH z;{7+r3rX|k1I*{e8?Z?X(?3r{08>*%YF)tqfGwTKO9;eDUj7pAoA%-Z*^H#OojDT8t)^j_eeLR;NOjN!6!F^v^%WrX`9x2EZd2~Wv> zPF;CD2^tzd)~UP|KM=iZddFxRVlmW>k#(}XE`N{t^6`v}qrJ@}_-*x(vHDCfQ$$DNh<%&vx5JoUNz)yXF5FC zxFEX+jN@9j7;h-kp~?y5(inIvF%95m_@Syd0A{|;H@qURSZDgHlJ&PU@j%r4YQdl> z?Qt@ydvw1f|srPG~Hzsi1kS{0ug)V%Z#PwyzPd(xZ8 zv{>J;M>sV{rz=-CgUUfy(yDZKzNGZ!k9$>5o``}1_(@dcRAPtRE$2460t;>y2$4w* zf4fw;RKAg5nb3X6cjmjl;5aFT>JamONT^e{ptJ26QBFEfP*d>kt0s+U^ZCcwCOl9a zA$fGSnAk#EZOyujTZ6eUCtEMi3@ZQtS(WUB6P<7?n^~75=~GKmScL?L0LKa9I>whDoed) z)kiibDi8>%EV&4mC4cseCSTCptn$Myx^xc5MgL$c>6;~Ec10#47eNgT<9%Ar(=88f zWhC-vi2bCzzN_c=M07x)-(~ENR~1CA_FD0ef>Zw+G)!mYME|KRSnCI6!dd5`qWNgj zs$O31%VkprvZ95nZ7$v$J(f8-Tvjs2-w3Ad3mDkqhAy~nIW0)5#7j3 z%Z{Vy8{oqb<%k3oNeb5zcf}g7w8_ zp3n#UWFf;Da&W`mtcg&5R*Q^FD$udHc%ML!1+f^N-6C;`4P-lcnKK>wPbcT^ zj$5DA9c9(cZ)an`->`SB!?@~(ub(Y2R*bN!Q6g{^=yJXH&ue0{8N`qDDHBo}zZM%V zW{&hw?7qxzH@Y9UqF)zi*LiC%vSG(8)av2wp0Y1v^?Z2?Z8=kH^-a?{(T)Gmk)O0dB$av&kzU&2jIW_P;>oD^+8pbk^v?*B#t72}HQpL>N{)`6CLxT>k~~ zti$J6lj$37*YTF{;?f4fgYsalvBDGTc5zq&Auny-=ezk)pM#dnnI+@54c{TRXH`+` zr$Kd=3r`xnI=D0CC%xb-sntfR&3%fk!62ME+~ko^y=W%MsOv}t%xC)#Os5p~S9DVD zuB}jJ>~oQJl1uz5Y(#QhEv8HK7sxmF5EH%lha9b9KWNl@KtYFvy&ZhI2hgbbUgF*O&D@E-6?VvG(R4}@2v{c+T5GMl zHihwOngKjh6JQ7Y&$s{h&D}{``q3Y!rOqGhKOhO?&es8VMCH-^&-1?jJ;D2DqW1?E zJltC!I0WHK@QYud5TKY#d+LdTg*6?%mIR7ahCqh3*=8{KXN?r#8hcZ*e>maTAMG%B zFx>j|!J%MXd#G>=yWC6IJ3q6MOUfg-egO> zT0j01rcrpTe=DqJqsg#JgTcQ*yA;-dWN9aTC`-MkFuk2VD-#&Gqv)3~ZKh8@`_$Vkvi+DRB zlqB71uD`=DKJu)urt`_4`L31#uwGdAkFXt6O~R@dGNl zX)Ql+I{C6ZatBfqyuBdvIq^1bdiY8(JuTwIwFVN#cuRN7C~-+=@jOQMZUptNYN+-H zO#eG2pZu+lE5gX|O4Mzk%?A})$sF%vO0#E3* zcB;h22-@aotawN24 znd3E_Y*LIFO3fqE(T&-~Yg>B#-V?k`Vm+PTN-=}u{08)?A(^yOIY%lx=B0;Kuq{eE zSFW8&ZVxX<3C1jK?WV73v+9kd4yW!3l)J>Ta$FCYqVvYIzV;n>!F6{Ly}hQ!4al>O zLhBdN55_-??UfB+9_2}Wam6^FQ0yi$*1cQi=Ho4|sh|25eEnT?T|RMVqd`$@^8!ag zEA~OC6X3fU%`oEj5Z-XY0OMO|kYtl~h>1{eJ!fK1a#$mjd#KUc6>qJ}4Uelk#X!(-2SlyDH4{YJZIZH>1X0LxTss@i3uY;IdVULeib`4k|Z{sn0>?T z_}N8KN%m&E{DDSo|7;p~-by7-HD=L5Szbu>%DcM6uj_)m@em2!`v!26mBs*YA*YtN)ZX-a zUbD@X`uou6ZA8^SNESy5rz3iJX}b+R0ET&#V1ai^6kWa1$*+miYQ;Hln~ko%3GG1D zsiir#`Q&JWo+&F`%k%dGks%)fIE=rW2T{UoSUaH6sFAA@0hP@HK{3-WdAWS zzavTBziMv0Ia)8quwoE)pZ!8sVeNpIS?t`&vG?xSq=Fnp&VMVlXXHk?W1mL_fOoLG zS2PBr2J9$TfZDQ)W&m#;G6O*n*DR2&{<}?QydNo$4U#aT|2S>aJAZ*rfLLavA++8Y z(f$R!wF14eOKMUBqL}}%&k}t?2MJKS%)TlCV1ph5_!8utU78Nqbu@~xp*lw-|GmWa z?7IN=fY)%CS_`dauZA25EYJ&!Fnl&zyn%m5+0~N1fZW7C{`yL6SA&8hKoMMc#O02- z;&iPFm%A1JQ}}MmD(4!MJ{gaGqJiQ>Sb=*wiv7K$kWc~TDAenD%)+93ESa{vI(HX$ zxovaL>Pn$5wsQp7^kAh;Wwzk5%DqdbPmQVq-)%bil07wMI7$i1q`7ew0tN^a1;0`6 z6=spO;OpK~%*4At{-pUWM6KWAAC0v5{u~o?Xs}jD8*N63&vDt;1jf|c6zMPGS(2$j z)oNJO3#4S0#(E66XUtu4HbExTvpGHah7wKD8Jvs32Cb~M=E|5;YS(d+SN=0Sn zd!?FTC8J8bwH>8OVo&u!k`ACLnOK&+*-ms#oA0!FaKyqN6OOeoeEgVxRYXmD;`Vh~ z#>&LF$izgcr25nND*0jWo&1KbUX#xOYyK^73(GlZa3z@Ikk8IuCDKg% z#F126DjNT0hH7EHU)GZo6(*!P@^;kZk}$p!Mg2}&aMs;oEJk&bFaCOrs`Gb1bXHaV zaqSU@~3jkIVqk@mx} z&k35Xp&WUC*uValE@vnpJWdR&OwHO#Sr+_QMC}>l7S(Hs*_q<%0<7Ijc~Y~s-;&X_ z+fH5FQ6?F5#N-e5*`Ju(GjE9+$6l(_W8F^5Br7W=`BJ- z-u_+%fn06ST1d~Qhh}>Gb~g06tE9I&EGkP7Xct}mYrK10Nn*vm(_T))U4+w9YR@cd zCh>2xb04{!dyYwSqiz&c-AuSqUzJcg{d7w>-8Ti|q}>a0=s(O^GL3pQQkXOSy?o7Z zM*hrNe`Hoys;UWLDLC`!aqS$ z9{>Lpko2Em>Ho{0B)8DR;!_xHq{dp$v`uWPC5cR>8oc|i!7j0<77#pJ_8g#T4;w_5t0J+Ct+h-aUF62)eoT{N-_5;tIiI{AGMRYOhfWTP zhY^g-2gsQLQH8w#l@oEPV3mzE1&(pLG5}~CVqUZ;#$_ru$b+rF2GU7f5`YV;0zZu! zzgHDwj?4fM`>rd&V_fij3W;x8Jt213Gv^oRt2zmW2#is=f0gbEobmjh4bhY^bRy_% zhN~Hd$PhBTAis0P^9PYN?+ivG>9|528I6FEbY%@X2n+RmDtY1+{FcJEe&}X#8;#sz z*B~v#&bwQ(hkqr@yBQ2{q~`Md(ArD4>hV&(tbGNNhAz_if%*V14(UMl12i@P!PR=dDT0JwG`{oMC0TC)lpB8krO6N4O;M-nddR(TPw?oW z^vkry$Xc`qLb;2ZC+u2`^JTn6$ZCd~HS(x6-U%;6&i}(NP;$WtNzX@$b)YDq(bV2V zw%s&I&%}#dgC(3}Ljo+48O9}L-MEkQmDt4El)@i)mAO#tC*vW7s@~g7&rhtp{9>eC z;+KAzzlYh$4!C8T`lc{V(b(W4Z4fS!g4Oel-gORX^L%M7;pIp2@0d&}dWh!@^REDm zxA@ulr{AHIf?`q&$_3V;>`{AZwR?R|II(n*;ow2$2Nf2%pI^s@SDJm!Q~f-yC?S+5 zZ8%v@0MzHLqD*sJ)w(!V_Pd)FUd?IR`Y7dF)VkG}*}7UQ?i)$^t;9*EM9Q2|Z0HoX zD0{H*rfu6_i^b-xiTEGCi(2)qI2u3v8SS2#hk=YbVIQ?=1Vr-ACHRb9Rv1oXe^N8} z;7eeAiPhZ`EY6L2fz{>GQbDsG1&^P27en{bSAl^18-^=hl>S*#4MZpV&f4ddzU}NS z_X|eDY|BZ{ietbEkHpdOVQU)6O0*8<%VbB$t4Tg)t%3Itjwt3x+ZKjX4n7BM<`j`a7_Dc7u*r>l$Qa9b zsxu|Cgv!Lk`45@S?}_W~1hGf7i5}=CiiCnIfEtJj$*wQtls8Mmy6vlBr4O23LbESza>Gmgqg1P5X+QZcKCCgcbzo>H&Mz zW)%D*z!blWM2}1Noc7Jj*spms8eU9m2z+P!Ru=9YIo|Y_u1tRv)3kW7kD9(MUr(kR zDVK32`u?~-$56@b!JXUgHn+YheZoY{TL8UX|123}WOLAwor*w@NU&{we(;fwkMeG# z_6mrEyUHB?!l-8OI{Kg;%U@P9me6uq>8Uan!>k9W9q^#763k4zJv8T^&d6~Vhu<*X zL@8j{l5dZC%btQud}@VZW#^4%eSCU$&4Umb-Q$1jL;Y4HR2ZWe)e1Mhyim3>v^w&% z{c1d2#$PaD@()?d;w zl!b!+F=x%Uv=Sp`4T&Ji*ugvc^_pFK1iUlvK(^naYGM>;Jm`FOp8gpgQX9z+Xo;QW zY0*-CbGt0!mW8|7uO$wp`SA_DKNjA}mWNUP0@2!I?qA^SWXYYwQH6ONxMbKn2f$%F z#KSa+u@-1wU>FuGzP)`B(HLm&E|eKQ+GQtuSAfMd;H`5HHO9KAVDWB$&MZ_*11=lY zKek-@b$4a9&b#HdOys$Z;}eP|1Tg^pUR^_6!8#MLcdkG#qxUg`=!tQ1oJdLb)M6EJ zK6Dj&3~3>5njc(Mam(jxQ)jtF%FSD9junofJ^-%#ANKhF-w4;*117mA3itko?Q730 zG-aWkdU#I0!ONZ;-ipIidY4>Z!N0vp^bXcKigdra3I0>-lKWIe|DO0ZS2Up9$X+_Q zAcXx>QG;Os2**+XP}F4aZcO`6ssR=x++aM|knvyS9)I~G#sQx%z}k;ag=Wj6c;Qzc zJx<|edq*&rttvOiGrz%kDK3N5tfVi0CS4Riq3O$vu?TK;38LoH62k`L zbAfsY5EiU_zKT$7aq;A)*f2!aNs9dfN$X@^T}1r?MFOD~L0KF8Xe|%62t;A%HO9{D zx3yA~p#wugb@q2R-7X4alhAEGz09o_a+Cp;JEB zkL#W*LPZPY!z|SkW(kl;%}EL>HBtfbx$7#S__6*$D}GX*LwH;(J!#;(jSQVE`Ug34 z;zb^u+;A2zC$RWo63^&M6qVnBq?#9kU?;+JX%LKIfzP@jeIn)DX2>N|+M|~qs^ft+ z3cU>CkZmm&tZSJI-_k$q+pHdOuX}wofeuW(#4%&HV`wz28*u!tZiwMQ+GXdd-)c zs^dkwWjj2+z)ikdhH_q+>kofb5qH5v)Alh|QwYskP+179JJ3^H5@ugCO;@L@Il3G$)we_MQKnYS!MqLvQ6EYev(>@^Mck?2w*@_T*<+Sp zTYq>KQ)0%MK>8p6qQ~iv)>6rWx+@Q#5bW%UPjxuwcoiP{r>I=y|I+4 z3RrgN_<(2=W$DS?G+lr&Hwp8SCa7^+`zTpPHrW7jlD-C{)qyAiZ0jf37QZH}U6*T5 zcDc*X_P9Y)pKUF5?B{$3p;M_py%?Py#YXn?O(CWrEZMkgScB$%>!yLhW3P|*#){sN z-bt0=jKLYg83}6&S|DvK9WAsg;7Jl}dsuG2#}&=uYk33f$hMM{o-5i#okHMA>Ay@Q zq9(A7<*S>p#gsOgC3Y^b5_QtKSdh@8zB|7G|F>3QNv5|jav%(7-(YzIRI0<)T8A-dnL+Z+4siHdRFZZH_wT~RADfD)lMv#hkg%ddGN6I-!5#JH z%U2L>r0Lj>Z9a?e>1i>@ILO^%_WwjA$iR_!(^0!u^Pv}G2ngG#? z4@70Oz}{sdhMOPEIUwW8*^h5b_bfGV1>~Sx0fJt&)5b!LMrFq+y$Cq!ZB4B$LF3HT z)uq9zv}7!*9r*FKH4=WzLz>vKtQO=^SE3(MuI^1()a^wBp#r;sn7L=KJ1>>Q>>QJ` zrB618pagBgwJP!7Y%{uuG9$LF?kLdJMmvOXF+Ub_8$A0s=sgi$%a|nc;r_&0<$O+y z-RW?DL*tvNVAI*8Y*qypGe1d%c4-1+e?qGiUb~xsgjJOmtxM@5UAFm{fs!!~OYfa| zWsvXw0H3BSff7a+#ol3EfaX8wumt)rSXz>9tLbKjo3YyDNrt+Mu~w~A;e{SEBcqy| zEcl~H+Ozve(;kiFJ!@%O7bL0#f0cLhPY$^ktwRf_%Yl*sI{C`JB1xdX?(Vrf)I0{y z1-nB%t;}1}okGGNa>==a2>y%}AAXAxu1*lx0_y7X3hqLK18!W(Wc+KdL3_!&sk%37OJ21j?*E!gfbnbcMiW3iPN)S+iLUo@Y4TA-FNzw8i%o7F| z{mhNJ!S3VNOF3L)Sn)O z{Ff!pt7K_Ng_D~veeI+-`_k9c(ehs)@)m2vRQ({az7^Qal_gw{W7A3cMJ1@~W`pia zv@L=`OD{pIY1kxlj%oRM$45&clVfC3LGOd z4wcwrAWlvykHmT4Hw$683O3S{ISTYzs&Aq>73$v3sNNK*k^%ffKpr<65D^5eFrwoo zDzw3}+AZdKklZ7LoH^+Jrw(MAn zL>0LZMVXKW0OA9bZi-c9OLYl$Z(;%WVy_{*K}uipkzKIqr6Kh!OYbtBs9Z;7>S@T) zy$356uQ%|&u&?3bu_SvG%Z}CyWkSPNvcoec3L7T`S4Y_@Bjzhvf<+`w0|VOLf|3K7 zYlqon_ zg|5E4*T@1K9#bFVifstu9CapG=0L-m-IF;QkU=M%4G!jTEGcBK4l3RCpw1Sb@uiU> zk~|mJ&v~Mb?kF4Gq*)fGg`7xT-m@cO96l&8st|}L2OR>xKpxA4cLy(jTKQNbCWE|Xa*I;)EM@lN@8iVKtOj}; zr#+7NEP84)gcrF<){}#_S3q{=OHR}>42JUxo-a{_Bi=>OtW+HN_ulsvfPbUcGEG67 z%ORWg2)QMtr3VRG2K3nmf_A0p!Awhr6ZQ?K=)6tDPXC6;KKxDRG-tTl2iV$9Uk z0I3b5LmOz7e2Z3KR>9kKc(r0ipq;Ke_Ta|7=;H^4O@WwK%iPA#;hnXe@e|@2%Z761 z8Ph#fN#f@3+&!ofN&|R0I~Cj{s^j|wJVFF8aeeWXJ>kNJgx*+7{kglz)JP|>{9_!1 zr)I3ZB?9(gfw$5>YqGq-_>H(vTN!xTL3f|WLCnm!i#>M8$j7UVmg+s0Zp)V!+0dTe zeoa^G{#Zv_4^PHnxBrML49cJ#xiEE1v6E=vpJg$$(2=e4A-$?7-^wb^xc z8mSP*@sHWwkCAq9`Eof^n~n;Sq%?0|J&GbHx!PPd;|Q65ZR97)ZLL;=G{HVbx+Ol> z-3g&+?|kYFzi54!k7#jw>G?YqC1Ji>Lw^@>V3G4@N( z)uG5B{PPbMb5WL+EUl1tQE$qTA;Blwt5I@e6+ULl)pw^Uw-vM4IKKKbJ)G;ZN7)u@ z4@=XbA#JtaJ%eL2KJ2I7co(Dl(d-b1`T-yFV^v~lJ;x4ZUO!1*a7fdS^%3J(2o;G- zNqwY_n06SI*1(!g$?DzkCC4X>mdo7YgRP#~5#C~m(jkj8M*O-)I7G`VbY{tv;xp+} zd-ZADqPbDKdcG{Q*Hg6nvOc$Ym`?q;U^mY}B4S4Q!#YSYDmEa)g}S-(CfBG7V5|o< z2BJQ0{$AzRRpUk$_F*c_y$<1-ik8}8$+vOWS0s&!=Fo-;^`kDm1mC1iXI>0JOp>jm z9wL5$G@Xcb8AI-!^@E^A*>~Y>2J9b{AF)9`^5w)(&1}W{nL>;tXy?a|!wf^ZyBji~01Y4X3ONqq;vf(sLDj4arciJe zu-5uCJt&=Fr`O}f5~I*SPkA1!bPk!HAu%?T(Rx3J;U5#Kj(q_GX>V$g>2vU4exqDfNkcMBnU3D}Y-7as?8|rKVx%Bls(1aEUR|%(RlLu_TvEfB91#VVs`bo6c}6(AZyK?f;MK4#h%~*>%f(n7@9Z0ylnO6y1iXK3pJ0#r4C3F%p(JG_G`Yd#bkL=E<6* zI&nNtYq%0jU*91UwMTq9!{;ilL#h^Y`GhRINi#+=$ zA{egbGo7)Q+r1AgPlpFBmT|F3>rY1Wa^_n&BE60~Eca69ykkW3xblGfRZFoVRy9gv zGBenE$J!&F&YDDQsK46JY5Otx{Q-A|75pdt@2qu95_#%;GW#F&u*S8263CY4>~I2e z<_z$=J$1A=2EZ1>BLKLnf?eer)EForxv<7frw6}46@R3CVPkVbXX`900{D!WJgev8p9^`l)4E1xAC@`E;$6D>YgCtgUl2nRM+DTT5-6k68Yy8tLL*Ik zRoF<+o&0DtV4TG=`5Y+MEnbN26cux3cV0aQ%JC`J>UaJ+nx5PqlbwU-qd*`aRw&3-k9wF%wN`Ugf(=xo z1z~qmXdB*Z5$0EzTo$EIhX|2`)H7#5%^uX+mY%<_I#|`<-;>;13YeGsWy> z>)s8ugdwLoqc(QZ)YklZ+Ot2;#J|TMm9-a`evqYPHd5d^s=|xmZrE+KlM1cW0~K6lAAa^D=2B~p zK8`s|3tu@SM0DSx0SONgqT|w)l6^9=zh^UPT23}CzjbYi@IiDCHEwna(0C1(|Ex`i zG81O+le1atIzOMIX74DKCi!VkOus;03okk{IIdnSwXs?#d${~`Tr2auLRR$L?H8z^ zbN{>RR)?k96Pn6K`k`G{%L-j?I!NW1oruTerMHQL_u0!8Vi>ZyDn9&N zI^-LgNFv8cT%aFX)T15Uobj^CAHmF|e)q0}O&GhYiXShB84_E#iI>k5#z$n&T8Yrr z?{wR$vBf&}+Bxt$JppvfBWZs8Hr@{rd;AhP$MbkE%9O{ZT`ErNkbuDQ1#9e#slLsU?CTMgcwLvYC#OXi&7?S%Kc0`Y$#qmc$BJSgEcwb~s zLHgtWr@i-%imJ=jy-^TUlA`3OASg)ASwylVB~}qcawu{rk|Y5o2Z<6S#{vljMb23= z6i{S}oGBzD@3&w3o^$%O&mDcb@9FdP9k>5rRAB5?d#@eVnsfc;^JF<4;&cwVi=k^W zPk_D}vw_(h5n?OV!7KFRhg40ev+;eoLS*m1AxiUyuYV!vnbyZEC@uLg;&? zVnW!fG-<>IFssMd4~c>6b6O!?v1*79;k*?;FP`G6Ud&TXQ+~}KN-Jk14b1RjEQU8o zEU3U6(UM8DvAVKGvTLii!oOhLyPQDZ)o^9@fd0y#0!;xLmkDmxW_9de(s~8u$+3*? zhdpkl6~Ce2xd_95)l}U$<_sX%yJL^55oyD8@~$Z*NJh4R?k;JNvl^~7)JfXg-dZ)w za;LCV>Ch_30kiWPmTvg0(AH=OyO(grB#g{7e%W3VlzG0^1in+6WzW2m8w{YILH@E`;7_q zMo*#bEFDu@VH0eeeUXUP-%m*}a5pjyXN@oo@l}sL^x+X@E)Q!BAN+QYT59<)Vl{OB z)~SBFq>P}e5G-4|Z8NgMM$5}p9pFDlthB9$e->4-@GD|2Z-+*kR!&K_` z7l;!bp%S_9{4WF_{>sCO7`PD?vgEQAzF6AjzPK`RRW_vzq)ty{76|BBqwTjIenv^& zcyE6-%hcLD--1ei7M8qS1)wIg40_kzzv9Zma{f;GXfLReUGZw}LVehItFBHhb8gA= zh5G}PW1UV|2{9urp(W4?Y_Xs4s0Ahwo>x`az}a6&+0|G5!%WZ_U8?dJzP}o5T%=q$ zWr6ap%5tb1s1F(^u@t1KTEk{xy6)%>V||Rx+|`;!H_BKWsXXM|$Jd~opk!xG^VVf8 z7|W|Iw&jQ~3aZ)`k9v8oS>>10mZw*Bwv8?iH;O~7L=oI;-W2`)jPTF{H)E`9qud%gSl=44xe*b7RZlPK&(^?Q3^BMi|v;) zUQ{KvjGmRtT^BJ;HpuPEsji6N7CCGKOayus&XbYAfiM74xmH=1qi$_yIs4h;-j#0+yEZzckw(RE!o|99_smV=k9W_ zW$(^g9)wt!Gk+fNse~(WfIv0{ZL?DGnbe(rB(7 z5~<>ijYt8PC)kpALkoqQK$Pk@y;c#?%O9kLj(^6biVYM50B7W11MA;1u&SLFDU8_G zvjbs`MWW4H#7Hi@rs;0@{`9uZVc3qEZrMn+HDgEm)ck(nmd|vW`LX%$Ma4Fl#^11F zSE_zAUO0tdP5iTje3U+mICTfo*2l@6S-Eo!nJ8}f9iB>~P$H&}XFZ#&1*e|5gsi8OkWbaXYXh_<$jw;Zc*O;UGWTdDvp2eqiTwED-LBZ2XU zH6*el+5IU$mRaS#K^cBn>0Z%qB;aWhyLd2;mBgQB))H6fmCPtpLuM!-csS)3Z{kV#isS|gU(%m7=wPz% zV`S!Ps*_R6!xPd=?P5vZw8%_WuwkB_IV=rN$2>y$OiD?9*Na<>+x4NATvh^d+F$*B z)@#_>*hbrY2!dI@w?BT22yF_J}X3Q7CO2Mby2@N=*d^vpHX#=Sb0Bjt4e`)V3qnaP@GZ! z4sH;FXpvcGVII^wCH)PHd;Y==Ft(4|id*)%-n1(E(`n%1RfA*wjNAbQyFXwT4J>^C zkqs@o6s|8Di6_;LZlEpH6jL$Vz zs>$bDUxo%+>fKp`sY%2nQ^`xRFTC2;_a)%4wILSHYkb?}V2R{Kw~V)`!b{1Sqj zY5@3w1%M8JIETa51HT_r0ub980ev^@s8#9n;r+1~PXoz`-mv+|Ud)AVsBXp8AlF9K ziK{6b-(7*gFAvj<3Ik`qCtctaqH~k+aPm(rxvfn1Nz5Tf0Z4hD_w$y|;OaX$3Q|^s z)u8l(-IS+;b4N?*nU~LoA@z1H4(`@G(|ViH@|;TvW_>#HnCL9bWE{2ThgaEgbaAU1 zT87$z#oCq8=ISxG;G#)3<0E)+$^6kLT(6)#&4bHqV^=qPzPVk^{)Tm&<4)_b_8+lc zo}uE)z?!X3>N4)8bhj2F&mPa;k=$mTKNs-W-Fp8^ne3UX!_|-1D`$)&>p+z6{_Iy< zM+h|GFN3caWB(b9`k#MS4&a7&HySCvD$TxC$nsZsp=bn;cS88T+qP;ac(O)u*@0!H zuIG~1;e$7~iS#fL2^^W7SA19<0pZ!?$(ar8)81HVIU(9RAg zfkc*=p|-tP!`tB*Ejy|ImEiu;sp=JpQDGZ%1f|C83m5~z03-Hod~+u(S)sjR1?JjDA1S$p#A66G7T}vPWSln1pCBd zo9B0DXpHH;Un}^ty0(8R63f6m$Kvj0BijLA#VPpNcqUbkTaX!kWvRVMuGjk=+7+9-o9eDba1RRUtnM1Jys$gX zYCSe!A3=W|%Rz)ZUcHBn{TR}s;|3%jCY}I%wJJb3T>yj=027_gT7#{w9w1?G{8jww2SYp$y|$ z^FDwz72`Ry%syaAp{-xAq#6k+H|ho+34i<@`u*%n0JV~=&HM2KK&`^ZKiiRSp|V#^;^@N94DBc5Whkd8pFd-jzECzE#OIUN@z6~B#MW!SaJXLMkSncQ>&WF7}t z#q&fFLI{{jNXW|3;MwDMz~JV1@_Svqq(0KcbV4@z%jd^=N_dSi;K^i}Hx#U$*UQl? z!Zs;bLc)tqcu$PM`v!hXqGNSP8;Ma7*@xPP*)Jb6p>H?4Fjq7!YC%P>0EN>te!<_c z$klY9r8);8HZktG-qUZjWT~+*)12_D{WIvAXzTg-7Pi?z$_5f5iNx>46pGOsd+%tIx#T)d+l@J?9*Bd zkcB`sD#pt0ilf~5y``7YB22mK@_ptw$B9RA}Ow;0@;-`Z&;xDgoE89K4C9lmJ@Si8C+xlbKX;Zm}IXvWBsF_F02 zerp$g+-!TzUJ9K?Y{#)J{#jI+O|fFwd9v~c5B)@OH9uV zW7~QRrxvV2xQ_^SDmS!8N#co#+-ckAU&R$J2AGR1?cmqr;YW4zEd(Q02_)`Tv9-C_ z!dSjvY&*Tr_{DZP)^n(n4S%^Ohkw0^EDcUK4_`)VM5+xNgQv00v?xjiiwm3tKjpbg z!TsZ_t8&heJYI5S+c7-^O)GUzNa%|oklr57y&jwVfyx$sr zqw8-BG(3Iv?ssf+_Vv|O7l1Ra15_!?;^5hjaml@HpG#Xfza4!?4m5;NJfjS1il`1q zm67Q=4Dn;AzOB-%XHxNG%NN>D=+r?KcX_OwJMB*O78-(&TNkliTppMB)VHgW_~}>E z0gMV>UqF=iTkp21a?W3VaVu*--QRf+&%5-3$GYI%M1>EE7EJACOrib*4f6ONNgQf*nrMzR}c>FysAjzsI#Z_&MQlfDtXeO^e9pZ;~lxTx70^d z(r#(Rj=WS9oZMXp*nV;) zB$KxBoV3|OPd_dInRJ@29BJzkxjeAWjCZcJWpU#u?R1#C=Y+?KMv$nARCo81?_(&n ze8T}V0*DK|)Un$f94I4Yzb0Jiv8x{3MJb4+OZjczTX0t3Y-95Vy`g_SZfnZ{rwmzK zP9Jc2P`8goaSQ`?qDyUly2l$0#{X;*2eP>L{BDvOeUh|$mn9>kkkI!+$O56E;@Dn^ z*xjYvVRn~W$xEJ;+a$ZBagB#v@voA^qGNbbzFb#q8z{2W{m~9%88CErmvh^E>}`-< zG@D*akjY@T?lW;*k3$2Pfv4wwCUqp1)j0v^+fISCAh-UUHM!bHlX#6d8WP`p{P(E) zcd*1SwlU)JEo22ge;-=Wvb6*OkUAZGl_g?grDDt440wbvZO)g##~a3l_A`AGRYmJ*?6f1cWieKX{wosK3)6FQHo~2e%LBfQm}NBA7Ay3 zVVkK_E-XZj2G?S$O^)GgV794U#c9Yn8(A;oo;!cq)ufNaa*wwR}-2zNESZE zFYKN{f#m`_XbU{bd12Mns)4`t5kJ37C91-uq@OtYXrG@K_4}+yE;f-m7s^w(d-&im@8J4N#ZB9=Xx&5|uJ?z5k)zJ{c z*5h;8EV@9t(o9ts_fV6>j;BtnWRb4!1J7pU+eoAsv}FX_`V9v5UK`$q))2`pBJDUKveunYG$|4OsLpNmt#MoaD13)A6xzPv4K8o7F!{ zla&};dr?qL-Dm?DfDU-7XF};Os5`Wh2akhOk0I9y$$KyYyO^1#&vg!+PT>eN(pTu_ zr5ySqGFW8rN+=n zzr9=;qT~t9j99{0Qj3N%h1jQJp>By`xItxJqL@Z{Xh0i1D(Pw}8Dm%pfYqvL9c9&S z{nZj#65|GT!O5`FP)?UYLg*JuM=Lcc(j}$boE~PTn=oo#!W5$ST!VbqdL}QQ9T-$B z8sZD27oc)}oP1yz$*Z>(V>&48`A8raC&mWBapbbUMG9jH^^#f$_iRtL`@k=?^ccWX zfLRq}`sHzt9m9iJ0_7FoY?7J*9^Sc1zVtvjrRtG4BHIaUIa?K0TTDnGN0KOCELQ!X ztd2v$9@nRq&HU9qdr2vp`iHq%dOy5r=r^pg+;YspCm!B}`LxA@Fo&>JU$MiEbGvZK zMY8?Xf>LM%p)7T(u}b`Ihs`UdDt4YYOzOM0*mv?=9f_bDub`1#bPQz&vZavx(=ss@ zK0#%=SZkjg+p_u(SenZw5|wYHdwCQU1k z{Zo%Q^G+S}wJYu4e^znfZjoVsdJ1?nS26><4}s z-LZ)X%f)}3JS&!}0-ZuT-g2;;pB=2$;27Yu59By=FLqCioBIiw zqnlS<#A=IVSHYK!HM!BuQHDw-YbDJoIu52!bWr^Icunju5{DuCYa*XshjVCqma}|Z z3$G!$_zml4mwX!sED^Vyz{>BcuY>jHURF&wPS@IE3HDPzS-z%O;zge|2Wq)7=H}>r zdp)Kq!(r{dQ@m`#yW`h>m@-DcuIpu2td>-eJ>MgxzJ3Yh(&pUc8E@b9ijG6#+IEw7 zq+j|Wi!iqr!_MLYoxOdpVit4d8SXA*d-`3o=dr)WM0W!WKa#zDJRE;Se`~!qBXmd0 z^o6~5B76PFvr^(qj7zvL@MtnE7Z!7LR9Ivuk)M_5_$oeJ$1I$B^HW~DJZp3Q6HFWh zj)`&dTBRh}md9>E4(P>G_KtRPH$kEy(aWgWo38nDT#8?p*YL_VR z3tYxLAgFg}StcQrBM;*HU}IFN^!#nmhTZ+jfq~H?TN2*bnrZRL6m)X$0p14}Yi~15 z+Y2&z)VpMU%Kl}W);GGXojJO$K1DV)vtbd${NV-AJzcW%s+`;|W7?pEJkTZ~VLJ!r zTY14-zX0Ft8)A#K-!l;YVM&vmL6vb$f<1ml{jD&%1gloGWx zbxEn@TnLCI8#Mh@0`o^2TzD3(2P1Hs%4vP!UC;n8IVzX8 zw{Eh)Y0OuJTwH}aMqyK-TI*NkgT3?y=-=(tzy3k(Bt-0XHV!|jcCU_*J)ImfYT8zU0 z`@Yww#un`Fs4c=*rn6>1a$@0j#0d>aQZqBD1JFJo6!`@JMA^AF{?*e%kf4;<&IqI*Lka0L-3|YMCzk&mb4>NiuoL*x29t> z%A;;kM-{y}S}=AEc^Z(E(y{0FwA5~wgD4|khPGo_a1cWCapmm526gsW=YYyTC*(*7 z59jF|ZrNwGd$6kvQp6bfD>CkG|GV}S+&(pR1X7ROAbliQLX5dTMKe1l>bY?nSQRI# z<6jk%OpBs;u$g!ubHN^8TTsFjMiDm)Q3?KhJ5q^qPVS}z$d9IOH;VF=5cfoly?f=G z%_(2Of*8fQhlk}@iOeFrFRAk+3MZD7-ba@%Hcb|1V0RJ66yna;RafhsbdhG|Sl+S3 zhq9;1Ug(b{IJ&>55lxBW!Xteb;`+SK{J(%z8U7nq}yl$LmCiWJ! z_EuQ+mFVfX;f+%uGHOruRQ1W}vGVFN4~v|2@!a5 zEYV$hsk%Dg*_hqi zM2?F@rs}&bu>lCN!Y*2saa$3S14UF0YRkXf0u%tItNjo&-%ZcqLFqM6?>*2sgZznX z6zb1djq3JgSdo2|tAl(W0VkRQ!m4Civ1wV3L@DSTIpbnO{VwMTI-0TVm$z#95HVw) zV+VUbGru9m-ixD&@Ie10to}+L(CaqpQ;Cl6BlAy)E_F-gnqP=&;qunCFqr=V)*DrsrgG>K} zOTm^gfCbOqT{A)?wQ$C{XQ>h(VUXh-6MAHf&&Q}HkH%iaUp+f>8tPkhLGQX8uZHTs z+C^(659s5o!TrUj?Q&yg+Bk@ChsrBcj;N!Y*J#;(;y6go5_GL~B$1UXGtMlPo`RKf z&)SM|EEk^NNpFOlxP6qh;K&B=oWdgP)vYC)M`1Cbq+A-u95Zgeo{IruylD}DEt1|6 z?8}n#XrvmaTb#Gnc^cp7Nc8UQ%Q*ufTADODT6=>nL1dLyMGMddMqz>n-0~>j)5)(b zAxR_60mDl~T;&2BOW&*(26;6%M~JQ75b~yO_f5=<9Igt{0;Y(@MN|{95!=CLm0(?h ze>cO5(8go)p^^`SSIxTVp~%6B$c58SdZVPk&7nxyoFgzF)IzsYJ*r@9lz@kAp$k&+ z2=5kgiio3)DD!rs9o2(6y)NToULRRfdS$CB$!e42D@NR?;V8TnZUvkiLbG#yX3rim z{z54+<@aSVO0W6aA~cFSxr8O%TNW-%yv@#>E%vnAKv^@QJJvU1CI+MizbSm~>%z{8 z?M9dI0|yg2Yj%$8MM8l#3=~9Gm7q*;Vq1G5$3xcG0SQ^7mg8>;wXhY~kA`|G+$_)g zEp9U{j}Q?ADYPvsT0)zyMGm7ZA)^4M1lFk2x7P{BSF<*rP$vPOVXq8Ib0$qh)=W$% zv%4tOg@dexo!OrwZ=OIJla-tZ5JJ??dqMK-DzA}Jd5W+Q=mb-Ah=Qwi(Zc%PJG7B z03MNn=_~iH?r%a8Q$LX_7jPf=!V}6zD0}?Gf3L=0$$^GaNHn0g*kNo(3!STaA6BSe zf_N$$n9pCfmH(0b(hswik??J+Yi4Vw|0f_>n={)9<4>t2%dp1rteRJTR1>5}LzrP| zDZDAjurVN_;VRN`G~=f1u-LEC-uyXB=_9*Bjo4*Dxf#~J#F={cS_wbEwS3_Jyy2X* z$Fz?uz&Q{g=~Q5UIZ7n_s)C|<`NtYwz)tkh=au2C217!tNc%l_F`1H~FrFkgvmGZ5 zQG_aE1mbsEiPPot7MM+U0cgXWX)B3+A!baxrg^dNTcN7Z8D%iuG>^e%b$s>l@xBFB z`1b1?^G-PNOF}&MZg_Dz=mHe1>t!07N(fdz@aa-x5C@n)LM*=3P{VOIz6f< z0R>kJ(FnW8DXh^maxGk#|D>=LtY#xRZ4q% zfxx)zwfvcYJfRKs$u05;hgtrvV1Chi*KNZ&nBdIIhnU=+MC|5^6*X6N zFCr`!A%gxLTxvkt!E9jW0d1h1<=7IFYJVlQ<2CGHPM!iW^s*TZy-km2;T&L_Hr?{Y zO0euDx%W2`@P~z-mKi!t8`;%deF1)zPhl+Lvdgr>U5Y!GRZy$o`KV~4t#RQ8j9o*yTtwxz&j4`>~ZQTv4U#z}f&n?s`LW7(&ftDi& zPFg%>OA1_$MW1{>LnCTBy%JFZfS$82)7AZJrT?sp<1+XEm%`1zzh2XRJqqCu7x0!; z4;_Fb^vmTCC5uNmchxpgq(N0x0P%CT*8nBWMAG8GL?YXvm|9BBMi9ghwtx)0UmWae zvXMqH{M{Y4JZckI2bO+%XUFvcV~iAI$*r!Z*N)e@gz|Jx?G(Q13xPmq#xLcRROf^- zah(*7?gOH$@W+|m9N%DuZ6K{0)}8`zU2W&^JsOP6s_d+>cbH(t)s~5;lMGNi;5m6j zvHP@*Iqy1n_Hpzl1*+?$P)1v9xVT9-2}me+>E{SJ)e?*tpD&y&O#&c zqxOhS2l|9nl5a}1?*mfS3f7X7>IJiFyJ42m>=-M~i>}p0#khA3A)K^A8=y}>1E#dE zWy_I95u&HF^$CX$W1gf@GTPjYbAIq?A-aVUCn6{#w9Vt?^>%5q{HG6NsJ%qJLYW2E z(i2mzEA$MgI4WDI%S7qNeZRnmuqjuKZZl$FkheM+kq(gjEG(1dG(3+onfo_^4BDGN z$3gx!;Sm|q6|Db~>*hVRKTEU$8drb6vi#q>ZE+--kGW4PIY2|&0^%#_Q-?n)dM~b2 z`J07+kxCBs zFZI<>j>QP5o)J0@n~m5W%K!NnYdS-zxYdK^5qpOQAgA@vl$75LsCsJMIraVxOB(M= zLC@!)R&vqxQUY*n4ghM1N+eHbjeS~K7U$2gEPYP#=ug#uY0#kbyr2H;*nIoJ>i=O& zaz7iQYo#+AyyTb ztD)cjcz$(f<2;$kC9f6m}#@ z1)aOo_3J$B|M>H3lW^vbOG#w%vx>D`-ETbnMMGTv zeU|ro>(`bH;f9wn{eo9*>OSiqH$DM#yV5HKGhnzf%5VDq;(PCzEyHhE2|kiTNq}0M zA;+_S)FJ#|G8Oq{3iCIY()<3>z<<|#>hE=)__LtoPbMLMX2|+K@V~#E68_7*v`4Mx z+&l<7Hh6%v;|nDX5-7(!;$m7}bGO73#>1v0We0RIgZ(e1_(UeAw~@2iqq`&CqYRUd zlw$-7XgsF#3G;FNEVqUxddY9DqKa((6^4Wg#@K^sa86v-tA(v)qq0HjQy5$KE`K_i zKuB`n3M@P@S?NhtVi!}n@B>G53RVreKy3IakIKZboy!}MTDC!cLaXzM*7Nuz@tx6G zuvPSAm&;uVPucBa;=X~M_YopXa4&xLkgXW7JL)@m(OuK3@eMteVpNQ`s|YLkh0Rf}@k?o4o!K!jRa zrsJCjgz}x`$B)3Ckwnm_O^lXu0qf26cZW(&8MQy4Ozg%lvrZHrBYki z32lwFi@Q>8n|Tm`wn;1-wsnL+ZDs3}?6`o;kT z2CR4WV?PXF6Lkn`4K3QHP`-=w?E@OOYo&RfE^?99G7qoo>fP()p62@@-G1!hGLV6D zpwe$-#`);+m!RkJ%{^O~G{pJHF)1hDVZ1PXh;0_K1}Mw&liEnShBw#^5tW3XD}C-Vf6m<^2Nj>(+d=NK@1QAT3$Xb-ZJSoJ-$w1SNg^k>r>wz4q#~g^@=6DZfP#!mnD!sp=hH zSsel{S24!UQ12aIt<7Zy0jh8YYo$JEE3JBKYeuxz_=A9mo$hFu( zhC}4npm5<~FHMJ>4RR`%@SU_iYiv3?h3hGZ58gA&1TI1w2B9*p()Sk{CXc_5%!+Ox z1_b(aMi#$TN7xZ;roDYpIDf$G)D2L*gi2zE8}C@IW|albm%3h+g)`|eu=DXedE_Q{ z5+rRr8DR~}OsEc@UYYlPhJG4Um#1T}rFCw5ws&+_45=dNRn?4h&E8@4jXB-~tyM=^ z%>i*(u?zp`ZgFwtT<(Is-ZM|0@^*n~PoK%M-_}Thm1VxwiNT|~ zNQK5Awr~m=+ehz%KLx!LhzOQ!o1hR{Z6FCz@4)Pk=B;=J4hXi_%IqLRGxR{PxgGK0 z)rcWKq1SXHYFrFo2c`GaPhESJ(n%j(a5OM!9S``Uwb;m?%5|4*6L^>lV@DiKtG_CH zb?gGzB(8F{fXV;55+k-`%pGZ zPKuWYG1E{Qj5k|$W`8m40Rf`xtxQz#oIo04L!p(>nJYk zp!NNSg!QbJXGdiFy<&lTvawd5jr+LhA9mj1bslhv5S{Rmu{jvALgJ^eZA=8W(A}xN zpjicbPBSMPFk4lcz-DV}@ zP}J*jyVP%8OYSmq$q&V+G(OOXVH&2)tmW>&5tV;bKgdadD}>*34EsScu*xpkp~POF zKe{Q%dDDcUJC_fuG@r?ZbbMGPm%SeZ;C8_Xy#>BL>wW=4JiWoZIUbq3hRRkU%4G64 ziE|?P3mA{Lb?1+Zt+kF}0(DoAt1rOp{SCt}bFlx1=T3h%+tX7G9VTyg9o<3-CY;}d zvy#l}jtHNaRDP(BuEx3-JrS}~ls*=#KYFw}#)nYJGZ#~$sZw@WseGAzxly;WOeaT+ z$3GsJz^-)WR*fDGr=+47&aN2W72_RONByn?^+sf8sk>EH7ZOE2>M5-`yA6v? zgr`oLmM>1qs6&^2!}5}*XRB*eqBy@8Kebz_JJl|lo=chAICc|olh~u;8eHP?p(<}A z4Fw;N734!dt3+6wFp+WhO22(X`IHMf^G$_V%(+n8fUI_udE)7%yA?+OCCtr!4W2QN1%Y z+gGqTM^W1_p4(eFZ{y3Pkj5CUbXjyBi_A>P&0XuCmSdX6*eQ#C5x7)Z>SHH)K;w3N z{lNBt0zx3l{$j z@1Y4h+CYN60w`tsI%atO(8E;nSEKPp@CV72`N8kZz*JYeFX|t)*Z=KB(tl*Ff9I|L z5q}4qzhsOOjtk^`0<~_CCNh`ZtiiB)j;i)@lO(E tY)=@egJW-YUrNyjdg{M>{|ASQf7IjnU+v2LrP#!u+&X`L@AKQ#{|6E&G==~G literal 61368 zcmeFZ2Urx_wk}!-N(Pafl`IGdNDi$aS&~SQC`o8?&d^{$$w@)UQ8I|+ERsb;a;7CG zfo@_0P4}y{_d0v8v(G*6ynDZE^A%lHJ!{N4N6i}ZAO9G$u#?#Dz-2WhRV4ri z2M2fr{sGv9%jJr`(8mCvp#ks$06+lX;Yb4)z&$GPKxgGm^Q(G1i$V5`ux(sFAe0C&I(;0LV0 zZz$jac!K{e0B7JTpbVb30&Kve-}nk5M>|hXS1Cb3XAc1jYZpr!0V@|LL0=13K_P*g zf`AOf*VV$x!N&8drHw7rS(baZsg3(8)LNF?Kvd(VhO2^&9aP2N-A316^MRGWgO#K; zH$;w}lc4@9e?;yMVhk9w0Vy^@O@OU;Ry> zg{6y^r!1S77t~tnvBhIiOKWRUeoG4xYknaiYYTo0YY`!SYY`D^aZw=&;m1OjY`<4; zZS}X>UA^2L|5CTLm7tBIjgyVDrw6DFAwf35zc%`Rv`#r0Ybz-$cN+^&7x%wbuWRG> zzos)ssNBB;DrE$J(;xWTUw6P-z#Bs}=dui}Kf_s0v>)@4F{|7$5 zD*2a`{7YTG)b%fE;9n~IYjpim*T1BJf2r`V(e;0ry8ezFZJa^4=mX+H>co7c_E)KAV7DzOtSA{t$vg#M1o zY$s$FxsRZ>bRQz3;kdQHiTtf=f9ctOu47OBOFjEr$Nt{0X@CS52fTT>6aWM`+NJe9 z>yWz`GlteH<_~GUarOL50_{xnEL&pt!eD*5Erx-7A@-aEesawN3v_QqoaZgZEOoV! zWoL*cT^D?3plnidJz?_lolV|0G+Qt;7Rb7kj0Hm6u)uRa-yhv{l02Wq>r*S|u|UTi zv=A1^PQ?No0x;AZE8-iB1h)Pd3-l3ZV#G~of4-a*5svb~gfN(6aC$J*?dNUkCv*)l z$A50nIu;0fin7823gQ?Q6D)vi{NA=eiP${{ZndFtW6?ZV;F(rO+W|0)1rTHqMDAH| z^4`r=X*kLb5(YUCfh|8D!~%@Df0nxSNa5PWL7Qz&=JT_qU#0! z;nF|#6a&vkM@jxt&>waCOF@4eoWDlUPqyOMBliDdgLXWb12m9gFPuv44AgxrJPE^W z^i3x%3&Mb?%Sr^>=2EEC4k^;MXElCVL$}uRW4a$JtE+VI5%l3*mJr>9RIQ=oGRa{x zgP2$SW*PX*Ox7kjWflbuJ97b2F?>PV4K^OR{bo6~vf?o#cn zUzRrU)mE{|&Ti@`Db<7MQcIFqcK=2RP46ixLPU|9U(7594@HR`n zqMr}?7VQ(*T1(IQX^B3B8BOlzS}B$_einoK`I+FN9q!P2;f-CV-EFIe4;hl*<7_yh z>-fm6bid(02_9X;2cP~uzTi*1%}@`JVDx`!&4^CpRQqnAt%$_ zAD}8YxI5rSVDWt6i3w}gPnkt-vRn~76}db-IT66WyOr~G!f4UN3$pG`tmYH?;~3zb ziel-o<7{@A+BIeZi9!GVf0#IdgA~4jwx4FtpC;xka@CyXnLp3^|A-}iN&2NHWaIz* zD9Ea8sU1DoayTQ@cQ7tYva>OZiNeum)xJ}-4&+4e{JUE@{t|bTEy5*)yM6@T-`eEn z14twVBnrF8$T1(@qH~UP(3S^ zk(kkxVOfPEW^;H-;etpzElSQ5hnq1I<*n~n*_*h^{fA<;0HeImebkAO@JFD@FP6=L3 z!sHF>_^4Xdud=cZlj~VzJ{aobr=SgbINXMyfP5<4gcAi)mrS-)&$CoLb^Vw$Ekv1p zc+uf~PKca8D#)V{Er{wD4|Q?QSW<6wIdJa@F?=kJTPZPpd)Hin>@{efVs(AC?<~M= zKuw*1jlyk**uhVjFpRKCd6#o~C;iQWZAL7>p4s7YMxcQOa`}tr0%KrkLw|~^IT3to zghYHjGC={be6(Jq?(h<&%abKd9|bIc zllpW=%An{xQ$S^Ob*QT?#h?y-rPN=KdL@`YpzVbjZ?f4?uJVVm_yjw;1${?r@wI&z zTp=oAcsNjI8uIDf{RnlEl2KqKJMg8f?Yy)=qF}WCN3l4j=4QT(_v*)tlpB2e1g~+X z`!JWPZoO_F46ZT!fcrr zFC}~BYVsG(B+=wZ7FIH2vjLBMd;RSjI$zu^y+}NI=ufn6i^OLs;} z)9A&wHM(9J>80CB{L0IU(mZ6$ykajU5Wmpfn$dkv?aX|;Rdr5P4I1?RM2glbCRf1cfb>xyA2{oI6kvfCK}?kWfKCgo{@Jb811!)> z_9Z=b0OthaRQfKK|sT zZxu&qh)fVxl3Zh#D3;?Ibt-G+LwRU7dAK;%3i4HdevmbDZJFiH(N+eZ?<4yLBO^O_ z(Ch8oq35w`Iq%W@i^Q2%4Eq94tqiBC;_dg;8`ezD7n_uZMjCbxWeU0?RSt=FNv6I$ zw5o3rl2mwtONGyZ9`}4-?sXnDSJ!6x`s0B=Utgf&cO+tSoRz}YO1tUG9p3y-1F}4| zC}mdO7~xBI1}pFkY)gDU89UvFs}0>M5_M9tyVxPmZKyACt}af$(bG0uok6xKoGW0x zyW-#y&?dKFRghDEgbF1`U-LO#G?b_xSuu2Wv`&Po5*Noe;m4+yOZM33b9YXaS&yu= zA;y-)q!L!gt>2odYT{pjxGM=O-MN$_!F0F6?#FiHoCDlc^xF-eY6Jc()TgEUNapV6 zrFMHz1H>n;2m9kTUQ3XhfDcQ{sb#T=FJ{xB1T<30%@DaVn*!!Karp%+oG>4}`-Fiw zGntN$-kzpAI~#iklsMGZ)wX7XL!!_wW#C;~ZhH~*M>k>EZHut`WJK|sq~_&*irt#R zbAXN_H5(C6PRJiO;lPJjfbDS&7I*~0q61@tfHOH*A0guSycr8@+^cE#{ioP!>jU|M z)@Xf3A_(e+Uj0X)F0gGeNUs0>c_CVlEEjrlR^5siFN4#Iba{s4drWiY*V;cZC4ACG zSRka8q!9H;>z)t}v4292%(yyUjIjO}q~;!iS^f2N!qbd+mL(1W|U+&{~R{h50i&xv(1 zILVy9r1i6qKl4^)iY(I=`;cam%%3Gd{-_2%qX^j=^HrGdFBO8o<9}R*e95Tjg>9Oi z1x&u1O`f6g*9`qBi`u(3Ukb?x=$WqYwU(0%~9ps`$@#%vTzsUZmo_u9YM zunQrBEGPNuVm{WwPOtIhmAfqTpc4j(V3Rb1Sl}+F=j&7YEFDEE&=UOPW)K}b9NE-P zqkLA!fqBxB)GTrouO#J_YEeti0 z4Ov8^p!<6LFOU$&Zh(^tsD4%b3TJ^u1Oz5Em%=e$Xh6)xD!NO(FwbiWuRcn~45Wd; zip`+@zu-Q)j%@gdpsmjC)#}PV-FV0SHiwH%(>=d3_ESR({wJf%7Z`zu-L(_e8_sV9pg$JbrW{G~FO!c>m=hIgam;_9j~3f)|LXF7BKtR?77Z;)W) zI0=4PM$f|oDx*EfOJ|e7R&ur97Rruar?$gWx)S9~mS$x)4Uhh`!t5@d+;JM^#xC7b zT3npV8Lkj=(J%RVpw6No3CbO=23k_~2aS8`nc~*rO&&BGE1Bj-hmE{;i|m@I1ri=y zyG`bCECFSTC2}VA5{rg)-dchx876`ab7WIGBGvu0vmLSed3iei=xgrIn?y z&_6S9M?h<;{K}Q1ucgXgzLGOz(rlSVF*gt^gW=6VSpxY5v;3*kmfKnV92)y#BV0lg zxV0W;uNBQFrVBT_udBjMeH>0LJmL`qW4E@X%Ww^!1a5qAtZlS=8RM%pH$6utEAsKG zw`e+24zBG`K|T*{bo!d*SpH>@x!G}!D2@i|lTkK#YpyHt^cL%MMNuB#$ ztE&CH45*&9JYDvRrbthnsQAlUE%FW!oEu`|!i*2EisM|fTK=w_jt;DE-`X%sROF0J z@u|~4cJXq~_IRmI+>XrOZS8|hk!4nGvpn28cI)1GdsLdvTm!>3wm;=tX9&wZ3ZD<) zOI1Pl!hNT4>kw9UhcX$H+#_~HhCR*?l{Wi=W-fm9_-I7h^FrpDlT}ctySh4WiS;$B z^oAq4uM%JVCzKVb`}FgQ2S$^2wLxrCb@?arhLgBBctR;!afT0C!JO$P_|!f|Me9Y| zHfWI4Y|4qdGWWO~%#VKa_!Mh=+WyEDnw!SKh=TJw4^nt?TBEZ51D6+fHQE8ASLAhDkn?kzszaRDay&f)!ts5-x`R?P9edgDkxxvg>-8~N2UhV_!L zGBsX3wqYy&Aw}x1psxp--3Gxcfl9+Nf+aB9O`78m>MP;mw_h6I%azLVM#pvyT*545 zhmGjy8```{j<_k-!zhW7tJjV7{}F>v$>UKdP4;DHz4V;?VIA^Pq)X9MUeU#moch|h zBtmAcDx0zn@(nh$gcALpIEqvcUjBt3D-9y+=Cj>dQSq;cvq z`fs1yNTw*f-IK*3)U6e0*%ZO2U2|!BIeDp=vn`;bSFOoo0vt;*SJxa=`M)u4w!Q^NN&ID;LeHQ#iP>aj*v01THqsa zKIAFqjDZH`U*=69BV6Nf>+-0D(FKZo`7x0*AAaba+%E{fz&$~t2_f1nc-pD=Lgwl; zbIef$Pr1%TD*fQHvdQ%lXP4E<3Edl)v*>Nz-9jK0YK7hRy(60Fv;R#udp7sG4pQG535pS72@21(AI4@;0h@fEtAofpA(YiG zo0UsZb%x&@1$$C0-mQD^H$*U@!&JQ!estg+(W7~{n;DKfDk#>ECd{t2An{++IK+ch zP|CAx4twhhy?=$%Vpu**uypkse%|lTB+g^Pn*KkvY5aS8QRf6F)ewGcR0y&pvugx)+D#wLy zy81a|fiD`Iwy1Oun1{8Q#KHP7{k-r4p~ocPG{{;`-lC9WZ0>7io_RN79_kqoH!`VN zS;b$)V#Lj!vlb8941*F$#gUb##|?Vuu^RRLAdJz_(?ur{jc+%ojdm7YCj%(<9h`tiKJg#t!BW{UIMJ7ZTU~jS5^sg-|M%nM) zZABbTjX7HdxLZ9-HAxG-8kcsFiN&vXLmL&brZ-Z0P(d~`vzcI2R?L5R{=DS#4=Sh0 zXRd_p9EU)}@R;rAhBCeu=Zqwy^8OFzSFhK;W!_0%BIQ#OIDJ46Hs+J0vO`5{6LmyS z96vdR1ulc`3t?Dz7Bs$fsH9-ph8?BH1`-(AABbiVEi12*lsYtrDh~P`Y;f-HeCuSC z+{kPW3a*L#-okb?V%|(UKHTM!-#MER?)u_`zf)+_IeAGr~zEh;dGAc zVnEY45@J@(L2lO~O;dm3%Pc^`S z*f)t2gl1Nk`9{_4JX5J|)g31;UU`vOyk6aJOUIe%#{15JLW|L6-ov|sH)`0K zkg~7jEFNCiwtggK3p^dks8&-oyOmMfcv6Gfn?d4U2nsfa5u}T4Vmu9Nif%PHw_9C* zPH6Q+^2URUOBoJYx1XxjAU!EI^pB@0tI1al=Q`!*E9ktWdr1lsGv7QNke{a?eG!)3 zCT2gK;(%`$Ap3ErpQ$G!wRQI9-zSr`Rx(GR;QxM2{$cNYKrXo`V0ZY&Vb|W&^W3s-sQzP#G4cj=LG( zTt~ka`b0X|b85RL^NKIqmilPvoL98m1Kz#vy9PFl*Ivis-Na*+577JiAl=++J%874 zt1V}He-n?vnnAQK+_QH0`)KvUJpOR!MW>VmC&~NjLA#3=L*&M0jNs?RM>{h=lC{rY zzYd(roldm2<$=8z`G4PXDJkY_&0`FhjLWWbL+iSm(zBKPhUO<{>HFPb_m zVBgYId&W5mv9U21vpdS0qW{dgh?{*}E~BxWm~^xo;BXG>ASfyIwNjc`iP13Y63F1> zef~BK=aj;vqGOkE-QCwmYs_3rAuv&`Uu?CPPvrTM#CIIibB|Ws+Kj>Wq&U-djw_{! zNih$2J47UzK<*uFZ()|_IvkNW=d}Sfkz&FEFGL5FI@HIa!@@Za#2TYV2Cml|Vu7ei zf}84>1%8l;oxVLq~6qh z*YnyN5wT(Xz@x)r2F=U>=E2aYq{OV6%5-jiN^;I9JHT1)zKU!RU$K4ErkV!7;Mmqq z9lUYFB9#)AfHqSscxVTQj-um5zd-DXnLi|kz7^ZkBm<~9>muZa^2}zL#df!Ah5d9V zmGBbqmjH@({Hr?~Q7P>c)e>3A^sfa)(B#wS(LX2(gJf6Wc;VgjR*%%;WBl3+*+;yj z&51Va{JCCxyzBGvpf^mi4XCR#xuELpC?^sk6uKLcX(g{6-8f^G98h-ZFpPQRN#UEU zQ#V#xCfY*zLkKPzLzvt2FeH$&CIpv>Y%0%%+EgRR_f{E$@eCi~J#le9siOHdUp9*U zrA^r?lfffLci$KCO~ci)rtD#epqw2nFaVX*2b|nh%=JIwMvRZ_?4kvxlQK?44>yu_ zj3XtTa^{$F6zVTIE)a0zrMYQ(Liw$z1Dpc94q=(;Ax(%ijOr>#{g}*vSwi-(NEuUT z7SxAp`n0`<$LJ>i<2N)NQcquzFz!@>n8GK-sh|oW@Ycl#FYaFad*2oL(l%)?{CM@n zLE?@Iy9ptqnTKTu0~EAZx^X@=CME%yjd{VZBRw<3Gz&VufPvy(Q;h&-%?{n@OpTVh zrn?f4>t0(E1(A_@wNgX%XLQ6iS+omvwB&;wiB_B(oo?tQeI94@vP!z#eVGzvps~{(Z45kVcx_kKC? zB-6f6>*NXuJIcXmihgu;9JJ)dgb{ou?ww5fSry89Ojgv%x%t+($9#w5fWU5gSb#T& z!E3EKgW3oke{L69mezuMHQrl~t)Q8EG*zIO4R8h`+Ny9C?QHh?Q1wLRl9&iZV$WGe ziv_dXh*on|imWDM?7_2HT3oxY?tU_EM#+`=14{$6FURp5Ek%=`FP$$KE#?!|u!|N~ z&B+L-%3BLpYv>=R>b%{Fzwb2ZWfl@6d(K<-aFp#b{BxwcK-iuA(64(+S{`~O zlLgKyGY(7%Z6fs`dz#Iq6$x3sH{SMx6@rPh--X!@o?Me-0X2|$em$vPkOtQKwhT5Y z2Ro-3o5u`h?#TzrVgVP(sV;wz_Z{^0(`3ru5)Mv4ZFxp3s}vRp2!0vvOg(^BNU&>V-Q0FGlzeu5=6v|0I7Ujt z^EGo%7(o)lae2EhoIgL5f& z^@kx}3fM{0q@Kq2uosw&$22T#k&~eL$4YN?TF`~QP5)}7BysZQ6u~zctw!Xe6!_KM z=;21$VVhYB$*K#b$#5&{#{7-g&c>*T2sWQ54}EU;_TZ=;%S0t;`W2z?ECvi1bZxxL zb%=kc@HnyBh+);+N6)bmvrdLT!O~E|Kpwgy3MW_}n%|n>&wVrOGlI_VbJoOritnr? zPX=L=GPP~rGjoXBl42=5mCK6vBWJt)Aus-vN`fUbZYg414}mCxR!^^vkE=WIw|Hw# zkdj%-T6Gd5s*I&FkD|-QQZLpt)<7O4CCtka6hSb^M_Cg??) z34=u6rG^$tjLN;tBjN^(mT6dJ0TytuOKyavE}s|UzxXoKUTMcA>azT%~l(6 z`#s*i@sl?vG4864%WhEyii_$kTKAE=FC6(r)m!8k&tyl4AF4%N?s~~A5*p&F^8Ki+ z2#voMDE;CSd|Ep2-QaX{Oq(REsR_<(KRSPTKTt2%0pi?qWZD+Ld;-}D)~BCqiftLe z&-dx4SGw=vWVTY2Z)leO@9bjnc%8S7V%9ki%v z@I9#2rK>l5R=n=9_aO~;;!uV~hz?<8f-=Jbs^eafb4tcXaLzAfAyJI(Kkmg96EKmr z-NQ-jv{+FR@@`EYF@_t|)b8)SXCm>RopyN{D0eE*R=(+dY(PxidEDMr)BRBInMEVT zzHPZgdwGoVsEh%U{r-q%Wzf4xsE$BqWpY21ZYfFT=~w@=fYCNYx!|fP58OA!IBD1> zy6n|7Z%)qA%16h-haU&0U3UpK)?7(tIwm*w>!*mT{_aTUhcky(?nOFWpTk--roGqg}O%)d*W zm(cIf>gtOH3_EdA!M@ZZTN8DsyRl_~qR_%wXsx=#QPI0TyJKGNE$K%jwlfn zeEi%C3(&wflXQBS%koIXFO%I=ua!FNcGXf_2Y(>|v6a1dWBKbs)x6E5Vk`BRi&yx# zj~|lbGc9ewqa0+E7?7%ERJEFYE$Qj-gOF7xQ4L+SR-{2#xhP}gXyr&=V|CNpzPC8H zUCoQweb;89JP8+YVdSA&kzUMJ_ghlt!F21Iq~$j%_dhzDmAaF2oca^3d+y@p=ZBR# z9})_BX&7oV1l}Dlsc!gw#{vbbURf zF*UDEG+2~!o7`GcO9BSGn+|XXL`kI|w4t=z78$pLF^dk(GUFdqNG{5J2Oji%cE{=M zaf{L$FgI_}T}Zz)cWAh6tQNNDmRs&@Eq(Js#z&{V)0BzCh389l?(5-;k)io6f)^`m zb>Hs{ewn)X!tBye{nHtIV{OEp`WMQnT4NmV$8HtU%u9DZlkg&bLQi;lyyHKi+qJM; znmDduH&$M~F|talbSb`gt8W29b;rN4S$le>PaxB$uybhEiMQus)BBHWvS%bXMTjk} zmd0;Cyau$4M$6Zd#C2Tw+i!+8ho~JplI0yAl}W>h=E%wIlNe$eykK5MN*kPCKK_Vx zz3Lb#p)K-_C8!=(xg$j!&5mKI9tOkI)j@C7PMXAa`YA`anS&f6TDejSL^UUz92<>I zC-m`Iks-Z}0tt__hokSPU0*kLcw_)6g`+aN{PWwMHEYql&6WAU@wtmpaMXfMd5@VY*}|;+1Y!79-WvLXvR&%GZwxNp~2rAEBN!sFHUo< zYUzx+jkIZ#I)rr%6=BVyqZdf!PJ^VTePuRw_-7pR4ZNw1 zD^JMfFllrLk#oul$eQCYXHmX%wV~4JvE~V_M#ETF<2G2Y71Nrn5h5z(694HrlQg=`z^^1>cne)3uL=BAiwosOmKP3OFeIIxgkM_j_`c!&c}6;gY5y^ z?LuCrI%A{pi4-hAy*=~w{09EDoXyi$ZFq-#8(zc(%}POaq$2dRuh*w~OW~A8{e@5# z{N{#Hm#8{o*D4w(^U7DYr39L)GgwVs#C}M7PA{fsd~N>ukA?hv=;`%lC+qL3$UiBY&>4nYKsY zRz=T^kb!2cjK&od>NW*N*B=jSo)x7%KbfmvA`#i0Nl84j?Ic7L7)d1`Mdy#Dy-b=g zps1#lQJlcb*dDz?xCJlT5NxImkUf7_W>e9UQAKruII^oo-}w2VP+|y76F;lSS%#T^ z;>k|6blKz0)qoES>iucGcSs6W~T|TzP2oXzCnuCo2Pgc*kn! z$DzZyxpr%Pb5(STbolYzkPxM@!){?s)#YQ+(J>9Ko-;wk5AXM7;2&ms$lumEZx_=_ ztkL(V)tPDdXAI}YJ!ue(VBOO=)H(xa+T4W3>E%`)SfBV9WIGlUqc(z%+1Em=|L1~g zl79`VJsfYuqy|)&uh&j6){siF2fVrG*hF(%?XpUTE&fho4667@PT*UOAk`)d(}%W) zUQVLaJ7v$DN$hW5-C>8Gb!1Bn-omL;d<6HM={R+4{Nj`HB59gQXs|GpB>KoR?#i$eK8$RJIv_l7b$vua1W@4DlkT%GPE?7u95&y2jy>_nw=8>G>0U-Zq~ zrspu9biHeF$qKhVRhBmJQMp_m>!+3v&B{kn5eoS;{gutx4s6Liz)5_X?L-7{Sn;R0 zpp5=c1S4IZHCeu?0w2j`r8`uc)`cHBk!^EcysiNZz_JW}mhaO~4sxLZqGhY0c0&0k zPZU3OYf-4QkPUsb7`2SV0;CR&U@DZ8i)dom$C*lH)Q?`E` z;Xyg18+Iv>H5Wy0KKkS8D0}0F5odvG9z~k%rfiROpG?YxfqC{s;L>ZRIz?vXP_|jB8_j>?qAQ#`Y8+Jj~N;N>i&Og1_$*joVu08*Wdx7BD`4@ zmfIy(L6+!t!$)yexZ1V0BgCy6-+639bP#nq9WWR+&skFyrn4BQP{YK@<`^&J%kaw92qzsb>~%#O7Y zc}SGEv^1Zj7rSqUWkS*A!C(`D~{)8xtWwgvT|7e7XVDlimaROJWe;l9jZ z)zahnrmAkK)dm-e_32meDwenTcM42Z3%N4$*{AYI9_y=K6(GWiGjO2np_AOW&Db~* zd+4CW+P@%+`w0t7AG=L*B41aG&t0Igxw@iBCcjkfFEv4 zYpwMT2X%_6I4N|;*XKV{WHt)>M|eGdz8L5}E;v8zRh4+RHe7(jTInli+-uTraRd^_ ziR#8L{@*<58|NsfWBTr{{00xQQ^m{Pg;2VuoAPYHE(}l6Gnr$Q5-N;U6&{PfnlW z#~eCaq;Nhe+kbw)l#q#HxZWY1yiQE z=9j89{B{9O!qG;}-Z|SotF2E33(8;Xc zX-x?4DkRztaLlA( zg{VkP6sOO3am3>~k22$p-GXrbGWF?xh9^0CuUy^Jp0NtaShgg}M=v0D(wPeT*o-<$ zqi#NUMvv!x3nv)#jQ<5s7|c5I?R@@k*6V-e+ufWBvYfh^dDH_w@tj^YeSz9wPMu3J zY=-rm>Gc?B2mA^!oF~!F0fRqBX;M+(LNku4Pnky-LE2)7&=haK!wGl5gID1SNpr$Y zJ)KR}4fEWTD>}C&>8Ze!Rr~x~tTB!H`Rsn))AP}8w%284`n@UnScAf}J{mAC*un3O z$uKUx4UIBr}&$oRqAnZeYot`K!<`b=0zFcCU#nOl!+Kw zq>a5*gihU-$1EC4KZ%$OyKwd8LMZ-@&>DNnfuD@c!kqYzqsGCPo+W%6Y|1xH=DVm~ zxPIT}UK`{q~!n-+rNb9eAgX$;ZG1S0IpM-z}|o zTCr7qjUrbk-9v1Bn0at}Ye-p`bu}7Bb}?e~WzGw}Tv07?WKl%#zuU&Cl#!D{<2NQw zZOSUTstS!~Zn^aoI9IdTnBcH}7WbrEN?G>e*KKEzeLBCHiF?SWZut2{iW4uj-i>yH z^tnD&7`ck`o$(%An58@Ia49O#LJMK|}m)WEDaV&jjb zx%le+rO#JSU1dv#Aq(ZOO;s%L8Kn846-vm7k1zt?iGhZQnKMS+z|5K{9_{T-i-a?*i`5#L#fpV`Irt{K&EF}ab=7<5D#Wm~dpKwhM>(7+`$nj5IWcxN zKA6S=Z{#_SC}4RpPhYWudB#fxqbbLbm%%t6P|;b_8w}~A(j2!Hq((}E!J$Y+Pz_YY%7zIsRkf4)Lg2AM_IVvaKxXaIFf!)obG?) zRL@>nUf%F?Dup?DI;^Gb?%g^fo@;;nL(v_~ z@~=eSVB$WCN`2YOYLzL01zP#^`#X)yvW_C5?xq#@Rj-m#7I`Uz$%IC+n%LGj-H^58 z`%D`6WbK95>?1 zIG#?M*J!*QIgi9x-tI^71ZvocuvTI7EV@os>SP`Ov*(5br6c zyPycMGDysPJ=0Q+YZ<|tKVD>O699#Ji1qD0Ov0Pi+{@*TyD4#4I%<+0N3&i$9hU2m zKYgBqG3VvqV%g4beSGcqNBjnAa|7h1a1%RM8h7K)>p*7}PV| z(szzuAQeMbe{iDGsQ3^_cu#nYIAqIYlr>Ll~IY;BcN5^tAU(IlcP)i>*Yr zzjwD??f4CW1Dz7%S-#0P)8^7pFbttdFi3Z+C2c#vFYpY>ZAjdoR1YiMgb|(@qil;dr(n?64ZmU0h`Jc~78Qm5gyo`c?j= z*dWoI7qzq~7$sv7#39GimQEvnb&~gu)ytSJStUp$SL?T*kdU_T;6mo}zyN21P6kWa zuX9BKr*Uar;^!A#K@{8DtqcyX7@{wWeQ)&kv(L=2My{w2V?Kpv>M+9&ZW~+oO#aJG!HNJM1nwZn;^fg{!eHO@Fq){{tUEI}8dHiPH z%u-p&Qma?!*;Z6&=6$;hgB=yLn;0R)CVVS{uKC;Jr3>DS+^qArUBCNu2uRZL54c0B zmC-LjoY4$FkN=$i^9@IlE+<4{HqA0k;T9 zwwT?7txq3KBOzD7S1x=31Jx5ztfyivA3|g(kD@_jHMmfB{)`Jm(Me;@#Xm1Bo#+L# z_PSnVUjhB(R@b=yC^hQ8a2}WYpCkgB(EgLiUu)A<4Ar@M_{J?A#UT1Szr(5DAk`l? z{DGf>dH-yx%W1aMe7uEG3rh!AX7sfkSn5Hp^aP1_l3wB$_N;xqU9NBsxw|*9(np*| z`HciQ=s%sQnxRE+wD}o%a(Su`_d2)RW1Fj?QC6`=0tat*WK0X}Um{=fJFSL~Ce|m< zM3GoAu^hsQDx-3CtBp=JMcCkaW2JdWn)HA`LC%pMT>~}nghIHmPzMjACef+hwel?~ zNGKbUtf(k|cETHRa#MyVzH>K9l2_PQl6|ks$;3B!)5+Mh@!>VX!b#5R+m)Z+8_+vT z1$MlHK1TGLqG$&1X1I|K)HD+%Q@CF-{In3}7XKPuqIduK*l?9wYlhLO!=$Y&bO{$) z3XLbHoN*`$aIGD=UAx72*Z8?7A6oi7f#jBfSBuf+j83C^ChgS5y^2T&bzd4Ez8I2_ zCsW)qJZKHOb_+0as5WpIIV0_0tiMlx>nKjN-wF_Od%jzjQUqPthN(A>=8Op3TB&Po z@WV{;Hq^)Z_0i#y#&l+O)R>EsIcx;@fmVXF4dA=87;W%yC{U6#u?q?-4QEh~74!|a zWR=vDx#Ig#a!YIE(I|iG^_O1KH7$I(k}+;{(QgBn7ebb2Axg7EYpIch!wk zt;alV6F+;;4ynaxt~le+GX}US2iG{L4|xru?#-BtzpLbNBrR^YH$R3o>odJy%kEpM zqso`Mt~CV~n(%S(Gn&7xh!m|wv3R#TYT=W#T~wsPi%uzyams`!_$}d> zN)@@S*z9u=!=Vzjn@>_&Qcs);W2|&WQs(#DqM*BiclBrOU@zUGR-WA09~svk3TwpCtVA=oz$S$|%Rz+o7 zNllrVXZ|SA5*WU@i>WFnWO6$l-8jMmS9}LmMw6ABM)*CuUNzT66mjHF*xk;`klr^M z$kvo`aVY5?B38L|R5NL~J8RBfD-`QLSCqjf6y-+^=daib&Ioz%0W-8O&{iGXU-cF8 zcu(B6f4dFRHBmr4=$ngCHYbElbb@O`c^er8w^@a^&Xj*N$t)eYuzLr#&g`R2{oNkO zsAdnADnR+4f2(e*Ow)4V6Il65z}xZdX~gHKT!x9)2~}oBB{*6jkFduVdy1|Fjak2H zIkd5?F5)WkQnbURoDDlC>*^$P{*bvQcOg3bG^V3Mn{R04^4V$baN7~K%Gz{i20ol? z&?!Hh$ODu8(3F}IJO5$__>37-Q(era%3aEtc|N*#+N!#*S5*2Au>i|UwOgYWUmA~V zYlpFbK**iE&FSFW#VnVD$aFqaW6KBuDRr7V(uT|xPf?hf*o88!PMTW(D1U<&xosi# z;+&5i4kNk0$T;!B(p{jZ0u>$=?WMj6i(mSols!%^)@7CAOCB`Ns#mS(y0k~CE9mS# zZIa5^xf}QU+*lv!6GJeEw|`n{fexsB0i?OfR~|BMc<+Gf%0!Q3uCv26Eb z@rnJnJ1n=RLzZwJ_yf`-hsf6*-1+6kH}jVacLhXA6?FSi&mZ5MzwwmS7C;w1{a}SJyNRi@^?C>Ofg_@!m*=zs zhgCgRHKHm_Z1HztO>x(~WH0>i%^5NMwj6dHxeQn2qc(mS;EBJ=9IY&nxtPk=G?WK_ zI6GsiW)lT}OFTn4WODk(#L)cV2e;cWKUhX+18<-c@t2NRO1mCK2Z%GbAD=hSC zPNm*AcCa~!*?3Aml(|>_gq3)ZwUbb^Hi_NZN+9luPw9{1sL5`jnxKFbQF3ApzojOA z8_sCQMMda>bmjk9`*;Qw(YHXc-Cd(PmxF^=|^uOdK7h>$q}pf zu0R0%1rsa~UOuAWqQAU&6@oGt@@jV`+dBgHL zg4L+>k2dai@Z((l$LwS{Cj8Cbr~KI9pRbComaV^LNpv&f?eg|k;^^r83Qhh8iNk%y z`I2d#IugrW>;5{k7#?3EYwq78vWp_O_c$Rk_iR@UNGVH0$w^6+BC{19^1xp zTq9iLfg-R1qiU$=7e$IZ4jwra-e~b>YH0O%tg(~B2?i2Vcj3GO?biV&e@&b`sP5J7 zabXY>F2?B@&NQ={jr%D-y!NNilq+oa7Km`$gvti}enQu#oF1@0FZ!w&8u<58i~e%% zPt?^Pm@N3;nXHXJGg%oR!u&gv)z|jfh0hty+|+1W3mxq<=^<{+_SWOz+3Xn(k;80Pl3lL_dRxZfVBjKDR`6iaN%Y{fMds za(oave?+8LM2Ny^wubE)Qr;RurxT4k9=pT57zBX=g|xJ%DeE#9U<*8mZ{`&0EHzxu zO9!YkayB8s7M7KRJ&f-=t=;16a9hA-XaB}zCH|GkdIVbDn(fz%!5|Bh_@)wMs0kpy zQCom7_fJdbOTtjOK1Ezb3;m=b_ZvpK4m-NoXL>*T*^N>@5sB`Jn(+838+}0z#HhVf z-v>|6UCzlEkX!O113XG<8}LImBen|kH90mgcWw6pdKu(Ps$rif7X?pQ4z<2&VWdrK zs87j{lyEUY6`gx>RR(R#ZV<#XR3zp_i|&3R7Kj-FvmZd$V?AIDA_+lldyndz$A@5n zOa~-+>DcZGlh!|%P6e}m1X-I#D{P4dV3aBUER6L}HBC4vvQE*FpB%MaJ{0A1LpKbjcFyYfVIWWmeg)x;o;fbf+@lmdTOM|Gll zHf{Xm-j_#x+{g;;^GwL{GgJU(9(M4~Xs_)g7jg_>ff@fptv@X&s~B{5qBcjelxnGh zFX4dyhp!Ym$u;_Uox4yOtZx*2n^8LgH?|h`D~{{dUnVVp>+7TbTj+EHPNV`x zwY3QBKJ38Vz}O_Yi~NM^wBQ`HjYEB=hLGbF*rNHH@wH|&NT4P>T+lkZFa@^eS$RT3 z+Y8n`b(!m+M`{c?zx;aGV0|_8CnxuB4zHQwnIf$B1?w5;uG>_YR6x%0TL#D+^D!* zI^f3oQZp@ijpJ4%AaSj7bjfGUtmZqZveIZEqg~+t!`@o}#npA&qD>$`5+o1^!AT&v zI|L2Eg9o?Z(ztsQAP_uw@ZjDAcXxMpcWGRj&fWRXJLi7if9^T2&Z~FdyLIbUg$l4Y zyZ73AuDRwKbIdXMKF^z^RtQ#T2zZiBe=sED);~cV_I6CW?A|@uXhF4LyYZB+IlZdM zn`4PH@D|FnUKEEv`Y`X%&-+$^!ed5rRgUonA{LFQ@TszCs`PlPsVRD?j98A+H~?kG z{1x&H;fV;TDqf}HBPCgB5i*8#;ak2?mb+7bK=f*+Y9_=j5+QFo0KCvYkVie}^q*w0 z)Stk35E3J(keLI>uHB65f4;<=6+(Jvu+JYp?o{yi(`L4)2t5A_&Veknp`~*$7xnH)wI-{mymnd&^zSF{NknX_d^$qw9IWjowO^Ues;>YO_;pIVx_WwZ)-eB)yV6){R+ME=?Jq=cFEI4<*J+;i zsIHtjuSwqo_mS48GRPFrONbqNtp-qGczkCSCab(#y*QFTlUh}%>g|tS`N?26{s_;+ z$I)5 zTai#upTIT~zOwe5)tgi(rLLA{>QW7xR1{mxVh~;5=Eh8t&r)@?o<8f9<$Q9>X^cgh zb}!Lx7vbmgXLMoU%I}@cL$xR*DH|bEYU+x;0DHv`OBBD~T+JhOB}k8!<>+U1yk~4% zCDR*!4*$S&wzS$?2(qF~%-%q0pNZf^Dn0u2Fgf29H3dm58s>o?dha!7mX;;GvX<~! ziwjnY&A6G_$0Suh>Zp!5y^QB|a9^q!7JJJ9SFlmeeu53xGwEl&GYYR?DJq*#rM9s3 zyg~!&IEO3T3-?@I$K<$vl~qb*Yiu%v#+$HX@gIS(Z*U6ZDdYD_AbGcsavbY&#pwr& z6?x~ouLJ(L%7E5AVnTc19hlDsCQ!ew9F@mJE) z8SyL-Gjescs~%s`-z+{1+oEchAbBnVDr==YzI#M_*Iiw6S#w$2l$P+0h#|B(di`9Z zYGVFwuXv-O{;Mv{=ZQC&&!73nRE1*f2(#!_wmIj^y4vRSF!Z4}G=ve_>b;CH(EVnj z%G7GgyYF)5Mp0S}UDi*yjhu5&Z4$F~eY}!<<+`%jJ0^@`5TrEZFkRx#oCnUaNi&1eU21&EA&aSrpRmJ;DX z`P8_fd4?Avwb}}g_O5XsDHEea`5yQt77jsIX0_+^E&b+7SVY@J!pM-f67gO#ik)V^ z__~AlQ29y4TfFypoL`0^ZYp;QDnRb-=wdb0)Sb?7Yfs705!)Z$`5h7T_429+K{iD* z)mibT2R}@>PHG7~F$F2!#z)D&eS_+`1HWPsjgU6xge4F6E)=Xf0oB&$;UVJW--`W~ z|Lr)r#6Go4St0iL)*Xe6ZgL(8Sl#&w zoaf_`5YU8!QJ>-cYrr;QgE|wUEnVXKoQ)i6Y+$xE)p1$D)h}NqxXjsyJ?Bo(Q5~-u zxZ%`go*md$uzxmujoJ_PD@RJs*d4(*x3mQL<71Eb$6*fut3eu$F#{R~dN+3j$J= z_<16aDKqt%EZEpk_*IFNed0{r3U8_0!;r(!7{i~ydp6!|X-TX9E5IsXGZ zB;Y0)&=xfF7e2Ubx!?siJY+#O9dCdvtih9(3zI6l^cRp#t5dTFpBh9Ern{=}COGI8 zk?S~@Y62AF7o?&8mDtl2NR_y)F=p}|bc|>7nZsAX%NXH|znyNDFHr!ocsx$mUpy8B zx(f>_6Q_<*GjLJU?yIb5Y07Z?O^SxcpgLq^nidk3zSh3= zBB3l3!j5I_f(!P1L}d=G*t!M5Q)hZ%d!F5wN!H>1Qq$aOS3@)_teyGV2VX{1(k>KAd%vMp8vB-cMxK*QBgJ*@$`QK?7hw$*59S0~wCc%1RTp@k62;y{hoC z22y4WhHWgi>$0>I<$>JU5t~stGg~U=ZHe%8<>JoGvRB=X!-e;hR?s1 zWQc+oo@=z8we1s3oaX-dBjgUj)W$L?gi$w)PR;h@xg^bU@t7q2e4C4^H;Y1am(_Cj zT#4e=XVwDoJ7zZJg#}Ry@&qu79kpXM=TnY@FUr8l@_UbGfuhIv9L$_5%mr^BnzLLj z7|XJ4UgO|@&W^esYiYDdKaJEbW_9NwU|noId9##77nO)WIONEmd^Gyv%L+(|jm(La z>7212!G$esIbWb9Zhg&masB+UgaRqC_Q01d3`u2g-q^z?Hp$CTmXQtG$!@(^6o%AF zDtKE|saVj>yoVg)nfQ|bNm+FuP&+YK@<#MkO`HLJFDiF5CEBa&%$1J#F##dxuA#-3 z`vbPNcKv`FT(twg?G84*!KJP?@EE5JFrVZ;#JRA`be4${c)tCz8eeEzy zg1J?8xeXP|5wk65x?p)D5XGqclhP{L=Kv?{7&**;yi`d}#cvLcGcj2xg6vARL3W{t z&=h(2j2q`QGU)q$2Zeo91pfs-;ptJ{9i23_L=8J`+ZPV^l)e^<9oK5~qYyxx%?xdn zFWXRb?VDkI+cM(HATR35I4Z^xl;g5WyVSPt;C9g0-?8??I-^Egd!g32dhyp_pkN=d z5!+b+`zG@FBM1KJDSV;sXL*+oug`n^hG!04)>-&1hGjWpnzs!-?y-M@u-bq90ULY$ z^8q-5<$)+}LjAAdQhq0c!FGb#EmnLL<$k#Ee~4QE#I7Wc-yl2ehnmt)e*-(<6#&$k z(6TPr=^=-wqz4oIk9Ph4U;bWC^j-qe`<48`1<(Ki&m8msk^u{=+V&57FnB)lL?bYi zzY;MIIR0P`{|0aWO$G4}=Uzai6LRJ_O@4(9;6q}iR-}*JTtoEDj)Zdn{W24Ps<5%$ z)agC;?@5sVgaZT6_uoWXb!a+QZixi|N3UN30Ky%5stUJ6YY0d|%9WX>s?(9ogj%_F zlaM|?DizwiIu!{SI$C~_YUd5M*7zZu28F;QF6G4&<3Wev!VYHpHonpc8uj>W!z&BK zOF(q6GmPcsSdsHa3znvyEZ8~!Fo}Tf%`GkoD=+11d--};Pf&4VdgVT`z)d{BgRy_T z7?iQ*T@*X9l_m(*dwx?s^MQO`d7CgZc;NiH*#Wy|P3ya*np*mE`2CXnZ1){MZM{1_ zuG-3^V}zajV|&RLs#jVIwuprbNwJ*AD|fe~rl|#*`_o|8Je{|ln5`y<-sl4Uhn7?B zSpqQ~>(9c8Rf6Qpl9eKjb62&4s|(l}9gO^X&;((7N#myvN6@Ub;ck5Moq1#?1;L@xz+$?LQML_3h+40{<-k-sG)S(KdHIisgFa3`oa_a9EImEa&kyvxq^Y7E6qLbR=f(3HW{0$1y85;^G>fMr*c077 z2O2qUPP*`wgzW+Kq|~kZ7tVIa!VM|3aDG)S+R~s@>B$7nr4>MAlmF9hPjrg1ZoKak zl;?JmVp?~QVB13twC{`JOH_RDNF_}?wOD(6bJ?WWBvalLYH|W>Grgy>BX<*<9;V3! z3;XfQ))fxCPJ*BAr~1zY8I)o^wn%T#*w`IBY#lRo=!Us?Uyp?9*m8#ca3#ThTbfJDn-ixIE4xe+JSr|AT`YHPyoQ za2{pb54J%albzGyL^5YF<&;yG_tvyl!cDc5-zG2a(x!Ts-C~p*X|A{N5Qq9K2h$Z) zQQJ}3aiI+)6=c~H;PXZo``|9={AP_S{epXH^^PBm7%yT!?MyZKY)zb#ob|mPXkfdf z;iBS6;6B6vv1t_F7vHJgRV#eoe4;+-@gVL^rky&K!=>>2HuJ7&<~D1CqnV&% zovwbC_iV^XTbRMgyX5@XgA30$Q1R0y&UXv&i9(;>pNCPG{;lPVVqf@b06^SwoTdih zK&%smrUY!{^zXPB(qF)z+zI!NC&2!ny1vr?6>?ZLmDawa7t+?~+4u!B$H*I$5?n_YHBRD}`W4knGt2-lk^5d@MzvhwZ~AiUk841sYXEsp8%z?ma~xb%Wu z6lfm+Y@gNvm-2NCfT|IJQo<*b>2Nua>!-L5Nc--MH{e34$glSm5Y$o4Twa38KX0Nj z%32>L(-ILURlsRgz}6l(5Axs7i@eb##|D6AV}Ha0unq1UMRS(^_aA8)Q36|Ot#=L` zvM%J#pe3hzIa<9ftPCR80&NI@saNLx#h&$gjH$X7aJT#I1Dc zvS`V-smpUu3_YTyw&Qh?C6mokvuFFZ@;|It1zAS;+P7YnJf-(edH4EUwobS5o~G>n z#k|P$59D4pWHO{)V*7~7w(PwD!)aLqOD2tDR&;d(LC2a`M{2u;TagC3fT#TQFS2kz z_#X-@4%k zm_Q?&cK{Hfu$%xg)DhE3Go|_TOf^iWjq1iNS7d*~V%5K`D9L2ehwAjIzCI@~je4Ra z{%U!BxtqZYKMp6$mX><8?fwkC7wRf94HbA-s%1GXjTbZDe4+V;UY@NNg$z;Up^r~~ zSXX&KN-qDavM!pZK4NiDu2n2f!Yt~W&iPjcJtyN>EBJ^+6H#=@5I(%xyLbWOaermn zoyF)1!M0(!Oy!X)udQ!XIQ&{!DMda&+_+MY4f7C6gEB!S3-GFQ6 z-l$G_A>-AN9foBSzG@C_Q3NXiay3JGL9*Pg_1Az5w87$qg_^v}qK04UnKup+2_4g6 z@b5VgP$%}NdaAFcuM&`rAU&AiY)~=D0nS|hK-}DSp%~LCugi1?bYn8>v9FS1 zd`oY;?$FXl0~va`n;CMSb@uCDA$llJcX^DrHI|QRShZkZ&jqxoSdRW6Zh zG{U$O!C4D?F&1nJj@FLWoP)XsUhMq6hge&Dy$gP5iuQ`qc@{)LzFbUd3(^tYvOG1~ zu7NNpb&Ng3>r{vLbd;~FCD=s>htwKj)_%}3=HMJ1Ej=(&^txyA7_U@n4ZlPtXZJd& zZ_y5&)KQ5XPeW_>`l_Bf%!-+d*2r&Pt%1Eezm}2meVy*$&*;G$LS#}fxb>V;0msDn zTGyM!+XH^L3w8XYB<`42x4TT1n0NY+Ril^;If<6MD51~E(&kEww0;)Go~z;Uq7UKh z(xTN)Cy6bm;K}gNbG~grD@&;M2|+-oJ$~Ec&g;mOz3y36$(ZJ3*euedOWxc~?&3 zfcl1Y%hlY-MJX7Ffn^bd^S#~+zl4vnAYW-8(yW7ISA|!t5%@>3KzR_*I!)-k@b+t< z8n@;~Rd&Vq&Wpgq%T=o-fvKx4V$PNAoC-&3%jbmrP2JHo1o^lsu9!K+Sq^0%>%gw& z(CX0+CeK`6FYnQodtMq)`xu)(cf5GnG6KhJX^%k=u8&?ejXYG^o|akxccSPsJP(2C z>>%cWk2+#mr4G+qmb9m`U&P~kMwJt^sgBy@5(3JzHnc7o$784hJq4Qi?fKHrhtZPx z#fSV)O|*gjuNnP_A=$i?$=J_%iNqg8JBMP=)O5Yv%*~ig8rz#P>?Z4zxG;%Ib7;~N z>A5VPIn_NCZm6v>K#UnYFl^9o{@Ax!Ot?TmeG-G#y`Yu0M|}FGNxwl~Zc?`JCpuP( z{8sh|?0*6XjVwe!Z95g9vIqoyI?o{qrrIGF9aXFK3L;d~yW7%(Y#M~E57uB49Bz#; z55Skx6C>A3vHANGX8I~w*d#hqeuDrp519k=%;t^9{yF|RhkNi97az?;Q`K|&<0{+e z-Gt8o7+!h){$JzKBKd`)R#NMIh5dMn*GXg?}TwVT{94=+7AFC2{EfC%4p{#+;-vtYbIlb~%Un>Dzz+!bN7!>J`vbiLJ?&yJ zfe`-9RQ`U9n4=zToqMtfM!RFUq9h2ae-& zJIZWW&zUm9x?V4b)_|fxG`aRYlBZ?}>2t`e@;zWX#>EehoyqaxpF_LK+#pJ$7Yl-P zhiP*1qPeR?r3k+-@+AS>YUburBZ8p;?|-gw+EW}k-s z^XYF8p=2O-7da{rF**_?XL-k859u>&vd_vjN<4G!k!e`<)c03$YaYB|?=Y<(yRLzh z>q*u;btUP|@GvWR*Ok;Y?PQP}!`AglEVBE%B5@_0}9@ygn8IL|ke z)A4;K17h9Vgx-o^ZulJ1HR?znU#SVqihc2hMcZ$gC*H#8cAR%ZdGOHaGYGkWrpjIm zyCYRt_l6;Jj~|-+kX#VXk6R-o8RuwWSIBzX`njz>GM^Jky;YAc28fVR7u08bR-8=} z%Ehy?3$?cQQDdy@4eH)jd`X)XWcc|Dwp@hTl=nyPq+?fqe$c2al_h$QNF=AR;OUpL zUNlnCT}=BsX!3eGsn=V?;7ny`APhUGiZ;zHMF3~N=$ZF!&c;cGFnd%WX*pdIPf%r( zN_Wx=b279UtBkVrBiDp9irOaC8hWg$U_HZ9>WvwUpJq^VWFPDhqT@X3rU(DkM3%Kt z=Vze|i4mDm!2-EG$8GO5dv|O=gvjs?$>|E9 zGYc`)Um|_e4rY>7h(Nyj5v|C2K-l(H6IC6G{m7T|Le6DrQ>#KI))C^Lm?%HJ65MRPv%)YkwnO<)&Yudf`n&s>bs64@8c*GA^Vov z>94g5HHMAg=Ju8#@#CV^`EtbDii1$mhBc9Z~;HRlr5e$v-_ z*{?Oao%GgieXlj^!;n_EMu4d|IeAnW3c;~l#;PwnZR&VUuni+K&vbYsO9k>Oba>K% zi?sKtQE;t9zbhTfOB+%=FP(GX!;G8nx6dt66Ha-SA)(THpVPAHEU7WoD7qdQ2wwfx z__|mN?5YOSSRAmot{z^*%-DLd1BN0|&;jIT5whUCo1gkO2WqG5^VUSpB~86`xI07V zuJ$z~MrJxGJ5>flFrnp%j^?*hHkEUrF|NRIqd>kdJjy)<=1F??@57Vx|*wtm^ssSFo_bu8V8=qy^2 zy-nJxv=&9b7q38f{I!Yt`RCdfN(WdH=){Qy_r~u;hsf+3{4IC1@t53?<7XMJHg+Pk z!}u=3e4sEA5;BGt8@U;U7Axpg!JOY5o7qUtOL}5QB{Uwjem)*q>XyWick426qm)h? z>ACZCV~~e&hp$!o85C-PeGElYv-&lZm9_0`WU*M;lJ=X~HS{dg(Yfvg*~dKx3JgR^ zUcwSdM}FjeC8YTxLYU-J1u#5S<73u@v2K`YFAsXR8m!5t;qKgH3`ZQ&b^~yImeXi? zNgEsN;2~81bqi;?r`n|8j`$Uex(VZ2jPeZS-m!jELV5JzMgPf9K5yk@J0SQ>Uiw%u zo<$Z3MAGBOF$w_#f)$M2A7Tbb%2PW@jKj%N&JFy1_M7xMEJL~C27oEDHXWVvL)h8SxqU^vb-=oOE!^NtLDk?05`F}@@{ zLwgH@tgU=y@uFOZyjU_HlP)gt?`IxpUhN~B;vMFFiY7m`>w#yB9ptpTB_WMF{npsP zFPoy5vaA>qtd_v@8}tk=2{y828XBB;>ceBraE%H{0W^KQzk=*t^|9b|Yb^o%+hv*N zV_KFk+zhvjQ+4}3PjA+sMD;z&Ilbrjd8#A2cK^-lh(HFHXVLyXdE^29YIh{BE{6!(z z%hyllfQrV~w->@J04Z9wtdDC65TK*3v(6rzo^h49Wok>5(4+OITOLRuIU?NPq7F51 zC+LpE)0eg2*HXySq*BKu#OdufUc|4*WoJkGIFklxr!-hgHS2ut7TGTJcABbwlDcW) z_(Jozu_z$+7^gNwq^v&0PXi>$2lUnh$l3Szvh7Lo6>GX!_nO|CgZA3cH_vezASpX< zSaW338czX5Yq+bca4-ueIsPtWR{iRVM(KTm;WnXlhqWmdzMUu~MaWtyClf^UR6l@G zTWYe{$x-0!pdJ#qoh18h06qps+Lp_k&!I4j_kw)S~p0&_#Hj=2V$mz#FF2CvT zKSDcmrF*4(5LMg4dypTh8x%-LB+0>%fXM!(5jWyolbhjBCY70m)0Z z3T5G&$-$;`o2e^Dz0}t#GWGV^q^Z;PJZe~nd)dblo<6N5*+4PM;L`6&k}u*8T`SR+ zEb}}_MMV(LS*bsg&O-0qPwW{+Hb$Po7eB7TCi4kDUCNHi zVk?#k@4N4e@8&%aA+iIOciXQ7Y3%hA^UK;?aWoTQbH=sO7(Vh3O|nOXJuoc#dbdcq z2`|SIeam{bik7m|MV^^!`^CzZdQ=J4fL1gMwcA>zG{0XgaJr(JuH4b}vSb8~wU}~H zr^;fnac6}@fB@CSK!2H#AcwYVy$irleJ0y^U2l_Ak?6&P!Cm6|!aK>`zuzm@25Fz2 zV|4U!6LyalB2Ore>)P*_sj@`dcCOUARBgADP?q6iNY;Qd+VTKM3av!B5*FdVmM>si zSRKcdH|zWbvo+8(N%lT4f;H#UD&4y{mk8dG68n1QV0+u*U9;9^Vi?cYDmM2Q`&Z}g z!MTi@52v@YSv#o>f{tAl`($`C&Y17INAmX0hri&FAB1`*X*ToMKD6H#^q2uaih(OuCbu_}PhOC+Z>TiGa2E3R+Qq{YeW~S+9q?7qXp&+&5Q3A= zEMzc+4?Y^T3dIJ-&7( zJ<=0{x(%mp< zTPezy7|qXq2;@=nKT;Pmu{_ERR}m!&Y0x3QdimJ#Yx3d5W{S&M~iDq;PPj zi4X*jUkc-BTHuP2E)vBCnk?o{$kx??AeDyUe(6U3D$GGS)D;iKNzR3q?=Vb{43y}U zMd>v#qFN8s50+^MCcVVWa#qAG9I>*`J|d}AO)%R~67t@r@y@B|y_Y}}q-}y>rll8( z8wl{n3~?`&pe8zUirKd=(Mu?KpLHO|e9?+kMAhv9f(Pes7k#fMwcMZj!YmTl-}5*P z4iJWUZUw$u4;BzJds)qy8>GyGA%azJG9cPJa<@hvFVs*gKn7M00S%D7uHfIfk_uA3 zm$z@+OAwM=T0*o8oZY!D%|tXR5qz`So=%pPa>lXC_B+YdDJH>4`Dlcbet(eWS4I01 zqe1`q+_L4_UYS?{BkU!{*U3-Z-m_Y4lvtAV z+0GYSMdBb6ns0~MW5!czm>;#f7c_}w>NNX$N!}ZszjEMvDycF`B)mpdhUh{}o^c6R z9M4tU)9;K7+avM@&e=|CNDtIPK>ZM$ImyhP!b+mVnyBhR<~WB5|7gAd$!*%zvrkw- z8F&iovc%SJFlD5;I8ctNa0ThNw$aj?o^~56wQa>>rDgtOAT2m^nikbF6QTu`Ji_({ z<4}`W`}8EvuzEku+C@x4lqUIhrPp8T=LAgUrEb z%60wrk7)y@g;iOv-I1RhNP#BDzV&m{*wlb946>r*#8m*ij`Zhq;g0uI9R=Qbyvv*e z>6FI+Q9^&~*8AP@L6077WGA=7ftiek^J~DgkN#oWfciVzt=U0COzZYPj2rTNZV8NQ z5!I1j42yrfHNk8YaC8uy#7214L2@$R<|HQO@g4ue5m-kjrYD&9QL|#&mj&lS@)ACG?G@B^a z6o0Y%M7FLP1yXJjE=F$fFXo-RE=#KRE~v_1B}^N7eXkbhXd|_A989Ua6A>CSF{xw# zyb77|{q1E;Iov5%DQ3>1AEbd#ZgHiivIU$J6+{=+O7M{4%mB+d;@`e{#l;meYcg$3 zzfFftcuVQl(E>*yVrrB$an2se??TP}rJcero1@diws&o4-qE60nAei==Y`U<;A#wH z4iqvH{iq49W*3TcsCe<6H=t*mb<+VaqB#fzBaIr9FQk}63=`XQp&wT_BMfkEeeEZq{ABCFa7h!}td4>{)LiRr>%yo# zbrx2Ehg~&}Hxby3KbINnmfAa-4!ZR7q8UqV;;}G_Z##`N&Mv7 zVKJk%%?^OfL1Q_=sBw;*A*|RVL=u|Vg0GMlN-W1j2(^NO8Jz|^HKCs;muwQe3>ReT zYE53D?PzQm5#9!2ARX-5S^7|xkE4)V`m4l@==NR7(Qoe{Ka|pQ&%5u={$rZ&`@Ak6 zx5=!j4^ocWCR73EEH38nkaI{9(?2}HvjqI<1lKDosKI2Kre7S`8Zhl{X=JCU?%u`- zQA*^PwjoO;5kgm=*A*30nG=9xw%DS_Uz=by39#WMjH6^Ltz%@H1fGYOnQd`y0u_I7 zt;0_N50im*jtRi@*-qj&n*U)~w$JCFbq~=7lg$&~dBWK@+xq`z-3rg=nt{W=_TTSN z*;=!2inarX^^E@b^}dZ#{6F(!;U;i+N5h+)7jW)hzqoS_#0G3Ysm(jh7BEMw#sEC% z-IA6r|10OWX>Z!nfN{`9O!!x;hf#VOM0kXSOad?D0_fp0x9<^9?J~MA%}5asPG#R- z=I}!spo%K2(eq7-ki@e{ds99Ir4F3Nl;QsB%2q#qY#kf6v1MVT*faa$kMmbc1ngJS zjQf|ReW>#yAizBiwJztoZ?*zA!p0mR{G5RLg2ukfjLL#&L8cb;_VI9>BQk57@S8rO zL~OLLC>NLbe|)c|TSPywX{l@U!;~|uLg}s8Q)lg6G}{c{0EA-2(I!e>E>o2?j30BM z|D2pAb_~*VD*CY{D0C?I%Jl$F5B}qPgF0PQb|)+?P;;5qtcxRabh0~P*9L6C|8U>> zVqd(Z4d)pw{V){{_ZOa$(r+rHeCZU@{~;;(exnJnEfU)hrb_)6=G^el8Kay>*zMEhH*o-(Rpgrg^~(v%p^aI?Y)*AvbQx+m z63Rmt8b!*cx;-!|otudM37MM7xBe>T%vd;Y#-YZs&i7-CCKGuu+M|8iM%df%h;(ar z0itAaCk~>v9G#&zu=KQl@%0yf<}HIFj5IzO47LYc`JPil*2{U-!NV*N{D8!&*PVnF ztu!M`8CV}fH2DCN5aj(nVaQ&AVB>~0Dw(zZz8!3m2NvY-r)^Khd2?BMnfZ+;GV zbE0f5uhV@w&IOl7AP^YC>_K)aAQZnIz`&A!OaM%r>gg9Bqe(w3@+p!DvTv;s?j^=^ zyt*C$+PnR+*S>XP-pjHaPX4G`D$Ijiol250fW?gS$DgmlWm#`)v8lI(%hfrSVvM-?b5J(`;z0wvQ0l{oJe9eOhtA@T902}Tw54C(t=y4tZG8fMf|BptC61Un$ErQP4u=co0n3SJzPn@lg04U? z7WO1FgJJ*Gic)#ValdNPlLQC;Yx0S``4)w6Ee9L6XlpX!u;_*l7b;Zoyhbb>#pdXb zf2=y#32O<=!Z%)Co?&C0IdgLk^b%S!%C6@4MFt( zd^ugyP;cs-tTt!4`?dGNY4Ba-4fOJEVgcT89&P*m2u(CCq{sGh5=lpH&Au0*;d-j zkk5Afk-^U9T(bFw4GScW{P}02tEdz%g@9bmfBy{nv{K*>8&2+SVt#|(bII2(=6DZ9 zt8xGJ?g3uf6SWGUJx}`W6XEu<-K-?t9%Cy=yK3=o(8vzry~1f00=L8r0TDjKg?u#{ zljLmp8ntvItJ*Y)n7P_(TwyU?`Ho@c;(=|TOX@&|0?=}QgYE&2dxg5bF6%Tk`y#{N z3!K&EbVmMK4^`d?EYCiXXUzY5G2;G8Jl51|&cIA7_}RvlsUvuKFNzl)w(zSuO>QG1 z$H;htgm0$|XbEMctWBySS_3xzu}^ShLmJ5%Wi8OqLke-OslhNuR{PhyHt;_-%70q< z;0pOqok}Tv9z5I*c;S=7o*cMzW|3Wgs=n8gtucr*V$*0-`pzzid-skM%{?+E4h0y= zR<$(Wc1@~Cy`{rzbu#U1>!T_4`2oH2Mw6;b&8-_RHjNwB+^m)`721rjw5S|-7AkdQ z!)TpT6H2DT^0b^96%{WG3ya|bKOo6f;ruv#z$Pf+C=0B8R~5-Nb=*>Qc*3mzsg}D8 zTo}ba?80d5Ot=?jOy*BrVsuZ_MYJ>&SmbDLkLf3C`L-7ODy3Uq3c;GS{i^gmzeJMt zrtjWWE};fz)a|pX-d(BgC+jKo)*(7QcJXQl0@7POw83I;Hi$*LMS3jtRpM@wXAtD@ zj)fwvmFb`-+55QK`$@uAuHS5&U0cG#4{-;naJ&*1(cl$rg4pAQ7LJy7=03#JD_WB@ z(FaP}78LP@W3kMuryl7E1taT|HGO>aHxV#T^D9IZFZv~22%8%?okN_M=%9-gm~xXoRl=%58+_1)3mKV+fmCd%1*y+lRp9>aKf{+ant z+~>by(cd^oy`A%_+6g=F9dbVlmp9#bfanFu*jMMK6|Ie6ig^|t5P4@uyFu>X=2j>% zz!OkyE1<-DwyB!8y**Z+)l|E3!wYV(Ri-J%jK(ob7FjiV6WFC@sQh%vJ)aL2RRyc+ zHSu+s(u8aQKKP9=rrfj2XP#GqaVAf-1R#aT7CnQqW@!rY^gY3ivf1G3(H^tx6^r$0 zHvAOw`6q9i>UWp|&QybKqz&hQCQI+Xei(OMX;HYL*m{vrDsfs059Llj6@I`h8U~Lw zG60nSp*%Q1BNeke$$^oa&&~qWjO<r`QjemL{iV zB_n*LqNkNf-orsT^LxUx`twn83@dX7FZb%jrvSY zIRQNNYN-XyDUi{f22Fupb(hsdNyUC*Dm2WnsL}Pt{W1qFQdSF&;)x6GXQjV%boX#H zIx_ZW3i225amzwDISQp_Z(-$9XCAPK+I;5)(s$BhRo)g(p=Q<7G-cjGbT7WeO^n2; z+dR#ukUaZtCpF|SdNZINGNT)uEv>IhKNG_bzkM9c;0Nk;L5m33z{f+-w$x2HfeGW$ zf+S7Nk$W1Y>--HxI*X8iG8?0iKIL@omKpsKh4;5vMxLDmwgqlzAEym#CXzN+WHCGE ztqT_<(T&xmNFPDB$$18mUcFje0)H!6((mH1Oj5S^ZgItL@~sY>>(@uZ&@aJ*d)V{k zJBR|~qL_X@MaRhWLz2}c&|p?1Uik8a9N|a5_0P*_W;Gwc70N}6{}ZYZ{|Qxsg)bj%Z`N zr}n0VNp7~f=R(t(<&DjT0q^q5ROP zajQ-wqfZgsM$Cgo&(3Hs4SNcc&iZ#71vg5c-xwF}&BwJ>OKpCrjCL1@TSjMm&IYA&HSBBknHdvao*tz*{k%3Oo7hz!bA?AQ0#HpE? z423mG&YGv&KL1J4P%%unH9ZR+k^`5z%Thp?k36&rUoAJOTzLU?#V^)Q?%jWb#uLH) zzd_qT;J*ljde#S1!hdUs*TT@(vUPG3X-^gd5HTAS|EqwrlDK<%XCykDcfzU^uDRZV z-R0@ZKns$lNp@u;R_0P%ENdmf@=fdZ6=V-N9byryzu`G`)raA|jMBUb(ljpv6Efi^ zzdHkS+w1f4hfwW#G8= z`@6d>Yep;UQ?hlnVN`{uAe49k5Ce|{tP7q-S95w2Dj+mZmf?v!V%+Ce!@7vleTjuH zWe0RmkarXz1w;f~^j~qMinVjxq)oI=2t^s2+*_^8(-NxjyiR({kO)$WNp0N3*x;(! z80hs9T^mA^F1LocCEYCxrBwYQ^U5O&)kjQ*WU`TPSGz+_i3a_gN=fFw>;Dp>kIo=Ht)6PF|-Dn!Qk2oS(i8b-) zTKiL~r5>Z90oh@z%*JZG&v?e%xE?|9j^b%uA)L(|aSOACU8WkAcBwW;rVuI&z#_k6fU zTh_=@G^HVU11`)N(X_B_ul=Gxoy{<(6HUlzRTb?8FI>TOb)i;(j(LVCXnqX(@+Af1 zkPYg4$Fx@|jv=6nLWZwXKCdlt+>YQ(YbThgh6ndT?=I4hiZHYZLsADn9qqD(cOLJu zCG|$GAD1|~H`tKNIbx9>w{6SzC{3QR zng7a6SJNvk=rbrZcNuFhXU_7P9%maiQnKc32x>M&MxcO|%P*}Z_6Jl(SF64nhuq!% ztTW8MwGXw(#z5aY@AjvOOeU53i7E3J#`V8f5&oxb{L+73?a^46e#X@S{|!>%I~*<# zp)H*pK>@aapnrT7x78 zdBdWlKdA-&g{9?SS>XX?CVr-Pv9(66yzTXCllNij`6z~UvyHE_<&B>&EegkOkz0kh zRI^Ji9SoT%Gc`R8E$0nkXaM3RN&tXJyVk#+2ehg=A?-N1z&6pd^!^BPlQc5d3w5%K zRR_v6&?S-q9h2jh6JT%urz+>~f9A=D#?LGBPuudszh7*+I&kL01ZBWb^{e60vtNCT zi`WG;kDxgAuEu?NnapG2Vpp|7i;UO5LD{e1OFx8Nd51lmOQ7+aFVuuXS~fL-d-a9v zg0=B6mx_6+OKqK!*S&0Xq5xUbYdkLJ&)R7U;vOg-*g;#3Nn=bE0#75~xJP?sRMezw zq~@LFpKwNEYOoU6xf}cXT;vrMVg=m~qWuQt&#=6WI}Wd_s*1o0xp)?i+;LTcURynD z_FbI(gzDW7KatftWEDs|Ll$Ht9U%^Z6<*oa)(X0{+dLjkA-r2ymk0!N*`l0&P*uHK5NTI#bp z&MJ(|#Xr4chRd`bzu34vB%{#MI#=X8`C0N0qwwsgRkk${As@!R0-5h5+riJ03LT4U zmjP#b@h9KAU0}7Pb%h7?DgKMZMy~9UcSB6M zdsK#lUOj|Vo7cI28BOsLoetE=eF%T|ueWVUJc7OJqQFe&EW7Q5#$6kx`l5RaoI>@9f)H)}EnV z3s0Whh9EY{*7URAAV3lfXm@3Ku>TdBY>|zM7^#G;uone*t$L&mjT&F<%ud}c)Ax5f zO#RQm7{qUwN-gwAAJRCVJ-8~?OdNe$^k?e)f+TE_@Fgv8)=@w1Uu0NnBQ-J`7i4d) zR|WMuOS0$pi!i`1q@16%S5I&Hp^lC}m*%@T1XoVNmDV0`rHrPXhjhFA7nK#bQYg~Zidn58GV+6q$gqOKvtJ4>IT;fz*A-dgWC>Y<3&|HzzVv!2OP3CXX zMVqI##*3?(_&1aS%KOal7j4<`c|R+XcA%A#C>gDLqkWp(ny6f|m2YhJw~wD*KIVHH zY0+UL;=n3}M(Hm?6srbgd%e-L8sjGZ3arVF z`LhT0CPU$+a4%gkcj7J}DfWYeh2;DL8U5+ybd*pLxYQ!XV*02Y+e2wg`fV6r~7A zC?Z9vf;2&@NRTc|;l7CIafSJ-j5q5XCCIHEqdPo&W=8#*K`6G1#mWU2jE`r0^7RDk$Grq z4@YI^=a1u+Gl*N&TH{N6pD`O61Ep=E22GGt-F7EWw7FR{2KiV?h{^k*(FDOX`gUed!=nXixiw*JY$_{^Xa1WVB z2es}{o;exgM!*<1XhjKz*{Sp{Kf!Av?H_Uw^G!NS6~vw*3}m18FUI9H0C=d=j|DBn(X- zI>*k)u6B;h2#T?-R!tq8UxVmWjU?OUe$g^}7rQJF-$sAqyvk%uZ@5+5$9)pop4p8B z4`+{zOVmxvlN8Z%_sC<=QJoL)Cd=aECPw{SYR---3>PsHnb|Tdz_N^ zNG4MyHg|nM3%4OkcDb-CAGwP%J@rQ}C}Vn*!t?Df*1yQqHc(QO%RlRkWZQvf-mTs81CQ5M67c27VV8ZVm7q z70l)Wde_apycpcP-cmYV!6b53j6R$c&k0GsIjjy8PEL^0Hf?bTaNl2|(36pm=ek8F zH^tvzLdWD*&}!Ky=CpRFF`=wHFmKL7HE{BMtm2l^BioHO0VCZo^4h0(irk^DfX4Eg z#Pb4UC5ub|$+m`=N{jV}TUere?Uimu%MszHY$jMD#3WIl1U!V^XU~(JU4CW5Gx@Sv zT$e)_sH)u|68P9}wF=L87g4v-Wu zdq5Jq0h+pN%lb%w%Xe6XN>2(DD-%fIx*@Uvc1@fpB7^b{DP}^k7W+W<5Q|wCk>Tv* z(oD{H{%KP{7nakwkIL%D!~tMZz74INhI+PsQ@BDf^;Pi%DmDeq)LY%n&Rd-a12vCg zyan?Rp&SSA95BQ+0JePj$q4x%<8ZO5)bO*BcN43z@3VGq)oWM8@+o?ya4E~}bDHyA z(2DGsaiH1Lf&EftS>xf2L{y9CLI&<^({9JRSX%KrIFWv{qX*IK4W6KmYy|*r?wOqc zDZ9#i-@61SKBN;>%F6(t4u0;uCjxKAi~q4ZVbga!`Vm!#n0AHQTsqMR-(}ON&vZ}* zI)c#2Y}s2M+d&#NCEbEH)ZInP&e!y>Nfq?cEi<2a)z9C2C?wxIK-JX*bc=F&TfzMz zNHip}{F9x=IzNd`cf89^&7uRjcM#QL2{)l+MUarJR@~*?5jmzOpRQiEgoqHB ziHA|_<}_|&#qO4MptJ914*>{h4j^FEuLy{$2QU)PvFcoiTaK4;ZPe1Vki)KPM?cRO z8F^4<#4FNX;RcYHxwZr{V;-`Ko^Z*S8-O}_=R#GXM9-cNaUpQTJbVpk@}%t|X+SwG zu)rDZ{b0wamwSQ|Io6 z-u1~x&0%!j`CFk1Z70JO&#+4Uh;B&SD9=m-?AAB;4{j)CDrOtW=Uro-<~7GGvhnDx zqIuEmpisB`Y;M(tW4_*Mg?*m1JV-?q39WaJE-v1(Gy(KpG1RL`!Sv!8rf_Ht8i1F_ z`LbEYP!E^#3|=in2eh&Wa^VE`RaEiu6WD?GZ3?oZoKSOJ^Nv(R7OX&wL_K?!qH?B! zzKbvp0-aFSI%cyjfl13CHH88?l`&~I;~coI6Q|hgrq0q$nVy-omL#@XflS)aRO4ry zpoBF#*|b-Coi`Q1o0LF6Wnj=7r`2j)Ojmh$_-cqSE_qmF zt~Y@Kfd7PU;ne7c53afSAgd!+oke=2^qHef1n51i_Y-^*6sNg2WZ; z6&}Rf6oH~l3@PGnDyaLjvv=*Q0g=oriwPvz{9W(%Z6tuEuCBgi?H{j1RojzT^3;#R zXr@E#s9+vDN|k+!TT6TsANnRdD~mu@>0*rW4Ij3ysd}75AZcr=fy)ArGEZ-}hj9;| zl`DC~0r*!z&;PuXF&@TVxs~RnH9pgApbPeVXv0lsW_+Rb(EsVP=WMPsEF_jSCxM+Z za4Us~szzv)Nzd1E?zQTOR_-Jd#pL&`Aetqa+MBDJfZ}BJ{&qY=yy#QJ)(YrS>(FYU zN{^5B7y}?GFKAVekEDY6v;nk>6~SS?QPuate#-`}7!Fl-VgLsi0!z|2nv58FOAnw& z_W_)Ey4-A2$X*==dTk~m$4=TJ_Mh{dVH6e4Bv2)+e?mZSLOaw^%c&Ei}C z&ty&ufIQ9?f5YFa>P3)bO?hue1y)W=n3_H*;Htp z_0#a?%IKriaCYKM7KcJNWMcA|dD2-qUaTyM8s~X4g+^Z2^QjiWpV)^|oV2og1aKj- zm6g3q7RfL3AFSr{5}5cYbli5>EL2pB$@xV6^bL>g6H{Dq-;=)OvTJe^p9-e6A}l@y zU%!WFK+HhRqaEx0gqQR%ZQGEk0M3x0)M^Zt=-U;tD#eJ0!L=b-4o5NVSBy#A=+X^#ByrkDJ_bTVm5s3_&$wcDtqJ`9( zK~uIVF8z{k$7<0B%+_jbYxYg`R>LVEHaGHmv81qJ4^xA$wohGXoUhv2!Y3YcaYI2W zU)EZ_<8k|%D%peBi*%@ZWpnhTNYolE?da8Nce|O@a);LO=owTcwupN5!7eUz!RjB$ z1zgt(U>s=M2?KTqQP`M?Ws&|hBG!#VQFvUdPd9yk-+=vG)kxa4;T9y-UPWk4ypX!bPb8C=MRFI_Moh#jN~2WuW+NFU`49W8UiH263`>JYKEQRGMC)^uD)Y*)5rn61`6lYNT~+ z4}CQ!@e8MUovY%6QyQ!5*6rW%^!MQ4z$Fb2W^Ar3F~9F^K1Vpe?#!_~z?>-t$S&RK zW!=;Qnqks!LT~2Q}Xh-ttite`ksXn$1W(B)CPlU-c?kFOIF6n6keG< zKT+arJ_Q^U0+~_Lu3G0;;XL#6RxaqAidu+svtO5yaTC*qjCO?w{2j%!B*}MeqFIV9tD0Kv)mbT-0nPTR`&7vV%LNwd8=5-Mk>KC5~=2E%Mi?V z`F8Ar9Uvnp{T@eeMI{F;|KZtLkB1ZNJdf`HO5O*u848~V^en2oL1EANjfp5PI_A?w z`y_>XH<{@P0!E#Qd4fwrahKc^otC6D5s^U@1j$Ow{jtkp{$` z3{Ei#bJIPW2O(PJDa}}2s)_`q9!eIX`W{XS8ia&^^}>;`4Xk`l`tV5RvuOpH4*ER&Sb9H?u*`L6 zMTKq;R`6L{Gv(7Kk?$W5F0;gJwF`1BnYP5)5Sv~;ffvS{)v|5o; z;dUOazZQe<#aCH3RY=Qs*qk)9IbhF^Ws_BptASi!7peII^%{82h{12%t%-H$df(>b zDG8}<@$)NSajHi-9m7pD>q*?huZsHPR#xS)^8SveJv@etzyOi{T|)rBu=+7X6v?iofd0aqQH=6Zeri)@scD3%9ea zBMnyMPpX4c=Etj3r4W2lLFO@$Di;;$X`_$95;nK=V!&3|qowD%rAhBY>xEti&#bI; zNHTDC-N=I(l&{pq6(L_Am1Aj;SaL`TV_8+D4uA%nZ%Gyj@g2V7nOm}KQ*{itUF%Em zpBGMikf`Qss6_KwjPnv{>pZ%cuKY|VO(6y`;+)i@(@jp3yI}SrZgCWl5@7{SIN#O| zTU4~R#LU=Lh3Ki7Sz5e z^4yu#Df|6&DT?<;x-|Gyx>SCQp4{*dzw2>jFl%sAt9jIYPO{RrKHByFy5>b*KFjOw zYPSD`S&>zOU@g+8TYwAmK8!}!&qr!~3qO)G`%fb^^H0ea;+Uy7-rgAOxnJYn?9Q~a@^Ez~ zM9}ld>`}A>>s0QuoOfjiK@$1IGC6y)2~`y+RcPjL*>DlMC@rTrK}Y;7V&bWoGLV_! zo#0%0SfHc*NReLMH&YrX*WY?DXf}|9u|S5DDREP1RQ26jW~&Jpxuc|1BW{8P`>p(< z`Xx1GH*Jz5A1tnQys~Suec3Xz+mLG?Q4|Yujd~dM38{%9h? z<4IkidmS$S5aHM)eR~Fqs)8riUD7m&yD7TQ8CSd}SQZfVSRyCyQ?8UJ=#91UlS|E+ zmQxlT^21CH9USYs6V03kMD5|}lWH3hUxM*0?O)H>E^b6cbUxGBLTIC1kL$)_7IQpV zoJ+L{BzQ{S_psEKm-Ib>Jy~ac7d}|JR#)}BzD1-%)MX+~;%+a6@|9@ZsQhs(*T|K? z%PrRl*5A)P!?9zL7!LUDnxunk+*Iu?lgWYww+h)SYRf#SWn-~0q0dT3Lp+{G)}%U3 zT*uTkHHd4EuvLTJn{}$!TdyCk7A8ok!pWYeWm)#727~mx8ZTt#DOy3m;s$q8_xfQGM{eabdY9v z0bsn_nI*B)6dQ|i-O(=B56H4}povtncna2%-wAFOUF$PT(ykqeu0@kC&I}Hxzeh*V zLsmm>F=O`Eic&Yyl&tVeXd13|IErkKZRpjqto1Zz%@bv`z~ZRC$=&*;(n>?Q?Io8Z zzn?saF-vAm(~Nqh;!xy4D6T9ViwHk=%Z~02>&we<;^-<8KY%6l!$jt1+G>^cDYi;y z@G-#=<2Q)XZq$|>@?T1Gz53UJUOqZ8@V3!4h6!;tAju0$P5;%X_V4OW|Le~MHTu`& zz^eDX#lPB2)LPb_sUIf$nyq$zbbw`BaiTEj|P zDWC1s!Pb%(muHIqvuKLS)0KS#iKD(lv%UV? zhFz(cSt`>Zz!W&HIk?M7`_fDuVCE@QwzrrC_E(d-xU&^MovL_YNcYGh&cuwDr#I=M za0hQfZ&x+1P#B7}9u`&w>BjnIF7xEDmV}yYj8y4!3XenNyygJ@!Y_4wIr=t^@8X{~ z>XZyZyDp5rQ_3B#`AC67p9`fYk7?+npDa_4Yrv+IUE3UCMwcBJ0_N~UW!g6og^Ugz zM6CX`hslud;(VuC1G9z#7oEym0o0%4nDO z$-TDu{I0ZoS}s9Pk&!=kYz^5H@0ke;Afp0XSJBP+^E_7gJVL`Kba3OitY2Mg3zmC> zZSzX0R|mL5N29B3lpM0XO*^!G`=0qNXN>HQFr$N}@Yc7OCEb1h!V0r|m_}FUll>Qr z*5O32dBbJN3x_BDi0J7p2NE`K-emU=EkoBP>;ttt(iwV%fs|gHMchdhMBb323@6X+ z#MeG96;XIhat<4OleuE_V>2|oQe$CqH~PhJRQNg}YRs3q)6?^Y5S79W!t|T-vTmB{ zTMvxjFi%KQQ)i$ZQU|lbOzYJKr{|=+6IB}Y;G$d6wS97AmT8Xfmff!0mMEFTXMAU~ zbyQmHBLYv|%U`{U*{>cFj?W6HbFp%W)=9R&zfeI?)phvMb$~Gwbyl8)znghEHkScb zrG1MWSNgJr@Og@LbJV!IKm@sz3uW$h0$=1P-E)09`epn^FSDp-Vys3Mmsx zj^#p*2CX1hmJ(Ab8ujLz0cm4L?gfJ4oGR7Dv^I;=;}07SyA%lu@72>>bC*P38>UR5 zPK@BG>nT1eEpmuV3#Yu_uZbU#C4t}sGR#1s0wqvO{{N}s;Xj9=r~dveC#dC6zRRUX z`#`#8^(Y;zl=E=?tr#LhMEd(2fIX)KmIIIsFu*X8@ zz(@N5W$-@loC&+53sr7MN5;qEMv1bj`vdWA#u0n34`|_^|I1G^E*M!1`$$eRG$Yqj zEVhxsb(=hMqdQyh-7QAQi3@}DG7y5nbpYK(o$PM;zg;`9BYb1z!3$&W4_Cy)5VRpweph3T;k^=0h5o77yr=K|G!C`{F|@QNN@oR zJAR{lP~&YfBv4sh=2rJ^<}eaT2FGd-Q=s=QOKq!q>>V6ag$yifqzy!Qd9>q$NP2R%rT)bQ4L z6nszuenj0ra{QA5x4qHt!pi>Q^W8^VJnWf(SIDNtFaIWH{ii?AKy0>Yl@SoG*m{>6nCeg{&F!I5xcpRA9Y z2>_CX{^`z4P9ZCP!>K-<&pGA#{$|)K9Db-Qsy2H5X{%EDW+ zan-)cl#|-2?w5ZQlKoFz=QpxtZ-zC0vxSNRhFb`kGz-uOukq`r5dO!Z-+%M9bE?0y z&{f|09Zd0dl{)0ukE1vd?%(J0`-5QYkAlO~*ZEB;xFm6(<5grpreaCAC3Q&Np>fFqU@ScdAx+-8os<|qE^otkp=Ce!i zwFJrWS7PKqPQdsQd`yP%@JYlL{5ZvjarORRSO2SL{u(pCGn*dT{SKBn!B5Ziym7`0 zy0BXx%8eL%Xf5BpBLP7M`O9Z`6q(NSN8IBaXj_$h6q?cQxo5Ct_Mo{Pu=b1m@Mnj> H?_d89hEDj1 From 6f251bddd33bbdd77fe38e58524225fbd3fcab49 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Tue, 16 Mar 2021 09:07:49 -0700 Subject: [PATCH 27/39] Fix help info in shell is not correctly shown issue (#5360) --- examples/shell/shell_common/cmd_ping.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/examples/shell/shell_common/cmd_ping.cpp b/examples/shell/shell_common/cmd_ping.cpp index bb0101c38b7a42..f1a1ad089561ae 100644 --- a/examples/shell/shell_common/cmd_ping.cpp +++ b/examples/shell/shell_common/cmd_ping.cpp @@ -361,14 +361,15 @@ void PrintUsage(streamer_t * stream) { streamer_printf(stream, "Usage: ping [options] \n\nOptions:\n"); - streamer_printf(stream, - " -h print help information\n" - " -u use UDP (default)\n" - " -t use TCP\n" - " -p echo server port\n" - " -i ping interval time in seconds\n" - " -c stop after replies\n" - " -r <1|0> enalbe/disable CRMP\n"); + // Need to split the help info to prevent overflowing the streamer_printf + // buffer (CONSOLE_DEFAULT_MAX_LINE 256) + streamer_printf(stream, " -h print help information\n"); + streamer_printf(stream, " -u use UDP (default)\n"); + streamer_printf(stream, " -t use TCP\n"); + streamer_printf(stream, " -p echo server port\n"); + streamer_printf(stream, " -i ping interval time in seconds\n"); + streamer_printf(stream, " -c stop after replies\n"); + streamer_printf(stream, " -r <1|0> enable or disable CRMP\n"); } int cmd_ping(int argc, char ** argv) From 6e0aaa5289e0cade934771f85c4e53bd9faf7b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Kr=C3=B3lik?= <66667989+Damian-Nordic@users.noreply.github.com> Date: Tue, 16 Mar 2021 17:14:54 +0100 Subject: [PATCH 28/39] [doc] Add guide on setting up Thread environment for chip-device-ctrl.py (#5320) Add an instruction on how to set up a simple testing environment on Raspberry Pi or other Linux machine to enable using Python CHIP Controller with Thread devices. The instruction recommends using nRF52840 Dongle as a Thread radio device, but can be easily adapted to other radio solutions. --- docs/guides/linux_thread_connectivity.md | 122 +++++++++ docs/guides/openthread_rcp_nrf_dongle.md | 64 +++++ docs/images/linux_thread_connectivity.svg | 312 ++++++++++++++++++++++ src/controller/python/README.md | 12 +- 4 files changed, 506 insertions(+), 4 deletions(-) create mode 100644 docs/guides/linux_thread_connectivity.md create mode 100644 docs/guides/openthread_rcp_nrf_dongle.md create mode 100644 docs/images/linux_thread_connectivity.svg diff --git a/docs/guides/linux_thread_connectivity.md b/docs/guides/linux_thread_connectivity.md new file mode 100644 index 00000000000000..35ca8de7bf2cb5 --- /dev/null +++ b/docs/guides/linux_thread_connectivity.md @@ -0,0 +1,122 @@ +# Configuring Thread network on a Linux machine + +You can use a Project CHIP controller such as +[Python CHIP Controller](../../src/controller/python/README.md) to control +Thread devices enabled for Project CHIP from a Linux host. + +For this purpose, you must equip the host with a Thread radio device, create a +new Thread network, and ensure that packets addressed to devices within the +network are routed through the radio device. + +
+ +- [Overview](#overview) +- [Requirements](#requirements) +- [Configuration](#configuration) +- [Preparing OpenThread Radio Co-Processor device](#preparing-openthread-radio-co-processor) +- [Configuring OpenThread Border Router](#configuring-openthread-border-router) +- [Testing](#testing) + +
+ +## Overview + +The following figure shows the setup created as a result of configuring Thread +network on a Linux machine. + +![linux_thread_connectivity](../images/linux_thread_connectivity.svg) + +In this setup, the connectivity between Python CHIP Controller and Thread +devices is ensured in the following way: + +- CHIP messages generated by the Project CHIP controller are routed through a + virtual network interface **otbr0** to + [OpenThread Border Router container](https://openthread.io/guides/border-router/docker) + in Docker. +- The OpenThread Border Router container uses a device with the + [OpenThread Radio Co-Processor](https://openthread.io/platforms/co-processor) + firmware to transmit Project CHIP messages to the Thread network. +- CHIP-enabled Thread devices connected to the same Thread network receive and + consume Project CHIP messages. + +
+ +## Requirements + +You need the following hardware and software for this configuration: + +- OpenThread Radio Co-Processor device (for example, + [nRF52840 Dongle](https://www.nordicsemi.com/Software-and-tools/Development-Kits/nRF52840-Dongle)) +- Linux machine with Ubuntu v20.04 or later + +
+ +## Configuration + +The configuration process is composed of the following steps: + +- Preparing OpenThread Radio Co-Processor (RCP) device +- Configuring OpenThread Border Router container in Docker + +### Configuring OpenThread Radio Co-Processor + +Read +[Configuring OpenThread Radio Co-processor on nRF52840 Dongle](openthread_rcp_nrf_dongle.md) +to learn how to configure Nordic Semiconductor's +[nRF52840 Dongle](https://www.nordicsemi.com/Software-and-tools/Development-Kits/nRF52840-Dongle) +as OpenThread Radio Co-Processor. + +You can replace the nRF52840 Dongle with a variety of development boards from +different vendors. If you are using a Raspberry Pi as your testing platform, you +can execute this step on a more powerful Linux machine to shorten the firmware +build time. + +### Configuring OpenThread Border Router + +To configure OpenThread Border Router, complete the following steps: + +1. Install Docker daemon: + + $ sudo apt update && sudo apt install docker.io + +2. Start the Docker daemon: + + $ sudo systemctl start docker + +3. Create an IPv6 network for the OpenThread Border Router container in Docker: + + $ sudo docker network create --ipv6 --subnet fd11:db8:1::/64 -o com.docker.network.bridge.name=otbr0 otbr + +4. Start the OpenThread Border Router container using the following command (in + the last line, replace _/dev/ttyACM0_ with the device node name of the + OpenThread Radio Co-processor): + + $ sudo docker run -it --rm --privileged --network otbr -p 8080:80 -e NAT64=0 -e DNS64=0 \ + --sysctl "net.ipv6.conf.all.disable_ipv6=0 net.ipv4.conf.all.forwarding=1 net.ipv6.conf.all.forwarding=1" \ + --volume /dev/ttyACM0:/dev/radio openthread/otbr --radio-url spinel+hdlc+uart:///dev/radio + +5. Open the `http://localhost:8080/` address in a web browser. If you are using + a Raspberry Pi without a screen, but you have a different device in the same + network, you can start a web browser on that device and use the address of + the Raspberry Pi instead of `localhost`. +6. Click **Form** in the menu to the left. The network forming creator window + appears. +7. Make sure that the On-Mesh Prefix is set to `fd11:22::`. This value is used + later to configure the IPv6 packet routing. +8. Click the **Form** button at the bottom of the window to form a new Thread + network using the default settings. +9. To ensure that packets addressed to devices in the Thread network are routed + through the OpenThread Border Router container in Docker, run the following + command with the On-Mesh Prefix that you set earlier: + + $ sudo ip -6 route add fd11:22::/64 dev otbr0 via fd11:db8:1::2 + +
+ +## Testing + +After Open Thread Border Router has been configured, complete the steps +described in the +[Python CHIP Controller README](../../src/controller/python/README.md) to +commission a Thread device into the network and control it using the Project +CHIP protocol. diff --git a/docs/guides/openthread_rcp_nrf_dongle.md b/docs/guides/openthread_rcp_nrf_dongle.md new file mode 100644 index 00000000000000..03248105e8fda8 --- /dev/null +++ b/docs/guides/openthread_rcp_nrf_dongle.md @@ -0,0 +1,64 @@ +# Configuring OpenThread Radio Co-processor on nRF52840 Dongle + +OpenThread Radio Co-processor design allows to add Thread network capabilities +to devices that do not natively support Thread. + +You can build and program +[OpenThread Radio Co-Processor](https://openthread.io/platforms/co-processor) +(RCP) firmware onto Nordic Semiconductor's +[nRF52840 Dongle](https://www.nordicsemi.com/Software-and-tools/Development-Kits/nRF52840-Dongle). +Once programmed, the dongle can be used for +[configuring Thread network on a Linux machine](linux_thread_connectivity.md). + +## Building and programming the RCP firmware onto an nRF52840 Dongle + +Run the following commands to build and program the RCP firmware onto an +nRF52840 Dongle: + +1. Clone the OpenThread repository into the current directory: + + $ git clone https://github.com/openthread/openthread.git + +2. Enter the _openthread_ directory: + + $ cd openthread + +3. Install OpenThread dependencies: + + $ ./script/bootstrap + +4. Set up the build environment: + + $ ./bootstrap + +5. Build OpenThread for the nRF52840 Dongle: + + $ make -f examples/Makefile-nrf52840 BOOTLOADER=USB USB=1 THREAD_VERSION=1.2 + + This creates an RCP image at `output/nrf52840/bin/ot-rcp`. + +6. Convert the RCP image to the `.hex` format: + + $ arm-none-eabi-objcopy -O ihex output/nrf52840/bin/ot-rcp output/nrf52840/bin/ot-rcp.hex + +7. Install + [nRF Util](https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Util): + + $ python3 -m pip install -U nrfutil + +8. Generate the RCP firmware package: + + $ nrfutil pkg generate --hw-version 52 --sd-req=0x00 \ + --application output/nrf52840/bin/ot-rcp.hex \ + --application-version 1 output/nrf52840/bin/ot-rcp.zip + +9. Connect the nRF52840 Dongle to the USB port. + +10. Press the **Reset** button on the dongle to put it into the DFU mode. Red + LED on the dongle starts blinking. + +11. To install the RCP firmware package onto the dongle, run the following + command, with _/dev/ttyACM0_ replaced with the device node name of your + nRF52840 Dongle: + + $ nrfutil dfu usb-serial -pkg output/nrf52840/bin/ot-rcp.zip -p /dev/ttyACM0 diff --git a/docs/images/linux_thread_connectivity.svg b/docs/images/linux_thread_connectivity.svg new file mode 100644 index 00000000000000..5c354dac59350e --- /dev/null +++ b/docs/images/linux_thread_connectivity.svg @@ -0,0 +1,312 @@ + + + +image/svg+xml + + + + + + + + + + + + Drawing + + Nordic Middle Grey + Linux machine (Raspberry Pi or other) + + Linux machine (Raspberry Pi or other) + + + Nordic Light Grey + Controller (Python CHIP Controller) + + Controller(Python CHIP Controller) + + + Nordic Light Grey.8 + Virtual network interface (otbr0) + + Virtual network interface (otbr0) + + + Nordic Light Grey.9 + OpenThread Border Router Docker image + + OpenThread Border RouterDocker container + + + Dynamic connector + + + + Dynamic connector.11 + + + + Nordic Light Grey.12 + OpenThread Radio Co-Processor (on nRF52840 Dongle or other) + + OpenThread Radio Co-Processor (on nRF52840 Dongle or other) + + + Nordic Light Grey.13 + Thread device enabled for Project CHIP + + Thread device enabledfor Project CHIP + + + Dynamic connector.14 + Thread + + + Thread + + + Dynamic connector.15 + USB + + + USB + + + \ No newline at end of file diff --git a/src/controller/python/README.md b/src/controller/python/README.md index 2838607b96b1f6..a4b654261096e6 100644 --- a/src/controller/python/README.md +++ b/src/controller/python/README.md @@ -163,21 +163,25 @@ chip-device-ctrl > set-pairing-wifi-credential TestAP TestPassword chip-device-ctrl > connect -ble 1383 12345678 ``` -## Thread Secure Session provisioning +## Thread provisioning -1. Run CHIP Device Controller +1. Configure Thread border router. For example, follow + [Configuring Thread network on a Linux machine](../../../docs/guides/linux_thread_connectivity.md) + instruction to configure OpenThread Border Router on a Linux workstation. + +2. Run CHIP Device Controller ``` sudo chip-device-ctrl ``` -2. Set Thread credentials +3. Set Thread credentials ``` set-pairing-thread-credential ``` -3. BLE Connect to the device +4. BLE Connect to the device ``` connect -ble [] From c54101c1123345a8b6ae9870f802c4c00c19e1be Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Tue, 16 Mar 2021 17:17:27 +0100 Subject: [PATCH 29/39] error: no member named 'OnPeristentStorageValue' in 'chip::PersistentStorageResultDelegate' (#5397) --- .../Framework/CHIP/CHIPPersistentStorageDelegateBridge.mm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.mm b/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.mm index 0222ef3fd42b03..aa235928acb398 100644 --- a/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.mm +++ b/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.mm @@ -49,7 +49,7 @@ chip::PersistentStorageResultDelegate * callback = mCallback; if (callback) { dispatch_async(mWorkQueue, ^{ - callback->OnPeristentStorageValue([key UTF8String], [value UTF8String]); + callback->OnPersistentStorageValue([key UTF8String], [value UTF8String]); }); } }; @@ -58,8 +58,8 @@ chip::PersistentStorageResultDelegate * callback = mCallback; if (callback) { dispatch_async(mWorkQueue, ^{ - callback->OnPeristentStorageStatus([key UTF8String], chip::PersistentStorageResultDelegate::Operation::kSET, - [CHIPError errorToCHIPErrorCode:status]); + callback->OnPersistentStorageStatus([key UTF8String], + chip::PersistentStorageResultDelegate::Operation::kSET, [CHIPError errorToCHIPErrorCode:status]); }); } }; @@ -68,7 +68,7 @@ chip::PersistentStorageResultDelegate * callback = mCallback; if (callback) { dispatch_async(mWorkQueue, ^{ - callback->OnPeristentStorageStatus([key UTF8String], + callback->OnPersistentStorageStatus([key UTF8String], chip::PersistentStorageResultDelegate::Operation::kDELETE, [CHIPError errorToCHIPErrorCode:status]); }); } From 79d36fa3f49ed26aae1f7bb66791b7750bcdf368 Mon Sep 17 00:00:00 2001 From: jmartinez-silabs <67972863+jmartinez-silabs@users.noreply.github.com> Date: Tue, 16 Mar 2021 12:34:42 -0400 Subject: [PATCH 30/39] Examples running on EFR32MG21 fail rendez-vous at Spake2p msg1 (#5375) * wip * Remove all _ALT defines, let "config-device-acceleration.h" define the right alternates API to accelerate MG21 crypto * Cleanup Mbedtls defines reactivate LCD on BRD4180A Free up some heap space by reducing some task stack size * Restyled by gn Co-authored-by: jepenven-silabs Co-authored-by: Restyled.io --- examples/lighting-app/efr32/src/AppTask.cpp | 2 +- examples/lock-app/efr32/src/AppTask.cpp | 2 +- .../EFR32/efr32-chip-mbedtls-config.h | 161 ++++-------------- src/platform/EFR32/freertos_bluetooth.c | 4 +- third_party/efr32_sdk/efr32_sdk.gni | 20 ++- 5 files changed, 49 insertions(+), 140 deletions(-) diff --git a/examples/lighting-app/efr32/src/AppTask.cpp b/examples/lighting-app/efr32/src/AppTask.cpp index 8c1599ecf58cfb..212a3491823a66 100644 --- a/examples/lighting-app/efr32/src/AppTask.cpp +++ b/examples/lighting-app/efr32/src/AppTask.cpp @@ -47,7 +47,7 @@ #define FACTORY_RESET_TRIGGER_TIMEOUT 3000 #define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000 -#define APP_TASK_STACK_SIZE (4096) +#define APP_TASK_STACK_SIZE (2048) #define APP_TASK_PRIORITY 2 #define APP_EVENT_QUEUE_SIZE 10 #define EXAMPLE_VENDOR_ID 0xcafe diff --git a/examples/lock-app/efr32/src/AppTask.cpp b/examples/lock-app/efr32/src/AppTask.cpp index 6ca91522a3c1c5..a80c10e7b5d173 100644 --- a/examples/lock-app/efr32/src/AppTask.cpp +++ b/examples/lock-app/efr32/src/AppTask.cpp @@ -47,7 +47,7 @@ #define FACTORY_RESET_TRIGGER_TIMEOUT 3000 #define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000 -#define APP_TASK_STACK_SIZE (4096) +#define APP_TASK_STACK_SIZE (2048) #define APP_TASK_PRIORITY 2 #define APP_EVENT_QUEUE_SIZE 10 diff --git a/src/platform/EFR32/efr32-chip-mbedtls-config.h b/src/platform/EFR32/efr32-chip-mbedtls-config.h index 501f811bacd6fe..4ddebceb9029fc 100644 --- a/src/platform/EFR32/efr32-chip-mbedtls-config.h +++ b/src/platform/EFR32/efr32-chip-mbedtls-config.h @@ -34,6 +34,7 @@ #include "em_device.h" #include "em_se.h" +#include "sl_malloc.h" /** * Enable FreeRTOS threading support @@ -55,106 +56,6 @@ #define MBEDTLS_CIPHER_MODE_CTR #define MBEDTLS_TRNG_C -/** - * \def MBEDTLS_AES_ALT - * - * Enable hardware acceleration for the AES block cipher - * - * Module: sl_crypto/src/crypto_aes.c for devices with CRYPTO - * sl_crypto/src/aes_aes.c for devices with AES - * - * See MBEDTLS_AES_C for more information. - */ -#define MBEDTLS_AES_ALT - -#if defined(EFR32MG12) -#define MBEDTLS_SHA1_C -#define TRNG_PRESENT - -#if defined(CRYPTO_COUNT) && (CRYPTO_COUNT > 0) -/** - * \def MBEDTLS_ECP_INTERNAL_ALT - * \def ECP_SHORTWEIERSTRASS - * \def MBEDTLS_ECP_ADD_MIXED_ALT - * \def MBEDTLS_ECP_DOUBLE_JAC_ALT - * \def MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT - * \def MBEDTLS_ECP_NORMALIZE_JAC_ALT - * - * Enable hardware acceleration for the elliptic curve over GF(p) library. - * - * Module: sl_crypto/src/crypto_ecp.c - * Caller: library/ecp.c - * - * Requires: MBEDTLS_BIGNUM_C, MBEDTLS_ECP_C and at least one - * MBEDTLS_ECP_DP_XXX_ENABLED and (CRYPTO_COUNT > 0) - */ -#define MBEDTLS_ECP_INTERNAL_ALT -#define ECP_SHORTWEIERSTRASS -#define MBEDTLS_ECP_ADD_MIXED_ALT -#define MBEDTLS_ECP_DOUBLE_JAC_ALT -#define MBEDTLS_ECP_NORMALIZE_JAC_MANY_ALT -#define MBEDTLS_ECP_NORMALIZE_JAC_ALT -#define MBEDTLS_ECP_RANDOMIZE_JAC_ALT - -/** - * \def MBEDTLS_SHA1_ALT - * - * Enable hardware acceleration for the SHA-224 and SHA-256 cryptographic - * hash algorithms. - * Module: sl_crypto/src/crypto_sha.c - * Caller: library/mbedtls_md.c - * library/ssl_cli.c - * library/ssl_srv.c - * library/ssl_tls.c - * library/x509write_crt.c - * - * Requires: MBEDTLS_SHA1_C and (CRYPTO_COUNT > 0) - * See MBEDTLS_SHA1_C for more information. - */ -#define MBEDTLS_SHA1_ALT - -/** - * \def MBEDTLS_SHA256_ALT - * - * Enable hardware acceleration for the SHA-224 and SHA-256 cryptographic - * hash algorithms. - * - * Module: sl_crypto/src/crypto_sha.c - * Caller: library/entropy.c - * library/mbedtls_md.c - * library/ssl_cli.c - * library/ssl_srv.c - * library/ssl_tls.c - * - * Requires: MBEDTLS_SHA256_C and (CRYPTO_COUNT > 0) - * See MBEDTLS_SHA256_C for more information. - */ -#define MBEDTLS_SHA256_ALT -#endif - -#elif defined(EFR32MG21) -#define MBEDTLS_SHA1_ALT -#define MBEDTLS_SHA1_PROCESS_ALT -#define MBEDTLS_SHA256_ALT -#define MBEDTLS_SHA256_PROCESS_ALT -#define MBEDTLS_SHA512_ALT -#define MBEDTLS_SHA512_PROCESS_ALT - -#define MBEDTLS_CCM_ALT -#define MBEDTLS_CMAC_ALT - -/* Turning on ECC acceleration is dependant on not requiring curve25519 when - * running on EFR32xG21A devices */ -#if (defined(_SILICON_LABS_SECURITY_FEATURE) && (_SILICON_LABS_SECURITY_FEATURE == _SILICON_LABS_SECURITY_FEATURE_VAULT)) || \ - !defined(MBEDTLS_ECP_DP_CURVE25519_ENABLED) -#define MBEDTLS_ECDH_GEN_PUBLIC_ALT -#define MBEDTLS_ECDSA_GENKEY_ALT -#define MBEDTLS_ECDH_COMPUTE_SHARED_ALT -#define MBEDTLS_ECDSA_SIGN_ALT -#define MBEDTLS_ECDSA_VERIFY_ALT -#endif /* EFR32xG21B or curve25519 not enabled */ -#endif // Familiy Selection - #if defined(MBEDTLS_ECP_ALT) && !defined(MBEDTLS_ECP_RESTARTABLE) typedef void mbedtls_ecp_restart_ctx; #endif @@ -164,71 +65,74 @@ typedef void mbedtls_ecp_restart_ctx; #define MBEDTLS_AES_ROM_TABLES #define MBEDTLS_ASN1_PARSE_C #define MBEDTLS_ASN1_WRITE_C +#define MBEDTLS_BASE64_C #define MBEDTLS_BIGNUM_C #define MBEDTLS_CCM_C #define MBEDTLS_CIPHER_C +#define MBEDTLS_CIPHER_MODE_CBC +#define MBEDTLS_CIPHER_MODE_CFB #define MBEDTLS_CMAC_C #define MBEDTLS_CTR_DRBG_C +#define MBEDTLS_ECDH_LEGACY_CONTEXT +#define MBEDTLS_ECDSA_C #define MBEDTLS_ECJPAKE_C #define MBEDTLS_ECP_DP_SECP256R1_ENABLED #define MBEDTLS_ECP_NIST_OPTIM +#define MBEDTLS_ENTROPY_FORCE_SHA256 #define MBEDTLS_ENTROPY_HARDWARE_ALT +#define MBEDTLS_ERROR_STRERROR_DUMMY #define MBEDTLS_HAVE_ASM +#define MBEDTLS_HKDF_C #define MBEDTLS_HMAC_DRBG_C +#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED #define MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED +#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED #define MBEDTLS_MD_C #define MBEDTLS_NO_PLATFORM_ENTROPY +#define MBEDTLS_OID_C +#define MBEDTLS_PEM_PARSE_C +#define MBEDTLS_PEM_WRITE_C #define MBEDTLS_PK_C #define MBEDTLS_PK_PARSE_C #define MBEDTLS_PK_WRITE_C +#define MBEDTLS_PKCS5_C #define MBEDTLS_PLATFORM_C #define MBEDTLS_PLATFORM_MEMORY #define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS +#define MBEDTLS_PSA_CRYPTO_C +#define MBEDTLS_PSA_CRYPTO_CONFIG +#define MBEDTLS_PSA_CRYPTO_DRIVERS +#define MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS +#define MBEDTLS_PSA_CRYPTO_STORAGE_C #define MBEDTLS_SHA256_SMALLER +#define MBEDTLS_SHA512_C #define MBEDTLS_SSL_CLI_C +#define MBEDTLS_SSL_COOKIE_C #define MBEDTLS_SSL_DTLS_ANTI_REPLAY #define MBEDTLS_SSL_DTLS_HELLO_VERIFY #define MBEDTLS_SSL_EXPORT_KEYS +#define MBEDTLS_SSL_KEEP_PEER_CERTIFICATE #define MBEDTLS_SSL_MAX_FRAGMENT_LENGTH #define MBEDTLS_SSL_PROTO_TLS1_2 #define MBEDTLS_SSL_PROTO_DTLS +#define MBEDTLS_SSL_SRV_C #define MBEDTLS_SSL_TLS_C -#define MBEDTLS_ERROR_STRERROR_DUMMY -#define MBEDTLS_HKDF_C #define MBEDTLS_X509_CREATE_C #define MBEDTLS_X509_CSR_WRITE_C -#define MBEDTLS_BASE64_C -#define MBEDTLS_PEM_WRITE_C -#define MBEDTLS_PKCS5_C - -#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE || OPENTHREAD_CONFIG_COMMISSIONER_ENABLE || OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE -#define MBEDTLS_SSL_COOKIE_C -#define MBEDTLS_SSL_SRV_C -#endif - -#if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE -#define MBEDTLS_KEY_EXCHANGE_PSK_ENABLED -#define MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED -#endif - -#ifdef MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED -#define MBEDTLS_BASE64_C -#define MBEDTLS_ECDSA_C -#define MBEDTLS_OID_C -#define MBEDTLS_PEM_PARSE_C -#define MBEDTLS_X509_USE_C +#define MBEDTLS_X509_CRL_PARSE_C #define MBEDTLS_X509_CRT_PARSE_C -#endif +#define MBEDTLS_X509_CSR_PARSE_C +#define MBEDTLS_X509_USE_C #define MBEDTLS_MPI_WINDOW_SIZE 1 /**< Maximum windows size used. */ #define MBEDTLS_MPI_MAX_SIZE 32 /**< Maximum number of bytes for usable MPIs. */ #define MBEDTLS_ECP_MAX_BITS 256 /**< Maximum bit size of groups */ #define MBEDTLS_ECP_WINDOW_SIZE 2 /**< Maximum window size used */ #define MBEDTLS_ECP_FIXED_POINT_OPTIM 0 /**< Enable fixed-point speed-up */ -#define MBEDTLS_ENTROPY_MAX_SOURCES 1 /**< Maximum number of sources supported */ +#define MBEDTLS_ENTROPY_MAX_SOURCES 2 /**< Maximum number of sources supported */ -#define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< Default allocator to use, can be undefined */ -#define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use, can be undefined */ +#define MBEDTLS_PLATFORM_STD_CALLOC sl_calloc /**< Default allocator to use, can be undefined */ +#define MBEDTLS_PLATFORM_STD_FREE sl_free /**< Default free to use, can be undefined */ #if OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE #define MBEDTLS_SSL_MAX_CONTENT_LEN 900 /**< Maxium fragment length in bytes */ @@ -238,6 +142,5 @@ typedef void mbedtls_ecp_restart_ctx; #define MBEDTLS_SSL_CIPHERSUITES MBEDTLS_TLS_ECJPAKE_WITH_AES_128_CCM_8 -#if defined(MBEDTLS_USER_CONFIG_FILE) -#include MBEDTLS_USER_CONFIG_FILE -#endif +#include "config-device-acceleration.h" +#include "mbedtls/check_config.h" diff --git a/src/platform/EFR32/freertos_bluetooth.c b/src/platform/EFR32/freertos_bluetooth.c index 4fdc47035ff59d..9d6c5be95c4d2e 100644 --- a/src/platform/EFR32/freertos_bluetooth.c +++ b/src/platform/EFR32/freertos_bluetooth.c @@ -42,7 +42,7 @@ static volatile sl_bgapi_handler command_handler_func = NULL; // Bluetooth task #ifndef BLUETOOTH_STACK_SIZE -#define BLUETOOTH_STACK_SIZE (2048) +#define BLUETOOTH_STACK_SIZE (1024) #endif static void BluetoothTask(void * p_arg); static TaskHandle_t BluetoothTaskHandle = NULL; @@ -53,7 +53,7 @@ extern uint32_t sli_bt_can_sleep_ticks(); // Linklayer task #ifndef LINKLAYER_STACK_SIZE -#define LINKLAYER_STACK_SIZE (2048) +#define LINKLAYER_STACK_SIZE (1024) #endif static void LinklayerTask(void * p_arg); static TaskHandle_t LinklayerTaskHandle = NULL; diff --git a/third_party/efr32_sdk/efr32_sdk.gni b/third_party/efr32_sdk/efr32_sdk.gni index 416ce3aca3a9d5..cbbca4c33e084c 100644 --- a/third_party/efr32_sdk/efr32_sdk.gni +++ b/third_party/efr32_sdk/efr32_sdk.gni @@ -97,20 +97,22 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/middleware/glib", "${efr32_sdk_root}/platform/middleware/glib/glib", "${efr32_sdk_root}/platform/middleware/glib/dmd", + "${efr32_sdk_root}/platform/base/hal/plugin/psstore", + "${efr32_sdk_root}/platform/base/hal/plugin/antenna", "${efr32_sdk_root}/hardware/kit/config", "${efr32_sdk_root}/util/silicon_labs/silabs_core/graphics", "${efr32_sdk_root}/util/third_party/crypto/mbedtls/include", "${efr32_sdk_root}/util/third_party/crypto/mbedtls/include/mbedtls", "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library", - "${efr32_sdk_root}/platform/base/hal/plugin/psstore", - "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_protocol_crypto/src", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_alt/include", + + #"${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_protocol_crypto/src", "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_mbedtls_support/inc", - "${efr32_sdk_root}/platform/base/hal/plugin/antenna", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_mbedtls_support/inc/configs", "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_psa_driver/inc", "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/inc", "${efr32_sdk_root}/util/silicon_labs/silabs_core/memory_manager", "${efr32_sdk_root}/platform/bootloader", - "${mbedtls_root}/repo/include", ] if (efr32_board == "BRD4166A") { @@ -185,7 +187,6 @@ template("efr32_sdk") { "${efr32_sdk_root}/util/third_party/freertos/Source/portable/GCC/ARM_CM3", "${efr32_sdk_root}/platform/radio/rail_lib/plugin/pa-conversions/efr32xg21/config", "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src", - "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_alt/include", ] libs += [ @@ -268,6 +269,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/service/sleeptimer/src/sl_sleeptimer.c", "${efr32_sdk_root}/platform/service/sleeptimer/src/sl_sleeptimer_hal_rtcc.c", "${efr32_sdk_root}/protocol/bluetooth/src/sl_bt_mbedtls_context.c", + "${efr32_sdk_root}/util/silicon_labs/silabs_core/memory_manager/sl_malloc.c", "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/aes.c", "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/aesni.c", "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/arc4.c", @@ -295,6 +297,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/entropy_poll.c", "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/error.c", "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/gcm.c", + "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/hkdf.c", "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/hmac_drbg.c", "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/md.c", "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/md5.c", @@ -307,6 +310,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/pkparse.c", "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/pkwrite.c", "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/platform.c", + "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/platform_util.c", "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/ripemd160.c", "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/rsa.c", "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/rsa_internal.c", @@ -328,6 +332,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/x509.c", "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/x509_create.c", "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/x509_crl.c", + "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/x509_crt.c", "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/x509_csr.c", "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/x509write_crt.c", "${efr32_sdk_root}/util/third_party/crypto/mbedtls/library/x509write_csr.c", @@ -343,6 +348,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_protocol_crypto/src/sli_protocol_crypto_radioaes.c", "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_psa_driver/src/crypto_management.c", "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_crypto_transparent_driver_hash.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_driver_signature.c", "${efr32_sdk_root}/util/third_party/freertos/Source/croutine.c", "${efr32_sdk_root}/util/third_party/freertos/Source/event_groups.c", "${efr32_sdk_root}/util/third_party/freertos/Source/include/FreeRTOS.h", @@ -351,8 +357,6 @@ template("efr32_sdk") { "${efr32_sdk_root}/util/third_party/freertos/Source/queue.c", "${efr32_sdk_root}/util/third_party/freertos/Source/tasks.c", "${efr32_sdk_root}/util/third_party/freertos/Source/timers.c", - "${mbedtls_root}/repo/library/hkdf.c", - "${mbedtls_root}/repo/library/platform_util.c", ] if (defined(enable_fem)) { @@ -392,9 +396,11 @@ template("efr32_sdk") { "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_hash.c", "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_key_derivation.c", "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_key_handling.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_signature.c", "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_alt/source/sl_se_management.c", "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_mbedtls_support/src/se_aes.c", "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_mbedtls_support/src/se_ccm.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_mbedtls_support/src/se_jpake.c", "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_protocol_crypto/src/sli_radioaes_management.c", "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_driver_key_derivation.c", "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_driver_key_management.c", From 85c0f95741662f81665c90056ae98dddc6e23f48 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Tue, 16 Mar 2021 17:37:20 +0100 Subject: [PATCH 31/39] error: unknown type name 'CHIPInt64uAttributeCallbackBridge' (#5398) --- .../gen/CHIPClustersObjc.mm | 34 +++++++++++++++++- .../bridge-common/gen/CHIPClustersObjc.mm | 34 +++++++++++++++++- examples/chip-tool/gen/CHIPClustersObjc.mm | 34 +++++++++++++++++- .../lighting-common/gen/CHIPClustersObjc.mm | 34 +++++++++++++++++- .../lock-common/gen/CHIPClustersObjc.mm | 34 +++++++++++++++++- .../esp32/main/gen/CHIPClustersObjc.mm | 34 +++++++++++++++++- .../tv-app/tv-common/gen/CHIPClustersObjc.mm | 34 +++++++++++++++++- src/app/zap-templates/app-templates.json | 4 +-- .../{chip => app}/CHIPClustersObjc-src.zapt | 35 ++++++++++++++++++- .../{chip => app}/CHIPClustersObjc.zapt | 0 .../Framework/CHIP/gen/CHIPClustersObjc.mm | 34 +++++++++++++++++- 11 files changed, 300 insertions(+), 11 deletions(-) rename src/app/zap-templates/templates/{chip => app}/CHIPClustersObjc-src.zapt (94%) rename src/app/zap-templates/templates/{chip => app}/CHIPClustersObjc.zapt (100%) diff --git a/examples/all-clusters-app/all-clusters-common/gen/CHIPClustersObjc.mm b/examples/all-clusters-app/all-clusters-common/gen/CHIPClustersObjc.mm index 48568b1104c636..37031d4e13869f 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/CHIPClustersObjc.mm +++ b/examples/all-clusters-app/all-clusters-common/gen/CHIPClustersObjc.mm @@ -21,7 +21,7 @@ #import "CHIPDevice.h" #import "CHIPDevice_Internal.h" -#import "ChipError.h" +#import "CHIPError.h" #import "gen/CHIPClientCallbacks.h" #import "gen/CHIPClustersObjc.h" @@ -292,6 +292,38 @@ static void CallbackFn(void * context, uint32_t value) bool mKeepAlive; }; +class CHIPInt64uAttributeCallbackBridge : public Callback::Callback { +public: + CHIPInt64uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mKeepAlive(keepAlive) + { + } + + ~CHIPInt64uAttributeCallbackBridge() {}; + + static void CallbackFn(void * context, uint64_t value) + { + CHIPInt64uAttributeCallbackBridge * callback = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedLongLong:value] }); + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; + bool mKeepAlive; +}; + class CHIPInt16sAttributeCallbackBridge : public Callback::Callback { public: CHIPInt16sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) diff --git a/examples/bridge-app/bridge-common/gen/CHIPClustersObjc.mm b/examples/bridge-app/bridge-common/gen/CHIPClustersObjc.mm index f58335756438ca..11a59ed6077dca 100644 --- a/examples/bridge-app/bridge-common/gen/CHIPClustersObjc.mm +++ b/examples/bridge-app/bridge-common/gen/CHIPClustersObjc.mm @@ -21,7 +21,7 @@ #import "CHIPDevice.h" #import "CHIPDevice_Internal.h" -#import "ChipError.h" +#import "CHIPError.h" #import "gen/CHIPClientCallbacks.h" #import "gen/CHIPClustersObjc.h" @@ -292,6 +292,38 @@ static void CallbackFn(void * context, uint32_t value) bool mKeepAlive; }; +class CHIPInt64uAttributeCallbackBridge : public Callback::Callback { +public: + CHIPInt64uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mKeepAlive(keepAlive) + { + } + + ~CHIPInt64uAttributeCallbackBridge() {}; + + static void CallbackFn(void * context, uint64_t value) + { + CHIPInt64uAttributeCallbackBridge * callback = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedLongLong:value] }); + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; + bool mKeepAlive; +}; + class CHIPInt16sAttributeCallbackBridge : public Callback::Callback { public: CHIPInt16sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) diff --git a/examples/chip-tool/gen/CHIPClustersObjc.mm b/examples/chip-tool/gen/CHIPClustersObjc.mm index cd60722f9897d6..f256509b2b1e3d 100644 --- a/examples/chip-tool/gen/CHIPClustersObjc.mm +++ b/examples/chip-tool/gen/CHIPClustersObjc.mm @@ -21,7 +21,7 @@ #import "CHIPDevice.h" #import "CHIPDevice_Internal.h" -#import "ChipError.h" +#import "CHIPError.h" #import "gen/CHIPClientCallbacks.h" #import "gen/CHIPClustersObjc.h" @@ -292,6 +292,38 @@ static void CallbackFn(void * context, uint32_t value) bool mKeepAlive; }; +class CHIPInt64uAttributeCallbackBridge : public Callback::Callback { +public: + CHIPInt64uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mKeepAlive(keepAlive) + { + } + + ~CHIPInt64uAttributeCallbackBridge() {}; + + static void CallbackFn(void * context, uint64_t value) + { + CHIPInt64uAttributeCallbackBridge * callback = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedLongLong:value] }); + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; + bool mKeepAlive; +}; + class CHIPInt16sAttributeCallbackBridge : public Callback::Callback { public: CHIPInt16sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) diff --git a/examples/lighting-app/lighting-common/gen/CHIPClustersObjc.mm b/examples/lighting-app/lighting-common/gen/CHIPClustersObjc.mm index d554b9bd8ca244..6116b8d82b9acc 100644 --- a/examples/lighting-app/lighting-common/gen/CHIPClustersObjc.mm +++ b/examples/lighting-app/lighting-common/gen/CHIPClustersObjc.mm @@ -21,7 +21,7 @@ #import "CHIPDevice.h" #import "CHIPDevice_Internal.h" -#import "ChipError.h" +#import "CHIPError.h" #import "gen/CHIPClientCallbacks.h" #import "gen/CHIPClustersObjc.h" @@ -292,6 +292,38 @@ static void CallbackFn(void * context, uint32_t value) bool mKeepAlive; }; +class CHIPInt64uAttributeCallbackBridge : public Callback::Callback { +public: + CHIPInt64uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mKeepAlive(keepAlive) + { + } + + ~CHIPInt64uAttributeCallbackBridge() {}; + + static void CallbackFn(void * context, uint64_t value) + { + CHIPInt64uAttributeCallbackBridge * callback = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedLongLong:value] }); + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; + bool mKeepAlive; +}; + class CHIPInt16sAttributeCallbackBridge : public Callback::Callback { public: CHIPInt16sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) diff --git a/examples/lock-app/lock-common/gen/CHIPClustersObjc.mm b/examples/lock-app/lock-common/gen/CHIPClustersObjc.mm index 2877d11c507428..5c3d869c670646 100644 --- a/examples/lock-app/lock-common/gen/CHIPClustersObjc.mm +++ b/examples/lock-app/lock-common/gen/CHIPClustersObjc.mm @@ -21,7 +21,7 @@ #import "CHIPDevice.h" #import "CHIPDevice_Internal.h" -#import "ChipError.h" +#import "CHIPError.h" #import "gen/CHIPClientCallbacks.h" #import "gen/CHIPClustersObjc.h" @@ -292,6 +292,38 @@ static void CallbackFn(void * context, uint32_t value) bool mKeepAlive; }; +class CHIPInt64uAttributeCallbackBridge : public Callback::Callback { +public: + CHIPInt64uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mKeepAlive(keepAlive) + { + } + + ~CHIPInt64uAttributeCallbackBridge() {}; + + static void CallbackFn(void * context, uint64_t value) + { + CHIPInt64uAttributeCallbackBridge * callback = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedLongLong:value] }); + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; + bool mKeepAlive; +}; + class CHIPInt16sAttributeCallbackBridge : public Callback::Callback { public: CHIPInt16sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) diff --git a/examples/temperature-measurement-app/esp32/main/gen/CHIPClustersObjc.mm b/examples/temperature-measurement-app/esp32/main/gen/CHIPClustersObjc.mm index 6329098398a2fa..ab7e6960244f0e 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/CHIPClustersObjc.mm +++ b/examples/temperature-measurement-app/esp32/main/gen/CHIPClustersObjc.mm @@ -21,7 +21,7 @@ #import "CHIPDevice.h" #import "CHIPDevice_Internal.h" -#import "ChipError.h" +#import "CHIPError.h" #import "gen/CHIPClientCallbacks.h" #import "gen/CHIPClustersObjc.h" @@ -292,6 +292,38 @@ static void CallbackFn(void * context, uint32_t value) bool mKeepAlive; }; +class CHIPInt64uAttributeCallbackBridge : public Callback::Callback { +public: + CHIPInt64uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mKeepAlive(keepAlive) + { + } + + ~CHIPInt64uAttributeCallbackBridge() {}; + + static void CallbackFn(void * context, uint64_t value) + { + CHIPInt64uAttributeCallbackBridge * callback = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedLongLong:value] }); + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; + bool mKeepAlive; +}; + class CHIPInt16sAttributeCallbackBridge : public Callback::Callback { public: CHIPInt16sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) diff --git a/examples/tv-app/tv-common/gen/CHIPClustersObjc.mm b/examples/tv-app/tv-common/gen/CHIPClustersObjc.mm index 6647078a096242..79a2894a6be739 100644 --- a/examples/tv-app/tv-common/gen/CHIPClustersObjc.mm +++ b/examples/tv-app/tv-common/gen/CHIPClustersObjc.mm @@ -21,7 +21,7 @@ #import "CHIPDevice.h" #import "CHIPDevice_Internal.h" -#import "ChipError.h" +#import "CHIPError.h" #import "gen/CHIPClientCallbacks.h" #import "gen/CHIPClustersObjc.h" @@ -292,6 +292,38 @@ static void CallbackFn(void * context, uint32_t value) bool mKeepAlive; }; +class CHIPInt64uAttributeCallbackBridge : public Callback::Callback { +public: + CHIPInt64uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mKeepAlive(keepAlive) + { + } + + ~CHIPInt64uAttributeCallbackBridge() {}; + + static void CallbackFn(void * context, uint64_t value) + { + CHIPInt64uAttributeCallbackBridge * callback = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedLongLong:value] }); + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; + bool mKeepAlive; +}; + class CHIPInt16sAttributeCallbackBridge : public Callback::Callback { public: CHIPInt16sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) diff --git a/src/app/zap-templates/app-templates.json b/src/app/zap-templates/app-templates.json index ca59e2bc9e1ff3..01ab9eb959a4d7 100644 --- a/src/app/zap-templates/app-templates.json +++ b/src/app/zap-templates/app-templates.json @@ -131,12 +131,12 @@ "output": "IMClusterCommandHandler.cpp" }, { - "path": "templates/chip/CHIPClustersObjc.zapt", + "path": "templates/app/CHIPClustersObjc.zapt", "name": "Objc ZCL API Header", "output": "CHIPClustersObjc.h" }, { - "path": "templates/chip/CHIPClustersObjc-src.zapt", + "path": "templates/app/CHIPClustersObjc-src.zapt", "name": "Objc ZCL API", "output": "CHIPClustersObjc.mm" } diff --git a/src/app/zap-templates/templates/chip/CHIPClustersObjc-src.zapt b/src/app/zap-templates/templates/app/CHIPClustersObjc-src.zapt similarity index 94% rename from src/app/zap-templates/templates/chip/CHIPClustersObjc-src.zapt rename to src/app/zap-templates/templates/app/CHIPClustersObjc-src.zapt index 4a0ec37eae11f7..e32d63ccc9f85f 100644 --- a/src/app/zap-templates/templates/chip/CHIPClustersObjc-src.zapt +++ b/src/app/zap-templates/templates/app/CHIPClustersObjc-src.zapt @@ -4,7 +4,7 @@ #import "CHIPDevice.h" #import "CHIPDevice_Internal.h" -#import "ChipError.h" +#import "CHIPError.h" #import "gen/CHIPClustersObjc.h" #import "gen/CHIPClientCallbacks.h" @@ -280,6 +280,39 @@ private: bool mKeepAlive; }; +class CHIPInt64uAttributeCallbackBridge : public Callback::Callback { +public: + CHIPInt64uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mKeepAlive(keepAlive) + { + } + + ~CHIPInt64uAttributeCallbackBridge() {}; + + static void CallbackFn(void * context, uint64_t value) + { + CHIPInt64uAttributeCallbackBridge * callback = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @{ @"value": [NSNumber numberWithUnsignedLongLong:value] }); + if (!callback->mKeepAlive) + { + callback->Cancel(); + delete callback; + } + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; + bool mKeepAlive; +}; + class CHIPInt16sAttributeCallbackBridge : public Callback::Callback { public: CHIPInt16sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) diff --git a/src/app/zap-templates/templates/chip/CHIPClustersObjc.zapt b/src/app/zap-templates/templates/app/CHIPClustersObjc.zapt similarity index 100% rename from src/app/zap-templates/templates/chip/CHIPClustersObjc.zapt rename to src/app/zap-templates/templates/app/CHIPClustersObjc.zapt diff --git a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm index cd60722f9897d6..f256509b2b1e3d 100644 --- a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm +++ b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm @@ -21,7 +21,7 @@ #import "CHIPDevice.h" #import "CHIPDevice_Internal.h" -#import "ChipError.h" +#import "CHIPError.h" #import "gen/CHIPClientCallbacks.h" #import "gen/CHIPClustersObjc.h" @@ -292,6 +292,38 @@ static void CallbackFn(void * context, uint32_t value) bool mKeepAlive; }; +class CHIPInt64uAttributeCallbackBridge : public Callback::Callback { +public: + CHIPInt64uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) + : Callback::Callback(CallbackFn, this) + , mHandler(handler) + , mQueue(queue) + , mKeepAlive(keepAlive) + { + } + + ~CHIPInt64uAttributeCallbackBridge() {}; + + static void CallbackFn(void * context, uint64_t value) + { + CHIPInt64uAttributeCallbackBridge * callback = reinterpret_cast(context); + if (callback && callback->mQueue) { + dispatch_async(callback->mQueue, ^{ + callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedLongLong:value] }); + if (!callback->mKeepAlive) { + callback->Cancel(); + delete callback; + } + }); + } + }; + +private: + ResponseHandler mHandler; + dispatch_queue_t mQueue; + bool mKeepAlive; +}; + class CHIPInt16sAttributeCallbackBridge : public Callback::Callback { public: CHIPInt16sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false) From 01ac21645a62e1639aeb8b569b151da550e4d17a Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Tue, 16 Mar 2021 09:54:33 -0700 Subject: [PATCH 32/39] Fix sending PacketBuffer with "ref count > 1" fails in LwIP (#5309) Clone packet buffer and queues that for transmission for Lwip --- src/inet/UDPEndPoint.cpp | 11 +++++++++++ src/system/SystemPacketBuffer.h | 9 +++++++++ 2 files changed, 20 insertions(+) diff --git a/src/inet/UDPEndPoint.cpp b/src/inet/UDPEndPoint.cpp index e874ffb1b01577..c2b3c81d0163f7 100644 --- a/src/inet/UDPEndPoint.cpp +++ b/src/inet/UDPEndPoint.cpp @@ -543,6 +543,17 @@ INET_ERROR UDPEndPoint::SendMsg(const IPPacketInfo * pktInfo, System::PacketBuff #if CHIP_SYSTEM_CONFIG_USE_LWIP + if (!msg.HasSoleOwnership()) + { + // when retaining a buffer, the caller expects the msg to be unmodified. + // LwIP stack will normally prepend the packet headers as the packet traverses + // the UDP/IP/netif layers, which normally modifies the packet. We need to clone + // msg into a fresh object in this case, and queues that for transmission, leaving + // the original msg available after return. + msg = msg.CloneData(); + VerifyOrExit(!msg.IsNull(), res = INET_ERROR_NO_MEMORY); + } + // Lock LwIP stack LOCK_TCPIP_CORE(); diff --git a/src/system/SystemPacketBuffer.h b/src/system/SystemPacketBuffer.h index aec29136f4e48b..f65b3ccc64f659 100644 --- a/src/system/SystemPacketBuffer.h +++ b/src/system/SystemPacketBuffer.h @@ -380,6 +380,7 @@ class DLL_EXPORT PacketBuffer : private pbuf #endif void AddRef(); + bool HasSoleOwnership() const { return (this->ref == 1); } static void Free(PacketBuffer * aPacket); static PacketBuffer * FreeHead(PacketBuffer * aPacket); @@ -474,6 +475,14 @@ class DLL_EXPORT PacketBufferHandle */ bool IsNull() const { return mBuffer == nullptr; } + /** + * Test whether the PacketBuffer owned by this PacketBufferHandle has unique ownership. + * + * @return \c true if the PacketBuffer owned by this PacketBufferHandle is solely owned; return \c false if + * it has more than one ownership. + */ + bool HasSoleOwnership() const { return mBuffer->HasSoleOwnership(); } + /** * Detach and return the head of a buffer chain while updating this handle to point to the remaining buffers. * The current buffer must be the head of the chain. From cb0f14e3ccba9406cf9ce4dffb358e7adb901583 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Tue, 16 Mar 2021 19:11:51 +0100 Subject: [PATCH 33/39] Add missing emberAfMediaPlaybackClusterClientCommandParse symbol to src/darwin/Framework/ (#5400) --- src/darwin/Framework/CHIP.xcodeproj/project.pbxproj | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj b/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj index 40aad367c9bc5b..67b1a476f4b7f4 100644 --- a/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj +++ b/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj @@ -28,6 +28,7 @@ 1EC4CE6025CC26E900D7304F /* CHIPClientCallbacks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1EC4CE5C25CC26E900D7304F /* CHIPClientCallbacks.cpp */; }; 1EC4CE6225CC271B00D7304F /* af-event.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1EC4CE6125CC271B00D7304F /* af-event.cpp */; }; 1EC4CE6425CC276600D7304F /* CHIPClustersObjc.h in Headers */ = {isa = PBXBuildFile; fileRef = 1EC4CE6325CC276600D7304F /* CHIPClustersObjc.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 1ED0B8CC260125E100D19DB5 /* media-playback-client.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1ED0B8CB260125E100D19DB5 /* media-playback-client.cpp */; }; 2C222AD0255C620600E446B9 /* CHIPDevice.h in Headers */ = {isa = PBXBuildFile; fileRef = 2C222ACE255C620600E446B9 /* CHIPDevice.h */; settings = {ATTRIBUTES = (Public, ); }; }; 2C222AD1255C620600E446B9 /* CHIPDevice.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2C222ACF255C620600E446B9 /* CHIPDevice.mm */; }; 2C222ADF255C811800E446B9 /* CHIPDevice_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 2C222ADE255C811800E446B9 /* CHIPDevice_Internal.h */; }; @@ -87,6 +88,7 @@ 1EC4CE5C25CC26E900D7304F /* CHIPClientCallbacks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CHIPClientCallbacks.cpp; path = gen/CHIPClientCallbacks.cpp; sourceTree = ""; }; 1EC4CE6125CC271B00D7304F /* af-event.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "af-event.cpp"; path = "../../../app/util/af-event.cpp"; sourceTree = ""; }; 1EC4CE6325CC276600D7304F /* CHIPClustersObjc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CHIPClustersObjc.h; path = gen/CHIPClustersObjc.h; sourceTree = ""; }; + 1ED0B8CB260125E100D19DB5 /* media-playback-client.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "media-playback-client.cpp"; path = "../../../app/clusters/media-playback-client/media-playback-client.cpp"; sourceTree = ""; }; 2C222ACE255C620600E446B9 /* CHIPDevice.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHIPDevice.h; sourceTree = ""; }; 2C222ACF255C620600E446B9 /* CHIPDevice.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CHIPDevice.mm; sourceTree = ""; }; 2C222ADE255C811800E446B9 /* CHIPDevice_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHIPDevice_Internal.h; sourceTree = ""; }; @@ -142,6 +144,7 @@ 1EC4CE3525CC259700D7304F /* CHIPApp */ = { isa = PBXGroup; children = ( + 1ED0B8CB260125E100D19DB5 /* media-playback-client.cpp */, 1EC4CE6125CC271B00D7304F /* af-event.cpp */, 1EC4CE4925CC267700D7304F /* af-main-common.cpp */, 1EC4CE4125CC267600D7304F /* attribute-size.cpp */, @@ -404,6 +407,7 @@ 1EC4CE6225CC271B00D7304F /* af-event.cpp in Sources */, 1EC4CE4E25CC267700D7304F /* attribute-size.cpp in Sources */, 1EC4CE4D25CC267700D7304F /* process-global-message.cpp in Sources */, + 1ED0B8CC260125E100D19DB5 /* media-playback-client.cpp in Sources */, 1EC4CE5125CC267700D7304F /* message.cpp in Sources */, 1EC4CE5D25CC26E900D7304F /* CHIPClustersObjc.mm in Sources */, B2E0D7B3245B0B5C003C5B48 /* CHIPError.mm in Sources */, From 8b649a234e8797c5f7ac5d05d23b50c9ac155f0e Mon Sep 17 00:00:00 2001 From: Bo YU Date: Wed, 17 Mar 2021 06:04:05 +0800 Subject: [PATCH 34/39] Add python packages for linux setting up (#5387) Add python3.8-dev and python3.8-venv as pi_install.sh Signed-off-by: Bo YU --- scripts/setup/linux/install_packages.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/setup/linux/install_packages.sh b/scripts/setup/linux/install_packages.sh index 993623c1f63478..6d4a0488f0067a 100755 --- a/scripts/setup/linux/install_packages.sh +++ b/scripts/setup/linux/install_packages.sh @@ -39,7 +39,9 @@ apt-get install -fy \ unzip \ wget \ libdbus-1-dev \ - libmbedtls-dev + libmbedtls-dev \ + python3.8-dev \ + python3.8-venv if [[ ! -f 'ci-cache-persistent/openssl/open_ssl_1.1.1f_installed' ]]; then mkdir -p ci-cache-persistent/openssl From 9a8655cf4f58a24bdda35588a86737bdb1ec769c Mon Sep 17 00:00:00 2001 From: Song Guo Date: Wed, 17 Mar 2021 11:16:34 +0800 Subject: [PATCH 35/39] [examples] Enable networkcommissioning on all example apps (#5234) * Emable network commissioning cluster on all example apps * Run codegen --- .../all-clusters-common/BUILD.gn | 2 + .../all-clusters-common/all-clusters-app.zap | 418 +++- .../gen/CHIPClustersObjc.h | 46 + .../gen/CHIPClustersObjc.mm | 279 +++ .../gen/IMClusterCommandHandler.cpp | 332 +++ .../all-clusters-common/gen/attribute-id.h | 12 +- .../gen/call-command-handler.cpp | 263 +++ .../all-clusters-common/gen/callback-stub.cpp | 8 + .../all-clusters-common/gen/callback.h | 164 ++ .../gen/client-command-macro.h | 438 ++-- .../all-clusters-common/gen/cluster-id.h | 6 +- .../all-clusters-common/gen/command-id.h | 38 +- .../all-clusters-common/gen/endpoint_config.h | 68 +- .../all-clusters-common/gen/gen_config.h | 6 + .../all-clusters-common/gen/print-cluster.h | 14 +- .../all-clusters-app/esp32/main/component.mk | 1 + examples/bridge-app/bridge-common/BUILD.gn | 2 + .../bridge-app/bridge-common/bridge-app.zap | 1960 ++++++++--------- .../bridge-common/gen/CHIPClustersObjc.h | 46 + .../bridge-common/gen/CHIPClustersObjc.mm | 279 +++ .../gen/IMClusterCommandHandler.cpp | 332 +++ .../bridge-common/gen/attribute-id.h | 12 +- .../gen/call-command-handler.cpp | 263 +++ .../bridge-common/gen/callback-stub.cpp | 8 + .../bridge-app/bridge-common/gen/callback.h | 164 ++ .../bridge-common/gen/client-command-macro.h | 438 ++-- .../bridge-app/bridge-common/gen/cluster-id.h | 6 +- .../bridge-app/bridge-common/gen/command-id.h | 38 +- .../bridge-common/gen/endpoint_config.h | 62 +- .../bridge-app/bridge-common/gen/gen_config.h | 6 + .../bridge-common/gen/print-cluster.h | 14 +- examples/chip-tool/gen/attribute-id.h | 12 +- examples/chip-tool/gen/client-command-macro.h | 438 ++-- examples/chip-tool/gen/cluster-id.h | 6 +- examples/chip-tool/gen/command-id.h | 38 +- examples/chip-tool/gen/print-cluster.h | 14 +- .../lighting-common/gen/attribute-id.h | 12 +- .../gen/client-command-macro.h | 438 ++-- .../lighting-common/gen/cluster-id.h | 6 +- .../lighting-common/gen/command-id.h | 38 +- .../lighting-common/gen/endpoint_config.h | 36 +- .../lighting-common/gen/print-cluster.h | 14 +- .../lighting-common/lighting-app.zap | 964 ++++---- examples/lock-app/lock-common/BUILD.gn | 2 + .../lock-common/gen/CHIPClustersObjc.h | 46 + .../lock-common/gen/CHIPClustersObjc.mm | 279 +++ .../gen/IMClusterCommandHandler.cpp | 332 +++ .../lock-app/lock-common/gen/attribute-id.h | 12 +- .../lock-common/gen/call-command-handler.cpp | 263 +++ .../lock-common/gen/callback-stub.cpp | 8 + examples/lock-app/lock-common/gen/callback.h | 164 ++ .../lock-common/gen/client-command-macro.h | 438 ++-- .../lock-app/lock-common/gen/cluster-id.h | 6 +- .../lock-app/lock-common/gen/command-id.h | 38 +- .../lock-common/gen/endpoint_config.h | 34 +- .../lock-app/lock-common/gen/gen_config.h | 6 + .../lock-app/lock-common/gen/print-cluster.h | 14 +- examples/lock-app/lock-common/lock-app.zap | 272 ++- examples/lock-app/nrfconnect/CMakeLists.txt | 3 + .../esp32/main/component.mk | 1 + .../esp32/main/gen/CHIPClustersObjc.h | 46 + .../esp32/main/gen/CHIPClustersObjc.mm | 279 +++ .../main/gen/IMClusterCommandHandler.cpp | 332 +++ .../esp32/main/gen/attribute-id.h | 12 +- .../esp32/main/gen/call-command-handler.cpp | 264 +++ .../esp32/main/gen/callback-stub.cpp | 8 + .../esp32/main/gen/callback.h | 164 ++ .../esp32/main/gen/client-command-macro.h | 438 ++-- .../esp32/main/gen/cluster-id.h | 6 +- .../esp32/main/gen/command-id.h | 38 +- .../esp32/main/gen/endpoint_config.h | 34 +- .../esp32/main/gen/gen_config.h | 6 + .../esp32/main/gen/print-cluster.h | 14 +- .../esp32/main/temperature-measurement.zap | 712 +++--- examples/tv-app/tv-common/BUILD.gn | 2 + .../tv-app/tv-common/gen/CHIPClustersObjc.h | 46 + .../tv-app/tv-common/gen/CHIPClustersObjc.mm | 279 +++ .../tv-common/gen/IMClusterCommandHandler.cpp | 332 +++ examples/tv-app/tv-common/gen/attribute-id.h | 12 +- .../tv-common/gen/call-command-handler.cpp | 263 +++ .../tv-app/tv-common/gen/callback-stub.cpp | 8 + examples/tv-app/tv-common/gen/callback.h | 164 ++ .../tv-common/gen/client-command-macro.h | 438 ++-- examples/tv-app/tv-common/gen/cluster-id.h | 6 +- examples/tv-app/tv-common/gen/command-id.h | 38 +- .../tv-app/tv-common/gen/endpoint_config.h | 66 +- examples/tv-app/tv-common/gen/gen_config.h | 6 + examples/tv-app/tv-common/gen/print-cluster.h | 14 +- examples/tv-app/tv-common/tv-app.zap | 1106 ++++++---- src/app/chip-zcl-zpro-codec-api.h | 4 +- .../network-commissioning.cpp | 1 + src/app/encoder.cpp | 6 +- src/app/zap-templates/zcl/commissioning.xml | 2 +- src/controller/CHIPClusters.h | 2 +- src/controller/controller-clusters.zap | 696 +++--- src/darwin/Framework/CHIP/gen/attribute-id.h | 12 +- .../Framework/CHIP/gen/client-command-macro.h | 438 ++-- src/darwin/Framework/CHIP/gen/cluster-id.h | 6 +- src/darwin/Framework/CHIP/gen/command-id.h | 38 +- src/darwin/Framework/CHIP/gen/print-cluster.h | 14 +- 100 files changed, 11118 insertions(+), 4893 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/BUILD.gn b/examples/all-clusters-app/all-clusters-common/BUILD.gn index 0715d61989b3ec..1575d1c978881f 100644 --- a/examples/all-clusters-app/all-clusters-common/BUILD.gn +++ b/examples/all-clusters-app/all-clusters-common/BUILD.gn @@ -39,6 +39,8 @@ source_set("all-clusters-common") { "${chip_root}/src/app/clusters/level-control/level-control.cpp", "${chip_root}/src/app/clusters/low-power-server/low-power-server.cpp", "${chip_root}/src/app/clusters/media-playback-server/media-playback-server.cpp", + "${chip_root}/src/app/clusters/network-commissioning/network-commissioning-ember.cpp", + "${chip_root}/src/app/clusters/network-commissioning/network-commissioning.cpp", "${chip_root}/src/app/clusters/on-off-server/on-off.cpp", "${chip_root}/src/app/clusters/scenes/scenes.cpp", "${chip_root}/src/app/clusters/temperature-measurement-server/temperature-measurement-server.cpp", diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 1bf684669b1ab8..47fc9c80d9d252 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -1,5 +1,5 @@ { - "writeTime": "Thu Mar 11 2021 17:27:52 GMT+0100 (Central European Standard Time)", + "writeTime": "Fri Mar 12 2021 15:15:46 GMT+0800 (China Standard Time)", "featureLevel": 11, "creator": "zap", "keyValuePairs": [ @@ -137,23 +137,6 @@ "define": "GROUPS_CLUSTER", "side": "client", "enabled": 0, - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ], "commands": [ { "name": "AddGroup", @@ -203,6 +186,23 @@ "incoming": 1, "outgoing": 1 } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } ] }, { @@ -369,56 +369,6 @@ "define": "SCENES_CLUSTER", "side": "server", "enabled": 0, - "commands": [ - { - "name": "AddSceneResponse", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "ViewSceneResponse", - "code": 1, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "RemoveSceneResponse", - "code": 2, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "RemoveAllScenesResponse", - "code": 3, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "StoreSceneResponse", - "code": 4, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "GetSceneMembershipResponse", - "code": 6, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - } - ], "attributes": [ { "name": "cluster revision", @@ -510,6 +460,56 @@ "maxInterval": 65344, "reportableChange": 0 } + ], + "commands": [ + { + "name": "AddSceneResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ViewSceneResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveSceneResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveAllScenesResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "StoreSceneResponse", + "code": 4, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetSceneMembershipResponse", + "code": 6, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } ] }, { @@ -570,7 +570,6 @@ "define": "ON_OFF_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "cluster revision", @@ -602,7 +601,8 @@ "maxInterval": 65344, "reportableChange": 0 } - ] + ], + "commands": [] }, { "name": "Level Control", @@ -1659,6 +1659,23 @@ "define": "BARRIER_CONTROL_CLUSTER", "side": "client", "enabled": 0, + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], "commands": [ { "name": "BarrierControlGoToPercent", @@ -1676,23 +1693,6 @@ "incoming": 1, "outgoing": 1 } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0001", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } ] }, { @@ -3019,6 +3019,16 @@ "define": "IDENTIFY_CLUSTER", "side": "server", "enabled": 1, + "commands": [ + { + "name": "IdentifyQueryResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], "attributes": [ { "name": "cluster revision", @@ -3050,16 +3060,6 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [ - { - "name": "IdentifyQueryResponse", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - } ] }, { @@ -3218,6 +3218,23 @@ "define": "SCENES_CLUSTER", "side": "client", "enabled": 0, + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], "commands": [ { "name": "AddScene", @@ -3275,23 +3292,6 @@ "incoming": 1, "outgoing": 1 } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } ] }, { @@ -4051,6 +4051,196 @@ } ] }, + { + "name": "Network Commissioning", + "code": 49, + "mfgCode": null, + "define": "NETWORK_COMMISSIONING_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "ScanNetworks", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "AddWiFiNetwork", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "UpdateWiFiNetwork", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "AddThreadNetwork", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "UpdateThreadNetwork", + "code": 8, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveNetwork", + "code": 10, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "EnableNetwork", + "code": 12, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "DisableNetwork", + "code": 14, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetLastNetworkCommissioningResult", + "code": 16, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Network Commissioning", + "code": 49, + "mfgCode": null, + "define": "NETWORK_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "ScanNetworksResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "AddWiFiNetworkResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "UpdateWiFiNetworkResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "AddThreadNetworkResponse", + "code": 7, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "UpdateThreadNetworkResponse", + "code": 9, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RemoveNetworkResponse", + "code": 11, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "EnableNetworkResponse", + "code": 13, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "DisableNetworkResponse", + "code": 15, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, { "name": "Door Lock", "code": 257, diff --git a/examples/all-clusters-app/all-clusters-common/gen/CHIPClustersObjc.h b/examples/all-clusters-app/all-clusters-common/gen/CHIPClustersObjc.h index f518ac99918a2d..f82aca72db379b 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/CHIPClustersObjc.h +++ b/examples/all-clusters-app/all-clusters-common/gen/CHIPClustersObjc.h @@ -529,6 +529,52 @@ NS_ASSUME_NONNULL_BEGIN @end +/** + * Cluster Network Commissioning + * + */ +@interface CHIPNetworkCommissioning : CHIPCluster + +- (void)addThreadNetwork:(NSData *)operationalDataset + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)addWiFiNetwork:(NSData *)ssid + credentials:(NSData *)credentials + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)disableNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)enableNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)getLastNetworkCommissioningResult:(uint32_t)timeoutMs completionHandler:(ResponseHandler)completionHandler; +- (void)removeNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)scanNetworks:(NSData *)ssid + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)updateThreadNetwork:(NSData *)operationalDataset + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)updateWiFiNetwork:(NSData *)ssid + credentials:(NSData *)credentials + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; + +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler; + +@end + /** * Cluster On/off * diff --git a/examples/all-clusters-app/all-clusters-common/gen/CHIPClustersObjc.mm b/examples/all-clusters-app/all-clusters-common/gen/CHIPClustersObjc.mm index 37031d4e13869f..f364b2e8d1c6e0 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/CHIPClustersObjc.mm +++ b/examples/all-clusters-app/all-clusters-common/gen/CHIPClustersObjc.mm @@ -5399,6 +5399,285 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler @end +@interface CHIPNetworkCommissioning () +@property (readonly) Controller::NetworkCommissioningCluster cppCluster; +@end + +@implementation CHIPNetworkCommissioning + +- (Controller::ClusterBase *)getCluster +{ + return &_cppCluster; +} + +- (void)addThreadNetwork:(NSData *)operationalDataset + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterAddThreadNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterAddThreadNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.AddThreadNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) operationalDataset.bytes, operationalDataset.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)addWiFiNetwork:(NSData *)ssid + credentials:(NSData *)credentials + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterAddWiFiNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterAddWiFiNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.AddWiFiNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), + chip::ByteSpan((const uint8_t *) credentials.bytes, credentials.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)disableNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterDisableNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterDisableNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.DisableNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)enableNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterEnableNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterEnableNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.EnableNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)getLastNetworkCommissioningResult:(uint32_t)timeoutMs completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.GetLastNetworkCommissioningResult(onSuccess->Cancel(), onFailure->Cancel(), timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)removeNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterRemoveNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterRemoveNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.RemoveNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)scanNetworks:(NSData *)ssid + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterScanNetworksResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterScanNetworksResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ScanNetworks( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)updateThreadNetwork:(NSData *)operationalDataset + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterUpdateThreadNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterUpdateThreadNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.UpdateThreadNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) operationalDataset.bytes, operationalDataset.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)updateWiFiNetwork:(NSData *)ssid + credentials:(NSData *)credentials + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterUpdateWiFiNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterUpdateWiFiNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.UpdateWiFiNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), + chip::ByteSpan((const uint8_t *) credentials.bytes, credentials.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +@end + @interface CHIPOnOff () @property (readonly) Controller::OnOffCluster cppCluster; @end diff --git a/examples/all-clusters-app/all-clusters-common/gen/IMClusterCommandHandler.cpp b/examples/all-clusters-app/all-clusters-common/gen/IMClusterCommandHandler.cpp index fd7bc5747c3040..c3a00f32299dcf 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/IMClusterCommandHandler.cpp +++ b/examples/all-clusters-app/all-clusters-common/gen/IMClusterCommandHandler.cpp @@ -2216,6 +2216,335 @@ void DispatchServerCommand(app::Command * command, CommandId commandId, Endpoint } // namespace MediaPlayback +namespace NetworkCommissioning { + +void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv) +{ + { + switch (commandId) + { + case ZCL_ADD_THREAD_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * operationalDataset; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(operationalDataset); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterAddThreadNetworkCallback(const_cast(operationalDataset), breadcrumb, + timeoutMs); + break; + } + case ZCL_ADD_WI_FI_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * ssid; + const uint8_t * credentials; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(ssid); + break; + case 1: + TLVError = dataTlv.GetDataPtr(credentials); + break; + case 2: + TLVError = dataTlv.Get(breadcrumb); + break; + case 3: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterAddWiFiNetworkCallback(const_cast(ssid), + const_cast(credentials), breadcrumb, timeoutMs); + break; + } + case ZCL_DISABLE_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * networkID; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(networkID); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterDisableNetworkCallback(const_cast(networkID), breadcrumb, timeoutMs); + break; + } + case ZCL_ENABLE_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * networkID; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(networkID); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterEnableNetworkCallback(const_cast(networkID), breadcrumb, timeoutMs); + break; + } + case ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterGetLastNetworkCommissioningResultCallback(timeoutMs); + break; + } + case ZCL_REMOVE_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * NetworkID; + uint64_t Breadcrumb; + uint32_t TimeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(NetworkID); + break; + case 1: + TLVError = dataTlv.Get(Breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(TimeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterRemoveNetworkCallback(const_cast(NetworkID), Breadcrumb, TimeoutMs); + break; + } + case ZCL_SCAN_NETWORKS_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * ssid; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(ssid); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterScanNetworksCallback(const_cast(ssid), breadcrumb, timeoutMs); + break; + } + case ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * operationalDataset; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(operationalDataset); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterUpdateThreadNetworkCallback(const_cast(operationalDataset), breadcrumb, + timeoutMs); + break; + } + case ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * ssid; + const uint8_t * credentials; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(ssid); + break; + case 1: + TLVError = dataTlv.GetDataPtr(credentials); + break; + case 2: + TLVError = dataTlv.Get(breadcrumb); + break; + case 3: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterUpdateWiFiNetworkCallback(const_cast(ssid), + const_cast(credentials), breadcrumb, timeoutMs); + break; + } + default: { + // Unrecognized command ID, error status will apply. + // TODO: Encode response for command not found + ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_NETWORK_COMMISSIONING_CLUSTER_ID); + break; + } + } + } +} + +} // namespace NetworkCommissioning + namespace OnOff { void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv) @@ -2538,6 +2867,9 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC case ZCL_MEDIA_PLAYBACK_CLUSTER_ID: clusters::MediaPlayback::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; + case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID: + clusters::NetworkCommissioning::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; case ZCL_ON_OFF_CLUSTER_ID: clusters::OnOff::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; diff --git a/examples/all-clusters-app/all-clusters-common/gen/attribute-id.h b/examples/all-clusters-app/all-clusters-common/gen/attribute-id.h index 8c8757f826ca7f..72a0198e2f97be 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/attribute-id.h +++ b/examples/all-clusters-app/all-clusters-common/gen/attribute-id.h @@ -391,6 +391,12 @@ #define ZCL_FABRIC_ID_ATTRIBUTE_ID (0x0000) #define ZCL_BREADCRUMB_ATTRIBUTE_ID (0x0001) +// Attribute ids for cluster: Network Commissioning + +// Client attributes + +// Server attributes + // Attribute ids for cluster: Shade Configuration // Client attributes @@ -4084,12 +4090,6 @@ // Server attributes -// Attribute ids for cluster: Network Commissioning - -// Client attributes - -// Server attributes - // Attribute ids for cluster: Binding // Client attributes diff --git a/examples/all-clusters-app/all-clusters-common/gen/call-command-handler.cpp b/examples/all-clusters-app/all-clusters-common/gen/call-command-handler.cpp index f34585d1e0e626..2cb33409ea2a0f 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/call-command-handler.cpp +++ b/examples/all-clusters-app/all-clusters-common/gen/call-command-handler.cpp @@ -42,6 +42,7 @@ EmberAfStatus emberAfIdentifyClusterServerCommandParse(EmberAfClusterCommand * c EmberAfStatus emberAfLevelControlClusterServerCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfLowPowerClusterServerCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfMediaPlaybackClusterServerCommandParse(EmberAfClusterCommand * cmd); +EmberAfStatus emberAfNetworkCommissioningClusterServerCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfOnOffClusterServerCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfScenesClusterServerCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfTemperatureMeasurementClusterServerCommandParse(EmberAfClusterCommand * cmd); @@ -128,6 +129,9 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd) case ZCL_MEDIA_PLAYBACK_CLUSTER_ID: result = emberAfMediaPlaybackClusterServerCommandParse(cmd); break; + case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID: + result = emberAfNetworkCommissioningClusterServerCommandParse(cmd); + break; case ZCL_ON_OFF_CLUSTER_ID: result = emberAfOnOffClusterServerCommandParse(cmd); break; @@ -1886,6 +1890,265 @@ EmberAfStatus emberAfMediaPlaybackClusterServerCommandParse(EmberAfClusterComman } return status(wasHandled, true, cmd->mfgSpecific); } +EmberAfStatus emberAfNetworkCommissioningClusterServerCommandParse(EmberAfClusterCommand * cmd) +{ + bool wasHandled = false; + + if (!cmd->mfgSpecific) + { + switch (cmd->commandId) + { + case ZCL_ADD_THREAD_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * operationalDataset; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + operationalDataset = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(operationalDataset) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterAddThreadNetworkCallback(operationalDataset, breadcrumb, timeoutMs); + break; + } + case ZCL_ADD_WI_FI_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * ssid; + uint8_t * credentials; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + ssid = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(ssid) + 1u); + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + credentials = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(credentials) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterAddWiFiNetworkCallback(ssid, credentials, breadcrumb, timeoutMs); + break; + } + case ZCL_DISABLE_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * networkID; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + networkID = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(networkID) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterDisableNetworkCallback(networkID, breadcrumb, timeoutMs); + break; + } + case ZCL_ENABLE_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * networkID; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + networkID = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(networkID) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterEnableNetworkCallback(networkID, breadcrumb, timeoutMs); + break; + } + case ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterGetLastNetworkCommissioningResultCallback(timeoutMs); + break; + } + case ZCL_REMOVE_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * NetworkID; + uint64_t Breadcrumb; + uint32_t TimeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + NetworkID = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(NetworkID) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + Breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + TimeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterRemoveNetworkCallback(NetworkID, Breadcrumb, TimeoutMs); + break; + } + case ZCL_SCAN_NETWORKS_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * ssid; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + ssid = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(ssid) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterScanNetworksCallback(ssid, breadcrumb, timeoutMs); + break; + } + case ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * operationalDataset; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + operationalDataset = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(operationalDataset) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterUpdateThreadNetworkCallback(operationalDataset, breadcrumb, timeoutMs); + break; + } + case ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * ssid; + uint8_t * credentials; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + ssid = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(ssid) + 1u); + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + credentials = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(credentials) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterUpdateWiFiNetworkCallback(ssid, credentials, breadcrumb, timeoutMs); + break; + } + default: { + // Unrecognized command ID, error status will apply. + break; + } + } + } + return status(wasHandled, true, cmd->mfgSpecific); +} EmberAfStatus emberAfOnOffClusterServerCommandParse(EmberAfClusterCommand * cmd) { bool wasHandled = false; diff --git a/examples/all-clusters-app/all-clusters-common/gen/callback-stub.cpp b/examples/all-clusters-app/all-clusters-common/gen/callback-stub.cpp index b50c4f2cebc39d..f4108c83fb1273 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/callback-stub.cpp +++ b/examples/all-clusters-app/all-clusters-common/gen/callback-stub.cpp @@ -69,6 +69,9 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) case ZCL_MEDIA_PLAYBACK_CLUSTER_ID: emberAfMediaPlaybackClusterInitCallback(endpoint); break; + case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID: + emberAfNetworkCommissioningClusterInitCallback(endpoint); + break; case ZCL_ON_OFF_CLUSTER_ID: emberAfOnOffClusterInitCallback(endpoint); break; @@ -154,6 +157,11 @@ void __attribute__((weak)) emberAfMediaPlaybackClusterInitCallback(EndpointId en // To prevent warning (void) endpoint; } +void __attribute__((weak)) emberAfNetworkCommissioningClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} void __attribute__((weak)) emberAfOnOffClusterInitCallback(EndpointId endpoint) { // To prevent warning diff --git a/examples/all-clusters-app/all-clusters-common/gen/callback.h b/examples/all-clusters-app/all-clusters-common/gen/callback.h index d58578441f7b5d..1167dd1e5db5b8 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/callback.h +++ b/examples/all-clusters-app/all-clusters-common/gen/callback.h @@ -149,6 +149,14 @@ void emberAfLowPowerClusterInitCallback(chip::EndpointId endpoint); */ void emberAfMediaPlaybackClusterInitCallback(chip::EndpointId endpoint); +/** @brief Network Commissioning Cluster Init + * + * Cluster Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfNetworkCommissioningClusterInitCallback(chip::EndpointId endpoint); + /** @brief On/off Cluster Init * * Cluster Init @@ -1156,6 +1164,77 @@ EmberAfStatus emberAfMediaPlaybackClusterServerPreAttributeChangedCallback(chip: */ void emberAfMediaPlaybackClusterServerTickCallback(chip::EndpointId endpoint); +// +// Network Commissioning Cluster server +// + +/** @brief Network Commissioning Cluster Server Init + * + * Server Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfNetworkCommissioningClusterServerInitCallback(chip::EndpointId endpoint); + +/** @brief Network Commissioning Cluster Server Attribute Changed + * + * Server Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + */ +void emberAfNetworkCommissioningClusterServerAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId); + +/** @brief Network Commissioning Cluster Server Manufacturer Specific Attribute Changed + * + * Server Manufacturer Specific Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + * @param manufacturerCode Manufacturer Code of the attribute that changed + */ +void emberAfNetworkCommissioningClusterServerManufacturerSpecificAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + uint16_t manufacturerCode); + +/** @brief Network Commissioning Cluster Server Message Sent + * + * Server Message Sent + * + * @param type The type of message sent + * @param indexOrDestination The destination or address to which the message was sent + * @param apsFrame The APS frame for the message + * @param msgLen The length of the message + * @param message The message that was sent + * @param status The status of the sent message + */ +void emberAfNetworkCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); + +/** @brief Network Commissioning Cluster Server Pre Attribute Changed + * + * server Pre Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute to be changed + * @param attributeType Attribute type + * @param size Attribute size + * @param value Attribute value + */ +EmberAfStatus emberAfNetworkCommissioningClusterServerPreAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + EmberAfAttributeType attributeType, uint8_t size, + uint8_t * value); + +/** @brief Network Commissioning Cluster Server Tick + * + * server Tick + * + * @param endpoint Endpoint that is being served + */ +void emberAfNetworkCommissioningClusterServerTickCallback(chip::EndpointId endpoint); + // // On/off Cluster server // @@ -1997,6 +2076,91 @@ bool emberAfMediaPlaybackClusterStartOverRequestCallback(); bool emberAfMediaPlaybackClusterStopRequestCallback(); +/** + * @brief Network Commissioning Cluster AddThreadNetwork Command callback + * @param operationalDataset + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterAddThreadNetworkCallback(uint8_t * operationalDataset, uint64_t breadcrumb, + uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster AddWiFiNetwork Command callback + * @param ssid + * @param credentials + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterAddWiFiNetworkCallback(uint8_t * ssid, uint8_t * credentials, uint64_t breadcrumb, + uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster DisableNetwork Command callback + * @param networkID + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterDisableNetworkCallback(uint8_t * networkID, uint64_t breadcrumb, uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster EnableNetwork Command callback + * @param networkID + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterEnableNetworkCallback(uint8_t * networkID, uint64_t breadcrumb, uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster GetLastNetworkCommissioningResult Command callback + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterGetLastNetworkCommissioningResultCallback(uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster RemoveNetwork Command callback + * @param networkID + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterRemoveNetworkCallback(uint8_t * NetworkID, uint64_t Breadcrumb, uint32_t TimeoutMs); + +/** + * @brief Network Commissioning Cluster ScanNetworks Command callback + * @param ssid + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterScanNetworksCallback(uint8_t * ssid, uint64_t breadcrumb, uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster UpdateThreadNetwork Command callback + * @param operationalDataset + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterUpdateThreadNetworkCallback(uint8_t * operationalDataset, uint64_t breadcrumb, + uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster UpdateWiFiNetwork Command callback + * @param ssid + * @param credentials + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterUpdateWiFiNetworkCallback(uint8_t * ssid, uint8_t * credentials, uint64_t breadcrumb, + uint32_t timeoutMs); + /** * @brief On/off Cluster Off Command callback */ diff --git a/examples/all-clusters-app/all-clusters-common/gen/client-command-macro.h b/examples/all-clusters-app/all-clusters-common/gen/client-command-macro.h index f72c96f951dcff..79d1e159594a4a 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/client-command-macro.h +++ b/examples/all-clusters-app/all-clusters-common/gen/client-command-macro.h @@ -1911,6 +1911,225 @@ \ ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); +/** @brief Command description for ScanNetworks + * + * Command: ScanNetworks + * @param ssid OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterScanNetworks(ssid, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SCAN_NETWORKS_COMMAND_ID, "uuu", ssid, breadcrumb, timeoutMs); + +/** @brief Command description for ScanNetworksResponse + * + * Command: ScanNetworksResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + * @param wifiScanResults WiFiInterfaceScanResult [] + * @param wifiScanResultsLen int + * @param threadScanResults ThreadInterfaceScanResult [] + * @param threadScanResultsLen int + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterScanNetworksResponse(errorCode, debugText, wifiScanResults, wifiScanResultsLen, threadScanResults, \ + threadScanResultsLen) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID, "uubb", errorCode, debugText, wifiScanResults, \ + wifiScanResultsLen, threadScanResults, threadScanResultsLen); + +/** @brief Command description for AddWiFiNetwork + * + * Command: AddWiFiNetwork + * @param ssid OCTET_STRING + * @param credentials OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); + +/** @brief Command description for AddWiFiNetworkResponse + * + * Command: AddWiFiNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddWiFiNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for UpdateWiFiNetwork + * + * Command: UpdateWiFiNetwork + * @param ssid OCTET_STRING + * @param credentials OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); + +/** @brief Command description for UpdateWiFiNetworkResponse + * + * Command: UpdateWiFiNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateWiFiNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for AddThreadNetwork + * + * Command: AddThreadNetwork + * @param operationalDataset OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); + +/** @brief Command description for AddThreadNetworkResponse + * + * Command: AddThreadNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddThreadNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for UpdateThreadNetwork + * + * Command: UpdateThreadNetwork + * @param operationalDataset OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); + +/** @brief Command description for UpdateThreadNetworkResponse + * + * Command: UpdateThreadNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateThreadNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for RemoveNetwork + * + * Command: RemoveNetwork + * @param NetworkID OCTET_STRING + * @param Breadcrumb INT64U + * @param TimeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterRemoveNetwork(NetworkID, Breadcrumb, TimeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_NETWORK_COMMAND_ID, "uuu", NetworkID, Breadcrumb, TimeoutMs); + +/** @brief Command description for RemoveNetworkResponse + * + * Command: RemoveNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterRemoveNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for EnableNetwork + * + * Command: EnableNetwork + * @param networkID OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterEnableNetwork(networkID, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ENABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); + +/** @brief Command description for EnableNetworkResponse + * + * Command: EnableNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterEnableNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for DisableNetwork + * + * Command: DisableNetwork + * @param networkID OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterDisableNetwork(networkID, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_DISABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); + +/** @brief Command description for DisableNetworkResponse + * + * Command: DisableNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterDisableNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for GetLastNetworkCommissioningResult + * + * Command: GetLastNetworkCommissioningResult + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterGetLastNetworkCommissioningResult(timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID, "u", timeoutMs); + /** @brief Command description for LockDoor * * Command: LockDoor @@ -5783,225 +6002,6 @@ ZCL_GET_ENDPOINT_LIST_REQUEST_COMMAND_ID, "uuuub", startIndex, total, startIndex, count, \ endpointInformationRecordList, endpointInformationRecordListLen); -/** @brief Command description for ScanNetworks - * - * Command: ScanNetworks - * @param ssid OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterScanNetworks(ssid, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_SCAN_NETWORKS_COMMAND_ID, "uuu", ssid, breadcrumb, timeoutMs); - -/** @brief Command description for ScanNetworksResponse - * - * Command: ScanNetworksResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - * @param wifiScanResults WiFiInterfaceScanResult [] - * @param wifiScanResultsLen int - * @param threadScanResults ThreadInterfaceScanResult [] - * @param threadScanResultsLen int - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterScanNetworksResponse(errorCode, debugText, wifiScanResults, wifiScanResultsLen, threadScanResults, \ - threadScanResultsLen) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID, "uubb", errorCode, debugText, wifiScanResults, \ - wifiScanResultsLen, threadScanResults, threadScanResultsLen); - -/** @brief Command description for AddWiFiNetwork - * - * Command: AddWiFiNetwork - * @param ssid OCTET_STRING - * @param credentials OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); - -/** @brief Command description for AddWiFiNetworkResponse - * - * Command: AddWiFiNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddWiFiNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for UpdateWiFiNetwork - * - * Command: UpdateWiFiNetwork - * @param ssid OCTET_STRING - * @param credentials OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); - -/** @brief Command description for UpdateWiFiNetworkResponse - * - * Command: UpdateWiFiNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateWiFiNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for AddThreadNetwork - * - * Command: AddThreadNetwork - * @param operationalDataset OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); - -/** @brief Command description for AddThreadNetworkResponse - * - * Command: AddThreadNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddThreadNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for UpdateThreadNetwork - * - * Command: UpdateThreadNetwork - * @param operationalDataset OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); - -/** @brief Command description for UpdateThreadNetworkResponse - * - * Command: UpdateThreadNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateThreadNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for RemoveNetwork - * - * Command: RemoveNetwork - * @param NetworkID OCTET_STRING - * @param Breadcrumb INT64U - * @param TimeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterRemoveNetwork(NetworkID, Breadcrumb, TimeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_REMOVE_NETWORK_COMMAND_ID, "uuu", NetworkID, Breadcrumb, TimeoutMs); - -/** @brief Command description for RemoveNetworkResponse - * - * Command: RemoveNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterRemoveNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for EnableNetwork - * - * Command: EnableNetwork - * @param networkID OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterEnableNetwork(networkID, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ENABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); - -/** @brief Command description for EnableNetworkResponse - * - * Command: EnableNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterEnableNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for DisableNetwork - * - * Command: DisableNetwork - * @param networkID OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterDisableNetwork(networkID, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_DISABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); - -/** @brief Command description for DisableNetworkResponse - * - * Command: DisableNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterDisableNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for GetLastNetworkCommissioningResult - * - * Command: GetLastNetworkCommissioningResult - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterGetLastNetworkCommissioningResult(timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID, "u", timeoutMs); - /** @brief Command description for Bind * * Command: Bind diff --git a/examples/all-clusters-app/all-clusters-common/gen/cluster-id.h b/examples/all-clusters-app/all-clusters-common/gen/cluster-id.h index d77da915200ab4..add8f83d188cf8 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/cluster-id.h +++ b/examples/all-clusters-app/all-clusters-common/gen/cluster-id.h @@ -86,6 +86,9 @@ // Definitions for cluster: General Commissioning #define ZCL_GENERAL_COMMISSIONING_CLUSTER_ID (0x0030) +// Definitions for cluster: Network Commissioning +#define ZCL_NETWORK_COMMISSIONING_CLUSTER_ID (0x0031) + // Definitions for cluster: Shade Configuration #define ZCL_SHADE_CONFIG_CLUSTER_ID (0x0100) @@ -341,9 +344,6 @@ // Definitions for cluster: ZLL Commissioning #define ZCL_ZLL_COMMISSIONING_CLUSTER_ID (0x1000) -// Definitions for cluster: Network Commissioning -#define ZCL_NETWORK_COMMISSIONING_CLUSTER_ID (0xAAAA) - // Definitions for cluster: Binding #define ZCL_BINDING_CLUSTER_ID (0xF000) diff --git a/examples/all-clusters-app/all-clusters-common/gen/command-id.h b/examples/all-clusters-app/all-clusters-common/gen/command-id.h index adc2b1c6f32733..864943b5727fcd 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/command-id.h +++ b/examples/all-clusters-app/all-clusters-common/gen/command-id.h @@ -238,6 +238,25 @@ #define ZCL_COMMISSIONING_COMPLETE_COMMAND_ID (0x06) #define ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID (0x07) +// Commands for cluster: Network Commissioning +#define ZCL_SCAN_NETWORKS_COMMAND_ID (0x00) +#define ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID (0x01) +#define ZCL_ADD_WI_FI_NETWORK_COMMAND_ID (0x02) +#define ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x03) +#define ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID (0x04) +#define ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x05) +#define ZCL_ADD_THREAD_NETWORK_COMMAND_ID (0x06) +#define ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x07) +#define ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID (0x08) +#define ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x09) +#define ZCL_REMOVE_NETWORK_COMMAND_ID (0x0A) +#define ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID (0x0B) +#define ZCL_ENABLE_NETWORK_COMMAND_ID (0x0C) +#define ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID (0x0D) +#define ZCL_DISABLE_NETWORK_COMMAND_ID (0x0E) +#define ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID (0x0F) +#define ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID (0x10) + // Commands for cluster: Door Lock #define ZCL_LOCK_DOOR_COMMAND_ID (0x00) #define ZCL_LOCK_DOOR_RESPONSE_COMMAND_ID (0x00) @@ -700,25 +719,6 @@ #define ZCL_GET_ENDPOINT_LIST_REQUEST_COMMAND_ID (0x42) #define ZCL_GET_ENDPOINT_LIST_RESPONSE_COMMAND_ID (0x42) -// Commands for cluster: Network Commissioning -#define ZCL_SCAN_NETWORKS_COMMAND_ID (0x00) -#define ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID (0x01) -#define ZCL_ADD_WI_FI_NETWORK_COMMAND_ID (0x02) -#define ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x03) -#define ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID (0x04) -#define ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x05) -#define ZCL_ADD_THREAD_NETWORK_COMMAND_ID (0x06) -#define ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x07) -#define ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID (0x08) -#define ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x09) -#define ZCL_REMOVE_NETWORK_COMMAND_ID (0x0A) -#define ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID (0x0B) -#define ZCL_ENABLE_NETWORK_COMMAND_ID (0x0C) -#define ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID (0x0D) -#define ZCL_DISABLE_NETWORK_COMMAND_ID (0x0E) -#define ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID (0x0F) -#define ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID (0x10) - // Commands for cluster: Binding #define ZCL_BIND_COMMAND_ID (0x00) #define ZCL_UNBIND_COMMAND_ID (0x01) diff --git a/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h b/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h index 202d80c95d0291..1a35ec1c5b8d4d 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h +++ b/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h @@ -205,7 +205,7 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 126 +#define GENERATED_ATTRIBUTE_COUNT 127 #define GENERATED_ATTRIBUTES \ { \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 2 } }, /* Identify (server): cluster revision */ \ @@ -259,14 +259,15 @@ }, /* Basic (server): SoftwareVersion */ \ { \ 0x000A, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(180) } \ - }, /* Basic (server): SoftwareVersionString */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* General Commissioning (server): cluster revision */ \ + }, /* Basic (server): SoftwareVersionString */ \ { \ 0x0000, ZAP_TYPE(OCTET_STRING), 8, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(244) } \ }, /* General Commissioning (server): FabricId */ \ { \ 0x0001, ZAP_TYPE(INT64U), 8, ZAP_ATTRIBUTE_MASK(WRITABLE), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(252) } \ }, /* General Commissioning (server): Breadcrumb */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* General Commissioning (server): cluster revision */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Network Commissioning (server): cluster revision */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 3 } }, /* Door Lock (server): cluster revision */ \ { 0x0000, ZAP_TYPE(ENUM8), 1, 0, { (uint8_t *) 2 } }, /* Door Lock (server): lock state */ \ { 0x0001, ZAP_TYPE(ENUM8), 1, 0, { (uint8_t *) 0 } }, /* Door Lock (server): lock type */ \ @@ -370,23 +371,23 @@ }, /* IAS Zone (server): IAS CIE address */ \ { 0x0011, ZAP_TYPE(INT8U), 1, 0, { (uint8_t *) 0xff } }, /* IAS Zone (server): Zone ID */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Low Power (server): cluster revision */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Application Basic (server): cluster revision */ \ { \ 0x0000, ZAP_TYPE(OCTET_STRING), 32, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(522) } \ }, /* Application Basic (server): vendor name */ \ { 0x0001, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0 } }, /* Application Basic (server): vendor id */ \ { \ 0x0002, ZAP_TYPE(OCTET_STRING), 32, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(554) } \ - }, /* Application Basic (server): application name */ \ - { 0x0003, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0 } }, /* Application Basic (server): product id */ \ + }, /* Application Basic (server): application name */ \ + { 0x0003, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0 } }, /* Application Basic (server): product id */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Application Basic (server): cluster revision */ \ { \ 0x0005, ZAP_TYPE(OCTET_STRING), 32, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(586) } \ }, /* Application Basic (server): application id */ \ { 0x0006, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0 } }, /* Application Basic (server): catalog vendor id */ \ { 0x0007, ZAP_TYPE(ENUM8), 1, 0, { (uint8_t *) 0x01 } }, /* Application Basic (server): application satus */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Binding (server): cluster revision */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Media Playback (server): cluster revision */ \ { 0x0000, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0 } }, /* Media Playback (server): current state */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Media Playback (server): cluster revision */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Content Launch (server): cluster revision */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 2 } }, /* On/off (server): cluster revision */ \ { 0x0000, ZAP_TYPE(BOOLEAN), 1, 0, { (uint8_t *) 0x00 } }, /* On/off (server): on/off */ \ @@ -462,7 +463,7 @@ }; #define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask -#define GENERATED_CLUSTER_COUNT 19 +#define GENERATED_CLUSTER_COUNT 20 #define GENERATED_CLUSTERS \ { \ { 0x0003, \ @@ -501,54 +502,57 @@ { \ 0x0030, ZAP_ATTRIBUTE_INDEX(26), 3, 18, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: General Commissioning (server) */ \ + { \ + 0x0031, ZAP_ATTRIBUTE_INDEX(29), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 1, Cluster: Network Commissioning (server) */ \ { 0x0101, \ - ZAP_ATTRIBUTE_INDEX(29), \ + ZAP_ATTRIBUTE_INDEX(30), \ 4, \ 5, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(ATTRIBUTE_CHANGED_FUNCTION), \ chipFuncArrayDoorLockServer }, /* Endpoint: 1, Cluster: Door Lock (server) */ \ { \ - 0x0103, ZAP_ATTRIBUTE_INDEX(33), 5, 7, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0103, ZAP_ATTRIBUTE_INDEX(34), 5, 7, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Barrier Control (server) */ \ { 0x0300, \ - ZAP_ATTRIBUTE_INDEX(38), \ + ZAP_ATTRIBUTE_INDEX(39), \ 51, \ 336, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayColorControlServer }, /* Endpoint: 1, Cluster: Color Control (server) */ \ { \ - 0x0402, ZAP_ATTRIBUTE_INDEX(89), 4, 8, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0402, ZAP_ATTRIBUTE_INDEX(90), 4, 8, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Temperature Measurement (server) */ \ { 0x0500, \ - ZAP_ATTRIBUTE_INDEX(93), \ + ZAP_ATTRIBUTE_INDEX(94), \ 6, \ 16, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION) | ZAP_CLUSTER_MASK(PRE_ATTRIBUTE_CHANGED_FUNCTION) | \ ZAP_CLUSTER_MASK(MESSAGE_SENT_FUNCTION), \ chipFuncArrayIasZoneServer }, /* Endpoint: 1, Cluster: IAS Zone (server) */ \ { \ - 0x0508, ZAP_ATTRIBUTE_INDEX(99), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0508, ZAP_ATTRIBUTE_INDEX(100), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Low Power (server) */ \ { \ - 0x050D, ZAP_ATTRIBUTE_INDEX(100), 8, 105, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x050D, ZAP_ATTRIBUTE_INDEX(101), 8, 105, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Application Basic (server) */ \ { \ - 0xF000, ZAP_ATTRIBUTE_INDEX(108), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0xF000, ZAP_ATTRIBUTE_INDEX(109), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Binding (server) */ \ { \ - 0xF001, ZAP_ATTRIBUTE_INDEX(109), 2, 4, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0xF001, ZAP_ATTRIBUTE_INDEX(110), 2, 4, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Media Playback (server) */ \ { \ - 0xF002, ZAP_ATTRIBUTE_INDEX(111), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0xF002, ZAP_ATTRIBUTE_INDEX(112), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Content Launch (server) */ \ { 0x0006, \ - ZAP_ATTRIBUTE_INDEX(112), \ + ZAP_ATTRIBUTE_INDEX(113), \ 2, \ 3, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayOnOffServer }, /* Endpoint: 2, Cluster: On/off (server) */ \ { \ - 0x0028, ZAP_ATTRIBUTE_INDEX(114), 12, 254, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0028, ZAP_ATTRIBUTE_INDEX(115), 12, 254, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 2, Cluster: Basic (server) */ \ } @@ -557,7 +561,7 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 17, 780 }, { ZAP_CLUSTER_INDEX(17), 2, 257 }, \ + { ZAP_CLUSTER_INDEX(0), 18, 782 }, { ZAP_CLUSTER_INDEX(18), 2, 257 }, \ } // Largest attribute size is needed for various buffers @@ -567,7 +571,7 @@ #define ATTRIBUTE_SINGLETONS_SIZE (508) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (1037) +#define ATTRIBUTE_MAX_SIZE (1039) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (2) @@ -611,7 +615,7 @@ // Array of EmberAfCommandMetadata structs. #define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask -#define EMBER_AF_GENERATED_COMMAND_COUNT (115) +#define EMBER_AF_GENERATED_COMMAND_COUNT (132) #define GENERATED_COMMANDS \ { \ { 0x0003, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Identify (server): Identify */ \ @@ -668,6 +672,24 @@ { 0x0030, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* General Commissioning (server): CommissioningComplete */ \ { 0x0030, 0x07, \ ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* General Commissioning (server): CommissioningCompleteResponse */ \ + { 0x0031, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): ScanNetworks */ \ + { 0x0031, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): ScanNetworksResponse */ \ + { 0x0031, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): AddWiFiNetwork */ \ + { 0x0031, 0x03, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): AddWiFiNetworkResponse */ \ + { 0x0031, 0x04, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): UpdateWiFiNetwork */ \ + { 0x0031, 0x05, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): UpdateWiFiNetworkResponse */ \ + { 0x0031, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): AddThreadNetwork */ \ + { 0x0031, 0x07, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): AddThreadNetworkResponse */ \ + { 0x0031, 0x08, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): UpdateThreadNetwork */ \ + { 0x0031, 0x09, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): UpdateThreadNetworkResponse */ \ + { 0x0031, 0x0A, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): RemoveNetwork */ \ + { 0x0031, 0x0B, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): RemoveNetworkResponse */ \ + { 0x0031, 0x0C, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): EnableNetwork */ \ + { 0x0031, 0x0D, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): EnableNetworkResponse */ \ + { 0x0031, 0x0E, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): DisableNetwork */ \ + { 0x0031, 0x0F, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): DisableNetworkResponse */ \ + { 0x0031, 0x10, \ + ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): GetLastNetworkCommissioningResult */ \ { 0x0101, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Door Lock (server): LockDoor */ \ { 0x0101, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Door Lock (server): LockDoorResponse */ \ { 0x0101, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Door Lock (server): UnlockDoor */ \ diff --git a/examples/all-clusters-app/all-clusters-common/gen/gen_config.h b/examples/all-clusters-app/all-clusters-common/gen/gen_config.h index 6a1a6e9bd77ed4..09a3a3eaeea112 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/gen_config.h +++ b/examples/all-clusters-app/all-clusters-common/gen/gen_config.h @@ -43,6 +43,7 @@ #define EMBER_AF_LEVEL_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_LOW_POWER_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_MEDIA_PLAYBACK_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_NETWORK_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_ON_OFF_CLUSTER_SERVER_ENDPOINT_COUNT (2) #define EMBER_AF_SCENES_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_TEMP_MEASUREMENT_CLUSTER_SERVER_ENDPOINT_COUNT (1) @@ -129,6 +130,11 @@ #define EMBER_AF_PLUGIN_MEDIA_PLAYBACK_SERVER #define EMBER_AF_PLUGIN_MEDIA_PLAYBACK +// Use this macro to check if the server side of the Network Commissioning cluster is included +#define ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING_SERVER +#define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING + // Use this macro to check if the server side of the On/off cluster is included #define ZCL_USING_ON_OFF_CLUSTER_SERVER #define EMBER_AF_PLUGIN_ON_OFF_SERVER diff --git a/examples/all-clusters-app/all-clusters-common/gen/print-cluster.h b/examples/all-clusters-app/all-clusters-common/gen/print-cluster.h index bd08d38a581506..8c737e93fea79c 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/print-cluster.h +++ b/examples/all-clusters-app/all-clusters-common/gen/print-cluster.h @@ -156,6 +156,12 @@ #define CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER #endif +#if defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER { ZCL_NETWORK_COMMISSIONING_CLUSTER_ID, 49, "Network Commissioning" }, +#else +#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER +#endif + #if defined(ZCL_USING_SHADE_CONFIG_CLUSTER_SERVER) || defined(ZCL_USING_SHADE_CONFIG_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER { ZCL_SHADE_CONFIG_CLUSTER_ID, 256, "Shade Configuration" }, #else @@ -734,12 +740,6 @@ #define CHIP_PRINTCLUSTER_ZLL_COMMISSIONING_CLUSTER #endif -#if defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_CLIENT) -#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER { ZCL_NETWORK_COMMISSIONING_CLUSTER_ID, 43690, "Network Commissioning" }, -#else -#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER -#endif - #if defined(ZCL_USING_BINDING_CLUSTER_SERVER) || defined(ZCL_USING_BINDING_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_BINDING_CLUSTER { ZCL_BINDING_CLUSTER_ID, 61440, "Binding" }, #else @@ -812,6 +812,7 @@ CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER \ CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER \ + CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DOOR_LOCK_CLUSTER \ CHIP_PRINTCLUSTER_WINDOW_COVERING_CLUSTER \ @@ -897,7 +898,6 @@ CHIP_PRINTCLUSTER_ELECTRICAL_MEASUREMENT_CLUSTER \ CHIP_PRINTCLUSTER_DIAGNOSTICS_CLUSTER \ CHIP_PRINTCLUSTER_ZLL_COMMISSIONING_CLUSTER \ - CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_BINDING_CLUSTER \ CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER \ CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER \ diff --git a/examples/all-clusters-app/esp32/main/component.mk b/examples/all-clusters-app/esp32/main/component.mk index df7b728547883e..2c99a7611b8008 100644 --- a/examples/all-clusters-app/esp32/main/component.mk +++ b/examples/all-clusters-app/esp32/main/component.mk @@ -37,6 +37,7 @@ COMPONENT_SRCDIRS := ../third_party/connectedhomeip/src/app/clusters/content-launch-server \ ../third_party/connectedhomeip/src/app/clusters/low-power-server \ ../third_party/connectedhomeip/src/app/clusters/media-playback-server \ + ../third_party/connectedhomeip/src/app/clusters/network-commissioning \ ../third_party/connectedhomeip/src/app/clusters/temperature-measurement-server \ ../third_party/connectedhomeip/src/app/clusters/scenes \ ../third_party/connectedhomeip/src/app/clusters/basic \ diff --git a/examples/bridge-app/bridge-common/BUILD.gn b/examples/bridge-app/bridge-common/BUILD.gn index 2e7f42667d8945..90d5518ea01665 100644 --- a/examples/bridge-app/bridge-common/BUILD.gn +++ b/examples/bridge-app/bridge-common/BUILD.gn @@ -26,6 +26,8 @@ source_set("bridge-common") { "${chip_root}/src/app/clusters/basic/basic.cpp", "${chip_root}/src/app/clusters/bindings/bindings.cpp", "${chip_root}/src/app/clusters/level-control/level-control.cpp", + "${chip_root}/src/app/clusters/network-commissioning/network-commissioning-ember.cpp", + "${chip_root}/src/app/clusters/network-commissioning/network-commissioning.cpp", "${chip_root}/src/app/clusters/on-off-server/on-off.cpp", "${chip_root}/src/app/reporting/reporting-default-configuration.cpp", "${chip_root}/src/app/reporting/reporting.cpp", diff --git a/examples/bridge-app/bridge-common/bridge-app.zap b/examples/bridge-app/bridge-common/bridge-app.zap index 405d0aa5359b17..c788f1ec966d01 100644 --- a/examples/bridge-app/bridge-common/bridge-app.zap +++ b/examples/bridge-app/bridge-common/bridge-app.zap @@ -1,5 +1,5 @@ { - "writeTime": "Tue Feb 16 2021 18:07:17 GMT+0100 (Central European Standard Time)", + "writeTime": "Fri Mar 12 2021 15:17:33 GMT+0800 (China Standard Time)", "featureLevel": 11, "creator": "zap", "keyValuePairs": [ @@ -38,254 +38,30 @@ "deviceTypeProfileId": 260, "clusters": [ { - "name": "Basic", - "code": 40, + "name": "Identify", + "code": 3, "mfgCode": null, - "define": "BASIC_CLUSTER", + "define": "IDENTIFY_CLUSTER", "side": "client", "enabled": 0, - "commands": [], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Basic", - "code": 40, - "mfgCode": null, - "define": "BASIC_CLUSTER", - "side": "server", - "enabled": 1, "commands": [ { - "name": "StartUp", + "name": "Identify", "code": 0, "mfgCode": null, - "source": "server", + "source": "client", "incoming": 1, - "outgoing": 1 + "outgoing": 0 }, { - "name": "ShutDown", + "name": "IdentifyQuery", "code": 1, "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "Leave", - "code": 2, - "mfgCode": null, - "source": "server", + "source": "client", "incoming": 1, - "outgoing": 1 + "outgoing": 0 } ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "InteractionModelVersion", - "code": 0, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "VendorName", - "code": 1, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "VendorID", - "code": 2, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ProductName", - "code": 3, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ProductID", - "code": 4, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "UserLabel", - "code": 5, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "Location", - "code": 6, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "HardwareVersion", - "code": 7, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "HardwareVersionString", - "code": 8, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "SoftwareVersion", - "code": 9, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "SoftwareVersionString", - "code": 10, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Identify", - "code": 3, - "mfgCode": null, - "define": "IDENTIFY_CLUSTER", - "side": "client", - "enabled": 0, "attributes": [ { "name": "cluster revision", @@ -302,24 +78,6 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [ - { - "name": "Identify", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "IdentifyQuery", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - } ] }, { @@ -329,16 +87,6 @@ "define": "IDENTIFY_CLUSTER", "side": "server", "enabled": 0, - "commands": [ - { - "name": "IdentifyQueryResponse", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - } - ], "attributes": [ { "name": "cluster revision", @@ -370,6 +118,16 @@ "maxInterval": 65344, "reportableChange": 0 } + ], + "commands": [ + { + "name": "IdentifyQueryResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } ] }, { @@ -379,6 +137,23 @@ "define": "GROUPS_CLUSTER", "side": "client", "enabled": 0, + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], "commands": [ { "name": "AddGroup", @@ -428,23 +203,6 @@ "incoming": 1, "outgoing": 0 } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } ] }, { @@ -602,15 +360,65 @@ "maxInterval": 65344, "reportableChange": 0 } - ] - }, - { - "name": "Scenes", - "code": 5, - "mfgCode": null, - "define": "SCENES_CLUSTER", - "side": "server", - "enabled": 0, + ] + }, + { + "name": "Scenes", + "code": 5, + "mfgCode": null, + "define": "SCENES_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [ + { + "name": "AddSceneResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "ViewSceneResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RemoveSceneResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RemoveAllScenesResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "StoreSceneResponse", + "code": 4, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "GetSceneMembershipResponse", + "code": 6, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } + ], "attributes": [ { "name": "cluster revision", @@ -702,56 +510,6 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [ - { - "name": "AddSceneResponse", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "ViewSceneResponse", - "code": 1, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "RemoveSceneResponse", - "code": 2, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "RemoveAllScenesResponse", - "code": 3, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "StoreSceneResponse", - "code": 4, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "GetSceneMembershipResponse", - "code": 6, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - } ] }, { @@ -977,15 +735,7 @@ "reportableChange": 0 } ] - } - ] - }, - { - "name": "Anonymous Endpoint Type", - "deviceTypeName": "LO-colordimmablelight", - "deviceTypeCode": 258, - "deviceTypeProfileId": 260, - "clusters": [ + }, { "name": "Basic", "code": 40, @@ -1227,7 +977,15 @@ "reportableChange": 0 } ] - }, + } + ] + }, + { + "name": "Anonymous Endpoint Type", + "deviceTypeName": "LO-colordimmablelight", + "deviceTypeCode": 258, + "deviceTypeProfileId": 260, + "clusters": [ { "name": "Identify", "code": 3, @@ -1235,23 +993,6 @@ "define": "IDENTIFY_CLUSTER", "side": "client", "enabled": 0, - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "2", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ], "commands": [ { "name": "Identify", @@ -1277,6 +1018,23 @@ "incoming": 1, "outgoing": 0 } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "2", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } ] }, { @@ -2238,148 +1996,19 @@ "defaultValue": "4", "reportable": 0, "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Color Control", - "code": 768, - "mfgCode": null, - "define": "COLOR_CONTROL_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [ - { - "name": "MoveToHue", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "MoveHue", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "StepHue", - "code": 2, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "MoveToSaturation", - "code": 3, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "MoveSaturation", - "code": 4, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "StepSaturation", - "code": 5, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "MoveToHueAndSaturation", - "code": 6, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "MoveToColor", - "code": 7, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "MoveColor", - "code": 8, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "StepColor", - "code": 9, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "EnhancedMoveToHue", - "code": 64, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "EnhancedMoveHue", - "code": 65, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "EnhancedStepHue", - "code": 66, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "EnhancedMoveToHueAndSaturation", - "code": 67, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "ColorLoopSet", - "code": 68, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "StopMoveStep", - "code": 71, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 + "maxInterval": 65344, + "reportableChange": 0 } - ], + ] + }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -2388,7 +2017,7 @@ "side": "client", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, "defaultValue": "3", "reportable": 0, @@ -2399,13 +2028,38 @@ ] }, { - "name": "Color Control", - "code": 768, + "name": "Basic", + "code": 40, "mfgCode": null, - "define": "COLOR_CONTROL_CLUSTER", + "define": "BASIC_CLUSTER", "side": "server", - "enabled": 0, - "commands": [], + "enabled": 1, + "commands": [ + { + "name": "StartUp", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ShutDown", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "Leave", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], "attributes": [ { "name": "cluster revision", @@ -2414,7 +2068,7 @@ "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, "defaultValue": "3", "reportable": 0, @@ -2423,118 +2077,118 @@ "reportableChange": 0 }, { - "name": "current hue", + "name": "InteractionModelVersion", "code": 0, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "current saturation", + "name": "VendorName", "code": 1, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "remaining time", + "name": "VendorID", "code": 2, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "current x", + "name": "ProductName", "code": 3, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "0x616B", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "current y", + "name": "ProductID", "code": 4, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "0x607D", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "color temperature", - "code": 7, + "name": "UserLabel", + "code": 5, "mfgCode": null, "side": "server", - "included": 0, + "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "0x00FA", - "reportable": 1, + "defaultValue": "", + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "color mode", - "code": 8, + "name": "Location", + "code": 6, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "0x01", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "color control options", - "code": 15, + "name": "HardwareVersion", + "code": 7, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, "defaultValue": "0x00", "reportable": 0, @@ -2543,13 +2197,13 @@ "reportableChange": 0 }, { - "name": "number of primaries", - "code": 16, + "name": "HardwareVersionString", + "code": 8, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, "defaultValue": "", "reportable": 0, @@ -2558,203 +2212,339 @@ "reportableChange": 0 }, { - "name": "primary 1 x", - "code": 17, + "name": "SoftwareVersion", + "code": 9, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersionString", + "code": 10, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, "bounded": 0, "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 + } + ] + }, + { + "name": "Color Control", + "code": 768, + "mfgCode": null, + "define": "COLOR_CONTROL_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "MoveToHue", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveHue", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StepHue", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveToSaturation", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveSaturation", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StepSaturation", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveToHueAndSaturation", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveToColor", + "code": 7, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveColor", + "code": 8, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StepColor", + "code": 9, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "EnhancedMoveToHue", + "code": 64, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "EnhancedMoveHue", + "code": 65, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "EnhancedStepHue", + "code": 66, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "EnhancedMoveToHueAndSaturation", + "code": 67, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 }, { - "name": "primary 1 y", - "code": 18, + "name": "ColorLoopSet", + "code": 68, "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 + "source": "client", + "incoming": 1, + "outgoing": 0 }, { - "name": "primary 1 intensity", - "code": 19, + "name": "StopMoveStep", + "code": 71, "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ { - "name": "primary 2 x", - "code": 21, + "name": "cluster revision", + "code": 65533, "mfgCode": null, - "side": "server", + "side": "client", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "3", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - }, + } + ] + }, + { + "name": "Color Control", + "code": 768, + "mfgCode": null, + "define": "COLOR_CONTROL_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [], + "attributes": [ { - "name": "primary 2 y", - "code": 22, + "name": "cluster revision", + "code": 65533, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "3", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "primary 2 intensity", - "code": 23, + "name": "current hue", + "code": 0, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0x00", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "primary 3 x", - "code": 25, + "name": "current saturation", + "code": 1, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0x00", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "primary 3 y", - "code": 26, + "name": "remaining time", + "code": 2, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0x0000", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "primary 3 intensity", - "code": 27, + "name": "current x", + "code": 3, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0x616B", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "primary 4 x", - "code": 32, + "name": "current y", + "code": 4, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0x607D", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "primary 4 y", - "code": 33, + "name": "color temperature", + "code": 7, "mfgCode": null, "side": "server", - "included": 1, + "included": 0, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", - "reportable": 0, + "defaultValue": "0x00FA", + "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "primary 4 intensity", - "code": 34, + "name": "color mode", + "code": 8, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0x01", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "primary 5 x", - "code": 36, + "name": "color control options", + "code": 15, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0x00", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "primary 5 y", - "code": 37, + "name": "number of primaries", + "code": 16, "mfgCode": null, "side": "server", "included": 1, @@ -2768,8 +2558,8 @@ "reportableChange": 0 }, { - "name": "primary 5 intensity", - "code": 38, + "name": "primary 1 x", + "code": 17, "mfgCode": null, "side": "server", "included": 1, @@ -2783,8 +2573,8 @@ "reportableChange": 0 }, { - "name": "primary 6 x", - "code": 40, + "name": "primary 1 y", + "code": 18, "mfgCode": null, "side": "server", "included": 1, @@ -2798,8 +2588,8 @@ "reportableChange": 0 }, { - "name": "primary 6 y", - "code": 41, + "name": "primary 1 intensity", + "code": 19, "mfgCode": null, "side": "server", "included": 1, @@ -2813,8 +2603,8 @@ "reportableChange": 0 }, { - "name": "primary 6 intensity", - "code": 42, + "name": "primary 2 x", + "code": 21, "mfgCode": null, "side": "server", "included": 1, @@ -2828,8 +2618,8 @@ "reportableChange": 0 }, { - "name": "couple color temp to level min-mireds", - "code": 16397, + "name": "primary 2 y", + "code": 22, "mfgCode": null, "side": "server", "included": 1, @@ -2843,8 +2633,8 @@ "reportableChange": 0 }, { - "name": "start up color temperature mireds", - "code": 16400, + "name": "primary 2 intensity", + "code": 23, "mfgCode": null, "side": "server", "included": 1, @@ -2858,180 +2648,128 @@ "reportableChange": 0 }, { - "name": "enhanced current hue", - "code": 16384, + "name": "primary 3 x", + "code": 25, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "enhanced color mode", - "code": 16385, + "name": "primary 3 y", + "code": 26, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x01", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "color loop active", - "code": 16386, + "name": "primary 3 intensity", + "code": 27, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "color loop direction", - "code": 16387, + "name": "primary 4 x", + "code": 32, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "color loop time", - "code": 16388, + "name": "primary 4 y", + "code": 33, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0019", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "color loop start enhanced hue", - "code": 16389, + "name": "primary 4 intensity", + "code": 34, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x2300", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "color loop stored enhanced hue", - "code": 16390, + "name": "primary 5 x", + "code": 36, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "color capabilities", - "code": 16394, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Occupancy Sensing", - "code": 1030, - "mfgCode": null, - "define": "OCCUPANCY_SENSING_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "2", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Occupancy Sensing", - "code": 1030, - "mfgCode": null, - "define": "OCCUPANCY_SENSING_CLUSTER", - "side": "server", - "enabled": 0, - "commands": [], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, + "name": "primary 5 y", + "code": 37, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "2", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "occupancy", - "code": 0, + "name": "primary 5 intensity", + "code": 38, "mfgCode": null, "side": "server", "included": 1, @@ -3039,14 +2777,14 @@ "singleton": 0, "bounded": 0, "defaultValue": "", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "occupancy sensor type", - "code": 1, + "name": "primary 6 x", + "code": 40, "mfgCode": null, "side": "server", "included": 1, @@ -3060,8 +2798,8 @@ "reportableChange": 0 }, { - "name": "occupancy sensor type bitmap", - "code": 2, + "name": "primary 6 y", + "code": 41, "mfgCode": null, "side": "server", "included": 1, @@ -3073,288 +2811,90 @@ "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - } - ] - }, - { - "name": "ZLL Commissioning", - "code": 4096, - "mfgCode": null, - "define": "ZLL_COMMISSIONING_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [ - { - "name": "ScanRequest", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "DeviceInformationRequest", - "code": 2, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "IdentifyRequest", - "code": 6, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "ResetToFactoryNewRequest", - "code": 7, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "NetworkStartRequest", - "code": 16, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "NetworkJoinRouterRequest", - "code": 18, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "NetworkJoinEndDeviceRequest", - "code": 20, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "NetworkUpdateRequest", - "code": 22, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "GetGroupIdentifiersRequest", - "code": 65, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 }, { - "name": "GetEndpointListRequest", - "code": 66, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, + "name": "primary 6 intensity", + "code": 42, "mfgCode": null, - "side": "client", + "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0001", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - } - ] - }, - { - "name": "ZLL Commissioning", - "code": 4096, - "mfgCode": null, - "define": "ZLL_COMMISSIONING_CLUSTER", - "side": "server", - "enabled": 0, - "commands": [ - { - "name": "ScanResponse", - "code": 1, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "DeviceInformationResponse", - "code": 3, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "NetworkStartResponse", - "code": 17, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "NetworkJoinRouterResponse", - "code": 19, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "NetworkJoinEndDeviceResponse", - "code": 21, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "EndpointInformation", - "code": 64, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "GetGroupIdentifiersResponse", - "code": 65, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 }, { - "name": "GetEndpointListResponse", - "code": 66, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, + "name": "couple color temp to level min-mireds", + "code": 16397, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0001", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - } - ] - } - ] - }, - { - "name": "Anonymous Endpoint Type", - "deviceTypeName": "LO-colortemperaturelight", - "deviceTypeCode": 268, - "deviceTypeProfileId": 260, - "clusters": [ - { - "name": "Basic", - "code": 0, - "mfgCode": null, - "define": "BASIC_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [], - "attributes": [ + }, { - "name": "cluster revision", - "code": 65533, + "name": "start up color temperature mireds", + "code": 16400, "mfgCode": null, - "side": "client", + "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - } - ] - }, - { - "name": "Basic", - "code": 0, - "mfgCode": null, - "define": "BASIC_CLUSTER", - "side": "server", - "enabled": 0, - "commands": [], - "attributes": [ + }, { - "name": "cluster revision", - "code": 65533, + "name": "enhanced current hue", + "code": 16384, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "0x0000", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "ZCL version", - "code": 0, + "name": "enhanced color mode", + "code": 16385, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "0x08", + "defaultValue": "0x01", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "application version", - "code": 1, + "name": "color loop active", + "code": 16386, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, "defaultValue": "0x00", "reportable": 0, @@ -3363,13 +2903,13 @@ "reportableChange": 0 }, { - "name": "stack version", - "code": 2, + "name": "color loop direction", + "code": 16387, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, "defaultValue": "0x00", "reportable": 0, @@ -3378,118 +2918,140 @@ "reportableChange": 0 }, { - "name": "hardware version", - "code": 3, + "name": "color loop time", + "code": 16388, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "0x0019", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "manufacturer name", - "code": 4, + "name": "color loop start enhanced hue", + "code": 16389, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0x2300", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "model identifier", - "code": 5, + "name": "color loop stored enhanced hue", + "code": 16390, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0x0000", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "date code", - "code": 6, + "name": "color capabilities", + "code": 16394, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0x0000", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - }, + } + ] + }, + { + "name": "Occupancy Sensing", + "code": 1030, + "mfgCode": null, + "define": "OCCUPANCY_SENSING_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], + "attributes": [ { - "name": "power source", - "code": 7, + "name": "cluster revision", + "code": 65533, "mfgCode": null, - "side": "server", + "side": "client", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "2", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - }, + } + ] + }, + { + "name": "Occupancy Sensing", + "code": 1030, + "mfgCode": null, + "define": "OCCUPANCY_SENSING_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [], + "attributes": [ { - "name": "generic device class", - "code": 8, + "name": "cluster revision", + "code": 65533, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "0xFF", + "defaultValue": "2", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "generic device type", - "code": 9, + "name": "occupancy", + "code": 0, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "0xFF", - "reportable": 0, + "defaultValue": "", + "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "product code", - "code": 10, + "name": "occupancy sensor type", + "code": 1, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 0, @@ -3498,30 +3060,122 @@ "reportableChange": 0 }, { - "name": "product url", - "code": 11, + "name": "occupancy sensor type bitmap", + "code": 2, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 + } + ] + }, + { + "name": "ZLL Commissioning", + "code": 4096, + "mfgCode": null, + "define": "ZLL_COMMISSIONING_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "ScanRequest", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 }, { - "name": "sw build id", - "code": 16384, + "name": "DeviceInformationRequest", + "code": 2, "mfgCode": null, - "side": "server", + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "IdentifyRequest", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "ResetToFactoryNewRequest", + "code": 7, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "NetworkStartRequest", + "code": 16, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "NetworkJoinRouterRequest", + "code": 18, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "NetworkJoinEndDeviceRequest", + "code": 20, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "NetworkUpdateRequest", + "code": 22, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "GetGroupIdentifiersRequest", + "code": 65, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "GetEndpointListRequest", + "code": 66, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0x0001", "reportable": 0, "minInterval": 0, "maxInterval": 65344, @@ -3530,29 +3184,111 @@ ] }, { - "name": "Identify", - "code": 3, + "name": "ZLL Commissioning", + "code": 4096, "mfgCode": null, - "define": "IDENTIFY_CLUSTER", - "side": "client", + "define": "ZLL_COMMISSIONING_CLUSTER", + "side": "server", "enabled": 0, + "commands": [ + { + "name": "ScanResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "DeviceInformationResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "NetworkStartResponse", + "code": 17, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "NetworkJoinRouterResponse", + "code": 19, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "NetworkJoinEndDeviceResponse", + "code": 21, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "EndpointInformation", + "code": 64, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "GetGroupIdentifiersResponse", + "code": 65, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "GetEndpointListResponse", + "code": 66, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } + ], "attributes": [ { "name": "cluster revision", "code": 65533, "mfgCode": null, - "side": "client", + "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "2", + "defaultValue": "0x0001", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 } - ], + ] + } + ] + }, + { + "name": "Anonymous Endpoint Type", + "deviceTypeName": "LO-colortemperaturelight", + "deviceTypeCode": 268, + "deviceTypeProfileId": 260, + "clusters": [ + { + "name": "Identify", + "code": 3, + "mfgCode": null, + "define": "IDENTIFY_CLUSTER", + "side": "client", + "enabled": 0, "commands": [ { "name": "Identify", @@ -3578,6 +3314,23 @@ "incoming": 1, "outgoing": 0 } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "2", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } ] }, { @@ -3587,16 +3340,6 @@ "define": "IDENTIFY_CLUSTER", "side": "server", "enabled": 0, - "commands": [ - { - "name": "IdentifyQueryResponse", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - } - ], "attributes": [ { "name": "cluster revision", @@ -3628,6 +3371,16 @@ "maxInterval": 65344, "reportableChange": 0 } + ], + "commands": [ + { + "name": "IdentifyQueryResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } ] }, { @@ -3637,6 +3390,23 @@ "define": "GROUPS_CLUSTER", "side": "client", "enabled": 0, + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], "commands": [ { "name": "AddGroup", @@ -3686,23 +3456,6 @@ "incoming": 1, "outgoing": 0 } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } ] }, { @@ -5451,22 +5204,12 @@ "deviceTypeProfileId": 43981, "clusters": [ { - "name": "Basic", - "code": 0, + "name": "Network Commissioning", + "code": 49, "mfgCode": null, - "define": "BASIC_CLUSTER", + "define": "NETWORK_COMMISSIONING_CLUSTER", "side": "client", "enabled": 0, - "commands": [ - { - "name": "ResetToFactoryDefaults", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - } - ], "attributes": [ { "name": "cluster revision", @@ -5475,65 +5218,174 @@ "side": "client", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "0x0001", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 } + ], + "commands": [ + { + "name": "ScanNetworks", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "AddWiFiNetwork", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "UpdateWiFiNetwork", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "AddThreadNetwork", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "UpdateThreadNetwork", + "code": 8, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveNetwork", + "code": 10, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "EnableNetwork", + "code": 12, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "DisableNetwork", + "code": 14, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetLastNetworkCommissioningResult", + "code": 16, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } ] }, { - "name": "Basic", - "code": 0, + "name": "Network Commissioning", + "code": 49, "mfgCode": null, - "define": "BASIC_CLUSTER", + "define": "NETWORK_COMMISSIONING_CLUSTER", "side": "server", "enabled": 1, - "commands": [], - "attributes": [ + "commands": [ { - "name": "cluster revision", - "code": 65533, + "name": "ScanNetworksResponse", + "code": 1, "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 + "source": "server", + "incoming": 1, + "outgoing": 1 }, { - "name": "ZCL version", - "code": 0, + "name": "AddWiFiNetworkResponse", + "code": 3, "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "0x08", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 + "source": "server", + "incoming": 0, + "outgoing": 1 }, { - "name": "power source", + "name": "UpdateWiFiNetworkResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "AddThreadNetworkResponse", "code": 7, "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "UpdateThreadNetworkResponse", + "code": 9, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RemoveNetworkResponse", + "code": 11, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "EnableNetworkResponse", + "code": 13, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "DisableNetworkResponse", + "code": 15, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "0x0001", "reportable": 0, "minInterval": 0, "maxInterval": 65344, @@ -5574,4 +5426,4 @@ "networkId": 0 } ] -} +} \ No newline at end of file diff --git a/examples/bridge-app/bridge-common/gen/CHIPClustersObjc.h b/examples/bridge-app/bridge-common/gen/CHIPClustersObjc.h index e41b61bf809bd4..b066625c88ce44 100644 --- a/examples/bridge-app/bridge-common/gen/CHIPClustersObjc.h +++ b/examples/bridge-app/bridge-common/gen/CHIPClustersObjc.h @@ -113,6 +113,52 @@ NS_ASSUME_NONNULL_BEGIN @end +/** + * Cluster Network Commissioning + * + */ +@interface CHIPNetworkCommissioning : CHIPCluster + +- (void)addThreadNetwork:(NSData *)operationalDataset + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)addWiFiNetwork:(NSData *)ssid + credentials:(NSData *)credentials + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)disableNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)enableNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)getLastNetworkCommissioningResult:(uint32_t)timeoutMs completionHandler:(ResponseHandler)completionHandler; +- (void)removeNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)scanNetworks:(NSData *)ssid + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)updateThreadNetwork:(NSData *)operationalDataset + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)updateWiFiNetwork:(NSData *)ssid + credentials:(NSData *)credentials + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; + +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler; + +@end + /** * Cluster On/off * diff --git a/examples/bridge-app/bridge-common/gen/CHIPClustersObjc.mm b/examples/bridge-app/bridge-common/gen/CHIPClustersObjc.mm index 11a59ed6077dca..8b04fffcbe65c8 100644 --- a/examples/bridge-app/bridge-common/gen/CHIPClustersObjc.mm +++ b/examples/bridge-app/bridge-common/gen/CHIPClustersObjc.mm @@ -1144,6 +1144,285 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler @end +@interface CHIPNetworkCommissioning () +@property (readonly) Controller::NetworkCommissioningCluster cppCluster; +@end + +@implementation CHIPNetworkCommissioning + +- (Controller::ClusterBase *)getCluster +{ + return &_cppCluster; +} + +- (void)addThreadNetwork:(NSData *)operationalDataset + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterAddThreadNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterAddThreadNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.AddThreadNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) operationalDataset.bytes, operationalDataset.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)addWiFiNetwork:(NSData *)ssid + credentials:(NSData *)credentials + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterAddWiFiNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterAddWiFiNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.AddWiFiNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), + chip::ByteSpan((const uint8_t *) credentials.bytes, credentials.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)disableNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterDisableNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterDisableNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.DisableNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)enableNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterEnableNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterEnableNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.EnableNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)getLastNetworkCommissioningResult:(uint32_t)timeoutMs completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.GetLastNetworkCommissioningResult(onSuccess->Cancel(), onFailure->Cancel(), timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)removeNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterRemoveNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterRemoveNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.RemoveNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)scanNetworks:(NSData *)ssid + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterScanNetworksResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterScanNetworksResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ScanNetworks( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)updateThreadNetwork:(NSData *)operationalDataset + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterUpdateThreadNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterUpdateThreadNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.UpdateThreadNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) operationalDataset.bytes, operationalDataset.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)updateWiFiNetwork:(NSData *)ssid + credentials:(NSData *)credentials + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterUpdateWiFiNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterUpdateWiFiNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.UpdateWiFiNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), + chip::ByteSpan((const uint8_t *) credentials.bytes, credentials.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +@end + @interface CHIPOnOff () @property (readonly) Controller::OnOffCluster cppCluster; @end diff --git a/examples/bridge-app/bridge-common/gen/IMClusterCommandHandler.cpp b/examples/bridge-app/bridge-common/gen/IMClusterCommandHandler.cpp index e5c62ee3c4c594..38e77a95d8b37c 100644 --- a/examples/bridge-app/bridge-common/gen/IMClusterCommandHandler.cpp +++ b/examples/bridge-app/bridge-common/gen/IMClusterCommandHandler.cpp @@ -305,6 +305,335 @@ void DispatchServerCommand(app::Command * command, CommandId commandId, Endpoint } // namespace LevelControl +namespace NetworkCommissioning { + +void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv) +{ + { + switch (commandId) + { + case ZCL_ADD_THREAD_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * operationalDataset; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(operationalDataset); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterAddThreadNetworkCallback(const_cast(operationalDataset), breadcrumb, + timeoutMs); + break; + } + case ZCL_ADD_WI_FI_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * ssid; + const uint8_t * credentials; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(ssid); + break; + case 1: + TLVError = dataTlv.GetDataPtr(credentials); + break; + case 2: + TLVError = dataTlv.Get(breadcrumb); + break; + case 3: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterAddWiFiNetworkCallback(const_cast(ssid), + const_cast(credentials), breadcrumb, timeoutMs); + break; + } + case ZCL_DISABLE_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * networkID; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(networkID); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterDisableNetworkCallback(const_cast(networkID), breadcrumb, timeoutMs); + break; + } + case ZCL_ENABLE_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * networkID; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(networkID); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterEnableNetworkCallback(const_cast(networkID), breadcrumb, timeoutMs); + break; + } + case ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterGetLastNetworkCommissioningResultCallback(timeoutMs); + break; + } + case ZCL_REMOVE_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * NetworkID; + uint64_t Breadcrumb; + uint32_t TimeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(NetworkID); + break; + case 1: + TLVError = dataTlv.Get(Breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(TimeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterRemoveNetworkCallback(const_cast(NetworkID), Breadcrumb, TimeoutMs); + break; + } + case ZCL_SCAN_NETWORKS_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * ssid; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(ssid); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterScanNetworksCallback(const_cast(ssid), breadcrumb, timeoutMs); + break; + } + case ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * operationalDataset; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(operationalDataset); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterUpdateThreadNetworkCallback(const_cast(operationalDataset), breadcrumb, + timeoutMs); + break; + } + case ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * ssid; + const uint8_t * credentials; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(ssid); + break; + case 1: + TLVError = dataTlv.GetDataPtr(credentials); + break; + case 2: + TLVError = dataTlv.Get(breadcrumb); + break; + case 3: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterUpdateWiFiNetworkCallback(const_cast(ssid), + const_cast(credentials), breadcrumb, timeoutMs); + break; + } + default: { + // Unrecognized command ID, error status will apply. + // TODO: Encode response for command not found + ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_NETWORK_COMMISSIONING_CLUSTER_ID); + break; + } + } + } +} + +} // namespace NetworkCommissioning + namespace OnOff { void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv) @@ -352,6 +681,9 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC case ZCL_LEVEL_CONTROL_CLUSTER_ID: clusters::LevelControl::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; + case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID: + clusters::NetworkCommissioning::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; case ZCL_ON_OFF_CLUSTER_ID: clusters::OnOff::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; diff --git a/examples/bridge-app/bridge-common/gen/attribute-id.h b/examples/bridge-app/bridge-common/gen/attribute-id.h index 8c8757f826ca7f..72a0198e2f97be 100644 --- a/examples/bridge-app/bridge-common/gen/attribute-id.h +++ b/examples/bridge-app/bridge-common/gen/attribute-id.h @@ -391,6 +391,12 @@ #define ZCL_FABRIC_ID_ATTRIBUTE_ID (0x0000) #define ZCL_BREADCRUMB_ATTRIBUTE_ID (0x0001) +// Attribute ids for cluster: Network Commissioning + +// Client attributes + +// Server attributes + // Attribute ids for cluster: Shade Configuration // Client attributes @@ -4084,12 +4090,6 @@ // Server attributes -// Attribute ids for cluster: Network Commissioning - -// Client attributes - -// Server attributes - // Attribute ids for cluster: Binding // Client attributes diff --git a/examples/bridge-app/bridge-common/gen/call-command-handler.cpp b/examples/bridge-app/bridge-common/gen/call-command-handler.cpp index 8a3306f30630b6..4680bec8290107 100644 --- a/examples/bridge-app/bridge-common/gen/call-command-handler.cpp +++ b/examples/bridge-app/bridge-common/gen/call-command-handler.cpp @@ -30,6 +30,7 @@ using namespace chip; EmberAfStatus emberAfBasicClusterServerCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfLevelControlClusterServerCommandParse(EmberAfClusterCommand * cmd); +EmberAfStatus emberAfNetworkCommissioningClusterServerCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfOnOffClusterServerCommandParse(EmberAfClusterCommand * cmd); static EmberAfStatus status(bool wasHandled, bool clusterExists, bool mfgSpecific) @@ -78,6 +79,9 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd) case ZCL_LEVEL_CONTROL_CLUSTER_ID: result = emberAfLevelControlClusterServerCommandParse(cmd); break; + case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID: + result = emberAfNetworkCommissioningClusterServerCommandParse(cmd); + break; case ZCL_ON_OFF_CLUSTER_ID: result = emberAfOnOffClusterServerCommandParse(cmd); break; @@ -307,6 +311,265 @@ EmberAfStatus emberAfLevelControlClusterServerCommandParse(EmberAfClusterCommand } return status(wasHandled, true, cmd->mfgSpecific); } +EmberAfStatus emberAfNetworkCommissioningClusterServerCommandParse(EmberAfClusterCommand * cmd) +{ + bool wasHandled = false; + + if (!cmd->mfgSpecific) + { + switch (cmd->commandId) + { + case ZCL_ADD_THREAD_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * operationalDataset; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + operationalDataset = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(operationalDataset) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterAddThreadNetworkCallback(operationalDataset, breadcrumb, timeoutMs); + break; + } + case ZCL_ADD_WI_FI_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * ssid; + uint8_t * credentials; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + ssid = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(ssid) + 1u); + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + credentials = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(credentials) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterAddWiFiNetworkCallback(ssid, credentials, breadcrumb, timeoutMs); + break; + } + case ZCL_DISABLE_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * networkID; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + networkID = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(networkID) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterDisableNetworkCallback(networkID, breadcrumb, timeoutMs); + break; + } + case ZCL_ENABLE_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * networkID; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + networkID = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(networkID) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterEnableNetworkCallback(networkID, breadcrumb, timeoutMs); + break; + } + case ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterGetLastNetworkCommissioningResultCallback(timeoutMs); + break; + } + case ZCL_REMOVE_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * NetworkID; + uint64_t Breadcrumb; + uint32_t TimeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + NetworkID = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(NetworkID) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + Breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + TimeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterRemoveNetworkCallback(NetworkID, Breadcrumb, TimeoutMs); + break; + } + case ZCL_SCAN_NETWORKS_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * ssid; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + ssid = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(ssid) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterScanNetworksCallback(ssid, breadcrumb, timeoutMs); + break; + } + case ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * operationalDataset; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + operationalDataset = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(operationalDataset) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterUpdateThreadNetworkCallback(operationalDataset, breadcrumb, timeoutMs); + break; + } + case ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * ssid; + uint8_t * credentials; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + ssid = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(ssid) + 1u); + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + credentials = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(credentials) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterUpdateWiFiNetworkCallback(ssid, credentials, breadcrumb, timeoutMs); + break; + } + default: { + // Unrecognized command ID, error status will apply. + break; + } + } + } + return status(wasHandled, true, cmd->mfgSpecific); +} EmberAfStatus emberAfOnOffClusterServerCommandParse(EmberAfClusterCommand * cmd) { bool wasHandled = false; diff --git a/examples/bridge-app/bridge-common/gen/callback-stub.cpp b/examples/bridge-app/bridge-common/gen/callback-stub.cpp index eed6cef3a28321..f40262e72697b7 100644 --- a/examples/bridge-app/bridge-common/gen/callback-stub.cpp +++ b/examples/bridge-app/bridge-common/gen/callback-stub.cpp @@ -33,6 +33,9 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) case ZCL_LEVEL_CONTROL_CLUSTER_ID: emberAfLevelControlClusterInitCallback(endpoint); break; + case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID: + emberAfNetworkCommissioningClusterInitCallback(endpoint); + break; case ZCL_ON_OFF_CLUSTER_ID: emberAfOnOffClusterInitCallback(endpoint); break; @@ -52,6 +55,11 @@ void __attribute__((weak)) emberAfLevelControlClusterInitCallback(EndpointId end // To prevent warning (void) endpoint; } +void __attribute__((weak)) emberAfNetworkCommissioningClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} void __attribute__((weak)) emberAfOnOffClusterInitCallback(EndpointId endpoint) { // To prevent warning diff --git a/examples/bridge-app/bridge-common/gen/callback.h b/examples/bridge-app/bridge-common/gen/callback.h index 26742ee65aad54..dfac28f4dfce71 100644 --- a/examples/bridge-app/bridge-common/gen/callback.h +++ b/examples/bridge-app/bridge-common/gen/callback.h @@ -53,6 +53,14 @@ void emberAfBasicClusterInitCallback(chip::EndpointId endpoint); */ void emberAfLevelControlClusterInitCallback(chip::EndpointId endpoint); +/** @brief Network Commissioning Cluster Init + * + * Cluster Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfNetworkCommissioningClusterInitCallback(chip::EndpointId endpoint); + /** @brief On/off Cluster Init * * Cluster Init @@ -201,6 +209,77 @@ EmberAfStatus emberAfLevelControlClusterServerPreAttributeChangedCallback(chip:: */ void emberAfLevelControlClusterServerTickCallback(chip::EndpointId endpoint); +// +// Network Commissioning Cluster server +// + +/** @brief Network Commissioning Cluster Server Init + * + * Server Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfNetworkCommissioningClusterServerInitCallback(chip::EndpointId endpoint); + +/** @brief Network Commissioning Cluster Server Attribute Changed + * + * Server Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + */ +void emberAfNetworkCommissioningClusterServerAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId); + +/** @brief Network Commissioning Cluster Server Manufacturer Specific Attribute Changed + * + * Server Manufacturer Specific Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + * @param manufacturerCode Manufacturer Code of the attribute that changed + */ +void emberAfNetworkCommissioningClusterServerManufacturerSpecificAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + uint16_t manufacturerCode); + +/** @brief Network Commissioning Cluster Server Message Sent + * + * Server Message Sent + * + * @param type The type of message sent + * @param indexOrDestination The destination or address to which the message was sent + * @param apsFrame The APS frame for the message + * @param msgLen The length of the message + * @param message The message that was sent + * @param status The status of the sent message + */ +void emberAfNetworkCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); + +/** @brief Network Commissioning Cluster Server Pre Attribute Changed + * + * server Pre Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute to be changed + * @param attributeType Attribute type + * @param size Attribute size + * @param value Attribute value + */ +EmberAfStatus emberAfNetworkCommissioningClusterServerPreAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + EmberAfAttributeType attributeType, uint8_t size, + uint8_t * value); + +/** @brief Network Commissioning Cluster Server Tick + * + * server Tick + * + * @param endpoint Endpoint that is being served + */ +void emberAfNetworkCommissioningClusterServerTickCallback(chip::EndpointId endpoint); + // // On/off Cluster server // @@ -343,6 +422,91 @@ bool emberAfLevelControlClusterStopCallback(uint8_t optionMask, uint8_t optionOv bool emberAfLevelControlClusterStopWithOnOffCallback(); +/** + * @brief Network Commissioning Cluster AddThreadNetwork Command callback + * @param operationalDataset + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterAddThreadNetworkCallback(uint8_t * operationalDataset, uint64_t breadcrumb, + uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster AddWiFiNetwork Command callback + * @param ssid + * @param credentials + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterAddWiFiNetworkCallback(uint8_t * ssid, uint8_t * credentials, uint64_t breadcrumb, + uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster DisableNetwork Command callback + * @param networkID + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterDisableNetworkCallback(uint8_t * networkID, uint64_t breadcrumb, uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster EnableNetwork Command callback + * @param networkID + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterEnableNetworkCallback(uint8_t * networkID, uint64_t breadcrumb, uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster GetLastNetworkCommissioningResult Command callback + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterGetLastNetworkCommissioningResultCallback(uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster RemoveNetwork Command callback + * @param networkID + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterRemoveNetworkCallback(uint8_t * NetworkID, uint64_t Breadcrumb, uint32_t TimeoutMs); + +/** + * @brief Network Commissioning Cluster ScanNetworks Command callback + * @param ssid + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterScanNetworksCallback(uint8_t * ssid, uint64_t breadcrumb, uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster UpdateThreadNetwork Command callback + * @param operationalDataset + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterUpdateThreadNetworkCallback(uint8_t * operationalDataset, uint64_t breadcrumb, + uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster UpdateWiFiNetwork Command callback + * @param ssid + * @param credentials + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterUpdateWiFiNetworkCallback(uint8_t * ssid, uint8_t * credentials, uint64_t breadcrumb, + uint32_t timeoutMs); + /** * @brief On/off Cluster Off Command callback */ diff --git a/examples/bridge-app/bridge-common/gen/client-command-macro.h b/examples/bridge-app/bridge-common/gen/client-command-macro.h index f72c96f951dcff..79d1e159594a4a 100644 --- a/examples/bridge-app/bridge-common/gen/client-command-macro.h +++ b/examples/bridge-app/bridge-common/gen/client-command-macro.h @@ -1911,6 +1911,225 @@ \ ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); +/** @brief Command description for ScanNetworks + * + * Command: ScanNetworks + * @param ssid OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterScanNetworks(ssid, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SCAN_NETWORKS_COMMAND_ID, "uuu", ssid, breadcrumb, timeoutMs); + +/** @brief Command description for ScanNetworksResponse + * + * Command: ScanNetworksResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + * @param wifiScanResults WiFiInterfaceScanResult [] + * @param wifiScanResultsLen int + * @param threadScanResults ThreadInterfaceScanResult [] + * @param threadScanResultsLen int + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterScanNetworksResponse(errorCode, debugText, wifiScanResults, wifiScanResultsLen, threadScanResults, \ + threadScanResultsLen) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID, "uubb", errorCode, debugText, wifiScanResults, \ + wifiScanResultsLen, threadScanResults, threadScanResultsLen); + +/** @brief Command description for AddWiFiNetwork + * + * Command: AddWiFiNetwork + * @param ssid OCTET_STRING + * @param credentials OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); + +/** @brief Command description for AddWiFiNetworkResponse + * + * Command: AddWiFiNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddWiFiNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for UpdateWiFiNetwork + * + * Command: UpdateWiFiNetwork + * @param ssid OCTET_STRING + * @param credentials OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); + +/** @brief Command description for UpdateWiFiNetworkResponse + * + * Command: UpdateWiFiNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateWiFiNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for AddThreadNetwork + * + * Command: AddThreadNetwork + * @param operationalDataset OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); + +/** @brief Command description for AddThreadNetworkResponse + * + * Command: AddThreadNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddThreadNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for UpdateThreadNetwork + * + * Command: UpdateThreadNetwork + * @param operationalDataset OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); + +/** @brief Command description for UpdateThreadNetworkResponse + * + * Command: UpdateThreadNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateThreadNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for RemoveNetwork + * + * Command: RemoveNetwork + * @param NetworkID OCTET_STRING + * @param Breadcrumb INT64U + * @param TimeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterRemoveNetwork(NetworkID, Breadcrumb, TimeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_NETWORK_COMMAND_ID, "uuu", NetworkID, Breadcrumb, TimeoutMs); + +/** @brief Command description for RemoveNetworkResponse + * + * Command: RemoveNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterRemoveNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for EnableNetwork + * + * Command: EnableNetwork + * @param networkID OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterEnableNetwork(networkID, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ENABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); + +/** @brief Command description for EnableNetworkResponse + * + * Command: EnableNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterEnableNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for DisableNetwork + * + * Command: DisableNetwork + * @param networkID OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterDisableNetwork(networkID, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_DISABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); + +/** @brief Command description for DisableNetworkResponse + * + * Command: DisableNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterDisableNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for GetLastNetworkCommissioningResult + * + * Command: GetLastNetworkCommissioningResult + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterGetLastNetworkCommissioningResult(timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID, "u", timeoutMs); + /** @brief Command description for LockDoor * * Command: LockDoor @@ -5783,225 +6002,6 @@ ZCL_GET_ENDPOINT_LIST_REQUEST_COMMAND_ID, "uuuub", startIndex, total, startIndex, count, \ endpointInformationRecordList, endpointInformationRecordListLen); -/** @brief Command description for ScanNetworks - * - * Command: ScanNetworks - * @param ssid OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterScanNetworks(ssid, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_SCAN_NETWORKS_COMMAND_ID, "uuu", ssid, breadcrumb, timeoutMs); - -/** @brief Command description for ScanNetworksResponse - * - * Command: ScanNetworksResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - * @param wifiScanResults WiFiInterfaceScanResult [] - * @param wifiScanResultsLen int - * @param threadScanResults ThreadInterfaceScanResult [] - * @param threadScanResultsLen int - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterScanNetworksResponse(errorCode, debugText, wifiScanResults, wifiScanResultsLen, threadScanResults, \ - threadScanResultsLen) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID, "uubb", errorCode, debugText, wifiScanResults, \ - wifiScanResultsLen, threadScanResults, threadScanResultsLen); - -/** @brief Command description for AddWiFiNetwork - * - * Command: AddWiFiNetwork - * @param ssid OCTET_STRING - * @param credentials OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); - -/** @brief Command description for AddWiFiNetworkResponse - * - * Command: AddWiFiNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddWiFiNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for UpdateWiFiNetwork - * - * Command: UpdateWiFiNetwork - * @param ssid OCTET_STRING - * @param credentials OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); - -/** @brief Command description for UpdateWiFiNetworkResponse - * - * Command: UpdateWiFiNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateWiFiNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for AddThreadNetwork - * - * Command: AddThreadNetwork - * @param operationalDataset OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); - -/** @brief Command description for AddThreadNetworkResponse - * - * Command: AddThreadNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddThreadNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for UpdateThreadNetwork - * - * Command: UpdateThreadNetwork - * @param operationalDataset OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); - -/** @brief Command description for UpdateThreadNetworkResponse - * - * Command: UpdateThreadNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateThreadNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for RemoveNetwork - * - * Command: RemoveNetwork - * @param NetworkID OCTET_STRING - * @param Breadcrumb INT64U - * @param TimeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterRemoveNetwork(NetworkID, Breadcrumb, TimeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_REMOVE_NETWORK_COMMAND_ID, "uuu", NetworkID, Breadcrumb, TimeoutMs); - -/** @brief Command description for RemoveNetworkResponse - * - * Command: RemoveNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterRemoveNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for EnableNetwork - * - * Command: EnableNetwork - * @param networkID OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterEnableNetwork(networkID, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ENABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); - -/** @brief Command description for EnableNetworkResponse - * - * Command: EnableNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterEnableNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for DisableNetwork - * - * Command: DisableNetwork - * @param networkID OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterDisableNetwork(networkID, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_DISABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); - -/** @brief Command description for DisableNetworkResponse - * - * Command: DisableNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterDisableNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for GetLastNetworkCommissioningResult - * - * Command: GetLastNetworkCommissioningResult - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterGetLastNetworkCommissioningResult(timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID, "u", timeoutMs); - /** @brief Command description for Bind * * Command: Bind diff --git a/examples/bridge-app/bridge-common/gen/cluster-id.h b/examples/bridge-app/bridge-common/gen/cluster-id.h index d77da915200ab4..add8f83d188cf8 100644 --- a/examples/bridge-app/bridge-common/gen/cluster-id.h +++ b/examples/bridge-app/bridge-common/gen/cluster-id.h @@ -86,6 +86,9 @@ // Definitions for cluster: General Commissioning #define ZCL_GENERAL_COMMISSIONING_CLUSTER_ID (0x0030) +// Definitions for cluster: Network Commissioning +#define ZCL_NETWORK_COMMISSIONING_CLUSTER_ID (0x0031) + // Definitions for cluster: Shade Configuration #define ZCL_SHADE_CONFIG_CLUSTER_ID (0x0100) @@ -341,9 +344,6 @@ // Definitions for cluster: ZLL Commissioning #define ZCL_ZLL_COMMISSIONING_CLUSTER_ID (0x1000) -// Definitions for cluster: Network Commissioning -#define ZCL_NETWORK_COMMISSIONING_CLUSTER_ID (0xAAAA) - // Definitions for cluster: Binding #define ZCL_BINDING_CLUSTER_ID (0xF000) diff --git a/examples/bridge-app/bridge-common/gen/command-id.h b/examples/bridge-app/bridge-common/gen/command-id.h index adc2b1c6f32733..864943b5727fcd 100644 --- a/examples/bridge-app/bridge-common/gen/command-id.h +++ b/examples/bridge-app/bridge-common/gen/command-id.h @@ -238,6 +238,25 @@ #define ZCL_COMMISSIONING_COMPLETE_COMMAND_ID (0x06) #define ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID (0x07) +// Commands for cluster: Network Commissioning +#define ZCL_SCAN_NETWORKS_COMMAND_ID (0x00) +#define ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID (0x01) +#define ZCL_ADD_WI_FI_NETWORK_COMMAND_ID (0x02) +#define ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x03) +#define ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID (0x04) +#define ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x05) +#define ZCL_ADD_THREAD_NETWORK_COMMAND_ID (0x06) +#define ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x07) +#define ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID (0x08) +#define ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x09) +#define ZCL_REMOVE_NETWORK_COMMAND_ID (0x0A) +#define ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID (0x0B) +#define ZCL_ENABLE_NETWORK_COMMAND_ID (0x0C) +#define ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID (0x0D) +#define ZCL_DISABLE_NETWORK_COMMAND_ID (0x0E) +#define ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID (0x0F) +#define ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID (0x10) + // Commands for cluster: Door Lock #define ZCL_LOCK_DOOR_COMMAND_ID (0x00) #define ZCL_LOCK_DOOR_RESPONSE_COMMAND_ID (0x00) @@ -700,25 +719,6 @@ #define ZCL_GET_ENDPOINT_LIST_REQUEST_COMMAND_ID (0x42) #define ZCL_GET_ENDPOINT_LIST_RESPONSE_COMMAND_ID (0x42) -// Commands for cluster: Network Commissioning -#define ZCL_SCAN_NETWORKS_COMMAND_ID (0x00) -#define ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID (0x01) -#define ZCL_ADD_WI_FI_NETWORK_COMMAND_ID (0x02) -#define ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x03) -#define ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID (0x04) -#define ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x05) -#define ZCL_ADD_THREAD_NETWORK_COMMAND_ID (0x06) -#define ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x07) -#define ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID (0x08) -#define ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x09) -#define ZCL_REMOVE_NETWORK_COMMAND_ID (0x0A) -#define ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID (0x0B) -#define ZCL_ENABLE_NETWORK_COMMAND_ID (0x0C) -#define ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID (0x0D) -#define ZCL_DISABLE_NETWORK_COMMAND_ID (0x0E) -#define ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID (0x0F) -#define ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID (0x10) - // Commands for cluster: Binding #define ZCL_BIND_COMMAND_ID (0x00) #define ZCL_UNBIND_COMMAND_ID (0x01) diff --git a/examples/bridge-app/bridge-common/gen/endpoint_config.h b/examples/bridge-app/bridge-common/gen/endpoint_config.h index b1860457e022a7..b797a636a44e30 100644 --- a/examples/bridge-app/bridge-common/gen/endpoint_config.h +++ b/examples/bridge-app/bridge-common/gen/endpoint_config.h @@ -145,10 +145,11 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 50 +#define GENERATED_ATTRIBUTE_COUNT 51 #define GENERATED_ATTRIBUTES \ { \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 2 } }, /* On/off (server): cluster revision */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Network Commissioning (server): cluster revision */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 2 } }, /* On/off (server): cluster revision */ \ { 0x0000, ZAP_TYPE(BOOLEAN), 1, 0, { (uint8_t *) 0x00 } }, /* On/off (server): on/off */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 3 } }, /* Level Control (server): cluster revision */ \ { 0x0000, ZAP_TYPE(INT8U), 1, 0, { (uint8_t *) 0x00 } }, /* Level Control (server): current level */ \ @@ -277,49 +278,50 @@ }; #define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask -#define GENERATED_CLUSTER_COUNT 8 +#define GENERATED_CLUSTER_COUNT 9 #define GENERATED_CLUSTERS \ { \ { \ - 0x0006, \ - ZAP_ATTRIBUTE_INDEX(0), \ - 2, \ - 3, \ - ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ - chipFuncArrayOnOffServer \ - }, /* Endpoint: 1, Cluster: On/off (server) */ \ + 0x0031, ZAP_ATTRIBUTE_INDEX(0), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 0, Cluster: Network Commissioning (server) */ \ + { 0x0006, \ + ZAP_ATTRIBUTE_INDEX(1), \ + 2, \ + 3, \ + ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ + chipFuncArrayOnOffServer }, /* Endpoint: 1, Cluster: On/off (server) */ \ { 0x0008, \ - ZAP_ATTRIBUTE_INDEX(2), \ + ZAP_ATTRIBUTE_INDEX(3), \ 2, \ 3, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayLevelControlServer }, /* Endpoint: 1, Cluster: Level Control (server) */ \ { \ - 0x0028, ZAP_ATTRIBUTE_INDEX(4), 12, 254, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0028, ZAP_ATTRIBUTE_INDEX(5), 12, 254, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Basic (server) */ \ { 0x0006, \ - ZAP_ATTRIBUTE_INDEX(16), \ + ZAP_ATTRIBUTE_INDEX(17), \ 6, \ 9, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayOnOffServer }, /* Endpoint: 2, Cluster: On/off (server) */ \ { 0x0008, \ - ZAP_ATTRIBUTE_INDEX(22), \ + ZAP_ATTRIBUTE_INDEX(23), \ 5, \ 7, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayLevelControlServer }, /* Endpoint: 2, Cluster: Level Control (server) */ \ { \ - 0x0028, ZAP_ATTRIBUTE_INDEX(27), 12, 254, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0028, ZAP_ATTRIBUTE_INDEX(28), 12, 254, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 2, Cluster: Basic (server) */ \ { 0x0006, \ - ZAP_ATTRIBUTE_INDEX(39), \ + ZAP_ATTRIBUTE_INDEX(40), \ 6, \ 9, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayOnOffServer }, /* Endpoint: 3, Cluster: On/off (server) */ \ { 0x0008, \ - ZAP_ATTRIBUTE_INDEX(45), \ + ZAP_ATTRIBUTE_INDEX(46), \ 5, \ 7, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ @@ -331,8 +333,8 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 0, 0 }, { ZAP_CLUSTER_INDEX(0), 3, 260 }, { ZAP_CLUSTER_INDEX(3), 3, 270 }, \ - { ZAP_CLUSTER_INDEX(6), 2, 16 }, \ + { ZAP_CLUSTER_INDEX(0), 1, 2 }, { ZAP_CLUSTER_INDEX(1), 3, 260 }, { ZAP_CLUSTER_INDEX(4), 3, 270 }, \ + { ZAP_CLUSTER_INDEX(7), 2, 16 }, \ } // Largest attribute size is needed for various buffers @@ -342,7 +344,7 @@ #define ATTRIBUTE_SINGLETONS_SIZE (508) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (546) +#define ATTRIBUTE_MAX_SIZE (548) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (4) @@ -386,7 +388,7 @@ // Array of EmberAfCommandMetadata structs. #define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask -#define EMBER_AF_GENERATED_COMMAND_COUNT (45) +#define EMBER_AF_GENERATED_COMMAND_COUNT (62) #define GENERATED_COMMANDS \ { \ { 0x0006, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* On/off (server): Off */ \ @@ -434,6 +436,24 @@ { 0x0028, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): ShutDown */ \ { 0x0028, 0x02, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): Leave */ \ { 0x0028, 0x02, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): Leave */ \ + { 0x0031, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): ScanNetworks */ \ + { 0x0031, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): ScanNetworksResponse */ \ + { 0x0031, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): AddWiFiNetwork */ \ + { 0x0031, 0x03, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): AddWiFiNetworkResponse */ \ + { 0x0031, 0x04, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): UpdateWiFiNetwork */ \ + { 0x0031, 0x05, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): UpdateWiFiNetworkResponse */ \ + { 0x0031, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): AddThreadNetwork */ \ + { 0x0031, 0x07, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): AddThreadNetworkResponse */ \ + { 0x0031, 0x08, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): UpdateThreadNetwork */ \ + { 0x0031, 0x09, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): UpdateThreadNetworkResponse */ \ + { 0x0031, 0x0A, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): RemoveNetwork */ \ + { 0x0031, 0x0B, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): RemoveNetworkResponse */ \ + { 0x0031, 0x0C, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): EnableNetwork */ \ + { 0x0031, 0x0D, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): EnableNetworkResponse */ \ + { 0x0031, 0x0E, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): DisableNetwork */ \ + { 0x0031, 0x0F, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): DisableNetworkResponse */ \ + { 0x0031, 0x10, \ + ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): GetLastNetworkCommissioningResult */ \ } // Array of EmberAfManufacturerCodeEntry structures for commands. diff --git a/examples/bridge-app/bridge-common/gen/gen_config.h b/examples/bridge-app/bridge-common/gen/gen_config.h index 3f145a50331b91..d5a44941d9a09b 100644 --- a/examples/bridge-app/bridge-common/gen/gen_config.h +++ b/examples/bridge-app/bridge-common/gen/gen_config.h @@ -31,6 +31,7 @@ /**** Cluster endpoint counts ****/ #define EMBER_AF_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT (2) #define EMBER_AF_LEVEL_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (3) +#define EMBER_AF_NETWORK_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_ON_OFF_CLUSTER_SERVER_ENDPOINT_COUNT (3) /**** Cluster Plugins ****/ @@ -49,6 +50,11 @@ #define EMBER_AF_PLUGIN_LEVEL_CONTROL_MINIMUM_LEVEL 0 #define EMBER_AF_PLUGIN_LEVEL_CONTROL_RATE 0 +// Use this macro to check if the server side of the Network Commissioning cluster is included +#define ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING_SERVER +#define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING + // Use this macro to check if the server side of the On/off cluster is included #define ZCL_USING_ON_OFF_CLUSTER_SERVER #define EMBER_AF_PLUGIN_ON_OFF_SERVER diff --git a/examples/bridge-app/bridge-common/gen/print-cluster.h b/examples/bridge-app/bridge-common/gen/print-cluster.h index bd08d38a581506..8c737e93fea79c 100644 --- a/examples/bridge-app/bridge-common/gen/print-cluster.h +++ b/examples/bridge-app/bridge-common/gen/print-cluster.h @@ -156,6 +156,12 @@ #define CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER #endif +#if defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER { ZCL_NETWORK_COMMISSIONING_CLUSTER_ID, 49, "Network Commissioning" }, +#else +#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER +#endif + #if defined(ZCL_USING_SHADE_CONFIG_CLUSTER_SERVER) || defined(ZCL_USING_SHADE_CONFIG_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER { ZCL_SHADE_CONFIG_CLUSTER_ID, 256, "Shade Configuration" }, #else @@ -734,12 +740,6 @@ #define CHIP_PRINTCLUSTER_ZLL_COMMISSIONING_CLUSTER #endif -#if defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_CLIENT) -#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER { ZCL_NETWORK_COMMISSIONING_CLUSTER_ID, 43690, "Network Commissioning" }, -#else -#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER -#endif - #if defined(ZCL_USING_BINDING_CLUSTER_SERVER) || defined(ZCL_USING_BINDING_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_BINDING_CLUSTER { ZCL_BINDING_CLUSTER_ID, 61440, "Binding" }, #else @@ -812,6 +812,7 @@ CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER \ CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER \ + CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DOOR_LOCK_CLUSTER \ CHIP_PRINTCLUSTER_WINDOW_COVERING_CLUSTER \ @@ -897,7 +898,6 @@ CHIP_PRINTCLUSTER_ELECTRICAL_MEASUREMENT_CLUSTER \ CHIP_PRINTCLUSTER_DIAGNOSTICS_CLUSTER \ CHIP_PRINTCLUSTER_ZLL_COMMISSIONING_CLUSTER \ - CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_BINDING_CLUSTER \ CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER \ CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER \ diff --git a/examples/chip-tool/gen/attribute-id.h b/examples/chip-tool/gen/attribute-id.h index 8c8757f826ca7f..72a0198e2f97be 100644 --- a/examples/chip-tool/gen/attribute-id.h +++ b/examples/chip-tool/gen/attribute-id.h @@ -391,6 +391,12 @@ #define ZCL_FABRIC_ID_ATTRIBUTE_ID (0x0000) #define ZCL_BREADCRUMB_ATTRIBUTE_ID (0x0001) +// Attribute ids for cluster: Network Commissioning + +// Client attributes + +// Server attributes + // Attribute ids for cluster: Shade Configuration // Client attributes @@ -4084,12 +4090,6 @@ // Server attributes -// Attribute ids for cluster: Network Commissioning - -// Client attributes - -// Server attributes - // Attribute ids for cluster: Binding // Client attributes diff --git a/examples/chip-tool/gen/client-command-macro.h b/examples/chip-tool/gen/client-command-macro.h index f72c96f951dcff..79d1e159594a4a 100644 --- a/examples/chip-tool/gen/client-command-macro.h +++ b/examples/chip-tool/gen/client-command-macro.h @@ -1911,6 +1911,225 @@ \ ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); +/** @brief Command description for ScanNetworks + * + * Command: ScanNetworks + * @param ssid OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterScanNetworks(ssid, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SCAN_NETWORKS_COMMAND_ID, "uuu", ssid, breadcrumb, timeoutMs); + +/** @brief Command description for ScanNetworksResponse + * + * Command: ScanNetworksResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + * @param wifiScanResults WiFiInterfaceScanResult [] + * @param wifiScanResultsLen int + * @param threadScanResults ThreadInterfaceScanResult [] + * @param threadScanResultsLen int + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterScanNetworksResponse(errorCode, debugText, wifiScanResults, wifiScanResultsLen, threadScanResults, \ + threadScanResultsLen) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID, "uubb", errorCode, debugText, wifiScanResults, \ + wifiScanResultsLen, threadScanResults, threadScanResultsLen); + +/** @brief Command description for AddWiFiNetwork + * + * Command: AddWiFiNetwork + * @param ssid OCTET_STRING + * @param credentials OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); + +/** @brief Command description for AddWiFiNetworkResponse + * + * Command: AddWiFiNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddWiFiNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for UpdateWiFiNetwork + * + * Command: UpdateWiFiNetwork + * @param ssid OCTET_STRING + * @param credentials OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); + +/** @brief Command description for UpdateWiFiNetworkResponse + * + * Command: UpdateWiFiNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateWiFiNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for AddThreadNetwork + * + * Command: AddThreadNetwork + * @param operationalDataset OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); + +/** @brief Command description for AddThreadNetworkResponse + * + * Command: AddThreadNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddThreadNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for UpdateThreadNetwork + * + * Command: UpdateThreadNetwork + * @param operationalDataset OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); + +/** @brief Command description for UpdateThreadNetworkResponse + * + * Command: UpdateThreadNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateThreadNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for RemoveNetwork + * + * Command: RemoveNetwork + * @param NetworkID OCTET_STRING + * @param Breadcrumb INT64U + * @param TimeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterRemoveNetwork(NetworkID, Breadcrumb, TimeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_NETWORK_COMMAND_ID, "uuu", NetworkID, Breadcrumb, TimeoutMs); + +/** @brief Command description for RemoveNetworkResponse + * + * Command: RemoveNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterRemoveNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for EnableNetwork + * + * Command: EnableNetwork + * @param networkID OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterEnableNetwork(networkID, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ENABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); + +/** @brief Command description for EnableNetworkResponse + * + * Command: EnableNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterEnableNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for DisableNetwork + * + * Command: DisableNetwork + * @param networkID OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterDisableNetwork(networkID, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_DISABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); + +/** @brief Command description for DisableNetworkResponse + * + * Command: DisableNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterDisableNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for GetLastNetworkCommissioningResult + * + * Command: GetLastNetworkCommissioningResult + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterGetLastNetworkCommissioningResult(timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID, "u", timeoutMs); + /** @brief Command description for LockDoor * * Command: LockDoor @@ -5783,225 +6002,6 @@ ZCL_GET_ENDPOINT_LIST_REQUEST_COMMAND_ID, "uuuub", startIndex, total, startIndex, count, \ endpointInformationRecordList, endpointInformationRecordListLen); -/** @brief Command description for ScanNetworks - * - * Command: ScanNetworks - * @param ssid OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterScanNetworks(ssid, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_SCAN_NETWORKS_COMMAND_ID, "uuu", ssid, breadcrumb, timeoutMs); - -/** @brief Command description for ScanNetworksResponse - * - * Command: ScanNetworksResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - * @param wifiScanResults WiFiInterfaceScanResult [] - * @param wifiScanResultsLen int - * @param threadScanResults ThreadInterfaceScanResult [] - * @param threadScanResultsLen int - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterScanNetworksResponse(errorCode, debugText, wifiScanResults, wifiScanResultsLen, threadScanResults, \ - threadScanResultsLen) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID, "uubb", errorCode, debugText, wifiScanResults, \ - wifiScanResultsLen, threadScanResults, threadScanResultsLen); - -/** @brief Command description for AddWiFiNetwork - * - * Command: AddWiFiNetwork - * @param ssid OCTET_STRING - * @param credentials OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); - -/** @brief Command description for AddWiFiNetworkResponse - * - * Command: AddWiFiNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddWiFiNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for UpdateWiFiNetwork - * - * Command: UpdateWiFiNetwork - * @param ssid OCTET_STRING - * @param credentials OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); - -/** @brief Command description for UpdateWiFiNetworkResponse - * - * Command: UpdateWiFiNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateWiFiNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for AddThreadNetwork - * - * Command: AddThreadNetwork - * @param operationalDataset OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); - -/** @brief Command description for AddThreadNetworkResponse - * - * Command: AddThreadNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddThreadNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for UpdateThreadNetwork - * - * Command: UpdateThreadNetwork - * @param operationalDataset OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); - -/** @brief Command description for UpdateThreadNetworkResponse - * - * Command: UpdateThreadNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateThreadNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for RemoveNetwork - * - * Command: RemoveNetwork - * @param NetworkID OCTET_STRING - * @param Breadcrumb INT64U - * @param TimeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterRemoveNetwork(NetworkID, Breadcrumb, TimeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_REMOVE_NETWORK_COMMAND_ID, "uuu", NetworkID, Breadcrumb, TimeoutMs); - -/** @brief Command description for RemoveNetworkResponse - * - * Command: RemoveNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterRemoveNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for EnableNetwork - * - * Command: EnableNetwork - * @param networkID OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterEnableNetwork(networkID, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ENABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); - -/** @brief Command description for EnableNetworkResponse - * - * Command: EnableNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterEnableNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for DisableNetwork - * - * Command: DisableNetwork - * @param networkID OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterDisableNetwork(networkID, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_DISABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); - -/** @brief Command description for DisableNetworkResponse - * - * Command: DisableNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterDisableNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for GetLastNetworkCommissioningResult - * - * Command: GetLastNetworkCommissioningResult - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterGetLastNetworkCommissioningResult(timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID, "u", timeoutMs); - /** @brief Command description for Bind * * Command: Bind diff --git a/examples/chip-tool/gen/cluster-id.h b/examples/chip-tool/gen/cluster-id.h index d77da915200ab4..add8f83d188cf8 100644 --- a/examples/chip-tool/gen/cluster-id.h +++ b/examples/chip-tool/gen/cluster-id.h @@ -86,6 +86,9 @@ // Definitions for cluster: General Commissioning #define ZCL_GENERAL_COMMISSIONING_CLUSTER_ID (0x0030) +// Definitions for cluster: Network Commissioning +#define ZCL_NETWORK_COMMISSIONING_CLUSTER_ID (0x0031) + // Definitions for cluster: Shade Configuration #define ZCL_SHADE_CONFIG_CLUSTER_ID (0x0100) @@ -341,9 +344,6 @@ // Definitions for cluster: ZLL Commissioning #define ZCL_ZLL_COMMISSIONING_CLUSTER_ID (0x1000) -// Definitions for cluster: Network Commissioning -#define ZCL_NETWORK_COMMISSIONING_CLUSTER_ID (0xAAAA) - // Definitions for cluster: Binding #define ZCL_BINDING_CLUSTER_ID (0xF000) diff --git a/examples/chip-tool/gen/command-id.h b/examples/chip-tool/gen/command-id.h index adc2b1c6f32733..864943b5727fcd 100644 --- a/examples/chip-tool/gen/command-id.h +++ b/examples/chip-tool/gen/command-id.h @@ -238,6 +238,25 @@ #define ZCL_COMMISSIONING_COMPLETE_COMMAND_ID (0x06) #define ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID (0x07) +// Commands for cluster: Network Commissioning +#define ZCL_SCAN_NETWORKS_COMMAND_ID (0x00) +#define ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID (0x01) +#define ZCL_ADD_WI_FI_NETWORK_COMMAND_ID (0x02) +#define ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x03) +#define ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID (0x04) +#define ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x05) +#define ZCL_ADD_THREAD_NETWORK_COMMAND_ID (0x06) +#define ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x07) +#define ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID (0x08) +#define ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x09) +#define ZCL_REMOVE_NETWORK_COMMAND_ID (0x0A) +#define ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID (0x0B) +#define ZCL_ENABLE_NETWORK_COMMAND_ID (0x0C) +#define ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID (0x0D) +#define ZCL_DISABLE_NETWORK_COMMAND_ID (0x0E) +#define ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID (0x0F) +#define ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID (0x10) + // Commands for cluster: Door Lock #define ZCL_LOCK_DOOR_COMMAND_ID (0x00) #define ZCL_LOCK_DOOR_RESPONSE_COMMAND_ID (0x00) @@ -700,25 +719,6 @@ #define ZCL_GET_ENDPOINT_LIST_REQUEST_COMMAND_ID (0x42) #define ZCL_GET_ENDPOINT_LIST_RESPONSE_COMMAND_ID (0x42) -// Commands for cluster: Network Commissioning -#define ZCL_SCAN_NETWORKS_COMMAND_ID (0x00) -#define ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID (0x01) -#define ZCL_ADD_WI_FI_NETWORK_COMMAND_ID (0x02) -#define ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x03) -#define ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID (0x04) -#define ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x05) -#define ZCL_ADD_THREAD_NETWORK_COMMAND_ID (0x06) -#define ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x07) -#define ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID (0x08) -#define ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x09) -#define ZCL_REMOVE_NETWORK_COMMAND_ID (0x0A) -#define ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID (0x0B) -#define ZCL_ENABLE_NETWORK_COMMAND_ID (0x0C) -#define ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID (0x0D) -#define ZCL_DISABLE_NETWORK_COMMAND_ID (0x0E) -#define ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID (0x0F) -#define ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID (0x10) - // Commands for cluster: Binding #define ZCL_BIND_COMMAND_ID (0x00) #define ZCL_UNBIND_COMMAND_ID (0x01) diff --git a/examples/chip-tool/gen/print-cluster.h b/examples/chip-tool/gen/print-cluster.h index bd08d38a581506..8c737e93fea79c 100644 --- a/examples/chip-tool/gen/print-cluster.h +++ b/examples/chip-tool/gen/print-cluster.h @@ -156,6 +156,12 @@ #define CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER #endif +#if defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER { ZCL_NETWORK_COMMISSIONING_CLUSTER_ID, 49, "Network Commissioning" }, +#else +#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER +#endif + #if defined(ZCL_USING_SHADE_CONFIG_CLUSTER_SERVER) || defined(ZCL_USING_SHADE_CONFIG_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER { ZCL_SHADE_CONFIG_CLUSTER_ID, 256, "Shade Configuration" }, #else @@ -734,12 +740,6 @@ #define CHIP_PRINTCLUSTER_ZLL_COMMISSIONING_CLUSTER #endif -#if defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_CLIENT) -#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER { ZCL_NETWORK_COMMISSIONING_CLUSTER_ID, 43690, "Network Commissioning" }, -#else -#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER -#endif - #if defined(ZCL_USING_BINDING_CLUSTER_SERVER) || defined(ZCL_USING_BINDING_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_BINDING_CLUSTER { ZCL_BINDING_CLUSTER_ID, 61440, "Binding" }, #else @@ -812,6 +812,7 @@ CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER \ CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER \ + CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DOOR_LOCK_CLUSTER \ CHIP_PRINTCLUSTER_WINDOW_COVERING_CLUSTER \ @@ -897,7 +898,6 @@ CHIP_PRINTCLUSTER_ELECTRICAL_MEASUREMENT_CLUSTER \ CHIP_PRINTCLUSTER_DIAGNOSTICS_CLUSTER \ CHIP_PRINTCLUSTER_ZLL_COMMISSIONING_CLUSTER \ - CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_BINDING_CLUSTER \ CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER \ CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER \ diff --git a/examples/lighting-app/lighting-common/gen/attribute-id.h b/examples/lighting-app/lighting-common/gen/attribute-id.h index 8c8757f826ca7f..72a0198e2f97be 100644 --- a/examples/lighting-app/lighting-common/gen/attribute-id.h +++ b/examples/lighting-app/lighting-common/gen/attribute-id.h @@ -391,6 +391,12 @@ #define ZCL_FABRIC_ID_ATTRIBUTE_ID (0x0000) #define ZCL_BREADCRUMB_ATTRIBUTE_ID (0x0001) +// Attribute ids for cluster: Network Commissioning + +// Client attributes + +// Server attributes + // Attribute ids for cluster: Shade Configuration // Client attributes @@ -4084,12 +4090,6 @@ // Server attributes -// Attribute ids for cluster: Network Commissioning - -// Client attributes - -// Server attributes - // Attribute ids for cluster: Binding // Client attributes diff --git a/examples/lighting-app/lighting-common/gen/client-command-macro.h b/examples/lighting-app/lighting-common/gen/client-command-macro.h index f72c96f951dcff..79d1e159594a4a 100644 --- a/examples/lighting-app/lighting-common/gen/client-command-macro.h +++ b/examples/lighting-app/lighting-common/gen/client-command-macro.h @@ -1911,6 +1911,225 @@ \ ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); +/** @brief Command description for ScanNetworks + * + * Command: ScanNetworks + * @param ssid OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterScanNetworks(ssid, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SCAN_NETWORKS_COMMAND_ID, "uuu", ssid, breadcrumb, timeoutMs); + +/** @brief Command description for ScanNetworksResponse + * + * Command: ScanNetworksResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + * @param wifiScanResults WiFiInterfaceScanResult [] + * @param wifiScanResultsLen int + * @param threadScanResults ThreadInterfaceScanResult [] + * @param threadScanResultsLen int + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterScanNetworksResponse(errorCode, debugText, wifiScanResults, wifiScanResultsLen, threadScanResults, \ + threadScanResultsLen) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID, "uubb", errorCode, debugText, wifiScanResults, \ + wifiScanResultsLen, threadScanResults, threadScanResultsLen); + +/** @brief Command description for AddWiFiNetwork + * + * Command: AddWiFiNetwork + * @param ssid OCTET_STRING + * @param credentials OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); + +/** @brief Command description for AddWiFiNetworkResponse + * + * Command: AddWiFiNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddWiFiNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for UpdateWiFiNetwork + * + * Command: UpdateWiFiNetwork + * @param ssid OCTET_STRING + * @param credentials OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); + +/** @brief Command description for UpdateWiFiNetworkResponse + * + * Command: UpdateWiFiNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateWiFiNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for AddThreadNetwork + * + * Command: AddThreadNetwork + * @param operationalDataset OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); + +/** @brief Command description for AddThreadNetworkResponse + * + * Command: AddThreadNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddThreadNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for UpdateThreadNetwork + * + * Command: UpdateThreadNetwork + * @param operationalDataset OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); + +/** @brief Command description for UpdateThreadNetworkResponse + * + * Command: UpdateThreadNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateThreadNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for RemoveNetwork + * + * Command: RemoveNetwork + * @param NetworkID OCTET_STRING + * @param Breadcrumb INT64U + * @param TimeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterRemoveNetwork(NetworkID, Breadcrumb, TimeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_NETWORK_COMMAND_ID, "uuu", NetworkID, Breadcrumb, TimeoutMs); + +/** @brief Command description for RemoveNetworkResponse + * + * Command: RemoveNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterRemoveNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for EnableNetwork + * + * Command: EnableNetwork + * @param networkID OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterEnableNetwork(networkID, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ENABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); + +/** @brief Command description for EnableNetworkResponse + * + * Command: EnableNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterEnableNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for DisableNetwork + * + * Command: DisableNetwork + * @param networkID OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterDisableNetwork(networkID, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_DISABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); + +/** @brief Command description for DisableNetworkResponse + * + * Command: DisableNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterDisableNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for GetLastNetworkCommissioningResult + * + * Command: GetLastNetworkCommissioningResult + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterGetLastNetworkCommissioningResult(timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID, "u", timeoutMs); + /** @brief Command description for LockDoor * * Command: LockDoor @@ -5783,225 +6002,6 @@ ZCL_GET_ENDPOINT_LIST_REQUEST_COMMAND_ID, "uuuub", startIndex, total, startIndex, count, \ endpointInformationRecordList, endpointInformationRecordListLen); -/** @brief Command description for ScanNetworks - * - * Command: ScanNetworks - * @param ssid OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterScanNetworks(ssid, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_SCAN_NETWORKS_COMMAND_ID, "uuu", ssid, breadcrumb, timeoutMs); - -/** @brief Command description for ScanNetworksResponse - * - * Command: ScanNetworksResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - * @param wifiScanResults WiFiInterfaceScanResult [] - * @param wifiScanResultsLen int - * @param threadScanResults ThreadInterfaceScanResult [] - * @param threadScanResultsLen int - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterScanNetworksResponse(errorCode, debugText, wifiScanResults, wifiScanResultsLen, threadScanResults, \ - threadScanResultsLen) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID, "uubb", errorCode, debugText, wifiScanResults, \ - wifiScanResultsLen, threadScanResults, threadScanResultsLen); - -/** @brief Command description for AddWiFiNetwork - * - * Command: AddWiFiNetwork - * @param ssid OCTET_STRING - * @param credentials OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); - -/** @brief Command description for AddWiFiNetworkResponse - * - * Command: AddWiFiNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddWiFiNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for UpdateWiFiNetwork - * - * Command: UpdateWiFiNetwork - * @param ssid OCTET_STRING - * @param credentials OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); - -/** @brief Command description for UpdateWiFiNetworkResponse - * - * Command: UpdateWiFiNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateWiFiNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for AddThreadNetwork - * - * Command: AddThreadNetwork - * @param operationalDataset OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); - -/** @brief Command description for AddThreadNetworkResponse - * - * Command: AddThreadNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddThreadNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for UpdateThreadNetwork - * - * Command: UpdateThreadNetwork - * @param operationalDataset OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); - -/** @brief Command description for UpdateThreadNetworkResponse - * - * Command: UpdateThreadNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateThreadNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for RemoveNetwork - * - * Command: RemoveNetwork - * @param NetworkID OCTET_STRING - * @param Breadcrumb INT64U - * @param TimeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterRemoveNetwork(NetworkID, Breadcrumb, TimeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_REMOVE_NETWORK_COMMAND_ID, "uuu", NetworkID, Breadcrumb, TimeoutMs); - -/** @brief Command description for RemoveNetworkResponse - * - * Command: RemoveNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterRemoveNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for EnableNetwork - * - * Command: EnableNetwork - * @param networkID OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterEnableNetwork(networkID, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ENABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); - -/** @brief Command description for EnableNetworkResponse - * - * Command: EnableNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterEnableNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for DisableNetwork - * - * Command: DisableNetwork - * @param networkID OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterDisableNetwork(networkID, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_DISABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); - -/** @brief Command description for DisableNetworkResponse - * - * Command: DisableNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterDisableNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for GetLastNetworkCommissioningResult - * - * Command: GetLastNetworkCommissioningResult - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterGetLastNetworkCommissioningResult(timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID, "u", timeoutMs); - /** @brief Command description for Bind * * Command: Bind diff --git a/examples/lighting-app/lighting-common/gen/cluster-id.h b/examples/lighting-app/lighting-common/gen/cluster-id.h index d77da915200ab4..add8f83d188cf8 100644 --- a/examples/lighting-app/lighting-common/gen/cluster-id.h +++ b/examples/lighting-app/lighting-common/gen/cluster-id.h @@ -86,6 +86,9 @@ // Definitions for cluster: General Commissioning #define ZCL_GENERAL_COMMISSIONING_CLUSTER_ID (0x0030) +// Definitions for cluster: Network Commissioning +#define ZCL_NETWORK_COMMISSIONING_CLUSTER_ID (0x0031) + // Definitions for cluster: Shade Configuration #define ZCL_SHADE_CONFIG_CLUSTER_ID (0x0100) @@ -341,9 +344,6 @@ // Definitions for cluster: ZLL Commissioning #define ZCL_ZLL_COMMISSIONING_CLUSTER_ID (0x1000) -// Definitions for cluster: Network Commissioning -#define ZCL_NETWORK_COMMISSIONING_CLUSTER_ID (0xAAAA) - // Definitions for cluster: Binding #define ZCL_BINDING_CLUSTER_ID (0xF000) diff --git a/examples/lighting-app/lighting-common/gen/command-id.h b/examples/lighting-app/lighting-common/gen/command-id.h index adc2b1c6f32733..864943b5727fcd 100644 --- a/examples/lighting-app/lighting-common/gen/command-id.h +++ b/examples/lighting-app/lighting-common/gen/command-id.h @@ -238,6 +238,25 @@ #define ZCL_COMMISSIONING_COMPLETE_COMMAND_ID (0x06) #define ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID (0x07) +// Commands for cluster: Network Commissioning +#define ZCL_SCAN_NETWORKS_COMMAND_ID (0x00) +#define ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID (0x01) +#define ZCL_ADD_WI_FI_NETWORK_COMMAND_ID (0x02) +#define ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x03) +#define ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID (0x04) +#define ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x05) +#define ZCL_ADD_THREAD_NETWORK_COMMAND_ID (0x06) +#define ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x07) +#define ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID (0x08) +#define ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x09) +#define ZCL_REMOVE_NETWORK_COMMAND_ID (0x0A) +#define ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID (0x0B) +#define ZCL_ENABLE_NETWORK_COMMAND_ID (0x0C) +#define ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID (0x0D) +#define ZCL_DISABLE_NETWORK_COMMAND_ID (0x0E) +#define ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID (0x0F) +#define ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID (0x10) + // Commands for cluster: Door Lock #define ZCL_LOCK_DOOR_COMMAND_ID (0x00) #define ZCL_LOCK_DOOR_RESPONSE_COMMAND_ID (0x00) @@ -700,25 +719,6 @@ #define ZCL_GET_ENDPOINT_LIST_REQUEST_COMMAND_ID (0x42) #define ZCL_GET_ENDPOINT_LIST_RESPONSE_COMMAND_ID (0x42) -// Commands for cluster: Network Commissioning -#define ZCL_SCAN_NETWORKS_COMMAND_ID (0x00) -#define ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID (0x01) -#define ZCL_ADD_WI_FI_NETWORK_COMMAND_ID (0x02) -#define ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x03) -#define ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID (0x04) -#define ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x05) -#define ZCL_ADD_THREAD_NETWORK_COMMAND_ID (0x06) -#define ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x07) -#define ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID (0x08) -#define ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x09) -#define ZCL_REMOVE_NETWORK_COMMAND_ID (0x0A) -#define ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID (0x0B) -#define ZCL_ENABLE_NETWORK_COMMAND_ID (0x0C) -#define ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID (0x0D) -#define ZCL_DISABLE_NETWORK_COMMAND_ID (0x0E) -#define ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID (0x0F) -#define ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID (0x10) - // Commands for cluster: Binding #define ZCL_BIND_COMMAND_ID (0x00) #define ZCL_UNBIND_COMMAND_ID (0x01) diff --git a/examples/lighting-app/lighting-common/gen/endpoint_config.h b/examples/lighting-app/lighting-common/gen/endpoint_config.h index f82aab447d96cc..e4ee406058800d 100644 --- a/examples/lighting-app/lighting-common/gen/endpoint_config.h +++ b/examples/lighting-app/lighting-common/gen/endpoint_config.h @@ -180,7 +180,7 @@ 0x0028, ZAP_ATTRIBUTE_INDEX(4), 12, 254, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Basic (server) */ \ { \ - 0xAAAA, ZAP_ATTRIBUTE_INDEX(16), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0031, ZAP_ATTRIBUTE_INDEX(16), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Network Commissioning (server) */ \ } @@ -260,23 +260,23 @@ { 0x0028, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): StartUp */ \ { 0x0028, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): ShutDown */ \ { 0x0028, 0x02, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): Leave */ \ - { 0xAAAA, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): ScanNetworks */ \ - { 0xAAAA, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): ScanNetworksResponse */ \ - { 0xAAAA, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): AddWiFiNetwork */ \ - { 0xAAAA, 0x03, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): AddWiFiNetworkResponse */ \ - { 0xAAAA, 0x04, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): UpdateWiFiNetwork */ \ - { 0xAAAA, 0x05, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): UpdateWiFiNetworkResponse */ \ - { 0xAAAA, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): AddThreadNetwork */ \ - { 0xAAAA, 0x07, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): AddThreadNetworkResponse */ \ - { 0xAAAA, 0x08, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): UpdateThreadNetwork */ \ - { 0xAAAA, 0x09, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): UpdateThreadNetworkResponse */ \ - { 0xAAAA, 0x0A, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): RemoveNetwork */ \ - { 0xAAAA, 0x0B, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): RemoveNetworkResponse */ \ - { 0xAAAA, 0x0C, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): EnableNetwork */ \ - { 0xAAAA, 0x0D, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): EnableNetworkResponse */ \ - { 0xAAAA, 0x0E, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): DisableNetwork */ \ - { 0xAAAA, 0x0F, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): DisableNetworkResponse */ \ - { 0xAAAA, 0x10, \ + { 0x0031, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): ScanNetworks */ \ + { 0x0031, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): ScanNetworksResponse */ \ + { 0x0031, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): AddWiFiNetwork */ \ + { 0x0031, 0x03, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): AddWiFiNetworkResponse */ \ + { 0x0031, 0x04, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): UpdateWiFiNetwork */ \ + { 0x0031, 0x05, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): UpdateWiFiNetworkResponse */ \ + { 0x0031, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): AddThreadNetwork */ \ + { 0x0031, 0x07, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): AddThreadNetworkResponse */ \ + { 0x0031, 0x08, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): UpdateThreadNetwork */ \ + { 0x0031, 0x09, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): UpdateThreadNetworkResponse */ \ + { 0x0031, 0x0A, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): RemoveNetwork */ \ + { 0x0031, 0x0B, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): RemoveNetworkResponse */ \ + { 0x0031, 0x0C, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): EnableNetwork */ \ + { 0x0031, 0x0D, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): EnableNetworkResponse */ \ + { 0x0031, 0x0E, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): DisableNetwork */ \ + { 0x0031, 0x0F, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): DisableNetworkResponse */ \ + { 0x0031, 0x10, \ ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): GetLastNetworkCommissioningResult */ \ } diff --git a/examples/lighting-app/lighting-common/gen/print-cluster.h b/examples/lighting-app/lighting-common/gen/print-cluster.h index bd08d38a581506..8c737e93fea79c 100644 --- a/examples/lighting-app/lighting-common/gen/print-cluster.h +++ b/examples/lighting-app/lighting-common/gen/print-cluster.h @@ -156,6 +156,12 @@ #define CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER #endif +#if defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER { ZCL_NETWORK_COMMISSIONING_CLUSTER_ID, 49, "Network Commissioning" }, +#else +#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER +#endif + #if defined(ZCL_USING_SHADE_CONFIG_CLUSTER_SERVER) || defined(ZCL_USING_SHADE_CONFIG_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER { ZCL_SHADE_CONFIG_CLUSTER_ID, 256, "Shade Configuration" }, #else @@ -734,12 +740,6 @@ #define CHIP_PRINTCLUSTER_ZLL_COMMISSIONING_CLUSTER #endif -#if defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_CLIENT) -#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER { ZCL_NETWORK_COMMISSIONING_CLUSTER_ID, 43690, "Network Commissioning" }, -#else -#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER -#endif - #if defined(ZCL_USING_BINDING_CLUSTER_SERVER) || defined(ZCL_USING_BINDING_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_BINDING_CLUSTER { ZCL_BINDING_CLUSTER_ID, 61440, "Binding" }, #else @@ -812,6 +812,7 @@ CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER \ CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER \ + CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DOOR_LOCK_CLUSTER \ CHIP_PRINTCLUSTER_WINDOW_COVERING_CLUSTER \ @@ -897,7 +898,6 @@ CHIP_PRINTCLUSTER_ELECTRICAL_MEASUREMENT_CLUSTER \ CHIP_PRINTCLUSTER_DIAGNOSTICS_CLUSTER \ CHIP_PRINTCLUSTER_ZLL_COMMISSIONING_CLUSTER \ - CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_BINDING_CLUSTER \ CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER \ CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER \ diff --git a/examples/lighting-app/lighting-common/lighting-app.zap b/examples/lighting-app/lighting-common/lighting-app.zap index 79094c919ddd3b..58535dbaf1e157 100644 --- a/examples/lighting-app/lighting-common/lighting-app.zap +++ b/examples/lighting-app/lighting-common/lighting-app.zap @@ -1,5 +1,5 @@ { - "writeTime": "Fri Feb 26 2021 15:33:11 GMT+0800 (China Standard Time)", + "writeTime": "Fri Mar 12 2021 15:18:57 GMT+0800 (China Standard Time)", "featureLevel": 11, "creator": "zap", "keyValuePairs": [ @@ -38,13 +38,12 @@ "deviceTypeProfileId": 260, "clusters": [ { - "name": "Basic", - "code": 40, + "name": "Identify", + "code": 3, "mfgCode": null, - "define": "BASIC_CLUSTER", + "define": "IDENTIFY_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "cluster revision", @@ -53,49 +52,41 @@ "side": "client", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "2", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 } - ] - }, - { - "name": "Basic", - "code": 40, - "mfgCode": null, - "define": "BASIC_CLUSTER", - "side": "server", - "enabled": 1, + ], "commands": [ { - "name": "StartUp", + "name": "Identify", "code": 0, "mfgCode": null, - "source": "server", + "source": "client", "incoming": 1, - "outgoing": 1 + "outgoing": 0 }, { - "name": "ShutDown", + "name": "IdentifyQuery", "code": 1, "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "Leave", - "code": 2, - "mfgCode": null, - "source": "server", + "source": "client", "incoming": 1, - "outgoing": 1 + "outgoing": 0 } - ], + ] + }, + { + "name": "Identify", + "code": 3, + "mfgCode": null, + "define": "IDENTIFY_CLUSTER", + "side": "server", + "enabled": 0, "attributes": [ { "name": "cluster revision", @@ -104,172 +95,181 @@ "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "2", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "InteractionModelVersion", + "name": "identify time", "code": 0, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0x0000", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 + } + ], + "commands": [ + { + "name": "IdentifyQueryResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } + ] + }, + { + "name": "Groups", + "code": 4, + "mfgCode": null, + "define": "GROUPS_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "AddGroup", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 }, { - "name": "VendorName", + "name": "ViewGroup", "code": 1, "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 + "source": "client", + "incoming": 1, + "outgoing": 0 }, { - "name": "VendorID", + "name": "GetGroupMembership", "code": 2, "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 + "source": "client", + "incoming": 1, + "outgoing": 0 }, { - "name": "ProductName", + "name": "RemoveGroup", "code": 3, "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 + "source": "client", + "incoming": 1, + "outgoing": 0 }, { - "name": "ProductID", + "name": "RemoveAllGroups", "code": 4, "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 + "source": "client", + "incoming": 1, + "outgoing": 0 }, { - "name": "UserLabel", + "name": "AddGroupIfIdentifying", "code": 5, "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ { - "name": "Location", - "code": 6, + "name": "cluster revision", + "code": 65533, "mfgCode": null, - "side": "server", + "side": "client", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "3", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 + } + ] + }, + { + "name": "Groups", + "code": 4, + "mfgCode": null, + "define": "GROUPS_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [ + { + "name": "AddGroupResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 }, { - "name": "HardwareVersion", - "code": 7, + "name": "ViewGroupResponse", + "code": 1, "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 + "source": "server", + "incoming": 0, + "outgoing": 1 }, { - "name": "HardwareVersionString", - "code": 8, + "name": "GetGroupMembershipResponse", + "code": 2, "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 + "source": "server", + "incoming": 0, + "outgoing": 1 }, { - "name": "SoftwareVersion", - "code": 9, + "name": "RemoveGroupResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "3", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "SoftwareVersionString", - "code": 10, + "name": "name support", + "code": 0, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 0, @@ -280,15 +280,15 @@ ] }, { - "name": "Identify", - "code": 3, + "name": "Scenes", + "code": 5, "mfgCode": null, - "define": "IDENTIFY_CLUSTER", + "define": "SCENES_CLUSTER", "side": "client", "enabled": 0, "commands": [ { - "name": "Identify", + "name": "AddScene", "code": 0, "mfgCode": null, "source": "client", @@ -296,12 +296,52 @@ "outgoing": 0 }, { - "name": "IdentifyQuery", + "name": "ViewScene", "code": 1, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 0 + }, + { + "name": "RemoveScene", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveAllScenes", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StoreScene", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RecallScene", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "GetSceneMembership", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 } ], "attributes": [ @@ -314,7 +354,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "2", + "defaultValue": "3", "reportable": 0, "minInterval": 0, "maxInterval": 65344, @@ -323,20 +363,60 @@ ] }, { - "name": "Identify", - "code": 3, + "name": "Scenes", + "code": 5, "mfgCode": null, - "define": "IDENTIFY_CLUSTER", + "define": "SCENES_CLUSTER", "side": "server", "enabled": 0, "commands": [ { - "name": "IdentifyQueryResponse", + "name": "AddSceneResponse", "code": 0, "mfgCode": null, "source": "server", "incoming": 0, "outgoing": 1 + }, + { + "name": "ViewSceneResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RemoveSceneResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RemoveAllScenesResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "StoreSceneResponse", + "code": 4, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "GetSceneMembershipResponse", + "code": 6, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 } ], "attributes": [ @@ -349,14 +429,14 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "2", + "defaultValue": "3", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "identify time", + "name": "scene count", "code": 0, "mfgCode": null, "side": "server", @@ -364,65 +444,101 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "0x00", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - } - ] - }, - { - "name": "Groups", - "code": 4, - "mfgCode": null, - "define": "GROUPS_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [ - { - "name": "AddGroup", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 }, { - "name": "ViewGroup", + "name": "current scene", "code": 1, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 }, { - "name": "GetGroupMembership", + "name": "current group", "code": 2, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 }, { - "name": "RemoveGroup", - "code": 3, + "name": "scene valid", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "name support", + "code": 4, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "On/off", + "code": 6, + "mfgCode": null, + "define": "ON_OFF_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "Off", + "code": 0, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 0 }, { - "name": "RemoveAllGroups", - "code": 4, + "name": "On", + "code": 1, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 0 }, { - "name": "AddGroupIfIdentifying", - "code": 5, + "name": "Toggle", + "code": 2, "mfgCode": null, "source": "client", "incoming": 1, @@ -439,7 +555,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "2", "reportable": 0, "minInterval": 0, "maxInterval": 65344, @@ -448,46 +564,13 @@ ] }, { - "name": "Groups", - "code": 4, + "name": "On/off", + "code": 6, "mfgCode": null, - "define": "GROUPS_CLUSTER", + "define": "ON_OFF_CLUSTER", "side": "server", - "enabled": 0, - "commands": [ - { - "name": "AddGroupResponse", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "ViewGroupResponse", - "code": 1, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "GetGroupMembershipResponse", - "code": 2, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "RemoveGroupResponse", - "code": 3, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - } - ], + "enabled": 1, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -498,14 +581,14 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "2", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "name support", + "name": "on/off", "code": 0, "mfgCode": null, "side": "server", @@ -513,8 +596,8 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", - "reportable": 0, + "defaultValue": "0x00", + "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -522,15 +605,32 @@ ] }, { - "name": "Scenes", - "code": 5, + "name": "Level Control", + "code": 8, "mfgCode": null, - "define": "SCENES_CLUSTER", + "define": "LEVEL_CONTROL_CLUSTER", "side": "client", "enabled": 0, + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], "commands": [ { - "name": "AddScene", + "name": "MoveToLevel", "code": 0, "mfgCode": null, "source": "client", @@ -538,7 +638,7 @@ "outgoing": 0 }, { - "name": "ViewScene", + "name": "Move", "code": 1, "mfgCode": null, "source": "client", @@ -546,7 +646,7 @@ "outgoing": 0 }, { - "name": "RemoveScene", + "name": "Step", "code": 2, "mfgCode": null, "source": "client", @@ -554,7 +654,7 @@ "outgoing": 0 }, { - "name": "RemoveAllScenes", + "name": "Stop", "code": 3, "mfgCode": null, "source": "client", @@ -562,7 +662,7 @@ "outgoing": 0 }, { - "name": "StoreScene", + "name": "MoveToLevelWithOnOff", "code": 4, "mfgCode": null, "source": "client", @@ -570,7 +670,7 @@ "outgoing": 0 }, { - "name": "RecallScene", + "name": "MoveWithOnOff", "code": 5, "mfgCode": null, "source": "client", @@ -578,20 +678,37 @@ "outgoing": 0 }, { - "name": "GetSceneMembership", + "name": "StepWithOnOff", "code": 6, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 0 + }, + { + "name": "StopWithOnOff", + "code": 7, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 } - ], + ] + }, + { + "name": "Level Control", + "code": 8, + "mfgCode": null, + "define": "LEVEL_CONTROL_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], "attributes": [ { "name": "cluster revision", "code": 65533, "mfgCode": null, - "side": "client", + "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -601,66 +718,57 @@ "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 + }, + { + "name": "current level", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 } ] }, { - "name": "Scenes", - "code": 5, + "name": "Basic", + "code": 40, "mfgCode": null, - "define": "SCENES_CLUSTER", - "side": "server", + "define": "BASIC_CLUSTER", + "side": "client", "enabled": 0, - "commands": [ - { - "name": "AddSceneResponse", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "ViewSceneResponse", - "code": 1, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "RemoveSceneResponse", - "code": 2, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "RemoveAllScenesResponse", - "code": 3, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "StoreSceneResponse", - "code": 4, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, + "attributes": [ { - "name": "GetSceneMembershipResponse", - "code": 6, + "name": "cluster revision", + "code": 65533, "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 } ], + "commands": [] + }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "server", + "enabled": 1, "attributes": [ { "name": "cluster revision", @@ -669,7 +777,7 @@ "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, "defaultValue": "3", "reportable": 0, @@ -678,192 +786,165 @@ "reportableChange": 0 }, { - "name": "scene count", + "name": "InteractionModelVersion", "code": 0, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "current scene", + "name": "VendorName", "code": 1, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorID", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductName", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "current group", - "code": 2, + "name": "ProductID", + "code": 4, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "scene valid", - "code": 3, + "name": "UserLabel", + "code": 5, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "name support", - "code": 4, + "name": "Location", + "code": 6, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - } - ] - }, - { - "name": "On/off", - "code": 6, - "mfgCode": null, - "define": "ON_OFF_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [ - { - "name": "Off", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "On", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 }, { - "name": "Toggle", - "code": 2, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, + "name": "HardwareVersion", + "code": 7, "mfgCode": null, - "side": "client", + "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "2", + "defaultValue": "0x00", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - } - ] - }, - { - "name": "On/off", - "code": 6, - "mfgCode": null, - "define": "ON_OFF_CLUSTER", - "side": "server", - "enabled": 1, - "commands": [], - "attributes": [ + }, { - "name": "cluster revision", - "code": 65533, + "name": "HardwareVersionString", + "code": 8, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "2", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "on/off", - "code": 0, + "name": "SoftwareVersion", + "code": 9, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, "defaultValue": "0x00", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - } - ] - }, - { - "name": "Level Control", - "code": 8, - "mfgCode": null, - "define": "LEVEL_CONTROL_CLUSTER", - "side": "client", - "enabled": 0, - "attributes": [ + }, { - "name": "cluster revision", - "code": 65533, + "name": "SoftwareVersionString", + "code": 10, "mfgCode": null, - "side": "client", + "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "3", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, @@ -872,115 +953,34 @@ ], "commands": [ { - "name": "MoveToLevel", + "name": "StartUp", "code": 0, "mfgCode": null, - "source": "client", + "source": "server", "incoming": 1, - "outgoing": 0 + "outgoing": 1 }, { - "name": "Move", + "name": "ShutDown", "code": 1, "mfgCode": null, - "source": "client", + "source": "server", "incoming": 1, - "outgoing": 0 + "outgoing": 1 }, { - "name": "Step", + "name": "Leave", "code": 2, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "Stop", - "code": 3, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "MoveToLevelWithOnOff", - "code": 4, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "MoveWithOnOff", - "code": 5, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "StepWithOnOff", - "code": 6, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "StopWithOnOff", - "code": 7, - "mfgCode": null, - "source": "client", + "source": "server", "incoming": 1, - "outgoing": 0 - } - ] - }, - { - "name": "Level Control", - "code": 8, - "mfgCode": null, - "define": "LEVEL_CONTROL_CLUSTER", - "side": "server", - "enabled": 1, - "commands": [], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "current level", - "code": 0, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 + "outgoing": 1 } ] }, { "name": "Network Commissioning", - "code": 43690, + "code": 49, "mfgCode": null, "define": "NETWORK_COMMISSIONING_CLUSTER", "side": "client", @@ -1079,28 +1079,11 @@ }, { "name": "Network Commissioning", - "code": 43690, + "code": 49, "mfgCode": null, "define": "NETWORK_COMMISSIONING_CLUSTER", "side": "server", "enabled": 1, - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0001", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ], "commands": [ { "name": "ScanNetworksResponse", @@ -1166,6 +1149,23 @@ "incoming": 1, "outgoing": 1 } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } ] } ] diff --git a/examples/lock-app/lock-common/BUILD.gn b/examples/lock-app/lock-common/BUILD.gn index 932a186ba4d4bd..e58c95d399a506 100644 --- a/examples/lock-app/lock-common/BUILD.gn +++ b/examples/lock-app/lock-common/BUILD.gn @@ -25,6 +25,8 @@ config("includes") { source_set("lock-common") { sources = [ "${chip_root}/src/app/clusters/bindings/bindings.cpp", + "${chip_root}/src/app/clusters/network-commissioning/network-commissioning-ember.cpp", + "${chip_root}/src/app/clusters/network-commissioning/network-commissioning.cpp", "${chip_root}/src/app/clusters/on-off-server/on-off.cpp", "${chip_root}/src/app/reporting/reporting-default-configuration.cpp", "${chip_root}/src/app/reporting/reporting.cpp", diff --git a/examples/lock-app/lock-common/gen/CHIPClustersObjc.h b/examples/lock-app/lock-common/gen/CHIPClustersObjc.h index acd8add7e83adf..786c7dc995f4af 100644 --- a/examples/lock-app/lock-common/gen/CHIPClustersObjc.h +++ b/examples/lock-app/lock-common/gen/CHIPClustersObjc.h @@ -65,6 +65,52 @@ NS_ASSUME_NONNULL_BEGIN @end +/** + * Cluster Network Commissioning + * + */ +@interface CHIPNetworkCommissioning : CHIPCluster + +- (void)addThreadNetwork:(NSData *)operationalDataset + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)addWiFiNetwork:(NSData *)ssid + credentials:(NSData *)credentials + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)disableNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)enableNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)getLastNetworkCommissioningResult:(uint32_t)timeoutMs completionHandler:(ResponseHandler)completionHandler; +- (void)removeNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)scanNetworks:(NSData *)ssid + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)updateThreadNetwork:(NSData *)operationalDataset + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)updateWiFiNetwork:(NSData *)ssid + credentials:(NSData *)credentials + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; + +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler; + +@end + /** * Cluster On/off * diff --git a/examples/lock-app/lock-common/gen/CHIPClustersObjc.mm b/examples/lock-app/lock-common/gen/CHIPClustersObjc.mm index 5c3d869c670646..ce5be43ca8396d 100644 --- a/examples/lock-app/lock-common/gen/CHIPClustersObjc.mm +++ b/examples/lock-app/lock-common/gen/CHIPClustersObjc.mm @@ -731,6 +731,285 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler @end +@interface CHIPNetworkCommissioning () +@property (readonly) Controller::NetworkCommissioningCluster cppCluster; +@end + +@implementation CHIPNetworkCommissioning + +- (Controller::ClusterBase *)getCluster +{ + return &_cppCluster; +} + +- (void)addThreadNetwork:(NSData *)operationalDataset + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterAddThreadNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterAddThreadNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.AddThreadNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) operationalDataset.bytes, operationalDataset.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)addWiFiNetwork:(NSData *)ssid + credentials:(NSData *)credentials + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterAddWiFiNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterAddWiFiNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.AddWiFiNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), + chip::ByteSpan((const uint8_t *) credentials.bytes, credentials.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)disableNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterDisableNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterDisableNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.DisableNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)enableNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterEnableNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterEnableNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.EnableNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)getLastNetworkCommissioningResult:(uint32_t)timeoutMs completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.GetLastNetworkCommissioningResult(onSuccess->Cancel(), onFailure->Cancel(), timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)removeNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterRemoveNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterRemoveNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.RemoveNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)scanNetworks:(NSData *)ssid + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterScanNetworksResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterScanNetworksResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ScanNetworks( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)updateThreadNetwork:(NSData *)operationalDataset + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterUpdateThreadNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterUpdateThreadNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.UpdateThreadNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) operationalDataset.bytes, operationalDataset.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)updateWiFiNetwork:(NSData *)ssid + credentials:(NSData *)credentials + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterUpdateWiFiNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterUpdateWiFiNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.UpdateWiFiNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), + chip::ByteSpan((const uint8_t *) credentials.bytes, credentials.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +@end + @interface CHIPOnOff () @property (readonly) Controller::OnOffCluster cppCluster; @end diff --git a/examples/lock-app/lock-common/gen/IMClusterCommandHandler.cpp b/examples/lock-app/lock-common/gen/IMClusterCommandHandler.cpp index 72eaae70a65a25..a6156f96242f1b 100644 --- a/examples/lock-app/lock-common/gen/IMClusterCommandHandler.cpp +++ b/examples/lock-app/lock-common/gen/IMClusterCommandHandler.cpp @@ -39,6 +39,335 @@ namespace app { namespace clusters { +namespace NetworkCommissioning { + +void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv) +{ + { + switch (commandId) + { + case ZCL_ADD_THREAD_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * operationalDataset; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(operationalDataset); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterAddThreadNetworkCallback(const_cast(operationalDataset), breadcrumb, + timeoutMs); + break; + } + case ZCL_ADD_WI_FI_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * ssid; + const uint8_t * credentials; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(ssid); + break; + case 1: + TLVError = dataTlv.GetDataPtr(credentials); + break; + case 2: + TLVError = dataTlv.Get(breadcrumb); + break; + case 3: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterAddWiFiNetworkCallback(const_cast(ssid), + const_cast(credentials), breadcrumb, timeoutMs); + break; + } + case ZCL_DISABLE_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * networkID; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(networkID); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterDisableNetworkCallback(const_cast(networkID), breadcrumb, timeoutMs); + break; + } + case ZCL_ENABLE_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * networkID; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(networkID); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterEnableNetworkCallback(const_cast(networkID), breadcrumb, timeoutMs); + break; + } + case ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterGetLastNetworkCommissioningResultCallback(timeoutMs); + break; + } + case ZCL_REMOVE_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * NetworkID; + uint64_t Breadcrumb; + uint32_t TimeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(NetworkID); + break; + case 1: + TLVError = dataTlv.Get(Breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(TimeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterRemoveNetworkCallback(const_cast(NetworkID), Breadcrumb, TimeoutMs); + break; + } + case ZCL_SCAN_NETWORKS_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * ssid; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(ssid); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterScanNetworksCallback(const_cast(ssid), breadcrumb, timeoutMs); + break; + } + case ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * operationalDataset; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(operationalDataset); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterUpdateThreadNetworkCallback(const_cast(operationalDataset), breadcrumb, + timeoutMs); + break; + } + case ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * ssid; + const uint8_t * credentials; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(ssid); + break; + case 1: + TLVError = dataTlv.GetDataPtr(credentials); + break; + case 2: + TLVError = dataTlv.Get(breadcrumb); + break; + case 3: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterUpdateWiFiNetworkCallback(const_cast(ssid), + const_cast(credentials), breadcrumb, timeoutMs); + break; + } + default: { + // Unrecognized command ID, error status will apply. + // TODO: Encode response for command not found + ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_NETWORK_COMMISSIONING_CLUSTER_ID); + break; + } + } + } +} + +} // namespace NetworkCommissioning + namespace OnOff { void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv) @@ -83,6 +412,9 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId); switch (aClusterId) { + case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID: + clusters::NetworkCommissioning::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; case ZCL_ON_OFF_CLUSTER_ID: clusters::OnOff::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; diff --git a/examples/lock-app/lock-common/gen/attribute-id.h b/examples/lock-app/lock-common/gen/attribute-id.h index 8c8757f826ca7f..72a0198e2f97be 100644 --- a/examples/lock-app/lock-common/gen/attribute-id.h +++ b/examples/lock-app/lock-common/gen/attribute-id.h @@ -391,6 +391,12 @@ #define ZCL_FABRIC_ID_ATTRIBUTE_ID (0x0000) #define ZCL_BREADCRUMB_ATTRIBUTE_ID (0x0001) +// Attribute ids for cluster: Network Commissioning + +// Client attributes + +// Server attributes + // Attribute ids for cluster: Shade Configuration // Client attributes @@ -4084,12 +4090,6 @@ // Server attributes -// Attribute ids for cluster: Network Commissioning - -// Client attributes - -// Server attributes - // Attribute ids for cluster: Binding // Client attributes diff --git a/examples/lock-app/lock-common/gen/call-command-handler.cpp b/examples/lock-app/lock-common/gen/call-command-handler.cpp index 730d7b2f96ff87..9da037ea070e68 100644 --- a/examples/lock-app/lock-common/gen/call-command-handler.cpp +++ b/examples/lock-app/lock-common/gen/call-command-handler.cpp @@ -29,6 +29,7 @@ using namespace chip; EmberAfStatus emberAfBasicClusterServerCommandParse(EmberAfClusterCommand * cmd); +EmberAfStatus emberAfNetworkCommissioningClusterServerCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfOnOffClusterServerCommandParse(EmberAfClusterCommand * cmd); static EmberAfStatus status(bool wasHandled, bool clusterExists, bool mfgSpecific) @@ -74,6 +75,9 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd) // No commands are enabled for cluster Basic result = status(false, true, cmd->mfgSpecific); break; + case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID: + result = emberAfNetworkCommissioningClusterServerCommandParse(cmd); + break; case ZCL_ON_OFF_CLUSTER_ID: result = emberAfOnOffClusterServerCommandParse(cmd); break; @@ -87,6 +91,265 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd) // Cluster specific command parsing +EmberAfStatus emberAfNetworkCommissioningClusterServerCommandParse(EmberAfClusterCommand * cmd) +{ + bool wasHandled = false; + + if (!cmd->mfgSpecific) + { + switch (cmd->commandId) + { + case ZCL_ADD_THREAD_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * operationalDataset; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + operationalDataset = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(operationalDataset) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterAddThreadNetworkCallback(operationalDataset, breadcrumb, timeoutMs); + break; + } + case ZCL_ADD_WI_FI_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * ssid; + uint8_t * credentials; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + ssid = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(ssid) + 1u); + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + credentials = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(credentials) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterAddWiFiNetworkCallback(ssid, credentials, breadcrumb, timeoutMs); + break; + } + case ZCL_DISABLE_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * networkID; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + networkID = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(networkID) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterDisableNetworkCallback(networkID, breadcrumb, timeoutMs); + break; + } + case ZCL_ENABLE_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * networkID; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + networkID = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(networkID) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterEnableNetworkCallback(networkID, breadcrumb, timeoutMs); + break; + } + case ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterGetLastNetworkCommissioningResultCallback(timeoutMs); + break; + } + case ZCL_REMOVE_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * NetworkID; + uint64_t Breadcrumb; + uint32_t TimeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + NetworkID = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(NetworkID) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + Breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + TimeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterRemoveNetworkCallback(NetworkID, Breadcrumb, TimeoutMs); + break; + } + case ZCL_SCAN_NETWORKS_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * ssid; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + ssid = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(ssid) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterScanNetworksCallback(ssid, breadcrumb, timeoutMs); + break; + } + case ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * operationalDataset; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + operationalDataset = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(operationalDataset) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterUpdateThreadNetworkCallback(operationalDataset, breadcrumb, timeoutMs); + break; + } + case ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * ssid; + uint8_t * credentials; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + ssid = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(ssid) + 1u); + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + credentials = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(credentials) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterUpdateWiFiNetworkCallback(ssid, credentials, breadcrumb, timeoutMs); + break; + } + default: { + // Unrecognized command ID, error status will apply. + break; + } + } + } + return status(wasHandled, true, cmd->mfgSpecific); +} EmberAfStatus emberAfOnOffClusterServerCommandParse(EmberAfClusterCommand * cmd) { bool wasHandled = false; diff --git a/examples/lock-app/lock-common/gen/callback-stub.cpp b/examples/lock-app/lock-common/gen/callback-stub.cpp index 3c6022fe4e04d8..fad53a93a44359 100644 --- a/examples/lock-app/lock-common/gen/callback-stub.cpp +++ b/examples/lock-app/lock-common/gen/callback-stub.cpp @@ -30,6 +30,9 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) case ZCL_BASIC_CLUSTER_ID: emberAfBasicClusterInitCallback(endpoint); break; + case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID: + emberAfNetworkCommissioningClusterInitCallback(endpoint); + break; case ZCL_ON_OFF_CLUSTER_ID: emberAfOnOffClusterInitCallback(endpoint); break; @@ -44,6 +47,11 @@ void __attribute__((weak)) emberAfBasicClusterInitCallback(EndpointId endpoint) // To prevent warning (void) endpoint; } +void __attribute__((weak)) emberAfNetworkCommissioningClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} void __attribute__((weak)) emberAfOnOffClusterInitCallback(EndpointId endpoint) { // To prevent warning diff --git a/examples/lock-app/lock-common/gen/callback.h b/examples/lock-app/lock-common/gen/callback.h index 367f192b93dac0..4f0364b30405b4 100644 --- a/examples/lock-app/lock-common/gen/callback.h +++ b/examples/lock-app/lock-common/gen/callback.h @@ -45,6 +45,14 @@ void emberAfClusterInitCallback(chip::EndpointId endpoint, chip::ClusterId clust */ void emberAfBasicClusterInitCallback(chip::EndpointId endpoint); +/** @brief Network Commissioning Cluster Init + * + * Cluster Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfNetworkCommissioningClusterInitCallback(chip::EndpointId endpoint); + /** @brief On/off Cluster Init * * Cluster Init @@ -123,6 +131,77 @@ EmberAfStatus emberAfBasicClusterServerPreAttributeChangedCallback(chip::Endpoin */ void emberAfBasicClusterServerTickCallback(chip::EndpointId endpoint); +// +// Network Commissioning Cluster server +// + +/** @brief Network Commissioning Cluster Server Init + * + * Server Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfNetworkCommissioningClusterServerInitCallback(chip::EndpointId endpoint); + +/** @brief Network Commissioning Cluster Server Attribute Changed + * + * Server Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + */ +void emberAfNetworkCommissioningClusterServerAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId); + +/** @brief Network Commissioning Cluster Server Manufacturer Specific Attribute Changed + * + * Server Manufacturer Specific Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + * @param manufacturerCode Manufacturer Code of the attribute that changed + */ +void emberAfNetworkCommissioningClusterServerManufacturerSpecificAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + uint16_t manufacturerCode); + +/** @brief Network Commissioning Cluster Server Message Sent + * + * Server Message Sent + * + * @param type The type of message sent + * @param indexOrDestination The destination or address to which the message was sent + * @param apsFrame The APS frame for the message + * @param msgLen The length of the message + * @param message The message that was sent + * @param status The status of the sent message + */ +void emberAfNetworkCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); + +/** @brief Network Commissioning Cluster Server Pre Attribute Changed + * + * server Pre Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute to be changed + * @param attributeType Attribute type + * @param size Attribute size + * @param value Attribute value + */ +EmberAfStatus emberAfNetworkCommissioningClusterServerPreAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + EmberAfAttributeType attributeType, uint8_t size, + uint8_t * value); + +/** @brief Network Commissioning Cluster Server Tick + * + * server Tick + * + * @param endpoint Endpoint that is being served + */ +void emberAfNetworkCommissioningClusterServerTickCallback(chip::EndpointId endpoint); + // // On/off Cluster server // @@ -193,6 +272,91 @@ void emberAfOnOffClusterServerTickCallback(chip::EndpointId endpoint); // Cluster Commands Callback +/** + * @brief Network Commissioning Cluster AddThreadNetwork Command callback + * @param operationalDataset + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterAddThreadNetworkCallback(uint8_t * operationalDataset, uint64_t breadcrumb, + uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster AddWiFiNetwork Command callback + * @param ssid + * @param credentials + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterAddWiFiNetworkCallback(uint8_t * ssid, uint8_t * credentials, uint64_t breadcrumb, + uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster DisableNetwork Command callback + * @param networkID + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterDisableNetworkCallback(uint8_t * networkID, uint64_t breadcrumb, uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster EnableNetwork Command callback + * @param networkID + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterEnableNetworkCallback(uint8_t * networkID, uint64_t breadcrumb, uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster GetLastNetworkCommissioningResult Command callback + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterGetLastNetworkCommissioningResultCallback(uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster RemoveNetwork Command callback + * @param networkID + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterRemoveNetworkCallback(uint8_t * NetworkID, uint64_t Breadcrumb, uint32_t TimeoutMs); + +/** + * @brief Network Commissioning Cluster ScanNetworks Command callback + * @param ssid + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterScanNetworksCallback(uint8_t * ssid, uint64_t breadcrumb, uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster UpdateThreadNetwork Command callback + * @param operationalDataset + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterUpdateThreadNetworkCallback(uint8_t * operationalDataset, uint64_t breadcrumb, + uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster UpdateWiFiNetwork Command callback + * @param ssid + * @param credentials + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterUpdateWiFiNetworkCallback(uint8_t * ssid, uint8_t * credentials, uint64_t breadcrumb, + uint32_t timeoutMs); + /** * @brief On/off Cluster Off Command callback */ diff --git a/examples/lock-app/lock-common/gen/client-command-macro.h b/examples/lock-app/lock-common/gen/client-command-macro.h index f72c96f951dcff..79d1e159594a4a 100644 --- a/examples/lock-app/lock-common/gen/client-command-macro.h +++ b/examples/lock-app/lock-common/gen/client-command-macro.h @@ -1911,6 +1911,225 @@ \ ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); +/** @brief Command description for ScanNetworks + * + * Command: ScanNetworks + * @param ssid OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterScanNetworks(ssid, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SCAN_NETWORKS_COMMAND_ID, "uuu", ssid, breadcrumb, timeoutMs); + +/** @brief Command description for ScanNetworksResponse + * + * Command: ScanNetworksResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + * @param wifiScanResults WiFiInterfaceScanResult [] + * @param wifiScanResultsLen int + * @param threadScanResults ThreadInterfaceScanResult [] + * @param threadScanResultsLen int + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterScanNetworksResponse(errorCode, debugText, wifiScanResults, wifiScanResultsLen, threadScanResults, \ + threadScanResultsLen) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID, "uubb", errorCode, debugText, wifiScanResults, \ + wifiScanResultsLen, threadScanResults, threadScanResultsLen); + +/** @brief Command description for AddWiFiNetwork + * + * Command: AddWiFiNetwork + * @param ssid OCTET_STRING + * @param credentials OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); + +/** @brief Command description for AddWiFiNetworkResponse + * + * Command: AddWiFiNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddWiFiNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for UpdateWiFiNetwork + * + * Command: UpdateWiFiNetwork + * @param ssid OCTET_STRING + * @param credentials OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); + +/** @brief Command description for UpdateWiFiNetworkResponse + * + * Command: UpdateWiFiNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateWiFiNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for AddThreadNetwork + * + * Command: AddThreadNetwork + * @param operationalDataset OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); + +/** @brief Command description for AddThreadNetworkResponse + * + * Command: AddThreadNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddThreadNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for UpdateThreadNetwork + * + * Command: UpdateThreadNetwork + * @param operationalDataset OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); + +/** @brief Command description for UpdateThreadNetworkResponse + * + * Command: UpdateThreadNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateThreadNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for RemoveNetwork + * + * Command: RemoveNetwork + * @param NetworkID OCTET_STRING + * @param Breadcrumb INT64U + * @param TimeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterRemoveNetwork(NetworkID, Breadcrumb, TimeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_NETWORK_COMMAND_ID, "uuu", NetworkID, Breadcrumb, TimeoutMs); + +/** @brief Command description for RemoveNetworkResponse + * + * Command: RemoveNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterRemoveNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for EnableNetwork + * + * Command: EnableNetwork + * @param networkID OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterEnableNetwork(networkID, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ENABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); + +/** @brief Command description for EnableNetworkResponse + * + * Command: EnableNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterEnableNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for DisableNetwork + * + * Command: DisableNetwork + * @param networkID OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterDisableNetwork(networkID, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_DISABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); + +/** @brief Command description for DisableNetworkResponse + * + * Command: DisableNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterDisableNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for GetLastNetworkCommissioningResult + * + * Command: GetLastNetworkCommissioningResult + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterGetLastNetworkCommissioningResult(timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID, "u", timeoutMs); + /** @brief Command description for LockDoor * * Command: LockDoor @@ -5783,225 +6002,6 @@ ZCL_GET_ENDPOINT_LIST_REQUEST_COMMAND_ID, "uuuub", startIndex, total, startIndex, count, \ endpointInformationRecordList, endpointInformationRecordListLen); -/** @brief Command description for ScanNetworks - * - * Command: ScanNetworks - * @param ssid OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterScanNetworks(ssid, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_SCAN_NETWORKS_COMMAND_ID, "uuu", ssid, breadcrumb, timeoutMs); - -/** @brief Command description for ScanNetworksResponse - * - * Command: ScanNetworksResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - * @param wifiScanResults WiFiInterfaceScanResult [] - * @param wifiScanResultsLen int - * @param threadScanResults ThreadInterfaceScanResult [] - * @param threadScanResultsLen int - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterScanNetworksResponse(errorCode, debugText, wifiScanResults, wifiScanResultsLen, threadScanResults, \ - threadScanResultsLen) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID, "uubb", errorCode, debugText, wifiScanResults, \ - wifiScanResultsLen, threadScanResults, threadScanResultsLen); - -/** @brief Command description for AddWiFiNetwork - * - * Command: AddWiFiNetwork - * @param ssid OCTET_STRING - * @param credentials OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); - -/** @brief Command description for AddWiFiNetworkResponse - * - * Command: AddWiFiNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddWiFiNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for UpdateWiFiNetwork - * - * Command: UpdateWiFiNetwork - * @param ssid OCTET_STRING - * @param credentials OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); - -/** @brief Command description for UpdateWiFiNetworkResponse - * - * Command: UpdateWiFiNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateWiFiNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for AddThreadNetwork - * - * Command: AddThreadNetwork - * @param operationalDataset OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); - -/** @brief Command description for AddThreadNetworkResponse - * - * Command: AddThreadNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddThreadNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for UpdateThreadNetwork - * - * Command: UpdateThreadNetwork - * @param operationalDataset OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); - -/** @brief Command description for UpdateThreadNetworkResponse - * - * Command: UpdateThreadNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateThreadNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for RemoveNetwork - * - * Command: RemoveNetwork - * @param NetworkID OCTET_STRING - * @param Breadcrumb INT64U - * @param TimeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterRemoveNetwork(NetworkID, Breadcrumb, TimeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_REMOVE_NETWORK_COMMAND_ID, "uuu", NetworkID, Breadcrumb, TimeoutMs); - -/** @brief Command description for RemoveNetworkResponse - * - * Command: RemoveNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterRemoveNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for EnableNetwork - * - * Command: EnableNetwork - * @param networkID OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterEnableNetwork(networkID, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ENABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); - -/** @brief Command description for EnableNetworkResponse - * - * Command: EnableNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterEnableNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for DisableNetwork - * - * Command: DisableNetwork - * @param networkID OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterDisableNetwork(networkID, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_DISABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); - -/** @brief Command description for DisableNetworkResponse - * - * Command: DisableNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterDisableNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for GetLastNetworkCommissioningResult - * - * Command: GetLastNetworkCommissioningResult - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterGetLastNetworkCommissioningResult(timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID, "u", timeoutMs); - /** @brief Command description for Bind * * Command: Bind diff --git a/examples/lock-app/lock-common/gen/cluster-id.h b/examples/lock-app/lock-common/gen/cluster-id.h index d77da915200ab4..add8f83d188cf8 100644 --- a/examples/lock-app/lock-common/gen/cluster-id.h +++ b/examples/lock-app/lock-common/gen/cluster-id.h @@ -86,6 +86,9 @@ // Definitions for cluster: General Commissioning #define ZCL_GENERAL_COMMISSIONING_CLUSTER_ID (0x0030) +// Definitions for cluster: Network Commissioning +#define ZCL_NETWORK_COMMISSIONING_CLUSTER_ID (0x0031) + // Definitions for cluster: Shade Configuration #define ZCL_SHADE_CONFIG_CLUSTER_ID (0x0100) @@ -341,9 +344,6 @@ // Definitions for cluster: ZLL Commissioning #define ZCL_ZLL_COMMISSIONING_CLUSTER_ID (0x1000) -// Definitions for cluster: Network Commissioning -#define ZCL_NETWORK_COMMISSIONING_CLUSTER_ID (0xAAAA) - // Definitions for cluster: Binding #define ZCL_BINDING_CLUSTER_ID (0xF000) diff --git a/examples/lock-app/lock-common/gen/command-id.h b/examples/lock-app/lock-common/gen/command-id.h index adc2b1c6f32733..864943b5727fcd 100644 --- a/examples/lock-app/lock-common/gen/command-id.h +++ b/examples/lock-app/lock-common/gen/command-id.h @@ -238,6 +238,25 @@ #define ZCL_COMMISSIONING_COMPLETE_COMMAND_ID (0x06) #define ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID (0x07) +// Commands for cluster: Network Commissioning +#define ZCL_SCAN_NETWORKS_COMMAND_ID (0x00) +#define ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID (0x01) +#define ZCL_ADD_WI_FI_NETWORK_COMMAND_ID (0x02) +#define ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x03) +#define ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID (0x04) +#define ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x05) +#define ZCL_ADD_THREAD_NETWORK_COMMAND_ID (0x06) +#define ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x07) +#define ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID (0x08) +#define ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x09) +#define ZCL_REMOVE_NETWORK_COMMAND_ID (0x0A) +#define ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID (0x0B) +#define ZCL_ENABLE_NETWORK_COMMAND_ID (0x0C) +#define ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID (0x0D) +#define ZCL_DISABLE_NETWORK_COMMAND_ID (0x0E) +#define ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID (0x0F) +#define ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID (0x10) + // Commands for cluster: Door Lock #define ZCL_LOCK_DOOR_COMMAND_ID (0x00) #define ZCL_LOCK_DOOR_RESPONSE_COMMAND_ID (0x00) @@ -700,25 +719,6 @@ #define ZCL_GET_ENDPOINT_LIST_REQUEST_COMMAND_ID (0x42) #define ZCL_GET_ENDPOINT_LIST_RESPONSE_COMMAND_ID (0x42) -// Commands for cluster: Network Commissioning -#define ZCL_SCAN_NETWORKS_COMMAND_ID (0x00) -#define ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID (0x01) -#define ZCL_ADD_WI_FI_NETWORK_COMMAND_ID (0x02) -#define ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x03) -#define ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID (0x04) -#define ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x05) -#define ZCL_ADD_THREAD_NETWORK_COMMAND_ID (0x06) -#define ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x07) -#define ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID (0x08) -#define ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x09) -#define ZCL_REMOVE_NETWORK_COMMAND_ID (0x0A) -#define ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID (0x0B) -#define ZCL_ENABLE_NETWORK_COMMAND_ID (0x0C) -#define ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID (0x0D) -#define ZCL_DISABLE_NETWORK_COMMAND_ID (0x0E) -#define ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID (0x0F) -#define ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID (0x10) - // Commands for cluster: Binding #define ZCL_BIND_COMMAND_ID (0x00) #define ZCL_UNBIND_COMMAND_ID (0x01) diff --git a/examples/lock-app/lock-common/gen/endpoint_config.h b/examples/lock-app/lock-common/gen/endpoint_config.h index 07daefdf20ddf5..ea49715c508385 100644 --- a/examples/lock-app/lock-common/gen/endpoint_config.h +++ b/examples/lock-app/lock-common/gen/endpoint_config.h @@ -100,7 +100,7 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 14 +#define GENERATED_ATTRIBUTE_COUNT 15 #define GENERATED_ATTRIBUTES \ { \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 2 } }, /* On/off (server): cluster revision */ \ @@ -140,7 +140,8 @@ }, /* Basic (server): SoftwareVersion */ \ { \ 0x000A, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(180) } \ - }, /* Basic (server): SoftwareVersionString */ \ + }, /* Basic (server): SoftwareVersionString */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Network Commissioning (server): cluster revision */ \ } // This is an array of EmberAfCluster structures. @@ -153,7 +154,7 @@ }; #define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask -#define GENERATED_CLUSTER_COUNT 2 +#define GENERATED_CLUSTER_COUNT 3 #define GENERATED_CLUSTERS \ { \ { \ @@ -167,6 +168,9 @@ { \ 0x0028, ZAP_ATTRIBUTE_INDEX(2), 12, 254, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Basic (server) */ \ + { \ + 0x0031, ZAP_ATTRIBUTE_INDEX(14), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 1, Cluster: Network Commissioning (server) */ \ } #define ZAP_CLUSTER_INDEX(index) ((EmberAfCluster *) (&generatedClusters[index])) @@ -174,7 +178,7 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 2, 257 }, \ + { ZAP_CLUSTER_INDEX(0), 3, 259 }, \ } // Largest attribute size is needed for various buffers @@ -184,7 +188,7 @@ #define ATTRIBUTE_SINGLETONS_SIZE (254) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (257) +#define ATTRIBUTE_MAX_SIZE (259) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (1) @@ -228,7 +232,7 @@ // Array of EmberAfCommandMetadata structs. #define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask -#define EMBER_AF_GENERATED_COMMAND_COUNT (6) +#define EMBER_AF_GENERATED_COMMAND_COUNT (23) #define GENERATED_COMMANDS \ { \ { 0x0006, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* On/off (server): Off */ \ @@ -237,6 +241,24 @@ { 0x0028, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): StartUp */ \ { 0x0028, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): ShutDown */ \ { 0x0028, 0x02, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): Leave */ \ + { 0x0031, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): ScanNetworks */ \ + { 0x0031, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): ScanNetworksResponse */ \ + { 0x0031, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): AddWiFiNetwork */ \ + { 0x0031, 0x03, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): AddWiFiNetworkResponse */ \ + { 0x0031, 0x04, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): UpdateWiFiNetwork */ \ + { 0x0031, 0x05, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): UpdateWiFiNetworkResponse */ \ + { 0x0031, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): AddThreadNetwork */ \ + { 0x0031, 0x07, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): AddThreadNetworkResponse */ \ + { 0x0031, 0x08, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): UpdateThreadNetwork */ \ + { 0x0031, 0x09, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): UpdateThreadNetworkResponse */ \ + { 0x0031, 0x0A, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): RemoveNetwork */ \ + { 0x0031, 0x0B, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): RemoveNetworkResponse */ \ + { 0x0031, 0x0C, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): EnableNetwork */ \ + { 0x0031, 0x0D, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): EnableNetworkResponse */ \ + { 0x0031, 0x0E, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): DisableNetwork */ \ + { 0x0031, 0x0F, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): DisableNetworkResponse */ \ + { 0x0031, 0x10, \ + ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): GetLastNetworkCommissioningResult */ \ } // Array of EmberAfManufacturerCodeEntry structures for commands. diff --git a/examples/lock-app/lock-common/gen/gen_config.h b/examples/lock-app/lock-common/gen/gen_config.h index d4f918b37c702f..48ae4c3873f632 100644 --- a/examples/lock-app/lock-common/gen/gen_config.h +++ b/examples/lock-app/lock-common/gen/gen_config.h @@ -30,6 +30,7 @@ /**** Cluster endpoint counts ****/ #define EMBER_AF_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_NETWORK_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_ON_OFF_CLUSTER_SERVER_ENDPOINT_COUNT (1) /**** Cluster Plugins ****/ @@ -39,6 +40,11 @@ #define EMBER_AF_PLUGIN_BASIC_SERVER #define EMBER_AF_PLUGIN_BASIC +// Use this macro to check if the server side of the Network Commissioning cluster is included +#define ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING_SERVER +#define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING + // Use this macro to check if the server side of the On/off cluster is included #define ZCL_USING_ON_OFF_CLUSTER_SERVER #define EMBER_AF_PLUGIN_ON_OFF_SERVER diff --git a/examples/lock-app/lock-common/gen/print-cluster.h b/examples/lock-app/lock-common/gen/print-cluster.h index bd08d38a581506..8c737e93fea79c 100644 --- a/examples/lock-app/lock-common/gen/print-cluster.h +++ b/examples/lock-app/lock-common/gen/print-cluster.h @@ -156,6 +156,12 @@ #define CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER #endif +#if defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER { ZCL_NETWORK_COMMISSIONING_CLUSTER_ID, 49, "Network Commissioning" }, +#else +#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER +#endif + #if defined(ZCL_USING_SHADE_CONFIG_CLUSTER_SERVER) || defined(ZCL_USING_SHADE_CONFIG_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER { ZCL_SHADE_CONFIG_CLUSTER_ID, 256, "Shade Configuration" }, #else @@ -734,12 +740,6 @@ #define CHIP_PRINTCLUSTER_ZLL_COMMISSIONING_CLUSTER #endif -#if defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_CLIENT) -#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER { ZCL_NETWORK_COMMISSIONING_CLUSTER_ID, 43690, "Network Commissioning" }, -#else -#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER -#endif - #if defined(ZCL_USING_BINDING_CLUSTER_SERVER) || defined(ZCL_USING_BINDING_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_BINDING_CLUSTER { ZCL_BINDING_CLUSTER_ID, 61440, "Binding" }, #else @@ -812,6 +812,7 @@ CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER \ CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER \ + CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DOOR_LOCK_CLUSTER \ CHIP_PRINTCLUSTER_WINDOW_COVERING_CLUSTER \ @@ -897,7 +898,6 @@ CHIP_PRINTCLUSTER_ELECTRICAL_MEASUREMENT_CLUSTER \ CHIP_PRINTCLUSTER_DIAGNOSTICS_CLUSTER \ CHIP_PRINTCLUSTER_ZLL_COMMISSIONING_CLUSTER \ - CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_BINDING_CLUSTER \ CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER \ CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER \ diff --git a/examples/lock-app/lock-common/lock-app.zap b/examples/lock-app/lock-common/lock-app.zap index 807263df93c371..6b9c6e7f508122 100644 --- a/examples/lock-app/lock-common/lock-app.zap +++ b/examples/lock-app/lock-common/lock-app.zap @@ -1,5 +1,5 @@ { - "writeTime": "Tue Mar 02 2021 13:36:08 GMT-0500 (Eastern Standard Time)", + "writeTime": "Fri Mar 12 2021 15:19:34 GMT+0800 (China Standard Time)", "featureLevel": 11, "creator": "zap", "keyValuePairs": [ @@ -152,6 +152,7 @@ "define": "DEVICE_TEMP_CLUSTER", "side": "server", "enabled": 0, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -183,8 +184,7 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [] + ] }, { "name": "Identify", @@ -193,6 +193,23 @@ "define": "IDENTIFY_CLUSTER", "side": "client", "enabled": 0, + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "2", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], "commands": [ { "name": "Identify", @@ -210,23 +227,6 @@ "incoming": 1, "outgoing": 0 } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "2", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } ] }, { @@ -719,6 +719,7 @@ "define": "ON_OFF_CLUSTER", "side": "server", "enabled": 1, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -750,8 +751,7 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [] + ] }, { "name": "Alarms", @@ -760,23 +760,6 @@ "define": "ALARM_CLUSTER", "side": "client", "enabled": 0, - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0001", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ], "commands": [ { "name": "ResetAlarm", @@ -794,6 +777,23 @@ "incoming": 1, "outgoing": 0 } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } ] }, { @@ -1520,6 +1520,196 @@ } ] }, + { + "name": "Network Commissioning", + "code": 49, + "mfgCode": null, + "define": "NETWORK_COMMISSIONING_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "ScanNetworks", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "AddWiFiNetwork", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "UpdateWiFiNetwork", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "AddThreadNetwork", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "UpdateThreadNetwork", + "code": 8, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveNetwork", + "code": 10, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "EnableNetwork", + "code": 12, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "DisableNetwork", + "code": 14, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetLastNetworkCommissioningResult", + "code": 16, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Network Commissioning", + "code": 49, + "mfgCode": null, + "define": "NETWORK_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "ScanNetworksResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "AddWiFiNetworkResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "UpdateWiFiNetworkResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "AddThreadNetworkResponse", + "code": 7, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "UpdateThreadNetworkResponse", + "code": 9, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RemoveNetworkResponse", + "code": 11, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "EnableNetworkResponse", + "code": 13, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "DisableNetworkResponse", + "code": 15, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, { "name": "Occupancy Sensing", "code": 1030, @@ -1553,6 +1743,7 @@ "define": "OCCUPANCY_SENSING_CLUSTER", "side": "server", "enabled": 0, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -1614,8 +1805,7 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [] + ] } ] } diff --git a/examples/lock-app/nrfconnect/CMakeLists.txt b/examples/lock-app/nrfconnect/CMakeLists.txt index 3b51c837dc18d4..57c8ea827283b3 100644 --- a/examples/lock-app/nrfconnect/CMakeLists.txt +++ b/examples/lock-app/nrfconnect/CMakeLists.txt @@ -32,6 +32,7 @@ project(chip-nrfconnect-lock-example) target_include_directories(app PRIVATE main/include + ${CHIP_ROOT}/src/app ${LOCK_COMMON} ${NRFCONNECT_COMMON}/util/include ${NRFCONNECT_COMMON}/app/include) @@ -64,4 +65,6 @@ target_sources(app PRIVATE ${CHIP_ROOT}/src/app/util/process-global-message.cpp ${CHIP_ROOT}/src/app/util/util.cpp ${CHIP_ROOT}/src/app/clusters/bindings/bindings.cpp + ${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning-ember.cpp + ${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning.cpp ${CHIP_ROOT}/src/app/clusters/on-off-server/on-off.cpp) diff --git a/examples/temperature-measurement-app/esp32/main/component.mk b/examples/temperature-measurement-app/esp32/main/component.mk index 5edc12fa3c5f2b..58501eb3ccceb1 100644 --- a/examples/temperature-measurement-app/esp32/main/component.mk +++ b/examples/temperature-measurement-app/esp32/main/component.mk @@ -29,6 +29,7 @@ COMPONENT_SRCDIRS := ../third_party/connectedhomeip/src/app/reporting \ ../third_party/connectedhomeip/src/app/clusters/basic \ ../third_party/connectedhomeip/src/app/clusters/bindings \ + ../third_party/connectedhomeip/src/app/clusters/network-commissioning \ ../third_party/connectedhomeip/src/app/clusters/temperature-measurement-server \ diff --git a/examples/temperature-measurement-app/esp32/main/gen/CHIPClustersObjc.h b/examples/temperature-measurement-app/esp32/main/gen/CHIPClustersObjc.h index 29ae867de27ec3..bde4d17081f57b 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/CHIPClustersObjc.h +++ b/examples/temperature-measurement-app/esp32/main/gen/CHIPClustersObjc.h @@ -65,6 +65,52 @@ NS_ASSUME_NONNULL_BEGIN @end +/** + * Cluster Network Commissioning + * + */ +@interface CHIPNetworkCommissioning : CHIPCluster + +- (void)addThreadNetwork:(NSData *)operationalDataset + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)addWiFiNetwork:(NSData *)ssid + credentials:(NSData *)credentials + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)disableNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)enableNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)getLastNetworkCommissioningResult:(uint32_t)timeoutMs completionHandler:(ResponseHandler)completionHandler; +- (void)removeNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)scanNetworks:(NSData *)ssid + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)updateThreadNetwork:(NSData *)operationalDataset + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)updateWiFiNetwork:(NSData *)ssid + credentials:(NSData *)credentials + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; + +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler; + +@end + /** * Cluster Temperature Measurement * diff --git a/examples/temperature-measurement-app/esp32/main/gen/CHIPClustersObjc.mm b/examples/temperature-measurement-app/esp32/main/gen/CHIPClustersObjc.mm index ab7e6960244f0e..23ccc4a8f75ebe 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/CHIPClustersObjc.mm +++ b/examples/temperature-measurement-app/esp32/main/gen/CHIPClustersObjc.mm @@ -731,6 +731,285 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler @end +@interface CHIPNetworkCommissioning () +@property (readonly) Controller::NetworkCommissioningCluster cppCluster; +@end + +@implementation CHIPNetworkCommissioning + +- (Controller::ClusterBase *)getCluster +{ + return &_cppCluster; +} + +- (void)addThreadNetwork:(NSData *)operationalDataset + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterAddThreadNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterAddThreadNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.AddThreadNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) operationalDataset.bytes, operationalDataset.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)addWiFiNetwork:(NSData *)ssid + credentials:(NSData *)credentials + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterAddWiFiNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterAddWiFiNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.AddWiFiNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), + chip::ByteSpan((const uint8_t *) credentials.bytes, credentials.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)disableNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterDisableNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterDisableNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.DisableNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)enableNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterEnableNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterEnableNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.EnableNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)getLastNetworkCommissioningResult:(uint32_t)timeoutMs completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.GetLastNetworkCommissioningResult(onSuccess->Cancel(), onFailure->Cancel(), timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)removeNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterRemoveNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterRemoveNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.RemoveNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)scanNetworks:(NSData *)ssid + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterScanNetworksResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterScanNetworksResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ScanNetworks( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)updateThreadNetwork:(NSData *)operationalDataset + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterUpdateThreadNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterUpdateThreadNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.UpdateThreadNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) operationalDataset.bytes, operationalDataset.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)updateWiFiNetwork:(NSData *)ssid + credentials:(NSData *)credentials + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterUpdateWiFiNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterUpdateWiFiNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.UpdateWiFiNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), + chip::ByteSpan((const uint8_t *) credentials.bytes, credentials.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +@end + @interface CHIPTemperatureMeasurement () @property (readonly) Controller::TemperatureMeasurementCluster cppCluster; @end diff --git a/examples/temperature-measurement-app/esp32/main/gen/IMClusterCommandHandler.cpp b/examples/temperature-measurement-app/esp32/main/gen/IMClusterCommandHandler.cpp index c9e33667ccf5ea..f5fdc561515948 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/IMClusterCommandHandler.cpp +++ b/examples/temperature-measurement-app/esp32/main/gen/IMClusterCommandHandler.cpp @@ -39,6 +39,335 @@ namespace app { namespace clusters { +namespace NetworkCommissioning { + +void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv) +{ + { + switch (commandId) + { + case ZCL_ADD_THREAD_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * operationalDataset; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(operationalDataset); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterAddThreadNetworkCallback(const_cast(operationalDataset), breadcrumb, + timeoutMs); + break; + } + case ZCL_ADD_WI_FI_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * ssid; + const uint8_t * credentials; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(ssid); + break; + case 1: + TLVError = dataTlv.GetDataPtr(credentials); + break; + case 2: + TLVError = dataTlv.Get(breadcrumb); + break; + case 3: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterAddWiFiNetworkCallback(const_cast(ssid), + const_cast(credentials), breadcrumb, timeoutMs); + break; + } + case ZCL_DISABLE_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * networkID; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(networkID); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterDisableNetworkCallback(const_cast(networkID), breadcrumb, timeoutMs); + break; + } + case ZCL_ENABLE_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * networkID; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(networkID); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterEnableNetworkCallback(const_cast(networkID), breadcrumb, timeoutMs); + break; + } + case ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterGetLastNetworkCommissioningResultCallback(timeoutMs); + break; + } + case ZCL_REMOVE_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * NetworkID; + uint64_t Breadcrumb; + uint32_t TimeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(NetworkID); + break; + case 1: + TLVError = dataTlv.Get(Breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(TimeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterRemoveNetworkCallback(const_cast(NetworkID), Breadcrumb, TimeoutMs); + break; + } + case ZCL_SCAN_NETWORKS_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * ssid; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(ssid); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterScanNetworksCallback(const_cast(ssid), breadcrumb, timeoutMs); + break; + } + case ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * operationalDataset; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(operationalDataset); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterUpdateThreadNetworkCallback(const_cast(operationalDataset), breadcrumb, + timeoutMs); + break; + } + case ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * ssid; + const uint8_t * credentials; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(ssid); + break; + case 1: + TLVError = dataTlv.GetDataPtr(credentials); + break; + case 2: + TLVError = dataTlv.Get(breadcrumb); + break; + case 3: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterUpdateWiFiNetworkCallback(const_cast(ssid), + const_cast(credentials), breadcrumb, timeoutMs); + break; + } + default: { + // Unrecognized command ID, error status will apply. + // TODO: Encode response for command not found + ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_NETWORK_COMMISSIONING_CLUSTER_ID); + break; + } + } + } +} + +} // namespace NetworkCommissioning + } // namespace clusters void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aCommandId, chip::EndpointId aEndPointId, @@ -49,6 +378,9 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId); switch (aClusterId) { + case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID: + clusters::NetworkCommissioning::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; default: // Unrecognized cluster ID, error status will apply. // TODO: Encode response for Cluster not found diff --git a/examples/temperature-measurement-app/esp32/main/gen/attribute-id.h b/examples/temperature-measurement-app/esp32/main/gen/attribute-id.h index 8c8757f826ca7f..72a0198e2f97be 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/attribute-id.h +++ b/examples/temperature-measurement-app/esp32/main/gen/attribute-id.h @@ -391,6 +391,12 @@ #define ZCL_FABRIC_ID_ATTRIBUTE_ID (0x0000) #define ZCL_BREADCRUMB_ATTRIBUTE_ID (0x0001) +// Attribute ids for cluster: Network Commissioning + +// Client attributes + +// Server attributes + // Attribute ids for cluster: Shade Configuration // Client attributes @@ -4084,12 +4090,6 @@ // Server attributes -// Attribute ids for cluster: Network Commissioning - -// Client attributes - -// Server attributes - // Attribute ids for cluster: Binding // Client attributes diff --git a/examples/temperature-measurement-app/esp32/main/gen/call-command-handler.cpp b/examples/temperature-measurement-app/esp32/main/gen/call-command-handler.cpp index edceae46501114..84548bacfd8fda 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/call-command-handler.cpp +++ b/examples/temperature-measurement-app/esp32/main/gen/call-command-handler.cpp @@ -29,6 +29,7 @@ using namespace chip; EmberAfStatus emberAfBasicClusterServerCommandParse(EmberAfClusterCommand * cmd); +EmberAfStatus emberAfNetworkCommissioningClusterServerCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfTemperatureMeasurementClusterServerCommandParse(EmberAfClusterCommand * cmd); static EmberAfStatus status(bool wasHandled, bool clusterExists, bool mfgSpecific) @@ -74,6 +75,9 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd) // No commands are enabled for cluster Basic result = status(false, true, cmd->mfgSpecific); break; + case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID: + result = emberAfNetworkCommissioningClusterServerCommandParse(cmd); + break; case ZCL_TEMP_MEASUREMENT_CLUSTER_ID: // No commands are enabled for cluster Temperature Measurement result = status(false, true, cmd->mfgSpecific); @@ -87,3 +91,263 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd) } // Cluster specific command parsing + +EmberAfStatus emberAfNetworkCommissioningClusterServerCommandParse(EmberAfClusterCommand * cmd) +{ + bool wasHandled = false; + + if (!cmd->mfgSpecific) + { + switch (cmd->commandId) + { + case ZCL_ADD_THREAD_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * operationalDataset; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + operationalDataset = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(operationalDataset) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterAddThreadNetworkCallback(operationalDataset, breadcrumb, timeoutMs); + break; + } + case ZCL_ADD_WI_FI_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * ssid; + uint8_t * credentials; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + ssid = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(ssid) + 1u); + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + credentials = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(credentials) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterAddWiFiNetworkCallback(ssid, credentials, breadcrumb, timeoutMs); + break; + } + case ZCL_DISABLE_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * networkID; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + networkID = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(networkID) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterDisableNetworkCallback(networkID, breadcrumb, timeoutMs); + break; + } + case ZCL_ENABLE_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * networkID; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + networkID = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(networkID) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterEnableNetworkCallback(networkID, breadcrumb, timeoutMs); + break; + } + case ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterGetLastNetworkCommissioningResultCallback(timeoutMs); + break; + } + case ZCL_REMOVE_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * NetworkID; + uint64_t Breadcrumb; + uint32_t TimeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + NetworkID = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(NetworkID) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + Breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + TimeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterRemoveNetworkCallback(NetworkID, Breadcrumb, TimeoutMs); + break; + } + case ZCL_SCAN_NETWORKS_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * ssid; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + ssid = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(ssid) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterScanNetworksCallback(ssid, breadcrumb, timeoutMs); + break; + } + case ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * operationalDataset; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + operationalDataset = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(operationalDataset) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterUpdateThreadNetworkCallback(operationalDataset, breadcrumb, timeoutMs); + break; + } + case ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * ssid; + uint8_t * credentials; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + ssid = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(ssid) + 1u); + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + credentials = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(credentials) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterUpdateWiFiNetworkCallback(ssid, credentials, breadcrumb, timeoutMs); + break; + } + default: { + // Unrecognized command ID, error status will apply. + break; + } + } + } + return status(wasHandled, true, cmd->mfgSpecific); +} diff --git a/examples/temperature-measurement-app/esp32/main/gen/callback-stub.cpp b/examples/temperature-measurement-app/esp32/main/gen/callback-stub.cpp index f3b3fad1c71615..5f99758d28e55c 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/callback-stub.cpp +++ b/examples/temperature-measurement-app/esp32/main/gen/callback-stub.cpp @@ -30,6 +30,9 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) case ZCL_BASIC_CLUSTER_ID: emberAfBasicClusterInitCallback(endpoint); break; + case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID: + emberAfNetworkCommissioningClusterInitCallback(endpoint); + break; case ZCL_TEMP_MEASUREMENT_CLUSTER_ID: emberAfTemperatureMeasurementClusterInitCallback(endpoint); break; @@ -44,6 +47,11 @@ void __attribute__((weak)) emberAfBasicClusterInitCallback(EndpointId endpoint) // To prevent warning (void) endpoint; } +void __attribute__((weak)) emberAfNetworkCommissioningClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} void __attribute__((weak)) emberAfTemperatureMeasurementClusterInitCallback(EndpointId endpoint) { // To prevent warning diff --git a/examples/temperature-measurement-app/esp32/main/gen/callback.h b/examples/temperature-measurement-app/esp32/main/gen/callback.h index b999d830984c88..99a199fffa2314 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/callback.h +++ b/examples/temperature-measurement-app/esp32/main/gen/callback.h @@ -45,6 +45,14 @@ void emberAfClusterInitCallback(chip::EndpointId endpoint, chip::ClusterId clust */ void emberAfBasicClusterInitCallback(chip::EndpointId endpoint); +/** @brief Network Commissioning Cluster Init + * + * Cluster Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfNetworkCommissioningClusterInitCallback(chip::EndpointId endpoint); + /** @brief Temperature Measurement Cluster Init * * Cluster Init @@ -123,6 +131,77 @@ EmberAfStatus emberAfBasicClusterServerPreAttributeChangedCallback(chip::Endpoin */ void emberAfBasicClusterServerTickCallback(chip::EndpointId endpoint); +// +// Network Commissioning Cluster server +// + +/** @brief Network Commissioning Cluster Server Init + * + * Server Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfNetworkCommissioningClusterServerInitCallback(chip::EndpointId endpoint); + +/** @brief Network Commissioning Cluster Server Attribute Changed + * + * Server Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + */ +void emberAfNetworkCommissioningClusterServerAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId); + +/** @brief Network Commissioning Cluster Server Manufacturer Specific Attribute Changed + * + * Server Manufacturer Specific Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + * @param manufacturerCode Manufacturer Code of the attribute that changed + */ +void emberAfNetworkCommissioningClusterServerManufacturerSpecificAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + uint16_t manufacturerCode); + +/** @brief Network Commissioning Cluster Server Message Sent + * + * Server Message Sent + * + * @param type The type of message sent + * @param indexOrDestination The destination or address to which the message was sent + * @param apsFrame The APS frame for the message + * @param msgLen The length of the message + * @param message The message that was sent + * @param status The status of the sent message + */ +void emberAfNetworkCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); + +/** @brief Network Commissioning Cluster Server Pre Attribute Changed + * + * server Pre Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute to be changed + * @param attributeType Attribute type + * @param size Attribute size + * @param value Attribute value + */ +EmberAfStatus emberAfNetworkCommissioningClusterServerPreAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + EmberAfAttributeType attributeType, uint8_t size, + uint8_t * value); + +/** @brief Network Commissioning Cluster Server Tick + * + * server Tick + * + * @param endpoint Endpoint that is being served + */ +void emberAfNetworkCommissioningClusterServerTickCallback(chip::EndpointId endpoint); + // // Temperature Measurement Cluster server // @@ -196,6 +275,91 @@ void emberAfTemperatureMeasurementClusterServerTickCallback(chip::EndpointId end // Cluster Commands Callback +/** + * @brief Network Commissioning Cluster AddThreadNetwork Command callback + * @param operationalDataset + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterAddThreadNetworkCallback(uint8_t * operationalDataset, uint64_t breadcrumb, + uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster AddWiFiNetwork Command callback + * @param ssid + * @param credentials + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterAddWiFiNetworkCallback(uint8_t * ssid, uint8_t * credentials, uint64_t breadcrumb, + uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster DisableNetwork Command callback + * @param networkID + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterDisableNetworkCallback(uint8_t * networkID, uint64_t breadcrumb, uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster EnableNetwork Command callback + * @param networkID + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterEnableNetworkCallback(uint8_t * networkID, uint64_t breadcrumb, uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster GetLastNetworkCommissioningResult Command callback + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterGetLastNetworkCommissioningResultCallback(uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster RemoveNetwork Command callback + * @param networkID + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterRemoveNetworkCallback(uint8_t * NetworkID, uint64_t Breadcrumb, uint32_t TimeoutMs); + +/** + * @brief Network Commissioning Cluster ScanNetworks Command callback + * @param ssid + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterScanNetworksCallback(uint8_t * ssid, uint64_t breadcrumb, uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster UpdateThreadNetwork Command callback + * @param operationalDataset + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterUpdateThreadNetworkCallback(uint8_t * operationalDataset, uint64_t breadcrumb, + uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster UpdateWiFiNetwork Command callback + * @param ssid + * @param credentials + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterUpdateWiFiNetworkCallback(uint8_t * ssid, uint8_t * credentials, uint64_t breadcrumb, + uint32_t timeoutMs); + // // Non-Cluster Related Callbacks // diff --git a/examples/temperature-measurement-app/esp32/main/gen/client-command-macro.h b/examples/temperature-measurement-app/esp32/main/gen/client-command-macro.h index f72c96f951dcff..79d1e159594a4a 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/client-command-macro.h +++ b/examples/temperature-measurement-app/esp32/main/gen/client-command-macro.h @@ -1911,6 +1911,225 @@ \ ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); +/** @brief Command description for ScanNetworks + * + * Command: ScanNetworks + * @param ssid OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterScanNetworks(ssid, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SCAN_NETWORKS_COMMAND_ID, "uuu", ssid, breadcrumb, timeoutMs); + +/** @brief Command description for ScanNetworksResponse + * + * Command: ScanNetworksResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + * @param wifiScanResults WiFiInterfaceScanResult [] + * @param wifiScanResultsLen int + * @param threadScanResults ThreadInterfaceScanResult [] + * @param threadScanResultsLen int + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterScanNetworksResponse(errorCode, debugText, wifiScanResults, wifiScanResultsLen, threadScanResults, \ + threadScanResultsLen) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID, "uubb", errorCode, debugText, wifiScanResults, \ + wifiScanResultsLen, threadScanResults, threadScanResultsLen); + +/** @brief Command description for AddWiFiNetwork + * + * Command: AddWiFiNetwork + * @param ssid OCTET_STRING + * @param credentials OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); + +/** @brief Command description for AddWiFiNetworkResponse + * + * Command: AddWiFiNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddWiFiNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for UpdateWiFiNetwork + * + * Command: UpdateWiFiNetwork + * @param ssid OCTET_STRING + * @param credentials OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); + +/** @brief Command description for UpdateWiFiNetworkResponse + * + * Command: UpdateWiFiNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateWiFiNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for AddThreadNetwork + * + * Command: AddThreadNetwork + * @param operationalDataset OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); + +/** @brief Command description for AddThreadNetworkResponse + * + * Command: AddThreadNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddThreadNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for UpdateThreadNetwork + * + * Command: UpdateThreadNetwork + * @param operationalDataset OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); + +/** @brief Command description for UpdateThreadNetworkResponse + * + * Command: UpdateThreadNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateThreadNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for RemoveNetwork + * + * Command: RemoveNetwork + * @param NetworkID OCTET_STRING + * @param Breadcrumb INT64U + * @param TimeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterRemoveNetwork(NetworkID, Breadcrumb, TimeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_NETWORK_COMMAND_ID, "uuu", NetworkID, Breadcrumb, TimeoutMs); + +/** @brief Command description for RemoveNetworkResponse + * + * Command: RemoveNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterRemoveNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for EnableNetwork + * + * Command: EnableNetwork + * @param networkID OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterEnableNetwork(networkID, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ENABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); + +/** @brief Command description for EnableNetworkResponse + * + * Command: EnableNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterEnableNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for DisableNetwork + * + * Command: DisableNetwork + * @param networkID OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterDisableNetwork(networkID, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_DISABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); + +/** @brief Command description for DisableNetworkResponse + * + * Command: DisableNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterDisableNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for GetLastNetworkCommissioningResult + * + * Command: GetLastNetworkCommissioningResult + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterGetLastNetworkCommissioningResult(timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID, "u", timeoutMs); + /** @brief Command description for LockDoor * * Command: LockDoor @@ -5783,225 +6002,6 @@ ZCL_GET_ENDPOINT_LIST_REQUEST_COMMAND_ID, "uuuub", startIndex, total, startIndex, count, \ endpointInformationRecordList, endpointInformationRecordListLen); -/** @brief Command description for ScanNetworks - * - * Command: ScanNetworks - * @param ssid OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterScanNetworks(ssid, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_SCAN_NETWORKS_COMMAND_ID, "uuu", ssid, breadcrumb, timeoutMs); - -/** @brief Command description for ScanNetworksResponse - * - * Command: ScanNetworksResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - * @param wifiScanResults WiFiInterfaceScanResult [] - * @param wifiScanResultsLen int - * @param threadScanResults ThreadInterfaceScanResult [] - * @param threadScanResultsLen int - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterScanNetworksResponse(errorCode, debugText, wifiScanResults, wifiScanResultsLen, threadScanResults, \ - threadScanResultsLen) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID, "uubb", errorCode, debugText, wifiScanResults, \ - wifiScanResultsLen, threadScanResults, threadScanResultsLen); - -/** @brief Command description for AddWiFiNetwork - * - * Command: AddWiFiNetwork - * @param ssid OCTET_STRING - * @param credentials OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); - -/** @brief Command description for AddWiFiNetworkResponse - * - * Command: AddWiFiNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddWiFiNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for UpdateWiFiNetwork - * - * Command: UpdateWiFiNetwork - * @param ssid OCTET_STRING - * @param credentials OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); - -/** @brief Command description for UpdateWiFiNetworkResponse - * - * Command: UpdateWiFiNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateWiFiNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for AddThreadNetwork - * - * Command: AddThreadNetwork - * @param operationalDataset OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); - -/** @brief Command description for AddThreadNetworkResponse - * - * Command: AddThreadNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddThreadNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for UpdateThreadNetwork - * - * Command: UpdateThreadNetwork - * @param operationalDataset OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); - -/** @brief Command description for UpdateThreadNetworkResponse - * - * Command: UpdateThreadNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateThreadNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for RemoveNetwork - * - * Command: RemoveNetwork - * @param NetworkID OCTET_STRING - * @param Breadcrumb INT64U - * @param TimeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterRemoveNetwork(NetworkID, Breadcrumb, TimeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_REMOVE_NETWORK_COMMAND_ID, "uuu", NetworkID, Breadcrumb, TimeoutMs); - -/** @brief Command description for RemoveNetworkResponse - * - * Command: RemoveNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterRemoveNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for EnableNetwork - * - * Command: EnableNetwork - * @param networkID OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterEnableNetwork(networkID, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ENABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); - -/** @brief Command description for EnableNetworkResponse - * - * Command: EnableNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterEnableNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for DisableNetwork - * - * Command: DisableNetwork - * @param networkID OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterDisableNetwork(networkID, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_DISABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); - -/** @brief Command description for DisableNetworkResponse - * - * Command: DisableNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterDisableNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for GetLastNetworkCommissioningResult - * - * Command: GetLastNetworkCommissioningResult - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterGetLastNetworkCommissioningResult(timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID, "u", timeoutMs); - /** @brief Command description for Bind * * Command: Bind diff --git a/examples/temperature-measurement-app/esp32/main/gen/cluster-id.h b/examples/temperature-measurement-app/esp32/main/gen/cluster-id.h index d77da915200ab4..add8f83d188cf8 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/cluster-id.h +++ b/examples/temperature-measurement-app/esp32/main/gen/cluster-id.h @@ -86,6 +86,9 @@ // Definitions for cluster: General Commissioning #define ZCL_GENERAL_COMMISSIONING_CLUSTER_ID (0x0030) +// Definitions for cluster: Network Commissioning +#define ZCL_NETWORK_COMMISSIONING_CLUSTER_ID (0x0031) + // Definitions for cluster: Shade Configuration #define ZCL_SHADE_CONFIG_CLUSTER_ID (0x0100) @@ -341,9 +344,6 @@ // Definitions for cluster: ZLL Commissioning #define ZCL_ZLL_COMMISSIONING_CLUSTER_ID (0x1000) -// Definitions for cluster: Network Commissioning -#define ZCL_NETWORK_COMMISSIONING_CLUSTER_ID (0xAAAA) - // Definitions for cluster: Binding #define ZCL_BINDING_CLUSTER_ID (0xF000) diff --git a/examples/temperature-measurement-app/esp32/main/gen/command-id.h b/examples/temperature-measurement-app/esp32/main/gen/command-id.h index adc2b1c6f32733..864943b5727fcd 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/command-id.h +++ b/examples/temperature-measurement-app/esp32/main/gen/command-id.h @@ -238,6 +238,25 @@ #define ZCL_COMMISSIONING_COMPLETE_COMMAND_ID (0x06) #define ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID (0x07) +// Commands for cluster: Network Commissioning +#define ZCL_SCAN_NETWORKS_COMMAND_ID (0x00) +#define ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID (0x01) +#define ZCL_ADD_WI_FI_NETWORK_COMMAND_ID (0x02) +#define ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x03) +#define ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID (0x04) +#define ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x05) +#define ZCL_ADD_THREAD_NETWORK_COMMAND_ID (0x06) +#define ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x07) +#define ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID (0x08) +#define ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x09) +#define ZCL_REMOVE_NETWORK_COMMAND_ID (0x0A) +#define ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID (0x0B) +#define ZCL_ENABLE_NETWORK_COMMAND_ID (0x0C) +#define ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID (0x0D) +#define ZCL_DISABLE_NETWORK_COMMAND_ID (0x0E) +#define ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID (0x0F) +#define ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID (0x10) + // Commands for cluster: Door Lock #define ZCL_LOCK_DOOR_COMMAND_ID (0x00) #define ZCL_LOCK_DOOR_RESPONSE_COMMAND_ID (0x00) @@ -700,25 +719,6 @@ #define ZCL_GET_ENDPOINT_LIST_REQUEST_COMMAND_ID (0x42) #define ZCL_GET_ENDPOINT_LIST_RESPONSE_COMMAND_ID (0x42) -// Commands for cluster: Network Commissioning -#define ZCL_SCAN_NETWORKS_COMMAND_ID (0x00) -#define ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID (0x01) -#define ZCL_ADD_WI_FI_NETWORK_COMMAND_ID (0x02) -#define ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x03) -#define ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID (0x04) -#define ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x05) -#define ZCL_ADD_THREAD_NETWORK_COMMAND_ID (0x06) -#define ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x07) -#define ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID (0x08) -#define ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x09) -#define ZCL_REMOVE_NETWORK_COMMAND_ID (0x0A) -#define ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID (0x0B) -#define ZCL_ENABLE_NETWORK_COMMAND_ID (0x0C) -#define ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID (0x0D) -#define ZCL_DISABLE_NETWORK_COMMAND_ID (0x0E) -#define ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID (0x0F) -#define ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID (0x10) - // Commands for cluster: Binding #define ZCL_BIND_COMMAND_ID (0x00) #define ZCL_UNBIND_COMMAND_ID (0x01) diff --git a/examples/temperature-measurement-app/esp32/main/gen/endpoint_config.h b/examples/temperature-measurement-app/esp32/main/gen/endpoint_config.h index f701c1c4199df8..aac33bcf5ad7c3 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/endpoint_config.h +++ b/examples/temperature-measurement-app/esp32/main/gen/endpoint_config.h @@ -100,7 +100,7 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 16 +#define GENERATED_ATTRIBUTE_COUNT 17 #define GENERATED_ATTRIBUTES \ { \ { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) 3 } }, /* Basic (server): cluster revision */ \ @@ -137,6 +137,7 @@ { \ 0x000A, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(180) } \ }, /* Basic (server): SoftwareVersionString */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Network Commissioning (server): cluster revision */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 3 } }, /* Temperature Measurement (server): cluster revision */ \ { 0x0000, ZAP_TYPE(INT16S), 2, 0, { (uint8_t *) 0x8000 } }, /* Temperature Measurement (server): measured value */ \ { 0x0001, ZAP_TYPE(INT16S), 2, 0, { (uint8_t *) 0x8000 } }, /* Temperature Measurement (server): min measured value */ \ @@ -150,12 +151,15 @@ #define GENERATED_FUNCTION_ARRAYS #define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask -#define GENERATED_CLUSTER_COUNT 2 +#define GENERATED_CLUSTER_COUNT 3 #define GENERATED_CLUSTERS \ { \ { 0x0028, ZAP_ATTRIBUTE_INDEX(0), 12, 254, ZAP_CLUSTER_MASK(SERVER), NULL }, /* Endpoint: 1, Cluster: Basic (server) */ \ { \ - 0x0402, ZAP_ATTRIBUTE_INDEX(12), 4, 8, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0031, ZAP_ATTRIBUTE_INDEX(12), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 1, Cluster: Network Commissioning (server) */ \ + { \ + 0x0402, ZAP_ATTRIBUTE_INDEX(13), 4, 8, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Temperature Measurement (server) */ \ } @@ -164,7 +168,7 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 2, 262 }, \ + { ZAP_CLUSTER_INDEX(0), 3, 264 }, \ } // Largest attribute size is needed for various buffers @@ -174,7 +178,7 @@ #define ATTRIBUTE_SINGLETONS_SIZE (254) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (262) +#define ATTRIBUTE_MAX_SIZE (264) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (1) @@ -218,12 +222,30 @@ // Array of EmberAfCommandMetadata structs. #define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask -#define EMBER_AF_GENERATED_COMMAND_COUNT (3) +#define EMBER_AF_GENERATED_COMMAND_COUNT (20) #define GENERATED_COMMANDS \ { \ { 0x0028, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): StartUp */ \ { 0x0028, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): ShutDown */ \ { 0x0028, 0x02, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): Leave */ \ + { 0x0031, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): ScanNetworks */ \ + { 0x0031, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): ScanNetworksResponse */ \ + { 0x0031, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): AddWiFiNetwork */ \ + { 0x0031, 0x03, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): AddWiFiNetworkResponse */ \ + { 0x0031, 0x04, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): UpdateWiFiNetwork */ \ + { 0x0031, 0x05, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): UpdateWiFiNetworkResponse */ \ + { 0x0031, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): AddThreadNetwork */ \ + { 0x0031, 0x07, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): AddThreadNetworkResponse */ \ + { 0x0031, 0x08, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): UpdateThreadNetwork */ \ + { 0x0031, 0x09, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): UpdateThreadNetworkResponse */ \ + { 0x0031, 0x0A, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): RemoveNetwork */ \ + { 0x0031, 0x0B, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): RemoveNetworkResponse */ \ + { 0x0031, 0x0C, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): EnableNetwork */ \ + { 0x0031, 0x0D, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): EnableNetworkResponse */ \ + { 0x0031, 0x0E, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): DisableNetwork */ \ + { 0x0031, 0x0F, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): DisableNetworkResponse */ \ + { 0x0031, 0x10, \ + ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): GetLastNetworkCommissioningResult */ \ } // Array of EmberAfManufacturerCodeEntry structures for commands. diff --git a/examples/temperature-measurement-app/esp32/main/gen/gen_config.h b/examples/temperature-measurement-app/esp32/main/gen/gen_config.h index 5a04a8fb141862..d6a95b43b2b908 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/gen_config.h +++ b/examples/temperature-measurement-app/esp32/main/gen/gen_config.h @@ -30,6 +30,7 @@ /**** Cluster endpoint counts ****/ #define EMBER_AF_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_NETWORK_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_TEMP_MEASUREMENT_CLUSTER_SERVER_ENDPOINT_COUNT (1) /**** Cluster Plugins ****/ @@ -39,6 +40,11 @@ #define EMBER_AF_PLUGIN_BASIC_SERVER #define EMBER_AF_PLUGIN_BASIC +// Use this macro to check if the server side of the Network Commissioning cluster is included +#define ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING_SERVER +#define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING + // Use this macro to check if the server side of the Temperature Measurement cluster is included #define ZCL_USING_TEMP_MEASUREMENT_CLUSTER_SERVER #define EMBER_AF_PLUGIN_TEMPERATURE_MEASUREMENT_SERVER diff --git a/examples/temperature-measurement-app/esp32/main/gen/print-cluster.h b/examples/temperature-measurement-app/esp32/main/gen/print-cluster.h index bd08d38a581506..8c737e93fea79c 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/print-cluster.h +++ b/examples/temperature-measurement-app/esp32/main/gen/print-cluster.h @@ -156,6 +156,12 @@ #define CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER #endif +#if defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER { ZCL_NETWORK_COMMISSIONING_CLUSTER_ID, 49, "Network Commissioning" }, +#else +#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER +#endif + #if defined(ZCL_USING_SHADE_CONFIG_CLUSTER_SERVER) || defined(ZCL_USING_SHADE_CONFIG_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER { ZCL_SHADE_CONFIG_CLUSTER_ID, 256, "Shade Configuration" }, #else @@ -734,12 +740,6 @@ #define CHIP_PRINTCLUSTER_ZLL_COMMISSIONING_CLUSTER #endif -#if defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_CLIENT) -#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER { ZCL_NETWORK_COMMISSIONING_CLUSTER_ID, 43690, "Network Commissioning" }, -#else -#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER -#endif - #if defined(ZCL_USING_BINDING_CLUSTER_SERVER) || defined(ZCL_USING_BINDING_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_BINDING_CLUSTER { ZCL_BINDING_CLUSTER_ID, 61440, "Binding" }, #else @@ -812,6 +812,7 @@ CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER \ CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER \ + CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DOOR_LOCK_CLUSTER \ CHIP_PRINTCLUSTER_WINDOW_COVERING_CLUSTER \ @@ -897,7 +898,6 @@ CHIP_PRINTCLUSTER_ELECTRICAL_MEASUREMENT_CLUSTER \ CHIP_PRINTCLUSTER_DIAGNOSTICS_CLUSTER \ CHIP_PRINTCLUSTER_ZLL_COMMISSIONING_CLUSTER \ - CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_BINDING_CLUSTER \ CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER \ CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER \ diff --git a/examples/temperature-measurement-app/esp32/main/temperature-measurement.zap b/examples/temperature-measurement-app/esp32/main/temperature-measurement.zap index 2342fb2bfdee06..8099386da86d77 100644 --- a/examples/temperature-measurement-app/esp32/main/temperature-measurement.zap +++ b/examples/temperature-measurement-app/esp32/main/temperature-measurement.zap @@ -1,6 +1,6 @@ { - "writeTime": "Tue Nov 17 2020 19:19:54 GMT+0100 (Central European Standard Time)", - "featureLevel": 4, + "writeTime": "Fri Mar 12 2021 15:20:19 GMT+0800 (China Standard Time)", + "featureLevel": 11, "creator": "zap", "keyValuePairs": [ { @@ -19,13 +19,13 @@ "package": [ { "pathRelativity": "relativeToZap", - "path": "../../../../src/app/zap-templates/zcl/zcl.json", + "path": "../../../../../src/app/zap-templates/zcl/zcl.json", "version": "ZCL Test Data", "type": "zcl-properties" }, { "pathRelativity": "relativeToZap", - "path": "../../../../src/app/zap-templates/app-templates.json", + "path": "../../../../../src/app/zap-templates/app-templates.json", "version": "chip-v1", "type": "gen-templates-json" } @@ -34,251 +34,9 @@ { "name": "Anonymous Endpoint Type", "deviceTypeName": "CBA-tempsensor", - "deviceTypeCode": "0x0302", - "deviceTypeProfileId": "0x105", + "deviceTypeCode": 770, + "deviceTypeProfileId": 261, "clusters": [ - { - "name": "Basic", - "code": 40, - "mfgCode": null, - "define": "BASIC_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Basic", - "code": 40, - "mfgCode": null, - "define": "BASIC_CLUSTER", - "side": "server", - "enabled": 1, - "commands": [ - { - "name": "StartUp", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "ShutDown", - "code": 1, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "Leave", - "code": 2, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "InteractionModelVersion", - "code": 0, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "VendorName", - "code": 1, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "VendorID", - "code": 2, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ProductName", - "code": 3, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "ProductID", - "code": 4, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "UserLabel", - "code": 5, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "Location", - "code": 6, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "HardwareVersion", - "code": 7, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "HardwareVersionString", - "code": 8, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "SoftwareVersion", - "code": 9, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "SoftwareVersionString", - "code": 10, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, { "name": "Power Configuration", "code": 1, @@ -286,6 +44,7 @@ "define": "POWER_CONFIG_CLUSTER", "side": "client", "enabled": 0, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -302,8 +61,7 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [] + ] }, { "name": "Power Configuration", @@ -312,6 +70,7 @@ "define": "POWER_CONFIG_CLUSTER", "side": "server", "enabled": 0, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -358,8 +117,7 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [] + ] }, { "name": "Device Temperature Configuration", @@ -368,7 +126,6 @@ "define": "DEVICE_TEMP_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "cluster revision", @@ -385,7 +142,8 @@ "maxInterval": 65344, "reportableChange": 0 } - ] + ], + "commands": [] }, { "name": "Device Temperature Configuration", @@ -1196,10 +954,10 @@ ] }, { - "name": "Temperature Measurement", - "code": 1026, + "name": "Basic", + "code": 40, "mfgCode": null, - "define": "TEMP_MEASUREMENT_CLUSTER", + "define": "BASIC_CLUSTER", "side": "client", "enabled": 0, "commands": [], @@ -1211,16 +969,448 @@ "side": "client", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "StartUp", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ShutDown", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "Leave", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, "bounded": 0, "defaultValue": "3", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 + }, + { + "name": "InteractionModelVersion", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorName", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorID", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductName", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductID", + "code": 4, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UserLabel", + "code": 5, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Location", + "code": 6, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersion", + "code": 7, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersionString", + "code": 8, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersion", + "code": 9, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersionString", + "code": 10, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Network Commissioning", + "code": 49, + "mfgCode": null, + "define": "NETWORK_COMMISSIONING_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "ScanNetworks", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "AddWiFiNetwork", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "UpdateWiFiNetwork", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "AddThreadNetwork", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "UpdateThreadNetwork", + "code": 8, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveNetwork", + "code": 10, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "EnableNetwork", + "code": 12, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "DisableNetwork", + "code": 14, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetLastNetworkCommissioningResult", + "code": 16, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Network Commissioning", + "code": 49, + "mfgCode": null, + "define": "NETWORK_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], + "commands": [ + { + "name": "ScanNetworksResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "AddWiFiNetworkResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "UpdateWiFiNetworkResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "AddThreadNetworkResponse", + "code": 7, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "UpdateThreadNetworkResponse", + "code": 9, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RemoveNetworkResponse", + "code": 11, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "EnableNetworkResponse", + "code": 13, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "DisableNetworkResponse", + "code": 15, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 } ] }, + { + "name": "Temperature Measurement", + "code": 1026, + "mfgCode": null, + "define": "TEMP_MEASUREMENT_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], + "commands": [] + }, { "name": "Temperature Measurement", "code": 1026, @@ -1228,7 +1418,6 @@ "define": "TEMP_MEASUREMENT_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "cluster revision", @@ -1305,7 +1494,8 @@ "maxInterval": 65344, "reportableChange": 0 } - ] + ], + "commands": [] } ] } @@ -1319,4 +1509,4 @@ "networkId": 0 } ] -} +} \ No newline at end of file diff --git a/examples/tv-app/tv-common/BUILD.gn b/examples/tv-app/tv-common/BUILD.gn index 644a234342b8eb..d9931cad4f1bc6 100644 --- a/examples/tv-app/tv-common/BUILD.gn +++ b/examples/tv-app/tv-common/BUILD.gn @@ -41,6 +41,8 @@ source_set("tv-common") { "${chip_root}/src/app/clusters/level-control/level-control.cpp", "${chip_root}/src/app/clusters/low-power-server/low-power-server.cpp", "${chip_root}/src/app/clusters/media-playback-server/media-playback-server.cpp", + "${chip_root}/src/app/clusters/network-commissioning/network-commissioning-ember.cpp", + "${chip_root}/src/app/clusters/network-commissioning/network-commissioning.cpp", "${chip_root}/src/app/clusters/on-off-server/on-off.cpp", "${chip_root}/src/app/clusters/scenes-client/scenes-client.cpp", "${chip_root}/src/app/clusters/scenes/scenes.cpp", diff --git a/examples/tv-app/tv-common/gen/CHIPClustersObjc.h b/examples/tv-app/tv-common/gen/CHIPClustersObjc.h index e4f190ad7e7068..5e99fca8479815 100644 --- a/examples/tv-app/tv-common/gen/CHIPClustersObjc.h +++ b/examples/tv-app/tv-common/gen/CHIPClustersObjc.h @@ -741,6 +741,52 @@ NS_ASSUME_NONNULL_BEGIN @end +/** + * Cluster Network Commissioning + * + */ +@interface CHIPNetworkCommissioning : CHIPCluster + +- (void)addThreadNetwork:(NSData *)operationalDataset + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)addWiFiNetwork:(NSData *)ssid + credentials:(NSData *)credentials + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)disableNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)enableNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)getLastNetworkCommissioningResult:(uint32_t)timeoutMs completionHandler:(ResponseHandler)completionHandler; +- (void)removeNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)scanNetworks:(NSData *)ssid + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)updateThreadNetwork:(NSData *)operationalDataset + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; +- (void)updateWiFiNetwork:(NSData *)ssid + credentials:(NSData *)credentials + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler; + +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler; + +@end + /** * Cluster On/off * diff --git a/examples/tv-app/tv-common/gen/CHIPClustersObjc.mm b/examples/tv-app/tv-common/gen/CHIPClustersObjc.mm index 79a2894a6be739..00dc2fc9a1da40 100644 --- a/examples/tv-app/tv-common/gen/CHIPClustersObjc.mm +++ b/examples/tv-app/tv-common/gen/CHIPClustersObjc.mm @@ -8107,6 +8107,285 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler @end +@interface CHIPNetworkCommissioning () +@property (readonly) Controller::NetworkCommissioningCluster cppCluster; +@end + +@implementation CHIPNetworkCommissioning + +- (Controller::ClusterBase *)getCluster +{ + return &_cppCluster; +} + +- (void)addThreadNetwork:(NSData *)operationalDataset + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterAddThreadNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterAddThreadNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.AddThreadNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) operationalDataset.bytes, operationalDataset.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)addWiFiNetwork:(NSData *)ssid + credentials:(NSData *)credentials + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterAddWiFiNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterAddWiFiNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.AddWiFiNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), + chip::ByteSpan((const uint8_t *) credentials.bytes, credentials.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)disableNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterDisableNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterDisableNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.DisableNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)enableNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterEnableNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterEnableNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.EnableNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)getLastNetworkCommissioningResult:(uint32_t)timeoutMs completionHandler:(ResponseHandler)completionHandler +{ + CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.GetLastNetworkCommissioningResult(onSuccess->Cancel(), onFailure->Cancel(), timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)removeNetwork:(NSData *)networkID + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterRemoveNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterRemoveNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.RemoveNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)scanNetworks:(NSData *)ssid + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterScanNetworksResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterScanNetworksResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ScanNetworks( + onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)updateThreadNetwork:(NSData *)operationalDataset + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterUpdateThreadNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterUpdateThreadNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.UpdateThreadNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) operationalDataset.bytes, operationalDataset.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} +- (void)updateWiFiNetwork:(NSData *)ssid + credentials:(NSData *)credentials + breadcrumb:(uint64_t)breadcrumb + timeoutMs:(uint32_t)timeoutMs + completionHandler:(ResponseHandler)completionHandler +{ + CHIPNetworkCommissioningClusterUpdateWiFiNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterUpdateWiFiNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.UpdateWiFiNetwork(onSuccess->Cancel(), onFailure->Cancel(), + chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), + chip::ByteSpan((const uint8_t *) credentials.bytes, credentials.length), breadcrumb, timeoutMs); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +- (void)readAttributeClusterRevision:(ResponseHandler)completionHandler +{ + CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + if (!onSuccess) { + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(completionHandler, [self callbackQueue]); + if (!onFailure) { + delete onSuccess; + completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); + return; + } + + CHIP_ERROR err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel()); + if (err != CHIP_NO_ERROR) { + delete onSuccess; + delete onFailure; + completionHandler([CHIPError errorForCHIPErrorCode:err], nil); + } +} + +@end + @interface CHIPOnOff () @property (readonly) Controller::OnOffCluster cppCluster; @end diff --git a/examples/tv-app/tv-common/gen/IMClusterCommandHandler.cpp b/examples/tv-app/tv-common/gen/IMClusterCommandHandler.cpp index ebe9a25774f085..c8edddf1704a82 100644 --- a/examples/tv-app/tv-common/gen/IMClusterCommandHandler.cpp +++ b/examples/tv-app/tv-common/gen/IMClusterCommandHandler.cpp @@ -2076,6 +2076,335 @@ void DispatchServerCommand(app::Command * command, CommandId commandId, Endpoint } // namespace MediaPlayback +namespace NetworkCommissioning { + +void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv) +{ + { + switch (commandId) + { + case ZCL_ADD_THREAD_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * operationalDataset; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(operationalDataset); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterAddThreadNetworkCallback(const_cast(operationalDataset), breadcrumb, + timeoutMs); + break; + } + case ZCL_ADD_WI_FI_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * ssid; + const uint8_t * credentials; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(ssid); + break; + case 1: + TLVError = dataTlv.GetDataPtr(credentials); + break; + case 2: + TLVError = dataTlv.Get(breadcrumb); + break; + case 3: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterAddWiFiNetworkCallback(const_cast(ssid), + const_cast(credentials), breadcrumb, timeoutMs); + break; + } + case ZCL_DISABLE_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * networkID; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(networkID); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterDisableNetworkCallback(const_cast(networkID), breadcrumb, timeoutMs); + break; + } + case ZCL_ENABLE_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * networkID; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(networkID); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterEnableNetworkCallback(const_cast(networkID), breadcrumb, timeoutMs); + break; + } + case ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterGetLastNetworkCommissioningResultCallback(timeoutMs); + break; + } + case ZCL_REMOVE_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * NetworkID; + uint64_t Breadcrumb; + uint32_t TimeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(NetworkID); + break; + case 1: + TLVError = dataTlv.Get(Breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(TimeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterRemoveNetworkCallback(const_cast(NetworkID), Breadcrumb, TimeoutMs); + break; + } + case ZCL_SCAN_NETWORKS_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * ssid; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(ssid); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterScanNetworksCallback(const_cast(ssid), breadcrumb, timeoutMs); + break; + } + case ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * operationalDataset; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(operationalDataset); + break; + case 1: + TLVError = dataTlv.Get(breadcrumb); + break; + case 2: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterUpdateThreadNetworkCallback(const_cast(operationalDataset), breadcrumb, + timeoutMs); + break; + } + case ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID: { + CHIP_ERROR TLVError = CHIP_NO_ERROR; + const uint8_t * ssid; + const uint8_t * credentials; + uint64_t breadcrumb; + uint32_t timeoutMs; + + while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR) + { + switch (TLV::TagNumFromTag(dataTlv.GetTag())) + { + case 0: + TLVError = dataTlv.GetDataPtr(ssid); + break; + case 1: + TLVError = dataTlv.GetDataPtr(credentials); + break; + case 2: + TLVError = dataTlv.Get(breadcrumb); + break; + case 3: + TLVError = dataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (TLVError != CHIP_NO_ERROR) + { + ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32, + TLV::TagNumFromTag(dataTlv.GetTag()), TLVError); + } + } + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + emberAfNetworkCommissioningClusterUpdateWiFiNetworkCallback(const_cast(ssid), + const_cast(credentials), breadcrumb, timeoutMs); + break; + } + default: { + // Unrecognized command ID, error status will apply. + // TODO: Encode response for command not found + ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_NETWORK_COMMISSIONING_CLUSTER_ID); + break; + } + } + } +} + +} // namespace NetworkCommissioning + namespace OnOff { void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv) @@ -2389,6 +2718,9 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC case ZCL_MEDIA_PLAYBACK_CLUSTER_ID: clusters::MediaPlayback::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; + case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID: + clusters::NetworkCommissioning::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; case ZCL_ON_OFF_CLUSTER_ID: clusters::OnOff::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; diff --git a/examples/tv-app/tv-common/gen/attribute-id.h b/examples/tv-app/tv-common/gen/attribute-id.h index 8c8757f826ca7f..72a0198e2f97be 100644 --- a/examples/tv-app/tv-common/gen/attribute-id.h +++ b/examples/tv-app/tv-common/gen/attribute-id.h @@ -391,6 +391,12 @@ #define ZCL_FABRIC_ID_ATTRIBUTE_ID (0x0000) #define ZCL_BREADCRUMB_ATTRIBUTE_ID (0x0001) +// Attribute ids for cluster: Network Commissioning + +// Client attributes + +// Server attributes + // Attribute ids for cluster: Shade Configuration // Client attributes @@ -4084,12 +4090,6 @@ // Server attributes -// Attribute ids for cluster: Network Commissioning - -// Client attributes - -// Server attributes - // Attribute ids for cluster: Binding // Client attributes diff --git a/examples/tv-app/tv-common/gen/call-command-handler.cpp b/examples/tv-app/tv-common/gen/call-command-handler.cpp index 3d358720f8341a..3c64fa530af572 100644 --- a/examples/tv-app/tv-common/gen/call-command-handler.cpp +++ b/examples/tv-app/tv-common/gen/call-command-handler.cpp @@ -43,6 +43,7 @@ EmberAfStatus emberAfIdentifyClusterServerCommandParse(EmberAfClusterCommand * c EmberAfStatus emberAfLevelControlClusterServerCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfLowPowerClusterServerCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfMediaPlaybackClusterServerCommandParse(EmberAfClusterCommand * cmd); +EmberAfStatus emberAfNetworkCommissioningClusterServerCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfOnOffClusterServerCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfScenesClusterServerCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfTemperatureMeasurementClusterServerCommandParse(EmberAfClusterCommand * cmd); @@ -135,6 +136,9 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd) case ZCL_MEDIA_PLAYBACK_CLUSTER_ID: result = emberAfMediaPlaybackClusterServerCommandParse(cmd); break; + case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID: + result = emberAfNetworkCommissioningClusterServerCommandParse(cmd); + break; case ZCL_ON_OFF_CLUSTER_ID: result = emberAfOnOffClusterServerCommandParse(cmd); break; @@ -1747,6 +1751,265 @@ EmberAfStatus emberAfMediaPlaybackClusterServerCommandParse(EmberAfClusterComman } return status(wasHandled, true, cmd->mfgSpecific); } +EmberAfStatus emberAfNetworkCommissioningClusterServerCommandParse(EmberAfClusterCommand * cmd) +{ + bool wasHandled = false; + + if (!cmd->mfgSpecific) + { + switch (cmd->commandId) + { + case ZCL_ADD_THREAD_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * operationalDataset; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + operationalDataset = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(operationalDataset) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterAddThreadNetworkCallback(operationalDataset, breadcrumb, timeoutMs); + break; + } + case ZCL_ADD_WI_FI_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * ssid; + uint8_t * credentials; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + ssid = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(ssid) + 1u); + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + credentials = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(credentials) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterAddWiFiNetworkCallback(ssid, credentials, breadcrumb, timeoutMs); + break; + } + case ZCL_DISABLE_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * networkID; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + networkID = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(networkID) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterDisableNetworkCallback(networkID, breadcrumb, timeoutMs); + break; + } + case ZCL_ENABLE_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * networkID; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + networkID = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(networkID) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterEnableNetworkCallback(networkID, breadcrumb, timeoutMs); + break; + } + case ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterGetLastNetworkCommissioningResultCallback(timeoutMs); + break; + } + case ZCL_REMOVE_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * NetworkID; + uint64_t Breadcrumb; + uint32_t TimeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + NetworkID = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(NetworkID) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + Breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + TimeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterRemoveNetworkCallback(NetworkID, Breadcrumb, TimeoutMs); + break; + } + case ZCL_SCAN_NETWORKS_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * ssid; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + ssid = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(ssid) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterScanNetworksCallback(ssid, breadcrumb, timeoutMs); + break; + } + case ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * operationalDataset; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + operationalDataset = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(operationalDataset) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterUpdateThreadNetworkCallback(operationalDataset, breadcrumb, timeoutMs); + break; + } + case ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID: { + uint16_t payloadOffset = cmd->payloadStartIndex; + uint8_t * ssid; + uint8_t * credentials; + uint64_t breadcrumb; + uint32_t timeoutMs; + + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + ssid = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(ssid) + 1u); + if (cmd->bufLen < payloadOffset + 1u) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + credentials = emberAfGetString(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + emberAfStringLength(credentials) + 1u); + if (cmd->bufLen < payloadOffset + 8) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + breadcrumb = emberAfGetInt64u(cmd->buffer, payloadOffset, cmd->bufLen); + payloadOffset = static_cast(payloadOffset + 8); + if (cmd->bufLen < payloadOffset + 4) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + timeoutMs = emberAfGetInt32u(cmd->buffer, payloadOffset, cmd->bufLen); + + wasHandled = emberAfNetworkCommissioningClusterUpdateWiFiNetworkCallback(ssid, credentials, breadcrumb, timeoutMs); + break; + } + default: { + // Unrecognized command ID, error status will apply. + break; + } + } + } + return status(wasHandled, true, cmd->mfgSpecific); +} EmberAfStatus emberAfOnOffClusterServerCommandParse(EmberAfClusterCommand * cmd) { bool wasHandled = false; diff --git a/examples/tv-app/tv-common/gen/callback-stub.cpp b/examples/tv-app/tv-common/gen/callback-stub.cpp index 565ae323a403d5..3e35321a66c256 100644 --- a/examples/tv-app/tv-common/gen/callback-stub.cpp +++ b/examples/tv-app/tv-common/gen/callback-stub.cpp @@ -63,6 +63,9 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) case ZCL_MEDIA_PLAYBACK_CLUSTER_ID: emberAfMediaPlaybackClusterInitCallback(endpoint); break; + case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID: + emberAfNetworkCommissioningClusterInitCallback(endpoint); + break; case ZCL_ON_OFF_CLUSTER_ID: emberAfOnOffClusterInitCallback(endpoint); break; @@ -138,6 +141,11 @@ void __attribute__((weak)) emberAfMediaPlaybackClusterInitCallback(EndpointId en // To prevent warning (void) endpoint; } +void __attribute__((weak)) emberAfNetworkCommissioningClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} void __attribute__((weak)) emberAfOnOffClusterInitCallback(EndpointId endpoint) { // To prevent warning diff --git a/examples/tv-app/tv-common/gen/callback.h b/examples/tv-app/tv-common/gen/callback.h index 887dabe4bc7ba0..1f411502dda27c 100644 --- a/examples/tv-app/tv-common/gen/callback.h +++ b/examples/tv-app/tv-common/gen/callback.h @@ -133,6 +133,14 @@ void emberAfLowPowerClusterInitCallback(chip::EndpointId endpoint); */ void emberAfMediaPlaybackClusterInitCallback(chip::EndpointId endpoint); +/** @brief Network Commissioning Cluster Init + * + * Cluster Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfNetworkCommissioningClusterInitCallback(chip::EndpointId endpoint); + /** @brief On/off Cluster Init * * Cluster Init @@ -1210,6 +1218,77 @@ EmberAfStatus emberAfMediaPlaybackClusterServerPreAttributeChangedCallback(chip: */ void emberAfMediaPlaybackClusterServerTickCallback(chip::EndpointId endpoint); +// +// Network Commissioning Cluster server +// + +/** @brief Network Commissioning Cluster Server Init + * + * Server Init + * + * @param endpoint Endpoint that is being initialized + */ +void emberAfNetworkCommissioningClusterServerInitCallback(chip::EndpointId endpoint); + +/** @brief Network Commissioning Cluster Server Attribute Changed + * + * Server Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + */ +void emberAfNetworkCommissioningClusterServerAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId); + +/** @brief Network Commissioning Cluster Server Manufacturer Specific Attribute Changed + * + * Server Manufacturer Specific Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute that changed + * @param manufacturerCode Manufacturer Code of the attribute that changed + */ +void emberAfNetworkCommissioningClusterServerManufacturerSpecificAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + uint16_t manufacturerCode); + +/** @brief Network Commissioning Cluster Server Message Sent + * + * Server Message Sent + * + * @param type The type of message sent + * @param indexOrDestination The destination or address to which the message was sent + * @param apsFrame The APS frame for the message + * @param msgLen The length of the message + * @param message The message that was sent + * @param status The status of the sent message + */ +void emberAfNetworkCommissioningClusterServerMessageSentCallback(EmberOutgoingMessageType type, uint64_t indexOrDestination, + EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message, + EmberStatus status); + +/** @brief Network Commissioning Cluster Server Pre Attribute Changed + * + * server Pre Attribute Changed + * + * @param endpoint Endpoint that is being initialized + * @param attributeId Attribute to be changed + * @param attributeType Attribute type + * @param size Attribute size + * @param value Attribute value + */ +EmberAfStatus emberAfNetworkCommissioningClusterServerPreAttributeChangedCallback(chip::EndpointId endpoint, + chip::AttributeId attributeId, + EmberAfAttributeType attributeType, uint8_t size, + uint8_t * value); + +/** @brief Network Commissioning Cluster Server Tick + * + * server Tick + * + * @param endpoint Endpoint that is being served + */ +void emberAfNetworkCommissioningClusterServerTickCallback(chip::EndpointId endpoint); + // // On/off Cluster server // @@ -2011,6 +2090,91 @@ bool emberAfMediaPlaybackClusterStartOverRequestCallback(); bool emberAfMediaPlaybackClusterStopRequestCallback(); +/** + * @brief Network Commissioning Cluster AddThreadNetwork Command callback + * @param operationalDataset + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterAddThreadNetworkCallback(uint8_t * operationalDataset, uint64_t breadcrumb, + uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster AddWiFiNetwork Command callback + * @param ssid + * @param credentials + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterAddWiFiNetworkCallback(uint8_t * ssid, uint8_t * credentials, uint64_t breadcrumb, + uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster DisableNetwork Command callback + * @param networkID + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterDisableNetworkCallback(uint8_t * networkID, uint64_t breadcrumb, uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster EnableNetwork Command callback + * @param networkID + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterEnableNetworkCallback(uint8_t * networkID, uint64_t breadcrumb, uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster GetLastNetworkCommissioningResult Command callback + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterGetLastNetworkCommissioningResultCallback(uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster RemoveNetwork Command callback + * @param networkID + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterRemoveNetworkCallback(uint8_t * NetworkID, uint64_t Breadcrumb, uint32_t TimeoutMs); + +/** + * @brief Network Commissioning Cluster ScanNetworks Command callback + * @param ssid + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterScanNetworksCallback(uint8_t * ssid, uint64_t breadcrumb, uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster UpdateThreadNetwork Command callback + * @param operationalDataset + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterUpdateThreadNetworkCallback(uint8_t * operationalDataset, uint64_t breadcrumb, + uint32_t timeoutMs); + +/** + * @brief Network Commissioning Cluster UpdateWiFiNetwork Command callback + * @param ssid + * @param credentials + * @param breadcrumb + * @param timeoutMs + */ + +bool emberAfNetworkCommissioningClusterUpdateWiFiNetworkCallback(uint8_t * ssid, uint8_t * credentials, uint64_t breadcrumb, + uint32_t timeoutMs); + /** * @brief On/off Cluster Off Command callback */ diff --git a/examples/tv-app/tv-common/gen/client-command-macro.h b/examples/tv-app/tv-common/gen/client-command-macro.h index f72c96f951dcff..79d1e159594a4a 100644 --- a/examples/tv-app/tv-common/gen/client-command-macro.h +++ b/examples/tv-app/tv-common/gen/client-command-macro.h @@ -1911,6 +1911,225 @@ \ ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); +/** @brief Command description for ScanNetworks + * + * Command: ScanNetworks + * @param ssid OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterScanNetworks(ssid, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SCAN_NETWORKS_COMMAND_ID, "uuu", ssid, breadcrumb, timeoutMs); + +/** @brief Command description for ScanNetworksResponse + * + * Command: ScanNetworksResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + * @param wifiScanResults WiFiInterfaceScanResult [] + * @param wifiScanResultsLen int + * @param threadScanResults ThreadInterfaceScanResult [] + * @param threadScanResultsLen int + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterScanNetworksResponse(errorCode, debugText, wifiScanResults, wifiScanResultsLen, threadScanResults, \ + threadScanResultsLen) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID, "uubb", errorCode, debugText, wifiScanResults, \ + wifiScanResultsLen, threadScanResults, threadScanResultsLen); + +/** @brief Command description for AddWiFiNetwork + * + * Command: AddWiFiNetwork + * @param ssid OCTET_STRING + * @param credentials OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); + +/** @brief Command description for AddWiFiNetworkResponse + * + * Command: AddWiFiNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddWiFiNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for UpdateWiFiNetwork + * + * Command: UpdateWiFiNetwork + * @param ssid OCTET_STRING + * @param credentials OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); + +/** @brief Command description for UpdateWiFiNetworkResponse + * + * Command: UpdateWiFiNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateWiFiNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for AddThreadNetwork + * + * Command: AddThreadNetwork + * @param operationalDataset OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); + +/** @brief Command description for AddThreadNetworkResponse + * + * Command: AddThreadNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddThreadNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for UpdateThreadNetwork + * + * Command: UpdateThreadNetwork + * @param operationalDataset OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); + +/** @brief Command description for UpdateThreadNetworkResponse + * + * Command: UpdateThreadNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateThreadNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for RemoveNetwork + * + * Command: RemoveNetwork + * @param NetworkID OCTET_STRING + * @param Breadcrumb INT64U + * @param TimeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterRemoveNetwork(NetworkID, Breadcrumb, TimeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_NETWORK_COMMAND_ID, "uuu", NetworkID, Breadcrumb, TimeoutMs); + +/** @brief Command description for RemoveNetworkResponse + * + * Command: RemoveNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterRemoveNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for EnableNetwork + * + * Command: EnableNetwork + * @param networkID OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterEnableNetwork(networkID, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ENABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); + +/** @brief Command description for EnableNetworkResponse + * + * Command: EnableNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterEnableNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for DisableNetwork + * + * Command: DisableNetwork + * @param networkID OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterDisableNetwork(networkID, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_DISABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); + +/** @brief Command description for DisableNetworkResponse + * + * Command: DisableNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterDisableNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for GetLastNetworkCommissioningResult + * + * Command: GetLastNetworkCommissioningResult + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterGetLastNetworkCommissioningResult(timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID, "u", timeoutMs); + /** @brief Command description for LockDoor * * Command: LockDoor @@ -5783,225 +6002,6 @@ ZCL_GET_ENDPOINT_LIST_REQUEST_COMMAND_ID, "uuuub", startIndex, total, startIndex, count, \ endpointInformationRecordList, endpointInformationRecordListLen); -/** @brief Command description for ScanNetworks - * - * Command: ScanNetworks - * @param ssid OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterScanNetworks(ssid, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_SCAN_NETWORKS_COMMAND_ID, "uuu", ssid, breadcrumb, timeoutMs); - -/** @brief Command description for ScanNetworksResponse - * - * Command: ScanNetworksResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - * @param wifiScanResults WiFiInterfaceScanResult [] - * @param wifiScanResultsLen int - * @param threadScanResults ThreadInterfaceScanResult [] - * @param threadScanResultsLen int - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterScanNetworksResponse(errorCode, debugText, wifiScanResults, wifiScanResultsLen, threadScanResults, \ - threadScanResultsLen) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID, "uubb", errorCode, debugText, wifiScanResults, \ - wifiScanResultsLen, threadScanResults, threadScanResultsLen); - -/** @brief Command description for AddWiFiNetwork - * - * Command: AddWiFiNetwork - * @param ssid OCTET_STRING - * @param credentials OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); - -/** @brief Command description for AddWiFiNetworkResponse - * - * Command: AddWiFiNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddWiFiNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for UpdateWiFiNetwork - * - * Command: UpdateWiFiNetwork - * @param ssid OCTET_STRING - * @param credentials OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); - -/** @brief Command description for UpdateWiFiNetworkResponse - * - * Command: UpdateWiFiNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateWiFiNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for AddThreadNetwork - * - * Command: AddThreadNetwork - * @param operationalDataset OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); - -/** @brief Command description for AddThreadNetworkResponse - * - * Command: AddThreadNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddThreadNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for UpdateThreadNetwork - * - * Command: UpdateThreadNetwork - * @param operationalDataset OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); - -/** @brief Command description for UpdateThreadNetworkResponse - * - * Command: UpdateThreadNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateThreadNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for RemoveNetwork - * - * Command: RemoveNetwork - * @param NetworkID OCTET_STRING - * @param Breadcrumb INT64U - * @param TimeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterRemoveNetwork(NetworkID, Breadcrumb, TimeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_REMOVE_NETWORK_COMMAND_ID, "uuu", NetworkID, Breadcrumb, TimeoutMs); - -/** @brief Command description for RemoveNetworkResponse - * - * Command: RemoveNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterRemoveNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for EnableNetwork - * - * Command: EnableNetwork - * @param networkID OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterEnableNetwork(networkID, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ENABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); - -/** @brief Command description for EnableNetworkResponse - * - * Command: EnableNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterEnableNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for DisableNetwork - * - * Command: DisableNetwork - * @param networkID OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterDisableNetwork(networkID, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_DISABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); - -/** @brief Command description for DisableNetworkResponse - * - * Command: DisableNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterDisableNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for GetLastNetworkCommissioningResult - * - * Command: GetLastNetworkCommissioningResult - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterGetLastNetworkCommissioningResult(timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID, "u", timeoutMs); - /** @brief Command description for Bind * * Command: Bind diff --git a/examples/tv-app/tv-common/gen/cluster-id.h b/examples/tv-app/tv-common/gen/cluster-id.h index d77da915200ab4..add8f83d188cf8 100644 --- a/examples/tv-app/tv-common/gen/cluster-id.h +++ b/examples/tv-app/tv-common/gen/cluster-id.h @@ -86,6 +86,9 @@ // Definitions for cluster: General Commissioning #define ZCL_GENERAL_COMMISSIONING_CLUSTER_ID (0x0030) +// Definitions for cluster: Network Commissioning +#define ZCL_NETWORK_COMMISSIONING_CLUSTER_ID (0x0031) + // Definitions for cluster: Shade Configuration #define ZCL_SHADE_CONFIG_CLUSTER_ID (0x0100) @@ -341,9 +344,6 @@ // Definitions for cluster: ZLL Commissioning #define ZCL_ZLL_COMMISSIONING_CLUSTER_ID (0x1000) -// Definitions for cluster: Network Commissioning -#define ZCL_NETWORK_COMMISSIONING_CLUSTER_ID (0xAAAA) - // Definitions for cluster: Binding #define ZCL_BINDING_CLUSTER_ID (0xF000) diff --git a/examples/tv-app/tv-common/gen/command-id.h b/examples/tv-app/tv-common/gen/command-id.h index adc2b1c6f32733..864943b5727fcd 100644 --- a/examples/tv-app/tv-common/gen/command-id.h +++ b/examples/tv-app/tv-common/gen/command-id.h @@ -238,6 +238,25 @@ #define ZCL_COMMISSIONING_COMPLETE_COMMAND_ID (0x06) #define ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID (0x07) +// Commands for cluster: Network Commissioning +#define ZCL_SCAN_NETWORKS_COMMAND_ID (0x00) +#define ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID (0x01) +#define ZCL_ADD_WI_FI_NETWORK_COMMAND_ID (0x02) +#define ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x03) +#define ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID (0x04) +#define ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x05) +#define ZCL_ADD_THREAD_NETWORK_COMMAND_ID (0x06) +#define ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x07) +#define ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID (0x08) +#define ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x09) +#define ZCL_REMOVE_NETWORK_COMMAND_ID (0x0A) +#define ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID (0x0B) +#define ZCL_ENABLE_NETWORK_COMMAND_ID (0x0C) +#define ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID (0x0D) +#define ZCL_DISABLE_NETWORK_COMMAND_ID (0x0E) +#define ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID (0x0F) +#define ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID (0x10) + // Commands for cluster: Door Lock #define ZCL_LOCK_DOOR_COMMAND_ID (0x00) #define ZCL_LOCK_DOOR_RESPONSE_COMMAND_ID (0x00) @@ -700,25 +719,6 @@ #define ZCL_GET_ENDPOINT_LIST_REQUEST_COMMAND_ID (0x42) #define ZCL_GET_ENDPOINT_LIST_RESPONSE_COMMAND_ID (0x42) -// Commands for cluster: Network Commissioning -#define ZCL_SCAN_NETWORKS_COMMAND_ID (0x00) -#define ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID (0x01) -#define ZCL_ADD_WI_FI_NETWORK_COMMAND_ID (0x02) -#define ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x03) -#define ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID (0x04) -#define ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x05) -#define ZCL_ADD_THREAD_NETWORK_COMMAND_ID (0x06) -#define ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x07) -#define ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID (0x08) -#define ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x09) -#define ZCL_REMOVE_NETWORK_COMMAND_ID (0x0A) -#define ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID (0x0B) -#define ZCL_ENABLE_NETWORK_COMMAND_ID (0x0C) -#define ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID (0x0D) -#define ZCL_DISABLE_NETWORK_COMMAND_ID (0x0E) -#define ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID (0x0F) -#define ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID (0x10) - // Commands for cluster: Binding #define ZCL_BIND_COMMAND_ID (0x00) #define ZCL_UNBIND_COMMAND_ID (0x01) diff --git a/examples/tv-app/tv-common/gen/endpoint_config.h b/examples/tv-app/tv-common/gen/endpoint_config.h index 5e0cee004c1e61..ed2ac088b822cd 100644 --- a/examples/tv-app/tv-common/gen/endpoint_config.h +++ b/examples/tv-app/tv-common/gen/endpoint_config.h @@ -152,7 +152,7 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 111 +#define GENERATED_ATTRIBUTE_COUNT 112 #define GENERATED_ATTRIBUTES \ { \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 2 } }, /* Identify (server): cluster revision */ \ @@ -206,7 +206,8 @@ }, /* Basic (server): SoftwareVersion */ \ { \ 0x000A, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(180) } \ - }, /* Basic (server): SoftwareVersionString */ \ + }, /* Basic (server): SoftwareVersionString */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Network Commissioning (server): cluster revision */ \ { \ 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), { (uint8_t *) 3 } \ }, /* Door Lock (client): cluster revision */ \ @@ -319,22 +320,22 @@ }, /* IAS Zone (server): IAS CIE address */ \ { 0x0011, ZAP_TYPE(INT8U), 1, 0, { (uint8_t *) 0xff } }, /* IAS Zone (server): Zone ID */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Low Power (server): cluster revision */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Application Basic (server): cluster revision */ \ { \ 0x0000, ZAP_TYPE(OCTET_STRING), 32, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(506) } \ }, /* Application Basic (server): vendor name */ \ { 0x0001, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0 } }, /* Application Basic (server): vendor id */ \ { \ 0x0002, ZAP_TYPE(OCTET_STRING), 32, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(538) } \ - }, /* Application Basic (server): application name */ \ - { 0x0003, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0 } }, /* Application Basic (server): product id */ \ + }, /* Application Basic (server): application name */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Application Basic (server): cluster revision */ \ + { 0x0003, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0 } }, /* Application Basic (server): product id */ \ { \ 0x0005, ZAP_TYPE(OCTET_STRING), 32, 0, { (uint8_t *) ZAP_LONG_DEFAULTS_INDEX(570) } \ }, /* Application Basic (server): application id */ \ { 0x0006, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0 } }, /* Application Basic (server): catalog vendor id */ \ { 0x0007, ZAP_TYPE(ENUM8), 1, 0, { (uint8_t *) 0x01 } }, /* Application Basic (server): application satus */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Media Playback (server): cluster revision */ \ { 0x0000, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0 } }, /* Media Playback (server): current state */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Media Playback (server): cluster revision */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Content Launch (server): cluster revision */ \ } @@ -372,7 +373,7 @@ }; #define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask -#define GENERATED_CLUSTER_COUNT 18 +#define GENERATED_CLUSTER_COUNT 19 #define GENERATED_CLUSTERS \ { \ { 0x0003, \ @@ -409,50 +410,53 @@ 0x0028, ZAP_ATTRIBUTE_INDEX(14), 12, 254, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Basic (server) */ \ { \ - 0x0101, ZAP_ATTRIBUTE_INDEX(26), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0031, ZAP_ATTRIBUTE_INDEX(26), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 1, Cluster: Network Commissioning (server) */ \ + { \ + 0x0101, ZAP_ATTRIBUTE_INDEX(27), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Door Lock (client) */ \ { 0x0101, \ - ZAP_ATTRIBUTE_INDEX(27), \ + ZAP_ATTRIBUTE_INDEX(28), \ 4, \ 5, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(ATTRIBUTE_CHANGED_FUNCTION), \ chipFuncArrayDoorLockServer }, /* Endpoint: 1, Cluster: Door Lock (server) */ \ { \ - 0x0103, ZAP_ATTRIBUTE_INDEX(31), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0103, ZAP_ATTRIBUTE_INDEX(32), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Barrier Control (client) */ \ { \ - 0x0103, ZAP_ATTRIBUTE_INDEX(32), 5, 7, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0103, ZAP_ATTRIBUTE_INDEX(33), 5, 7, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Barrier Control (server) */ \ { \ - 0x0300, ZAP_ATTRIBUTE_INDEX(37), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0300, ZAP_ATTRIBUTE_INDEX(38), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Color Control (client) */ \ { 0x0300, \ - ZAP_ATTRIBUTE_INDEX(38), \ + ZAP_ATTRIBUTE_INDEX(39), \ 51, \ 336, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayColorControlServer }, /* Endpoint: 1, Cluster: Color Control (server) */ \ { \ - 0x0402, ZAP_ATTRIBUTE_INDEX(89), 4, 8, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0402, ZAP_ATTRIBUTE_INDEX(90), 4, 8, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Temperature Measurement (server) */ \ { 0x0500, \ - ZAP_ATTRIBUTE_INDEX(93), \ + ZAP_ATTRIBUTE_INDEX(94), \ 6, \ 16, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION) | ZAP_CLUSTER_MASK(PRE_ATTRIBUTE_CHANGED_FUNCTION) | \ ZAP_CLUSTER_MASK(MESSAGE_SENT_FUNCTION), \ chipFuncArrayIasZoneServer }, /* Endpoint: 1, Cluster: IAS Zone (server) */ \ { \ - 0x0508, ZAP_ATTRIBUTE_INDEX(99), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0508, ZAP_ATTRIBUTE_INDEX(100), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Low Power (server) */ \ { \ - 0x050D, ZAP_ATTRIBUTE_INDEX(100), 8, 105, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x050D, ZAP_ATTRIBUTE_INDEX(101), 8, 105, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Application Basic (server) */ \ { \ - 0xF001, ZAP_ATTRIBUTE_INDEX(108), 2, 4, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0xF001, ZAP_ATTRIBUTE_INDEX(109), 2, 4, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Media Playback (server) */ \ { \ - 0xF002, ZAP_ATTRIBUTE_INDEX(110), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0xF002, ZAP_ATTRIBUTE_INDEX(111), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Content Launch (server) */ \ } @@ -461,7 +465,7 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 18, 766 }, \ + { ZAP_CLUSTER_INDEX(0), 19, 768 }, \ } // Largest attribute size is needed for various buffers @@ -471,7 +475,7 @@ #define ATTRIBUTE_SINGLETONS_SIZE (254) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (766) +#define ATTRIBUTE_MAX_SIZE (768) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (1) @@ -515,7 +519,7 @@ // Array of EmberAfCommandMetadata structs. #define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask -#define EMBER_AF_GENERATED_COMMAND_COUNT (141) +#define EMBER_AF_GENERATED_COMMAND_COUNT (158) #define GENERATED_COMMANDS \ { \ { 0x0003, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Identify (server): Identify */ \ @@ -558,6 +562,24 @@ { 0x0028, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): StartUp */ \ { 0x0028, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): ShutDown */ \ { 0x0028, 0x02, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Basic (server): Leave */ \ + { 0x0031, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): ScanNetworks */ \ + { 0x0031, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): ScanNetworksResponse */ \ + { 0x0031, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): AddWiFiNetwork */ \ + { 0x0031, 0x03, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): AddWiFiNetworkResponse */ \ + { 0x0031, 0x04, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): UpdateWiFiNetwork */ \ + { 0x0031, 0x05, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): UpdateWiFiNetworkResponse */ \ + { 0x0031, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): AddThreadNetwork */ \ + { 0x0031, 0x07, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): AddThreadNetworkResponse */ \ + { 0x0031, 0x08, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): UpdateThreadNetwork */ \ + { 0x0031, 0x09, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* Network Commissioning (server): UpdateThreadNetworkResponse */ \ + { 0x0031, 0x0A, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): RemoveNetwork */ \ + { 0x0031, 0x0B, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): RemoveNetworkResponse */ \ + { 0x0031, 0x0C, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): EnableNetwork */ \ + { 0x0031, 0x0D, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): EnableNetworkResponse */ \ + { 0x0031, 0x0E, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): DisableNetwork */ \ + { 0x0031, 0x0F, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Network Commissioning (server): DisableNetworkResponse */ \ + { 0x0031, 0x10, \ + ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Network Commissioning (server): GetLastNetworkCommissioningResult */ \ { 0x0101, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Door Lock (client): LockDoor */ \ { 0x0101, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Door Lock (client): LockDoorResponse */ \ { 0x0101, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Door Lock (server): LockDoor */ \ diff --git a/examples/tv-app/tv-common/gen/gen_config.h b/examples/tv-app/tv-common/gen/gen_config.h index fe38703a4f5d3b..341731eabe6215 100644 --- a/examples/tv-app/tv-common/gen/gen_config.h +++ b/examples/tv-app/tv-common/gen/gen_config.h @@ -44,6 +44,7 @@ #define EMBER_AF_LEVEL_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_LOW_POWER_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_MEDIA_PLAYBACK_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_NETWORK_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_ON_OFF_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_SCENES_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_TEMP_MEASUREMENT_CLUSTER_SERVER_ENDPOINT_COUNT (1) @@ -132,6 +133,11 @@ #define EMBER_AF_PLUGIN_MEDIA_PLAYBACK_SERVER #define EMBER_AF_PLUGIN_MEDIA_PLAYBACK +// Use this macro to check if the server side of the Network Commissioning cluster is included +#define ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING_SERVER +#define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING + // Use this macro to check if the server side of the On/off cluster is included #define ZCL_USING_ON_OFF_CLUSTER_SERVER #define EMBER_AF_PLUGIN_ON_OFF_SERVER diff --git a/examples/tv-app/tv-common/gen/print-cluster.h b/examples/tv-app/tv-common/gen/print-cluster.h index bd08d38a581506..8c737e93fea79c 100644 --- a/examples/tv-app/tv-common/gen/print-cluster.h +++ b/examples/tv-app/tv-common/gen/print-cluster.h @@ -156,6 +156,12 @@ #define CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER #endif +#if defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER { ZCL_NETWORK_COMMISSIONING_CLUSTER_ID, 49, "Network Commissioning" }, +#else +#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER +#endif + #if defined(ZCL_USING_SHADE_CONFIG_CLUSTER_SERVER) || defined(ZCL_USING_SHADE_CONFIG_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER { ZCL_SHADE_CONFIG_CLUSTER_ID, 256, "Shade Configuration" }, #else @@ -734,12 +740,6 @@ #define CHIP_PRINTCLUSTER_ZLL_COMMISSIONING_CLUSTER #endif -#if defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_CLIENT) -#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER { ZCL_NETWORK_COMMISSIONING_CLUSTER_ID, 43690, "Network Commissioning" }, -#else -#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER -#endif - #if defined(ZCL_USING_BINDING_CLUSTER_SERVER) || defined(ZCL_USING_BINDING_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_BINDING_CLUSTER { ZCL_BINDING_CLUSTER_ID, 61440, "Binding" }, #else @@ -812,6 +812,7 @@ CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER \ CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER \ + CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DOOR_LOCK_CLUSTER \ CHIP_PRINTCLUSTER_WINDOW_COVERING_CLUSTER \ @@ -897,7 +898,6 @@ CHIP_PRINTCLUSTER_ELECTRICAL_MEASUREMENT_CLUSTER \ CHIP_PRINTCLUSTER_DIAGNOSTICS_CLUSTER \ CHIP_PRINTCLUSTER_ZLL_COMMISSIONING_CLUSTER \ - CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_BINDING_CLUSTER \ CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER \ CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER \ diff --git a/examples/tv-app/tv-common/tv-app.zap b/examples/tv-app/tv-common/tv-app.zap index af07b1a7dc06a0..4c7ff527d87ca3 100644 --- a/examples/tv-app/tv-common/tv-app.zap +++ b/examples/tv-app/tv-common/tv-app.zap @@ -1,5 +1,5 @@ { - "writeTime": "Mon Mar 08 2021 19:19:58 GMT+0100 (Central European Standard Time)", + "writeTime": "Fri Mar 12 2021 15:20:50 GMT+0800 (China Standard Time)", "featureLevel": 11, "creator": "zap", "keyValuePairs": [ @@ -38,13 +38,12 @@ "deviceTypeProfileId": 259, "clusters": [ { - "name": "Basic", - "code": 40, + "name": "Identify", + "code": 3, "mfgCode": null, - "define": "BASIC_CLUSTER", + "define": "IDENTIFY_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "cluster revision", @@ -53,49 +52,41 @@ "side": "client", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "2", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 } - ] - }, - { - "name": "Basic", - "code": 40, - "mfgCode": null, - "define": "BASIC_CLUSTER", - "side": "server", - "enabled": 1, + ], "commands": [ { - "name": "StartUp", + "name": "Identify", "code": 0, "mfgCode": null, - "source": "server", + "source": "client", "incoming": 1, "outgoing": 1 }, { - "name": "ShutDown", + "name": "IdentifyQuery", "code": 1, "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "Leave", - "code": 2, - "mfgCode": null, - "source": "server", + "source": "client", "incoming": 1, "outgoing": 1 } - ], + ] + }, + { + "name": "Identify", + "code": 3, + "mfgCode": null, + "define": "IDENTIFY_CLUSTER", + "side": "server", + "enabled": 1, "attributes": [ { "name": "cluster revision", @@ -104,127 +95,369 @@ "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "2", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "InteractionModelVersion", + "name": "identify time", "code": 0, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0x0000", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - }, + } + ], + "commands": [ { - "name": "VendorName", - "code": 1, + "name": "IdentifyQueryResponse", + "code": 0, "mfgCode": null, - "side": "server", + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ] + }, + { + "name": "Groups", + "code": 4, + "mfgCode": null, + "define": "GROUPS_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "3", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 + } + ], + "commands": [ + { + "name": "AddGroup", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 }, { - "name": "VendorID", + "name": "ViewGroup", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetGroupMembership", "code": 2, "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveGroup", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveAllGroups", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "AddGroupIfIdentifying", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ] + }, + { + "name": "Groups", + "code": 4, + "mfgCode": null, + "define": "GROUPS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "AddGroupResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ViewGroupResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetGroupMembershipResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveGroupResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "3", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "ProductName", - "code": 3, + "name": "name support", + "code": 0, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 + } + ] + }, + { + "name": "Scenes", + "code": 5, + "mfgCode": null, + "define": "SCENES_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "AddScene", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 }, { - "name": "ProductID", + "name": "ViewScene", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveScene", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveAllScenes", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "StoreScene", "code": 4, "mfgCode": null, - "side": "server", + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RecallScene", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetSceneMembership", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "3", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 + } + ] + }, + { + "name": "Scenes", + "code": 5, + "mfgCode": null, + "define": "SCENES_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "AddSceneResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ViewSceneResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveSceneResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveAllScenesResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 }, { - "name": "UserLabel", - "code": 5, + "name": "StoreSceneResponse", + "code": 4, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetSceneMembershipResponse", + "code": 6, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "3", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "Location", - "code": 6, + "name": "scene count", + "code": 0, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0x00", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "HardwareVersion", - "code": 7, + "name": "current scene", + "code": 1, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, "defaultValue": "0x00", "reportable": 0, @@ -233,28 +466,28 @@ "reportableChange": 0 }, { - "name": "HardwareVersionString", - "code": 8, + "name": "current group", + "code": 2, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0x0000", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "SoftwareVersion", - "code": 9, + "name": "scene valid", + "code": 3, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, "defaultValue": "0x00", "reportable": 0, @@ -263,13 +496,13 @@ "reportableChange": 0 }, { - "name": "SoftwareVersionString", - "code": 10, + "name": "name support", + "code": 4, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 1, + "singleton": 0, "bounded": 0, "defaultValue": "", "reportable": 0, @@ -280,15 +513,15 @@ ] }, { - "name": "Identify", - "code": 3, + "name": "On/off", + "code": 6, "mfgCode": null, - "define": "IDENTIFY_CLUSTER", + "define": "ON_OFF_CLUSTER", "side": "client", "enabled": 0, "commands": [ { - "name": "Identify", + "name": "Off", "code": 0, "mfgCode": null, "source": "client", @@ -296,12 +529,20 @@ "outgoing": 1 }, { - "name": "IdentifyQuery", + "name": "On", "code": 1, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 1 + }, + { + "name": "Toggle", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 } ], "attributes": [ @@ -323,12 +564,13 @@ ] }, { - "name": "Identify", - "code": 3, + "name": "On/off", + "code": 6, "mfgCode": null, - "define": "IDENTIFY_CLUSTER", + "define": "ON_OFF_CLUSTER", "side": "server", "enabled": 1, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -346,7 +588,7 @@ "reportableChange": 0 }, { - "name": "identify time", + "name": "on/off", "code": 0, "mfgCode": null, "side": "server", @@ -354,34 +596,24 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", - "reportable": 0, + "defaultValue": "0x00", + "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [ - { - "name": "IdentifyQueryResponse", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - } ] }, { - "name": "Groups", - "code": 4, + "name": "Level Control", + "code": 8, "mfgCode": null, - "define": "GROUPS_CLUSTER", + "define": "LEVEL_CONTROL_CLUSTER", "side": "client", "enabled": 0, "commands": [ { - "name": "AddGroup", + "name": "MoveToLevel", "code": 0, "mfgCode": null, "source": "client", @@ -389,7 +621,7 @@ "outgoing": 1 }, { - "name": "ViewGroup", + "name": "Move", "code": 1, "mfgCode": null, "source": "client", @@ -397,7 +629,7 @@ "outgoing": 1 }, { - "name": "GetGroupMembership", + "name": "Step", "code": 2, "mfgCode": null, "source": "client", @@ -405,7 +637,7 @@ "outgoing": 1 }, { - "name": "RemoveGroup", + "name": "Stop", "code": 3, "mfgCode": null, "source": "client", @@ -413,7 +645,7 @@ "outgoing": 1 }, { - "name": "RemoveAllGroups", + "name": "MoveToLevelWithOnOff", "code": 4, "mfgCode": null, "source": "client", @@ -421,12 +653,28 @@ "outgoing": 1 }, { - "name": "AddGroupIfIdentifying", + "name": "MoveWithOnOff", "code": 5, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 1 + }, + { + "name": "StepWithOnOff", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "StopWithOnOff", + "code": 7, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 } ], "attributes": [ @@ -448,46 +696,13 @@ ] }, { - "name": "Groups", - "code": 4, + "name": "Level Control", + "code": 8, "mfgCode": null, - "define": "GROUPS_CLUSTER", + "define": "LEVEL_CONTROL_CLUSTER", "side": "server", "enabled": 1, - "commands": [ - { - "name": "AddGroupResponse", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "ViewGroupResponse", - "code": 1, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "GetGroupMembershipResponse", - "code": 2, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "RemoveGroupResponse", - "code": 3, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - } - ], + "commands": [], "attributes": [ { "name": "cluster revision", @@ -498,94 +713,37 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "name support", - "code": 0, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Scenes", - "code": 5, - "mfgCode": null, - "define": "SCENES_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [ - { - "name": "AddScene", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "ViewScene", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "RemoveScene", - "code": 2, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "RemoveAllScenes", - "code": 3, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "StoreScene", - "code": 4, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "RecallScene", - "code": 5, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 }, { - "name": "GetSceneMembership", - "code": 6, + "name": "current level", + "code": 0, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 } - ], + ] + }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -594,7 +752,7 @@ "side": "client", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, "defaultValue": "3", "reportable": 0, @@ -605,15 +763,15 @@ ] }, { - "name": "Scenes", - "code": 5, + "name": "Basic", + "code": 40, "mfgCode": null, - "define": "SCENES_CLUSTER", + "define": "BASIC_CLUSTER", "side": "server", "enabled": 1, "commands": [ { - "name": "AddSceneResponse", + "name": "StartUp", "code": 0, "mfgCode": null, "source": "server", @@ -621,7 +779,7 @@ "outgoing": 1 }, { - "name": "ViewSceneResponse", + "name": "ShutDown", "code": 1, "mfgCode": null, "source": "server", @@ -629,36 +787,12 @@ "outgoing": 1 }, { - "name": "RemoveSceneResponse", + "name": "Leave", "code": 2, "mfgCode": null, "source": "server", "incoming": 1, "outgoing": 1 - }, - { - "name": "RemoveAllScenesResponse", - "code": 3, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "StoreSceneResponse", - "code": 4, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "GetSceneMembershipResponse", - "code": 6, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 } ], "attributes": [ @@ -669,7 +803,7 @@ "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, "defaultValue": "3", "reportable": 0, @@ -678,73 +812,163 @@ "reportableChange": 0 }, { - "name": "scene count", + "name": "InteractionModelVersion", "code": 0, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "current scene", + "name": "VendorName", "code": 1, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "current group", + "name": "VendorID", "code": 2, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "scene valid", + "name": "ProductName", "code": 3, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "name support", + "name": "ProductID", "code": 4, "mfgCode": null, "side": "server", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UserLabel", + "code": 5, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Location", + "code": 6, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersion", + "code": 7, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersionString", + "code": 8, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersion", + "code": 9, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersionString", + "code": 10, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, "bounded": 0, "defaultValue": "", "reportable": 0, @@ -755,15 +979,15 @@ ] }, { - "name": "On/off", - "code": 6, + "name": "Network Commissioning", + "code": 49, "mfgCode": null, - "define": "ON_OFF_CLUSTER", + "define": "NETWORK_COMMISSIONING_CLUSTER", "side": "client", "enabled": 0, "commands": [ { - "name": "Off", + "name": "ScanNetworks", "code": 0, "mfgCode": null, "source": "client", @@ -771,150 +995,157 @@ "outgoing": 1 }, { - "name": "On", - "code": 1, + "name": "AddWiFiNetwork", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "UpdateWiFiNetwork", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "AddThreadNetwork", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "UpdateThreadNetwork", + "code": 8, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveNetwork", + "code": 10, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 1 }, { - "name": "Toggle", - "code": 2, + "name": "EnableNetwork", + "code": 12, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 1 - } - ], - "attributes": [ + }, { - "name": "cluster revision", - "code": 65533, + "name": "DisableNetwork", + "code": 14, "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "2", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetLastNetworkCommissioningResult", + "code": 16, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 } - ] - }, - { - "name": "On/off", - "code": 6, - "mfgCode": null, - "define": "ON_OFF_CLUSTER", - "side": "server", - "enabled": 1, - "commands": [], + ], "attributes": [ { "name": "cluster revision", "code": 65533, "mfgCode": null, - "side": "server", + "side": "client", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "2", + "defaultValue": "0x0001", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - }, - { - "name": "on/off", - "code": 0, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 } ] }, { - "name": "Level Control", - "code": 8, + "name": "Network Commissioning", + "code": 49, "mfgCode": null, - "define": "LEVEL_CONTROL_CLUSTER", - "side": "client", - "enabled": 0, + "define": "NETWORK_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 1, "commands": [ { - "name": "MoveToLevel", - "code": 0, + "name": "ScanNetworksResponse", + "code": 1, "mfgCode": null, - "source": "client", + "source": "server", "incoming": 1, "outgoing": 1 }, { - "name": "Move", - "code": 1, + "name": "AddWiFiNetworkResponse", + "code": 3, "mfgCode": null, - "source": "client", - "incoming": 1, + "source": "server", + "incoming": 0, "outgoing": 1 }, { - "name": "Step", - "code": 2, + "name": "UpdateWiFiNetworkResponse", + "code": 5, "mfgCode": null, - "source": "client", - "incoming": 1, + "source": "server", + "incoming": 0, "outgoing": 1 }, { - "name": "Stop", - "code": 3, + "name": "AddThreadNetworkResponse", + "code": 7, "mfgCode": null, - "source": "client", - "incoming": 1, + "source": "server", + "incoming": 0, "outgoing": 1 }, { - "name": "MoveToLevelWithOnOff", - "code": 4, + "name": "UpdateThreadNetworkResponse", + "code": 9, "mfgCode": null, - "source": "client", - "incoming": 1, + "source": "server", + "incoming": 0, "outgoing": 1 }, { - "name": "MoveWithOnOff", - "code": 5, + "name": "RemoveNetworkResponse", + "code": 11, "mfgCode": null, - "source": "client", + "source": "server", "incoming": 1, "outgoing": 1 }, { - "name": "StepWithOnOff", - "code": 6, + "name": "EnableNetworkResponse", + "code": 13, "mfgCode": null, - "source": "client", + "source": "server", "incoming": 1, "outgoing": 1 }, { - "name": "StopWithOnOff", - "code": 7, + "name": "DisableNetworkResponse", + "code": 15, "mfgCode": null, - "source": "client", + "source": "server", "incoming": 1, "outgoing": 1 } @@ -924,12 +1155,12 @@ "name": "cluster revision", "code": 65533, "mfgCode": null, - "side": "client", + "side": "server", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "0x0001", "reportable": 0, "minInterval": 0, "maxInterval": 65344, @@ -938,18 +1169,18 @@ ] }, { - "name": "Level Control", - "code": 8, + "name": "Door Lock", + "code": 257, "mfgCode": null, - "define": "LEVEL_CONTROL_CLUSTER", - "side": "server", + "define": "DOOR_LOCK_CLUSTER", + "side": "client", "enabled": 1, "attributes": [ { "name": "cluster revision", "code": 65533, "mfgCode": null, - "side": "server", + "side": "client", "included": 1, "storageOption": "RAM", "singleton": 0, @@ -959,32 +1190,8 @@ "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 - }, - { - "name": "current level", - "code": 0, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 } ], - "commands": [] - }, - { - "name": "Door Lock", - "code": 257, - "mfgCode": null, - "define": "DOOR_LOCK_CLUSTER", - "side": "client", - "enabled": 1, "commands": [ { "name": "LockDoor", @@ -1170,23 +1377,6 @@ "incoming": 1, "outgoing": 1 } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } ] }, { @@ -1788,6 +1978,23 @@ "define": "COLOR_CONTROL_CLUSTER", "side": "client", "enabled": 1, + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], "commands": [ { "name": "MoveToHue", @@ -1901,23 +2108,6 @@ "incoming": 1, "outgoing": 1 } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } ] }, { @@ -1927,6 +2117,7 @@ "define": "COLOR_CONTROL_CLUSTER", "side": "server", "enabled": 1, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -2693,8 +2884,7 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [] + ] }, { "name": "Temperature Measurement", @@ -2703,7 +2893,6 @@ "define": "TEMP_MEASUREMENT_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "cluster revision", @@ -2720,7 +2909,8 @@ "maxInterval": 65344, "reportableChange": 0 } - ] + ], + "commands": [] }, { "name": "Temperature Measurement", @@ -2850,24 +3040,6 @@ "define": "IAS_ZONE_CLUSTER", "side": "server", "enabled": 1, - "commands": [ - { - "name": "ZoneStatusChangeNotification", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "ZoneEnrollRequest", - "code": 1, - "mfgCode": null, - "source": "server", - "incoming": 0, - "outgoing": 1 - } - ], "attributes": [ { "name": "cluster revision", @@ -2959,6 +3131,24 @@ "maxInterval": 65344, "reportableChange": 0 } + ], + "commands": [ + { + "name": "ZoneStatusChangeNotification", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "ZoneEnrollRequest", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } ] }, { @@ -3029,7 +3219,6 @@ "define": "APPLICATION_BASIC_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "cluster revision", @@ -3046,7 +3235,8 @@ "maxInterval": 65344, "reportableChange": 0 } - ] + ], + "commands": [] }, { "name": "Application Basic", @@ -3343,6 +3533,23 @@ "define": "CONTENT_LAUNCH_CLUSTER", "side": "client", "enabled": 0, + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], "commands": [ { "name": "LaunchContent", @@ -3360,23 +3567,6 @@ "incoming": 1, "outgoing": 1 } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0001", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } ] }, { @@ -3434,4 +3624,4 @@ "networkId": 1 } ] -} +} \ No newline at end of file diff --git a/src/app/chip-zcl-zpro-codec-api.h b/src/app/chip-zcl-zpro-codec-api.h index 437fd961591507..e6c14354c1099e 100644 --- a/src/app/chip-zcl-zpro-codec-api.h +++ b/src/app/chip-zcl-zpro-codec-api.h @@ -42,7 +42,7 @@ | LevelControl | 0x0008 | | LowPower | 0x0508 | | MediaPlayback | 0xF001 | -| NetworkCommissioning | 0xAAAA | +| NetworkCommissioning | 0x0031 | | OnOff | 0x0006 | | Scenes | 0x0005 | | TemperatureMeasurement | 0x0402 | @@ -1858,7 +1858,7 @@ chip::System::PacketBufferHandle encodeMediaPlaybackClusterReadClusterRevisionAt chip::EndpointId destinationEndpoint); /*----------------------------------------------------------------------------*\ -| Cluster NetworkCommissioning | 0xAAAA | +| Cluster NetworkCommissioning | 0x0031 | |------------------------------------------------------------------------------| | Commands: | | | * AddThreadNetwork | 0x06 | diff --git a/src/app/clusters/network-commissioning/network-commissioning.cpp b/src/app/clusters/network-commissioning/network-commissioning.cpp index ae0d400e9ae458..52d8219cf01d19 100644 --- a/src/app/clusters/network-commissioning/network-commissioning.cpp +++ b/src/app/clusters/network-commissioning/network-commissioning.cpp @@ -220,6 +220,7 @@ CHIP_ERROR DoEnableNetwork(NetworkInfo * network) { case NetworkType::kThread: #if CHIP_DEVICE_CONFIG_ENABLE_THREAD + ReturnErrorOnFailure(DeviceLayer::ThreadStackMgr().SetThreadEnabled(false)); ReturnErrorOnFailure( DeviceLayer::ThreadStackMgr().SetThreadProvision(network->mData.mThread.mDataset, network->mData.mThread.mDatasetLen)); ReturnErrorOnFailure(DeviceLayer::ThreadStackMgr().SetThreadEnabled(true)); diff --git a/src/app/encoder.cpp b/src/app/encoder.cpp index bee0afea08dbc8..88f47303dc1cd8 100644 --- a/src/app/encoder.cpp +++ b/src/app/encoder.cpp @@ -113,7 +113,7 @@ uint16_t encodeApsFrame(uint8_t * buffer, uint16_t buf_length, EmberApsFrame * a | LevelControl | 0x0008 | | LowPower | 0x0508 | | MediaPlayback | 0xF001 | -| NetworkCommissioning | 0xAAAA | +| NetworkCommissioning | 0x0031 | | OnOff | 0x0006 | | Scenes | 0x0005 | | TemperatureMeasurement | 0x0402 | @@ -247,7 +247,7 @@ uint16_t encodeApsFrame(uint8_t * buffer, uint16_t buf_length, EmberApsFrame * a #define ZCL_START_OVER_REQUEST_COMMAND_ID (0x03) #define ZCL_STOP_REQUEST_COMMAND_ID (0x02) -#define NETWORK_COMMISSIONING_CLUSTER_ID 0xAAAA +#define NETWORK_COMMISSIONING_CLUSTER_ID 0x0031 #define ZCL_ADD_THREAD_NETWORK_COMMAND_ID (0x06) #define ZCL_ADD_WI_FI_NETWORK_COMMAND_ID (0x02) #define ZCL_DISABLE_NETWORK_COMMAND_ID (0x0E) @@ -3182,7 +3182,7 @@ PacketBufferHandle encodeMediaPlaybackClusterReadClusterRevisionAttribute(uint8_ } /*----------------------------------------------------------------------------*\ -| Cluster NetworkCommissioning | 0xAAAA | +| Cluster NetworkCommissioning | 0x0031 | |------------------------------------------------------------------------------| | Commands: | | | * AddThreadNetwork | 0x06 | diff --git a/src/app/zap-templates/zcl/commissioning.xml b/src/app/zap-templates/zcl/commissioning.xml index 8e8a35ba8314ba..97b417b87cefe3 100644 --- a/src/app/zap-templates/zcl/commissioning.xml +++ b/src/app/zap-templates/zcl/commissioning.xml @@ -59,7 +59,7 @@ limitations under the License. Network Commissioning CHIP TODO - 0xaaaa + 0x0031 NETWORK_COMMISSIONING_CLUSTER true true diff --git a/src/controller/CHIPClusters.h b/src/controller/CHIPClusters.h index 751dd903f0064f..5e6c39ffc63e9b 100644 --- a/src/controller/CHIPClusters.h +++ b/src/controller/CHIPClusters.h @@ -41,7 +41,7 @@ constexpr ClusterId kIdentifyClusterId = 0x0003; constexpr ClusterId kLevelControlClusterId = 0x0008; constexpr ClusterId kLowPowerClusterId = 0x0508; constexpr ClusterId kMediaPlaybackClusterId = 0xF001; -constexpr ClusterId kNetworkCommissioningClusterId = 0xAAAA; +constexpr ClusterId kNetworkCommissioningClusterId = 0x0031; constexpr ClusterId kOnOffClusterId = 0x0006; constexpr ClusterId kScenesClusterId = 0x0005; constexpr ClusterId kTemperatureMeasurementClusterId = 0x0402; diff --git a/src/controller/controller-clusters.zap b/src/controller/controller-clusters.zap index 6ee591f40574dd..52bf3b0aefd0a4 100644 --- a/src/controller/controller-clusters.zap +++ b/src/controller/controller-clusters.zap @@ -1,5 +1,5 @@ { - "writeTime": "Thu Mar 11 2021 17:28:29 GMT+0100 (Central European Standard Time)", + "writeTime": "Fri Mar 12 2021 15:15:13 GMT+0800 (China Standard Time)", "featureLevel": 11, "creator": "zap", "keyValuePairs": [ @@ -137,23 +137,6 @@ "define": "GROUPS_CLUSTER", "side": "client", "enabled": 0, - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ], "commands": [ { "name": "AddGroup", @@ -203,6 +186,23 @@ "incoming": 1, "outgoing": 1 } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } ] }, { @@ -286,6 +286,23 @@ "define": "SCENES_CLUSTER", "side": "client", "enabled": 0, + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], "commands": [ { "name": "AddScene", @@ -343,23 +360,6 @@ "incoming": 1, "outgoing": 1 } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } ] }, { @@ -743,6 +743,23 @@ "define": "DOOR_LOCK_CLUSTER", "side": "client", "enabled": 0, + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], "commands": [ { "name": "LockDoor", @@ -928,23 +945,6 @@ "incoming": 1, "outgoing": 1 } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } ] }, { @@ -2777,6 +2777,16 @@ "define": "IDENTIFY_CLUSTER", "side": "server", "enabled": 1, + "commands": [ + { + "name": "IdentifyQueryResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], "attributes": [ { "name": "cluster revision", @@ -2808,16 +2818,6 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [ - { - "name": "IdentifyQueryResponse", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - } ] }, { @@ -3810,15 +3810,15 @@ ] }, { - "name": "Door Lock", - "code": 257, + "name": "Network Commissioning", + "code": 49, "mfgCode": null, - "define": "DOOR_LOCK_CLUSTER", + "define": "NETWORK_COMMISSIONING_CLUSTER", "side": "client", "enabled": 0, "commands": [ { - "name": "LockDoor", + "name": "ScanNetworks", "code": 0, "mfgCode": null, "source": "client", @@ -3826,138 +3826,328 @@ "outgoing": 1 }, { - "name": "UnlockDoor", - "code": 1, + "name": "AddWiFiNetwork", + "code": 2, "mfgCode": null, "source": "client", "incoming": 1, - "outgoing": 1 + "outgoing": 0 }, { - "name": "UnlockWithTimeout", - "code": 3, + "name": "UpdateWiFiNetwork", + "code": 4, "mfgCode": null, "source": "client", "incoming": 1, - "outgoing": 1 + "outgoing": 0 }, { - "name": "GetLogRecord", - "code": 4, + "name": "AddThreadNetwork", + "code": 6, "mfgCode": null, "source": "client", "incoming": 1, - "outgoing": 1 + "outgoing": 0 }, { - "name": "SetPin", - "code": 5, + "name": "UpdateThreadNetwork", + "code": 8, "mfgCode": null, "source": "client", "incoming": 1, - "outgoing": 1 + "outgoing": 0 }, { - "name": "GetPin", - "code": 6, + "name": "RemoveNetwork", + "code": 10, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 1 }, { - "name": "ClearPin", - "code": 7, + "name": "EnableNetwork", + "code": 12, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 1 }, { - "name": "ClearAllPins", - "code": 8, + "name": "DisableNetwork", + "code": 14, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 1 }, { - "name": "SetWeekdaySchedule", - "code": 11, + "name": "GetLastNetworkCommissioningResult", + "code": 16, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 1 - }, + } + ], + "attributes": [ { - "name": "GetWeekdaySchedule", - "code": 12, + "name": "cluster revision", + "code": 65533, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Network Commissioning", + "code": 49, + "mfgCode": null, + "define": "NETWORK_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ { - "name": "ClearWeekdaySchedule", - "code": 13, + "name": "ScanNetworksResponse", + "code": 1, "mfgCode": null, - "source": "client", + "source": "server", "incoming": 1, "outgoing": 1 }, { - "name": "SetYeardaySchedule", - "code": 14, + "name": "AddWiFiNetworkResponse", + "code": 3, "mfgCode": null, - "source": "client", - "incoming": 1, + "source": "server", + "incoming": 0, "outgoing": 1 }, { - "name": "GetYeardaySchedule", - "code": 15, + "name": "UpdateWiFiNetworkResponse", + "code": 5, "mfgCode": null, - "source": "client", - "incoming": 1, + "source": "server", + "incoming": 0, "outgoing": 1 }, { - "name": "ClearYeardaySchedule", - "code": 16, + "name": "AddThreadNetworkResponse", + "code": 7, "mfgCode": null, - "source": "client", - "incoming": 1, + "source": "server", + "incoming": 0, "outgoing": 1 }, { - "name": "SetHolidaySchedule", - "code": 17, + "name": "UpdateThreadNetworkResponse", + "code": 9, "mfgCode": null, - "source": "client", - "incoming": 1, + "source": "server", + "incoming": 0, "outgoing": 1 }, { - "name": "GetHolidaySchedule", - "code": 18, + "name": "RemoveNetworkResponse", + "code": 11, "mfgCode": null, - "source": "client", + "source": "server", "incoming": 1, "outgoing": 1 }, { - "name": "ClearHolidaySchedule", - "code": 19, + "name": "EnableNetworkResponse", + "code": 13, "mfgCode": null, - "source": "client", + "source": "server", "incoming": 1, "outgoing": 1 }, { - "name": "SetUserType", - "code": 20, + "name": "DisableNetworkResponse", + "code": 15, "mfgCode": null, - "source": "client", + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Door Lock", + "code": 257, + "mfgCode": null, + "define": "DOOR_LOCK_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "LockDoor", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "UnlockDoor", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "UnlockWithTimeout", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetLogRecord", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetPin", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetPin", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ClearPin", + "code": 7, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ClearAllPins", + "code": 8, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetWeekdaySchedule", + "code": 11, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetWeekdaySchedule", + "code": 12, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ClearWeekdaySchedule", + "code": 13, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetYeardaySchedule", + "code": 14, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetYeardaySchedule", + "code": 15, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ClearYeardaySchedule", + "code": 16, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetHolidaySchedule", + "code": 17, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetHolidaySchedule", + "code": 18, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ClearHolidaySchedule", + "code": 19, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetUserType", + "code": 20, + "mfgCode": null, + "source": "client", "incoming": 1, "outgoing": 1 }, @@ -4027,24 +4217,6 @@ "define": "DOOR_LOCK_CLUSTER", "side": "server", "enabled": 1, - "commands": [ - { - "name": "LockDoorResponse", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "UnlockDoorResponse", - "code": 1, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - } - ], "attributes": [ { "name": "cluster revision", @@ -4481,6 +4653,24 @@ "maxInterval": 65344, "reportableChange": 0 } + ], + "commands": [ + { + "name": "LockDoorResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "UnlockDoorResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } ] }, { @@ -4533,6 +4723,7 @@ "define": "BARRIER_CONTROL_CLUSTER", "side": "server", "enabled": 1, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -4609,8 +4800,7 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [] + ] }, { "name": "Color Control", @@ -4619,6 +4809,23 @@ "define": "COLOR_CONTROL_CLUSTER", "side": "client", "enabled": 0, + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], "commands": [ { "name": "MoveToHue", @@ -4732,23 +4939,6 @@ "incoming": 1, "outgoing": 1 } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "3", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } ] }, { @@ -6010,196 +6200,6 @@ } ] }, - { - "name": "Network Commissioning", - "code": 43690, - "mfgCode": null, - "define": "NETWORK_COMMISSIONING_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [ - { - "name": "ScanNetworks", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "AddWiFiNetwork", - "code": 2, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "UpdateWiFiNetwork", - "code": 4, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "AddThreadNetwork", - "code": 6, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "UpdateThreadNetwork", - "code": 8, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "RemoveNetwork", - "code": 10, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "EnableNetwork", - "code": 12, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "DisableNetwork", - "code": 14, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "GetLastNetworkCommissioningResult", - "code": 16, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0001", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, - { - "name": "Network Commissioning", - "code": 43690, - "mfgCode": null, - "define": "NETWORK_COMMISSIONING_CLUSTER", - "side": "server", - "enabled": 1, - "commands": [ - { - "name": "ScanNetworksResponse", - "code": 1, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "AddWiFiNetworkResponse", - "code": 3, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "UpdateWiFiNetworkResponse", - "code": 5, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "AddThreadNetworkResponse", - "code": 7, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "UpdateThreadNetworkResponse", - "code": 9, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "RemoveNetworkResponse", - "code": 11, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "EnableNetworkResponse", - "code": 13, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "DisableNetworkResponse", - "code": 15, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0001", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ] - }, { "name": "Binding", "code": 61440, diff --git a/src/darwin/Framework/CHIP/gen/attribute-id.h b/src/darwin/Framework/CHIP/gen/attribute-id.h index 8c8757f826ca7f..72a0198e2f97be 100644 --- a/src/darwin/Framework/CHIP/gen/attribute-id.h +++ b/src/darwin/Framework/CHIP/gen/attribute-id.h @@ -391,6 +391,12 @@ #define ZCL_FABRIC_ID_ATTRIBUTE_ID (0x0000) #define ZCL_BREADCRUMB_ATTRIBUTE_ID (0x0001) +// Attribute ids for cluster: Network Commissioning + +// Client attributes + +// Server attributes + // Attribute ids for cluster: Shade Configuration // Client attributes @@ -4084,12 +4090,6 @@ // Server attributes -// Attribute ids for cluster: Network Commissioning - -// Client attributes - -// Server attributes - // Attribute ids for cluster: Binding // Client attributes diff --git a/src/darwin/Framework/CHIP/gen/client-command-macro.h b/src/darwin/Framework/CHIP/gen/client-command-macro.h index f72c96f951dcff..79d1e159594a4a 100644 --- a/src/darwin/Framework/CHIP/gen/client-command-macro.h +++ b/src/darwin/Framework/CHIP/gen/client-command-macro.h @@ -1911,6 +1911,225 @@ \ ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); +/** @brief Command description for ScanNetworks + * + * Command: ScanNetworks + * @param ssid OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterScanNetworks(ssid, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SCAN_NETWORKS_COMMAND_ID, "uuu", ssid, breadcrumb, timeoutMs); + +/** @brief Command description for ScanNetworksResponse + * + * Command: ScanNetworksResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + * @param wifiScanResults WiFiInterfaceScanResult [] + * @param wifiScanResultsLen int + * @param threadScanResults ThreadInterfaceScanResult [] + * @param threadScanResultsLen int + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterScanNetworksResponse(errorCode, debugText, wifiScanResults, wifiScanResultsLen, threadScanResults, \ + threadScanResultsLen) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID, "uubb", errorCode, debugText, wifiScanResults, \ + wifiScanResultsLen, threadScanResults, threadScanResultsLen); + +/** @brief Command description for AddWiFiNetwork + * + * Command: AddWiFiNetwork + * @param ssid OCTET_STRING + * @param credentials OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); + +/** @brief Command description for AddWiFiNetworkResponse + * + * Command: AddWiFiNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddWiFiNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for UpdateWiFiNetwork + * + * Command: UpdateWiFiNetwork + * @param ssid OCTET_STRING + * @param credentials OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); + +/** @brief Command description for UpdateWiFiNetworkResponse + * + * Command: UpdateWiFiNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateWiFiNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for AddThreadNetwork + * + * Command: AddThreadNetwork + * @param operationalDataset OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); + +/** @brief Command description for AddThreadNetworkResponse + * + * Command: AddThreadNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterAddThreadNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for UpdateThreadNetwork + * + * Command: UpdateThreadNetwork + * @param operationalDataset OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); + +/** @brief Command description for UpdateThreadNetworkResponse + * + * Command: UpdateThreadNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterUpdateThreadNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for RemoveNetwork + * + * Command: RemoveNetwork + * @param NetworkID OCTET_STRING + * @param Breadcrumb INT64U + * @param TimeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterRemoveNetwork(NetworkID, Breadcrumb, TimeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_NETWORK_COMMAND_ID, "uuu", NetworkID, Breadcrumb, TimeoutMs); + +/** @brief Command description for RemoveNetworkResponse + * + * Command: RemoveNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterRemoveNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for EnableNetwork + * + * Command: EnableNetwork + * @param networkID OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterEnableNetwork(networkID, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ENABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); + +/** @brief Command description for EnableNetworkResponse + * + * Command: EnableNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterEnableNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for DisableNetwork + * + * Command: DisableNetwork + * @param networkID OCTET_STRING + * @param breadcrumb INT64U + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterDisableNetwork(networkID, breadcrumb, timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_DISABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); + +/** @brief Command description for DisableNetworkResponse + * + * Command: DisableNetworkResponse + * @param errorCode INT8U + * @param debugText CHAR_STRING + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterDisableNetworkResponse(errorCode, debugText) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); + +/** @brief Command description for GetLastNetworkCommissioningResult + * + * Command: GetLastNetworkCommissioningResult + * @param timeoutMs INT32U + */ +#define emberAfFillCommandNetwork \ + CommissioningClusterGetLastNetworkCommissioningResult(timeoutMs) \ + emberAfFillExternalBuffer(mask, \ + \ + ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID, "u", timeoutMs); + /** @brief Command description for LockDoor * * Command: LockDoor @@ -5783,225 +6002,6 @@ ZCL_GET_ENDPOINT_LIST_REQUEST_COMMAND_ID, "uuuub", startIndex, total, startIndex, count, \ endpointInformationRecordList, endpointInformationRecordListLen); -/** @brief Command description for ScanNetworks - * - * Command: ScanNetworks - * @param ssid OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterScanNetworks(ssid, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_SCAN_NETWORKS_COMMAND_ID, "uuu", ssid, breadcrumb, timeoutMs); - -/** @brief Command description for ScanNetworksResponse - * - * Command: ScanNetworksResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - * @param wifiScanResults WiFiInterfaceScanResult [] - * @param wifiScanResultsLen int - * @param threadScanResults ThreadInterfaceScanResult [] - * @param threadScanResultsLen int - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterScanNetworksResponse(errorCode, debugText, wifiScanResults, wifiScanResultsLen, threadScanResults, \ - threadScanResultsLen) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID, "uubb", errorCode, debugText, wifiScanResults, \ - wifiScanResultsLen, threadScanResults, threadScanResultsLen); - -/** @brief Command description for AddWiFiNetwork - * - * Command: AddWiFiNetwork - * @param ssid OCTET_STRING - * @param credentials OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); - -/** @brief Command description for AddWiFiNetworkResponse - * - * Command: AddWiFiNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddWiFiNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for UpdateWiFiNetwork - * - * Command: UpdateWiFiNetwork - * @param ssid OCTET_STRING - * @param credentials OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateWiFiNetwork(ssid, credentials, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID, "uuuu", ssid, credentials, breadcrumb, timeoutMs); - -/** @brief Command description for UpdateWiFiNetworkResponse - * - * Command: UpdateWiFiNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateWiFiNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for AddThreadNetwork - * - * Command: AddThreadNetwork - * @param operationalDataset OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); - -/** @brief Command description for AddThreadNetworkResponse - * - * Command: AddThreadNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterAddThreadNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for UpdateThreadNetwork - * - * Command: UpdateThreadNetwork - * @param operationalDataset OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateThreadNetwork(operationalDataset, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID, "uuu", operationalDataset, breadcrumb, timeoutMs); - -/** @brief Command description for UpdateThreadNetworkResponse - * - * Command: UpdateThreadNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterUpdateThreadNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for RemoveNetwork - * - * Command: RemoveNetwork - * @param NetworkID OCTET_STRING - * @param Breadcrumb INT64U - * @param TimeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterRemoveNetwork(NetworkID, Breadcrumb, TimeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_REMOVE_NETWORK_COMMAND_ID, "uuu", NetworkID, Breadcrumb, TimeoutMs); - -/** @brief Command description for RemoveNetworkResponse - * - * Command: RemoveNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterRemoveNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for EnableNetwork - * - * Command: EnableNetwork - * @param networkID OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterEnableNetwork(networkID, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ENABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); - -/** @brief Command description for EnableNetworkResponse - * - * Command: EnableNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterEnableNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for DisableNetwork - * - * Command: DisableNetwork - * @param networkID OCTET_STRING - * @param breadcrumb INT64U - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterDisableNetwork(networkID, breadcrumb, timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_DISABLE_NETWORK_COMMAND_ID, "uuu", networkID, breadcrumb, timeoutMs); - -/** @brief Command description for DisableNetworkResponse - * - * Command: DisableNetworkResponse - * @param errorCode INT8U - * @param debugText CHAR_STRING - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterDisableNetworkResponse(errorCode, debugText) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID, "uu", errorCode, debugText); - -/** @brief Command description for GetLastNetworkCommissioningResult - * - * Command: GetLastNetworkCommissioningResult - * @param timeoutMs INT32U - */ -#define emberAfFillCommandNetwork \ - CommissioningClusterGetLastNetworkCommissioningResult(timeoutMs) \ - emberAfFillExternalBuffer(mask, \ - \ - ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID, "u", timeoutMs); - /** @brief Command description for Bind * * Command: Bind diff --git a/src/darwin/Framework/CHIP/gen/cluster-id.h b/src/darwin/Framework/CHIP/gen/cluster-id.h index d77da915200ab4..add8f83d188cf8 100644 --- a/src/darwin/Framework/CHIP/gen/cluster-id.h +++ b/src/darwin/Framework/CHIP/gen/cluster-id.h @@ -86,6 +86,9 @@ // Definitions for cluster: General Commissioning #define ZCL_GENERAL_COMMISSIONING_CLUSTER_ID (0x0030) +// Definitions for cluster: Network Commissioning +#define ZCL_NETWORK_COMMISSIONING_CLUSTER_ID (0x0031) + // Definitions for cluster: Shade Configuration #define ZCL_SHADE_CONFIG_CLUSTER_ID (0x0100) @@ -341,9 +344,6 @@ // Definitions for cluster: ZLL Commissioning #define ZCL_ZLL_COMMISSIONING_CLUSTER_ID (0x1000) -// Definitions for cluster: Network Commissioning -#define ZCL_NETWORK_COMMISSIONING_CLUSTER_ID (0xAAAA) - // Definitions for cluster: Binding #define ZCL_BINDING_CLUSTER_ID (0xF000) diff --git a/src/darwin/Framework/CHIP/gen/command-id.h b/src/darwin/Framework/CHIP/gen/command-id.h index adc2b1c6f32733..864943b5727fcd 100644 --- a/src/darwin/Framework/CHIP/gen/command-id.h +++ b/src/darwin/Framework/CHIP/gen/command-id.h @@ -238,6 +238,25 @@ #define ZCL_COMMISSIONING_COMPLETE_COMMAND_ID (0x06) #define ZCL_COMMISSIONING_COMPLETE_RESPONSE_COMMAND_ID (0x07) +// Commands for cluster: Network Commissioning +#define ZCL_SCAN_NETWORKS_COMMAND_ID (0x00) +#define ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID (0x01) +#define ZCL_ADD_WI_FI_NETWORK_COMMAND_ID (0x02) +#define ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x03) +#define ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID (0x04) +#define ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x05) +#define ZCL_ADD_THREAD_NETWORK_COMMAND_ID (0x06) +#define ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x07) +#define ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID (0x08) +#define ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x09) +#define ZCL_REMOVE_NETWORK_COMMAND_ID (0x0A) +#define ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID (0x0B) +#define ZCL_ENABLE_NETWORK_COMMAND_ID (0x0C) +#define ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID (0x0D) +#define ZCL_DISABLE_NETWORK_COMMAND_ID (0x0E) +#define ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID (0x0F) +#define ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID (0x10) + // Commands for cluster: Door Lock #define ZCL_LOCK_DOOR_COMMAND_ID (0x00) #define ZCL_LOCK_DOOR_RESPONSE_COMMAND_ID (0x00) @@ -700,25 +719,6 @@ #define ZCL_GET_ENDPOINT_LIST_REQUEST_COMMAND_ID (0x42) #define ZCL_GET_ENDPOINT_LIST_RESPONSE_COMMAND_ID (0x42) -// Commands for cluster: Network Commissioning -#define ZCL_SCAN_NETWORKS_COMMAND_ID (0x00) -#define ZCL_SCAN_NETWORKS_RESPONSE_COMMAND_ID (0x01) -#define ZCL_ADD_WI_FI_NETWORK_COMMAND_ID (0x02) -#define ZCL_ADD_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x03) -#define ZCL_UPDATE_WI_FI_NETWORK_COMMAND_ID (0x04) -#define ZCL_UPDATE_WI_FI_NETWORK_RESPONSE_COMMAND_ID (0x05) -#define ZCL_ADD_THREAD_NETWORK_COMMAND_ID (0x06) -#define ZCL_ADD_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x07) -#define ZCL_UPDATE_THREAD_NETWORK_COMMAND_ID (0x08) -#define ZCL_UPDATE_THREAD_NETWORK_RESPONSE_COMMAND_ID (0x09) -#define ZCL_REMOVE_NETWORK_COMMAND_ID (0x0A) -#define ZCL_REMOVE_NETWORK_RESPONSE_COMMAND_ID (0x0B) -#define ZCL_ENABLE_NETWORK_COMMAND_ID (0x0C) -#define ZCL_ENABLE_NETWORK_RESPONSE_COMMAND_ID (0x0D) -#define ZCL_DISABLE_NETWORK_COMMAND_ID (0x0E) -#define ZCL_DISABLE_NETWORK_RESPONSE_COMMAND_ID (0x0F) -#define ZCL_GET_LAST_NETWORK_COMMISSIONING_RESULT_COMMAND_ID (0x10) - // Commands for cluster: Binding #define ZCL_BIND_COMMAND_ID (0x00) #define ZCL_UNBIND_COMMAND_ID (0x01) diff --git a/src/darwin/Framework/CHIP/gen/print-cluster.h b/src/darwin/Framework/CHIP/gen/print-cluster.h index bd08d38a581506..8c737e93fea79c 100644 --- a/src/darwin/Framework/CHIP/gen/print-cluster.h +++ b/src/darwin/Framework/CHIP/gen/print-cluster.h @@ -156,6 +156,12 @@ #define CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER #endif +#if defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_CLIENT) +#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER { ZCL_NETWORK_COMMISSIONING_CLUSTER_ID, 49, "Network Commissioning" }, +#else +#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER +#endif + #if defined(ZCL_USING_SHADE_CONFIG_CLUSTER_SERVER) || defined(ZCL_USING_SHADE_CONFIG_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER { ZCL_SHADE_CONFIG_CLUSTER_ID, 256, "Shade Configuration" }, #else @@ -734,12 +740,6 @@ #define CHIP_PRINTCLUSTER_ZLL_COMMISSIONING_CLUSTER #endif -#if defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER) || defined(ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_CLIENT) -#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER { ZCL_NETWORK_COMMISSIONING_CLUSTER_ID, 43690, "Network Commissioning" }, -#else -#define CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER -#endif - #if defined(ZCL_USING_BINDING_CLUSTER_SERVER) || defined(ZCL_USING_BINDING_CLUSTER_CLIENT) #define CHIP_PRINTCLUSTER_BINDING_CLUSTER { ZCL_BINDING_CLUSTER_ID, 61440, "Binding" }, #else @@ -812,6 +812,7 @@ CHIP_PRINTCLUSTER_KEEPALIVE_CLUSTER \ CHIP_PRINTCLUSTER_BASIC_CLUSTER \ CHIP_PRINTCLUSTER_GENERAL_COMMISSIONING_CLUSTER \ + CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DOOR_LOCK_CLUSTER \ CHIP_PRINTCLUSTER_WINDOW_COVERING_CLUSTER \ @@ -897,7 +898,6 @@ CHIP_PRINTCLUSTER_ELECTRICAL_MEASUREMENT_CLUSTER \ CHIP_PRINTCLUSTER_DIAGNOSTICS_CLUSTER \ CHIP_PRINTCLUSTER_ZLL_COMMISSIONING_CLUSTER \ - CHIP_PRINTCLUSTER_NETWORK_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_BINDING_CLUSTER \ CHIP_PRINTCLUSTER_MEDIA_PLAYBACK_CLUSTER \ CHIP_PRINTCLUSTER_CONTENT_LAUNCH_CLUSTER \ From ebe57740ae79d1db56a28796a63de26cd0f7a251 Mon Sep 17 00:00:00 2001 From: Markus Becker Date: Wed, 17 Mar 2021 14:43:26 +0100 Subject: [PATCH 36/39] [nordic] Fix compilation if NFC commissioning is disabled (#5396) If NFC commissioning is disabled, build breaks because * sNFC variable is used unconditionally * NFCWidget.cpp is built unconditionally Signed-off-by: Markus Becker --- examples/lighting-app/nrfconnect/CMakeLists.txt | 7 ++++++- examples/lighting-app/nrfconnect/main/AppTask.cpp | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/examples/lighting-app/nrfconnect/CMakeLists.txt b/examples/lighting-app/nrfconnect/CMakeLists.txt index bc46f101bc75c2..28e152f86fb8a2 100644 --- a/examples/lighting-app/nrfconnect/CMakeLists.txt +++ b/examples/lighting-app/nrfconnect/CMakeLists.txt @@ -45,7 +45,6 @@ target_sources(app PRIVATE ${LIGHTING_COMMON}/gen/call-command-handler.cpp ${LIGHTING_COMMON}/gen/callback-stub.cpp ${NRFCONNECT_COMMON}/util/LEDWidget.cpp - ${NRFCONNECT_COMMON}/util/NFCWidget.cpp ${NRFCONNECT_COMMON}/util/ThreadUtil.cpp ${NRFCONNECT_COMMON}/app/Service.cpp ${CHIP_ROOT}/src/app/server/DataModelHandler.cpp @@ -71,6 +70,12 @@ target_sources(app PRIVATE ${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning.cpp ) +if (CONFIG_CHIP_NFC_COMMISSIONING) +target_sources(app PRIVATE + ${NRFCONNECT_COMMON}/util/NFCWidget.cpp +) +endif(CONFIG_CHIP_NFC_COMMISSIONING) + if (CONFIG_CHIP_PW_RPC) set(PIGWEED_ROOT "${CHIP_ROOT}/third_party/pigweed/repo") diff --git a/examples/lighting-app/nrfconnect/main/AppTask.cpp b/examples/lighting-app/nrfconnect/main/AppTask.cpp index fb91a3812bf2a9..421eddc1d211ea 100644 --- a/examples/lighting-app/nrfconnect/main/AppTask.cpp +++ b/examples/lighting-app/nrfconnect/main/AppTask.cpp @@ -383,6 +383,7 @@ void AppTask::StartBLEAdvertisementHandler(AppEvent * aEvent) return; } +#ifdef CONFIG_CHIP_NFC_COMMISSIONING if (!sNFC.IsTagEmulationStarted()) { if (!(GetAppTask().StartNFCTag() < 0)) @@ -398,6 +399,7 @@ void AppTask::StartBLEAdvertisementHandler(AppEvent * aEvent) { LOG_INF("NFC Tag emulation is already started"); } +#endif if (ConnectivityMgr().IsBLEAdvertisingEnabled()) { From 9754931942e875791178639c297647406d0d1e9f Mon Sep 17 00:00:00 2001 From: chrisbeach59 <33329862+chrisbeach59@users.noreply.github.com> Date: Wed, 17 Mar 2021 09:46:18 -0400 Subject: [PATCH 37/39] specify path for util.h (#5408) --- .../zap-templates/templates/app/call-command-handler-src.zapt | 2 +- .../zap-templates/templates/app/im-cluster-command-handler.zapt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/zap-templates/templates/app/call-command-handler-src.zapt b/src/app/zap-templates/templates/app/call-command-handler-src.zapt index d4fc4e84d4da3f..bf35d8dcd338ec 100644 --- a/src/app/zap-templates/templates/app/call-command-handler-src.zapt +++ b/src/app/zap-templates/templates/app/call-command-handler-src.zapt @@ -7,7 +7,7 @@ #include "callback.h" #include "cluster-id.h" #include "command-id.h" -#include "util.h" +#include "app/util/util.h" using namespace chip; diff --git a/src/app/zap-templates/templates/app/im-cluster-command-handler.zapt b/src/app/zap-templates/templates/app/im-cluster-command-handler.zapt index 2d5d886e5061cb..c99090e40e1415 100644 --- a/src/app/zap-templates/templates/app/im-cluster-command-handler.zapt +++ b/src/app/zap-templates/templates/app/im-cluster-command-handler.zapt @@ -8,7 +8,7 @@ #include "callback.h" #include "cluster-id.h" #include "command-id.h" -#include "util.h" +#include "app/util/util.h" #include From 2f064a53f037b7d544bae8c2aa93ef662d4d8adc Mon Sep 17 00:00:00 2001 From: Pankaj Garg Date: Wed, 17 Mar 2021 06:47:58 -0700 Subject: [PATCH 38/39] Persist controller's key ID across reboots (#5385) * Persist controller's key ID across reboots - Controller initialized rendezvous session with the key ID. Currently, the sessions established via rendezvous get persisted across controller reboots, and are used for storing encryption key. This change enables controller to remember the next key ID that should be used for further device pairing so that key ID will be across all paired devices. * restyled * check for valid persistent storage delegate before using it. * address review comments * add TODO to store key ID as binary data * Use correct key for storing value * fix build issue * use new storage delegate methods --- src/controller/CHIPDeviceController.cpp | 55 ++++++++++++++++++------- src/controller/CHIPDeviceController.h | 6 +++ 2 files changed, 47 insertions(+), 14 deletions(-) diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index 92b954f4346128..87b75ba01a0376 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -69,6 +70,10 @@ using namespace chip::Encoding; constexpr const char kPairedDeviceListKeyPrefix[] = "ListPairedDevices"; constexpr const char kPairedDeviceKeyPrefix[] = "PairedDevice"; +constexpr const char kNextAvailableKeyID[] = "StartKeyID"; + +// Maximum key ID is 65535 (given it's uint16_t type) +constexpr uint16_t kMaxKeyIDStringSize = 6; // This macro generates a key using node ID an key prefix, and performs the given action // on that key. @@ -497,12 +502,31 @@ DeviceCommissioner::DeviceCommissioner() mPairedDevicesUpdated = false; } +CHIP_ERROR DeviceCommissioner::LoadKeyId(PersistentStorageDelegate * delegate, uint16_t & out) +{ + VerifyOrReturnError(delegate != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + + // TODO: Consider storing value in binary representation instead of converting to string + char keyIDStr[kMaxKeyIDStringSize]; + uint16_t size = sizeof(keyIDStr); + ReturnErrorOnFailure(delegate->SyncGetKeyValue(kNextAvailableKeyID, keyIDStr, size)); + + ReturnErrorCodeIf(!ArgParser::ParseInt(keyIDStr, out), CHIP_ERROR_INTERNAL); + + return CHIP_NO_ERROR; +} + CHIP_ERROR DeviceCommissioner::Init(NodeId localDeviceId, PersistentStorageDelegate * storageDelegate, DevicePairingDelegate * pairingDelegate, System::Layer * systemLayer, Inet::InetLayer * inetLayer) { ReturnErrorOnFailure(DeviceController::Init(localDeviceId, storageDelegate, systemLayer, inetLayer)); + if (LoadKeyId(mStorageDelegate, mNextKeyId) != CHIP_NO_ERROR) + { + mNextKeyId = 0; + } + mPairingDelegate = pairingDelegate; return CHIP_NO_ERROR; } @@ -515,11 +539,7 @@ CHIP_ERROR DeviceCommissioner::Shutdown() PersistDeviceList(); - if (mRendezvousSession != nullptr) - { - chip::Platform::Delete(mRendezvousSession); - mRendezvousSession = nullptr; - } + FreeRendezvousSession(); DeviceController::Shutdown(); return CHIP_NO_ERROR; @@ -566,6 +586,7 @@ CHIP_ERROR DeviceCommissioner::PairDevice(NodeId remoteDeviceId, RendezvousParam mIsIPRendezvous = (params.GetPeerAddress().GetTransportType() != Transport::Type::kBle); mRendezvousSession = chip::Platform::New(this); VerifyOrExit(mRendezvousSession != nullptr, err = CHIP_ERROR_NO_MEMORY); + mRendezvousSession->SetNextKeyId(mNextKeyId); err = mRendezvousSession->Init(params.SetLocalNodeId(mLocalDeviceId).SetRemoteNodeId(remoteDeviceId), mTransportMgr, mSessionManager, admin); SuccessOrExit(err); @@ -583,10 +604,9 @@ CHIP_ERROR DeviceCommissioner::PairDevice(NodeId remoteDeviceId, RendezvousParam if (err != CHIP_NO_ERROR) { // Delete the current rendezvous session only if a device is not currently being paired. - if (mDeviceBeingPaired == kNumMaxActiveDevices && mRendezvousSession != nullptr) + if (mDeviceBeingPaired == kNumMaxActiveDevices) { - chip::Platform::Delete(mRendezvousSession); - mRendezvousSession = nullptr; + FreeRendezvousSession(); } if (device != nullptr) @@ -654,11 +674,7 @@ CHIP_ERROR DeviceCommissioner::StopPairing(NodeId remoteDeviceId) Device * device = &mActiveDevices[mDeviceBeingPaired]; VerifyOrReturnError(device->GetDeviceId() == remoteDeviceId, CHIP_ERROR_INVALID_DEVICE_DESCRIPTOR); - if (mRendezvousSession != nullptr) - { - chip::Platform::Delete(mRendezvousSession); - mRendezvousSession = nullptr; - } + FreeRendezvousSession(); ReleaseDevice(device); mDeviceBeingPaired = kNumMaxActiveDevices; @@ -681,13 +697,19 @@ CHIP_ERROR DeviceCommissioner::UnpairDevice(NodeId remoteDeviceId) return CHIP_NO_ERROR; } -void DeviceCommissioner::RendezvousCleanup(CHIP_ERROR status) +void DeviceCommissioner::FreeRendezvousSession() { if (mRendezvousSession != nullptr) { + mNextKeyId = mRendezvousSession->GetNextKeyId(); chip::Platform::Delete(mRendezvousSession); mRendezvousSession = nullptr; } +} + +void DeviceCommissioner::RendezvousCleanup(CHIP_ERROR status) +{ + FreeRendezvousSession(); if (mPairingDelegate != nullptr) { @@ -801,6 +823,11 @@ void DeviceCommissioner::PersistDeviceList() } chip::Platform::MemoryFree(serialized); } + + // TODO: Consider storing value in binary representation instead of converting to string + char keyIDStr[kMaxKeyIDStringSize]; + snprintf(keyIDStr, sizeof(keyIDStr), "%d", mNextKeyId); + mStorageDelegate->AsyncSetKeyValue(kNextAvailableKeyID, keyIDStr); } } diff --git a/src/controller/CHIPDeviceController.h b/src/controller/CHIPDeviceController.h index 98cf13955eda79..bb00165d78e0f7 100644 --- a/src/controller/CHIPDeviceController.h +++ b/src/controller/CHIPDeviceController.h @@ -337,6 +337,12 @@ class DLL_EXPORT DeviceCommissioner : public DeviceController, public Rendezvous DeviceCommissionerRendezvousAdvertisementDelegate mRendezvousAdvDelegate; void PersistDeviceList(); + + void FreeRendezvousSession(); + + CHIP_ERROR LoadKeyId(PersistentStorageDelegate * delegate, uint16_t & out); + + uint16_t mNextKeyId = 0; }; } // namespace Controller From 3f681e235fae462bee39740c2c55b6aedbdb0454 Mon Sep 17 00:00:00 2001 From: jepenven-silabs <67962328+jepenven-silabs@users.noreply.github.com> Date: Wed, 17 Mar 2021 12:10:06 -0400 Subject: [PATCH 39/39] Add Silabs RCP setup (#5426) --- docs/guides/linux_thread_connectivity.md | 29 +++++++++++++++-------- docs/images/linux_thread_connectivity.svg | 2 +- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/docs/guides/linux_thread_connectivity.md b/docs/guides/linux_thread_connectivity.md index 35ca8de7bf2cb5..70befbaaec7058 100644 --- a/docs/guides/linux_thread_connectivity.md +++ b/docs/guides/linux_thread_connectivity.md @@ -46,7 +46,8 @@ devices is ensured in the following way: You need the following hardware and software for this configuration: - OpenThread Radio Co-Processor device (for example, - [nRF52840 Dongle](https://www.nordicsemi.com/Software-and-tools/Development-Kits/nRF52840-Dongle)) + [nRF52840 Dongle](https://www.nordicsemi.com/Software-and-tools/Development-Kits/nRF52840-Dongle), + [Thunderboard Sense 2](https://www.silabs.com/development-tools/thunderboard/thunderboard-sense-two-kit)) - Linux machine with Ubuntu v20.04 or later
@@ -60,16 +61,24 @@ The configuration process is composed of the following steps: ### Configuring OpenThread Radio Co-Processor -Read -[Configuring OpenThread Radio Co-processor on nRF52840 Dongle](openthread_rcp_nrf_dongle.md) -to learn how to configure Nordic Semiconductor's -[nRF52840 Dongle](https://www.nordicsemi.com/Software-and-tools/Development-Kits/nRF52840-Dongle) -as OpenThread Radio Co-Processor. +#### On Nordic Hardware -You can replace the nRF52840 Dongle with a variety of development boards from -different vendors. If you are using a Raspberry Pi as your testing platform, you -can execute this step on a more powerful Linux machine to shorten the firmware -build time. +> Read +> [Configuring OpenThread Radio Co-processor on nRF52840 Dongle](openthread_rcp_nrf_dongle.md) +> to learn how to configure Nordic Semiconductor's +> [nRF52840 Dongle](https://www.nordicsemi.com/Software-and-tools/Development-Kits/nRF52840-Dongle) +> as OpenThread Radio Co-Processor. + +#### On Silicon Labs Hardware + +> Please refer to this +> [guide](https://www.silabs.com/documents/public/application-notes/an1256-using-sl-rcp-with-openthread-border-router.pdf) +> to configure the OpenThread Radio Co-Processor on the Thunderboard sense 2. + +You can replace the nRF52840 Dongle or the Thunderboard with a variety of +development boards from different vendors. If you are using a Raspberry Pi as +your testing platform, you can execute this step on a more powerful Linux +machine to shorten the firmware build time. ### Configuring OpenThread Border Router diff --git a/docs/images/linux_thread_connectivity.svg b/docs/images/linux_thread_connectivity.svg index 5c354dac59350e..75fc719a81d178 100644 --- a/docs/images/linux_thread_connectivity.svg +++ b/docs/images/linux_thread_connectivity.svg @@ -229,7 +229,7 @@ dy="14.400145" class="st5" id="tspan67" - style="font-size:12.00012016px">(on nRF52840 Dongle or other) + style="font-size:12.00012016px">(nRF52840 Dongle/Thunderboard/etc...)