@@ -510,40 +510,49 @@ async def form_network(self):
510
510
),
511
511
]
512
512
):
513
- if self ._znp .version > 1.2 :
514
- # Z-Stack 3 uses the BDB subsystem
515
- commissioning_rsp = await self ._znp .request_callback_rsp (
516
- request = c .AppConfig .BDBStartCommissioning .Req (
517
- Mode = c .app_config .BDBCommissioningMode .NwkFormation
518
- ),
519
- RspStatus = t .Status .SUCCESS ,
520
- callback = c .AppConfig .BDBCommissioningNotification .Callback (
521
- partial = True ,
522
- RemainingModes = c .app_config .BDBCommissioningMode .NONE ,
523
- ),
524
- timeout = NETWORK_COMMISSIONING_TIMEOUT ,
525
- )
513
+ try :
514
+ if self ._znp .version > 1.2 :
515
+ # Z-Stack 3 uses the BDB subsystem
516
+ commissioning_rsp = await self ._znp .request_callback_rsp (
517
+ request = c .AppConfig .BDBStartCommissioning .Req (
518
+ Mode = c .app_config .BDBCommissioningMode .NwkFormation
519
+ ),
520
+ RspStatus = t .Status .SUCCESS ,
521
+ callback = c .AppConfig .BDBCommissioningNotification .Callback (
522
+ partial = True ,
523
+ RemainingModes = c .app_config .BDBCommissioningMode .NONE ,
524
+ ),
525
+ timeout = NETWORK_COMMISSIONING_TIMEOUT ,
526
+ )
526
527
527
- if (
528
- commissioning_rsp .Status
529
- != c .app_config .BDBCommissioningStatus .Success
530
- ):
531
- raise RuntimeError (f"Network formation failed: { commissioning_rsp } " )
532
- else :
533
- await self ._znp .nvram .osal_write (
534
- OsalNvIds .TCLK_SEED ,
535
- value = DEFAULT_TC_LINK_KEY ,
536
- create = True ,
537
- )
528
+ if (
529
+ commissioning_rsp .Status
530
+ != c .app_config .BDBCommissioningStatus .Success
531
+ ):
532
+ raise RuntimeError (
533
+ f"Network formation failed: { commissioning_rsp } "
534
+ )
535
+ else :
536
+ await self ._znp .nvram .osal_write (
537
+ OsalNvIds .TCLK_SEED ,
538
+ value = DEFAULT_TC_LINK_KEY ,
539
+ create = True ,
540
+ )
538
541
539
- # In Z-Stack 1.2.2, StartupFromApp actually does what it says
540
- await self ._znp .request (
541
- c .ZDO .StartupFromApp .Req (StartDelay = 100 ),
542
- RspState = c .zdo .StartupState .NewNetworkState ,
543
- )
542
+ # In Z-Stack 1.2.2, StartupFromApp actually does what it says
543
+ await self ._znp .request (
544
+ c .ZDO .StartupFromApp .Req (StartDelay = 100 ),
545
+ RspState = c .zdo .StartupState .NewNetworkState ,
546
+ )
544
547
545
- # Both versions still end with this callback
546
- await started_as_coordinator
548
+ # Both versions still end with this callback
549
+ await started_as_coordinator
550
+ except asyncio .TimeoutError as e :
551
+ raise RuntimeError (
552
+ "Network formation refused, RF environment is likely too noisy."
553
+ " Temporarily unscrew the antenna or shield the coordinator"
554
+ " with metal until a network is formed."
555
+ ) from e
547
556
548
557
LOGGER .debug ("Waiting for the NIB to be populated" )
549
558
0 commit comments