84
84
85
85
_ChipDeviceController_IterateDiscoveredCommissionableNodesFunct = CFUNCTYPE (None , c_char_p , c_size_t )
86
86
87
+ # Defines for the transport payload types to use to select the suitable
88
+ # underlying transport of the session.
89
+ # class TransportPayloadCapability(ctypes.c_int):
90
+
91
+
92
+ class TransportPayloadCapability (ctypes .c_int ):
93
+ MRP_PAYLOAD = 0
94
+ LARGE_PAYLOAD = 1
95
+ MRP_OR_TCP_PAYLOAD = 2
96
+
87
97
88
98
@dataclass
89
99
class CommissioningParameters :
@@ -371,6 +381,40 @@ def attestationChallenge(self) -> bytes:
371
381
372
382
return bytes (buf )
373
383
384
+ @property
385
+ def sessionAllowsLargePayload (self ) -> bool :
386
+ self ._dmLib .pychip_SessionAllowsLargePayload .argtypes = [ctypes .c_void_p , POINTER (ctypes .c_bool )]
387
+ self ._dmLib .pychip_SessionAllowsLargePayload .restype = PyChipError
388
+
389
+ supportsLargePayload = ctypes .c_bool (False )
390
+
391
+ builtins .chipStack .Call (
392
+ lambda : self ._dmLib .pychip_SessionAllowsLargePayload (self ._deviceProxy , pointer (supportsLargePayload ))
393
+ ).raise_on_error ()
394
+
395
+ return supportsLargePayload .value
396
+
397
+ @property
398
+ def isSessionActive (self ) -> bool :
399
+ self ._dmLib .pychip_IsSessionActive .argtypes = [ctypes .c_void_p , POINTER (ctypes .c_bool )]
400
+ self ._dmLib .pychip_IsSessionActive .restype = PyChipError
401
+
402
+ isSessionActive = ctypes .c_bool (False )
403
+
404
+ builtins .chipStack .Call (
405
+ lambda : self ._dmLib .pychip_IsSessionActive (self ._deviceProxy , pointer (isSessionActive ))
406
+ ).raise_on_error ()
407
+
408
+ return isSessionActive .value
409
+
410
+ def closeTCPConnectionWithPeer (self ):
411
+ self ._dmLib .pychip_CloseTCPConnectionWithPeer .argtypes = [ctypes .c_void_p ]
412
+ self ._dmLib .pychip_CloseTCPConnectionWithPeer .restype = PyChipError
413
+
414
+ builtins .chipStack .Call (
415
+ lambda : self ._dmLib .pychip_CloseTCPConnectionWithPeer (self ._deviceProxy )
416
+ ).raise_on_error ()
417
+
374
418
375
419
DiscoveryFilterType = discovery .FilterType
376
420
DiscoveryType = discovery .DiscoveryType
@@ -906,7 +950,7 @@ async def FindOrEstablishPASESession(self, setupCode: str, nodeid: int, timeoutM
906
950
if res .is_success :
907
951
return DeviceProxyWrapper (returnDevice , DeviceProxyWrapper .DeviceProxyType .COMMISSIONEE , self ._dmLib )
908
952
909
- def GetConnectedDeviceSync (self , nodeid , allowPASE = True , timeoutMs : int = None ):
953
+ def GetConnectedDeviceSync (self , nodeid , allowPASE = True , timeoutMs : int = None , payloadCapability : int = TransportPayloadCapability . MRP_PAYLOAD ):
910
954
''' Gets an OperationalDeviceProxy or CommissioneeDeviceProxy for the specified Node.
911
955
912
956
nodeId: Target's Node ID
@@ -943,7 +987,7 @@ def deviceAvailable(self, device, err):
943
987
closure = DeviceAvailableClosure ()
944
988
ctypes .pythonapi .Py_IncRef (ctypes .py_object (closure ))
945
989
self ._ChipStack .Call (lambda : self ._dmLib .pychip_GetConnectedDeviceByNodeId (
946
- self .devCtrl , nodeid , ctypes .py_object (closure ), _DeviceAvailableCallback ),
990
+ self .devCtrl , nodeid , ctypes .py_object (closure ), _DeviceAvailableCallback , payloadCapability ),
947
991
timeoutMs ).raise_on_error ()
948
992
949
993
# The callback might have been received synchronously (during self._ChipStack.Call()).
@@ -975,7 +1019,8 @@ async def WaitForActive(self, nodeid, *, timeoutSeconds=30.0, stayActiveDuration
975
1019
await WaitForCheckIn (ScopedNodeId (nodeid , self ._fabricIndex ), timeoutSeconds = timeoutSeconds )
976
1020
return await self .SendCommand (nodeid , 0 , Clusters .IcdManagement .Commands .StayActiveRequest (stayActiveDuration = stayActiveDurationMs ))
977
1021
978
- async def GetConnectedDevice (self , nodeid , allowPASE : bool = True , timeoutMs : int = None ):
1022
+ async def GetConnectedDevice (self , nodeid , allowPASE : bool = True , timeoutMs : int = None ,
1023
+ payloadCapability : int = TransportPayloadCapability .MRP_PAYLOAD ):
979
1024
''' Gets an OperationalDeviceProxy or CommissioneeDeviceProxy for the specified Node.
980
1025
981
1026
nodeId: Target's Node ID
@@ -1020,7 +1065,7 @@ def deviceAvailable(self, device, err):
1020
1065
closure = DeviceAvailableClosure (eventLoop , future )
1021
1066
ctypes .pythonapi .Py_IncRef (ctypes .py_object (closure ))
1022
1067
await self ._ChipStack .CallAsync (lambda : self ._dmLib .pychip_GetConnectedDeviceByNodeId (
1023
- self .devCtrl , nodeid , ctypes .py_object (closure ), _DeviceAvailableCallback ),
1068
+ self .devCtrl , nodeid , ctypes .py_object (closure ), _DeviceAvailableCallback , payloadCapability ),
1024
1069
timeoutMs )
1025
1070
1026
1071
# The callback might have been received synchronously (during self._ChipStack.CallAsync()).
@@ -1124,7 +1169,8 @@ async def TestOnlySendCommandTimedRequestFlagWithNoTimedInvoke(self, nodeid: int
1124
1169
async def SendCommand (self , nodeid : int , endpoint : int , payload : ClusterObjects .ClusterCommand , responseType = None ,
1125
1170
timedRequestTimeoutMs : typing .Union [None , int ] = None ,
1126
1171
interactionTimeoutMs : typing .Union [None , int ] = None , busyWaitMs : typing .Union [None , int ] = None ,
1127
- suppressResponse : typing .Union [None , bool ] = None ):
1172
+ suppressResponse : typing .Union [None , bool ] = None ,
1173
+ payloadCapability : int = TransportPayloadCapability .MRP_PAYLOAD ):
1128
1174
'''
1129
1175
Send a cluster-object encapsulated command to a node and get returned a future that can be awaited upon to receive
1130
1176
the response. If a valid responseType is passed in, that will be used to de-serialize the object. If not,
@@ -1144,7 +1190,7 @@ async def SendCommand(self, nodeid: int, endpoint: int, payload: ClusterObjects.
1144
1190
eventLoop = asyncio .get_running_loop ()
1145
1191
future = eventLoop .create_future ()
1146
1192
1147
- device = await self .GetConnectedDevice (nodeid , timeoutMs = interactionTimeoutMs )
1193
+ device = await self .GetConnectedDevice (nodeid , timeoutMs = interactionTimeoutMs , payloadCapability = payloadCapability )
1148
1194
res = await ClusterCommand .SendCommand (
1149
1195
future , eventLoop , responseType , device .deviceProxy , ClusterCommand .CommandPath (
1150
1196
EndpointId = endpoint ,
@@ -1158,7 +1204,8 @@ async def SendCommand(self, nodeid: int, endpoint: int, payload: ClusterObjects.
1158
1204
async def SendBatchCommands (self , nodeid : int , commands : typing .List [ClusterCommand .InvokeRequestInfo ],
1159
1205
timedRequestTimeoutMs : typing .Optional [int ] = None ,
1160
1206
interactionTimeoutMs : typing .Optional [int ] = None , busyWaitMs : typing .Optional [int ] = None ,
1161
- suppressResponse : typing .Optional [bool ] = None ):
1207
+ suppressResponse : typing .Optional [bool ] = None ,
1208
+ payloadCapability : int = TransportPayloadCapability .MRP_PAYLOAD ):
1162
1209
'''
1163
1210
Send a batch of cluster-object encapsulated commands to a node and get returned a future that can be awaited upon to receive
1164
1211
the responses. If a valid responseType is passed in, that will be used to de-serialize the object. If not,
@@ -1186,7 +1233,7 @@ async def SendBatchCommands(self, nodeid: int, commands: typing.List[ClusterComm
1186
1233
eventLoop = asyncio .get_running_loop ()
1187
1234
future = eventLoop .create_future ()
1188
1235
1189
- device = await self .GetConnectedDevice (nodeid , timeoutMs = interactionTimeoutMs )
1236
+ device = await self .GetConnectedDevice (nodeid , timeoutMs = interactionTimeoutMs , payloadCapability = payloadCapability )
1190
1237
1191
1238
res = await ClusterCommand .SendBatchCommands (
1192
1239
future , eventLoop , device .deviceProxy , commands ,
@@ -1215,7 +1262,8 @@ def SendGroupCommand(self, groupid: int, payload: ClusterObjects.ClusterCommand,
1215
1262
async def WriteAttribute (self , nodeid : int ,
1216
1263
attributes : typing .List [typing .Tuple [int , ClusterObjects .ClusterAttributeDescriptor ]],
1217
1264
timedRequestTimeoutMs : typing .Union [None , int ] = None ,
1218
- interactionTimeoutMs : typing .Union [None , int ] = None , busyWaitMs : typing .Union [None , int ] = None ):
1265
+ interactionTimeoutMs : typing .Union [None , int ] = None , busyWaitMs : typing .Union [None , int ] = None ,
1266
+ payloadCapability : int = TransportPayloadCapability .MRP_PAYLOAD ):
1219
1267
'''
1220
1268
Write a list of attributes on a target node.
1221
1269
@@ -1237,7 +1285,7 @@ async def WriteAttribute(self, nodeid: int,
1237
1285
eventLoop = asyncio .get_running_loop ()
1238
1286
future = eventLoop .create_future ()
1239
1287
1240
- device = await self .GetConnectedDevice (nodeid , timeoutMs = interactionTimeoutMs )
1288
+ device = await self .GetConnectedDevice (nodeid , timeoutMs = interactionTimeoutMs , payloadCapability = payloadCapability )
1241
1289
1242
1290
attrs = []
1243
1291
for v in attributes :
@@ -1396,7 +1444,8 @@ async def Read(self, nodeid: int, attributes: typing.List[typing.Union[
1396
1444
]] = None ,
1397
1445
eventNumberFilter : typing .Optional [int ] = None ,
1398
1446
returnClusterObject : bool = False , reportInterval : typing .Tuple [int , int ] = None ,
1399
- fabricFiltered : bool = True , keepSubscriptions : bool = False , autoResubscribe : bool = True ):
1447
+ fabricFiltered : bool = True , keepSubscriptions : bool = False , autoResubscribe : bool = True ,
1448
+ payloadCapability : int = TransportPayloadCapability .MRP_PAYLOAD ):
1400
1449
'''
1401
1450
Read a list of attributes and/or events from a target node
1402
1451
@@ -1456,7 +1505,7 @@ async def Read(self, nodeid: int, attributes: typing.List[typing.Union[
1456
1505
eventLoop = asyncio .get_running_loop ()
1457
1506
future = eventLoop .create_future ()
1458
1507
1459
- device = await self .GetConnectedDevice (nodeid )
1508
+ device = await self .GetConnectedDevice (nodeid , payloadCapability = payloadCapability )
1460
1509
attributePaths = [self ._parseAttributePathTuple (
1461
1510
v ) for v in attributes ] if attributes else None
1462
1511
clusterDataVersionFilters = [self ._parseDataVersionFilterTuple (
@@ -1487,7 +1536,8 @@ async def ReadAttribute(self, nodeid: int, attributes: typing.List[typing.Union[
1487
1536
]], dataVersionFilters : typing .List [typing .Tuple [int , typing .Type [ClusterObjects .Cluster ], int ]] = None ,
1488
1537
returnClusterObject : bool = False ,
1489
1538
reportInterval : typing .Tuple [int , int ] = None ,
1490
- fabricFiltered : bool = True , keepSubscriptions : bool = False , autoResubscribe : bool = True ):
1539
+ fabricFiltered : bool = True , keepSubscriptions : bool = False , autoResubscribe : bool = True ,
1540
+ payloadCapability : int = TransportPayloadCapability .MRP_PAYLOAD ):
1491
1541
'''
1492
1542
Read a list of attributes from a target node, this is a wrapper of DeviceController.Read()
1493
1543
@@ -1547,7 +1597,8 @@ async def ReadAttribute(self, nodeid: int, attributes: typing.List[typing.Union[
1547
1597
reportInterval = reportInterval ,
1548
1598
fabricFiltered = fabricFiltered ,
1549
1599
keepSubscriptions = keepSubscriptions ,
1550
- autoResubscribe = autoResubscribe )
1600
+ autoResubscribe = autoResubscribe ,
1601
+ payloadCapability = payloadCapability )
1551
1602
if isinstance (res , ClusterAttribute .SubscriptionTransaction ):
1552
1603
return res
1553
1604
else :
@@ -1569,7 +1620,8 @@ async def ReadEvent(self, nodeid: int, events: typing.List[typing.Union[
1569
1620
fabricFiltered : bool = True ,
1570
1621
reportInterval : typing .Tuple [int , int ] = None ,
1571
1622
keepSubscriptions : bool = False ,
1572
- autoResubscribe : bool = True ):
1623
+ autoResubscribe : bool = True ,
1624
+ payloadCapability : int = TransportPayloadCapability .MRP_PAYLOAD ):
1573
1625
'''
1574
1626
Read a list of events from a target node, this is a wrapper of DeviceController.Read()
1575
1627
@@ -1616,7 +1668,7 @@ async def ReadEvent(self, nodeid: int, events: typing.List[typing.Union[
1616
1668
'''
1617
1669
res = await self .Read (nodeid = nodeid , events = events , eventNumberFilter = eventNumberFilter ,
1618
1670
fabricFiltered = fabricFiltered , reportInterval = reportInterval , keepSubscriptions = keepSubscriptions ,
1619
- autoResubscribe = autoResubscribe )
1671
+ autoResubscribe = autoResubscribe , payloadCapability = payloadCapability )
1620
1672
if isinstance (res , ClusterAttribute .SubscriptionTransaction ):
1621
1673
return res
1622
1674
else :
@@ -1764,7 +1816,7 @@ def _InitLib(self):
1764
1816
self ._dmLib .pychip_ScriptDevicePairingDelegate_SetExpectingPairingComplete .restype = PyChipError
1765
1817
1766
1818
self ._dmLib .pychip_GetConnectedDeviceByNodeId .argtypes = [
1767
- c_void_p , c_uint64 , py_object , _DeviceAvailableCallbackFunct ]
1819
+ c_void_p , c_uint64 , py_object , _DeviceAvailableCallbackFunct , c_int ]
1768
1820
self ._dmLib .pychip_GetConnectedDeviceByNodeId .restype = PyChipError
1769
1821
1770
1822
self ._dmLib .pychip_FreeOperationalDeviceProxy .argtypes = [
0 commit comments