@@ -25,63 +25,65 @@ using namespace chip::app::Clusters;
2525
2626// endpoint for enhanced color light device
2727namespace esp_matter {
28- using namespace cluster ;
29- namespace endpoint {
28+ using namespace cluster ;
29+ namespace endpoint {
3030namespace enhanced_color_light {
3131typedef struct config {
32- cluster::descriptor::config_t descriptor;
33- cluster::identify::config_t identify;
34- cluster::groups::config_t groups;
35- cluster::scenes_management::config_t scenes_management;
36- cluster::on_off::config_t on_off;
37- cluster::level_control::config_t level_control;
38- cluster::color_control::config_t color_control;
32+ cluster::descriptor::config_t descriptor;
33+ cluster::identify::config_t identify;
34+ cluster::groups::config_t groups;
35+ cluster::scenes_management::config_t scenes_management;
36+ cluster::on_off::config_t on_off;
37+ cluster::level_control::config_t level_control;
38+ cluster::color_control::config_t color_control;
3939} config_t ;
4040
4141uint32_t get_device_type_id () {
42- return ESP_MATTER_EXTENDED_COLOR_LIGHT_DEVICE_TYPE_ID;
42+ return ESP_MATTER_EXTENDED_COLOR_LIGHT_DEVICE_TYPE_ID;
4343}
4444
4545uint8_t get_device_type_version () {
46- return ESP_MATTER_EXTENDED_COLOR_LIGHT_DEVICE_TYPE_VERSION;
46+ return ESP_MATTER_EXTENDED_COLOR_LIGHT_DEVICE_TYPE_VERSION;
4747}
4848
4949esp_err_t add (endpoint_t *endpoint, config_t *config) {
50- if (!endpoint) {
51- log_e (" Endpoint cannot be NULL" );
52- return ESP_ERR_INVALID_ARG;
53- }
54- esp_err_t err = add_device_type (endpoint, get_device_type_id (), get_device_type_version ());
55- if (err != ESP_OK) {
56- log_e (" Failed to add device type id:%" PRIu32 " ,err: %d" , get_device_type_id (), err);
57- return err;
58- }
50+ if (!endpoint) {
51+ log_e (" Endpoint cannot be NULL" );
52+ return ESP_ERR_INVALID_ARG;
53+ }
54+ esp_err_t err = add_device_type (endpoint, get_device_type_id (), get_device_type_version ());
55+ if (err != ESP_OK) {
56+ log_e (" Failed to add device type id:%" PRIu32 " ,err: %d" , get_device_type_id (), err);
57+ return err;
58+ }
5959
60- descriptor::create (endpoint, &(config->descriptor ), CLUSTER_FLAG_SERVER);
61- cluster_t *identify_cluster = identify::create (endpoint, &(config->identify ), CLUSTER_FLAG_SERVER);
62- identify::command::create_trigger_effect (identify_cluster);
63- groups::create (endpoint, &(config->groups ), CLUSTER_FLAG_SERVER);
64- cluster_t *scenes_cluster = scenes_management::create (endpoint, &(config->scenes_management ), CLUSTER_FLAG_SERVER);
65- scenes_management::command::create_copy_scene (scenes_cluster);
66- scenes_management::command::create_copy_scene_response (scenes_cluster);
67-
68- on_off::create (endpoint, &(config->on_off ), CLUSTER_FLAG_SERVER, on_off::feature::lighting::get_id ());
69- level_control::create (endpoint, &(config->level_control ), CLUSTER_FLAG_SERVER,
70- level_control::feature::on_off::get_id () | level_control::feature::lighting::get_id ());
71- color_control::create (endpoint, &(config->color_control ), CLUSTER_FLAG_SERVER,
72- color_control::feature::hue_saturation::get_id () | color_control::feature::color_temperature::get_id ());
73- return ESP_OK;
60+ descriptor::create (endpoint, &(config->descriptor ), CLUSTER_FLAG_SERVER);
61+ cluster_t *identify_cluster = identify::create (endpoint, &(config->identify ), CLUSTER_FLAG_SERVER);
62+ identify::command::create_trigger_effect (identify_cluster);
63+ groups::create (endpoint, &(config->groups ), CLUSTER_FLAG_SERVER);
64+ cluster_t *scenes_cluster = scenes_management::create (endpoint, &(config->scenes_management ), CLUSTER_FLAG_SERVER);
65+ scenes_management::command::create_copy_scene (scenes_cluster);
66+ scenes_management::command::create_copy_scene_response (scenes_cluster);
67+
68+ on_off::create (endpoint, &(config->on_off ), CLUSTER_FLAG_SERVER, on_off::feature::lighting::get_id ());
69+ level_control::create (
70+ endpoint, &(config->level_control ), CLUSTER_FLAG_SERVER, level_control::feature::on_off::get_id () | level_control::feature::lighting::get_id ()
71+ );
72+ color_control::create (
73+ endpoint, &(config->color_control ), CLUSTER_FLAG_SERVER,
74+ color_control::feature::hue_saturation::get_id () | color_control::feature::color_temperature::get_id ()
75+ );
76+ return ESP_OK;
7477}
7578
7679endpoint_t *create (node_t *node, config_t *config, uint8_t flags, void *priv_data) {
77- endpoint_t *endpoint = endpoint::create (node, flags, priv_data);
78- add (endpoint, config);
79- return endpoint;
80+ endpoint_t *endpoint = endpoint::create (node, flags, priv_data);
81+ add (endpoint, config);
82+ return endpoint;
8083}
81- } /* enhanced_color_light */
82- } /* endpoint */
83- } /* esp_matter */
84-
84+ } // namespace enhanced_color_light
85+ } // namespace endpoint
86+ } // namespace esp_matter
8587
8688bool MatterEnhancedColorLight::attributeChangeCB (uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val) {
8789 bool ret = true ;
@@ -90,7 +92,10 @@ bool MatterEnhancedColorLight::attributeChangeCB(uint16_t endpoint_id, uint32_t
9092 return false ;
9193 }
9294
93- log_d (" Enhanced ColorAttr update callback: endpoint: %u, cluster: %u, attribute: %u, val: %u, type: %u" , endpoint_id, cluster_id, attribute_id, val->val .u32 , val->type );
95+ log_d (
96+ " Enhanced ColorAttr update callback: endpoint: %u, cluster: %u, attribute: %u, val: %u, type: %u" , endpoint_id, cluster_id, attribute_id, val->val .u32 ,
97+ val->type
98+ );
9499
95100 if (endpoint_id == getEndPointId ()) {
96101 switch (cluster_id) {
@@ -101,7 +106,7 @@ bool MatterEnhancedColorLight::attributeChangeCB(uint16_t endpoint_id, uint32_t
101106 ret &= _onChangeOnOffCB (val->val .b );
102107 }
103108 if (_onChangeCB != NULL ) {
104- ret &= _onChangeCB (val->val .b , colorHSV, brightnessLevel, colorTemperatureLevel);
109+ ret &= _onChangeCB (val->val .b , colorHSV, brightnessLevel, colorTemperatureLevel);
105110 }
106111 if (ret == true ) {
107112 onOffState = val->val .b ;
@@ -145,13 +150,13 @@ bool MatterEnhancedColorLight::attributeChangeCB(uint16_t endpoint_id, uint32_t
145150 if (attribute_id == ColorControl::Attributes::CurrentHue::Id) {
146151 log_d (" Enhanced ColorLight Hue changed to %d" , val->val .u8 );
147152 hsvColor.h = val->val .u8 ;
148- } else { // attribute_id == ColorControl::Attributes::CurrentSaturation::Id)
153+ } else { // attribute_id == ColorControl::Attributes::CurrentSaturation::Id)
149154 log_d (" Enhanced ColorLight Saturation changed to %d" , val->val .u8 );
150155 hsvColor.s = val->val .u8 ;
151156 }
152157 if (_onChangeColorCB != NULL ) {
153158 ret &= _onChangeColorCB (hsvColor);
154- }
159+ }
155160 if (_onChangeCB != NULL ) {
156161 ret &= _onChangeCB (onOffState, hsvColor, brightnessLevel, colorTemperatureLevel);
157162 }
@@ -338,7 +343,7 @@ bool MatterEnhancedColorLight::setColorHSV(espHsvColor_t _hsvColor) {
338343 return true ;
339344 }
340345
341- colorHSV = { _hsvColor.h , _hsvColor.s , _hsvColor.v };
346+ colorHSV = {_hsvColor.h , _hsvColor.s , _hsvColor.v };
342347
343348 endpoint_t *endpoint = endpoint::get (node::get (), endpoint_id);
344349 cluster_t *cluster = cluster::get (endpoint, ColorControl::Id);
0 commit comments