mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
Merge branch 'feature/missing_features_color_control' into 'main'
Cluster: Add enhanced-hue and color-loop features to color-control cluster See merge request app-frameworks/esp-matter!148
This commit is contained in:
@@ -758,6 +758,12 @@ attribute_t *create_current_saturation(cluster_t *cluster, uint8_t value)
|
||||
esp_matter_uint8(value));
|
||||
}
|
||||
|
||||
attribute_t *create_remaining_time(cluster_t *cluster, uint16_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::RemainingTime::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint16(value));
|
||||
}
|
||||
|
||||
attribute_t *create_color_mode(cluster_t *cluster, uint8_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::ColorMode::Id, ATTRIBUTE_FLAG_NONE,
|
||||
@@ -824,6 +830,42 @@ attribute_t *create_current_y(cluster_t *cluster, uint16_t value)
|
||||
esp_matter_uint16(value));
|
||||
}
|
||||
|
||||
attribute_t *create_enhanced_current_hue(cluster_t *cluster, uint16_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::EnhancedCurrentHue::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint16(value));
|
||||
}
|
||||
|
||||
attribute_t *create_color_loop_active(cluster_t *cluster, uint8_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::ColorLoopActive::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint8(value));
|
||||
}
|
||||
|
||||
attribute_t *create_color_loop_direction(cluster_t *cluster, uint8_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::ColorLoopDirection::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint8(value));
|
||||
}
|
||||
|
||||
attribute_t *create_color_loop_time(cluster_t *cluster, uint16_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::ColorLoopTime::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint16(value));
|
||||
}
|
||||
|
||||
attribute_t *create_color_loop_start_enhanced_hue(cluster_t *cluster, uint16_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::ColorLoopStartEnhancedHue::Id,
|
||||
ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value));
|
||||
}
|
||||
|
||||
attribute_t *create_color_loop_stored_enhanced_hue(cluster_t *cluster, uint16_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, ColorControl::Attributes::ColorLoopStoredEnhancedHue::Id,
|
||||
ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value));
|
||||
}
|
||||
|
||||
} /* attribute */
|
||||
} /* color_control */
|
||||
|
||||
|
||||
@@ -224,6 +224,7 @@ namespace color_control {
|
||||
namespace attribute {
|
||||
attribute_t *create_current_hue(cluster_t *cluster, uint8_t value);
|
||||
attribute_t *create_current_saturation(cluster_t *cluster, uint8_t value);
|
||||
attribute_t *create_remaining_time(cluster_t *cluster, uint16_t value);
|
||||
attribute_t *create_color_mode(cluster_t *cluster, uint8_t value);
|
||||
attribute_t *create_color_control_options(cluster_t *cluster, uint8_t value);
|
||||
attribute_t *create_enhanced_color_mode(cluster_t *cluster, uint8_t value);
|
||||
@@ -235,6 +236,12 @@ attribute_t *create_couple_color_temp_to_level_min_mireds(cluster_t *cluster, ui
|
||||
attribute_t *create_startup_color_temperature_mireds(cluster_t *cluster, uint16_t value);
|
||||
attribute_t *create_current_x(cluster_t *cluster, uint16_t value);
|
||||
attribute_t *create_current_y(cluster_t *cluster, uint16_t value);
|
||||
attribute_t *create_enhanced_current_hue(cluster_t *cluster, uint16_t value);
|
||||
attribute_t *create_color_loop_active(cluster_t *cluster, uint8_t value);
|
||||
attribute_t *create_color_loop_direction(cluster_t *cluster, uint8_t value);
|
||||
attribute_t *create_color_loop_time(cluster_t *cluster, uint16_t value);
|
||||
attribute_t *create_color_loop_start_enhanced_hue(cluster_t *cluster, uint16_t value);
|
||||
attribute_t *create_color_loop_stored_enhanced_hue(cluster_t *cluster, uint16_t value);
|
||||
} /* attribute */
|
||||
} /* color_control */
|
||||
|
||||
|
||||
@@ -1010,6 +1010,9 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes.");
|
||||
}
|
||||
|
||||
/* Attributes managed internally */
|
||||
attribute::create_remaining_time(cluster, 0);
|
||||
}
|
||||
|
||||
/* Features */
|
||||
@@ -1019,6 +1022,15 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
|
||||
if (features & feature::color_temperature::get_id()) {
|
||||
feature::color_temperature::add(cluster, &(config->color_temperature));
|
||||
}
|
||||
if (features & feature::xy::get_id()) {
|
||||
feature::xy::add(cluster, &(config->xy));
|
||||
}
|
||||
if (features & feature::enhanced_hue::get_id()) {
|
||||
feature::enhanced_hue::add(cluster, &(config->enhanced_hue));
|
||||
}
|
||||
if (features & feature::color_loop::get_id()) {
|
||||
feature::color_loop::add(cluster, &(config->color_loop));
|
||||
}
|
||||
|
||||
return cluster;
|
||||
}
|
||||
|
||||
@@ -225,6 +225,9 @@ typedef struct config {
|
||||
uint16_t color_capabilities;
|
||||
feature::hue_saturation::config_t hue_saturation;
|
||||
feature::color_temperature::config_t color_temperature;
|
||||
feature::xy::config_t xy;
|
||||
feature::enhanced_hue::config_t enhanced_hue;
|
||||
feature::color_loop::config_t color_loop;
|
||||
config() : cluster_revision(5), color_mode(1), color_control_options(0), enhanced_color_mode(1),
|
||||
color_capabilities(0) {}
|
||||
} config_t;
|
||||
|
||||
@@ -855,6 +855,66 @@ static esp_err_t esp_matter_command_callback_step_color_temperature(const Concre
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t esp_matter_command_callback_enhanced_move_to_hue(const ConcreteCommandPath &command_path,
|
||||
TLVReader &tlv_data, void *opaque_ptr)
|
||||
{
|
||||
chip::app::Clusters::ColorControl::Commands::EnhancedMoveToHue::DecodableType command_data;
|
||||
CHIP_ERROR error = Decode(tlv_data, command_data);
|
||||
if (error == CHIP_NO_ERROR) {
|
||||
emberAfColorControlClusterEnhancedMoveToHueCallback((CommandHandler *)opaque_ptr, command_path,
|
||||
command_data);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t esp_matter_command_callback_enhanced_move_hue(const ConcreteCommandPath &command_path,
|
||||
TLVReader &tlv_data, void *opaque_ptr)
|
||||
{
|
||||
chip::app::Clusters::ColorControl::Commands::EnhancedMoveHue::DecodableType command_data;
|
||||
CHIP_ERROR error = Decode(tlv_data, command_data);
|
||||
if (error == CHIP_NO_ERROR) {
|
||||
emberAfColorControlClusterEnhancedMoveHueCallback((CommandHandler *)opaque_ptr, command_path,
|
||||
command_data);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t esp_matter_command_callback_enhanced_step_hue(const ConcreteCommandPath &command_path,
|
||||
TLVReader &tlv_data, void *opaque_ptr)
|
||||
{
|
||||
chip::app::Clusters::ColorControl::Commands::EnhancedStepHue::DecodableType command_data;
|
||||
CHIP_ERROR error = Decode(tlv_data, command_data);
|
||||
if (error == CHIP_NO_ERROR) {
|
||||
emberAfColorControlClusterEnhancedStepHueCallback((CommandHandler *)opaque_ptr, command_path,
|
||||
command_data);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t esp_matter_command_callback_enhanced_move_to_hue_and_saturation(const ConcreteCommandPath &command_path,
|
||||
TLVReader &tlv_data, void *opaque_ptr)
|
||||
{
|
||||
chip::app::Clusters::ColorControl::Commands::EnhancedMoveToHueAndSaturation::DecodableType command_data;
|
||||
CHIP_ERROR error = Decode(tlv_data, command_data);
|
||||
if (error == CHIP_NO_ERROR) {
|
||||
emberAfColorControlClusterEnhancedMoveToHueAndSaturationCallback((CommandHandler *)opaque_ptr, command_path,
|
||||
command_data);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t esp_matter_command_callback_color_loop_set(const ConcreteCommandPath &command_path,
|
||||
TLVReader &tlv_data, void *opaque_ptr)
|
||||
{
|
||||
chip::app::Clusters::ColorControl::Commands::ColorLoopSet::DecodableType command_data;
|
||||
CHIP_ERROR error = Decode(tlv_data, command_data);
|
||||
if (error == CHIP_NO_ERROR) {
|
||||
emberAfColorControlClusterColorLoopSetCallback((CommandHandler *)opaque_ptr, command_path,
|
||||
command_data);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t esp_matter_command_callback_move_to_color(const ConcreteCommandPath &command_path,
|
||||
TLVReader &tlv_data, void *opaque_ptr)
|
||||
{
|
||||
@@ -1611,6 +1671,36 @@ command_t *create_step_color(cluster_t *cluster)
|
||||
esp_matter_command_callback_step_color);
|
||||
}
|
||||
|
||||
command_t *create_enhanced_move_to_hue(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::command::create(cluster, ColorControl::Commands::EnhancedMoveToHue::Id, COMMAND_FLAG_ACCEPTED,
|
||||
esp_matter_command_callback_enhanced_move_to_hue);
|
||||
}
|
||||
|
||||
command_t *create_enhanced_move_hue(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::command::create(cluster, ColorControl::Commands::EnhancedMoveHue::Id, COMMAND_FLAG_ACCEPTED,
|
||||
esp_matter_command_callback_enhanced_move_hue);
|
||||
}
|
||||
|
||||
command_t *create_enhanced_step_hue(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::command::create(cluster, ColorControl::Commands::EnhancedStepHue::Id, COMMAND_FLAG_ACCEPTED,
|
||||
esp_matter_command_callback_enhanced_step_hue);
|
||||
}
|
||||
|
||||
command_t *create_enhanced_move_to_hue_and_saturation(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::command::create(cluster, ColorControl::Commands::EnhancedMoveToHueAndSaturation::Id,
|
||||
COMMAND_FLAG_ACCEPTED, esp_matter_command_callback_enhanced_move_to_hue_and_saturation);
|
||||
}
|
||||
|
||||
command_t *create_color_loop_set(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::command::create(cluster, ColorControl::Commands::ColorLoopSet::Id, COMMAND_FLAG_ACCEPTED,
|
||||
esp_matter_command_callback_color_loop_set);
|
||||
}
|
||||
|
||||
} /* command */
|
||||
} /* color_control */
|
||||
|
||||
|
||||
@@ -194,6 +194,11 @@ command_t *create_step_color_temperature(cluster_t *cluster);
|
||||
command_t *create_move_to_color(cluster_t *cluster);
|
||||
command_t *create_move_color(cluster_t *cluster);
|
||||
command_t *create_step_color(cluster_t *cluster);
|
||||
command_t *create_enhanced_move_to_hue(cluster_t *cluster);
|
||||
command_t *create_enhanced_move_hue(cluster_t *cluster);
|
||||
command_t *create_enhanced_step_hue(cluster_t *cluster);
|
||||
command_t *create_enhanced_move_to_hue_and_saturation(cluster_t *cluster);
|
||||
command_t *create_color_loop_set(cluster_t *cluster);
|
||||
} /* command */
|
||||
} /* color_control */
|
||||
|
||||
|
||||
@@ -237,6 +237,62 @@ esp_err_t add(cluster_t *cluster, config_t *config)
|
||||
}
|
||||
|
||||
} /* xy */
|
||||
|
||||
namespace enhanced_hue {
|
||||
|
||||
uint32_t get_id()
|
||||
{
|
||||
return (uint32_t)chip::app::Clusters::ColorControl::ColorCapabilities::kEnhancedHueSupported;
|
||||
}
|
||||
|
||||
esp_err_t add(cluster_t *cluster, config_t *config)
|
||||
{
|
||||
if (!cluster) {
|
||||
ESP_LOGE(TAG, "Cluster cannot be NULL");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
update_feature_map(cluster, get_id());
|
||||
|
||||
/* Attributes not managed internally */
|
||||
attribute::create_enhanced_current_hue(cluster, config->enhanced_current_hue);
|
||||
|
||||
/* Commands */
|
||||
command::create_enhanced_move_to_hue(cluster);
|
||||
command::create_enhanced_move_hue(cluster);
|
||||
command::create_enhanced_step_hue(cluster);
|
||||
command::create_enhanced_move_to_hue_and_saturation(cluster);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
} /* enhanced_hue */
|
||||
|
||||
namespace color_loop {
|
||||
uint32_t get_id()
|
||||
{
|
||||
return (uint32_t)chip::app::Clusters::ColorControl::ColorCapabilities::kColorLoopSupported;
|
||||
}
|
||||
|
||||
esp_err_t add(cluster_t *cluster, config_t *config)
|
||||
{
|
||||
if (!cluster) {
|
||||
ESP_LOGE(TAG, "Cluster cannot be NULL");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
update_feature_map(cluster, get_id());
|
||||
|
||||
/* Attributes not managed internally */
|
||||
attribute::create_color_loop_active(cluster, config->color_loop_active);
|
||||
attribute::create_color_loop_direction(cluster, config->color_loop_direction);
|
||||
attribute::create_color_loop_time(cluster, config->color_loop_time);
|
||||
attribute::create_color_loop_start_enhanced_hue(cluster, config->color_loop_start_enhanced_hue);
|
||||
attribute::create_color_loop_stored_enhanced_hue(cluster, config->color_loop_stored_enhanced_hue);
|
||||
|
||||
/* Commands */
|
||||
command::create_color_loop_set(cluster);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
} /* color_loop */
|
||||
} /* feature */
|
||||
} /* color_control */
|
||||
|
||||
|
||||
@@ -121,6 +121,35 @@ uint32_t get_id();
|
||||
esp_err_t add(cluster_t *cluster, config_t *config);
|
||||
|
||||
} /* xy */
|
||||
|
||||
namespace enhanced_hue {
|
||||
|
||||
typedef struct config {
|
||||
uint16_t enhanced_current_hue;
|
||||
config() : enhanced_current_hue(0) {}
|
||||
} config_t;
|
||||
|
||||
uint32_t get_id();
|
||||
esp_err_t add(cluster_t *cluster, config_t *config);
|
||||
|
||||
} /* enhanced_hue */
|
||||
|
||||
namespace color_loop {
|
||||
|
||||
typedef struct config {
|
||||
uint8_t color_loop_active;
|
||||
uint8_t color_loop_direction;
|
||||
uint16_t color_loop_time;
|
||||
uint16_t color_loop_start_enhanced_hue;
|
||||
uint16_t color_loop_stored_enhanced_hue;
|
||||
config() : color_loop_active(0), color_loop_direction(0), color_loop_time(0),
|
||||
color_loop_start_enhanced_hue(0), color_loop_stored_enhanced_hue(0) {}
|
||||
} config_t;
|
||||
|
||||
uint32_t get_id();
|
||||
esp_err_t add(cluster_t *cluster, config_t *config);
|
||||
|
||||
} /* color_loop */
|
||||
} /* feature */
|
||||
} /* color_control */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user