From d1054f3cae3e03c38506b2ea30f7b8267547de21 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Tue, 8 Dec 2020 18:49:57 +0100 Subject: [PATCH] Convert 'echo' command to a manufacturer specific 'ping' command --- .../all-clusters-common/all-clusters-app.zap | 78 +-- .../gen/call-command-handler.cpp | 9 +- .../all-clusters-common/gen/callback.h | 6 + .../all-clusters-common/gen/command-id.h | 1 + .../all-clusters-common/gen/endpoint_config.h | 11 +- .../esp32/main/DeviceCallbacks.cpp | 7 + examples/all-clusters-app/linux/main.cpp | 6 + examples/chip-tool/BUILD.gn | 2 - examples/chip-tool/README.md | 9 - .../chip-tool/commands/clusters/Commands.h | 28 +- .../commands/clusters/ModelCommand.cpp | 116 ++++- .../commands/clusters/ModelCommand.h | 23 +- .../commands/common/NetworkCommand.cpp | 117 ----- .../commands/common/NetworkCommand.h | 46 -- examples/chip-tool/commands/echo/Commands.h | 38 -- .../chip-tool/commands/echo/EchoCommand.cpp | 60 --- .../chip-tool/commands/echo/EchoCommand.h | 31 -- examples/chip-tool/main.cpp | 2 - .../chip-app-server/DataModelHandler.cpp | 133 +----- src/app/chip-zcl-zpro-codec-api.h | 7 + src/app/encoder.cpp | 449 ++++++++++-------- .../call-command-handler-src.zapt | 60 +-- src/app/zap-templates/chip-templates.json | 4 + src/app/zap-templates/encoder-src.zapt | 72 +-- src/app/zap-templates/helper-chip.js | 42 +- .../command_handler_cluster_commands.zapt | 38 ++ 26 files changed, 612 insertions(+), 783 deletions(-) delete mode 100644 examples/chip-tool/commands/common/NetworkCommand.cpp delete mode 100644 examples/chip-tool/commands/common/NetworkCommand.h delete mode 100644 examples/chip-tool/commands/echo/Commands.h delete mode 100644 examples/chip-tool/commands/echo/EchoCommand.cpp delete mode 100644 examples/chip-tool/commands/echo/EchoCommand.h create mode 100644 src/app/zap-templates/partials/command_handler_cluster_commands.zapt diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 204240cdfae12c..33c0f3f1b50735 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -1,6 +1,6 @@ { - "writeTime": "Wed Nov 18 2020 10:23:41 GMT+0100 (Central European Standard Time)", - "featureLevel": 4, + "writeTime": "Tue Dec 08 2020 13:12:25 GMT+0100 (Central European Standard Time)", + "featureLevel": 5, "creator": "zap", "keyValuePairs": [ { @@ -33,9 +33,9 @@ "endpointTypes": [ { "name": "Anonymous Endpoint Type", - "deviceTypeName": null, - "deviceTypeCode": null, - "deviceTypeProfileId": null, + "deviceTypeName": "CHIP-All-Clusters-Server", + "deviceTypeCode": "0x0000", + "deviceTypeProfileId": "0x0103", "clusters": [ { "name": "Basic", @@ -52,6 +52,14 @@ "source": "client", "incoming": 1, "outgoing": 1 + }, + { + "name": "MfgSpecificPing", + "code": 0, + "mfgCode": "0x1002", + "source": "client", + "incoming": 1, + "outgoing": 1 } ], "attributes": [ @@ -79,6 +87,7 @@ "define": "BASIC_CLUSTER", "side": "server", "enabled": 1, + "commands": [], "attributes": [ { "name": "cluster revision", @@ -125,8 +134,7 @@ "maxInterval": 65344, "reportableChange": 0 } - ], - "commands": [] + ] }, { "name": "Identify", @@ -135,6 +143,23 @@ "define": "IDENTIFY_CLUSTER", "side": "client", "enabled": 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 + } + ], "commands": [ { "name": "Identify", @@ -152,23 +177,6 @@ "incoming": 1, "outgoing": 1 } - ], - "attributes": [ - { - "name": "cluster revision", - "code": 65533, - "mfgCode": null, - "side": "client", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "2", - "reportable": 0, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } ] }, { @@ -178,16 +186,6 @@ "define": "IDENTIFY_CLUSTER", "side": "server", "enabled": 1, - "commands": [ - { - "name": "IdentifyQueryResponse", - "code": 0, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - } - ], "attributes": [ { "name": "cluster revision", @@ -219,6 +217,16 @@ "maxInterval": 65344, "reportableChange": 0 } + ], + "commands": [ + { + "name": "IdentifyQueryResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } ] }, { @@ -2822,4 +2830,4 @@ "networkId": 1 } ] -} +} \ No newline at end of file diff --git a/examples/all-clusters-app/all-clusters-common/gen/call-command-handler.cpp b/examples/all-clusters-app/all-clusters-common/gen/call-command-handler.cpp index 9db10b94ef3350..8800211673c58c 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/call-command-handler.cpp +++ b/examples/all-clusters-app/all-clusters-common/gen/call-command-handler.cpp @@ -199,7 +199,14 @@ EmberAfStatus emberAfBasicClusterServerCommandParse(EmberAfClusterCommand * cmd) { bool wasHandled = false; - if (!cmd->mfgSpecific) + if (cmd->mfgSpecific) + { + if (cmd->mfgCode == 0x1002 && cmd->commandId == ZCL_MFG_SPECIFIC_PING_COMMAND_ID) + { + wasHandled = emberAfBasicClusterMfgSpecificPingCallback(); + } + } + else { switch (cmd->commandId) { diff --git a/examples/all-clusters-app/all-clusters-common/gen/callback.h b/examples/all-clusters-app/all-clusters-common/gen/callback.h index 7391f06f5fcdf0..8e9a076da715b0 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/callback.h +++ b/examples/all-clusters-app/all-clusters-common/gen/callback.h @@ -1536,6 +1536,12 @@ bool emberAfBarrierControlClusterBarrierControlGoToPercentCallback(uint8_t perce bool emberAfBarrierControlClusterBarrierControlStopCallback(); +/** + * @brief Basic Cluster MfgSpecificPing Command callback + */ + +bool emberAfBasicClusterMfgSpecificPingCallback(); + /** * @brief Basic Cluster ResetToFactoryDefaults Command callback */ diff --git a/examples/all-clusters-app/all-clusters-common/gen/command-id.h b/examples/all-clusters-app/all-clusters-common/gen/command-id.h index 940258f4527aa5..cc63eff3ebc90b 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/command-id.h +++ b/examples/all-clusters-app/all-clusters-common/gen/command-id.h @@ -46,6 +46,7 @@ // Commands for cluster: Basic #define ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID (0x00) +#define ZCL_MFG_SPECIFIC_PING_COMMAND_ID (0x00) // Commands for cluster: Identify #define ZCL_IDENTIFY_COMMAND_ID (0x00) diff --git a/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h b/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h index 8cef47f152fda4..96be9d9b2525eb 100644 --- a/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h +++ b/examples/all-clusters-app/all-clusters-common/gen/endpoint_config.h @@ -419,8 +419,9 @@ // Generated data for the command discovery #define GENERATED_COMMANDS \ { \ - { 0x0000, 0x00, COMMAND_MASK_OUTGOING_CLIENT | COMMAND_MASK_INCOMING_SERVER }, /* Basic / ResetToFactoryDefaults */ \ - { 0x0003, 0x00, COMMAND_MASK_OUTGOING_CLIENT | COMMAND_MASK_INCOMING_SERVER }, /* Identify / Identify */ \ + { 0x0000, 0x00, COMMAND_MASK_OUTGOING_CLIENT | COMMAND_MASK_INCOMING_SERVER }, /* Basic / ResetToFactoryDefaults */ \ + { 0x0000, 0x00, COMMAND_MASK_INCOMING_SERVER | COMMAND_MASK_MANUFACTURER_SPECIFIC }, /* Basic / MfgSpecificPing */ \ + { 0x0003, 0x00, COMMAND_MASK_OUTGOING_CLIENT | COMMAND_MASK_INCOMING_SERVER }, /* Identify / Identify */ \ { 0x0003, 0x00, COMMAND_MASK_OUTGOING_SERVER | COMMAND_MASK_INCOMING_CLIENT }, /* Identify / IdentifyQueryResponse */ \ { 0x0003, 0x01, COMMAND_MASK_OUTGOING_CLIENT | COMMAND_MASK_INCOMING_SERVER }, /* Identify / IdentifyQuery */ \ { 0x0004, 0x00, COMMAND_MASK_OUTGOING_CLIENT | COMMAND_MASK_INCOMING_SERVER }, /* Groups / AddGroup */ \ @@ -592,16 +593,16 @@ { 0x0B03, 0x02, COMMAND_MASK_INCOMING_CLIENT }, /* Appliance Statistics / LogQueueResponse */ \ { 0x0B03, 0x03, COMMAND_MASK_INCOMING_CLIENT }, /* Appliance Statistics / StatisticsAvailable */ \ } -#define EMBER_AF_GENERATED_COMMAND_COUNT (160) +#define EMBER_AF_GENERATED_COMMAND_COUNT (161) // Command manufacturer codes #define GENERATED_COMMAND_MANUFACTURER_CODES \ { \ { \ - 0x00, 0x00 \ + 0x01, 0x1002 \ } \ } -#define GENERATED_COMMAND_MANUFACTURER_CODE_COUNT (0) +#define GENERATED_COMMAND_MANUFACTURER_CODE_COUNT (1) // Generated reporting configuration defaults #define EMBER_AF_GENERATED_REPORTING_CONFIG_DEFAULTS \ diff --git a/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp b/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp index 6f7e8a48b9339a..6a5e9d76e3f2ee 100644 --- a/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp +++ b/examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp @@ -33,6 +33,7 @@ #include "gen/attribute-id.h" #include "gen/cluster-id.h" #include +#include #include #include @@ -167,3 +168,9 @@ void DeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointI exit: return; } + +bool emberAfBasicClusterMfgSpecificPingCallback(void) +{ + emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS); + return true; +} diff --git a/examples/all-clusters-app/linux/main.cpp b/examples/all-clusters-app/linux/main.cpp index 145ce38a267ffe..18a90d159b2216 100644 --- a/examples/all-clusters-app/linux/main.cpp +++ b/examples/all-clusters-app/linux/main.cpp @@ -44,6 +44,12 @@ void emberAfPostAttributeChangeCallback(EndpointId endpoint, ClusterId clusterId uint16_t manufacturerCode, uint8_t type, uint8_t size, uint8_t * value) {} +bool emberAfBasicClusterMfgSpecificPingCallback(void) +{ + emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS); + return true; +} + int main(int argc, char * argv[]) { CHIP_ERROR err = CHIP_NO_ERROR; diff --git a/examples/chip-tool/BUILD.gn b/examples/chip-tool/BUILD.gn index beacb0f4951055..61dc58a8965b90 100644 --- a/examples/chip-tool/BUILD.gn +++ b/examples/chip-tool/BUILD.gn @@ -23,8 +23,6 @@ executable("chip-tool") { "commands/clusters/ModelCommand.cpp", "commands/common/Command.cpp", "commands/common/Commands.cpp", - "commands/common/NetworkCommand.cpp", - "commands/echo/EchoCommand.cpp", "commands/pairing/PairingCommand.cpp", "commands/payload/ParseCommand.cpp", "config/PersistentStorage.cpp", diff --git a/examples/chip-tool/README.md b/examples/chip-tool/README.md index bf0cbdff08b5fa..acb3c2bdbe2faa 100644 --- a/examples/chip-tool/README.md +++ b/examples/chip-tool/README.md @@ -57,15 +57,6 @@ the ESP32 all-clusters-app: $ chip-tool pairing unpair -## Using the Client to Request an Echo - -### Ping a device - - $ chip-tool echo ip - -If valid values are supplied, it will send a message to the paired device and -verify that the incoming echo from the server matches what was sent out. - ## Using the Client to Send CHIP Commands To use the Client to send a CHIP commands, run the built executable and pass it diff --git a/examples/chip-tool/commands/clusters/Commands.h b/examples/chip-tool/commands/clusters/Commands.h index 039c37c0796f5a..ab964a2b1c5dbc 100644 --- a/examples/chip-tool/commands/clusters/Commands.h +++ b/examples/chip-tool/commands/clusters/Commands.h @@ -1098,6 +1098,7 @@ class ReadBarrierControlBarrierPosition : public ModelCommand |------------------------------------------------------------------------------| | Commands: | | | * ResetToFactoryDefaults | 0x00 | +| * MfgSpecificPing | 0x00 | |------------------------------------------------------------------------------| | Attributes: | | | * ZclVersion | 0x0000 | @@ -1128,6 +1129,27 @@ class BasicResetToFactoryDefaults : public ModelCommand } }; +/* + * Command MfgSpecificPing + */ +class BasicMfgSpecificPing : public ModelCommand +{ +public: + BasicMfgSpecificPing() : ModelCommand("ping", kBasicClusterId, 0x00) { ModelCommand::AddArguments(); } + + uint16_t EncodeCommand(const PacketBufferHandle & buffer, uint16_t bufferSize, uint8_t endPointId) override + { + return encodeBasicClusterMfgSpecificPingCommand(buffer->Start(), bufferSize, endPointId); + } + + // Global Response: DefaultResponse + bool HandleGlobalResponse(uint8_t commandId, uint8_t * message, uint16_t messageLen) const override + { + DefaultResponse response; + return response.HandleCommandResponse(commandId, message, messageLen); + } +}; + /* * Discover attributes */ @@ -6457,10 +6479,8 @@ void registerClusterBasic(Commands & commands) const char * clusterName = "Basic"; commands_list clusterCommands = { - make_unique(), - make_unique(), - make_unique(), - make_unique(), + make_unique(), make_unique(), make_unique(), + make_unique(), make_unique(), }; commands.Register(clusterName, clusterCommands); diff --git a/examples/chip-tool/commands/clusters/ModelCommand.cpp b/examples/chip-tool/commands/clusters/ModelCommand.cpp index 5d3bf097f2a901..a099e10660ad6c 100644 --- a/examples/chip-tool/commands/clusters/ModelCommand.cpp +++ b/examples/chip-tool/commands/clusters/ModelCommand.cpp @@ -21,34 +21,103 @@ using namespace ::chip; namespace { -constexpr uint8_t kZCLGlobalCmdFrameControlHeader = 8; -constexpr uint8_t kZCLClusterCmdFrameControlHeader = 9; +// Make sure our buffer is big enough, but this will need a better setup! +constexpr uint16_t kMaxBufferSize = 1024; +constexpr uint16_t kWaitDurationInSeconds = 10; +constexpr uint8_t kZCLGlobalCmdFrameControlHeader = 8; +constexpr uint8_t kZCLClusterCmdFrameControlHeader = 9; +constexpr uint8_t kZCLGlobalMfgSpecificCmdFrameControlHeader = 12; bool isValidFrame(uint8_t frameControl) { // Bit 3 of the frame control byte set means direction is server to client. - return (frameControl == kZCLGlobalCmdFrameControlHeader || frameControl == kZCLClusterCmdFrameControlHeader); + return (frameControl == kZCLGlobalCmdFrameControlHeader || frameControl == kZCLClusterCmdFrameControlHeader || + kZCLGlobalMfgSpecificCmdFrameControlHeader); } bool isGlobalCommand(uint8_t frameControl) { - return (frameControl == kZCLGlobalCmdFrameControlHeader); + return (frameControl == kZCLGlobalCmdFrameControlHeader || frameControl == kZCLGlobalMfgSpecificCmdFrameControlHeader); } } // namespace -uint16_t ModelCommand::Encode(PacketBufferHandle & buffer, uint16_t bufferSize) +CHIP_ERROR ModelCommand::Run(PersistentStorage & storage, NodeId localId, NodeId remoteId) { + CHIP_ERROR err = CHIP_NO_ERROR; + + err = mCommissioner.SetUdpListenPort(storage.GetListenPort()); + VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Init failure! Commissioner: %s", chip::ErrorStr(err))); + + err = mCommissioner.Init(localId, &storage); + VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Init failure! Commissioner: %s", chip::ErrorStr(err))); + + err = mCommissioner.ServiceEvents(); + VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Init failure! Run Loop: %s", chip::ErrorStr(err))); + + err = RunInternal(remoteId); + SuccessOrExit(err); + + VerifyOrExit(GetCommandExitStatus(), err = CHIP_ERROR_INTERNAL); + +exit: + mCommissioner.ServiceEventSignal(); + mCommissioner.Shutdown(); + return err; +} + +CHIP_ERROR ModelCommand::RunInternal(NodeId remoteId) +{ + ChipDevice * device; + CHIP_ERROR err = mCommissioner.GetDevice(remoteId, &device); + VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(chipTool, "Could not find a paired device. Are you sure it has been paired ?")); + + device->SetDelegate(this); + + err = RunCommandInternal(device); + SuccessOrExit(err); + + UpdateWaitForResponse(true); + WaitForResponse(kWaitDurationInSeconds); + +exit: + return err; +} + +CHIP_ERROR ModelCommand::RunCommandInternal(ChipDevice * device) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + uint16_t payloadLen = 0; + + PacketBufferHandle buffer = PacketBuffer::NewWithAvailableSize(kMaxBufferSize); + VerifyOrExit(!buffer.IsNull(), err = CHIP_ERROR_NO_MEMORY); + ChipLogProgress(chipTool, "Endpoint id: '0x%02x', Cluster id: '0x%04x', Command id: '0x%02x'", mEndPointId, mClusterId, mCommandId); - return EncodeCommand(buffer, bufferSize, mEndPointId); + payloadLen = EncodeCommand(buffer, kMaxBufferSize, mEndPointId); + VerifyOrExit(payloadLen != 0, err = CHIP_ERROR_INVALID_MESSAGE_LENGTH); + + buffer->SetDataLength(payloadLen); + +#ifdef DEBUG + PrintBuffer(buffer); +#endif + + err = device->SendMessage(std::move(buffer)); + VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(chipTool, "Failed to send message: %s", ErrorStr(err))); + +exit: + return err; } -bool ModelCommand::Decode(PacketBufferHandle & buffer) const +void ModelCommand::OnMessage(PacketBufferHandle buffer) { + ChipLogDetail(chipTool, "OnMessage: Received %zu bytes", buffer->DataLength()); + EmberApsFrame frame; uint8_t * message; uint16_t messageLen; + uint16_t mfgCode; uint8_t frameControl; uint8_t sequenceNumber; uint8_t commandId; @@ -62,9 +131,17 @@ bool ModelCommand::Decode(PacketBufferHandle & buffer) const ChipLogDetail(chipTool, "APS frame processing success!"); messageLen = extractMessage(buffer->Start(), buffer->DataLength(), &message); - VerifyOrExit(messageLen >= 3, ChipLogError(chipTool, "Unexpected response length: %d", messageLen)); + VerifyOrExit(messageLen >= 1, ChipLogError(chipTool, "Unexpected response length: %d", messageLen)); - frameControl = chip::Encoding::Read8(message); + frameControl = chip::Encoding::Read8(message); + if (frameControl & (1u << 2)) + { + VerifyOrExit(messageLen >= 5, ChipLogError(chipTool, "Unexpected response length: %d", messageLen)); + mfgCode = chip::Encoding::LittleEndian::Read16(message); + ChipLogDetail(chipTool, "Manufacturer specific code in response: 0x%04x", mfgCode); + messageLen = static_cast(messageLen - 2); + } + VerifyOrExit(messageLen >= 3, ChipLogError(chipTool, "Unexpected response length: %d", messageLen)); sequenceNumber = chip::Encoding::Read8(message); commandId = chip::Encoding::Read8(message); messageLen = static_cast(messageLen - 3); @@ -77,7 +154,24 @@ bool ModelCommand::Decode(PacketBufferHandle & buffer) const success = isGlobalCommand(frameControl) ? HandleGlobalResponse(commandId, message, messageLen) : HandleSpecificResponse(commandId, message, messageLen); - exit: - return success; + SetCommandExitStatus(success); + UpdateWaitForResponse(false); +} + +void ModelCommand::OnStatusChange(void) +{ + ChipLogProgress(chipTool, "DeviceStatusDelegate::OnStatusChange"); +} + +void ModelCommand::PrintBuffer(const PacketBufferHandle & buffer) const +{ + const size_t dataLen = buffer->DataLength(); + + fprintf(stderr, "SENDING: %zu ", dataLen); + for (size_t i = 0; i < dataLen; ++i) + { + fprintf(stderr, "%02x ", buffer->Start()[i]); + } + fprintf(stderr, "\n"); } diff --git a/examples/chip-tool/commands/clusters/ModelCommand.h b/examples/chip-tool/commands/clusters/ModelCommand.h index b8d159d182a0af..4ead0e68784eb0 100644 --- a/examples/chip-tool/commands/clusters/ModelCommand.h +++ b/examples/chip-tool/commands/clusters/ModelCommand.h @@ -18,8 +18,8 @@ #pragma once -#include "../common/NetworkCommand.h" - +#include "../../config/PersistentStorage.h" +#include "../common/Command.h" #include #include @@ -28,24 +28,33 @@ #define CHIP_ZCL_ENDPOINT_MIN 0x01 #define CHIP_ZCL_ENDPOINT_MAX 0xF0 -class ModelCommand : public NetworkCommand +class ModelCommand : public Command, public chip::Controller::DeviceStatusDelegate { public: ModelCommand(const char * commandName, uint16_t clusterId, uint8_t commandId) : - NetworkCommand(commandName), mClusterId(clusterId), mCommandId(commandId) + Command(commandName), mClusterId(clusterId), mCommandId(commandId) {} void AddArguments() { AddArgument("endpoint-id", CHIP_ZCL_ENDPOINT_MIN, CHIP_ZCL_ENDPOINT_MAX, &mEndPointId); } - /////////// NetworkCommand Interface ///////// - uint16_t Encode(PacketBufferHandle & buffer, uint16_t bufferSize) override; - bool Decode(PacketBufferHandle & buffer) const override; + /////////// Command Interface ///////// + CHIP_ERROR Run(PersistentStorage & storage, NodeId localId, NodeId remoteId) override; + + /////////// DeviceStatusDelegate Interface ///////// + void OnMessage(PacketBufferHandle buffer) override; + void OnStatusChange(void) override; virtual uint16_t EncodeCommand(const PacketBufferHandle & buffer, uint16_t bufferSize, uint8_t endPointId) = 0; virtual bool HandleGlobalResponse(uint8_t commandId, uint8_t * message, uint16_t messageLen) const { return false; } virtual bool HandleSpecificResponse(uint8_t commandId, uint8_t * message, uint16_t messageLen) const { return false; } private: + CHIP_ERROR RunInternal(NodeId remoteId); + CHIP_ERROR RunCommandInternal(ChipDevice * device); + + void PrintBuffer(const PacketBufferHandle & buffer) const; + + ChipDeviceCommissioner mCommissioner; const uint16_t mClusterId; const uint8_t mCommandId; uint8_t mEndPointId; diff --git a/examples/chip-tool/commands/common/NetworkCommand.cpp b/examples/chip-tool/commands/common/NetworkCommand.cpp deleted file mode 100644 index 047f5ef7b83ad4..00000000000000 --- a/examples/chip-tool/commands/common/NetworkCommand.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2020 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "NetworkCommand.h" - -using namespace ::chip; - -constexpr uint16_t kWaitDurationInSeconds = 10; - -// Make sure our buffer is big enough, but this will need a better setup! -constexpr uint16_t kMaxBufferSize = 1024; - -CHIP_ERROR NetworkCommand::Run(PersistentStorage & storage, NodeId localId, NodeId remoteId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - - err = mCommissioner.SetUdpListenPort(storage.GetListenPort()); - VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Init failure! Commissioner: %s", chip::ErrorStr(err))); - - err = mCommissioner.Init(localId, &storage); - VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Init failure! Commissioner: %s", chip::ErrorStr(err))); - - err = mCommissioner.ServiceEvents(); - VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(Controller, "Init failure! Run Loop: %s", chip::ErrorStr(err))); - - err = RunInternal(remoteId); - SuccessOrExit(err); - - VerifyOrExit(GetCommandExitStatus(), err = CHIP_ERROR_INTERNAL); - -exit: - mCommissioner.ServiceEventSignal(); - mCommissioner.Shutdown(); - return err; -} - -CHIP_ERROR NetworkCommand::RunInternal(NodeId remoteId) -{ - ChipDevice * device; - CHIP_ERROR err = mCommissioner.GetDevice(remoteId, &device); - VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(chipTool, "Could not find a paired device. Are you sure it has been paired ?")); - - device->SetDelegate(this); - - err = RunCommandInternal(device); - SuccessOrExit(err); - - UpdateWaitForResponse(true); - WaitForResponse(kWaitDurationInSeconds); - -exit: - return err; -} - -CHIP_ERROR NetworkCommand::RunCommandInternal(ChipDevice * device) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - uint16_t payloadLen = 0; - - PacketBufferHandle buffer = PacketBuffer::NewWithAvailableSize(kMaxBufferSize); - VerifyOrExit(!buffer.IsNull(), err = CHIP_ERROR_NO_MEMORY); - - payloadLen = Encode(buffer, kMaxBufferSize); - VerifyOrExit(payloadLen != 0, err = CHIP_ERROR_INVALID_MESSAGE_LENGTH); - - buffer->SetDataLength(payloadLen); - -#ifdef DEBUG - PrintBuffer(buffer); -#endif - - err = device->SendMessage(std::move(buffer)); - VerifyOrExit(err == CHIP_NO_ERROR, ChipLogError(chipTool, "Failed to send message: %s", ErrorStr(err))); - -exit: - return err; -} - -void NetworkCommand::OnMessage(PacketBufferHandle buffer) -{ - ChipLogDetail(chipTool, "OnMessage: Received %zu bytes", buffer->DataLength()); - - SetCommandExitStatus(Decode(buffer)); - UpdateWaitForResponse(false); -} - -void NetworkCommand::OnStatusChange(void) -{ - ChipLogProgress(chipTool, "DeviceStatusDelegate::OnStatusChange"); -} - -void NetworkCommand::PrintBuffer(PacketBufferHandle & buffer) const -{ - const size_t data_len = buffer->DataLength(); - - fprintf(stderr, "SENDING: %zu ", data_len); - for (size_t i = 0; i < data_len; ++i) - { - fprintf(stderr, "%d ", buffer->Start()[i]); - } - fprintf(stderr, "\n"); -} diff --git a/examples/chip-tool/commands/common/NetworkCommand.h b/examples/chip-tool/commands/common/NetworkCommand.h deleted file mode 100644 index d520f6d7dfd0e5..00000000000000 --- a/examples/chip-tool/commands/common/NetworkCommand.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#pragma once - -#include "../../config/PersistentStorage.h" -#include "Command.h" - -class NetworkCommand : public Command, public chip::Controller::DeviceStatusDelegate -{ -public: - NetworkCommand(const char * commandName) : Command(commandName) {} - - virtual uint16_t Encode(PacketBufferHandle & buffer, uint16_t bufferSize) = 0; - virtual bool Decode(PacketBufferHandle & buffer) const = 0; - - /////////// Command Interface ///////// - CHIP_ERROR Run(PersistentStorage & storage, NodeId localId, NodeId remoteId) override; - - /////////// DeviceStatusDelegate Interface ///////// - void OnMessage(PacketBufferHandle buffer) override; - void OnStatusChange(void) override; - -private: - CHIP_ERROR RunInternal(NodeId remoteId); - CHIP_ERROR RunCommandInternal(ChipDevice * device); - - void PrintBuffer(PacketBufferHandle & buffer) const; - - ChipDeviceCommissioner mCommissioner; -}; diff --git a/examples/chip-tool/commands/echo/Commands.h b/examples/chip-tool/commands/echo/Commands.h deleted file mode 100644 index a9702dbe3d607b..00000000000000 --- a/examples/chip-tool/commands/echo/Commands.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2020 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#pragma once - -#include "EchoCommand.h" - -class Echo : public EchoCommand -{ -public: - Echo() : EchoCommand("ip") {} -}; - -void registerCommandsEcho(Commands & commands) -{ - const char * clusterName = "Echo"; - - commands_list clusterCommands = { - make_unique(), - }; - - commands.Register(clusterName, clusterCommands); -} diff --git a/examples/chip-tool/commands/echo/EchoCommand.cpp b/examples/chip-tool/commands/echo/EchoCommand.cpp deleted file mode 100644 index 04e2fe20ab49b0..00000000000000 --- a/examples/chip-tool/commands/echo/EchoCommand.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2020 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include "EchoCommand.h" - -using namespace ::chip; - -namespace { -static const char PAYLOAD[] = "Message from Standalone CHIP echo client!"; - -bool IsIdenticalMessage(System::PacketBufferHandle & buffer) -{ - size_t dataLen = buffer->DataLength(); - return (dataLen + 1 == sizeof PAYLOAD) && (memcmp(buffer->Start(), PAYLOAD, dataLen) == 0); -} -} // namespace - -uint16_t EchoCommand::Encode(PacketBufferHandle & buffer, uint16_t bufferSize) -{ - uint16_t payloadLen = 0; - - if (strlen(PAYLOAD) > bufferSize) - { - ChipLogError(chipTool, "PAYLOAD length too big for PacketBuffer (> bufferSize)"); - } - else - { - payloadLen = static_cast(strlen(PAYLOAD)); - memcpy(buffer->Start(), PAYLOAD, payloadLen); - } - - return payloadLen; -} - -bool EchoCommand::Decode(PacketBufferHandle & buffer) const -{ - bool success = IsIdenticalMessage(buffer); - - if (!success) - { - ChipLogError(chipTool, "Echo: Error \nSend: %s \nRecv: %.*s", PAYLOAD, buffer->DataLength(), buffer->Start()); - } - - return success; -} diff --git a/examples/chip-tool/commands/echo/EchoCommand.h b/examples/chip-tool/commands/echo/EchoCommand.h deleted file mode 100644 index 5ce008d68ff8b0..00000000000000 --- a/examples/chip-tool/commands/echo/EchoCommand.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2020 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#pragma once - -#include "../common/NetworkCommand.h" - -class EchoCommand : public NetworkCommand -{ -public: - EchoCommand(const char * commandName) : NetworkCommand(commandName) {} - - /////////// NetworkCommand Interface ///////// - uint16_t Encode(PacketBufferHandle & buffer, uint16_t bufferSize) override; - bool Decode(PacketBufferHandle & buffer) const override; -}; diff --git a/examples/chip-tool/main.cpp b/examples/chip-tool/main.cpp index a7bf3ec9b1f478..ce59b9758a3330 100644 --- a/examples/chip-tool/main.cpp +++ b/examples/chip-tool/main.cpp @@ -19,7 +19,6 @@ #include "commands/common/Commands.h" #include "commands/clusters/Commands.h" -#include "commands/echo/Commands.h" #include "commands/pairing/Commands.h" #include "commands/payload/Commands.h" @@ -31,7 +30,6 @@ int main(int argc, char * argv[]) { Commands commands; - registerCommandsEcho(commands); registerCommandsPayload(commands); registerCommandsPairing(commands); registerClusters(commands); diff --git a/examples/common/chip-app-server/DataModelHandler.cpp b/examples/common/chip-app-server/DataModelHandler.cpp index 9aa86739d7736e..7ab9f4b1e547c4 100644 --- a/examples/common/chip-app-server/DataModelHandler.cpp +++ b/examples/common/chip-app-server/DataModelHandler.cpp @@ -33,112 +33,13 @@ using namespace ::chip; /** - * A data model message has nonzero length and always has a first byte whose - * value is one of: 0x00, 0x01, 0x02, 0x03. See chipZclEncodeZclHeader for the - * construction of the message and in particular the first byte. - * - * Echo messages should generally not have a first byte with those values, so we - * can use that to try to distinguish between the two. - */ -bool ContentMayBeADataModelMessage(const System::PacketBufferHandle & buffer) -{ - const size_t data_len = buffer->DataLength(); - const uint8_t * data = buffer->Start(); - bool maybeDataModelMessage = true; - - // Has to have nonzero length. - VerifyOrExit(data_len > 0, maybeDataModelMessage = false); - - // Has to have a valid first byte value. - VerifyOrExit(data[0] < 0x04, maybeDataModelMessage = false); - -exit: - return maybeDataModelMessage; -} - -/** - * @brief implements something like "od -c", changes an arbitrary byte string - * into a single-line of ascii. Destroys any byte-wise encoding that - * might be present, e.g. utf-8. + * Handle a message that should be processed via our data model processing + * codepath. This function will free the packet buffer. * - * @param bytes potentially unprintable buffer - * @param bytes_len length of bytes - * @param out where to put the printable string - * @param out_len length of out - * @return size_t required size of output buffer, including null-termination + * @param [in] buffer The buffer holding the message. This function guarantees + * that it will free the buffer before returning. */ -static size_t BinaryBytesToPrintableString(const uint8_t * bytes, size_t bytes_len, char * out, size_t out_len) -{ - size_t required = 1; // always need null termination - memset(out, 0, out_len); - // count and print - for (; bytes_len > 0; bytes_len--, bytes++) - { - uint8_t byte = *bytes; - - if ((byte >= '\t' && byte <= '\r') || byte == '\\') - { - static const char * kCodes = "tnvfr"; - char code = (byte == '\\') ? '\\' : kCodes[byte - '\t']; - required += 2; - if (out_len > 2) - { - *out++ = '\\'; - *out++ = code; - out_len -= 2; - } - } - else if (byte >= ' ' && byte <= '~') - { - required += 1; - if (out_len > 1) - { - *out++ = byte; - out_len--; - } - } - else - { - static const size_t kBinCodeLen = sizeof("\\xFF") - 1; - static const char * kCodes = "0123456789ABCDEF"; - - required += kBinCodeLen; - if (out_len > kBinCodeLen) - { - *out++ = '\\'; - *out++ = 'x'; - *out++ = kCodes[(byte & 0xf0) >> 4]; - *out++ = kCodes[byte & 0xf]; - out_len -= kBinCodeLen; - } - } - } - - return required; -} - -void ProcessOthersMessage(const PacketHeader & header, System::PacketBufferHandle & buffer, SecureSessionMgr * mgr) -{ - CHIP_ERROR err; - char logmsg[512]; - - BinaryBytesToPrintableString(buffer->Start(), buffer->DataLength(), logmsg, sizeof(logmsg)); - - ChipLogProgress(AppServer, "Client sent: %s", logmsg); - - // Attempt to echo back - err = mgr->SendMessage(header.GetSourceNodeId().Value(), std::move(buffer)); - if (err != CHIP_NO_ERROR) - { - ChipLogProgress(AppServer, "Unable to echo back to client: %s", ErrorStr(err)); - } - else - { - ChipLogProgress(AppServer, "Echo sent"); - } -} - -void ProcessDataModelMessage(const PacketHeader & header, System::PacketBufferHandle & buffer) +void HandleDataModelMessage(const PacketHeader & header, System::PacketBufferHandle buffer, SecureSessionMgr * mgr) { EmberApsFrame frame; bool ok = extractApsFrame(buffer->Start(), buffer->DataLength(), &frame) > 0; @@ -170,30 +71,6 @@ void ProcessDataModelMessage(const PacketHeader & header, System::PacketBufferHa } } -/** - * Handle a message that should be processed via our data model processing - * codepath. This function will free the packet buffer. - * - * @param [in] buffer The buffer holding the message. This function guarantees - * that it will free the buffer before returning. - */ -void HandleDataModelMessage(const PacketHeader & header, System::PacketBufferHandle buffer, SecureSessionMgr * mgr) -{ - // FIXME: Long-term we shouldn't be guessing what sort of message this is - // based on the message bytes. We're doing this for now to support both - // data model messages and text echo messages, but in the long term we - // should either do echo via a data model command or do echo on a separate - // port from data model processing. - if (ContentMayBeADataModelMessage(buffer)) - { - ProcessDataModelMessage(header, buffer); - } - else - { - ProcessOthersMessage(header, buffer, mgr); - } -} - void InitDataModelHandler() { emberAfEndpointConfigure(); diff --git a/src/app/chip-zcl-zpro-codec-api.h b/src/app/chip-zcl-zpro-codec-api.h index d7e3bbd2591c51..332b26d71193e7 100644 --- a/src/app/chip-zcl-zpro-codec-api.h +++ b/src/app/chip-zcl-zpro-codec-api.h @@ -117,6 +117,7 @@ uint16_t encodeBarrierControlClusterReadClusterRevisionAttribute(uint8_t * buffe | Cluster Basic | 0x0000 | |------------------------------------------------------------------------------| | Commands: | | +| * MfgSpecificPing | 0x00 | | * ResetToFactoryDefaults | 0x00 | |------------------------------------------------------------------------------| | Attributes: | | @@ -125,6 +126,12 @@ uint16_t encodeBarrierControlClusterReadClusterRevisionAttribute(uint8_t * buffe | * ClusterRevision | 0xFFFD | \*----------------------------------------------------------------------------*/ +/** + * @brief + * Encode an MfgSpecificPing command for Basic server into buffer including the APS frame + */ +uint16_t encodeBasicClusterMfgSpecificPingCommand(uint8_t * buffer, uint16_t buf_length, chip::EndpointId destination_endpoint); + /** * @brief * Encode an ResetToFactoryDefaults command for Basic server into buffer including the APS frame diff --git a/src/app/encoder.cpp b/src/app/encoder.cpp index 0b4e124368a3e6..0692dd72befc2f 100644 --- a/src/app/encoder.cpp +++ b/src/app/encoder.cpp @@ -26,6 +26,8 @@ using namespace chip; +constexpr uint16_t kNullManufacturerCode = 0x0000; + #define CHECK_FRAME_LENGTH(value, name) \ if (value == 0) \ { \ @@ -33,9 +35,10 @@ using namespace chip; return 0; \ } -#define READ_ATTRIBUTES(name, cluster_id) \ +#define READ_ATTRIBUTES(name, cluster_id, mfgCode) \ uint16_t attr_id_count = sizeof(attr_ids) / sizeof(attr_ids[0]); \ - uint16_t result = encodeReadAttributesCommand(buffer, buf_length, destination_endpoint, cluster_id, attr_ids, attr_id_count); \ + uint16_t result = \ + encodeReadAttributesCommand(buffer, buf_length, destination_endpoint, cluster_id, mfgCode, attr_ids, attr_id_count); \ if (result == 0) \ { \ ChipLogError(Zcl, "Error encoding %s command", name); \ @@ -43,9 +46,9 @@ using namespace chip; } \ return result; -#define WRITE_ATTRIBUTE(name, cluster_id, value) \ +#define WRITE_ATTRIBUTE(name, cluster_id, mfgCode, value) \ BufBound buf = BufBound(buffer, buf_length); \ - if (_encodeGlobalCommand(buf, destination_endpoint, cluster_id, 0x02)) \ + if (_encodeGlobalCommand(buf, destination_endpoint, cluster_id, mfgCode, 0x02)) \ { \ buf.Put16(attr_id); \ buf.Put(attr_type); \ @@ -77,9 +80,9 @@ using namespace chip; } \ return result; -#define REPORT_ATTRIBUTE(name, cluster_id, isAnalog, value) \ +#define REPORT_ATTRIBUTE(name, cluster_id, mfgCode, isAnalog, value) \ BufBound buf = BufBound(buffer, buf_length); \ - if (_encodeGlobalCommand(buf, destination_endpoint, cluster_id, 0x06)) \ + if (_encodeGlobalCommand(buf, destination_endpoint, cluster_id, mfgCode, 0x06)) \ { \ uint8_t direction = 0x00; \ buf.Put(direction); \ @@ -115,9 +118,9 @@ using namespace chip; } \ return result; -#define DISCOVER_ATTRIBUTES(name, cluster_id) \ +#define DISCOVER_ATTRIBUTES(name, cluster_id, mfgCode) \ BufBound buf = BufBound(buffer, buf_length); \ - if (_encodeGlobalCommand(buf, destination_endpoint, cluster_id, 0x0c)) \ + if (_encodeGlobalCommand(buf, destination_endpoint, cluster_id, mfgCode, 0x0c)) \ { \ /* Discover all attributes */ \ buf.Put16(0x0000); \ @@ -132,9 +135,9 @@ using namespace chip; } \ return result; -#define COMMAND_HEADER(name, cluster_id, command_id) \ +#define COMMAND_HEADER(name, cluster_id, mfgCode, command_id) \ BufBound buf = BufBound(buffer, buf_length); \ - uint16_t result = _encodeClusterSpecificCommand(buf, destination_endpoint, cluster_id, command_id); \ + uint16_t result = _encodeClusterSpecificCommand(buf, destination_endpoint, cluster_id, mfgCode, command_id); \ if (result == 0) \ { \ ChipLogError(Zcl, "Error encoding %s command", name); \ @@ -162,8 +165,8 @@ using namespace chip; buf.Put(str); \ } -#define COMMAND(name, cluster_id, command_id) \ - COMMAND_HEADER(name, cluster_id, command_id); \ +#define COMMAND(name, cluster_id, mfgCode, command_id) \ + COMMAND_HEADER(name, cluster_id, mfgCode, command_id); \ COMMAND_FOOTER(name); using namespace chip; @@ -239,7 +242,7 @@ uint16_t encodeApsFrame(uint8_t * buffer, uint16_t buf_length, EmberApsFrame * a apsFrame->groupId, apsFrame->sequence, apsFrame->radius, !buffer); } -uint16_t _encodeCommand(BufBound & buf, EndpointId destination_endpoint, ClusterId cluster_id, CommandId command, +uint16_t _encodeCommand(BufBound & buf, EndpointId destination_endpoint, ClusterId cluster_id, uint16_t mfgCode, CommandId command, uint8_t frame_control) { CHECK_FRAME_LENGTH(buf.Size(), "Buffer is empty"); @@ -250,6 +253,10 @@ uint16_t _encodeCommand(BufBound & buf, EndpointId destination_endpoint, Cluster if (doEncodeApsFrame(buf, cluster_id, source_endpoint, destination_endpoint, 0, 0, 0, 0, false)) { buf.Put(frame_control); + if (mfgCode != kNullManufacturerCode) + { + buf.Put16(mfgCode); + } buf.Put(seq_num); buf.Put(command); } @@ -257,31 +264,39 @@ uint16_t _encodeCommand(BufBound & buf, EndpointId destination_endpoint, Cluster return buf.Fit() && CanCastTo(buf.Needed()) ? static_cast(buf.Needed()) : 0; } -uint16_t _encodeClusterSpecificCommand(BufBound & buf, EndpointId destination_endpoint, ClusterId cluster_id, CommandId command) +uint16_t _encodeClusterSpecificCommand(BufBound & buf, EndpointId destination_endpoint, ClusterId cluster_id, uint16_t mfgCode, + CommandId command) { - // This is a cluster-specific command so low two bits are 0b01. The command - // is standard, so does not need a manufacturer code, and we're sending + // This is a cluster-specific command so low two bits are 0b01 and we're sending // client to server, so all the remaining bits are 0. uint8_t frame_control = 0x01; + if (mfgCode != kNullManufacturerCode) + { + frame_control = frame_control | (1u << 2); + } - return _encodeCommand(buf, destination_endpoint, cluster_id, command, frame_control); + return _encodeCommand(buf, destination_endpoint, cluster_id, mfgCode, command, frame_control); } -uint16_t _encodeGlobalCommand(BufBound & buf, EndpointId destination_endpoint, ClusterId cluster_id, CommandId command) +uint16_t _encodeGlobalCommand(BufBound & buf, EndpointId destination_endpoint, ClusterId cluster_id, uint16_t mfgCode, + CommandId command) { - // This is a global command, so the low bits are 0b00. The command is - // standard, so does not need a manufacturer code, and we're sending client + // This is a global command, so the low bits are 0b00 and we're sending client // to server, so all the remaining bits are 0. uint8_t frame_control = 0x00; + if (mfgCode != kNullManufacturerCode) + { + frame_control = frame_control | (1u << 2); + } - return _encodeCommand(buf, destination_endpoint, cluster_id, command, frame_control); + return _encodeCommand(buf, destination_endpoint, cluster_id, mfgCode, command, frame_control); } uint16_t encodeReadAttributesCommand(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint, ClusterId cluster_id, - const uint16_t * attr_ids, uint16_t attr_id_count) + uint16_t mfgCode, const uint16_t * attr_ids, uint16_t attr_id_count) { BufBound buf = BufBound(buffer, buf_length); - if (_encodeGlobalCommand(buf, destination_endpoint, cluster_id, 0x00)) + if (_encodeGlobalCommand(buf, destination_endpoint, cluster_id, mfgCode, 0x00)) { for (uint16_t i = 0; i < attr_id_count; ++i) { @@ -315,7 +330,7 @@ uint16_t encodeBarrierControlClusterBarrierControlGoToPercentCommand(uint8_t * b EndpointId destination_endpoint, uint8_t percentOpen) { const char * kName = "BarrierControlBarrierControlGoToPercent"; - COMMAND_HEADER(kName, BARRIER_CONTROL_CLUSTER_ID, 0x00); + COMMAND_HEADER(kName, BARRIER_CONTROL_CLUSTER_ID, 0x0000, 0x00); buf.Put(percentOpen); COMMAND_FOOTER(kName); } @@ -327,13 +342,13 @@ uint16_t encodeBarrierControlClusterBarrierControlStopCommand(uint8_t * buffer, EndpointId destination_endpoint) { const char * kName = "BarrierControlBarrierControlStop"; - COMMAND_HEADER(kName, BARRIER_CONTROL_CLUSTER_ID, 0x01); + COMMAND_HEADER(kName, BARRIER_CONTROL_CLUSTER_ID, 0x0000, 0x01); COMMAND_FOOTER(kName); } uint16_t encodeBarrierControlClusterDiscoverAttributes(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { - DISCOVER_ATTRIBUTES("DiscoverBarrierControlAttributes", BARRIER_CONTROL_CLUSTER_ID); + DISCOVER_ATTRIBUTES("DiscoverBarrierControlAttributes", BARRIER_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -343,7 +358,7 @@ uint16_t encodeBarrierControlClusterReadBarrierMovingStateAttribute(uint8_t * bu EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0001 }; - READ_ATTRIBUTES("ReadBarrierControlBarrierMovingState", BARRIER_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadBarrierControlBarrierMovingState", BARRIER_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -353,7 +368,7 @@ uint16_t encodeBarrierControlClusterReadBarrierSafetyStatusAttribute(uint8_t * b EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0002 }; - READ_ATTRIBUTES("ReadBarrierControlBarrierSafetyStatus", BARRIER_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadBarrierControlBarrierSafetyStatus", BARRIER_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -363,7 +378,7 @@ uint16_t encodeBarrierControlClusterReadBarrierCapabilitiesAttribute(uint8_t * b EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0003 }; - READ_ATTRIBUTES("ReadBarrierControlBarrierCapabilities", BARRIER_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadBarrierControlBarrierCapabilities", BARRIER_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -373,7 +388,7 @@ uint16_t encodeBarrierControlClusterReadBarrierPositionAttribute(uint8_t * buffe EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x000A }; - READ_ATTRIBUTES("ReadBarrierControlBarrierPosition", BARRIER_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadBarrierControlBarrierPosition", BARRIER_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -383,13 +398,14 @@ uint16_t encodeBarrierControlClusterReadClusterRevisionAttribute(uint8_t * buffe EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0xFFFD }; - READ_ATTRIBUTES("ReadBarrierControlClusterRevision", BARRIER_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadBarrierControlClusterRevision", BARRIER_CONTROL_CLUSTER_ID, 0x0000); } /*----------------------------------------------------------------------------*\ | Cluster Basic | 0x0000 | |------------------------------------------------------------------------------| | Commands: | | +| * MfgSpecificPing | 0x00 | | * ResetToFactoryDefaults | 0x00 | |------------------------------------------------------------------------------| | Attributes: | | @@ -398,19 +414,29 @@ uint16_t encodeBarrierControlClusterReadClusterRevisionAttribute(uint8_t * buffe | * ClusterRevision | 0xFFFD | \*----------------------------------------------------------------------------*/ +/* + * Command MfgSpecificPing + */ +uint16_t encodeBasicClusterMfgSpecificPingCommand(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) +{ + const char * kName = "BasicMfgSpecificPing"; + COMMAND_HEADER(kName, BASIC_CLUSTER_ID, 0x1002, 0x00); + COMMAND_FOOTER(kName); +} + /* * Command ResetToFactoryDefaults */ uint16_t encodeBasicClusterResetToFactoryDefaultsCommand(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { const char * kName = "BasicResetToFactoryDefaults"; - COMMAND_HEADER(kName, BASIC_CLUSTER_ID, 0x00); + COMMAND_HEADER(kName, BASIC_CLUSTER_ID, 0x0000, 0x00); COMMAND_FOOTER(kName); } uint16_t encodeBasicClusterDiscoverAttributes(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { - DISCOVER_ATTRIBUTES("DiscoverBasicAttributes", BASIC_CLUSTER_ID); + DISCOVER_ATTRIBUTES("DiscoverBasicAttributes", BASIC_CLUSTER_ID, 0x0000); } /* @@ -419,7 +445,7 @@ uint16_t encodeBasicClusterDiscoverAttributes(uint8_t * buffer, uint16_t buf_len uint16_t encodeBasicClusterReadZclVersionAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0000 }; - READ_ATTRIBUTES("ReadBasicZclVersion", BASIC_CLUSTER_ID); + READ_ATTRIBUTES("ReadBasicZclVersion", BASIC_CLUSTER_ID, 0x0000); } /* @@ -428,7 +454,7 @@ uint16_t encodeBasicClusterReadZclVersionAttribute(uint8_t * buffer, uint16_t bu uint16_t encodeBasicClusterReadPowerSourceAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0007 }; - READ_ATTRIBUTES("ReadBasicPowerSource", BASIC_CLUSTER_ID); + READ_ATTRIBUTES("ReadBasicPowerSource", BASIC_CLUSTER_ID, 0x0000); } /* @@ -437,7 +463,7 @@ uint16_t encodeBasicClusterReadPowerSourceAttribute(uint8_t * buffer, uint16_t b uint16_t encodeBasicClusterReadClusterRevisionAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0xFFFD }; - READ_ATTRIBUTES("ReadBasicClusterRevision", BASIC_CLUSTER_ID); + READ_ATTRIBUTES("ReadBasicClusterRevision", BASIC_CLUSTER_ID, 0x0000); } /*----------------------------------------------------------------------------*\ @@ -520,7 +546,7 @@ uint16_t encodeColorControlClusterMoveColorCommand(uint8_t * buffer, uint16_t bu int16_t rateX, int16_t rateY, uint8_t optionsMask, uint8_t optionsOverride) { const char * kName = "ColorControlMoveColor"; - COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x08); + COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x0000, 0x08); buf.Put16(static_cast(rateX)); buf.Put16(static_cast(rateY)); buf.Put(optionsMask); @@ -537,7 +563,7 @@ uint16_t encodeColorControlClusterMoveColorTemperatureCommand(uint8_t * buffer, uint8_t optionsMask, uint8_t optionsOverride) { const char * kName = "ColorControlMoveColorTemperature"; - COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x4B); + COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x0000, 0x4B); buf.Put(moveMode); buf.Put16(rate); buf.Put16(colorTemperatureMinimum); @@ -554,7 +580,7 @@ uint16_t encodeColorControlClusterMoveHueCommand(uint8_t * buffer, uint16_t buf_ uint8_t moveMode, uint8_t rate, uint8_t optionsMask, uint8_t optionsOverride) { const char * kName = "ColorControlMoveHue"; - COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x01); + COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x0000, 0x01); buf.Put(moveMode); buf.Put(rate); buf.Put(optionsMask); @@ -570,7 +596,7 @@ uint16_t encodeColorControlClusterMoveSaturationCommand(uint8_t * buffer, uint16 uint8_t optionsOverride) { const char * kName = "ColorControlMoveSaturation"; - COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x04); + COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x0000, 0x04); buf.Put(moveMode); buf.Put(rate); buf.Put(optionsMask); @@ -586,7 +612,7 @@ uint16_t encodeColorControlClusterMoveToColorCommand(uint8_t * buffer, uint16_t uint8_t optionsOverride) { const char * kName = "ColorControlMoveToColor"; - COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x07); + COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x0000, 0x07); buf.Put16(colorX); buf.Put16(colorY); buf.Put16(transitionTime); @@ -604,7 +630,7 @@ uint16_t encodeColorControlClusterMoveToColorTemperatureCommand(uint8_t * buffer uint8_t optionsOverride) { const char * kName = "ColorControlMoveToColorTemperature"; - COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x0A); + COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x0000, 0x0A); buf.Put16(colorTemperature); buf.Put16(transitionTime); buf.Put(optionsMask); @@ -620,7 +646,7 @@ uint16_t encodeColorControlClusterMoveToHueCommand(uint8_t * buffer, uint16_t bu uint8_t optionsOverride) { const char * kName = "ColorControlMoveToHue"; - COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x00); + COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x0000, 0x00); buf.Put(hue); buf.Put(direction); buf.Put16(transitionTime); @@ -638,7 +664,7 @@ uint16_t encodeColorControlClusterMoveToHueAndSaturationCommand(uint8_t * buffer uint8_t optionsOverride) { const char * kName = "ColorControlMoveToHueAndSaturation"; - COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x06); + COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x0000, 0x06); buf.Put(hue); buf.Put(saturation); buf.Put16(transitionTime); @@ -655,7 +681,7 @@ uint16_t encodeColorControlClusterMoveToSaturationCommand(uint8_t * buffer, uint uint8_t optionsOverride) { const char * kName = "ColorControlMoveToSaturation"; - COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x03); + COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x0000, 0x03); buf.Put(saturation); buf.Put16(transitionTime); buf.Put(optionsMask); @@ -671,7 +697,7 @@ uint16_t encodeColorControlClusterStepColorCommand(uint8_t * buffer, uint16_t bu uint8_t optionsOverride) { const char * kName = "ColorControlStepColor"; - COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x09); + COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x0000, 0x09); buf.Put16(static_cast(stepX)); buf.Put16(static_cast(stepY)); buf.Put16(transitionTime); @@ -690,7 +716,7 @@ uint16_t encodeColorControlClusterStepColorTemperatureCommand(uint8_t * buffer, uint8_t optionsOverride) { const char * kName = "ColorControlStepColorTemperature"; - COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x4C); + COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x0000, 0x4C); buf.Put(stepMode); buf.Put16(stepSize); buf.Put16(transitionTime); @@ -709,7 +735,7 @@ uint16_t encodeColorControlClusterStepHueCommand(uint8_t * buffer, uint16_t buf_ uint8_t optionsOverride) { const char * kName = "ColorControlStepHue"; - COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x02); + COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x0000, 0x02); buf.Put(stepMode); buf.Put(stepSize); buf.Put(transitionTime); @@ -726,7 +752,7 @@ uint16_t encodeColorControlClusterStepSaturationCommand(uint8_t * buffer, uint16 uint8_t optionsMask, uint8_t optionsOverride) { const char * kName = "ColorControlStepSaturation"; - COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x05); + COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x0000, 0x05); buf.Put(stepMode); buf.Put(stepSize); buf.Put(transitionTime); @@ -742,7 +768,7 @@ uint16_t encodeColorControlClusterStopMoveStepCommand(uint8_t * buffer, uint16_t uint8_t optionsMask, uint8_t optionsOverride) { const char * kName = "ColorControlStopMoveStep"; - COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x47); + COMMAND_HEADER(kName, COLOR_CONTROL_CLUSTER_ID, 0x0000, 0x47); buf.Put(optionsMask); buf.Put(optionsOverride); COMMAND_FOOTER(kName); @@ -750,7 +776,7 @@ uint16_t encodeColorControlClusterStopMoveStepCommand(uint8_t * buffer, uint16_t uint16_t encodeColorControlClusterDiscoverAttributes(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { - DISCOVER_ATTRIBUTES("DiscoverColorControlAttributes", COLOR_CONTROL_CLUSTER_ID); + DISCOVER_ATTRIBUTES("DiscoverColorControlAttributes", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -759,7 +785,7 @@ uint16_t encodeColorControlClusterDiscoverAttributes(uint8_t * buffer, uint16_t uint16_t encodeColorControlClusterReadCurrentHueAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0000 }; - READ_ATTRIBUTES("ReadColorControlCurrentHue", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlCurrentHue", COLOR_CONTROL_CLUSTER_ID, 0x0000); } uint16_t encodeColorControlClusterReportCurrentHueAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint, @@ -767,7 +793,7 @@ uint16_t encodeColorControlClusterReportCurrentHueAttribute(uint8_t * buffer, ui { uint16_t attr_id = 0x0000; uint8_t attr_type = { 0x20 }; - REPORT_ATTRIBUTE("ReportColorControlCurrentHue", COLOR_CONTROL_CLUSTER_ID, true, change); + REPORT_ATTRIBUTE("ReportColorControlCurrentHue", COLOR_CONTROL_CLUSTER_ID, 0x0000, true, change); } /* @@ -777,7 +803,7 @@ uint16_t encodeColorControlClusterReadCurrentSaturationAttribute(uint8_t * buffe EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0001 }; - READ_ATTRIBUTES("ReadColorControlCurrentSaturation", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlCurrentSaturation", COLOR_CONTROL_CLUSTER_ID, 0x0000); } uint16_t encodeColorControlClusterReportCurrentSaturationAttribute(uint8_t * buffer, uint16_t buf_length, @@ -786,7 +812,7 @@ uint16_t encodeColorControlClusterReportCurrentSaturationAttribute(uint8_t * buf { uint16_t attr_id = 0x0001; uint8_t attr_type = { 0x20 }; - REPORT_ATTRIBUTE("ReportColorControlCurrentSaturation", COLOR_CONTROL_CLUSTER_ID, true, change); + REPORT_ATTRIBUTE("ReportColorControlCurrentSaturation", COLOR_CONTROL_CLUSTER_ID, 0x0000, true, change); } /* @@ -795,7 +821,7 @@ uint16_t encodeColorControlClusterReportCurrentSaturationAttribute(uint8_t * buf uint16_t encodeColorControlClusterReadRemainingTimeAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0002 }; - READ_ATTRIBUTES("ReadColorControlRemainingTime", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlRemainingTime", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -804,7 +830,7 @@ uint16_t encodeColorControlClusterReadRemainingTimeAttribute(uint8_t * buffer, u uint16_t encodeColorControlClusterReadCurrentXAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0003 }; - READ_ATTRIBUTES("ReadColorControlCurrentX", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlCurrentX", COLOR_CONTROL_CLUSTER_ID, 0x0000); } uint16_t encodeColorControlClusterReportCurrentXAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint, @@ -812,7 +838,7 @@ uint16_t encodeColorControlClusterReportCurrentXAttribute(uint8_t * buffer, uint { uint16_t attr_id = 0x0003; uint8_t attr_type = { 0x21 }; - REPORT_ATTRIBUTE("ReportColorControlCurrentX", COLOR_CONTROL_CLUSTER_ID, true, change); + REPORT_ATTRIBUTE("ReportColorControlCurrentX", COLOR_CONTROL_CLUSTER_ID, 0x0000, true, change); } /* @@ -821,7 +847,7 @@ uint16_t encodeColorControlClusterReportCurrentXAttribute(uint8_t * buffer, uint uint16_t encodeColorControlClusterReadCurrentYAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0004 }; - READ_ATTRIBUTES("ReadColorControlCurrentY", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlCurrentY", COLOR_CONTROL_CLUSTER_ID, 0x0000); } uint16_t encodeColorControlClusterReportCurrentYAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint, @@ -829,7 +855,7 @@ uint16_t encodeColorControlClusterReportCurrentYAttribute(uint8_t * buffer, uint { uint16_t attr_id = 0x0004; uint8_t attr_type = { 0x21 }; - REPORT_ATTRIBUTE("ReportColorControlCurrentY", COLOR_CONTROL_CLUSTER_ID, true, change); + REPORT_ATTRIBUTE("ReportColorControlCurrentY", COLOR_CONTROL_CLUSTER_ID, 0x0000, true, change); } /* @@ -839,7 +865,7 @@ uint16_t encodeColorControlClusterReadDriftCompensationAttribute(uint8_t * buffe EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0005 }; - READ_ATTRIBUTES("ReadColorControlDriftCompensation", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlDriftCompensation", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -849,7 +875,7 @@ uint16_t encodeColorControlClusterReadCompensationTextAttribute(uint8_t * buffer EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0006 }; - READ_ATTRIBUTES("ReadColorControlCompensationText", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlCompensationText", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -859,7 +885,7 @@ uint16_t encodeColorControlClusterReadColorTemperatureAttribute(uint8_t * buffer EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0007 }; - READ_ATTRIBUTES("ReadColorControlColorTemperature", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlColorTemperature", COLOR_CONTROL_CLUSTER_ID, 0x0000); } uint16_t encodeColorControlClusterReportColorTemperatureAttribute(uint8_t * buffer, uint16_t buf_length, @@ -868,7 +894,7 @@ uint16_t encodeColorControlClusterReportColorTemperatureAttribute(uint8_t * buff { uint16_t attr_id = 0x0007; uint8_t attr_type = { 0x21 }; - REPORT_ATTRIBUTE("ReportColorControlColorTemperature", COLOR_CONTROL_CLUSTER_ID, true, change); + REPORT_ATTRIBUTE("ReportColorControlColorTemperature", COLOR_CONTROL_CLUSTER_ID, 0x0000, true, change); } /* @@ -877,7 +903,7 @@ uint16_t encodeColorControlClusterReportColorTemperatureAttribute(uint8_t * buff uint16_t encodeColorControlClusterReadColorModeAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0008 }; - READ_ATTRIBUTES("ReadColorControlColorMode", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlColorMode", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -887,7 +913,7 @@ uint16_t encodeColorControlClusterReadColorControlOptionsAttribute(uint8_t * buf EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x000F }; - READ_ATTRIBUTES("ReadColorControlColorControlOptions", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlColorControlOptions", COLOR_CONTROL_CLUSTER_ID, 0x0000); } uint16_t encodeColorControlClusterWriteColorControlOptionsAttribute(uint8_t * buffer, uint16_t buf_length, @@ -895,7 +921,7 @@ uint16_t encodeColorControlClusterWriteColorControlOptionsAttribute(uint8_t * bu { uint16_t attr_id = 0x000F; uint8_t attr_type = { 0x18 }; - WRITE_ATTRIBUTE("WriteColorControlColorControlOptions", COLOR_CONTROL_CLUSTER_ID, colorControlOptions); + WRITE_ATTRIBUTE("WriteColorControlColorControlOptions", COLOR_CONTROL_CLUSTER_ID, 0x0000, colorControlOptions); } /* @@ -905,7 +931,7 @@ uint16_t encodeColorControlClusterReadNumberOfPrimariesAttribute(uint8_t * buffe EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0010 }; - READ_ATTRIBUTES("ReadColorControlNumberOfPrimaries", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlNumberOfPrimaries", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -914,7 +940,7 @@ uint16_t encodeColorControlClusterReadNumberOfPrimariesAttribute(uint8_t * buffe uint16_t encodeColorControlClusterReadPrimary1XAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0011 }; - READ_ATTRIBUTES("ReadColorControlPrimary1X", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlPrimary1X", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -923,7 +949,7 @@ uint16_t encodeColorControlClusterReadPrimary1XAttribute(uint8_t * buffer, uint1 uint16_t encodeColorControlClusterReadPrimary1YAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0012 }; - READ_ATTRIBUTES("ReadColorControlPrimary1Y", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlPrimary1Y", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -933,7 +959,7 @@ uint16_t encodeColorControlClusterReadPrimary1IntensityAttribute(uint8_t * buffe EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0013 }; - READ_ATTRIBUTES("ReadColorControlPrimary1Intensity", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlPrimary1Intensity", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -942,7 +968,7 @@ uint16_t encodeColorControlClusterReadPrimary1IntensityAttribute(uint8_t * buffe uint16_t encodeColorControlClusterReadPrimary2XAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0015 }; - READ_ATTRIBUTES("ReadColorControlPrimary2X", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlPrimary2X", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -951,7 +977,7 @@ uint16_t encodeColorControlClusterReadPrimary2XAttribute(uint8_t * buffer, uint1 uint16_t encodeColorControlClusterReadPrimary2YAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0016 }; - READ_ATTRIBUTES("ReadColorControlPrimary2Y", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlPrimary2Y", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -961,7 +987,7 @@ uint16_t encodeColorControlClusterReadPrimary2IntensityAttribute(uint8_t * buffe EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0017 }; - READ_ATTRIBUTES("ReadColorControlPrimary2Intensity", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlPrimary2Intensity", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -970,7 +996,7 @@ uint16_t encodeColorControlClusterReadPrimary2IntensityAttribute(uint8_t * buffe uint16_t encodeColorControlClusterReadPrimary3XAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0019 }; - READ_ATTRIBUTES("ReadColorControlPrimary3X", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlPrimary3X", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -979,7 +1005,7 @@ uint16_t encodeColorControlClusterReadPrimary3XAttribute(uint8_t * buffer, uint1 uint16_t encodeColorControlClusterReadPrimary3YAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x001A }; - READ_ATTRIBUTES("ReadColorControlPrimary3Y", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlPrimary3Y", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -989,7 +1015,7 @@ uint16_t encodeColorControlClusterReadPrimary3IntensityAttribute(uint8_t * buffe EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x001B }; - READ_ATTRIBUTES("ReadColorControlPrimary3Intensity", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlPrimary3Intensity", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -998,7 +1024,7 @@ uint16_t encodeColorControlClusterReadPrimary3IntensityAttribute(uint8_t * buffe uint16_t encodeColorControlClusterReadPrimary4XAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0020 }; - READ_ATTRIBUTES("ReadColorControlPrimary4X", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlPrimary4X", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -1007,7 +1033,7 @@ uint16_t encodeColorControlClusterReadPrimary4XAttribute(uint8_t * buffer, uint1 uint16_t encodeColorControlClusterReadPrimary4YAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0021 }; - READ_ATTRIBUTES("ReadColorControlPrimary4Y", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlPrimary4Y", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -1017,7 +1043,7 @@ uint16_t encodeColorControlClusterReadPrimary4IntensityAttribute(uint8_t * buffe EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0022 }; - READ_ATTRIBUTES("ReadColorControlPrimary4Intensity", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlPrimary4Intensity", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -1026,7 +1052,7 @@ uint16_t encodeColorControlClusterReadPrimary4IntensityAttribute(uint8_t * buffe uint16_t encodeColorControlClusterReadPrimary5XAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0024 }; - READ_ATTRIBUTES("ReadColorControlPrimary5X", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlPrimary5X", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -1035,7 +1061,7 @@ uint16_t encodeColorControlClusterReadPrimary5XAttribute(uint8_t * buffer, uint1 uint16_t encodeColorControlClusterReadPrimary5YAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0025 }; - READ_ATTRIBUTES("ReadColorControlPrimary5Y", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlPrimary5Y", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -1045,7 +1071,7 @@ uint16_t encodeColorControlClusterReadPrimary5IntensityAttribute(uint8_t * buffe EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0026 }; - READ_ATTRIBUTES("ReadColorControlPrimary5Intensity", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlPrimary5Intensity", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -1054,7 +1080,7 @@ uint16_t encodeColorControlClusterReadPrimary5IntensityAttribute(uint8_t * buffe uint16_t encodeColorControlClusterReadPrimary6XAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0028 }; - READ_ATTRIBUTES("ReadColorControlPrimary6X", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlPrimary6X", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -1063,7 +1089,7 @@ uint16_t encodeColorControlClusterReadPrimary6XAttribute(uint8_t * buffer, uint1 uint16_t encodeColorControlClusterReadPrimary6YAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0029 }; - READ_ATTRIBUTES("ReadColorControlPrimary6Y", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlPrimary6Y", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -1073,7 +1099,7 @@ uint16_t encodeColorControlClusterReadPrimary6IntensityAttribute(uint8_t * buffe EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x002A }; - READ_ATTRIBUTES("ReadColorControlPrimary6Intensity", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlPrimary6Intensity", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -1082,7 +1108,7 @@ uint16_t encodeColorControlClusterReadPrimary6IntensityAttribute(uint8_t * buffe uint16_t encodeColorControlClusterReadWhitePointXAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0030 }; - READ_ATTRIBUTES("ReadColorControlWhitePointX", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlWhitePointX", COLOR_CONTROL_CLUSTER_ID, 0x0000); } uint16_t encodeColorControlClusterWriteWhitePointXAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint, @@ -1090,7 +1116,7 @@ uint16_t encodeColorControlClusterWriteWhitePointXAttribute(uint8_t * buffer, ui { uint16_t attr_id = 0x0030; uint8_t attr_type = { 0x21 }; - WRITE_ATTRIBUTE("WriteColorControlWhitePointX", COLOR_CONTROL_CLUSTER_ID, whitePointX); + WRITE_ATTRIBUTE("WriteColorControlWhitePointX", COLOR_CONTROL_CLUSTER_ID, 0x0000, whitePointX); } /* @@ -1099,7 +1125,7 @@ uint16_t encodeColorControlClusterWriteWhitePointXAttribute(uint8_t * buffer, ui uint16_t encodeColorControlClusterReadWhitePointYAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0031 }; - READ_ATTRIBUTES("ReadColorControlWhitePointY", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlWhitePointY", COLOR_CONTROL_CLUSTER_ID, 0x0000); } uint16_t encodeColorControlClusterWriteWhitePointYAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint, @@ -1107,7 +1133,7 @@ uint16_t encodeColorControlClusterWriteWhitePointYAttribute(uint8_t * buffer, ui { uint16_t attr_id = 0x0031; uint8_t attr_type = { 0x21 }; - WRITE_ATTRIBUTE("WriteColorControlWhitePointY", COLOR_CONTROL_CLUSTER_ID, whitePointY); + WRITE_ATTRIBUTE("WriteColorControlWhitePointY", COLOR_CONTROL_CLUSTER_ID, 0x0000, whitePointY); } /* @@ -1116,7 +1142,7 @@ uint16_t encodeColorControlClusterWriteWhitePointYAttribute(uint8_t * buffer, ui uint16_t encodeColorControlClusterReadColorPointRXAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0032 }; - READ_ATTRIBUTES("ReadColorControlColorPointRX", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlColorPointRX", COLOR_CONTROL_CLUSTER_ID, 0x0000); } uint16_t encodeColorControlClusterWriteColorPointRXAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint, @@ -1124,7 +1150,7 @@ uint16_t encodeColorControlClusterWriteColorPointRXAttribute(uint8_t * buffer, u { uint16_t attr_id = 0x0032; uint8_t attr_type = { 0x21 }; - WRITE_ATTRIBUTE("WriteColorControlColorPointRX", COLOR_CONTROL_CLUSTER_ID, colorPointRX); + WRITE_ATTRIBUTE("WriteColorControlColorPointRX", COLOR_CONTROL_CLUSTER_ID, 0x0000, colorPointRX); } /* @@ -1133,7 +1159,7 @@ uint16_t encodeColorControlClusterWriteColorPointRXAttribute(uint8_t * buffer, u uint16_t encodeColorControlClusterReadColorPointRYAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0033 }; - READ_ATTRIBUTES("ReadColorControlColorPointRY", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlColorPointRY", COLOR_CONTROL_CLUSTER_ID, 0x0000); } uint16_t encodeColorControlClusterWriteColorPointRYAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint, @@ -1141,7 +1167,7 @@ uint16_t encodeColorControlClusterWriteColorPointRYAttribute(uint8_t * buffer, u { uint16_t attr_id = 0x0033; uint8_t attr_type = { 0x21 }; - WRITE_ATTRIBUTE("WriteColorControlColorPointRY", COLOR_CONTROL_CLUSTER_ID, colorPointRY); + WRITE_ATTRIBUTE("WriteColorControlColorPointRY", COLOR_CONTROL_CLUSTER_ID, 0x0000, colorPointRY); } /* @@ -1151,7 +1177,7 @@ uint16_t encodeColorControlClusterReadColorPointRIntensityAttribute(uint8_t * bu EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0034 }; - READ_ATTRIBUTES("ReadColorControlColorPointRIntensity", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlColorPointRIntensity", COLOR_CONTROL_CLUSTER_ID, 0x0000); } uint16_t encodeColorControlClusterWriteColorPointRIntensityAttribute(uint8_t * buffer, uint16_t buf_length, @@ -1159,7 +1185,7 @@ uint16_t encodeColorControlClusterWriteColorPointRIntensityAttribute(uint8_t * b { uint16_t attr_id = 0x0034; uint8_t attr_type = { 0x20 }; - WRITE_ATTRIBUTE("WriteColorControlColorPointRIntensity", COLOR_CONTROL_CLUSTER_ID, colorPointRIntensity); + WRITE_ATTRIBUTE("WriteColorControlColorPointRIntensity", COLOR_CONTROL_CLUSTER_ID, 0x0000, colorPointRIntensity); } /* @@ -1168,7 +1194,7 @@ uint16_t encodeColorControlClusterWriteColorPointRIntensityAttribute(uint8_t * b uint16_t encodeColorControlClusterReadColorPointGXAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0036 }; - READ_ATTRIBUTES("ReadColorControlColorPointGX", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlColorPointGX", COLOR_CONTROL_CLUSTER_ID, 0x0000); } uint16_t encodeColorControlClusterWriteColorPointGXAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint, @@ -1176,7 +1202,7 @@ uint16_t encodeColorControlClusterWriteColorPointGXAttribute(uint8_t * buffer, u { uint16_t attr_id = 0x0036; uint8_t attr_type = { 0x21 }; - WRITE_ATTRIBUTE("WriteColorControlColorPointGX", COLOR_CONTROL_CLUSTER_ID, colorPointGX); + WRITE_ATTRIBUTE("WriteColorControlColorPointGX", COLOR_CONTROL_CLUSTER_ID, 0x0000, colorPointGX); } /* @@ -1185,7 +1211,7 @@ uint16_t encodeColorControlClusterWriteColorPointGXAttribute(uint8_t * buffer, u uint16_t encodeColorControlClusterReadColorPointGYAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0037 }; - READ_ATTRIBUTES("ReadColorControlColorPointGY", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlColorPointGY", COLOR_CONTROL_CLUSTER_ID, 0x0000); } uint16_t encodeColorControlClusterWriteColorPointGYAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint, @@ -1193,7 +1219,7 @@ uint16_t encodeColorControlClusterWriteColorPointGYAttribute(uint8_t * buffer, u { uint16_t attr_id = 0x0037; uint8_t attr_type = { 0x21 }; - WRITE_ATTRIBUTE("WriteColorControlColorPointGY", COLOR_CONTROL_CLUSTER_ID, colorPointGY); + WRITE_ATTRIBUTE("WriteColorControlColorPointGY", COLOR_CONTROL_CLUSTER_ID, 0x0000, colorPointGY); } /* @@ -1203,7 +1229,7 @@ uint16_t encodeColorControlClusterReadColorPointGIntensityAttribute(uint8_t * bu EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0038 }; - READ_ATTRIBUTES("ReadColorControlColorPointGIntensity", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlColorPointGIntensity", COLOR_CONTROL_CLUSTER_ID, 0x0000); } uint16_t encodeColorControlClusterWriteColorPointGIntensityAttribute(uint8_t * buffer, uint16_t buf_length, @@ -1211,7 +1237,7 @@ uint16_t encodeColorControlClusterWriteColorPointGIntensityAttribute(uint8_t * b { uint16_t attr_id = 0x0038; uint8_t attr_type = { 0x20 }; - WRITE_ATTRIBUTE("WriteColorControlColorPointGIntensity", COLOR_CONTROL_CLUSTER_ID, colorPointGIntensity); + WRITE_ATTRIBUTE("WriteColorControlColorPointGIntensity", COLOR_CONTROL_CLUSTER_ID, 0x0000, colorPointGIntensity); } /* @@ -1220,7 +1246,7 @@ uint16_t encodeColorControlClusterWriteColorPointGIntensityAttribute(uint8_t * b uint16_t encodeColorControlClusterReadColorPointBXAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x003A }; - READ_ATTRIBUTES("ReadColorControlColorPointBX", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlColorPointBX", COLOR_CONTROL_CLUSTER_ID, 0x0000); } uint16_t encodeColorControlClusterWriteColorPointBXAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint, @@ -1228,7 +1254,7 @@ uint16_t encodeColorControlClusterWriteColorPointBXAttribute(uint8_t * buffer, u { uint16_t attr_id = 0x003A; uint8_t attr_type = { 0x21 }; - WRITE_ATTRIBUTE("WriteColorControlColorPointBX", COLOR_CONTROL_CLUSTER_ID, colorPointBX); + WRITE_ATTRIBUTE("WriteColorControlColorPointBX", COLOR_CONTROL_CLUSTER_ID, 0x0000, colorPointBX); } /* @@ -1237,7 +1263,7 @@ uint16_t encodeColorControlClusterWriteColorPointBXAttribute(uint8_t * buffer, u uint16_t encodeColorControlClusterReadColorPointBYAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x003B }; - READ_ATTRIBUTES("ReadColorControlColorPointBY", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlColorPointBY", COLOR_CONTROL_CLUSTER_ID, 0x0000); } uint16_t encodeColorControlClusterWriteColorPointBYAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint, @@ -1245,7 +1271,7 @@ uint16_t encodeColorControlClusterWriteColorPointBYAttribute(uint8_t * buffer, u { uint16_t attr_id = 0x003B; uint8_t attr_type = { 0x21 }; - WRITE_ATTRIBUTE("WriteColorControlColorPointBY", COLOR_CONTROL_CLUSTER_ID, colorPointBY); + WRITE_ATTRIBUTE("WriteColorControlColorPointBY", COLOR_CONTROL_CLUSTER_ID, 0x0000, colorPointBY); } /* @@ -1255,7 +1281,7 @@ uint16_t encodeColorControlClusterReadColorPointBIntensityAttribute(uint8_t * bu EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x003C }; - READ_ATTRIBUTES("ReadColorControlColorPointBIntensity", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlColorPointBIntensity", COLOR_CONTROL_CLUSTER_ID, 0x0000); } uint16_t encodeColorControlClusterWriteColorPointBIntensityAttribute(uint8_t * buffer, uint16_t buf_length, @@ -1263,7 +1289,7 @@ uint16_t encodeColorControlClusterWriteColorPointBIntensityAttribute(uint8_t * b { uint16_t attr_id = 0x003C; uint8_t attr_type = { 0x20 }; - WRITE_ATTRIBUTE("WriteColorControlColorPointBIntensity", COLOR_CONTROL_CLUSTER_ID, colorPointBIntensity); + WRITE_ATTRIBUTE("WriteColorControlColorPointBIntensity", COLOR_CONTROL_CLUSTER_ID, 0x0000, colorPointBIntensity); } /* @@ -1273,7 +1299,7 @@ uint16_t encodeColorControlClusterReadEnhancedCurrentHueAttribute(uint8_t * buff EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x4000 }; - READ_ATTRIBUTES("ReadColorControlEnhancedCurrentHue", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlEnhancedCurrentHue", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -1283,7 +1309,7 @@ uint16_t encodeColorControlClusterReadEnhancedColorModeAttribute(uint8_t * buffe EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x4001 }; - READ_ATTRIBUTES("ReadColorControlEnhancedColorMode", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlEnhancedColorMode", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -1293,7 +1319,7 @@ uint16_t encodeColorControlClusterReadColorLoopActiveAttribute(uint8_t * buffer, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x4002 }; - READ_ATTRIBUTES("ReadColorControlColorLoopActive", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlColorLoopActive", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -1303,7 +1329,7 @@ uint16_t encodeColorControlClusterReadColorLoopDirectionAttribute(uint8_t * buff EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x4003 }; - READ_ATTRIBUTES("ReadColorControlColorLoopDirection", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlColorLoopDirection", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -1312,7 +1338,7 @@ uint16_t encodeColorControlClusterReadColorLoopDirectionAttribute(uint8_t * buff uint16_t encodeColorControlClusterReadColorLoopTimeAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x4004 }; - READ_ATTRIBUTES("ReadColorControlColorLoopTime", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlColorLoopTime", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -1322,7 +1348,7 @@ uint16_t encodeColorControlClusterReadColorCapabilitiesAttribute(uint8_t * buffe EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x400A }; - READ_ATTRIBUTES("ReadColorControlColorCapabilities", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlColorCapabilities", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -1332,7 +1358,7 @@ uint16_t encodeColorControlClusterReadColorTempPhysicalMinAttribute(uint8_t * bu EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x400B }; - READ_ATTRIBUTES("ReadColorControlColorTempPhysicalMin", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlColorTempPhysicalMin", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -1342,7 +1368,7 @@ uint16_t encodeColorControlClusterReadColorTempPhysicalMaxAttribute(uint8_t * bu EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x400C }; - READ_ATTRIBUTES("ReadColorControlColorTempPhysicalMax", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlColorTempPhysicalMax", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -1352,7 +1378,7 @@ uint16_t encodeColorControlClusterReadCoupleColorTempToLevelMinMiredsAttribute(u EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x400D }; - READ_ATTRIBUTES("ReadColorControlCoupleColorTempToLevelMinMireds", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlCoupleColorTempToLevelMinMireds", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -1362,7 +1388,7 @@ uint16_t encodeColorControlClusterReadStartUpColorTemperatureMiredsAttribute(uin EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x4010 }; - READ_ATTRIBUTES("ReadColorControlStartUpColorTemperatureMireds", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlStartUpColorTemperatureMireds", COLOR_CONTROL_CLUSTER_ID, 0x0000); } uint16_t encodeColorControlClusterWriteStartUpColorTemperatureMiredsAttribute(uint8_t * buffer, uint16_t buf_length, @@ -1371,7 +1397,8 @@ uint16_t encodeColorControlClusterWriteStartUpColorTemperatureMiredsAttribute(ui { uint16_t attr_id = 0x4010; uint8_t attr_type = { 0x21 }; - WRITE_ATTRIBUTE("WriteColorControlStartUpColorTemperatureMireds", COLOR_CONTROL_CLUSTER_ID, startUpColorTemperatureMireds); + WRITE_ATTRIBUTE("WriteColorControlStartUpColorTemperatureMireds", COLOR_CONTROL_CLUSTER_ID, 0x0000, + startUpColorTemperatureMireds); } /* @@ -1381,7 +1408,7 @@ uint16_t encodeColorControlClusterReadClusterRevisionAttribute(uint8_t * buffer, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0xFFFD }; - READ_ATTRIBUTES("ReadColorControlClusterRevision", COLOR_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadColorControlClusterRevision", COLOR_CONTROL_CLUSTER_ID, 0x0000); } /*----------------------------------------------------------------------------*\ @@ -1425,7 +1452,7 @@ uint16_t encodeColorControlClusterReadClusterRevisionAttribute(uint8_t * buffer, uint16_t encodeDoorLockClusterClearAllPinsCommand(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { const char * kName = "DoorLockClearAllPins"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x08); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x08); COMMAND_FOOTER(kName); } @@ -1435,7 +1462,7 @@ uint16_t encodeDoorLockClusterClearAllPinsCommand(uint8_t * buffer, uint16_t buf uint16_t encodeDoorLockClusterClearAllRfidsCommand(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { const char * kName = "DoorLockClearAllRfids"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x19); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x19); COMMAND_FOOTER(kName); } @@ -1446,7 +1473,7 @@ uint16_t encodeDoorLockClusterClearHolidayScheduleCommand(uint8_t * buffer, uint uint8_t scheduleId) { const char * kName = "DoorLockClearHolidaySchedule"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x13); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x13); buf.Put(scheduleId); COMMAND_FOOTER(kName); } @@ -1458,7 +1485,7 @@ uint16_t encodeDoorLockClusterClearPinCommand(uint8_t * buffer, uint16_t buf_len uint16_t userId) { const char * kName = "DoorLockClearPin"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x07); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x07); buf.Put16(userId); COMMAND_FOOTER(kName); } @@ -1470,7 +1497,7 @@ uint16_t encodeDoorLockClusterClearRfidCommand(uint8_t * buffer, uint16_t buf_le uint16_t userId) { const char * kName = "DoorLockClearRfid"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x18); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x18); buf.Put16(userId); COMMAND_FOOTER(kName); } @@ -1482,7 +1509,7 @@ uint16_t encodeDoorLockClusterClearWeekdayScheduleCommand(uint8_t * buffer, uint uint8_t scheduleId, uint16_t userId) { const char * kName = "DoorLockClearWeekdaySchedule"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0D); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x0D); buf.Put(scheduleId); buf.Put16(userId); COMMAND_FOOTER(kName); @@ -1495,7 +1522,7 @@ uint16_t encodeDoorLockClusterClearYeardayScheduleCommand(uint8_t * buffer, uint uint8_t scheduleId, uint16_t userId) { const char * kName = "DoorLockClearYeardaySchedule"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x10); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x10); buf.Put(scheduleId); buf.Put16(userId); COMMAND_FOOTER(kName); @@ -1508,7 +1535,7 @@ uint16_t encodeDoorLockClusterGetHolidayScheduleCommand(uint8_t * buffer, uint16 uint8_t scheduleId) { const char * kName = "DoorLockGetHolidaySchedule"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x12); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x12); buf.Put(scheduleId); COMMAND_FOOTER(kName); } @@ -1520,7 +1547,7 @@ uint16_t encodeDoorLockClusterGetLogRecordCommand(uint8_t * buffer, uint16_t buf uint16_t logIndex) { const char * kName = "DoorLockGetLogRecord"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x04); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x04); buf.Put16(logIndex); COMMAND_FOOTER(kName); } @@ -1531,7 +1558,7 @@ uint16_t encodeDoorLockClusterGetLogRecordCommand(uint8_t * buffer, uint16_t buf uint16_t encodeDoorLockClusterGetPinCommand(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint, uint16_t userId) { const char * kName = "DoorLockGetPin"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x06); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x06); buf.Put16(userId); COMMAND_FOOTER(kName); } @@ -1543,7 +1570,7 @@ uint16_t encodeDoorLockClusterGetRfidCommand(uint8_t * buffer, uint16_t buf_leng uint16_t userId) { const char * kName = "DoorLockGetRfid"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x17); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x17); buf.Put16(userId); COMMAND_FOOTER(kName); } @@ -1555,7 +1582,7 @@ uint16_t encodeDoorLockClusterGetUserTypeCommand(uint8_t * buffer, uint16_t buf_ uint16_t userId) { const char * kName = "DoorLockGetUserType"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x15); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x15); buf.Put16(userId); COMMAND_FOOTER(kName); } @@ -1567,7 +1594,7 @@ uint16_t encodeDoorLockClusterGetWeekdayScheduleCommand(uint8_t * buffer, uint16 uint8_t scheduleId, uint16_t userId) { const char * kName = "DoorLockGetWeekdaySchedule"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0C); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x0C); buf.Put(scheduleId); buf.Put16(userId); COMMAND_FOOTER(kName); @@ -1580,7 +1607,7 @@ uint16_t encodeDoorLockClusterGetYeardayScheduleCommand(uint8_t * buffer, uint16 uint8_t scheduleId, uint16_t userId) { const char * kName = "DoorLockGetYeardaySchedule"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0F); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x0F); buf.Put(scheduleId); buf.Put16(userId); COMMAND_FOOTER(kName); @@ -1592,7 +1619,7 @@ uint16_t encodeDoorLockClusterGetYeardayScheduleCommand(uint8_t * buffer, uint16 uint16_t encodeDoorLockClusterLockDoorCommand(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint, char * pin) { const char * kName = "DoorLockLockDoor"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x00); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x00); COMMAND_INSERT_STRING(kName, pin); COMMAND_FOOTER(kName); } @@ -1605,7 +1632,7 @@ uint16_t encodeDoorLockClusterSetHolidayScheduleCommand(uint8_t * buffer, uint16 uint8_t operatingModeDuringHoliday) { const char * kName = "DoorLockSetHolidaySchedule"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x11); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x11); buf.Put(scheduleId); buf.Put32(localStartTime); buf.Put32(localEndTime); @@ -1620,7 +1647,7 @@ uint16_t encodeDoorLockClusterSetPinCommand(uint8_t * buffer, uint16_t buf_lengt uint8_t userStatus, uint8_t userType, char * pin) { const char * kName = "DoorLockSetPin"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x05); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x05); buf.Put16(userId); buf.Put(userStatus); buf.Put(userType); @@ -1635,7 +1662,7 @@ uint16_t encodeDoorLockClusterSetRfidCommand(uint8_t * buffer, uint16_t buf_leng uint16_t userId, uint8_t userStatus, uint8_t userType, char * id) { const char * kName = "DoorLockSetRfid"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x16); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x16); buf.Put16(userId); buf.Put(userStatus); buf.Put(userType); @@ -1650,7 +1677,7 @@ uint16_t encodeDoorLockClusterSetUserTypeCommand(uint8_t * buffer, uint16_t buf_ uint16_t userId, uint8_t userType) { const char * kName = "DoorLockSetUserType"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x14); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x14); buf.Put16(userId); buf.Put(userType); COMMAND_FOOTER(kName); @@ -1664,7 +1691,7 @@ uint16_t encodeDoorLockClusterSetWeekdayScheduleCommand(uint8_t * buffer, uint16 uint8_t startMinute, uint8_t endHour, uint8_t endMinute) { const char * kName = "DoorLockSetWeekdaySchedule"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0B); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x0B); buf.Put(scheduleId); buf.Put16(userId); buf.Put(daysMask); @@ -1683,7 +1710,7 @@ uint16_t encodeDoorLockClusterSetYeardayScheduleCommand(uint8_t * buffer, uint16 uint32_t localEndTime) { const char * kName = "DoorLockSetYeardaySchedule"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0E); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x0E); buf.Put(scheduleId); buf.Put16(userId); buf.Put32(localStartTime); @@ -1697,7 +1724,7 @@ uint16_t encodeDoorLockClusterSetYeardayScheduleCommand(uint8_t * buffer, uint16 uint16_t encodeDoorLockClusterUnlockDoorCommand(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint, char * pin) { const char * kName = "DoorLockUnlockDoor"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x01); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x01); COMMAND_INSERT_STRING(kName, pin); COMMAND_FOOTER(kName); } @@ -1709,7 +1736,7 @@ uint16_t encodeDoorLockClusterUnlockWithTimeoutCommand(uint8_t * buffer, uint16_ uint16_t timeoutInSeconds, char * pin) { const char * kName = "DoorLockUnlockWithTimeout"; - COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x03); + COMMAND_HEADER(kName, DOOR_LOCK_CLUSTER_ID, 0x0000, 0x03); buf.Put16(timeoutInSeconds); COMMAND_INSERT_STRING(kName, pin); COMMAND_FOOTER(kName); @@ -1717,7 +1744,7 @@ uint16_t encodeDoorLockClusterUnlockWithTimeoutCommand(uint8_t * buffer, uint16_ uint16_t encodeDoorLockClusterDiscoverAttributes(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { - DISCOVER_ATTRIBUTES("DiscoverDoorLockAttributes", DOOR_LOCK_CLUSTER_ID); + DISCOVER_ATTRIBUTES("DiscoverDoorLockAttributes", DOOR_LOCK_CLUSTER_ID, 0x0000); } /* @@ -1726,7 +1753,7 @@ uint16_t encodeDoorLockClusterDiscoverAttributes(uint8_t * buffer, uint16_t buf_ uint16_t encodeDoorLockClusterReadLockStateAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0000 }; - READ_ATTRIBUTES("ReadDoorLockLockState", DOOR_LOCK_CLUSTER_ID); + READ_ATTRIBUTES("ReadDoorLockLockState", DOOR_LOCK_CLUSTER_ID, 0x0000); } uint16_t encodeDoorLockClusterReportLockStateAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint, @@ -1734,7 +1761,7 @@ uint16_t encodeDoorLockClusterReportLockStateAttribute(uint8_t * buffer, uint16_ { uint16_t attr_id = 0x0000; uint8_t attr_type = { 0x30 }; - REPORT_ATTRIBUTE("ReportDoorLockLockState", DOOR_LOCK_CLUSTER_ID, false, 0); + REPORT_ATTRIBUTE("ReportDoorLockLockState", DOOR_LOCK_CLUSTER_ID, 0x0000, false, 0); } /* @@ -1743,7 +1770,7 @@ uint16_t encodeDoorLockClusterReportLockStateAttribute(uint8_t * buffer, uint16_ uint16_t encodeDoorLockClusterReadLockTypeAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0001 }; - READ_ATTRIBUTES("ReadDoorLockLockType", DOOR_LOCK_CLUSTER_ID); + READ_ATTRIBUTES("ReadDoorLockLockType", DOOR_LOCK_CLUSTER_ID, 0x0000); } /* @@ -1752,7 +1779,7 @@ uint16_t encodeDoorLockClusterReadLockTypeAttribute(uint8_t * buffer, uint16_t b uint16_t encodeDoorLockClusterReadActuatorEnabledAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0002 }; - READ_ATTRIBUTES("ReadDoorLockActuatorEnabled", DOOR_LOCK_CLUSTER_ID); + READ_ATTRIBUTES("ReadDoorLockActuatorEnabled", DOOR_LOCK_CLUSTER_ID, 0x0000); } /* @@ -1761,7 +1788,7 @@ uint16_t encodeDoorLockClusterReadActuatorEnabledAttribute(uint8_t * buffer, uin uint16_t encodeDoorLockClusterReadClusterRevisionAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0xFFFD }; - READ_ATTRIBUTES("ReadDoorLockClusterRevision", DOOR_LOCK_CLUSTER_ID); + READ_ATTRIBUTES("ReadDoorLockClusterRevision", DOOR_LOCK_CLUSTER_ID, 0x0000); } /*----------------------------------------------------------------------------*\ @@ -1787,7 +1814,7 @@ uint16_t encodeGroupsClusterAddGroupCommand(uint8_t * buffer, uint16_t buf_lengt uint16_t groupId, char * groupName) { const char * kName = "GroupsAddGroup"; - COMMAND_HEADER(kName, GROUPS_CLUSTER_ID, 0x00); + COMMAND_HEADER(kName, GROUPS_CLUSTER_ID, 0x0000, 0x00); buf.Put16(groupId); COMMAND_INSERT_STRING(kName, groupName); COMMAND_FOOTER(kName); @@ -1800,7 +1827,7 @@ uint16_t encodeGroupsClusterAddGroupIfIdentifyingCommand(uint8_t * buffer, uint1 uint16_t groupId, char * groupName) { const char * kName = "GroupsAddGroupIfIdentifying"; - COMMAND_HEADER(kName, GROUPS_CLUSTER_ID, 0x05); + COMMAND_HEADER(kName, GROUPS_CLUSTER_ID, 0x0000, 0x05); buf.Put16(groupId); COMMAND_INSERT_STRING(kName, groupName); COMMAND_FOOTER(kName); @@ -1813,7 +1840,7 @@ uint16_t encodeGroupsClusterGetGroupMembershipCommand(uint8_t * buffer, uint16_t uint8_t groupCount, uint16_t groupList) { const char * kName = "GroupsGetGroupMembership"; - COMMAND_HEADER(kName, GROUPS_CLUSTER_ID, 0x02); + COMMAND_HEADER(kName, GROUPS_CLUSTER_ID, 0x0000, 0x02); buf.Put(groupCount); buf.Put16(groupList); COMMAND_FOOTER(kName); @@ -1825,7 +1852,7 @@ uint16_t encodeGroupsClusterGetGroupMembershipCommand(uint8_t * buffer, uint16_t uint16_t encodeGroupsClusterRemoveAllGroupsCommand(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { const char * kName = "GroupsRemoveAllGroups"; - COMMAND_HEADER(kName, GROUPS_CLUSTER_ID, 0x04); + COMMAND_HEADER(kName, GROUPS_CLUSTER_ID, 0x0000, 0x04); COMMAND_FOOTER(kName); } @@ -1836,7 +1863,7 @@ uint16_t encodeGroupsClusterRemoveGroupCommand(uint8_t * buffer, uint16_t buf_le uint16_t groupId) { const char * kName = "GroupsRemoveGroup"; - COMMAND_HEADER(kName, GROUPS_CLUSTER_ID, 0x03); + COMMAND_HEADER(kName, GROUPS_CLUSTER_ID, 0x0000, 0x03); buf.Put16(groupId); COMMAND_FOOTER(kName); } @@ -1848,14 +1875,14 @@ uint16_t encodeGroupsClusterViewGroupCommand(uint8_t * buffer, uint16_t buf_leng uint16_t groupId) { const char * kName = "GroupsViewGroup"; - COMMAND_HEADER(kName, GROUPS_CLUSTER_ID, 0x01); + COMMAND_HEADER(kName, GROUPS_CLUSTER_ID, 0x0000, 0x01); buf.Put16(groupId); COMMAND_FOOTER(kName); } uint16_t encodeGroupsClusterDiscoverAttributes(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { - DISCOVER_ATTRIBUTES("DiscoverGroupsAttributes", GROUPS_CLUSTER_ID); + DISCOVER_ATTRIBUTES("DiscoverGroupsAttributes", GROUPS_CLUSTER_ID, 0x0000); } /* @@ -1864,7 +1891,7 @@ uint16_t encodeGroupsClusterDiscoverAttributes(uint8_t * buffer, uint16_t buf_le uint16_t encodeGroupsClusterReadNameSupportAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0000 }; - READ_ATTRIBUTES("ReadGroupsNameSupport", GROUPS_CLUSTER_ID); + READ_ATTRIBUTES("ReadGroupsNameSupport", GROUPS_CLUSTER_ID, 0x0000); } /* @@ -1873,7 +1900,7 @@ uint16_t encodeGroupsClusterReadNameSupportAttribute(uint8_t * buffer, uint16_t uint16_t encodeGroupsClusterReadClusterRevisionAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0xFFFD }; - READ_ATTRIBUTES("ReadGroupsClusterRevision", GROUPS_CLUSTER_ID); + READ_ATTRIBUTES("ReadGroupsClusterRevision", GROUPS_CLUSTER_ID, 0x0000); } /*----------------------------------------------------------------------------*\ @@ -1892,7 +1919,7 @@ uint16_t encodeGroupsClusterReadClusterRevisionAttribute(uint8_t * buffer, uint1 uint16_t encodeIasZoneClusterDiscoverAttributes(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { - DISCOVER_ATTRIBUTES("DiscoverIasZoneAttributes", IAS_ZONE_CLUSTER_ID); + DISCOVER_ATTRIBUTES("DiscoverIasZoneAttributes", IAS_ZONE_CLUSTER_ID, 0x0000); } /* @@ -1901,7 +1928,7 @@ uint16_t encodeIasZoneClusterDiscoverAttributes(uint8_t * buffer, uint16_t buf_l uint16_t encodeIasZoneClusterReadZoneStateAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0000 }; - READ_ATTRIBUTES("ReadIasZoneZoneState", IAS_ZONE_CLUSTER_ID); + READ_ATTRIBUTES("ReadIasZoneZoneState", IAS_ZONE_CLUSTER_ID, 0x0000); } /* @@ -1910,7 +1937,7 @@ uint16_t encodeIasZoneClusterReadZoneStateAttribute(uint8_t * buffer, uint16_t b uint16_t encodeIasZoneClusterReadZoneTypeAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0001 }; - READ_ATTRIBUTES("ReadIasZoneZoneType", IAS_ZONE_CLUSTER_ID); + READ_ATTRIBUTES("ReadIasZoneZoneType", IAS_ZONE_CLUSTER_ID, 0x0000); } /* @@ -1919,7 +1946,7 @@ uint16_t encodeIasZoneClusterReadZoneTypeAttribute(uint8_t * buffer, uint16_t bu uint16_t encodeIasZoneClusterReadZoneStatusAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0002 }; - READ_ATTRIBUTES("ReadIasZoneZoneStatus", IAS_ZONE_CLUSTER_ID); + READ_ATTRIBUTES("ReadIasZoneZoneStatus", IAS_ZONE_CLUSTER_ID, 0x0000); } /* @@ -1928,7 +1955,7 @@ uint16_t encodeIasZoneClusterReadZoneStatusAttribute(uint8_t * buffer, uint16_t uint16_t encodeIasZoneClusterReadIasCieAddressAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0010 }; - READ_ATTRIBUTES("ReadIasZoneIasCieAddress", IAS_ZONE_CLUSTER_ID); + READ_ATTRIBUTES("ReadIasZoneIasCieAddress", IAS_ZONE_CLUSTER_ID, 0x0000); } uint16_t encodeIasZoneClusterWriteIasCieAddressAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint, @@ -1936,7 +1963,7 @@ uint16_t encodeIasZoneClusterWriteIasCieAddressAttribute(uint8_t * buffer, uint1 { uint16_t attr_id = 0x0010; uint8_t attr_type = { 0xF0 }; - WRITE_ATTRIBUTE("WriteIasZoneIasCieAddress", IAS_ZONE_CLUSTER_ID, iasCieAddress); + WRITE_ATTRIBUTE("WriteIasZoneIasCieAddress", IAS_ZONE_CLUSTER_ID, 0x0000, iasCieAddress); } /* @@ -1945,7 +1972,7 @@ uint16_t encodeIasZoneClusterWriteIasCieAddressAttribute(uint8_t * buffer, uint1 uint16_t encodeIasZoneClusterReadZoneIdAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0011 }; - READ_ATTRIBUTES("ReadIasZoneZoneId", IAS_ZONE_CLUSTER_ID); + READ_ATTRIBUTES("ReadIasZoneZoneId", IAS_ZONE_CLUSTER_ID, 0x0000); } /* @@ -1954,7 +1981,7 @@ uint16_t encodeIasZoneClusterReadZoneIdAttribute(uint8_t * buffer, uint16_t buf_ uint16_t encodeIasZoneClusterReadClusterRevisionAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0xFFFD }; - READ_ATTRIBUTES("ReadIasZoneClusterRevision", IAS_ZONE_CLUSTER_ID); + READ_ATTRIBUTES("ReadIasZoneClusterRevision", IAS_ZONE_CLUSTER_ID, 0x0000); } /*----------------------------------------------------------------------------*\ @@ -1976,7 +2003,7 @@ uint16_t encodeIdentifyClusterIdentifyCommand(uint8_t * buffer, uint16_t buf_len uint16_t identifyTime) { const char * kName = "IdentifyIdentify"; - COMMAND_HEADER(kName, IDENTIFY_CLUSTER_ID, 0x00); + COMMAND_HEADER(kName, IDENTIFY_CLUSTER_ID, 0x0000, 0x00); buf.Put16(identifyTime); COMMAND_FOOTER(kName); } @@ -1987,13 +2014,13 @@ uint16_t encodeIdentifyClusterIdentifyCommand(uint8_t * buffer, uint16_t buf_len uint16_t encodeIdentifyClusterIdentifyQueryCommand(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { const char * kName = "IdentifyIdentifyQuery"; - COMMAND_HEADER(kName, IDENTIFY_CLUSTER_ID, 0x01); + COMMAND_HEADER(kName, IDENTIFY_CLUSTER_ID, 0x0000, 0x01); COMMAND_FOOTER(kName); } uint16_t encodeIdentifyClusterDiscoverAttributes(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { - DISCOVER_ATTRIBUTES("DiscoverIdentifyAttributes", IDENTIFY_CLUSTER_ID); + DISCOVER_ATTRIBUTES("DiscoverIdentifyAttributes", IDENTIFY_CLUSTER_ID, 0x0000); } /* @@ -2002,7 +2029,7 @@ uint16_t encodeIdentifyClusterDiscoverAttributes(uint8_t * buffer, uint16_t buf_ uint16_t encodeIdentifyClusterReadIdentifyTimeAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0000 }; - READ_ATTRIBUTES("ReadIdentifyIdentifyTime", IDENTIFY_CLUSTER_ID); + READ_ATTRIBUTES("ReadIdentifyIdentifyTime", IDENTIFY_CLUSTER_ID, 0x0000); } uint16_t encodeIdentifyClusterWriteIdentifyTimeAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint, @@ -2010,7 +2037,7 @@ uint16_t encodeIdentifyClusterWriteIdentifyTimeAttribute(uint8_t * buffer, uint1 { uint16_t attr_id = 0x0000; uint8_t attr_type = { 0x21 }; - WRITE_ATTRIBUTE("WriteIdentifyIdentifyTime", IDENTIFY_CLUSTER_ID, identifyTime); + WRITE_ATTRIBUTE("WriteIdentifyIdentifyTime", IDENTIFY_CLUSTER_ID, 0x0000, identifyTime); } /* @@ -2019,7 +2046,7 @@ uint16_t encodeIdentifyClusterWriteIdentifyTimeAttribute(uint8_t * buffer, uint1 uint16_t encodeIdentifyClusterReadClusterRevisionAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0xFFFD }; - READ_ATTRIBUTES("ReadIdentifyClusterRevision", IDENTIFY_CLUSTER_ID); + READ_ATTRIBUTES("ReadIdentifyClusterRevision", IDENTIFY_CLUSTER_ID, 0x0000); } /*----------------------------------------------------------------------------*\ @@ -2047,7 +2074,7 @@ uint16_t encodeLevelControlClusterMoveCommand(uint8_t * buffer, uint16_t buf_len uint8_t moveMode, uint8_t rate, uint8_t optionMask, uint8_t optionOverride) { const char * kName = "LevelControlMove"; - COMMAND_HEADER(kName, LEVEL_CONTROL_CLUSTER_ID, 0x01); + COMMAND_HEADER(kName, LEVEL_CONTROL_CLUSTER_ID, 0x0000, 0x01); buf.Put(moveMode); buf.Put(rate); buf.Put(optionMask); @@ -2063,7 +2090,7 @@ uint16_t encodeLevelControlClusterMoveToLevelCommand(uint8_t * buffer, uint16_t uint8_t optionOverride) { const char * kName = "LevelControlMoveToLevel"; - COMMAND_HEADER(kName, LEVEL_CONTROL_CLUSTER_ID, 0x00); + COMMAND_HEADER(kName, LEVEL_CONTROL_CLUSTER_ID, 0x0000, 0x00); buf.Put(level); buf.Put16(transitionTime); buf.Put(optionMask); @@ -2079,7 +2106,7 @@ uint16_t encodeLevelControlClusterMoveToLevelWithOnOffCommand(uint8_t * buffer, uint16_t transitionTime) { const char * kName = "LevelControlMoveToLevelWithOnOff"; - COMMAND_HEADER(kName, LEVEL_CONTROL_CLUSTER_ID, 0x04); + COMMAND_HEADER(kName, LEVEL_CONTROL_CLUSTER_ID, 0x0000, 0x04); buf.Put(level); buf.Put16(transitionTime); COMMAND_FOOTER(kName); @@ -2092,7 +2119,7 @@ uint16_t encodeLevelControlClusterMoveWithOnOffCommand(uint8_t * buffer, uint16_ uint8_t moveMode, uint8_t rate) { const char * kName = "LevelControlMoveWithOnOff"; - COMMAND_HEADER(kName, LEVEL_CONTROL_CLUSTER_ID, 0x05); + COMMAND_HEADER(kName, LEVEL_CONTROL_CLUSTER_ID, 0x0000, 0x05); buf.Put(moveMode); buf.Put(rate); COMMAND_FOOTER(kName); @@ -2106,7 +2133,7 @@ uint16_t encodeLevelControlClusterStepCommand(uint8_t * buffer, uint16_t buf_len uint8_t optionOverride) { const char * kName = "LevelControlStep"; - COMMAND_HEADER(kName, LEVEL_CONTROL_CLUSTER_ID, 0x02); + COMMAND_HEADER(kName, LEVEL_CONTROL_CLUSTER_ID, 0x0000, 0x02); buf.Put(stepMode); buf.Put(stepSize); buf.Put16(transitionTime); @@ -2122,7 +2149,7 @@ uint16_t encodeLevelControlClusterStepWithOnOffCommand(uint8_t * buffer, uint16_ uint8_t stepMode, uint8_t stepSize, uint16_t transitionTime) { const char * kName = "LevelControlStepWithOnOff"; - COMMAND_HEADER(kName, LEVEL_CONTROL_CLUSTER_ID, 0x06); + COMMAND_HEADER(kName, LEVEL_CONTROL_CLUSTER_ID, 0x0000, 0x06); buf.Put(stepMode); buf.Put(stepSize); buf.Put16(transitionTime); @@ -2136,7 +2163,7 @@ uint16_t encodeLevelControlClusterStopCommand(uint8_t * buffer, uint16_t buf_len uint8_t optionMask, uint8_t optionOverride) { const char * kName = "LevelControlStop"; - COMMAND_HEADER(kName, LEVEL_CONTROL_CLUSTER_ID, 0x03); + COMMAND_HEADER(kName, LEVEL_CONTROL_CLUSTER_ID, 0x0000, 0x03); buf.Put(optionMask); buf.Put(optionOverride); COMMAND_FOOTER(kName); @@ -2148,13 +2175,13 @@ uint16_t encodeLevelControlClusterStopCommand(uint8_t * buffer, uint16_t buf_len uint16_t encodeLevelControlClusterStopWithOnOffCommand(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { const char * kName = "LevelControlStopWithOnOff"; - COMMAND_HEADER(kName, LEVEL_CONTROL_CLUSTER_ID, 0x07); + COMMAND_HEADER(kName, LEVEL_CONTROL_CLUSTER_ID, 0x0000, 0x07); COMMAND_FOOTER(kName); } uint16_t encodeLevelControlClusterDiscoverAttributes(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { - DISCOVER_ATTRIBUTES("DiscoverLevelControlAttributes", LEVEL_CONTROL_CLUSTER_ID); + DISCOVER_ATTRIBUTES("DiscoverLevelControlAttributes", LEVEL_CONTROL_CLUSTER_ID, 0x0000); } /* @@ -2163,7 +2190,7 @@ uint16_t encodeLevelControlClusterDiscoverAttributes(uint8_t * buffer, uint16_t uint16_t encodeLevelControlClusterReadCurrentLevelAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0000 }; - READ_ATTRIBUTES("ReadLevelControlCurrentLevel", LEVEL_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadLevelControlCurrentLevel", LEVEL_CONTROL_CLUSTER_ID, 0x0000); } uint16_t encodeLevelControlClusterReportCurrentLevelAttribute(uint8_t * buffer, uint16_t buf_length, @@ -2172,7 +2199,7 @@ uint16_t encodeLevelControlClusterReportCurrentLevelAttribute(uint8_t * buffer, { uint16_t attr_id = 0x0000; uint8_t attr_type = { 0x20 }; - REPORT_ATTRIBUTE("ReportLevelControlCurrentLevel", LEVEL_CONTROL_CLUSTER_ID, true, change); + REPORT_ATTRIBUTE("ReportLevelControlCurrentLevel", LEVEL_CONTROL_CLUSTER_ID, 0x0000, true, change); } /* @@ -2182,7 +2209,7 @@ uint16_t encodeLevelControlClusterReadClusterRevisionAttribute(uint8_t * buffer, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0xFFFD }; - READ_ATTRIBUTES("ReadLevelControlClusterRevision", LEVEL_CONTROL_CLUSTER_ID); + READ_ATTRIBUTES("ReadLevelControlClusterRevision", LEVEL_CONTROL_CLUSTER_ID, 0x0000); } /*----------------------------------------------------------------------------*\ @@ -2204,7 +2231,7 @@ uint16_t encodeLevelControlClusterReadClusterRevisionAttribute(uint8_t * buffer, uint16_t encodeOnOffClusterOffCommand(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { const char * kName = "OnOffOff"; - COMMAND_HEADER(kName, ON_OFF_CLUSTER_ID, 0x00); + COMMAND_HEADER(kName, ON_OFF_CLUSTER_ID, 0x0000, 0x00); COMMAND_FOOTER(kName); } @@ -2214,7 +2241,7 @@ uint16_t encodeOnOffClusterOffCommand(uint8_t * buffer, uint16_t buf_length, End uint16_t encodeOnOffClusterOnCommand(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { const char * kName = "OnOffOn"; - COMMAND_HEADER(kName, ON_OFF_CLUSTER_ID, 0x01); + COMMAND_HEADER(kName, ON_OFF_CLUSTER_ID, 0x0000, 0x01); COMMAND_FOOTER(kName); } @@ -2224,13 +2251,13 @@ uint16_t encodeOnOffClusterOnCommand(uint8_t * buffer, uint16_t buf_length, Endp uint16_t encodeOnOffClusterToggleCommand(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { const char * kName = "OnOffToggle"; - COMMAND_HEADER(kName, ON_OFF_CLUSTER_ID, 0x02); + COMMAND_HEADER(kName, ON_OFF_CLUSTER_ID, 0x0000, 0x02); COMMAND_FOOTER(kName); } uint16_t encodeOnOffClusterDiscoverAttributes(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { - DISCOVER_ATTRIBUTES("DiscoverOnOffAttributes", ON_OFF_CLUSTER_ID); + DISCOVER_ATTRIBUTES("DiscoverOnOffAttributes", ON_OFF_CLUSTER_ID, 0x0000); } /* @@ -2239,7 +2266,7 @@ uint16_t encodeOnOffClusterDiscoverAttributes(uint8_t * buffer, uint16_t buf_len uint16_t encodeOnOffClusterReadOnOffAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0000 }; - READ_ATTRIBUTES("ReadOnOffOnOff", ON_OFF_CLUSTER_ID); + READ_ATTRIBUTES("ReadOnOffOnOff", ON_OFF_CLUSTER_ID, 0x0000); } uint16_t encodeOnOffClusterReportOnOffAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint, @@ -2247,7 +2274,7 @@ uint16_t encodeOnOffClusterReportOnOffAttribute(uint8_t * buffer, uint16_t buf_l { uint16_t attr_id = 0x0000; uint8_t attr_type = { 0x10 }; - REPORT_ATTRIBUTE("ReportOnOffOnOff", ON_OFF_CLUSTER_ID, false, 0); + REPORT_ATTRIBUTE("ReportOnOffOnOff", ON_OFF_CLUSTER_ID, 0x0000, false, 0); } /* @@ -2256,7 +2283,7 @@ uint16_t encodeOnOffClusterReportOnOffAttribute(uint8_t * buffer, uint16_t buf_l uint16_t encodeOnOffClusterReadClusterRevisionAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0xFFFD }; - READ_ATTRIBUTES("ReadOnOffClusterRevision", ON_OFF_CLUSTER_ID); + READ_ATTRIBUTES("ReadOnOffClusterRevision", ON_OFF_CLUSTER_ID, 0x0000); } /*----------------------------------------------------------------------------*\ @@ -2288,7 +2315,7 @@ uint16_t encodeScenesClusterAddSceneCommand(uint8_t * buffer, uint16_t buf_lengt chip::ClusterId clusterId, uint8_t length, uint8_t value) { const char * kName = "ScenesAddScene"; - COMMAND_HEADER(kName, SCENES_CLUSTER_ID, 0x00); + COMMAND_HEADER(kName, SCENES_CLUSTER_ID, 0x0000, 0x00); buf.Put16(groupId); buf.Put(sceneId); buf.Put16(transitionTime); @@ -2306,7 +2333,7 @@ uint16_t encodeScenesClusterGetSceneMembershipCommand(uint8_t * buffer, uint16_t uint16_t groupId) { const char * kName = "ScenesGetSceneMembership"; - COMMAND_HEADER(kName, SCENES_CLUSTER_ID, 0x06); + COMMAND_HEADER(kName, SCENES_CLUSTER_ID, 0x0000, 0x06); buf.Put16(groupId); COMMAND_FOOTER(kName); } @@ -2318,7 +2345,7 @@ uint16_t encodeScenesClusterRecallSceneCommand(uint8_t * buffer, uint16_t buf_le uint16_t groupId, uint8_t sceneId, uint16_t transitionTime) { const char * kName = "ScenesRecallScene"; - COMMAND_HEADER(kName, SCENES_CLUSTER_ID, 0x05); + COMMAND_HEADER(kName, SCENES_CLUSTER_ID, 0x0000, 0x05); buf.Put16(groupId); buf.Put(sceneId); buf.Put16(transitionTime); @@ -2332,7 +2359,7 @@ uint16_t encodeScenesClusterRemoveAllScenesCommand(uint8_t * buffer, uint16_t bu uint16_t groupId) { const char * kName = "ScenesRemoveAllScenes"; - COMMAND_HEADER(kName, SCENES_CLUSTER_ID, 0x03); + COMMAND_HEADER(kName, SCENES_CLUSTER_ID, 0x0000, 0x03); buf.Put16(groupId); COMMAND_FOOTER(kName); } @@ -2344,7 +2371,7 @@ uint16_t encodeScenesClusterRemoveSceneCommand(uint8_t * buffer, uint16_t buf_le uint16_t groupId, uint8_t sceneId) { const char * kName = "ScenesRemoveScene"; - COMMAND_HEADER(kName, SCENES_CLUSTER_ID, 0x02); + COMMAND_HEADER(kName, SCENES_CLUSTER_ID, 0x0000, 0x02); buf.Put16(groupId); buf.Put(sceneId); COMMAND_FOOTER(kName); @@ -2357,7 +2384,7 @@ uint16_t encodeScenesClusterStoreSceneCommand(uint8_t * buffer, uint16_t buf_len uint16_t groupId, uint8_t sceneId) { const char * kName = "ScenesStoreScene"; - COMMAND_HEADER(kName, SCENES_CLUSTER_ID, 0x04); + COMMAND_HEADER(kName, SCENES_CLUSTER_ID, 0x0000, 0x04); buf.Put16(groupId); buf.Put(sceneId); COMMAND_FOOTER(kName); @@ -2370,7 +2397,7 @@ uint16_t encodeScenesClusterViewSceneCommand(uint8_t * buffer, uint16_t buf_leng uint16_t groupId, uint8_t sceneId) { const char * kName = "ScenesViewScene"; - COMMAND_HEADER(kName, SCENES_CLUSTER_ID, 0x01); + COMMAND_HEADER(kName, SCENES_CLUSTER_ID, 0x0000, 0x01); buf.Put16(groupId); buf.Put(sceneId); COMMAND_FOOTER(kName); @@ -2378,7 +2405,7 @@ uint16_t encodeScenesClusterViewSceneCommand(uint8_t * buffer, uint16_t buf_leng uint16_t encodeScenesClusterDiscoverAttributes(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { - DISCOVER_ATTRIBUTES("DiscoverScenesAttributes", SCENES_CLUSTER_ID); + DISCOVER_ATTRIBUTES("DiscoverScenesAttributes", SCENES_CLUSTER_ID, 0x0000); } /* @@ -2387,7 +2414,7 @@ uint16_t encodeScenesClusterDiscoverAttributes(uint8_t * buffer, uint16_t buf_le uint16_t encodeScenesClusterReadSceneCountAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0000 }; - READ_ATTRIBUTES("ReadScenesSceneCount", SCENES_CLUSTER_ID); + READ_ATTRIBUTES("ReadScenesSceneCount", SCENES_CLUSTER_ID, 0x0000); } /* @@ -2396,7 +2423,7 @@ uint16_t encodeScenesClusterReadSceneCountAttribute(uint8_t * buffer, uint16_t b uint16_t encodeScenesClusterReadCurrentSceneAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0001 }; - READ_ATTRIBUTES("ReadScenesCurrentScene", SCENES_CLUSTER_ID); + READ_ATTRIBUTES("ReadScenesCurrentScene", SCENES_CLUSTER_ID, 0x0000); } /* @@ -2405,7 +2432,7 @@ uint16_t encodeScenesClusterReadCurrentSceneAttribute(uint8_t * buffer, uint16_t uint16_t encodeScenesClusterReadCurrentGroupAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0002 }; - READ_ATTRIBUTES("ReadScenesCurrentGroup", SCENES_CLUSTER_ID); + READ_ATTRIBUTES("ReadScenesCurrentGroup", SCENES_CLUSTER_ID, 0x0000); } /* @@ -2414,7 +2441,7 @@ uint16_t encodeScenesClusterReadCurrentGroupAttribute(uint8_t * buffer, uint16_t uint16_t encodeScenesClusterReadSceneValidAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0003 }; - READ_ATTRIBUTES("ReadScenesSceneValid", SCENES_CLUSTER_ID); + READ_ATTRIBUTES("ReadScenesSceneValid", SCENES_CLUSTER_ID, 0x0000); } /* @@ -2423,7 +2450,7 @@ uint16_t encodeScenesClusterReadSceneValidAttribute(uint8_t * buffer, uint16_t b uint16_t encodeScenesClusterReadNameSupportAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0004 }; - READ_ATTRIBUTES("ReadScenesNameSupport", SCENES_CLUSTER_ID); + READ_ATTRIBUTES("ReadScenesNameSupport", SCENES_CLUSTER_ID, 0x0000); } /* @@ -2432,7 +2459,7 @@ uint16_t encodeScenesClusterReadNameSupportAttribute(uint8_t * buffer, uint16_t uint16_t encodeScenesClusterReadClusterRevisionAttribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0xFFFD }; - READ_ATTRIBUTES("ReadScenesClusterRevision", SCENES_CLUSTER_ID); + READ_ATTRIBUTES("ReadScenesClusterRevision", SCENES_CLUSTER_ID, 0x0000); } /*----------------------------------------------------------------------------*\ @@ -2450,7 +2477,7 @@ uint16_t encodeScenesClusterReadClusterRevisionAttribute(uint8_t * buffer, uint1 uint16_t encodeTemperatureMeasurementClusterDiscoverAttributes(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { - DISCOVER_ATTRIBUTES("DiscoverTemperatureMeasurementAttributes", TEMP_MEASUREMENT_CLUSTER_ID); + DISCOVER_ATTRIBUTES("DiscoverTemperatureMeasurementAttributes", TEMP_MEASUREMENT_CLUSTER_ID, 0x0000); } /* @@ -2460,7 +2487,7 @@ uint16_t encodeTemperatureMeasurementClusterReadMeasuredValueAttribute(uint8_t * EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0000 }; - READ_ATTRIBUTES("ReadTemperatureMeasurementMeasuredValue", TEMP_MEASUREMENT_CLUSTER_ID); + READ_ATTRIBUTES("ReadTemperatureMeasurementMeasuredValue", TEMP_MEASUREMENT_CLUSTER_ID, 0x0000); } uint16_t encodeTemperatureMeasurementClusterReportMeasuredValueAttribute(uint8_t * buffer, uint16_t buf_length, @@ -2469,7 +2496,7 @@ uint16_t encodeTemperatureMeasurementClusterReportMeasuredValueAttribute(uint8_t { uint16_t attr_id = 0x0000; uint8_t attr_type = { 0x29 }; - REPORT_ATTRIBUTE("ReportTemperatureMeasurementMeasuredValue", TEMP_MEASUREMENT_CLUSTER_ID, true, change); + REPORT_ATTRIBUTE("ReportTemperatureMeasurementMeasuredValue", TEMP_MEASUREMENT_CLUSTER_ID, 0x0000, true, change); } /* @@ -2479,7 +2506,7 @@ uint16_t encodeTemperatureMeasurementClusterReadMinMeasuredValueAttribute(uint8_ EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0001 }; - READ_ATTRIBUTES("ReadTemperatureMeasurementMinMeasuredValue", TEMP_MEASUREMENT_CLUSTER_ID); + READ_ATTRIBUTES("ReadTemperatureMeasurementMinMeasuredValue", TEMP_MEASUREMENT_CLUSTER_ID, 0x0000); } /* @@ -2489,7 +2516,7 @@ uint16_t encodeTemperatureMeasurementClusterReadMaxMeasuredValueAttribute(uint8_ EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0x0002 }; - READ_ATTRIBUTES("ReadTemperatureMeasurementMaxMeasuredValue", TEMP_MEASUREMENT_CLUSTER_ID); + READ_ATTRIBUTES("ReadTemperatureMeasurementMaxMeasuredValue", TEMP_MEASUREMENT_CLUSTER_ID, 0x0000); } /* @@ -2499,7 +2526,7 @@ uint16_t encodeTemperatureMeasurementClusterReadClusterRevisionAttribute(uint8_t EndpointId destination_endpoint) { uint16_t attr_ids[] = { 0xFFFD }; - READ_ATTRIBUTES("ReadTemperatureMeasurementClusterRevision", TEMP_MEASUREMENT_CLUSTER_ID); + READ_ATTRIBUTES("ReadTemperatureMeasurementClusterRevision", TEMP_MEASUREMENT_CLUSTER_ID, 0x0000); } } // extern "C" diff --git a/src/app/zap-templates/call-command-handler-src.zapt b/src/app/zap-templates/call-command-handler-src.zapt index 0f2421f55d5f28..cf409f85f9446d 100644 --- a/src/app/zap-templates/call-command-handler-src.zapt +++ b/src/app/zap-templates/call-command-handler-src.zapt @@ -97,56 +97,40 @@ EmberAfStatus emberAf{{asCamelCased name false}}Cluster{{asCamelCased side false { bool wasHandled = false; + {{#if (user_cluster_has_enabled_manufacturer_command name side)}} + if (cmd->mfgSpecific) + { + {{#all_user_cluster_commands}} + {{#if mfgCode}} + {{#if (isStrEqual clusterName parent.name)}} + {{#if (isCommandAvailable parent.side incoming outgoing commandSource name)}} + if (cmd->mfgCode == {{mfgCode}} && cmd->commandId == ZCL_{{asDelimitedMacro name}}_COMMAND_ID) + { + {{> command_handler_cluster_commands}} + } + {{/if}} + {{/if}} + {{/if}} + {{/all_user_cluster_commands}} + } + else + {{else}} if (!cmd->mfgSpecific) + {{/if}} { switch (cmd->commandId) { {{#all_user_cluster_commands}} + {{#unless mfgCode}} {{#if (isStrEqual clusterName parent.name)}} {{#if (isCommandAvailable parent.side incoming outgoing commandSource name)}} case ZCL_{{asDelimitedMacro name}}_COMMAND_ID: { - {{#if (zcl_command_arguments_count this.id)}} - uint32_t payloadOffset = cmd->payloadStartIndex; - {{#zcl_command_arguments}} - {{asUnderlyingZclType type}} {{asSymbol label}}; - {{/zcl_command_arguments}} - - {{#zcl_command_arguments}} - {{#if presentIf}} - if ({{presentIf}}) - { - {{/if}} - {{#if isArray}} - {{asSymbol label}} = cmd->buffer + payloadOffset; - {{else}} - if (cmd->bufLen < payloadOffset + {{asReadTypeLength type}}) - { - return EMBER_ZCL_STATUS_MALFORMED_COMMAND; - } - {{asSymbol label}} = emberAfGet{{asReadType type}}(cmd->buffer, payloadOffset, cmd->bufLen); - {{#unless (isLastElement index count)}} - {{#if (isString type)}} - payloadOffset += emberAf{{asReadType type}}Length({{asSymbol label}}) + {{asReadTypeLength type}}; - {{else}} - payloadOffset += {{asReadTypeLength type}}; - {{/if}} - {{/unless}} - {{/if}} - {{#if presentIf}} - } - else - { - {{asSymbol label}} = {{asValueIfNotPresent type isArray}}; - } - {{/if}} - {{/zcl_command_arguments}} - - {{/if}} - wasHandled = emberAf{{asCamelCased parent.name false}}Cluster{{asCamelCased name false}}Callback({{#zcl_command_arguments}}{{asSymbol label}}{{#unless (isLastElement index count)}}, {{/unless}}{{/zcl_command_arguments}}); + {{> command_handler_cluster_commands}} break; } {{/if}} {{/if}} + {{/unless}} {{/all_user_cluster_commands}} default: { // Unrecognized command ID, error status will apply. diff --git a/src/app/zap-templates/chip-templates.json b/src/app/zap-templates/chip-templates.json index e889cb3d04500a..5755a930b0928a 100644 --- a/src/app/zap-templates/chip-templates.json +++ b/src/app/zap-templates/chip-templates.json @@ -11,6 +11,10 @@ { "name": "cluster_header", "path": "partials/cluster_header.zapt" + }, + { + "name": "command_handler_cluster_commands", + "path": "partials/command_handler_cluster_commands.zapt" } ], "templates": [ diff --git a/src/app/zap-templates/encoder-src.zapt b/src/app/zap-templates/encoder-src.zapt index 1f7275f39834f1..ce5b4e2c9e1247 100644 --- a/src/app/zap-templates/encoder-src.zapt +++ b/src/app/zap-templates/encoder-src.zapt @@ -10,6 +10,8 @@ using namespace chip; +constexpr uint16_t kNullManufacturerCode = 0x0000; + #define CHECK_FRAME_LENGTH(value, name) \ if (value == 0) \ { \ @@ -18,9 +20,10 @@ using namespace chip; } -#define READ_ATTRIBUTES(name, cluster_id) \ +#define READ_ATTRIBUTES(name, cluster_id, mfgCode) \ uint16_t attr_id_count = sizeof(attr_ids) / sizeof(attr_ids[0]); \ - uint16_t result = encodeReadAttributesCommand(buffer, buf_length, destination_endpoint, cluster_id, attr_ids, attr_id_count); \ + uint16_t result = \ + encodeReadAttributesCommand(buffer, buf_length, destination_endpoint, cluster_id, mfgCode, attr_ids, attr_id_count); \ if (result == 0) \ { \ ChipLogError(Zcl, "Error encoding %s command", name); \ @@ -28,9 +31,9 @@ using namespace chip; } \ return result; -#define WRITE_ATTRIBUTE(name, cluster_id, value) \ +#define WRITE_ATTRIBUTE(name, cluster_id, mfgCode, value) \ BufBound buf = BufBound(buffer, buf_length); \ - if (_encodeGlobalCommand(buf, destination_endpoint, cluster_id, 0x02)) \ + if (_encodeGlobalCommand(buf, destination_endpoint, cluster_id, mfgCode, 0x02)) \ { \ buf.Put16(attr_id); \ buf.Put(attr_type); \ @@ -55,9 +58,9 @@ using namespace chip; } \ return result; -#define REPORT_ATTRIBUTE(name, cluster_id, isAnalog, value) \ +#define REPORT_ATTRIBUTE(name, cluster_id, mfgCode, isAnalog, value) \ BufBound buf = BufBound(buffer, buf_length); \ - if (_encodeGlobalCommand(buf, destination_endpoint, cluster_id, 0x06)) \ + if (_encodeGlobalCommand(buf, destination_endpoint, cluster_id, mfgCode, 0x06)) \ { \ uint8_t direction = 0x00; \ buf.Put(direction); \ @@ -91,9 +94,9 @@ using namespace chip; } \ return result; -#define DISCOVER_ATTRIBUTES(name, cluster_id) \ +#define DISCOVER_ATTRIBUTES(name, cluster_id, mfgCode) \ BufBound buf = BufBound(buffer, buf_length); \ - if (_encodeGlobalCommand(buf, destination_endpoint, cluster_id, 0x0c)) \ + if (_encodeGlobalCommand(buf, destination_endpoint, cluster_id, mfgCode, 0x0c)) \ { \ /* Discover all attributes */ \ buf.Put16(0x0000); \ @@ -108,9 +111,9 @@ using namespace chip; } \ return result; -#define COMMAND_HEADER(name, cluster_id, command_id) \ +#define COMMAND_HEADER(name, cluster_id, mfgCode, command_id) \ BufBound buf = BufBound(buffer, buf_length); \ - uint16_t result = _encodeClusterSpecificCommand(buf, destination_endpoint, cluster_id, command_id); \ + uint16_t result = _encodeClusterSpecificCommand(buf, destination_endpoint, cluster_id, mfgCode, command_id); \ if (result == 0) \ { \ ChipLogError(Zcl, "Error encoding %s command", name); \ @@ -138,8 +141,8 @@ using namespace chip; buf.Put(str); \ } \ -#define COMMAND(name, cluster_id, command_id) \ - COMMAND_HEADER(name, cluster_id, command_id); \ +#define COMMAND(name, cluster_id, mfgCode, command_id) \ + COMMAND_HEADER(name, cluster_id, mfgCode, command_id); \ COMMAND_FOOTER(name); using namespace chip; @@ -194,7 +197,8 @@ uint16_t encodeApsFrame(uint8_t * buffer, uint16_t buf_length, EmberApsFrame * a apsFrame->options, apsFrame->groupId, apsFrame->sequence, apsFrame->radius, !buffer); } -uint16_t _encodeCommand(BufBound & buf, EndpointId destination_endpoint, ClusterId cluster_id, CommandId command, uint8_t frame_control) +uint16_t _encodeCommand(BufBound & buf, EndpointId destination_endpoint, ClusterId cluster_id, uint16_t mfgCode, CommandId command, + uint8_t frame_control) { CHECK_FRAME_LENGTH(buf.Size(), "Buffer is empty"); @@ -204,6 +208,10 @@ uint16_t _encodeCommand(BufBound & buf, EndpointId destination_endpoint, Cluster if (doEncodeApsFrame(buf, cluster_id, source_endpoint, destination_endpoint, 0, 0, 0, 0, false)) { buf.Put(frame_control); + if (mfgCode != kNullManufacturerCode) + { + buf.Put16(mfgCode); + } buf.Put(seq_num); buf.Put(command); } @@ -211,31 +219,39 @@ uint16_t _encodeCommand(BufBound & buf, EndpointId destination_endpoint, Cluster return buf.Fit() && CanCastTo(buf.Needed()) ? static_cast(buf.Needed()) : 0; } -uint16_t _encodeClusterSpecificCommand(BufBound & buf, EndpointId destination_endpoint, ClusterId cluster_id, CommandId command) +uint16_t _encodeClusterSpecificCommand(BufBound & buf, EndpointId destination_endpoint, ClusterId cluster_id, uint16_t mfgCode, + CommandId command) { - // This is a cluster-specific command so low two bits are 0b01. The command - // is standard, so does not need a manufacturer code, and we're sending + // This is a cluster-specific command so low two bits are 0b01 and we're sending // client to server, so all the remaining bits are 0. uint8_t frame_control = 0x01; + if (mfgCode != kNullManufacturerCode) + { + frame_control = frame_control | (1u << 2); + } - return _encodeCommand(buf, destination_endpoint, cluster_id, command, frame_control); + return _encodeCommand(buf, destination_endpoint, cluster_id, mfgCode, command, frame_control); } -uint16_t _encodeGlobalCommand(BufBound & buf, EndpointId destination_endpoint, ClusterId cluster_id, CommandId command) +uint16_t _encodeGlobalCommand(BufBound & buf, EndpointId destination_endpoint, ClusterId cluster_id, uint16_t mfgCode, + CommandId command) { - // This is a global command, so the low bits are 0b00. The command is - // standard, so does not need a manufacturer code, and we're sending client + // This is a global command, so the low bits are 0b00 and we're sending client // to server, so all the remaining bits are 0. uint8_t frame_control = 0x00; + if (mfgCode != kNullManufacturerCode) + { + frame_control = frame_control | (1u << 2); + } - return _encodeCommand(buf, destination_endpoint, cluster_id, command, frame_control); + return _encodeCommand(buf, destination_endpoint, cluster_id, mfgCode, command, frame_control); } uint16_t encodeReadAttributesCommand(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint, ClusterId cluster_id, - const uint16_t * attr_ids, uint16_t attr_id_count) + uint16_t mfgCode, const uint16_t * attr_ids, uint16_t attr_id_count) { BufBound buf = BufBound(buffer, buf_length); - if (_encodeGlobalCommand(buf, destination_endpoint, cluster_id, 0x00)) + if (_encodeGlobalCommand(buf, destination_endpoint, cluster_id, mfgCode, 0x00)) { for (uint16_t i = 0; i < attr_id_count; ++i) { @@ -257,7 +273,7 @@ uint16_t encodeReadAttributesCommand(uint8_t * buffer, uint16_t buf_length, Endp uint16_t encode{{asCamelCased clusterName false}}Cluster{{asType name}}Command(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint{{#chip_server_cluster_command_arguments}}, {{chipType}} {{asCamelCased label}}{{/chip_server_cluster_command_arguments}}) { const char * kName = "{{asCamelCased clusterName false}}{{asType name}}"; - COMMAND_HEADER(kName, {{parent.define}}_ID, {{asHex code 2}}); + COMMAND_HEADER(kName, {{parent.define}}_ID, {{asHex mfgCode 4}}, {{asHex code 2}}); {{#chip_server_cluster_command_arguments}} {{#if (isString type)}} COMMAND_INSERT_STRING(kName, {{asCamelCased label}}); @@ -273,7 +289,7 @@ uint16_t encode{{asCamelCased clusterName false}}Cluster{{asType name}}Command(u {{/chip_server_cluster_commands}} uint16_t encode{{asCamelCased name false}}ClusterDiscoverAttributes(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { - DISCOVER_ATTRIBUTES("Discover{{asCamelCased name false}}Attributes", {{define}}_ID); + DISCOVER_ATTRIBUTES("Discover{{asCamelCased name false}}Attributes", {{define}}_ID, {{asHex mfgCode 4}}); } {{#chip_server_cluster_attributes}} @@ -283,7 +299,7 @@ uint16_t encode{{asCamelCased name false}}ClusterDiscoverAttributes(uint8_t * bu uint16_t encode{{asCamelCased parent.name false}}ClusterRead{{asCamelCased name false}}Attribute(uint8_t * buffer, uint16_t buf_length, EndpointId destination_endpoint) { uint16_t attr_ids[] = { {{asHex attributeCode 4}} }; - READ_ATTRIBUTES("Read{{asCamelCased parent.name false}}{{asCamelCased name false}}", {{parent.define}}_ID); + READ_ATTRIBUTES("Read{{asCamelCased parent.name false}}{{asCamelCased name false}}", {{parent.define}}_ID, {{asHex mfgCode 4}}); } {{#if (isWritableAttribute)}} @@ -291,7 +307,7 @@ uint16_t encode{{asCamelCased parent.name false}}ClusterWrite{{asCamelCased name { uint16_t attr_id = {{asHex attributeCode 4}}; uint8_t attr_type = { {{atomicTypeId}} }; - WRITE_ATTRIBUTE("Write{{asCamelCased parent.name false}}{{asCamelCased name false}}", {{parent.define}}_ID, {{asCamelCased name}}); + WRITE_ATTRIBUTE("Write{{asCamelCased parent.name false}}{{asCamelCased name false}}", {{parent.define}}_ID, {{asHex mfgCode 4}}, {{asCamelCased name}}); } {{/if}} @@ -300,7 +316,7 @@ uint16_t encode{{asCamelCased parent.name false}}ClusterReport{{asCamelCased nam { uint16_t attr_id = {{asHex attributeCode 4}}; uint8_t attr_type = { {{atomicTypeId}} }; - REPORT_ATTRIBUTE("Report{{asCamelCased parent.name false}}{{asCamelCased name false}}", {{parent.define}}_ID, {{#unless (isDiscreteType)}}true, change{{else}}false, 0{{/unless}}); + REPORT_ATTRIBUTE("Report{{asCamelCased parent.name false}}{{asCamelCased name false}}", {{parent.define}}_ID, {{asHex mfgCode 4}}, {{#unless (isDiscreteType)}}true, change{{else}}false, 0{{/unless}}); } {{/if}} diff --git a/src/app/zap-templates/helper-chip.js b/src/app/zap-templates/helper-chip.js index 07ec63be26f806..bca1739e2a7dcd 100644 --- a/src/app/zap-templates/helper-chip.js +++ b/src/app/zap-templates/helper-chip.js @@ -547,6 +547,27 @@ function isReportableAttribute(options) return this.reportable.included == 1; } +/** + * Check if the cluster (name) has any enabled manufacturer commands. This works only inside + * cluster block helpers. + * + * @param {*} name : Cluster name + * @param {*} side : Cluster side + * @param {*} options + * @returns True if cluster has enabled commands otherwise false + */ +function user_cluster_has_enabled_manufacturer_command(name, side, options) +{ + return queryImpexp.exportendPointTypeIds(this.global.db, this.global.sessionId) + .then((endpointTypes) => zclQuery.exportClustersAndEndpointDetailsFromEndpointTypes(this.global.db, endpointTypes)) + .then((endpointsAndClusters) => zclQuery.exportCommandDetailsFromAllEndpointTypesAndClusters( + this.global.db, endpointsAndClusters)) + .then((endpointCommands) => { + return !!endpointCommands.find(cmd => cmd.mfgCode && zclHelper.isStrEqual(name, cmd.clusterName) + && zclHelper.isCommandAvailable(side, cmd.incoming, cmd.outgoing, cmd.commandSource, cmd.name)); + }) +} + // WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! // // Note: these exports are public API. Templates that might have been created in the past and are @@ -561,13 +582,14 @@ exports.asReadTypeLength = asReadTypeLength; exports.asValueIfNotPresent = asValueIfNotPresent; exports.asChipUnderlyingType = asChipUnderlyingType; -exports.chip_server_clusters = chip_server_clusters; -exports.chip_server_cluster_commands = chip_server_cluster_commands; -exports.chip_server_cluster_command_arguments = chip_server_cluster_command_arguments -exports.isSignedType = isSignedType; -exports.isDiscreteType = isDiscreteType; -exports.chip_server_cluster_attributes = chip_server_cluster_attributes; -exports.isWritableAttribute = isWritableAttribute; -exports.isReportableAttribute = isReportableAttribute; -exports.chip_server_writable_attributes_types = chip_server_writable_attributes_types; -exports.chip_server_reportable_attributes_types = chip_server_reportable_attributes_types; +exports.chip_server_clusters = chip_server_clusters; +exports.chip_server_cluster_commands = chip_server_cluster_commands; +exports.chip_server_cluster_command_arguments = chip_server_cluster_command_arguments +exports.isSignedType = isSignedType; +exports.isDiscreteType = isDiscreteType; +exports.chip_server_cluster_attributes = chip_server_cluster_attributes; +exports.isWritableAttribute = isWritableAttribute; +exports.isReportableAttribute = isReportableAttribute; +exports.chip_server_writable_attributes_types = chip_server_writable_attributes_types; +exports.chip_server_reportable_attributes_types = chip_server_reportable_attributes_types; +exports.user_cluster_has_enabled_manufacturer_command = user_cluster_has_enabled_manufacturer_command; diff --git a/src/app/zap-templates/partials/command_handler_cluster_commands.zapt b/src/app/zap-templates/partials/command_handler_cluster_commands.zapt new file mode 100644 index 00000000000000..2a1e9ec91f92e2 --- /dev/null +++ b/src/app/zap-templates/partials/command_handler_cluster_commands.zapt @@ -0,0 +1,38 @@ +{{#if (zcl_command_arguments_count this.id)}} +uint32_t payloadOffset = cmd->payloadStartIndex; +{{#zcl_command_arguments}} +{{asUnderlyingZclType type}} {{asSymbol label}}; +{{/zcl_command_arguments}} + +{{#zcl_command_arguments}} +{{#if presentIf}} +if ({{presentIf}}) +{ +{{/if}} + {{#if isArray}} + {{asSymbol label}} = cmd->buffer + payloadOffset; + {{else}} + if (cmd->bufLen < payloadOffset + {{asReadTypeLength type}}) + { + return EMBER_ZCL_STATUS_MALFORMED_COMMAND; + } + {{asSymbol label}} = emberAfGet{{asReadType type}}(cmd->buffer, payloadOffset, cmd->bufLen); + {{#unless (isLastElement index count)}} + {{#if (isString type)}} + payloadOffset += emberAf{{asReadType type}}Length({{asSymbol label}}) + {{asReadTypeLength type}}; + {{else}} + payloadOffset += {{asReadTypeLength type}}; + {{/if}} + {{/unless}} + {{/if}} +{{#if presentIf}} +} +else +{ + {{asSymbol label}} = {{asValueIfNotPresent type isArray}}; +} +{{/if}} +{{/zcl_command_arguments}} + +{{/if}} +wasHandled = emberAf{{asCamelCased parent.name false}}Cluster{{asCamelCased name false}}Callback({{#zcl_command_arguments}}{{asSymbol label}}{{#unless (isLastElement index count)}}, {{/unless}}{{/zcl_command_arguments}});