mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
Add robotic vaccum cleaner device type
This commit is contained in:
@@ -3816,5 +3816,37 @@ attribute_t *create_supported(cluster_t *cluster, uint32_t value)
|
||||
} /* attribute */
|
||||
} /* refrigerator_alarm */
|
||||
|
||||
namespace rvc_run_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, RvcRunMode::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));
|
||||
}
|
||||
|
||||
} /* 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)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, RvcCleanMode::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, RvcCleanMode::Attributes::CurrentMode::Id, ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_uint8(value));
|
||||
}
|
||||
|
||||
} /* attribute */
|
||||
} /* rvc_clean_mode */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -874,5 +874,19 @@ attribute_t *create_supported(cluster_t *cluster, uint32_t value);
|
||||
} /* attribute */
|
||||
} /* refrigerator_alarm */
|
||||
|
||||
namespace rvc_run_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_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 */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -2911,6 +2911,114 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
|
||||
}
|
||||
} /* refrigerator_alarm */
|
||||
|
||||
namespace rvc_run_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, RvcRunMode::Id, flags);
|
||||
if (!cluster) {
|
||||
ESP_LOGE(TAG, "Could not create cluster");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (flags & CLUSTER_FLAG_SERVER) {
|
||||
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);
|
||||
|
||||
/* Attributes not managed internally */
|
||||
if (config) {
|
||||
global::attribute::create_cluster_revision(cluster, config->cluster_revision);
|
||||
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);
|
||||
|
||||
return cluster;
|
||||
}
|
||||
} /* rvc_run_mode */
|
||||
|
||||
namespace rvc_clean_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, RvcCleanMode::Id, flags);
|
||||
if (!cluster) {
|
||||
ESP_LOGE(TAG, "Could not create cluster");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (flags & CLUSTER_FLAG_SERVER) {
|
||||
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);
|
||||
|
||||
/* Attributes not managed internally */
|
||||
if (config) {
|
||||
global::attribute::create_cluster_revision(cluster, config->cluster_revision);
|
||||
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);
|
||||
|
||||
return cluster;
|
||||
}
|
||||
} /* rvc_clean_mode */
|
||||
|
||||
namespace rvc_operational_state {
|
||||
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, RvcOperationalState::Id, flags);
|
||||
if (!cluster) {
|
||||
ESP_LOGE(TAG, "Could not create cluster");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (flags & CLUSTER_FLAG_SERVER) {
|
||||
add_function_list(cluster, function_list, function_flags);
|
||||
}
|
||||
if (flags & CLUSTER_FLAG_CLIENT) {
|
||||
create_default_binding_cluster(endpoint);
|
||||
}
|
||||
|
||||
if (flags & CLUSTER_FLAG_SERVER) {
|
||||
/* Attributes managed internally */
|
||||
global::attribute::create_feature_map(cluster, 0);
|
||||
global::attribute::create_event_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;
|
||||
}
|
||||
} /* rvc_operational_state */
|
||||
|
||||
// namespace binary_input_basic {
|
||||
// // ToDo
|
||||
// } /* binary_input_basic */
|
||||
|
||||
@@ -720,5 +720,34 @@ typedef struct config {
|
||||
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
|
||||
} /* refrigerator_alarm */
|
||||
|
||||
namespace rvc_run_mode {
|
||||
typedef struct config {
|
||||
uint16_t cluster_revision;
|
||||
uint8_t current_mode;
|
||||
config() : cluster_revision(1), current_mode(0) {}
|
||||
} config_t;
|
||||
|
||||
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
|
||||
} /* rvc_run_mode */
|
||||
|
||||
namespace rvc_clean_mode {
|
||||
typedef struct config {
|
||||
uint16_t cluster_revision;
|
||||
uint8_t current_mode;
|
||||
config() : cluster_revision(1), current_mode(0) {}
|
||||
} config_t;
|
||||
|
||||
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
|
||||
} /* rvc_clean_mode */
|
||||
|
||||
namespace rvc_operational_state {
|
||||
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);
|
||||
} /* rvc_operational_state */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -2250,6 +2250,26 @@ command_t *create_reset_condition(cluster_t *cluster)
|
||||
} /* command */
|
||||
} /* activated_carbon_filter_monitoring */
|
||||
|
||||
namespace rvc_run_mode {
|
||||
namespace command {
|
||||
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);
|
||||
}
|
||||
|
||||
} /* 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 */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
|
||||
@@ -325,5 +325,17 @@ command_t *create_reset_condition(cluster_t *cluster);
|
||||
} /* command */
|
||||
} /* activated_carbon_filter_monitoring */
|
||||
|
||||
namespace rvc_run_mode {
|
||||
namespace command {
|
||||
command_t *create_change_to_mode(cluster_t *cluster);
|
||||
} /* command */
|
||||
} /* rvc_run_mode */
|
||||
|
||||
namespace rvc_clean_mode {
|
||||
namespace command {
|
||||
command_t *create_change_to_mode(cluster_t *cluster);
|
||||
} /* command */
|
||||
} /* rvc_clean_mode */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -1399,6 +1399,46 @@ esp_err_t add(endpoint_t *endpoint, config_t *config)
|
||||
}
|
||||
} /** refrigerator **/
|
||||
|
||||
namespace robotic_vaccum_cleaner{
|
||||
|
||||
uint32_t get_device_type_id()
|
||||
{
|
||||
return ESP_MATTER_ROBOTIC_VACCUM_CLEANER_DEVICE_TYPE_ID;
|
||||
}
|
||||
|
||||
uint8_t get_device_type_version()
|
||||
{
|
||||
return ESP_MATTER_ROBOTIC_VACCUM_CLEANER_DEVICE_TYPE_VERSION;
|
||||
}
|
||||
|
||||
endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data)
|
||||
{
|
||||
endpoint_t *endpoint = endpoint::create(node, flags, priv_data);
|
||||
add(endpoint, config);
|
||||
return endpoint;
|
||||
}
|
||||
|
||||
esp_err_t add(endpoint_t *endpoint, config_t *config)
|
||||
{
|
||||
if (!endpoint) {
|
||||
ESP_LOGE(TAG, "Could not create endpoint");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version());
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Failed to add device type id:%" PRIu32 ", err: %d", get_device_type_id(), err);
|
||||
return err;
|
||||
}
|
||||
|
||||
descriptor::create(endpoint, &(config->descriptor), CLUSTER_FLAG_SERVER);
|
||||
identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER);
|
||||
rvc_run_mode::create(endpoint, &(config->rvc_run_mode), CLUSTER_FLAG_SERVER);
|
||||
rvc_operational_state::create(endpoint, &(config->rvc_operational_state), CLUSTER_FLAG_SERVER);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
} /** robotic_vaccum_cleaner **/
|
||||
|
||||
} /* endpoint */
|
||||
|
||||
namespace node {
|
||||
|
||||
@@ -92,6 +92,8 @@
|
||||
#define ESP_MATTER_PUMP_DEVICE_TYPE_VERSION 2
|
||||
#define ESP_MATTER_MODE_SELECT_DEVICE_TYPE_ID 0x0027
|
||||
#define ESP_MATTER_MODE_SELECT_DEVICE_TYPE_VERSION 1
|
||||
#define ESP_MATTER_ROBOTIC_VACCUM_CLEANER_DEVICE_TYPE_ID 0x0074
|
||||
#define ESP_MATTER_ROBOTIC_VACCUM_CLEANER_DEVICE_TYPE_VERSION 1
|
||||
|
||||
namespace esp_matter {
|
||||
|
||||
@@ -576,6 +578,20 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat
|
||||
esp_err_t add(endpoint_t *endpoint, config_t *config);
|
||||
} /** refrigerator **/
|
||||
|
||||
namespace robotic_vaccum_cleaner{
|
||||
typedef struct config {
|
||||
cluster::descriptor::config_t descriptor;
|
||||
cluster::identify::config_t identify;
|
||||
cluster::rvc_run_mode::config_t rvc_run_mode;
|
||||
cluster::rvc_operational_state::config_t rvc_operational_state;
|
||||
} config_t;
|
||||
|
||||
uint32_t get_device_type_id();
|
||||
uint8_t get_device_type_version();
|
||||
endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data);
|
||||
esp_err_t add(endpoint_t *endpoint, config_t *config);
|
||||
} /** robotic_vaccum_cleaner **/
|
||||
|
||||
} /* endpoint */
|
||||
|
||||
namespace node {
|
||||
|
||||
Reference in New Issue
Block a user