From 2f5ac94b67cb2ce8d90773b9978410ee3bd32106 Mon Sep 17 00:00:00 2001 From: Markus Becker Date: Wed, 26 May 2021 07:18:18 +0200 Subject: [PATCH 1/4] Initial matter Python end-device This PR facilitates to create a Python based matter end-device. * Adds sample with README in examples/lighting-app/python * This sample requires a DALI-USB-interface * Checked onnetwork / ip commissioning only * Adds server clusters for Python matter end-device to controller-clusters.zap * Possibly this should be split into another zap file, but hard to get the build system set up without duplicating code. Help/Suggestions welcome. * build-chip-wheel.py was auto-formatted * Typo fixed in operational-credentials-server.cpp TODO: [ ] check whether WiFi/BLE commissioning would work --- examples/lighting-app/python/BUILD.gn | 92 + examples/lighting-app/python/README.md | 48 + examples/lighting-app/python/lighting.py | 280 ++ .../operational-credentials-server.cpp | 2 +- .../data_model/controller-clusters.zap | 3612 ++++++++++++++++- src/controller/data_model/gen/af-gen-event.h | 30 +- src/controller/python/BUILD.gn | 3 + src/controller/python/build-chip-wheel.py | 157 +- .../python/chip/server/ServerInit.cpp | 179 + src/controller/python/chip/server/__init__.py | 90 + src/controller/python/chip/server/types.py | 14 + 11 files changed, 4238 insertions(+), 269 deletions(-) create mode 100644 examples/lighting-app/python/BUILD.gn create mode 100644 examples/lighting-app/python/README.md create mode 100644 examples/lighting-app/python/lighting.py create mode 100644 src/controller/python/chip/server/ServerInit.cpp create mode 100644 src/controller/python/chip/server/__init__.py create mode 100644 src/controller/python/chip/server/types.py diff --git a/examples/lighting-app/python/BUILD.gn b/examples/lighting-app/python/BUILD.gn new file mode 100644 index 00000000000000..e7348bd8240eee --- /dev/null +++ b/examples/lighting-app/python/BUILD.gn @@ -0,0 +1,92 @@ +# 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}/build/chip/tools.gni") +import("${chip_root}/src/app/common_flags.gni") + +assert(chip_build_tools) + +import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") + +config("includes") { + include_dirs = [ + ".", + "include", + ] +} + +executable("chip-lighting-app") { + sources = [ + "LightingManager.cpp", + "include/CHIPProjectAppConfig.h", + "include/LightingManager.h", + "main.cpp", + ] + + deps = [ + "${chip_root}/examples/lighting-app/lighting-common", + "${chip_root}/examples/platform/linux:app-main", + "${chip_root}/src/lib", + ] + + include_dirs = [ "include" ] + + cflags = [ "-Wconversion" ] + + if (chip_enable_pw_rpc) { + import("//build_overrides/pigweed.gni") + + defines = [ "PW_RPC_ENABLED" ] + + sources += [ + "${dir_pigweed}/targets/host/system_rpc_server.cc", + "Rpc.cpp", + ] + + deps += [ + "$dir_pw_hdlc:pw_rpc", + "$dir_pw_hdlc:rpc_channel_output", + "$dir_pw_log", + "$dir_pw_rpc:server", + "$dir_pw_rpc:synchronized_channel_output", + "$dir_pw_rpc/system_server:facade", + "$dir_pw_stream:socket_stream", + "$dir_pw_stream:sys_io_stream", + "$dir_pw_sync:mutex", + "${chip_root}/config/linux/lib/pw_rpc:pw_rpc", + "${chip_root}/examples/common/pigweed:button_service.nanopb_rpc", + "${chip_root}/examples/common/pigweed:device_service.nanopb_rpc", + "${chip_root}/examples/lighting-app/lighting-common:lighting_service.nanopb_rpc", + ] + } + + output_dir = root_out_dir +} + +group("linux") { + deps = [ ":chip-lighting-app" ] + + if (chip_enable_pw_rpc) { + deps += [ + "${chip_root}/examples/lighting-app/lighting-common/py:lighting_app.install", + "${chip_root}/examples/lighting-app/lighting-common/py:lighting_app_wheel", + ] + } +} + +group("default") { + deps = [ ":linux" ] +} diff --git a/examples/lighting-app/python/README.md b/examples/lighting-app/python/README.md new file mode 100644 index 00000000000000..f52a56771ee949 --- /dev/null +++ b/examples/lighting-app/python/README.md @@ -0,0 +1,48 @@ +# README + +Python based lighting example (bridge) device to DALI. + +## Installation + +Add the following options in scripts/build_python.sh to the gn args: + +```shell +chip_config_network_layer_ble=false +``` + +Build the Python/C library: + +```shell +scripts/build_python.sh --clusters_for_ip_commissioning false --chip_mdns platform --chip_detail_logging true + +source ./out/python_env/bin/activate +``` + +Install the python dependencies: + +```shell +cd examples/lighting-app/python +pip3 install python-dali +``` + +Plug-in a python-dali compatible USB-DALI interface. + +## Usage + +Run the Python lighting matter device: + +```shell +cd examples/lighting-app/python +python lighting.py +``` + +Control the Python lighting matter device: + +```shell +source ./out/python_env/bin/activate + +chip-device-ctrl + +chip-device-ctrl > connect -ip 127.0.0.1 20202021 1234 +chip-device-ctrl > zcl OnOff Toggle 1234 1 0 +``` diff --git a/examples/lighting-app/python/lighting.py b/examples/lighting-app/python/lighting.py new file mode 100644 index 00000000000000..1067e3a38003f5 --- /dev/null +++ b/examples/lighting-app/python/lighting.py @@ -0,0 +1,280 @@ +# +# 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. +# + +from chip.server import ( + GetLibraryHandle, + NativeLibraryHandleMethodArguments, + PostAttributeChangeCallback, +) + +# from chip.server.types import PostAttributeChangeCallback +from chip.exceptions import ChipStackError + +from ctypes import CFUNCTYPE, c_char_p, c_int32, c_uint8 + +import sys +import os + +import textwrap +import string + +from cmd import Cmd + +import asyncio +import threading + +from dali.driver.hid import tridonic +from dali.gear.general import RecallMaxLevel, Off, DAPC +from dali.address import Broadcast, Short + +dali_loop = None +dev = None + + +async def dali_on(is_on: bool): + global dali_loop + global dev + + #print("Waiting for device...") + await dev.connected.wait() + #print(f"Connected, firmware={dev.firmware_version}, serial={dev.serial}") + if (is_on): + await dev.send(RecallMaxLevel(Broadcast())) + else: + await dev.send(Off(Broadcast())) + + +async def dali_level(level: int): + global dali_loop + global dev + + #print("Waiting for device...") + await dev.connected.wait() + #print(f"Connected, firmware={dev.firmware_version}, serial={dev.serial}") + await dev.send(DAPC(Broadcast(), level)) + + +def daliworker(): + global dali_loop + global dev + + dali_loop = asyncio.new_event_loop() + dev = tridonic("/dev/dali/daliusb-*", glob=True, loop=dali_loop) + dev.connect() + + asyncio.set_event_loop(dali_loop) + dali_loop.run_forever() + + +class LightingMgrCmd(Cmd): + def __init__(self, rendezvousAddr=None, controllerNodeId=0, bluetoothAdapter=None): + self.lastNetworkId = None + + Cmd.__init__(self) + + Cmd.identchars = string.ascii_letters + string.digits + "-" + + if sys.stdin.isatty(): + self.prompt = "chip-lighting > " + else: + self.use_rawinput = 0 + self.prompt = "" + + LightingMgrCmd.command_names.sort() + + # self.bleMgr = None + + # self.devCtrl = ChipDeviceCtrl.ChipDeviceController( + # controllerNodeId=controllerNodeId, bluetoothAdapter=bluetoothAdapter + # ) + + # # If we are on Linux and user selects non-default bluetooth adapter. + # if sys.platform.startswith("linux") and (bluetoothAdapter is not None): + # self.bleMgr = BleManager(self.devCtrl) + # self.bleMgr.ble_adapter_select("hci{}".format(bluetoothAdapter)) + + self.historyFileName = os.path.expanduser("~/.chip-lighting-history") + + try: + import readline + + if "libedit" in readline.__doc__: + readline.parse_and_bind("bind ^I rl_complete") + readline.set_completer_delims(" ") + try: + readline.read_history_file(self.historyFileName) + except IOError: + pass + except ImportError: + pass + + command_names = [ + "help" + # "setup-payload", + # "ble-scan", + # "ble-adapter-select", + # "ble-adapter-print", + # "ble-debug-log", + # "connect", + # "close-ble", + # "resolve", + # "zcl", + # "zclread", + # "zclconfigure", + # "discover", + # "set-pairing-wifi-credential", + # "set-pairing-thread-credential", + ] + + def parseline(self, line): + cmd, arg, line = Cmd.parseline(self, line) + if cmd: + cmd = self.shortCommandName(cmd) + line = cmd + " " + arg + return cmd, arg, line + + def completenames(self, text, *ignored): + return [ + name + " " + for name in LightingMgrCmd.command_names + if name.startswith(text) or self.shortCommandName(name).startswith(text) + ] + + def shortCommandName(self, cmd): + return cmd.replace("-", "") + + def precmd(self, line): + if not self.use_rawinput and line != "EOF" and line != "": + print(">>> " + line) + return line + + def postcmd(self, stop, line): + if not stop and self.use_rawinput: + self.prompt = "chip-lighting > " + return stop + + def postloop(self): + try: + import readline + + try: + readline.write_history_file(self.historyFileName) + except IOError: + pass + except ImportError: + pass + + def do_help(self, line): + """ + help + + Print the help + """ + if line: + cmd, arg, unused = self.parseline(line) + try: + doc = getattr(self, "do_" + cmd).__doc__ + except AttributeError: + doc = None + if doc: + self.stdout.write("%s\n" % textwrap.dedent(doc)) + else: + self.stdout.write("No help on %s\n" % (line)) + else: + self.print_topics( + "\nAvailable commands (type help for more information):", + LightingMgrCmd.command_names, + 15, + 80, + ) + + +@PostAttributeChangeCallback +def attributeChangeCallback( + endpoint: int, + clusterId: int, + attributeId: int, + mask: int, + manufacturerCode: int, + xx_type: int, + size: int, + value: bytes, +): + # print( + # "[PY] AttributeChangeCallback endpoint {} clusterId {} attributeId {} mask {} manufacturerCode {} type {} size {} value {}".format( + # endpoint, + # clusterId, + # attributeId, + # mask, + # manufacturerCode, + # xx_type, + # size, + # value, + # ) + # ) + global dali_loop + if endpoint == 1: + if clusterId == 6 and attributeId == 0: + if len(value) == 1 and value[0] == 1: + # print("[PY] light on") + future = asyncio.run_coroutine_threadsafe( + dali_on(True), dali_loop) + future.result() + else: + # print("[PY] light off") + future = asyncio.run_coroutine_threadsafe( + dali_on(False), dali_loop) + future.result() + elif clusterId == 8 and attributeId == 0: + if len(value) == 2: + # print("[PY] level {}".format(value[0])) + future = asyncio.run_coroutine_threadsafe( + dali_level(value[0]), dali_loop) + future.result() + else: + print("[PY] no level") + else: + # print("[PY] [ERR] unhandled cluster {} or attribute {}".format( + # clusterId, attributeId)) + pass + else: + print("[PY] [ERR] unhandled endpoint {} ".format(endpoint)) + + +class Lighting: + def __init__(self): + self.chipLib = GetLibraryHandle(attributeChangeCallback) + + +if __name__ == "__main__": + l = Lighting() + + lightMgrCmd = LightingMgrCmd() + print("Chip Lighting Device Shell") + print() + + print("Starting DALI async") + threads = [] + t = threading.Thread(target=daliworker) + threads.append(t) + t.start() + + try: + lightMgrCmd.cmdloop() + except KeyboardInterrupt: + print("\nQuitting") + + sys.exit(0) diff --git a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp index 107de026bf75bd..07511c8b69991e 100644 --- a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp +++ b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp @@ -120,7 +120,7 @@ CHIP_ERROR writeAdminsIntoFabricsListAttribute() if (nodeId == kUndefinedNodeId || fabricId == kUndefinedFabricId || vendorId == kUndefinedVendorId) { emberAfPrintln(EMBER_AF_PRINT_DEBUG, - "OpCreds: Skipping over unitialized admin with fabricId 0x" ChipLogFormatX64 + "OpCreds: Skipping over uninitialized admin with fabricId 0x" ChipLogFormatX64 ", nodeId 0x" ChipLogFormatX64 " vendorId 0x%04" PRIX16, ChipLogValueX64(fabricId), ChipLogValueX64(nodeId), vendorId); continue; diff --git a/src/controller/data_model/controller-clusters.zap b/src/controller/data_model/controller-clusters.zap index 65b8e15031e61a..a4ad0d5741b86b 100644 --- a/src/controller/data_model/controller-clusters.zap +++ b/src/controller/data_model/controller-clusters.zap @@ -30,6 +30,3411 @@ } ], "endpointTypes": [ + { + "name": "Anonymous Endpoint Type", + "deviceTypeName": "CHIP-All-Clusters-Server", + "deviceTypeCode": 0, + "deviceTypeProfileId": 259, + "clusters": [ + { + "name": "Identify", + "code": 3, + "mfgCode": null, + "define": "IDENTIFY_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", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "2", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Identify", + "code": 3, + "mfgCode": null, + "define": "IDENTIFY_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [ + { + "name": "IdentifyQueryResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "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": "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": "Groups", + "code": 4, + "mfgCode": null, + "define": "GROUPS_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "AddGroup", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ViewGroup", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetGroupMembership", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveGroup", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveAllGroups", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "AddGroupIfIdentifying", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "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": "Groups", + "code": 4, + "mfgCode": null, + "define": "GROUPS_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [ + { + "name": "AddGroupResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ViewGroupResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetGroupMembershipResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveGroupResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "name support", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "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": "Scenes", + "code": 5, + "mfgCode": null, + "define": "SCENES_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "AddScene", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ViewScene", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveScene", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveAllScenes", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "StoreScene", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RecallScene", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetSceneMembership", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Scenes", + "code": 5, + "mfgCode": null, + "define": "SCENES_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [ + { + "name": "AddSceneResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ViewSceneResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveSceneResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveAllScenesResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "StoreSceneResponse", + "code": 4, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetSceneMembershipResponse", + "code": 6, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "scene count", + "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": "current scene", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "current group", + "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": "scene valid", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "name support", + "code": 4, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "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": "On/off", + "code": 6, + "mfgCode": null, + "define": "ON_OFF_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "Off", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "On", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "Toggle", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "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": "On/off", + "code": 6, + "mfgCode": null, + "define": "ON_OFF_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [], + "attributes": [ + { + "name": "OnOff", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "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": "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": 0, + "commands": [], + "attributes": [ + { + "name": "current level", + "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": "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": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "MfgSpecificPing", + "code": 0, + "mfgCode": 4098, + "source": "client", + "incoming": 1, + "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": 1, + "commands": [ + { + "name": "StartUp", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "ShutDown", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Leave", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "InteractionModelVersion", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "1", + "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": "0", + "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": "0", + "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": "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": "General Commissioning", + "code": 48, + "mfgCode": null, + "define": "GENERAL_COMMISSIONING_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "ArmFailSafe", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetRegulatoryConfig", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "CommissioningComplete", + "code": 4, + "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": "ArmFailSafeResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetRegulatoryConfigResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "CommissioningCompleteResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "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": "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": "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": 0, + "outgoing": 0 + }, + { + "name": "UpdateThreadNetwork", + "code": 8, + "mfgCode": null, + "source": "client", + "incoming": 0, + "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": 0 + }, + { + "name": "UpdateThreadNetworkResponse", + "code": 9, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 0 + }, + { + "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": "Operational Credentials", + "code": 62, + "mfgCode": null, + "define": "OPERATIONAL_CREDENTIALS_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "SetFabric", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "OpCSRRequest", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "AddOpCert", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "UpdateFabricLabel", + "code": 9, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveFabric", + "code": 10, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveAllFabrics", + "code": 11, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "AddTrustedRootCertificate", + "code": 161, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveTrustedRootCertificate", + "code": 162, + "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": "Operational Credentials", + "code": 62, + "mfgCode": null, + "define": "OPERATIONAL_CREDENTIALS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "SetFabricResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "OpCSRResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "OpCertResponse", + "code": 8, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "fabrics list", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "cluster revision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Door Lock", + "code": 257, + "mfgCode": null, + "define": "DOOR_LOCK_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "LockDoor", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "UnlockDoor", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "UnlockWithTimeout", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetLogRecord", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetPin", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetPin", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ClearPin", + "code": 7, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ClearAllPins", + "code": 8, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetWeekdaySchedule", + "code": 11, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetWeekdaySchedule", + "code": 12, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ClearWeekdaySchedule", + "code": 13, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetYeardaySchedule", + "code": 14, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetYeardaySchedule", + "code": 15, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ClearYeardaySchedule", + "code": 16, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetHolidaySchedule", + "code": 17, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetHolidaySchedule", + "code": 18, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ClearHolidaySchedule", + "code": 19, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetUserType", + "code": 20, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetUserType", + "code": 21, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetRfid", + "code": 22, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "GetRfid", + "code": 23, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ClearRfid", + "code": 24, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "ClearAllRfids", + "code": 25, + "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": "Door Lock", + "code": 257, + "mfgCode": null, + "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": "lock state", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "lock 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": "actuator enabled", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "door state", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "enable logging", + "code": 32, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "language", + "code": 33, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "led settings", + "code": 34, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "auto relock time", + "code": 35, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "sound volume", + "code": 36, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "operating mode", + "code": 37, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "default configuration register", + "code": 39, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "enable local programming", + "code": 40, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "enable one touch locking", + "code": 41, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "enable inside status led", + "code": 42, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "enable privacy mode button", + "code": 43, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "wrong code entry limit", + "code": 48, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "user code temporary disable time", + "code": 49, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "send pin over the air", + "code": 50, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "require pin for rf operation", + "code": 51, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "zigbee security level", + "code": 52, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "alarm mask", + "code": 64, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "keypad operation event mask", + "code": 65, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RF operation event mask", + "code": 66, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "manual operation event mask", + "code": 67, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "rfid operation event mask", + "code": 68, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "keypad programming event mask", + "code": 69, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "rf programming event mask", + "code": 70, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "rfid programming event mask", + "code": 71, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "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": "Barrier Control", + "code": 259, + "mfgCode": null, + "define": "BARRIER_CONTROL_CLUSTER", + "side": "client", + "enabled": 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 + } + ], + "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": "Barrier Control", + "code": 259, + "mfgCode": null, + "define": "BARRIER_CONTROL_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [], + "attributes": [ + { + "name": "barrier moving state", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "barrier safety status", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "barrier capabilities", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "barrier position", + "code": 10, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "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": "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": 1 + }, + { + "name": "MoveHue", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "StepHue", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "MoveToSaturation", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "MoveSaturation", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "StepSaturation", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "MoveToHueAndSaturation", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "MoveToColor", + "code": 7, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "MoveColor", + "code": 8, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "StepColor", + "code": 9, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "MoveToColorTemperature", + "code": 10, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "StopMoveStep", + "code": 71, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "MoveColorTemperature", + "code": 75, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "StepColorTemperature", + "code": 76, + "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": "Color Control", + "code": 768, + "mfgCode": null, + "define": "COLOR_CONTROL_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [], + "attributes": [ + { + "name": "current hue", + "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": "current saturation", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "remaining time", + "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": "current x", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x616B", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "current y", + "code": 4, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x607D", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "drift compensation", + "code": 5, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "compensation text", + "code": 6, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "color temperature", + "code": 7, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00FA", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "color mode", + "code": 8, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "color control options", + "code": 15, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "number of primaries", + "code": 16, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "primary 1 x", + "code": 17, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "primary 1 y", + "code": 18, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "primary 1 intensity", + "code": 19, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "primary 2 x", + "code": 21, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "primary 2 y", + "code": 22, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "primary 2 intensity", + "code": 23, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "primary 3 x", + "code": 25, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "primary 3 y", + "code": 26, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "primary 3 intensity", + "code": 27, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "primary 4 x", + "code": 32, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "primary 4 y", + "code": 33, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "primary 4 intensity", + "code": 34, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "primary 5 x", + "code": 36, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "primary 5 y", + "code": 37, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "primary 5 intensity", + "code": 38, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "primary 6 x", + "code": 40, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "primary 6 y", + "code": 41, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "primary 6 intensity", + "code": 42, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "white point x", + "code": 48, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "white point y", + "code": 49, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "color point r x", + "code": 50, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "color point r y", + "code": 51, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "color point r intensity", + "code": 52, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "color point g x", + "code": 54, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "color point g y", + "code": 55, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "color point g intensity", + "code": 56, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "color point b x", + "code": 58, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "color point b y", + "code": 59, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "color point b intensity", + "code": 60, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "enhanced current hue", + "code": 16384, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "enhanced color mode", + "code": 16385, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "color loop active", + "code": 16386, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "color loop direction", + "code": 16387, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "color loop time", + "code": 16388, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0019", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "color capabilities", + "code": 16394, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "color temp physical min", + "code": 16395, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "color temp physical max", + "code": 16396, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFEFF", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "couple color temp to level min-mireds", + "code": 16397, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "start up color temperature mireds", + "code": 16400, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "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": "Temperature Measurement", + "code": 1026, + "mfgCode": null, + "define": "TEMP_MEASUREMENT_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": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Temperature Measurement", + "code": 1026, + "mfgCode": null, + "define": "TEMP_MEASUREMENT_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [], + "attributes": [ + { + "name": "measured value", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "min measured value", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x8000", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "max measured value", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x8000", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "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": "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": 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 + } + ] + }, + { + "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": 0, + "outgoing": 1 + }, + { + "name": "ZoneEnrollRequest", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "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": "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": "Anonymous Endpoint Type", "deviceTypeName": "CHIP-All-Clusters-Server", @@ -210,7 +3615,7 @@ "mfgCode": null, "define": "GROUPS_CLUSTER", "side": "server", - "enabled": 0, + "enabled": 1, "commands": [ { "name": "AddGroupResponse", @@ -367,7 +3772,7 @@ "mfgCode": null, "define": "SCENES_CLUSTER", "side": "server", - "enabled": 0, + "enabled": 1, "commands": [ { "name": "AddSceneResponse", @@ -592,7 +3997,7 @@ "mfgCode": null, "define": "ON_OFF_CLUSTER", "side": "server", - "enabled": 0, + "enabled": 1, "commands": [], "attributes": [ { @@ -799,7 +4204,7 @@ "mfgCode": null, "define": "LEVEL_CONTROL_CLUSTER", "side": "server", - "enabled": 0, + "enabled": 1, "commands": [], "attributes": [ { @@ -4715,7 +8120,7 @@ "outgoing": 1 }, { - "name": "Stop", + "name": "StopMotion", "code": 2, "mfgCode": null, "source": "client", @@ -5680,70 +9085,6 @@ "source": "client", "incoming": 1, "outgoing": 1 - }, - { - "name": "EnhancedMoveToHue", - "code": 64, - "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "EnhancedMoveHue", - "code": 65, - "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "EnhancedStepHue", - "code": 66, - "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "EnhancedMoveToHueAndSaturation", - "code": 67, - "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "ColorLoopSet", - "code": 68, - "mfgCode": null, - "source": "client", - "incoming": 0, - "outgoing": 1 - }, - { - "name": "StopMoveStep", - "code": 71, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "MoveColorTemperature", - "code": 75, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, - { - "name": "StepColorTemperature", - "code": 76, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 } ], "attributes": [ @@ -6373,126 +9714,6 @@ "maxInterval": 65344, "reportableChange": 0 }, - { - "name": "enhanced current hue", - "code": 16384, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "enhanced color mode", - "code": 16385, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x01", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "color loop active", - "code": 16386, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "color loop direction", - "code": 16387, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x00", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "color loop time", - "code": 16388, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0019", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "color capabilities", - "code": 16394, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "color temp physical min", - "code": 16395, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "color temp physical max", - "code": 16396, - "mfgCode": null, - "side": "server", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0xFEFF", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, { "name": "couple color temp to level min-mireds", "code": 16397, @@ -9400,10 +12621,19 @@ { "endpointTypeName": "Anonymous Endpoint Type", "endpointTypeIndex": 0, - "profileId": "0x0103", + "profileId": 259, + "endpointId": 0, + "networkId": 0, + "endpointVersion": 1, + "deviceIdentifier": 0 + }, + { + "endpointTypeName": "Anonymous Endpoint Type", + "endpointTypeIndex": 1, + "profileId": 259, "endpointId": 1, "networkId": 0, - "endpointVersion": null, + "endpointVersion": 1, "deviceIdentifier": null } ], diff --git a/src/controller/data_model/gen/af-gen-event.h b/src/controller/data_model/gen/af-gen-event.h index 0b0c750065e3a7..1f202280dd32ac 100644 --- a/src/controller/data_model/gen/af-gen-event.h +++ b/src/controller/data_model/gen/af-gen-event.h @@ -40,9 +40,33 @@ #define __AF_GEN_EVENT__ // Code used to configure the cluster event mechanism -#define EMBER_AF_GENERATED_EVENT_CODE +#define EMBER_AF_GENERATED_EVENT_CODE \ + EmberEventControl emberAfLevelControlClusterServerTickCallbackControl1; \ + static void clusterTickWrapper(EmberEventControl * control, EmberAfTickFunction callback, uint8_t endpoint) \ + { \ + /* emberAfPushEndpointNetworkIndex(endpoint); */ \ + emberEventControlSetInactive(control); \ + (*callback)(endpoint); \ + /* emberAfPopNetworkIndex(); */ \ + } \ + \ + void emberAfLevelControlClusterServerTickCallbackWrapperFunction1(void) \ + { \ + clusterTickWrapper(&emberAfLevelControlClusterServerTickCallbackControl1, emberAfLevelControlClusterServerTickCallback, \ + 1); \ + } + // EmberEventData structs used to populate the EmberEventData table -#define EMBER_AF_GENERATED_EVENTS -#define EMBER_AF_GENERATED_EVENT_STRINGS +#define EMBER_AF_GENERATED_EVENTS \ + { &emberAfLevelControlClusterServerTickCallbackControl1, emberAfLevelControlClusterServerTickCallbackWrapperFunction1 }, + +#define EMBER_AF_GENERATED_EVENT_STRINGS "Level Control Cluster Server EP 1", + +// The length of the event context table used to track and retrieve cluster events +#define EMBER_AF_EVENT_CONTEXT_LENGTH 1 + +// EmberAfEventContext structs used to populate the EmberAfEventContext table +#define EMBER_AF_GENERATED_EVENT_CONTEXT \ + { 0x1, 0x8, false, EMBER_AF_LONG_POLL, EMBER_AF_OK_TO_SLEEP, &emberAfLevelControlClusterServerTickCallbackControl1 }, #endif // __AF_GEN_EVENT__ diff --git a/src/controller/python/BUILD.gn b/src/controller/python/BUILD.gn index 1e79e5196f1bc4..80961eeff3e301 100644 --- a/src/controller/python/BUILD.gn +++ b/src/controller/python/BUILD.gn @@ -54,6 +54,7 @@ shared_library("ChipDeviceCtrl") { "chip/logging/LoggingRedirect.cpp", "chip/native/StackInit.cpp", "chip/setup_payload/Generator.cpp", + "chip/server/ServerInit.cpp", "chip/setup_payload/Parser.cpp", ] @@ -126,6 +127,8 @@ pw_python_action("python") { "chip/logging/library_handle.py", "chip/logging/types.py", "chip/native/__init__.py", + "chip/server/__init__.py", + "chip/server/types.py", "chip/setup_payload/__init__.py", "chip/setup_payload/setup_payload.py", "chip/tlv/__init__.py", diff --git a/src/controller/python/build-chip-wheel.py b/src/controller/python/build-chip-wheel.py index 59f1a5a95cbc49..e7b59be96f692c 100644 --- a/src/controller/python/build-chip-wheel.py +++ b/src/controller/python/build-chip-wheel.py @@ -33,31 +33,38 @@ import shutil -parser = argparse.ArgumentParser(description='build the pip package for chip using chip components generated during the build and python source code') -parser.add_argument('--package_name', default='chip', help='configure the python package name') -parser.add_argument('--build_number', default='0.0', help='configure the chip build number') -parser.add_argument('--build_dir', help='directory to build in') -parser.add_argument('--dist_dir', help='directory to place distribution in') -parser.add_argument('--manifest', help='list of files to package') -parser.add_argument('--plat-name', help='platform name to embed in generated filenames') +parser = argparse.ArgumentParser( + description="build the pip package for chip using chip components generated during the build and python source code" +) +parser.add_argument( + "--package_name", default="chip", help="configure the python package name" +) +parser.add_argument( + "--build_number", default="0.0", help="configure the chip build number" +) +parser.add_argument("--build_dir", help="directory to build in") +parser.add_argument("--dist_dir", help="directory to place distribution in") +parser.add_argument("--manifest", help="list of files to package") +parser.add_argument("--plat-name", help="platform name to embed in generated filenames") args = parser.parse_args() + class InstalledScriptInfo: """Information holder about a script that is to be installed.""" def __init__(self, name): - self.name = name - self.installName = os.path.splitext(name)[0] + self.name = name + self.installName = os.path.splitext(name)[0] -chipDLLName = '_ChipDeviceCtrl.so' +chipDLLName = "_ChipDeviceCtrl.so" packageName = args.package_name chipPackageVer = args.build_number installScripts = [ - InstalledScriptInfo('chip-device-ctrl.py'), - InstalledScriptInfo('chip-repl.py'), + InstalledScriptInfo("chip-device-ctrl.py"), + InstalledScriptInfo("chip-repl.py"), ] # Record the current directory at the start of execution. @@ -69,9 +76,9 @@ def __init__(self, name): # Use a temporary directory within the build directory to assemble the components # for the installable package. -tmpDir = os.path.join(buildDir, 'chip-wheel-components') +tmpDir = os.path.join(buildDir, "chip-wheel-components") -manifest = json.load(open(manifestFile, 'r')) +manifest = json.load(open(manifestFile, "r")) try: @@ -89,17 +96,18 @@ def __init__(self, name): os.chdir(tmpDir) manifestBase = os.path.dirname(manifestFile) - for entry in manifest['files']: - srcDir = os.path.join(manifestBase, entry['src_dir']) - for path in entry['sources']: - srcFile = os.path.join(srcDir, path) - dstFile = os.path.join(tmpDir, path) - os.makedirs(os.path.dirname(dstFile), exist_ok=True) - shutil.copyfile(srcFile, dstFile) + for entry in manifest["files"]: + srcDir = os.path.join(manifestBase, entry["src_dir"]) + for path in entry["sources"]: + srcFile = os.path.join(srcDir, path) + dstFile = os.path.join(tmpDir, path) + os.makedirs(os.path.dirname(dstFile), exist_ok=True) + shutil.copyfile(srcFile, dstFile) for script in installScripts: - os.rename(os.path.join(tmpDir, script.name), - os.path.join(tmpDir, script.installName)) + os.rename( + os.path.join(tmpDir, script.name), os.path.join(tmpDir, script.installName) + ) # Define a custom version of the bdist_wheel command that configures the # resultant wheel as platform-specific (i.e. not "pure"). @@ -110,35 +118,36 @@ def finalize_options(self): requiredPackages = [ "coloredlogs", - 'construct', - 'ipython', + "construct", + "ipython", ] - if platform.system() == 'Darwin': - requiredPackages.append('pyobjc-framework-corebluetooth') + if platform.system() == "Darwin": + requiredPackages.append("pyobjc-framework-corebluetooth") - if platform.system() == 'Linux': - requiredPackages.append('dbus-python') - requiredPackages.append('pygobject') + if platform.system() == "Linux": + requiredPackages.append("dbus-python") + requiredPackages.append("pygobject") # # Build the chip package... # - packages=[ - 'chip', - 'chip.ble', - 'chip.ble.commissioning', - 'chip.configuration', - 'chip.clusters', - 'chip.discovery', - 'chip.exceptions', - 'chip.internal', - 'chip.interaction_model', - 'chip.logging', - 'chip.native', - 'chip.clusters', - 'chip.tlv', - 'chip.setup_payload', + packages = [ + "chip", + "chip.ble", + "chip.ble.commissioning", + "chip.configuration", + "chip.clusters", + "chip.discovery", + "chip.exceptions", + "chip.internal", + "chip.interaction_model", + "chip.logging", + "chip.native", + "chip.server", + "chip.clusters", + "chip.tlv", + "chip.setup_payload", ] # Invoke the setuptools 'bdist_wheel' command to generate a wheel containing @@ -146,50 +155,50 @@ def finalize_options(self): setup( name=packageName, version=chipPackageVer, - description='Python-base APIs and tools for CHIP.', - url='https://github.com/project-chip/connectedhomeip', - license='Apache', + description="Python-base APIs and tools for CHIP.", + url="https://github.com/project-chip/connectedhomeip", + license="Apache", classifiers=[ - 'Intended Audience :: Developers', - 'License :: OSI Approved :: Apache Software License', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3', + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 2", + "Programming Language :: Python :: 2.7", + "Programming Language :: Python :: 3", ], - python_requires='>=2.7', + python_requires=">=2.7", packages=packages, package_dir={ - '':tmpDir, # By default, look in the tmp directory for packages/modules to be included. + "": tmpDir, # By default, look in the tmp directory for packages/modules to be included. }, package_data={ - packageName:[ - chipDLLName # Include the wrapper DLL as package data in the "chip" package. + packageName: [ + chipDLLName # Include the wrapper DLL as package data in the "chip" package. ] }, - scripts = [name for name in map( - lambda script: os.path.join(tmpDir, script.installName), - installScripts - )], + scripts=[ + name + for name in map( + lambda script: os.path.join(tmpDir, script.installName), installScripts + ) + ], install_requires=requiredPackages, options={ - 'bdist_wheel':{ - 'universal':False, - 'dist_dir':distDir, # Place the generated .whl in the dist directory. - 'py_limited_api':'cp37', - 'plat_name':args.plat_name, + "bdist_wheel": { + "universal": False, + "dist_dir": distDir, # Place the generated .whl in the dist directory. + "py_limited_api": "cp37", + "plat_name": args.plat_name, + }, + "egg_info": { + "egg_base": tmpDir # Place the .egg-info subdirectory in the tmp directory. }, - 'egg_info':{ - 'egg_base':tmpDir # Place the .egg-info subdirectory in the tmp directory. - } - }, - cmdclass={ - 'bdist_wheel':bdist_wheel_override }, - script_args=[ 'clean', '--all', 'bdist_wheel' ] + cmdclass={"bdist_wheel": bdist_wheel_override}, + script_args=["clean", "--all", "bdist_wheel"], ) finally: - + # Switch back to the initial current directory. os.chdir(curDir) diff --git a/src/controller/python/chip/server/ServerInit.cpp b/src/controller/python/chip/server/ServerInit.cpp new file mode 100644 index 00000000000000..d560605ad197fd --- /dev/null +++ b/src/controller/python/chip/server/ServerInit.cpp @@ -0,0 +1,179 @@ +/* + * + * 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 "Options.h" + +using namespace chip; +using namespace chip::Inet; +using namespace chip::Transport; +using namespace chip::DeviceLayer; + +namespace { + +void EventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg) +{ + (void) arg; + if (event->Type == chip::DeviceLayer::DeviceEventType::kCHIPoBLEConnectionEstablished) + { + ChipLogProgress(DeviceLayer, "Receive kCHIPoBLEConnectionEstablished"); + } +} + +pthread_t sPlatformMainThread; + +// #if CHIP_DEVICE_LAYER_TARGET_LINUX && CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE +// uint32_t sBluetoothAdapterId = 0; +// #endif + +void * PlatformMainLoop(void *) +{ + ChipLogProgress(DeviceLayer, "Platform main loop started."); + chip::DeviceLayer::PlatformMgr().RunEventLoop(); + ChipLogProgress(DeviceLayer, "Platform main loop completed."); + return nullptr; +} + +} // namespace + +extern "C" { + +// CHIP_ERROR pychip_BLEMgrImpl_ConfigureBle(uint32_t bluetoothAdapterId) +// { +// #if CHIP_DEVICE_LAYER_TARGET_LINUX && CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE +// // By default, Linux device is configured as a BLE peripheral while the controller needs a BLE central. +// sBluetoothAdapterId = bluetoothAdapterId; +// ReturnErrorOnFailure( +// chip::DeviceLayer::Internal::BLEMgrImpl().ConfigureBle(/* BLE adapter ID */ bluetoothAdapterId, /* BLE central */ true)); +// #endif +// return CHIP_NO_ERROR; +// } + + +using PostAttributeChangeCallback = void (*)(uint16_t endpoint, uint16_t clusterId, uint16_t attributeId, uint8_t mask, uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value); + +class PythonServerDelegate// : public ServerDelegate +{ +public: + void SetPostAttributeChangeCallback(PostAttributeChangeCallback cb) { + //ChipLogProgress(NotSpecified, "callback %p", cb); + mPostAttributeChangeCallback = cb; + }; + PostAttributeChangeCallback mPostAttributeChangeCallback = nullptr; +}; + +PythonServerDelegate gPythonServerDelegate; + +void pychip_server_set_callbacks(PostAttributeChangeCallback cb) +{ + //ChipLogProgress(NotSpecified, "setting cb"); + gPythonServerDelegate.SetPostAttributeChangeCallback(cb); +} + +void pychip_server_native_init() +{ + CHIP_ERROR err = CHIP_NO_ERROR; + int result; + int tmpErrno; + + err = chip::Platform::MemoryInit(); + SuccessOrExit(err); + + err = chip::DeviceLayer::PlatformMgr().InitChipStack(); + SuccessOrExit(err); + + ConfigurationMgr().LogDeviceConfig(); + PrintOnboardingCodes(chip::RendezvousInformationFlag::kOnNetwork); + +#if defined(PW_RPC_ENABLED) + chip::rpc::Init(); + ChipLogProgress(NotSpecified, "PW_RPC initialized."); +#endif // defined(PW_RPC_ENABLED) + + chip::DeviceLayer::PlatformMgrImpl().AddEventHandler(EventHandler, 0); + + chip::DeviceLayer::ConnectivityMgr().SetBLEDeviceName(nullptr); // Use default device name (CHIP-XXXX) + +// #if CONFIG_NETWORK_LAYER_BLE +// chip::DeviceLayer::Internal::BLEMgrImpl().ConfigureBle(LinuxDeviceOptions::GetInstance().mBleDevice, false); +// #endif + + chip::DeviceLayer::ConnectivityMgr().SetBLEAdvertisingEnabled(false); +// chip::DeviceLayer::ConnectivityMgr().SetBLEAdvertisingEnabled(true); + +// #if CHIP_DEVICE_CONFIG_ENABLE_WPA +// if (LinuxDeviceOptions::GetInstance().mWiFi) +// { +// chip::DeviceLayer::ConnectivityMgrImpl().StartWiFiManagement(); +// } +// #endif // CHIP_DEVICE_CONFIG_ENABLE_WPA + +// #if CHIP_ENABLE_OPENTHREAD +// if (LinuxDeviceOptions::GetInstance().mThread) +// { +// SuccessOrExit(err = chip::DeviceLayer::ThreadStackMgrImpl().InitThreadStack()); +// ChipLogProgress(NotSpecified, "Thread initialized."); +// } +// #endif // CHIP_ENABLE_OPENTHREAD + + InitServer(); + + result = pthread_create(&sPlatformMainThread, nullptr, PlatformMainLoop, nullptr); + tmpErrno = errno; + + if (result != 0) + { + ChipLogError(DeviceLayer, "Failed to initialize CHIP stack: pthread_create failed: %s", strerror(tmpErrno)); + } + +exit: + if (err != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "Failed to initialize CHIP stack"); + } + return /*err*/; +} + +} + +void emberAfPostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId, + uint8_t mask, uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value) +{ + //ChipLogProgress(NotSpecified, "emberAfPostAttributeChangeCallback()"); + if (gPythonServerDelegate.mPostAttributeChangeCallback != nullptr ) { + //ChipLogProgress(NotSpecified, "callback %p", gPythonServerDelegate.mPostAttributeChangeCallback); + gPythonServerDelegate.mPostAttributeChangeCallback(endpoint, clusterId, attributeId, mask, manufacturerCode, type, size, value); + } else { + //ChipLogProgress(NotSpecified, "callback nullptr"); + } +}; diff --git a/src/controller/python/chip/server/__init__.py b/src/controller/python/chip/server/__init__.py new file mode 100644 index 00000000000000..27cc6796bdb214 --- /dev/null +++ b/src/controller/python/chip/server/__init__.py @@ -0,0 +1,90 @@ +import ctypes +import glob +import os +import platform + +from chip.server.types import PostAttributeChangeCallback + +# NATIVE_LIBRARY_BASE_NAME = "_ChipServer.so" +NATIVE_LIBRARY_BASE_NAME = "_ChipDeviceCtrl.so" + + +def _AllDirsToRoot(dir): + """Return all parent paths of a directory.""" + dir = os.path.abspath(dir) + while True: + yield dir + parent = os.path.dirname(dir) + if parent == "" or parent == dir: + break + dir = parent + + +def FindNativeLibraryPath() -> str: + """Find the native CHIP dll/so path.""" + + scriptDir = os.path.dirname(os.path.abspath(__file__)) + + # When properly installed in the chip package, the Chip Device Manager DLL will + # be located in the package root directory, along side the package's + # modules. + dmDLLPath = os.path.join( + os.path.dirname(scriptDir), # file should be inside 'chip' + NATIVE_LIBRARY_BASE_NAME, + ) + if os.path.exists(dmDLLPath): + return dmDLLPath + + # For the convenience of developers, search the list of parent paths relative to the + # running script looking for an CHIP build directory containing the Chip Device + # Manager DLL. This makes it possible to import and use the ChipDeviceMgr module + # directly from a built copy of the CHIP source tree. + buildMachineGlob = "%s-*-%s*" % (platform.machine(), platform.system().lower()) + relDMDLLPathGlob = os.path.join( + "build", + buildMachineGlob, + "src/controller/python/.libs", + NATIVE_LIBRARY_BASE_NAME, + ) + for dir in _AllDirsToRoot(scriptDir): + dmDLLPathGlob = os.path.join(dir, relDMDLLPathGlob) + for dmDLLPath in glob.glob(dmDLLPathGlob): + if os.path.exists(dmDLLPath): + return dmDLLPath + + raise Exception( + "Unable to locate Chip Device Manager DLL (%s); expected location: %s" + % (NATIVE_LIBRARY_BASE_NAME, scriptDir) + ) + + +class NativeLibraryHandleMethodArguments: + """Convenience wrapper to set native method argtype and restype for methods.""" + + def __init__(self, handle): + self.handle = handle + + def Set(self, methodName: str, resultType, argumentTypes: list): + method = getattr(self.handle, methodName) + method.restype = resultType + method.argtype = argumentTypes + + +_nativeLibraryHandle: ctypes.CDLL = None + + +def GetLibraryHandle(cb: PostAttributeChangeCallback) -> ctypes.CDLL: + """Get a memoized handle to the chip native code dll.""" + + global _nativeLibraryHandle + if _nativeLibraryHandle is None: + _nativeLibraryHandle = ctypes.CDLL(FindNativeLibraryPath()) + + setter = NativeLibraryHandleMethodArguments(_nativeLibraryHandle) + setter.Set("pychip_server_native_init", None, []) + setter.Set("pychip_server_set_callbacks", None, [PostAttributeChangeCallback]) + + _nativeLibraryHandle.pychip_server_native_init() + _nativeLibraryHandle.pychip_server_set_callbacks(cb) + + return _nativeLibraryHandle diff --git a/src/controller/python/chip/server/types.py b/src/controller/python/chip/server/types.py new file mode 100644 index 00000000000000..9aaeb60e10c8ea --- /dev/null +++ b/src/controller/python/chip/server/types.py @@ -0,0 +1,14 @@ +from ctypes import CFUNCTYPE, py_object, c_char_p, c_uint8, c_uint16 + +PostAttributeChangeCallback = CFUNCTYPE( + None, + # py_object, + c_uint16, + c_uint16, + c_uint16, + c_uint8, + c_uint16, + c_uint8, + c_uint16, + c_char_p, +) From cc08d63e8731b7f24ec4e5df1d40cf94a81c1fc5 Mon Sep 17 00:00:00 2001 From: Markus Becker Date: Thu, 22 Jul 2021 11:18:46 +0200 Subject: [PATCH 2/4] modified zap generated files --- .../chip-tool/commands/clusters/Commands.h | 523 +-- .../chip-tool/commands/reporting/Commands.h | 10 + examples/chip-tool/commands/tests/Commands.h | 1559 +------ .../data_model/gen/CHIPClusters.cpp | 348 -- src/controller/data_model/gen/CHIPClusters.h | 56 +- .../gen/IMClusterCommandHandler.cpp | 3916 ++++++++++++++--- .../data_model/gen/attribute-size.cpp | 44 + .../data_model/gen/chip-zcl-zpro-codec-api.h | 4 + src/controller/data_model/gen/encoder.cpp | 125 +- .../data_model/gen/endpoint_config.h | 484 +- src/controller/data_model/gen/gen_config.h | 54 + src/controller/java/gen/CHIPClusters-JNI.cpp | 540 --- src/controller/java/gen/ChipClusters.java | 183 - .../python/chip/clusters/CHIPClusters.cpp | 144 - .../python/chip/clusters/CHIPClusters.py | 143 - .../Framework/CHIP/gen/CHIPClustersObjc.h | 39 - .../Framework/CHIP/gen/CHIPClustersObjc.mm | 377 -- .../Framework/CHIPTests/CHIPClustersTests.m | 152 - 18 files changed, 4021 insertions(+), 4680 deletions(-) diff --git a/examples/chip-tool/commands/clusters/Commands.h b/examples/chip-tool/commands/clusters/Commands.h index ca3f02a137f784..641bb82faba4b2 100644 --- a/examples/chip-tool/commands/clusters/Commands.h +++ b/examples/chip-tool/commands/clusters/Commands.h @@ -1095,6 +1095,7 @@ static void OnThreadNetworkDiagnosticsActiveNetworkFaultsListListAttributeRespon | AudioOutput | 0x050B | | BarrierControl | 0x0103 | | Basic | 0x0028 | +| Basic | 0x0028 | | BinaryInputBasic | 0x000F | | Binding | 0xF000 | | BridgedDeviceBasic | 0x0039 | @@ -1108,24 +1109,31 @@ static void OnThreadNetworkDiagnosticsActiveNetworkFaultsListListAttributeRespon | FixedLabel | 0x0040 | | FlowMeasurement | 0x0404 | | GeneralCommissioning | 0x0030 | +| GeneralCommissioning | 0x0030 | | GeneralDiagnostics | 0x0033 | | GroupKeyManagement | 0xF004 | | Groups | 0x0004 | +| Groups | 0x0004 | | Identify | 0x0003 | | KeypadInput | 0x0509 | | LevelControl | 0x0008 | +| LevelControl | 0x0008 | | LowPower | 0x0508 | | MediaInput | 0x0507 | | MediaPlayback | 0x0506 | | NetworkCommissioning | 0x0031 | +| NetworkCommissioning | 0x0031 | | OtaSoftwareUpdateProvider | 0x0029 | | OccupancySensing | 0x0406 | | OnOff | 0x0006 | +| OnOff | 0x0006 | +| OperationalCredentials | 0x003E | | OperationalCredentials | 0x003E | | PressureMeasurement | 0x0403 | | PumpConfigurationAndControl | 0x0200 | | RelativeHumidityMeasurement | 0x0405 | | Scenes | 0x0005 | +| Scenes | 0x0005 | | SoftwareDiagnostics | 0x0034 | | Switch | 0x003B | | TvChannel | 0x0504 | @@ -4332,11 +4340,6 @@ class ReadBridgedDeviceBasicClusterRevision : public ModelCommand | Cluster ColorControl | 0x0300 | |------------------------------------------------------------------------------| | Commands: | | -| * ColorLoopSet | 0x44 | -| * EnhancedMoveHue | 0x41 | -| * EnhancedMoveToHue | 0x40 | -| * EnhancedMoveToHueAndSaturation | 0x43 | -| * EnhancedStepHue | 0x42 | | * MoveColor | 0x08 | | * MoveColorTemperature | 0x4B | | * MoveHue | 0x01 | @@ -4393,236 +4396,11 @@ class ReadBridgedDeviceBasicClusterRevision : public ModelCommand | * ColorPointBX | 0x003A | | * ColorPointBY | 0x003B | | * ColorPointBIntensity | 0x003C | -| * EnhancedCurrentHue | 0x4000 | -| * EnhancedColorMode | 0x4001 | -| * ColorLoopActive | 0x4002 | -| * ColorLoopDirection | 0x4003 | -| * ColorLoopTime | 0x4004 | -| * ColorCapabilities | 0x400A | -| * ColorTempPhysicalMin | 0x400B | -| * ColorTempPhysicalMax | 0x400C | | * CoupleColorTempToLevelMinMireds | 0x400D | | * StartUpColorTemperatureMireds | 0x4010 | | * ClusterRevision | 0xFFFD | \*----------------------------------------------------------------------------*/ -/* - * Command ColorLoopSet - */ -class ColorControlColorLoopSet : public ModelCommand -{ -public: - ColorControlColorLoopSet() : ModelCommand("color-loop-set") - { - AddArgument("UpdateFlags", 0, UINT8_MAX, &mUpdateFlags); - AddArgument("Action", 0, UINT8_MAX, &mAction); - AddArgument("Direction", 0, UINT8_MAX, &mDirection); - AddArgument("Time", 0, UINT16_MAX, &mTime); - AddArgument("StartHue", 0, UINT16_MAX, &mStartHue); - AddArgument("OptionsMask", 0, UINT8_MAX, &mOptionsMask); - AddArgument("OptionsOverride", 0, UINT8_MAX, &mOptionsOverride); - ModelCommand::AddArguments(); - } - ~ColorControlColorLoopSet() - { - delete onSuccessCallback; - delete onFailureCallback; - } - - CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override - { - ChipLogProgress(chipTool, "Sending cluster (0x0300) command (0x44) on endpoint %" PRIu8, endpointId); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, endpointId); - return cluster.ColorLoopSet(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mUpdateFlags, mAction, mDirection, - mTime, mStartHue, mOptionsMask, mOptionsOverride); - } - -private: - chip::Callback::Callback * onSuccessCallback = - new chip::Callback::Callback(OnDefaultSuccessResponse, this); - chip::Callback::Callback * onFailureCallback = - new chip::Callback::Callback(OnDefaultFailureResponse, this); - uint8_t mUpdateFlags; - uint8_t mAction; - uint8_t mDirection; - uint16_t mTime; - uint16_t mStartHue; - uint8_t mOptionsMask; - uint8_t mOptionsOverride; -}; - -/* - * Command EnhancedMoveHue - */ -class ColorControlEnhancedMoveHue : public ModelCommand -{ -public: - ColorControlEnhancedMoveHue() : ModelCommand("enhanced-move-hue") - { - AddArgument("MoveMode", 0, UINT8_MAX, &mMoveMode); - AddArgument("Rate", 0, UINT16_MAX, &mRate); - AddArgument("OptionsMask", 0, UINT8_MAX, &mOptionsMask); - AddArgument("OptionsOverride", 0, UINT8_MAX, &mOptionsOverride); - ModelCommand::AddArguments(); - } - ~ColorControlEnhancedMoveHue() - { - delete onSuccessCallback; - delete onFailureCallback; - } - - CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override - { - ChipLogProgress(chipTool, "Sending cluster (0x0300) command (0x41) on endpoint %" PRIu8, endpointId); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, endpointId); - return cluster.EnhancedMoveHue(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mMoveMode, mRate, mOptionsMask, - mOptionsOverride); - } - -private: - chip::Callback::Callback * onSuccessCallback = - new chip::Callback::Callback(OnDefaultSuccessResponse, this); - chip::Callback::Callback * onFailureCallback = - new chip::Callback::Callback(OnDefaultFailureResponse, this); - uint8_t mMoveMode; - uint16_t mRate; - uint8_t mOptionsMask; - uint8_t mOptionsOverride; -}; - -/* - * Command EnhancedMoveToHue - */ -class ColorControlEnhancedMoveToHue : public ModelCommand -{ -public: - ColorControlEnhancedMoveToHue() : ModelCommand("enhanced-move-to-hue") - { - AddArgument("EnhancedHue", 0, UINT16_MAX, &mEnhancedHue); - AddArgument("Direction", 0, UINT8_MAX, &mDirection); - AddArgument("TransitionTime", 0, UINT16_MAX, &mTransitionTime); - AddArgument("OptionsMask", 0, UINT8_MAX, &mOptionsMask); - AddArgument("OptionsOverride", 0, UINT8_MAX, &mOptionsOverride); - ModelCommand::AddArguments(); - } - ~ColorControlEnhancedMoveToHue() - { - delete onSuccessCallback; - delete onFailureCallback; - } - - CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override - { - ChipLogProgress(chipTool, "Sending cluster (0x0300) command (0x40) on endpoint %" PRIu8, endpointId); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, endpointId); - return cluster.EnhancedMoveToHue(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mEnhancedHue, mDirection, - mTransitionTime, mOptionsMask, mOptionsOverride); - } - -private: - chip::Callback::Callback * onSuccessCallback = - new chip::Callback::Callback(OnDefaultSuccessResponse, this); - chip::Callback::Callback * onFailureCallback = - new chip::Callback::Callback(OnDefaultFailureResponse, this); - uint16_t mEnhancedHue; - uint8_t mDirection; - uint16_t mTransitionTime; - uint8_t mOptionsMask; - uint8_t mOptionsOverride; -}; - -/* - * Command EnhancedMoveToHueAndSaturation - */ -class ColorControlEnhancedMoveToHueAndSaturation : public ModelCommand -{ -public: - ColorControlEnhancedMoveToHueAndSaturation() : ModelCommand("enhanced-move-to-hue-and-saturation") - { - AddArgument("EnhancedHue", 0, UINT16_MAX, &mEnhancedHue); - AddArgument("Saturation", 0, UINT8_MAX, &mSaturation); - AddArgument("TransitionTime", 0, UINT16_MAX, &mTransitionTime); - AddArgument("OptionsMask", 0, UINT8_MAX, &mOptionsMask); - AddArgument("OptionsOverride", 0, UINT8_MAX, &mOptionsOverride); - ModelCommand::AddArguments(); - } - ~ColorControlEnhancedMoveToHueAndSaturation() - { - delete onSuccessCallback; - delete onFailureCallback; - } - - CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override - { - ChipLogProgress(chipTool, "Sending cluster (0x0300) command (0x43) on endpoint %" PRIu8, endpointId); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, endpointId); - return cluster.EnhancedMoveToHueAndSaturation(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mEnhancedHue, - mSaturation, mTransitionTime, mOptionsMask, mOptionsOverride); - } - -private: - chip::Callback::Callback * onSuccessCallback = - new chip::Callback::Callback(OnDefaultSuccessResponse, this); - chip::Callback::Callback * onFailureCallback = - new chip::Callback::Callback(OnDefaultFailureResponse, this); - uint16_t mEnhancedHue; - uint8_t mSaturation; - uint16_t mTransitionTime; - uint8_t mOptionsMask; - uint8_t mOptionsOverride; -}; - -/* - * Command EnhancedStepHue - */ -class ColorControlEnhancedStepHue : public ModelCommand -{ -public: - ColorControlEnhancedStepHue() : ModelCommand("enhanced-step-hue") - { - AddArgument("StepMode", 0, UINT8_MAX, &mStepMode); - AddArgument("StepSize", 0, UINT16_MAX, &mStepSize); - AddArgument("TransitionTime", 0, UINT16_MAX, &mTransitionTime); - AddArgument("OptionsMask", 0, UINT8_MAX, &mOptionsMask); - AddArgument("OptionsOverride", 0, UINT8_MAX, &mOptionsOverride); - ModelCommand::AddArguments(); - } - ~ColorControlEnhancedStepHue() - { - delete onSuccessCallback; - delete onFailureCallback; - } - - CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override - { - ChipLogProgress(chipTool, "Sending cluster (0x0300) command (0x42) on endpoint %" PRIu8, endpointId); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, endpointId); - return cluster.EnhancedStepHue(onSuccessCallback->Cancel(), onFailureCallback->Cancel(), mStepMode, mStepSize, - mTransitionTime, mOptionsMask, mOptionsOverride); - } - -private: - chip::Callback::Callback * onSuccessCallback = - new chip::Callback::Callback(OnDefaultSuccessResponse, this); - chip::Callback::Callback * onFailureCallback = - new chip::Callback::Callback(OnDefaultFailureResponse, this); - uint8_t mStepMode; - uint16_t mStepSize; - uint16_t mTransitionTime; - uint8_t mOptionsMask; - uint8_t mOptionsOverride; -}; - /* * Command MoveColor */ @@ -7241,278 +7019,6 @@ class WriteColorControlColorPointBIntensity : public ModelCommand uint8_t mValue; }; -/* - * Attribute EnhancedCurrentHue - */ -class ReadColorControlEnhancedCurrentHue : public ModelCommand -{ -public: - ReadColorControlEnhancedCurrentHue() : ModelCommand("read") - { - AddArgument("attr-name", "enhanced-current-hue"); - ModelCommand::AddArguments(); - } - - ~ReadColorControlEnhancedCurrentHue() - { - delete onSuccessCallback; - delete onFailureCallback; - } - - CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override - { - ChipLogProgress(chipTool, "Sending cluster (0x0300) command (0x00) on endpoint %" PRIu8, endpointId); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, endpointId); - return cluster.ReadAttributeEnhancedCurrentHue(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 EnhancedColorMode - */ -class ReadColorControlEnhancedColorMode : public ModelCommand -{ -public: - ReadColorControlEnhancedColorMode() : ModelCommand("read") - { - AddArgument("attr-name", "enhanced-color-mode"); - ModelCommand::AddArguments(); - } - - ~ReadColorControlEnhancedColorMode() - { - delete onSuccessCallback; - delete onFailureCallback; - } - - CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override - { - ChipLogProgress(chipTool, "Sending cluster (0x0300) command (0x00) on endpoint %" PRIu8, endpointId); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, endpointId); - return cluster.ReadAttributeEnhancedColorMode(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); - } - -private: - chip::Callback::Callback * onSuccessCallback = - new chip::Callback::Callback(OnInt8uAttributeResponse, this); - chip::Callback::Callback * onFailureCallback = - new chip::Callback::Callback(OnDefaultFailureResponse, this); -}; - -/* - * Attribute ColorLoopActive - */ -class ReadColorControlColorLoopActive : public ModelCommand -{ -public: - ReadColorControlColorLoopActive() : ModelCommand("read") - { - AddArgument("attr-name", "color-loop-active"); - ModelCommand::AddArguments(); - } - - ~ReadColorControlColorLoopActive() - { - delete onSuccessCallback; - delete onFailureCallback; - } - - CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override - { - ChipLogProgress(chipTool, "Sending cluster (0x0300) command (0x00) on endpoint %" PRIu8, endpointId); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, endpointId); - return cluster.ReadAttributeColorLoopActive(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); - } - -private: - chip::Callback::Callback * onSuccessCallback = - new chip::Callback::Callback(OnInt8uAttributeResponse, this); - chip::Callback::Callback * onFailureCallback = - new chip::Callback::Callback(OnDefaultFailureResponse, this); -}; - -/* - * Attribute ColorLoopDirection - */ -class ReadColorControlColorLoopDirection : public ModelCommand -{ -public: - ReadColorControlColorLoopDirection() : ModelCommand("read") - { - AddArgument("attr-name", "color-loop-direction"); - ModelCommand::AddArguments(); - } - - ~ReadColorControlColorLoopDirection() - { - delete onSuccessCallback; - delete onFailureCallback; - } - - CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override - { - ChipLogProgress(chipTool, "Sending cluster (0x0300) command (0x00) on endpoint %" PRIu8, endpointId); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, endpointId); - return cluster.ReadAttributeColorLoopDirection(onSuccessCallback->Cancel(), onFailureCallback->Cancel()); - } - -private: - chip::Callback::Callback * onSuccessCallback = - new chip::Callback::Callback(OnInt8uAttributeResponse, this); - chip::Callback::Callback * onFailureCallback = - new chip::Callback::Callback(OnDefaultFailureResponse, this); -}; - -/* - * Attribute ColorLoopTime - */ -class ReadColorControlColorLoopTime : public ModelCommand -{ -public: - ReadColorControlColorLoopTime() : ModelCommand("read") - { - AddArgument("attr-name", "color-loop-time"); - ModelCommand::AddArguments(); - } - - ~ReadColorControlColorLoopTime() - { - delete onSuccessCallback; - delete onFailureCallback; - } - - CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override - { - ChipLogProgress(chipTool, "Sending cluster (0x0300) command (0x00) on endpoint %" PRIu8, endpointId); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, endpointId); - return cluster.ReadAttributeColorLoopTime(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 ColorCapabilities - */ -class ReadColorControlColorCapabilities : public ModelCommand -{ -public: - ReadColorControlColorCapabilities() : ModelCommand("read") - { - AddArgument("attr-name", "color-capabilities"); - ModelCommand::AddArguments(); - } - - ~ReadColorControlColorCapabilities() - { - delete onSuccessCallback; - delete onFailureCallback; - } - - CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override - { - ChipLogProgress(chipTool, "Sending cluster (0x0300) command (0x00) on endpoint %" PRIu8, endpointId); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, endpointId); - return cluster.ReadAttributeColorCapabilities(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 ColorTempPhysicalMin - */ -class ReadColorControlColorTempPhysicalMin : public ModelCommand -{ -public: - ReadColorControlColorTempPhysicalMin() : ModelCommand("read") - { - AddArgument("attr-name", "color-temp-physical-min"); - ModelCommand::AddArguments(); - } - - ~ReadColorControlColorTempPhysicalMin() - { - delete onSuccessCallback; - delete onFailureCallback; - } - - CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override - { - ChipLogProgress(chipTool, "Sending cluster (0x0300) command (0x00) on endpoint %" PRIu8, endpointId); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, endpointId); - return cluster.ReadAttributeColorTempPhysicalMin(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 ColorTempPhysicalMax - */ -class ReadColorControlColorTempPhysicalMax : public ModelCommand -{ -public: - ReadColorControlColorTempPhysicalMax() : ModelCommand("read") - { - AddArgument("attr-name", "color-temp-physical-max"); - ModelCommand::AddArguments(); - } - - ~ReadColorControlColorTempPhysicalMax() - { - delete onSuccessCallback; - delete onFailureCallback; - } - - CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override - { - ChipLogProgress(chipTool, "Sending cluster (0x0300) command (0x00) on endpoint %" PRIu8, endpointId); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, endpointId); - return cluster.ReadAttributeColorTempPhysicalMax(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 CoupleColorTempToLevelMinMireds */ @@ -23344,11 +22850,6 @@ void registerClusterColorControl(Commands & commands) const char * clusterName = "ColorControl"; commands_list clusterCommands = { - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), make_unique(), make_unique(), make_unique(), @@ -23421,14 +22922,6 @@ void registerClusterColorControl(Commands & commands) 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(), diff --git a/examples/chip-tool/commands/reporting/Commands.h b/examples/chip-tool/commands/reporting/Commands.h index cc289ceea00863..be69d0a6e5c2c3 100644 --- a/examples/chip-tool/commands/reporting/Commands.h +++ b/examples/chip-tool/commands/reporting/Commands.h @@ -39,8 +39,10 @@ class Listen : public ReportingCommand delete onReportColorControlColorTemperatureCallback; delete onReportDoorLockLockStateCallback; delete onReportLevelControlCurrentLevelCallback; + delete onReportLevelControlCurrentLevelCallback; delete onReportOccupancySensingOccupancyCallback; delete onReportOnOffOnOffCallback; + delete onReportOnOffOnOffCallback; delete onReportPressureMeasurementMeasuredValueCallback; delete onReportPumpConfigurationAndControlCapacityCallback; delete onReportRelativeHumidityMeasurementMeasuredValueCallback; @@ -78,10 +80,14 @@ class Listen : public ReportingCommand onReportDoorLockLockStateCallback->Cancel()); callbacksMgr.AddReportCallback(GetExecContext()->storage->GetRemoteNodeId(), endpointId, 0x0008, 0x0000, onReportLevelControlCurrentLevelCallback->Cancel()); + callbacksMgr.AddReportCallback(GetExecContext()->storage->GetRemoteNodeId(), endpointId, 0x0008, 0x0000, + onReportLevelControlCurrentLevelCallback->Cancel()); callbacksMgr.AddReportCallback(GetExecContext()->storage->GetRemoteNodeId(), endpointId, 0x0406, 0x0000, onReportOccupancySensingOccupancyCallback->Cancel()); callbacksMgr.AddReportCallback(GetExecContext()->storage->GetRemoteNodeId(), endpointId, 0x0006, 0x0000, onReportOnOffOnOffCallback->Cancel()); + callbacksMgr.AddReportCallback(GetExecContext()->storage->GetRemoteNodeId(), endpointId, 0x0006, 0x0000, + onReportOnOffOnOffCallback->Cancel()); callbacksMgr.AddReportCallback(GetExecContext()->storage->GetRemoteNodeId(), endpointId, 0x0403, 0x0000, onReportPressureMeasurementMeasuredValueCallback->Cancel()); callbacksMgr.AddReportCallback(GetExecContext()->storage->GetRemoteNodeId(), endpointId, 0x0200, 0x0013, @@ -163,8 +169,12 @@ class Listen : public ReportingCommand new chip::Callback::Callback(OnInt8uAttributeResponse, this); chip::Callback::Callback * onReportLevelControlCurrentLevelCallback = new chip::Callback::Callback(OnInt8uAttributeResponse, this); +// chip::Callback::Callback * onReportLevelControlCurrentLevelCallback = +// new chip::Callback::Callback(OnInt8uAttributeResponse, this); chip::Callback::Callback * onReportOccupancySensingOccupancyCallback = new chip::Callback::Callback(OnInt8uAttributeResponse, this); +// chip::Callback::Callback * onReportOnOffOnOffCallback = +// new chip::Callback::Callback(OnBooleanAttributeResponse, this); chip::Callback::Callback * onReportOnOffOnOffCallback = new chip::Callback::Callback(OnBooleanAttributeResponse, this); chip::Callback::Callback * onReportPressureMeasurementMeasuredValueCallback = diff --git a/examples/chip-tool/commands/tests/Commands.h b/examples/chip-tool/commands/tests/Commands.h index ff5d133decf6db..f924f8f1aed63f 100644 --- a/examples/chip-tool/commands/tests/Commands.h +++ b/examples/chip-tool/commands/tests/Commands.h @@ -15771,23 +15771,20 @@ class Test_TC_CC_5 : public TestCommand err = TestSendClusterColorControlCommandReadAttribute_7(); break; case 8: - err = TestSendClusterColorControlCommandStopMoveStep_8(); + err = TestSendClusterColorControlCommandReadAttribute_8(); break; case 9: err = TestSendClusterColorControlCommandReadAttribute_9(); break; case 10: - err = TestSendClusterColorControlCommandReadAttribute_10(); + err = TestSendClusterColorControlCommandStepColor_10(); break; case 11: - err = TestSendClusterColorControlCommandStepColor_11(); + err = TestSendClusterColorControlCommandReadAttribute_11(); break; case 12: err = TestSendClusterColorControlCommandReadAttribute_12(); break; - case 13: - err = TestSendClusterColorControlCommandReadAttribute_13(); - break; } if (CHIP_NO_ERROR != err) @@ -15799,7 +15796,7 @@ class Test_TC_CC_5 : public TestCommand private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; + const uint16_t mTestCount = 13; // // Tests methods @@ -16291,76 +16288,17 @@ class Test_TC_CC_5 : public TestCommand runner->NextTest(); } - // Test Stop Move Step command - using SuccessCallback_8 = void (*)(void * context); + // Test Check current x attribute value matched the value sent by the last command + using SuccessCallback_8 = void (*)(void * context, uint16_t currentX); chip::Callback::Callback mOnSuccessCallback_8{ - OnTestSendClusterColorControlCommandStopMoveStep_8_SuccessResponse, this + OnTestSendClusterColorControlCommandReadAttribute_8_SuccessResponse, this }; chip::Callback::Callback mOnFailureCallback_8{ - OnTestSendClusterColorControlCommandStopMoveStep_8_FailureResponse, this + OnTestSendClusterColorControlCommandReadAttribute_8_FailureResponse, this }; bool mIsFailureExpected_8 = 0; - CHIP_ERROR TestSendClusterColorControlCommandStopMoveStep_8() - { - ChipLogProgress(chipTool, "Color Control - Stop Move Step command: Sending command..."); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(mDevice, 1); - - CHIP_ERROR err = CHIP_NO_ERROR; - - uint8_t optionsMaskArgument = 0; - uint8_t optionsOverrideArgument = 0; - err = cluster.StopMoveStep(mOnSuccessCallback_8.Cancel(), mOnFailureCallback_8.Cancel(), optionsMaskArgument, - optionsOverrideArgument); - - return err; - } - - static void OnTestSendClusterColorControlCommandStopMoveStep_8_FailureResponse(void * context, uint8_t status) - { - ChipLogProgress(chipTool, "Color Control - Stop Move Step command: Failure Response"); - - Test_TC_CC_5 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_8 == false) - { - ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - static void OnTestSendClusterColorControlCommandStopMoveStep_8_SuccessResponse(void * context) - { - ChipLogProgress(chipTool, "Color Control - Stop Move Step command: Success Response"); - - Test_TC_CC_5 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_8 == true) - { - ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - // Test Check current x attribute value matched the value sent by the last command - using SuccessCallback_9 = void (*)(void * context, uint16_t currentX); - chip::Callback::Callback mOnSuccessCallback_9{ - OnTestSendClusterColorControlCommandReadAttribute_9_SuccessResponse, this - }; - chip::Callback::Callback mOnFailureCallback_9{ - OnTestSendClusterColorControlCommandReadAttribute_9_FailureResponse, this - }; - bool mIsFailureExpected_9 = 0; - - CHIP_ERROR TestSendClusterColorControlCommandReadAttribute_9() + CHIP_ERROR TestSendClusterColorControlCommandReadAttribute_8() { ChipLogProgress( chipTool, @@ -16371,12 +16309,12 @@ class Test_TC_CC_5 : public TestCommand CHIP_ERROR err = CHIP_NO_ERROR; - err = cluster.ReadAttributeCurrentX(mOnSuccessCallback_9.Cancel(), mOnFailureCallback_9.Cancel()); + err = cluster.ReadAttributeCurrentX(mOnSuccessCallback_8.Cancel(), mOnFailureCallback_8.Cancel()); return err; } - static void OnTestSendClusterColorControlCommandReadAttribute_9_FailureResponse(void * context, uint8_t status) + static void OnTestSendClusterColorControlCommandReadAttribute_8_FailureResponse(void * context, uint8_t status) { ChipLogProgress( chipTool, @@ -16384,7 +16322,7 @@ class Test_TC_CC_5 : public TestCommand Test_TC_CC_5 * runner = reinterpret_cast(context); - if (runner->mIsFailureExpected_9 == false) + if (runner->mIsFailureExpected_8 == false) { ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); @@ -16394,7 +16332,7 @@ class Test_TC_CC_5 : public TestCommand runner->NextTest(); } - static void OnTestSendClusterColorControlCommandReadAttribute_9_SuccessResponse(void * context, uint16_t currentX) + static void OnTestSendClusterColorControlCommandReadAttribute_8_SuccessResponse(void * context, uint16_t currentX) { ChipLogProgress( chipTool, @@ -16402,7 +16340,7 @@ class Test_TC_CC_5 : public TestCommand Test_TC_CC_5 * runner = reinterpret_cast(context); - if (runner->mIsFailureExpected_9 == true) + if (runner->mIsFailureExpected_8 == true) { ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); @@ -16413,16 +16351,16 @@ class Test_TC_CC_5 : public TestCommand } // Test Check current y attribute value matched the value sent by the last command - using SuccessCallback_10 = void (*)(void * context, uint16_t currentY); - chip::Callback::Callback mOnSuccessCallback_10{ - OnTestSendClusterColorControlCommandReadAttribute_10_SuccessResponse, this + using SuccessCallback_9 = void (*)(void * context, uint16_t currentY); + chip::Callback::Callback mOnSuccessCallback_9{ + OnTestSendClusterColorControlCommandReadAttribute_9_SuccessResponse, this }; - chip::Callback::Callback mOnFailureCallback_10{ - OnTestSendClusterColorControlCommandReadAttribute_10_FailureResponse, this + chip::Callback::Callback mOnFailureCallback_9{ + OnTestSendClusterColorControlCommandReadAttribute_9_FailureResponse, this }; - bool mIsFailureExpected_10 = 0; + bool mIsFailureExpected_9 = 0; - CHIP_ERROR TestSendClusterColorControlCommandReadAttribute_10() + CHIP_ERROR TestSendClusterColorControlCommandReadAttribute_9() { ChipLogProgress( chipTool, @@ -16433,12 +16371,12 @@ class Test_TC_CC_5 : public TestCommand CHIP_ERROR err = CHIP_NO_ERROR; - err = cluster.ReadAttributeCurrentY(mOnSuccessCallback_10.Cancel(), mOnFailureCallback_10.Cancel()); + err = cluster.ReadAttributeCurrentY(mOnSuccessCallback_9.Cancel(), mOnFailureCallback_9.Cancel()); return err; } - static void OnTestSendClusterColorControlCommandReadAttribute_10_FailureResponse(void * context, uint8_t status) + static void OnTestSendClusterColorControlCommandReadAttribute_9_FailureResponse(void * context, uint8_t status) { ChipLogProgress( chipTool, @@ -16446,7 +16384,7 @@ class Test_TC_CC_5 : public TestCommand Test_TC_CC_5 * runner = reinterpret_cast(context); - if (runner->mIsFailureExpected_10 == false) + if (runner->mIsFailureExpected_9 == false) { ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); @@ -16456,7 +16394,7 @@ class Test_TC_CC_5 : public TestCommand runner->NextTest(); } - static void OnTestSendClusterColorControlCommandReadAttribute_10_SuccessResponse(void * context, uint16_t currentY) + static void OnTestSendClusterColorControlCommandReadAttribute_9_SuccessResponse(void * context, uint16_t currentY) { ChipLogProgress( chipTool, @@ -16464,7 +16402,7 @@ class Test_TC_CC_5 : public TestCommand Test_TC_CC_5 * runner = reinterpret_cast(context); - if (runner->mIsFailureExpected_10 == true) + if (runner->mIsFailureExpected_9 == true) { ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); @@ -16475,16 +16413,16 @@ class Test_TC_CC_5 : public TestCommand } // Test Step Color command - using SuccessCallback_11 = void (*)(void * context); - chip::Callback::Callback mOnSuccessCallback_11{ - OnTestSendClusterColorControlCommandStepColor_11_SuccessResponse, this + using SuccessCallback_10 = void (*)(void * context); + chip::Callback::Callback mOnSuccessCallback_10{ + OnTestSendClusterColorControlCommandStepColor_10_SuccessResponse, this }; - chip::Callback::Callback mOnFailureCallback_11{ - OnTestSendClusterColorControlCommandStepColor_11_FailureResponse, this + chip::Callback::Callback mOnFailureCallback_10{ + OnTestSendClusterColorControlCommandStepColor_10_FailureResponse, this }; - bool mIsFailureExpected_11 = 0; + bool mIsFailureExpected_10 = 0; - CHIP_ERROR TestSendClusterColorControlCommandStepColor_11() + CHIP_ERROR TestSendClusterColorControlCommandStepColor_10() { ChipLogProgress(chipTool, "Color Control - Step Color command: Sending command..."); @@ -16498,19 +16436,19 @@ class Test_TC_CC_5 : public TestCommand uint16_t transitionTimeArgument = 50U; uint8_t optionsMaskArgument = 0; uint8_t optionsOverrideArgument = 0; - err = cluster.StepColor(mOnSuccessCallback_11.Cancel(), mOnFailureCallback_11.Cancel(), stepXArgument, stepYArgument, + err = cluster.StepColor(mOnSuccessCallback_10.Cancel(), mOnFailureCallback_10.Cancel(), stepXArgument, stepYArgument, transitionTimeArgument, optionsMaskArgument, optionsOverrideArgument); return err; } - static void OnTestSendClusterColorControlCommandStepColor_11_FailureResponse(void * context, uint8_t status) + static void OnTestSendClusterColorControlCommandStepColor_10_FailureResponse(void * context, uint8_t status) { ChipLogProgress(chipTool, "Color Control - Step Color command: Failure Response"); Test_TC_CC_5 * runner = reinterpret_cast(context); - if (runner->mIsFailureExpected_11 == false) + if (runner->mIsFailureExpected_10 == false) { ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); @@ -16520,13 +16458,13 @@ class Test_TC_CC_5 : public TestCommand runner->NextTest(); } - static void OnTestSendClusterColorControlCommandStepColor_11_SuccessResponse(void * context) + static void OnTestSendClusterColorControlCommandStepColor_10_SuccessResponse(void * context) { ChipLogProgress(chipTool, "Color Control - Step Color command: Success Response"); Test_TC_CC_5 * runner = reinterpret_cast(context); - if (runner->mIsFailureExpected_11 == true) + if (runner->mIsFailureExpected_10 == true) { ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); @@ -16537,16 +16475,16 @@ class Test_TC_CC_5 : public TestCommand } // Test Check current x attribute value matched the value sent by the last command - using SuccessCallback_12 = void (*)(void * context, uint16_t currentX); - chip::Callback::Callback mOnSuccessCallback_12{ - OnTestSendClusterColorControlCommandReadAttribute_12_SuccessResponse, this + using SuccessCallback_11 = void (*)(void * context, uint16_t currentX); + chip::Callback::Callback mOnSuccessCallback_11{ + OnTestSendClusterColorControlCommandReadAttribute_11_SuccessResponse, this }; - chip::Callback::Callback mOnFailureCallback_12{ - OnTestSendClusterColorControlCommandReadAttribute_12_FailureResponse, this + chip::Callback::Callback mOnFailureCallback_11{ + OnTestSendClusterColorControlCommandReadAttribute_11_FailureResponse, this }; - bool mIsFailureExpected_12 = 0; + bool mIsFailureExpected_11 = 0; - CHIP_ERROR TestSendClusterColorControlCommandReadAttribute_12() + CHIP_ERROR TestSendClusterColorControlCommandReadAttribute_11() { ChipLogProgress( chipTool, @@ -16557,12 +16495,12 @@ class Test_TC_CC_5 : public TestCommand CHIP_ERROR err = CHIP_NO_ERROR; - err = cluster.ReadAttributeCurrentX(mOnSuccessCallback_12.Cancel(), mOnFailureCallback_12.Cancel()); + err = cluster.ReadAttributeCurrentX(mOnSuccessCallback_11.Cancel(), mOnFailureCallback_11.Cancel()); return err; } - static void OnTestSendClusterColorControlCommandReadAttribute_12_FailureResponse(void * context, uint8_t status) + static void OnTestSendClusterColorControlCommandReadAttribute_11_FailureResponse(void * context, uint8_t status) { ChipLogProgress( chipTool, @@ -16570,7 +16508,7 @@ class Test_TC_CC_5 : public TestCommand Test_TC_CC_5 * runner = reinterpret_cast(context); - if (runner->mIsFailureExpected_12 == false) + if (runner->mIsFailureExpected_11 == false) { ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); @@ -16580,7 +16518,7 @@ class Test_TC_CC_5 : public TestCommand runner->NextTest(); } - static void OnTestSendClusterColorControlCommandReadAttribute_12_SuccessResponse(void * context, uint16_t currentX) + static void OnTestSendClusterColorControlCommandReadAttribute_11_SuccessResponse(void * context, uint16_t currentX) { ChipLogProgress( chipTool, @@ -16588,7 +16526,7 @@ class Test_TC_CC_5 : public TestCommand Test_TC_CC_5 * runner = reinterpret_cast(context); - if (runner->mIsFailureExpected_12 == true) + if (runner->mIsFailureExpected_11 == true) { ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); @@ -16599,16 +16537,16 @@ class Test_TC_CC_5 : public TestCommand } // Test Check current y attribute value matched the value sent by the last command - using SuccessCallback_13 = void (*)(void * context, uint16_t currentY); - chip::Callback::Callback mOnSuccessCallback_13{ - OnTestSendClusterColorControlCommandReadAttribute_13_SuccessResponse, this + using SuccessCallback_12 = void (*)(void * context, uint16_t currentY); + chip::Callback::Callback mOnSuccessCallback_12{ + OnTestSendClusterColorControlCommandReadAttribute_12_SuccessResponse, this }; - chip::Callback::Callback mOnFailureCallback_13{ - OnTestSendClusterColorControlCommandReadAttribute_13_FailureResponse, this + chip::Callback::Callback mOnFailureCallback_12{ + OnTestSendClusterColorControlCommandReadAttribute_12_FailureResponse, this }; - bool mIsFailureExpected_13 = 0; + bool mIsFailureExpected_12 = 0; - CHIP_ERROR TestSendClusterColorControlCommandReadAttribute_13() + CHIP_ERROR TestSendClusterColorControlCommandReadAttribute_12() { ChipLogProgress( chipTool, @@ -16619,12 +16557,12 @@ class Test_TC_CC_5 : public TestCommand CHIP_ERROR err = CHIP_NO_ERROR; - err = cluster.ReadAttributeCurrentY(mOnSuccessCallback_13.Cancel(), mOnFailureCallback_13.Cancel()); + err = cluster.ReadAttributeCurrentY(mOnSuccessCallback_12.Cancel(), mOnFailureCallback_12.Cancel()); return err; } - static void OnTestSendClusterColorControlCommandReadAttribute_13_FailureResponse(void * context, uint8_t status) + static void OnTestSendClusterColorControlCommandReadAttribute_12_FailureResponse(void * context, uint8_t status) { ChipLogProgress( chipTool, @@ -16632,7 +16570,7 @@ class Test_TC_CC_5 : public TestCommand Test_TC_CC_5 * runner = reinterpret_cast(context); - if (runner->mIsFailureExpected_13 == false) + if (runner->mIsFailureExpected_12 == false) { ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); @@ -16642,7 +16580,7 @@ class Test_TC_CC_5 : public TestCommand runner->NextTest(); } - static void OnTestSendClusterColorControlCommandReadAttribute_13_SuccessResponse(void * context, uint16_t currentY) + static void OnTestSendClusterColorControlCommandReadAttribute_12_SuccessResponse(void * context, uint16_t currentY) { ChipLogProgress( chipTool, @@ -16650,7 +16588,7 @@ class Test_TC_CC_5 : public TestCommand Test_TC_CC_5 * runner = reinterpret_cast(context); - if (runner->mIsFailureExpected_13 == true) + if (runner->mIsFailureExpected_12 == true) { ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); @@ -16690,41 +16628,23 @@ class Test_TC_CC_6 : public TestCommand err = TestSendClusterOnOffCommandReadAttribute_1(); break; case 2: - err = TestSendClusterColorControlCommandMoveToColorTemperature_2(); + err = TestSendClusterColorControlCommandReadAttribute_2(); break; case 3: err = TestSendClusterColorControlCommandReadAttribute_3(); break; case 4: - err = TestSendClusterColorControlCommandMoveColorTemperature_4(); + err = TestSendClusterColorControlCommandReadAttribute_4(); break; case 5: err = TestSendClusterColorControlCommandReadAttribute_5(); break; case 6: - err = TestSendClusterColorControlCommandMoveColorTemperature_6(); + err = TestSendClusterColorControlCommandReadAttribute_6(); break; case 7: err = TestSendClusterColorControlCommandReadAttribute_7(); break; - case 8: - err = TestSendClusterColorControlCommandMoveColorTemperature_8(); - break; - case 9: - err = TestSendClusterColorControlCommandReadAttribute_9(); - break; - case 10: - err = TestSendClusterColorControlCommandStepColorTemperature_10(); - break; - case 11: - err = TestSendClusterColorControlCommandReadAttribute_11(); - break; - case 12: - err = TestSendClusterColorControlCommandStepColorTemperature_12(); - break; - case 13: - err = TestSendClusterColorControlCommandReadAttribute_13(); - break; } if (CHIP_NO_ERROR != err) @@ -16736,7 +16656,7 @@ class Test_TC_CC_6 : public TestCommand private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; + const uint16_t mTestCount = 8; // // Tests methods @@ -16857,38 +16777,33 @@ class Test_TC_CC_6 : public TestCommand runner->NextTest(); } - // Test Move To Color Temperature command - using SuccessCallback_2 = void (*)(void * context); + // Test Read current color temprature + using SuccessCallback_2 = void (*)(void * context, uint16_t colorTemperature); chip::Callback::Callback mOnSuccessCallback_2{ - OnTestSendClusterColorControlCommandMoveToColorTemperature_2_SuccessResponse, this + OnTestSendClusterColorControlCommandReadAttribute_2_SuccessResponse, this }; chip::Callback::Callback mOnFailureCallback_2{ - OnTestSendClusterColorControlCommandMoveToColorTemperature_2_FailureResponse, this + OnTestSendClusterColorControlCommandReadAttribute_2_FailureResponse, this }; bool mIsFailureExpected_2 = 0; - CHIP_ERROR TestSendClusterColorControlCommandMoveToColorTemperature_2() + CHIP_ERROR TestSendClusterColorControlCommandReadAttribute_2() { - ChipLogProgress(chipTool, "Color Control - Move To Color Temperature command: Sending command..."); + ChipLogProgress(chipTool, "Color Control - Read current color temprature: Sending command..."); chip::Controller::ColorControlCluster cluster; cluster.Associate(mDevice, 1); CHIP_ERROR err = CHIP_NO_ERROR; - uint16_t colorTemperatureArgument = 100U; - uint16_t transitionTimeArgument = 10U; - uint8_t optionsMaskArgument = 0; - uint8_t optionsOverrideArgument = 0; - err = cluster.MoveToColorTemperature(mOnSuccessCallback_2.Cancel(), mOnFailureCallback_2.Cancel(), colorTemperatureArgument, - transitionTimeArgument, optionsMaskArgument, optionsOverrideArgument); + err = cluster.ReadAttributeColorTemperature(mOnSuccessCallback_2.Cancel(), mOnFailureCallback_2.Cancel()); return err; } - static void OnTestSendClusterColorControlCommandMoveToColorTemperature_2_FailureResponse(void * context, uint8_t status) + static void OnTestSendClusterColorControlCommandReadAttribute_2_FailureResponse(void * context, uint8_t status) { - ChipLogProgress(chipTool, "Color Control - Move To Color Temperature command: Failure Response"); + ChipLogProgress(chipTool, "Color Control - Read current color temprature: Failure Response"); Test_TC_CC_6 * runner = reinterpret_cast(context); @@ -16902,9 +16817,9 @@ class Test_TC_CC_6 : public TestCommand runner->NextTest(); } - static void OnTestSendClusterColorControlCommandMoveToColorTemperature_2_SuccessResponse(void * context) + static void OnTestSendClusterColorControlCommandReadAttribute_2_SuccessResponse(void * context, uint16_t colorTemperature) { - ChipLogProgress(chipTool, "Color Control - Move To Color Temperature command: Success Response"); + ChipLogProgress(chipTool, "Color Control - Read current color temprature: Success Response"); Test_TC_CC_6 * runner = reinterpret_cast(context); @@ -16974,41 +16889,33 @@ class Test_TC_CC_6 : public TestCommand runner->NextTest(); } - // Test Move up color temperature command - using SuccessCallback_4 = void (*)(void * context); + // Test Read current color temprature + using SuccessCallback_4 = void (*)(void * context, uint16_t colorTemperature); chip::Callback::Callback mOnSuccessCallback_4{ - OnTestSendClusterColorControlCommandMoveColorTemperature_4_SuccessResponse, this + OnTestSendClusterColorControlCommandReadAttribute_4_SuccessResponse, this }; chip::Callback::Callback mOnFailureCallback_4{ - OnTestSendClusterColorControlCommandMoveColorTemperature_4_FailureResponse, this + OnTestSendClusterColorControlCommandReadAttribute_4_FailureResponse, this }; bool mIsFailureExpected_4 = 0; - CHIP_ERROR TestSendClusterColorControlCommandMoveColorTemperature_4() + CHIP_ERROR TestSendClusterColorControlCommandReadAttribute_4() { - ChipLogProgress(chipTool, "Color Control - Move up color temperature command: Sending command..."); + ChipLogProgress(chipTool, "Color Control - Read current color temprature: Sending command..."); chip::Controller::ColorControlCluster cluster; cluster.Associate(mDevice, 1); CHIP_ERROR err = CHIP_NO_ERROR; - uint8_t moveModeArgument = 1; - uint16_t rateArgument = 10U; - uint16_t colorTemperatureMinimumArgument = 1U; - uint16_t colorTemperatureMaximumArgument = 255U; - uint8_t optionsMaskArgument = 0; - uint8_t optionsOverrideArgument = 0; - err = cluster.MoveColorTemperature(mOnSuccessCallback_4.Cancel(), mOnFailureCallback_4.Cancel(), moveModeArgument, - rateArgument, colorTemperatureMinimumArgument, colorTemperatureMaximumArgument, - optionsMaskArgument, optionsOverrideArgument); + err = cluster.ReadAttributeColorTemperature(mOnSuccessCallback_4.Cancel(), mOnFailureCallback_4.Cancel()); return err; } - static void OnTestSendClusterColorControlCommandMoveColorTemperature_4_FailureResponse(void * context, uint8_t status) + static void OnTestSendClusterColorControlCommandReadAttribute_4_FailureResponse(void * context, uint8_t status) { - ChipLogProgress(chipTool, "Color Control - Move up color temperature command: Failure Response"); + ChipLogProgress(chipTool, "Color Control - Read current color temprature: Failure Response"); Test_TC_CC_6 * runner = reinterpret_cast(context); @@ -17022,9 +16929,9 @@ class Test_TC_CC_6 : public TestCommand runner->NextTest(); } - static void OnTestSendClusterColorControlCommandMoveColorTemperature_4_SuccessResponse(void * context) + static void OnTestSendClusterColorControlCommandReadAttribute_4_SuccessResponse(void * context, uint16_t colorTemperature) { - ChipLogProgress(chipTool, "Color Control - Move up color temperature command: Success Response"); + ChipLogProgress(chipTool, "Color Control - Read current color temprature: Success Response"); Test_TC_CC_6 * runner = reinterpret_cast(context); @@ -17094,41 +17001,33 @@ class Test_TC_CC_6 : public TestCommand runner->NextTest(); } - // Test Stop Color Temperature command - using SuccessCallback_6 = void (*)(void * context); + // Test Read current color temprature + using SuccessCallback_6 = void (*)(void * context, uint16_t colorTemperature); chip::Callback::Callback mOnSuccessCallback_6{ - OnTestSendClusterColorControlCommandMoveColorTemperature_6_SuccessResponse, this + OnTestSendClusterColorControlCommandReadAttribute_6_SuccessResponse, this }; chip::Callback::Callback mOnFailureCallback_6{ - OnTestSendClusterColorControlCommandMoveColorTemperature_6_FailureResponse, this + OnTestSendClusterColorControlCommandReadAttribute_6_FailureResponse, this }; bool mIsFailureExpected_6 = 0; - CHIP_ERROR TestSendClusterColorControlCommandMoveColorTemperature_6() + CHIP_ERROR TestSendClusterColorControlCommandReadAttribute_6() { - ChipLogProgress(chipTool, "Color Control - Stop Color Temperature command: Sending command..."); + ChipLogProgress(chipTool, "Color Control - Read current color temprature: Sending command..."); chip::Controller::ColorControlCluster cluster; cluster.Associate(mDevice, 1); CHIP_ERROR err = CHIP_NO_ERROR; - uint8_t moveModeArgument = 0; - uint16_t rateArgument = 10U; - uint16_t colorTemperatureMinimumArgument = 1U; - uint16_t colorTemperatureMaximumArgument = 255U; - uint8_t optionsMaskArgument = 0; - uint8_t optionsOverrideArgument = 0; - err = cluster.MoveColorTemperature(mOnSuccessCallback_6.Cancel(), mOnFailureCallback_6.Cancel(), moveModeArgument, - rateArgument, colorTemperatureMinimumArgument, colorTemperatureMaximumArgument, - optionsMaskArgument, optionsOverrideArgument); + err = cluster.ReadAttributeColorTemperature(mOnSuccessCallback_6.Cancel(), mOnFailureCallback_6.Cancel()); return err; } - static void OnTestSendClusterColorControlCommandMoveColorTemperature_6_FailureResponse(void * context, uint8_t status) + static void OnTestSendClusterColorControlCommandReadAttribute_6_FailureResponse(void * context, uint8_t status) { - ChipLogProgress(chipTool, "Color Control - Stop Color Temperature command: Failure Response"); + ChipLogProgress(chipTool, "Color Control - Read current color temprature: Failure Response"); Test_TC_CC_6 * runner = reinterpret_cast(context); @@ -17142,9 +17041,9 @@ class Test_TC_CC_6 : public TestCommand runner->NextTest(); } - static void OnTestSendClusterColorControlCommandMoveColorTemperature_6_SuccessResponse(void * context) + static void OnTestSendClusterColorControlCommandReadAttribute_6_SuccessResponse(void * context, uint16_t colorTemperature) { - ChipLogProgress(chipTool, "Color Control - Stop Color Temperature command: Success Response"); + ChipLogProgress(chipTool, "Color Control - Read current color temprature: Success Response"); Test_TC_CC_6 * runner = reinterpret_cast(context); @@ -17213,46 +17112,87 @@ class Test_TC_CC_6 : public TestCommand runner->NextTest(); } +}; - // Test Move down color temperature command - using SuccessCallback_8 = void (*)(void * context); - chip::Callback::Callback mOnSuccessCallback_8{ - OnTestSendClusterColorControlCommandMoveColorTemperature_8_SuccessResponse, this - }; - chip::Callback::Callback mOnFailureCallback_8{ - OnTestSendClusterColorControlCommandMoveColorTemperature_8_FailureResponse, this - }; - bool mIsFailureExpected_8 = 0; +class Test_TC_CC_7 : public TestCommand +{ +public: + Test_TC_CC_7() : TestCommand("Test_TC_CC_7"), mTestIndex(0) {} - CHIP_ERROR TestSendClusterColorControlCommandMoveColorTemperature_8() + /////////// TestCommand Interface ///////// + void NextTest() override { - ChipLogProgress(chipTool, "Color Control - Move down color temperature command: Sending command..."); + CHIP_ERROR err = CHIP_NO_ERROR; - chip::Controller::ColorControlCluster cluster; + if (mTestCount == mTestIndex) + { + ChipLogProgress(chipTool, "Test_TC_CC_7: Test complete"); + SetCommandExitStatus(CHIP_NO_ERROR); + } + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) + { + case 0: + err = TestSendClusterOnOffCommandOn_0(); + break; + case 1: + err = TestSendClusterOnOffCommandReadAttribute_1(); + break; + case 2: + err = TestSendClusterColorControlCommandReadAttribute_2(); + break; + case 3: + err = TestSendClusterColorControlCommandReadAttribute_3(); + break; + } + + if (CHIP_NO_ERROR != err) + { + ChipLogProgress(chipTool, "Test_TC_CC_7: %s", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 4; + + // + // Tests methods + // + + // Test Turn on light for color control tests + using SuccessCallback_0 = void (*)(void * context); + chip::Callback::Callback mOnSuccessCallback_0{ OnTestSendClusterOnOffCommandOn_0_SuccessResponse, this }; + chip::Callback::Callback mOnFailureCallback_0{ OnTestSendClusterOnOffCommandOn_0_FailureResponse, + this }; + bool mIsFailureExpected_0 = 0; + + CHIP_ERROR TestSendClusterOnOffCommandOn_0() + { + ChipLogProgress(chipTool, "On/Off - Turn on light for color control tests: Sending command..."); + + chip::Controller::OnOffCluster cluster; cluster.Associate(mDevice, 1); CHIP_ERROR err = CHIP_NO_ERROR; - uint8_t moveModeArgument = 3; - uint16_t rateArgument = 20U; - uint16_t colorTemperatureMinimumArgument = 1U; - uint16_t colorTemperatureMaximumArgument = 255U; - uint8_t optionsMaskArgument = 0; - uint8_t optionsOverrideArgument = 0; - err = cluster.MoveColorTemperature(mOnSuccessCallback_8.Cancel(), mOnFailureCallback_8.Cancel(), moveModeArgument, - rateArgument, colorTemperatureMinimumArgument, colorTemperatureMaximumArgument, - optionsMaskArgument, optionsOverrideArgument); + err = cluster.On(mOnSuccessCallback_0.Cancel(), mOnFailureCallback_0.Cancel()); return err; } - static void OnTestSendClusterColorControlCommandMoveColorTemperature_8_FailureResponse(void * context, uint8_t status) + static void OnTestSendClusterOnOffCommandOn_0_FailureResponse(void * context, uint8_t status) { - ChipLogProgress(chipTool, "Color Control - Move down color temperature command: Failure Response"); + ChipLogProgress(chipTool, "On/Off - Turn on light for color control tests: Failure Response"); - Test_TC_CC_6 * runner = reinterpret_cast(context); + Test_TC_CC_7 * runner = reinterpret_cast(context); - if (runner->mIsFailureExpected_8 == false) + if (runner->mIsFailureExpected_0 == false) { ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); @@ -17262,13 +17202,13 @@ class Test_TC_CC_6 : public TestCommand runner->NextTest(); } - static void OnTestSendClusterColorControlCommandMoveColorTemperature_8_SuccessResponse(void * context) + static void OnTestSendClusterOnOffCommandOn_0_SuccessResponse(void * context) { - ChipLogProgress(chipTool, "Color Control - Move down color temperature command: Success Response"); + ChipLogProgress(chipTool, "On/Off - Turn on light for color control tests: Success Response"); - Test_TC_CC_6 * runner = reinterpret_cast(context); + Test_TC_CC_7 * runner = reinterpret_cast(context); - if (runner->mIsFailureExpected_8 == true) + if (runner->mIsFailureExpected_0 == true) { ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); @@ -17278,975 +17218,36 @@ class Test_TC_CC_6 : public TestCommand runner->NextTest(); } - // Test Read current color temprature - using SuccessCallback_9 = void (*)(void * context, uint16_t colorTemperature); - chip::Callback::Callback mOnSuccessCallback_9{ - OnTestSendClusterColorControlCommandReadAttribute_9_SuccessResponse, this + // Test Check on/off attribute value is true after on command + using SuccessCallback_1 = void (*)(void * context, uint8_t onOff); + chip::Callback::Callback mOnSuccessCallback_1{ OnTestSendClusterOnOffCommandReadAttribute_1_SuccessResponse, + this }; + chip::Callback::Callback mOnFailureCallback_1{ + OnTestSendClusterOnOffCommandReadAttribute_1_FailureResponse, this }; - chip::Callback::Callback mOnFailureCallback_9{ - OnTestSendClusterColorControlCommandReadAttribute_9_FailureResponse, this - }; - bool mIsFailureExpected_9 = 0; - - CHIP_ERROR TestSendClusterColorControlCommandReadAttribute_9() - { - ChipLogProgress(chipTool, "Color Control - Read current color temprature: Sending command..."); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(mDevice, 1); - - CHIP_ERROR err = CHIP_NO_ERROR; - - err = cluster.ReadAttributeColorTemperature(mOnSuccessCallback_9.Cancel(), mOnFailureCallback_9.Cancel()); - - return err; - } - - static void OnTestSendClusterColorControlCommandReadAttribute_9_FailureResponse(void * context, uint8_t status) - { - ChipLogProgress(chipTool, "Color Control - Read current color temprature: Failure Response"); - - Test_TC_CC_6 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_9 == false) - { - ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - static void OnTestSendClusterColorControlCommandReadAttribute_9_SuccessResponse(void * context, uint16_t colorTemperature) - { - ChipLogProgress(chipTool, "Color Control - Read current color temprature: Success Response"); - - Test_TC_CC_6 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_9 == true) - { - ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - // Test Step up color temperature command - using SuccessCallback_10 = void (*)(void * context); - chip::Callback::Callback mOnSuccessCallback_10{ - OnTestSendClusterColorControlCommandStepColorTemperature_10_SuccessResponse, this - }; - chip::Callback::Callback mOnFailureCallback_10{ - OnTestSendClusterColorControlCommandStepColorTemperature_10_FailureResponse, this - }; - bool mIsFailureExpected_10 = 0; - - CHIP_ERROR TestSendClusterColorControlCommandStepColorTemperature_10() - { - ChipLogProgress(chipTool, "Color Control - Step up color temperature command: Sending command..."); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(mDevice, 1); - - CHIP_ERROR err = CHIP_NO_ERROR; - - uint8_t stepModeArgument = 1; - uint16_t stepSizeArgument = 5U; - uint16_t transitionTimeArgument = 50U; - uint16_t colorTemperatureMinimumArgument = 5U; - uint16_t colorTemperatureMaximumArgument = 100U; - uint8_t optionsMaskArgument = 0; - uint8_t optionsOverrideArgument = 0; - err = cluster.StepColorTemperature(mOnSuccessCallback_10.Cancel(), mOnFailureCallback_10.Cancel(), stepModeArgument, - stepSizeArgument, transitionTimeArgument, colorTemperatureMinimumArgument, - colorTemperatureMaximumArgument, optionsMaskArgument, optionsOverrideArgument); - - return err; - } - - static void OnTestSendClusterColorControlCommandStepColorTemperature_10_FailureResponse(void * context, uint8_t status) - { - ChipLogProgress(chipTool, "Color Control - Step up color temperature command: Failure Response"); - - Test_TC_CC_6 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_10 == false) - { - ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - static void OnTestSendClusterColorControlCommandStepColorTemperature_10_SuccessResponse(void * context) - { - ChipLogProgress(chipTool, "Color Control - Step up color temperature command: Success Response"); - - Test_TC_CC_6 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_10 == true) - { - ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - // Test Read current color temprature - using SuccessCallback_11 = void (*)(void * context, uint16_t colorTemperature); - chip::Callback::Callback mOnSuccessCallback_11{ - OnTestSendClusterColorControlCommandReadAttribute_11_SuccessResponse, this - }; - chip::Callback::Callback mOnFailureCallback_11{ - OnTestSendClusterColorControlCommandReadAttribute_11_FailureResponse, this - }; - bool mIsFailureExpected_11 = 0; - - CHIP_ERROR TestSendClusterColorControlCommandReadAttribute_11() - { - ChipLogProgress(chipTool, "Color Control - Read current color temprature: Sending command..."); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(mDevice, 1); - - CHIP_ERROR err = CHIP_NO_ERROR; - - err = cluster.ReadAttributeColorTemperature(mOnSuccessCallback_11.Cancel(), mOnFailureCallback_11.Cancel()); - - return err; - } - - static void OnTestSendClusterColorControlCommandReadAttribute_11_FailureResponse(void * context, uint8_t status) - { - ChipLogProgress(chipTool, "Color Control - Read current color temprature: Failure Response"); - - Test_TC_CC_6 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_11 == false) - { - ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - static void OnTestSendClusterColorControlCommandReadAttribute_11_SuccessResponse(void * context, uint16_t colorTemperature) - { - ChipLogProgress(chipTool, "Color Control - Read current color temprature: Success Response"); - - Test_TC_CC_6 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_11 == true) - { - ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - // Test Step down color temperature command - using SuccessCallback_12 = void (*)(void * context); - chip::Callback::Callback mOnSuccessCallback_12{ - OnTestSendClusterColorControlCommandStepColorTemperature_12_SuccessResponse, this - }; - chip::Callback::Callback mOnFailureCallback_12{ - OnTestSendClusterColorControlCommandStepColorTemperature_12_FailureResponse, this - }; - bool mIsFailureExpected_12 = 0; - - CHIP_ERROR TestSendClusterColorControlCommandStepColorTemperature_12() - { - ChipLogProgress(chipTool, "Color Control - Step down color temperature command: Sending command..."); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(mDevice, 1); - - CHIP_ERROR err = CHIP_NO_ERROR; - - uint8_t stepModeArgument = 3; - uint16_t stepSizeArgument = 5U; - uint16_t transitionTimeArgument = 50U; - uint16_t colorTemperatureMinimumArgument = 5U; - uint16_t colorTemperatureMaximumArgument = 100U; - uint8_t optionsMaskArgument = 0; - uint8_t optionsOverrideArgument = 0; - err = cluster.StepColorTemperature(mOnSuccessCallback_12.Cancel(), mOnFailureCallback_12.Cancel(), stepModeArgument, - stepSizeArgument, transitionTimeArgument, colorTemperatureMinimumArgument, - colorTemperatureMaximumArgument, optionsMaskArgument, optionsOverrideArgument); - - return err; - } - - static void OnTestSendClusterColorControlCommandStepColorTemperature_12_FailureResponse(void * context, uint8_t status) - { - ChipLogProgress(chipTool, "Color Control - Step down color temperature command: Failure Response"); - - Test_TC_CC_6 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_12 == false) - { - ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - static void OnTestSendClusterColorControlCommandStepColorTemperature_12_SuccessResponse(void * context) - { - ChipLogProgress(chipTool, "Color Control - Step down color temperature command: Success Response"); - - Test_TC_CC_6 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_12 == true) - { - ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - // Test Read current color temprature - using SuccessCallback_13 = void (*)(void * context, uint16_t colorTemperature); - chip::Callback::Callback mOnSuccessCallback_13{ - OnTestSendClusterColorControlCommandReadAttribute_13_SuccessResponse, this - }; - chip::Callback::Callback mOnFailureCallback_13{ - OnTestSendClusterColorControlCommandReadAttribute_13_FailureResponse, this - }; - bool mIsFailureExpected_13 = 0; - - CHIP_ERROR TestSendClusterColorControlCommandReadAttribute_13() - { - ChipLogProgress(chipTool, "Color Control - Read current color temprature: Sending command..."); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(mDevice, 1); - - CHIP_ERROR err = CHIP_NO_ERROR; - - err = cluster.ReadAttributeColorTemperature(mOnSuccessCallback_13.Cancel(), mOnFailureCallback_13.Cancel()); - - return err; - } - - static void OnTestSendClusterColorControlCommandReadAttribute_13_FailureResponse(void * context, uint8_t status) - { - ChipLogProgress(chipTool, "Color Control - Read current color temprature: Failure Response"); - - Test_TC_CC_6 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_13 == false) - { - ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - static void OnTestSendClusterColorControlCommandReadAttribute_13_SuccessResponse(void * context, uint16_t colorTemperature) - { - ChipLogProgress(chipTool, "Color Control - Read current color temprature: Success Response"); - - Test_TC_CC_6 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_13 == true) - { - ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } -}; - -class Test_TC_CC_7 : public TestCommand -{ -public: - Test_TC_CC_7() : TestCommand("Test_TC_CC_7"), mTestIndex(0) {} - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (mTestCount == mTestIndex) - { - ChipLogProgress(chipTool, "Test_TC_CC_7: Test complete"); - SetCommandExitStatus(CHIP_NO_ERROR); - } - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) - { - case 0: - err = TestSendClusterOnOffCommandOn_0(); - break; - case 1: - err = TestSendClusterOnOffCommandReadAttribute_1(); - break; - case 2: - err = TestSendClusterColorControlCommandEnhancedMoveToHue_2(); - break; - case 3: - err = TestSendClusterColorControlCommandReadAttribute_3(); - break; - case 4: - err = TestSendClusterColorControlCommandReadAttribute_4(); - break; - case 5: - err = TestSendClusterColorControlCommandEnhancedMoveHue_5(); - break; - case 6: - err = TestSendClusterColorControlCommandEnhancedMoveHue_6(); - break; - case 7: - err = TestSendClusterColorControlCommandEnhancedMoveHue_7(); - break; - case 8: - err = TestSendClusterColorControlCommandEnhancedMoveHue_8(); - break; - case 9: - err = TestSendClusterColorControlCommandEnhancedStepHue_9(); - break; - case 10: - err = TestSendClusterColorControlCommandEnhancedStepHue_10(); - break; - case 11: - err = TestSendClusterColorControlCommandEnhancedMoveToHueAndSaturation_11(); - break; - case 12: - err = TestSendClusterColorControlCommandReadAttribute_12(); - break; - case 13: - err = TestSendClusterColorControlCommandReadAttribute_13(); - break; - } - - if (CHIP_NO_ERROR != err) - { - ChipLogProgress(chipTool, "Test_TC_CC_7: %s", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - // - // Tests methods - // - - // Test Turn on light for color control tests - using SuccessCallback_0 = void (*)(void * context); - chip::Callback::Callback mOnSuccessCallback_0{ OnTestSendClusterOnOffCommandOn_0_SuccessResponse, this }; - chip::Callback::Callback mOnFailureCallback_0{ OnTestSendClusterOnOffCommandOn_0_FailureResponse, - this }; - bool mIsFailureExpected_0 = 0; - - CHIP_ERROR TestSendClusterOnOffCommandOn_0() - { - ChipLogProgress(chipTool, "On/Off - Turn on light for color control tests: Sending command..."); - - chip::Controller::OnOffCluster cluster; - cluster.Associate(mDevice, 1); - - CHIP_ERROR err = CHIP_NO_ERROR; - - err = cluster.On(mOnSuccessCallback_0.Cancel(), mOnFailureCallback_0.Cancel()); - - return err; - } - - static void OnTestSendClusterOnOffCommandOn_0_FailureResponse(void * context, uint8_t status) - { - ChipLogProgress(chipTool, "On/Off - Turn on light for color control tests: Failure Response"); - - Test_TC_CC_7 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_0 == false) - { - ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - static void OnTestSendClusterOnOffCommandOn_0_SuccessResponse(void * context) - { - ChipLogProgress(chipTool, "On/Off - Turn on light for color control tests: Success Response"); - - Test_TC_CC_7 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_0 == true) - { - ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - // Test Check on/off attribute value is true after on command - using SuccessCallback_1 = void (*)(void * context, uint8_t onOff); - chip::Callback::Callback mOnSuccessCallback_1{ OnTestSendClusterOnOffCommandReadAttribute_1_SuccessResponse, - this }; - chip::Callback::Callback mOnFailureCallback_1{ - OnTestSendClusterOnOffCommandReadAttribute_1_FailureResponse, this - }; - bool mIsFailureExpected_1 = 0; - - CHIP_ERROR TestSendClusterOnOffCommandReadAttribute_1() - { - ChipLogProgress(chipTool, "On/Off - Check on/off attribute value is true after on command: Sending command..."); - - chip::Controller::OnOffCluster cluster; - cluster.Associate(mDevice, 1); - - CHIP_ERROR err = CHIP_NO_ERROR; - - err = cluster.ReadAttributeOnOff(mOnSuccessCallback_1.Cancel(), mOnFailureCallback_1.Cancel()); - - return err; - } - - static void OnTestSendClusterOnOffCommandReadAttribute_1_FailureResponse(void * context, uint8_t status) - { - ChipLogProgress(chipTool, "On/Off - Check on/off attribute value is true after on command: Failure Response"); - - Test_TC_CC_7 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_1 == false) - { - ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - static void OnTestSendClusterOnOffCommandReadAttribute_1_SuccessResponse(void * context, uint8_t onOff) - { - ChipLogProgress(chipTool, "On/Off - Check on/off attribute value is true after on command: Success Response"); - - Test_TC_CC_7 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_1 == true) - { - ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - if (onOff != 1) - { - ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "1"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - // Test Enhanced Move To Hue command - using SuccessCallback_2 = void (*)(void * context); - chip::Callback::Callback mOnSuccessCallback_2{ - OnTestSendClusterColorControlCommandEnhancedMoveToHue_2_SuccessResponse, this - }; - chip::Callback::Callback mOnFailureCallback_2{ - OnTestSendClusterColorControlCommandEnhancedMoveToHue_2_FailureResponse, this - }; - bool mIsFailureExpected_2 = 0; - - CHIP_ERROR TestSendClusterColorControlCommandEnhancedMoveToHue_2() - { - ChipLogProgress(chipTool, "Color Control - Enhanced Move To Hue command: Sending command..."); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(mDevice, 1); - - CHIP_ERROR err = CHIP_NO_ERROR; - - uint16_t enhancedHueArgument = 1025U; - uint8_t directionArgument = 0; - uint16_t transitionTimeArgument = 1U; - uint8_t optionsMaskArgument = 0; - uint8_t optionsOverrideArgument = 0; - err = cluster.EnhancedMoveToHue(mOnSuccessCallback_2.Cancel(), mOnFailureCallback_2.Cancel(), enhancedHueArgument, - directionArgument, transitionTimeArgument, optionsMaskArgument, optionsOverrideArgument); - - return err; - } - - static void OnTestSendClusterColorControlCommandEnhancedMoveToHue_2_FailureResponse(void * context, uint8_t status) - { - ChipLogProgress(chipTool, "Color Control - Enhanced Move To Hue command: Failure Response"); - - Test_TC_CC_7 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_2 == false) - { - ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - static void OnTestSendClusterColorControlCommandEnhancedMoveToHue_2_SuccessResponse(void * context) - { - ChipLogProgress(chipTool, "Color Control - Enhanced Move To Hue command: Success Response"); - - Test_TC_CC_7 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_2 == true) - { - ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - // Test Check Remaining time attribute value matched the value sent by the last command - using SuccessCallback_3 = void (*)(void * context, uint16_t remainingTime); - chip::Callback::Callback mOnSuccessCallback_3{ - OnTestSendClusterColorControlCommandReadAttribute_3_SuccessResponse, this - }; - chip::Callback::Callback mOnFailureCallback_3{ - OnTestSendClusterColorControlCommandReadAttribute_3_FailureResponse, this - }; - bool mIsFailureExpected_3 = 0; - - CHIP_ERROR TestSendClusterColorControlCommandReadAttribute_3() - { - ChipLogProgress( - chipTool, - "Color Control - Check Remaining time attribute value matched the value sent by the last command: Sending command..."); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(mDevice, 1); - - CHIP_ERROR err = CHIP_NO_ERROR; - - err = cluster.ReadAttributeRemainingTime(mOnSuccessCallback_3.Cancel(), mOnFailureCallback_3.Cancel()); - - return err; - } - - static void OnTestSendClusterColorControlCommandReadAttribute_3_FailureResponse(void * context, uint8_t status) - { - ChipLogProgress( - chipTool, - "Color Control - Check Remaining time attribute value matched the value sent by the last command: Failure Response"); - - Test_TC_CC_7 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_3 == false) - { - ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - static void OnTestSendClusterColorControlCommandReadAttribute_3_SuccessResponse(void * context, uint16_t remainingTime) - { - ChipLogProgress( - chipTool, - "Color Control - Check Remaining time attribute value matched the value sent by the last command: Success Response"); - - Test_TC_CC_7 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_3 == true) - { - ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - if (remainingTime != 1U) - { - ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "1"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - // Test Check EnhancedCurrentHue attribute value matched the value sent by the last command - using SuccessCallback_4 = void (*)(void * context, uint16_t enhancedCurrentHue); - chip::Callback::Callback mOnSuccessCallback_4{ - OnTestSendClusterColorControlCommandReadAttribute_4_SuccessResponse, this - }; - chip::Callback::Callback mOnFailureCallback_4{ - OnTestSendClusterColorControlCommandReadAttribute_4_FailureResponse, this - }; - bool mIsFailureExpected_4 = 0; - - CHIP_ERROR TestSendClusterColorControlCommandReadAttribute_4() - { - ChipLogProgress(chipTool, - "Color Control - Check EnhancedCurrentHue attribute value matched the value sent by the last command: " - "Sending command..."); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(mDevice, 1); - - CHIP_ERROR err = CHIP_NO_ERROR; - - err = cluster.ReadAttributeEnhancedCurrentHue(mOnSuccessCallback_4.Cancel(), mOnFailureCallback_4.Cancel()); - - return err; - } - - static void OnTestSendClusterColorControlCommandReadAttribute_4_FailureResponse(void * context, uint8_t status) - { - ChipLogProgress(chipTool, - "Color Control - Check EnhancedCurrentHue attribute value matched the value sent by the last command: " - "Failure Response"); - - Test_TC_CC_7 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_4 == false) - { - ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - static void OnTestSendClusterColorControlCommandReadAttribute_4_SuccessResponse(void * context, uint16_t enhancedCurrentHue) - { - ChipLogProgress(chipTool, - "Color Control - Check EnhancedCurrentHue attribute value matched the value sent by the last command: " - "Success Response"); - - Test_TC_CC_7 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_4 == true) - { - ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - // Test Enhanced Move Hue Down command - using SuccessCallback_5 = void (*)(void * context); - chip::Callback::Callback mOnSuccessCallback_5{ - OnTestSendClusterColorControlCommandEnhancedMoveHue_5_SuccessResponse, this - }; - chip::Callback::Callback mOnFailureCallback_5{ - OnTestSendClusterColorControlCommandEnhancedMoveHue_5_FailureResponse, this - }; - bool mIsFailureExpected_5 = 0; - - CHIP_ERROR TestSendClusterColorControlCommandEnhancedMoveHue_5() - { - ChipLogProgress(chipTool, "Color Control - Enhanced Move Hue Down command : Sending command..."); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(mDevice, 1); - - CHIP_ERROR err = CHIP_NO_ERROR; - - uint8_t moveModeArgument = 3; - uint16_t rateArgument = 5U; - uint8_t optionsMaskArgument = 0; - uint8_t optionsOverrideArgument = 0; - err = cluster.EnhancedMoveHue(mOnSuccessCallback_5.Cancel(), mOnFailureCallback_5.Cancel(), moveModeArgument, rateArgument, - optionsMaskArgument, optionsOverrideArgument); - - return err; - } - - static void OnTestSendClusterColorControlCommandEnhancedMoveHue_5_FailureResponse(void * context, uint8_t status) - { - ChipLogProgress(chipTool, "Color Control - Enhanced Move Hue Down command : Failure Response"); - - Test_TC_CC_7 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_5 == false) - { - ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - static void OnTestSendClusterColorControlCommandEnhancedMoveHue_5_SuccessResponse(void * context) - { - ChipLogProgress(chipTool, "Color Control - Enhanced Move Hue Down command : Success Response"); - - Test_TC_CC_7 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_5 == true) - { - ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - // Test Enhanced Move Hue Stop command - using SuccessCallback_6 = void (*)(void * context); - chip::Callback::Callback mOnSuccessCallback_6{ - OnTestSendClusterColorControlCommandEnhancedMoveHue_6_SuccessResponse, this - }; - chip::Callback::Callback mOnFailureCallback_6{ - OnTestSendClusterColorControlCommandEnhancedMoveHue_6_FailureResponse, this - }; - bool mIsFailureExpected_6 = 0; - - CHIP_ERROR TestSendClusterColorControlCommandEnhancedMoveHue_6() - { - ChipLogProgress(chipTool, "Color Control - Enhanced Move Hue Stop command: Sending command..."); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(mDevice, 1); - - CHIP_ERROR err = CHIP_NO_ERROR; - - uint8_t moveModeArgument = 0; - uint16_t rateArgument = 0U; - uint8_t optionsMaskArgument = 0; - uint8_t optionsOverrideArgument = 0; - err = cluster.EnhancedMoveHue(mOnSuccessCallback_6.Cancel(), mOnFailureCallback_6.Cancel(), moveModeArgument, rateArgument, - optionsMaskArgument, optionsOverrideArgument); - - return err; - } - - static void OnTestSendClusterColorControlCommandEnhancedMoveHue_6_FailureResponse(void * context, uint8_t status) - { - ChipLogProgress(chipTool, "Color Control - Enhanced Move Hue Stop command: Failure Response"); - - Test_TC_CC_7 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_6 == false) - { - ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - static void OnTestSendClusterColorControlCommandEnhancedMoveHue_6_SuccessResponse(void * context) - { - ChipLogProgress(chipTool, "Color Control - Enhanced Move Hue Stop command: Success Response"); - - Test_TC_CC_7 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_6 == true) - { - ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - // Test Enhanced Move Hue Up command - using SuccessCallback_7 = void (*)(void * context); - chip::Callback::Callback mOnSuccessCallback_7{ - OnTestSendClusterColorControlCommandEnhancedMoveHue_7_SuccessResponse, this - }; - chip::Callback::Callback mOnFailureCallback_7{ - OnTestSendClusterColorControlCommandEnhancedMoveHue_7_FailureResponse, this - }; - bool mIsFailureExpected_7 = 0; - - CHIP_ERROR TestSendClusterColorControlCommandEnhancedMoveHue_7() - { - ChipLogProgress(chipTool, "Color Control - Enhanced Move Hue Up command: Sending command..."); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(mDevice, 1); - - CHIP_ERROR err = CHIP_NO_ERROR; - - uint8_t moveModeArgument = 1; - uint16_t rateArgument = 50U; - uint8_t optionsMaskArgument = 0; - uint8_t optionsOverrideArgument = 0; - err = cluster.EnhancedMoveHue(mOnSuccessCallback_7.Cancel(), mOnFailureCallback_7.Cancel(), moveModeArgument, rateArgument, - optionsMaskArgument, optionsOverrideArgument); - - return err; - } - - static void OnTestSendClusterColorControlCommandEnhancedMoveHue_7_FailureResponse(void * context, uint8_t status) - { - ChipLogProgress(chipTool, "Color Control - Enhanced Move Hue Up command: Failure Response"); - - Test_TC_CC_7 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_7 == false) - { - ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - static void OnTestSendClusterColorControlCommandEnhancedMoveHue_7_SuccessResponse(void * context) - { - ChipLogProgress(chipTool, "Color Control - Enhanced Move Hue Up command: Success Response"); - - Test_TC_CC_7 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_7 == true) - { - ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - // Test Enhanced Move Hue Stop command - using SuccessCallback_8 = void (*)(void * context); - chip::Callback::Callback mOnSuccessCallback_8{ - OnTestSendClusterColorControlCommandEnhancedMoveHue_8_SuccessResponse, this - }; - chip::Callback::Callback mOnFailureCallback_8{ - OnTestSendClusterColorControlCommandEnhancedMoveHue_8_FailureResponse, this - }; - bool mIsFailureExpected_8 = 0; - - CHIP_ERROR TestSendClusterColorControlCommandEnhancedMoveHue_8() - { - ChipLogProgress(chipTool, "Color Control - Enhanced Move Hue Stop command: Sending command..."); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(mDevice, 1); - - CHIP_ERROR err = CHIP_NO_ERROR; - - uint8_t moveModeArgument = 0; - uint16_t rateArgument = 0U; - uint8_t optionsMaskArgument = 0; - uint8_t optionsOverrideArgument = 0; - err = cluster.EnhancedMoveHue(mOnSuccessCallback_8.Cancel(), mOnFailureCallback_8.Cancel(), moveModeArgument, rateArgument, - optionsMaskArgument, optionsOverrideArgument); - - return err; - } - - static void OnTestSendClusterColorControlCommandEnhancedMoveHue_8_FailureResponse(void * context, uint8_t status) - { - ChipLogProgress(chipTool, "Color Control - Enhanced Move Hue Stop command: Failure Response"); - - Test_TC_CC_7 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_8 == false) - { - ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - static void OnTestSendClusterColorControlCommandEnhancedMoveHue_8_SuccessResponse(void * context) - { - ChipLogProgress(chipTool, "Color Control - Enhanced Move Hue Stop command: Success Response"); - - Test_TC_CC_7 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_8 == true) - { - ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - // Test Enhanced Step Hue Up command - using SuccessCallback_9 = void (*)(void * context); - chip::Callback::Callback mOnSuccessCallback_9{ - OnTestSendClusterColorControlCommandEnhancedStepHue_9_SuccessResponse, this - }; - chip::Callback::Callback mOnFailureCallback_9{ - OnTestSendClusterColorControlCommandEnhancedStepHue_9_FailureResponse, this - }; - bool mIsFailureExpected_9 = 0; + bool mIsFailureExpected_1 = 0; - CHIP_ERROR TestSendClusterColorControlCommandEnhancedStepHue_9() + CHIP_ERROR TestSendClusterOnOffCommandReadAttribute_1() { - ChipLogProgress(chipTool, "Color Control - Enhanced Step Hue Up command: Sending command..."); + ChipLogProgress(chipTool, "On/Off - Check on/off attribute value is true after on command: Sending command..."); - chip::Controller::ColorControlCluster cluster; + chip::Controller::OnOffCluster cluster; cluster.Associate(mDevice, 1); CHIP_ERROR err = CHIP_NO_ERROR; - uint8_t stepModeArgument = 0; - uint16_t stepSizeArgument = 50U; - uint16_t transitionTimeArgument = 1U; - uint8_t optionsMaskArgument = 0; - uint8_t optionsOverrideArgument = 0; - err = cluster.EnhancedStepHue(mOnSuccessCallback_9.Cancel(), mOnFailureCallback_9.Cancel(), stepModeArgument, - stepSizeArgument, transitionTimeArgument, optionsMaskArgument, optionsOverrideArgument); + err = cluster.ReadAttributeOnOff(mOnSuccessCallback_1.Cancel(), mOnFailureCallback_1.Cancel()); return err; } - static void OnTestSendClusterColorControlCommandEnhancedStepHue_9_FailureResponse(void * context, uint8_t status) + static void OnTestSendClusterOnOffCommandReadAttribute_1_FailureResponse(void * context, uint8_t status) { - ChipLogProgress(chipTool, "Color Control - Enhanced Step Hue Up command: Failure Response"); + ChipLogProgress(chipTool, "On/Off - Check on/off attribute value is true after on command: Failure Response"); Test_TC_CC_7 * runner = reinterpret_cast(context); - if (runner->mIsFailureExpected_9 == false) + if (runner->mIsFailureExpected_1 == false) { ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); @@ -18256,77 +17257,22 @@ class Test_TC_CC_7 : public TestCommand runner->NextTest(); } - static void OnTestSendClusterColorControlCommandEnhancedStepHue_9_SuccessResponse(void * context) + static void OnTestSendClusterOnOffCommandReadAttribute_1_SuccessResponse(void * context, uint8_t onOff) { - ChipLogProgress(chipTool, "Color Control - Enhanced Step Hue Up command: Success Response"); + ChipLogProgress(chipTool, "On/Off - Check on/off attribute value is true after on command: Success Response"); Test_TC_CC_7 * runner = reinterpret_cast(context); - if (runner->mIsFailureExpected_9 == true) + if (runner->mIsFailureExpected_1 == true) { ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); return; } - runner->NextTest(); - } - - // Test Enhanced Step Hue Down command - using SuccessCallback_10 = void (*)(void * context); - chip::Callback::Callback mOnSuccessCallback_10{ - OnTestSendClusterColorControlCommandEnhancedStepHue_10_SuccessResponse, this - }; - chip::Callback::Callback mOnFailureCallback_10{ - OnTestSendClusterColorControlCommandEnhancedStepHue_10_FailureResponse, this - }; - bool mIsFailureExpected_10 = 0; - - CHIP_ERROR TestSendClusterColorControlCommandEnhancedStepHue_10() - { - ChipLogProgress(chipTool, "Color Control - Enhanced Step Hue Down command: Sending command..."); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(mDevice, 1); - - CHIP_ERROR err = CHIP_NO_ERROR; - - uint8_t stepModeArgument = 1; - uint16_t stepSizeArgument = 75U; - uint16_t transitionTimeArgument = 1U; - uint8_t optionsMaskArgument = 0; - uint8_t optionsOverrideArgument = 0; - err = cluster.EnhancedStepHue(mOnSuccessCallback_10.Cancel(), mOnFailureCallback_10.Cancel(), stepModeArgument, - stepSizeArgument, transitionTimeArgument, optionsMaskArgument, optionsOverrideArgument); - - return err; - } - - static void OnTestSendClusterColorControlCommandEnhancedStepHue_10_FailureResponse(void * context, uint8_t status) - { - ChipLogProgress(chipTool, "Color Control - Enhanced Step Hue Down command: Failure Response"); - - Test_TC_CC_7 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_10 == false) - { - ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - static void OnTestSendClusterColorControlCommandEnhancedStepHue_10_SuccessResponse(void * context) - { - ChipLogProgress(chipTool, "Color Control - Enhanced Step Hue Down command: Success Response"); - - Test_TC_CC_7 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_10 == true) + if (onOff != 1) { - ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "1"); runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); return; } @@ -18334,45 +17280,41 @@ class Test_TC_CC_7 : public TestCommand runner->NextTest(); } - // Test Enhanced move to hue and saturation command - using SuccessCallback_11 = void (*)(void * context); - chip::Callback::Callback mOnSuccessCallback_11{ - OnTestSendClusterColorControlCommandEnhancedMoveToHueAndSaturation_11_SuccessResponse, this + // Test Check Remaining time attribute value matched the value sent by the last command + using SuccessCallback_2 = void (*)(void * context, uint16_t remainingTime); + chip::Callback::Callback mOnSuccessCallback_2{ + OnTestSendClusterColorControlCommandReadAttribute_2_SuccessResponse, this }; - chip::Callback::Callback mOnFailureCallback_11{ - OnTestSendClusterColorControlCommandEnhancedMoveToHueAndSaturation_11_FailureResponse, this + chip::Callback::Callback mOnFailureCallback_2{ + OnTestSendClusterColorControlCommandReadAttribute_2_FailureResponse, this }; - bool mIsFailureExpected_11 = 0; + bool mIsFailureExpected_2 = 0; - CHIP_ERROR TestSendClusterColorControlCommandEnhancedMoveToHueAndSaturation_11() + CHIP_ERROR TestSendClusterColorControlCommandReadAttribute_2() { - ChipLogProgress(chipTool, "Color Control - Enhanced move to hue and saturation command: Sending command..."); + ChipLogProgress( + chipTool, + "Color Control - Check Remaining time attribute value matched the value sent by the last command: Sending command..."); chip::Controller::ColorControlCluster cluster; cluster.Associate(mDevice, 1); CHIP_ERROR err = CHIP_NO_ERROR; - uint16_t enhancedHueArgument = 1200U; - uint8_t saturationArgument = 90; - uint16_t transitionTimeArgument = 10U; - uint8_t optionsMaskArgument = 0; - uint8_t optionsOverrideArgument = 0; - err = cluster.EnhancedMoveToHueAndSaturation(mOnSuccessCallback_11.Cancel(), mOnFailureCallback_11.Cancel(), - enhancedHueArgument, saturationArgument, transitionTimeArgument, - optionsMaskArgument, optionsOverrideArgument); + err = cluster.ReadAttributeRemainingTime(mOnSuccessCallback_2.Cancel(), mOnFailureCallback_2.Cancel()); return err; } - static void OnTestSendClusterColorControlCommandEnhancedMoveToHueAndSaturation_11_FailureResponse(void * context, - uint8_t status) + static void OnTestSendClusterColorControlCommandReadAttribute_2_FailureResponse(void * context, uint8_t status) { - ChipLogProgress(chipTool, "Color Control - Enhanced move to hue and saturation command: Failure Response"); + ChipLogProgress( + chipTool, + "Color Control - Check Remaining time attribute value matched the value sent by the last command: Failure Response"); Test_TC_CC_7 * runner = reinterpret_cast(context); - if (runner->mIsFailureExpected_11 == false) + if (runner->mIsFailureExpected_2 == false) { ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); @@ -18382,77 +17324,24 @@ class Test_TC_CC_7 : public TestCommand runner->NextTest(); } - static void OnTestSendClusterColorControlCommandEnhancedMoveToHueAndSaturation_11_SuccessResponse(void * context) + static void OnTestSendClusterColorControlCommandReadAttribute_2_SuccessResponse(void * context, uint16_t remainingTime) { - ChipLogProgress(chipTool, "Color Control - Enhanced move to hue and saturation command: Success Response"); + ChipLogProgress( + chipTool, + "Color Control - Check Remaining time attribute value matched the value sent by the last command: Success Response"); Test_TC_CC_7 * runner = reinterpret_cast(context); - if (runner->mIsFailureExpected_11 == true) + if (runner->mIsFailureExpected_2 == true) { ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); return; } - runner->NextTest(); - } - - // Test Check EnhancedCurrentHue attribute value matched the value sent by the last command - using SuccessCallback_12 = void (*)(void * context, uint16_t enhancedCurrentHue); - chip::Callback::Callback mOnSuccessCallback_12{ - OnTestSendClusterColorControlCommandReadAttribute_12_SuccessResponse, this - }; - chip::Callback::Callback mOnFailureCallback_12{ - OnTestSendClusterColorControlCommandReadAttribute_12_FailureResponse, this - }; - bool mIsFailureExpected_12 = 0; - - CHIP_ERROR TestSendClusterColorControlCommandReadAttribute_12() - { - ChipLogProgress(chipTool, - "Color Control - Check EnhancedCurrentHue attribute value matched the value sent by the last command: " - "Sending command..."); - - chip::Controller::ColorControlCluster cluster; - cluster.Associate(mDevice, 1); - - CHIP_ERROR err = CHIP_NO_ERROR; - - err = cluster.ReadAttributeEnhancedCurrentHue(mOnSuccessCallback_12.Cancel(), mOnFailureCallback_12.Cancel()); - - return err; - } - - static void OnTestSendClusterColorControlCommandReadAttribute_12_FailureResponse(void * context, uint8_t status) - { - ChipLogProgress(chipTool, - "Color Control - Check EnhancedCurrentHue attribute value matched the value sent by the last command: " - "Failure Response"); - - Test_TC_CC_7 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_12 == false) - { - ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); - runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); - return; - } - - runner->NextTest(); - } - - static void OnTestSendClusterColorControlCommandReadAttribute_12_SuccessResponse(void * context, uint16_t enhancedCurrentHue) - { - ChipLogProgress(chipTool, - "Color Control - Check EnhancedCurrentHue attribute value matched the value sent by the last command: " - "Success Response"); - - Test_TC_CC_7 * runner = reinterpret_cast(context); - - if (runner->mIsFailureExpected_12 == true) + if (remainingTime != 1U) { - ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); + ChipLogError(chipTool, "Error: Value mismatch. Expected: '%s'", "1"); runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); return; } @@ -18461,16 +17350,16 @@ class Test_TC_CC_7 : public TestCommand } // Test Check Saturation attribute value matched the value sent by the last command - using SuccessCallback_13 = void (*)(void * context, uint8_t currentSaturation); - chip::Callback::Callback mOnSuccessCallback_13{ - OnTestSendClusterColorControlCommandReadAttribute_13_SuccessResponse, this + using SuccessCallback_3 = void (*)(void * context, uint8_t currentSaturation); + chip::Callback::Callback mOnSuccessCallback_3{ + OnTestSendClusterColorControlCommandReadAttribute_3_SuccessResponse, this }; - chip::Callback::Callback mOnFailureCallback_13{ - OnTestSendClusterColorControlCommandReadAttribute_13_FailureResponse, this + chip::Callback::Callback mOnFailureCallback_3{ + OnTestSendClusterColorControlCommandReadAttribute_3_FailureResponse, this }; - bool mIsFailureExpected_13 = 0; + bool mIsFailureExpected_3 = 0; - CHIP_ERROR TestSendClusterColorControlCommandReadAttribute_13() + CHIP_ERROR TestSendClusterColorControlCommandReadAttribute_3() { ChipLogProgress( chipTool, @@ -18481,12 +17370,12 @@ class Test_TC_CC_7 : public TestCommand CHIP_ERROR err = CHIP_NO_ERROR; - err = cluster.ReadAttributeCurrentSaturation(mOnSuccessCallback_13.Cancel(), mOnFailureCallback_13.Cancel()); + err = cluster.ReadAttributeCurrentSaturation(mOnSuccessCallback_3.Cancel(), mOnFailureCallback_3.Cancel()); return err; } - static void OnTestSendClusterColorControlCommandReadAttribute_13_FailureResponse(void * context, uint8_t status) + static void OnTestSendClusterColorControlCommandReadAttribute_3_FailureResponse(void * context, uint8_t status) { ChipLogProgress( chipTool, @@ -18494,7 +17383,7 @@ class Test_TC_CC_7 : public TestCommand Test_TC_CC_7 * runner = reinterpret_cast(context); - if (runner->mIsFailureExpected_13 == false) + if (runner->mIsFailureExpected_3 == false) { ChipLogError(chipTool, "Error: The test was expecting a success callback. Got failure callback"); runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); @@ -18504,7 +17393,7 @@ class Test_TC_CC_7 : public TestCommand runner->NextTest(); } - static void OnTestSendClusterColorControlCommandReadAttribute_13_SuccessResponse(void * context, uint8_t currentSaturation) + static void OnTestSendClusterColorControlCommandReadAttribute_3_SuccessResponse(void * context, uint8_t currentSaturation) { ChipLogProgress( chipTool, @@ -18512,7 +17401,7 @@ class Test_TC_CC_7 : public TestCommand Test_TC_CC_7 * runner = reinterpret_cast(context); - if (runner->mIsFailureExpected_13 == true) + if (runner->mIsFailureExpected_3 == true) { ChipLogError(chipTool, "Error: The test was expecting a failure callback. Got success callback"); runner->SetCommandExitStatus(CHIP_ERROR_INTERNAL); diff --git a/src/controller/data_model/gen/CHIPClusters.cpp b/src/controller/data_model/gen/CHIPClusters.cpp index 935516ac8c0136..2e1a33f5976c75 100644 --- a/src/controller/data_model/gen/CHIPClusters.cpp +++ b/src/controller/data_model/gen/CHIPClusters.cpp @@ -1368,258 +1368,6 @@ CHIP_ERROR BridgedDeviceBasicCluster::ReadAttributeClusterRevision(Callback::Can } // ColorControl Cluster Commands -CHIP_ERROR ColorControlCluster::ColorLoopSet(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t updateFlags, uint8_t action, uint8_t direction, uint16_t time, - uint16_t startHue, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - app::CommandSender * sender = nullptr; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kColorLoopSetCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - - SuccessOrExit(err = chip::app::InteractionModelEngine::GetInstance()->NewCommandSender(&sender)); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataElementTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // updateFlags: colorLoopUpdateFlags - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), updateFlags)); - // action: colorLoopAction - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), action)); - // direction: colorLoopDirection - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), direction)); - // time: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), time)); - // startHue: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), startHue)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender, onSuccessCallback, onFailureCallback); - - err = mDevice->SendCommands(sender); - -exit: - // On error, we are responsible to close the sender. - if (err != CHIP_NO_ERROR && sender != nullptr) - { - sender->Shutdown(); - } - return err; -} - -CHIP_ERROR ColorControlCluster::EnhancedMoveHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t moveMode, uint16_t rate, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - app::CommandSender * sender = nullptr; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kEnhancedMoveHueCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - - SuccessOrExit(err = chip::app::InteractionModelEngine::GetInstance()->NewCommandSender(&sender)); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataElementTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // moveMode: hueMoveMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), moveMode)); - // rate: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), rate)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender, onSuccessCallback, onFailureCallback); - - err = mDevice->SendCommands(sender); - -exit: - // On error, we are responsible to close the sender. - if (err != CHIP_NO_ERROR && sender != nullptr) - { - sender->Shutdown(); - } - return err; -} - -CHIP_ERROR ColorControlCluster::EnhancedMoveToHue(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t enhancedHue, uint8_t direction, - uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - app::CommandSender * sender = nullptr; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kEnhancedMoveToHueCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - - SuccessOrExit(err = chip::app::InteractionModelEngine::GetInstance()->NewCommandSender(&sender)); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataElementTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // enhancedHue: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), enhancedHue)); - // direction: hueDirection - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), direction)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender, onSuccessCallback, onFailureCallback); - - err = mDevice->SendCommands(sender); - -exit: - // On error, we are responsible to close the sender. - if (err != CHIP_NO_ERROR && sender != nullptr) - { - sender->Shutdown(); - } - return err; -} - -CHIP_ERROR ColorControlCluster::EnhancedMoveToHueAndSaturation(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback, uint16_t enhancedHue, - uint8_t saturation, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - app::CommandSender * sender = nullptr; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kEnhancedMoveToHueAndSaturationCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - - SuccessOrExit(err = chip::app::InteractionModelEngine::GetInstance()->NewCommandSender(&sender)); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataElementTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // enhancedHue: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), enhancedHue)); - // saturation: int8u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), saturation)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender, onSuccessCallback, onFailureCallback); - - err = mDevice->SendCommands(sender); - -exit: - // On error, we are responsible to close the sender. - if (err != CHIP_NO_ERROR && sender != nullptr) - { - sender->Shutdown(); - } - return err; -} - -CHIP_ERROR ColorControlCluster::EnhancedStepHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint8_t stepMode, uint16_t stepSize, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - app::CommandSender * sender = nullptr; - TLV::TLVWriter * writer = nullptr; - uint8_t argSeqNumber = 0; - - // Used when encoding non-empty command. Suppress error message when encoding empty commands. - (void) writer; - (void) argSeqNumber; - - VerifyOrReturnError(mDevice != nullptr, CHIP_ERROR_INCORRECT_STATE); - - app::CommandPathParams cmdParams = { mEndpoint, /* group id */ 0, mClusterId, kEnhancedStepHueCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - - SuccessOrExit(err = chip::app::InteractionModelEngine::GetInstance()->NewCommandSender(&sender)); - - SuccessOrExit(err = sender->PrepareCommand(cmdParams)); - - VerifyOrExit((writer = sender->GetCommandDataElementTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // stepMode: hueStepMode - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepMode)); - // stepSize: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), stepSize)); - // transitionTime: int16u - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), transitionTime)); - // optionsMask: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsMask)); - // optionsOverride: bitmap8 - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), optionsOverride)); - - SuccessOrExit(err = sender->FinishCommand()); - - // #6308: This is a temporary solution before we fully support IM on application side and should be replaced by IMDelegate. - mDevice->AddIMResponseHandler(sender, onSuccessCallback, onFailureCallback); - - err = mDevice->SendCommands(sender); - -exit: - // On error, we are responsible to close the sender. - if (err != CHIP_NO_ERROR && sender != nullptr) - { - sender->Shutdown(); - } - return err; -} - CHIP_ERROR ColorControlCluster::MoveColor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, int16_t rateX, int16_t rateY, uint8_t optionsMask, uint8_t optionsOverride) { @@ -2971,102 +2719,6 @@ CHIP_ERROR ColorControlCluster::WriteAttributeColorPointBIntensity(Callback::Can return SendCommand(seqNum, std::move(encodedCommand), onSuccessCallback, onFailureCallback); } -CHIP_ERROR ColorControlCluster::ReadAttributeEnhancedCurrentHue(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::AttributePathParams attributePath; - attributePath.mEndpointId = mEndpoint; - attributePath.mClusterId = mClusterId; - attributePath.mFieldId = 0x4000; - attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); - return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, - BasicAttributeFilter); -} - -CHIP_ERROR ColorControlCluster::ReadAttributeEnhancedColorMode(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::AttributePathParams attributePath; - attributePath.mEndpointId = mEndpoint; - attributePath.mClusterId = mClusterId; - attributePath.mFieldId = 0x4001; - attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); - return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, - BasicAttributeFilter); -} - -CHIP_ERROR ColorControlCluster::ReadAttributeColorLoopActive(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::AttributePathParams attributePath; - attributePath.mEndpointId = mEndpoint; - attributePath.mClusterId = mClusterId; - attributePath.mFieldId = 0x4002; - attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); - return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, - BasicAttributeFilter); -} - -CHIP_ERROR ColorControlCluster::ReadAttributeColorLoopDirection(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::AttributePathParams attributePath; - attributePath.mEndpointId = mEndpoint; - attributePath.mClusterId = mClusterId; - attributePath.mFieldId = 0x4003; - attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); - return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, - BasicAttributeFilter); -} - -CHIP_ERROR ColorControlCluster::ReadAttributeColorLoopTime(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::AttributePathParams attributePath; - attributePath.mEndpointId = mEndpoint; - attributePath.mClusterId = mClusterId; - attributePath.mFieldId = 0x4004; - attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); - return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, - BasicAttributeFilter); -} - -CHIP_ERROR ColorControlCluster::ReadAttributeColorCapabilities(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::AttributePathParams attributePath; - attributePath.mEndpointId = mEndpoint; - attributePath.mClusterId = mClusterId; - attributePath.mFieldId = 0x400A; - attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); - return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, - BasicAttributeFilter); -} - -CHIP_ERROR ColorControlCluster::ReadAttributeColorTempPhysicalMin(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::AttributePathParams attributePath; - attributePath.mEndpointId = mEndpoint; - attributePath.mClusterId = mClusterId; - attributePath.mFieldId = 0x400B; - attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); - return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, - BasicAttributeFilter); -} - -CHIP_ERROR ColorControlCluster::ReadAttributeColorTempPhysicalMax(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback) -{ - chip::app::AttributePathParams attributePath; - attributePath.mEndpointId = mEndpoint; - attributePath.mClusterId = mClusterId; - attributePath.mFieldId = 0x400C; - attributePath.mFlags.Set(chip::app::AttributePathParams::Flags::kFieldIdValid); - return mDevice->SendReadAttributeRequest(attributePath, onSuccessCallback, onFailureCallback, - BasicAttributeFilter); -} - CHIP_ERROR ColorControlCluster::ReadAttributeCoupleColorTempToLevelMinMireds(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) { diff --git a/src/controller/data_model/gen/CHIPClusters.h b/src/controller/data_model/gen/CHIPClusters.h index 38411658ae6a20..1a1c3ad87172ca 100644 --- a/src/controller/data_model/gen/CHIPClusters.h +++ b/src/controller/data_model/gen/CHIPClusters.h @@ -314,19 +314,6 @@ class DLL_EXPORT ColorControlCluster : public ClusterBase ~ColorControlCluster() {} // Cluster Commands - CHIP_ERROR ColorLoopSet(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t updateFlags, - uint8_t action, uint8_t direction, uint16_t time, uint16_t startHue, uint8_t optionsMask, - uint8_t optionsOverride); - CHIP_ERROR EnhancedMoveHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t moveMode, - uint16_t rate, uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR EnhancedMoveToHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t enhancedHue, uint8_t direction, uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride); - CHIP_ERROR EnhancedMoveToHueAndSaturation(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - uint16_t enhancedHue, uint8_t saturation, uint16_t transitionTime, - uint8_t optionsMask, uint8_t optionsOverride); - CHIP_ERROR EnhancedStepHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, uint8_t stepMode, - uint16_t stepSize, uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride); CHIP_ERROR MoveColor(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, int16_t rateX, int16_t rateY, uint8_t optionsMask, uint8_t optionsOverride); CHIP_ERROR MoveColorTemperature(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, @@ -405,16 +392,6 @@ class DLL_EXPORT ColorControlCluster : public ClusterBase CHIP_ERROR ReadAttributeColorPointBY(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); CHIP_ERROR ReadAttributeColorPointBIntensity(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR ReadAttributeEnhancedCurrentHue(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR ReadAttributeEnhancedColorMode(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR ReadAttributeColorLoopActive(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR ReadAttributeColorLoopDirection(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR ReadAttributeColorLoopTime(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR ReadAttributeColorCapabilities(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); - CHIP_ERROR ReadAttributeColorTempPhysicalMin(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback); - CHIP_ERROR ReadAttributeColorTempPhysicalMax(Callback::Cancelable * onSuccessCallback, - Callback::Cancelable * onFailureCallback); CHIP_ERROR ReadAttributeCoupleColorTempToLevelMinMireds(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback); CHIP_ERROR ReadAttributeStartUpColorTemperatureMireds(Callback::Cancelable * onSuccessCallback, @@ -465,25 +442,20 @@ class DLL_EXPORT ColorControlCluster : public ClusterBase CHIP_ERROR ReportAttributeColorTemperature(Callback::Cancelable * onReportCallback); private: - static constexpr CommandId kColorLoopSetCommandId = 0x44; - static constexpr CommandId kEnhancedMoveHueCommandId = 0x41; - static constexpr CommandId kEnhancedMoveToHueCommandId = 0x40; - static constexpr CommandId kEnhancedMoveToHueAndSaturationCommandId = 0x43; - static constexpr CommandId kEnhancedStepHueCommandId = 0x42; - static constexpr CommandId kMoveColorCommandId = 0x08; - static constexpr CommandId kMoveColorTemperatureCommandId = 0x4B; - static constexpr CommandId kMoveHueCommandId = 0x01; - static constexpr CommandId kMoveSaturationCommandId = 0x04; - static constexpr CommandId kMoveToColorCommandId = 0x07; - static constexpr CommandId kMoveToColorTemperatureCommandId = 0x0A; - static constexpr CommandId kMoveToHueCommandId = 0x00; - static constexpr CommandId kMoveToHueAndSaturationCommandId = 0x06; - static constexpr CommandId kMoveToSaturationCommandId = 0x03; - static constexpr CommandId kStepColorCommandId = 0x09; - static constexpr CommandId kStepColorTemperatureCommandId = 0x4C; - static constexpr CommandId kStepHueCommandId = 0x02; - static constexpr CommandId kStepSaturationCommandId = 0x05; - static constexpr CommandId kStopMoveStepCommandId = 0x47; + static constexpr CommandId kMoveColorCommandId = 0x08; + static constexpr CommandId kMoveColorTemperatureCommandId = 0x4B; + static constexpr CommandId kMoveHueCommandId = 0x01; + static constexpr CommandId kMoveSaturationCommandId = 0x04; + static constexpr CommandId kMoveToColorCommandId = 0x07; + static constexpr CommandId kMoveToColorTemperatureCommandId = 0x0A; + static constexpr CommandId kMoveToHueCommandId = 0x00; + static constexpr CommandId kMoveToHueAndSaturationCommandId = 0x06; + static constexpr CommandId kMoveToSaturationCommandId = 0x03; + static constexpr CommandId kStepColorCommandId = 0x09; + static constexpr CommandId kStepColorTemperatureCommandId = 0x4C; + static constexpr CommandId kStepHueCommandId = 0x02; + static constexpr CommandId kStepSaturationCommandId = 0x05; + static constexpr CommandId kStopMoveStepCommandId = 0x47; }; class DLL_EXPORT ContentLauncherCluster : public ClusterBase diff --git a/src/controller/data_model/gen/IMClusterCommandHandler.cpp b/src/controller/data_model/gen/IMClusterCommandHandler.cpp index 5c4612cabd3cd5..3844dc306b73d4 100644 --- a/src/controller/data_model/gen/IMClusterCommandHandler.cpp +++ b/src/controller/data_model/gen/IMClusterCommandHandler.cpp @@ -273,6 +273,134 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand } // namespace ApplicationLauncher +namespace Basic { + +void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, + TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::Basic::Commands::Ids::Leave: { + + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. +// wasHandled = emberAfBasicClusterLeaveCallback(apCommandObj); + break; + } + case Clusters::Basic::Commands::Ids::ShutDown: { + + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. +// wasHandled = emberAfBasicClusterShutDownCallback(apCommandObj); + break; + } + case Clusters::Basic::Commands::Ids::StartUp: { + + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. +// wasHandled = emberAfBasicClusterStartUpCallback(apCommandObj); + break; + } + default: { + // Unrecognized command ID, error status will apply. + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::Basic::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, + Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::Basic::Id); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::Basic::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, ChipError::FormatError(TLVError), + ChipError::FormatError(TLVUnpackError), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); + } +} + +} // namespace Basic + +namespace Basic { + +void DispatchServerCommand(app::CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, + TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + default: { + // Unrecognized command ID, error status will apply. + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::Basic::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, + Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::Basic::Id); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::Basic::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, ChipError::FormatError(TLVError), + ChipError::FormatError(TLVUnpackError), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); + } +} + +} // namespace Basic + namespace ContentLauncher { void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, @@ -2139,11 +2267,67 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand } break; } - case Clusters::GeneralCommissioning::Commands::Ids::SetRegulatoryConfigResponse: { - expectArgumentCount = 2; - uint8_t errorCode; - const uint8_t * debugText; - bool argExists[2]; + default: { + // Unrecognized command ID, error status will apply. + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::GeneralCommissioning::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, + Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::GeneralCommissioning::Id); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::GeneralCommissioning::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, ChipError::FormatError(TLVError), + ChipError::FormatError(TLVUnpackError), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); + } +} + +} // namespace GeneralCommissioning + +namespace GeneralCommissioning { + +void DispatchServerCommand(app::CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, + TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::GeneralCommissioning::Commands::Ids::ArmFailSafe: { + expectArgumentCount = 3; + uint16_t expiryLengthSeconds; + uint64_t breadcrumb; + uint32_t timeoutMs; + bool argExists[3]; memset(argExists, 0, sizeof argExists); @@ -2156,7 +2340,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) + if (currentDecodeTagId < 3) { if (argExists[currentDecodeTagId]) { @@ -2173,11 +2357,92 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(errorCode); + TLVUnpackError = aDataTlv.Get(expiryLengthSeconds); + break; + case 1: + TLVUnpackError = aDataTlv.Get(breadcrumb); + break; + case 2: + TLVUnpackError = aDataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = + emberAfGeneralCommissioningClusterArmFailSafeCallback(apCommandObj, expiryLengthSeconds, breadcrumb, timeoutMs); + } + break; + } + case Clusters::GeneralCommissioning::Commands::Ids::CommissioningComplete: { + + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfGeneralCommissioningClusterCommissioningCompleteCallback(apCommandObj); + break; + } + case Clusters::GeneralCommissioning::Commands::Ids::SetRegulatoryConfig: { + expectArgumentCount = 4; + uint8_t location; + const uint8_t * countryCode; + uint64_t breadcrumb; + uint32_t timeoutMs; + bool argExists[4]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 4) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(location); break; case 1: // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. - TLVUnpackError = aDataTlv.GetDataPtr(debugText); + TLVUnpackError = aDataTlv.GetDataPtr(countryCode); + break; + case 2: + TLVUnpackError = aDataTlv.Get(breadcrumb); + break; + case 3: + TLVUnpackError = aDataTlv.Get(timeoutMs); break; default: // Unsupported tag, ignore it. @@ -2196,11 +2461,11 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfGeneralCommissioningClusterSetRegulatoryConfigResponseCallback( - apCommandObj, errorCode, const_cast(debugText)); + wasHandled = emberAfGeneralCommissioningClusterSetRegulatoryConfigCallback( + apCommandObj, location, const_cast(countryCode), breadcrumb, timeoutMs); } break; } @@ -2559,9 +2824,9 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand } // namespace Groups -namespace Identify { +namespace Groups { -void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, +void DispatchServerCommand(app::CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) { // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV @@ -2577,10 +2842,11 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand { switch (aCommandId) { - case Clusters::Identify::Commands::Ids::IdentifyQueryResponse: { - expectArgumentCount = 1; - uint16_t timeout; - bool argExists[1]; + case Clusters::Groups::Commands::Ids::AddGroup: { + expectArgumentCount = 2; + uint16_t groupId; + const uint8_t * groupName; + bool argExists[2]; memset(argExists, 0, sizeof argExists); @@ -2593,7 +2859,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) + if (currentDecodeTagId < 2) { if (argExists[currentDecodeTagId]) { @@ -2610,7 +2876,11 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(timeout); + TLVUnpackError = aDataTlv.Get(groupId); + break; + case 1: + // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. + TLVUnpackError = aDataTlv.GetDataPtr(groupName); break; default: // Unsupported tag, ignore it. @@ -2629,72 +2899,18 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfIdentifyClusterIdentifyQueryResponseCallback(apCommandObj, timeout); + wasHandled = emberAfGroupsClusterAddGroupCallback(apCommandObj, groupId, const_cast(groupName)); } break; } - default: { - // Unrecognized command ID, error status will apply. - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::Identify::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, - Protocols::SecureChannel::Id, - Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::Identify::Id); - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::Identify::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, - Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, ChipError::FormatError(TLVError), - ChipError::FormatError(TLVUnpackError), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace Identify - -namespace KeypadInput { - -void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, - TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandId) - { - case Clusters::KeypadInput::Commands::Ids::SendKeyResponse: { - expectArgumentCount = 1; - uint8_t status; - bool argExists[1]; + case Clusters::Groups::Commands::Ids::AddGroupIfIdentifying: { + expectArgumentCount = 2; + uint16_t groupId; + const uint8_t * groupName; + bool argExists[2]; memset(argExists, 0, sizeof argExists); @@ -2707,7 +2923,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) + if (currentDecodeTagId < 2) { if (argExists[currentDecodeTagId]) { @@ -2724,7 +2940,11 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(status); + TLVUnpackError = aDataTlv.Get(groupId); + break; + case 1: + // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. + TLVUnpackError = aDataTlv.GetDataPtr(groupName); break; default: // Unsupported tag, ignore it. @@ -2743,72 +2963,19 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfKeypadInputClusterSendKeyResponseCallback(apCommandObj, status); + wasHandled = + emberAfGroupsClusterAddGroupIfIdentifyingCallback(apCommandObj, groupId, const_cast(groupName)); } break; } - default: { - // Unrecognized command ID, error status will apply. - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::KeypadInput::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, - Protocols::SecureChannel::Id, - Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::KeypadInput::Id); - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::KeypadInput::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, - Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, ChipError::FormatError(TLVError), - ChipError::FormatError(TLVUnpackError), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace KeypadInput - -namespace MediaPlayback { - -void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, - TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandId) - { - case Clusters::MediaPlayback::Commands::Ids::MediaFastForwardResponse: { - expectArgumentCount = 1; - uint8_t mediaPlaybackStatus; - bool argExists[1]; + case Clusters::Groups::Commands::Ids::GetGroupMembership: { + expectArgumentCount = 2; + uint8_t groupCount; + /* TYPE WARNING: array array defaults to */ uint8_t * groupList; + bool argExists[2]; memset(argExists, 0, sizeof argExists); @@ -2821,7 +2988,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) + if (currentDecodeTagId < 2) { if (argExists[currentDecodeTagId]) { @@ -2838,7 +3005,11 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(mediaPlaybackStatus); + TLVUnpackError = aDataTlv.Get(groupCount); + break; + case 1: + // Just for compatibility, we will add array type support in IM later. + TLVUnpackError = aDataTlv.GetDataPtr(const_cast(groupList)); break; default: // Unsupported tag, ignore it. @@ -2857,16 +3028,22 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfMediaPlaybackClusterMediaFastForwardResponseCallback(apCommandObj, mediaPlaybackStatus); + wasHandled = emberAfGroupsClusterGetGroupMembershipCallback(apCommandObj, groupCount, groupList); } break; } - case Clusters::MediaPlayback::Commands::Ids::MediaNextResponse: { + case Clusters::Groups::Commands::Ids::RemoveAllGroups: { + + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfGroupsClusterRemoveAllGroupsCallback(apCommandObj); + break; + } + case Clusters::Groups::Commands::Ids::RemoveGroup: { expectArgumentCount = 1; - uint8_t mediaPlaybackStatus; + uint16_t groupId; bool argExists[1]; memset(argExists, 0, sizeof argExists); @@ -2897,7 +3074,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(mediaPlaybackStatus); + TLVUnpackError = aDataTlv.Get(groupId); break; default: // Unsupported tag, ignore it. @@ -2919,13 +3096,13 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfMediaPlaybackClusterMediaNextResponseCallback(apCommandObj, mediaPlaybackStatus); + wasHandled = emberAfGroupsClusterRemoveGroupCallback(apCommandObj, groupId); } break; } - case Clusters::MediaPlayback::Commands::Ids::MediaPauseResponse: { + case Clusters::Groups::Commands::Ids::ViewGroup: { expectArgumentCount = 1; - uint8_t mediaPlaybackStatus; + uint16_t groupId; bool argExists[1]; memset(argExists, 0, sizeof argExists); @@ -2956,7 +3133,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(mediaPlaybackStatus); + TLVUnpackError = aDataTlv.Get(groupId); break; default: // Unsupported tag, ignore it. @@ -2978,13 +3155,68 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfMediaPlaybackClusterMediaPauseResponseCallback(apCommandObj, mediaPlaybackStatus); + wasHandled = emberAfGroupsClusterViewGroupCallback(apCommandObj, groupId); } break; } - case Clusters::MediaPlayback::Commands::Ids::MediaPlayResponse: { + default: { + // Unrecognized command ID, error status will apply. + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::Groups::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, + Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::Groups::Id); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::Groups::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, ChipError::FormatError(TLVError), + ChipError::FormatError(TLVUnpackError), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); + } +} + +} // namespace Groups + +namespace Identify { + +void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, + TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::Identify::Commands::Ids::IdentifyQueryResponse: { expectArgumentCount = 1; - uint8_t mediaPlaybackStatus; + uint16_t timeout; bool argExists[1]; memset(argExists, 0, sizeof argExists); @@ -3015,7 +3247,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(mediaPlaybackStatus); + TLVUnpackError = aDataTlv.Get(timeout); break; default: // Unsupported tag, ignore it. @@ -3037,18 +3269,73 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfMediaPlaybackClusterMediaPlayResponseCallback(apCommandObj, mediaPlaybackStatus); + wasHandled = emberAfIdentifyClusterIdentifyQueryResponseCallback(apCommandObj, timeout); } break; } - case Clusters::MediaPlayback::Commands::Ids::MediaPreviousResponse: { - expectArgumentCount = 1; - uint8_t mediaPlaybackStatus; - bool argExists[1]; - - memset(argExists, 0, sizeof argExists); + default: { + // Unrecognized command ID, error status will apply. + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::Identify::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, + Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::Identify::Id); + return; + } + } + } - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::Identify::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, ChipError::FormatError(TLVError), + ChipError::FormatError(TLVUnpackError), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); + } +} + +} // namespace Identify + +namespace KeypadInput { + +void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, + TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::KeypadInput::Commands::Ids::SendKeyResponse: { + expectArgumentCount = 1; + uint8_t status; + bool argExists[1]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) { // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. @@ -3074,7 +3361,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(mediaPlaybackStatus); + TLVUnpackError = aDataTlv.Get(status); break; default: // Unsupported tag, ignore it. @@ -3096,14 +3383,72 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfMediaPlaybackClusterMediaPreviousResponseCallback(apCommandObj, mediaPlaybackStatus); + wasHandled = emberAfKeypadInputClusterSendKeyResponseCallback(apCommandObj, status); } break; } - case Clusters::MediaPlayback::Commands::Ids::MediaRewindResponse: { - expectArgumentCount = 1; - uint8_t mediaPlaybackStatus; - bool argExists[1]; + default: { + // Unrecognized command ID, error status will apply. + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::KeypadInput::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, + Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::KeypadInput::Id); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::KeypadInput::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, ChipError::FormatError(TLVError), + ChipError::FormatError(TLVUnpackError), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); + } +} + +} // namespace KeypadInput + +namespace LevelControl { + +void DispatchServerCommand(app::CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, + TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::LevelControl::Commands::Ids::Move: { + expectArgumentCount = 4; + uint8_t moveMode; + uint8_t rate; + uint8_t optionMask; + uint8_t optionOverride; + bool argExists[4]; memset(argExists, 0, sizeof argExists); @@ -3116,7 +3461,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) + if (currentDecodeTagId < 4) { if (argExists[currentDecodeTagId]) { @@ -3133,7 +3478,16 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(mediaPlaybackStatus); + TLVUnpackError = aDataTlv.Get(moveMode); + break; + case 1: + TLVUnpackError = aDataTlv.Get(rate); + break; + case 2: + TLVUnpackError = aDataTlv.Get(optionMask); + break; + case 3: + TLVUnpackError = aDataTlv.Get(optionOverride); break; default: // Unsupported tag, ignore it. @@ -3152,17 +3506,20 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfMediaPlaybackClusterMediaRewindResponseCallback(apCommandObj, mediaPlaybackStatus); + wasHandled = emberAfLevelControlClusterMoveCallback(apCommandObj, moveMode, rate, optionMask, optionOverride); } break; } - case Clusters::MediaPlayback::Commands::Ids::MediaSeekResponse: { - expectArgumentCount = 1; - uint8_t mediaPlaybackStatus; - bool argExists[1]; + case Clusters::LevelControl::Commands::Ids::MoveToLevel: { + expectArgumentCount = 4; + uint8_t level; + uint16_t transitionTime; + uint8_t optionMask; + uint8_t optionOverride; + bool argExists[4]; memset(argExists, 0, sizeof argExists); @@ -3175,7 +3532,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) + if (currentDecodeTagId < 4) { if (argExists[currentDecodeTagId]) { @@ -3192,7 +3549,16 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(mediaPlaybackStatus); + TLVUnpackError = aDataTlv.Get(level); + break; + case 1: + TLVUnpackError = aDataTlv.Get(transitionTime); + break; + case 2: + TLVUnpackError = aDataTlv.Get(optionMask); + break; + case 3: + TLVUnpackError = aDataTlv.Get(optionOverride); break; default: // Unsupported tag, ignore it. @@ -3211,17 +3577,19 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfMediaPlaybackClusterMediaSeekResponseCallback(apCommandObj, mediaPlaybackStatus); + wasHandled = + emberAfLevelControlClusterMoveToLevelCallback(apCommandObj, level, transitionTime, optionMask, optionOverride); } break; } - case Clusters::MediaPlayback::Commands::Ids::MediaSkipBackwardResponse: { - expectArgumentCount = 1; - uint8_t mediaPlaybackStatus; - bool argExists[1]; + case Clusters::LevelControl::Commands::Ids::MoveToLevelWithOnOff: { + expectArgumentCount = 2; + uint8_t level; + uint16_t transitionTime; + bool argExists[2]; memset(argExists, 0, sizeof argExists); @@ -3234,7 +3602,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) + if (currentDecodeTagId < 2) { if (argExists[currentDecodeTagId]) { @@ -3251,7 +3619,10 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(mediaPlaybackStatus); + TLVUnpackError = aDataTlv.Get(level); + break; + case 1: + TLVUnpackError = aDataTlv.Get(transitionTime); break; default: // Unsupported tag, ignore it. @@ -3270,17 +3641,18 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfMediaPlaybackClusterMediaSkipBackwardResponseCallback(apCommandObj, mediaPlaybackStatus); + wasHandled = emberAfLevelControlClusterMoveToLevelWithOnOffCallback(apCommandObj, level, transitionTime); } break; } - case Clusters::MediaPlayback::Commands::Ids::MediaSkipForwardResponse: { - expectArgumentCount = 1; - uint8_t mediaPlaybackStatus; - bool argExists[1]; + case Clusters::LevelControl::Commands::Ids::MoveWithOnOff: { + expectArgumentCount = 2; + uint8_t moveMode; + uint8_t rate; + bool argExists[2]; memset(argExists, 0, sizeof argExists); @@ -3293,7 +3665,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) + if (currentDecodeTagId < 2) { if (argExists[currentDecodeTagId]) { @@ -3310,7 +3682,10 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(mediaPlaybackStatus); + TLVUnpackError = aDataTlv.Get(moveMode); + break; + case 1: + TLVUnpackError = aDataTlv.Get(rate); break; default: // Unsupported tag, ignore it. @@ -3329,17 +3704,21 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfMediaPlaybackClusterMediaSkipForwardResponseCallback(apCommandObj, mediaPlaybackStatus); + wasHandled = emberAfLevelControlClusterMoveWithOnOffCallback(apCommandObj, moveMode, rate); } break; } - case Clusters::MediaPlayback::Commands::Ids::MediaStartOverResponse: { - expectArgumentCount = 1; - uint8_t mediaPlaybackStatus; - bool argExists[1]; + case Clusters::LevelControl::Commands::Ids::Step: { + expectArgumentCount = 5; + uint8_t stepMode; + uint8_t stepSize; + uint16_t transitionTime; + uint8_t optionMask; + uint8_t optionOverride; + bool argExists[5]; memset(argExists, 0, sizeof argExists); @@ -3352,7 +3731,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) + if (currentDecodeTagId < 5) { if (argExists[currentDecodeTagId]) { @@ -3369,7 +3748,19 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(mediaPlaybackStatus); + TLVUnpackError = aDataTlv.Get(stepMode); + break; + case 1: + TLVUnpackError = aDataTlv.Get(stepSize); + break; + case 2: + TLVUnpackError = aDataTlv.Get(transitionTime); + break; + case 3: + TLVUnpackError = aDataTlv.Get(optionMask); + break; + case 4: + TLVUnpackError = aDataTlv.Get(optionOverride); break; default: // Unsupported tag, ignore it. @@ -3388,17 +3779,20 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfMediaPlaybackClusterMediaStartOverResponseCallback(apCommandObj, mediaPlaybackStatus); + wasHandled = emberAfLevelControlClusterStepCallback(apCommandObj, stepMode, stepSize, transitionTime, optionMask, + optionOverride); } break; } - case Clusters::MediaPlayback::Commands::Ids::MediaStopResponse: { - expectArgumentCount = 1; - uint8_t mediaPlaybackStatus; - bool argExists[1]; + case Clusters::LevelControl::Commands::Ids::StepWithOnOff: { + expectArgumentCount = 3; + uint8_t stepMode; + uint8_t stepSize; + uint16_t transitionTime; + bool argExists[3]; memset(argExists, 0, sizeof argExists); @@ -3411,7 +3805,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) + if (currentDecodeTagId < 3) { if (argExists[currentDecodeTagId]) { @@ -3428,7 +3822,13 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(mediaPlaybackStatus); + TLVUnpackError = aDataTlv.Get(stepMode); + break; + case 1: + TLVUnpackError = aDataTlv.Get(stepSize); + break; + case 2: + TLVUnpackError = aDataTlv.Get(transitionTime); break; default: // Unsupported tag, ignore it. @@ -3447,75 +3847,20 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfMediaPlaybackClusterMediaStopResponseCallback(apCommandObj, mediaPlaybackStatus); + wasHandled = emberAfLevelControlClusterStepWithOnOffCallback(apCommandObj, stepMode, stepSize, transitionTime); } break; } - default: { - // Unrecognized command ID, error status will apply. - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::MediaPlayback::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, - Protocols::SecureChannel::Id, - Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::MediaPlayback::Id); - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::MediaPlayback::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, - Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, ChipError::FormatError(TLVError), - ChipError::FormatError(TLVUnpackError), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace MediaPlayback + case Clusters::LevelControl::Commands::Ids::Stop: { + expectArgumentCount = 2; + uint8_t optionMask; + uint8_t optionOverride; + bool argExists[2]; -namespace NetworkCommissioning { - -void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, - TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandId) - { - case Clusters::NetworkCommissioning::Commands::Ids::AddThreadNetworkResponse: { - expectArgumentCount = 2; - uint8_t errorCode; - const uint8_t * debugText; - bool argExists[2]; - - memset(argExists, 0, sizeof argExists); + memset(argExists, 0, sizeof argExists); while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) { @@ -3543,11 +3888,10 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(errorCode); + TLVUnpackError = aDataTlv.Get(optionMask); break; case 1: - // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. - TLVUnpackError = aDataTlv.GetDataPtr(debugText); + TLVUnpackError = aDataTlv.Get(optionOverride); break; default: // Unsupported tag, ignore it. @@ -3569,16 +3913,75 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfNetworkCommissioningClusterAddThreadNetworkResponseCallback(apCommandObj, errorCode, - const_cast(debugText)); + wasHandled = emberAfLevelControlClusterStopCallback(apCommandObj, optionMask, optionOverride); } break; } - case Clusters::NetworkCommissioning::Commands::Ids::AddWiFiNetworkResponse: { - expectArgumentCount = 2; - uint8_t errorCode; - const uint8_t * debugText; - bool argExists[2]; + case Clusters::LevelControl::Commands::Ids::StopWithOnOff: { + + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfLevelControlClusterStopWithOnOffCallback(apCommandObj); + break; + } + default: { + // Unrecognized command ID, error status will apply. + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::LevelControl::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, + Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::LevelControl::Id); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::LevelControl::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, ChipError::FormatError(TLVError), + ChipError::FormatError(TLVUnpackError), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); + } +} + +} // namespace LevelControl + +namespace MediaPlayback { + +void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, + TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::MediaPlayback::Commands::Ids::MediaFastForwardResponse: { + expectArgumentCount = 1; + uint8_t mediaPlaybackStatus; + bool argExists[1]; memset(argExists, 0, sizeof argExists); @@ -3591,7 +3994,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) + if (currentDecodeTagId < 1) { if (argExists[currentDecodeTagId]) { @@ -3608,11 +4011,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(errorCode); - break; - case 1: - // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. - TLVUnpackError = aDataTlv.GetDataPtr(debugText); + TLVUnpackError = aDataTlv.Get(mediaPlaybackStatus); break; default: // Unsupported tag, ignore it. @@ -3631,19 +4030,17 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfNetworkCommissioningClusterAddWiFiNetworkResponseCallback(apCommandObj, errorCode, - const_cast(debugText)); + wasHandled = emberAfMediaPlaybackClusterMediaFastForwardResponseCallback(apCommandObj, mediaPlaybackStatus); } break; } - case Clusters::NetworkCommissioning::Commands::Ids::DisableNetworkResponse: { - expectArgumentCount = 2; - uint8_t errorCode; - const uint8_t * debugText; - bool argExists[2]; + case Clusters::MediaPlayback::Commands::Ids::MediaNextResponse: { + expectArgumentCount = 1; + uint8_t mediaPlaybackStatus; + bool argExists[1]; memset(argExists, 0, sizeof argExists); @@ -3656,7 +4053,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) + if (currentDecodeTagId < 1) { if (argExists[currentDecodeTagId]) { @@ -3673,11 +4070,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(errorCode); - break; - case 1: - // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. - TLVUnpackError = aDataTlv.GetDataPtr(debugText); + TLVUnpackError = aDataTlv.Get(mediaPlaybackStatus); break; default: // Unsupported tag, ignore it. @@ -3696,19 +4089,17 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfNetworkCommissioningClusterDisableNetworkResponseCallback(apCommandObj, errorCode, - const_cast(debugText)); + wasHandled = emberAfMediaPlaybackClusterMediaNextResponseCallback(apCommandObj, mediaPlaybackStatus); } break; } - case Clusters::NetworkCommissioning::Commands::Ids::EnableNetworkResponse: { - expectArgumentCount = 2; - uint8_t errorCode; - const uint8_t * debugText; - bool argExists[2]; + case Clusters::MediaPlayback::Commands::Ids::MediaPauseResponse: { + expectArgumentCount = 1; + uint8_t mediaPlaybackStatus; + bool argExists[1]; memset(argExists, 0, sizeof argExists); @@ -3721,7 +4112,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) + if (currentDecodeTagId < 1) { if (argExists[currentDecodeTagId]) { @@ -3738,11 +4129,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(errorCode); - break; - case 1: - // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. - TLVUnpackError = aDataTlv.GetDataPtr(debugText); + TLVUnpackError = aDataTlv.Get(mediaPlaybackStatus); break; default: // Unsupported tag, ignore it. @@ -3761,19 +4148,17 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfNetworkCommissioningClusterEnableNetworkResponseCallback(apCommandObj, errorCode, - const_cast(debugText)); + wasHandled = emberAfMediaPlaybackClusterMediaPauseResponseCallback(apCommandObj, mediaPlaybackStatus); } break; } - case Clusters::NetworkCommissioning::Commands::Ids::RemoveNetworkResponse: { - expectArgumentCount = 2; - uint8_t errorCode; - const uint8_t * debugText; - bool argExists[2]; + case Clusters::MediaPlayback::Commands::Ids::MediaPlayResponse: { + expectArgumentCount = 1; + uint8_t mediaPlaybackStatus; + bool argExists[1]; memset(argExists, 0, sizeof argExists); @@ -3786,7 +4171,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) + if (currentDecodeTagId < 1) { if (argExists[currentDecodeTagId]) { @@ -3803,11 +4188,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(errorCode); - break; - case 1: - // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. - TLVUnpackError = aDataTlv.GetDataPtr(debugText); + TLVUnpackError = aDataTlv.Get(mediaPlaybackStatus); break; default: // Unsupported tag, ignore it. @@ -3826,21 +4207,17 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfNetworkCommissioningClusterRemoveNetworkResponseCallback(apCommandObj, errorCode, - const_cast(debugText)); + wasHandled = emberAfMediaPlaybackClusterMediaPlayResponseCallback(apCommandObj, mediaPlaybackStatus); } break; } - case Clusters::NetworkCommissioning::Commands::Ids::ScanNetworksResponse: { - expectArgumentCount = 4; - uint8_t errorCode; - const uint8_t * debugText; - /* TYPE WARNING: array array defaults to */ uint8_t * wifiScanResults; - /* TYPE WARNING: array array defaults to */ uint8_t * threadScanResults; - bool argExists[4]; + case Clusters::MediaPlayback::Commands::Ids::MediaPreviousResponse: { + expectArgumentCount = 1; + uint8_t mediaPlaybackStatus; + bool argExists[1]; memset(argExists, 0, sizeof argExists); @@ -3853,7 +4230,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 4) + if (currentDecodeTagId < 1) { if (argExists[currentDecodeTagId]) { @@ -3870,19 +4247,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(errorCode); - break; - case 1: - // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. - TLVUnpackError = aDataTlv.GetDataPtr(debugText); - break; - case 2: - // Just for compatibility, we will add array type support in IM later. - TLVUnpackError = aDataTlv.GetDataPtr(const_cast(wifiScanResults)); - break; - case 3: - // Just for compatibility, we will add array type support in IM later. - TLVUnpackError = aDataTlv.GetDataPtr(const_cast(threadScanResults)); + TLVUnpackError = aDataTlv.Get(mediaPlaybackStatus); break; default: // Unsupported tag, ignore it. @@ -3901,19 +4266,17 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfNetworkCommissioningClusterScanNetworksResponseCallback( - apCommandObj, errorCode, const_cast(debugText), wifiScanResults, threadScanResults); + wasHandled = emberAfMediaPlaybackClusterMediaPreviousResponseCallback(apCommandObj, mediaPlaybackStatus); } break; } - case Clusters::NetworkCommissioning::Commands::Ids::UpdateThreadNetworkResponse: { - expectArgumentCount = 2; - uint8_t errorCode; - const uint8_t * debugText; - bool argExists[2]; + case Clusters::MediaPlayback::Commands::Ids::MediaRewindResponse: { + expectArgumentCount = 1; + uint8_t mediaPlaybackStatus; + bool argExists[1]; memset(argExists, 0, sizeof argExists); @@ -3926,7 +4289,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) + if (currentDecodeTagId < 1) { if (argExists[currentDecodeTagId]) { @@ -3943,11 +4306,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(errorCode); - break; - case 1: - // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. - TLVUnpackError = aDataTlv.GetDataPtr(debugText); + TLVUnpackError = aDataTlv.Get(mediaPlaybackStatus); break; default: // Unsupported tag, ignore it. @@ -3966,19 +4325,17 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfNetworkCommissioningClusterUpdateThreadNetworkResponseCallback( - apCommandObj, errorCode, const_cast(debugText)); + wasHandled = emberAfMediaPlaybackClusterMediaRewindResponseCallback(apCommandObj, mediaPlaybackStatus); } break; } - case Clusters::NetworkCommissioning::Commands::Ids::UpdateWiFiNetworkResponse: { - expectArgumentCount = 2; - uint8_t errorCode; - const uint8_t * debugText; - bool argExists[2]; + case Clusters::MediaPlayback::Commands::Ids::MediaSeekResponse: { + expectArgumentCount = 1; + uint8_t mediaPlaybackStatus; + bool argExists[1]; memset(argExists, 0, sizeof argExists); @@ -3991,7 +4348,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) + if (currentDecodeTagId < 1) { if (argExists[currentDecodeTagId]) { @@ -4008,11 +4365,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(errorCode); - break; - case 1: - // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. - TLVUnpackError = aDataTlv.GetDataPtr(debugText); + TLVUnpackError = aDataTlv.Get(mediaPlaybackStatus); break; default: // Unsupported tag, ignore it. @@ -4031,34 +4384,2226 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfNetworkCommissioningClusterUpdateWiFiNetworkResponseCallback(apCommandObj, errorCode, - const_cast(debugText)); + wasHandled = emberAfMediaPlaybackClusterMediaSeekResponseCallback(apCommandObj, mediaPlaybackStatus); } break; } - default: { - // Unrecognized command ID, error status will apply. - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::NetworkCommissioning::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, - Protocols::SecureChannel::Id, - Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::NetworkCommissioning::Id); - return; - } - } - } + case Clusters::MediaPlayback::Commands::Ids::MediaSkipBackwardResponse: { + expectArgumentCount = 1; + uint8_t mediaPlaybackStatus; + bool argExists[1]; - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - chip::app::CommandPathParams returnStatusParam = { aEndpointId, + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 1) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(mediaPlaybackStatus); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfMediaPlaybackClusterMediaSkipBackwardResponseCallback(apCommandObj, mediaPlaybackStatus); + } + break; + } + case Clusters::MediaPlayback::Commands::Ids::MediaSkipForwardResponse: { + expectArgumentCount = 1; + uint8_t mediaPlaybackStatus; + bool argExists[1]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 1) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(mediaPlaybackStatus); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfMediaPlaybackClusterMediaSkipForwardResponseCallback(apCommandObj, mediaPlaybackStatus); + } + break; + } + case Clusters::MediaPlayback::Commands::Ids::MediaStartOverResponse: { + expectArgumentCount = 1; + uint8_t mediaPlaybackStatus; + bool argExists[1]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 1) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(mediaPlaybackStatus); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfMediaPlaybackClusterMediaStartOverResponseCallback(apCommandObj, mediaPlaybackStatus); + } + break; + } + case Clusters::MediaPlayback::Commands::Ids::MediaStopResponse: { + expectArgumentCount = 1; + uint8_t mediaPlaybackStatus; + bool argExists[1]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 1) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(mediaPlaybackStatus); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfMediaPlaybackClusterMediaStopResponseCallback(apCommandObj, mediaPlaybackStatus); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::MediaPlayback::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, + Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::MediaPlayback::Id); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::MediaPlayback::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, ChipError::FormatError(TLVError), + ChipError::FormatError(TLVUnpackError), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); + } +} + +} // namespace MediaPlayback + +namespace NetworkCommissioning { + +void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, + TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::NetworkCommissioning::Commands::Ids::DisableNetworkResponse: { + expectArgumentCount = 2; + uint8_t errorCode; + const uint8_t * debugText; + bool argExists[2]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 2) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(errorCode); + break; + case 1: + // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. + TLVUnpackError = aDataTlv.GetDataPtr(debugText); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfNetworkCommissioningClusterDisableNetworkResponseCallback(apCommandObj, errorCode, + const_cast(debugText)); + } + break; + } + case Clusters::NetworkCommissioning::Commands::Ids::EnableNetworkResponse: { + expectArgumentCount = 2; + uint8_t errorCode; + const uint8_t * debugText; + bool argExists[2]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 2) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(errorCode); + break; + case 1: + // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. + TLVUnpackError = aDataTlv.GetDataPtr(debugText); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfNetworkCommissioningClusterEnableNetworkResponseCallback(apCommandObj, errorCode, + const_cast(debugText)); + } + break; + } + case Clusters::NetworkCommissioning::Commands::Ids::RemoveNetworkResponse: { + expectArgumentCount = 2; + uint8_t errorCode; + const uint8_t * debugText; + bool argExists[2]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 2) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(errorCode); + break; + case 1: + // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. + TLVUnpackError = aDataTlv.GetDataPtr(debugText); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfNetworkCommissioningClusterRemoveNetworkResponseCallback(apCommandObj, errorCode, + const_cast(debugText)); + } + break; + } + case Clusters::NetworkCommissioning::Commands::Ids::ScanNetworksResponse: { + expectArgumentCount = 4; + uint8_t errorCode; + const uint8_t * debugText; + /* TYPE WARNING: array array defaults to */ uint8_t * wifiScanResults; + /* TYPE WARNING: array array defaults to */ uint8_t * threadScanResults; + bool argExists[4]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 4) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(errorCode); + break; + case 1: + // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. + TLVUnpackError = aDataTlv.GetDataPtr(debugText); + break; + case 2: + // Just for compatibility, we will add array type support in IM later. + TLVUnpackError = aDataTlv.GetDataPtr(const_cast(wifiScanResults)); + break; + case 3: + // Just for compatibility, we will add array type support in IM later. + TLVUnpackError = aDataTlv.GetDataPtr(const_cast(threadScanResults)); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfNetworkCommissioningClusterScanNetworksResponseCallback( + apCommandObj, errorCode, const_cast(debugText), wifiScanResults, threadScanResults); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::NetworkCommissioning::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, + Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::NetworkCommissioning::Id); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::NetworkCommissioning::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, ChipError::FormatError(TLVError), + ChipError::FormatError(TLVUnpackError), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); + } +} + +} // namespace NetworkCommissioning + +namespace NetworkCommissioning { + +void DispatchServerCommand(app::CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, + TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::NetworkCommissioning::Commands::Ids::AddWiFiNetwork: { + expectArgumentCount = 4; + chip::ByteSpan ssid; + chip::ByteSpan credentials; + uint64_t breadcrumb; + uint32_t timeoutMs; + bool argExists[4]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 4) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + ssid = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + case 1: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + credentials = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + case 2: + TLVUnpackError = aDataTlv.Get(breadcrumb); + break; + case 3: + TLVUnpackError = aDataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfNetworkCommissioningClusterAddWiFiNetworkCallback(apCommandObj, ssid, credentials, breadcrumb, + timeoutMs); + } + break; + } + case Clusters::NetworkCommissioning::Commands::Ids::DisableNetwork: { + expectArgumentCount = 3; + chip::ByteSpan networkID; + uint64_t breadcrumb; + uint32_t timeoutMs; + bool argExists[3]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 3) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + networkID = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + case 1: + TLVUnpackError = aDataTlv.Get(breadcrumb); + break; + case 2: + TLVUnpackError = aDataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = + emberAfNetworkCommissioningClusterDisableNetworkCallback(apCommandObj, networkID, breadcrumb, timeoutMs); + } + break; + } + case Clusters::NetworkCommissioning::Commands::Ids::EnableNetwork: { + expectArgumentCount = 3; + chip::ByteSpan networkID; + uint64_t breadcrumb; + uint32_t timeoutMs; + bool argExists[3]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 3) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + networkID = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + case 1: + TLVUnpackError = aDataTlv.Get(breadcrumb); + break; + case 2: + TLVUnpackError = aDataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = + emberAfNetworkCommissioningClusterEnableNetworkCallback(apCommandObj, networkID, breadcrumb, timeoutMs); + } + break; + } + case Clusters::NetworkCommissioning::Commands::Ids::GetLastNetworkCommissioningResult: { + expectArgumentCount = 1; + uint32_t timeoutMs; + bool argExists[1]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 1) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfNetworkCommissioningClusterGetLastNetworkCommissioningResultCallback(apCommandObj, timeoutMs); + } + break; + } + case Clusters::NetworkCommissioning::Commands::Ids::RemoveNetwork: { + expectArgumentCount = 3; + chip::ByteSpan NetworkID; + uint64_t Breadcrumb; + uint32_t TimeoutMs; + bool argExists[3]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 3) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + NetworkID = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + case 1: + TLVUnpackError = aDataTlv.Get(Breadcrumb); + break; + case 2: + TLVUnpackError = aDataTlv.Get(TimeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = + emberAfNetworkCommissioningClusterRemoveNetworkCallback(apCommandObj, NetworkID, Breadcrumb, TimeoutMs); + } + break; + } + case Clusters::NetworkCommissioning::Commands::Ids::ScanNetworks: { + expectArgumentCount = 3; + chip::ByteSpan ssid; + uint64_t breadcrumb; + uint32_t timeoutMs; + bool argExists[3]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 3) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + ssid = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + case 1: + TLVUnpackError = aDataTlv.Get(breadcrumb); + break; + case 2: + TLVUnpackError = aDataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfNetworkCommissioningClusterScanNetworksCallback(apCommandObj, ssid, breadcrumb, timeoutMs); + } + break; + } + case Clusters::NetworkCommissioning::Commands::Ids::UpdateWiFiNetwork: { + expectArgumentCount = 4; + chip::ByteSpan ssid; + chip::ByteSpan credentials; + uint64_t breadcrumb; + uint32_t timeoutMs; + bool argExists[4]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 4) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + ssid = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + case 1: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + credentials = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + case 2: + TLVUnpackError = aDataTlv.Get(breadcrumb); + break; + case 3: + TLVUnpackError = aDataTlv.Get(timeoutMs); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfNetworkCommissioningClusterUpdateWiFiNetworkCallback(apCommandObj, ssid, credentials, + breadcrumb, timeoutMs); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::NetworkCommissioning::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, + Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::NetworkCommissioning::Id); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::NetworkCommissioning::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, ChipError::FormatError(TLVError), + ChipError::FormatError(TLVUnpackError), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); + } +} + +} // namespace NetworkCommissioning + +namespace OtaSoftwareUpdateProvider { + +void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, + TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::OtaSoftwareUpdateProvider::Commands::Ids::ApplyUpdateRequestResponse: { + expectArgumentCount = 2; + uint8_t action; + uint32_t delayedActionTime; + bool argExists[2]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 2) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(action); + break; + case 1: + TLVUnpackError = aDataTlv.Get(delayedActionTime); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfOtaSoftwareUpdateProviderClusterApplyUpdateRequestResponseCallback(apCommandObj, action, + delayedActionTime); + } + break; + } + case Clusters::OtaSoftwareUpdateProvider::Commands::Ids::QueryImageResponse: { + expectArgumentCount = 7; + uint8_t status; + uint32_t delayedActionTime; + const uint8_t * imageURI; + uint32_t softwareVersion; + chip::ByteSpan updateToken; + uint8_t userConsentNeeded; + chip::ByteSpan metadataForRequestor; + bool argExists[7]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 7) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(status); + break; + case 1: + TLVUnpackError = aDataTlv.Get(delayedActionTime); + break; + case 2: + // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. + TLVUnpackError = aDataTlv.GetDataPtr(imageURI); + break; + case 3: + TLVUnpackError = aDataTlv.Get(softwareVersion); + break; + case 4: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + updateToken = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + case 5: + TLVUnpackError = aDataTlv.Get(userConsentNeeded); + break; + case 6: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + metadataForRequestor = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 7 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfOtaSoftwareUpdateProviderClusterQueryImageResponseCallback( + apCommandObj, status, delayedActionTime, const_cast(imageURI), softwareVersion, updateToken, + userConsentNeeded, metadataForRequestor); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::OtaSoftwareUpdateProvider::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, + Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, + Clusters::OtaSoftwareUpdateProvider::Id); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::OtaSoftwareUpdateProvider::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, ChipError::FormatError(TLVError), + ChipError::FormatError(TLVUnpackError), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); + } +} + +} // namespace OtaSoftwareUpdateProvider + +namespace OnOff { + +void DispatchServerCommand(app::CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, + TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::OnOff::Commands::Ids::Off: { + + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfOnOffClusterOffCallback(apCommandObj); + break; + } + case Clusters::OnOff::Commands::Ids::On: { + + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfOnOffClusterOnCallback(apCommandObj); + break; + } + case Clusters::OnOff::Commands::Ids::Toggle: { + + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfOnOffClusterToggleCallback(apCommandObj); + break; + } + default: { + // Unrecognized command ID, error status will apply. + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::OnOff::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, + Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::OnOff::Id); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::OnOff::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, ChipError::FormatError(TLVError), + ChipError::FormatError(TLVUnpackError), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); + } +} + +} // namespace OnOff + +namespace OperationalCredentials { + +void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, + TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::OperationalCredentials::Commands::Ids::OpCSRResponse: { + expectArgumentCount = 6; + chip::ByteSpan CSR; + chip::ByteSpan CSRNonce; + chip::ByteSpan VendorReserved1; + chip::ByteSpan VendorReserved2; + chip::ByteSpan VendorReserved3; + chip::ByteSpan Signature; + bool argExists[6]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 6) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + CSR = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + case 1: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + CSRNonce = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + case 2: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + VendorReserved1 = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + case 3: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + VendorReserved2 = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + case 4: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + VendorReserved3 = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + case 5: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + Signature = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 6 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfOperationalCredentialsClusterOpCSRResponseCallback(apCommandObj, CSR, CSRNonce, VendorReserved1, + VendorReserved2, VendorReserved3, Signature); + } + break; + } + case Clusters::OperationalCredentials::Commands::Ids::OpCertResponse: { + expectArgumentCount = 3; + uint8_t StatusCode; + uint64_t FabricIndex; + const uint8_t * DebugText; + bool argExists[3]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 3) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(StatusCode); + break; + case 1: + TLVUnpackError = aDataTlv.Get(FabricIndex); + break; + case 2: + // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. + TLVUnpackError = aDataTlv.GetDataPtr(DebugText); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfOperationalCredentialsClusterOpCertResponseCallback(apCommandObj, StatusCode, FabricIndex, + const_cast(DebugText)); + } + break; + } + case Clusters::OperationalCredentials::Commands::Ids::SetFabricResponse: { + expectArgumentCount = 1; + chip::FabricId FabricId; + bool argExists[1]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 1) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(FabricId); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfOperationalCredentialsClusterSetFabricResponseCallback(apCommandObj, FabricId); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::OperationalCredentials::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, + Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::OperationalCredentials::Id); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::OperationalCredentials::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, ChipError::FormatError(TLVError), + ChipError::FormatError(TLVUnpackError), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); + } +} + +} // namespace OperationalCredentials + +namespace OperationalCredentials { + +void DispatchServerCommand(app::CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, + TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::OperationalCredentials::Commands::Ids::AddOpCert: { + expectArgumentCount = 4; + chip::ByteSpan NOCArray; + chip::ByteSpan IPKValue; + chip::NodeId CaseAdminNode; + uint16_t AdminVendorId; + bool argExists[4]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 4) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + NOCArray = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + case 1: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + IPKValue = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + case 2: + TLVUnpackError = aDataTlv.Get(CaseAdminNode); + break; + case 3: + TLVUnpackError = aDataTlv.Get(AdminVendorId); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfOperationalCredentialsClusterAddOpCertCallback(apCommandObj, NOCArray, IPKValue, CaseAdminNode, + AdminVendorId); + } + break; + } + case Clusters::OperationalCredentials::Commands::Ids::AddTrustedRootCertificate: { + expectArgumentCount = 1; + chip::ByteSpan RootCertificate; + bool argExists[1]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 1) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + RootCertificate = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfOperationalCredentialsClusterAddTrustedRootCertificateCallback(apCommandObj, RootCertificate); + } + break; + } + case Clusters::OperationalCredentials::Commands::Ids::OpCSRRequest: { + expectArgumentCount = 1; + chip::ByteSpan CSRNonce; + bool argExists[1]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 1) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + CSRNonce = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfOperationalCredentialsClusterOpCSRRequestCallback(apCommandObj, CSRNonce); + } + break; + } + case Clusters::OperationalCredentials::Commands::Ids::RemoveAllFabrics: { + + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfOperationalCredentialsClusterRemoveAllFabricsCallback(apCommandObj); + break; + } + case Clusters::OperationalCredentials::Commands::Ids::RemoveFabric: { + expectArgumentCount = 3; + chip::FabricId FabricId; + chip::NodeId NodeId; + uint16_t VendorId; + bool argExists[3]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 3) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(FabricId); + break; + case 1: + TLVUnpackError = aDataTlv.Get(NodeId); + break; + case 2: + TLVUnpackError = aDataTlv.Get(VendorId); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfOperationalCredentialsClusterRemoveFabricCallback(apCommandObj, FabricId, NodeId, VendorId); + } + break; + } + case Clusters::OperationalCredentials::Commands::Ids::RemoveTrustedRootCertificate: { + expectArgumentCount = 1; + chip::ByteSpan TrustedRootIdentifier; + bool argExists[1]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 1) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: { + const uint8_t * data = nullptr; + TLVUnpackError = aDataTlv.GetDataPtr(data); + TrustedRootIdentifier = chip::ByteSpan(data, aDataTlv.GetLength()); + } + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = + emberAfOperationalCredentialsClusterRemoveTrustedRootCertificateCallback(apCommandObj, TrustedRootIdentifier); + } + break; + } + case Clusters::OperationalCredentials::Commands::Ids::SetFabric: { + expectArgumentCount = 1; + uint16_t VendorId; + bool argExists[1]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 1) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(VendorId); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfOperationalCredentialsClusterSetFabricCallback(apCommandObj, VendorId); + } + break; + } + case Clusters::OperationalCredentials::Commands::Ids::UpdateFabricLabel: { + expectArgumentCount = 1; + const uint8_t * Label; + bool argExists[1]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 1) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. + TLVUnpackError = aDataTlv.GetDataPtr(Label); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = + emberAfOperationalCredentialsClusterUpdateFabricLabelCallback(apCommandObj, const_cast(Label)); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + chip::app::CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::OperationalCredentials::Id, aCommandId, + (chip::app::CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, + Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::OperationalCredentials::Id); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + chip::app::CommandPathParams returnStatusParam = { aEndpointId, 0, // GroupId - Clusters::NetworkCommissioning::Id, aCommandId, + Clusters::OperationalCredentials::Id, aCommandId, (chip::app::CommandPathFlags::kEndpointIdValid) }; apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); @@ -4074,9 +6619,9 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand } } -} // namespace NetworkCommissioning +} // namespace OperationalCredentials -namespace OtaSoftwareUpdateProvider { +namespace Scenes { void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) @@ -4094,11 +6639,12 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand { switch (aCommandId) { - case Clusters::OtaSoftwareUpdateProvider::Commands::Ids::ApplyUpdateRequestResponse: { - expectArgumentCount = 2; - uint8_t action; - uint32_t delayedActionTime; - bool argExists[2]; + case Clusters::Scenes::Commands::Ids::AddSceneResponse: { + expectArgumentCount = 3; + uint8_t status; + uint16_t groupId; + uint8_t sceneId; + bool argExists[3]; memset(argExists, 0, sizeof argExists); @@ -4111,7 +6657,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) + if (currentDecodeTagId < 3) { if (argExists[currentDecodeTagId]) { @@ -4128,10 +6674,13 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(action); + TLVUnpackError = aDataTlv.Get(status); break; case 1: - TLVUnpackError = aDataTlv.Get(delayedActionTime); + TLVUnpackError = aDataTlv.Get(groupId); + break; + case 2: + TLVUnpackError = aDataTlv.Get(sceneId); break; default: // Unsupported tag, ignore it. @@ -4150,24 +6699,21 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOtaSoftwareUpdateProviderClusterApplyUpdateRequestResponseCallback(apCommandObj, action, - delayedActionTime); + wasHandled = emberAfScenesClusterAddSceneResponseCallback(apCommandObj, status, groupId, sceneId); } break; } - case Clusters::OtaSoftwareUpdateProvider::Commands::Ids::QueryImageResponse: { - expectArgumentCount = 7; + case Clusters::Scenes::Commands::Ids::GetSceneMembershipResponse: { + expectArgumentCount = 5; uint8_t status; - uint32_t delayedActionTime; - const uint8_t * imageURI; - uint32_t softwareVersion; - chip::ByteSpan updateToken; - uint8_t userConsentNeeded; - chip::ByteSpan metadataForRequestor; - bool argExists[7]; + uint8_t capacity; + uint16_t groupId; + uint8_t sceneCount; + /* TYPE WARNING: array array defaults to */ uint8_t * sceneList; + bool argExists[5]; memset(argExists, 0, sizeof argExists); @@ -4180,7 +6726,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 7) + if (currentDecodeTagId < 5) { if (argExists[currentDecodeTagId]) { @@ -4200,30 +6746,18 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVUnpackError = aDataTlv.Get(status); break; case 1: - TLVUnpackError = aDataTlv.Get(delayedActionTime); + TLVUnpackError = aDataTlv.Get(capacity); break; case 2: - // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. - TLVUnpackError = aDataTlv.GetDataPtr(imageURI); + TLVUnpackError = aDataTlv.Get(groupId); break; case 3: - TLVUnpackError = aDataTlv.Get(softwareVersion); + TLVUnpackError = aDataTlv.Get(sceneCount); break; - case 4: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - updateToken = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; - case 5: - TLVUnpackError = aDataTlv.Get(userConsentNeeded); + case 4: + // Just for compatibility, we will add array type support in IM later. + TLVUnpackError = aDataTlv.GetDataPtr(const_cast(sceneList)); break; - case 6: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - metadataForRequestor = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; default: // Unsupported tag, ignore it. ChipLogProgress(Zcl, "Unknown TLV tag during processing."); @@ -4241,80 +6775,19 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 7 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOtaSoftwareUpdateProviderClusterQueryImageResponseCallback( - apCommandObj, status, delayedActionTime, const_cast(imageURI), softwareVersion, updateToken, - userConsentNeeded, metadataForRequestor); + wasHandled = emberAfScenesClusterGetSceneMembershipResponseCallback(apCommandObj, status, capacity, groupId, + sceneCount, sceneList); } break; } - default: { - // Unrecognized command ID, error status will apply. - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::OtaSoftwareUpdateProvider::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, - Protocols::SecureChannel::Id, - Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, - Clusters::OtaSoftwareUpdateProvider::Id); - return; - } - } - } - - if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) - { - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::OtaSoftwareUpdateProvider::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, - Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); - ChipLogProgress(Zcl, - "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT - ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, ChipError::FormatError(TLVError), - ChipError::FormatError(TLVUnpackError), currentDecodeTagId); - // A command with no arguments would never write currentDecodeTagId. If - // progress logging is also disabled, it would look unused. Silence that - // warning. - UNUSED_VAR(currentDecodeTagId); - } -} - -} // namespace OtaSoftwareUpdateProvider - -namespace OperationalCredentials { - -void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, - TLV::TLVReader & aDataTlv) -{ - // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV - // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. - // Any error value TLVUnpackError means we have received an illegal value. - // The following variables are used for all commands to save code size. - CHIP_ERROR TLVError = CHIP_NO_ERROR; - CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; - uint32_t validArgumentCount = 0; - uint32_t expectArgumentCount = 0; - uint32_t currentDecodeTagId = 0; - bool wasHandled = false; - { - switch (aCommandId) - { - case Clusters::OperationalCredentials::Commands::Ids::OpCSRResponse: { - expectArgumentCount = 6; - chip::ByteSpan CSR; - chip::ByteSpan CSRNonce; - chip::ByteSpan VendorReserved1; - chip::ByteSpan VendorReserved2; - chip::ByteSpan VendorReserved3; - chip::ByteSpan Signature; - bool argExists[6]; + case Clusters::Scenes::Commands::Ids::RemoveAllScenesResponse: { + expectArgumentCount = 2; + uint8_t status; + uint16_t groupId; + bool argExists[2]; memset(argExists, 0, sizeof argExists); @@ -4327,7 +6800,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 6) + if (currentDecodeTagId < 2) { if (argExists[currentDecodeTagId]) { @@ -4343,42 +6816,79 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - CSR = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; - case 1: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - CSRNonce = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; - case 2: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - VendorReserved1 = chip::ByteSpan(data, aDataTlv.GetLength()); + case 0: + TLVUnpackError = aDataTlv.Get(status); + break; + case 1: + TLVUnpackError = aDataTlv.Get(groupId); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; } - break; - case 3: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - VendorReserved2 = chip::ByteSpan(data, aDataTlv.GetLength()); + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; } - break; - case 4: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - VendorReserved3 = chip::ByteSpan(data, aDataTlv.GetLength()); + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfScenesClusterRemoveAllScenesResponseCallback(apCommandObj, status, groupId); + } + break; + } + case Clusters::Scenes::Commands::Ids::RemoveSceneResponse: { + expectArgumentCount = 3; + uint8_t status; + uint16_t groupId; + uint8_t sceneId; + bool argExists[3]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; } - break; - case 5: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - Signature = chip::ByteSpan(data, aDataTlv.GetLength()); + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 3) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } } - break; + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(status); + break; + case 1: + TLVUnpackError = aDataTlv.Get(groupId); + break; + case 2: + TLVUnpackError = aDataTlv.Get(sceneId); + break; default: // Unsupported tag, ignore it. ChipLogProgress(Zcl, "Unknown TLV tag during processing."); @@ -4396,19 +6906,18 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 6 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOperationalCredentialsClusterOpCSRResponseCallback(apCommandObj, CSR, CSRNonce, VendorReserved1, - VendorReserved2, VendorReserved3, Signature); + wasHandled = emberAfScenesClusterRemoveSceneResponseCallback(apCommandObj, status, groupId, sceneId); } break; } - case Clusters::OperationalCredentials::Commands::Ids::OpCertResponse: { + case Clusters::Scenes::Commands::Ids::StoreSceneResponse: { expectArgumentCount = 3; - uint8_t StatusCode; - uint64_t FabricIndex; - const uint8_t * DebugText; + uint8_t status; + uint16_t groupId; + uint8_t sceneId; bool argExists[3]; memset(argExists, 0, sizeof argExists); @@ -4439,14 +6948,13 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(StatusCode); + TLVUnpackError = aDataTlv.Get(status); break; case 1: - TLVUnpackError = aDataTlv.Get(FabricIndex); + TLVUnpackError = aDataTlv.Get(groupId); break; case 2: - // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. - TLVUnpackError = aDataTlv.GetDataPtr(DebugText); + TLVUnpackError = aDataTlv.Get(sceneId); break; default: // Unsupported tag, ignore it. @@ -4468,15 +6976,19 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOperationalCredentialsClusterOpCertResponseCallback(apCommandObj, StatusCode, FabricIndex, - const_cast(DebugText)); + wasHandled = emberAfScenesClusterStoreSceneResponseCallback(apCommandObj, status, groupId, sceneId); } break; } - case Clusters::OperationalCredentials::Commands::Ids::SetFabricResponse: { - expectArgumentCount = 1; - chip::FabricId FabricId; - bool argExists[1]; + case Clusters::Scenes::Commands::Ids::ViewSceneResponse: { + expectArgumentCount = 6; + uint8_t status; + uint16_t groupId; + uint8_t sceneId; + uint16_t transitionTime; + const uint8_t * sceneName; + /* TYPE WARNING: array array defaults to */ uint8_t * extensionFieldSets; + bool argExists[6]; memset(argExists, 0, sizeof argExists); @@ -4489,7 +7001,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) + if (currentDecodeTagId < 6) { if (argExists[currentDecodeTagId]) { @@ -4506,7 +7018,24 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(FabricId); + TLVUnpackError = aDataTlv.Get(status); + break; + case 1: + TLVUnpackError = aDataTlv.Get(groupId); + break; + case 2: + TLVUnpackError = aDataTlv.Get(sceneId); + break; + case 3: + TLVUnpackError = aDataTlv.Get(transitionTime); + break; + case 4: + // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. + TLVUnpackError = aDataTlv.GetDataPtr(sceneName); + break; + case 5: + // Just for compatibility, we will add array type support in IM later. + TLVUnpackError = aDataTlv.GetDataPtr(const_cast(extensionFieldSets)); break; default: // Unsupported tag, ignore it. @@ -4525,10 +7054,11 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 6 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOperationalCredentialsClusterSetFabricResponseCallback(apCommandObj, FabricId); + wasHandled = emberAfScenesClusterViewSceneResponseCallback(apCommandObj, status, groupId, sceneId, transitionTime, + const_cast(sceneName), extensionFieldSets); } break; } @@ -4536,12 +7066,12 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand // Unrecognized command ID, error status will apply. chip::app::CommandPathParams returnStatusParam = { aEndpointId, 0, // GroupId - Clusters::OperationalCredentials::Id, aCommandId, + Clusters::Scenes::Id, aCommandId, (chip::app::CommandPathFlags::kEndpointIdValid) }; apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::OperationalCredentials::Id); + ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::Scenes::Id); return; } } @@ -4551,7 +7081,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand { chip::app::CommandPathParams returnStatusParam = { aEndpointId, 0, // GroupId - Clusters::OperationalCredentials::Id, aCommandId, + Clusters::Scenes::Id, aCommandId, (chip::app::CommandPathFlags::kEndpointIdValid) }; apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); @@ -4567,11 +7097,11 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand } } -} // namespace OperationalCredentials +} // namespace Scenes namespace Scenes { -void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, +void DispatchServerCommand(app::CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) { // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV @@ -4587,12 +7117,14 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand { switch (aCommandId) { - case Clusters::Scenes::Commands::Ids::AddSceneResponse: { - expectArgumentCount = 3; - uint8_t status; + case Clusters::Scenes::Commands::Ids::AddScene: { + expectArgumentCount = 5; uint16_t groupId; uint8_t sceneId; - bool argExists[3]; + uint16_t transitionTime; + const uint8_t * sceneName; + /* TYPE WARNING: array array defaults to */ uint8_t * extensionFieldSets; + bool argExists[5]; memset(argExists, 0, sizeof argExists); @@ -4605,7 +7137,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 3) + if (currentDecodeTagId < 5) { if (argExists[currentDecodeTagId]) { @@ -4622,13 +7154,21 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(status); + TLVUnpackError = aDataTlv.Get(groupId); break; case 1: - TLVUnpackError = aDataTlv.Get(groupId); + TLVUnpackError = aDataTlv.Get(sceneId); break; case 2: - TLVUnpackError = aDataTlv.Get(sceneId); + TLVUnpackError = aDataTlv.Get(transitionTime); + break; + case 3: + // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. + TLVUnpackError = aDataTlv.GetDataPtr(sceneName); + break; + case 4: + // Just for compatibility, we will add array type support in IM later. + TLVUnpackError = aDataTlv.GetDataPtr(const_cast(extensionFieldSets)); break; default: // Unsupported tag, ignore it. @@ -4647,21 +7187,18 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfScenesClusterAddSceneResponseCallback(apCommandObj, status, groupId, sceneId); + wasHandled = emberAfScenesClusterAddSceneCallback(apCommandObj, groupId, sceneId, transitionTime, + const_cast(sceneName), extensionFieldSets); } break; } - case Clusters::Scenes::Commands::Ids::GetSceneMembershipResponse: { - expectArgumentCount = 5; - uint8_t status; - uint8_t capacity; + case Clusters::Scenes::Commands::Ids::GetSceneMembership: { + expectArgumentCount = 1; uint16_t groupId; - uint8_t sceneCount; - /* TYPE WARNING: array array defaults to */ uint8_t * sceneList; - bool argExists[5]; + bool argExists[1]; memset(argExists, 0, sizeof argExists); @@ -4674,7 +7211,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 5) + if (currentDecodeTagId < 1) { if (argExists[currentDecodeTagId]) { @@ -4691,20 +7228,74 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(status); + TLVUnpackError = aDataTlv.Get(groupId); break; - case 1: - TLVUnpackError = aDataTlv.Get(capacity); + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); break; - case 2: + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + { + // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. + wasHandled = emberAfScenesClusterGetSceneMembershipCallback(apCommandObj, groupId); + } + break; + } + case Clusters::Scenes::Commands::Ids::RecallScene: { + expectArgumentCount = 3; + uint16_t groupId; + uint8_t sceneId; + uint16_t transitionTime; + bool argExists[3]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 3) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: TLVUnpackError = aDataTlv.Get(groupId); break; - case 3: - TLVUnpackError = aDataTlv.Get(sceneCount); + case 1: + TLVUnpackError = aDataTlv.Get(sceneId); break; - case 4: - // Just for compatibility, we will add array type support in IM later. - TLVUnpackError = aDataTlv.GetDataPtr(const_cast(sceneList)); + case 2: + TLVUnpackError = aDataTlv.Get(transitionTime); break; default: // Unsupported tag, ignore it. @@ -4723,19 +7314,17 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfScenesClusterGetSceneMembershipResponseCallback(apCommandObj, status, capacity, groupId, - sceneCount, sceneList); + wasHandled = emberAfScenesClusterRecallSceneCallback(apCommandObj, groupId, sceneId, transitionTime); } break; } - case Clusters::Scenes::Commands::Ids::RemoveAllScenesResponse: { - expectArgumentCount = 2; - uint8_t status; + case Clusters::Scenes::Commands::Ids::RemoveAllScenes: { + expectArgumentCount = 1; uint16_t groupId; - bool argExists[2]; + bool argExists[1]; memset(argExists, 0, sizeof argExists); @@ -4748,7 +7337,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 2) + if (currentDecodeTagId < 1) { if (argExists[currentDecodeTagId]) { @@ -4765,9 +7354,6 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - case 1: TLVUnpackError = aDataTlv.Get(groupId); break; default: @@ -4787,19 +7373,18 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfScenesClusterRemoveAllScenesResponseCallback(apCommandObj, status, groupId); + wasHandled = emberAfScenesClusterRemoveAllScenesCallback(apCommandObj, groupId); } break; } - case Clusters::Scenes::Commands::Ids::RemoveSceneResponse: { - expectArgumentCount = 3; - uint8_t status; + case Clusters::Scenes::Commands::Ids::RemoveScene: { + expectArgumentCount = 2; uint16_t groupId; uint8_t sceneId; - bool argExists[3]; + bool argExists[2]; memset(argExists, 0, sizeof argExists); @@ -4812,7 +7397,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 3) + if (currentDecodeTagId < 2) { if (argExists[currentDecodeTagId]) { @@ -4829,12 +7414,9 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - case 1: TLVUnpackError = aDataTlv.Get(groupId); break; - case 2: + case 1: TLVUnpackError = aDataTlv.Get(sceneId); break; default: @@ -4854,19 +7436,18 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfScenesClusterRemoveSceneResponseCallback(apCommandObj, status, groupId, sceneId); + wasHandled = emberAfScenesClusterRemoveSceneCallback(apCommandObj, groupId, sceneId); } break; } - case Clusters::Scenes::Commands::Ids::StoreSceneResponse: { - expectArgumentCount = 3; - uint8_t status; + case Clusters::Scenes::Commands::Ids::StoreScene: { + expectArgumentCount = 2; uint16_t groupId; uint8_t sceneId; - bool argExists[3]; + bool argExists[2]; memset(argExists, 0, sizeof argExists); @@ -4879,7 +7460,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 3) + if (currentDecodeTagId < 2) { if (argExists[currentDecodeTagId]) { @@ -4896,12 +7477,9 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - case 1: TLVUnpackError = aDataTlv.Get(groupId); break; - case 2: + case 1: TLVUnpackError = aDataTlv.Get(sceneId); break; default: @@ -4921,22 +7499,18 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfScenesClusterStoreSceneResponseCallback(apCommandObj, status, groupId, sceneId); + wasHandled = emberAfScenesClusterStoreSceneCallback(apCommandObj, groupId, sceneId); } break; } - case Clusters::Scenes::Commands::Ids::ViewSceneResponse: { - expectArgumentCount = 6; - uint8_t status; + case Clusters::Scenes::Commands::Ids::ViewScene: { + expectArgumentCount = 2; uint16_t groupId; uint8_t sceneId; - uint16_t transitionTime; - const uint8_t * sceneName; - /* TYPE WARNING: array array defaults to */ uint8_t * extensionFieldSets; - bool argExists[6]; + bool argExists[2]; memset(argExists, 0, sizeof argExists); @@ -4949,7 +7523,7 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 6) + if (currentDecodeTagId < 2) { if (argExists[currentDecodeTagId]) { @@ -4966,25 +7540,11 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(status); - break; - case 1: TLVUnpackError = aDataTlv.Get(groupId); break; - case 2: + case 1: TLVUnpackError = aDataTlv.Get(sceneId); break; - case 3: - TLVUnpackError = aDataTlv.Get(transitionTime); - break; - case 4: - // TODO(#5542): The cluster handlers should accept a ByteSpan for all string types. - TLVUnpackError = aDataTlv.GetDataPtr(sceneName); - break; - case 5: - // Just for compatibility, we will add array type support in IM later. - TLVUnpackError = aDataTlv.GetDataPtr(const_cast(extensionFieldSets)); - break; default: // Unsupported tag, ignore it. ChipLogProgress(Zcl, "Unknown TLV tag during processing."); @@ -5002,11 +7562,10 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 6 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfScenesClusterViewSceneResponseCallback(apCommandObj, status, groupId, sceneId, transitionTime, - const_cast(sceneName), extensionFieldSets); + wasHandled = emberAfScenesClusterViewSceneCallback(apCommandObj, groupId, sceneId); } break; } @@ -5412,6 +7971,30 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC SuccessOrExit(aReader.EnterContainer(dataTlvType)); switch (aClusterId) { + case Clusters::Basic::Id: + clusters::Basic::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; + case Clusters::GeneralCommissioning::Id: + clusters::GeneralCommissioning::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; + case Clusters::Groups::Id: + clusters::Groups::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; + case Clusters::LevelControl::Id: + clusters::LevelControl::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; + case Clusters::NetworkCommissioning::Id: + clusters::NetworkCommissioning::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; + case Clusters::OnOff::Id: + clusters::OnOff::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; + case Clusters::OperationalCredentials::Id: + clusters::OperationalCredentials::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; + case Clusters::Scenes::Id: + clusters::Scenes::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; default: // Unrecognized cluster ID, error status will apply. chip::app::CommandPathParams returnStatusParam = { aEndPointId, @@ -5444,6 +8027,9 @@ void DispatchSingleClusterResponseCommand(chip::ClusterId aClusterId, chip::Comm case Clusters::ApplicationLauncher::Id: clusters::ApplicationLauncher::DispatchClientCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; + case Clusters::Basic::Id: + clusters::Basic::DispatchClientCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; case Clusters::ContentLauncher::Id: clusters::ContentLauncher::DispatchClientCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; diff --git a/src/controller/data_model/gen/attribute-size.cpp b/src/controller/data_model/gen/attribute-size.cpp index 2de85f537275b0..97e2effb1bf61c 100644 --- a/src/controller/data_model/gen/attribute-size.cpp +++ b/src/controller/data_model/gen/attribute-size.cpp @@ -78,6 +78,41 @@ uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, boo uint16_t entryLength = 0; switch (clusterId) { + case 0x003E: // Operational Credentials Cluster + { + uint16_t entryOffset = kSizeLengthInBytes; + switch (am->attributeId) + { + case 0x0001: // fabrics list + { + entryLength = 52; + if (((index - 1) * entryLength) > (am->size - entryLength)) + { + ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); + return 0; + } + entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); + // Struct _FabricDescriptor + _FabricDescriptor * entry = reinterpret_cast<_FabricDescriptor *>(write ? src : dest); + copyListMember(write ? dest : (uint8_t *) &entry->FabricId, write ? (uint8_t *) &entry->FabricId : src, write, + &entryOffset, sizeof(entry->FabricId)); // FABRIC_ID + copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, + &entryOffset, sizeof(entry->VendorId)); // INT16U + copyListMember(write ? dest : (uint8_t *) &entry->NodeId, write ? (uint8_t *) &entry->NodeId : src, write, &entryOffset, + sizeof(entry->NodeId)); // NODE_ID + chip::ByteSpan * LabelSpan = &entry->Label; // OCTET_STRING + if (CHIP_NO_ERROR != + (write ? WriteByteSpan(dest + entryOffset, 34, LabelSpan) : ReadByteSpan(src + entryOffset, 34, LabelSpan))) + { + ChipLogError(Zcl, "Index %" PRId32 " is invalid. Not enough remaining space", index); + return 0; + } + entryOffset = static_cast(entryOffset + 34); + break; + } + } + break; + } } return entryLength; @@ -97,6 +132,15 @@ uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attribut uint16_t entryLength = 0; switch (clusterId) { + case 0x003E: // Operational Credentials Cluster + switch (attributeId) + { + case 0x0001: // fabrics list + // Struct _FabricDescriptor + entryLength = 52; + break; + } + break; } uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength); diff --git a/src/controller/data_model/gen/chip-zcl-zpro-codec-api.h b/src/controller/data_model/gen/chip-zcl-zpro-codec-api.h index 0f6dc3724f6966..739ce076c82d18 100644 --- a/src/controller/data_model/gen/chip-zcl-zpro-codec-api.h +++ b/src/controller/data_model/gen/chip-zcl-zpro-codec-api.h @@ -50,9 +50,11 @@ | GeneralDiagnostics | 0x0033 | | GroupKeyManagement | 0xF004 | | Groups | 0x0004 | +| Groups | 0x0004 | | Identify | 0x0003 | | KeypadInput | 0x0509 | | LevelControl | 0x0008 | +| LevelControl | 0x0008 | | LowPower | 0x0508 | | MediaInput | 0x0507 | | MediaPlayback | 0x0506 | @@ -60,11 +62,13 @@ | OtaSoftwareUpdateProvider | 0x0029 | | OccupancySensing | 0x0406 | | OnOff | 0x0006 | +| OnOff | 0x0006 | | OperationalCredentials | 0x003E | | PressureMeasurement | 0x0403 | | PumpConfigurationAndControl | 0x0200 | | RelativeHumidityMeasurement | 0x0405 | | Scenes | 0x0005 | +| Scenes | 0x0005 | | SoftwareDiagnostics | 0x0034 | | Switch | 0x003B | | TvChannel | 0x0504 | diff --git a/src/controller/data_model/gen/encoder.cpp b/src/controller/data_model/gen/encoder.cpp index aa79a32b61d8ac..81b7d753f41a9e 100644 --- a/src/controller/data_model/gen/encoder.cpp +++ b/src/controller/data_model/gen/encoder.cpp @@ -65,6 +65,7 @@ using namespace chip::Encoding::LittleEndian; | AudioOutput | 0x050B | | BarrierControl | 0x0103 | | Basic | 0x0028 | +| Basic | 0x0028 | | BinaryInputBasic | 0x000F | | Binding | 0xF000 | | BridgedDeviceBasic | 0x0039 | @@ -78,24 +79,31 @@ using namespace chip::Encoding::LittleEndian; | FixedLabel | 0x0040 | | FlowMeasurement | 0x0404 | | GeneralCommissioning | 0x0030 | +| GeneralCommissioning | 0x0030 | | GeneralDiagnostics | 0x0033 | | GroupKeyManagement | 0xF004 | | Groups | 0x0004 | +| Groups | 0x0004 | | Identify | 0x0003 | | KeypadInput | 0x0509 | | LevelControl | 0x0008 | +| LevelControl | 0x0008 | | LowPower | 0x0508 | | MediaInput | 0x0507 | | MediaPlayback | 0x0506 | | NetworkCommissioning | 0x0031 | +| NetworkCommissioning | 0x0031 | | OtaSoftwareUpdateProvider | 0x0029 | | OccupancySensing | 0x0406 | | OnOff | 0x0006 | +| OnOff | 0x0006 | +| OperationalCredentials | 0x003E | | OperationalCredentials | 0x003E | | PressureMeasurement | 0x0403 | | PumpConfigurationAndControl | 0x0200 | | RelativeHumidityMeasurement | 0x0405 | | Scenes | 0x0005 | +| Scenes | 0x0005 | | SoftwareDiagnostics | 0x0034 | | Switch | 0x003B | | TvChannel | 0x0504 | @@ -1245,11 +1253,6 @@ PacketBufferHandle encodeBridgedDeviceBasicClusterReadClusterRevisionAttribute(u | Cluster ColorControl | 0x0300 | |------------------------------------------------------------------------------| | Commands: | | -| * ColorLoopSet | 0x44 | -| * EnhancedMoveHue | 0x41 | -| * EnhancedMoveToHue | 0x40 | -| * EnhancedMoveToHueAndSaturation | 0x43 | -| * EnhancedStepHue | 0x42 | | * MoveColor | 0x08 | | * MoveColorTemperature | 0x4B | | * MoveHue | 0x01 | @@ -1306,14 +1309,6 @@ PacketBufferHandle encodeBridgedDeviceBasicClusterReadClusterRevisionAttribute(u | * ColorPointBX | 0x003A | | * ColorPointBY | 0x003B | | * ColorPointBIntensity | 0x003C | -| * EnhancedCurrentHue | 0x4000 | -| * EnhancedColorMode | 0x4001 | -| * ColorLoopActive | 0x4002 | -| * ColorLoopDirection | 0x4003 | -| * ColorLoopTime | 0x4004 | -| * ColorCapabilities | 0x400A | -| * ColorTempPhysicalMin | 0x400B | -| * ColorTempPhysicalMax | 0x400C | | * CoupleColorTempToLevelMinMireds | 0x400D | | * StartUpColorTemperatureMireds | 0x4010 | | * ClusterRevision | 0xFFFD | @@ -2084,110 +2079,6 @@ PacketBufferHandle encodeColorControlClusterWriteColorPointBIntensityAttribute(u COMMAND_FOOTER(); } -/* - * Attribute EnhancedCurrentHue - */ -PacketBufferHandle encodeColorControlClusterReadEnhancedCurrentHueAttribute(uint8_t seqNum, EndpointId destinationEndpoint) -{ - COMMAND_HEADER("ReadColorControlEnhancedCurrentHue", ColorControl::Id); - buf.Put8(kFrameControlGlobalCommand) - .Put8(seqNum) - .Put32(Globals::Commands::Ids::ReadAttributes) - .Put32(ColorControl::Attributes::Ids::EnhancedCurrentHue); - COMMAND_FOOTER(); -} - -/* - * Attribute EnhancedColorMode - */ -PacketBufferHandle encodeColorControlClusterReadEnhancedColorModeAttribute(uint8_t seqNum, EndpointId destinationEndpoint) -{ - COMMAND_HEADER("ReadColorControlEnhancedColorMode", ColorControl::Id); - buf.Put8(kFrameControlGlobalCommand) - .Put8(seqNum) - .Put32(Globals::Commands::Ids::ReadAttributes) - .Put32(ColorControl::Attributes::Ids::EnhancedColorMode); - COMMAND_FOOTER(); -} - -/* - * Attribute ColorLoopActive - */ -PacketBufferHandle encodeColorControlClusterReadColorLoopActiveAttribute(uint8_t seqNum, EndpointId destinationEndpoint) -{ - COMMAND_HEADER("ReadColorControlColorLoopActive", ColorControl::Id); - buf.Put8(kFrameControlGlobalCommand) - .Put8(seqNum) - .Put32(Globals::Commands::Ids::ReadAttributes) - .Put32(ColorControl::Attributes::Ids::ColorLoopActive); - COMMAND_FOOTER(); -} - -/* - * Attribute ColorLoopDirection - */ -PacketBufferHandle encodeColorControlClusterReadColorLoopDirectionAttribute(uint8_t seqNum, EndpointId destinationEndpoint) -{ - COMMAND_HEADER("ReadColorControlColorLoopDirection", ColorControl::Id); - buf.Put8(kFrameControlGlobalCommand) - .Put8(seqNum) - .Put32(Globals::Commands::Ids::ReadAttributes) - .Put32(ColorControl::Attributes::Ids::ColorLoopDirection); - COMMAND_FOOTER(); -} - -/* - * Attribute ColorLoopTime - */ -PacketBufferHandle encodeColorControlClusterReadColorLoopTimeAttribute(uint8_t seqNum, EndpointId destinationEndpoint) -{ - COMMAND_HEADER("ReadColorControlColorLoopTime", ColorControl::Id); - buf.Put8(kFrameControlGlobalCommand) - .Put8(seqNum) - .Put32(Globals::Commands::Ids::ReadAttributes) - .Put32(ColorControl::Attributes::Ids::ColorLoopTime); - COMMAND_FOOTER(); -} - -/* - * Attribute ColorCapabilities - */ -PacketBufferHandle encodeColorControlClusterReadColorCapabilitiesAttribute(uint8_t seqNum, EndpointId destinationEndpoint) -{ - COMMAND_HEADER("ReadColorControlColorCapabilities", ColorControl::Id); - buf.Put8(kFrameControlGlobalCommand) - .Put8(seqNum) - .Put32(Globals::Commands::Ids::ReadAttributes) - .Put32(ColorControl::Attributes::Ids::ColorCapabilities); - COMMAND_FOOTER(); -} - -/* - * Attribute ColorTempPhysicalMin - */ -PacketBufferHandle encodeColorControlClusterReadColorTempPhysicalMinAttribute(uint8_t seqNum, EndpointId destinationEndpoint) -{ - COMMAND_HEADER("ReadColorControlColorTempPhysicalMin", ColorControl::Id); - buf.Put8(kFrameControlGlobalCommand) - .Put8(seqNum) - .Put32(Globals::Commands::Ids::ReadAttributes) - .Put32(ColorControl::Attributes::Ids::ColorTempPhysicalMin); - COMMAND_FOOTER(); -} - -/* - * Attribute ColorTempPhysicalMax - */ -PacketBufferHandle encodeColorControlClusterReadColorTempPhysicalMaxAttribute(uint8_t seqNum, EndpointId destinationEndpoint) -{ - COMMAND_HEADER("ReadColorControlColorTempPhysicalMax", ColorControl::Id); - buf.Put8(kFrameControlGlobalCommand) - .Put8(seqNum) - .Put32(Globals::Commands::Ids::ReadAttributes) - .Put32(ColorControl::Attributes::Ids::ColorTempPhysicalMax); - COMMAND_FOOTER(); -} - /* * Attribute CoupleColorTempToLevelMinMireds */ diff --git a/src/controller/data_model/gen/endpoint_config.h b/src/controller/data_model/gen/endpoint_config.h index b8e6e862160012..b8706f9a6f6091 100644 --- a/src/controller/data_model/gen/endpoint_config.h +++ b/src/controller/data_model/gen/endpoint_config.h @@ -26,16 +26,136 @@ #if BIGENDIAN_CPU #define GENERATED_DEFAULTS \ { \ + \ + /* Endpoint: 0, Cluster: Basic (server), big-endian */ \ + \ + /* 0 - VendorName, */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + \ + /* 32 - ProductName, */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + \ + /* 64 - UserLabel, */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + \ + /* 96 - HardwareVersionString, */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + \ + /* 160 - SoftwareVersion, */ \ + 0x00, 0x00, 0x00, 0x00, \ + \ + /* 164 - SoftwareVersionString, */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + \ + /* Endpoint: 0, Cluster: General Commissioning (server), big-endian */ \ + \ + /* 228 - FabricId, */ \ + 1, 'o', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + \ + /* 236 - Breadcrumb, */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + \ + /* Endpoint: 0, Cluster: Operational Credentials (server), big-endian */ \ + \ + /* 244 - fabrics list, */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + \ + /* Endpoint: 1, Cluster: On/off (server), big-endian */ \ + \ + /* 498 - feature map, */ \ + 0x00, 0x00, 0x00, 0x00, \ } #else // !BIGENDIAN_CPU #define GENERATED_DEFAULTS \ { \ + \ + /* Endpoint: 0, Cluster: Basic (server), little-endian */ \ + \ + /* 0 - VendorName, */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + \ + /* 32 - ProductName, */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + \ + /* 64 - UserLabel, */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + \ + /* 96 - HardwareVersionString, */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + \ + /* 160 - SoftwareVersion, */ \ + 0x00, 0x00, 0x00, 0x00, \ + \ + /* 164 - SoftwareVersionString, */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + \ + /* Endpoint: 0, Cluster: General Commissioning (server), little-endian */ \ + \ + /* 228 - FabricId, */ \ + 1, 'o', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + \ + /* 236 - Breadcrumb, */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + \ + /* Endpoint: 0, Cluster: Operational Credentials (server), little-endian */ \ + \ + /* 244 - fabrics list, */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + \ + /* Endpoint: 1, Cluster: On/off (server), little-endian */ \ + \ + /* 498 - feature map, */ \ + 0x00, 0x00, 0x00, 0x00, \ } #endif // BIGENDIAN_CPU -#define GENERATED_DEFAULTS_COUNT (0) +#define GENERATED_DEFAULTS_COUNT (10) #define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE #define ZAP_LONG_DEFAULTS_INDEX(index) \ @@ -63,25 +183,80 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 47 +#define GENERATED_ATTRIBUTE_COUNT 82 #define GENERATED_ATTRIBUTES \ { \ \ - /* Endpoint: 1, Cluster: Identify (client) */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), ZAP_SIMPLE_DEFAULT(2) }, /* cluster revision */ \ + /* Endpoint: 0, Cluster: Basic (server) */ \ + { 0x0000, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), ZAP_SIMPLE_DEFAULT(1) }, /* InteractionModelVersion */ \ + { 0x0001, ZAP_TYPE(CHAR_STRING), 32, ZAP_ATTRIBUTE_MASK(SINGLETON), ZAP_LONG_DEFAULTS_INDEX(0) }, /* VendorName */ \ + { 0x0002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), ZAP_EMPTY_DEFAULT() }, /* VendorID */ \ + { 0x0003, ZAP_TYPE(CHAR_STRING), 32, ZAP_ATTRIBUTE_MASK(SINGLETON), ZAP_LONG_DEFAULTS_INDEX(32) }, /* ProductName */ \ + { 0x0004, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), ZAP_EMPTY_DEFAULT() }, /* ProductID */ \ + { 0x0005, ZAP_TYPE(CHAR_STRING), 32, ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + ZAP_LONG_DEFAULTS_INDEX(64) }, /* UserLabel */ \ + { 0x0006, ZAP_TYPE(CHAR_STRING), 2, ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + ZAP_EMPTY_DEFAULT() }, /* Location */ \ + { 0x0007, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), ZAP_SIMPLE_DEFAULT(0) }, /* HardwareVersion */ \ + { 0x0008, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), \ + ZAP_LONG_DEFAULTS_INDEX(96) }, /* HardwareVersionString */ \ + { 0x0009, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(SINGLETON), ZAP_LONG_DEFAULTS_INDEX(160) }, /* SoftwareVersion */ \ + { 0x000A, ZAP_TYPE(CHAR_STRING), 64, ZAP_ATTRIBUTE_MASK(SINGLETON), \ + ZAP_LONG_DEFAULTS_INDEX(164) }, /* SoftwareVersionString */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), ZAP_SIMPLE_DEFAULT(3) }, /* cluster revision */ \ + \ + /* Endpoint: 0, Cluster: General Commissioning (server) */ \ + { 0x0000, ZAP_TYPE(OCTET_STRING), 8, 0, ZAP_LONG_DEFAULTS_INDEX(228) }, /* FabricId */ \ + { 0x0001, ZAP_TYPE(INT64U), 8, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_LONG_DEFAULTS_INDEX(236) }, /* Breadcrumb */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ + \ + /* Endpoint: 0, Cluster: Network Commissioning (server) */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ + \ + /* Endpoint: 0, Cluster: Operational Credentials (server) */ \ + { 0x0001, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(244) }, /* fabrics list */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ + \ + /* Endpoint: 1, Cluster: Identify (client) */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), ZAP_SIMPLE_DEFAULT(2) }, /* cluster revision */ \ \ /* Endpoint: 1, Cluster: Groups (client) */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), ZAP_SIMPLE_DEFAULT(3) }, /* cluster revision */ \ \ + /* Endpoint: 1, Cluster: Groups (server) */ \ + { 0x0000, ZAP_TYPE(BITMAP8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* name support */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(3) }, /* cluster revision */ \ + \ /* Endpoint: 1, Cluster: Scenes (client) */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), ZAP_SIMPLE_DEFAULT(3) }, /* cluster revision */ \ \ + /* Endpoint: 1, Cluster: Scenes (server) */ \ + { 0x0000, ZAP_TYPE(INT8U), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* scene count */ \ + { 0x0001, ZAP_TYPE(INT8U), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* current scene */ \ + { 0x0002, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0000) }, /* current group */ \ + { 0x0003, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* scene valid */ \ + { 0x0004, ZAP_TYPE(BITMAP8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* name support */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(3) }, /* cluster revision */ \ + \ /* Endpoint: 1, Cluster: On/off (client) */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), ZAP_SIMPLE_DEFAULT(2) }, /* cluster revision */ \ \ + /* Endpoint: 1, Cluster: On/off (server) */ \ + { 0x0000, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* OnOff */ \ + { 0x4000, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x01) }, /* GlobalSceneControl */ \ + { 0x4001, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_SIMPLE_DEFAULT(0x0000) }, /* OnTime */ \ + { 0x4002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_SIMPLE_DEFAULT(0x0000) }, /* OffWaitTime */ \ + { 0x4003, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_EMPTY_DEFAULT() }, /* StartUpOnOff */ \ + { 0xFFFC, ZAP_TYPE(INT32U), 4, 0, ZAP_LONG_DEFAULTS_INDEX(498) }, /* feature map */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(2) }, /* cluster revision */ \ + \ /* Endpoint: 1, Cluster: Level Control (client) */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), ZAP_SIMPLE_DEFAULT(3) }, /* cluster revision */ \ \ + /* Endpoint: 1, Cluster: Level Control (server) */ \ + { 0x0000, ZAP_TYPE(INT8U), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* current level */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(3) }, /* cluster revision */ \ + \ /* Endpoint: 1, Cluster: Binary Input (Basic) (client) */ \ { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ \ @@ -215,143 +390,199 @@ #define ZAP_ATTRIBUTE_INDEX(index) ((EmberAfAttributeMetadata *) (&generatedAttributes[index])) // Cluster function static arrays -#define GENERATED_FUNCTION_ARRAYS +#define GENERATED_FUNCTION_ARRAYS \ + const EmberAfGenericClusterFunction chipFuncArrayBasicServer[] = { \ + (EmberAfGenericClusterFunction) emberAfBasicClusterServerInitCallback, \ + }; \ + const EmberAfGenericClusterFunction chipFuncArrayGroupsServer[] = { \ + (EmberAfGenericClusterFunction) emberAfGroupsClusterServerInitCallback, \ + }; \ + const EmberAfGenericClusterFunction chipFuncArrayScenesServer[] = { \ + (EmberAfGenericClusterFunction) emberAfScenesClusterServerInitCallback, \ + }; \ + const EmberAfGenericClusterFunction chipFuncArrayOnOffServer[] = { \ + (EmberAfGenericClusterFunction) emberAfOnOffClusterServerInitCallback, \ + }; \ + const EmberAfGenericClusterFunction chipFuncArrayLevelControlServer[] = { \ + (EmberAfGenericClusterFunction) emberAfLevelControlClusterServerInitCallback, \ + }; #define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask -#define GENERATED_CLUSTER_COUNT 48 +#define GENERATED_CLUSTER_COUNT 56 #define GENERATED_CLUSTERS \ { \ - { 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) */ \ + { 0x0028, \ + ZAP_ATTRIBUTE_INDEX(0), \ + 12, \ + 240, \ + ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ + chipFuncArrayBasicServer }, /* Endpoint: 0, Cluster: Basic (server) */ \ + { \ + 0x0030, ZAP_ATTRIBUTE_INDEX(12), 3, 18, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 0, Cluster: General Commissioning (server) */ \ + { \ + 0x0031, ZAP_ATTRIBUTE_INDEX(15), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 0, Cluster: Network Commissioning (server) */ \ + { \ + 0x003E, ZAP_ATTRIBUTE_INDEX(16), 2, 256, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 0, Cluster: Operational Credentials (server) */ \ { \ - 0x0008, ZAP_ATTRIBUTE_INDEX(4), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0003, ZAP_ATTRIBUTE_INDEX(18), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + }, /* Endpoint: 1, Cluster: Identify (client) */ \ + { 0x0004, ZAP_ATTRIBUTE_INDEX(19), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: Groups (client) */ \ + { 0x0004, \ + ZAP_ATTRIBUTE_INDEX(20), \ + 2, \ + 3, \ + ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ + chipFuncArrayGroupsServer }, /* Endpoint: 1, Cluster: Groups (server) */ \ + { 0x0005, ZAP_ATTRIBUTE_INDEX(22), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: Scenes (client) */ \ + { 0x0005, \ + ZAP_ATTRIBUTE_INDEX(23), \ + 6, \ + 8, \ + ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ + chipFuncArrayScenesServer }, /* Endpoint: 1, Cluster: Scenes (server) */ \ + { 0x0006, ZAP_ATTRIBUTE_INDEX(29), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: On/off (client) */ \ + { 0x0006, \ + ZAP_ATTRIBUTE_INDEX(30), \ + 7, \ + 13, \ + ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ + chipFuncArrayOnOffServer }, /* Endpoint: 1, Cluster: On/off (server) */ \ + { \ + 0x0008, ZAP_ATTRIBUTE_INDEX(37), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Level Control (client) */ \ + { 0x0008, \ + ZAP_ATTRIBUTE_INDEX(38), \ + 2, \ + 3, \ + ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ + chipFuncArrayLevelControlServer }, /* Endpoint: 1, Cluster: Level Control (server) */ \ { \ - 0x000F, ZAP_ATTRIBUTE_INDEX(5), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x000F, ZAP_ATTRIBUTE_INDEX(40), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Binary Input (Basic) (client) */ \ { \ - 0x001D, ZAP_ATTRIBUTE_INDEX(6), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x001D, ZAP_ATTRIBUTE_INDEX(41), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Descriptor (client) */ \ - { 0x0028, ZAP_ATTRIBUTE_INDEX(7), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: Basic (client) */ \ + { 0x0028, ZAP_ATTRIBUTE_INDEX(42), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: Basic (client) */ \ { \ - 0x0029, ZAP_ATTRIBUTE_INDEX(8), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0029, ZAP_ATTRIBUTE_INDEX(43), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: OTA Software Update Provider (client) */ \ { \ - 0x0030, ZAP_ATTRIBUTE_INDEX(9), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0030, ZAP_ATTRIBUTE_INDEX(44), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: General Commissioning (client) */ \ { \ - 0x0031, ZAP_ATTRIBUTE_INDEX(10), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0031, ZAP_ATTRIBUTE_INDEX(45), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Network Commissioning (client) */ \ { \ - 0x0032, ZAP_ATTRIBUTE_INDEX(11), 0, 0, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0032, ZAP_ATTRIBUTE_INDEX(46), 0, 0, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Diagnostic Logs (client) */ \ { \ - 0x0033, ZAP_ATTRIBUTE_INDEX(11), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0033, ZAP_ATTRIBUTE_INDEX(46), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: General Diagnostics (client) */ \ { \ - 0x0034, ZAP_ATTRIBUTE_INDEX(12), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0034, ZAP_ATTRIBUTE_INDEX(47), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Software Diagnostics (client) */ \ { \ - 0x0035, ZAP_ATTRIBUTE_INDEX(13), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0035, ZAP_ATTRIBUTE_INDEX(48), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Thread Network Diagnostics (client) */ \ { \ - 0x0036, ZAP_ATTRIBUTE_INDEX(14), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0036, ZAP_ATTRIBUTE_INDEX(49), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: WiFi Network Diagnostics (client) */ \ { \ - 0x0037, ZAP_ATTRIBUTE_INDEX(15), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0037, ZAP_ATTRIBUTE_INDEX(50), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Ethernet Network Diagnostics (client) */ \ { \ - 0x0039, ZAP_ATTRIBUTE_INDEX(16), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0039, ZAP_ATTRIBUTE_INDEX(51), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Bridged Device Basic (client) */ \ - { 0x003B, ZAP_ATTRIBUTE_INDEX(17), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: Switch (client) */ \ + { 0x003B, ZAP_ATTRIBUTE_INDEX(52), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL }, /* Endpoint: 1, Cluster: Switch (client) */ \ { \ - 0x003E, ZAP_ATTRIBUTE_INDEX(18), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x003E, ZAP_ATTRIBUTE_INDEX(53), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Operational Credentials (client) */ \ { \ - 0x0040, ZAP_ATTRIBUTE_INDEX(19), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0040, ZAP_ATTRIBUTE_INDEX(54), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Fixed Label (client) */ \ { \ - 0x0101, ZAP_ATTRIBUTE_INDEX(20), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0101, ZAP_ATTRIBUTE_INDEX(55), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Door Lock (client) */ \ { \ - 0x0102, ZAP_ATTRIBUTE_INDEX(21), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0102, ZAP_ATTRIBUTE_INDEX(56), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Window Covering (client) */ \ { \ - 0x0103, ZAP_ATTRIBUTE_INDEX(22), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0103, ZAP_ATTRIBUTE_INDEX(57), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Barrier Control (client) */ \ { \ - 0x0200, ZAP_ATTRIBUTE_INDEX(23), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0200, ZAP_ATTRIBUTE_INDEX(58), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Pump Configuration and Control (client) */ \ { \ - 0x0201, ZAP_ATTRIBUTE_INDEX(24), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0201, ZAP_ATTRIBUTE_INDEX(59), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Thermostat (client) */ \ { \ - 0x0300, ZAP_ATTRIBUTE_INDEX(25), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0300, ZAP_ATTRIBUTE_INDEX(60), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Color Control (client) */ \ { \ - 0x0402, ZAP_ATTRIBUTE_INDEX(26), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0402, ZAP_ATTRIBUTE_INDEX(61), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Temperature Measurement (client) */ \ { \ - 0x0403, ZAP_ATTRIBUTE_INDEX(27), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0403, ZAP_ATTRIBUTE_INDEX(62), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Pressure Measurement (client) */ \ { \ - 0x0404, ZAP_ATTRIBUTE_INDEX(28), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0404, ZAP_ATTRIBUTE_INDEX(63), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Flow Measurement (client) */ \ { \ - 0x0405, ZAP_ATTRIBUTE_INDEX(29), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0405, ZAP_ATTRIBUTE_INDEX(64), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Relative Humidity Measurement (client) */ \ { \ - 0x0406, ZAP_ATTRIBUTE_INDEX(30), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0406, ZAP_ATTRIBUTE_INDEX(65), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Occupancy Sensing (client) */ \ { \ - 0x0503, ZAP_ATTRIBUTE_INDEX(31), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0503, ZAP_ATTRIBUTE_INDEX(66), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Wake on LAN (client) */ \ { \ - 0x0504, ZAP_ATTRIBUTE_INDEX(32), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0504, ZAP_ATTRIBUTE_INDEX(67), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: TV Channel (client) */ \ { \ - 0x0505, ZAP_ATTRIBUTE_INDEX(33), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0505, ZAP_ATTRIBUTE_INDEX(68), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Target Navigator (client) */ \ { \ - 0x0506, ZAP_ATTRIBUTE_INDEX(34), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0506, ZAP_ATTRIBUTE_INDEX(69), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Media Playback (client) */ \ { \ - 0x0507, ZAP_ATTRIBUTE_INDEX(35), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0507, ZAP_ATTRIBUTE_INDEX(70), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Media Input (client) */ \ { \ - 0x0508, ZAP_ATTRIBUTE_INDEX(36), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0508, ZAP_ATTRIBUTE_INDEX(71), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Low Power (client) */ \ { \ - 0x0509, ZAP_ATTRIBUTE_INDEX(37), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0509, ZAP_ATTRIBUTE_INDEX(72), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Keypad Input (client) */ \ { \ - 0x050A, ZAP_ATTRIBUTE_INDEX(38), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x050A, ZAP_ATTRIBUTE_INDEX(73), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Content Launcher (client) */ \ { \ - 0x050B, ZAP_ATTRIBUTE_INDEX(39), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x050B, ZAP_ATTRIBUTE_INDEX(74), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Audio Output (client) */ \ { \ - 0x050C, ZAP_ATTRIBUTE_INDEX(40), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x050C, ZAP_ATTRIBUTE_INDEX(75), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Application Launcher (client) */ \ { \ - 0x050D, ZAP_ATTRIBUTE_INDEX(41), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x050D, ZAP_ATTRIBUTE_INDEX(76), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Application Basic (client) */ \ { \ - 0x050E, ZAP_ATTRIBUTE_INDEX(42), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x050E, ZAP_ATTRIBUTE_INDEX(77), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Account Login (client) */ \ { \ - 0x050F, ZAP_ATTRIBUTE_INDEX(43), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x050F, ZAP_ATTRIBUTE_INDEX(78), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Test Cluster (client) */ \ { \ - 0x0B04, ZAP_ATTRIBUTE_INDEX(44), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0x0B04, ZAP_ATTRIBUTE_INDEX(79), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Electrical Measurement (client) */ \ { \ - 0xF000, ZAP_ATTRIBUTE_INDEX(45), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0xF000, ZAP_ATTRIBUTE_INDEX(80), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Binding (client) */ \ { \ - 0xF004, ZAP_ATTRIBUTE_INDEX(46), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ + 0xF004, ZAP_ATTRIBUTE_INDEX(81), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 1, Cluster: Group Key Management (client) */ \ } @@ -360,66 +591,112 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 48, 94 }, \ + { ZAP_CLUSTER_INDEX(0), 4, 516 }, { ZAP_CLUSTER_INDEX(4), 52, 121 }, \ } // Largest attribute size is needed for various buffers -#define ATTRIBUTE_LARGEST (3) +#define ATTRIBUTE_LARGEST (255) // Total size of singleton attributes -#define ATTRIBUTE_SINGLETONS_SIZE (4) +#define ATTRIBUTE_SINGLETONS_SIZE (244) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (94) +#define ATTRIBUTE_MAX_SIZE (637) // Number of fixed endpoints -#define FIXED_ENDPOINT_COUNT (1) +#define FIXED_ENDPOINT_COUNT (2) // Array of endpoints that are supported, the data inside // the array is the endpoint number. #define FIXED_ENDPOINT_ARRAY \ { \ - 0x0001 \ + 0x0000, 0x0001 \ } // Array of profile ids #define FIXED_PROFILE_IDS \ { \ - 0x0103 \ + 0x0103, 0x0103 \ } // Array of device ids #define FIXED_DEVICE_IDS \ { \ - 0 \ + 0, 0 \ } // Array of device versions #define FIXED_DEVICE_VERSIONS \ { \ - 1 \ + 1, 1 \ } // Array of endpoint types supported on each endpoint #define FIXED_ENDPOINT_TYPES \ { \ - 0 \ + 0, 1 \ } // Array of networks supported on each endpoint #define FIXED_NETWORKS \ { \ - 0 \ + 0, 0 \ } // Array of EmberAfCommandMetadata structs. #define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask -#define EMBER_AF_GENERATED_COMMAND_COUNT (228) +#define EMBER_AF_GENERATED_COMMAND_COUNT (295) #define GENERATED_COMMANDS \ { \ \ - /* Endpoint: 1, Cluster: Identify (client) */ \ - { 0x0003, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Identify */ \ + /* Endpoint: 0, Cluster: Basic (server) */ \ + { 0x0028, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* StartUp */ \ + { 0x0028, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* ShutDown */ \ + { 0x0028, 0x02, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* Leave */ \ + { 0x0028, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) | ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* MfgSpecificPing */ \ + \ + /* Endpoint: 0, Cluster: General Commissioning (server) */ \ + { 0x0030, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* ArmFailSafe */ \ + { 0x0030, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* ArmFailSafeResponse */ \ + { 0x0030, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* SetRegulatoryConfig */ \ + { 0x0030, 0x03, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* SetRegulatoryConfigResponse */ \ + { 0x0030, 0x04, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* CommissioningComplete */ \ + { 0x0030, 0x05, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* CommissioningCompleteResponse */ \ + \ + /* Endpoint: 0, Cluster: Network Commissioning (server) */ \ + { 0x0031, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* ScanNetworks */ \ + { 0x0031, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* ScanNetworksResponse */ \ + { 0x0031, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* AddWiFiNetwork */ \ + { 0x0031, 0x03, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* AddWiFiNetworkResponse */ \ + { 0x0031, 0x04, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* UpdateWiFiNetwork */ \ + { 0x0031, 0x05, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* UpdateWiFiNetworkResponse */ \ + { 0x0031, 0x06, 0 }, /* AddThreadNetwork */ \ + { 0x0031, 0x07, 0 }, /* AddThreadNetworkResponse */ \ + { 0x0031, 0x08, 0 }, /* UpdateThreadNetwork */ \ + { 0x0031, 0x09, 0 }, /* UpdateThreadNetworkResponse */ \ + { 0x0031, 0x0A, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveNetwork */ \ + { 0x0031, 0x0B, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* RemoveNetworkResponse */ \ + { 0x0031, 0x0C, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* EnableNetwork */ \ + { 0x0031, 0x0D, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* EnableNetworkResponse */ \ + { 0x0031, 0x0E, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* DisableNetwork */ \ + { 0x0031, 0x0F, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* DisableNetworkResponse */ \ + { 0x0031, 0x10, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* GetLastNetworkCommissioningResult */ \ + \ + /* Endpoint: 0, Cluster: Operational Credentials (server) */ \ + { 0x003E, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* SetFabric */ \ + { 0x003E, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* SetFabricResponse */ \ + { 0x003E, 0x04, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* OpCSRRequest */ \ + { 0x003E, 0x05, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* OpCSRResponse */ \ + { 0x003E, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* AddOpCert */ \ + { 0x003E, 0x08, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* OpCertResponse */ \ + { 0x003E, 0x09, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* UpdateFabricLabel */ \ + { 0x003E, 0x0A, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveFabric */ \ + { 0x003E, 0x0B, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveAllFabrics */ \ + { 0x003E, 0xA1, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* AddTrustedRootCertificate */ \ + { 0x003E, 0xA2, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveTrustedRootCertificate */ \ + \ + /* Endpoint: 1, Cluster: Identify (client) */ \ + { 0x0003, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Identify */ \ { 0x0003, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* IdentifyQueryResponse */ \ { 0x0003, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* IdentifyQuery */ \ \ @@ -433,6 +710,18 @@ { 0x0004, 0x03, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveGroup */ \ { 0x0004, 0x03, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* RemoveGroupResponse */ \ { 0x0004, 0x04, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveAllGroups */ \ + { 0x0004, 0x05, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* AddGroupIfIdentifying */ \ + \ + /* Endpoint: 1, Cluster: Groups (server) */ \ + { 0x0004, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* AddGroup */ \ + { 0x0004, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* AddGroupResponse */ \ + { 0x0004, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* ViewGroup */ \ + { 0x0004, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* ViewGroupResponse */ \ + { 0x0004, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* GetGroupMembership */ \ + { 0x0004, 0x02, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* GetGroupMembershipResponse */ \ + { 0x0004, 0x03, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveGroup */ \ + { 0x0004, 0x03, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* RemoveGroupResponse */ \ + { 0x0004, 0x04, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveAllGroups */ \ { 0x0004, 0x05, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* AddGroupIfIdentifying */ \ \ /* Endpoint: 1, Cluster: Scenes (client) */ \ @@ -448,6 +737,21 @@ { 0x0005, 0x04, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* StoreSceneResponse */ \ { 0x0005, 0x05, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RecallScene */ \ { 0x0005, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* GetSceneMembership */ \ + { 0x0005, 0x06, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* GetSceneMembershipResponse */ \ + \ + /* Endpoint: 1, Cluster: Scenes (server) */ \ + { 0x0005, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* AddScene */ \ + { 0x0005, 0x00, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* AddSceneResponse */ \ + { 0x0005, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* ViewScene */ \ + { 0x0005, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* ViewSceneResponse */ \ + { 0x0005, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveScene */ \ + { 0x0005, 0x02, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* RemoveSceneResponse */ \ + { 0x0005, 0x03, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveAllScenes */ \ + { 0x0005, 0x03, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* RemoveAllScenesResponse */ \ + { 0x0005, 0x04, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* StoreScene */ \ + { 0x0005, 0x04, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* StoreSceneResponse */ \ + { 0x0005, 0x05, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RecallScene */ \ + { 0x0005, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* GetSceneMembership */ \ { 0x0005, 0x06, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* GetSceneMembershipResponse */ \ \ /* Endpoint: 1, Cluster: On/off (client) */ \ @@ -458,6 +762,14 @@ { 0x0006, 0x41, ZAP_COMMAND_MASK(OUTGOING_CLIENT) }, /* OnWithRecallGlobalScene */ \ { 0x0006, 0x42, ZAP_COMMAND_MASK(OUTGOING_CLIENT) }, /* OnWithTimedOff */ \ \ + /* Endpoint: 1, Cluster: On/off (server) */ \ + { 0x0006, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Off */ \ + { 0x0006, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* On */ \ + { 0x0006, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Toggle */ \ + { 0x0006, 0x40, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* OffWithEffect */ \ + { 0x0006, 0x41, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* OnWithRecallGlobalScene */ \ + { 0x0006, 0x42, ZAP_COMMAND_MASK(OUTGOING_SERVER) }, /* OnWithTimedOff */ \ + \ /* Endpoint: 1, Cluster: Level Control (client) */ \ { 0x0008, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* MoveToLevel */ \ { 0x0008, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Move */ \ @@ -466,6 +778,16 @@ { 0x0008, 0x04, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* MoveToLevelWithOnOff */ \ { 0x0008, 0x05, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* MoveWithOnOff */ \ { 0x0008, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* StepWithOnOff */ \ + { 0x0008, 0x07, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* StopWithOnOff */ \ + \ + /* Endpoint: 1, Cluster: Level Control (server) */ \ + { 0x0008, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* MoveToLevel */ \ + { 0x0008, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Move */ \ + { 0x0008, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Step */ \ + { 0x0008, 0x03, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Stop */ \ + { 0x0008, 0x04, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* MoveToLevelWithOnOff */ \ + { 0x0008, 0x05, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* MoveWithOnOff */ \ + { 0x0008, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* StepWithOnOff */ \ { 0x0008, 0x07, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* StopWithOnOff */ \ \ /* Endpoint: 1, Cluster: Basic (client) */ \ @@ -634,14 +956,6 @@ { 0x0300, 0x08, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* MoveColor */ \ { 0x0300, 0x09, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* StepColor */ \ { 0x0300, 0x0A, ZAP_COMMAND_MASK(INCOMING_CLIENT) | ZAP_COMMAND_MASK(OUTGOING_CLIENT) }, /* MoveToColorTemperature */ \ - { 0x0300, 0x40, ZAP_COMMAND_MASK(OUTGOING_CLIENT) }, /* EnhancedMoveToHue */ \ - { 0x0300, 0x41, ZAP_COMMAND_MASK(OUTGOING_CLIENT) }, /* EnhancedMoveHue */ \ - { 0x0300, 0x42, ZAP_COMMAND_MASK(OUTGOING_CLIENT) }, /* EnhancedStepHue */ \ - { 0x0300, 0x43, ZAP_COMMAND_MASK(OUTGOING_CLIENT) }, /* EnhancedMoveToHueAndSaturation */ \ - { 0x0300, 0x44, ZAP_COMMAND_MASK(OUTGOING_CLIENT) }, /* ColorLoopSet */ \ - { 0x0300, 0x47, ZAP_COMMAND_MASK(INCOMING_CLIENT) | ZAP_COMMAND_MASK(OUTGOING_CLIENT) }, /* StopMoveStep */ \ - { 0x0300, 0x4B, ZAP_COMMAND_MASK(INCOMING_CLIENT) | ZAP_COMMAND_MASK(OUTGOING_CLIENT) }, /* MoveColorTemperature */ \ - { 0x0300, 0x4C, ZAP_COMMAND_MASK(INCOMING_CLIENT) | ZAP_COMMAND_MASK(OUTGOING_CLIENT) }, /* StepColorTemperature */ \ \ /* Endpoint: 1, Cluster: TV Channel (client) */ \ { 0x0504, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* ChangeChannel */ \ @@ -725,10 +1039,10 @@ } // Array of EmberAfManufacturerCodeEntry structures for commands. -#define GENERATED_COMMAND_MANUFACTURER_CODE_COUNT (1) +#define GENERATED_COMMAND_MANUFACTURER_CODE_COUNT (2) #define GENERATED_COMMAND_MANUFACTURER_CODES \ { \ - { 43, 4098 }, \ + { 3, 4098 }, { 118, 4098 }, \ } // This is an array of EmberAfManufacturerCodeEntry structures for clusters. @@ -754,10 +1068,20 @@ #define ZAP_REPORT_DIRECTION(x) ZRD(x) // User options for plugin Reporting -#define EMBER_AF_PLUGIN_REPORTING_TABLE_SIZE (0) +#define EMBER_AF_PLUGIN_REPORTING_TABLE_SIZE (2) #define EMBER_AF_PLUGIN_REPORTING_ENABLE_GROUP_BOUND_REPORTS -#define EMBER_AF_GENERATED_REPORTING_CONFIG_DEFAULTS_TABLE_SIZE (0) +#define EMBER_AF_GENERATED_REPORTING_CONFIG_DEFAULTS_TABLE_SIZE (2) #define EMBER_AF_GENERATED_REPORTING_CONFIG_DEFAULTS \ { \ + \ + /* Endpoint: 1, Cluster: On/off (server) */ \ + { \ + ZAP_REPORT_DIRECTION(REPORTED), 0x0001, 0x0006, 0x0000, ZAP_CLUSTER_MASK(SERVER), 0x0000, { { 0, 65344, 0 } } \ + }, /* OnOff */ \ + \ + /* Endpoint: 1, Cluster: Level Control (server) */ \ + { \ + ZAP_REPORT_DIRECTION(REPORTED), 0x0001, 0x0008, 0x0000, ZAP_CLUSTER_MASK(SERVER), 0x0000, { { 0, 65344, 0 } } \ + }, /* current level */ \ } diff --git a/src/controller/data_model/gen/gen_config.h b/src/controller/data_model/gen/gen_config.h index 07d1b5c5bc2969..4104cd0f40e16f 100644 --- a/src/controller/data_model/gen/gen_config.h +++ b/src/controller/data_model/gen/gen_config.h @@ -35,6 +35,7 @@ #define EMBER_AF_AUDIO_OUTPUT_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_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_BINARY_INPUT_BASIC_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_BINDING_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_BRIDGED_DEVICE_BASIC_CLUSTER_CLIENT_ENDPOINT_COUNT (1) @@ -48,24 +49,31 @@ #define EMBER_AF_FIXED_LABEL_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_FLOW_MEASUREMENT_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_GENERAL_COMMISSIONING_CLUSTER_CLIENT_ENDPOINT_COUNT (1) +#define EMBER_AF_GENERAL_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_GENERAL_DIAGNOSTICS_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_GROUP_KEY_MANAGEMENT_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_GROUPS_CLUSTER_CLIENT_ENDPOINT_COUNT (1) +#define EMBER_AF_GROUPS_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_IDENTIFY_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_KEYPAD_INPUT_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_LEVEL_CONTROL_CLUSTER_CLIENT_ENDPOINT_COUNT (1) +#define EMBER_AF_LEVEL_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_LOW_POWER_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_MEDIA_INPUT_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_MEDIA_PLAYBACK_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_NETWORK_COMMISSIONING_CLUSTER_CLIENT_ENDPOINT_COUNT (1) +#define EMBER_AF_NETWORK_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_OTA_PROVIDER_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_OCCUPANCY_SENSING_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_ON_OFF_CLUSTER_CLIENT_ENDPOINT_COUNT (1) +#define EMBER_AF_ON_OFF_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_OPERATIONAL_CREDENTIALS_CLUSTER_CLIENT_ENDPOINT_COUNT (1) +#define EMBER_AF_OPERATIONAL_CREDENTIALS_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_PRESSURE_MEASUREMENT_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_PUMP_CONFIG_CONTROL_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_RELATIVE_HUMIDITY_MEASUREMENT_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_SCENES_CLUSTER_CLIENT_ENDPOINT_COUNT (1) +#define EMBER_AF_SCENES_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_SOFTWARE_DIAGNOSTICS_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_SWITCH_CLUSTER_CLIENT_ENDPOINT_COUNT (1) #define EMBER_AF_TV_CHANNEL_CLUSTER_CLIENT_ENDPOINT_COUNT (1) @@ -104,6 +112,11 @@ #define ZCL_USING_BASIC_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_BASIC_CLIENT +// 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 client side of the Binary Input (Basic) cluster is included #define ZCL_USING_BINARY_INPUT_BASIC_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_BINARY_INPUT_BASIC_CLIENT @@ -156,6 +169,11 @@ #define ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_GENERAL_COMMISSIONING_CLIENT +// Use this macro to check if the server side of the General Commissioning cluster is included +#define ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_GENERAL_COMMISSIONING_SERVER +#define EMBER_AF_PLUGIN_GENERAL_COMMISSIONING + // Use this macro to check if the client side of the General Diagnostics cluster is included #define ZCL_USING_GENERAL_DIAGNOSTICS_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_GENERAL_DIAGNOSTICS_CLIENT @@ -168,6 +186,11 @@ #define ZCL_USING_GROUPS_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_GROUPS_CLIENT +// Use this macro to check if the server side of the Groups cluster is included +#define ZCL_USING_GROUPS_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_GROUPS_SERVER +#define EMBER_AF_PLUGIN_GROUPS + // Use this macro to check if the client side of the Identify cluster is included #define ZCL_USING_IDENTIFY_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_IDENTIFY_CLIENT @@ -180,6 +203,15 @@ #define ZCL_USING_LEVEL_CONTROL_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_LEVEL_CONTROL_CLIENT +// 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 +#define EMBER_AF_PLUGIN_LEVEL_CONTROL +// User options for server plugin Level Control +#define EMBER_AF_PLUGIN_LEVEL_CONTROL_MAXIMUM_LEVEL 255 +#define EMBER_AF_PLUGIN_LEVEL_CONTROL_MINIMUM_LEVEL 0 +#define EMBER_AF_PLUGIN_LEVEL_CONTROL_RATE 0 + // 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 @@ -196,6 +228,11 @@ #define ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING_CLIENT +// 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 client side of the OTA Software Update Provider cluster is included #define ZCL_USING_OTA_PROVIDER_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_OTA_SOFTWARE_UPDATE_PROVIDER_CLIENT @@ -208,10 +245,20 @@ #define ZCL_USING_ON_OFF_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_ON_OFF_CLIENT +// 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 +#define EMBER_AF_PLUGIN_ON_OFF + // Use this macro to check if the client side of the Operational Credentials cluster is included #define ZCL_USING_OPERATIONAL_CREDENTIALS_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_OPERATIONAL_CREDENTIALS_CLIENT +// Use this macro to check if the server side of the Operational Credentials cluster is included +#define ZCL_USING_OPERATIONAL_CREDENTIALS_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_OPERATIONAL_CREDENTIALS_SERVER +#define EMBER_AF_PLUGIN_OPERATIONAL_CREDENTIALS + // Use this macro to check if the client side of the Pressure Measurement cluster is included #define ZCL_USING_PRESSURE_MEASUREMENT_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_PRESSURE_MEASUREMENT_CLIENT @@ -228,6 +275,13 @@ #define ZCL_USING_SCENES_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_SCENES_CLIENT +// Use this macro to check if the server side of the Scenes cluster is included +#define ZCL_USING_SCENES_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_SCENES_SERVER +#define EMBER_AF_PLUGIN_SCENES +// User options for server plugin Scenes +#define EMBER_AF_PLUGIN_SCENES_TABLE_SIZE 3 + // Use this macro to check if the client side of the Software Diagnostics cluster is included #define ZCL_USING_SOFTWARE_DIAGNOSTICS_CLUSTER_CLIENT #define EMBER_AF_PLUGIN_SOFTWARE_DIAGNOSTICS_CLIENT diff --git a/src/controller/java/gen/CHIPClusters-JNI.cpp b/src/controller/java/gen/CHIPClusters-JNI.cpp index 9b947b00c6743e..7a59b5866ef557 100644 --- a/src/controller/java/gen/CHIPClusters-JNI.cpp +++ b/src/controller/java/gen/CHIPClusters-JNI.cpp @@ -10777,244 +10777,6 @@ JNI_METHOD(jlong, ColorControlCluster, initWithDevice)(JNIEnv * env, jobject sel return reinterpret_cast(cppCluster); } -JNI_METHOD(void, ColorControlCluster, colorLoopSet) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint updateFlags, jint action, jint direction, jint time, - jint startHue, jint optionsMask, jint optionsOverride) -{ - StackLockGuard lock(JniReferences::GetInstance().GetStackLock()); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; - - CHIPDefaultSuccessCallback * onSuccess; - CHIPDefaultFailureCallback * onFailure; - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrExit(cppCluster != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - - onSuccess = new CHIPDefaultSuccessCallback(callback); - VerifyOrExit(onSuccess != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - onFailure = new CHIPDefaultFailureCallback(callback); - VerifyOrExit(onFailure != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - - err = cppCluster->ColorLoopSet(onSuccess->Cancel(), onFailure->Cancel(), updateFlags, action, direction, time, startHue, - optionsMask, optionsOverride); - SuccessOrExit(err); - -exit: - if (err != CHIP_NO_ERROR) - { - delete onSuccess; - delete onFailure; - - jthrowable exception; - jmethodID method; - - err = JniReferences::GetInstance().FindMethod(env, callback, "onError", "(Ljava/lang/Exception;)V", &method); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Error throwing IllegalStateException %" CHIP_ERROR_FORMAT, ChipError::FormatError(err)); - return; - } - - err = CreateIllegalStateException(env, "Error invoking cluster", ChipError::FormatError(err), exception); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Error throwing IllegalStateException %" CHIP_ERROR_FORMAT, ChipError::FormatError(err)); - return; - } - env->CallVoidMethod(callback, method, exception); - } -} -JNI_METHOD(void, ColorControlCluster, enhancedMoveHue) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint moveMode, jint rate, jint optionsMask, jint optionsOverride) -{ - StackLockGuard lock(JniReferences::GetInstance().GetStackLock()); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; - - CHIPDefaultSuccessCallback * onSuccess; - CHIPDefaultFailureCallback * onFailure; - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrExit(cppCluster != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - - onSuccess = new CHIPDefaultSuccessCallback(callback); - VerifyOrExit(onSuccess != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - onFailure = new CHIPDefaultFailureCallback(callback); - VerifyOrExit(onFailure != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - - err = cppCluster->EnhancedMoveHue(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride); - SuccessOrExit(err); - -exit: - if (err != CHIP_NO_ERROR) - { - delete onSuccess; - delete onFailure; - - jthrowable exception; - jmethodID method; - - err = JniReferences::GetInstance().FindMethod(env, callback, "onError", "(Ljava/lang/Exception;)V", &method); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Error throwing IllegalStateException %" CHIP_ERROR_FORMAT, ChipError::FormatError(err)); - return; - } - - err = CreateIllegalStateException(env, "Error invoking cluster", ChipError::FormatError(err), exception); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Error throwing IllegalStateException %" CHIP_ERROR_FORMAT, ChipError::FormatError(err)); - return; - } - env->CallVoidMethod(callback, method, exception); - } -} -JNI_METHOD(void, ColorControlCluster, enhancedMoveToHue) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint enhancedHue, jint direction, jint transitionTime, - jint optionsMask, jint optionsOverride) -{ - StackLockGuard lock(JniReferences::GetInstance().GetStackLock()); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; - - CHIPDefaultSuccessCallback * onSuccess; - CHIPDefaultFailureCallback * onFailure; - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrExit(cppCluster != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - - onSuccess = new CHIPDefaultSuccessCallback(callback); - VerifyOrExit(onSuccess != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - onFailure = new CHIPDefaultFailureCallback(callback); - VerifyOrExit(onFailure != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - - err = cppCluster->EnhancedMoveToHue(onSuccess->Cancel(), onFailure->Cancel(), enhancedHue, direction, transitionTime, - optionsMask, optionsOverride); - SuccessOrExit(err); - -exit: - if (err != CHIP_NO_ERROR) - { - delete onSuccess; - delete onFailure; - - jthrowable exception; - jmethodID method; - - err = JniReferences::GetInstance().FindMethod(env, callback, "onError", "(Ljava/lang/Exception;)V", &method); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Error throwing IllegalStateException %" CHIP_ERROR_FORMAT, ChipError::FormatError(err)); - return; - } - - err = CreateIllegalStateException(env, "Error invoking cluster", ChipError::FormatError(err), exception); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Error throwing IllegalStateException %" CHIP_ERROR_FORMAT, ChipError::FormatError(err)); - return; - } - env->CallVoidMethod(callback, method, exception); - } -} -JNI_METHOD(void, ColorControlCluster, enhancedMoveToHueAndSaturation) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint enhancedHue, jint saturation, jint transitionTime, - jint optionsMask, jint optionsOverride) -{ - StackLockGuard lock(JniReferences::GetInstance().GetStackLock()); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; - - CHIPDefaultSuccessCallback * onSuccess; - CHIPDefaultFailureCallback * onFailure; - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrExit(cppCluster != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - - onSuccess = new CHIPDefaultSuccessCallback(callback); - VerifyOrExit(onSuccess != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - onFailure = new CHIPDefaultFailureCallback(callback); - VerifyOrExit(onFailure != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - - err = cppCluster->EnhancedMoveToHueAndSaturation(onSuccess->Cancel(), onFailure->Cancel(), enhancedHue, saturation, - transitionTime, optionsMask, optionsOverride); - SuccessOrExit(err); - -exit: - if (err != CHIP_NO_ERROR) - { - delete onSuccess; - delete onFailure; - - jthrowable exception; - jmethodID method; - - err = JniReferences::GetInstance().FindMethod(env, callback, "onError", "(Ljava/lang/Exception;)V", &method); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Error throwing IllegalStateException %" CHIP_ERROR_FORMAT, ChipError::FormatError(err)); - return; - } - - err = CreateIllegalStateException(env, "Error invoking cluster", ChipError::FormatError(err), exception); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Error throwing IllegalStateException %" CHIP_ERROR_FORMAT, ChipError::FormatError(err)); - return; - } - env->CallVoidMethod(callback, method, exception); - } -} -JNI_METHOD(void, ColorControlCluster, enhancedStepHue) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint stepMode, jint stepSize, jint transitionTime, - jint optionsMask, jint optionsOverride) -{ - StackLockGuard lock(JniReferences::GetInstance().GetStackLock()); - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster; - - CHIPDefaultSuccessCallback * onSuccess; - CHIPDefaultFailureCallback * onFailure; - - cppCluster = reinterpret_cast(clusterPtr); - VerifyOrExit(cppCluster != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - - onSuccess = new CHIPDefaultSuccessCallback(callback); - VerifyOrExit(onSuccess != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - onFailure = new CHIPDefaultFailureCallback(callback); - VerifyOrExit(onFailure != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - - err = cppCluster->EnhancedStepHue(onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, - optionsOverride); - SuccessOrExit(err); - -exit: - if (err != CHIP_NO_ERROR) - { - delete onSuccess; - delete onFailure; - - jthrowable exception; - jmethodID method; - - err = JniReferences::GetInstance().FindMethod(env, callback, "onError", "(Ljava/lang/Exception;)V", &method); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Error throwing IllegalStateException %" CHIP_ERROR_FORMAT, ChipError::FormatError(err)); - return; - } - - err = CreateIllegalStateException(env, "Error invoking cluster", ChipError::FormatError(err), exception); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Error throwing IllegalStateException %" CHIP_ERROR_FORMAT, ChipError::FormatError(err)); - return; - } - env->CallVoidMethod(callback, method, exception); - } -} JNI_METHOD(void, ColorControlCluster, moveColor) (JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint rateX, jint rateY, jint optionsMask, jint optionsOverride) { @@ -13629,308 +13391,6 @@ JNI_METHOD(void, ColorControlCluster, writeColorPointBIntensityAttribute) } } -JNI_METHOD(void, ColorControlCluster, readEnhancedCurrentHueAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback) -{ - StackLockGuard lock(JniReferences::GetInstance().GetStackLock()); - CHIPInt16uAttributeCallback * onSuccess = new CHIPInt16uAttributeCallback(callback); - if (!onSuccess) - { - ReturnIllegalStateException(env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY); - return; - } - - CHIPDefaultFailureCallback * onFailure = new CHIPDefaultFailureCallback(callback); - if (!onFailure) - { - delete onSuccess; - ReturnIllegalStateException(env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY); - return; - } - - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - if (cppCluster == nullptr) - { - delete onSuccess; - delete onFailure; - ReturnIllegalStateException(env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE); - return; - } - - err = cppCluster->ReadAttributeEnhancedCurrentHue(onSuccess->Cancel(), onFailure->Cancel()); - if (err != CHIP_NO_ERROR) - { - delete onSuccess; - delete onFailure; - ReturnIllegalStateException(env, callback, "Error reading attribute", err); - } -} - -JNI_METHOD(void, ColorControlCluster, readEnhancedColorModeAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback) -{ - StackLockGuard lock(JniReferences::GetInstance().GetStackLock()); - CHIPInt8uAttributeCallback * onSuccess = new CHIPInt8uAttributeCallback(callback); - if (!onSuccess) - { - ReturnIllegalStateException(env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY); - return; - } - - CHIPDefaultFailureCallback * onFailure = new CHIPDefaultFailureCallback(callback); - if (!onFailure) - { - delete onSuccess; - ReturnIllegalStateException(env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY); - return; - } - - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - if (cppCluster == nullptr) - { - delete onSuccess; - delete onFailure; - ReturnIllegalStateException(env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE); - return; - } - - err = cppCluster->ReadAttributeEnhancedColorMode(onSuccess->Cancel(), onFailure->Cancel()); - if (err != CHIP_NO_ERROR) - { - delete onSuccess; - delete onFailure; - ReturnIllegalStateException(env, callback, "Error reading attribute", err); - } -} - -JNI_METHOD(void, ColorControlCluster, readColorLoopActiveAttribute)(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback) -{ - StackLockGuard lock(JniReferences::GetInstance().GetStackLock()); - CHIPInt8uAttributeCallback * onSuccess = new CHIPInt8uAttributeCallback(callback); - if (!onSuccess) - { - ReturnIllegalStateException(env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY); - return; - } - - CHIPDefaultFailureCallback * onFailure = new CHIPDefaultFailureCallback(callback); - if (!onFailure) - { - delete onSuccess; - ReturnIllegalStateException(env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY); - return; - } - - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - if (cppCluster == nullptr) - { - delete onSuccess; - delete onFailure; - ReturnIllegalStateException(env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE); - return; - } - - err = cppCluster->ReadAttributeColorLoopActive(onSuccess->Cancel(), onFailure->Cancel()); - if (err != CHIP_NO_ERROR) - { - delete onSuccess; - delete onFailure; - ReturnIllegalStateException(env, callback, "Error reading attribute", err); - } -} - -JNI_METHOD(void, ColorControlCluster, readColorLoopDirectionAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback) -{ - StackLockGuard lock(JniReferences::GetInstance().GetStackLock()); - CHIPInt8uAttributeCallback * onSuccess = new CHIPInt8uAttributeCallback(callback); - if (!onSuccess) - { - ReturnIllegalStateException(env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY); - return; - } - - CHIPDefaultFailureCallback * onFailure = new CHIPDefaultFailureCallback(callback); - if (!onFailure) - { - delete onSuccess; - ReturnIllegalStateException(env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY); - return; - } - - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - if (cppCluster == nullptr) - { - delete onSuccess; - delete onFailure; - ReturnIllegalStateException(env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE); - return; - } - - err = cppCluster->ReadAttributeColorLoopDirection(onSuccess->Cancel(), onFailure->Cancel()); - if (err != CHIP_NO_ERROR) - { - delete onSuccess; - delete onFailure; - ReturnIllegalStateException(env, callback, "Error reading attribute", err); - } -} - -JNI_METHOD(void, ColorControlCluster, readColorLoopTimeAttribute)(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback) -{ - StackLockGuard lock(JniReferences::GetInstance().GetStackLock()); - CHIPInt16uAttributeCallback * onSuccess = new CHIPInt16uAttributeCallback(callback); - if (!onSuccess) - { - ReturnIllegalStateException(env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY); - return; - } - - CHIPDefaultFailureCallback * onFailure = new CHIPDefaultFailureCallback(callback); - if (!onFailure) - { - delete onSuccess; - ReturnIllegalStateException(env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY); - return; - } - - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - if (cppCluster == nullptr) - { - delete onSuccess; - delete onFailure; - ReturnIllegalStateException(env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE); - return; - } - - err = cppCluster->ReadAttributeColorLoopTime(onSuccess->Cancel(), onFailure->Cancel()); - if (err != CHIP_NO_ERROR) - { - delete onSuccess; - delete onFailure; - ReturnIllegalStateException(env, callback, "Error reading attribute", err); - } -} - -JNI_METHOD(void, ColorControlCluster, readColorCapabilitiesAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback) -{ - StackLockGuard lock(JniReferences::GetInstance().GetStackLock()); - CHIPInt16uAttributeCallback * onSuccess = new CHIPInt16uAttributeCallback(callback); - if (!onSuccess) - { - ReturnIllegalStateException(env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY); - return; - } - - CHIPDefaultFailureCallback * onFailure = new CHIPDefaultFailureCallback(callback); - if (!onFailure) - { - delete onSuccess; - ReturnIllegalStateException(env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY); - return; - } - - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - if (cppCluster == nullptr) - { - delete onSuccess; - delete onFailure; - ReturnIllegalStateException(env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE); - return; - } - - err = cppCluster->ReadAttributeColorCapabilities(onSuccess->Cancel(), onFailure->Cancel()); - if (err != CHIP_NO_ERROR) - { - delete onSuccess; - delete onFailure; - ReturnIllegalStateException(env, callback, "Error reading attribute", err); - } -} - -JNI_METHOD(void, ColorControlCluster, readColorTempPhysicalMinAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback) -{ - StackLockGuard lock(JniReferences::GetInstance().GetStackLock()); - CHIPInt16uAttributeCallback * onSuccess = new CHIPInt16uAttributeCallback(callback); - if (!onSuccess) - { - ReturnIllegalStateException(env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY); - return; - } - - CHIPDefaultFailureCallback * onFailure = new CHIPDefaultFailureCallback(callback); - if (!onFailure) - { - delete onSuccess; - ReturnIllegalStateException(env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY); - return; - } - - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - if (cppCluster == nullptr) - { - delete onSuccess; - delete onFailure; - ReturnIllegalStateException(env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE); - return; - } - - err = cppCluster->ReadAttributeColorTempPhysicalMin(onSuccess->Cancel(), onFailure->Cancel()); - if (err != CHIP_NO_ERROR) - { - delete onSuccess; - delete onFailure; - ReturnIllegalStateException(env, callback, "Error reading attribute", err); - } -} - -JNI_METHOD(void, ColorControlCluster, readColorTempPhysicalMaxAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback) -{ - StackLockGuard lock(JniReferences::GetInstance().GetStackLock()); - CHIPInt16uAttributeCallback * onSuccess = new CHIPInt16uAttributeCallback(callback); - if (!onSuccess) - { - ReturnIllegalStateException(env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY); - return; - } - - CHIPDefaultFailureCallback * onFailure = new CHIPDefaultFailureCallback(callback); - if (!onFailure) - { - delete onSuccess; - ReturnIllegalStateException(env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY); - return; - } - - CHIP_ERROR err = CHIP_NO_ERROR; - ColorControlCluster * cppCluster = reinterpret_cast(clusterPtr); - if (cppCluster == nullptr) - { - delete onSuccess; - delete onFailure; - ReturnIllegalStateException(env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE); - return; - } - - err = cppCluster->ReadAttributeColorTempPhysicalMax(onSuccess->Cancel(), onFailure->Cancel()); - if (err != CHIP_NO_ERROR) - { - delete onSuccess; - delete onFailure; - ReturnIllegalStateException(env, callback, "Error reading attribute", err); - } -} - JNI_METHOD(void, ColorControlCluster, readCoupleColorTempToLevelMinMiredsAttribute) (JNIEnv * env, jobject self, jlong clusterPtr, jobject callback) { diff --git a/src/controller/java/gen/ChipClusters.java b/src/controller/java/gen/ChipClusters.java index f2539ba4effba5..cc4b11bd65e7f8 100644 --- a/src/controller/java/gen/ChipClusters.java +++ b/src/controller/java/gen/ChipClusters.java @@ -770,87 +770,6 @@ public ColorControlCluster(long devicePtr, int endpointId) { @Override public native long initWithDevice(long devicePtr, int endpointId); - public void colorLoopSet( - DefaultClusterCallback callback, - int updateFlags, - int action, - int direction, - int time, - int startHue, - int optionsMask, - int optionsOverride) { - colorLoopSet( - chipClusterPtr, - callback, - updateFlags, - action, - direction, - time, - startHue, - optionsMask, - optionsOverride); - } - - public void enhancedMoveHue( - DefaultClusterCallback callback, - int moveMode, - int rate, - int optionsMask, - int optionsOverride) { - enhancedMoveHue(chipClusterPtr, callback, moveMode, rate, optionsMask, optionsOverride); - } - - public void enhancedMoveToHue( - DefaultClusterCallback callback, - int enhancedHue, - int direction, - int transitionTime, - int optionsMask, - int optionsOverride) { - enhancedMoveToHue( - chipClusterPtr, - callback, - enhancedHue, - direction, - transitionTime, - optionsMask, - optionsOverride); - } - - public void enhancedMoveToHueAndSaturation( - DefaultClusterCallback callback, - int enhancedHue, - int saturation, - int transitionTime, - int optionsMask, - int optionsOverride) { - enhancedMoveToHueAndSaturation( - chipClusterPtr, - callback, - enhancedHue, - saturation, - transitionTime, - optionsMask, - optionsOverride); - } - - public void enhancedStepHue( - DefaultClusterCallback callback, - int stepMode, - int stepSize, - int transitionTime, - int optionsMask, - int optionsOverride) { - enhancedStepHue( - chipClusterPtr, - callback, - stepMode, - stepSize, - transitionTime, - optionsMask, - optionsOverride); - } - public void moveColor( DefaultClusterCallback callback, int rateX, @@ -1021,52 +940,6 @@ public void stopMoveStep( stopMoveStep(chipClusterPtr, callback, optionsMask, optionsOverride); } - private native void colorLoopSet( - long chipClusterPtr, - DefaultClusterCallback callback, - int updateFlags, - int action, - int direction, - int time, - int startHue, - int optionsMask, - int optionsOverride); - - private native void enhancedMoveHue( - long chipClusterPtr, - DefaultClusterCallback callback, - int moveMode, - int rate, - int optionsMask, - int optionsOverride); - - private native void enhancedMoveToHue( - long chipClusterPtr, - DefaultClusterCallback callback, - int enhancedHue, - int direction, - int transitionTime, - int optionsMask, - int optionsOverride); - - private native void enhancedMoveToHueAndSaturation( - long chipClusterPtr, - DefaultClusterCallback callback, - int enhancedHue, - int saturation, - int transitionTime, - int optionsMask, - int optionsOverride); - - private native void enhancedStepHue( - long chipClusterPtr, - DefaultClusterCallback callback, - int stepMode, - int stepSize, - int transitionTime, - int optionsMask, - int optionsOverride); - private native void moveColor( long chipClusterPtr, DefaultClusterCallback callback, @@ -1393,38 +1266,6 @@ public void writeColorPointBIntensityAttribute(DefaultClusterCallback callback, writeColorPointBIntensityAttribute(chipClusterPtr, callback, value); } - public void readEnhancedCurrentHueAttribute(IntegerAttributeCallback callback) { - readEnhancedCurrentHueAttribute(chipClusterPtr, callback); - } - - public void readEnhancedColorModeAttribute(IntegerAttributeCallback callback) { - readEnhancedColorModeAttribute(chipClusterPtr, callback); - } - - public void readColorLoopActiveAttribute(IntegerAttributeCallback callback) { - readColorLoopActiveAttribute(chipClusterPtr, callback); - } - - public void readColorLoopDirectionAttribute(IntegerAttributeCallback callback) { - readColorLoopDirectionAttribute(chipClusterPtr, callback); - } - - public void readColorLoopTimeAttribute(IntegerAttributeCallback callback) { - readColorLoopTimeAttribute(chipClusterPtr, callback); - } - - public void readColorCapabilitiesAttribute(IntegerAttributeCallback callback) { - readColorCapabilitiesAttribute(chipClusterPtr, callback); - } - - public void readColorTempPhysicalMinAttribute(IntegerAttributeCallback callback) { - readColorTempPhysicalMinAttribute(chipClusterPtr, callback); - } - - public void readColorTempPhysicalMaxAttribute(IntegerAttributeCallback callback) { - readColorTempPhysicalMaxAttribute(chipClusterPtr, callback); - } - public void readCoupleColorTempToLevelMinMiredsAttribute(IntegerAttributeCallback callback) { readCoupleColorTempToLevelMinMiredsAttribute(chipClusterPtr, callback); } @@ -1598,30 +1439,6 @@ private native void readColorPointBIntensityAttribute( private native void writeColorPointBIntensityAttribute( long chipClusterPtr, DefaultClusterCallback callback, int value); - private native void readEnhancedCurrentHueAttribute( - long chipClusterPtr, IntegerAttributeCallback callback); - - private native void readEnhancedColorModeAttribute( - long chipClusterPtr, IntegerAttributeCallback callback); - - private native void readColorLoopActiveAttribute( - long chipClusterPtr, IntegerAttributeCallback callback); - - private native void readColorLoopDirectionAttribute( - long chipClusterPtr, IntegerAttributeCallback callback); - - private native void readColorLoopTimeAttribute( - long chipClusterPtr, IntegerAttributeCallback callback); - - private native void readColorCapabilitiesAttribute( - long chipClusterPtr, IntegerAttributeCallback callback); - - private native void readColorTempPhysicalMinAttribute( - long chipClusterPtr, IntegerAttributeCallback callback); - - private native void readColorTempPhysicalMaxAttribute( - long chipClusterPtr, IntegerAttributeCallback callback); - private native void readCoupleColorTempToLevelMinMiredsAttribute( long chipClusterPtr, IntegerAttributeCallback callback); diff --git a/src/controller/python/chip/clusters/CHIPClusters.cpp b/src/controller/python/chip/clusters/CHIPClusters.cpp index 815ad51a7f4ea4..09252ae419c926 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.cpp +++ b/src/controller/python/chip/clusters/CHIPClusters.cpp @@ -1209,62 +1209,6 @@ chip::ChipError::StorageType chip_ime_ReadAttribute_BridgedDeviceBasic_ClusterRe // End of Cluster BridgedDeviceBasic // Cluster ColorControl -chip::ChipError::StorageType chip_ime_AppendCommand_ColorControl_ColorLoopSet(chip::Controller::Device * device, - chip::EndpointId ZCLendpointId, chip::GroupId, - uint8_t updateFlags, uint8_t action, - uint8_t direction, uint16_t time, uint16_t startHue, - uint8_t optionsMask, uint8_t optionsOverride) -{ - VerifyOrReturnError(device != nullptr, chip::ChipError::AsInteger(CHIP_ERROR_INVALID_ARGUMENT)); - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, ZCLendpointId); - return chip::ChipError::AsInteger( - cluster.ColorLoopSet(nullptr, nullptr, updateFlags, action, direction, time, startHue, optionsMask, optionsOverride)); -} -chip::ChipError::StorageType chip_ime_AppendCommand_ColorControl_EnhancedMoveHue(chip::Controller::Device * device, - chip::EndpointId ZCLendpointId, chip::GroupId, - uint8_t moveMode, uint16_t rate, - uint8_t optionsMask, uint8_t optionsOverride) -{ - VerifyOrReturnError(device != nullptr, chip::ChipError::AsInteger(CHIP_ERROR_INVALID_ARGUMENT)); - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, ZCLendpointId); - return chip::ChipError::AsInteger(cluster.EnhancedMoveHue(nullptr, nullptr, moveMode, rate, optionsMask, optionsOverride)); -} -chip::ChipError::StorageType chip_ime_AppendCommand_ColorControl_EnhancedMoveToHue(chip::Controller::Device * device, - chip::EndpointId ZCLendpointId, chip::GroupId, - uint16_t enhancedHue, uint8_t direction, - uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - VerifyOrReturnError(device != nullptr, chip::ChipError::AsInteger(CHIP_ERROR_INVALID_ARGUMENT)); - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, ZCLendpointId); - return chip::ChipError::AsInteger( - cluster.EnhancedMoveToHue(nullptr, nullptr, enhancedHue, direction, transitionTime, optionsMask, optionsOverride)); -} -chip::ChipError::StorageType chip_ime_AppendCommand_ColorControl_EnhancedMoveToHueAndSaturation( - chip::Controller::Device * device, chip::EndpointId ZCLendpointId, chip::GroupId, uint16_t enhancedHue, uint8_t saturation, - uint16_t transitionTime, uint8_t optionsMask, uint8_t optionsOverride) -{ - VerifyOrReturnError(device != nullptr, chip::ChipError::AsInteger(CHIP_ERROR_INVALID_ARGUMENT)); - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, ZCLendpointId); - return chip::ChipError::AsInteger(cluster.EnhancedMoveToHueAndSaturation(nullptr, nullptr, enhancedHue, saturation, - transitionTime, optionsMask, optionsOverride)); -} -chip::ChipError::StorageType chip_ime_AppendCommand_ColorControl_EnhancedStepHue(chip::Controller::Device * device, - chip::EndpointId ZCLendpointId, chip::GroupId, - uint8_t stepMode, uint16_t stepSize, - uint16_t transitionTime, uint8_t optionsMask, - uint8_t optionsOverride) -{ - VerifyOrReturnError(device != nullptr, chip::ChipError::AsInteger(CHIP_ERROR_INVALID_ARGUMENT)); - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, ZCLendpointId); - return chip::ChipError::AsInteger( - cluster.EnhancedStepHue(nullptr, nullptr, stepMode, stepSize, transitionTime, optionsMask, optionsOverride)); -} chip::ChipError::StorageType chip_ime_AppendCommand_ColorControl_MoveColor(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, chip::GroupId, int16_t rateX, int16_t rateY, uint8_t optionsMask, @@ -2035,94 +1979,6 @@ chip::ChipError::StorageType chip_ime_WriteAttribute_ColorControl_ColorPointBInt return ChipError::AsInteger( cluster.WriteAttributeColorPointBIntensity(gDefaultSuccessCallback.Cancel(), gDefaultFailureCallback.Cancel(), value)); } -chip::ChipError::StorageType chip_ime_ReadAttribute_ColorControl_EnhancedCurrentHue(chip::Controller::Device * device, - chip::EndpointId ZCLendpointId, - chip::GroupId /* ZCLgroupId */) -{ - VerifyOrReturnError(device != nullptr, chip::ChipError::AsInteger(CHIP_ERROR_INVALID_ARGUMENT)); - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, ZCLendpointId); - return chip::ChipError::AsInteger( - cluster.ReadAttributeEnhancedCurrentHue(gInt16uAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel())); -} - -chip::ChipError::StorageType chip_ime_ReadAttribute_ColorControl_EnhancedColorMode(chip::Controller::Device * device, - chip::EndpointId ZCLendpointId, - chip::GroupId /* ZCLgroupId */) -{ - VerifyOrReturnError(device != nullptr, chip::ChipError::AsInteger(CHIP_ERROR_INVALID_ARGUMENT)); - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, ZCLendpointId); - return chip::ChipError::AsInteger( - cluster.ReadAttributeEnhancedColorMode(gInt8uAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel())); -} - -chip::ChipError::StorageType chip_ime_ReadAttribute_ColorControl_ColorLoopActive(chip::Controller::Device * device, - chip::EndpointId ZCLendpointId, - chip::GroupId /* ZCLgroupId */) -{ - VerifyOrReturnError(device != nullptr, chip::ChipError::AsInteger(CHIP_ERROR_INVALID_ARGUMENT)); - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, ZCLendpointId); - return chip::ChipError::AsInteger( - cluster.ReadAttributeColorLoopActive(gInt8uAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel())); -} - -chip::ChipError::StorageType chip_ime_ReadAttribute_ColorControl_ColorLoopDirection(chip::Controller::Device * device, - chip::EndpointId ZCLendpointId, - chip::GroupId /* ZCLgroupId */) -{ - VerifyOrReturnError(device != nullptr, chip::ChipError::AsInteger(CHIP_ERROR_INVALID_ARGUMENT)); - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, ZCLendpointId); - return chip::ChipError::AsInteger( - cluster.ReadAttributeColorLoopDirection(gInt8uAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel())); -} - -chip::ChipError::StorageType chip_ime_ReadAttribute_ColorControl_ColorLoopTime(chip::Controller::Device * device, - chip::EndpointId ZCLendpointId, - chip::GroupId /* ZCLgroupId */) -{ - VerifyOrReturnError(device != nullptr, chip::ChipError::AsInteger(CHIP_ERROR_INVALID_ARGUMENT)); - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, ZCLendpointId); - return chip::ChipError::AsInteger( - cluster.ReadAttributeColorLoopTime(gInt16uAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel())); -} - -chip::ChipError::StorageType chip_ime_ReadAttribute_ColorControl_ColorCapabilities(chip::Controller::Device * device, - chip::EndpointId ZCLendpointId, - chip::GroupId /* ZCLgroupId */) -{ - VerifyOrReturnError(device != nullptr, chip::ChipError::AsInteger(CHIP_ERROR_INVALID_ARGUMENT)); - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, ZCLendpointId); - return chip::ChipError::AsInteger( - cluster.ReadAttributeColorCapabilities(gInt16uAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel())); -} - -chip::ChipError::StorageType chip_ime_ReadAttribute_ColorControl_ColorTempPhysicalMin(chip::Controller::Device * device, - chip::EndpointId ZCLendpointId, - chip::GroupId /* ZCLgroupId */) -{ - VerifyOrReturnError(device != nullptr, chip::ChipError::AsInteger(CHIP_ERROR_INVALID_ARGUMENT)); - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, ZCLendpointId); - return chip::ChipError::AsInteger( - cluster.ReadAttributeColorTempPhysicalMin(gInt16uAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel())); -} - -chip::ChipError::StorageType chip_ime_ReadAttribute_ColorControl_ColorTempPhysicalMax(chip::Controller::Device * device, - chip::EndpointId ZCLendpointId, - chip::GroupId /* ZCLgroupId */) -{ - VerifyOrReturnError(device != nullptr, chip::ChipError::AsInteger(CHIP_ERROR_INVALID_ARGUMENT)); - chip::Controller::ColorControlCluster cluster; - cluster.Associate(device, ZCLendpointId); - return chip::ChipError::AsInteger( - cluster.ReadAttributeColorTempPhysicalMax(gInt16uAttributeCallback.Cancel(), gDefaultFailureCallback.Cancel())); -} - chip::ChipError::StorageType chip_ime_ReadAttribute_ColorControl_CoupleColorTempToLevelMinMireds(chip::Controller::Device * device, chip::EndpointId ZCLendpointId, chip::GroupId /* ZCLgroupId */) diff --git a/src/controller/python/chip/clusters/CHIPClusters.py b/src/controller/python/chip/clusters/CHIPClusters.py index 028ffe8920fb1a..d0f430e415b149 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.py +++ b/src/controller/python/chip/clusters/CHIPClusters.py @@ -98,42 +98,6 @@ def ListClusterCommands(self): "BridgedDeviceBasic": { }, "ColorControl": { - "ColorLoopSet": { - "updateFlags": "int", - "action": "int", - "direction": "int", - "time": "int", - "startHue": "int", - "optionsMask": "int", - "optionsOverride": "int", - }, - "EnhancedMoveHue": { - "moveMode": "int", - "rate": "int", - "optionsMask": "int", - "optionsOverride": "int", - }, - "EnhancedMoveToHue": { - "enhancedHue": "int", - "direction": "int", - "transitionTime": "int", - "optionsMask": "int", - "optionsOverride": "int", - }, - "EnhancedMoveToHueAndSaturation": { - "enhancedHue": "int", - "saturation": "int", - "transitionTime": "int", - "optionsMask": "int", - "optionsOverride": "int", - }, - "EnhancedStepHue": { - "stepMode": "int", - "stepSize": "int", - "transitionTime": "int", - "optionsMask": "int", - "optionsOverride": "int", - }, "MoveColor": { "rateX": "int", "rateY": "int", @@ -1180,38 +1144,6 @@ def ListClusterAttributes(self): "type": "int", "writable": True, }, - "EnhancedCurrentHue": { - "attributeId": 0x4000, - "type": "int", - }, - "EnhancedColorMode": { - "attributeId": 0x4001, - "type": "int", - }, - "ColorLoopActive": { - "attributeId": 0x4002, - "type": "int", - }, - "ColorLoopDirection": { - "attributeId": 0x4003, - "type": "int", - }, - "ColorLoopTime": { - "attributeId": 0x4004, - "type": "int", - }, - "ColorCapabilities": { - "attributeId": 0x400A, - "type": "int", - }, - "ColorTempPhysicalMin": { - "attributeId": 0x400B, - "type": "int", - }, - "ColorTempPhysicalMax": { - "attributeId": 0x400C, - "type": "int", - }, "CoupleColorTempToLevelMinMireds": { "attributeId": 0x400D, "type": "int", @@ -2345,26 +2277,6 @@ def ClusterBinding_CommandUnbind(self, device: ctypes.c_void_p, ZCLendpoint: int return self._chipLib.chip_ime_AppendCommand_Binding_Unbind( device, ZCLendpoint, ZCLgroupid, nodeId, groupId, endpointId, clusterId ) - def ClusterColorControl_CommandColorLoopSet(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, updateFlags: int, action: int, direction: int, time: int, startHue: int, optionsMask: int, optionsOverride: int): - return self._chipLib.chip_ime_AppendCommand_ColorControl_ColorLoopSet( - device, ZCLendpoint, ZCLgroupid, updateFlags, action, direction, time, startHue, optionsMask, optionsOverride - ) - def ClusterColorControl_CommandEnhancedMoveHue(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, moveMode: int, rate: int, optionsMask: int, optionsOverride: int): - return self._chipLib.chip_ime_AppendCommand_ColorControl_EnhancedMoveHue( - device, ZCLendpoint, ZCLgroupid, moveMode, rate, optionsMask, optionsOverride - ) - def ClusterColorControl_CommandEnhancedMoveToHue(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, enhancedHue: int, direction: int, transitionTime: int, optionsMask: int, optionsOverride: int): - return self._chipLib.chip_ime_AppendCommand_ColorControl_EnhancedMoveToHue( - device, ZCLendpoint, ZCLgroupid, enhancedHue, direction, transitionTime, optionsMask, optionsOverride - ) - def ClusterColorControl_CommandEnhancedMoveToHueAndSaturation(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, enhancedHue: int, saturation: int, transitionTime: int, optionsMask: int, optionsOverride: int): - return self._chipLib.chip_ime_AppendCommand_ColorControl_EnhancedMoveToHueAndSaturation( - device, ZCLendpoint, ZCLgroupid, enhancedHue, saturation, transitionTime, optionsMask, optionsOverride - ) - def ClusterColorControl_CommandEnhancedStepHue(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, stepMode: int, stepSize: int, transitionTime: int, optionsMask: int, optionsOverride: int): - return self._chipLib.chip_ime_AppendCommand_ColorControl_EnhancedStepHue( - device, ZCLendpoint, ZCLgroupid, stepMode, stepSize, transitionTime, optionsMask, optionsOverride - ) def ClusterColorControl_CommandMoveColor(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, rateX: int, rateY: int, optionsMask: int, optionsOverride: int): return self._chipLib.chip_ime_AppendCommand_ColorControl_MoveColor( device, ZCLendpoint, ZCLgroupid, rateX, rateY, optionsMask, optionsOverride @@ -3166,22 +3078,6 @@ def ClusterColorControl_ReadAttributeColorPointBIntensity(self, device: ctypes.c return self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorPointBIntensity(device, ZCLendpoint, ZCLgroupid) def ClusterColorControl_WriteAttributeColorPointBIntensity(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int, value: int): return self._chipLib.chip_ime_WriteAttribute_ColorControl_ColorPointBIntensity(device, ZCLendpoint, ZCLgroupid, value) - def ClusterColorControl_ReadAttributeEnhancedCurrentHue(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): - return self._chipLib.chip_ime_ReadAttribute_ColorControl_EnhancedCurrentHue(device, ZCLendpoint, ZCLgroupid) - def ClusterColorControl_ReadAttributeEnhancedColorMode(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): - return self._chipLib.chip_ime_ReadAttribute_ColorControl_EnhancedColorMode(device, ZCLendpoint, ZCLgroupid) - def ClusterColorControl_ReadAttributeColorLoopActive(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): - return self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorLoopActive(device, ZCLendpoint, ZCLgroupid) - def ClusterColorControl_ReadAttributeColorLoopDirection(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): - return self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorLoopDirection(device, ZCLendpoint, ZCLgroupid) - def ClusterColorControl_ReadAttributeColorLoopTime(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): - return self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorLoopTime(device, ZCLendpoint, ZCLgroupid) - def ClusterColorControl_ReadAttributeColorCapabilities(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): - return self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorCapabilities(device, ZCLendpoint, ZCLgroupid) - def ClusterColorControl_ReadAttributeColorTempPhysicalMin(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): - return self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorTempPhysicalMin(device, ZCLendpoint, ZCLgroupid) - def ClusterColorControl_ReadAttributeColorTempPhysicalMax(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): - return self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorTempPhysicalMax(device, ZCLendpoint, ZCLgroupid) def ClusterColorControl_ReadAttributeCoupleColorTempToLevelMinMireds(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): return self._chipLib.chip_ime_ReadAttribute_ColorControl_CoupleColorTempToLevelMinMireds(device, ZCLendpoint, ZCLgroupid) def ClusterColorControl_ReadAttributeStartUpColorTemperatureMireds(self, device: ctypes.c_void_p, ZCLendpoint: int, ZCLgroupid: int): @@ -4001,21 +3897,6 @@ def InitLib(self, chipLib): self._chipLib.chip_ime_ReadAttribute_BridgedDeviceBasic_ClusterRevision.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] self._chipLib.chip_ime_ReadAttribute_BridgedDeviceBasic_ClusterRevision.restype = ctypes.c_uint32 # Cluster ColorControl - # Cluster ColorControl Command ColorLoopSet - self._chipLib.chip_ime_AppendCommand_ColorControl_ColorLoopSet.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint8] - self._chipLib.chip_ime_AppendCommand_ColorControl_ColorLoopSet.restype = ctypes.c_uint32 - # Cluster ColorControl Command EnhancedMoveHue - self._chipLib.chip_ime_AppendCommand_ColorControl_EnhancedMoveHue.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint8] - self._chipLib.chip_ime_AppendCommand_ColorControl_EnhancedMoveHue.restype = ctypes.c_uint32 - # Cluster ColorControl Command EnhancedMoveToHue - self._chipLib.chip_ime_AppendCommand_ColorControl_EnhancedMoveToHue.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint8] - self._chipLib.chip_ime_AppendCommand_ColorControl_EnhancedMoveToHue.restype = ctypes.c_uint32 - # Cluster ColorControl Command EnhancedMoveToHueAndSaturation - self._chipLib.chip_ime_AppendCommand_ColorControl_EnhancedMoveToHueAndSaturation.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint8] - self._chipLib.chip_ime_AppendCommand_ColorControl_EnhancedMoveToHueAndSaturation.restype = ctypes.c_uint32 - # Cluster ColorControl Command EnhancedStepHue - self._chipLib.chip_ime_AppendCommand_ColorControl_EnhancedStepHue.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint16, ctypes.c_uint8, ctypes.c_uint8] - self._chipLib.chip_ime_AppendCommand_ColorControl_EnhancedStepHue.restype = ctypes.c_uint32 # Cluster ColorControl Command MoveColor self._chipLib.chip_ime_AppendCommand_ColorControl_MoveColor.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_int16, ctypes.c_int16, ctypes.c_uint8, ctypes.c_uint8] self._chipLib.chip_ime_AppendCommand_ColorControl_MoveColor.restype = ctypes.c_uint32 @@ -4229,30 +4110,6 @@ def InitLib(self, chipLib): # Cluster ColorControl WriteAttribute ColorPointBIntensity self._chipLib.chip_ime_WriteAttribute_ColorControl_ColorPointBIntensity.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16, ctypes.c_uint8] self._chipLib.chip_ime_WriteAttribute_ColorControl_ColorPointBIntensity.restype = ctypes.c_uint32 - # Cluster ColorControl ReadAttribute EnhancedCurrentHue - self._chipLib.chip_ime_ReadAttribute_ColorControl_EnhancedCurrentHue.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] - self._chipLib.chip_ime_ReadAttribute_ColorControl_EnhancedCurrentHue.restype = ctypes.c_uint32 - # Cluster ColorControl ReadAttribute EnhancedColorMode - self._chipLib.chip_ime_ReadAttribute_ColorControl_EnhancedColorMode.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] - self._chipLib.chip_ime_ReadAttribute_ColorControl_EnhancedColorMode.restype = ctypes.c_uint32 - # Cluster ColorControl ReadAttribute ColorLoopActive - self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorLoopActive.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] - self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorLoopActive.restype = ctypes.c_uint32 - # Cluster ColorControl ReadAttribute ColorLoopDirection - self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorLoopDirection.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] - self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorLoopDirection.restype = ctypes.c_uint32 - # Cluster ColorControl ReadAttribute ColorLoopTime - self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorLoopTime.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] - self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorLoopTime.restype = ctypes.c_uint32 - # Cluster ColorControl ReadAttribute ColorCapabilities - self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorCapabilities.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] - self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorCapabilities.restype = ctypes.c_uint32 - # Cluster ColorControl ReadAttribute ColorTempPhysicalMin - self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorTempPhysicalMin.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] - self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorTempPhysicalMin.restype = ctypes.c_uint32 - # Cluster ColorControl ReadAttribute ColorTempPhysicalMax - self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorTempPhysicalMax.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] - self._chipLib.chip_ime_ReadAttribute_ColorControl_ColorTempPhysicalMax.restype = ctypes.c_uint32 # Cluster ColorControl ReadAttribute CoupleColorTempToLevelMinMireds self._chipLib.chip_ime_ReadAttribute_ColorControl_CoupleColorTempToLevelMinMireds.argtypes = [ctypes.c_void_p, ctypes.c_uint8, ctypes.c_uint16] self._chipLib.chip_ime_ReadAttribute_ColorControl_CoupleColorTempToLevelMinMireds.restype = ctypes.c_uint32 diff --git a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h index 8c3ceabe989b4d..24269259b87b2d 100644 --- a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h +++ b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.h @@ -232,37 +232,6 @@ NS_ASSUME_NONNULL_BEGIN */ @interface CHIPColorControl : CHIPCluster -- (void)colorLoopSet:(uint8_t)updateFlags - action:(uint8_t)action - direction:(uint8_t)direction - time:(uint16_t)time - startHue:(uint16_t)startHue - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - responseHandler:(ResponseHandler)responseHandler; -- (void)enhancedMoveHue:(uint8_t)moveMode - rate:(uint16_t)rate - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - responseHandler:(ResponseHandler)responseHandler; -- (void)enhancedMoveToHue:(uint16_t)enhancedHue - direction:(uint8_t)direction - transitionTime:(uint16_t)transitionTime - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - responseHandler:(ResponseHandler)responseHandler; -- (void)enhancedMoveToHueAndSaturation:(uint16_t)enhancedHue - saturation:(uint8_t)saturation - transitionTime:(uint16_t)transitionTime - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - responseHandler:(ResponseHandler)responseHandler; -- (void)enhancedStepHue:(uint8_t)stepMode - stepSize:(uint16_t)stepSize - transitionTime:(uint16_t)transitionTime - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - responseHandler:(ResponseHandler)responseHandler; - (void)moveColor:(int16_t)rateX rateY:(int16_t)rateY optionsMask:(uint8_t)optionsMask @@ -418,14 +387,6 @@ NS_ASSUME_NONNULL_BEGIN - (void)writeAttributeColorPointBYWithValue:(uint16_t)value responseHandler:(ResponseHandler)responseHandler; - (void)readAttributeColorPointBIntensityWithResponseHandler:(ResponseHandler)responseHandler; - (void)writeAttributeColorPointBIntensityWithValue:(uint8_t)value responseHandler:(ResponseHandler)responseHandler; -- (void)readAttributeEnhancedCurrentHueWithResponseHandler:(ResponseHandler)responseHandler; -- (void)readAttributeEnhancedColorModeWithResponseHandler:(ResponseHandler)responseHandler; -- (void)readAttributeColorLoopActiveWithResponseHandler:(ResponseHandler)responseHandler; -- (void)readAttributeColorLoopDirectionWithResponseHandler:(ResponseHandler)responseHandler; -- (void)readAttributeColorLoopTimeWithResponseHandler:(ResponseHandler)responseHandler; -- (void)readAttributeColorCapabilitiesWithResponseHandler:(ResponseHandler)responseHandler; -- (void)readAttributeColorTempPhysicalMinWithResponseHandler:(ResponseHandler)responseHandler; -- (void)readAttributeColorTempPhysicalMaxWithResponseHandler:(ResponseHandler)responseHandler; - (void)readAttributeCoupleColorTempToLevelMinMiredsWithResponseHandler:(ResponseHandler)responseHandler; - (void)readAttributeStartUpColorTemperatureMiredsWithResponseHandler:(ResponseHandler)responseHandler; - (void)writeAttributeStartUpColorTemperatureMiredsWithValue:(uint16_t)value responseHandler:(ResponseHandler)responseHandler; diff --git a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm index a055c6cd2ec72d..3e8b165c897882 100644 --- a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm +++ b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm @@ -5990,167 +5990,6 @@ @implementation CHIPColorControl return &_cppCluster; } -- (void)colorLoopSet:(uint8_t)updateFlags - action:(uint8_t)action - direction:(uint8_t)direction - time:(uint16_t)time - startHue:(uint16_t)startHue - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - responseHandler:(ResponseHandler)responseHandler -{ - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]); - if (!onSuccess) { - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); - if (!onFailure) { - delete onSuccess; - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - __block CHIP_ERROR err; - dispatch_sync([self chipWorkQueue], ^{ - err = self.cppCluster.ColorLoopSet( - onSuccess->Cancel(), onFailure->Cancel(), updateFlags, action, direction, time, startHue, optionsMask, optionsOverride); - }); - - if (err != CHIP_NO_ERROR) { - delete onSuccess; - delete onFailure; - responseHandler([CHIPError errorForCHIPErrorCode:err], nil); - } -} -- (void)enhancedMoveHue:(uint8_t)moveMode - rate:(uint16_t)rate - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - responseHandler:(ResponseHandler)responseHandler -{ - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]); - if (!onSuccess) { - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); - if (!onFailure) { - delete onSuccess; - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - __block CHIP_ERROR err; - dispatch_sync([self chipWorkQueue], ^{ - err = self.cppCluster.EnhancedMoveHue( - onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride); - }); - - if (err != CHIP_NO_ERROR) { - delete onSuccess; - delete onFailure; - responseHandler([CHIPError errorForCHIPErrorCode:err], nil); - } -} -- (void)enhancedMoveToHue:(uint16_t)enhancedHue - direction:(uint8_t)direction - transitionTime:(uint16_t)transitionTime - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - responseHandler:(ResponseHandler)responseHandler -{ - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]); - if (!onSuccess) { - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); - if (!onFailure) { - delete onSuccess; - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - __block CHIP_ERROR err; - dispatch_sync([self chipWorkQueue], ^{ - err = self.cppCluster.EnhancedMoveToHue( - onSuccess->Cancel(), onFailure->Cancel(), enhancedHue, direction, transitionTime, optionsMask, optionsOverride); - }); - - if (err != CHIP_NO_ERROR) { - delete onSuccess; - delete onFailure; - responseHandler([CHIPError errorForCHIPErrorCode:err], nil); - } -} -- (void)enhancedMoveToHueAndSaturation:(uint16_t)enhancedHue - saturation:(uint8_t)saturation - transitionTime:(uint16_t)transitionTime - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - responseHandler:(ResponseHandler)responseHandler -{ - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]); - if (!onSuccess) { - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); - if (!onFailure) { - delete onSuccess; - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - __block CHIP_ERROR err; - dispatch_sync([self chipWorkQueue], ^{ - err = self.cppCluster.EnhancedMoveToHueAndSaturation( - onSuccess->Cancel(), onFailure->Cancel(), enhancedHue, saturation, transitionTime, optionsMask, optionsOverride); - }); - - if (err != CHIP_NO_ERROR) { - delete onSuccess; - delete onFailure; - responseHandler([CHIPError errorForCHIPErrorCode:err], nil); - } -} -- (void)enhancedStepHue:(uint8_t)stepMode - stepSize:(uint16_t)stepSize - transitionTime:(uint16_t)transitionTime - optionsMask:(uint8_t)optionsMask - optionsOverride:(uint8_t)optionsOverride - responseHandler:(ResponseHandler)responseHandler -{ - CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]); - if (!onSuccess) { - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); - if (!onFailure) { - delete onSuccess; - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - __block CHIP_ERROR err; - dispatch_sync([self chipWorkQueue], ^{ - err = self.cppCluster.EnhancedStepHue( - onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, optionsOverride); - }); - - if (err != CHIP_NO_ERROR) { - delete onSuccess; - delete onFailure; - responseHandler([CHIPError errorForCHIPErrorCode:err], nil); - } -} - (void)moveColor:(int16_t)rateX rateY:(int16_t)rateY optionsMask:(uint8_t)optionsMask @@ -8245,222 +8084,6 @@ - (void)writeAttributeColorPointBIntensityWithValue:(uint8_t)value responseHandl } } -- (void)readAttributeEnhancedCurrentHueWithResponseHandler:(ResponseHandler)responseHandler -{ - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]); - if (!onSuccess) { - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); - if (!onFailure) { - delete onSuccess; - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - __block CHIP_ERROR err; - dispatch_sync([self chipWorkQueue], ^{ - err = self.cppCluster.ReadAttributeEnhancedCurrentHue(onSuccess->Cancel(), onFailure->Cancel()); - }); - - if (err != CHIP_NO_ERROR) { - delete onSuccess; - delete onFailure; - responseHandler([CHIPError errorForCHIPErrorCode:err], nil); - } -} - -- (void)readAttributeEnhancedColorModeWithResponseHandler:(ResponseHandler)responseHandler -{ - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]); - if (!onSuccess) { - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); - if (!onFailure) { - delete onSuccess; - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - __block CHIP_ERROR err; - dispatch_sync([self chipWorkQueue], ^{ - err = self.cppCluster.ReadAttributeEnhancedColorMode(onSuccess->Cancel(), onFailure->Cancel()); - }); - - if (err != CHIP_NO_ERROR) { - delete onSuccess; - delete onFailure; - responseHandler([CHIPError errorForCHIPErrorCode:err], nil); - } -} - -- (void)readAttributeColorLoopActiveWithResponseHandler:(ResponseHandler)responseHandler -{ - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]); - if (!onSuccess) { - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); - if (!onFailure) { - delete onSuccess; - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - __block CHIP_ERROR err; - dispatch_sync([self chipWorkQueue], ^{ - err = self.cppCluster.ReadAttributeColorLoopActive(onSuccess->Cancel(), onFailure->Cancel()); - }); - - if (err != CHIP_NO_ERROR) { - delete onSuccess; - delete onFailure; - responseHandler([CHIPError errorForCHIPErrorCode:err], nil); - } -} - -- (void)readAttributeColorLoopDirectionWithResponseHandler:(ResponseHandler)responseHandler -{ - CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]); - if (!onSuccess) { - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); - if (!onFailure) { - delete onSuccess; - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - __block CHIP_ERROR err; - dispatch_sync([self chipWorkQueue], ^{ - err = self.cppCluster.ReadAttributeColorLoopDirection(onSuccess->Cancel(), onFailure->Cancel()); - }); - - if (err != CHIP_NO_ERROR) { - delete onSuccess; - delete onFailure; - responseHandler([CHIPError errorForCHIPErrorCode:err], nil); - } -} - -- (void)readAttributeColorLoopTimeWithResponseHandler:(ResponseHandler)responseHandler -{ - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]); - if (!onSuccess) { - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); - if (!onFailure) { - delete onSuccess; - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - __block CHIP_ERROR err; - dispatch_sync([self chipWorkQueue], ^{ - err = self.cppCluster.ReadAttributeColorLoopTime(onSuccess->Cancel(), onFailure->Cancel()); - }); - - if (err != CHIP_NO_ERROR) { - delete onSuccess; - delete onFailure; - responseHandler([CHIPError errorForCHIPErrorCode:err], nil); - } -} - -- (void)readAttributeColorCapabilitiesWithResponseHandler:(ResponseHandler)responseHandler -{ - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]); - if (!onSuccess) { - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); - if (!onFailure) { - delete onSuccess; - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - __block CHIP_ERROR err; - dispatch_sync([self chipWorkQueue], ^{ - err = self.cppCluster.ReadAttributeColorCapabilities(onSuccess->Cancel(), onFailure->Cancel()); - }); - - if (err != CHIP_NO_ERROR) { - delete onSuccess; - delete onFailure; - responseHandler([CHIPError errorForCHIPErrorCode:err], nil); - } -} - -- (void)readAttributeColorTempPhysicalMinWithResponseHandler:(ResponseHandler)responseHandler -{ - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]); - if (!onSuccess) { - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); - if (!onFailure) { - delete onSuccess; - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - __block CHIP_ERROR err; - dispatch_sync([self chipWorkQueue], ^{ - err = self.cppCluster.ReadAttributeColorTempPhysicalMin(onSuccess->Cancel(), onFailure->Cancel()); - }); - - if (err != CHIP_NO_ERROR) { - delete onSuccess; - delete onFailure; - responseHandler([CHIPError errorForCHIPErrorCode:err], nil); - } -} - -- (void)readAttributeColorTempPhysicalMaxWithResponseHandler:(ResponseHandler)responseHandler -{ - CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]); - if (!onSuccess) { - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]); - if (!onFailure) { - delete onSuccess; - responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil); - return; - } - - __block CHIP_ERROR err; - dispatch_sync([self chipWorkQueue], ^{ - err = self.cppCluster.ReadAttributeColorTempPhysicalMax(onSuccess->Cancel(), onFailure->Cancel()); - }); - - if (err != CHIP_NO_ERROR) { - delete onSuccess; - delete onFailure; - responseHandler([CHIPError errorForCHIPErrorCode:err], nil); - } -} - - (void)readAttributeCoupleColorTempToLevelMinMiredsWithResponseHandler:(ResponseHandler)responseHandler { CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]); diff --git a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m index 5816f053ed0f0d..ed7f908d8900d7 100644 --- a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m +++ b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m @@ -5151,158 +5151,6 @@ - (void)testSendClusterColorControlWriteAttributeColorPointBIntensityWithValue [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)testSendClusterColorControlReadAttributeEnhancedCurrentHueWithResponseHandler -{ - XCTestExpectation * expectation = - [self expectationWithDescription:@"ColorControlReadAttributeEnhancedCurrentHueWithResponseHandler"]; - - CHIPDevice * device = GetPairedDevice(kDeviceId); - dispatch_queue_t queue = dispatch_get_main_queue(); - CHIPColorControl * cluster = [[CHIPColorControl alloc] initWithDevice:device endpoint:1 queue:queue]; - XCTAssertNotNil(cluster); - - [cluster readAttributeEnhancedCurrentHueWithResponseHandler:^(NSError * err, NSDictionary * values) { - NSLog(@"ColorControl EnhancedCurrentHue Error: %@", err); - XCTAssertEqual(err.code, 0); - [expectation fulfill]; - }]; - - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; -} - -- (void)testSendClusterColorControlReadAttributeEnhancedColorModeWithResponseHandler -{ - XCTestExpectation * expectation = - [self expectationWithDescription:@"ColorControlReadAttributeEnhancedColorModeWithResponseHandler"]; - - CHIPDevice * device = GetPairedDevice(kDeviceId); - dispatch_queue_t queue = dispatch_get_main_queue(); - CHIPColorControl * cluster = [[CHIPColorControl alloc] initWithDevice:device endpoint:1 queue:queue]; - XCTAssertNotNil(cluster); - - [cluster readAttributeEnhancedColorModeWithResponseHandler:^(NSError * err, NSDictionary * values) { - NSLog(@"ColorControl EnhancedColorMode Error: %@", err); - XCTAssertEqual(err.code, 0); - [expectation fulfill]; - }]; - - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; -} - -- (void)testSendClusterColorControlReadAttributeColorLoopActiveWithResponseHandler -{ - XCTestExpectation * expectation = - [self expectationWithDescription:@"ColorControlReadAttributeColorLoopActiveWithResponseHandler"]; - - CHIPDevice * device = GetPairedDevice(kDeviceId); - dispatch_queue_t queue = dispatch_get_main_queue(); - CHIPColorControl * cluster = [[CHIPColorControl alloc] initWithDevice:device endpoint:1 queue:queue]; - XCTAssertNotNil(cluster); - - [cluster readAttributeColorLoopActiveWithResponseHandler:^(NSError * err, NSDictionary * values) { - NSLog(@"ColorControl ColorLoopActive Error: %@", err); - XCTAssertEqual(err.code, 0); - [expectation fulfill]; - }]; - - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; -} - -- (void)testSendClusterColorControlReadAttributeColorLoopDirectionWithResponseHandler -{ - XCTestExpectation * expectation = - [self expectationWithDescription:@"ColorControlReadAttributeColorLoopDirectionWithResponseHandler"]; - - CHIPDevice * device = GetPairedDevice(kDeviceId); - dispatch_queue_t queue = dispatch_get_main_queue(); - CHIPColorControl * cluster = [[CHIPColorControl alloc] initWithDevice:device endpoint:1 queue:queue]; - XCTAssertNotNil(cluster); - - [cluster readAttributeColorLoopDirectionWithResponseHandler:^(NSError * err, NSDictionary * values) { - NSLog(@"ColorControl ColorLoopDirection Error: %@", err); - XCTAssertEqual(err.code, 0); - [expectation fulfill]; - }]; - - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; -} - -- (void)testSendClusterColorControlReadAttributeColorLoopTimeWithResponseHandler -{ - XCTestExpectation * expectation = - [self expectationWithDescription:@"ColorControlReadAttributeColorLoopTimeWithResponseHandler"]; - - CHIPDevice * device = GetPairedDevice(kDeviceId); - dispatch_queue_t queue = dispatch_get_main_queue(); - CHIPColorControl * cluster = [[CHIPColorControl alloc] initWithDevice:device endpoint:1 queue:queue]; - XCTAssertNotNil(cluster); - - [cluster readAttributeColorLoopTimeWithResponseHandler:^(NSError * err, NSDictionary * values) { - NSLog(@"ColorControl ColorLoopTime Error: %@", err); - XCTAssertEqual(err.code, 0); - [expectation fulfill]; - }]; - - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; -} - -- (void)testSendClusterColorControlReadAttributeColorCapabilitiesWithResponseHandler -{ - XCTestExpectation * expectation = - [self expectationWithDescription:@"ColorControlReadAttributeColorCapabilitiesWithResponseHandler"]; - - CHIPDevice * device = GetPairedDevice(kDeviceId); - dispatch_queue_t queue = dispatch_get_main_queue(); - CHIPColorControl * cluster = [[CHIPColorControl alloc] initWithDevice:device endpoint:1 queue:queue]; - XCTAssertNotNil(cluster); - - [cluster readAttributeColorCapabilitiesWithResponseHandler:^(NSError * err, NSDictionary * values) { - NSLog(@"ColorControl ColorCapabilities Error: %@", err); - XCTAssertEqual(err.code, 0); - [expectation fulfill]; - }]; - - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; -} - -- (void)testSendClusterColorControlReadAttributeColorTempPhysicalMinWithResponseHandler -{ - XCTestExpectation * expectation = - [self expectationWithDescription:@"ColorControlReadAttributeColorTempPhysicalMinWithResponseHandler"]; - - CHIPDevice * device = GetPairedDevice(kDeviceId); - dispatch_queue_t queue = dispatch_get_main_queue(); - CHIPColorControl * cluster = [[CHIPColorControl alloc] initWithDevice:device endpoint:1 queue:queue]; - XCTAssertNotNil(cluster); - - [cluster readAttributeColorTempPhysicalMinWithResponseHandler:^(NSError * err, NSDictionary * values) { - NSLog(@"ColorControl ColorTempPhysicalMin Error: %@", err); - XCTAssertEqual(err.code, 0); - [expectation fulfill]; - }]; - - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; -} - -- (void)testSendClusterColorControlReadAttributeColorTempPhysicalMaxWithResponseHandler -{ - XCTestExpectation * expectation = - [self expectationWithDescription:@"ColorControlReadAttributeColorTempPhysicalMaxWithResponseHandler"]; - - CHIPDevice * device = GetPairedDevice(kDeviceId); - dispatch_queue_t queue = dispatch_get_main_queue(); - CHIPColorControl * cluster = [[CHIPColorControl alloc] initWithDevice:device endpoint:1 queue:queue]; - XCTAssertNotNil(cluster); - - [cluster readAttributeColorTempPhysicalMaxWithResponseHandler:^(NSError * err, NSDictionary * values) { - NSLog(@"ColorControl ColorTempPhysicalMax Error: %@", err); - XCTAssertEqual(err.code, 0); - [expectation fulfill]; - }]; - - [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; -} - - (void)testSendClusterColorControlReadAttributeCoupleColorTempToLevelMinMiredsWithResponseHandler { XCTestExpectation * expectation = From 6041f792ba73916fee70a8f99950d5c7cc066e1d Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 23 Jul 2021 08:01:21 +0000 Subject: [PATCH 3/4] Restyled by clang-format --- .../chip-tool/commands/reporting/Commands.h | 8 +-- .../gen/IMClusterCommandHandler.cpp | 6 +- .../python/chip/server/ServerInit.cpp | 68 ++++++++++--------- 3 files changed, 43 insertions(+), 39 deletions(-) diff --git a/examples/chip-tool/commands/reporting/Commands.h b/examples/chip-tool/commands/reporting/Commands.h index be69d0a6e5c2c3..a4739c26ec8c9e 100644 --- a/examples/chip-tool/commands/reporting/Commands.h +++ b/examples/chip-tool/commands/reporting/Commands.h @@ -169,12 +169,12 @@ class Listen : public ReportingCommand new chip::Callback::Callback(OnInt8uAttributeResponse, this); chip::Callback::Callback * onReportLevelControlCurrentLevelCallback = new chip::Callback::Callback(OnInt8uAttributeResponse, this); -// chip::Callback::Callback * onReportLevelControlCurrentLevelCallback = -// new chip::Callback::Callback(OnInt8uAttributeResponse, this); + // chip::Callback::Callback * onReportLevelControlCurrentLevelCallback = + // new chip::Callback::Callback(OnInt8uAttributeResponse, this); chip::Callback::Callback * onReportOccupancySensingOccupancyCallback = new chip::Callback::Callback(OnInt8uAttributeResponse, this); -// chip::Callback::Callback * onReportOnOffOnOffCallback = -// new chip::Callback::Callback(OnBooleanAttributeResponse, this); + // chip::Callback::Callback * onReportOnOffOnOffCallback = + // new chip::Callback::Callback(OnBooleanAttributeResponse, this); chip::Callback::Callback * onReportOnOffOnOffCallback = new chip::Callback::Callback(OnBooleanAttributeResponse, this); chip::Callback::Callback * onReportPressureMeasurementMeasuredValueCallback = diff --git a/src/controller/data_model/gen/IMClusterCommandHandler.cpp b/src/controller/data_model/gen/IMClusterCommandHandler.cpp index 3844dc306b73d4..55cf5a0c4d0d4b 100644 --- a/src/controller/data_model/gen/IMClusterCommandHandler.cpp +++ b/src/controller/data_model/gen/IMClusterCommandHandler.cpp @@ -294,19 +294,19 @@ void DispatchClientCommand(app::CommandSender * apCommandObj, CommandId aCommand case Clusters::Basic::Commands::Ids::Leave: { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. -// wasHandled = emberAfBasicClusterLeaveCallback(apCommandObj); + // wasHandled = emberAfBasicClusterLeaveCallback(apCommandObj); break; } case Clusters::Basic::Commands::Ids::ShutDown: { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. -// wasHandled = emberAfBasicClusterShutDownCallback(apCommandObj); + // wasHandled = emberAfBasicClusterShutDownCallback(apCommandObj); break; } case Clusters::Basic::Commands::Ids::StartUp: { // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. -// wasHandled = emberAfBasicClusterStartUpCallback(apCommandObj); + // wasHandled = emberAfBasicClusterStartUpCallback(apCommandObj); break; } default: { diff --git a/src/controller/python/chip/server/ServerInit.cpp b/src/controller/python/chip/server/ServerInit.cpp index d560605ad197fd..261f526648ef3e 100644 --- a/src/controller/python/chip/server/ServerInit.cpp +++ b/src/controller/python/chip/server/ServerInit.cpp @@ -79,14 +79,15 @@ extern "C" { // return CHIP_NO_ERROR; // } +using PostAttributeChangeCallback = void (*)(uint16_t endpoint, uint16_t clusterId, uint16_t attributeId, uint8_t mask, + uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value); -using PostAttributeChangeCallback = void (*)(uint16_t endpoint, uint16_t clusterId, uint16_t attributeId, uint8_t mask, uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value); - -class PythonServerDelegate// : public ServerDelegate +class PythonServerDelegate // : public ServerDelegate { public: - void SetPostAttributeChangeCallback(PostAttributeChangeCallback cb) { - //ChipLogProgress(NotSpecified, "callback %p", cb); + void SetPostAttributeChangeCallback(PostAttributeChangeCallback cb) + { + // ChipLogProgress(NotSpecified, "callback %p", cb); mPostAttributeChangeCallback = cb; }; PostAttributeChangeCallback mPostAttributeChangeCallback = nullptr; @@ -96,7 +97,7 @@ PythonServerDelegate gPythonServerDelegate; void pychip_server_set_callbacks(PostAttributeChangeCallback cb) { - //ChipLogProgress(NotSpecified, "setting cb"); + // ChipLogProgress(NotSpecified, "setting cb"); gPythonServerDelegate.SetPostAttributeChangeCallback(cb); } @@ -124,27 +125,27 @@ void pychip_server_native_init() chip::DeviceLayer::ConnectivityMgr().SetBLEDeviceName(nullptr); // Use default device name (CHIP-XXXX) -// #if CONFIG_NETWORK_LAYER_BLE -// chip::DeviceLayer::Internal::BLEMgrImpl().ConfigureBle(LinuxDeviceOptions::GetInstance().mBleDevice, false); -// #endif + // #if CONFIG_NETWORK_LAYER_BLE + // chip::DeviceLayer::Internal::BLEMgrImpl().ConfigureBle(LinuxDeviceOptions::GetInstance().mBleDevice, false); + // #endif chip::DeviceLayer::ConnectivityMgr().SetBLEAdvertisingEnabled(false); -// chip::DeviceLayer::ConnectivityMgr().SetBLEAdvertisingEnabled(true); - -// #if CHIP_DEVICE_CONFIG_ENABLE_WPA -// if (LinuxDeviceOptions::GetInstance().mWiFi) -// { -// chip::DeviceLayer::ConnectivityMgrImpl().StartWiFiManagement(); -// } -// #endif // CHIP_DEVICE_CONFIG_ENABLE_WPA - -// #if CHIP_ENABLE_OPENTHREAD -// if (LinuxDeviceOptions::GetInstance().mThread) -// { -// SuccessOrExit(err = chip::DeviceLayer::ThreadStackMgrImpl().InitThreadStack()); -// ChipLogProgress(NotSpecified, "Thread initialized."); -// } -// #endif // CHIP_ENABLE_OPENTHREAD + // chip::DeviceLayer::ConnectivityMgr().SetBLEAdvertisingEnabled(true); + + // #if CHIP_DEVICE_CONFIG_ENABLE_WPA + // if (LinuxDeviceOptions::GetInstance().mWiFi) + // { + // chip::DeviceLayer::ConnectivityMgrImpl().StartWiFiManagement(); + // } + // #endif // CHIP_DEVICE_CONFIG_ENABLE_WPA + + // #if CHIP_ENABLE_OPENTHREAD + // if (LinuxDeviceOptions::GetInstance().mThread) + // { + // SuccessOrExit(err = chip::DeviceLayer::ThreadStackMgrImpl().InitThreadStack()); + // ChipLogProgress(NotSpecified, "Thread initialized."); + // } + // #endif // CHIP_ENABLE_OPENTHREAD InitServer(); @@ -163,17 +164,20 @@ void pychip_server_native_init() } return /*err*/; } - } void emberAfPostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId, uint8_t mask, uint16_t manufacturerCode, uint8_t type, uint16_t size, uint8_t * value) { - //ChipLogProgress(NotSpecified, "emberAfPostAttributeChangeCallback()"); - if (gPythonServerDelegate.mPostAttributeChangeCallback != nullptr ) { - //ChipLogProgress(NotSpecified, "callback %p", gPythonServerDelegate.mPostAttributeChangeCallback); - gPythonServerDelegate.mPostAttributeChangeCallback(endpoint, clusterId, attributeId, mask, manufacturerCode, type, size, value); - } else { - //ChipLogProgress(NotSpecified, "callback nullptr"); + // ChipLogProgress(NotSpecified, "emberAfPostAttributeChangeCallback()"); + if (gPythonServerDelegate.mPostAttributeChangeCallback != nullptr) + { + // ChipLogProgress(NotSpecified, "callback %p", gPythonServerDelegate.mPostAttributeChangeCallback); + gPythonServerDelegate.mPostAttributeChangeCallback(endpoint, clusterId, attributeId, mask, manufacturerCode, type, size, + value); + } + else + { + // ChipLogProgress(NotSpecified, "callback nullptr"); } }; From 22e752f81a31a12f193b678e4ef5f6ab7d555957 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 23 Jul 2021 08:01:27 +0000 Subject: [PATCH 4/4] Restyled by gn --- src/controller/python/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controller/python/BUILD.gn b/src/controller/python/BUILD.gn index 80961eeff3e301..80aa27945efa54 100644 --- a/src/controller/python/BUILD.gn +++ b/src/controller/python/BUILD.gn @@ -53,8 +53,8 @@ shared_library("ChipDeviceCtrl") { "chip/internal/CommissionerImpl.cpp", "chip/logging/LoggingRedirect.cpp", "chip/native/StackInit.cpp", - "chip/setup_payload/Generator.cpp", "chip/server/ServerInit.cpp", + "chip/setup_payload/Generator.cpp", "chip/setup_payload/Parser.cpp", ]