Skip to content

Commit e3dc655

Browse files
committed
fixed error caused by missing secrets.py
1 parent af46e03 commit e3dc655

File tree

1 file changed

+13
-8
lines changed
  • micropython/examples/cosmic_unicorn/launch

1 file changed

+13
-8
lines changed

micropython/examples/cosmic_unicorn/launch/today.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@
2424

2525
DAYS = ["Mon", "Tue", "Wed", "Thur", "Fri", "Sat", "Sun"]
2626

27+
# Enable the Wireless
28+
wlan = network.WLAN(network.STA_IF)
29+
wlan.active(True)
30+
2731

2832
def network_connect(SSID, PSK):
29-
# Enable the Wireless
30-
wlan = network.WLAN(network.STA_IF)
31-
wlan.active(True)
3233

3334
# Number of attempts to make before timeout
3435
max_wait = 5
@@ -52,12 +53,16 @@ def network_connect(SSID, PSK):
5253
# Function to sync the Pico RTC using NTP
5354
def sync_time():
5455

55-
network_connect(WIFI_SSID, WIFI_PASSWORD)
56-
5756
try:
58-
ntptime.settime()
59-
except OSError:
60-
print("Unable to sync with NTP server. Check network and try again.")
57+
network_connect(WIFI_SSID, WIFI_PASSWORD)
58+
except NameError:
59+
print("Create secrets.py with your WiFi credentials")
60+
61+
if wlan.status() < 0 or wlan.status() >= 3:
62+
try:
63+
ntptime.settime()
64+
except OSError:
65+
print("Unable to sync with NTP server. Check network and try again.")
6166

6267

6368
def init():

0 commit comments

Comments
 (0)