Skip to content

Commit 446beca

Browse files
committed
raise error in get_time if zero returned
1 parent c28977f commit 446beca

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

adafruit_esp32spi/adafruit_esp32spi.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,8 @@ def get_time(self):
766766
"""The current unix timestamp"""
767767
if self.status == WL_CONNECTED:
768768
resp = self._send_command_get_response(_GET_TIME)
769+
if struct.unpack('<i', resp[0]) == (0,):
770+
raise ValueError("_GET_TIME returned 0")
769771
return struct.unpack('<i', resp[0])
770772
if self.status in (WL_AP_LISTENING, WL_AP_CONNECTED):
771773
raise RuntimeError("Cannot obtain NTP while in AP mode, must be connected to internet")

0 commit comments

Comments
 (0)