Skip to content

Commit

Permalink
Correctly handle TX power status codes > 128
Browse files Browse the repository at this point in the history
  • Loading branch information
puddly committed Feb 10, 2022
1 parent ae74701 commit 06294f9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
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

0 comments on commit 06294f9

Please sign in to comment.