Skip to content

Correctly handle TX power status codes > 128 #136

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
Feb 10, 2022
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
4 changes: 3 additions & 1 deletion tests/application/test_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,9 @@ async def test_tx_power(device, succeed, make_application):
set_tx_power = znp_server.reply_once_to(
request=c.SYS.SetTxPower.Req(TXPower=19),
responses=[
c.SYS.SetTxPower.Rsp(StatusOrPower=t.Status.INVALID_PARAMETER)
c.SYS.SetTxPower.Rsp(
StatusOrPower=t.Status.MAC_INVALID_PARAMETER - 0xFF - 1
)
],
)
else:
Expand Down
2 changes: 1 addition & 1 deletion zigpy_znp/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ async def set_tx_power(self, dbm: int) -> None:
if self._znp.version >= 3.30 and rsp.StatusOrPower != t.Status.SUCCESS:
# Z-Stack 3's response indicates success or failure
raise InvalidCommandResponse(
f"Failed to set TX power: {t.Status(rsp.StatusOrPower)!r}", rsp
f"Failed to set TX power: {t.Status(rsp.StatusOrPower & 0xFF)!r}", rsp
)
elif self._znp.version < 3.30 and rsp.StatusOrPower != dbm:
# Old Z-Stack releases used the response status field to indicate the power
Expand Down