From 5003ab8bae3f3e06ab4582dadffe76415ba7fd3e Mon Sep 17 00:00:00 2001 From: WanqQixiang Date: Sat, 11 May 2024 14:32:00 +0800 Subject: [PATCH] Use common APIs for all the client examples --- components/esp_matter/esp_matter_client.cpp | 247 ++---- components/esp_matter/esp_matter_client.h | 95 +-- .../zap_common/zap-generated/CHIPClusters.h | 733 ------------------ .../esp_matter_controller_cluster_command.cpp | 5 +- .../esp_matter_controller_cluster_command.h | 2 +- .../esp_matter_controller_read_command.cpp | 9 +- ...sp_matter_controller_subscribe_command.cpp | 11 +- .../esp_matter_controller_write_command.cpp | 7 +- .../core/esp_matter_controller_console.cpp | 2 +- .../esp-now_bridge_light/main/app_driver.cpp | 86 +- examples/light_switch/main/app_driver.cpp | 80 +- 11 files changed, 202 insertions(+), 1075 deletions(-) delete mode 100644 components/esp_matter/zap_common/zap-generated/CHIPClusters.h diff --git a/components/esp_matter/esp_matter_client.cpp b/components/esp_matter/esp_matter_client.cpp index d9d23cfe9..0c2b780c2 100644 --- a/components/esp_matter/esp_matter_client.cpp +++ b/components/esp_matter/esp_matter_client.cpp @@ -19,33 +19,25 @@ #include #include -#include #include #include #include #include #include #include +#include #include #include #include -#if CONFIG_ESP_MATTER_ENABLE_DATA_MODEL -#include -#include "app/CASESessionManager.h" +#include "app/CommandPathParams.h" #include "app/CommandSender.h" #include "app/InteractionModelEngine.h" -#endif // CONFIG_ESP_MATTER_ENABLE_DATA_MODEL using namespace chip::app::Clusters; -using chip::BitMask; using chip::DeviceProxy; -using chip::FabricInfo; -using chip::kInvalidEndpointId; using chip::OperationalDeviceProxy; -using chip::OperationalSessionSetup; using chip::ScopedNodeId; -using chip::Server; using chip::SessionHandle; using chip::Callback::Callback; using chip::Messaging::ExchangeManager; @@ -110,8 +102,7 @@ esp_err_t connect(case_session_mgr_t *case_session_mgr, uint8_t fabric_index, ui } success_callback.mContext = static_cast(context); failure_callback.mContext = static_cast(context); - case_session_mgr->FindOrEstablishSession(ScopedNodeId(node_id, fabric_index), &success_callback, - &failure_callback); + case_session_mgr->FindOrEstablishSession(ScopedNodeId(node_id, fabric_index), &success_callback, &failure_callback); return ESP_OK; } @@ -140,8 +131,11 @@ static void esp_matter_command_client_binding_callback(const EmberBindingTableEn if (binding.type == MATTER_UNICAST_BINDING && peer_device) { if (client_request_callback) { if (req_handle->type == INVOKE_CMD) { + req_handle->command_path.mFlags.Set(chip::app::CommandPathFlags::kEndpointIdValid); + req_handle->command_path.mFlags.Clear(chip::app::CommandPathFlags::kGroupIdValid); req_handle->command_path.mEndpointId = binding.remote; - } else if (req_handle->type == WRITE_ATTR || req_handle->type == READ_ATTR || req_handle->type == SUBSCRIBE_ATTR) { + } else if (req_handle->type == WRITE_ATTR || req_handle->type == READ_ATTR || + req_handle->type == SUBSCRIBE_ATTR) { req_handle->attribute_path.mEndpointId = binding.remote; } else if (req_handle->type == READ_EVENT || req_handle->type == SUBSCRIBE_EVENT) { req_handle->event_path.mEndpointId = binding.remote; @@ -151,6 +145,8 @@ static void esp_matter_command_client_binding_callback(const EmberBindingTableEn } else if (binding.type == MATTER_MULTICAST_BINDING && !peer_device) { if (client_group_request_callback) { if (req_handle->type == INVOKE_CMD) { + req_handle->command_path.mFlags.Set(chip::app::CommandPathFlags::kGroupIdValid); + req_handle->command_path.mFlags.Clear(chip::app::CommandPathFlags::kEndpointIdValid); req_handle->command_path.mGroupId = binding.groupId; } else { return; @@ -222,30 +218,15 @@ void binding_init() { initialize_binding_manager = true; } -} // namespace client -#if CONFIG_ESP_MATTER_ENABLE_DATA_MODEL -namespace cluster { -using client::peer_device_t; - -static void send_command_success_callback(void *context, const chip::app::DataModel::NullObjectType &data) -{ - ESP_LOGI(TAG, "Send command success"); -} - -static void send_command_failure_callback(void *context, CHIP_ERROR error) -{ - ESP_LOGI(TAG, "Send command failure: err: %" CHIP_ERROR_FORMAT, error.Format()); -} - -namespace custom { -namespace command { +namespace interaction { +namespace invoke { using command_data_tag = chip::app::CommandDataIB::Tag; using chip::TLV::ContextTag; using chip::TLV::TLVWriter; -esp_err_t send_command(void *ctx, peer_device_t *remote_device, const CommandPathParams &command_path, +esp_err_t send_request(void *ctx, peer_device_t *remote_device, const CommandPathParams &command_path, const char *command_data_json_str, custom_command_callback::on_success_callback_t on_success, custom_command_callback::on_error_callback_t on_error, const Optional &timed_invoke_timeout_ms, const Optional &response_timeout) @@ -305,7 +286,7 @@ esp_err_t send_command(void *ctx, peer_device_t *remote_device, const CommandPat return ESP_OK; } -esp_err_t send_group_command(const uint8_t fabric_index, const CommandPathParams &command_path, +esp_err_t send_group_request(const uint8_t fabric_index, const CommandPathParams &command_path, const char *command_data_json_str) { if (!command_path.mFlags.Has(chip::app::CommandPathFlags::kGroupIdValid)) { @@ -313,7 +294,8 @@ esp_err_t send_group_command(const uint8_t fabric_index, const CommandPathParams return ESP_ERR_INVALID_ARG; } chip::Transport::OutgoingGroupSession session(command_path.mGroupId, fabric_index); - chip::Messaging::ExchangeManager *exchange_mgr = chip::app::InteractionModelEngine::GetInstance()->GetExchangeManager(); + chip::Messaging::ExchangeManager *exchange_mgr = + chip::app::InteractionModelEngine::GetInstance()->GetExchangeManager(); auto command_sender = chip::Platform::MakeUnique(nullptr, exchange_mgr); if (command_sender == nullptr) { ESP_LOGE(TAG, "No memory for command sender"); @@ -345,145 +327,41 @@ esp_err_t send_group_command(const uint8_t fabric_index, const CommandPathParams } return ESP_OK; } -} // namespace command -} // namespace custom -namespace on_off { -namespace command { - -esp_err_t send_on(peer_device_t *remote_device, uint16_t remote_endpoint_id) -{ - OnOff::Commands::On::Type command_data; - - chip::Controller::OnOffCluster cluster(*remote_device->GetExchangeManager(), - remote_device->GetSecureSession().Value(), remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); - return ESP_OK; -} - -esp_err_t group_send_on(uint8_t fabric_index, uint16_t group_id) -{ - OnOff::Commands::On::Type command_data; - chip::Messaging::ExchangeManager *exchange_mgr = chip::app::InteractionModelEngine::GetInstance()->GetExchangeManager(); - - chip::Controller::InvokeGroupCommandRequest(exchange_mgr, fabric_index, group_id, command_data); - return ESP_OK; -} - -esp_err_t send_off(peer_device_t *remote_device, uint16_t remote_endpoint_id) -{ - OnOff::Commands::Off::Type command_data; - - chip::Controller::OnOffCluster cluster(*remote_device->GetExchangeManager(), - remote_device->GetSecureSession().Value(), remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); - return ESP_OK; -} - -esp_err_t group_send_off(uint8_t fabric_index, uint16_t group_id) -{ - OnOff::Commands::Off::Type command_data; - chip::Messaging::ExchangeManager *exchange_mgr = chip::app::InteractionModelEngine::GetInstance()->GetExchangeManager(); - - chip::Controller::InvokeGroupCommandRequest(exchange_mgr, fabric_index, group_id, command_data); - return ESP_OK; -} - -esp_err_t send_toggle(peer_device_t *remote_device, uint16_t remote_endpoint_id) -{ - OnOff::Commands::Toggle::Type command_data; - - chip::Controller::OnOffCluster cluster(*remote_device->GetExchangeManager(), - remote_device->GetSecureSession().Value(), remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); - return ESP_OK; -} - -esp_err_t group_send_toggle(uint8_t fabric_index, uint16_t group_id) -{ - OnOff::Commands::Toggle::Type command_data; - chip::Messaging::ExchangeManager *exchange_mgr = chip::app::InteractionModelEngine::GetInstance()->GetExchangeManager(); - - chip::Controller::InvokeGroupCommandRequest(exchange_mgr, fabric_index, group_id, command_data); - return ESP_OK; -} - -} // namespace command -} // namespace on_off - -namespace identify { -namespace command { -esp_err_t send_identify(peer_device_t *remote_device, uint16_t remote_endpoint_id, uint16_t identify_time) -{ - Identify::Commands::Identify::Type command_data; - command_data.identifyTime = identify_time; - - chip::Controller::IdentifyCluster cluster(*remote_device->GetExchangeManager(), - remote_device->GetSecureSession().Value(), remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); - return ESP_OK; -} - -esp_err_t group_send_identify(uint8_t fabric_index, uint16_t group_id, uint16_t identify_time) -{ - Identify::Commands::Identify::Type command_data; - command_data.identifyTime = identify_time; - - chip::Messaging::ExchangeManager *exchange_mgr = chip::app::InteractionModelEngine::GetInstance()->GetExchangeManager(); - - chip::Controller::InvokeGroupCommandRequest(exchange_mgr, fabric_index, group_id, command_data); - return ESP_OK; -} - -esp_err_t send_trigger_effect(peer_device_t *remote_device, uint16_t remote_endpoint_id, uint8_t effect_identifier, - uint8_t effect_variant) -{ - Identify::Commands::TriggerEffect::Type command_data; - command_data.effectIdentifier = Identify::EffectIdentifierEnum(effect_identifier); - command_data.effectVariant = Identify::EffectVariantEnum(effect_variant); - - chip::Controller::IdentifyCluster cluster(*remote_device->GetExchangeManager(), - remote_device->GetSecureSession().Value(), remote_endpoint_id); - cluster.InvokeCommand(command_data, NULL, send_command_success_callback, send_command_failure_callback); - return ESP_OK; -} - -} // namespace command -} // namespace identify - -} // namespace cluster - -namespace interaction { +} // namespace invoke +using chip::SubscriptionId; using chip::app::ConcreteDataAttributePath; using chip::app::EventHeader; +using chip::app::ReadPrepareParams; +using chip::app::StatusIB; +using chip::app::DataVersionFilterIBs::Builder; using chip::TLV::TLVReader; using chip::TLV::TLVWriter; -using chip::app::StatusIB; -using chip::SubscriptionId; -using chip::app::DataVersionFilterIBs::Builder; -using chip::app::ReadPrepareParams; -class client_deleter_read_callback : public ReadClient::Callback -{ +class client_deleter_read_callback : public ReadClient::Callback { public: - client_deleter_read_callback(ReadClient::Callback & callback) : m_callback(callback) {} + client_deleter_read_callback(ReadClient::Callback &callback) + : m_callback(callback) + { + } + private: void OnReportBegin() override { m_callback.OnReportBegin(); } void OnReportEnd() override { m_callback.OnReportEnd(); } void OnError(CHIP_ERROR aError) override { m_callback.OnError(aError); } - void OnAttributeData(const ConcreteDataAttributePath & aPath, TLVReader * apData, const StatusIB & aStatus) override + void OnAttributeData(const ConcreteDataAttributePath &aPath, TLVReader *apData, const StatusIB &aStatus) override { m_callback.OnAttributeData(aPath, apData, aStatus); } - void OnEventData(const EventHeader & aEventHeader, TLVReader * apData, const StatusIB * apStatus) override + void OnEventData(const EventHeader &aEventHeader, TLVReader *apData, const StatusIB *apStatus) override { m_callback.OnEventData(aEventHeader, apData, apStatus); } - void OnDone(ReadClient * apReadClient) override + void OnDone(ReadClient *apReadClient) override { m_callback.OnDone(apReadClient); chip::Platform::Delete(apReadClient); @@ -495,43 +373,46 @@ private: m_callback.OnSubscriptionEstablished(aSubscriptionId); } - CHIP_ERROR OnResubscriptionNeeded(ReadClient * apReadClient, CHIP_ERROR aTerminationCause) override + CHIP_ERROR OnResubscriptionNeeded(ReadClient *apReadClient, CHIP_ERROR aTerminationCause) override { return m_callback.OnResubscriptionNeeded(apReadClient, aTerminationCause); } - void OnDeallocatePaths(chip::app::ReadPrepareParams && aReadPrepareParams) override + void OnDeallocatePaths(chip::app::ReadPrepareParams &&aReadPrepareParams) override { m_callback.OnDeallocatePaths(std::move(aReadPrepareParams)); } - CHIP_ERROR OnUpdateDataVersionFilterList(Builder & aDataVersionFilterIBsBuilder, - const chip::Span & aAttributePaths, - bool & aEncodedDataVersionList) override + CHIP_ERROR OnUpdateDataVersionFilterList(Builder &aDataVersionFilterIBsBuilder, + const chip::Span &aAttributePaths, + bool &aEncodedDataVersionList) override { - return m_callback.OnUpdateDataVersionFilterList(aDataVersionFilterIBsBuilder, aAttributePaths, aEncodedDataVersionList); + return m_callback.OnUpdateDataVersionFilterList(aDataVersionFilterIBsBuilder, aAttributePaths, + aEncodedDataVersionList); } - CHIP_ERROR GetHighestReceivedEventNumber(chip::Optional & aEventNumber) override + CHIP_ERROR GetHighestReceivedEventNumber(chip::Optional &aEventNumber) override { return m_callback.GetHighestReceivedEventNumber(aEventNumber); } - void OnUnsolicitedMessageFromPublisher(ReadClient * apReadClient) override + void OnUnsolicitedMessageFromPublisher(ReadClient *apReadClient) override { m_callback.OnUnsolicitedMessageFromPublisher(apReadClient); } - void OnCASESessionEstablished(const SessionHandle & aSession, ReadPrepareParams & aSubscriptionParams) override + void OnCASESessionEstablished(const SessionHandle &aSession, ReadPrepareParams &aSubscriptionParams) override { m_callback.OnCASESessionEstablished(aSession, aSubscriptionParams); } - ReadClient::Callback & m_callback; + ReadClient::Callback &m_callback; }; -esp_err_t send_read_request(client::peer_device_t *remote_device, AttributePathParams *attr_path, size_t attr_path_size, - EventPathParams *event_path, size_t event_path_size, ReadClient::Callback &callback) +namespace read { + +esp_err_t send_request(client::peer_device_t *remote_device, AttributePathParams *attr_path, size_t attr_path_size, + EventPathParams *event_path, size_t event_path_size, ReadClient::Callback &callback) { if (!remote_device->GetSecureSession().HasValue() || remote_device->GetSecureSession().Value()->IsGroupSession()) { ESP_LOGE(TAG, "Invalid Session Type"); @@ -573,10 +454,14 @@ esp_err_t send_read_request(client::peer_device_t *remote_device, AttributePathP return ESP_OK; } -esp_err_t send_subscribe_request(client::peer_device_t *remote_device, AttributePathParams *attr_path, - size_t attr_path_size, EventPathParams *event_path, size_t event_path_size, - uint16_t min_interval, uint16_t max_interval, bool keep_subscription, - bool auto_resubscribe, ReadClient::Callback &callback) +} // namespace read + +namespace subscribe { + +esp_err_t send_request(client::peer_device_t *remote_device, AttributePathParams *attr_path, size_t attr_path_size, + EventPathParams *event_path, size_t event_path_size, uint16_t min_interval, + uint16_t max_interval, bool keep_subscription, bool auto_resubscribe, + ReadClient::Callback &callback) { if (!remote_device->GetSecureSession().HasValue() || remote_device->GetSecureSession().Value()->IsGroupSession()) { ESP_LOGE(TAG, "Invalid Session Type"); @@ -627,19 +512,24 @@ esp_err_t send_subscribe_request(client::peer_device_t *remote_device, Attribute return ESP_OK; } +} // namespace subscribe + +namespace write { static constexpr size_t k_encoded_buf_size = chip::kMaxAppMessageLen; -class client_deleter_write_callback : public WriteClient::Callback -{ +class client_deleter_write_callback : public WriteClient::Callback { public: - client_deleter_write_callback(WriteClient::Callback &callback) : m_callback(callback) {} - void OnResponse(const WriteClient * apWriteClient, const ConcreteDataAttributePath & aPath, + client_deleter_write_callback(WriteClient::Callback &callback) + : m_callback(callback) + { + } + void OnResponse(const WriteClient *apWriteClient, const ConcreteDataAttributePath &aPath, StatusIB attributeStatus) override { m_callback.OnResponse(apWriteClient, aPath, attributeStatus); } - void OnError(const WriteClient * apWriteClient, CHIP_ERROR aError) override + void OnError(const WriteClient *apWriteClient, CHIP_ERROR aError) override { m_callback.OnError(apWriteClient, aError); } @@ -650,8 +540,9 @@ public: chip::Platform::Delete(apWriteClient); chip::Platform::Delete(this); } + private: - WriteClient::Callback & m_callback; + WriteClient::Callback &m_callback; }; static esp_err_t encode_attribute_value(uint8_t *encoded_buf, size_t encoded_buf_size, const char *attr_val_json_str, @@ -692,9 +583,9 @@ static esp_err_t encode_attribute_value(uint8_t *encoded_buf, size_t encoded_buf return ESP_OK; } -esp_err_t send_write_request(client::peer_device_t *remote_device, AttributePathParams &attr_path, - const char *attr_val_json_str, WriteClient::Callback &callback, - const chip::Optional &timeout_ms) +esp_err_t send_request(client::peer_device_t *remote_device, AttributePathParams &attr_path, + const char *attr_val_json_str, WriteClient::Callback &callback, + const chip::Optional &timeout_ms) { esp_err_t err = ESP_OK; if (!remote_device->GetSecureSession().HasValue() || remote_device->GetSecureSession().Value()->IsGroupSession()) { @@ -745,7 +636,7 @@ esp_err_t send_write_request(client::peer_device_t *remote_device, AttributePath return ESP_OK; } +} // namespace write } // namespace interaction -#endif // CONFIG_ESP_MATTER_ENABLE_DATA_MODEL - +} // namespace client } // namespace esp_matter diff --git a/components/esp_matter/esp_matter_client.h b/components/esp_matter/esp_matter_client.h index 3fc44ac59..2be2b88d0 100644 --- a/components/esp_matter/esp_matter_client.h +++ b/components/esp_matter/esp_matter_client.h @@ -19,24 +19,28 @@ #include namespace esp_matter { -namespace cluster { -using client::peer_device_t; - -/** Custom command send APIs - * - * They can be used for all the commands of all the clusters, including the custom clusters. - */ -namespace custom { -namespace command { +namespace client { +namespace interaction { using chip::Optional; +using chip::app::AttributePathParams; using chip::app::CommandPathParams; using chip::app::CommandSender; using chip::app::ConcreteCommandPath; +using chip::app::EventPathParams; +using chip::app::ReadClient; using chip::app::StatusIB; +using chip::app::WriteClient; using chip::Messaging::ExchangeManager; using chip::System::Clock::Timeout; using chip::TLV::TLVReader; +using client::peer_device_t; + +/** Command invoke APIs + * + * They can be used for all the commands of all the clusters, including the custom clusters. + */ +namespace invoke { class custom_command_callback final : public chip::app::CommandSender::Callback { public: @@ -96,65 +100,42 @@ private: void *context; }; -esp_err_t send_command(void *ctx, peer_device_t *remote_device, const CommandPathParams &command_path, +esp_err_t send_request(void *ctx, peer_device_t *remote_device, const CommandPathParams &command_path, const char *command_data_json_str, custom_command_callback::on_success_callback_t on_success, custom_command_callback::on_error_callback_t on_error, const Optional &timed_invoke_timeout_ms, const Optional &response_timeout = chip::NullOptional); -esp_err_t send_group_command(const uint8_t fabric_index, const CommandPathParams &command_path, +esp_err_t send_group_request(const uint8_t fabric_index, const CommandPathParams &command_path, const char *command_data_json_str); +} // namespace invoke -} // namespace command -} // namespace custom - -/** Specific command send APIs +/** Attribute/event read API * - * If some standard command is not present here, it can be added. + * It can be used for reading all the attributes/events of all the clusters, including the custom clusters. */ +namespace read { +esp_err_t send_request(client::peer_device_t *remote_device, AttributePathParams *attr_path, size_t attr_path_size, + EventPathParams *event_path, size_t event_path_size, ReadClient::Callback &callback); +} // namespace read -namespace on_off { -namespace command { -esp_err_t send_off(peer_device_t *remote_device, uint16_t remote_endpoint_id); -esp_err_t send_on(peer_device_t *remote_device, uint16_t remote_endpoint_id); -esp_err_t send_toggle(peer_device_t *remote_device, uint16_t remote_endpoint_id); -esp_err_t group_send_off(uint8_t fabric_index, uint16_t group_id); -esp_err_t group_send_on(uint8_t fabric_index, uint16_t group_id); -esp_err_t group_send_toggle(uint8_t fabric_index, uint16_t group_id); -} // namespace command -} // namespace on_off +/** Attribute write API + * + * It can be used for writing all the attributes of all the clusters, including the custom clusters. + */ +namespace write { +esp_err_t send_request(client::peer_device_t *remote_device, AttributePathParams &attr_path, + const char *attr_val_json_str, WriteClient::Callback &callback, + const chip::Optional &timeout_ms); +} // namespace write -namespace identify { -namespace command { -esp_err_t send_identify(peer_device_t *remote_device, uint16_t remote_endpoint_id, uint16_t identify_time); - -esp_err_t group_send_identify(uint8_t fabric_index, uint16_t group_id, uint16_t identify_time); - -esp_err_t send_trigger_effect(peer_device_t *remote_device, uint16_t remote_endpoint_id, uint8_t effect_identifier, - uint8_t effect_variant); -} // namespace command -} // namespace identify -} // namespace cluster - -namespace interaction { - -using chip::app::AttributePathParams; -using chip::app::EventPathParams; -using chip::app::ReadClient; -using chip::app::WriteClient; - -esp_err_t send_read_request(client::peer_device_t *remote_device, AttributePathParams *attr_path, size_t attr_path_size, - EventPathParams *event_path, size_t event_path_size, ReadClient::Callback &callback); - -esp_err_t send_subscribe_request(client::peer_device_t *remote_device, AttributePathParams *attr_path, - size_t attr_path_size, EventPathParams *event_path, size_t event_path_size, - uint16_t min_interval, uint16_t max_interval, bool keep_subscription, - bool auto_resubscribe, ReadClient::Callback &callback); - -esp_err_t send_write_request(client::peer_device_t *remote_device, AttributePathParams &attr_path, - const char *attr_val_json_str, WriteClient::Callback &callback, - const chip::Optional &timeout_ms); +namespace subscribe { +esp_err_t send_request(client::peer_device_t *remote_device, AttributePathParams *attr_path, size_t attr_path_size, + EventPathParams *event_path, size_t event_path_size, uint16_t min_interval, + uint16_t max_interval, bool keep_subscription, bool auto_resubscribe, + ReadClient::Callback &callback); +} // namespace subscribe } // namespace interaction - +} // namespace client } // namespace esp_matter diff --git a/components/esp_matter/zap_common/zap-generated/CHIPClusters.h b/components/esp_matter/zap_common/zap-generated/CHIPClusters.h deleted file mode 100644 index afc21f0e1..000000000 --- a/components/esp_matter/zap_common/zap-generated/CHIPClusters.h +++ /dev/null @@ -1,733 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// TODO: This header is removed from upstream zap generated files. We should also remove it. -// THIS FILE IS GENERATED BY ZAP -#pragma once - -#include -#include - -#include -#include -#include - -namespace chip { -namespace Controller { - -class DLL_EXPORT IdentifyCluster : public ClusterBase -{ -public: - IdentifyCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~IdentifyCluster() {} -}; - -class DLL_EXPORT GroupsCluster : public ClusterBase -{ -public: - GroupsCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~GroupsCluster() {} -}; - -class DLL_EXPORT ScenesManagementCluster : public ClusterBase -{ -public: - ScenesManagementCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~ScenesManagementCluster() {} -}; - -class DLL_EXPORT OnOffCluster : public ClusterBase -{ -public: - OnOffCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~OnOffCluster() {} -}; - -class DLL_EXPORT OnOffSwitchConfigurationCluster : public ClusterBase -{ -public: - OnOffSwitchConfigurationCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~OnOffSwitchConfigurationCluster() {} -}; - -class DLL_EXPORT LevelControlCluster : public ClusterBase -{ -public: - LevelControlCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~LevelControlCluster() {} -}; - -class DLL_EXPORT BinaryInputBasicCluster : public ClusterBase -{ -public: - BinaryInputBasicCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~BinaryInputBasicCluster() {} -}; - -class DLL_EXPORT DescriptorCluster : public ClusterBase -{ -public: - DescriptorCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~DescriptorCluster() {} -}; - -class DLL_EXPORT BindingCluster : public ClusterBase -{ -public: - BindingCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~BindingCluster() {} -}; - -class DLL_EXPORT AccessControlCluster : public ClusterBase -{ -public: - AccessControlCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~AccessControlCluster() {} -}; - -class DLL_EXPORT ActionsCluster : public ClusterBase -{ -public: - ActionsCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~ActionsCluster() {} -}; - -class DLL_EXPORT BasicInformationCluster : public ClusterBase -{ -public: - BasicInformationCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~BasicInformationCluster() {} -}; - -class DLL_EXPORT OtaSoftwareUpdateProviderCluster : public ClusterBase -{ -public: - OtaSoftwareUpdateProviderCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~OtaSoftwareUpdateProviderCluster() {} -}; - -class DLL_EXPORT OtaSoftwareUpdateRequestorCluster : public ClusterBase -{ -public: - OtaSoftwareUpdateRequestorCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~OtaSoftwareUpdateRequestorCluster() {} -}; - -class DLL_EXPORT LocalizationConfigurationCluster : public ClusterBase -{ -public: - LocalizationConfigurationCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~LocalizationConfigurationCluster() {} -}; - -class DLL_EXPORT TimeFormatLocalizationCluster : public ClusterBase -{ -public: - TimeFormatLocalizationCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~TimeFormatLocalizationCluster() {} -}; - -class DLL_EXPORT UnitLocalizationCluster : public ClusterBase -{ -public: - UnitLocalizationCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~UnitLocalizationCluster() {} -}; - -class DLL_EXPORT PowerSourceConfigurationCluster : public ClusterBase -{ -public: - PowerSourceConfigurationCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~PowerSourceConfigurationCluster() {} -}; - -class DLL_EXPORT PowerSourceCluster : public ClusterBase -{ -public: - PowerSourceCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~PowerSourceCluster() {} -}; - -class DLL_EXPORT GeneralCommissioningCluster : public ClusterBase -{ -public: - GeneralCommissioningCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~GeneralCommissioningCluster() {} -}; - -class DLL_EXPORT NetworkCommissioningCluster : public ClusterBase -{ -public: - NetworkCommissioningCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~NetworkCommissioningCluster() {} -}; - -class DLL_EXPORT DiagnosticLogsCluster : public ClusterBase -{ -public: - DiagnosticLogsCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~DiagnosticLogsCluster() {} -}; - -class DLL_EXPORT GeneralDiagnosticsCluster : public ClusterBase -{ -public: - GeneralDiagnosticsCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~GeneralDiagnosticsCluster() {} -}; - -class DLL_EXPORT SoftwareDiagnosticsCluster : public ClusterBase -{ -public: - SoftwareDiagnosticsCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~SoftwareDiagnosticsCluster() {} -}; - -class DLL_EXPORT ThreadNetworkDiagnosticsCluster : public ClusterBase -{ -public: - ThreadNetworkDiagnosticsCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~ThreadNetworkDiagnosticsCluster() {} -}; - -class DLL_EXPORT WiFiNetworkDiagnosticsCluster : public ClusterBase -{ -public: - WiFiNetworkDiagnosticsCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~WiFiNetworkDiagnosticsCluster() {} -}; - -class DLL_EXPORT EthernetNetworkDiagnosticsCluster : public ClusterBase -{ -public: - EthernetNetworkDiagnosticsCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~EthernetNetworkDiagnosticsCluster() {} -}; - -class DLL_EXPORT TimeSynchronizationCluster : public ClusterBase -{ -public: - TimeSynchronizationCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~TimeSynchronizationCluster() {} -}; - -class DLL_EXPORT BridgedDeviceBasicInformationCluster : public ClusterBase -{ -public: - BridgedDeviceBasicInformationCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~BridgedDeviceBasicInformationCluster() {} -}; - -class DLL_EXPORT SwitchCluster : public ClusterBase -{ -public: - SwitchCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~SwitchCluster() {} -}; - -class DLL_EXPORT AdministratorCommissioningCluster : public ClusterBase -{ -public: - AdministratorCommissioningCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~AdministratorCommissioningCluster() {} -}; - -class DLL_EXPORT OperationalCredentialsCluster : public ClusterBase -{ -public: - OperationalCredentialsCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~OperationalCredentialsCluster() {} -}; - -class DLL_EXPORT GroupKeyManagementCluster : public ClusterBase -{ -public: - GroupKeyManagementCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~GroupKeyManagementCluster() {} -}; - -class DLL_EXPORT FixedLabelCluster : public ClusterBase -{ -public: - FixedLabelCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~FixedLabelCluster() {} -}; - -class DLL_EXPORT UserLabelCluster : public ClusterBase -{ -public: - UserLabelCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~UserLabelCluster() {} -}; - -class DLL_EXPORT BooleanStateCluster : public ClusterBase -{ -public: - BooleanStateCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~BooleanStateCluster() {} -}; - -class DLL_EXPORT IcdManagementCluster : public ClusterBase -{ -public: - IcdManagementCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~IcdManagementCluster() {} -}; - -class DLL_EXPORT TimerCluster : public ClusterBase -{ -public: - TimerCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~TimerCluster() {} -}; - -class DLL_EXPORT OvenCavityOperationalStateCluster : public ClusterBase -{ -public: - OvenCavityOperationalStateCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~OvenCavityOperationalStateCluster() {} -}; - -class DLL_EXPORT OvenModeCluster : public ClusterBase -{ -public: - OvenModeCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~OvenModeCluster() {} -}; - -class DLL_EXPORT LaundryDryerControlsCluster : public ClusterBase -{ -public: - LaundryDryerControlsCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~LaundryDryerControlsCluster() {} -}; - -class DLL_EXPORT ModeSelectCluster : public ClusterBase -{ -public: - ModeSelectCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~ModeSelectCluster() {} -}; - -class DLL_EXPORT LaundryWasherModeCluster : public ClusterBase -{ -public: - LaundryWasherModeCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~LaundryWasherModeCluster() {} -}; - -class DLL_EXPORT RefrigeratorAndTemperatureControlledCabinetModeCluster : public ClusterBase -{ -public: - RefrigeratorAndTemperatureControlledCabinetModeCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~RefrigeratorAndTemperatureControlledCabinetModeCluster() {} -}; - -class DLL_EXPORT LaundryWasherControlsCluster : public ClusterBase -{ -public: - LaundryWasherControlsCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~LaundryWasherControlsCluster() {} -}; - -class DLL_EXPORT RvcRunModeCluster : public ClusterBase -{ -public: - RvcRunModeCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~RvcRunModeCluster() {} -}; - -class DLL_EXPORT RvcCleanModeCluster : public ClusterBase -{ -public: - RvcCleanModeCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~RvcCleanModeCluster() {} -}; - -class DLL_EXPORT TemperatureControlCluster : public ClusterBase -{ -public: - TemperatureControlCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~TemperatureControlCluster() {} -}; - -class DLL_EXPORT RefrigeratorAlarmCluster : public ClusterBase -{ -public: - RefrigeratorAlarmCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~RefrigeratorAlarmCluster() {} -}; - -class DLL_EXPORT DishwasherModeCluster : public ClusterBase -{ -public: - DishwasherModeCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~DishwasherModeCluster() {} -}; - -class DLL_EXPORT AirQualityCluster : public ClusterBase -{ -public: - AirQualityCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~AirQualityCluster() {} -}; - -class DLL_EXPORT SmokeCoAlarmCluster : public ClusterBase -{ -public: - SmokeCoAlarmCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~SmokeCoAlarmCluster() {} -}; - -class DLL_EXPORT DishwasherAlarmCluster : public ClusterBase -{ -public: - DishwasherAlarmCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~DishwasherAlarmCluster() {} -}; - -class DLL_EXPORT MicrowaveOvenModeCluster : public ClusterBase -{ -public: - MicrowaveOvenModeCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~MicrowaveOvenModeCluster() {} -}; - -class DLL_EXPORT OperationalStateCluster : public ClusterBase -{ -public: - OperationalStateCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~OperationalStateCluster() {} -}; - -class DLL_EXPORT RvcOperationalStateCluster : public ClusterBase -{ -public: - RvcOperationalStateCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~RvcOperationalStateCluster() {} -}; - -class DLL_EXPORT HepaFilterMonitoringCluster : public ClusterBase -{ -public: - HepaFilterMonitoringCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~HepaFilterMonitoringCluster() {} -}; - -class DLL_EXPORT ActivatedCarbonFilterMonitoringCluster : public ClusterBase -{ -public: - ActivatedCarbonFilterMonitoringCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~ActivatedCarbonFilterMonitoringCluster() {} -}; - -class DLL_EXPORT DeviceEnergyManagementCluster : public ClusterBase -{ -public: - DeviceEnergyManagementCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~DeviceEnergyManagementCluster() {} -}; - -class DLL_EXPORT EnergyEvseCluster : public ClusterBase -{ -public: - EnergyEvseCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~EnergyEvseCluster() {} -}; - -class DLL_EXPORT DoorLockCluster : public ClusterBase -{ -public: - DoorLockCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~DoorLockCluster() {} -}; - -class DLL_EXPORT WindowCoveringCluster : public ClusterBase -{ -public: - WindowCoveringCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~WindowCoveringCluster() {} -}; - -class DLL_EXPORT BarrierControlCluster : public ClusterBase -{ -public: - BarrierControlCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~BarrierControlCluster() {} -}; - -class DLL_EXPORT PumpConfigurationAndControlCluster : public ClusterBase -{ -public: - PumpConfigurationAndControlCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~PumpConfigurationAndControlCluster() {} -}; - -class DLL_EXPORT ThermostatCluster : public ClusterBase -{ -public: - ThermostatCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~ThermostatCluster() {} -}; - -class DLL_EXPORT FanControlCluster : public ClusterBase -{ -public: - FanControlCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~FanControlCluster() {} -}; - -class DLL_EXPORT ThermostatUserInterfaceConfigurationCluster : public ClusterBase -{ -public: - ThermostatUserInterfaceConfigurationCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~ThermostatUserInterfaceConfigurationCluster() {} -}; - -class DLL_EXPORT ColorControlCluster : public ClusterBase -{ -public: - ColorControlCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~ColorControlCluster() {} -}; - -class DLL_EXPORT BallastConfigurationCluster : public ClusterBase -{ -public: - BallastConfigurationCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~BallastConfigurationCluster() {} -}; - -class DLL_EXPORT IlluminanceMeasurementCluster : public ClusterBase -{ -public: - IlluminanceMeasurementCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~IlluminanceMeasurementCluster() {} -}; - -class DLL_EXPORT TemperatureMeasurementCluster : public ClusterBase -{ -public: - TemperatureMeasurementCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~TemperatureMeasurementCluster() {} -}; - -class DLL_EXPORT PressureMeasurementCluster : public ClusterBase -{ -public: - PressureMeasurementCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~PressureMeasurementCluster() {} -}; - -class DLL_EXPORT FlowMeasurementCluster : public ClusterBase -{ -public: - FlowMeasurementCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~FlowMeasurementCluster() {} -}; - -class DLL_EXPORT RelativeHumidityMeasurementCluster : public ClusterBase -{ -public: - RelativeHumidityMeasurementCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~RelativeHumidityMeasurementCluster() {} -}; - -class DLL_EXPORT OccupancySensingCluster : public ClusterBase -{ -public: - OccupancySensingCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~OccupancySensingCluster() {} -}; - -class DLL_EXPORT CarbonMonoxideConcentrationMeasurementCluster : public ClusterBase -{ -public: - CarbonMonoxideConcentrationMeasurementCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~CarbonMonoxideConcentrationMeasurementCluster() {} -}; - -class DLL_EXPORT CarbonDioxideConcentrationMeasurementCluster : public ClusterBase -{ -public: - CarbonDioxideConcentrationMeasurementCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~CarbonDioxideConcentrationMeasurementCluster() {} -}; - -class DLL_EXPORT NitrogenDioxideConcentrationMeasurementCluster : public ClusterBase -{ -public: - NitrogenDioxideConcentrationMeasurementCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~NitrogenDioxideConcentrationMeasurementCluster() {} -}; - -class DLL_EXPORT OzoneConcentrationMeasurementCluster : public ClusterBase -{ -public: - OzoneConcentrationMeasurementCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~OzoneConcentrationMeasurementCluster() {} -}; - -class DLL_EXPORT Pm25ConcentrationMeasurementCluster : public ClusterBase -{ -public: - Pm25ConcentrationMeasurementCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~Pm25ConcentrationMeasurementCluster() {} -}; - -class DLL_EXPORT FormaldehydeConcentrationMeasurementCluster : public ClusterBase -{ -public: - FormaldehydeConcentrationMeasurementCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~FormaldehydeConcentrationMeasurementCluster() {} -}; - -class DLL_EXPORT Pm1ConcentrationMeasurementCluster : public ClusterBase -{ -public: - Pm1ConcentrationMeasurementCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~Pm1ConcentrationMeasurementCluster() {} -}; - -class DLL_EXPORT Pm10ConcentrationMeasurementCluster : public ClusterBase -{ -public: - Pm10ConcentrationMeasurementCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~Pm10ConcentrationMeasurementCluster() {} -}; - -class DLL_EXPORT TotalVolatileOrganicCompoundsConcentrationMeasurementCluster : public ClusterBase -{ -public: - TotalVolatileOrganicCompoundsConcentrationMeasurementCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~TotalVolatileOrganicCompoundsConcentrationMeasurementCluster() {} -}; - -class DLL_EXPORT RadonConcentrationMeasurementCluster : public ClusterBase -{ -public: - RadonConcentrationMeasurementCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~RadonConcentrationMeasurementCluster() {} -}; - -class DLL_EXPORT WakeOnLanCluster : public ClusterBase -{ -public: - WakeOnLanCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~WakeOnLanCluster() {} -}; - -class DLL_EXPORT ChannelCluster : public ClusterBase -{ -public: - ChannelCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~ChannelCluster() {} -}; - -class DLL_EXPORT TargetNavigatorCluster : public ClusterBase -{ -public: - TargetNavigatorCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~TargetNavigatorCluster() {} -}; - -class DLL_EXPORT MediaPlaybackCluster : public ClusterBase -{ -public: - MediaPlaybackCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~MediaPlaybackCluster() {} -}; - -class DLL_EXPORT MediaInputCluster : public ClusterBase -{ -public: - MediaInputCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~MediaInputCluster() {} -}; - -class DLL_EXPORT LowPowerCluster : public ClusterBase -{ -public: - LowPowerCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~LowPowerCluster() {} -}; - -class DLL_EXPORT KeypadInputCluster : public ClusterBase -{ -public: - KeypadInputCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~KeypadInputCluster() {} -}; - -class DLL_EXPORT ContentLauncherCluster : public ClusterBase -{ -public: - ContentLauncherCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~ContentLauncherCluster() {} -}; - -class DLL_EXPORT AudioOutputCluster : public ClusterBase -{ -public: - AudioOutputCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~AudioOutputCluster() {} -}; - -class DLL_EXPORT ApplicationLauncherCluster : public ClusterBase -{ -public: - ApplicationLauncherCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~ApplicationLauncherCluster() {} -}; - -class DLL_EXPORT ApplicationBasicCluster : public ClusterBase -{ -public: - ApplicationBasicCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~ApplicationBasicCluster() {} -}; - -class DLL_EXPORT AccountLoginCluster : public ClusterBase -{ -public: - AccountLoginCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~AccountLoginCluster() {} -}; - -class DLL_EXPORT ElectricalMeasurementCluster : public ClusterBase -{ -public: - ElectricalMeasurementCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~ElectricalMeasurementCluster() {} -}; - -class DLL_EXPORT UnitTestingCluster : public ClusterBase -{ -public: - UnitTestingCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~UnitTestingCluster() {} -}; - -class DLL_EXPORT SampleMeiCluster : public ClusterBase -{ -public: - SampleMeiCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {} - ~SampleMeiCluster() {} -}; - -} // namespace Controller -} // namespace chip diff --git a/components/esp_matter_controller/commands/esp_matter_controller_cluster_command.cpp b/components/esp_matter_controller/commands/esp_matter_controller_cluster_command.cpp index 7e1936e05..d0ede9310 100644 --- a/components/esp_matter_controller/commands/esp_matter_controller_cluster_command.cpp +++ b/components/esp_matter_controller/commands/esp_matter_controller_cluster_command.cpp @@ -29,6 +29,7 @@ using namespace chip::app::Clusters; using namespace esp_matter::cluster; +using namespace esp_matter::client; static const char *TAG = "cluster_command"; namespace esp_matter { @@ -153,7 +154,7 @@ void cluster_command::on_device_connected_fcn(void *context, ExchangeManager &ex chip::OperationalDeviceProxy device_proxy(&exchangeMgr, sessionHandle); chip::app::CommandPathParams command_path = {cmd->m_endpoint_id, 0, cmd->m_cluster_id, cmd->m_command_id, chip::app::CommandPathFlags::kEndpointIdValid}; - custom::command::send_command(context, &device_proxy, command_path, cmd->m_command_data_field, cmd->on_success_cb, + interaction::invoke::send_request(context, &device_proxy, command_path, cmd->m_command_data_field, cmd->on_success_cb, cmd->on_error_cb, chip::NullOptional); chip::Platform::Delete(cmd); return; @@ -218,7 +219,7 @@ esp_err_t cluster_command::dispatch_group_command(void *context) #endif // CONFIG_ESP_MATTER_ENABLE_MATTER_SERVER chip::app::CommandPathParams command_path = {cmd->m_endpoint_id, group_id, cmd->m_cluster_id, cmd->m_command_id, chip::app::CommandPathFlags::kGroupIdValid}; - err = custom::command::send_group_command(fabric_index, command_path, cmd->m_command_data_field); + err = interaction::invoke::send_group_request(fabric_index, command_path, cmd->m_command_data_field); chip::Platform::Delete(cmd); return err; } diff --git a/components/esp_matter_controller/commands/esp_matter_controller_cluster_command.h b/components/esp_matter_controller/commands/esp_matter_controller_cluster_command.h index ba75f626b..2004cc6cf 100644 --- a/components/esp_matter_controller/commands/esp_matter_controller_cluster_command.h +++ b/components/esp_matter_controller/commands/esp_matter_controller_cluster_command.h @@ -29,7 +29,7 @@ using chip::app::StatusIB; using chip::Messaging::ExchangeManager; using chip::TLV::TLVReader; using esp_matter::client::peer_device_t; -using esp_matter::cluster::custom::command::custom_command_callback; +using esp_matter::client::interaction::invoke::custom_command_callback; constexpr char k_empty_command_data_field[] = "{}"; constexpr size_t k_command_data_field_buffer_size = CONFIG_ESP_MATTER_CONTROLLER_JSON_STRING_BUFFER_LEN; diff --git a/components/esp_matter_controller/commands/esp_matter_controller_read_command.cpp b/components/esp_matter_controller/commands/esp_matter_controller_read_command.cpp index 32a4974b1..252081832 100644 --- a/components/esp_matter_controller/commands/esp_matter_controller_read_command.cpp +++ b/components/esp_matter_controller/commands/esp_matter_controller_read_command.cpp @@ -14,15 +14,16 @@ #include #include +#include #include #include -#include #include #include "DataModelLogger.h" using namespace chip::app::Clusters; +using namespace esp_matter::client; using chip::DeviceProxy; using chip::app::InteractionModelEngine; using chip::app::ReadClient; @@ -38,9 +39,9 @@ void read_command::on_device_connected_fcn(void *context, ExchangeManager &excha { read_command *cmd = (read_command *)context; chip::OperationalDeviceProxy device_proxy(&exchangeMgr, sessionHandle); - esp_err_t err = interaction::send_read_request(&device_proxy, cmd->m_attr_paths.Get(), - cmd->m_attr_paths.AllocatedSize(), cmd->m_event_paths.Get(), - cmd->m_event_paths.AllocatedSize(), cmd->m_buffered_read_cb); + esp_err_t err = interaction::read::send_request(&device_proxy, cmd->m_attr_paths.Get(), + cmd->m_attr_paths.AllocatedSize(), cmd->m_event_paths.Get(), + cmd->m_event_paths.AllocatedSize(), cmd->m_buffered_read_cb); if (err != ESP_OK) { chip::Platform::Delete(cmd); } diff --git a/components/esp_matter_controller/commands/esp_matter_controller_subscribe_command.cpp b/components/esp_matter_controller/commands/esp_matter_controller_subscribe_command.cpp index 3f4b83bf6..78ae6c0a4 100644 --- a/components/esp_matter_controller/commands/esp_matter_controller_subscribe_command.cpp +++ b/components/esp_matter_controller/commands/esp_matter_controller_subscribe_command.cpp @@ -15,12 +15,14 @@ #include #include #include +#include #include #include #include "DataModelLogger.h" using namespace chip::app::Clusters; +using namespace esp_matter::client; using chip::DeviceProxy; using chip::app::InteractionModelEngine; using chip::app::ReadClient; @@ -38,11 +40,10 @@ void subscribe_command::on_device_connected_fcn(void *context, ExchangeManager & { subscribe_command *cmd = (subscribe_command *)context; chip::OperationalDeviceProxy device_proxy(&exchangeMgr, sessionHandle); - esp_err_t err = interaction::send_subscribe_request(&device_proxy, cmd->m_attr_paths.Get(), - cmd->m_attr_paths.AllocatedSize(), cmd->m_event_paths.Get(), - cmd->m_event_paths.AllocatedSize(), cmd->m_min_interval, - cmd->m_max_interval, true, cmd->m_auto_resubscribe, - cmd->m_buffered_read_cb); + esp_err_t err = interaction::subscribe::send_request( + &device_proxy, cmd->m_attr_paths.Get(), cmd->m_attr_paths.AllocatedSize(), cmd->m_event_paths.Get(), + cmd->m_event_paths.AllocatedSize(), cmd->m_min_interval, cmd->m_max_interval, true, cmd->m_auto_resubscribe, + cmd->m_buffered_read_cb); if (err != ESP_OK) { chip::Platform::Delete(cmd); } diff --git a/components/esp_matter_controller/commands/esp_matter_controller_write_command.cpp b/components/esp_matter_controller/commands/esp_matter_controller_write_command.cpp index 77b5f0749..cbbd97f64 100644 --- a/components/esp_matter_controller/commands/esp_matter_controller_write_command.cpp +++ b/components/esp_matter_controller/commands/esp_matter_controller_write_command.cpp @@ -19,10 +19,11 @@ #include #include -#include #include +#include using namespace chip::app::Clusters; +using namespace esp_matter::client; using chip::ByteSpan; using chip::DeviceProxy; using chip::app::DataModel::List; @@ -45,8 +46,8 @@ void write_command::on_device_connected_fcn(void *context, ExchangeManager &exch { write_command *cmd = (write_command *)context; chip::OperationalDeviceProxy device_proxy(&exchangeMgr, sessionHandle); - esp_err_t err = interaction::send_write_request(&device_proxy, cmd->m_attr_path, cmd->m_attr_val_str, - cmd->m_chunked_callback, chip::NullOptional); + esp_err_t err = interaction::write::send_request(&device_proxy, cmd->m_attr_path, cmd->m_attr_val_str, + cmd->m_chunked_callback, chip::NullOptional); if (err != ESP_OK) { chip::Platform::Delete(cmd); } diff --git a/components/esp_matter_controller/core/esp_matter_controller_console.cpp b/components/esp_matter_controller/core/esp_matter_controller_console.cpp index f6cb848df..910426a84 100644 --- a/components/esp_matter_controller/core/esp_matter_controller_console.cpp +++ b/components/esp_matter_controller/core/esp_matter_controller_console.cpp @@ -485,7 +485,7 @@ esp_err_t controller_register_commands() { .name = "subs-event", .description = "Subscribe events of the nodes.\n" - "\tUsage: controller subs-attr [node-id] [endpoint-id] [cluster-id] [event-id] " + "\tUsage: controller subs-event [node-id] [endpoint-id] [cluster-id] [event-id] " "[min-interval] [max-interval]", .handler = controller_subscribe_event_handler, }, diff --git a/examples/esp-now_bridge_light/main/app_driver.cpp b/examples/esp-now_bridge_light/main/app_driver.cpp index 708679c7b..f166807d8 100644 --- a/examples/esp-now_bridge_light/main/app_driver.cpp +++ b/examples/esp-now_bridge_light/main/app_driver.cpp @@ -82,10 +82,10 @@ static esp_err_t app_driver_client_console_handler(int argc, char **argv) req_handle.type = esp_matter::client::INVOKE_CMD; uint8_t fabric_index = strtoul((const char *)&argv[1][2], NULL, 16); uint64_t node_id = strtoull((const char *)&argv[2][2], NULL, 16); - req_handle.command_path.mFlags.Set(chip::app::CommandPathFlags::kEndpointIdValid); - req_handle.command_path.mEndpointId = strtoul((const char *)&argv[3][2], NULL, 16); - req_handle.command_path.mClusterId = strtoul((const char *)&argv[4][2], NULL, 16); - req_handle.command_path.mCommandId = strtoul((const char *)&argv[5][2], NULL, 16); + req_handle.command_path = {(chip::EndpointId)strtoul((const char *)&argv[3][2], NULL, 16) /* EndpointId */, + 0 /* GroupId */, strtoul((const char *)&argv[4][2], NULL, 16) /* ClusterId */, + strtoul((const char *)&argv[5][2], NULL, 16) /* CommandId */, + chip::app::CommandPathFlags::kEndpointIdValid}; if (argc > 6) { console_buffer[0] = argc - 6; @@ -106,10 +106,10 @@ static esp_err_t app_driver_client_console_handler(int argc, char **argv) client::request_handle_t req_handle; req_handle.type = esp_matter::client::INVOKE_CMD; uint8_t fabric_index = strtoul((const char *)&argv[1][2], NULL, 16); - req_handle.command_path.mFlags.Set(chip::app::CommandPathFlags::kGroupIdValid); - req_handle.command_path.mGroupId = strtoul((const char *)&argv[2][2], NULL, 16); - req_handle.command_path.mClusterId = strtoul((const char *)&argv[3][2], NULL, 16); - req_handle.command_path.mCommandId = strtoul((const char *)&argv[4][2], NULL, 16); + req_handle.command_path = { + 0 /* EndpointId */, (chip::GroupId)strtoul((const char *)&argv[2][2], NULL, 16) /* GroupId */, + strtoul((const char *)&argv[3][2], NULL, 16) /* ClusterId */, + strtoul((const char *)&argv[4][2], NULL, 16) /* CommandId */, chip::app::CommandPathFlags::kGroupIdValid}; if (argc > 5) { console_buffer[0] = argc - 5; @@ -159,6 +159,17 @@ static void app_driver_register_commands() } #endif // CONFIG_ENABLE_CHIP_SHELL +static void send_command_success_callback(void *context, const ConcreteCommandPath &command_path, + const chip::app::StatusIB &status, TLVReader *response_data) +{ + ESP_LOGI(TAG, "Send command success"); +} + +static void send_command_failure_callback(void *context, CHIP_ERROR error) +{ + ESP_LOGI(TAG, "Send command failure: err :%" CHIP_ERROR_FORMAT, error.Format()); +} + void app_driver_client_invoke_command_callback(client::peer_device_t *peer_device, client::request_handle_t *req_handle, void *priv_data) { @@ -166,40 +177,28 @@ void app_driver_client_invoke_command_callback(client::peer_device_t *peer_devic !req_handle->command_path.mFlags.Has(chip::app::CommandPathFlags::kEndpointIdValid)) { return; } + char command_data_str[32]; if (req_handle->command_path.mClusterId == OnOff::Id) { - switch(req_handle->command_path.mCommandId) { - case OnOff::Commands::Off::Id: - { - on_off::command::send_off(peer_device, req_handle->command_path.mEndpointId); - break; - }; - case OnOff::Commands::On::Id: - { - on_off::command::send_on(peer_device, req_handle->command_path.mEndpointId); - break; - }; - case OnOff::Commands::Toggle::Id: - { - on_off::command::send_toggle(peer_device, req_handle->command_path.mEndpointId); - break; - }; - default: - break; - } + strcpy(command_data_str, "{}"); } else if (req_handle->command_path.mClusterId == Identify::Id) { if (req_handle->command_path.mCommandId == Identify::Commands::Identify::Id) { if (((char *)req_handle->request_data)[0] != 1) { ESP_LOGE(TAG, "Number of parameters error"); return; } - identify::command::send_identify(peer_device, req_handle->command_path.mEndpointId, - strtoul((const char *)(req_handle->request_data) + 1, NULL, 16)); + sprintf(command_data_str, "{\"0:U16\": %ld}", + strtoul((const char *)(req_handle->request_data) + 1, NULL, 16)); } else { ESP_LOGE(TAG, "Unsupported command"); + return; } } else { ESP_LOGE(TAG, "Unsupported cluster"); + return; } + client::interaction::invoke::send_request(NULL, peer_device, req_handle->command_path, command_data_str, + send_command_success_callback, send_command_failure_callback, + chip::NullOptional); } void app_driver_client_group_invoke_command_callback(uint8_t fabric_index, client::request_handle_t *req_handle, void *priv_data) @@ -208,41 +207,26 @@ void app_driver_client_group_invoke_command_callback(uint8_t fabric_index, clien !req_handle->command_path.mFlags.Has(chip::app::CommandPathFlags::kGroupIdValid)) { return; } - + char command_data_str[32]; if (req_handle->command_path.mClusterId == OnOff::Id) { - switch(req_handle->command_path.mCommandId) { - case OnOff::Commands::Off::Id: - { - on_off::command::group_send_off(fabric_index, req_handle->command_path.mGroupId); - break; - }; - case OnOff::Commands::On::Id: - { - on_off::command::group_send_on(fabric_index, req_handle->command_path.mGroupId); - break; - }; - case OnOff::Commands::Toggle::Id: - { - on_off::command::group_send_toggle(fabric_index, req_handle->command_path.mGroupId); - break; - }; - default: - break; - } + strcpy(command_data_str, "{}"); } else if (req_handle->command_path.mClusterId == Identify::Id) { if (req_handle->command_path.mCommandId == Identify::Commands::Identify::Id) { if (((char *)req_handle->request_data)[0] != 1) { ESP_LOGE(TAG, "Number of parameters error"); return; } - identify::command::group_send_identify(fabric_index, req_handle->command_path.mGroupId, - strtoul((const char *)(req_handle->request_data) + 1, NULL, 16)); + sprintf(command_data_str, "{\"0:U16\": %ld}", + strtoul((const char *)(req_handle->request_data) + 1, NULL, 16)); } else { ESP_LOGE(TAG, "Unsupported command"); + return; } } else { ESP_LOGE(TAG, "Unsupported cluster"); + return; } + client::interaction::invoke::send_group_request(fabric_index, req_handle->command_path, command_data_str); } /* Do any conversions/remapping for the actual value here */ diff --git a/examples/light_switch/main/app_driver.cpp b/examples/light_switch/main/app_driver.cpp index d5fa112cc..048a8665f 100644 --- a/examples/light_switch/main/app_driver.cpp +++ b/examples/light_switch/main/app_driver.cpp @@ -6,6 +6,9 @@ CONDITIONS OF ANY KIND, either express or implied. */ +#include "esp_matter_client.h" +#include +#include #include #include #include @@ -19,6 +22,7 @@ #include #include +#include using chip::kInvalidClusterId; static constexpr chip::CommandId kInvalidCommandId = 0xFFFF'FFFF; @@ -84,9 +88,10 @@ static esp_err_t app_driver_client_console_handler(int argc, char **argv) req_handle.type = esp_matter::client::INVOKE_CMD; uint8_t fabric_index = strtoul((const char *)&argv[1][2], NULL, 16); uint64_t node_id = strtoull((const char *)&argv[2][2], NULL, 16); - req_handle.command_path.mEndpointId = strtoul((const char *)&argv[3][2], NULL, 16); - req_handle.command_path.mClusterId = strtoul((const char *)&argv[4][2], NULL, 16); - req_handle.command_path.mCommandId = strtoul((const char *)&argv[5][2], NULL, 16); + req_handle.command_path = {(chip::EndpointId)strtoul((const char *)&argv[3][2], NULL, 16) /* EndpointId */, + 0 /* GroupId */, strtoul((const char *)&argv[4][2], NULL, 16) /* ClusterId */, + strtoul((const char *)&argv[5][2], NULL, 16) /* CommandId */, + chip::app::CommandPathFlags::kEndpointIdValid}; if (argc > 6) { console_buffer[0] = argc - 6; @@ -110,6 +115,10 @@ static esp_err_t app_driver_client_console_handler(int argc, char **argv) req_handle.command_path.mGroupId = strtoul((const char *)&argv[2][2], NULL, 16); req_handle.command_path.mClusterId = strtoul((const char *)&argv[3][2], NULL, 16); req_handle.command_path.mCommandId = strtoul((const char *)&argv[4][2], NULL, 16); + req_handle.command_path = { + 0 /* EndpointId */, (chip::GroupId)strtoul((const char *)&argv[2][2], NULL, 16) /* GroupId */, + strtoul((const char *)&argv[3][2], NULL, 16) /* ClusterId */, + strtoul((const char *)&argv[4][2], NULL, 16) /* CommandId */, chip::app::CommandPathFlags::kGroupIdValid}; if (argc > 5) { console_buffer[0] = argc - 5; @@ -158,44 +167,46 @@ static void app_driver_register_commands() } #endif // CONFIG_ENABLE_CHIP_SHELL +static void send_command_success_callback(void *context, const ConcreteCommandPath &command_path, + const chip::app::StatusIB &status, TLVReader *response_data) +{ + ESP_LOGI(TAG, "Send command success"); +} + +static void send_command_failure_callback(void *context, CHIP_ERROR error) +{ + ESP_LOGI(TAG, "Send command failure: err :%" CHIP_ERROR_FORMAT, error.Format()); +} + void app_driver_client_invoke_command_callback(client::peer_device_t *peer_device, client::request_handle_t *req_handle, - void *priv_data) + void *priv_data) { if (req_handle->type != esp_matter::client::INVOKE_CMD) { return; } + char command_data_str[32]; // on_off light switch should support on_off cluster and identify cluster commands sending. if (req_handle->command_path.mClusterId == OnOff::Id) { - switch (req_handle->command_path.mCommandId) { - case OnOff::Commands::Off::Id: { - on_off::command::send_off(peer_device, req_handle->command_path.mEndpointId); - break; - }; - case OnOff::Commands::On::Id: { - on_off::command::send_on(peer_device, req_handle->command_path.mEndpointId); - break; - }; - case OnOff::Commands::Toggle::Id: { - on_off::command::send_toggle(peer_device, req_handle->command_path.mEndpointId); - break; - }; - default: - break; - } + strcpy(command_data_str, "{}"); } else if (req_handle->command_path.mClusterId == Identify::Id) { if (req_handle->command_path.mCommandId == Identify::Commands::Identify::Id) { if (((char *)req_handle->request_data)[0] != 1) { ESP_LOGE(TAG, "Number of parameters error"); return; } - identify::command::send_identify(peer_device, req_handle->command_path.mEndpointId, - strtoul((const char *)(req_handle->request_data) + 1, NULL, 16)); + sprintf(command_data_str, "{\"0:U16\": %ld}", + strtoul((const char *)(req_handle->request_data) + 1, NULL, 16)); } else { ESP_LOGE(TAG, "Unsupported command"); + return; } } else { ESP_LOGE(TAG, "Unsupported cluster"); + return; } + client::interaction::invoke::send_request(NULL, peer_device, req_handle->command_path, command_data_str, + send_command_success_callback, send_command_failure_callback, + chip::NullOptional); } void app_driver_client_group_invoke_command_callback(uint8_t fabric_index, client::request_handle_t *req_handle, @@ -204,38 +215,27 @@ void app_driver_client_group_invoke_command_callback(uint8_t fabric_index, clien if (req_handle->type != esp_matter::client::INVOKE_CMD) { return; } + char command_data_str[32]; // on_off light switch should support on_off cluster and identify cluster commands sending. if (req_handle->command_path.mClusterId == OnOff::Id) { - switch (req_handle->command_path.mCommandId) { - case OnOff::Commands::Off::Id: { - on_off::command::group_send_off(fabric_index, req_handle->command_path.mGroupId); - break; - } - case OnOff::Commands::On::Id: { - on_off::command::group_send_on(fabric_index, req_handle->command_path.mGroupId); - break; - } - case OnOff::Commands::Toggle::Id: { - on_off::command::group_send_toggle(fabric_index, req_handle->command_path.mGroupId); - break; - } - default: - break; - } + strcpy(command_data_str, "{}"); } else if (req_handle->command_path.mClusterId == Identify::Id) { if (req_handle->command_path.mCommandId == Identify::Commands::Identify::Id) { if (((char *)req_handle->request_data)[0] != 1) { ESP_LOGE(TAG, "Number of parameters error"); return; } - identify::command::group_send_identify(fabric_index, req_handle->command_path.mGroupId, - strtoul((const char *)(req_handle->request_data) + 1, NULL, 16)); + sprintf(command_data_str, "{\"0:U16\": %ld}", + strtoul((const char *)(req_handle->request_data) + 1, NULL, 16)); } else { ESP_LOGE(TAG, "Unsupported command"); + return; } } else { ESP_LOGE(TAG, "Unsupported cluster"); + return; } + client::interaction::invoke::send_group_request(fabric_index, req_handle->command_path, command_data_str); } static void app_driver_button_toggle_cb(void *arg, void *data)