Merge branch 'bugfix/fan-mode' into 'main'

Add min/max bound to fan_mode attribute. Closes https://github.com/espressif/esp-matter/issues/354

See merge request app-frameworks/esp-matter!365
This commit is contained in:
Hrishikesh Dhayagude
2023-04-29 13:41:54 +08:00
4 changed files with 20 additions and 10 deletions
+1
View File
@@ -23,6 +23,7 @@ set(SRC_DIRS_LIST "."
"${MATTER_SDK_PATH}/src/app/clusters/diagnostic-logs-server"
"${MATTER_SDK_PATH}/src/app/clusters/door-lock-server"
"${MATTER_SDK_PATH}/src/app/clusters/ethernet-network-diagnostics-server"
"${MATTER_SDK_PATH}/src/app/clusters/fan-control-server"
"${MATTER_SDK_PATH}/src/app/clusters/fixed-label-server"
"${MATTER_SDK_PATH}/src/app/clusters/general-commissioning-server"
"${MATTER_SDK_PATH}/src/app/clusters/general-diagnostics-server"
+10 -3
View File
@@ -1198,10 +1198,17 @@ attribute_t *create_primary_n_intensity(cluster_t *cluster, nullable<uint8_t> va
namespace fan_control {
namespace attribute {
attribute_t *create_fan_mode(cluster_t *cluster, uint8_t value)
attribute_t *create_fan_mode(cluster_t *cluster, uint8_t value, uint8_t min, uint8_t max)
{
return esp_matter::attribute::create(cluster, FanControl::Attributes::FanMode::Id,
ATTRIBUTE_FLAG_NONVOLATILE | ATTRIBUTE_FLAG_WRITABLE, esp_matter_enum8(value));
attribute_t *attribute =
esp_matter::attribute::create(cluster, FanControl::Attributes::FanMode::Id,
ATTRIBUTE_FLAG_NONVOLATILE | ATTRIBUTE_FLAG_WRITABLE, esp_matter_enum8(value));
if (!attribute) {
ESP_LOGE(TAG, "Could not create attribute");
return NULL;
}
esp_matter::attribute::add_bounds(attribute, esp_matter_enum8(min), esp_matter_enum8(max));
return attribute;
}
attribute_t *create_fan_mode_sequence(cluster_t *cluster, uint8_t value)
+1 -1
View File
@@ -309,7 +309,7 @@ attribute_t *create_primary_n_intensity(cluster_t * cluster, nullable<uint8_t> v
namespace fan_control {
namespace attribute {
attribute_t *create_fan_mode(cluster_t *cluster, uint8_t value);
attribute_t *create_fan_mode(cluster_t *cluster, uint8_t value, uint8_t min, uint8_t max);
attribute_t *create_fan_mode_sequence(cluster_t *cluster, uint8_t value);
attribute_t *create_percent_setting(cluster_t *cluster, nullable<uint8_t> value);
attribute_t *create_percent_current(cluster_t *cluster, uint8_t value);
+7 -5
View File
@@ -1214,8 +1214,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
} /* color_control */
namespace fan_control {
const function_generic_t *function_list = NULL;
const int function_flags = CLUSTER_FLAG_NONE;
const function_generic_t function_list[] = {
(function_generic_t)MatterFanControlClusterServerAttributeChangedCallback,
(function_generic_t)MatterFanControlClusterServerPreAttributeChangedCallback,
};
const int function_flags = CLUSTER_FLAG_ATTRIBUTE_CHANGED_FUNCTION | CLUSTER_FLAG_PRE_ATTRIBUTE_CHANGED_FUNCTION;
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
{
@@ -1226,8 +1229,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
}
if (flags & CLUSTER_FLAG_SERVER) {
/* not implemented: Setting NULL since the MatterFanControlPluginServerInitCallback is not implemented */
set_plugin_server_init_callback(cluster, NULL);
set_plugin_server_init_callback(cluster, MatterFanControlPluginServerInitCallback);
add_function_list(cluster, function_list, function_flags);
}
if (flags & CLUSTER_FLAG_CLIENT) {
@@ -1243,7 +1245,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_fan_mode(cluster, config->fan_mode);
attribute::create_fan_mode(cluster, config->fan_mode, 0, 6);
attribute::create_fan_mode_sequence(cluster, config->fan_mode_sequence);
attribute::create_percent_setting(cluster, config->percent_setting);
attribute::create_percent_current(cluster, config->percent_current);