Skip to content

Commit 3881b09

Browse files
authored
Implement channel migration (#139)
1 parent dcb780b commit 3881b09

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

tests/test_application.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,3 +587,11 @@ async def mock_at_command(cmd, *args):
587587
await app.reset_network_info()
588588

589589
app._api._at_command.assert_called_once_with("NR", 0)
590+
591+
592+
async def test_move_network_to_channel(app):
593+
app._api._queued_at = mock.AsyncMock(spec=XBee._at_command)
594+
await app._move_network_to_channel(26, new_nwk_update_id=1)
595+
596+
assert len(app._api._queued_at.mock_calls) == 1
597+
app._api._queued_at.assert_any_call("SC", 1 << (26 - 11))

zigpy_xbee/zigbee/application.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,13 @@ async def write_network_info(self, *, network_info, node_info):
161161
)
162162
LOGGER.debug("Association state: %s", association_state)
163163

164+
async def _move_network_to_channel(
165+
self, new_channel: int, new_nwk_update_id: int
166+
) -> None:
167+
"""Moves the coordinator to a new channel."""
168+
scan_bitmask = 1 << (new_channel - 11)
169+
await self._api._queued_at("SC", scan_bitmask)
170+
164171
async def force_remove(self, dev):
165172
"""Forcibly remove device from NCP."""
166173
pass

0 commit comments

Comments
 (0)