Skip to content

Commit 46558eb

Browse files
committed
examples/managed_componenet_light: update docs and esp_matter component version 1.4.0
1 parent 8a7c81f commit 46558eb

File tree

5 files changed

+17
-39
lines changed

5 files changed

+17
-39
lines changed

docs/en/developing.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,17 @@ To add the esp_matter component to your project, run:
201201

202202
::
203203

204-
idf.py add-dependency "espressif/esp_matter^0.0.2"
204+
idf.py add-dependency "espressif/esp_matter^1.4.0"
205205

206206
An example with esp_matter component is offered:
207207

208208
- :project_file:`Managed Component Light <examples/managed_component_light/README.md>`
209209

210210
.. note::
211211

212-
To use this component, the version of IDF component management should be 1.4.*.
213-
Use ``compote version`` to show the version. Use ``pip install 'idf-component-manager~=1.4.0'`` to install.
212+
To use this component, the version of IDF component management should be ``1.4.*`` or ``>= 2.0``.
213+
Use ``compote version`` to show the version. Use ``pip install 'idf-component-manager~=1.4.0'``
214+
or ``pip install 'idf-component-manager~=2.0.0'`` to install.
214215

215216
2.2.3 Building Applications
216217
~~~~~~~~~~~~~~~~~~~~~~~~~~~

examples/managed_component_light/README.md

-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@
22

