|
1 | 1 | #
|
2 |
| -# Copyright (c) 2020-2022 Project CHIP Authors |
| 2 | +# Copyright (c) 2020-2025 Project CHIP Authors |
3 | 3 | # Copyright (c) 2019-2020 Google, LLC.
|
4 | 4 | # Copyright (c) 2013-2018 Nest Labs, Inc.
|
5 | 5 | # All rights reserved.
|
@@ -702,12 +702,52 @@ def ExpireSessions(self, nodeid):
|
702 | 702 |
|
703 | 703 | self._ChipStack.Call(lambda: self._dmLib.pychip_ExpireSessions(self.devCtrl, nodeid)).raise_on_error()
|
704 | 704 |
|
705 |
| - # TODO: This needs to be called MarkSessionDefunct |
706 |
| - def CloseSession(self, nodeid): |
| 705 | + def MarkSessionDefunct(self, nodeid): |
| 706 | + ''' |
| 707 | + Marks a previously active session with the specified node as defunct to temporarily prevent it |
| 708 | + from being used with new exchanges to send or receive messages. This should be called when there |
| 709 | + is suspicion of a loss-of-sync with the session state on the associated peer, such as evidence |
| 710 | + of transport failure. |
| 711 | +
|
| 712 | + If messages are received thereafter on this session, the session will be put back into the Active state. |
| 713 | +
|
| 714 | + This function should only be called on an active session. |
| 715 | + This will NOT detach any existing SessionHolders. |
| 716 | +
|
| 717 | + Parameters: |
| 718 | + nodeid (int): The node ID of the device whose session should be marked as defunct. |
| 719 | +
|
| 720 | + Raises: |
| 721 | + RuntimeError: If the controller is not active. |
| 722 | + PyChipError: If the operation fails. |
| 723 | + ''' |
| 724 | + self.CheckIsActive() |
| 725 | + |
| 726 | + self._ChipStack.Call( |
| 727 | + lambda: self._dmLib.pychip_DeviceController_MarkSessionDefunct( |
| 728 | + self.devCtrl, nodeid) |
| 729 | + ).raise_on_error() |
| 730 | + |
| 731 | + def MarkSessionForEviction(self, nodeid): |
| 732 | + ''' |
| 733 | + Marks the session with the specified node for eviction. It will first detach all SessionHolders |
| 734 | + attached to this session by calling 'OnSessionReleased' on each of them. This will force them |
| 735 | + to release their reference to the session. If there are no more references left, the session |
| 736 | + will then be de-allocated. |
| 737 | +
|
| 738 | + Once marked for eviction, the session SHALL NOT ever become active again. |
| 739 | +
|
| 740 | + Parameters: |
| 741 | + nodeid (int): The node ID of the device whose session should be marked for eviction. |
| 742 | +
|
| 743 | + Raises: |
| 744 | + RuntimeError: If the controller is not active. |
| 745 | + PyChipError: If the operation fails. |
| 746 | + ''' |
707 | 747 | self.CheckIsActive()
|
708 | 748 |
|
709 | 749 | self._ChipStack.Call(
|
710 |
| - lambda: self._dmLib.pychip_DeviceController_CloseSession( |
| 750 | + lambda: self._dmLib.pychip_DeviceController_MarkSessionForEviction( |
711 | 751 | self.devCtrl, nodeid)
|
712 | 752 | ).raise_on_error()
|
713 | 753 |
|
@@ -1873,9 +1913,13 @@ def _InitLib(self):
|
1873 | 1913 | c_void_p, c_uint64, _DeviceUnpairingCompleteFunct]
|
1874 | 1914 | self._dmLib.pychip_DeviceController_UnpairDevice.restype = PyChipError
|
1875 | 1915 |
|
1876 |
| - self._dmLib.pychip_DeviceController_CloseSession.argtypes = [ |
| 1916 | + self._dmLib.pychip_DeviceController_MarkSessionDefunct.argtypes = [ |
1877 | 1917 | c_void_p, c_uint64]
|
1878 |
| - self._dmLib.pychip_DeviceController_CloseSession.restype = PyChipError |
| 1918 | + self._dmLib.pychip_DeviceController_MarkSessionDefunct.restype = PyChipError |
| 1919 | + |
| 1920 | + self._dmLib.pychip_DeviceController_MarkSessionForEviction.argtypes = [ |
| 1921 | + c_void_p, c_uint64] |
| 1922 | + self._dmLib.pychip_DeviceController_MarkSessionForEviction.restype = PyChipError |
1879 | 1923 |
|
1880 | 1924 | self._dmLib.pychip_DeviceController_GetAddressAndPort.argtypes = [
|
1881 | 1925 | c_void_p, c_uint64, c_char_p, c_uint64, POINTER(c_uint16)]
|
@@ -2261,7 +2305,7 @@ async def CommissionOnNetwork(self, nodeId: int, setupPinCode: int,
|
2261 | 2305 | return await asyncio.futures.wrap_future(ctx.future)
|
2262 | 2306 |
|
2263 | 2307 | def get_rcac(self):
|
2264 |
| - ''' |
| 2308 | + ''' |
2265 | 2309 | Passes captured RCAC data back to Python test modules for validation
|
2266 | 2310 | - Setting buffer size to max size mentioned in spec:
|
2267 | 2311 | - Ref: https://github.com/CHIP-Specifications/connectedhomeip-spec/blob/06c4d55962954546ecf093c221fe1dab57645028/policies/matter_certificate_policy.adoc#615-key-sizes
|
|
0 commit comments