Skip to content

Commit c0fb895

Browse files
committed
Merge branch 'icd/update_features' into 'main'
Update features for ICD Management cluster See merge request app-frameworks/esp-matter!698
2 parents 8c101ca + eadcdc6 commit c0fb895

7 files changed

+150
-65
lines changed

components/esp_matter/esp_matter_attribute.cpp

+34-41
Original file line numberDiff line numberDiff line change
@@ -588,65 +588,58 @@ attribute_t *create_max_group_keys_per_fabric(cluster_t *cluster, uint16_t value
588588

589589
namespace icd_management {
590590
namespace attribute {
591-
attribute_t *create_idle_mode_duration(cluster_t *cluster, uint32_t value, uint32_t min, uint32_t max)
591+
attribute_t *create_idle_mode_duration(cluster_t *cluster, uint32_t value)
592592
{
593-
attribute_t *attribute = esp_matter::attribute::create(cluster, IcdManagement::Attributes::IdleModeDuration::Id,
594-
ATTRIBUTE_FLAG_NONE, esp_matter_uint32(value));
595-
if (!attribute) {
596-
ESP_LOGE(TAG, "Could not create attribute");
597-
return NULL;
598-
}
599-
esp_matter::attribute::add_bounds(attribute, esp_matter_uint32(min), esp_matter_uint32(max));
600-
return attribute;
593+
return esp_matter::attribute::create(cluster, IcdManagement::Attributes::IdleModeDuration::Id,
594+
ATTRIBUTE_FLAG_NONE, esp_matter_uint32(value));
601595
}
602596

603-
attribute_t *create_active_mode_duration(cluster_t *cluster, uint32_t value, uint32_t min)
597+
attribute_t *create_active_mode_duration(cluster_t *cluster, uint32_t value)
604598
{
605-
attribute_t *attribute = esp_matter::attribute::create(cluster, IcdManagement::Attributes::ActiveModeDuration::Id,
606-
ATTRIBUTE_FLAG_NONE, esp_matter_uint32(value));
607-
if (!attribute) {
608-
ESP_LOGE(TAG, "Could not create attribute");
609-
return NULL;
610-
}
611-
esp_matter::attribute::add_bounds(attribute, esp_matter_uint32(min), esp_matter_uint32(UINT32_MAX));
612-
return attribute;
599+
return esp_matter::attribute::create(cluster, IcdManagement::Attributes::ActiveModeDuration::Id,
600+
ATTRIBUTE_FLAG_NONE, esp_matter_uint32(value));
613601
}
614602

615-
attribute_t *create_active_mode_threshold(cluster_t *cluster, uint16_t value, uint16_t min)
603+
attribute_t *create_active_mode_threshold(cluster_t *cluster, uint16_t value)
616604
{
617-
attribute_t *attribute = esp_matter::attribute::create(cluster, IcdManagement::Attributes::ActiveModeThreshold::Id,
618-
ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value));
619-
if (!attribute) {
620-
ESP_LOGE(TAG, "Could not create attribute");
621-
return NULL;
622-
}
623-
esp_matter::attribute::add_bounds(attribute, esp_matter_uint16(min), esp_matter_uint16(UINT16_MAX));
624-
return attribute;
605+
return esp_matter::attribute::create(cluster, IcdManagement::Attributes::ActiveModeThreshold::Id,
606+
ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value));
625607
}
626608

627609
attribute_t *create_registered_clients(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
628610
{
629-
return esp_matter::attribute::create(cluster, IcdManagement::Attributes::RegisteredClients::Id, ATTRIBUTE_FLAG_NONVOLATILE,
630-
esp_matter_array(value,length, count));
611+
return esp_matter::attribute::create(cluster, IcdManagement::Attributes::RegisteredClients::Id,
612+
ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_array(value,length, count));
631613
}
632614

633-
attribute_t *create_icd_counter(cluster_t *cluster,uint32_t value)
615+
attribute_t *create_icd_counter(cluster_t *cluster, uint32_t value)
634616
{
635-
return esp_matter::attribute::create(cluster, IcdManagement::Attributes::ICDCounter::Id, ATTRIBUTE_FLAG_NONVOLATILE,
636-
esp_matter_uint32(value));
617+
return esp_matter::attribute::create(cluster, IcdManagement::Attributes::ICDCounter::Id,
618+
ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_uint32(value));
637619
}
638620

639-
attribute_t *create_clients_supported_per_fabric(cluster_t *cluster, uint16_t value, uint16_t min)
621+
attribute_t *create_clients_supported_per_fabric(cluster_t *cluster, uint16_t value)
640622
{
641-
attribute_t *attribute = esp_matter::attribute::create(cluster, IcdManagement::Attributes::ClientsSupportedPerFabric::Id,
642-
ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value));
643-
if (!attribute) {
644-
ESP_LOGE(TAG, "Could not create attribute");
645-
return NULL;
646-
}
647-
esp_matter::attribute::add_bounds(attribute, esp_matter_uint16(min), esp_matter_uint16(UINT16_MAX));
648-
return attribute;
623+
return esp_matter::attribute::create(cluster, IcdManagement::Attributes::ClientsSupportedPerFabric::Id,
624+
ATTRIBUTE_FLAG_NONE, esp_matter_uint16(value));
625+
}
649626

627+
attribute_t *create_user_active_mode_trigger_hint(cluster_t *cluster, uint32_t value)
628+
{
629+
return esp_matter::attribute::create(cluster, IcdManagement::Attributes::UserActiveModeTriggerHint::Id,
630+
ATTRIBUTE_FLAG_NONE, esp_matter_bitmap32(value));
631+
}
632+
633+
attribute_t *create_user_active_mode_trigger_instruction(cluster_t *cluster, char *value, uint16_t length)
634+
{
635+
return esp_matter::attribute::create(cluster, IcdManagement::Attributes::UserActiveModeTriggerInstruction::Id,
636+
ATTRIBUTE_FLAG_NONE, esp_matter_char_str(value, length));
637+
}
638+
639+
attribute_t *create_operating_mode(cluster_t *cluster, uint8_t value)
640+
{
641+
return esp_matter::attribute::create(cluster, IcdManagement::Attributes::OperatingMode::Id,
642+
ATTRIBUTE_FLAG_NONE, esp_matter_enum8(value));
650643
}
651644

652645
} /* attribute */

