added remote_node_id and attribute_path_param in read_done_cb

This commit is contained in:
Sayon Deep
2023-11-27 23:07:33 +05:30
parent 42ee6b551e
commit cc1107540b
3 changed files with 17 additions and 18 deletions
@@ -110,14 +110,17 @@ void read_command::OnAttributeData(const chip::app::ConcreteDataAttributePath &p
ESP_LOGE(TAG, "Response Failure: No Data");
return;
}
error = DataModelLogger::LogAttribute(path, data);
if (CHIP_NO_ERROR != error) {
ESP_LOGE(TAG, "Response Failure: Can not decode Data");
}
if (attribute_data_cb) {
attribute_data_cb(m_node_id, path, data);
}
else{
error = DataModelLogger::LogAttribute(path, data);
if (CHIP_NO_ERROR != error) {
ESP_LOGE(TAG, "Response Failure: Can not decode Data");
}
}
}
void read_command::OnEventData(const chip::app::EventHeader &event_header, chip::TLV::TLVReader *data,
@@ -161,8 +164,8 @@ void read_command::OnDone(ReadClient *apReadClient)
{
ESP_LOGI(TAG, "read done");
if (attribute_data_ondone_cb) {
attribute_data_ondone_cb();
if (read_done_cb) {
read_done_cb(m_node_id,m_attr_path);
}
chip::Platform::Delete(apReadClient);
chip::Platform::Delete(this);
@@ -39,22 +39,18 @@ 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, attribute_report_ondone_cb_t attribute_done_cb, event_report_cb_t event_cb)
read_command_type_t command_type, attribute_report_cb_t attribute_cb, read_done_cb_t read_cb_done, 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)
, read_done_cb(read_cb_done)
, event_data_cb(event_cb)
{
if (command_type == READ_ATTRIBUTE) {
m_attr_path.mEndpointId = endpoint_id;
m_attr_path.mClusterId = cluster_id;
m_attr_path.mAttributeId = attribute_or_event_id;
if(m_attr_path.mAttributeId == 0xFFFFFFFF)
m_attr_path.SetWildcardAttributeId();
if (command_type == READ_ATTRIBUTE) {
m_attr_path = AttributePathParams(endpoint_id, cluster_id, attribute_or_event_id);
} else if (command_type == READ_EVENT) {
m_event_path.mEndpointId = endpoint_id;
m_event_path.mClusterId = cluster_id;
@@ -62,8 +58,6 @@ public:
}
}
bool mOnDone = false;
~read_command() {}
esp_err_t send_command();
@@ -88,6 +82,7 @@ public:
void OnDeallocatePaths(chip::app::ReadPrepareParams &&aReadPrepareParams) override;
void OnDone(ReadClient *apReadClient) override;
private:
uint64_t m_node_id;
@@ -106,7 +101,7 @@ private:
chip::Callback::Callback<chip::OnDeviceConnectionFailure> on_device_connection_failure_cb;
attribute_report_cb_t attribute_data_cb;
attribute_report_ondone_cb_t attribute_data_ondone_cb;
read_done_cb_t read_done_cb;
event_report_cb_t event_data_cb;
};
@@ -17,6 +17,7 @@
#include <stdint.h>
#include <app/ConcreteAttributePath.h>
#include <app/AttributePathParams.h>
#include <app/EventHeader.h>
#include <lib/core/TLVReader.h>
@@ -29,7 +30,7 @@ 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 (*)();
using read_done_cb_t = void (*)(uint64_t remote_node_id, const chip::app::AttributePathParams &path);
#if !CONFIG_ESP_MATTER_COMMISSIONER_ENABLE
/**