-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
46 lines (28 loc) · 999 Bytes
/
main.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
38
39
40
41
42
43
44
45
46
# main.py
from machine import DEEPSLEEP_RESET, reset_cause
from include.secrets import _ssid, _pass
from src.ota_updater import OTAUpdater
from src.garuda import Garuda
### TODO: read these from a config file
GITHUB_REPO = 'https://github.com/desmith/Sudhama_esp32_mpy'
ota = OTAUpdater(GITHUB_REPO)
VERSION = ota.get_version(directory='src', version_file_name='.version')
f = open('board.py')
BOARD = f.readline().rstrip('\n')
f.close()
def download_and_install_update_if_available():
print('checking for updates...')
ota.download_and_install_update_if_available(_ssid, _pass)
def start():
print('Hare Krishna')
carrier = Garuda(board=BOARD, version=VERSION)
carrier.arise()
def boot():
# check if the device woke from a deep sleep
# (A software reset does not change the reset cause)
if reset_cause() == DEEPSLEEP_RESET:
print('woke from a deep sleep')
download_and_install_update_if_available()
while True:
start()
boot()