mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
components/esp-matter: Add delegate support for clusters which needs delegate
This commit is contained in:
@@ -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 */
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -31,6 +31,10 @@
|
||||
#include <app/clusters/application-basic-server/application-basic-server.h>
|
||||
#include <app/clusters/power-topology-server/power-topology-server.h>
|
||||
#include <app/clusters/electrical-power-measurement-server/electrical-power-measurement-server.h>
|
||||
#include <app/clusters/laundry-washer-controls-server/laundry-washer-controls-server.h>
|
||||
#include <app/clusters/window-covering-server/window-covering-server.h>
|
||||
#include <app/clusters/dishwasher-alarm-server/dishwasher-alarm-server.h>
|
||||
#include <app/clusters/keypad-input-server/keypad-input-server.h>
|
||||
|
||||
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<LaundryWasherControls::Delegate*>(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<WindowCovering::Delegate*>(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<DishwasherAlarm::Delegate*>(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<KeypadInput::Delegate*>(delegate);
|
||||
KeypadInput::SetDefaultDelegate(endpoint_id, keypad_input_delegate);
|
||||
}
|
||||
|
||||
} // namespace delegate_cb
|
||||
|
||||
} // namespace cluster
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user