-
Notifications
You must be signed in to change notification settings - Fork 10
/
boot.py
31 lines (26 loc) · 818 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
import machine
import pycom
import persistence
from network import Bluetooth, WLAN
from machine import WDT
from helpers import *
bluetooth = Bluetooth()
bluetooth.deinit()
wlan = WLAN(mode=WLAN.STA)
wlan.deinit()
########################################
## Handle wake by button to enter debug mode
########################################
if machine.wake_reason()[0] is machine.PIN_WAKE:
print('PIN WAKE')
connect_to_WLAN()
else:
watchdog_timer = None
if machine.reset_cause() not in [machine.DEEPSLEEP_RESET, machine.SOFT_RESET, machine.WDT_RESET]:
print('hard reset, erasing NVS')
pycom.nvs_erase_all()
persistence.cleanup()
else:
print('soft/deepsleep reset, enabling watchdog timer')
watchdog_timer = WDT(timeout=30000)
machine.main('main.py')