|
53 | 53 | from .clusters.CHIPClusters import ChipClusters
|
54 | 54 | from .crypto import p256keypair
|
55 | 55 | from .exceptions import UnknownAttribute, UnknownCommand
|
56 |
| -from .interaction_model import InteractionModelError |
| 56 | +from .interaction_model import InteractionModelError, SessionParameters, SessionParametersStruct |
57 | 57 | from .interaction_model import delegate as im
|
58 | 58 | from .native import PyChipError
|
59 | 59 |
|
@@ -809,6 +809,36 @@ def ComputeRoundTripTimeout(self, nodeid, upperLayerProcessingTimeoutMs: int = 0
|
809 | 809 | device.deviceProxy, upperLayerProcessingTimeoutMs))
|
810 | 810 | return res
|
811 | 811 |
|
| 812 | + def GetRemoteSessionParameters(self, nodeid) -> typing.Optional[SessionParameters]: |
| 813 | + ''' Returns the SessionParameters of reported by the remote node associated with `nodeid`. |
| 814 | + If there is some error in getting SessionParameters None is returned. |
| 815 | +
|
| 816 | + This will result in a session being established if one wasn't already established. |
| 817 | + ''' |
| 818 | + |
| 819 | + # First creating the struct to make building the ByteArray to be sent to CFFI easier. |
| 820 | + sessionParametersStruct = SessionParametersStruct.parse(b'\x00' * SessionParametersStruct.sizeof()) |
| 821 | + sessionParametersByteArray = SessionParametersStruct.build(sessionParametersStruct) |
| 822 | + device = self.GetConnectedDeviceSync(nodeid) |
| 823 | + res = self._ChipStack.Call(lambda: self._dmLib.pychip_DeviceProxy_GetRemoteSessionParameters( |
| 824 | + device.deviceProxy, ctypes.c_char_p(sessionParametersByteArray))) |
| 825 | + |
| 826 | + # 0 is CHIP_NO_ERROR |
| 827 | + if res != 0: |
| 828 | + return None |
| 829 | + |
| 830 | + sessionParametersStruct = SessionParametersStruct.parse(sessionParametersByteArray) |
| 831 | + return SessionParameters( |
| 832 | + sessionIdleInterval=sessionParametersStruct.SessionIdleInterval if sessionParametersStruct.SessionIdleInterval != 0 else None, |
| 833 | + sessionActiveInterval=sessionParametersStruct.SessionActiveInterval if sessionParametersStruct.SessionActiveInterval != 0 else None, |
| 834 | + sessionActiveThreshold=sessionParametersStruct.SessionActiveThreshold if sessionParametersStruct.SessionActiveThreshold != 0 else None, |
| 835 | + dataModelRevision=sessionParametersStruct.DataModelRevision if sessionParametersStruct.DataModelRevision != 0 else None, |
| 836 | + interactionModelRevision=sessionParametersStruct.InteractionModelRevision if sessionParametersStruct.InteractionModelRevision != 0 else None, |
| 837 | + specficiationVersion=sessionParametersStruct.SpecificationVersion if sessionParametersStruct.SpecificationVersion != 0 else None, |
| 838 | + maxPathsPerInvoke=sessionParametersStruct.MaxPathsPerInvoke) |
| 839 | + |
| 840 | + return res |
| 841 | + |
812 | 842 | async def TestOnlySendCommandTimedRequestFlagWithNoTimedInvoke(self, nodeid: int, endpoint: int,
|
813 | 843 | payload: ClusterObjects.ClusterCommand, responseType=None):
|
814 | 844 | '''
|
|
0 commit comments