@@ -31,7 +31,7 @@ void ZigbeeDoorWindowHandle::setIASClientEndpoint(uint8_t ep_number) {
3131
3232void ZigbeeDoorWindowHandle::setClosed () {
3333 log_v (" Setting Door/Window handle to closed" );
34- uint8_t closed = 0 ; // ALARM1 = 0, ALARM2 = 0
34+ uint8_t closed = 0 ; // ALARM1 = 0, ALARM2 = 0
3535 esp_zb_lock_acquire (portMAX_DELAY);
3636 esp_zb_zcl_set_attribute_val (
3737 _endpoint, ESP_ZB_ZCL_CLUSTER_ID_IAS_ZONE, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_IAS_ZONE_ZONESTATUS_ID, &closed, false
@@ -43,19 +43,17 @@ void ZigbeeDoorWindowHandle::setClosed() {
4343
4444void ZigbeeDoorWindowHandle::setOpen () {
4545 log_v (" Setting Door/Window handle to open" );
46- uint8_t open = ESP_ZB_ZCL_IAS_ZONE_ZONE_STATUS_ALARM1 | ESP_ZB_ZCL_IAS_ZONE_ZONE_STATUS_ALARM2; // ALARM1 = 1, ALARM2 = 1
46+ uint8_t open = ESP_ZB_ZCL_IAS_ZONE_ZONE_STATUS_ALARM1 | ESP_ZB_ZCL_IAS_ZONE_ZONE_STATUS_ALARM2; // ALARM1 = 1, ALARM2 = 1
4747 esp_zb_lock_acquire (portMAX_DELAY);
48- esp_zb_zcl_set_attribute_val (
49- _endpoint, ESP_ZB_ZCL_CLUSTER_ID_IAS_ZONE, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_IAS_ZONE_ZONESTATUS_ID, &open, false
50- );
48+ esp_zb_zcl_set_attribute_val (_endpoint, ESP_ZB_ZCL_CLUSTER_ID_IAS_ZONE, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_IAS_ZONE_ZONESTATUS_ID, &open, false );
5149 esp_zb_lock_release ();
5250 _zone_status = open;
5351 report ();
5452}
5553
5654void ZigbeeDoorWindowHandle::setTilted () {
5755 log_v (" Setting Door/Window handle to tilted" );
58- uint8_t tilted = ESP_ZB_ZCL_IAS_ZONE_ZONE_STATUS_ALARM1; // ALARM1 = 1, ALARM2 = 0
56+ uint8_t tilted = ESP_ZB_ZCL_IAS_ZONE_ZONE_STATUS_ALARM1; // ALARM1 = 1, ALARM2 = 0
5957 esp_zb_lock_acquire (portMAX_DELAY);
6058 esp_zb_zcl_set_attribute_val (
6159 _endpoint, ESP_ZB_ZCL_CLUSTER_ID_IAS_ZONE, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_IAS_ZONE_ZONESTATUS_ID, &tilted, false
@@ -71,7 +69,7 @@ void ZigbeeDoorWindowHandle::report() {
7169 esp_zb_zcl_ias_zone_status_change_notif_cmd_t status_change_notif_cmd;
7270 status_change_notif_cmd.address_mode = ESP_ZB_APS_ADDR_MODE_64_ENDP_PRESENT;
7371 status_change_notif_cmd.zcl_basic_cmd .src_endpoint = _endpoint;
74- status_change_notif_cmd.zcl_basic_cmd .dst_endpoint = _ias_cie_endpoint; // default is 1
72+ status_change_notif_cmd.zcl_basic_cmd .dst_endpoint = _ias_cie_endpoint; // default is 1
7573 memcpy (status_change_notif_cmd.zcl_basic_cmd .dst_addr_u .addr_long , _ias_cie_addr, sizeof (esp_zb_ieee_addr_t ));
7674
7775 status_change_notif_cmd.zone_status = _zone_status;
@@ -88,14 +86,20 @@ void ZigbeeDoorWindowHandle::report() {
8886void ZigbeeDoorWindowHandle::zbIASZoneEnrollResponse (const esp_zb_zcl_ias_zone_enroll_response_message_t *message) {
8987 if (message->info .cluster == ESP_ZB_ZCL_CLUSTER_ID_IAS_ZONE) {
9088 log_v (" IAS Zone Enroll Response: zone id(%d), status(%d)" , message->zone_id , message->response_code );
91- if (message->response_code == ESP_ZB_ZCL_IAS_ZONE_ENROLL_RESPONSE_CODE_SUCCESS) {
89+ if (message->response_code == ESP_ZB_ZCL_IAS_ZONE_ENROLL_RESPONSE_CODE_SUCCESS) {
9290 log_v (" IAS Zone Enroll Response: success" );
9391 esp_zb_lock_acquire (portMAX_DELAY);
94- memcpy (_ias_cie_addr, (*(esp_zb_ieee_addr_t *)esp_zb_zcl_get_attribute (_endpoint, ESP_ZB_ZCL_CLUSTER_ID_IAS_ZONE, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_IAS_ZONE_IAS_CIE_ADDRESS_ID)->data_p ),sizeof (esp_zb_ieee_addr_t ));
92+ memcpy (
93+ _ias_cie_addr,
94+ (*(esp_zb_ieee_addr_t *)
95+ esp_zb_zcl_get_attribute (_endpoint, ESP_ZB_ZCL_CLUSTER_ID_IAS_ZONE, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_IAS_ZONE_IAS_CIE_ADDRESS_ID)
96+ ->data_p ),
97+ sizeof (esp_zb_ieee_addr_t )
98+ );
9599 esp_zb_lock_release ();
96100 _zone_id = message->zone_id ;
97- }
98-
101+ }
102+
99103 } else {
100104 log_w (" Received message ignored. Cluster ID: %d not supported for On/Off Light" , message->info .cluster );
101105 }
0 commit comments