components/esp_matter/esp_matter_attribute.h

+8-5
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,15 @@ attribute_t *create_max_group_keys_per_fabric(cluster_t *cluster, uint16_t value
181181

182182
namespace icd_management {
183183
namespace attribute {
184-
attribute_t *create_idle_mode_duration(cluster_t *cluster, uint32_t value, uint32_t min, uint32_t max);
185-
attribute_t *create_active_mode_duration(cluster_t *cluster, uint32_t value, uint32_t min);
186-
attribute_t *create_active_mode_threshold(cluster_t *cluster, uint16_t value, uint16_t min);
184+
attribute_t *create_idle_mode_duration(cluster_t *cluster, uint32_t value);
185+
attribute_t *create_active_mode_duration(cluster_t *cluster, uint32_t value);
186+
attribute_t *create_active_mode_threshold(cluster_t *cluster, uint16_t value);
187187
attribute_t *create_registered_clients(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count);
188-
attribute_t *create_icd_counter(cluster_t *cluster,uint32_t value);
189-
attribute_t *create_clients_supported_per_fabric(cluster_t *cluster, uint16_t value, uint16_t min);
188+
attribute_t *create_icd_counter(cluster_t *cluster, uint32_t value);
189+
attribute_t *create_clients_supported_per_fabric(cluster_t *cluster, uint16_t value);
190+
attribute_t *create_user_active_mode_trigger_hint(cluster_t *cluster, uint32_t value);
191+
attribute_t *create_user_active_mode_trigger_instruction(cluster_t *cluster, char *value, uint16_t length);
192+
attribute_t *create_operating_mode(cluster_t *cluster, uint8_t value);
190193
} /* attribute */
191194
} /* icd_management */
192195

components/esp_matter/esp_matter_cluster.cpp

+11-6
Original file line numberDiff line numberDiff line change
@@ -985,22 +985,27 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
985985
if (flags & CLUSTER_FLAG_SERVER) {
986986
/* Attributes managed internally */
987987
global::attribute::create_feature_map(cluster, 0);
988+
attribute::create_idle_mode_duration(cluster, CONFIG_ICD_ACTIVE_MODE_INTERVAL_MS);
989+
attribute::create_active_mode_duration(cluster, CONFIG_ICD_IDLE_MODE_INTERVAL_SEC);
990+
attribute::create_active_mode_threshold(cluster, CONFIG_ICD_ACTIVE_MODE_THRESHOLD_MS);
988991

989992
/* Attributes not managed internally */
990993
if (config) {
991994
global::attribute::create_cluster_revision(cluster, config->cluster_revision);
992-
attribute::create_idle_mode_duration(cluster, config->idle_mode_interval, 500, 64800000);
993-
attribute::create_active_mode_duration(cluster, config->active_mode_interval, 300);
994-
attribute::create_active_mode_threshold(cluster, config->active_mode_threshold, 300);
995995
} else {
996996
ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes.");
997997
}
998998
}
999999

10001000
#if defined(CHIP_CONFIG_ENABLE_ICD_CIP) && CHIP_CONFIG_ENABLE_ICD_CIP
1001-
if (features & feature::check_in_protocol_support::get_id()) {
1002-
feature::check_in_protocol_support::config_t cip_config;
1003-
feature::check_in_protocol_support::add(cluster, &cip_config);
1001+
if (features & feature::long_idle_time_support::get_id()) {
1002+
feature::long_idle_time_support::add(cluster);
1003+
if (features & feature::user_active_mode_trigger::get_id()) {
1004+
feature::user_active_mode_trigger::add(cluster, &config->user_active_mode_trigger);
1005+
}
1006+
if (features & feature::check_in_protocol_support::get_id()) {
1007+
feature::check_in_protocol_support::add(cluster);
1008+
}
10041009
}
10051010
#endif // defined(CHIP_CONFIG_ENABLE_ICD_CIP) && CHIP_CONFIG_ENABLE_ICD_CIP
10061011
#endif // CONFIG_ENABLE_ICD_SERVER

components/esp_matter/esp_matter_cluster.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,8 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
246246
namespace icd_management {
247247
typedef struct config {
248248
uint16_t cluster_revision;
249-
uint32_t idle_mode_interval;
250-
uint32_t active_mode_interval;
251-
uint16_t active_mode_threshold;
252-
config() : cluster_revision(2), idle_mode_interval(5000), active_mode_interval(300), active_mode_threshold(300) {}
249+
feature::user_active_mode_trigger::config_t user_active_mode_trigger;
250+
config() : cluster_revision(2) {}
253251
} config_t;
254252

255253
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features);

components/esp_matter/esp_matter_endpoint.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,15 @@ esp_err_t add(endpoint_t *endpoint, config_t *config)
7171
#endif
7272
#if CHIP_CONFIG_ENABLE_ICD_SERVER
7373
icd_management::create(endpoint, &(config->icd_management), CLUSTER_FLAG_SERVER,
74-
icd_management::feature::check_in_protocol_support::get_id());
75-
#endif
74+
#if CHIP_CONFIG_ENABLE_ICD_LIT
75+
icd_management::feature::long_idle_time_support::get_id()
76+
#if CHIP_CONFIG_ENABLE_ICD_CIP
77+
| icd_management::feature::check_in_protocol_support::get_id());
78+
#endif // CHIP_CONFIG_ENABLE_ICD_CIP
79+
#else
80+
0);
81+
#endif // CHIP_CONFIG_ENABLE_ICD_LIT
82+
#endif // CHIP_CONFIG_ENABLE_ICD_SERVER
7683

