Skip to content

Commit

Permalink
Merge pull request #117 from puddly/puddly/bugfix/handle-empty-zstack…
Browse files Browse the repository at this point in the history
…-build-id

Handle empty Z-Stack build ID in the version response
  • Loading branch information
puddly authored Dec 20, 2021
2 parents 8097701 + 8cdcb74 commit 03ee732
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/application/test_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,31 @@ async def test_auto_form_necessary(device, make_application, mocker):
assert nvram[OsalNvIds.ZDO_DIRECT_CB] == t.Bool(True).serialize()

await app.shutdown()


@pytest.mark.parametrize("device", [FormedZStack1CC2531])
async def test_zstack_build_id_empty(device, make_application, mocker):
app, znp_server = make_application(server_cls=device)

znp_server.reply_once_to(
c.SYS.Version.Req(),
responses=c.SYS.Version.Rsp(
TransportRev=2,
ProductId=0,
MajorRel=2,
MinorRel=6,
MaintRel=3,
# These are missing
CodeRevision=None,
BootloaderBuildType=None,
BootloaderRevision=None,
),
override=True,
)

await app.startup(auto_form=True)

assert app._zstack_build_id is not None
assert app._zstack_build_id == 0x00000000

await app.shutdown()
4 changes: 4 additions & 0 deletions zigpy_znp/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,10 @@ def _zstack_build_id(self) -> t.uint32_t:
Z-Stack build ID, more recently the build date.
"""

# Old versions of Z-Stack do not include `CodeRevision` in the version response
if self._version_rsp.CodeRevision is None:
return 0x00000000

return self._version_rsp.CodeRevision

@property
Expand Down

0 comments on commit 03ee732

Please sign in to comment.