mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
Merge branch 'attribute_override_restriction' into 'main'
attribute_override: Add attribute type restriction for attribute_override callback See merge request app-frameworks/esp-matter!562
This commit is contained in:
@@ -1354,6 +1354,17 @@ esp_err_t set_override_callback(attribute_t *attribute, callback_t callback)
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
_attribute_t *current_attribute = (_attribute_t *)attribute;
|
||||
if (current_attribute->val.type == ESP_MATTER_VAL_TYPE_ARRAY ||
|
||||
current_attribute->val.type == ESP_MATTER_VAL_TYPE_OCTET_STRING ||
|
||||
current_attribute->val.type == ESP_MATTER_VAL_TYPE_CHAR_STRING ||
|
||||
current_attribute->val.type == ESP_MATTER_VAL_TYPE_LONG_CHAR_STRING ||
|
||||
current_attribute->val.type == ESP_MATTER_VAL_TYPE_LONG_OCTET_STRING) {
|
||||
// The override callback might allocate memory and we have no way to free the memory
|
||||
// TODO: Add memory-safe override callback for these attribute types
|
||||
ESP_LOGE(TAG, "Cannot set override callback for attribute 0x%" PRIX32 " on cluster 0x%" PRIX32,
|
||||
current_attribute->attribute_id, current_attribute->cluster_id);
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
}
|
||||
current_attribute->override_callback = callback;
|
||||
current_attribute->flags |= ATTRIBUTE_FLAG_OVERRIDE;
|
||||
return ESP_OK;
|
||||
|
||||
Reference in New Issue
Block a user