Skip to content

Commit

Permalink
handle nvram read failure at load_network_info
Browse files Browse the repository at this point in the history
  • Loading branch information
DamKast committed Nov 17, 2023
1 parent f8a6dbd commit 5505497
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
2 changes: 2 additions & 0 deletions zigpy_zboss/nvram.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ async def read(self, nv_id: t.DatasetId, item_type):
DatasetId=nv_id
)
)
if res.StatusCode != 0:
return

if not res.DatasetId == nv_id:
raise
Expand Down
48 changes: 25 additions & 23 deletions zigpy_zboss/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,35 +348,37 @@ async def load_network_info(self, *, load_devices=False):
t_zboss.DatasetId.ZB_IB_COUNTERS,
t_zboss.DSIbCounters
)
self.state.network_info.network_key = zigpy.state.Key(
key=common.nwk_key,
tx_counter=counters.nib_counter,
rx_counter=0,
seq=common.nwk_key_seq,
partner_ieee=self.state.node_info.ieee,
)

if self.state.node_info.logical_type == \
zdo_t.LogicalType.Coordinator:
self.state.network_info.tc_link_key = zigpy.state.Key(
key=common.tc_standard_key,
tx_counter=0,
if common and counters:
self.state.network_info.network_key = zigpy.state.Key(
key=common.nwk_key,
tx_counter=counters.nib_counter,
rx_counter=0,
seq=0,
seq=common.nwk_key_seq,
partner_ieee=self.state.node_info.ieee,
)
else:
res = await self._api.request(
c.NcpConfig.GetTrustCenterAddr.Req(TSN=self.get_sequence()))
self.state.network_info.tc_link_key = (
zigpy.state.Key(
key=None,

if self.state.node_info.logical_type == \
zdo_t.LogicalType.Coordinator:
self.state.network_info.tc_link_key = zigpy.state.Key(
key=common.tc_standard_key,
tx_counter=0,
rx_counter=0,
seq=0,
partner_ieee=res.TCIEEE,
),
)
partner_ieee=self.state.node_info.ieee,
)
else:
res = await self._api.request(
c.NcpConfig.GetTrustCenterAddr.Req(
TSN=self.get_sequence()))
self.state.network_info.tc_link_key = (
zigpy.state.Key(
key=None,
tx_counter=0,
rx_counter=0,
seq=0,
partner_ieee=res.TCIEEE,
),
)

res = await self._api.request(
c.NcpConfig.GetRxOnWhenIdle.Req(TSN=self.get_sequence()))
Expand Down

0 comments on commit 5505497

Please sign in to comment.