Skip to content

Commit 663152f

Browse files
Avoid AttributeError when calling start_wifi() after stop_bluetooth()
`stop_bluetooth()` sets _uart to None, so when calling `start_wifi()`, the call to reset that tries to read self._uart raises a Value Error. Check that _uart is not None
1 parent eb86a71 commit 663152f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

adafruit_airlift/esp32.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,11 @@ def reset(self, mode: int, debug: bool = False) -> None:
136136
return
137137

138138
startup_message = b""
139-
while self._uart.in_waiting: # pylint: disable=no-member
140-
more = self._uart.read()
141-
if more:
142-
startup_message += more
139+
if self._uart is not None:
140+
while self._uart.in_waiting: # pylint: disable=no-member
141+
more = self._uart.read()
142+
if more:
143+
startup_message += more
143144

144145
if not startup_message:
145146
raise RuntimeError("ESP32 did not respond with a startup message")

0 commit comments

Comments
 (0)