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 <90197375+P-R-O-C-H-Y@users.noreply.github.com> Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
This commit is contained in:
parent
496b841177
commit
15cbb1e857
2 changed files with 35 additions and 6 deletions
|
|
@ -105,6 +105,13 @@ public:
|
||||||
virtual void zbReadBasicCluster(const esp_zb_zcl_attribute_t *attribute); //already implemented
|
virtual void zbReadBasicCluster(const esp_zb_zcl_attribute_t *attribute); //already implemented
|
||||||
virtual void zbIdentify(const esp_zb_zcl_set_attr_value_message_t *message);
|
virtual void zbIdentify(const esp_zb_zcl_set_attr_value_message_t *message);
|
||||||
|
|
||||||
|
virtual void zbIASZoneStatusChangeNotification(const esp_zb_zcl_ias_zone_status_change_notification_message_t *message) {};
|
||||||
|
|
||||||
|
virtual void addBoundDevice(zb_device_params_t *device) {
|
||||||
|
_bound_devices.push_back(device);
|
||||||
|
_is_bound = true;
|
||||||
|
}
|
||||||
|
|
||||||
void onIdentify(void (*callback)(uint16_t)) {
|
void onIdentify(void (*callback)(uint16_t)) {
|
||||||
_on_identify = callback;
|
_on_identify = callback;
|
||||||
}
|
}
|
||||||
|
|
@ -125,10 +132,6 @@ protected:
|
||||||
SemaphoreHandle_t lock;
|
SemaphoreHandle_t lock;
|
||||||
zb_power_source_t _power_source;
|
zb_power_source_t _power_source;
|
||||||
|
|
||||||
void addBoundDevice(zb_device_params_t *device) {
|
|
||||||
_bound_devices.push_back(device);
|
|
||||||
_is_bound = true;
|
|
||||||
}
|
|
||||||
friend class ZigbeeCore;
|
friend class ZigbeeCore;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ static esp_err_t zb_attribute_set_handler(const esp_zb_zcl_set_attr_value_messag
|
||||||
static esp_err_t zb_attribute_reporting_handler(const esp_zb_zcl_report_attr_message_t *message);
|
static esp_err_t zb_attribute_reporting_handler(const esp_zb_zcl_report_attr_message_t *message);
|
||||||
static esp_err_t zb_cmd_read_attr_resp_handler(const esp_zb_zcl_cmd_read_attr_resp_message_t *message);
|
static esp_err_t zb_cmd_read_attr_resp_handler(const esp_zb_zcl_cmd_read_attr_resp_message_t *message);
|
||||||
static esp_err_t zb_configure_report_resp_handler(const esp_zb_zcl_cmd_config_report_resp_message_t *message);
|
static esp_err_t zb_configure_report_resp_handler(const esp_zb_zcl_cmd_config_report_resp_message_t *message);
|
||||||
|
static esp_err_t zb_cmd_ias_zone_status_change_handler(const esp_zb_zcl_ias_zone_status_change_notification_message_t *message);
|
||||||
static esp_err_t zb_cmd_default_resp_handler(const esp_zb_zcl_cmd_default_resp_message_t *message);
|
static esp_err_t zb_cmd_default_resp_handler(const esp_zb_zcl_cmd_default_resp_message_t *message);
|
||||||
|
|
||||||
// Zigbee action handlers
|
// Zigbee action handlers
|
||||||
|
|
@ -20,6 +21,9 @@ static esp_err_t zb_action_handler(esp_zb_core_action_callback_id_t callback_id,
|
||||||
case ESP_ZB_CORE_REPORT_ATTR_CB_ID: ret = zb_attribute_reporting_handler((esp_zb_zcl_report_attr_message_t *)message); break;
|
case ESP_ZB_CORE_REPORT_ATTR_CB_ID: ret = zb_attribute_reporting_handler((esp_zb_zcl_report_attr_message_t *)message); break;
|
||||||
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;
|
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;
|
||||||
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;
|
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;
|
||||||
|
case ESP_ZB_CORE_CMD_IAS_ZONE_ZONE_STATUS_CHANGE_NOT_ID:
|
||||||
|
ret = zb_cmd_ias_zone_status_change_handler((esp_zb_zcl_ias_zone_status_change_notification_message_t *)message);
|
||||||
|
break;
|
||||||
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;
|
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;
|
||||||
default: log_w("Receive unhandled Zigbee action(0x%x) callback", callback_id); break;
|
default: log_w("Receive unhandled Zigbee action(0x%x) callback", callback_id); break;
|
||||||
}
|
}
|
||||||
|
|
@ -132,6 +136,28 @@ static esp_err_t zb_configure_report_resp_handler(const esp_zb_zcl_cmd_config_re
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static esp_err_t zb_cmd_ias_zone_status_change_handler(const esp_zb_zcl_ias_zone_status_change_notification_message_t *message) {
|
||||||
|
if (!message) {
|
||||||
|
log_e("Empty message");
|
||||||
|
return ESP_FAIL;
|
||||||
|
}
|
||||||
|
if (message->info.status != ESP_ZB_ZCL_STATUS_SUCCESS) {
|
||||||
|
log_e("Received message: error status(%d)", message->info.status);
|
||||||
|
return ESP_ERR_INVALID_ARG;
|
||||||
|
}
|
||||||
|
log_v(
|
||||||
|
"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,
|
||||||
|
message->info.src_endpoint, message->info.dst_endpoint, message->info.cluster
|
||||||
|
);
|
||||||
|
|
||||||
|
for (std::list<ZigbeeEP *>::iterator it = Zigbee.ep_objects.begin(); it != Zigbee.ep_objects.end(); ++it) {
|
||||||
|
if (message->info.dst_endpoint == (*it)->getEndpoint()) {
|
||||||
|
(*it)->zbIASZoneStatusChangeNotification(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static esp_err_t zb_cmd_default_resp_handler(const esp_zb_zcl_cmd_default_resp_message_t *message) {
|
static esp_err_t zb_cmd_default_resp_handler(const esp_zb_zcl_cmd_default_resp_message_t *message) {
|
||||||
if (!message) {
|
if (!message) {
|
||||||
log_e("Empty message");
|
log_e("Empty message");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue