34
34
import ctypes
35
35
import enum
36
36
import json
37
+ import logging
37
38
import threading
38
39
import time
39
40
import typing
@@ -265,9 +266,9 @@ def __init__(self, name: str = ''):
265
266
def _set_dev_ctrl (self , devCtrl ):
266
267
def HandleCommissioningComplete (nodeid , err ):
267
268
if err .is_success :
268
- print ("Commissioning complete" )
269
+ logging . info ("Commissioning complete" )
269
270
else :
270
- print ("Failed to commission: {}" .format (err ))
271
+ logging . warning ("Failed to commission: {}" .format (err ))
271
272
272
273
self .state = DCState .IDLE
273
274
self ._ChipStack .callbackRes = err
@@ -283,30 +284,30 @@ def HandleFabricCheck(nodeId):
283
284
def HandleOpenWindowComplete (nodeid : int , setupPinCode : int , setupManualCode : str ,
284
285
setupQRCode : str , err : PyChipError ) -> None :
285
286
if err .is_success :
286
- print ("Open Commissioning Window complete setting nodeid {} pincode to {}" .format (nodeid , setupPinCode ))
287
+ logging . info ("Open Commissioning Window complete setting nodeid {} pincode to {}" .format (nodeid , setupPinCode ))
287
288
self ._ChipStack .openCommissioningWindowPincode [nodeid ] = CommissioningParameters (
288
289
setupPinCode = setupPinCode , setupManualCode = setupManualCode .decode (), setupQRCode = setupQRCode .decode ())
289
290
else :
290
- print ("Failed to open commissioning window: {}" .format (err ))
291
+ logging . warning ("Failed to open commissioning window: {}" .format (err ))
291
292
292
293
self ._ChipStack .callbackRes = err
293
294
self ._ChipStack .completeEvent .set ()
294
295
295
296
def HandleUnpairDeviceComplete (nodeid : int , err : PyChipError ):
296
297
if err .is_success :
297
- print ("Succesfully unpaired device with nodeid {}" .format (nodeid ))
298
+ logging . info ("Succesfully unpaired device with nodeid {}" .format (nodeid ))
298
299
else :
299
- print ("Failed to unpair device: {}" .format (err ))
300
+ logging . warning ("Failed to unpair device: {}" .format (err ))
300
301
301
302
self ._ChipStack .callbackRes = err
302
303
self ._ChipStack .completeEvent .set ()
303
304
304
305
def HandlePASEEstablishmentComplete (err : PyChipError ):
305
306
if not err .is_success :
306
- print ("Failed to establish secure session to device: {}" .format (err ))
307
+ logging . warning ("Failed to establish secure session to device: {}" .format (err ))
307
308
self ._ChipStack .callbackRes = err .to_exception ()
308
309
else :
309
- print ("Established secure session with Device" )
310
+ logging . info ("Established secure session with Device" )
310
311
311
312
if self .state != DCState .COMMISSIONING :
312
313
# During Commissioning, HandlePASEEstablishmentComplete will also be called,
@@ -785,7 +786,7 @@ def GetConnectedDeviceSync(self, nodeid, allowPASE=True, timeoutMs: int = None):
785
786
res = self ._ChipStack .Call (lambda : self ._dmLib .pychip_GetDeviceBeingCommissioned (
786
787
self .devCtrl , nodeid , byref (returnDevice )), timeoutMs )
787
788
if res .is_success :
788
- print ('Using PASE connection' )
789
+ logging . info ('Using PASE connection' )
789
790
return DeviceProxyWrapper (returnDevice )
790
791
791
792
class DeviceAvailableClosure ():
@@ -1151,7 +1152,7 @@ def _parseEventPathTuple(self, pathTuple: typing.Union[
1151
1152
# Wildcard
1152
1153
pass
1153
1154
elif not isinstance (pathTuple , tuple ):
1154
- print (type (pathTuple ))
1155
+ logging . debug (type (pathTuple ))
1155
1156
if isinstance (pathTuple , int ):
1156
1157
endpoint = pathTuple
1157
1158
elif issubclass (pathTuple , ClusterObjects .Cluster ):
@@ -1426,7 +1427,7 @@ def ZCLSend(self, cluster, command, nodeid, endpoint, groupid, args, blocking=Fa
1426
1427
raise UnknownCommand (cluster , command )
1427
1428
try :
1428
1429
res = asyncio .run (self .SendCommand (nodeid , endpoint , req ))
1429
- print (f"CommandResponse { res } " )
1430
+ logging . debug (f"CommandResponse { res } " )
1430
1431
return (0 , res )
1431
1432
except InteractionModelError as ex :
1432
1433
return (int (ex .status ), None )
0 commit comments