@@ -93,35 +93,28 @@ async def detect_zstack_version(self) -> float:
93
93
except CommandNotRecognized :
94
94
return 3.0
95
95
96
- async def load_network_info (self , * , load_devices = False ):
96
+ async def _load_network_info (self , * , load_devices = False ):
97
97
"""
98
98
Loads low-level network information from NVRAM.
99
99
Loading key data greatly increases the runtime so it not enabled by default.
100
100
"""
101
101
102
102
from zigpy_znp .znp import security
103
103
104
- is_on_network = None
105
- nib = None
106
-
107
- try :
108
- nib = await self .nvram .osal_read (OsalNvIds .NIB , item_type = t .NIB )
109
- except KeyError :
110
- is_on_network = False
111
- else :
112
- is_on_network = nib .nwkLogicalChannel != 0 and nib .nwkKeyLoaded
104
+ nib = await self .nvram .osal_read (OsalNvIds .NIB , item_type = t .NIB )
113
105
114
- if is_on_network and self .version >= 3.0 :
115
- # This NVRAM item is the very first thing initialized in `zgInit`
116
- is_on_network = (
117
- await self .nvram .osal_read (
118
- OsalNvIds .BDBNODEISONANETWORK , item_type = t .uint8_t
119
- )
120
- == 1
121
- )
106
+ if nib .nwkLogicalChannel == 0 or not nib .nwkKeyLoaded :
107
+ raise NetworkNotFormed ()
122
108
123
- if not is_on_network :
124
- raise NetworkNotFormed ("Device is not a part of a network" )
109
+ # This NVRAM item is the very first thing initialized in `zgInit`
110
+ if (
111
+ self .version >= 3.0
112
+ and await self .nvram .osal_read (
113
+ OsalNvIds .BDBNODEISONANETWORK , item_type = t .uint8_t
114
+ )
115
+ != 1
116
+ ):
117
+ raise NetworkNotFormed ()
125
118
126
119
ieee = await self .nvram .osal_read (OsalNvIds .EXTADDR , item_type = t .EUI64 )
127
120
logical_type = await self .nvram .osal_read (
@@ -225,6 +218,17 @@ async def load_network_info(self, *, load_devices=False):
225
218
self .network_info = network_info
226
219
self .node_info = node_info
227
220
221
+ async def load_network_info (self , * , load_devices = False ):
222
+ """
223
+ Loads low-level network information from NVRAM.
224
+ Loading key data greatly increases the runtime so it not enabled by default.
225
+ """
226
+
227
+ try :
228
+ await self ._load_network_info ()
229
+ except KeyError as e :
230
+ raise NetworkNotFormed () from e
231
+
228
232
async def start_network (self ):
229
233
# Both startup sequences end with the same callback
230
234
started_as_coordinator = self .wait_for_response (
0 commit comments