Skip to content

Commit

Permalink
Implement channel migration (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
puddly committed Apr 21, 2023
1 parent dcb780b commit 3881b09
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,3 +587,11 @@ async def mock_at_command(cmd, *args):
await app.reset_network_info()

app._api._at_command.assert_called_once_with("NR", 0)


async def test_move_network_to_channel(app):
app._api._queued_at = mock.AsyncMock(spec=XBee._at_command)
await app._move_network_to_channel(26, new_nwk_update_id=1)

assert len(app._api._queued_at.mock_calls) == 1
app._api._queued_at.assert_any_call("SC", 1 << (26 - 11))
7 changes: 7 additions & 0 deletions zigpy_xbee/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ async def write_network_info(self, *, network_info, node_info):
)
LOGGER.debug("Association state: %s", association_state)

async def _move_network_to_channel(
self, new_channel: int, new_nwk_update_id: int
) -> None:
"""Moves the coordinator to a new channel."""
scan_bitmask = 1 << (new_channel - 11)
await self._api._queued_at("SC", scan_bitmask)

async def force_remove(self, dev):
"""Forcibly remove device from NCP."""
pass
Expand Down

0 comments on commit 3881b09

Please sign in to comment.