7784
return ESP_OK;
7885
}

components/esp_matter/esp_matter_feature.cpp

+65-4
Original file line numberDiff line numberDiff line change
@@ -269,20 +269,24 @@ uint32_t get_id()
269269
return (uint32_t)IcdManagement::Feature::kCheckInProtocolSupport;
270270
}
271271

272-
esp_err_t add(cluster_t *cluster, config_t *config)
272+
esp_err_t add(cluster_t *cluster)
273273
{
274274
if (!cluster) {
275275
ESP_LOGE(TAG, "Cluster cannot be NULL");
276276
return ESP_ERR_INVALID_ARG;
277277
}
278+
uint32_t lits_feature_map = feature::long_idle_time_support::get_id();
279+
if ((get_feature_map_value(cluster) & lits_feature_map) != lits_feature_map) {
280+
ESP_LOGE(TAG, "Long Idle Time Support feature should be added to this cluster");
281+
return ESP_ERR_INVALID_STATE;
282+
}
283+
278284
update_feature_map(cluster, get_id());
279285

280286
/* Attributes managed internally */
281287
attribute::create_registered_clients(cluster, NULL, 0, 0);
282288
attribute::create_icd_counter(cluster, 0);
283-
284-
/* Attribute not managed internally*/
285-
attribute::create_clients_supported_per_fabric(cluster, config->clients_supported_per_fabric, 1);
289+
attribute::create_clients_supported_per_fabric(cluster, 0);
286290

287291
/* Commands */
288292
command::create_register_client(cluster);
@@ -293,6 +297,63 @@ esp_err_t add(cluster_t *cluster, config_t *config)
293297
}
294298

