From 42ee6b551ea36d8437e27bbe8594fcea2d71f25b Mon Sep 17 00:00:00 2001 From: Sayon Deep Date: Thu, 23 Nov 2023 22:37:49 +0530 Subject: [PATCH] added attribute_read_done_cb for read command in esp_matter_controller component --- .../esp_matter_controller_read_command.cpp | 8 ++++++-- .../esp_matter_controller_read_command.h | 7 ++++++- .../esp_matter_controller/esp_matter_controller_utils.h | 2 ++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/components/esp_matter_controller/esp_matter_controller_read_command.cpp b/components/esp_matter_controller/esp_matter_controller_read_command.cpp index 7589dc06c..41b473846 100644 --- a/components/esp_matter_controller/esp_matter_controller_read_command.cpp +++ b/components/esp_matter_controller/esp_matter_controller_read_command.cpp @@ -160,6 +160,10 @@ void read_command::OnDeallocatePaths(chip::app::ReadPrepareParams &&aReadPrepare void read_command::OnDone(ReadClient *apReadClient) { ESP_LOGI(TAG, "read done"); + + if (attribute_data_ondone_cb) { + attribute_data_ondone_cb(); + } chip::Platform::Delete(apReadClient); chip::Platform::Delete(this); } @@ -167,7 +171,7 @@ void read_command::OnDone(ReadClient *apReadClient) esp_err_t send_read_attr_command(uint64_t node_id, uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id) { read_command *cmd = chip::Platform::New(node_id, endpoint_id, cluster_id, attribute_id, - READ_ATTRIBUTE, nullptr, nullptr); + READ_ATTRIBUTE, nullptr, nullptr,nullptr); if (!cmd) { ESP_LOGE(TAG, "Failed to alloc memory for read_command"); return ESP_ERR_NO_MEM; @@ -179,7 +183,7 @@ esp_err_t send_read_attr_command(uint64_t node_id, uint16_t endpoint_id, uint32_ esp_err_t send_read_event_command(uint64_t node_id, uint16_t endpoint_id, uint32_t cluster_id, uint32_t event_id) { read_command *cmd = - chip::Platform::New(node_id, endpoint_id, cluster_id, event_id, READ_EVENT, nullptr, nullptr); + chip::Platform::New(node_id, endpoint_id, cluster_id, event_id, READ_EVENT, nullptr,nullptr, nullptr); if (!cmd) { ESP_LOGE(TAG, "Failed to alloc memory for read_command"); return ESP_ERR_NO_MEM; diff --git a/components/esp_matter_controller/esp_matter_controller_read_command.h b/components/esp_matter_controller/esp_matter_controller_read_command.h index 0005e416e..a097136be 100644 --- a/components/esp_matter_controller/esp_matter_controller_read_command.h +++ b/components/esp_matter_controller/esp_matter_controller_read_command.h @@ -39,13 +39,14 @@ typedef enum { class read_command : public ReadClient::Callback { public: read_command(uint64_t node_id, uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_or_event_id, - read_command_type_t command_type, attribute_report_cb_t attribute_cb, event_report_cb_t event_cb) + read_command_type_t command_type, attribute_report_cb_t attribute_cb, attribute_report_ondone_cb_t attribute_done_cb, event_report_cb_t event_cb) : m_node_id(node_id) , m_command_type(command_type) , m_buffered_read_cb(*this) , on_device_connected_cb(on_device_connected_fcn, this) , on_device_connection_failure_cb(on_device_connection_failure_fcn, this) , attribute_data_cb(attribute_cb) + , attribute_data_ondone_cb(attribute_done_cb) , event_data_cb(event_cb) { if (command_type == READ_ATTRIBUTE) { @@ -61,6 +62,8 @@ public: } } + bool mOnDone = false; + ~read_command() {} esp_err_t send_command(); @@ -103,7 +106,9 @@ private: chip::Callback::Callback on_device_connection_failure_cb; attribute_report_cb_t attribute_data_cb; + attribute_report_ondone_cb_t attribute_data_ondone_cb; event_report_cb_t event_data_cb; + }; esp_err_t send_read_attr_command(uint64_t node_id, uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id); diff --git a/components/esp_matter_controller/esp_matter_controller_utils.h b/components/esp_matter_controller/esp_matter_controller_utils.h index 7cfae016a..debf39f8e 100644 --- a/components/esp_matter_controller/esp_matter_controller_utils.h +++ b/components/esp_matter_controller/esp_matter_controller_utils.h @@ -29,6 +29,8 @@ using event_report_cb_t = void (*)(uint64_t remote_node_id, const chip::app::Eve using subscribe_done_cb_t = void (*)(uint64_t remote_node_id); using subscribe_failure_cb_t = void (*)(void *subscribe_command); +using attribute_report_ondone_cb_t = void (*)(); + #if !CONFIG_ESP_MATTER_COMMISSIONER_ENABLE /** * @brief Set the fabric index of the controller.