mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
Features: Add optional features APIs for LevelControl cluster.
Bugfix: Add NULLABLE flag for start_up_on_off attribute.
This commit is contained in:
@@ -683,7 +683,8 @@ attribute_t *create_off_wait_time(cluster_t *cluster, uint16_t value)
|
||||
attribute_t *create_start_up_on_off(cluster_t *cluster, uint8_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, OnOff::Attributes::StartUpOnOff::Id,
|
||||
ATTRIBUTE_FLAG_WRITABLE | ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_enum8(value));
|
||||
ATTRIBUTE_FLAG_WRITABLE | ATTRIBUTE_FLAG_NONVOLATILE | ATTRIBUTE_FLAG_NULLABLE,
|
||||
esp_matter_enum8(value));
|
||||
}
|
||||
|
||||
} /* attribute */
|
||||
@@ -734,6 +735,48 @@ attribute_t *create_max_level(cluster_t *cluster, uint8_t value)
|
||||
esp_matter_uint8(value));
|
||||
}
|
||||
|
||||
attribute_t *create_current_frequency(cluster_t *cluster, uint16_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, LevelControl::Attributes::CurrentFrequency::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint16(value));
|
||||
}
|
||||
|
||||
attribute_t *create_min_frequency(cluster_t *cluster, uint16_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, LevelControl::Attributes::MinFrequency::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint16(value));
|
||||
}
|
||||
|
||||
attribute_t *create_max_frequency(cluster_t *cluster, uint16_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, LevelControl::Attributes::MaxFrequency::Id, ATTRIBUTE_FLAG_NONE,
|
||||
esp_matter_uint16(value));
|
||||
}
|
||||
|
||||
attribute_t *create_on_off_transition_time(cluster_t *cluster, uint16_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, LevelControl::Attributes::OnOffTransitionTime::Id,
|
||||
ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint16(value));
|
||||
}
|
||||
|
||||
attribute_t *create_on_transition_time(cluster_t* cluster, uint16_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, LevelControl::Attributes::OnTransitionTime::Id,
|
||||
ATTRIBUTE_FLAG_WRITABLE | ATTRIBUTE_FLAG_NULLABLE, esp_matter_uint16(value));
|
||||
}
|
||||
|
||||
attribute_t *create_off_transition_time(cluster_t* cluster, uint16_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, LevelControl::Attributes::OffTransitionTime::Id,
|
||||
ATTRIBUTE_FLAG_WRITABLE | ATTRIBUTE_FLAG_NULLABLE, esp_matter_uint16(value));
|
||||
}
|
||||
|
||||
attribute_t *create_default_move_rate(cluster_t* cluster, uint8_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, LevelControl::Attributes::DefaultMoveRate::Id,
|
||||
ATTRIBUTE_FLAG_WRITABLE, esp_matter_uint8(value));
|
||||
}
|
||||
|
||||
attribute_t *create_start_up_current_level(cluster_t *cluster, uint8_t value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, LevelControl::Attributes::StartUpCurrentLevel::Id,
|
||||
|
||||
@@ -216,6 +216,13 @@ attribute_t *create_options(cluster_t *cluster, uint8_t value, uint8_t min, uint
|
||||
attribute_t *create_remaining_time(cluster_t *cluster, uint16_t value);
|
||||
attribute_t *create_min_level(cluster_t *cluster, uint8_t value);
|
||||
attribute_t *create_max_level(cluster_t *cluster, uint8_t value);
|
||||
attribute_t *create_current_frequency(cluster_t *cluster, uint16_t value);
|
||||
attribute_t *create_min_frequency(cluster_t *cluster, uint16_t value);
|
||||
attribute_t *create_max_frequency(cluster_t *cluster, uint16_t value);
|
||||
attribute_t *create_on_off_transition_time(cluster_t *cluster, uint16_t value);
|
||||
attribute_t *create_on_transition_time(cluster_t* cluster, uint16_t value);
|
||||
attribute_t *create_off_transition_time(cluster_t* cluster, uint16_t value);
|
||||
attribute_t *create_default_move_rate(cluster_t* cluster, uint8_t value);
|
||||
attribute_t *create_start_up_current_level(cluster_t *cluster, uint8_t value);
|
||||
} /* attribute */
|
||||
} /* level_control */
|
||||
|
||||
@@ -730,6 +730,17 @@ static esp_err_t esp_matter_command_callback_stop_with_on_off(const ConcreteComm
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t esp_matter_command_callback_move_to_closest_frequency(const ConcreteCommandPath &command_path,
|
||||
TLVReader &tlv_data, void *opaque_ptr)
|
||||
{
|
||||
chip::app::Clusters::LevelControl::Commands::MoveToClosestFrequency::DecodableType command_data;
|
||||
CHIP_ERROR error = Decode(tlv_data, command_data);
|
||||
if (error == CHIP_NO_ERROR) {
|
||||
emberAfLevelControlClusterMoveToClosestFrequencyCallback((CommandHandler *)opaque_ptr, command_path, command_data);
|
||||
}
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t esp_matter_command_callback_move_to_hue(const ConcreteCommandPath &command_path, TLVReader &tlv_data,
|
||||
void *opaque_ptr)
|
||||
{
|
||||
@@ -1581,6 +1592,12 @@ command_t *create_stop_with_on_off(cluster_t *cluster)
|
||||
esp_matter_command_callback_stop_with_on_off);
|
||||
}
|
||||
|
||||
command_t *create_move_to_closest_frequency(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::command::create(cluster, LevelControl::Commands::MoveToClosestFrequency::Id, COMMAND_FLAG_ACCEPTED,
|
||||
esp_matter_command_callback_move_to_closest_frequency);
|
||||
}
|
||||
|
||||
} /* command */
|
||||
} /* level_control */
|
||||
|
||||
|
||||
@@ -175,6 +175,7 @@ command_t *create_move_to_level_with_on_off(cluster_t *cluster);
|
||||
command_t *create_move_with_on_off(cluster_t *cluster);
|
||||
command_t *create_step_with_on_off(cluster_t *cluster);
|
||||
command_t *create_stop_with_on_off(cluster_t *cluster);
|
||||
command_t *create_move_to_closest_frequency(cluster_t *cluster);
|
||||
} /* command */
|
||||
} /* level_control */
|
||||
|
||||
|
||||
@@ -136,6 +136,33 @@ esp_err_t add(cluster_t *cluster, config_t *config)
|
||||
}
|
||||
|
||||
} /* lighting */
|
||||
|
||||
namespace frequency {
|
||||
|
||||
uint32_t get_id()
|
||||
{
|
||||
return (uint32_t)LevelControl::LevelControlFeature::kFrequency;
|
||||
}
|
||||
|
||||
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_current_frequency(cluster, config->current_frequency);
|
||||
attribute::create_min_frequency(cluster, config->min_frequency);
|
||||
attribute::create_max_frequency(cluster, config->max_frequency);
|
||||
|
||||
/* Commands */
|
||||
command::create_move_to_closest_frequency(cluster);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
} /* frequency */
|
||||
} /* feature */
|
||||
} /* level_control */
|
||||
|
||||
|
||||
@@ -73,6 +73,19 @@ uint32_t get_id();
|
||||
esp_err_t add(cluster_t *cluster, config_t *config);
|
||||
|
||||
} /* lighting */
|
||||
|
||||
namespace frequency {
|
||||
|
||||
typedef struct config {
|
||||
uint16_t current_frequency;
|
||||
uint16_t min_frequency;
|
||||
uint16_t max_frequency;
|
||||
config() : current_frequency(0), min_frequency(0), max_frequency(0) {}
|
||||
} config_t;
|
||||
|
||||
uint32_t get_id();
|
||||
esp_err_t add(cluster_t *cluster, config_t *config);
|
||||
} /* frequency */
|
||||
} /* feature */
|
||||
} /* level_control */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user