Skip to content

Commit 0d382ef

Browse files
authored
Merge pull request #67 from brentru/add-get-time
Expose nina-fw's getTime
2 parents ea860b2 + 2e02cd8 commit 0d382ef

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

adafruit_esp32spi/adafruit_esp32spi.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
_GET_HOST_BY_NAME_CMD = const(0x35)
8383
_START_SCAN_NETWORKS = const(0x36)
8484
_GET_FW_VERSION_CMD = const(0x37)
85+
_GET_TIME = const(0x3B)
8586
_PING_CMD = const(0x3E)
8687

8788
_SEND_DATA_TCP_CMD = const(0x44)
@@ -760,3 +761,10 @@ def set_analog_write(self, pin, analog_value):
760761
((pin,), (value,)))
761762
if resp[0][0] != 1:
762763
raise RuntimeError("Failed to write to pin")
764+
765+
def get_time(self):
766+
"""The current unix timestamp"""
767+
if self.status == 3:
768+
resp = self._send_command_get_response(_GET_TIME)
769+
return struct.unpack('<i', resp[0])
770+
raise RuntimeError("Must be connected to WiFi before obtaining NTP.")

0 commit comments

Comments
 (0)