From c00d022ebffc4fad7a0fea8cde2ae12b01e044cd Mon Sep 17 00:00:00 2001 From: Rohit Jadhav Date: Tue, 7 May 2024 13:07:17 +0530 Subject: [PATCH] Add cluster delegate init callback --- components/esp_matter/esp_matter_attribute.cpp | 16 ---------------- components/esp_matter/esp_matter_attribute.h | 7 ------- components/esp_matter/esp_matter_cluster.cpp | 4 ++++ components/esp_matter/esp_matter_cluster.h | 3 ++- .../esp_matter/esp_matter_delegate_callbacks.cpp | 11 +++++++++++ .../esp_matter/esp_matter_delegate_callbacks.h | 1 + docs/en/app_guide.rst | 11 +++++++++++ 7 files changed, 29 insertions(+), 24 deletions(-) diff --git a/components/esp_matter/esp_matter_attribute.cpp b/components/esp_matter/esp_matter_attribute.cpp index 42236110e..815562d64 100644 --- a/components/esp_matter/esp_matter_attribute.cpp +++ b/components/esp_matter/esp_matter_attribute.cpp @@ -2916,22 +2916,6 @@ attribute_t *create_selected_dryness_level(cluster_t *cluster, nullable } /* 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) diff --git a/components/esp_matter/esp_matter_attribute.h b/components/esp_matter/esp_matter_attribute.h index 6f280aa29..7ede901ff 100644 --- a/components/esp_matter/esp_matter_attribute.h +++ b/components/esp_matter/esp_matter_attribute.h @@ -710,13 +710,6 @@ attribute_t *create_selected_dryness_level(cluster_t *cluster, nullable } /* 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); diff --git a/components/esp_matter/esp_matter_cluster.cpp b/components/esp_matter/esp_matter_cluster.cpp index b3537d911..a0d817521 100644 --- a/components/esp_matter/esp_matter_cluster.cpp +++ b/components/esp_matter/esp_matter_cluster.cpp @@ -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) { diff --git a/components/esp_matter/esp_matter_cluster.h b/components/esp_matter/esp_matter_cluster.h index 821146975..93b9270e5 100644 --- a/components/esp_matter/esp_matter_cluster.h +++ b/components/esp_matter/esp_matter_cluster.h @@ -569,7 +569,8 @@ namespace laundry_dryer_controls { typedef struct config { uint16_t cluster_revision; nullable 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); diff --git a/components/esp_matter/esp_matter_delegate_callbacks.cpp b/components/esp_matter/esp_matter_delegate_callbacks.cpp index 40b507a8e..d70b3ead7 100644 --- a/components/esp_matter/esp_matter_delegate_callbacks.cpp +++ b/components/esp_matter/esp_matter_delegate_callbacks.cpp @@ -22,6 +22,7 @@ #include #include #include +#include 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(delegate); + LaundryDryerControls::LaundryDryerControlsServer::SetDefaultDelegate(endpoint_id, laundry_dryer_controls_delegate); +} + } // namespace delegate_cb } // namespace cluster diff --git a/components/esp_matter/esp_matter_delegate_callbacks.h b/components/esp_matter/esp_matter_delegate_callbacks.h index ca0cec698..f72fc6b2d 100644 --- a/components/esp_matter/esp_matter_delegate_callbacks.h +++ b/components/esp_matter/esp_matter_delegate_callbacks.h @@ -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 diff --git a/docs/en/app_guide.rst b/docs/en/app_guide.rst index 9f47f19d5..343d0b3b4 100644 --- a/docs/en/app_guide.rst +++ b/docs/en/app_guide.rst @@ -101,6 +101,15 @@ ModeWaterHeater, ModeRefrigerator, ModeLaundryWasher and ModeMicrowaveOven. `Resource Monitoring`_, `Resource Monitoring Delegate`_ +9.1.2 Laundry Dryer Controls Cluster +------------------------------------ + +.. csv-table:: Delegate and its impl + :header: "Delegate Class", "Reference Implementation" + + `Laundry Dryer Controls`_, `Laundry Dryer Controls Delegate`_ + + .. note:: Make sure that after implementing delegate class, you set the delegate class pointer at the time of creating cluster. @@ -126,3 +135,5 @@ ModeWaterHeater, ModeRefrigerator, ModeLaundryWasher and ModeMicrowaveOven. .. _`Fan Control Delegate`: https://github.com/project-chip/connectedhomeip/blob/master/examples/all-clusters-app/all-clusters-common/src/fan-stub.cpp .. _`Resource Monitoring`: https://github.com/project-chip/connectedhomeip/blob/master/src/app/clusters/resource-monitoring-server/resource-monitoring-server.h .. _`Resource Monitoring Delegate`: https://github.com/project-chip/connectedhomeip/blob/master/examples/all-clusters-app/all-clusters-common/include/resource-monitoring-delegates.h +.. _`Laundry Dryer Controls`: https://github.com/project-chip/connectedhomeip/blob/master/src/app/clusters/laundry-dryer-controls-server/laundry-dryer-controls-server.h +.. _`Laundry Dryer Controls Delegate`: https://github.com/project-chip/connectedhomeip/blob/master/examples/all-clusters-app/all-clusters-common/include/laundry-dryer-controls-delegate-impl.h