diff --git a/components/esp_matter/esp_matter_cluster.cpp b/components/esp_matter/esp_matter_cluster.cpp index 5c226e335..679ae64fb 100644 --- a/components/esp_matter/esp_matter_cluster.cpp +++ b/components/esp_matter/esp_matter_cluster.cpp @@ -2313,6 +2313,10 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } if (flags & CLUSTER_FLAG_SERVER) { + if (config && config -> delegate != nullptr) { + static const auto delegate_init_cb = LaundryWasherControlsDelegateInitCB; + set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate); + } add_function_list(cluster, function_list, function_flags); } if (flags & CLUSTER_FLAG_CLIENT) { @@ -2439,6 +2443,10 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } if (flags & CLUSTER_FLAG_SERVER) { + if (config && config -> delegate != nullptr) { + static const auto delegate_init_cb = DishwasherAlarmDelegateInitCB; + set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate); + } add_function_list(cluster, function_list, function_flags); } if (flags & CLUSTER_FLAG_CLIENT) { @@ -2595,6 +2603,10 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_ if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterWindowCoveringPluginServerInitCallback); set_plugin_server_init_callback(cluster, plugin_server_init_cb); + if (config && config -> delegate != nullptr) { + static const auto delegate_init_cb = WindowCoveringDelegateInitCB; + set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate); + } add_function_list(cluster, function_list, function_flags); } if (flags & CLUSTER_FLAG_CLIENT) { @@ -3656,6 +3668,10 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } if (flags & CLUSTER_FLAG_SERVER) { + if (config && config -> delegate != nullptr) { + static const auto delegate_init_cb = KeypadInputDelegateInitCB; + set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate); + } add_function_list(cluster, function_list, function_flags); /* Attributes managed internally */ diff --git a/components/esp_matter/esp_matter_cluster.h b/components/esp_matter/esp_matter_cluster.h index 73e1b9c6b..b3cae5d4b 100644 --- a/components/esp_matter/esp_matter_cluster.h +++ b/components/esp_matter/esp_matter_cluster.h @@ -560,7 +560,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); namespace laundry_washer_controls { typedef struct config { uint16_t cluster_revision; - config() : cluster_revision(1) {} + void *delegate; + config() : cluster_revision(1), delegate(nullptr) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); @@ -591,7 +592,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); namespace dish_washer_alarm { typedef struct config { uint16_t cluster_revision; - config() : cluster_revision(1) {} + void *delegate; + config() : cluster_revision(1), delegate(nullptr) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); @@ -630,7 +632,8 @@ typedef struct config { const uint8_t end_product_type; uint8_t mode; feature::lift::config_t lift; - config(uint8_t end_product_type = 0) : cluster_revision(5), type(0), config_status(0), operational_status(0), end_product_type(end_product_type), mode(0) {} + void *delegate; + config(uint8_t end_product_type = 0) : cluster_revision(5), type(0), config_status(0), operational_status(0), end_product_type(end_product_type), mode(0), delegate(nullptr) {} } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features); @@ -892,7 +895,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); namespace keypad_input { typedef struct config { uint16_t cluster_revision; - config() : cluster_revision(1) {} + void *delegate; + config() : cluster_revision(1), 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 48aa231e9..79e06f051 100644 --- a/components/esp_matter/esp_matter_delegate_callbacks.cpp +++ b/components/esp_matter/esp_matter_delegate_callbacks.cpp @@ -31,6 +31,10 @@ #include #include #include +#include +#include +#include +#include using namespace chip::app::Clusters; namespace esp_matter { @@ -299,6 +303,46 @@ void ElectricalPowerMeasurementDelegateInitCB(void *delegate, uint16_t endpoint_ electricalPowerMeasurementInstance->Init(); } +void LaundryWasherControlsDelegateInitCB(void *delegate, uint16_t endpoint_id) +{ + if(delegate == nullptr) + { + return; + } + LaundryWasherControls::Delegate *laundry_washer_controls_delegate = static_cast(delegate); + LaundryWasherControls::LaundryWasherControlsServer::SetDefaultDelegate(endpoint_id, laundry_washer_controls_delegate); +} + +void WindowCoveringDelegateInitCB(void *delegate, uint16_t endpoint_id) +{ + if(delegate == nullptr) + { + return; + } + WindowCovering::Delegate *window_covering_delegate = static_cast(delegate); + WindowCovering::SetDefaultDelegate(endpoint_id, window_covering_delegate); +} + +void DishwasherAlarmDelegateInitCB(void *delegate, uint16_t endpoint_id) +{ + if(delegate == nullptr) + { + return; + } + DishwasherAlarm::Delegate *dishwasher_alarm_delegate = static_cast(delegate); + DishwasherAlarm::SetDefaultDelegate(endpoint_id, dishwasher_alarm_delegate); +} + +void KeypadInputDelegateInitCB(void *delegate, uint16_t endpoint_id) +{ + if(delegate == nullptr) + { + return; + } + KeypadInput::Delegate *keypad_input_delegate = static_cast(delegate); + KeypadInput::SetDefaultDelegate(endpoint_id, keypad_input_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 26b979e8c..1db1ad4da 100644 --- a/components/esp_matter/esp_matter_delegate_callbacks.h +++ b/components/esp_matter/esp_matter_delegate_callbacks.h @@ -40,6 +40,10 @@ void TimeSynchronizationDelegateInitCB(void *delegate, uint16_t endpoint_id); void ApplicationBasicDelegateInitCB(void *delegate, uint16_t endpoint_id); void PowerTopologyDelegateInitCB(void *delegate, uint16_t endpoint_id); void ElectricalPowerMeasurementDelegateInitCB(void *delegate, uint16_t endpoint_id); +void LaundryWasherControlsDelegateInitCB(void *delegate, uint16_t endpoint_id); +void WindowCoveringDelegateInitCB(void *delegate, uint16_t endpoint_id); +void DishwasherAlarmDelegateInitCB(void *delegate, uint16_t endpoint_id); +void KeypadInputDelegateInitCB(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 ad5169c8f..49dd29c1d 100644 --- a/docs/en/app_guide.rst +++ b/docs/en/app_guide.rst @@ -175,6 +175,38 @@ ModeWaterHeater, ModeRefrigerator, ModeLaundryWasher and ModeMicrowaveOven. `Electrical Power Measurement`_, `Electrical Power Measurement Delegate`_ +9.1.16 Laundry Washer Controls Cluster +-------------------------------------- + +.. csv-table:: + :header: "Delegate Class", "Reference Implementation" + + `Laundry Washer Controls`_, `Laundry Washer Controls Delegate`_ + +9.1.17 Window Covering Cluster +------------------------------ + +.. csv-table:: + :header: "Delegate Class", "Reference Implementation" + + `Window Covering`_, `Window Covering Delegate`_ + +9.1.18 Dishwasher Alarm Cluster +------------------------------- + +.. csv-table:: + :header: "Delegate Class", "Reference Implementation" + + `Dishwasher Alarm`_, `Dishwasher Alarm Delegate`_ + +9.1.19 Keypad Input Cluster +--------------------------- + +.. csv-table:: + :header: "Delegate Class", "Reference Implementation" + + `Keypad Input`_, `Keypad Input Delegate`_ + .. note:: Make sure that after implementing delegate class, you set the delegate class pointer at the time of creating cluster. @@ -218,3 +250,11 @@ ModeWaterHeater, ModeRefrigerator, ModeLaundryWasher and ModeMicrowaveOven. .. _`Power Topology Delegate`: https://github.com/project-chip/connectedhomeip/blob/master/examples/energy-management-app/energy-management-common/include/PowerTopologyDelegate.h .. _`Electrical Power Measurement`: https://github.com/project-chip/connectedhomeip/blob/master/src/app/clusters/electrical-power-measurement-server/electrical-power-measurement-server.h .. _`Electrical Power Measurement Delegate`: https://github.com/project-chip/connectedhomeip/blob/master/examples/energy-management-app/energy-management-common/include/ElectricalPowerMeasurementDelegate.h +.. _`Laundry Washer Controls`: https://github.com/project-chip/connectedhomeip/blob/master/src/app/clusters/laundry-washer-controls-server/laundry-washer-controls-server.h +.. _`Laundry Washer Controls Delegate`: https://github.com/project-chip/connectedhomeip/blob/master/examples/all-clusters-app/all-clusters-common/include/laundry-washer-controls-delegate-impl.h +.. _`Window Covering`: https://github.com/project-chip/connectedhomeip/blob/master/src/app/clusters/window-covering-server/window-covering-server.h +.. _`Window Covering Delegate`: https://github.com/project-chip/connectedhomeip/blob/master/examples/all-clusters-app/linux/WindowCoveringManager.h +.. _`Dishwasher Alarm`: https://github.com/project-chip/connectedhomeip/blob/master/src/app/clusters/dishwasher-alarm-server/dishwasher-alarm-server.h +.. _`Dishwasher Alarm Delegate`: https://github.com/project-chip/connectedhomeip/blob/master/examples/all-clusters-app/all-clusters-common/src/dishwasher-alarm-stub.cpp +.. _`Keypad Input`: https://github.com/project-chip/connectedhomeip/blob/master/src/app/clusters/keypad-input-server/keypad-input-server.h +.. _`Keypad Input Delegate`: https://github.com/project-chip/connectedhomeip/blob/master/examples/chef/common/clusters/keypad-input/KeypadInputManager.h