Skip to content

Expose nina-fw's getTime #67

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 1 commit into from
Aug 22, 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
8 changes: 8 additions & 0 deletions adafruit_esp32spi/adafruit_esp32spi.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
_GET_HOST_BY_NAME_CMD = const(0x35)
_START_SCAN_NETWORKS = const(0x36)
_GET_FW_VERSION_CMD = const(0x37)
_GET_TIME = const(0x3B)
_PING_CMD = const(0x3E)

_SEND_DATA_TCP_CMD = const(0x44)
Expand Down Expand Up @@ -760,3 +761,10 @@ def set_analog_write(self, pin, analog_value):
((pin,), (value,)))
if resp[0][0] != 1:
raise RuntimeError("Failed to write to pin")

def get_time(self):
"""The current unix timestamp"""
if self.status == 3:
resp = self._send_command_get_response(_GET_TIME)
return struct.unpack('<i', resp[0])
raise RuntimeError("Must be connected to WiFi before obtaining NTP.")