Skip to content
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

Does not work with adafruit_esp32spi_socket #27

Closed
mattdm opened this issue Oct 9, 2022 · 2 comments
Closed

Does not work with adafruit_esp32spi_socket #27

mattdm opened this issue Oct 9, 2022 · 2 comments

Comments

@mattdm
Copy link

mattdm commented Oct 9, 2022

I found #16, which seems somewhat ironic. I have the Adafruit matrix portal, but I want to actually use the NTP server on my local network rather than the web API the example code seems to lean on. As a simple test, I'm doing

import adafruit_esp32spi.adafruit_esp32spi_socket as socket

[... wifi setup and stuff ... ]


ntp = adafruit_ntp.NTP(socket)

while True:
    print(ntp.datetime)
    time.sleep(1)

Traceback (most recent call last):
  File "code.py", line 62, in <module>
  File "adafruit_ntp.py", line 77, in datetime
AttributeError: 'socket' object has no attribute '__exit__'\

(Line 62, which triggers the error, is the ntp.datetime call.)

@anecdata
Copy link
Member

anecdata commented Oct 9, 2022

Yes, #20 switched it to work with native wifi (CPython-like UDP).

ESP32SPI has esp.get_time(). If there is a connection to the internet, the ESP32 will get the time in the background after (I think) about 15 seconds) and keep it's internal clock up to date. For LAN-only it may not work since the NTP server is probably hard-coded. But you can do an ESP32SPI-compatible UDP NTP implementation from an old version of this library.

@anecdata
Copy link
Member

Closed by #32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants