Skip to content

Commit 0fb0506

Browse files
committed
TCLK cannot be read on Z-Stack Home 1.2, only written
1 parent 069abd0 commit 0fb0506

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

zigpy_znp/api.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,24 +147,19 @@ async def load_network_info(self, *, load_devices=False):
147147
partner_ieee=node_info.ieee,
148148
),
149149
tc_link_key=zigpy.state.Key(
150-
key=None,
150+
key=const.DEFAULT_TC_LINK_KEY,
151151
seq=0,
152152
tx_counter=0,
153153
rx_counter=0,
154-
partner_ieee=None,
154+
partner_ieee=t.EUI64.convert("FF:FF:FF:FF:FF:FF:FF:FF"),
155155
),
156156
children=[],
157157
nwk_addresses={},
158158
key_table=[],
159-
stack_specific=None,
159+
stack_specific={},
160160
)
161161

162-
if self.version == 1.2:
163-
tc_link_key = await self.nvram.osal_read(
164-
OsalNvIds.TCLK_SEED, item_type=t.TCLinkKey
165-
)
166-
network_info.tc_link_key.key = tc_link_key.key
167-
else:
162+
if self.version > 1.2:
168163
tclk_seed = await self.nvram.osal_read(
169164
OsalNvIds.TCLK_SEED, item_type=t.KeyData
170165
)
@@ -374,12 +369,15 @@ async def write_network_info(
374369
# TCLK_SEED is TCLK_TABLE_START in Z-Stack 1
375370
nvram[OsalNvIds.TCLK_SEED] = t.TCLinkKey(
376371
ExtAddr=t.EUI64.convert("FF:FF:FF:FF:FF:FF:FF:FF"), # global
377-
Key=network_info.tc_link_key.key,
372+
Key=network_info.tc_link_key.key or const.DEFAULT_TC_LINK_KEY,
378373
TxFrameCounter=0,
379374
RxFrameCounter=0,
380375
)
381376
else:
382-
if network_info.tc_link_key.key != const.DEFAULT_TC_LINK_KEY:
377+
if (
378+
network_info.tc_link_key is not None
379+
and network_info.tc_link_key.key != const.DEFAULT_TC_LINK_KEY
380+
):
383381
LOGGER.warning(
384382
"TC link key is configured at build time in Z-Stack 3 and cannot be"
385383
" changed at runtime: %s",

zigpy_znp/tools/network_restore.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import zigpy.state
88
import zigpy.zdo.types as zdo_t
99

10+
import zigpy_znp.const as const
1011
import zigpy_znp.types as t
1112
from zigpy_znp.api import ZNP
1213
from zigpy_znp.tools.common import ClosableFileType, setup_parser, validate_backup_json
@@ -38,7 +39,7 @@ def json_backup_to_zigpy_state(
3839
network_info.channel_mask = t.Channels.from_channel_list(backup["channel_mask"])
3940
network_info.security_level = backup["security_level"]
4041
network_info.stack_specific = backup.get("stack_specific")
41-
network_info.tc_link_key = None
42+
network_info.tc_link_key.key = const.DEFAULT_TC_LINK_KEY
4243

4344
network_info.network_key = zigpy.state.Key()
4445
network_info.network_key.key, _ = t.KeyData.deserialize(

0 commit comments

Comments
 (0)