diff --git a/components/esp_matter/esp_matter_cluster.cpp b/components/esp_matter/esp_matter_cluster.cpp index fb8f8ce90..c94f5abec 100644 --- a/components/esp_matter/esp_matter_cluster.cpp +++ b/components/esp_matter/esp_matter_cluster.cpp @@ -165,8 +165,12 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) attribute::create_software_version_string(cluster, NULL, 0); /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); - attribute::create_node_label(cluster, config->node_label, sizeof(config->node_label)); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_node_label(cluster, config->node_label, sizeof(config->node_label)); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } return cluster; @@ -201,7 +205,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) attribute::create_binding(cluster, NULL, 0, 0); /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } return cluster; @@ -231,7 +239,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) if (flags & CLUSTER_FLAG_SERVER) { /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } /* Commands */ @@ -271,10 +283,14 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) attribute::create_default_ota_providers(cluster, NULL, 0); /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); - attribute::create_update_possible(cluster, config->update_possible); - attribute::create_update_state(cluster, config->update_state); - attribute::create_update_state_progress(cluster, config->update_state_progress); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_update_possible(cluster, config->update_possible); + attribute::create_update_state(cluster, config->update_state); + attribute::create_update_state_progress(cluster, config->update_state_progress); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } /* Commands */ @@ -312,8 +328,12 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) attribute::create_basic_commissioning_info(cluster, NULL, 0, 0); /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); - attribute::create_breadcrumb(cluster, config->breadcrumb); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_breadcrumb(cluster, config->breadcrumb); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } /* Commands */ @@ -362,7 +382,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) global::attribute::create_feature_map(cluster, 0); /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } /* Commands */ @@ -407,7 +431,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) attribute::create_reboot_count(cluster, 0); /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } return cluster; @@ -442,7 +470,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) attribute::create_admin_vendor_id(cluster, 0); /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } /* Commands */ @@ -485,7 +517,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) attribute::create_current_fabric_index(cluster, 0); /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } /* Commands */ @@ -573,11 +609,15 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) create_default_binding_cluster(endpoint); } - /* Attributes not managed internally */ if (flags & CLUSTER_FLAG_SERVER) { - global::attribute::create_cluster_revision(cluster, config->cluster_revision); - attribute::create_identify_time(cluster, config->identify_time, 0x0, 0xFE); - attribute::create_identify_type(cluster, config->identify_type); + /* Attributes not managed internally */ + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_identify_time(cluster, config->identify_time, 0x0, 0xFE); + attribute::create_identify_type(cluster, config->identify_type); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } /* Commands */ @@ -614,8 +654,12 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) if (flags & CLUSTER_FLAG_SERVER) { /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); - attribute::create_group_name_support(cluster, config->group_name_support); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_group_name_support(cluster, config->group_name_support); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } /* Commands */ @@ -659,12 +703,16 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) if (flags & CLUSTER_FLAG_SERVER) { /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); - attribute::create_scene_count(cluster, config->scene_count); - attribute::create_current_scene(cluster, config->current_scene); - attribute::create_current_group(cluster, config->current_group); - attribute::create_scene_valid(cluster, config->scene_valid); - attribute::create_scene_name_support(cluster, config->scene_name_support); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_scene_count(cluster, config->scene_count); + attribute::create_current_scene(cluster, config->current_scene); + attribute::create_current_group(cluster, config->current_group); + attribute::create_scene_valid(cluster, config->scene_valid); + attribute::create_scene_name_support(cluster, config->scene_name_support); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } /* Commands */ @@ -711,8 +759,12 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_ if (flags & CLUSTER_FLAG_SERVER) { /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); - attribute::create_on_off(cluster, config->on_off); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_on_off(cluster, config->on_off); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } /* Commands */ @@ -754,10 +806,14 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_ if (flags & CLUSTER_FLAG_SERVER) { /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); - attribute::create_current_level(cluster, config->current_level); - attribute::create_on_level(cluster, config->on_level); - attribute::create_options(cluster, config->options, 0x0, 0x3); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_current_level(cluster, config->current_level); + attribute::create_on_level(cluster, config->on_level); + attribute::create_options(cluster, config->options, 0x0, 0x3); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } /* Commands */ @@ -807,11 +863,15 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_ if (flags & CLUSTER_FLAG_SERVER) { /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); - attribute::create_color_mode(cluster, config->color_mode); - attribute::create_color_control_options(cluster, config->color_control_options); - attribute::create_enhanced_color_mode(cluster, config->enhanced_color_mode); - attribute::create_color_capabilities(cluster, config->color_capabilities); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_color_mode(cluster, config->color_mode); + attribute::create_color_control_options(cluster, config->color_control_options); + attribute::create_enhanced_color_mode(cluster, config->enhanced_color_mode); + attribute::create_color_capabilities(cluster, config->color_capabilities); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } /* Features */ @@ -851,13 +911,17 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) if (flags & CLUSTER_FLAG_SERVER) { /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); - attribute::create_fan_mode(cluster, config->fan_mode); - attribute::create_fan_mode_sequence(cluster, config->fan_mode_sequence); - /* Not implemented - attribute::create_percent_setting(cluster, config->percent_setting); - attribute::create_percent_current(cluster, config->percent_current); - */ + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_fan_mode(cluster, config->fan_mode); + attribute::create_fan_mode_sequence(cluster, config->fan_mode_sequence); + /* Not implemented + attribute::create_percent_setting(cluster, config->percent_setting); + attribute::create_percent_current(cluster, config->percent_current); + */ + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } return cluster; @@ -889,12 +953,16 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) if (flags & CLUSTER_FLAG_SERVER) { /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); - attribute::create_local_temperature(cluster, config->local_temperature); - attribute::create_occupied_cooling_setpoint(cluster, config->occupied_cooling_setpoint); - attribute::create_occupied_heating_setpoint(cluster, config->occupied_heating_setpoint); - attribute::create_control_sequence_of_operation(cluster, config->control_sequence_of_operation, 0x0, 0x5); - attribute::create_system_mode(cluster, config->system_mode, 0x0, 0x7); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_local_temperature(cluster, config->local_temperature); + attribute::create_occupied_cooling_setpoint(cluster, config->occupied_cooling_setpoint); + attribute::create_occupied_heating_setpoint(cluster, config->occupied_heating_setpoint); + attribute::create_control_sequence_of_operation(cluster, config->control_sequence_of_operation, 0x0, 0x5); + attribute::create_system_mode(cluster, config->system_mode, 0x0, 0x7); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } /* Commands */ @@ -930,13 +998,17 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) if (flags & CLUSTER_FLAG_SERVER) { /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); - attribute::create_lock_state(cluster, config->lock_state); - attribute::create_lock_type(cluster, config->lock_type); - attribute::create_actuator_enabled(cluster, config->actuator_enabled); - attribute::create_auto_relock_time(cluster, config->auto_relock_time); - attribute::create_operating_mode(cluster, config->operating_mode, 0x0, 0x4); - attribute::create_supported_operating_modes(cluster, config->supported_operating_modes); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_lock_state(cluster, config->lock_state); + attribute::create_lock_type(cluster, config->lock_type); + attribute::create_actuator_enabled(cluster, config->actuator_enabled); + attribute::create_auto_relock_time(cluster, config->auto_relock_time); + attribute::create_operating_mode(cluster, config->operating_mode, 0x0, 0x4); + attribute::create_supported_operating_modes(cluster, config->supported_operating_modes); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } /* Commands */ @@ -970,7 +1042,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) if (flags & CLUSTER_FLAG_SERVER) { /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } return cluster; @@ -996,9 +1072,13 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) if (flags & CLUSTER_FLAG_SERVER) { /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); - attribute::create_bridged_device_basic_node_label(cluster, config->node_label, sizeof(config->node_label)); - attribute::create_reachable(cluster, config->reachable); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_bridged_device_basic_node_label(cluster, config->node_label, sizeof(config->node_label)); + attribute::create_reachable(cluster, config->reachable); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } return cluster; @@ -1031,7 +1111,11 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) attribute::create_label_list(cluster, NULL, 0, 0); /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } return cluster; @@ -1061,10 +1145,14 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) if (flags & CLUSTER_FLAG_SERVER) { /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); - attribute::create_number_of_positions(cluster, config->number_of_positions); - attribute::create_current_position(cluster, config->current_position); - attribute::create_multi_press_max(cluster, config->multi_press_max); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_number_of_positions(cluster, config->number_of_positions); + attribute::create_current_position(cluster, config->current_position); + attribute::create_multi_press_max(cluster, config->multi_press_max); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } return cluster; @@ -1094,10 +1182,14 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) if (flags & CLUSTER_FLAG_SERVER) { /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); - attribute::create_temperature_measured_value(cluster, config->measured_value); - attribute::create_temperature_min_measured_value(cluster, config->min_measured_value); - attribute::create_temperature_max_measured_value(cluster, config->max_measured_value); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_temperature_measured_value(cluster, config->measured_value); + attribute::create_temperature_min_measured_value(cluster, config->min_measured_value); + attribute::create_temperature_max_measured_value(cluster, config->max_measured_value); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } return cluster; @@ -1127,10 +1219,14 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) if (flags & CLUSTER_FLAG_SERVER) { /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); - attribute::create_occupancy(cluster, config->occupancy); - attribute::create_occupancy_sensor_type(cluster, config->occupancy_sensor_type); - attribute::create_occupancy_sensor_type_bitmap(cluster, config->occupancy_sensor_type_bitmap); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_occupancy(cluster, config->occupancy); + attribute::create_occupancy_sensor_type(cluster, config->occupancy_sensor_type); + attribute::create_occupancy_sensor_type_bitmap(cluster, config->occupancy_sensor_type_bitmap); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } return cluster; @@ -1160,8 +1256,12 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) if (flags & CLUSTER_FLAG_SERVER) { /* Attributes not managed internally */ - global::attribute::create_cluster_revision(cluster, config->cluster_revision); - attribute::state_value(cluster, config->state_value); + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::state_value(cluster, config->state_value); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } } return cluster; diff --git a/components/esp_matter/esp_matter_endpoint.cpp b/components/esp_matter/esp_matter_endpoint.cpp index 64f91df26..a19f8d9bf 100644 --- a/components/esp_matter/esp_matter_endpoint.cpp +++ b/components/esp_matter/esp_matter_endpoint.cpp @@ -23,7 +23,6 @@ #define ESP_MATTER_ON_OFF_LIGHT_DEVICE_TYPE_ID 0x0100 #define ESP_MATTER_DIMMABLE_LIGHT_DEVICE_TYPE_ID 0x0101 -#define ESP_MATTER_COLOR_DIMMABLE_LIGHT_DEVICE_TYPE_ID 0x0102 #define ESP_MATTER_COLOR_TEMPERATURE_LIGHT_DEVICE_TYPE_ID 0x010C #define ESP_MATTER_EXTENDED_COLOR_LIGHT_DEVICE_TYPE_ID 0x010D @@ -66,7 +65,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) descriptor::create(endpoint, CLUSTER_FLAG_SERVER); access_control::create(endpoint, CLUSTER_FLAG_SERVER); basic::create(endpoint, &(config->basic), CLUSTER_FLAG_SERVER); - ota_provider::create(endpoint, &(config->ota_provider), CLUSTER_FLAG_CLIENT); + ota_provider::create(endpoint, NULL, CLUSTER_FLAG_CLIENT); ota_requestor::create(endpoint, &(config->ota_requestor), CLUSTER_FLAG_SERVER); general_commissioning::create(endpoint, &(config->general_commissioning), CLUSTER_FLAG_SERVER); network_commissioning::create(endpoint, &(config->network_commissioning), CLUSTER_FLAG_SERVER); @@ -94,12 +93,11 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) } set_device_type_id(endpoint, get_device_type_id()); + descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); scenes::create(endpoint, &(config->scenes), CLUSTER_FLAG_SERVER); on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER, on_off::feature::lighting::get_id()); - basic::create(endpoint, &(config->basic), CLUSTER_FLAG_SERVER); - descriptor::create(endpoint, CLUSTER_FLAG_SERVER); return endpoint; } @@ -120,49 +118,18 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) } set_device_type_id(endpoint, get_device_type_id()); + descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); scenes::create(endpoint, &(config->scenes), CLUSTER_FLAG_SERVER); on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER, on_off::feature::lighting::get_id()); level_control::create(endpoint, &(config->level_control), CLUSTER_FLAG_SERVER, level_control::feature::on_off::get_id() | level_control::feature::lighting::get_id()); - basic::create(endpoint, &(config->basic), CLUSTER_FLAG_SERVER); - descriptor::create(endpoint, CLUSTER_FLAG_SERVER); return endpoint; } } /* dimmable_light */ -namespace color_dimmable_light { -uint32_t get_device_type_id() -{ - return ESP_MATTER_COLOR_DIMMABLE_LIGHT_DEVICE_TYPE_ID; -} - -endpoint_t *create(node_t *node, config_t *config, uint8_t flags) -{ - endpoint_t *endpoint = endpoint::create(node, flags); - if (!endpoint) { - ESP_LOGE(TAG, "Could not create endpoint"); - return NULL; - } - set_device_type_id(endpoint, get_device_type_id()); - - identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); - groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); - scenes::create(endpoint, &(config->scenes), CLUSTER_FLAG_SERVER); - on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER, on_off::feature::lighting::get_id()); - level_control::create(endpoint, &(config->level_control), CLUSTER_FLAG_SERVER, - level_control::feature::on_off::get_id() | level_control::feature::lighting::get_id()); - basic::create(endpoint, &(config->basic), CLUSTER_FLAG_SERVER); - descriptor::create(endpoint, CLUSTER_FLAG_SERVER); - color_control::create(endpoint, &(config->color_control), CLUSTER_FLAG_SERVER, - color_control::feature::hue_saturation::get_id()); - - return endpoint; -} -} /* color_dimmable_light */ - namespace color_temperature_light { uint32_t get_device_type_id() { @@ -178,13 +145,13 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) } set_device_type_id(endpoint, get_device_type_id()); + descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); scenes::create(endpoint, &(config->scenes), CLUSTER_FLAG_SERVER); on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER, on_off::feature::lighting::get_id()); level_control::create(endpoint, &(config->level_control), CLUSTER_FLAG_SERVER, level_control::feature::on_off::get_id() | level_control::feature::lighting::get_id()); - descriptor::create(endpoint, CLUSTER_FLAG_SERVER); color_control::create(endpoint, &(config->color_control), CLUSTER_FLAG_SERVER, color_control::feature::color_temperature::get_id()); @@ -207,13 +174,13 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) } set_device_type_id(endpoint, get_device_type_id()); + descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); scenes::create(endpoint, &(config->scenes), CLUSTER_FLAG_SERVER); on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER, on_off::feature::lighting::get_id()); level_control::create(endpoint, &(config->level_control), CLUSTER_FLAG_SERVER, level_control::feature::on_off::get_id() | level_control::feature::lighting::get_id()); - descriptor::create(endpoint, CLUSTER_FLAG_SERVER); color_control::create(endpoint, &(config->color_control), CLUSTER_FLAG_SERVER, color_control::feature::color_temperature::get_id() | color_control::feature::xy::get_id()); @@ -236,13 +203,12 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) } set_device_type_id(endpoint, get_device_type_id()); - identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); - binding::create(endpoint, &(config->binding), CLUSTER_FLAG_SERVER); - groups::create(endpoint, &(config->groups), CLUSTER_FLAG_CLIENT); - scenes::create(endpoint, &(config->scenes), CLUSTER_FLAG_CLIENT); - on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_CLIENT, ESP_MATTER_NONE_FEATURE_ID); - basic::create(endpoint, &(config->basic), CLUSTER_FLAG_SERVER); descriptor::create(endpoint, CLUSTER_FLAG_SERVER); + identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER | CLUSTER_FLAG_CLIENT); + binding::create(endpoint, &(config->binding), CLUSTER_FLAG_SERVER); + groups::create(endpoint, NULL, CLUSTER_FLAG_CLIENT); + scenes::create(endpoint, NULL, CLUSTER_FLAG_CLIENT); + on_off::create(endpoint, NULL, CLUSTER_FLAG_CLIENT, ESP_MATTER_NONE_FEATURE_ID); return endpoint; } @@ -263,13 +229,13 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) } set_device_type_id(endpoint, get_device_type_id()); - identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); - binding::create(endpoint, &(config->binding), CLUSTER_FLAG_SERVER); - groups::create(endpoint, &(config->groups), CLUSTER_FLAG_CLIENT); - scenes::create(endpoint, &(config->scenes), CLUSTER_FLAG_CLIENT); - on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_CLIENT, ESP_MATTER_NONE_FEATURE_ID); - level_control::create(endpoint, &(config->level_control), CLUSTER_FLAG_CLIENT, ESP_MATTER_NONE_FEATURE_ID); descriptor::create(endpoint, CLUSTER_FLAG_SERVER); + identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER | CLUSTER_FLAG_CLIENT); + binding::create(endpoint, &(config->binding), CLUSTER_FLAG_SERVER); + groups::create(endpoint, NULL, CLUSTER_FLAG_CLIENT); + scenes::create(endpoint, NULL, CLUSTER_FLAG_CLIENT); + on_off::create(endpoint, NULL, CLUSTER_FLAG_CLIENT, ESP_MATTER_NONE_FEATURE_ID); + level_control::create(endpoint, NULL, CLUSTER_FLAG_CLIENT, ESP_MATTER_NONE_FEATURE_ID); return endpoint; } @@ -290,14 +256,14 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) } set_device_type_id(endpoint, get_device_type_id()); - identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); - binding::create(endpoint, &(config->binding), CLUSTER_FLAG_SERVER); - groups::create(endpoint, &(config->groups), CLUSTER_FLAG_CLIENT); - scenes::create(endpoint, &(config->scenes), CLUSTER_FLAG_CLIENT); - on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_CLIENT, ESP_MATTER_NONE_FEATURE_ID); - level_control::create(endpoint, &(config->level_control), CLUSTER_FLAG_CLIENT, ESP_MATTER_NONE_FEATURE_ID); - color_control::create(endpoint, &(config->color_control), CLUSTER_FLAG_CLIENT, ESP_MATTER_NONE_FEATURE_ID); descriptor::create(endpoint, CLUSTER_FLAG_SERVER); + identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER | CLUSTER_FLAG_CLIENT); + binding::create(endpoint, &(config->binding), CLUSTER_FLAG_SERVER); + groups::create(endpoint, NULL, CLUSTER_FLAG_CLIENT); + scenes::create(endpoint, NULL, CLUSTER_FLAG_CLIENT); + on_off::create(endpoint, NULL, CLUSTER_FLAG_CLIENT, ESP_MATTER_NONE_FEATURE_ID); + level_control::create(endpoint, NULL, CLUSTER_FLAG_CLIENT, ESP_MATTER_NONE_FEATURE_ID); + color_control::create(endpoint, NULL, CLUSTER_FLAG_CLIENT, ESP_MATTER_NONE_FEATURE_ID); return endpoint; } @@ -318,13 +284,13 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) } set_device_type_id(endpoint, get_device_type_id()); + descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); scenes::create(endpoint, &(config->scenes), CLUSTER_FLAG_SERVER); on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER, on_off::feature::lighting::get_id()); level_control::create(endpoint, &(config->level_control), CLUSTER_FLAG_SERVER, level_control::feature::on_off::get_id() | level_control::feature::lighting::get_id()); - descriptor::create(endpoint, CLUSTER_FLAG_SERVER); return endpoint; } @@ -345,13 +311,13 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) } set_device_type_id(endpoint, get_device_type_id()); + descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); scenes::create(endpoint, &(config->scenes), CLUSTER_FLAG_SERVER); on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER, on_off::feature::lighting::get_id()); level_control::create(endpoint, &(config->level_control), CLUSTER_FLAG_SERVER, level_control::feature::on_off::get_id() | level_control::feature::lighting::get_id()); - descriptor::create(endpoint, CLUSTER_FLAG_SERVER); return endpoint; } @@ -372,9 +338,9 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) } set_device_type_id(endpoint, get_device_type_id()); + descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); - descriptor::create(endpoint, CLUSTER_FLAG_SERVER); fan_control::create(endpoint, &(config->fan_control), CLUSTER_FLAG_SERVER); return endpoint; @@ -396,11 +362,10 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) } set_device_type_id(endpoint, get_device_type_id()); + descriptor::create(endpoint, CLUSTER_FLAG_SERVER); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); groups::create(endpoint, &(config->groups), CLUSTER_FLAG_SERVER); scenes::create(endpoint, &(config->scenes), CLUSTER_FLAG_SERVER); - basic::create(endpoint, &(config->basic), CLUSTER_FLAG_SERVER); - descriptor::create(endpoint, CLUSTER_FLAG_SERVER); cluster::thermostat::create(endpoint, &(config->thermostat), CLUSTER_FLAG_SERVER); return endpoint; @@ -455,8 +420,8 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) set_device_type_id(endpoint, get_device_type_id()); - identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); descriptor::create(endpoint, CLUSTER_FLAG_SERVER); + identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); cluster::door_lock::create(endpoint, &(config->door_lock), CLUSTER_FLAG_SERVER); time_synchronization::create(endpoint, &(config->time_synchronization), CLUSTER_FLAG_SERVER); @@ -480,7 +445,7 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags) set_device_type_id(endpoint, get_device_type_id()); identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER | CLUSTER_FLAG_CLIENT); - groups::create(endpoint, &(config->groups), CLUSTER_FLAG_CLIENT); + groups::create(endpoint, NULL, CLUSTER_FLAG_CLIENT); temperature_measurement::create(endpoint, &(config->temperature_measurement), CLUSTER_FLAG_SERVER); return endpoint; diff --git a/components/esp_matter/esp_matter_endpoint.h b/components/esp_matter/esp_matter_endpoint.h index c4d241842..08fc72ae8 100644 --- a/components/esp_matter/esp_matter_endpoint.h +++ b/components/esp_matter/esp_matter_endpoint.h @@ -33,7 +33,6 @@ namespace endpoint { namespace root_node { typedef struct config { basic::config_t basic; - ota_provider::config_t ota_provider; ota_requestor::config_t ota_requestor; general_commissioning::config_t general_commissioning; network_commissioning::config_t network_commissioning; @@ -52,7 +51,6 @@ typedef struct config { groups::config_t groups; scenes::config_t scenes; on_off::config_t on_off; - basic::config_t basic; } config_t; uint32_t get_device_type_id(); @@ -66,28 +64,12 @@ typedef struct config { scenes::config_t scenes; on_off::config_t on_off; level_control::config_t level_control; - basic::config_t basic; } config_t; uint32_t get_device_type_id(); endpoint_t *create(node_t *node, config_t *config, uint8_t flags); } /* dimmable_light */ -namespace color_dimmable_light { -typedef struct config { - identify::config_t identify; - groups::config_t groups; - scenes::config_t scenes; - on_off::config_t on_off; - level_control::config_t level_control; - basic::config_t basic; - color_control::config_t color_control; -} config_t; - -uint32_t get_device_type_id(); -endpoint_t *create(node_t *node, config_t *config, uint8_t flags); -} /* color_dimmable_light */ - namespace color_temperature_light { typedef struct config { identify::config_t identify; @@ -119,10 +101,6 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags); namespace on_off_switch { typedef struct config { identify::config_t identify; - groups::config_t groups; - scenes::config_t scenes; - on_off::config_t on_off; - basic::config_t basic; binding::config_t binding; } config_t; @@ -133,10 +111,6 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags); namespace dimmer_switch { typedef struct config { identify::config_t identify; - groups::config_t groups; - scenes::config_t scenes; - on_off::config_t on_off; - level_control::config_t level_control; binding::config_t binding; } config_t; @@ -147,11 +121,6 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags); namespace color_dimmer_switch { typedef struct config { identify::config_t identify; - groups::config_t groups; - scenes::config_t scenes; - on_off::config_t on_off; - level_control::config_t level_control; - color_control::config_t color_control; binding::config_t binding; } config_t; @@ -201,7 +170,6 @@ typedef struct config { identify::config_t identify; groups::config_t groups; scenes::config_t scenes; - basic::config_t basic; cluster::thermostat::config_t thermostat; } config_t; @@ -237,7 +205,6 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags); namespace temperature_sensor { typedef struct config { identify::config_t identify; - groups::config_t groups; temperature_measurement::config_t temperature_measurement; } config_t; diff --git a/docs/en/developing.rst b/docs/en/developing.rst index 0a387efe4..c0388e719 100644 --- a/docs/en/developing.rst +++ b/docs/en/developing.rst @@ -313,15 +313,13 @@ for clarity on the terms like endpoints, clusters, etc. that are used in this se :: - color_dimmable_light::config_t light_config; + color_temperature_light::config_t light_config; light_config.on_off.on_off = DEFAULT_POWER; light_config.level_control.current_level = DEFAULT_BRIGHTNESS; - light_config.color_control.hue_saturation.current_hue = DEFAULT_HUE; - light_config.color_control.hue_saturation.current_saturation = DEFAULT_SATURATION; - endpoint_t *endpoint = color_dimmable_light::create(node, &light_config, ENDPOINT_FLAG_NONE); + endpoint_t *endpoint = color_temperature_light::create(node, &light_config, ENDPOINT_FLAG_NONE); - In this case, we create the light using the ``color_dimmable_light::create()`` function. Similarly, multiple - endpoints can be created on the same endpoint. Check the following + In this case, we create the light using the ``color_temperature_light::create()`` function. Similarly, multiple + endpoints can be created on the same node. Check the following sections for more info. 2.4.1.2 Attribute Callback @@ -380,8 +378,8 @@ for clarity on the terms like endpoints, clusters, etc. that are used in this se - The driver's attribute update API just handles the attributes that are actually relevant for the device. For example, a - color_dimmable_light handles the power, brightness, hue and - saturation. + color_temperature_light handles the power, brightness, hue, + saturation and temperature. :: @@ -403,6 +401,8 @@ for clarity on the terms like endpoints, clusters, etc. that are used in this se err = app_driver_light_set_hue(val); } else if (attribute_id == ColorControl::Attributes::CurrentSaturation::Id) { err = app_driver_light_set_saturation(val); + } else if (attribute_id == ColorControl::Attributes::ColorTemperature::Id) { + err = app_driver_light_set_temperature(val); } } } @@ -675,7 +675,7 @@ subsection for :ref:`Using a different button driver