Skip to content

Commit

Permalink
Updating ChipDeviceCtrl and TC_CADMIN_1_3_4 modules:
Browse files Browse the repository at this point in the history
- Removed additional commented out line of code in TC_CADMIN_1_3_4 test module.
- Updated ChipDeviceCtrl module to move rcac_bytes var setting to a new function, removed additional print line.
- Updated ChipDeviceCtrl module to await before setting the rcac_bytes var.
  • Loading branch information
j-ororke committed Dec 6, 2024
1 parent ecbeba6 commit e3bf1ba
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
44 changes: 24 additions & 20 deletions src/controller/python/chip/ChipDeviceCtrl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2260,32 +2260,36 @@ async def CommissionOnNetwork(self, nodeId: int, setupPinCode: int,
self.devCtrl, self.pairingDelegate, nodeId, setupPinCode, int(filterType), str(filter).encode("utf-8") if filter is not None else None, discoveryTimeoutMsec)
)

# If RCAC data is needed, await the result
if get_rcac:
try:
sleep(60)
rcac_data_ptr = POINTER(c_uint8)()
rcac_size = c_size_t()
res = await asyncio.futures.wrap_future(ctx.future)

# Call the C++ function to get the RCAC data
self._dmLib.pychip_GetCommissioningRCACData(byref(rcac_data_ptr), byref(rcac_size))
# If RCAC data is wanted, attempt to pull the result
if get_rcac:
rcac_bytes = self.get_rcac()
return (res, rcac_bytes)

# Check if data is available
if rcac_size.value > 0:
# Convert the data to a Python bytes object
rcac_data = cast(rcac_data_ptr, POINTER(c_uint8 * rcac_size.value)).contents
rcac_bytes = bytes(rcac_data)
else:
raise Exception("RCAC data is empty")
else:
return res

except Exception as e:
LOGGER.error(f"Error during RCAC data fetching: {e}")
def get_rcac(self):
try:
rcac_data_ptr = POINTER(c_uint8)()
rcac_size = c_size_t()

LOGGER.info(f"Commissioning RCAC Data: {rcac_bytes}")
return (await asyncio.futures.wrap_future(ctx.future), rcac_bytes)
# Call the C++ function to get the RCAC data
self._dmLib.pychip_GetCommissioningRCACData(byref(rcac_data_ptr), byref(rcac_size))

# Check if data is available
if rcac_size.value > 0:
# Convert the data to a Python bytes object
rcac_data = cast(rcac_data_ptr, POINTER(c_uint8 * rcac_size.value)).contents
rcac_bytes = bytes(rcac_data)
else:
return await asyncio.futures.wrap_future(ctx.future)
raise Exception("RCAC data is empty")

except Exception as e:
LOGGER.error(f"Error during RCAC data fetching: {e}")

return rcac_bytes

async def CommissionWithCode(self, setupPayload: str, nodeid: int, discoveryType: DiscoveryType = DiscoveryType.DISCOVERY_ALL) -> int:
''' Commission with the given nodeid from the setupPayload.
Expand Down
3 changes: 0 additions & 3 deletions src/python_testing/TC_CADMIN_1_3_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,6 @@ async def test_TC_CADMIN_1_3(self):

# Verify that the RootPublicKey matches the root public key for TH_CR2 and the NodeID matches the node ID used when TH_CR2 commissioned the device.
await self.send_single_cmd(dev_ctrl=self.th2, node_id=self.dut_node_id, cmd=Clusters.GeneralCommissioning.Commands.ArmFailSafe(10))
# th2_cam_rcac = TLVReader(base64.b64decode(
# self.certificate_authority_manager.activeCaList[1]._persistentStorage._jsonData["sdk-config"]["f/2/r"])).get()["Any"][9]

if th2_fabric_info[0].rootPublicKey != th2_rcac_decoded:
asserts.fail("public keys from fabric and certs for TH1 are not the same")
Expand Down Expand Up @@ -368,6 +366,5 @@ async def test_TC_CADMIN_1_4(self):
removeFabricCmd = Clusters.OperationalCredentials.Commands.RemoveFabric(th2_idx[outer_key][inner_key][attribute_key])
await self.th1.SendCommand(nodeid=self.dut_node_id, endpoint=0, payload=removeFabricCmd)


if __name__ == "__main__":
default_matter_test_main()

0 comments on commit e3bf1ba

Please sign in to comment.