Skip to content

Handle empty Z-Stack build ID in the version response #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -812,6 +812,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