Merge branch 'bugfix-mode-select' into 'main'

Allowing empty semantic tags list in SupportedModes attribute of ModeSelect

See merge request app-frameworks/esp-matter!446
This commit is contained in:
Hrishikesh Dhayagude
2023-08-02 13:22:34 +08:00
2 changed files with 21 additions and 9 deletions
+11 -5
View File
@@ -1243,28 +1243,34 @@ Use `mfg_tool <https://github.com/espressif/esp-matter/blob/main/tools/mfg_tool/
-k path/to/esp-matter/connectedhomeip/connectedhomeip/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-Key.pem \
-c path/to/esp-matter/connectedhomeip/connectedhomeip/credentials/test/attestation/Chip-Test-PAI-FFF2-8001-Cert.pem \
-cd path/to/esp-matter/connectedhomeip/connectedhomeip/credentials/test/certification-declaration/Chip-Test-CD-FFF2-8001.der \
--supported-modes mode1/label1/endpointId/"value\\mfgCode, value\\mfgCode" mode2/label2/endpointId/"value\\mfgCode, value\\mfgCode"
--supported-modes mode1/label1/endpointId/"value\mfgCode, value\mfgCode" mode2/label2/endpointId/"value\mfgCode, value\mfgCode"
- For empty Semantic Tags list
::
--supported-modes mode1/label1/endpointId mode2/label2/endpointId
2.8.3 Build example
~~~~~~~~~~~~~~~~~~~
For example we want to use mode_select cluster in light example.
- Add implementation path toexample/light/main/CMakeList.txt
- Add source and include path to example/light/main/CMakeList.txt
::
Append "${MATTER_SDK_PATH}/examples/platform/esp32/mode-support" to SRC_DIRS
Append "${MATTER_SDK_PATH}/examples/platform/esp32/mode-support" to SRC_DIRS and PRIV_INCLUDE_DIRS
- In file example/light/app_main.cpp.
::
#include <examples/platform/esp32/mode-support/static-supported-modes-manager.h>
#include <static-supported-modes-manager.h>
{
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));
}
+10 -4
View File
@@ -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}