diff --git a/components/esp_matter/esp_matter_cluster.cpp b/components/esp_matter/esp_matter_cluster.cpp index c9aa7e768..6297ac4bf 100644 --- a/components/esp_matter/esp_matter_cluster.cpp +++ b/components/esp_matter/esp_matter_cluster.cpp @@ -47,10 +47,8 @@ void plugin_init_callback_common() { ESP_LOGI(TAG, "Cluster plugin init common callback"); node_t *node = node::get(); - if (!node) { - /* Skip plugin_init_callback_common when ESP Matter data model is not used */ - return; - } + /* Skip plugin_init_callback_common when ESP Matter data model is not used */ + VerifyOrReturn(node); endpoint_t *endpoint = endpoint::get_first(node); while (endpoint) { cluster_t *cluster = get_first(endpoint); @@ -69,10 +67,8 @@ void plugin_init_callback_common() void delegate_init_callback_common() { node_t *node = node::get(); - if (!node) { - /* Skip delegate_init_callback_common when ESP Matter data model is not used */ - return; - } + /* Skip delegate_init_callback_common when ESP Matter data model is not used */ + VerifyOrReturn(node); endpoint_t *endpoint = endpoint::get_first(node); while (endpoint) { uint16_t endpoint_id = endpoint::get_id(endpoint); @@ -92,10 +88,7 @@ void delegate_init_callback_common() void add_bounds_callback_common() { node_t *node = node::get(); - if (!node) { - /* Skip add_bounds_callback_common when ESP Matter data model is not used */ - return; - } + VerifyOrReturn(node); endpoint_t *endpoint = endpoint::get_first(node); while (endpoint) { cluster_t *cluster = get_first(endpoint); @@ -114,9 +107,7 @@ cluster_t *create_default_binding_cluster(endpoint_t *endpoint) { /* Don't create binding cluster if it already exists on the endpoint */ cluster_t *cluster = get(endpoint, Binding::Id); - if (cluster) { - return cluster; - } + VerifyOrReturnValue(!cluster, cluster); ESP_LOGI(TAG, "Creating default binding cluster"); binding::config_t config; return binding::create(endpoint, &config, CLUSTER_FLAG_SERVER); @@ -130,11 +121,8 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, Descriptor::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } - + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, Descriptor::Id)); + if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterDescriptorPluginServerInitCallback); set_plugin_server_init_callback(cluster, plugin_server_init_cb); @@ -163,10 +151,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, Actions::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, Actions::Id)); if (flags & CLUSTER_FLAG_SERVER) { set_plugin_server_init_callback(cluster, NULL); @@ -196,10 +181,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, AccessControl::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, AccessControl::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterAccessControlPluginServerInitCallback); set_plugin_server_init_callback(cluster, plugin_server_init_cb); @@ -232,10 +214,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, BasicInformation::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, BasicInformation::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterBasicInformationPluginServerInitCallback); @@ -282,10 +261,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, Binding::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, Binding::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterBindingPluginServerInitCallback); @@ -315,10 +291,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, OtaSoftwareUpdateProvider::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, OtaSoftwareUpdateProvider::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterOtaSoftwareUpdateProviderPluginServerInitCallback); @@ -343,10 +316,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, OtaSoftwareUpdateRequestor::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, OtaSoftwareUpdateRequestor::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterOtaSoftwareUpdateRequestorPluginServerInitCallback); @@ -384,10 +354,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, GeneralCommissioning::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, GeneralCommissioning::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterGeneralCommissioningPluginServerInitCallback); @@ -422,10 +389,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, NetworkCommissioning::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, NetworkCommissioning::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterNetworkCommissioningPluginServerInitCallback); @@ -473,10 +437,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, GeneralDiagnostics::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, GeneralDiagnostics::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterGeneralDiagnosticsPluginServerInitCallback); @@ -507,10 +468,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, AdministratorCommissioning::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, AdministratorCommissioning::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterAdministratorCommissioningPluginServerInitCallback); @@ -544,10 +502,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, OperationalCredentials::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, OperationalCredentials::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterOperationalCredentialsPluginServerInitCallback); @@ -579,10 +534,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, GroupKeyManagement::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, GroupKeyManagement::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterGroupKeyManagementPluginServerInitCallback); @@ -610,10 +562,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, WiFiNetworkDiagnostics::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, WiFiNetworkDiagnostics::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterWiFiNetworkDiagnosticsPluginServerInitCallback); @@ -644,10 +593,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, ThreadNetworkDiagnostics::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, ThreadNetworkDiagnostics::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterThreadNetworkDiagnosticsPluginServerInitCallback); @@ -690,10 +636,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, EthernetNetworkDiagnostics::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, EthernetNetworkDiagnostics::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterEthernetNetworkDiagnosticsPluginServerInitCallback); set_plugin_server_init_callback(cluster, plugin_server_init_cb); @@ -718,10 +661,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, TimeSynchronization::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, TimeSynchronization::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config -> delegate != nullptr) { @@ -753,10 +693,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, UnitLocalization::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, UnitLocalization::Id)); if (flags & CLUSTER_FLAG_SERVER) { add_function_list(cluster, function_list, function_flags); @@ -784,10 +721,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, BridgedDeviceBasicInformation::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, BridgedDeviceBasicInformation::Id)); if (flags & CLUSTER_FLAG_SERVER) { // There is not PluginServer(Client)InitCallback for this cluster @@ -819,11 +753,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, PowerSource::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } - + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, PowerSource::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterPowerSourcePluginServerInitCallback); set_plugin_server_init_callback(cluster, plugin_server_init_cb); @@ -871,10 +801,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, IcdManagement::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, IcdManagement::Id)); #if CONFIG_ENABLE_ICD_SERVER if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterIcdManagementPluginServerInitCallback); @@ -915,10 +842,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, UserLabel::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, UserLabel::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterUserLabelPluginServerInitCallback); @@ -945,10 +869,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, FixedLabel::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, FixedLabel::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterFixedLabelPluginServerInitCallback); @@ -978,10 +899,7 @@ const int function_flags = CLUSTER_FLAG_INIT_FUNCTION | CLUSTER_FLAG_ATTRIBUTE_C cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, Identify::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, Identify::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterIdentifyPluginServerInitCallback); @@ -1022,10 +940,7 @@ uint8_t get_server_cluster_count() { return server_cluster_count; } cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, Groups::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, Groups::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterGroupsPluginServerInitCallback); @@ -1060,10 +975,7 @@ const int function_flags = CLUSTER_FLAG_INIT_FUNCTION | CLUSTER_FLAG_SHUTDOWN_FU cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, ScenesManagement::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, ScenesManagement::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterScenesManagementPluginServerInitCallback); @@ -1098,10 +1010,7 @@ const int function_flags = CLUSTER_FLAG_INIT_FUNCTION | CLUSTER_FLAG_SHUTDOWN_FU cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, OnOff::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, OnOff::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterOnOffPluginServerInitCallback); @@ -1154,10 +1063,7 @@ const int function_flags = CLUSTER_FLAG_INIT_FUNCTION | CLUSTER_FLAG_SHUTDOWN_FU cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, LevelControl::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, LevelControl::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterLevelControlPluginServerInitCallback); @@ -1201,10 +1107,7 @@ const int function_flags = CLUSTER_FLAG_INIT_FUNCTION | CLUSTER_FLAG_SHUTDOWN_FU cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, ColorControl::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, ColorControl::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterColorControlPluginServerInitCallback); @@ -1272,10 +1175,7 @@ const int function_flags = CLUSTER_FLAG_ATTRIBUTE_CHANGED_FUNCTION | CLUSTER_FLA cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, FanControl::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, FanControl::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config -> delegate != nullptr) { @@ -1320,10 +1220,7 @@ const int function_flags = CLUSTER_FLAG_INIT_FUNCTION | CLUSTER_FLAG_PRE_ATTRIBU cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, Thermostat::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, Thermostat::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterThermostatPluginServerInitCallback); @@ -1387,10 +1284,7 @@ const int function_flags = CLUSTER_FLAG_PRE_ATTRIBUTE_CHANGED_FUNCTION; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, ThermostatUserInterfaceConfiguration::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, ThermostatUserInterfaceConfiguration::Id)); if (flags & CLUSTER_FLAG_CLIENT) { create_default_binding_cluster(endpoint); @@ -1423,10 +1317,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, AirQuality::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, AirQuality::Id)); if (flags & CLUSTER_FLAG_SERVER) { add_function_list(cluster, function_list, function_flags); @@ -1455,10 +1346,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, HepaFilterMonitoring::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, HepaFilterMonitoring::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config -> delegate != nullptr) { @@ -1491,10 +1379,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, HepaFilterMonitoring::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, HepaFilterMonitoring::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config -> delegate != nullptr) { @@ -1527,10 +1412,7 @@ static cluster_t *create(endpoint_t *endpoint, T *config, uint8_t flags, uint32_ const function_generic_t *function_list=NULL, const int function_flags=CLUSTER_FLAG_NONE) { cluster_t *cluster = cluster::create(endpoint, cluster_id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster, id: %lu", cluster_id); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster, id: %lu", cluster_id)); if (flags & CLUSTER_FLAG_SERVER) { add_function_list(cluster, function_list, function_flags); @@ -1654,6 +1536,7 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } /* total_volatile_organic_compounds_concentration_measurement */ + namespace operational_state { const function_generic_t *function_list = NULL; const int function_flags = CLUSTER_FLAG_NONE; @@ -1661,10 +1544,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, OperationalState::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, OperationalState::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config -> delegate != nullptr) { @@ -1703,10 +1583,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, LaundryWasherMode::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, LaundryWasherMode::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config && config -> delegate != nullptr) { @@ -1745,10 +1622,7 @@ const int function_flags = CLUSTER_FLAG_PRE_ATTRIBUTE_CHANGED_FUNCTION; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, LaundryWasherControls::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, LaundryWasherControls::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config && config -> delegate != nullptr) { @@ -1782,10 +1656,7 @@ const int function_flags = CLUSTER_FLAG_PRE_ATTRIBUTE_CHANGED_FUNCTION; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, LaundryDryerControls::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, LaundryDryerControls::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config -> delegate != nullptr) { @@ -1822,10 +1693,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, DishwasherMode::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, DishwasherMode::Id)); if (flags & CLUSTER_FLAG_SERVER) { add_function_list(cluster, function_list, function_flags); @@ -1861,10 +1729,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, DishwasherAlarm::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, DishwasherAlarm::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config && config -> delegate != nullptr) { @@ -1895,10 +1760,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, SmokeCoAlarm::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, SmokeCoAlarm::Id)); if (flags & CLUSTER_FLAG_SERVER) { add_function_list(cluster, function_list, function_flags); @@ -1946,10 +1808,7 @@ const int function_flags = CLUSTER_FLAG_ATTRIBUTE_CHANGED_FUNCTION | CLUSTER_FLA cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, DoorLock::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, DoorLock::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config && config -> delegate != nullptr) { @@ -1997,10 +1856,7 @@ const int function_flags = CLUSTER_FLAG_ATTRIBUTE_CHANGED_FUNCTION; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, WindowCovering::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, WindowCovering::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterWindowCoveringPluginServerInitCallback); @@ -2048,10 +1904,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, Switch::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, Switch::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterSwitchPluginServerInitCallback); @@ -2086,10 +1939,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, TemperatureMeasurement::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, TemperatureMeasurement::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterTemperatureMeasurementPluginServerInitCallback); @@ -2125,10 +1975,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, RelativeHumidityMeasurement::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, RelativeHumidityMeasurement::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterRelativeHumidityMeasurementPluginServerInitCallback); @@ -2166,10 +2013,7 @@ const int function_flags = CLUSTER_FLAG_INIT_FUNCTION; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, OccupancySensing::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, OccupancySensing::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterOccupancySensingPluginServerInitCallback); @@ -2205,10 +2049,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, BooleanState::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, BooleanState::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterBooleanStatePluginServerInitCallback); @@ -2242,10 +2083,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, BooleanStateConfiguration::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, BooleanStateConfiguration::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config && config -> delegate != nullptr) { @@ -2293,10 +2131,7 @@ const int function_flags = CLUSTER_FLAG_INIT_FUNCTION | CLUSTER_FLAG_PRE_ATTRIBU cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, LocalizationConfiguration::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, LocalizationConfiguration::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterLocalizationConfigurationPluginServerInitCallback); @@ -2332,10 +2167,7 @@ const int function_flags = CLUSTER_FLAG_INIT_FUNCTION | CLUSTER_FLAG_PRE_ATTRIBU cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, TimeFormatLocalization::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, TimeFormatLocalization::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterTimeFormatLocalizationPluginServerInitCallback); @@ -2372,10 +2204,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, IlluminanceMeasurement::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, IlluminanceMeasurement::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterIlluminanceMeasurementPluginServerInitCallback); set_plugin_server_init_callback(cluster, plugin_server_init_cb); @@ -2412,10 +2241,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, PressureMeasurement::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, PressureMeasurement::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterPressureMeasurementPluginServerInitCallback); set_plugin_server_init_callback(cluster, plugin_server_init_cb); @@ -2450,10 +2276,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, FlowMeasurement::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, FlowMeasurement::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterFlowMeasurementPluginServerInitCallback); set_plugin_server_init_callback(cluster, plugin_server_init_cb); @@ -2493,10 +2316,7 @@ const int function_flags = cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, PumpConfigurationAndControl::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, PumpConfigurationAndControl::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterPumpConfigurationAndControlPluginServerInitCallback); set_plugin_server_init_callback(cluster, plugin_server_init_cb); @@ -2537,10 +2357,7 @@ const int function_flags = CLUSTER_FLAG_INIT_FUNCTION; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, ModeSelect::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, ModeSelect::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config -> delegate != nullptr) { static const auto delegate_init_cb = ModeSelectDelegateInitCB; @@ -2611,10 +2428,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, SoftwareDiagnostics::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, SoftwareDiagnostics::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterSoftwareDiagnosticsPluginServerInitCallback); @@ -2643,10 +2457,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, TemperatureControl::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, TemperatureControl::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterTemperatureControlPluginServerInitCallback); @@ -2682,10 +2493,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, RefrigeratorAlarm::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, RefrigeratorAlarm::Id)); if (flags & CLUSTER_FLAG_SERVER) { static const auto plugin_server_init_cb = CALL_ONCE(MatterRefrigeratorAlarmPluginServerInitCallback); @@ -2717,10 +2525,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, RefrigeratorAndTemperatureControlledCabinetMode::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, RefrigeratorAndTemperatureControlledCabinetMode::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config && config -> delegate != nullptr) { @@ -2757,10 +2562,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, RvcRunMode::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, RvcRunMode::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config && config -> delegate != nullptr) { @@ -2797,10 +2599,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, RvcCleanMode::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, RvcCleanMode::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config && config -> delegate != nullptr) { @@ -2836,10 +2635,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, MicrowaveOvenMode::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, MicrowaveOvenMode::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config -> delegate != nullptr) { @@ -2872,10 +2668,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, MicrowaveOvenControl::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, MicrowaveOvenControl::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config -> delegate != nullptr) { @@ -2914,10 +2707,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, RvcOperationalState::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, RvcOperationalState::Id)); if (flags & CLUSTER_FLAG_SERVER) { add_function_list(cluster, function_list, function_flags); @@ -2944,10 +2734,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, KeypadInput::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, KeypadInput::Id)); if (flags & CLUSTER_FLAG_CLIENT) { create_default_binding_cluster(endpoint); @@ -2979,10 +2766,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, PowerTopology::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, PowerTopology::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config -> delegate != nullptr) { @@ -3023,10 +2807,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, ElectricalPowerMeasurement::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, ElectricalPowerMeasurement::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config -> delegate != nullptr) { @@ -3082,10 +2863,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, ElectricalEnergyMeasurement::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, ElectricalEnergyMeasurement::Id)); if (flags & CLUSTER_FLAG_SERVER) { add_function_list(cluster, function_list, function_flags); @@ -3134,10 +2912,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, EnergyEvseMode::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, EnergyEvseMode::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config -> delegate != nullptr) { @@ -3173,10 +2948,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, EnergyEvse::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, EnergyEvse::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config -> delegate != nullptr) { @@ -3230,10 +3002,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, ValveConfigurationAndControl::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, ValveConfigurationAndControl::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config -> delegate != nullptr) { static const auto delegate_init_cb = ValveConfigurationAndControlDelegateInitCB; @@ -3282,10 +3051,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, DeviceEnergyManagement::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, DeviceEnergyManagement::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config -> delegate != nullptr) { static const auto delegate_init_cb = DeviceEnergyManagementDelegateInitCB; @@ -3350,10 +3116,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) { cluster_t *cluster = cluster::create(endpoint, DeviceEnergyManagementMode::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, DeviceEnergyManagementMode::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config -> delegate != nullptr) { @@ -3389,10 +3152,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, ApplicationBasic::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, ApplicationBasic::Id)); if (flags & CLUSTER_FLAG_SERVER) { if (config -> delegate != nullptr) { static const auto delegate_init_cb = ApplicationBasicDelegateInitCB; @@ -3430,10 +3190,7 @@ const int function_flags = CLUSTER_FLAG_NONE; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features) { cluster_t *cluster = cluster::create(endpoint, ThreadBorderRouterManagement::Id, flags); - if (!cluster) { - ESP_LOGE(TAG, "Could not create cluster"); - return NULL; - } + VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster")); if (flags & CLUSTER_FLAG_SERVER) { if (config -> delegate != nullptr) { static const auto delegate_init_cb = ThreadBorderRouterManagementDelegateInitCB;