Skip to content

Commit 9db2963

Browse files
ci(pre-commit): Apply automatic fixes
1 parent 0bcf153 commit 9db2963

File tree

6 files changed

+35
-23
lines changed

6 files changed

+35
-23
lines changed

Diff for: libraries/Zigbee/examples/Zigbee_Contact_Switch/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Arduino-ESP32 Zigbee Contact Switch Example
22

3-
This example shows how to configure the Zigbee end device and use it as a Home Automation (HA) contact switch (IAS Zone),
3+
This example shows how to configure the Zigbee end device and use it as a Home Automation (HA) contact switch (IAS Zone),
44
that can be used for example as window/door sensor having 2 states - closed/open.
55

66
# Supported Targets

Diff for: libraries/Zigbee/src/ZigbeeHandlers.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ static esp_err_t zb_action_handler(esp_zb_core_action_callback_id_t callback_id,
2525
case ESP_ZB_CORE_CMD_IAS_ZONE_ZONE_STATUS_CHANGE_NOT_ID:
2626
ret = zb_cmd_ias_zone_status_change_handler((esp_zb_zcl_ias_zone_status_change_notification_message_t *)message);
2727
break;
28-
case ESP_ZB_CORE_IAS_ZONE_ENROLL_RESPONSE_VALUE_CB_ID: ret = zb_cmd_ias_zone_enroll_response_handler((esp_zb_zcl_ias_zone_enroll_response_message_t *)message); break;
28+
case ESP_ZB_CORE_IAS_ZONE_ENROLL_RESPONSE_VALUE_CB_ID:
29+
ret = zb_cmd_ias_zone_enroll_response_handler((esp_zb_zcl_ias_zone_enroll_response_message_t *)message);
30+
break;
2931
case ESP_ZB_CORE_CMD_DEFAULT_RESP_CB_ID: ret = zb_cmd_default_resp_handler((esp_zb_zcl_cmd_default_resp_message_t *)message); break;
3032
default: log_w("Receive unhandled Zigbee action(0x%x) callback", callback_id); break;
3133
}

Diff for: libraries/Zigbee/src/ep/ZigbeeContactSwitch.cpp

+14-10
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void ZigbeeContactSwitch::setIASClientEndpoint(uint8_t ep_number) {
3131

3232
void ZigbeeContactSwitch::setClosed() {
3333
log_v("Setting Contact switch 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,11 +43,9 @@ void ZigbeeContactSwitch::setClosed() {
4343

4444
void ZigbeeContactSwitch::setOpen() {
4545
log_v("Setting Contact switch 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();
@@ -59,7 +57,7 @@ void ZigbeeContactSwitch::report() {
5957
esp_zb_zcl_ias_zone_status_change_notif_cmd_t status_change_notif_cmd;
6058
status_change_notif_cmd.address_mode = ESP_ZB_APS_ADDR_MODE_64_ENDP_PRESENT;
6159
status_change_notif_cmd.zcl_basic_cmd.src_endpoint = _endpoint;
62-
status_change_notif_cmd.zcl_basic_cmd.dst_endpoint = _ias_cie_endpoint; //default is 1
60+
status_change_notif_cmd.zcl_basic_cmd.dst_endpoint = _ias_cie_endpoint; //default is 1
6361
memcpy(status_change_notif_cmd.zcl_basic_cmd.dst_addr_u.addr_long, _ias_cie_addr, sizeof(esp_zb_ieee_addr_t));
6462

6563
status_change_notif_cmd.zone_status = _zone_status;
@@ -76,14 +74,20 @@ void ZigbeeContactSwitch::report() {
7674
void ZigbeeContactSwitch::zbIASZoneEnrollResponse(const esp_zb_zcl_ias_zone_enroll_response_message_t *message) {
7775
if (message->info.cluster == ESP_ZB_ZCL_CLUSTER_ID_IAS_ZONE) {
7876
log_v("IAS Zone Enroll Response: zone id(%d), status(%d)", message->zone_id, message->response_code);
79-
if(message->response_code == ESP_ZB_ZCL_IAS_ZONE_ENROLL_RESPONSE_CODE_SUCCESS) {
77+
if (message->response_code == ESP_ZB_ZCL_IAS_ZONE_ENROLL_RESPONSE_CODE_SUCCESS) {
8078
log_v("IAS Zone Enroll Response: success");
8179
esp_zb_lock_acquire(portMAX_DELAY);
82-
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));
80+
memcpy(
81+
_ias_cie_addr,
82+
(*(esp_zb_ieee_addr_t *)
83+
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)
84+
->data_p),
85+
sizeof(esp_zb_ieee_addr_t)
86+
);
8387
esp_zb_lock_release();
8488
_zone_id = message->zone_id;
85-
}
86-
89+
}
90+
8791
} else {
8892
log_w("Received message ignored. Cluster ID: %d not supported for On/Off Light", message->info.cluster);
8993
}

Diff for: libraries/Zigbee/src/ep/ZigbeeContactSwitch.h

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class ZigbeeContactSwitch : public ZigbeeEP {
5555

5656
// Report the contact switch value, done automatically after setting the position
5757
void report();
58+
5859
private:
5960
void zbIASZoneEnrollResponse(const esp_zb_zcl_ias_zone_enroll_response_message_t *message) override;
6061
uint8_t _zone_status;

Diff for: libraries/Zigbee/src/ep/ZigbeeDoorWindowHandle.cpp

+15-11
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ void ZigbeeDoorWindowHandle::setIASClientEndpoint(uint8_t ep_number) {
3131

3232
void 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

4444
void 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

5654
void 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() {
8886
void 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
}

Diff for: libraries/Zigbee/src/ep/ZigbeeDoorWindowHandle.h

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class ZigbeeDoorWindowHandle : public ZigbeeEP {
5959

6060
// Report the door/window handle value, done automatically after setting the position
6161
void report();
62+
6263
private:
6364
void zbIASZoneEnrollResponse(const esp_zb_zcl_ias_zone_enroll_response_message_t *message) override;
6465
uint8_t _zone_status;

0 commit comments

Comments
 (0)