-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot.py
37 lines (29 loc) · 982 Bytes
/
boot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
print('\n\033[1;32m' + 'init boot.py' + '\033[0m\n\033[5m...\033[0m')
import config # Import configuration file
import network
import time
import uos
# Connect to WiFi using the configurations from config.py
wifi_ssid = config.wifi_ssid
wifi_password = config.wifi_password
wifi = network.WLAN(network.STA_IF)
wifi.active(True)
wifi.connect(wifi_ssid, wifi_password)
# Wait until connected
while not wifi.isconnected():
time.sleep(1)
print("\033[32mConnected to Wi-Fi:\033[0m", wifi_ssid, wifi.ifconfig())
print("\033[32m")
import webrepl
webrepl.start()
print("WebREPL started\033[0m")
# Check if the counter file exists
if 'counter.txt' not in uos.listdir('/'):
# Counter file doesn't exist, create it and initialize counter to 0
with open('/counter.txt', 'w') as f:
f.write('0')
else:
# Counter file exists, reset counter to 0
with open('/counter.txt', 'w') as f:
f.write('0')
print('\n\033[0;32mInit counter reset:\t\033[0m', '0\n')