Skip to content

Commit 15cbb1e

Browse files
lsroka76P-R-O-C-H-Ypre-commit-ci-lite[bot]
authored
Add IAS Zone Notification Message service to ZigbeeHandlers and ZigbeeEP.h (#10821)
* Update ZigbeeHandlers.cpp * Update ZigbeeEP.h * Update ZigbeeEP.h make addBoundDevice virtual for override * fix(zigbee): Update and reorder handlers * fix(zigbee): Place default handler to the end * ci(pre-commit): Apply automatic fixes --------- Co-authored-by: Jan Procházka <[email protected]> Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent 496b841 commit 15cbb1e

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

libraries/Zigbee/src/ZigbeeEP.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ class ZigbeeEP {
105105
virtual void zbReadBasicCluster(const esp_zb_zcl_attribute_t *attribute); //already implemented
106106
virtual void zbIdentify(const esp_zb_zcl_set_attr_value_message_t *message);
107107

108+
virtual void zbIASZoneStatusChangeNotification(const esp_zb_zcl_ias_zone_status_change_notification_message_t *message) {};
109+
110+
virtual void addBoundDevice(zb_device_params_t *device) {
111+
_bound_devices.push_back(device);
112+
_is_bound = true;
113+
}
114+
108115
void onIdentify(void (*callback)(uint16_t)) {
109116
_on_identify = callback;
110117
}
@@ -125,10 +132,6 @@ class ZigbeeEP {
125132
SemaphoreHandle_t lock;
126133
zb_power_source_t _power_source;
127134

128-
void addBoundDevice(zb_device_params_t *device) {
129-
_bound_devices.push_back(device);
130-
_is_bound = true;
131-
}
132135
friend class ZigbeeCore;
133136
};
134137

libraries/Zigbee/src/ZigbeeHandlers.cpp

+28-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ static esp_err_t zb_attribute_set_handler(const esp_zb_zcl_set_attr_value_messag
99
static esp_err_t zb_attribute_reporting_handler(const esp_zb_zcl_report_attr_message_t *message);
1010
static esp_err_t zb_cmd_read_attr_resp_handler(const esp_zb_zcl_cmd_read_attr_resp_message_t *message);
1111
static esp_err_t zb_configure_report_resp_handler(const esp_zb_zcl_cmd_config_report_resp_message_t *message);
12+
static esp_err_t zb_cmd_ias_zone_status_change_handler(const esp_zb_zcl_ias_zone_status_change_notification_message_t *message);
1213
static esp_err_t zb_cmd_default_resp_handler(const esp_zb_zcl_cmd_default_resp_message_t *message);
1314

1415
// Zigbee action handlers
@@ -20,8 +21,11 @@ static esp_err_t zb_action_handler(esp_zb_core_action_callback_id_t callback_id,
2021
case ESP_ZB_CORE_REPORT_ATTR_CB_ID: ret = zb_attribute_reporting_handler((esp_zb_zcl_report_attr_message_t *)message); break;
2122
case ESP_ZB_CORE_CMD_READ_ATTR_RESP_CB_ID: ret = zb_cmd_read_attr_resp_handler((esp_zb_zcl_cmd_read_attr_resp_message_t *)message); break;
2223
case ESP_ZB_CORE_CMD_REPORT_CONFIG_RESP_CB_ID: ret = zb_configure_report_resp_handler((esp_zb_zcl_cmd_config_report_resp_message_t *)message); break;
23-
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;
24-
default: log_w("Receive unhandled Zigbee action(0x%x) callback", callback_id); break;
24+
case ESP_ZB_CORE_CMD_IAS_ZONE_ZONE_STATUS_CHANGE_NOT_ID:
25+
ret = zb_cmd_ias_zone_status_change_handler((esp_zb_zcl_ias_zone_status_change_notification_message_t *)message);
26+
break;
27+
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;
28+
default: log_w("Receive unhandled Zigbee action(0x%x) callback", callback_id); break;
2529
}
2630
return ret;
2731
}
@@ -132,6 +136,28 @@ static esp_err_t zb_configure_report_resp_handler(const esp_zb_zcl_cmd_config_re
132136
return ESP_OK;
133137
}
134138

139+
static esp_err_t zb_cmd_ias_zone_status_change_handler(const esp_zb_zcl_ias_zone_status_change_notification_message_t *message) {
140+
if (!message) {
141+
log_e("Empty message");
142+
return ESP_FAIL;
143+
}
144+
if (message->info.status != ESP_ZB_ZCL_STATUS_SUCCESS) {
145+
log_e("Received message: error status(%d)", message->info.status);
146+
return ESP_ERR_INVALID_ARG;
147+
}
148+
log_v(
149+
"IAS Zone Status Notification: from address(0x%x) src endpoint(%d) to dst endpoint(%d) cluster(0x%x)", message->info.src_address.u.short_addr,
150+
message->info.src_endpoint, message->info.dst_endpoint, message->info.cluster
151+
);
152+
153+
for (std::list<ZigbeeEP *>::iterator it = Zigbee.ep_objects.begin(); it != Zigbee.ep_objects.end(); ++it) {
154+
if (message->info.dst_endpoint == (*it)->getEndpoint()) {
155+
(*it)->zbIASZoneStatusChangeNotification(message);
156+
}
157+
}
158+
return ESP_OK;
159+
}
160+
135161
static esp_err_t zb_cmd_default_resp_handler(const esp_zb_zcl_cmd_default_resp_message_t *message) {
136162
if (!message) {
137163
log_e("Empty message");

0 commit comments

Comments
 (0)