From 3a75dabe273f451fae0c9b7e213e373f6d4f72bc Mon Sep 17 00:00:00 2001 From: Rohit Jadhav Date: Fri, 28 Jul 2023 10:10:08 +0530 Subject: [PATCH] Allowing empty semantic tags list in SupportedModes attribute of ModeSelect. Fixes https://github.com/espressif/esp-matter/issues/529 --- docs/en/developing.rst | 16 +++++++++++----- tools/mfg_tool/utils.py | 14 ++++++++++---- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/docs/en/developing.rst b/docs/en/developing.rst index 68df060aa..eabda9852 100644 --- a/docs/en/developing.rst +++ b/docs/en/developing.rst @@ -1243,28 +1243,34 @@ Use `mfg_tool + #include { cluster::mode_select::config_t ms_config; cluster_t *ms_cluster = cluster::mode_select::create(endpoint, &ms_config, CLUSTER_FLAG_SERVER, ESP_MATTER_NONE_FEATURE_ID); - ModeSelect::StaticSupportedModesManager::getStaticSupportedModesManagerInstance().InitEndpointArray(get_endpoint_count(node)); + ModeSelect::StaticSupportedModesManager::getStaticSupportedModesManagerInstance().InitEndpointArray(get_count(node)); } diff --git a/tools/mfg_tool/utils.py b/tools/mfg_tool/utils.py index 5fecf58bf..d50a475ad 100644 --- a/tools/mfg_tool/utils.py +++ b/tools/mfg_tool/utils.py @@ -236,9 +236,13 @@ def get_fixed_label_dict(fixed_labels): # get_supported_modes_dict() converts the list of strings to per endpoint dictionaries. -# example input : ['0/label1/1/"1\0x8000, 2\0x8000", 1/label2/1/"1\0x8000, 2\0x8000"'] -# example outout : {'1': [{'Label': 'label1', 'Mode': 0, 'Semantic_Tag': [{'value': 1, 'mfgCode': 32768}, {'value': 2, 'mfgCode': 32768}]}, {'Label': 'label2', 'Mode': 1, 'Semantic_Tag': [{'value': 1, 'mfgCode': 32768}, {'value': 2, 'mfgCode': 32768}]}]} +# example with semantic tags +# input : ['0/label1/1/"1\0x8000, 2\0x8000" 1/label2/1/"1\0x8000, 2\0x8000"'] +# outout : {'1': [{'Label': 'label1', 'Mode': 0, 'Semantic_Tag': [{'value': 1, 'mfgCode': 32768}, {'value': 2, 'mfgCode': 32768}]}, {'Label': 'label2', 'Mode': 1, 'Semantic_Tag': [{'value': 1, 'mfgCode': 32768}, {'value': 2, 'mfgCode': 32768}]}]} +# example without semantic tags +# input : ['0/label1/1 1/label2/1'] +# outout : {'1': [{'Label': 'label1', 'Mode': 0, 'Semantic_Tag': []}, {'Label': 'label2', 'Mode': 1, 'Semantic_Tag': []}]} def get_supported_modes_dict(supported_modes): output_dict = {} @@ -249,8 +253,10 @@ def get_supported_modes_dict(supported_modes): label = mode_label_strs[1] ep = mode_label_strs[2] - semantic_tag_strs = mode_label_strs[3].split(', ') - semantic_tags = [{"value": int(v.split('\\')[0]), "mfgCode": int(v.split('\\')[1], 16)} for v in semantic_tag_strs] + semantic_tags = '' + if (len(mode_label_strs) == 4): + semantic_tag_strs = mode_label_strs[3].split(', ') + semantic_tags = [{"value": int(v.split('\\')[0]), "mfgCode": int(v.split('\\')[1], 16)} for v in semantic_tag_strs] mode_dict = {"Label": label, "Mode": int(mode), "Semantic_Tag": semantic_tags}