Skip to content

Commit

Permalink
Add OffOnly feature support in OnOff cluster and fixes https://jira.e…
Browse files Browse the repository at this point in the history
…spressif.com:8443/browse/CON-1009

(cherry picked from commit dbd97b890748199c0098553c9391419926f7a62f)
  • Loading branch information
jadhavrohit924 committed Feb 23, 2024
1 parent b5c2a0f commit 7ecd11e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
22 changes: 16 additions & 6 deletions components/esp_matter/esp_matter_cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1263,14 +1263,24 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
}
}

/* Features */
if (features & feature::off_only::get_id()) {
feature::off_only::add(cluster);
}
else {
if (features & feature::lighting::get_id()) {
feature::lighting::add(cluster, &(config->lighting));
}
if (features & feature::dead_front_behavior::get_id()) {
feature::dead_front_behavior::add(cluster);
}
}

/* Commands */
command::create_off(cluster);
command::create_on(cluster);
command::create_toggle(cluster);

/* Features */
if (features & feature::lighting::get_id()) {
feature::lighting::add(cluster, &(config->lighting));
if (!(features & feature::off_only::get_id())) {
command::create_on(cluster);
command::create_toggle(cluster);
}

return cluster;
Expand Down
20 changes: 20 additions & 0 deletions components/esp_matter/esp_matter_feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,26 @@ esp_err_t add(cluster_t *cluster)
}

} /* dead_front_behavior */

namespace off_only {

uint32_t get_id()
{
return (uint32_t)OnOff::Feature::kOffOnly;
}

esp_err_t add(cluster_t *cluster)
{
if (!cluster) {
ESP_LOGE(TAG, "Cluster cannot be NULL");
return ESP_ERR_INVALID_ARG;
}
update_feature_map(cluster, get_id());

return ESP_OK;
}

} /* off_only */
} /* feature */
} /* on_off */

Expand Down
7 changes: 7 additions & 0 deletions components/esp_matter/esp_matter_feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ uint32_t get_id();
esp_err_t add(cluster_t *cluster);

} /* dead_front_behavior */

namespace off_only {

uint32_t get_id();
esp_err_t add(cluster_t *cluster);

} /* off_only */
} /* feature */
} /* on_off */

Expand Down

0 comments on commit 7ecd11e

Please sign in to comment.