Skip to content

Commit 02ded47

Browse files
committed
raise AP specific error when trying to get_time while in AP mode
1 parent 0d382ef commit 02ded47

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

adafruit_esp32spi/adafruit_esp32spi.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,9 @@ def set_analog_write(self, pin, analog_value):
764764

765765
def get_time(self):
766766
"""The current unix timestamp"""
767-
if self.status == 3:
767+
if self.status == WL_CONNECTED:
768768
resp = self._send_command_get_response(_GET_TIME)
769769
return struct.unpack('<i', resp[0])
770+
if self.status in (WL_AP_LISTENING, WL_AP_CONNECTED):
771+
raise RuntimeError("Cannot obtain NTP while in AP mode, must be connected to internet")
770772
raise RuntimeError("Must be connected to WiFi before obtaining NTP.")

0 commit comments

Comments
 (0)