Skip to content

Disable skip_bootloader when the config is set to False #249

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 2 commits into from
Jul 10, 2024
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
21 changes: 21 additions & 0 deletions tests/api/test_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,27 @@ async def test_connect_skip_bootloader_rts_dtr_pins(make_znp_server, mocker):
znp.close()


async def test_connect_skip_bootloader_config(make_znp_server, mocker):
znp_server = make_znp_server(server_cls=BaseServerZNP)
znp = ZNP(config_for_port_path(znp_server.port_path))
znp._znp_config["skip_bootloader"] = False

mocker.patch.object(znp.nvram, "determine_alignment", new=CoroutineMock())
mocker.patch.object(znp, "detect_zstack_version", new=CoroutineMock())

znp_server.reply_to(
c.SYS.Ping.Req(), responses=[c.SYS.Ping.Rsp(Capabilities=t.MTCapabilities.SYS)]
)

await znp.connect(test_port=True)

serial = znp._uart._transport
assert serial._mock_dtr_prop.called is False
assert serial._mock_rts_prop.called is False

znp.close()


async def test_api_close(connected_znp, mocker):
znp, znp_server = connected_znp
uart = znp._uart
Expand Down
7 changes: 6 additions & 1 deletion zigpy_znp/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,12 @@ async def connect(self, *, test_port=True) -> None:
# prevent any data from being sent
if test_port:
# The reset indication callback is sent when some sticks start up
self.capabilities = (await self._skip_bootloader()).Capabilities
if self._znp_config[conf.CONF_SKIP_BOOTLOADER]:
self.capabilities = (await self._skip_bootloader()).Capabilities
else:
self.capabilities = (
await self.request(c.SYS.Ping.Req())
).Capabilities

# We need to know how structs are packed to deserialize frames correctly
await self.nvram.determine_alignment()
Expand Down
Loading