feat: allow reboot commands only if usb cable is inserted
Some checks failed
Build RPi Pico firmware image / Build-Firmware (push) Successful in 4m41s
Check code formatting / Check-C-Format (push) Successful in 7s
Check code formatting / Check-Python-Flake8 (push) Failing after 10s
Check code formatting / Check-Bash-Shellcheck (push) Successful in 5s
Run unit tests on host / Run-Unit-Tests (push) Successful in 8s
Run pytests / Check-Pytest (push) Successful in 11s
Some checks failed
Build RPi Pico firmware image / Build-Firmware (push) Successful in 4m41s
Check code formatting / Check-C-Format (push) Successful in 7s
Check code formatting / Check-Python-Flake8 (push) Failing after 10s
Check code formatting / Check-Bash-Shellcheck (push) Successful in 5s
Run unit tests on host / Run-Unit-Tests (push) Successful in 8s
Run pytests / Check-Pytest (push) Successful in 11s
This commit is contained in:
@@ -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
|
||||||
@@ -257,6 +258,9 @@ 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: no vbus', 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)
|
||||||
|
|||||||
Reference in New Issue
Block a user