Skip to content

Commit

Permalink
Merge branch 'esp_matter/memory_optimization' into 'main'
Browse files Browse the repository at this point in the history
components/esp_matter: memory optimization for the attributes managed internally

See merge request app-frameworks/esp-matter!821
  • Loading branch information
chshu committed Nov 5, 2024
2 parents af3da26 + bcd364f commit ab4aa48
Show file tree
Hide file tree
Showing 10 changed files with 924 additions and 511 deletions.
8 changes: 8 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 15-Oct-2024

API Change
```
esp_err_t get_bounds(attribute_t *attribute, esp_matter_attr_bounds_t *bounds);
```
- Above API returns the `esp_err_t` and has parameter `bounds`.

# 28-Aug-2024

- Removed the configurability of the NameSupport attribute of the Groups cluster and enabled
Expand Down
9 changes: 6 additions & 3 deletions components/esp_matter/esp_matter.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,21 @@ typedef enum attribute_flags {
/** The attribute has bounds */
ATTRIBUTE_FLAG_MIN_MAX = ATTRIBUTE_MASK_MIN_MAX, /* 0x04 */
ATTRIBUTE_FLAG_MUST_USE_TIMED_WRITE = ATTRIBUTE_MASK_MUST_USE_TIMED_WRITE, /* 0x08 */
/** The attribute uses external storage for its value. If the ESP Matter data model is used, all the attributes
/** The attribute uses external storage for its value. If attributes
have this flag enabled, as all of them are stored in the ESP Matter database. */
ATTRIBUTE_FLAG_EXTERNAL_STORAGE = ATTRIBUTE_MASK_EXTERNAL_STORAGE, /* 0x10 */
ATTRIBUTE_FLAG_SINGLETON = ATTRIBUTE_MASK_SINGLETON, /* 0x20 */
ATTRIBUTE_FLAG_NULLABLE = ATTRIBUTE_MASK_NULLABLE, /* 0x40 */
/** The attribute read and write are overridden. The attribute value will be fetched from and will be updated using
the override callback. The value of this attribute is not maintained internally. */
ATTRIBUTE_FLAG_OVERRIDE = ATTRIBUTE_FLAG_NULLABLE << 1, /* 0x100 */
ATTRIBUTE_FLAG_OVERRIDE = ATTRIBUTE_FLAG_NULLABLE << 1, /* 0x80 */
/** The attribute is non-volatile but its value will be changed frequently. If an attribute has this flag, its value
will not be written to flash immediately. A timer will be started and the attribute value will be written after
timeout. */
ATTRIBUTE_FLAG_DEFERRED = ATTRIBUTE_FLAG_NULLABLE << 2, /* 0x200 */
ATTRIBUTE_FLAG_DEFERRED = ATTRIBUTE_FLAG_NULLABLE << 2, /* 0x100 */
/** The attribute is managed internally and is not stored in the ESP Matter database.
If not set, ATTRIBUTE_FLAG_EXTERNAL_STORAGE flag will be enabled. */
ATTRIBUTE_FLAG_MANAGED_INTERNALLY = ATTRIBUTE_FLAG_NULLABLE << 3, /* 0x200 */
} attribute_flags_t;

/** Command flags */
Expand Down
208 changes: 104 additions & 104 deletions components/esp_matter/esp_matter_attribute.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion components/esp_matter/esp_matter_attribute_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ esp_err_t get_data_from_attr_val(esp_matter_attr_val_t *val, EmberAfAttributeTyp
return ESP_OK;
}

static esp_err_t get_attr_val_from_data(esp_matter_attr_val_t *val, EmberAfAttributeType attribute_type,
esp_err_t get_attr_val_from_data(esp_matter_attr_val_t *val, EmberAfAttributeType attribute_type,
uint16_t attribute_size, uint8_t *value,
const EmberAfAttributeMetadata * attribute_metadata)
{
Expand Down
141 changes: 0 additions & 141 deletions components/esp_matter/esp_matter_cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
global::attribute::create_cluster_revision(cluster, cluster_revision);
}

/* Commands */
command::create_query_image(cluster);
command::create_query_image_response(cluster);
command::create_apply_update_request(cluster);
command::create_apply_update_response(cluster);
command::create_notify_update_applied(cluster);

return cluster;
}
} /* ota_provider */
Expand Down Expand Up @@ -380,9 +373,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
event::create_state_transition(cluster);
event::create_version_applied(cluster);

