Skip to content

get_time( ) returns (0,) for awhile #72

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

Closed
jerryneedell opened this issue Sep 13, 2019 · 3 comments · Fixed by #73
Closed

get_time( ) returns (0,) for awhile #72

jerryneedell opened this issue Sep 13, 2019 · 3 comments · Fixed by #73

Comments

@jerryneedell
Copy link
Contributor

while investgating this issue
adafruit/Adafruit_CircuitPython_NTP#2

I found that esp.get_time() sometimes returns (0,) after first connectng.
It eventually returns a good value but it can take >15 seconds

using this test code"

import time
import board
import busio
from digitalio import DigitalInOut
from adafruit_esp32spi import adafruit_esp32spi

# If you are using a board with pre-defined ESP32 Pins:
esp32_cs = DigitalInOut(board.ESP_CS)
esp32_ready = DigitalInOut(board.ESP_BUSY)
esp32_reset = DigitalInOut(board.ESP_RESET)


spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)

print("Connecting to AP...")
while not esp.is_connected:
    try:
        esp.connect_AP(b"Needell Airport", b"browndog")
    except RuntimeError as e:
        print("could not connect to AP, retrying: ", e)
        continue

while True:
    print(esp.get_time())
    time.sleep(1)

you can see the problem

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.

Adafruit CircuitPython 5.0.0-alpha.1-2-gfebfc7e4e on 2019-09-02; Adafruit PyPortal with samd51j20
>>> 
>>> import gettime
Connecting to AP...
could not connect to AP, retrying:  ('No such ssid', b'Needell Airport')
(0,)
(0,)
(0,)
(0,)
(0,)
(0,)
(0,)
(0,)
(0,)
(0,)
(0,)
(0,)
(0,)
(0,)
(1568372023,)
(1568372024,)
(1568372025,)
(1568372026,)
(1568372027,)
(1568372028,)
@jerryneedell jerryneedell changed the title get_time( returns (0,) for awhile get_time( ) returns (0,) for awhile Sep 13, 2019
@ladyada
Copy link
Member

ladyada commented Sep 13, 2019

wanna add an exception raise?

@jerryneedell
Copy link
Contributor Author

Sure. Just raise ValueError? Let caller decide whether to retry?

@ladyada
Copy link
Member

ladyada commented Sep 13, 2019

yeppers

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

Successfully merging a pull request may close this issue.

2 participants