@@ -96,10 +96,7 @@ static void app_driver_button_toggle_cb(void *arg, void *data)
96
96
uint32_t cluster_id = OnOff::Id;
97
97
uint32_t attribute_id = OnOff::Attributes::OnOff::Id;
98
98
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);
99
+ attribute_t *attribute = attribute::get (endpoint_id, cluster_id, attribute_id);
103
100
104
101
esp_matter_attr_val_t val = esp_matter_invalid (NULL );
105
102
attribute::get_val (attribute, &val);
@@ -139,43 +136,37 @@ esp_err_t app_driver_light_set_defaults(uint16_t endpoint_id)
139
136
esp_err_t err = ESP_OK;
140
137
void *priv_data = endpoint::get_priv_data (endpoint_id);
141
138
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
139
attribute_t *attribute = NULL ;
146
140
esp_matter_attr_val_t val = esp_matter_invalid (NULL );
147
141
148
142
/* Setting brightness */
149
- cluster = cluster::get (endpoint, LevelControl::Id);
150
- attribute = attribute::get (cluster, LevelControl::Attributes::CurrentLevel::Id);
143
+ attribute = attribute::get (endpoint_id, LevelControl::Id, LevelControl::Attributes::CurrentLevel::Id);
151
144
attribute::get_val (attribute, &val);
152
145
err |= app_driver_light_set_brightness (handle, &val);
153
146
154
147
/* Setting color */
155
- cluster = cluster::get (endpoint, ColorControl::Id);
156
- attribute = attribute::get (cluster, ColorControl::Attributes::ColorMode::Id);
148
+ attribute = attribute::get (endpoint_id, ColorControl::Id, ColorControl::Attributes::ColorMode::Id);
157
149
attribute::get_val (attribute, &val);
158
150
if (val.val .u8 == (uint8_t )ColorControl::ColorMode::kCurrentHueAndCurrentSaturation ) {
159
151
/* Setting hue */
160
- attribute = attribute::get (cluster , ColorControl::Attributes::CurrentHue::Id);
152
+ attribute = attribute::get (endpoint_id, ColorControl::Id , ColorControl::Attributes::CurrentHue::Id);
161
153
attribute::get_val (attribute, &val);
162
154
err |= app_driver_light_set_hue (handle, &val);
163
155
/* Setting saturation */
164
- attribute = attribute::get (cluster , ColorControl::Attributes::CurrentSaturation::Id);
156
+ attribute = attribute::get (endpoint_id, ColorControl::Id , ColorControl::Attributes::CurrentSaturation::Id);
165
157
attribute::get_val (attribute, &val);
166
158
err |= app_driver_light_set_saturation (handle, &val);
167
159
} else if (val.val .u8 == (uint8_t )ColorControl::ColorMode::kColorTemperature ) {
168
160
/* Setting temperature */
169
- attribute = attribute::get (cluster , ColorControl::Attributes::ColorTemperatureMireds::Id);
161
+ attribute = attribute::get (endpoint_id, ColorControl::Id , ColorControl::Attributes::ColorTemperatureMireds::Id);
170
162
attribute::get_val (attribute, &val);
171
163
err |= app_driver_light_set_temperature (handle, &val);
172
164
} else {
173
165
ESP_LOGE (TAG, " Color mode not supported" );
174
166
}
175
167
176
168
/* Setting power */
177
- cluster = cluster::get (endpoint, OnOff::Id);
178
- attribute = attribute::get (cluster, OnOff::Attributes::OnOff::Id);
169
+ attribute = attribute::get (endpoint_id, OnOff::Id, OnOff::Attributes::OnOff::Id);
179
170
attribute::get_val (attribute, &val);
180
171
err |= app_driver_light_set_power (handle, &val);
181
172
@@ -189,7 +180,7 @@ app_driver_handle_t app_driver_light_init()
189
180
led_indicator_handle_t leds[CONFIG_BSP_LEDS_NUM];
190
181
ESP_ERROR_CHECK (bsp_led_indicator_create (leds, NULL , CONFIG_BSP_LEDS_NUM));
191
182
led_indicator_set_hsv (leds[0 ], SET_HSV (DEFAULT_HUE, DEFAULT_SATURATION, DEFAULT_BRIGHTNESS));
192
-
183
+
193
184
return (app_driver_handle_t )leds[0 ];
194
185
#else
195
186
return NULL ;
0 commit comments