mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 19:13:13 +00:00
esp_matter: Make the attribute buffer largest configurable
This commit is contained in:
committed by
shripad621git
parent
5abc3095da
commit
47ddf124e3
@@ -7,6 +7,13 @@ menu "ESP Matter"
|
|||||||
help
|
help
|
||||||
The maximum device type count supported per endpoint.
|
The maximum device type count supported per endpoint.
|
||||||
|
|
||||||
|
config ESP_MATTER_ATTRIBUTE_BUFFER_LARGEST
|
||||||
|
int "Largest attribute buffer size"
|
||||||
|
default 259
|
||||||
|
help
|
||||||
|
The Largest attribute size required for various attributes, the buffer will be used
|
||||||
|
for reading or writing attributes.
|
||||||
|
|
||||||
config ESP_MATTER_NVS_PART_NAME
|
config ESP_MATTER_NVS_PART_NAME
|
||||||
string "ESP Matter NVS partition name"
|
string "ESP Matter NVS partition name"
|
||||||
default "nvs"
|
default "nvs"
|
||||||
|
|||||||
@@ -1106,6 +1106,12 @@ esp_err_t get_data_from_attr_val(esp_matter_attr_val_t *val, EmberAfAttributeTyp
|
|||||||
if (value) {
|
if (value) {
|
||||||
int data_size_len = val->val.a.t - val->val.a.s;
|
int data_size_len = val->val.a.t - val->val.a.s;
|
||||||
memcpy(value, (uint8_t *)&val->val.a.s, data_size_len);
|
memcpy(value, (uint8_t *)&val->val.a.s, data_size_len);
|
||||||
|
if (*attribute_size > CONFIG_ESP_MATTER_ATTRIBUTE_BUFFER_LARGEST)
|
||||||
|
{
|
||||||
|
ESP_LOGE(TAG, "Attribute buffer not enough, cannot copy the data to the attribute buffer."
|
||||||
|
"Please configure the buffer size through menuconfig ESP_MATTER_ATTRIBUTE_BUFFER_LARGEST");
|
||||||
|
return ESP_FAIL;
|
||||||
|
}
|
||||||
memcpy((value + data_size_len), (uint8_t *)val->val.a.b, (*attribute_size - data_size_len));
|
memcpy((value + data_size_len), (uint8_t *)val->val.a.b, (*attribute_size - data_size_len));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1120,6 +1126,12 @@ esp_err_t get_data_from_attr_val(esp_matter_attr_val_t *val, EmberAfAttributeTyp
|
|||||||
if (value) {
|
if (value) {
|
||||||
int data_size_len = val->val.a.t - val->val.a.s;
|
int data_size_len = val->val.a.t - val->val.a.s;
|
||||||
memcpy(value, (uint8_t *)&val->val.a.s, data_size_len);
|
memcpy(value, (uint8_t *)&val->val.a.s, data_size_len);
|
||||||
|
if (*attribute_size > CONFIG_ESP_MATTER_ATTRIBUTE_BUFFER_LARGEST)
|
||||||
|
{
|
||||||
|
ESP_LOGE(TAG, "Attribute buffer not enough, cannot copy the data to the attribute buffer."
|
||||||
|
"Please configure the buffer size through menuconfig ESP_MATTER_ATTRIBUTE_BUFFER_LARGEST");
|
||||||
|
return ESP_FAIL;
|
||||||
|
}
|
||||||
memcpy((value + data_size_len), (uint8_t *)val->val.a.b, (*attribute_size - data_size_len));
|
memcpy((value + data_size_len), (uint8_t *)val->val.a.b, (*attribute_size - data_size_len));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1134,6 +1146,12 @@ esp_err_t get_data_from_attr_val(esp_matter_attr_val_t *val, EmberAfAttributeTyp
|
|||||||
if (value) {
|
if (value) {
|
||||||
int data_size_len = val->val.a.t - val->val.a.s;
|
int data_size_len = val->val.a.t - val->val.a.s;
|
||||||
memcpy(value, (uint8_t *)&val->val.a.s, data_size_len);
|
memcpy(value, (uint8_t *)&val->val.a.s, data_size_len);
|
||||||
|
if (*attribute_size > CONFIG_ESP_MATTER_ATTRIBUTE_BUFFER_LARGEST)
|
||||||
|
{
|
||||||
|
ESP_LOGE(TAG, "Attribute buffer not enough, cannot copy the data to the attribute buffer."
|
||||||
|
"Please configure the buffer size through menuconfig ESP_MATTER_ATTRIBUTE_BUFFER_LARGEST");
|
||||||
|
return ESP_FAIL;
|
||||||
|
}
|
||||||
memcpy((value + data_size_len), (uint8_t *)val->val.a.b, (*attribute_size - data_size_len));
|
memcpy((value + data_size_len), (uint8_t *)val->val.a.b, (*attribute_size - data_size_len));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
#define ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT 0
|
#define ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT 0
|
||||||
|
|
||||||
// Largest attribute size is needed for various buffers
|
// Largest attribute size is needed for various buffers
|
||||||
#define ATTRIBUTE_LARGEST (259)
|
#define ATTRIBUTE_LARGEST CONFIG_ESP_MATTER_ATTRIBUTE_BUFFER_LARGEST
|
||||||
|
|
||||||
static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE, "ATTRIBUTE_LARGEST larger than expected");
|
static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE, "ATTRIBUTE_LARGEST larger than expected");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user