forked from doniks/pycom-examples
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsafeboot-toggle.py
More file actions
29 lines (23 loc) · 803 Bytes
/
safeboot-toggle.py
File metadata and controls
29 lines (23 loc) · 803 Bytes
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
import pycom
def toggle_safeboot_on():
safeboot = pycom.bootmgr()[2]
if safeboot == "SafeBoot: False":
print("Switching to safeboot mode")
pycom.bootmgr(safeboot=True, reset=True)
elif safeboot == "SafeBoot: True":
print("Already in safeboot mode")
def toggle_safeboot_off():
safeboot = pycom.bootmgr()[2]
if safeboot == "SafeBoot: False":
print("Already in normal mode")
elif safeboot == "SafeBoot: True":
print("Switching to normal mode")
pycom.bootmgr(safeboot=False, reset=True)
def toggle_safeboot():
safeboot = pycom.bootmgr()[2]
if safeboot == "SafeBoot: False":
toggle_safeboot_on()
elif safeboot == "SafeBoot: True":
toggle_safeboot_off()
if __name__ == "__main__":
toggle_safeboot()