Compare commits
4 Commits
46cb7abbe2
...
cac61f924f
| Author | SHA1 | Date | |
|---|---|---|---|
| cac61f924f | |||
| 9320a3cff2 | |||
| 65efebc5c2 | |||
| 040ae4a731 |
@@ -154,7 +154,7 @@
|
|||||||
<!-- More screens can be added later -->
|
<!-- More screens can be added later -->
|
||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
<button onclick="fetch('/api/v1/reboot/bootloader', {'method': 'POST'});">Reboot to bootloader</button>
|
<button onclick="requestReboot()">Reboot to bootloader</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- CONFIG EDITOR SCREEN -->
|
<!-- CONFIG EDITOR SCREEN -->
|
||||||
@@ -966,6 +966,14 @@
|
|||||||
|
|
||||||
return { init, onShow };
|
return { init, onShow };
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
// Misc
|
||||||
|
async function requestReboot() {
|
||||||
|
const resp = await fetch('/api/v1/reboot/bootloader', {'method': 'POST'});
|
||||||
|
if (!resp.ok) {
|
||||||
|
alert('Reboot to bootloader failed: ' + await resp.text());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Initialization
|
// Initialization
|
||||||
Object.values(Screens).forEach(screen => {
|
Object.values(Screens).forEach(screen => {
|
||||||
|
|||||||
@@ -196,8 +196,5 @@ class PlayerApp:
|
|||||||
def get_playlist_db(self):
|
def get_playlist_db(self):
|
||||||
return self.playlist_db
|
return self.playlist_db
|
||||||
|
|
||||||
def get_timer_manager(self):
|
|
||||||
return self.timer_manager
|
|
||||||
|
|
||||||
def get_leds(self):
|
def get_leds(self):
|
||||||
return self.leds
|
return self.leds
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ Copyright (c) 2024-2025 Stefan Kratochwil <Kratochwil-LA@gmx.de>
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import hwconfig
|
||||||
import json
|
import json
|
||||||
import machine
|
import machine
|
||||||
import os
|
import os
|
||||||
@@ -33,7 +34,7 @@ def start_webserver(config_, app_):
|
|||||||
nfc = app.get_nfc()
|
nfc = app.get_nfc()
|
||||||
playlist_db = app.get_playlist_db()
|
playlist_db = app.get_playlist_db()
|
||||||
leds = app.get_leds()
|
leds = app.get_leds()
|
||||||
timer_manager = app.get_timer_manager()
|
timer_manager = TimerManager()
|
||||||
|
|
||||||
|
|
||||||
@webapp.before_request
|
@webapp.before_request
|
||||||
@@ -257,10 +258,13 @@ async def audiofile_delete(request):
|
|||||||
|
|
||||||
@webapp.route('/api/v1/reboot/<method>', methods=['POST'])
|
@webapp.route('/api/v1/reboot/<method>', methods=['POST'])
|
||||||
async def reboot(request, method):
|
async def reboot(request, method):
|
||||||
|
if hwconfig.get_on_battery():
|
||||||
|
return 'not allowed: usb not connected', 403
|
||||||
|
|
||||||
if method == 'bootloader':
|
if method == 'bootloader':
|
||||||
leds.set_state(LedManager.REBOOTING)
|
leds.set_state(LedManager.REBOOTING)
|
||||||
timer_manager.schedule(time.ticks_ms() + 1500, machine.bootloader)
|
timer_manager.schedule(time.ticks_ms() + 1500, machine.bootloader)
|
||||||
elif method =='application':
|
elif method == 'application':
|
||||||
leds.set_state(LedManager.REBOOTING)
|
leds.set_state(LedManager.REBOOTING)
|
||||||
timer_manager.schedule(time.ticks_ms() + 1500, machine.reset)
|
timer_manager.schedule(time.ticks_ms() + 1500, machine.reset)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user