@@ -393,15 +393,7 @@ def connection_lost(self, exc):
393
393
394
394
return super ().connection_lost (exc )
395
395
396
- def _startup (self ):
397
- startup_option = self .nvram_deserialize (
398
- self ._nvram [ExNvIds .LEGACY ].get (OsalNvIds .STARTUP_OPTION , b"\x00 " ),
399
- t .StartupOptions ,
400
- )
401
-
402
- if not startup_option & t .StartupOptions .ClearState :
403
- return
404
-
396
+ def _create_network_nvram (self ):
405
397
self .nib = self ._default_nib ()
406
398
407
399
empty_key = t .NwkActiveKeyItems (
@@ -663,10 +655,7 @@ def nib(self, nib):
663
655
self ._nvram [ExNvIds .LEGACY ][OsalNvIds .NIB ] = self .nvram_serialize (nib )
664
656
665
657
@reply_to (c .SYS .ResetReq .Req (Type = t .ResetType .Soft ))
666
- def reset_req (self , request , * , startup = True ):
667
- if startup :
668
- self ._startup ()
669
-
658
+ def reset_req (self , request ):
670
659
version = self .version_replier (None )
671
660
672
661
return c .SYS .ResetInd .Callback (
@@ -787,6 +776,8 @@ def startup_from_app(self, req):
787
776
self .update_device_state (t .DeviceState .StartedAsCoordinator ),
788
777
]
789
778
else :
779
+ self ._create_network_nvram ()
780
+
790
781
return [
791
782
c .ZDO .StartupFromApp .Rsp (State = c .zdo .StartupState .NewNetworkState ),
792
783
self .update_device_state (t .DeviceState .StartingAsCoordinator ),
@@ -913,6 +904,8 @@ def handle_bdb_start_commissioning(self, request):
913
904
),
914
905
]
915
906
else :
907
+ self ._create_network_nvram ()
908
+
916
909
return [
917
910
c .AppConfig .BDBStartCommissioning .Rsp (Status = t .Status .SUCCESS ),
918
911
self .update_device_state (t .DeviceState .StartingAsCoordinator ),
@@ -956,9 +949,7 @@ def connection_made(self):
956
949
self ._first_connection = False
957
950
958
951
# Z-Stack 3 devices send a callback when they're first used
959
- asyncio .get_running_loop ().call_soon (
960
- self .send , self .reset_req (None , startup = False )
961
- )
952
+ asyncio .get_running_loop ().call_soon (self .send , self .reset_req (None ))
962
953
963
954
964
955
class BaseLaunchpadCC26X2R1 (BaseZStack3Device ):
@@ -1114,6 +1105,21 @@ def version_replier(self, request):
1114
1105
def led_responder (self , req ):
1115
1106
return req .Rsp (Status = t .Status .SUCCESS )
1116
1107
1108
+ @reply_to (
1109
+ c .AppConfig .BDBStartCommissioning .Req (
1110
+ Mode = c .app_config .BDBCommissioningMode .NwkFormation
1111
+ )
1112
+ )
1113
+ def handle_bdb_start_commissioning (self , request ):
1114
+ result = super ().handle_bdb_start_commissioning (request )
1115
+
1116
+ # This item is only created after a network is formed
1117
+ self ._nvram [ExNvIds .LEGACY ][OsalNvIds .ADDRMGR ] = 124 * self .nvram_serialize (
1118
+ t .EMPTY_ADDR_MGR_ENTRY
1119
+ )
1120
+
1121
+ return result
1122
+
1117
1123
1118
1124
class FormedLaunchpadCC26X2R1 (BaseLaunchpadCC26X2R1 ):
1119
1125
def __init__ (self , * args , ** kwargs ):
0 commit comments