From 723d655a0a4e6a033fe6a751437632e502bd71ac Mon Sep 17 00:00:00 2001 From: Cecille Freeman Date: Sat, 20 Jan 2024 22:46:29 -0500 Subject: [PATCH] docs: add generator for pseudocluster tables --- docs/testing/yaml_pseudocluster.md | 70 +++++++++++++++++++ .../generate_pseudo_cluster_doc_tables.py | 50 +++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 docs/testing/yaml_pseudocluster.md create mode 100644 scripts/py_matter_yamltests/generate_pseudo_cluster_doc_tables.py diff --git a/docs/testing/yaml_pseudocluster.md b/docs/testing/yaml_pseudocluster.md new file mode 100644 index 00000000000000..bf9178b7fcec15 --- /dev/null +++ b/docs/testing/yaml_pseudocluster.md @@ -0,0 +1,70 @@ + + + + +CommissionerCommands +|command|args|arg type| arg optional| +|:---|:---|:---|:---| +|PairWithCode|nodeId
payload
discoverOnce|node_id
char_string
boolean|false
false
true| +|Unpair|nodeId|node_id|false| +|GetCommissionerNodeId|||| +|GetCommissionerNodeIdResponse|nodeId|node_id|false| +|GetCommissionerRootCertificate|||| +|GetCommissionerRootCertificateResponse|RCAC|OCTET_STRING|false| +|IssueNocChain|Elements
nodeId|octet_string
node_id|false
false| +|IssueNocChainResponse|NOC
ICAC
RCAC
IPK|octet_string
octet_string
octet_string
octet_string|false
false
false
false| + + +DelayCommands +|command|args|arg type| arg optional| +|:---|:---|:---|:---| +|WaitForCommissioning|||| +|WaitForCommissionee|nodeId
expireExistingSession|node_id
bool|false
true| +|WaitForMs|ms|int16u|false| +|WaitForMessage|registerKey
message|char_string
char_string|false
false| + + +DiscoveryCommands +|command|args|arg type| arg optional| +|:---|:---|:---|:---| +|FindCommissionable|||| +|FindCommissionableByShortDiscriminator|value|int16u|false| +|FindCommissionableByLongDiscriminator|value|int16u|false| +|FindCommissionableByCommissioningMode|||| +|FindCommissionableByVendorId|value|vendor_id|false| +|FindCommissionableByDeviceType|value|devtype_id|false| +|FindCommissioner|||| +|FindCommissionerByVendorId|value|vendor_id|false| +|FindCommissionerByDeviceType|value|devtype_id|false| +|FindResponse|hostName
instanceName
longDiscriminator
shortDiscriminator
vendorId
productId
commissioningMode
deviceType
deviceName
rotatingId
rotatingIdLen
pairingHint
pairingInstruction
supportsTcp
numIPs
port
mrpRetryIntervalIdle
mrpRetryIntervalActive
mrpRetryActiveThreshold
isICDOperatingAsLIT|char_string
char_string
int16u
int16u
vendor_id
int16u
int8u
devtype_id
char_string
octet_string
int64u
int16u
char_string
boolean
int8u
int16u
int32u
int32u
int16u
boolean|false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
false
true
true
true
true| + + +EqualityCommands +|command|args|arg type| arg optional| +|:---|:---|:---|:---| +|BooleanEquals|Value1
Value2|boolean
boolean|false
false| +|SignedNumberEquals|Value1
Value2|int64s
int64s|false
false| +|UnsignedNumberEquals|Value1
Value2|int64u
int64u|false
false| +|EqualityResponse|Equals|bool|false| + + +LogCommands +|command|args|arg type| arg optional| +|:---|:---|:---|:---| +|Log|message|char_string|false| +|UserPrompt|message
expectedValue|char_string
char_string|false
true| + + +SystemCommands +|command|args|arg type| arg optional| +|:---|:---|:---|:---| +|Start|registerKey
discriminator
port
minCommissioningTimeout
kvs
filepath
otaDownloadPath|char_string
int16u
int16u
int16u
char_string
char_string
char_string|true
true
true
true
true
true
true| +|Stop|registerKey|char_string|true| +|Reboot|registerKey|char_string|true| +|FactoryReset|registerKey|char_string|true| +|CreateOtaImage|otaImageFilePath
rawImageFilePath
rawImageContent|char_string
char_string
char_string|false
false
false| +|CompareFiles|file1
file2|char_string
char_string|false
false| diff --git a/scripts/py_matter_yamltests/generate_pseudo_cluster_doc_tables.py b/scripts/py_matter_yamltests/generate_pseudo_cluster_doc_tables.py new file mode 100644 index 00000000000000..9d60f4f8b2fb3f --- /dev/null +++ b/scripts/py_matter_yamltests/generate_pseudo_cluster_doc_tables.py @@ -0,0 +1,50 @@ +# Copyright (c) 2024 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +from matter_yamltests.pseudo_clusters.pseudo_clusters import get_default_pseudo_clusters +import xml.etree.ElementTree as ElementTree + +SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__)) +WARNING = ("\n\n") + + +def create_tables(): + pseudo_clusters = get_default_pseudo_clusters() + + doc_path = os.path.abspath(os.path.join(SCRIPT_DIR, '..', '..', 'docs', 'testing', 'yaml_pseudocluster.md')) + with open(doc_path, "w") as f: + f.writelines(WARNING) + + for cluster in pseudo_clusters.clusters: + f.writelines(f'\n\n{cluster.name}\n') + f.writelines('|command|args|arg type| arg optional|\n') + f.writelines('|:---|:---|:---|:---|\n') + + et = ElementTree.fromstring(cluster.definition) + cluster_xml = next(et.iter('cluster')) + for command_xml in cluster_xml.iter('command'): + cmd = command_xml.get('name') + arg = '
'.join([arg_xml.get('name') for arg_xml in command_xml.iter('arg')]) + argtype = '
'.join([arg_xml.get('type') for arg_xml in command_xml.iter('arg')]) + optional = '
'.join([arg_xml.get('optional', 'false') for arg_xml in command_xml.iter('arg')]) + + f.writelines(f'|{cmd}|{arg}|{argtype}|{optional}|\n') + + +create_tables()