mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
esp-matter/components: Add delegate for mode-select cluster
This commit is contained in:
@@ -2639,6 +2639,10 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
|
||||
return NULL;
|
||||
}
|
||||
if (flags & CLUSTER_FLAG_SERVER) {
|
||||
if (config -> delegate != nullptr) {
|
||||
static const auto delegate_init_cb = ModeSelectDelegateInitCB;
|
||||
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
|
||||
}
|
||||
static const auto plugin_server_init_cb = CALL_ONCE(MatterModeSelectPluginServerInitCallback);
|
||||
set_plugin_server_init_callback(cluster, plugin_server_init_cb);
|
||||
add_function_list(cluster, function_list, function_flags);
|
||||
|
||||
@@ -683,7 +683,8 @@ typedef struct config {
|
||||
const nullable<uint16_t> standard_namespace;
|
||||
uint8_t current_mode;
|
||||
feature::on_off::config_t on_off;
|
||||
config() : mode_select_description{0}, standard_namespace(), current_mode(0) {}
|
||||
void *delegate;
|
||||
config() : mode_select_description{0}, standard_namespace(), current_mode(0), delegate(nullptr) {}
|
||||
} config_t;
|
||||
|
||||
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features);
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#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>
|
||||
#include <app/clusters/mode-select-server//supported-modes-manager.h>
|
||||
|
||||
using namespace chip::app::Clusters;
|
||||
namespace esp_matter {
|
||||
@@ -343,6 +344,16 @@ void KeypadInputDelegateInitCB(void *delegate, uint16_t endpoint_id)
|
||||
KeypadInput::SetDefaultDelegate(endpoint_id, keypad_input_delegate);
|
||||
}
|
||||
|
||||
void ModeSelectDelegateInitCB(void *delegate, uint16_t endpoint_id)
|
||||
{
|
||||
if(delegate == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ModeSelect::SupportedModesManager *supported_modes_manager = static_cast<ModeSelect::SupportedModesManager*>(delegate);
|
||||
ModeSelect::setSupportedModesManager(supported_modes_manager);
|
||||
}
|
||||
|
||||
} // namespace delegate_cb
|
||||
|
||||
} // namespace cluster
|
||||
|
||||
@@ -44,6 +44,7 @@ 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);
|
||||
void ModeSelectDelegateInitCB(void *delegate, uint16_t endpoint_id);
|
||||
} // namespace delegate_cb
|
||||
|
||||
} // namespace cluster
|
||||
|
||||
@@ -44,6 +44,7 @@ List of clusters with delegate:
|
||||
- Account Login Cluster.
|
||||
- Wake On Lan Cluster.
|
||||
- Target Navigator Cluster.
|
||||
- Mode Select Cluster.
|
||||
|
||||
9.1.1 Mode Base Cluster
|
||||
-----------------------
|
||||
@@ -207,6 +208,14 @@ ModeWaterHeater, ModeRefrigerator, ModeLaundryWasher and ModeMicrowaveOven.
|
||||
|
||||
`Keypad Input`_, `Keypad Input Delegate`_
|
||||
|
||||
9.1.20 Mode Select Cluster
|
||||
--------------------------
|
||||
|
||||
.. csv-table::
|
||||
:header: "Delegate Class", "Reference Implementation"
|
||||
|
||||
`Mode Select`_, `Mode Select Delegate`_
|
||||
|
||||
|
||||
.. note::
|
||||
Make sure that after implementing delegate class, you set the delegate class pointer at the time of creating cluster.
|
||||
@@ -258,3 +267,5 @@ ModeWaterHeater, ModeRefrigerator, ModeLaundryWasher and ModeMicrowaveOven.
|
||||
.. _`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
|
||||
.. _`Mode Select`: https://github.com/project-chip/connectedhomeip/blob/master/src/app/clusters/mode-select-server/supported-modes-manager.h
|
||||
.. _`Mode Select Delegate`: https://github.com/project-chip/connectedhomeip/blob/master/examples/all-clusters-app/all-clusters-common/include/static-supported-modes-manager.h
|
||||
|
||||
Reference in New Issue
Block a user