|
14 | 14 | #include "bsp/esp-bsp.h"
|
15 | 15 |
|
16 | 16 | #include <app_priv.h>
|
17 |
| -#include "sdkconfig.h" |
18 | 17 |
|
19 | 18 | using namespace chip::app::Clusters;
|
20 | 19 | using namespace esp_matter;
|
@@ -96,10 +95,7 @@ static void app_driver_button_toggle_cb(void *arg, void *data)
|
96 | 95 | uint32_t cluster_id = OnOff::Id;
|
97 | 96 | uint32_t attribute_id = OnOff::Attributes::OnOff::Id;
|
98 | 97 |
|
99 |
| - node_t *node = node::get(); |
100 |
| - endpoint_t *endpoint = endpoint::get(node, endpoint_id); |
101 |
| - cluster_t *cluster = cluster::get(endpoint, cluster_id); |
102 |
| - attribute_t *attribute = attribute::get(cluster, attribute_id); |
| 98 | + attribute_t *attribute = attribute::get(endpoint_id, cluster_id, attribute_id); |
103 | 99 |
|
104 | 100 | esp_matter_attr_val_t val = esp_matter_invalid(NULL);
|
105 | 101 | attribute::get_val(attribute, &val);
|
@@ -139,43 +135,36 @@ esp_err_t app_driver_light_set_defaults(uint16_t endpoint_id)
|
139 | 135 | esp_err_t err = ESP_OK;
|
140 | 136 | void *priv_data = endpoint::get_priv_data(endpoint_id);
|
141 | 137 | led_indicator_handle_t handle = (led_indicator_handle_t)priv_data;
|
142 |
| - node_t *node = node::get(); |
143 |
| - endpoint_t *endpoint = endpoint::get(node, endpoint_id); |
144 |
| - cluster_t *cluster = NULL; |
145 |
| - attribute_t *attribute = NULL; |
146 | 138 | esp_matter_attr_val_t val = esp_matter_invalid(NULL);
|
147 | 139 |
|
148 | 140 | /* Setting brightness */
|
149 |
| - cluster = cluster::get(endpoint, LevelControl::Id); |
150 |
| - attribute = attribute::get(cluster, LevelControl::Attributes::CurrentLevel::Id); |
| 141 | + attribute_t *attribute = attribute::get(endpoint_id, LevelControl::Id, LevelControl::Attributes::CurrentLevel::Id); |
151 | 142 | attribute::get_val(attribute, &val);
|
152 | 143 | err |= app_driver_light_set_brightness(handle, &val);
|
153 | 144 |
|
154 | 145 | /* Setting color */
|
155 |
| - cluster = cluster::get(endpoint, ColorControl::Id); |
156 |
| - attribute = attribute::get(cluster, ColorControl::Attributes::ColorMode::Id); |
| 146 | + attribute = attribute::get(endpoint_id, ColorControl::Id, ColorControl::Attributes::ColorMode::Id); |
157 | 147 | attribute::get_val(attribute, &val);
|
158 | 148 | if (val.val.u8 == (uint8_t)ColorControl::ColorMode::kCurrentHueAndCurrentSaturation) {
|
159 | 149 | /* Setting hue */
|
160 |
| - attribute = attribute::get(cluster, ColorControl::Attributes::CurrentHue::Id); |
| 150 | + attribute = attribute::get(endpoint_id, ColorControl::Id, ColorControl::Attributes::CurrentHue::Id); |
161 | 151 | attribute::get_val(attribute, &val);
|
162 | 152 | err |= app_driver_light_set_hue(handle, &val);
|
163 | 153 | /* Setting saturation */
|
164 |
| - attribute = attribute::get(cluster, ColorControl::Attributes::CurrentSaturation::Id); |
| 154 | + attribute = attribute::get(endpoint_id, ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id); |
165 | 155 | attribute::get_val(attribute, &val);
|
166 | 156 | err |= app_driver_light_set_saturation(handle, &val);
|
167 | 157 | } else if (val.val.u8 == (uint8_t)ColorControl::ColorMode::kColorTemperature) {
|
168 | 158 | /* Setting temperature */
|
169 |
| - attribute = attribute::get(cluster, ColorControl::Attributes::ColorTemperatureMireds::Id); |
| 159 | + attribute = attribute::get(endpoint_id, ColorControl::Id, ColorControl::Attributes::ColorTemperatureMireds::Id); |
170 | 160 | attribute::get_val(attribute, &val);
|
171 | 161 | err |= app_driver_light_set_temperature(handle, &val);
|
172 | 162 | } else {
|
173 | 163 | ESP_LOGE(TAG, "Color mode not supported");
|
174 | 164 | }
|
175 | 165 |
|
176 | 166 | /* Setting power */
|
177 |
| - cluster = cluster::get(endpoint, OnOff::Id); |
178 |
| - attribute = attribute::get(cluster, OnOff::Attributes::OnOff::Id); |
| 167 | + attribute = attribute::get(endpoint_id, OnOff::Id, OnOff::Attributes::OnOff::Id); |
179 | 168 | attribute::get_val(attribute, &val);
|
180 | 169 | err |= app_driver_light_set_power(handle, &val);
|
181 | 170 |
|
|
0 commit comments