Skip to content

Commit

Permalink
Merge 4274cb3 into 420e6d4
Browse files Browse the repository at this point in the history
  • Loading branch information
ReneJosefsen authored Dec 29, 2023
2 parents 420e6d4 + 4274cb3 commit 3671961
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
33 changes: 27 additions & 6 deletions src/tools/PICS-generator/PICSGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ def GenerateDevicePicsXmlFiles(clusterName, clusterPicsCode, featurePicsList, at
nodeOperationalCredentialsCluster = "Node Operational Credentials Cluster"
basicInformationCluster = "Basic Information Cluster"
networkCommissioningCluster = "Network Commissioning Cluster"
diagnosticLogsCluster = "Diagnostic Logs Cluster"
thermostatUserInterfaceConfigurationCluster = "Thermostat User Interface Configuration Cluster"
wakeOnLANCluster = "Wake On LAN Cluster"
lowPowerCluster = "Low Power Cluster"

if otaProviderCluster in clusterName or otaRequestorCluster in clusterName:
clusterName = "OTA Software Update"
Expand All @@ -57,6 +61,15 @@ def GenerateDevicePicsXmlFiles(clusterName, clusterPicsCode, featurePicsList, at
elif groupKeyManagementCluster == clusterName:
clusterName = "Group Communication"

elif diagnosticLogsCluster == clusterName:
clusterName = "Diagnostics Logs Cluster"

elif thermostatUserInterfaceConfigurationCluster == clusterName:
clusterName = "Thermostat User Configuration Cluster"

elif wakeOnLANCluster == clusterName or lowPowerCluster == clusterName:
clusterName = "Media Cluster"

elif nodeOperationalCredentialsCluster == clusterName or basicInformationCluster == clusterName or networkCommissioningCluster == clusterName:
clusterName = clusterName.replace("Cluster", "").strip()

Expand Down Expand Up @@ -255,9 +268,14 @@ async def DeviceMapping(devCtrl, nodeID, outputPathStr):
acceptedCommandListPicsList = []
generatedCommandListPicsList = []

clusterClass = getattr(Clusters, devCtrl.GetClusterHandler().GetClusterInfoById(server)['clusterName'])
clusterID = f"0x{server:04x}"

try:
clusterClass = getattr(Clusters, devCtrl.GetClusterHandler().GetClusterInfoById(server)['clusterName'])
except AttributeError:
console.print(f"[red]Cluster class not found for ({clusterID}) not found! ❌")
continue

# Does the clusterInfoDict contain the found cluster ID?
if clusterID not in clusterInfoDict:
console.print(f"[red]Cluster ID ({clusterID}) not in list! ❌")
Expand Down Expand Up @@ -372,6 +390,7 @@ def cleanDirectory(pathToClean):
baseOutputPathStr = args.pics_output
if not baseOutputPathStr.endswith('/'):
baseOutputPathStr += '/'
outputPathStr = baseOutputPathStr + "GeneratedPICS/"

serverTag = ".S"
clientTag = ".C"
Expand Down Expand Up @@ -421,13 +440,15 @@ def cleanDirectory(pathToClean):
xmlFileList = os.listdir(xmlTemplatePathStr)

# Setup output path
baseOutputPath = pathlib.Path(baseOutputPathStr)
if not baseOutputPath.exists():
print(outputPathStr)

outputPath = pathlib.Path(outputPathStr)
if not outputPath.exists():
print("Create output folder")
baseOutputPath.mkdir()
outputPath.mkdir()
else:
print("Clean output folder")
cleanDirectory(baseOutputPath)
cleanDirectory(outputPath)


class DeviceMappingTest(MatterBaseTest):
Expand All @@ -439,7 +460,7 @@ async def test_device_mapping(self):
console = Console()

# Run device mapping function
await DeviceMapping(self.default_controller, self.dut_node_id, baseOutputPathStr)
await DeviceMapping(self.default_controller, self.dut_node_id, outputPathStr)


if __name__ == "__main__":
Expand Down
10 changes: 8 additions & 2 deletions src/tools/PICS-generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ certification)

# How to run

First change the directory to the tool location.

```
cd src/tools/PICS-generator/
```

The tool does, as mentioned above, have external dependencies, these are
provided to the tool using these arguments:

Expand All @@ -59,7 +65,7 @@ If the device has not been commissioned this can be done by passing in the
commissioning information:

```
python3 'src/python_testing/PICSGenerator.py' --cluster-data <pathToClusterJson> --pics-template <pathToPicsTemplateFolder> --pics-output <outputPath> --commissioning-method ble-thread --discriminator <DESCRIMINATOR> --passcode <PASSCODE> --thread-dataset-hex <DATASET_AS_HEX>
python3 PICSGenerator.py --cluster-data <pathToClusterJson> --pics-template <pathToPicsTemplateFolder> --pics-output <outputPath> --commissioning-method ble-thread --discriminator <DESCRIMINATOR> --passcode <PASSCODE> --thread-dataset-hex <DATASET_AS_HEX>
```

In case the device uses a development PAA, the following parameter should be
Expand All @@ -79,5 +85,5 @@ added.
If a device has already been commissioned, the tool can be executed like this:

```
python3 'src/python_testing/PICSGenerator.py' --cluster-data <pathToClusterJson> --pics-template <pathToPicsTemplateFolder> --pics-output <outputPath>
python3 PICSGenerator.py --cluster-data <pathToClusterJson> --pics-template <pathToPicsTemplateFolder> --pics-output <outputPath>
```

0 comments on commit 3671961

Please sign in to comment.