Skip to content

Commit

Permalink
Merge branch 'fix/switch' into 'main'
Browse files Browse the repository at this point in the history
components/esp-matter: Update feature checks on switch cluster and update documentation.

See merge request app-frameworks/esp-matter!988
  • Loading branch information
dhrishi committed Dec 24, 2024
2 parents 96cb173 + dbddd5b commit 911a0a5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
6 changes: 0 additions & 6 deletions components/esp_matter/esp_matter_feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2802,7 +2802,6 @@ uint32_t get_id()

esp_err_t add(cluster_t *cluster)
{
VerifyOrReturnError((get_feature_map_value(cluster) & feature::momentary_switch::get_id()) == feature::momentary_switch::get_id(), ESP_ERR_NOT_SUPPORTED, ESP_LOGE(TAG, "Momentary switch release is not supported because momentary is absent"));
uint32_t as_feature_map = feature::action_switch::get_id();
uint32_t ms_feature_map = feature::momentary_switch::get_id();
uint32_t feature_map = get_feature_map_value(cluster);
Expand All @@ -2824,8 +2823,6 @@ uint32_t get_id()

esp_err_t add(cluster_t *cluster)
{
uint32_t momentary_and_momentart_switch_release_feature_map = feature::momentary_switch::get_id() | feature::momentary_switch_release::get_id();
VerifyOrReturnError((get_feature_map_value(cluster) & momentary_and_momentart_switch_release_feature_map) == momentary_and_momentart_switch_release_feature_map, ESP_ERR_NOT_SUPPORTED, ESP_LOGE(TAG, "Momentary switch long press is not supported because momentary switch and/or momentary switch release is absent"));
uint32_t msr_feature_map = feature::momentary_switch_release::get_id();
uint32_t as_feature_map = feature::action_switch::get_id();
uint32_t ms_feature_map = feature::momentary_switch::get_id();
Expand All @@ -2850,10 +2847,7 @@ uint32_t get_id()

esp_err_t add(cluster_t *cluster, config_t *config)
{
uint32_t momentary_and_momentart_switch_release_feature_map = feature::momentary_switch::get_id() | feature::momentary_switch_release::get_id();
VerifyOrReturnError((get_feature_map_value(cluster) & momentary_and_momentart_switch_release_feature_map) == momentary_and_momentart_switch_release_feature_map, ESP_ERR_NOT_SUPPORTED, ESP_LOGE(TAG, "Momentary switch multi press is not supported because momentary switch and/or momentary switch releaseis absent"));
uint32_t as_feature_map = feature::action_switch::get_id();
VerifyOrReturnError((get_feature_map_value(cluster) & as_feature_map) != as_feature_map, ESP_ERR_NOT_SUPPORTED, ESP_LOGE(TAG, "Momentary switch multi press is not supported because action switch is absent"));
uint32_t ms_feature_map = feature::momentary_switch::get_id();
uint32_t msr_feature_map = feature::momentary_switch_release::get_id();
uint32_t ms_and_msr = ms_feature_map | msr_feature_map;
Expand Down
13 changes: 8 additions & 5 deletions components/esp_matter/esp_matter_feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,7 @@ esp_err_t add(cluster_t *cluster);

} /* momentary_switch */

// MomentarySwitchRelease feature is dependent on MomentarySwitch feature, in order to add
// MomentarySwitchRelease feature has dependency on MomentarySwitch and !ActionSwitch features, in order to add
// MomentarySwitchRelease feature one must add MomentarySwitch feature first.

namespace momentary_switch_release {
Expand All @@ -1513,8 +1513,8 @@ esp_err_t add(cluster_t *cluster);

} /* momentary_switch_release */

// MomentarySwitchRelease feature is dependent on MomentarySwitch and MomentarySwitchRelease feature, in order to add
// MomentarySwitchRelease feature one must add MomentarySwitch and MomentarySwitchRelease feature first.
// MomentarySwitchLongPress feature has dependency on MomentarySwitch and (MomentarySwitchRelease or ActionSwitch) features, in order to add
// MomentarySwitchLongPress feature one must add MomentarySwitch and (MomentarySwitchRelease or ActionSwitch) features first.

namespace momentary_switch_long_press {

Expand All @@ -1523,8 +1523,8 @@ esp_err_t add(cluster_t *cluster);

} /* momentary_switch_long_press */

// MomentarySwitchRelease feature is dependent on MomentarySwitch and MomentarySwitchRelease feature, in order to add
// MomentarySwitchRelease feature one must add MomentarySwitch and MomentarySwitchRelease feature first.
// MomentarySwitchMultiPress feature has dependency on ActionSwitch or (MomentarySwitch and MomentarySwitchRelease) features, in order to add
// MomentarySwitchMultiPress feature one must add ActionSwitch or (MomentarySwitch and MomentarySwitchRelease) features first.

namespace momentary_switch_multi_press {

Expand All @@ -1538,6 +1538,9 @@ esp_err_t add(cluster_t *cluster, config_t *config);

} /* momentary_switch_multi_press */

// ActionSwitch feature has dependency on MomentarySwitch feature, in order to add
// ActionSwitch feature one must add MomentarySwitch feature first.

namespace action_switch {

uint32_t get_id();
Expand Down

0 comments on commit 911a0a5

Please sign in to comment.