Skip to content

Commit 32f15ce

Browse files
committed
simplify get_time valid tst
1 parent 446beca commit 32f15ce

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

adafruit_esp32spi/adafruit_esp32spi.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -766,9 +766,10 @@ 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,):
769+
resp_time = struct.unpack('<i', resp[0])
770+
if resp_time == (0,):
770771
raise ValueError("_GET_TIME returned 0")
771-
return struct.unpack('<i', resp[0])
772+
return resp_time
772773
if self.status in (WL_AP_LISTENING, WL_AP_CONNECTED):
773774
raise RuntimeError("Cannot obtain NTP while in AP mode, must be connected to internet")
774775
raise RuntimeError("Must be connected to WiFi before obtaining NTP.")

0 commit comments

Comments
 (0)