|
20 | 20 | import queue
|
21 | 21 | import time
|
22 | 22 | from threading import Event
|
| 23 | +from typing import List |
23 | 24 |
|
24 | 25 | import chip.clusters as Clusters
|
25 | 26 | from chip.clusters import ClusterObjects as ClustersObjects
|
@@ -123,6 +124,24 @@ async def test_TC_SC_3_6(self):
|
123 | 124 | )
|
124 | 125 | asserts.assert_greater_equal(capability_minima.caseSessionsPerFabric, 3)
|
125 | 126 |
|
| 127 | + logging.info("Pre-condition: Remove all pre-existing fabrics on the device that do not belong to the TH") |
| 128 | + commissioned_fabric_count: int = await self.read_single_attribute( |
| 129 | + dev_ctrl, node_id=self.dut_node_id, |
| 130 | + endpoint=0, attribute=Clusters.OperationalCredentials.Attributes.CommissionedFabrics) |
| 131 | + |
| 132 | + if commissioned_fabric_count > 1: |
| 133 | + fabrics: List[Clusters.OperationalCredentials.Structs.FabricDescriptorStruct] = await self.read_single_attribute( |
| 134 | + dev_ctrl, node_id=self.dut_node_id, endpoint=0, |
| 135 | + attribute=Clusters.OperationalCredentials.Attributes.Fabrics, fabricFiltered=False) |
| 136 | + current_fabric_index = await self.read_single_attribute_check_success(cluster=Clusters.OperationalCredentials, attribute=Clusters.OperationalCredentials.Attributes.CurrentFabricIndex) |
| 137 | + for fabric in fabrics: |
| 138 | + if fabric.fabricIndex == current_fabric_index: |
| 139 | + continue |
| 140 | + # This is not the test client's fabric, so remove it. |
| 141 | + logging.info(f"Removing extra fabric at {fabric.fabricIndex} from device.") |
| 142 | + await dev_ctrl.SendCommand( |
| 143 | + self.dut_node_id, 0, Clusters.OperationalCredentials.Commands.RemoveFabric(fabricIndex=fabric.fabricIndex)) |
| 144 | + |
126 | 145 | logging.info("Pre-conditions: use existing fabric to configure new fabrics so that total is %d fabrics" %
|
127 | 146 | num_fabrics_to_commission)
|
128 | 147 |
|
|
0 commit comments