Closed remenyo closed 3 months ago
@remenyo ,
The issue is caused by the absence of an attribute in the thermostat cluster. The esp_zb_thermostat_cluster_create()
function only creates the mandatory attributes defined in the ZCL specification. The ZB_ZCL_ATTR_THERMOSTAT_OCCUPANCY_ID
is an optional attribute, which requires to be added by the user. You can refer to the code below to resolve this issue.
uint8_t thermostat_occupancy = 0;
esp_zb_attribute_list_t *thermostat_cluster_attr_list = esp_zb_thermostat_cluster_create(&(thermostat_cfg.thermostat_cfg));
esp_zb_thermostat_cluster_add_attr(thermostat_cluster_attr_list, ESP_ZB_ZCL_ATTR_THERMOSTAT_OCCUPANCY_ID, &thermostat_occupancy);
Thank you for your help, this was the solution to my problem indeed.
So this is not a bug, optional attributes are not created with esp_zb_*clustername*_cluster_create
May I also ask how to traverse through the cluster list, to examine the list?
// this does _not_ work correctly
for (esp_zb_cluster_list_t *c = cluster_list; cluster_list != NULL; c = c->next)
{
LOGI("Cluster ID: 0x%04x", c->cluster.cluster_id);
for (esp_zb_attribute_list_t *a = c->cluster.attr_list; a != NULL; a = a->next)
{
LOGI("Attribute ID: 0x%04x, Type: 0x%02x, Access: 0x%02x)", a->attribute.id, a->attribute.type, a->attribute.access);
}
}
This outputs:
I esp_zb_task: Cluster ID: 0x0000
I esp_zb_task: Cluster ID: 0x0b05
I esp_zb_task: Attribute ID: 0x0000, Type: 0x00, Access: 0x00)
I esp_zb_task: Attribute ID: 0xfffd, Type: 0x21, Access: 0x01)
I esp_zb_task: Cluster ID: 0x0201
I esp_zb_task: Attribute ID: 0x0000, Type: 0x00, Access: 0x00)
I esp_zb_task: Attribute ID: 0xfffd, Type: 0x21, Access: 0x01)
I esp_zb_task: Attribute ID: 0x0000, Type: 0x29, Access: 0x05)
I esp_zb_task: Attribute ID: 0x0011, Type: 0x29, Access: 0x13)
I esp_zb_task: Attribute ID: 0x0012, Type: 0x29, Access: 0x13)
I esp_zb_task: Attribute ID: 0x001b, Type: 0x30, Access: 0x03)
I esp_zb_task: Attribute ID: 0x001c, Type: 0x30, Access: 0x13)
...
Guru Meditation Error: Core 0 panic'ed (Load access fault). Exception was unhandled.
Core 0 register dump:
MEPC : 0x42006d18 RA : 0x42006d56 SP : 0x40851900 GP : 0x4080f0f0
TP : 0x40803e0c T0 : 0x40022494 T1 : 0xffffffe0 T2 : 0x00000200
S0/FP : 0x00000000 S1 : 0x00000001 A0 : 0x0000003f A1 : 0x40857fec
A2 : 0x00000010 A3 : 0x00000800 A4 : 0x00000001 A5 : 0x00000004
A6 : 0x00000001 A7 : 0x42005444 S2 : 0x40857ef4 S3 : 0x42121000
S4 : 0x42121000 S5 : 0x00000000 S6 : 0x42121000 S7 : 0x00000000
S8 : 0x00000000 S9 : 0x00000000 S10 : 0x00000000 S11 : 0x00000000
T3 : 0x00000000 T4 : 0x00000000 T5 : 0x0000000f T6 : 0xffffffb1
MSTATUS : 0x00001881 MTVEC : 0x40800001 MCAUSE : 0x00000005 MTVAL : 0x00000000
MHARTID : 0x00000000
@remenyo ,
suggestion:
for (esp_zb_cluster_list_t *c = cluster_list; c != NULL; c = c->next)
{
LOGI("Cluster ID: 0x%04x", c->cluster.cluster_id);
for (esp_zb_attribute_list_t *a = c->cluster.attr_list; a != NULL; a = a->next)
{
LOGI("Attribute ID: 0x%04x, Type: 0x%02x, Access: 0x%02x)", a->attribute.id, a->attribute.type, a->attribute.access);
}
}
Again, thank you very much.
Answers checklist.
IDF version.
v5.1.4
esp-zigbee-lib version.
1.4.1
esp-zboss-lib version.
1.4.1
Espressif SoC revision.
ESP32-C6
What is the expected behavior?
esp_zb_zcl_get_attribute should work on a read-only attribute, in this example, thermostat occupancy (Cluster ID: 0x0201, Attribute ID: 0x0002)
What is the actual behavior?
Steps to reproduce.
This works fine:
Outputs:
This does not work:
Outputs:
I : Write status: 1
then crash.More Information.
I hope that with the first (working) example I proved that I set up the thermostat cluster correctly, but feel free to check it: