Add cluster delegate init callback

This commit is contained in:
Rohit Jadhav
2024-05-07 13:07:17 +05:30
parent 8692a149b8
commit c00d022ebf
7 changed files with 29 additions and 24 deletions
@@ -2916,22 +2916,6 @@ attribute_t *create_selected_dryness_level(cluster_t *cluster, nullable<uint8_t>
} /* attribute */
} /* laundry_dryer_controls */
namespace dish_washer_mode {
namespace attribute {
attribute_t *create_supported_modes(cluster_t *cluster, const uint8_t * value, uint16_t length, uint16_t count)
{
return esp_matter::attribute::create(cluster, LaundryWasherMode::Attributes::SupportedModes::Id, ATTRIBUTE_FLAG_NONE, esp_matter_array((uint8_t*)value, length, count));
}
attribute_t *create_current_mode(cluster_t *cluster, uint8_t value)
{
return esp_matter::attribute::create(cluster, LaundryWasherMode::Attributes::CurrentMode::Id, ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_uint8(value));
}
} /* attribute */
} /* dish_washer_mode */
namespace smoke_co_alarm {
namespace attribute {
attribute_t *create_expressed_state(cluster_t *cluster, uint8_t value)
@@ -710,13 +710,6 @@ attribute_t *create_selected_dryness_level(cluster_t *cluster, nullable<uint8_t>
} /* attribute */
} /* laundry_dryer_controls */
namespace dish_washer_mode {
namespace attribute {
attribute_t *create_supported_modes(cluster_t *cluster, const uint8_t * value, uint16_t length, uint16_t count);
attribute_t *create_current_mode(cluster_t *cluster, uint8_t value);
} /* attribute */
} /* dish_washer_mode */
namespace smoke_co_alarm {
namespace attribute {
attribute_t *create_expressed_state(cluster_t *cluster, uint8_t value);
@@ -2349,6 +2349,10 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
}
if (flags & CLUSTER_FLAG_SERVER) {
if (config -> delegate != nullptr) {
static const auto delegate_init_cb = LaundryDryerControlsDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
add_function_list(cluster, function_list, function_flags);
}
if (flags & CLUSTER_FLAG_CLIENT) {
+2 -1
View File
@@ -569,7 +569,8 @@ namespace laundry_dryer_controls {
typedef struct config {
uint16_t cluster_revision;
nullable<uint8_t> selected_dryness_level;
config() : cluster_revision(1), selected_dryness_level(0) {}
void *delegate;
config() : cluster_revision(1), selected_dryness_level(0), delegate(nullptr) {}
} config_t;
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
@@ -22,6 +22,7 @@
#include <app/clusters/operational-state-server/operational-state-server.h>
#include <app/clusters/resource-monitoring-server/resource-monitoring-server.h>
#include <app/clusters/fan-control-server/fan-control-server.h>
#include <app/clusters/laundry-dryer-controls-server/laundry-dryer-controls-server.h>
using namespace chip::app::Clusters;
namespace esp_matter {
@@ -183,6 +184,16 @@ void ActivatedCarbonFilterMonitoringDelegateInitCB(void *delegate, uint16_t endp
activatedCarbonFilterMonitoringInstance->Init();
}
void LaundryDryerControlsDelegateInitCB(void *delegate, uint16_t endpoint_id)
{
if(delegate == nullptr)
{
return;
}
LaundryDryerControls::Delegate *laundry_dryer_controls_delegate = static_cast<LaundryDryerControls::Delegate*>(delegate);
LaundryDryerControls::LaundryDryerControlsServer::SetDefaultDelegate(endpoint_id, laundry_dryer_controls_delegate);
}
} // namespace delegate_cb
} // namespace cluster
@@ -30,6 +30,7 @@ void OperationalStateDelegateInitCB(void *delegate, uint16_t endpoint_id);
void FanControlDelegateInitCB(void *delegate, uint16_t endpoint_id);
void HepaFilterMonitoringDelegateInitCB(void *delegate, uint16_t endpoint_id);
void ActivatedCarbonFilterMonitoringDelegateInitCB(void *delegate, uint16_t endpoint_id);
void LaundryDryerControlsDelegateInitCB(void *delegate, uint16_t endpoint_id);
} // namespace delegate_cb
} // namespace cluster