/* Commands */
command::create_announce_ota_provider(cluster);

return cluster;
}
} /* ota_requestor */
Expand Down Expand Up @@ -421,14 +411,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
}
}

/* Commands */
command::create_arm_fail_safe(cluster);
command::create_arm_fail_safe_response(cluster);
command::create_set_regulatory_config(cluster);
command::create_set_regulatory_config_response(cluster);
command::create_commissioning_complete(cluster);
command::create_commissioning_complete_response(cluster);

return cluster;
}
} /* general_commissioning */
Expand Down Expand Up @@ -473,19 +455,12 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
}

/* Commands */
command::create_scan_networks(cluster);
command::create_scan_networks_response(cluster);
if (config->feature_map & chip::to_underlying(NetworkCommissioning::Feature::kWiFiNetworkInterface)) {
command::create_add_or_update_wifi_network(cluster);
}
if (config->feature_map & chip::to_underlying(NetworkCommissioning::Feature::kThreadNetworkInterface)) {
command::create_add_or_update_thread_network(cluster);
}
command::create_remove_network(cluster);
command::create_network_config_response(cluster);
command::create_connect_network(cluster);
command::create_connect_network_response(cluster);
command::create_reorder_network(cluster);

return cluster;
}
Expand Down Expand Up @@ -521,10 +496,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)

event::create_boot_reason(cluster);

command::create_test_event_trigger(cluster);
command::create_time_snap_shot(cluster);
command::create_time_snap_shot_response(cluster);

return cluster;
}
} /* general_diagnostics */
Expand Down Expand Up @@ -562,10 +533,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
feature::basic::add(cluster);
}

/* Commands */
command::create_open_commissioning_window(cluster);
command::create_revoke_commissioning(cluster);

return cluster;
}
} /* administrator_commissioning */
Expand Down Expand Up @@ -601,20 +568,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
global::attribute::create_cluster_revision(cluster, cluster_revision);
}

/* Commands */
command::create_attestation_request(cluster);
command::create_attestation_response(cluster);
command::create_certificate_chain_request(cluster);
command::create_certificate_chain_response(cluster);
command::create_csr_request(cluster);
command::create_csr_response(cluster);
command::create_add_noc(cluster);
command::create_update_noc(cluster);
command::create_noc_response(cluster);
command::create_update_fabric_label(cluster);
command::create_remove_fabric(cluster);
command::create_add_trusted_root_certificate(cluster);

return cluster;
}
} /* operational_credentials */
Expand Down Expand Up @@ -646,14 +599,6 @@ cluster_t *create(endpoint_t *endpoint, uint8_t flags)
attribute::create_max_group_keys_per_fabric(cluster, 0);
}

/* Commands */
command::create_key_set_write(cluster);
command::create_key_set_read(cluster);
command::create_key_set_read_response(cluster);
command::create_key_set_remove(cluster);
command::create_key_set_read_all_indices(cluster);
command::create_key_set_read_all_indices_response(cluster);

return cluster;
}
} /* group_key_management */
Expand Down Expand Up @@ -762,9 +707,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
global::attribute::create_cluster_revision(cluster, cluster_revision);
}

/* Commands */
command::create_reset_counts(cluster);

return cluster;
}
} /* ethernet_network_diagnostics */
Expand Down Expand Up @@ -1064,9 +1006,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
uint16_t endpoint_id = endpoint::get_id(endpoint);
identification::init(endpoint_id, config->identify_type);

/* Commands */
command::create_identify(cluster);

return cluster;
}
} /* identify */
Expand Down Expand Up @@ -1107,18 +1046,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
server_cluster_count++;
}

/* Commands */
command::create_add_group(cluster);
command::create_view_group(cluster);
command::create_get_group_membership(cluster);
command::create_remove_group(cluster);
command::create_remove_all_groups(cluster);
command::create_add_group_if_identifying(cluster);
command::create_add_group_response(cluster);
command::create_view_group_response(cluster);
command::create_get_group_membership_response(cluster);
command::create_remove_group_response(cluster);

return cluster;
}
} /* groups */
Expand Down Expand Up @@ -1157,21 +1084,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
}
}

/* Commands */
command::create_add_scene(cluster);
command::create_view_scene(cluster);
command::create_remove_scene(cluster);
command::create_remove_all_scenes(cluster);
command::create_store_scene(cluster);
command::create_recall_scene(cluster);
command::create_get_scene_membership(cluster);
command::create_add_scene_response(cluster);
command::create_view_scene_response(cluster);
command::create_remove_scene_response(cluster);
command::create_remove_all_scenes_response(cluster);
command::create_store_scene_response(cluster);
command::create_get_scene_membership_response(cluster);

