espressif / esp-zigbee-sdk

Espressif Zigbee SDK
Apache License 2.0
122 stars 19 forks source link

How does the write command work? (TZ-719) #300

Closed HOSTEER closed 2 months ago

HOSTEER commented 2 months ago

Question

Hello, I'm trying to write multiple attributes simultaneously, I'm using a custom cluster. When I use the write command the ESP32-C6 reset itself. Can someone help me to know how to properly make the cmd_req to write ?

Additional context.

No response

xieqinan commented 2 months ago

@HOSTEER

suggestion;

esp_zb_zcl_attribute_t attr_field[] = 
{
   {CUSTOM_OT_CLUSTER_ATTR_ERROR_ID + 0, {ESP_ZB_ZCL_ATTR_TYPE_U32, sizeof(uint32_t), reported_data[0]}},
   {CUSTOM_OT_CLUSTER_ATTR_ERROR_ID + 1, {ESP_ZB_ZCL_ATTR_TYPE_U32, sizeof(uint32_t), reported_data[1]}},
   {CUSTOM_OT_CLUSTER_ATTR_ERROR_ID + 2, {ESP_ZB_ZCL_ATTR_TYPE_U32, sizeof(uint32_t), reported_data[2]}},
}
esp_zb_zcl_write_attr_cmd_t cmd_req = {
                        .zcl_basic_cmd = {
                            .dst_addr_u.addr_short = 0x000,
                            .dst_endpoint = HA_ESP_LIGHT_ENDPOINT,
                            .src_endpoint = HA_ONOFF_SWITCH_ENDPOINT,
                        },
                        .address_mode = ESP_ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
                        .clusterID = CUSTOM_OT_CLUSTER_ID,
                        .attr_number = 3,
                        . attr_field = attr_field,
                    };
esp_zb_lock_acquire(portMAX_DELAY);
esp_zb_zcl_write_attr_cmd_req(&cmd_req);
esp_zb_lock_release();
HOSTEER commented 2 months ago

Thank you a lot ! It works now