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,53 @@ 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 isSessionOverTCPConnection (self ) -> bool :
399
+ self ._dmLib .pychip_IsSessionOverTCPConnection .argtypes = [ctypes .c_void_p , POINTER (ctypes .c_bool )]
400
+ self ._dmLib .pychip_IsSessionOverTCPConnection .restype = PyChipError
401
+
402
+ isSessionOverTCP = ctypes .c_bool (False )
403
+
404
+ builtins .chipStack .Call (
405
+ lambda : self ._dmLib .pychip_IsSessionOverTCPConnection (self ._deviceProxy , pointer (isSessionOverTCP ))
406
+ ).raise_on_error ()
407
+
408
+ return isSessionOverTCP .value
409
+
410
+ @property
411
+ def isActiveSession (self ) -> bool :
412
+ self ._dmLib .pychip_IsActiveSession .argtypes = [ctypes .c_void_p , POINTER (ctypes .c_bool )]
413
+ self ._dmLib .pychip_IsActiveSession .restype = PyChipError
414
+
415
+ isActiveSession = ctypes .c_bool (False )
416
+
417
+ builtins .chipStack .Call (
418
+ lambda : self ._dmLib .pychip_IsActiveSession (self ._deviceProxy , pointer (isActiveSession ))
419
+ ).raise_on_error ()
420
+
421
+ return isActiveSession .value
422
+
423
+ def closeTCPConnectionWithPeer (self ):
424
+ self ._dmLib .pychip_CloseTCPConnectionWithPeer .argtypes = [ctypes .c_void_p ]
425
+ self ._dmLib .pychip_CloseTCPConnectionWithPeer .restype = PyChipError
426
+
427
+ builtins .chipStack .Call (
428
+ lambda : self ._dmLib .pychip_CloseTCPConnectionWithPeer (self ._deviceProxy )
429
+ ).raise_on_error ()
430
+
374
431
375
432
DiscoveryFilterType = discovery .FilterType
376
433
DiscoveryType = discovery .DiscoveryType
@@ -906,7 +963,7 @@ async def FindOrEstablishPASESession(self, setupCode: str, nodeid: int, timeoutM
906
963
if res .is_success :
907
964
return DeviceProxyWrapper (returnDevice , DeviceProxyWrapper .DeviceProxyType .COMMISSIONEE , self ._dmLib )
908
965
909
- def GetConnectedDeviceSync (self , nodeid , allowPASE = True , timeoutMs : int = None ):
966
+ def GetConnectedDeviceSync (self , nodeid , allowPASE = True , timeoutMs : int = None , payloadCapability : int = TransportPayloadCapability . MRP_PAYLOAD ):
910
967
''' Gets an OperationalDeviceProxy or CommissioneeDeviceProxy for the specified Node.
911
968
912
969
nodeId: Target's Node ID
@@ -943,7 +1000,7 @@ def deviceAvailable(self, device, err):
943
1000
closure = DeviceAvailableClosure ()
944
1001
ctypes .pythonapi .Py_IncRef (ctypes .py_object (closure ))
945
1002
self ._ChipStack .Call (lambda : self ._dmLib .pychip_GetConnectedDeviceByNodeId (
946
- self .devCtrl , nodeid , ctypes .py_object (closure ), _DeviceAvailableCallback ),
1003
+ self .devCtrl , nodeid , ctypes .py_object (closure ), _DeviceAvailableCallback , payloadCapability ),
947
1004
timeoutMs ).raise_on_error ()
948
1005
949
1006
# The callback might have been received synchronously (during self._ChipStack.Call()).
@@ -975,7 +1032,8 @@ async def WaitForActive(self, nodeid, *, timeoutSeconds=30.0, stayActiveDuration
975
1032
await WaitForCheckIn (ScopedNodeId (nodeid , self ._fabricIndex ), timeoutSeconds = timeoutSeconds )
976
1033
return await self .SendCommand (nodeid , 0 , Clusters .IcdManagement .Commands .StayActiveRequest (stayActiveDuration = stayActiveDurationMs ))
977
1034
978
- async def GetConnectedDevice (self , nodeid , allowPASE : bool = True , timeoutMs : int = None ):
1035
+ async def GetConnectedDevice (self , nodeid , allowPASE : bool = True , timeoutMs : int = None ,
1036
+ payloadCapability : int = TransportPayloadCapability .MRP_PAYLOAD ):
979
1037
''' Gets an OperationalDeviceProxy or CommissioneeDeviceProxy for the specified Node.
980
1038
981
1039
nodeId: Target's Node ID
@@ -1020,7 +1078,7 @@ def deviceAvailable(self, device, err):
1020
1078
closure = DeviceAvailableClosure (eventLoop , future )
1021
1079
ctypes .pythonapi .Py_IncRef (ctypes .py_object (closure ))
1022
1080
await self ._ChipStack .CallAsync (lambda : self ._dmLib .pychip_GetConnectedDeviceByNodeId (
1023
- self .devCtrl , nodeid , ctypes .py_object (closure ), _DeviceAvailableCallback ),
1081
+ self .devCtrl , nodeid , ctypes .py_object (closure ), _DeviceAvailableCallback , payloadCapability ),
1024
1082
timeoutMs )
1025
1083
1026
1084
# The callback might have been received synchronously (during self._ChipStack.CallAsync()).
@@ -1124,7 +1182,8 @@ async def TestOnlySendCommandTimedRequestFlagWithNoTimedInvoke(self, nodeid: int
1124
1182
async def SendCommand (self , nodeid : int , endpoint : int , payload : ClusterObjects .ClusterCommand , responseType = None ,
1125
1183
timedRequestTimeoutMs : typing .Union [None , int ] = None ,
1126
1184
interactionTimeoutMs : typing .Union [None , int ] = None , busyWaitMs : typing .Union [None , int ] = None ,
1127
- suppressResponse : typing .Union [None , bool ] = None ):
1185
+ suppressResponse : typing .Union [None , bool ] = None ,
1186
+ payloadCapability : int = TransportPayloadCapability .MRP_PAYLOAD ):
1128
1187
'''
1129
1188
Send a cluster-object encapsulated command to a node and get returned a future that can be awaited upon to receive
1130
1189
the response. If a valid responseType is passed in, that will be used to de-serialize the object. If not,
@@ -1144,7 +1203,7 @@ async def SendCommand(self, nodeid: int, endpoint: int, payload: ClusterObjects.
1144
1203
eventLoop = asyncio .get_running_loop ()
1145
1204
future = eventLoop .create_future ()
1146
1205
1147
- device = await self .GetConnectedDevice (nodeid , timeoutMs = interactionTimeoutMs )
1206
+ device = await self .GetConnectedDevice (nodeid , timeoutMs = interactionTimeoutMs , payloadCapability = payloadCapability )
1148
1207
res = await ClusterCommand .SendCommand (
1149
1208
future , eventLoop , responseType , device .deviceProxy , ClusterCommand .CommandPath (
1150
1209
EndpointId = endpoint ,
@@ -1158,7 +1217,8 @@ async def SendCommand(self, nodeid: int, endpoint: int, payload: ClusterObjects.
1158
1217
async def SendBatchCommands (self , nodeid : int , commands : typing .List [ClusterCommand .InvokeRequestInfo ],
1159
1218
timedRequestTimeoutMs : typing .Optional [int ] = None ,
1160
1219
interactionTimeoutMs : typing .Optional [int ] = None , busyWaitMs : typing .Optional [int ] = None ,
1161
- suppressResponse : typing .Optional [bool ] = None ):
1220
+ suppressResponse : typing .Optional [bool ] = None ,
1221
+ payloadCapability : int = TransportPayloadCapability .MRP_PAYLOAD ):
1162
1222
'''
1163
1223
Send a batch of cluster-object encapsulated commands to a node and get returned a future that can be awaited upon to receive
1164
1224
the responses. If a valid responseType is passed in, that will be used to de-serialize the object. If not,
@@ -1186,7 +1246,7 @@ async def SendBatchCommands(self, nodeid: int, commands: typing.List[ClusterComm
1186
1246
eventLoop = asyncio .get_running_loop ()
1187
1247
future = eventLoop .create_future ()
1188
1248
1189
- device = await self .GetConnectedDevice (nodeid , timeoutMs = interactionTimeoutMs )
1249
+ device = await self .GetConnectedDevice (nodeid , timeoutMs = interactionTimeoutMs , payloadCapability = payloadCapability )
1190
1250
1191
1251
res = await ClusterCommand .SendBatchCommands (
1192
1252
future , eventLoop , device .deviceProxy , commands ,
@@ -1215,7 +1275,8 @@ def SendGroupCommand(self, groupid: int, payload: ClusterObjects.ClusterCommand,
1215
1275
async def WriteAttribute (self , nodeid : int ,
1216
1276
attributes : typing .List [typing .Tuple [int , ClusterObjects .ClusterAttributeDescriptor ]],
1217
1277
timedRequestTimeoutMs : typing .Union [None , int ] = None ,
1218
- interactionTimeoutMs : typing .Union [None , int ] = None , busyWaitMs : typing .Union [None , int ] = None ):
1278
+ interactionTimeoutMs : typing .Union [None , int ] = None , busyWaitMs : typing .Union [None , int ] = None ,
1279
+ payloadCapability : int = TransportPayloadCapability .MRP_PAYLOAD ):
1219
1280
'''
1220
1281
Write a list of attributes on a target node.
1221
1282
@@ -1237,7 +1298,7 @@ async def WriteAttribute(self, nodeid: int,
1237
1298
eventLoop = asyncio .get_running_loop ()
1238
1299
future = eventLoop .create_future ()
1239
1300
1240
- device = await self .GetConnectedDevice (nodeid , timeoutMs = interactionTimeoutMs )
1301
+ device = await self .GetConnectedDevice (nodeid , timeoutMs = interactionTimeoutMs , payloadCapability = payloadCapability )
1241
1302
1242
1303
attrs = []
1243
1304
for v in attributes :
@@ -1396,7 +1457,8 @@ async def Read(self, nodeid: int, attributes: typing.List[typing.Union[
1396
1457
]] = None ,
1397
1458
eventNumberFilter : typing .Optional [int ] = None ,
1398
1459
returnClusterObject : bool = False , reportInterval : typing .Tuple [int , int ] = None ,
1399
- fabricFiltered : bool = True , keepSubscriptions : bool = False , autoResubscribe : bool = True ):
1460
+ fabricFiltered : bool = True , keepSubscriptions : bool = False , autoResubscribe : bool = True ,
1461
+ payloadCapability : int = TransportPayloadCapability .MRP_PAYLOAD ):
1400
1462
'''
1401
1463
Read a list of attributes and/or events from a target node
1402
1464
@@ -1456,7 +1518,7 @@ async def Read(self, nodeid: int, attributes: typing.List[typing.Union[
1456
1518
eventLoop = asyncio .get_running_loop ()
1457
1519
future = eventLoop .create_future ()
1458
1520
1459
- device = await self .GetConnectedDevice (nodeid )
1521
+ device = await self .GetConnectedDevice (nodeid , payloadCapability = payloadCapability )
1460
1522
attributePaths = [self ._parseAttributePathTuple (
1461
1523
v ) for v in attributes ] if attributes else None
1462
1524
clusterDataVersionFilters = [self ._parseDataVersionFilterTuple (
@@ -1487,7 +1549,8 @@ async def ReadAttribute(self, nodeid: int, attributes: typing.List[typing.Union[
1487
1549
]], dataVersionFilters : typing .List [typing .Tuple [int , typing .Type [ClusterObjects .Cluster ], int ]] = None ,
1488
1550
returnClusterObject : bool = False ,
1489
1551
reportInterval : typing .Tuple [int , int ] = None ,
1490
- fabricFiltered : bool = True , keepSubscriptions : bool = False , autoResubscribe : bool = True ):
1552
+ fabricFiltered : bool = True , keepSubscriptions : bool = False , autoResubscribe : bool = True ,
1553
+ payloadCapability : int = TransportPayloadCapability .MRP_PAYLOAD ):
1491
1554
'''
1492
1555
Read a list of attributes from a target node, this is a wrapper of DeviceController.Read()
1493
1556
@@ -1547,7 +1610,8 @@ async def ReadAttribute(self, nodeid: int, attributes: typing.List[typing.Union[
1547
1610
reportInterval = reportInterval ,
1548
1611
fabricFiltered = fabricFiltered ,
1549
1612
keepSubscriptions = keepSubscriptions ,
1550
- autoResubscribe = autoResubscribe )
1613
+ autoResubscribe = autoResubscribe ,
1614
+ payloadCapability = payloadCapability )
1551
1615
if isinstance (res , ClusterAttribute .SubscriptionTransaction ):
1552
1616
return res
1553
1617
else :
@@ -1569,7 +1633,8 @@ async def ReadEvent(self, nodeid: int, events: typing.List[typing.Union[
1569
1633
fabricFiltered : bool = True ,
1570
1634
reportInterval : typing .Tuple [int , int ] = None ,
1571
1635
keepSubscriptions : bool = False ,
1572
- autoResubscribe : bool = True ):
1636
+ autoResubscribe : bool = True ,
1637
+ payloadCapability : int = TransportPayloadCapability .MRP_PAYLOAD ):
1573
1638
'''
1574
1639
Read a list of events from a target node, this is a wrapper of DeviceController.Read()
1575
1640
@@ -1616,7 +1681,7 @@ async def ReadEvent(self, nodeid: int, events: typing.List[typing.Union[
1616
1681
'''
1617
1682
res = await self .Read (nodeid = nodeid , events = events , eventNumberFilter = eventNumberFilter ,
1618
1683
fabricFiltered = fabricFiltered , reportInterval = reportInterval , keepSubscriptions = keepSubscriptions ,
1619
- autoResubscribe = autoResubscribe )
1684
+ autoResubscribe = autoResubscribe , payloadCapability = payloadCapability )
1620
1685
if isinstance (res , ClusterAttribute .SubscriptionTransaction ):
1621
1686
return res
1622
1687
else :
@@ -1764,7 +1829,7 @@ def _InitLib(self):
1764
1829
self ._dmLib .pychip_ScriptDevicePairingDelegate_SetExpectingPairingComplete .restype = PyChipError
1765
1830
1766
1831
self ._dmLib .pychip_GetConnectedDeviceByNodeId .argtypes = [
1767
- c_void_p , c_uint64 , py_object , _DeviceAvailableCallbackFunct ]
1832
+ c_void_p , c_uint64 , py_object , _DeviceAvailableCallbackFunct , c_int ]
1768
1833
self ._dmLib .pychip_GetConnectedDeviceByNodeId .restype = PyChipError
1769
1834
1770
1835
self ._dmLib .pychip_FreeOperationalDeviceProxy .argtypes = [
0 commit comments