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/.gitmodules b/.gitmodules index fd9e0b53b12536..0cb36b7aed6680 100644 --- a/.gitmodules +++ b/.gitmodules @@ -28,8 +28,8 @@ branch = master [submodule "pigweed"] path = third_party/pigweed/repo - url = https://pigweed.googlesource.com/pigweed/pigweed - branch = master + url = https://github.com/google/pigweed.git + branch = main [submodule "openthread"] path = third_party/openthread/repo url = https://github.com/openthread/openthread.git 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 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/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/docs/BUILDING.md b/docs/BUILDING.md index 3ccc65e6862ca7..20fc97747009ba 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 @@ -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 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/docs/guides/linux_thread_connectivity.md b/docs/guides/linux_thread_connectivity.md new file mode 100644 index 00000000000000..70befbaaec7058 --- /dev/null +++ b/docs/guides/linux_thread_connectivity.md @@ -0,0 +1,131 @@ +# 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), + [Thunderboard Sense 2](https://www.silabs.com/development-tools/thunderboard/thunderboard-sense-two-kit)) +- 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 + +#### On Nordic Hardware + +> 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 + +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/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/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..75fc719a81d178 --- /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 (nRF52840 Dongle/Thunderboard/etc...) + + + 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/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 49f08bd885a779..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": "Mon Mar 08 2021 19:19:42 GMT+0100 (Central European Standard Time)", + "writeTime": "Fri Mar 12 2021 15:15:46 GMT+0800 (China 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 - } ] }, { @@ -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 + } ] }, { @@ -661,7 +570,6 @@ "define": "ON_OFF_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "cluster revision", @@ -693,7 +601,8 @@ "maxInterval": 65344, "reportableChange": 0 } - ] + ], + "commands": [] }, { "name": "Level Control", @@ -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 + } ] }, { @@ -828,12 +737,13 @@ ] }, { - "name": "Door Lock", - "code": 257, + "name": "Basic", + "code": 40, "mfgCode": null, - "define": "DOOR_LOCK_CLUSTER", + "define": "BASIC_CLUSTER", "side": "client", "enabled": 0, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -842,7 +752,7 @@ "side": "client", "included": 1, "storageOption": "RAM", - "singleton": 0, + "singleton": 1, "bounded": 0, "defaultValue": "3", "reportable": 0, @@ -850,45 +760,269 @@ "maxInterval": 65344, "reportableChange": 0 } - ], + ] + }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "server", + "enabled": 1, "commands": [ { - "name": "LockDoor", + "name": "StartUp", "code": 0, "mfgCode": null, - "source": "client", + "source": "server", "incoming": 1, "outgoing": 1 }, { - "name": "UnlockDoor", + "name": "ShutDown", "code": 1, "mfgCode": null, - "source": "client", + "source": "server", "incoming": 1, "outgoing": 1 }, { - "name": "UnlockWithTimeout", - "code": 3, + "name": "Leave", + "code": 2, "mfgCode": null, - "source": "client", + "source": "server", "incoming": 1, "outgoing": 1 - }, + } + ], + "attributes": [ { - "name": "GetLogRecord", - "code": 4, + "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": "SetPin", - "code": 5, + "name": "InteractionModelVersion", + "code": 0, "mfgCode": null, - "source": "client", + "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": "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 }, @@ -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,24 +1650,6 @@ "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 - } ] }, { @@ -1637,27 +1788,10 @@ "define": "COLOR_CONTROL_CLUSTER", "side": "client", "enabled": 0, - "attributes": [ + "commands": [ { - "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", - "code": 0, + "name": "MoveToHue", + "code": 0, "mfgCode": null, "source": "client", "incoming": 1, @@ -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, @@ -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 - } ] }, { @@ -3166,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", @@ -3223,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 - } ] }, { @@ -3582,6 +3634,7 @@ "define": "LEVEL_CONTROL_CLUSTER", "side": "server", "enabled": 1, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -3599,50 +3652,480 @@ "reportableChange": 0 }, { - "name": "current level", - "code": 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, + "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": 0, + "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": 1, + "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": "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, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ], - "commands": [] - }, - { - "name": "General Commissioning", - "code": 48, - "mfgCode": null, - "define": "GENERAL_COMMISSIONING_CLUSTER", - "side": "client", - "enabled": 0, - "commands": [ + "source": "client", + "incoming": 1, + "outgoing": 0 + }, { - "name": "SetFabric", - "code": 0, + "name": "RemoveNetwork", + "code": 10, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 1 }, { - "name": "ArmFailSafe", - "code": 2, + "name": "EnableNetwork", + "code": 12, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 1 }, { - "name": "CommissioningComplete", - "code": 6, + "name": "DisableNetwork", + "code": 14, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetLastNetworkCommissioningResult", + "code": 16, "mfgCode": null, "source": "client", "incoming": 1, @@ -3668,15 +4151,15 @@ ] }, { - "name": "General Commissioning", - "code": 48, + "name": "Network Commissioning", + "code": 49, "mfgCode": null, - "define": "GENERAL_COMMISSIONING_CLUSTER", + "define": "NETWORK_COMMISSIONING_CLUSTER", "side": "server", "enabled": 1, "commands": [ { - "name": "SetFabricResponse", + "name": "ScanNetworksResponse", "code": 1, "mfgCode": null, "source": "server", @@ -3684,18 +4167,58 @@ "outgoing": 1 }, { - "name": "ArmFailSafeResponse", + "name": "AddWiFiNetworkResponse", "code": 3, "mfgCode": null, "source": "server", - "incoming": 1, + "incoming": 0, "outgoing": 1 }, { - "name": "CommissioningCompleteResponse", + "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 } @@ -3715,36 +4238,6 @@ "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 } ] }, @@ -3755,23 +4248,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 +4433,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 +5051,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 +5164,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 +5966,7 @@ "define": "TEMP_MEASUREMENT_CLUSTER", "side": "client", "enabled": 0, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -5489,8 +5983,7 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [] + ] }, { "name": "Temperature Measurement", @@ -5620,6 +6113,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 +6222,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 +6718,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 +6735,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..f82aca72db379b 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; @@ -517,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 * @@ -545,7 +603,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..f364b2e8d1c6e0 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" @@ -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,70 @@ 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 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) @@ -321,8 +399,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 +446,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 +493,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 +792,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 +949,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 +959,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 +975,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 +983,81 @@ - (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; @@ -775,7 +1070,31 @@ - (void)readAttributePowerSource:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePowerSource(onSuccess->Cancel(), onFailure->Cancel()); + 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; @@ -1603,8 +1922,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 +3701,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 +3717,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 +3756,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 +3772,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 +3784,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 +3800,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 +3888,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 +3904,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 +3928,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 +4167,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 +4271,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 +4287,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 +4311,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; @@ -5066,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 @@ -5248,7 +5860,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 +5880,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..c3a00f32299dcf 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 @@ -2221,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) @@ -2543,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 3ab0310a83cce7..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 @@ -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 @@ -392,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 @@ -1104,10 +1109,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 +3844,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) @@ -4085,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 36af8206486d4b..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; @@ -196,10 +200,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; @@ -1890,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 9865389e510885..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 // @@ -1386,12 +1465,6 @@ bool emberAfBarrierControlClusterBarrierControlStopCallback(); bool emberAfBasicClusterMfgSpecificPingCallback(); -/** - * @brief Basic Cluster ResetToFactoryDefaults Command callback - */ - -bool emberAfBasicClusterResetToFactoryDefaultsCallback(); - /** * @brief Binding Cluster Bind Command callback * @param nodeId @@ -2003,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 c4f2f0a4a2a4f2..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 @@ -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 @@ -1893,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 @@ -5765,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 2069290df636a7..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 @@ -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,9 +80,15 @@ // 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) +// 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 655425d5d43d35..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 @@ -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) @@ -236,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) @@ -698,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 3775b356ce564f..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 @@ -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 127 #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,49 @@ { 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 */ \ + { \ + 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 *) 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 */ \ @@ -161,7 +285,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,21 +367,21 @@ { 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 */ \ { \ - 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) } \ + 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 */ \ { 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(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 */ \ @@ -265,11 +389,44 @@ { 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 *) 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. @@ -306,90 +463,97 @@ }; #define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask -#define GENERATED_CLUSTER_COUNT 19 +#define GENERATED_CLUSTER_COUNT 20 #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) */ \ + { \ + 0x0031, ZAP_ATTRIBUTE_INDEX(29), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 1, Cluster: Network Commissioning (server) */ \ { 0x0101, \ - ZAP_ATTRIBUTE_INDEX(20), \ + 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(24), 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(29), \ + 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(80), 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(84), \ + 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(90), 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(91), 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(99), 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(100), 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(102), 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) */ \ - { 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(113), \ 2, \ 3, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayOnOffServer }, /* Endpoint: 2, Cluster: On/off (server) */ \ + { \ + 0x0028, ZAP_ATTRIBUTE_INDEX(115), 12, 254, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 2, Cluster: Basic (server) */ \ } #define ZAP_CLUSTER_INDEX(index) ((EmberAfCluster *) (&generatedClusters[index])) @@ -397,17 +561,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), 18, 782 }, { ZAP_CLUSTER_INDEX(18), 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 (1039) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (2) @@ -451,17 +615,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 (132) #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 +658,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 */ \ @@ -508,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 */ \ @@ -624,7 +806,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/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 1ea31513afebcd..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 @@ -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,12 +144,24 @@ #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 #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 @@ -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,7 +810,9 @@ 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_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 96ea807e80cb84..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,13 +38,30 @@ "deviceTypeProfileId": 260, "clusters": [ { - "name": "Basic", - "code": 0, + "name": "Identify", + "code": 3, "mfgCode": null, - "define": "BASIC_CLUSTER", + "define": "IDENTIFY_CLUSTER", "side": "client", "enabled": 0, - "commands": [], + "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 + } + ], "attributes": [ { "name": "cluster revision", @@ -55,7 +72,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "3", + "defaultValue": "2", "reportable": 0, "minInterval": 0, "maxInterval": 65344, @@ -64,13 +81,12 @@ ] }, { - "name": "Basic", - "code": 0, + "name": "Identify", + "code": 3, "mfgCode": null, - "define": "BASIC_CLUSTER", + "define": "IDENTIFY_CLUSTER", "side": "server", "enabled": 0, - "commands": [], "attributes": [ { "name": "cluster revision", @@ -81,14 +97,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", @@ -96,47 +112,7 @@ "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": 0, - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "2", + "defaultValue": "0x0000", "reportable": 0, "minInterval": 0, "maxInterval": 65344, @@ -145,80 +121,39 @@ ], "commands": [ { - "name": "Identify", + "name": "IdentifyQueryResponse", "code": 0, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "IdentifyQuery", - "code": 1, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 + "source": "server", + "incoming": 0, + "outgoing": 1 } ] }, { - "name": "Identify", - "code": 3, + "name": "Groups", + "code": 4, "mfgCode": null, - "define": "IDENTIFY_CLUSTER", - "side": "server", + "define": "GROUPS_CLUSTER", + "side": "client", "enabled": 0, - "commands": [ - { - "name": "IdentifyQueryResponse", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 0, - "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", + "side": "client", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0x0000", + "defaultValue": "3", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 } - ] - }, - { - "name": "Groups", - "code": 4, - "mfgCode": null, - "define": "GROUPS_CLUSTER", - "side": "client", - "enabled": 0, + ], "commands": [ { "name": "AddGroup", @@ -268,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 - } ] }, { @@ -451,6 +369,56 @@ "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", @@ -542,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 - } ] }, { @@ -817,18 +735,10 @@ "reportableChange": 0 } ] - } - ] - }, - { - "name": "Anonymous Endpoint Type", - "deviceTypeName": "LO-colordimmablelight", - "deviceTypeCode": 258, - "deviceTypeProfileId": 260, - "clusters": [ + }, { "name": "Basic", - "code": 0, + "code": 40, "mfgCode": null, "define": "BASIC_CLUSTER", "side": "client", @@ -854,12 +764,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 +812,7 @@ "reportableChange": 0 }, { - "name": "ZCL version", + "name": "InteractionModelVersion", "code": 0, "mfgCode": null, "side": "server", @@ -885,14 +820,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 +835,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 +850,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 +865,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 +887,7 @@ "reportableChange": 0 }, { - "name": "model identifier", + "name": "UserLabel", "code": 5, "mfgCode": null, "side": "server", @@ -967,7 +902,7 @@ "reportableChange": 0 }, { - "name": "date code", + "name": "Location", "code": 6, "mfgCode": null, "side": "server", @@ -982,7 +917,7 @@ "reportableChange": 0 }, { - "name": "power source", + "name": "HardwareVersion", "code": 7, "mfgCode": null, "side": "server", @@ -997,7 +932,7 @@ "reportableChange": 0 }, { - "name": "generic device class", + "name": "HardwareVersionString", "code": 8, "mfgCode": null, "side": "server", @@ -1005,14 +940,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 +955,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,39 +975,17 @@ "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 } ] - }, + } + ] + }, + { + "name": "Anonymous Endpoint Type", + "deviceTypeName": "LO-colordimmablelight", + "deviceTypeCode": 258, + "deviceTypeProfileId": 260, + "clusters": [ { "name": "Identify", "code": 3, @@ -1080,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", @@ -1122,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 + } ] }, { @@ -2089,88 +2002,330 @@ ] }, { - "name": "Color Control", - "code": 768, + "name": "Basic", + "code": 40, "mfgCode": null, - "define": "COLOR_CONTROL_CLUSTER", + "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": "MoveToHue", + "name": "StartUp", "code": 0, "mfgCode": null, - "source": "client", + "source": "server", "incoming": 1, - "outgoing": 0 + "outgoing": 1 }, { - "name": "MoveHue", + "name": "ShutDown", "code": 1, "mfgCode": null, - "source": "client", + "source": "server", "incoming": 1, - "outgoing": 0 + "outgoing": 1 }, { - "name": "StepHue", + "name": "Leave", "code": 2, "mfgCode": null, - "source": "client", + "source": "server", "incoming": 1, - "outgoing": 0 - }, + "outgoing": 1 + } + ], + "attributes": [ { - "name": "MoveToSaturation", - "code": 3, + "name": "cluster revision", + "code": 65533, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 }, { - "name": "MoveSaturation", - "code": 4, + "name": "InteractionModelVersion", + "code": 0, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 }, { - "name": "StepSaturation", - "code": 5, + "name": "VendorName", + "code": 1, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 }, { - "name": "MoveToHueAndSaturation", - "code": 6, + "name": "VendorID", + "code": 2, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 }, { - "name": "MoveToColor", - "code": 7, + "name": "ProductName", + "code": 3, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 }, { - "name": "MoveColor", - "code": 8, + "name": "ProductID", + "code": 4, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, - { - "name": "StepColor", - "code": 9, + "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": "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, @@ -3099,305 +3254,41 @@ "source": "server", "incoming": 0, "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": "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, - "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": 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": 1, - "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": 1, - "bounded": 0, - "defaultValue": "0x08", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "application version", - "code": 1, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "stack version", - "code": 2, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "hardware version", - "code": 3, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "manufacturer name", - "code": 4, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "model identifier", - "code": 5, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "date code", - "code": 6, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "power source", - "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": "generic device class", - "code": 8, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "0xFF", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "generic device type", - "code": 9, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "0xFF", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "product code", - "code": 10, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 1, - "bounded": 0, - "defaultValue": "", - "reportable": 0, - "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 - } - ] - }, - { - "name": "Identify", - "code": 3, - "mfgCode": null, - "define": "IDENTIFY_CLUSTER", - "side": "client", - "enabled": 0, + } + ], "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", @@ -3423,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 + } ] }, { @@ -3432,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", @@ -3473,6 +3371,16 @@ "maxInterval": 65344, "reportableChange": 0 } + ], + "commands": [ + { + "name": "IdentifyQueryResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } ] }, { @@ -3482,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", @@ -3531,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 - } ] }, { @@ -5296,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", @@ -5320,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, @@ -5419,4 +5426,4 @@ "networkId": 0 } ] -} +} \ No newline at end of file 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..b066625c88ce44 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 @@ -115,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 98ddbecdf8e85a..8b04fffcbe65c8 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" @@ -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,70 @@ 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 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) @@ -319,32 +397,9 @@ @implementation CHIPBasic return &_cppCluster; } -- (void)resetToFactoryDefaults:(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 +- (void)readAttributeInteractionModelVersion:(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 +412,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 +420,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 +436,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 +444,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 +459,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 +467,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 +483,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 +491,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 +506,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 +514,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 +530,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 +538,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 +553,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 +563,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 +579,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 +587,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 +602,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 +612,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 +627,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 +635,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 +651,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 +659,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 +674,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 +682,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 +698,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; @@ -1085,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 b08b0bc9b45077..38e77a95d8b37c 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) @@ -329,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) @@ -373,12 +678,12 @@ 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; + 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 8802797f112bd6..72a0198e2f97be 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 @@ -392,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 @@ -1093,15 +1098,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 +3844,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) @@ -4079,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 d1a86ac8a37a67..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) @@ -72,11 +73,15 @@ 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); break; + case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID: + result = emberAfNetworkCommissioningClusterServerCommandParse(cmd); + break; case ZCL_ON_OFF_CLUSTER_ID: result = emberAfOnOffClusterServerCommandParse(cmd); break; @@ -90,26 +95,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; @@ -326,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 6b284ee368dc37..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 // @@ -271,12 +350,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 @@ -349,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 97de7f69cfff1d..79d1e159594a4a 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 @@ -1893,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 @@ -2964,6 +3201,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 @@ -5756,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 99de14e2586034..add8f83d188cf8 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,9 +80,15 @@ // 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) +// Definitions for cluster: Network Commissioning +#define ZCL_NETWORK_COMMISSIONING_CLUSTER_ID (0x0031) + // Definitions for cluster: Shade Configuration #define ZCL_SHADE_CONFIG_CLUSTER_ID (0x0100) @@ -239,6 +242,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) @@ -338,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 d31a267c6254af..864943b5727fcd 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) @@ -236,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) @@ -369,6 +390,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) @@ -695,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 9a456798226f46..b797a636a44e30 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,50 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 29 +#define GENERATED_ATTRIBUTE_COUNT 51 #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 *) 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 */ \ + { \ + 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 +207,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 +278,50 @@ }; #define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask -#define GENERATED_CLUSTER_COUNT 7 +#define GENERATED_CLUSTER_COUNT 9 #define GENERATED_CLUSTERS \ { \ - { 0x0000, ZAP_ATTRIBUTE_INDEX(0), 3, 4, ZAP_CLUSTER_MASK(SERVER), NULL }, /* Endpoint: 0, Cluster: Basic (server) */ \ + { \ + 0x0031, ZAP_ATTRIBUTE_INDEX(0), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 0, Cluster: Network Commissioning (server) */ \ { 0x0006, \ - ZAP_ATTRIBUTE_INDEX(3), \ + 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(5), \ + 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(5), 12, 254, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 1, Cluster: Basic (server) */ \ { 0x0006, \ - ZAP_ATTRIBUTE_INDEX(7), \ + 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(13), \ + 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(28), 12, 254, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 2, Cluster: Basic (server) */ \ { 0x0006, \ - ZAP_ATTRIBUTE_INDEX(18), \ + 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(24), \ + ZAP_ATTRIBUTE_INDEX(46), \ 5, \ 7, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ @@ -167,18 +333,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), 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 -#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 (548) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (4) @@ -222,11 +388,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 (62) #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 +430,30 @@ { 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 */ \ + { 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 5aa3207d2e5f3d..d5a44941d9a09b 100644 --- a/examples/bridge-app/bridge-common/gen/gen_config.h +++ b/examples/bridge-app/bridge-common/gen/gen_config.h @@ -29,8 +29,9 @@ #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_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 86a2a27beec86b..8c737e93fea79c 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,12 +144,24 @@ #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 #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 @@ -526,6 +532,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 @@ -728,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 @@ -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,7 +810,9 @@ 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_NETWORK_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DOOR_LOCK_CLUSTER \ CHIP_PRINTCLUSTER_WINDOW_COVERING_CLUSTER \ @@ -857,6 +864,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 \ @@ -890,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/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/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/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/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..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" @@ -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,70 @@ 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 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) @@ -1599,8 +1677,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 +1724,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 +1771,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 +2070,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 +2227,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 +2237,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 +2253,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 +2261,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 +2372,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 +3200,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 +4993,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 +5009,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 +5049,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 +5066,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 +5078,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 +5095,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 +5186,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 +5202,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 +5227,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 +5466,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 +5570,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 +5586,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 +5610,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 +6706,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 +6726,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..72a0198e2f97be 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 @@ -392,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 @@ -1104,10 +1109,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 +3844,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) @@ -4085,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 c4f2f0a4a2a4f2..79d1e159594a4a 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 @@ -1893,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 @@ -5765,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 2069290df636a7..add8f83d188cf8 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,9 +80,15 @@ // 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) +// 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 655425d5d43d35..864943b5727fcd 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) @@ -236,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) @@ -698,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/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..8c737e93fea79c 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,12 +144,24 @@ #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 #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 @@ -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,7 +810,9 @@ 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_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/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/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/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 00000000000000..a7e527741c5407 Binary files /dev/null and b/examples/lighting-app/k32w/data.bin differ 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/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..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" @@ -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,70 @@ 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 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) @@ -308,6 +386,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..72a0198e2f97be 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 @@ -392,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 @@ -1093,15 +1098,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 +3844,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) @@ -4079,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/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..79d1e159594a4a 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 @@ -1893,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 @@ -2964,6 +3201,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 @@ -5756,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 99de14e2586034..add8f83d188cf8 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,9 +80,15 @@ // 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) +// Definitions for cluster: Network Commissioning +#define ZCL_NETWORK_COMMISSIONING_CLUSTER_ID (0x0031) + // Definitions for cluster: Shade Configuration #define ZCL_SHADE_CONFIG_CLUSTER_ID (0x0100) @@ -239,6 +242,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) @@ -338,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 d31a267c6254af..864943b5727fcd 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) @@ -236,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) @@ -369,6 +390,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) @@ -695,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 7246b726413757..e4ee406058800d 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) */ \ + { \ + 0x0031, 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,23 +257,26 @@ { 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 */ \ - { 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, \ + { 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 */ \ } 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..8c737e93fea79c 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,12 +144,24 @@ #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 #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 @@ -526,6 +532,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 @@ -728,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 @@ -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,7 +810,9 @@ 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_NETWORK_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DOOR_LOCK_CLUSTER \ CHIP_PRINTCLUSTER_WINDOW_COVERING_CLUSTER \ @@ -857,6 +864,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 \ @@ -890,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 699ae3fdc7c314..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": 0, + "name": "Identify", + "code": 3, "mfgCode": null, - "define": "BASIC_CLUSTER", + "define": "IDENTIFY_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "cluster revision", @@ -55,77 +54,13 @@ "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", + "defaultValue": "2", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 } - ] - }, - { - "name": "Identify", - "code": 3, - "mfgCode": null, - "define": "IDENTIFY_CLUSTER", - "side": "client", - "enabled": 0, + ], "commands": [ { "name": "Identify", @@ -143,23 +78,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 - } ] }, { @@ -169,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", @@ -210,6 +118,16 @@ "maxInterval": 65344, "reportableChange": 0 } + ], + "commands": [ + { + "name": "IdentifyQueryResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } ] }, { @@ -818,9 +736,251 @@ } ] }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "client", + "enabled": 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 + } + ], + "commands": [] + }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "server", + "enabled": 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 + } + ], + "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 + } + ] + }, { "name": "Network Commissioning", - "code": 43690, + "code": 49, "mfgCode": null, "define": "NETWORK_COMMISSIONING_CLUSTER", "side": "client", @@ -919,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", @@ -1006,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/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/examples/lighting-app/nrfconnect/CMakeLists.txt b/examples/lighting-app/nrfconnect/CMakeLists.txt index 32a65e7982ee08..28e152f86fb8a2 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}) @@ -44,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 @@ -70,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/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/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()) { 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/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/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/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/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..786c7dc995f4af 100644 --- a/examples/lock-app/lock-common/gen/CHIPClustersObjc.h +++ b/examples/lock-app/lock-common/gen/CHIPClustersObjc.h @@ -42,6 +42,75 @@ 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 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 2438c14e74d4a2..ce5be43ca8396d 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" @@ -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,70 @@ 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 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) @@ -308,6 +386,630 @@ - (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 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 8802797f112bd6..72a0198e2f97be 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 @@ -392,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 @@ -1093,15 +1098,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 +3844,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) @@ -4079,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 5c9bdd76005c89..9da037ea070e68 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,8 @@ using namespace chip; +EmberAfStatus emberAfBasicClusterServerCommandParse(EmberAfClusterCommand * cmd); +EmberAfStatus emberAfNetworkCommissioningClusterServerCommandParse(EmberAfClusterCommand * cmd); EmberAfStatus emberAfOnOffClusterServerCommandParse(EmberAfClusterCommand * cmd); static EmberAfStatus status(bool wasHandled, bool clusterExists, bool mfgSpecific) @@ -69,6 +71,13 @@ 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_NETWORK_COMMISSIONING_CLUSTER_ID: + result = emberAfNetworkCommissioningClusterServerCommandParse(cmd); + break; case ZCL_ON_OFF_CLUSTER_ID: result = emberAfOnOffClusterServerCommandParse(cmd); break; @@ -82,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 7673db7643259b..fad53a93a44359 100644 --- a/examples/lock-app/lock-common/gen/callback-stub.cpp +++ b/examples/lock-app/lock-common/gen/callback-stub.cpp @@ -27,6 +27,12 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) { switch (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; @@ -36,6 +42,16 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) } } +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 fe0caa9bb35762..4f0364b30405b4 100644 --- a/examples/lock-app/lock-common/gen/callback.h +++ b/examples/lock-app/lock-common/gen/callback.h @@ -37,6 +37,22 @@ 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 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 @@ -47,6 +63,145 @@ 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); + +// +// 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 // @@ -117,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 97de7f69cfff1d..79d1e159594a4a 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 @@ -1893,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 @@ -2964,6 +3201,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 @@ -5756,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 99de14e2586034..add8f83d188cf8 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,9 +80,15 @@ // 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) +// Definitions for cluster: Network Commissioning +#define ZCL_NETWORK_COMMISSIONING_CLUSTER_ID (0x0031) + // Definitions for cluster: Shade Configuration #define ZCL_SHADE_CONFIG_CLUSTER_ID (0x0100) @@ -239,6 +242,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) @@ -338,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 d31a267c6254af..864943b5727fcd 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) @@ -236,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) @@ -369,6 +390,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) @@ -695,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 41d5eeb70c4a20..ea49715c508385 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,48 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 2 +#define GENERATED_ATTRIBUTE_COUNT 15 #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 */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, { (uint8_t *) 0x0001 } }, /* Network Commissioning (server): cluster revision */ \ } // This is an array of EmberAfCluster structures. @@ -72,7 +154,7 @@ }; #define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask -#define GENERATED_CLUSTER_COUNT 1 +#define GENERATED_CLUSTER_COUNT 3 #define GENERATED_CLUSTERS \ { \ { \ @@ -83,6 +165,12 @@ 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) */ \ + { \ + 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])) @@ -90,17 +178,17 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 1, 3 }, \ + { ZAP_CLUSTER_INDEX(0), 3, 259 }, \ } // 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 (259) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (1) @@ -144,12 +232,33 @@ // 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 (23) #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 */ \ + { 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 b5f0621684ee4a..48ae4c3873f632 100644 --- a/examples/lock-app/lock-common/gen/gen_config.h +++ b/examples/lock-app/lock-common/gen/gen_config.h @@ -29,10 +29,22 @@ #define EMBER_APS_UNICAST_MESSAGE_COUNT 10 /**** 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 ****/ +// 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 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 86a2a27beec86b..8c737e93fea79c 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,12 +144,24 @@ #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 #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 @@ -526,6 +532,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 @@ -728,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 @@ -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,7 +810,9 @@ 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_NETWORK_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DOOR_LOCK_CLUSTER \ CHIP_PRINTCLUSTER_WINDOW_COVERING_CLUSTER \ @@ -857,6 +864,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 \ @@ -890,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 5d20290ec1aff6..6b9c6e7f508122 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": "Fri Mar 12 2021 15:19:34 GMT+0800 (China 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", @@ -275,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", @@ -292,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 - } ] }, { @@ -842,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", @@ -876,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 + } ] }, { @@ -1360,6 +1278,438 @@ } ] }, + { + "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": "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, @@ -1469,4 +1819,4 @@ "networkId": 0 } ] -} +} \ No newline at end of file diff --git a/examples/lock-app/nrfconnect/CMakeLists.txt b/examples/lock-app/nrfconnect/CMakeLists.txt index b97d0ba9ebc4ac..57c8ea827283b3 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}) @@ -31,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) @@ -63,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/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/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/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/examples/platform/k32w/doc/images/nxp_hw_connectivity.JPG b/examples/platform/k32w/doc/images/nxp_hw_connectivity.JPG index ad373d4f120527..80e19b30dfc6ef 100644 Binary files a/examples/platform/k32w/doc/images/nxp_hw_connectivity.JPG and b/examples/platform/k32w/doc/images/nxp_hw_connectivity.JPG differ 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/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/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..f1a1ad089561ae --- /dev/null +++ b/examples/shell/shell_common/cmd_ping.cpp @@ -0,0 +1,484 @@ +/* + * + * 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 + +#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"); + + // 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) +{ + 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/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/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..bde4d17081f57b 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/CHIPClustersObjc.h +++ b/examples/temperature-measurement-app/esp32/main/gen/CHIPClustersObjc.h @@ -48,10 +48,65 @@ NS_ASSUME_NONNULL_BEGIN */ @interface CHIPBasic : CHIPCluster -- (void)resetToFactoryDefaults:(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 + +/** + * 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)readAttributeZclVersion:(ResponseHandler)completionHandler; -- (void)readAttributePowerSource:(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..23ccc4a8f75ebe 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" @@ -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,70 @@ 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 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) @@ -319,7 +397,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 +553,33 @@ - (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; @@ -342,9 +587,9 @@ - (void)resetToFactoryDefaults:(ResponseHandler)completionHandler } } -- (void)readAttributeZclVersion:(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; @@ -357,7 +602,9 @@ - (void)readAttributeZclVersion:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeZclVersion(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; @@ -365,9 +612,357 @@ - (void)readAttributeZclVersion:(ResponseHandler)completionHandler } } -- (void)readAttributePowerSource:(ResponseHandler)completionHandler +- (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 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 { - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); + CHIPNetworkCommissioningClusterUpdateWiFiNetworkResponseCallbackBridge * onSuccess + = new CHIPNetworkCommissioningClusterUpdateWiFiNetworkResponseCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { completionHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); return; @@ -380,7 +975,9 @@ - (void)readAttributePowerSource:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePowerSource(onSuccess->Cancel(), onFailure->Cancel()); + 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; diff --git a/examples/temperature-measurement-app/esp32/main/gen/IMClusterCommandHandler.cpp b/examples/temperature-measurement-app/esp32/main/gen/IMClusterCommandHandler.cpp index a0006c7c102da4..f5fdc561515948 100644 --- a/examples/temperature-measurement-app/esp32/main/gen/IMClusterCommandHandler.cpp +++ b/examples/temperature-measurement-app/esp32/main/gen/IMClusterCommandHandler.cpp @@ -39,29 +39,334 @@ namespace app { namespace clusters { -namespace Basic { +namespace NetworkCommissioning { void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv) { { switch (commandId) { - case ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID: { + 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. - emberAfBasicClusterResetToFactoryDefaultsCallback(); + 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_BASIC_CLUSTER_ID); + ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_NETWORK_COMMISSIONING_CLUSTER_ID); break; } } } } -} // namespace Basic +} // namespace NetworkCommissioning } // namespace clusters @@ -73,8 +378,8 @@ 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); + case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID: + clusters::NetworkCommissioning::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; default: // Unrecognized cluster ID, error status will apply. 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..72a0198e2f97be 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 @@ -392,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 @@ -1093,15 +1098,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 +3844,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) @@ -4079,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 82d19ea4353c59..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) @@ -71,7 +72,11 @@ 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_NETWORK_COMMISSIONING_CLUSTER_ID: + result = emberAfNetworkCommissioningClusterServerCommandParse(cmd); break; case ZCL_TEMP_MEASUREMENT_CLUSTER_ID: // No commands are enabled for cluster Temperature Measurement @@ -87,7 +92,7 @@ EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd) // Cluster specific command parsing -EmberAfStatus emberAfBasicClusterServerCommandParse(EmberAfClusterCommand * cmd) +EmberAfStatus emberAfNetworkCommissioningClusterServerCommandParse(EmberAfClusterCommand * cmd) { bool wasHandled = false; @@ -95,8 +100,247 @@ EmberAfStatus emberAfBasicClusterServerCommandParse(EmberAfClusterCommand * cmd) { switch (cmd->commandId) { - case ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID: { - wasHandled = emberAfBasicClusterResetToFactoryDefaultsCallback(); + 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: { 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 c76cbccf4dd9ae..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 // @@ -197,10 +276,89 @@ void emberAfTemperatureMeasurementClusterServerTickCallback(chip::EndpointId end // Cluster Commands Callback /** - * @brief Basic Cluster ResetToFactoryDefaults Command 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 emberAfBasicClusterResetToFactoryDefaultsCallback(); +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 97de7f69cfff1d..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 @@ -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 @@ -1893,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 @@ -2964,6 +3201,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 @@ -5756,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 99de14e2586034..add8f83d188cf8 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,9 +80,15 @@ // 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) +// Definitions for cluster: Network Commissioning +#define ZCL_NETWORK_COMMISSIONING_CLUSTER_ID (0x0031) + // Definitions for cluster: Shade Configuration #define ZCL_SHADE_CONFIG_CLUSTER_ID (0x0100) @@ -239,6 +242,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) @@ -338,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 d31a267c6254af..864943b5727fcd 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) @@ -236,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) @@ -369,6 +390,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) @@ -695,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 ea331701181607..aac33bcf5ad7c3 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,44 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 7 +#define GENERATED_ATTRIBUTE_COUNT 17 #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 *) 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 */ \ @@ -74,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 \ { \ - { 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) */ \ + { \ + 0x0031, ZAP_ATTRIBUTE_INDEX(12), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 1, Cluster: Network Commissioning (server) */ \ { \ - 0x0402, ZAP_ATTRIBUTE_INDEX(3), 4, 8, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0402, ZAP_ATTRIBUTE_INDEX(13), 4, 8, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Temperature Measurement (server) */ \ } @@ -88,17 +168,17 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 2, 12 }, \ + { ZAP_CLUSTER_INDEX(0), 3, 264 }, \ } // 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 (264) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (1) @@ -142,10 +222,30 @@ // 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 (20) #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 */ \ + { 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 86a2a27beec86b..8c737e93fea79c 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,12 +144,24 @@ #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 #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 @@ -526,6 +532,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 @@ -728,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 @@ -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,7 +810,9 @@ 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_NETWORK_COMMISSIONING_CLUSTER \ CHIP_PRINTCLUSTER_SHADE_CONFIG_CLUSTER \ CHIP_PRINTCLUSTER_DOOR_LOCK_CLUSTER \ CHIP_PRINTCLUSTER_WINDOW_COVERING_CLUSTER \ @@ -857,6 +864,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 \ @@ -890,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 6ced702b8317bb..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,100 +34,9 @@ { "name": "Anonymous Endpoint Type", "deviceTypeName": "CBA-tempsensor", - "deviceTypeCode": "0x0302", - "deviceTypeProfileId": "0x105", + "deviceTypeCode": 770, + "deviceTypeProfileId": 261, "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": 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, - "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": "Power Configuration", "code": 1, @@ -135,6 +44,7 @@ "define": "POWER_CONFIG_CLUSTER", "side": "client", "enabled": 0, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -151,8 +61,7 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [] + ] }, { "name": "Power Configuration", @@ -161,6 +70,7 @@ "define": "POWER_CONFIG_CLUSTER", "side": "server", "enabled": 0, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -207,8 +117,7 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [] + ] }, { "name": "Device Temperature Configuration", @@ -217,7 +126,6 @@ "define": "DEVICE_TEMP_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "cluster revision", @@ -234,7 +142,8 @@ "maxInterval": 65344, "reportableChange": 0 } - ] + ], + "commands": [] }, { "name": "Device Temperature Configuration", @@ -1044,6 +953,438 @@ } ] }, + { + "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": "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, @@ -1051,7 +1392,6 @@ "define": "TEMP_MEASUREMENT_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "cluster revision", @@ -1068,7 +1408,8 @@ "maxInterval": 65344, "reportableChange": 0 } - ] + ], + "commands": [] }, { "name": "Temperature Measurement", @@ -1077,7 +1418,6 @@ "define": "TEMP_MEASUREMENT_CLUSTER", "side": "server", "enabled": 1, - "commands": [], "attributes": [ { "name": "cluster revision", @@ -1154,7 +1494,8 @@ "maxInterval": 65344, "reportableChange": 0 } - ] + ], + "commands": [] } ] } @@ -1168,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/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..5e99fca8479815 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; @@ -730,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 * @@ -758,7 +815,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..00dc2fc9a1da40 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" @@ -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,70 @@ 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 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) @@ -379,8 +457,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 +504,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 +551,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 +1001,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 +1157,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 +1167,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 +1183,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 +1191,9 @@ - (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; @@ -984,7 +1206,103 @@ - (void)readAttributePowerSource:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributePowerSource(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; + 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; @@ -1723,8 +2041,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 +4124,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 +5903,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 +5919,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 +5958,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 +5974,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 +5986,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 +6002,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 +6090,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 +6106,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 +6130,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 +6595,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 +6611,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 +6650,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 +6666,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 +6678,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 +6694,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 +6782,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 +6798,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 +6822,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 +6979,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 +6995,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 +7019,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; @@ -7765,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 @@ -7947,7 +8568,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 +8588,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..c8edddf1704a82 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) @@ -2100,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) @@ -2386,9 +2691,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; @@ -2416,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 3ab0310a83cce7..72a0198e2f97be 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 @@ -392,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 @@ -1104,10 +1109,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 +3844,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) @@ -4085,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 2619593ba40fdc..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); @@ -105,7 +106,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); @@ -134,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; @@ -187,26 +192,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; @@ -1766,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 01fb095464b618..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 // @@ -1434,12 +1513,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 @@ -2017,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 c4f2f0a4a2a4f2..79d1e159594a4a 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 @@ -1893,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 @@ -5765,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 2069290df636a7..add8f83d188cf8 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,9 +80,15 @@ // 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) +// 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 655425d5d43d35..864943b5727fcd 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) @@ -236,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) @@ -698,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 2f2e27ffcb2aae..ed2ac088b822cd 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 112 #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,43 @@ { 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 */ \ { \ 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), { (uint8_t *) 3 } \ }, /* Door Lock (client): cluster revision */ \ @@ -157,7 +234,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,21 +316,21 @@ { 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 */ \ { \ - 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) } \ + 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 */ \ { 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(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 */ \ @@ -296,85 +373,90 @@ }; #define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask -#define GENERATED_CLUSTER_COUNT 18 +#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) */ \ { \ - 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) */ \ + { \ + 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(18), \ + 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(22), 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(23), 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(28), 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(29), \ + 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(80), 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(84), \ + 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(90), 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(91), 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(99), 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(101), 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) */ \ } @@ -383,17 +465,17 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 18, 516 }, \ + { ZAP_CLUSTER_INDEX(0), 19, 768 }, \ } // 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 (768) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (1) @@ -437,19 +519,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 (158) #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 +559,27 @@ { 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 */ \ + { 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 1ea31513afebcd..8c737e93fea79c 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,12 +144,24 @@ #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 #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 @@ -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,7 +810,9 @@ 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_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 0b35602653138e..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,22 +38,12 @@ "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", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - } - ], "attributes": [ { "name": "cluster revision", @@ -62,79 +52,15 @@ "side": "client", "included": 1, "storageOption": "RAM", - "singleton": 1, - "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": 1, - "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": 1, - "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": 1, + "singleton": 0, "bounded": 0, - "defaultValue": "0x00", + "defaultValue": "2", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 } - ] - }, - { - "name": "Identify", - "code": 3, - "mfgCode": null, - "define": "IDENTIFY_CLUSTER", - "side": "client", - "enabled": 0, + ], "commands": [ { "name": "Identify", @@ -152,23 +78,6 @@ "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 - } ] }, { @@ -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 - } ] }, { @@ -652,118 +561,591 @@ "maxInterval": 65344, "reportableChange": 0 } - ] - }, - { - "name": "On/off", - "code": 6, - "mfgCode": null, - "define": "ON_OFF_CLUSTER", - "side": "server", - "enabled": 1, - "commands": [], + ] + }, + { + "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", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "2", + "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, + "mfgCode": null, + "define": "LEVEL_CONTROL_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "MoveToLevel", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "Move", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "Step", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "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": [], + "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": "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": "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 } @@ -773,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, @@ -787,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, @@ -808,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", @@ -1019,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 - } ] }, { @@ -1637,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", @@ -1750,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 - } ] }, { @@ -1776,6 +2117,7 @@ "define": "COLOR_CONTROL_CLUSTER", "side": "server", "enabled": 1, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -2542,8 +2884,7 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [] + ] }, { "name": "Temperature Measurement", @@ -2552,7 +2893,6 @@ "define": "TEMP_MEASUREMENT_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "cluster revision", @@ -2569,7 +2909,8 @@ "maxInterval": 65344, "reportableChange": 0 } - ] + ], + "commands": [] }, { "name": "Temperature Measurement", @@ -2699,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", @@ -2808,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 + } ] }, { @@ -2878,7 +3219,6 @@ "define": "APPLICATION_BASIC_CLUSTER", "side": "client", "enabled": 0, - "commands": [], "attributes": [ { "name": "cluster revision", @@ -2895,7 +3235,8 @@ "maxInterval": 65344, "reportableChange": 0 } - ] + ], + "commands": [] }, { "name": "Application Basic", @@ -3192,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", @@ -3209,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 - } ] }, { 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 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 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() 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/chip-zcl-zpro-codec-api.h b/src/app/chip-zcl-zpro-codec-api.h index d80a5e99869c5d..e6c14354c1099e 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 | @@ -42,7 +42,7 @@ | LevelControl | 0x0008 | | LowPower | 0x0508 | | MediaPlayback | 0xF001 | -| NetworkCommissioning | 0xAAAA | +| NetworkCommissioning | 0x0031 | | OnOff | 0x0006 | | Scenes | 0x0005 | | TemperatureMeasurement | 0x0402 | @@ -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 @@ -1784,7 +1858,7 @@ chip::System::PacketBufferHandle encodeMediaPlaybackClusterReadClusterRevisionAt chip::EndpointId destinationEndpoint); /*----------------------------------------------------------------------------*\ -| Cluster NetworkCommissioning | 0xAAAA | +| Cluster NetworkCommissioning | 0x0031 | |------------------------------------------------------------------------------| | Commands: | | | * AddThreadNetwork | 0x06 | @@ -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/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 8aa59ee982f8e1..88f47303dc1cd8 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 | @@ -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 | @@ -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) @@ -248,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) @@ -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(); } @@ -2993,7 +3182,7 @@ PacketBufferHandle encodeMediaPlaybackClusterReadClusterRevisionAttribute(uint8_ } /*----------------------------------------------------------------------------*\ -| Cluster NetworkCommissioning | 0xAAAA | +| Cluster NetworkCommissioning | 0x0031 | |------------------------------------------------------------------------------| | Commands: | | | * AddThreadNetwork | 0x06 | @@ -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/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/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 5e8699356fa9f0..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; @@ -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/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/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/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/CHIPClustersObjc-src.zapt b/src/app/zap-templates/templates/app/CHIPClustersObjc-src.zapt similarity index 76% rename from src/app/zap-templates/templates/chip/CHIPClustersObjc-src.zapt rename to src/app/zap-templates/templates/app/CHIPClustersObjc-src.zapt index 32c269f7a3a91d..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" @@ -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,72 @@ 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 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) @@ -360,7 +444,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 +466,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 +478,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 +500,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 +515,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 +558,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/app/CHIPClustersObjc.zapt similarity index 82% rename from src/app/zap-templates/templates/chip/CHIPClustersObjc.zapt rename to src/app/zap-templates/templates/app/CHIPClustersObjc.zapt index 45d3b6bebe984a..9ef083ab1fce28 100644 --- a/src/app/zap-templates/templates/chip/CHIPClustersObjc.zapt +++ b/src/app/zap-templates/templates/app/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/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 diff --git a/src/app/zap-templates/templates/chip/CHIPClusters-src.zapt b/src/app/zap-templates/templates/chip/CHIPClusters-src.zapt index bcfa34eca00cb4..62126b5d3a84ed 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(); @@ -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/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/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/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/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/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/CHIPClusters.cpp b/src/controller/CHIPClusters.cpp index f6145a98e38df1..4223e0e023e415 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(); @@ -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::kCommandPathFlag_EndpointIdValid) }; - 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 = 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 = encodeBasicClusterReadPowerSourceAttribute(seqNum, mEndpoint); + System::PacketBufferHandle encodedCommand = encodeBasicClusterReadSoftwareVersionStringAttribute(seqNum, mEndpoint); return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); } @@ -319,7 +373,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 +414,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 +470,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 +512,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 +556,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 +596,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 +637,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 +680,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 +721,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 +764,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 +807,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 +848,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 +892,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 +940,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 +983,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 +1025,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 +1664,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 +1694,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 +1741,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 +1771,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 +1802,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 +1835,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 +1868,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 +1901,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 +1937,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 +1973,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 +2006,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 +2039,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 +2072,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 +2105,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 +2138,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 +2174,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(); @@ -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); @@ -2155,7 +2210,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 +2244,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(); @@ -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); @@ -2229,7 +2284,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(); @@ -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); @@ -2269,7 +2324,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 +2364,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 +2400,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 +2446,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(); @@ -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); @@ -2431,7 +2486,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(); @@ -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); @@ -2464,7 +2519,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 +2611,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 +2649,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 +2681,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(); @@ -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); @@ -2707,7 +2762,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(); @@ -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); @@ -2742,7 +2797,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 +2833,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 +2868,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 +2899,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 +2932,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 +3051,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 +3083,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 +3146,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 +3186,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 +3227,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 +3263,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 +3299,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 +3341,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 +3379,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 +3413,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(); @@ -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(); @@ -3475,7 +3530,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 +3560,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 +3590,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 +3620,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 +3650,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 +3680,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 +3711,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 +3742,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 +3773,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 +3803,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 +3860,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 +3899,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 +3940,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 +3979,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 +4018,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 +4053,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 +4092,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 +4132,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 +4171,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 +4227,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 +4257,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 +4287,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(); @@ -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 @@ -4301,7 +4356,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 +4402,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 +4435,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 +4473,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 +4506,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 +4541,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 +4576,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/controller/CHIPClusters.h b/src/controller/CHIPClusters.h index cb960d4d7944f9..5e6c39ffc63e9b 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; @@ -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; @@ -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/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index d9117daf281cc3..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. @@ -126,7 +131,7 @@ CHIP_ERROR DeviceController::Init(NodeId localDeviceId, PersistentStorageDelegat if (mStorageDelegate != nullptr) { - mStorageDelegate->SetDelegate(this); + mStorageDelegate->SetStorageDelegate(this); } mTransportMgr = chip::Platform::New(); @@ -193,7 +198,7 @@ CHIP_ERROR DeviceController::Shutdown() if (mStorageDelegate != nullptr) { - mStorageDelegate->SetDelegate(nullptr); + mStorageDelegate->SetStorageDelegate(nullptr); mStorageDelegate = nullptr; } @@ -287,7 +292,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 +311,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 +490,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() { @@ -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; @@ -671,7 +687,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); @@ -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) { @@ -733,7 +755,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,11 +818,16 @@ 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); } + + // 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 1e9c75c2cf514f..bb00165d78e0f7 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(); @@ -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 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/controller-clusters.zap b/src/controller/controller-clusters.zap index a7167fd91457c3..52bf3b0aefd0a4 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": "Fri Mar 12 2021 15:15:13 GMT+0800 (China 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, @@ -377,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", @@ -434,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 - } ] }, { @@ -834,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", @@ -1019,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 - } ] }, { @@ -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,22 @@ ] }, { - "name": "Basic", - "code": 0, + "name": "Identify", + "code": 3, "mfgCode": null, - "define": "BASIC_CLUSTER", + "define": "IDENTIFY_CLUSTER", "side": "server", "enabled": 1, - "commands": [], + "commands": [ + { + "name": "IdentifyQueryResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], "attributes": [ { "name": "cluster revision", @@ -2879,14 +2797,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,22 +2812,7 @@ "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", + "defaultValue": "0x0000", "reportable": 0, "minInterval": 0, "maxInterval": 65344, @@ -2918,30 +2821,12 @@ ] }, { - "name": "Identify", - "code": 3, + "name": "Groups", + "code": 4, "mfgCode": null, - "define": "IDENTIFY_CLUSTER", + "define": "GROUPS_CLUSTER", "side": "client", "enabled": 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 - } - ], "attributes": [ { "name": "cluster revision", @@ -2952,71 +2837,13 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "2", + "defaultValue": "3", "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", @@ -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", @@ -3566,50 +3359,318 @@ "outgoing": 1 }, { - "name": "StopWithOnOff", - "code": 7, + "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, + "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, - "source": "client", - "incoming": 1, - "outgoing": 1 - } - ] - }, - { - "name": "Level Control", - "code": 8, - "mfgCode": null, - "define": "LEVEL_CONTROL_CLUSTER", - "side": "server", - "enabled": 1, - "commands": [], - "attributes": [ + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, { - "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 @@ -3748,6 +3809,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, @@ -4429,23 +4680,6 @@ "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", @@ -4459,9 +4693,26 @@ "name": "BarrierControlStop", "code": 1, "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 + "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 } ] }, @@ -4558,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", @@ -4671,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 - } ] }, { @@ -5738,6 +5989,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 +6015,6 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [ - { - "name": "Sleep", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 - } ] }, { @@ -5949,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, - "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": 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 - } - ] - }, { "name": "Binding", "code": 61440, 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/BUILD.gn b/src/controller/python/BUILD.gn index 8c42fb16d5a884..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" @@ -100,6 +95,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 +124,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/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/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/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 [] 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( 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/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/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/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 */, 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..aa235928acb398 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->OnPersistentStorageValue([key UTF8String], [value UTF8String]); }); } }; @@ -58,8 +58,8 @@ chip::PersistentStorageResultDelegate * callback = mCallback; if (callback) { dispatch_async(mWorkQueue, ^{ - callback->OnStatus([key UTF8String], chip::PersistentStorageResultDelegate::Operation::kSET, - [CHIPError errorToCHIPErrorCode:status]); + callback->OnPersistentStorageStatus([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->OnPersistentStorageStatus([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/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..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" @@ -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,70 @@ 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 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) @@ -278,6 +356,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 +1142,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 +1403,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 +1664,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 +1691,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 +1714,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 +1722,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 +1738,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 +1746,7 @@ - (void)readAttributeBarrierMovingState:(ResponseHandler)completionHandler } } -- (void)readAttributeBarrierSafetyStatus:(ResponseHandler)completionHandler +- (void)readAttributeProductId:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -1488,7 +1761,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 +1769,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 +1785,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 +1793,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 +1831,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 +1864,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 +1890,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 +1912,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 +1920,7 @@ - (void)resetToFactoryDefaults:(ResponseHandler)completionHandler } } -- (void)readAttributeZclVersion:(ResponseHandler)completionHandler +- (void)readAttributeBarrierMovingState:(ResponseHandler)completionHandler { CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -1638,7 +1935,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 +1943,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 +1958,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 +1966,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 +1981,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 +1989,9 @@ - (void)readAttributeClusterRevision:(ResponseHandler)completionHandler } } -@end - -@interface CHIPBinding () -@property (readonly) Controller::BindingCluster cppCluster; -@end - -@implementation CHIPBinding - -- (Controller::ClusterBase *)getCluster -{ - return &_cppCluster; -} - -- (void)bind:(uint64_t)nodeId - groupId:(uint16_t)groupId - endpointId:(uint8_t)endpointId - clusterId:(uint16_t)clusterId - completionHandler:(ResponseHandler)completionHandler +- (void)readAttributeBarrierPosition:(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 +2004,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 +2027,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 +2035,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 +2063,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 +2071,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 +2086,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 +2110,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 +2133,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 +2157,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 +2180,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 +2204,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 +2227,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 +2253,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 +2276,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 +2301,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 +2325,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 +2348,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 +2372,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 +2395,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 +2403,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 +2435,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 +2461,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,7 +2469,545 @@ - (void)configureAttributeCurrentHue:(uint16_t)minInterval } } -- (void)reportAttributeCurrentHue:(ResponseHandler)reportHandler +- (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 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) { @@ -2239,14 +3015,486 @@ - (void)reportAttributeCurrentHue:(ResponseHandler)reportHandler return; } - CHIP_ERROR err = self.cppCluster.ReportAttributeCurrentHue(onReport->Cancel()); + 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)readAttributeCurrentSaturation:(ResponseHandler)completionHandler +- (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) { @@ -2261,7 +3509,53 @@ - (void)readAttributeCurrentSaturation:(ResponseHandler)completionHandler return; } - CHIP_ERROR err = self.cppCluster.ReadAttributeCurrentSaturation(onSuccess->Cancel(), onFailure->Cancel()); + 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; + } + + 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.ReadAttributePrimary3Y(onSuccess->Cancel(), onFailure->Cancel()); if (err != CHIP_NO_ERROR) { delete onSuccess; delete onFailure; @@ -2269,12 +3563,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 +3578,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 +3586,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 +3601,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 +3609,7 @@ - (void)readAttributeRemainingTime:(ResponseHandler)completionHandler } } -- (void)readAttributeCurrentX:(ResponseHandler)completionHandler +- (void)readAttributePrimary4Y:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2349,7 +3624,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 +3632,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 +3647,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 +3655,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 +3693,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 +3701,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 +3716,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 +3724,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 +3762,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 +3770,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 +3785,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 +3793,7 @@ - (void)readAttributeCompensationText:(ResponseHandler)completionHandler } } -- (void)readAttributeColorTemperature:(ResponseHandler)completionHandler +- (void)readAttributeWhitePointX:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2526,7 +3808,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 +3816,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 +3831,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 +3839,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 +3854,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 +3862,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 +3877,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 +3885,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 +3900,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 +3908,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 +3923,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 +3931,7 @@ - (void)readAttributeNumberOfPrimaries:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary1X:(ResponseHandler)completionHandler +- (void)readAttributeColorPointRY:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2683,7 +3946,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 +3954,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 +3969,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 +3977,7 @@ - (void)readAttributePrimary1Y:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary1Intensity:(ResponseHandler)completionHandler +- (void)readAttributeColorPointRIntensity:(ResponseHandler)completionHandler { CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2729,7 +3992,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 +4000,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 +4015,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 +4023,7 @@ - (void)readAttributePrimary2X:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary2Y:(ResponseHandler)completionHandler +- (void)readAttributeColorPointGX:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2775,7 +4038,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 +4046,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 +4061,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 +4069,7 @@ - (void)readAttributePrimary2Intensity:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary3X:(ResponseHandler)completionHandler +- (void)readAttributeColorPointGY:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2821,7 +4084,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 +4092,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 +4107,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 +4115,7 @@ - (void)readAttributePrimary3Y:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary3Intensity:(ResponseHandler)completionHandler +- (void)readAttributeColorPointGIntensity:(ResponseHandler)completionHandler { CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2867,7 +4130,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 +4138,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 +4153,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 +4161,7 @@ - (void)readAttributePrimary4X:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary4Y:(ResponseHandler)completionHandler +- (void)readAttributeColorPointBX:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2913,7 +4176,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 +4184,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 +4199,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 +4207,7 @@ - (void)readAttributePrimary4Intensity:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary5X:(ResponseHandler)completionHandler +- (void)readAttributeColorPointBY:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -2959,7 +4222,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 +4230,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 +4245,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 +4253,7 @@ - (void)readAttributePrimary5Y:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary5Intensity:(ResponseHandler)completionHandler +- (void)readAttributeColorPointBIntensity:(ResponseHandler)completionHandler { CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -3005,7 +4268,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 +4276,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 +4291,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 +4299,7 @@ - (void)readAttributePrimary6X:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary6Y:(ResponseHandler)completionHandler +- (void)readAttributeEnhancedCurrentHue:(ResponseHandler)completionHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -3051,7 +4314,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 +4322,7 @@ - (void)readAttributePrimary6Y:(ResponseHandler)completionHandler } } -- (void)readAttributePrimary6Intensity:(ResponseHandler)completionHandler +- (void)readAttributeEnhancedColorMode:(ResponseHandler)completionHandler { CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(completionHandler, [self callbackQueue]); if (!onSuccess) { @@ -3074,7 +4337,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 +4345,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 +4360,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 +4368,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 +4383,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 +4391,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 +4406,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 +4414,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 +4429,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 +4437,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 +4452,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 +4460,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 +4475,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 +4483,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 +4498,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 +4506,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 +4521,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 +4529,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 +4544,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 +4552,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 +4567,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 +4575,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 +4604,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 +4627,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 +4635,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 +4650,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 +4658,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 +4687,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 +4710,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 +4733,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 +4756,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 +4779,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 +4802,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 +4825,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 +4848,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 +4871,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 +4894,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 +4917,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 +4940,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 +4963,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 +4986,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 +5009,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 +5038,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 +5066,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 +5095,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 +5120,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 +5150,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 +5178,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 +5202,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 +5227,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 +5252,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 +5277,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 +5316,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 +5340,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 +5363,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 +5403,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 +5427,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 +5454,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 +5480,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 +5503,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 +5526,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 +5549,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 +5586,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 +5610,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 +5635,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 +5657,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 +5680,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 +5703,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 +5726,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 +5749,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 +5757,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 +5785,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 +5808,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 +5816,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 +5831,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 +5839,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 +5854,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 +5887,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 +5917,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 +5943,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 +5968,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 +5990,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 +6017,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 +6043,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 +6065,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 +6087,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 +6095,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 +6110,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 +6136,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 +6145,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 +6175,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 +6183,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 +6211,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 +6244,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 +6270,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 +6292,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 +6314,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 +6336,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 +6358,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 +6380,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 +6402,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 +6424,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 +6446,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 +6468,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 +6476,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 +6706,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 +6726,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..72a0198e2f97be 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 @@ -392,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 @@ -1104,10 +1109,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 +3844,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) @@ -4085,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/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..79d1e159594a4a 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 @@ -1893,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 @@ -5765,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 2069290df636a7..add8f83d188cf8 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,9 +80,15 @@ // 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) +// 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 655425d5d43d35..864943b5727fcd 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) @@ -236,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) @@ -698,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/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..8c737e93fea79c 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,12 +144,24 @@ #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 #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 @@ -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,7 +810,9 @@ 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_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/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 71fc2f7dbcf3a8..16596fa307cba3 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; @@ -48,8 +53,6 @@ template class GenericThreadStackManagerImpl_OpenThread_LwIP; template class GenericThreadStackManagerImpl_FreeRTOS; -template -class GenericNetworkProvisioningServerImpl; } // namespace Internal /** @@ -74,6 +77,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 +86,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 @@ -111,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(); @@ -227,9 +229,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 +337,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.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..44e410beb39151 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 @@ -64,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); @@ -125,16 +128,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/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/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/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/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 eb712430482f2f..ab35b586a137db 100644 --- a/src/lib/mdns/Discovery_ImplPlatform.cpp +++ b/src/lib/mdns/Discovery_ImplPlatform.cpp @@ -57,28 +57,39 @@ 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; + mCommissionInstanceName = GetRandU64(); + mMdnsInitialized = true; } - else + + 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) { - error = ChipMdnsStopPublish(); + ChipLogError(Discovery, "Failed to initialize platform mdns: %s", ErrorStr(error)); } + error = SetupHostname(); if (error != CHIP_NO_ERROR) { - ChipLogError(Discovery, "Failed to initialize platform mdns: %s", ErrorStr(error)); + ChipLogError(Discovery, "Failed to setup mdns hostname: %s", ErrorStr(error)); } + return error; } @@ -137,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. @@ -145,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; @@ -251,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; @@ -280,6 +301,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 +380,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 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/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/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/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/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/platform/BUILD.gn b/src/platform/BUILD.gn index 4b924b5f4f403e..784e7fde2a3bbe 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" ] } @@ -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", @@ -241,7 +239,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" ] } @@ -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", @@ -494,7 +490,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 +591,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/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..a185e1ba99ddfa 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"); @@ -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 { @@ -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/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/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/src/platform/ESP32/BLEManagerImpl.h b/src/platform/ESP32/BLEManagerImpl.h index 0cafee56d59a10..317daff518af79 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. * @@ -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, @@ -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/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.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..9e41eb9161a7f3 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" @@ -40,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. */ @@ -67,6 +60,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 +108,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 +166,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/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/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..7ae4e60226f775 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. * @@ -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 { @@ -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/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/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 ****************************************/ 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/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/Linux/bluez/Helper.cpp b/src/platform/Linux/bluez/Helper.cpp index 701feea6c6b61f..bb61299009ea08 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); @@ -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; 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/Zephyr/BLEManagerImpl.cpp b/src/platform/Zephyr/BLEManagerImpl.cpp index 7396d486c882e0..e1845a7acad9a0 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); @@ -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); @@ -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/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/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..483e85a748456a 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. @@ -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 { @@ -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/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" ] } 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/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/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/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..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. @@ -598,16 +607,11 @@ class DLL_EXPORT PacketBufferHandle uint16_t aReservedSize = PacketBuffer::kDefaultHeaderReserve); /** - * Creates a copy of the data in this packet. - * - * 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. + * Creates a copy of a packet buffer (or chain). * - * @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() 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/SecureSessionMgr.cpp b/src/transport/SecureSessionMgr.cpp index 95219e5af0b098..d8d749f9bd9d7a 100644 --- a/src/transport/SecureSessionMgr.cpp +++ b/src/transport/SecureSessionMgr.cpp @@ -85,6 +85,18 @@ CHIP_ERROR SecureSessionMgr::Init(NodeId localNodeId, System::Layer * systemLaye return CHIP_NO_ERROR; } +void SecureSessionMgr::Shutdown() +{ + CancelExpiryTimer(); + + 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); @@ -317,6 +329,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")); @@ -365,14 +378,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 443262006894f9..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; }; /** @@ -270,6 +275,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 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; } 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..f6d93a1d4618b6 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. @@ -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; }; 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",