295299
} /* check_in_protocol_support */
300+
301+
namespace user_active_mode_trigger {
302+
303+
uint32_t get_id()
304+
{
305+
return (uint32_t)IcdManagement::Feature::kUserActiveModeTrigger;
306+
}
307+
308+
esp_err_t add(cluster_t *cluster, config_t *config)
309+
{
310+
if (!cluster) {
311+
ESP_LOGE(TAG, "Cluster cannot be NULL");
312+
return ESP_ERR_INVALID_ARG;
313+
}
314+
if (!config) {
315+
ESP_LOGE(TAG, "config cannot be NULL");
316+
return ESP_ERR_INVALID_ARG;
317+
}
318+
uint32_t lits_feature_map = feature::long_idle_time_support::get_id();
319+
if ((get_feature_map_value(cluster) & lits_feature_map) != lits_feature_map) {
320+
ESP_LOGE(TAG, "Long Idle Time Support feature should be added to this cluster");
321+
return ESP_ERR_INVALID_STATE;
322+
}
323+
324+
update_feature_map(cluster, get_id());
325+
326+
/* Attributes not managed internally */
327+
attribute::create_user_active_mode_trigger_hint(cluster, config->user_active_mode_trigger_hint);
328+
attribute::create_user_active_mode_trigger_instruction(cluster, config->user_active_mode_trigger_instruction,
329+
strlen(config->user_active_mode_trigger_instruction));
330+
331+
return ESP_OK;
332+
}
333+
334+
} /* user_active_mode_trigger */
335+
336+
namespace long_idle_time_support {
337+
338+
uint32_t get_id()
339+
{
340+
return (uint32_t)IcdManagement::Feature::kLongIdleTimeSupport;
341+
}
342+
343+
esp_err_t add(cluster_t *cluster)
344+
{
345+
if (!cluster) {
346+
ESP_LOGE(TAG, "Cluster cannot be NULL");
347+
return ESP_ERR_INVALID_ARG;
348+
}
349+
update_feature_map(cluster, get_id());
350+
351+
/* Attributes not managed internally */
352+
attribute::create_operating_mode(cluster, 0);
353+
return ESP_OK;
354+
}
355+
356+
} /* long_idle_time_support */
296357
} /* feature */
297358
} /* icd_management */
298359

components/esp_matter/esp_matter_feature.h

+21-3
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,32 @@ esp_err_t add(cluster_t *cluster);
149149
namespace icd_management {
150150
namespace feature {
151151
namespace check_in_protocol_support {
152-
typedef struct config {
153-
uint16_t clients_supported_per_fabric;
152+
153+
uint32_t get_id();
154+
esp_err_t add(cluster_t *cluster);
155+
156+
} /* check_in_protocol_support */
157+
158+
constexpr size_t k_max_user_active_mode_trigger_instruction_length = 128;
159+
160+
namespace user_active_mode_trigger {
161+
typedef struct {
162+
uint32_t user_active_mode_trigger_hint;
163+
char user_active_mode_trigger_instruction[k_max_user_active_mode_trigger_instruction_length + 1];
154164
} config_t;
155165

156166
uint32_t get_id();
157167
esp_err_t add(cluster_t *cluster, config_t *config);
158168

159-
} /* check_in_protocol_support */
169+
} /* user_active_mode_trigger */
170+
171+
namespace long_idle_time_support {
172+
173+
uint32_t get_id();
174+
esp_err_t add(cluster_t *cluster);
175+
176+
} /* long_idle_time_support */
177+
160178
} /* feature */
161179
} /* icd_management */
162180

0 commit comments

Comments
 (0)