mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
Add support of delegate to derived clusters of mode base cluster along with the documentation
This commit is contained in:
committed by
Hrishikesh Dhayagude
parent
3ddea0493b
commit
12fc797e55
@@ -16,6 +16,7 @@
|
||||
#include <esp_matter_attribute.h>
|
||||
#include <esp_matter.h>
|
||||
#include <esp_matter_core.h>
|
||||
#include <app/clusters/mode-base-server/mode-base-cluster-objects.h>
|
||||
|
||||
static const char *TAG = "esp_matter_attribute";
|
||||
|
||||
@@ -2866,22 +2867,6 @@ attribute_t *create_operational_error(cluster_t *cluster, uint8_t value)
|
||||
} /* attribute */
|
||||
} /* operational_state */
|
||||
|
||||
namespace laundry_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 */
|
||||
} /* laundry_washer_mode */
|
||||
|
||||
namespace laundry_washer_controls {
|
||||
namespace attribute {
|
||||
|
||||
@@ -2913,22 +2898,6 @@ attribute_t *create_supported_rinses(cluster_t *cluster, uint8_t *value, uint16_
|
||||
} /* attribute */
|
||||
} /* laundry_washer_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)
|
||||
@@ -4292,37 +4261,30 @@ attribute_t *create_supported(cluster_t *cluster, uint32_t value)
|
||||
} /* attribute */
|
||||
} /* refrigerator_alarm */
|
||||
|
||||
namespace rvc_run_mode {
|
||||
namespace mode_base {
|
||||
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, RvcRunMode::Attributes::SupportedModes::Id, ATTRIBUTE_FLAG_NONE, esp_matter_array((uint8_t*)value, length, count));
|
||||
return esp_matter::attribute::create(cluster, ModeBase::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, RvcRunMode::Attributes::CurrentMode::Id, ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_uint8(value));
|
||||
return esp_matter::attribute::create(cluster, ModeBase::Attributes::CurrentMode::Id, ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_uint8(value));
|
||||
}
|
||||
|
||||
} /* attribute */
|
||||
} /* rvc_run_mode */
|
||||
|
||||
namespace rvc_clean_mode {
|
||||
namespace attribute {
|
||||
|
||||
attribute_t *create_supported_modes(cluster_t *cluster, const uint8_t * value, uint16_t length, uint16_t count)
|
||||
attribute_t *create_start_up_mode(cluster_t *cluster, nullable<uint8_t> value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, RvcCleanMode::Attributes::SupportedModes::Id, ATTRIBUTE_FLAG_NONE, esp_matter_array((uint8_t*)value, length, count));
|
||||
return esp_matter::attribute::create(cluster, ModeBase::Attributes::StartUpMode::Id, ATTRIBUTE_FLAG_WRITABLE | ATTRIBUTE_FLAG_NULLABLE | ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_nullable_uint8(value));
|
||||
}
|
||||
|
||||
attribute_t *create_current_mode(cluster_t *cluster, uint8_t value)
|
||||
attribute_t *create_on_mode(cluster_t *cluster, nullable<uint8_t> value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, RvcCleanMode::Attributes::CurrentMode::Id, ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_uint8(value));
|
||||
return esp_matter::attribute::create(cluster, ModeBase::Attributes::OnMode::Id, ATTRIBUTE_FLAG_WRITABLE | ATTRIBUTE_FLAG_NULLABLE | ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_nullable_uint8(value));
|
||||
}
|
||||
|
||||
} /* attribute */
|
||||
} /* rvc_clean_mode */
|
||||
} /* mode_base */
|
||||
|
||||
namespace power_topology {
|
||||
namespace attribute {
|
||||
|
||||
@@ -694,13 +694,6 @@ attribute_t *create_expiring_user_timeout(cluster_t *cluster, uint16_t value);
|
||||
} /* attribute */
|
||||
} /* door_lock */
|
||||
|
||||
namespace laundry_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 */
|
||||
} /* laundry_washer_mode */
|
||||
|
||||
namespace laundry_washer_controls {
|
||||
namespace attribute {
|
||||
attribute_t *create_spin_speeds(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count);
|
||||
@@ -710,13 +703,6 @@ attribute_t *create_supported_rinses(cluster_t *cluster, uint8_t *value, uint16_
|
||||
} /* attribute */
|
||||
} /* laundry_washer_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);
|
||||
@@ -975,19 +961,14 @@ attribute_t *create_supported(cluster_t *cluster, uint32_t value);
|
||||
} /* attribute */
|
||||
} /* refrigerator_alarm */
|
||||
|
||||
namespace rvc_run_mode {
|
||||
namespace mode_base {
|
||||
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_t *create_start_up_mode(cluster_t *cluster, nullable<uint8_t> value);
|
||||
attribute_t *create_on_mode(cluster_t *cluster, nullable<uint8_t> value);
|
||||
} /* attribute */
|
||||
} /* rvc_run_mode */
|
||||
|
||||
namespace rvc_clean_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 */
|
||||
} /* rvc_clean_mode */
|
||||
} /* mode_base */
|
||||
|
||||
namespace power_topology {
|
||||
namespace attribute {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include <esp_matter_attribute.h>
|
||||
#include <esp_matter_cluster.h>
|
||||
#include <esp_matter_core.h>
|
||||
#include <esp_matter_delegate_callbacks.h>
|
||||
|
||||
#include <app-common/zap-generated/callback.h>
|
||||
#include <app/PluginApplicationCallbacks.h>
|
||||
@@ -24,6 +25,7 @@
|
||||
static const char *TAG = "esp_matter_cluster";
|
||||
|
||||
using namespace chip::app::Clusters;
|
||||
using namespace esp_matter::cluster::delegate_cb;
|
||||
|
||||
#define CALL_ONCE(cb) \
|
||||
[](){ \
|
||||
@@ -2245,6 +2247,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 = LaundryWasherModeDelegateInitCB;
|
||||
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
|
||||
}
|
||||
add_function_list(cluster, function_list, function_flags);
|
||||
}
|
||||
if (flags & CLUSTER_FLAG_CLIENT) {
|
||||
@@ -2261,7 +2267,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
|
||||
/* Attributes not managed internally */
|
||||
if (config) {
|
||||
global::attribute::create_cluster_revision(cluster, config->cluster_revision);
|
||||
attribute::create_current_mode(cluster, config->current_mode);
|
||||
mode_base::attribute::create_current_mode(cluster, config->current_mode);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes.");
|
||||
}
|
||||
@@ -2331,6 +2337,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 = DishWasherModeDelegateInitCB;
|
||||
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
|
||||
}
|
||||
/* Attributes managed internally */
|
||||
global::attribute::create_feature_map(cluster, 0);
|
||||
#if CHIP_CONFIG_ENABLE_EVENTLIST_ATTRIBUTE
|
||||
@@ -2340,7 +2350,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
|
||||
/* Attributes not managed internally */
|
||||
if (config) {
|
||||
global::attribute::create_cluster_revision(cluster, config->cluster_revision);
|
||||
attribute::create_current_mode(cluster, config->current_mode);
|
||||
mode_base::attribute::create_current_mode(cluster, config->current_mode);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes.");
|
||||
}
|
||||
@@ -3306,6 +3316,48 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
|
||||
}
|
||||
} /* refrigerator_alarm */
|
||||
|
||||
namespace refrigerator_and_tcc_mode {
|
||||
const function_generic_t *function_list = NULL;
|
||||
const int function_flags = CLUSTER_FLAG_NONE;
|
||||
|
||||
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
|
||||
{
|
||||
cluster_t *cluster = cluster::create(endpoint, RefrigeratorAndTemperatureControlledCabinetMode::Id, flags);
|
||||
if (!cluster) {
|
||||
ESP_LOGE(TAG, "Could not create cluster");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (flags & CLUSTER_FLAG_SERVER) {
|
||||
if (config && config -> delegate != nullptr) {
|
||||
static const auto delegate_init_cb = RefrigeratorAndTCCModeDelegateInitCB;
|
||||
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
|
||||
}
|
||||
add_function_list(cluster, function_list, function_flags);
|
||||
|
||||
/* Attributes managed internally */
|
||||
global::attribute::create_feature_map(cluster, 0);
|
||||
#if CHIP_CONFIG_ENABLE_EVENTLIST_ATTRIBUTE
|
||||
global::attribute::create_event_list(cluster, NULL, 0, 0);
|
||||
#endif
|
||||
mode_base::attribute::create_supported_modes(cluster, NULL, 0, 0);
|
||||
|
||||
/* Attributes not managed internally */
|
||||
if (config) {
|
||||
global::attribute::create_cluster_revision(cluster, config->cluster_revision);
|
||||
mode_base::attribute::create_current_mode(cluster, config->current_mode);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes.");
|
||||
}
|
||||
}
|
||||
|
||||
/* Commands */
|
||||
mode_base::command::create_change_to_mode(cluster);
|
||||
|
||||
return cluster;
|
||||
}
|
||||
} /* refrigerator_and_tcc_mode */
|
||||
|
||||
namespace rvc_run_mode {
|
||||
const function_generic_t *function_list = NULL;
|
||||
const int function_flags = CLUSTER_FLAG_NONE;
|
||||
@@ -3319,6 +3371,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 = RvcRunModeDelegateInitCB;
|
||||
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
|
||||
}
|
||||
add_function_list(cluster, function_list, function_flags);
|
||||
|
||||
/* Attributes managed internally */
|
||||
@@ -3326,19 +3382,19 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
|
||||
#if CHIP_CONFIG_ENABLE_EVENTLIST_ATTRIBUTE
|
||||
global::attribute::create_event_list(cluster, NULL, 0, 0);
|
||||
#endif
|
||||
attribute::create_supported_modes(cluster, NULL, 0, 0);
|
||||
mode_base::attribute::create_supported_modes(cluster, NULL, 0, 0);
|
||||
|
||||
/* Attributes not managed internally */
|
||||
if (config) {
|
||||
global::attribute::create_cluster_revision(cluster, config->cluster_revision);
|
||||
attribute::create_current_mode(cluster, config->current_mode);
|
||||
mode_base::attribute::create_current_mode(cluster, config->current_mode);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes.");
|
||||
}
|
||||
}
|
||||
|
||||
/* Commands */
|
||||
command::create_change_to_mode(cluster);
|
||||
mode_base::command::create_change_to_mode(cluster);
|
||||
|
||||
return cluster;
|
||||
}
|
||||
@@ -3357,24 +3413,28 @@ 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 = RvcCleanModeDelegateInitCB;
|
||||
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
|
||||
}
|
||||
add_function_list(cluster, function_list, function_flags);
|
||||
|
||||
/* Attributes managed internally */
|
||||
global::attribute::create_feature_map(cluster, 0);
|
||||
global::attribute::create_event_list(cluster, NULL, 0, 0);
|
||||
attribute::create_supported_modes(cluster, NULL, 0, 0);
|
||||
mode_base::attribute::create_supported_modes(cluster, NULL, 0, 0);
|
||||
|
||||
/* Attributes not managed internally */
|
||||
if (config) {
|
||||
global::attribute::create_cluster_revision(cluster, config->cluster_revision);
|
||||
attribute::create_current_mode(cluster, config->current_mode);
|
||||
mode_base::attribute::create_current_mode(cluster, config->current_mode);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes.");
|
||||
}
|
||||
}
|
||||
|
||||
/* Commands */
|
||||
command::create_change_to_mode(cluster);
|
||||
mode_base::command::create_change_to_mode(cluster);
|
||||
|
||||
return cluster;
|
||||
}
|
||||
|
||||
@@ -545,7 +545,8 @@ namespace laundry_washer_mode {
|
||||
typedef struct config {
|
||||
uint16_t cluster_revision;
|
||||
uint8_t current_mode;
|
||||
config() : cluster_revision(1), current_mode(0) {}
|
||||
void *delegate;
|
||||
config() : cluster_revision(1), current_mode(0), delegate(nullptr) {}
|
||||
} config_t;
|
||||
|
||||
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
|
||||
@@ -564,7 +565,8 @@ namespace dish_washer_mode {
|
||||
typedef struct config {
|
||||
uint16_t cluster_revision;
|
||||
uint8_t current_mode;
|
||||
config() : cluster_revision(1), current_mode(0) {}
|
||||
void *delegate;
|
||||
config() : cluster_revision(1), current_mode(0), delegate(nullptr) {}
|
||||
} config_t;
|
||||
|
||||
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
|
||||
@@ -806,11 +808,23 @@ typedef struct config {
|
||||
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
|
||||
} /* refrigerator_alarm */
|
||||
|
||||
namespace refrigerator_and_tcc_mode {
|
||||
typedef struct config {
|
||||
uint16_t cluster_revision;
|
||||
uint8_t current_mode;
|
||||
void *delegate;
|
||||
config() : cluster_revision(1), current_mode(0), delegate(nullptr) {}
|
||||
} config_t;
|
||||
|
||||
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
|
||||
} /* refrigerator_and_tcc_mode */
|
||||
|
||||
namespace rvc_run_mode {
|
||||
typedef struct config {
|
||||
uint16_t cluster_revision;
|
||||
uint8_t current_mode;
|
||||
config() : cluster_revision(1), current_mode(0) {}
|
||||
void *delegate;
|
||||
config() : cluster_revision(1), current_mode(0), delegate(nullptr) {}
|
||||
} config_t;
|
||||
|
||||
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
|
||||
@@ -820,7 +834,8 @@ namespace rvc_clean_mode {
|
||||
typedef struct config {
|
||||
uint16_t cluster_revision;
|
||||
uint8_t current_mode;
|
||||
config() : cluster_revision(1), current_mode(0) {}
|
||||
void *delegate;
|
||||
config() : cluster_revision(1), current_mode(0), delegate(nullptr) {}
|
||||
} config_t;
|
||||
|
||||
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <app-common/zap-generated/callback.h>
|
||||
#include <app/InteractionModelEngine.h>
|
||||
#include <app/util/af.h>
|
||||
#include <app/clusters/mode-base-server/mode-base-cluster-objects.h>
|
||||
|
||||
using namespace chip::app::Clusters;
|
||||
using chip::app::CommandHandler;
|
||||
@@ -2403,26 +2404,6 @@ command_t *create_operational_command_response(cluster_t *cluster)
|
||||
} /* command */
|
||||
} /* operational_state */
|
||||
|
||||
namespace laundry_washer_mode {
|
||||
namespace command {
|
||||
command_t *create_change_to_mode(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::command::create(cluster, LaundryWasherMode::Commands::ChangeToMode::Id, COMMAND_FLAG_ACCEPTED, NULL);
|
||||
}
|
||||
|
||||
} /* command */
|
||||
} /* laundry_washer_mode */
|
||||
|
||||
namespace dish_washer_mode {
|
||||
namespace command {
|
||||
command_t *create_change_to_mode(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::command::create(cluster, DishwasherMode::Commands::ChangeToMode::Id, COMMAND_FLAG_ACCEPTED, NULL);
|
||||
}
|
||||
|
||||
} /* command */
|
||||
} /* dish_washer_mode */
|
||||
|
||||
namespace smoke_co_alarm {
|
||||
namespace command {
|
||||
|
||||
@@ -2691,25 +2672,22 @@ command_t *create_reset_condition(cluster_t *cluster)
|
||||
} /* command */
|
||||
} /* activated_carbon_filter_monitoring */
|
||||
|
||||
namespace rvc_run_mode {
|
||||
namespace mode_base {
|
||||
namespace command {
|
||||
|
||||
// command response is null because of InvokeCommandHandler is overriden in srs/app/clusters/mode-base
|
||||
command_t *create_change_to_mode(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::command::create(cluster, RvcRunMode::Commands::ChangeToMode::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_change_to_mode);
|
||||
return esp_matter::command::create(cluster, ModeBase::Commands::ChangeToMode::Id, COMMAND_FLAG_ACCEPTED, NULL);
|
||||
}
|
||||
|
||||
command_t *create_change_to_mode_response(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::command::create(cluster, ModeBase::Commands::ChangeToModeResponse::Id, COMMAND_FLAG_GENERATED, NULL);
|
||||
}
|
||||
|
||||
} /* command */
|
||||
} /* rvc_run_mode */
|
||||
|
||||
namespace rvc_clean_mode {
|
||||
namespace command {
|
||||
command_t *create_change_to_mode(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::command::create(cluster, RvcCleanMode::Commands::ChangeToMode::Id, COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_change_to_mode);
|
||||
}
|
||||
|
||||
} /* command */
|
||||
} /* rvc_clean_mode */
|
||||
} /* mode_base */
|
||||
|
||||
namespace keypad_input {
|
||||
namespace command {
|
||||
|
||||
@@ -278,18 +278,6 @@ command_t *create_operational_command_response(cluster_t *cluster);
|
||||
} /* command */
|
||||
} /* operational_state */
|
||||
|
||||
namespace laundry_washer_mode {
|
||||
namespace command {
|
||||
command_t *create_change_to_mode(cluster_t *cluster);
|
||||
} /* command */
|
||||
} /* laundry_washer_mode */
|
||||
|
||||
namespace dish_washer_mode {
|
||||
namespace command {
|
||||
command_t *create_change_to_mode(cluster_t *cluster);
|
||||
} /* command */
|
||||
} /* dish_washer_mode */
|
||||
|
||||
namespace smoke_co_alarm {
|
||||
namespace command {
|
||||
command_t *create_self_test_request(cluster_t *cluster);
|
||||
@@ -368,17 +356,12 @@ command_t *create_reset_condition(cluster_t *cluster);
|
||||
} /* command */
|
||||
} /* activated_carbon_filter_monitoring */
|
||||
|
||||
namespace rvc_run_mode {
|
||||
namespace mode_base {
|
||||
namespace command {
|
||||
command_t *create_change_to_mode(cluster_t *cluster);
|
||||
command_t *create_change_to_mode_response(cluster_t *cluster, uint16_t command_id);
|
||||
} /* command */
|
||||
} /* rvc_run_mode */
|
||||
|
||||
namespace rvc_clean_mode {
|
||||
namespace command {
|
||||
command_t *create_change_to_mode(cluster_t *cluster);
|
||||
} /* command */
|
||||
} /* rvc_clean_mode */
|
||||
} /* mode_base */
|
||||
|
||||
namespace keypad_input {
|
||||
namespace command {
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <esp_matter_delegate_callbacks.h>
|
||||
#include <esp_matter_core.h>
|
||||
#include <app/clusters/mode-base-server/mode-base-server.h>
|
||||
|
||||
|
||||
using namespace chip::app::Clusters;
|
||||
namespace esp_matter {
|
||||
namespace cluster {
|
||||
|
||||
static uint32_t get_feature_map_value(uint16_t endpoint_id, uint32_t cluster_id)
|
||||
{
|
||||
node_t *node = node::get();
|
||||
endpoint_t *endpoint = endpoint::get(node, endpoint_id);
|
||||
cluster_t *cluster = cluster::get(endpoint, cluster_id);
|
||||
uint32_t attribute_id = Globals::Attributes::FeatureMap::Id;
|
||||
attribute_t *attribute = attribute::get(cluster, attribute_id);
|
||||
|
||||
esp_matter_attr_val_t val = esp_matter_invalid(NULL);
|
||||
attribute::get_val(attribute, &val);
|
||||
return val.val.u32;
|
||||
}
|
||||
|
||||
namespace delegate_cb {
|
||||
|
||||
void InitModeDelegate(void *delegate, uint16_t endpoint_id, uint32_t cluster_id)
|
||||
{
|
||||
if(delegate == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
static ModeBase::Instance * modeInstance = nullptr;
|
||||
ModeBase::Delegate *mode_delegate = static_cast<ModeBase::Delegate*>(delegate);
|
||||
uint32_t feature_map = get_feature_map_value(endpoint_id, cluster_id);
|
||||
modeInstance = new ModeBase::Instance(mode_delegate, endpoint_id, cluster_id, feature_map);
|
||||
modeInstance->Init();
|
||||
}
|
||||
|
||||
void LaundryWasherModeDelegateInitCB(void *delegate, uint16_t endpoint_id)
|
||||
{
|
||||
InitModeDelegate(delegate, endpoint_id, LaundryWasherMode::Id);
|
||||
}
|
||||
|
||||
void DishWasherModeDelegateInitCB(void *delegate, uint16_t endpoint_id)
|
||||
{
|
||||
InitModeDelegate(delegate, endpoint_id, DishwasherMode::Id);
|
||||
}
|
||||
|
||||
void RefrigeratorAndTCCModeDelegateInitCB(void *delegate, uint16_t endpoint_id)
|
||||
{
|
||||
InitModeDelegate(delegate, endpoint_id, RefrigeratorAndTemperatureControlledCabinetMode::Id);
|
||||
}
|
||||
|
||||
void RvcRunModeDelegateInitCB(void *delegate, uint16_t endpoint_id)
|
||||
{
|
||||
InitModeDelegate(delegate, endpoint_id, RvcRunMode::Id);
|
||||
}
|
||||
|
||||
void RvcCleanModeDelegateInitCB(void *delegate, uint16_t endpoint_id)
|
||||
{
|
||||
InitModeDelegate(delegate, endpoint_id, RvcCleanMode::Id);
|
||||
}
|
||||
|
||||
} // namespace delegate_cb
|
||||
|
||||
} // namespace cluster
|
||||
} // namespace esp_matter
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright 2024 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
namespace esp_matter {
|
||||
namespace cluster {
|
||||
|
||||
namespace delegate_cb {
|
||||
|
||||
void LaundryWasherModeDelegateInitCB(void *delegate, uint16_t endpoint_id);
|
||||
void DishWasherModeDelegateInitCB(void *delegate, uint16_t endpoint_id);
|
||||
void RefrigeratorAndTCCModeDelegateInitCB(void *delegate, uint16_t endpoint_id);
|
||||
void RvcRunModeDelegateInitCB(void *delegate, uint16_t endpoint_id);
|
||||
void RvcCleanModeDelegateInitCB(void *delegate, uint16_t endpoint_id);
|
||||
} // namespace delegate_cb
|
||||
|
||||
} // namespace cluster
|
||||
} // namespace esp_matter
|
||||
@@ -0,0 +1,76 @@
|
||||
9. Application User Guide
|
||||
<<<<<<<<<<<<<<<<<<<<<<<<<
|
||||
|
||||
9.1. Delegate Implementation
|
||||
============================
|
||||
|
||||
As per the implementation in the connectedhomeip repository, some of the clusters
|
||||
require an application defined delegate to consume specific data and actions.
|
||||
In order to provide this flexibity to the application, esp-matter facilitates delegate
|
||||
initilization callbacks in the cluster create API. It is expected that application
|
||||
will define it's data and actions in the form of delegate-impl class and set the
|
||||
delegate while creating cluster/device type.
|
||||
|
||||
List of clusters with delegate:
|
||||
- Mode Base Cluster (all derived types of clusters).
|
||||
- Content Launch Cluster.
|
||||
- Fan Control Cluster.
|
||||
- Audio Output Cluster.
|
||||
- Energy EVSE Cluster.
|
||||
- Device Energy Management Cluster.
|
||||
- Microwave Oven Control Cluster.
|
||||
- Door Lock Cluster.
|
||||
- Messages Cluster.
|
||||
- Operational State Cluster.
|
||||
- Electrical Power Measurement Cluster.
|
||||
- Media Playback Cluster.
|
||||
- Power Topology Cluster.
|
||||
- Content App Observer Cluster.
|
||||
- Channel Cluster.
|
||||
- Resource Monitoring Cluster.
|
||||
- Application Basic Cluster.
|
||||
- Dishwasher Alarm Cluster.
|
||||
- Boolean State Configuration Cluster.
|
||||
- Laundry Dryer Controls Cluster.
|
||||
- Media Input Cluster.
|
||||
- Application Launcher Cluster.
|
||||
- Laundry Washer Controls Cluster.
|
||||
- Valve Configuration And Control Cluster.
|
||||
- Window Covering Cluster.
|
||||
- Content Control Cluster.
|
||||
- Time Synchronization Cluster.
|
||||
- Low Power Cluster.
|
||||
- Keypad Input Cluster.
|
||||
- Account Login Cluster.
|
||||
- Wake On Lan Cluster.
|
||||
- Target Navigator Cluster.
|
||||
|
||||
9.1.1 Mode Base Cluster
|
||||
-----------------------
|
||||
|
||||
It is a base cluster for ModeEVSE, ModeOven, ModeRVSRun, ModeRVSClean, ModeDishwasher,
|
||||
ModeWaterHeater, ModeRefrigerator, ModeLaundryWasher and ModeMicrowaveOven.
|
||||
|
||||
.. csv-table:: Delegate and its impl
|
||||
:header: "Delegate Class", "Reference Implementation"
|
||||
|
||||
`Mode Base`_, `Refrigeratore And TCC Mode`_
|
||||
, `Laundry Washer Mode`_
|
||||
, `Dish Washer Mode`_
|
||||
, `Rvc Run And Rvc Clean Mode`_
|
||||
|
||||
|
||||
.. note::
|
||||
Make sure that after implementing delegate class, you set the delegate class pointer at the time of creating cluster.
|
||||
|
||||
::
|
||||
|
||||
robotic_vacuum_cleaner::config_t rvc_config;
|
||||
rvc_config.rvc_run_mode.delegate = object_of_delegate_class;
|
||||
endpoint_t *endpoint = robotic_vacuum_cleaner::create(node, & rvc_config, ENDPOINT_FLAG_NONE);
|
||||
|
||||
.. _`Mode Base`: https://github.com/project-chip/connectedhomeip/blob/master/src/app/clusters/mode-base-server/mode-base-server.h
|
||||
.. _`Refrigeratore And TCC Mode`: https://github.com/project-chip/connectedhomeip/blob/master/examples/all-clusters-app/all-clusters-common/include/tcc-mode.h
|
||||
.. _`Laundry Washer Mode`: https://github.com/project-chip/connectedhomeip/blob/master/examples/all-clusters-app/all-clusters-common/include/laundry-washer-mode.h
|
||||
.. _`Dish Washer Mode`: https://github.com/project-chip/connectedhomeip/blob/master/examples/all-clusters-app/all-clusters-common/include/dishwasher-mode.h
|
||||
.. _`Rvc Run And Rvc Clean Mode`: https://github.com/project-chip/connectedhomeip/blob/master/examples/all-clusters-app/all-clusters-common/include/rvc-modes.h
|
||||
@@ -25,4 +25,5 @@ Table of Contents
|
||||
6. RAM and Flash Optimizations <optimizations>
|
||||
7. API Reference <api-reference/index>
|
||||
8. Integration with esp-insights <insights>
|
||||
9. Application User Guide <app_guide>
|
||||
A1 Appendix FAQs <faq>
|
||||
|
||||
Reference in New Issue
Block a user