Skip to content

Commit

Permalink
Disable skip_bootloader when the config is set to False (#249)
Browse files Browse the repository at this point in the history
* Skip bootloader when the config is set to skip

On SMLIGHT SLZB-06 devices in USB mode the skip bootloader sequence
causes the esp32 in these devices to reset.

While there is a config option to disable skip bootloader, it is not
hooked up.

Ensure that it is possible to disable skip bootloader.

* Add test for config to disable skip bootloader
  • Loading branch information
tl-sl authored Jul 10, 2024
1 parent 92eef38 commit 3e54421
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
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

0 comments on commit 3e54421

Please sign in to comment.