user-label: add-user-label-cluster

This commit is contained in:
liyashuai
2022-08-18 13:50:00 +08:00
parent 3c73b4f310
commit 438ceb36b9
4 changed files with 65 additions and 0 deletions
@@ -699,6 +699,18 @@ attribute_t *create_reachable(cluster_t *cluster, bool value)
} /* attribute */
} /* bridged_device_basic */
namespace user_label {
namespace attribute {
attribute_t *create_label_list(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
{
return esp_matter::attribute::create(cluster, UserLabel::Attributes::LabelList::Id, ATTRIBUTE_FLAG_WRITABLE,
esp_matter_array(value, length, count));
}
} /* attribute */
} /* user_label */
namespace fixed_label {
namespace attribute {
@@ -206,6 +206,12 @@ attribute_t *create_reachable(cluster_t *cluster, bool value);
} /* attribute */
} /* bridged_device_basic */
namespace user_label {
namespace attribute {
attribute_t *create_label_list(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count);
} /* attribute */
} /* user_label */
namespace fixed_label {
namespace attribute {
attribute_t *create_label_list(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count);
@@ -780,6 +780,44 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
}
} /* bridged_device_basic */
namespace user_label {
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, UserLabel::Id, flags);
if (!cluster) {
ESP_LOGE(TAG, "Could not create cluster");
return NULL;
}
if (flags & CLUSTER_FLAG_SERVER) {
set_plugin_server_init_callback(cluster, MatterUserLabelPluginServerInitCallback);
add_function_list(cluster, function_list, function_flags);
}
if (flags & CLUSTER_FLAG_CLIENT) {
set_plugin_client_init_callback(cluster, MatterUserLabelPluginClientInitCallback);
create_default_binding_cluster(endpoint);
}
if (flags & CLUSTER_FLAG_SERVER) {
/* Attributes managed internally */
global::attribute::create_feature_map(cluster, 0);
attribute::create_label_list(cluster, NULL, 0, 0);
/* Attributes not managed internally */
if (config) {
global::attribute::create_cluster_revision(cluster, config->cluster_revision);
} else {
ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes.");
}
}
return cluster;
}
} /* user_label */
namespace fixed_label {
const function_generic_t *function_list = NULL;
const int function_flags = CLUSTER_FLAG_NONE;
@@ -175,6 +175,15 @@ typedef struct config {
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
} /* bridged_device_basic */
namespace user_label {
typedef struct config {
uint16_t cluster_revision;
config() : cluster_revision(1) {}
} config_t;
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
} /* user_label */
namespace fixed_label {
typedef struct config {
uint16_t cluster_revision;