Skip to content

raise error in get_time if zero returned #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 15, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion adafruit_esp32spi/adafruit_esp32spi.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,10 @@ def get_time(self):
"""The current unix timestamp"""
if self.status == WL_CONNECTED:
resp = self._send_command_get_response(_GET_TIME)
return struct.unpack('<i', resp[0])
resp_time = struct.unpack('<i', resp[0])
if resp_time == (0,):
raise ValueError("_GET_TIME returned 0")
return resp_time
if self.status in (WL_AP_LISTENING, WL_AP_CONNECTED):
raise RuntimeError("Cannot obtain NTP while in AP mode, must be connected to internet")
raise RuntimeError("Must be connected to WiFi before obtaining NTP.")