33
This example creates a Color Temperature Light device using the esp_matter component downloaded from [Espressif Component Registry](https://components.espressif.com/) instead of the extra component in local, so the example can work without setting the esp-matter environment.
44

5-
// TODO: IDF-9801
6-
> Note: To prevent the hash problem during building, the version [IDF component management](https://docs.espressif.com/projects/idf-component-manager/en/latest/) should be 1.4.*. Use `compote version` to show the version. Use `pip install 'idf-component-manager~=1.4.0'` to install.
7-
85
See the [docs](https://docs.espressif.com/projects/esp-matter/en/latest/esp32/developing.html) for more information about building and flashing the firmware.

examples/managed_component_light/main/app_driver.cpp

+7-18
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "bsp/esp-bsp.h"
1515

1616
#include <app_priv.h>
17-
#include "sdkconfig.h"
1817

1918
using namespace chip::app::Clusters;
2019
using namespace esp_matter;
@@ -96,10 +95,7 @@ static void app_driver_button_toggle_cb(void *arg, void *data)
9695
uint32_t cluster_id = OnOff::Id;
9796
uint32_t attribute_id = OnOff::Attributes::OnOff::Id;
9897

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);
10399

104100
esp_matter_attr_val_t val = esp_matter_invalid(NULL);
105101
attribute::get_val(attribute, &val);
@@ -139,43 +135,36 @@ esp_err_t app_driver_light_set_defaults(uint16_t endpoint_id)
139135
esp_err_t err = ESP_OK;
140136
void *priv_data = endpoint::get_priv_data(endpoint_id);
141137
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;
146138
esp_matter_attr_val_t val = esp_matter_invalid(NULL);
147139

148140
/* 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);
151142
attribute::get_val(attribute, &val);
152143
err |= app_driver_light_set_brightness(handle, &val);
153144

154145
/* 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);
157147
attribute::get_val(attribute, &val);
158148
if (val.val.u8 == (uint8_t)ColorControl::ColorMode::kCurrentHueAndCurrentSaturation) {
159149
/* Setting hue */
160-
attribute = attribute::get(cluster, ColorControl::Attributes::CurrentHue::Id);
150+
attribute = attribute::get(endpoint_id, ColorControl::Id, ColorControl::Attributes::CurrentHue::Id);
161151
attribute::get_val(attribute, &val);
162152
err |= app_driver_light_set_hue(handle, &val);
163153
/* Setting saturation */
164-
attribute = attribute::get(cluster, ColorControl::Attributes::CurrentSaturation::Id);
154+
attribute = attribute::get(endpoint_id, ColorControl::Id, ColorControl::Attributes::CurrentSaturation::Id);
165155
attribute::get_val(attribute, &val);
166156
err |= app_driver_light_set_saturation(handle, &val);
167157
} else if (val.val.u8 == (uint8_t)ColorControl::ColorMode::kColorTemperature) {
168158
/* Setting temperature */
169-
attribute = attribute::get(cluster, ColorControl::Attributes::ColorTemperatureMireds::Id);
159+
attribute = attribute::get(endpoint_id, ColorControl::Id, ColorControl::Attributes::ColorTemperatureMireds::Id);
170160
attribute::get_val(attribute, &val);
171161
err |= app_driver_light_set_temperature(handle, &val);
172162
} else {
173163
ESP_LOGE(TAG, "Color mode not supported");
174164
}
175165

176166
/* 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);
179168
attribute::get_val(attribute, &val);
180169
err |= app_driver_light_set_power(handle, &val);
181170

examples/managed_component_light/main/app_main.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ extern "C" void app_main()
166166
light_config.on_off.on_off = DEFAULT_POWER;
167167
light_config.on_off.lighting.start_up_on_off = nullptr;
168168
light_config.level_control.current_level = DEFAULT_BRIGHTNESS;
169+
light_config.level_control.on_level = DEFAULT_BRIGHTNESS;
169170
light_config.level_control.lighting.start_up_current_level = DEFAULT_BRIGHTNESS;
170171
light_config.color_control.color_mode = (uint8_t)ColorControl::ColorMode::kColorTemperature;
171172
light_config.color_control.enhanced_color_mode = (uint8_t)ColorControl::ColorMode::kColorTemperature;
@@ -179,16 +180,14 @@ extern "C" void app_main()
179180
ESP_LOGI(TAG, "Light created with endpoint_id %d", light_endpoint_id);
180181

181182
/* Mark deferred persistence for some attributes that might be changed rapidly */
182-
cluster_t *level_control_cluster = cluster::get(endpoint, LevelControl::Id);
183-
attribute_t *current_level_attribute = attribute::get(level_control_cluster, LevelControl::Attributes::CurrentLevel::Id);
183+
attribute_t *current_level_attribute = attribute::get(light_endpoint_id, LevelControl::Id, LevelControl::Attributes::CurrentLevel::Id);
184184
attribute::set_deferred_persistence(current_level_attribute);
185185

186-
cluster_t *color_control_cluster = cluster::get(endpoint, ColorControl::Id);
187-
attribute_t *current_x_attribute = attribute::get(color_control_cluster, ColorControl::Attributes::CurrentX::Id);
186+
attribute_t *current_x_attribute = attribute::get(light_endpoint_id, ColorControl::Id, ColorControl::Attributes::CurrentX::Id);
188187
attribute::set_deferred_persistence(current_x_attribute);
189-
attribute_t *current_y_attribute = attribute::get(color_control_cluster, ColorControl::Attributes::CurrentY::Id);
188+
attribute_t *current_y_attribute = attribute::get(light_endpoint_id, ColorControl::Id, ColorControl::Attributes::CurrentY::Id);
190189
attribute::set_deferred_persistence(current_y_attribute);
191-
attribute_t *color_temp_attribute = attribute::get(color_control_cluster, ColorControl::Attributes::ColorTemperatureMireds::Id);
190+
attribute_t *color_temp_attribute = attribute::get(light_endpoint_id, ColorControl::Id, ColorControl::Attributes::ColorTemperatureMireds::Id);
192191
attribute::set_deferred_persistence(color_temp_attribute);
193192

194193
#if CHIP_DEVICE_CONFIG_ENABLE_THREAD

examples/managed_component_light/main/idf_component.yml

+1-9
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,4 @@ dependencies:
99
espressif/led_strip:
1010
version: "^2.0.0"
1111
espressif/esp_matter:
12-
version: "^0.0.2"
13-
# This matches the dependency of esp_insights
14-
espressif/esp_diag_data_store:
15-
version: "1.0.1"
16-
require: public
17-
rules:
18-
- if: "idf_version >=5.0"
19-
- if: "target != esp32h2"
20-
12+
version: "^1.4.0"

0 commit comments

Comments
 (0)