@@ -25,63 +25,65 @@ using namespace chip::app::Clusters;
25
25
26
26
// endpoint for enhanced color light device
27
27
namespace esp_matter {
28
- using namespace cluster ;
29
- namespace endpoint {
28
+ using namespace cluster ;
29
+ namespace endpoint {
30
30
namespace enhanced_color_light {
31
31
typedef 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;
39
39
} config_t ;
40
40
41
41
uint32_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;
43
43
}
44
44
45
45
uint8_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;
47
47
}
48
48
49
49
esp_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
+ }
59
59
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;
74
77
}
75
78
76
79
endpoint_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;
80
83
}
81
- } /* enhanced_color_light */
82
- } /* endpoint */
83
- } /* esp_matter */
84
-
84
+ } // namespace enhanced_color_light
85
+ } // namespace endpoint
86
+ } // namespace esp_matter
85
87
86
88
bool MatterEnhancedColorLight::attributeChangeCB (uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val) {
87
89
bool ret = true ;
@@ -90,7 +92,10 @@ bool MatterEnhancedColorLight::attributeChangeCB(uint16_t endpoint_id, uint32_t
90
92
return false ;
91
93
}
92
94
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
+ );
94
99
95
100
if (endpoint_id == getEndPointId ()) {
96
101
switch (cluster_id) {
@@ -101,7 +106,7 @@ bool MatterEnhancedColorLight::attributeChangeCB(uint16_t endpoint_id, uint32_t
101
106
ret &= _onChangeOnOffCB (val->val .b );
102
107
}
103
108
if (_onChangeCB != NULL ) {
104
- ret &= _onChangeCB (val->val .b , colorHSV, brightnessLevel, colorTemperatureLevel);
109
+ ret &= _onChangeCB (val->val .b , colorHSV, brightnessLevel, colorTemperatureLevel);
105
110
}
106
111
if (ret == true ) {
107
112
onOffState = val->val .b ;
@@ -145,13 +150,13 @@ bool MatterEnhancedColorLight::attributeChangeCB(uint16_t endpoint_id, uint32_t
145
150
if (attribute_id == ColorControl::Attributes::CurrentHue::Id) {
146
151
log_d (" Enhanced ColorLight Hue changed to %d" , val->val .u8 );
147
152
hsvColor.h = val->val .u8 ;
148
- } else { // attribute_id == ColorControl::Attributes::CurrentSaturation::Id)
153
+ } else { // attribute_id == ColorControl::Attributes::CurrentSaturation::Id)
149
154
log_d (" Enhanced ColorLight Saturation changed to %d" , val->val .u8 );
150
155
hsvColor.s = val->val .u8 ;
151
156
}
152
157
if (_onChangeColorCB != NULL ) {
153
158
ret &= _onChangeColorCB (hsvColor);
154
- }
159
+ }
155
160
if (_onChangeCB != NULL ) {
156
161
ret &= _onChangeCB (onOffState, hsvColor, brightnessLevel, colorTemperatureLevel);
157
162
}
@@ -338,7 +343,7 @@ bool MatterEnhancedColorLight::setColorHSV(espHsvColor_t _hsvColor) {
338
343
return true ;
339
344
}
340
345
341
- colorHSV = { _hsvColor.h , _hsvColor.s , _hsvColor.v };
346
+ colorHSV = {_hsvColor.h , _hsvColor.s , _hsvColor.v };
342
347
343
348
endpoint_t *endpoint = endpoint::get (node::get (), endpoint_id);
344
349
cluster_t *cluster = cluster::get (endpoint, ColorControl::Id);
0 commit comments