61
61
# Defined in $CHIP_ROOT/src/lib/core/CHIPError.h
62
62
CHIP_ERROR_TIMEOUT : int = 50
63
63
64
+ LOGGER = logging .getLogger (__name__ )
65
+
64
66
_DevicePairingDelegate_OnPairingCompleteFunct = CFUNCTYPE (None , PyChipError )
65
67
_DeviceUnpairingCompleteFunct = CFUNCTYPE (None , c_uint64 , PyChipError )
66
68
_DevicePairingDelegate_OnCommissioningCompleteFunct = CFUNCTYPE (
@@ -401,17 +403,17 @@ def __init__(self, name: str = ''):
401
403
def _set_dev_ctrl (self , devCtrl , pairingDelegate ):
402
404
def HandleCommissioningComplete (nodeId : int , err : PyChipError ):
403
405
if err .is_success :
404
- logging .info ("Commissioning complete" )
406
+ LOGGER .info ("Commissioning complete" )
405
407
else :
406
- logging .warning ("Failed to commission: {}" .format (err ))
408
+ LOGGER .warning ("Failed to commission: {}" .format (err ))
407
409
408
410
self ._dmLib .pychip_DeviceController_SetIcdRegistrationParameters (False , None )
409
411
410
412
if self ._dmLib .pychip_TestCommissionerUsed ():
411
413
err = self ._dmLib .pychip_GetCompletionError ()
412
414
413
415
if self ._commissioning_context .future is None :
414
- logging .exception ("HandleCommissioningComplete called unexpectedly" )
416
+ LOGGER .exception ("HandleCommissioningComplete called unexpectedly" )
415
417
return
416
418
417
419
if err .is_success :
@@ -425,14 +427,14 @@ def HandleFabricCheck(nodeId):
425
427
def HandleOpenWindowComplete (nodeid : int , setupPinCode : int , setupManualCode : str ,
426
428
setupQRCode : str , err : PyChipError ) -> None :
427
429
if err .is_success :
428
- logging .info ("Open Commissioning Window complete setting nodeid {} pincode to {}" .format (nodeid , setupPinCode ))
430
+ LOGGER .info ("Open Commissioning Window complete setting nodeid {} pincode to {}" .format (nodeid , setupPinCode ))
429
431
commissioningParameters = CommissioningParameters (
430
432
setupPinCode = setupPinCode , setupManualCode = setupManualCode .decode (), setupQRCode = setupQRCode .decode ())
431
433
else :
432
- logging .warning ("Failed to open commissioning window: {}" .format (err ))
434
+ LOGGER .warning ("Failed to open commissioning window: {}" .format (err ))
433
435
434
436
if self ._open_window_context .future is None :
435
- logging .exception ("HandleOpenWindowComplete called unexpectedly" )
437
+ LOGGER .exception ("HandleOpenWindowComplete called unexpectedly" )
436
438
return
437
439
438
440
if err .is_success :
@@ -442,12 +444,12 @@ def HandleOpenWindowComplete(nodeid: int, setupPinCode: int, setupManualCode: st
442
444
443
445
def HandleUnpairDeviceComplete (nodeid : int , err : PyChipError ):
444
446
if err .is_success :
445
- logging .info ("Succesfully unpaired device with nodeid {}" .format (nodeid ))
447
+ LOGGER .info ("Succesfully unpaired device with nodeid {}" .format (nodeid ))
446
448
else :
447
- logging .warning ("Failed to unpair device: {}" .format (err ))
449
+ LOGGER .warning ("Failed to unpair device: {}" .format (err ))
448
450
449
451
if self ._unpair_device_context .future is None :
450
- logging .exception ("HandleUnpairDeviceComplete called unexpectedly" )
452
+ LOGGER .exception ("HandleUnpairDeviceComplete called unexpectedly" )
451
453
return
452
454
453
455
if err .is_success :
@@ -457,9 +459,9 @@ def HandleUnpairDeviceComplete(nodeid: int, err: PyChipError):
457
459
458
460
def HandlePASEEstablishmentComplete (err : PyChipError ):
459
461
if not err .is_success :
460
- logging .warning ("Failed to establish secure session to device: {}" .format (err ))
462
+ LOGGER .warning ("Failed to establish secure session to device: {}" .format (err ))
461
463
else :
462
- logging .info ("Established secure session with Device" )
464
+ LOGGER .info ("Established secure session with Device" )
463
465
464
466
if self ._commissioning_context .future is not None :
465
467
# During Commissioning, HandlePASEEstablishmentComplete will also be called.
@@ -469,7 +471,7 @@ def HandlePASEEstablishmentComplete(err: PyChipError):
469
471
return
470
472
471
473
if self ._pase_establishment_context .future is None :
472
- logging .exception ("HandlePASEEstablishmentComplete called unexpectedly" )
474
+ LOGGER .exception ("HandlePASEEstablishmentComplete called unexpectedly" )
473
475
return
474
476
475
477
if err .is_success :
@@ -926,7 +928,7 @@ def GetConnectedDeviceSync(self, nodeid, allowPASE=True, timeoutMs: int = None):
926
928
res = self ._ChipStack .Call (lambda : self ._dmLib .pychip_GetDeviceBeingCommissioned (
927
929
self .devCtrl , nodeid , byref (returnDevice )), timeoutMs )
928
930
if res .is_success :
929
- logging .info ('Using PASE connection' )
931
+ LOGGER .info ('Using PASE connection' )
930
932
return DeviceProxyWrapper (returnDevice , DeviceProxyWrapper .DeviceProxyType .COMMISSIONEE , self ._dmLib )
931
933
932
934
class DeviceAvailableClosure ():
@@ -992,7 +994,7 @@ async def GetConnectedDevice(self, nodeid, allowPASE: bool = True, timeoutMs: in
992
994
res = await self ._ChipStack .CallAsync (lambda : self ._dmLib .pychip_GetDeviceBeingCommissioned (
993
995
self .devCtrl , nodeid , byref (returnDevice )), timeoutMs )
994
996
if res .is_success :
995
- logging .info ('Using PASE connection' )
997
+ LOGGER .info ('Using PASE connection' )
996
998
return DeviceProxyWrapper (returnDevice , DeviceProxyWrapper .DeviceProxyType .COMMISSIONEE , self ._dmLib )
997
999
998
1000
eventLoop = asyncio .get_running_loop ()
@@ -1348,7 +1350,6 @@ def _parseEventPathTuple(self, pathTuple: typing.Union[
1348
1350
# Wildcard
1349
1351
return ClusterAttribute .EventPath ()
1350
1352
elif not isinstance (pathTuple , tuple ):
1351
- logging .debug (type (pathTuple ))
1352
1353
if isinstance (pathTuple , int ):
1353
1354
return ClusterAttribute .EventPath (EndpointId = pathTuple )
1354
1355
elif issubclass (pathTuple , ClusterObjects .Cluster ):
@@ -2115,7 +2116,7 @@ async def CommissionIP(self, ipaddr: str, setupPinCode: int, nodeid: int) -> int
2115
2116
2116
2117
def NOCChainCallback (self , nocChain ):
2117
2118
if self ._issue_node_chain_context .future is None :
2118
- logging .exception ("NOCChainCallback while not expecting a callback" )
2119
+ LOGGER .exception ("NOCChainCallback while not expecting a callback" )
2119
2120
return
2120
2121
self ._issue_node_chain_context .future .set_result (nocChain )
2121
2122
return
0 commit comments