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