Skip to content

Commit

Permalink
Merge branch 'cherry-pick-dbd97b89' into 'main'
Browse files Browse the repository at this point in the history
[Release v1.3/TE2] Add OffOnly feature support in OnOff cluster

See merge request app-frameworks/esp-matter!639
  • Loading branch information
dhrishi committed Feb 29, 2024
2 parents b037340 + 7ecd11e commit c6ec214
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 @@ -1270,14 +1270,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 c6ec214

Please sign in to comment.