return cluster;
}
} /* scenes_management */
Expand Down Expand Up @@ -1223,7 +1135,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
}

/* Commands */
command::create_off(cluster);
if (!(features & feature::off_only::get_id())) {
command::create_on(cluster);
command::create_toggle(cluster);
Expand Down Expand Up @@ -1268,16 +1179,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
}
}

/* Commands */
command::create_move_to_level(cluster);
command::create_move(cluster);
command::create_step(cluster);
command::create_stop(cluster);
command::create_move_to_level_with_on_off(cluster);
command::create_move_with_on_off(cluster);
command::create_step_with_on_off(cluster);
command::create_stop_with_on_off(cluster);

/* Features */
if (features & feature::on_off::get_id()) {
feature::on_off::add(cluster);
Expand Down Expand Up @@ -1448,9 +1349,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
create_default_binding_cluster(endpoint);
}

/* Commands */
command::create_setpoint_raise_lower(cluster);

/* Features */
if (!(features & (feature::heating::get_id() | feature::cooling::get_id()))) {
ESP_LOGE(TAG, "Cluster shall support at least one of heating or cooling features.");
Expand Down Expand Up @@ -2086,10 +1984,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
event::create_lock_operation(cluster);
event::create_lock_operation_error(cluster);

/* Commands */
command::create_lock_door(cluster);
command::create_unlock_door(cluster);

return cluster;
}
} /* door_lock */
Expand Down Expand Up @@ -2138,11 +2032,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
create_default_binding_cluster(endpoint);
}

/* Commands */
command::create_up_or_open(cluster);
command::create_down_or_close(cluster);
command::create_stop_motion(cluster);

/* Features */
if (features & feature::lift::get_id()) {
feature::lift::add(cluster, &(config->lift));
Expand Down Expand Up @@ -2679,9 +2568,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
create_default_binding_cluster(endpoint);
}

/* Commands */
command::create_change_to_mode(cluster);

/* Features */
if (features & feature::on_off::get_id()) {
feature::on_off::add(cluster, &(config->on_off));
Expand Down Expand Up @@ -2714,10 +2600,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
create_default_binding_cluster(endpoint);
}

/* commands */
command::create_retrieve_logs_request(cluster);
command::create_retrieve_logs_response(cluster);

return cluster;
}
} /* diagnostic_logs */
Expand Down Expand Up @@ -2778,9 +2660,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
global::attribute::create_cluster_revision(cluster, cluster_revision);
}

/* Commands */
command::create_set_temperature(cluster);

/* Features */
if (features & feature::temperature_number::get_id()) {
feature::temperature_number::add(cluster, &(config->temperature_number));
Expand Down Expand Up @@ -3014,9 +2893,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
global::attribute::create_cluster_revision(cluster, cluster_revision);
}

/* Commands */
command::create_set_cooking_parameters(cluster);

if (features & feature::power_as_number::get_id()) {
feature::power_as_number::add(cluster);
}
Expand Down Expand Up @@ -3092,10 +2968,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
global::attribute::create_cluster_revision(cluster, cluster_revision);
}

/* Commands */
command::create_send_key(cluster);
command::create_send_key_response(cluster);

return cluster;
}
} /* keypad_input */
Expand Down Expand Up @@ -3347,10 +3219,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
feature::v2x::add(cluster);
}

/* Commands */
command::create_disable(cluster);
command::create_enable_charging(cluster);

return cluster;
}
} /* energy_evse */
Expand Down Expand Up @@ -3395,10 +3263,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
create_default_binding_cluster(endpoint);
}

/* Commands */
command::create_open(cluster);
command::create_close(cluster);

/* Features */
if (features & feature::time_sync::get_id()) {
feature::time_sync::add(cluster, &(config->time_sync));
Expand Down Expand Up @@ -3592,11 +3456,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
global::attribute::create_cluster_revision(cluster, cluster_revision);
}

command::create_get_active_dataset_request(cluster);
command::create_get_pending_dataset_request(cluster);
command::create_dataset_response(cluster);
command::create_set_active_dataset_request(cluster);

if (features & feature::pan_change::get_id()) {
feature::pan_change::add(cluster);
}
Expand Down
Loading

0 comments on commit ab4aa48

Please sign in to comment.