From ff52e989a2454b51f3a449a344c3eb3d5b03c1f2 Mon Sep 17 00:00:00 2001 From: Stefan Kratochwil Date: Tue, 4 Mar 2025 19:21:01 +0100 Subject: [PATCH 01/10] Forumlated potentially useful json schema. Note that this is based on an earlier state of the project, and the terms used in this schema may differ from the current state of the project. --- software/src/tonberry.schema.json | 53 +++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 software/src/tonberry.schema.json diff --git a/software/src/tonberry.schema.json b/software/src/tonberry.schema.json new file mode 100644 index 0000000..ca5d77e --- /dev/null +++ b/software/src/tonberry.schema.json @@ -0,0 +1,53 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "definitions": { + "PlaybackPosition": { + "type": "object", + "properties": { + "position_seconds": { "type": "number" }, + "device_uptime": { "type": "number" } + }, + "required": ["position_seconds"] + }, + "AudioFile": { + "type": "object", + "properties": { + "id": { "type": "string", "format": "uuid" }, + "filename": { "type": "string" }, + "size_bytes": { "type": "integer" }, + "duration_seconds": { "type": "number" }, + "last_played_uptime": { "type": "number" }, + "playback_position": { "$ref": "#/definitions/PlaybackPosition" } + }, + "required": ["id", "filename"] + }, + "Playlist": { + "type": "object", + "properties": { + "id": { "type": "string", "format": "uuid" }, + "name": { "type": "string" }, + "audio_files": { + "type": "array", + "items": { "$ref": "#/definitions/AudioFile" } + }, + "current_track_index": { "type": "integer", "minimum": 0 }, + "last_played_uptime": { "type": "number" }, + "playback_position": { "$ref": "#/definitions/PlaybackPosition" } + }, + "required": ["id", "name", "audio_files"] + }, + "NfcTag": { + "type": "object", + "properties": { + "uid": { "type": "string" }, + "name": { "type": "string" }, + "linked_type": { + "type": "string", + "enum": ["audio_file", "playlist"] + }, + "linked_id": { "type": "string", "format": "uuid" } + }, + "required": ["uid", "linked_type", "linked_id"] + } + } +} From 135ad11de92157a5644e671fabfcd87e3d82a54f Mon Sep 17 00:00:00 2001 From: Stefan Kratochwil Date: Tue, 18 Mar 2025 22:03:05 +0100 Subject: [PATCH 02/10] Minimal example for api endpoint --- software/src/microdot_test.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/software/src/microdot_test.py b/software/src/microdot_test.py index a98ff28..87e662b 100644 --- a/software/src/microdot_test.py +++ b/software/src/microdot_test.py @@ -35,4 +35,16 @@ async def index(request): print(f" cookies: {request.cookies}") return "TonberryPico says 'Hello World!'" + +@app.route('/v1/api/playback/control', methods=['POST']) +async def playback_control(request): + if not request.json: + return {'success': False} + + # Example: + # curl -H "Content-Type: application/json" --data '{"action": "play", "target_type": "audio_file", "target_id": "1234"}' http://192.168.4.1/v1/api/playback/control + print(f'Calling {request.json["action"]} on {request.json["target_type"]} with id \ + {request.json["target_id"]}') + + app.run(port=80) From a59f00ad60006c451c3e88eb4cf7ede92f44c5eb Mon Sep 17 00:00:00 2001 From: Stefan Kratochwil Date: Sun, 2 Nov 2025 23:12:15 +0100 Subject: [PATCH 03/10] disabled wifi power management for now --- software/src/main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/software/src/main.py b/software/src/main.py index 673b182..47b9896 100644 --- a/software/src/main.py +++ b/software/src/main.py @@ -40,6 +40,9 @@ def setup_wifi(): wlan.config(ssid=f"TonberryPicoAP_{machine.unique_id().hex()}", security=wlan.SEC_OPEN) wlan.active(True) + # disable power management + wlan.config(pm=network.WLAN.PM_NONE) + DB_PATH = '/sd/tonberry.db' From abb880baca96df3ddae4d3264f09831beac4f7d4 Mon Sep 17 00:00:00 2001 From: Stefan Kratochwil Date: Sun, 2 Nov 2025 23:13:19 +0100 Subject: [PATCH 04/10] print network interface info --- software/src/main.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/software/src/main.py b/software/src/main.py index 47b9896..1d41719 100644 --- a/software/src/main.py +++ b/software/src/main.py @@ -9,6 +9,8 @@ import micropython import network import os import time +from math import pi, sin, pow +import ubinascii # Own modules import app @@ -43,6 +45,13 @@ def setup_wifi(): # disable power management wlan.config(pm=network.WLAN.PM_NONE) + mac = ubinascii.hexlify(network.WLAN().config('mac'), ':').decode() + print(f" mac: {mac}") + print(f" channel: {wlan.config('channel')}") + print(f" essid: {wlan.config('essid')}") + print(f" txpower: {wlan.config('txpower')}") + print(f"ifconfig: {wlan.ifconfig()}") + DB_PATH = '/sd/tonberry.db' From f64bbc27fd1061d66f165349bbb54624a625627f Mon Sep 17 00:00:00 2001 From: Stefan Kratochwil Date: Sun, 2 Nov 2025 23:37:30 +0100 Subject: [PATCH 05/10] basic webserver works --- software/src/main.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/software/src/main.py b/software/src/main.py index 1d41719..864473b 100644 --- a/software/src/main.py +++ b/software/src/main.py @@ -11,6 +11,7 @@ import os import time from math import pi, sin, pow import ubinascii +from microdot import Microdot # Own modules import app @@ -55,6 +56,29 @@ def setup_wifi(): DB_PATH = '/sd/tonberry.db' +webserver = Microdot() + +@webserver.route('/') +async def index(request): + print("wohoo, a guest :)") + print(f" app: {request.app}") + print(f" client: {request.client_addr}") + print(f" method: {request.method}") + print(f" url: {request.url}") + print(f" headers: {request.headers}") + print(f" cookies: {request.cookies}") + return "TonberryPico says 'Hello World!'" + + +@webserver.route('/v1/api/playback/control', methods=['POST']) +async def playback_control(request): + if not request.json: + return {'success': False} + + # Example: + # curl -H "Content-Type: application/json" --data '{"action": "play", "target_type": "audio_file", "target_id": "1234"}' http://192.168.4.1/v1/api/playback/control + print(f'Calling {request.json["action"]} on {request.json["target_type"]} with id \ + {request.json["target_id"]}') def run(): asyncio.new_event_loop() @@ -63,7 +87,9 @@ def run(): # Wifi with default config setup_wifi() - + #webserver.run(port=80) + server = asyncio.create_task(webserver.start_server(port=80)) + # Setup MP3 player with SDContext(mosi=hwconfig.SD_DI, miso=hwconfig.SD_DO, sck=hwconfig.SD_SCK, ss=hwconfig.SD_CS, baudrate=hwconfig.SD_CLOCKRATE): From 340aea6be6b3271bf67bbbb7b5e5881d0727c226 Mon Sep 17 00:00:00 2001 From: Stefan Kratochwil Date: Tue, 4 Nov 2025 20:31:14 +0100 Subject: [PATCH 06/10] Factored out webserver sample into dedicated module --- software/src/main.py | 29 ++------------ .../src/{microdot_test.py => webserver.py} | 39 +++++++------------ 2 files changed, 16 insertions(+), 52 deletions(-) rename software/src/{microdot_test.py => webserver.py} (50%) diff --git a/software/src/main.py b/software/src/main.py index 864473b..976a318 100644 --- a/software/src/main.py +++ b/software/src/main.py @@ -21,6 +21,7 @@ from mp3player import MP3Player from nfc import Nfc from rp2_neopixel import NeoPixel from utils import BTreeFileManager, Buttons, SDContext, TimerManager, LedManager +from webserver import start_webserver try: import hwconfig @@ -56,29 +57,6 @@ def setup_wifi(): DB_PATH = '/sd/tonberry.db' -webserver = Microdot() - -@webserver.route('/') -async def index(request): - print("wohoo, a guest :)") - print(f" app: {request.app}") - print(f" client: {request.client_addr}") - print(f" method: {request.method}") - print(f" url: {request.url}") - print(f" headers: {request.headers}") - print(f" cookies: {request.cookies}") - return "TonberryPico says 'Hello World!'" - - -@webserver.route('/v1/api/playback/control', methods=['POST']) -async def playback_control(request): - if not request.json: - return {'success': False} - - # Example: - # curl -H "Content-Type: application/json" --data '{"action": "play", "target_type": "audio_file", "target_id": "1234"}' http://192.168.4.1/v1/api/playback/control - print(f'Calling {request.json["action"]} on {request.json["target_type"]} with id \ - {request.json["target_id"]}') def run(): asyncio.new_event_loop() @@ -87,9 +65,8 @@ def run(): # Wifi with default config setup_wifi() - #webserver.run(port=80) - server = asyncio.create_task(webserver.start_server(port=80)) - + start_webserver() + # Setup MP3 player with SDContext(mosi=hwconfig.SD_DI, miso=hwconfig.SD_DO, sck=hwconfig.SD_SCK, ss=hwconfig.SD_CS, baudrate=hwconfig.SD_CLOCKRATE): diff --git a/software/src/microdot_test.py b/software/src/webserver.py similarity index 50% rename from software/src/microdot_test.py rename to software/src/webserver.py index 87e662b..63b1a6b 100644 --- a/software/src/microdot_test.py +++ b/software/src/webserver.py @@ -1,30 +1,19 @@ -import rp2 -import network -import ubinascii +''' +SPDX-License-Identifier: MIT +Copyright (c) 2024-2025 Stefan Kratochwil +''' + +import asyncio + from microdot import Microdot -rp2.country('DE') +webapp = Microdot() +server = None -wlan = network.WLAN(network.AP_IF) -wlan.config(ssid='TonberryPico', security=network.WLAN.SEC_OPEN) -# Important: we cannot change the ip in station mode, otherwise dhcp won't work! -# wlan.ipconfig(addr4='10.0.0.1') -wlan.active(True) # loads the firmware -while wlan.active() is False: - pass -wlan.config(pm=network.WLAN.PM_NONE) +def start_webserver(): + server = asyncio.create_task(webapp.start_server(port=80)) -mac = ubinascii.hexlify(network.WLAN().config('mac'), ':').decode() -print(f" mac: {mac}") -print(f" channel: {wlan.config('channel')}") -print(f" essid: {wlan.config('essid')}") -print(f" txpower: {wlan.config('txpower')}") -print(f"ifconfig: {wlan.ifconfig()}") - -app = Microdot() - - -@app.route('/') +@webapp.route('/') async def index(request): print("wohoo, a guest :)") print(f" app: {request.app}") @@ -36,7 +25,7 @@ async def index(request): return "TonberryPico says 'Hello World!'" -@app.route('/v1/api/playback/control', methods=['POST']) +@webapp.route('/v1/api/playback/control', methods=['POST']) async def playback_control(request): if not request.json: return {'success': False} @@ -46,5 +35,3 @@ async def playback_control(request): print(f'Calling {request.json["action"]} on {request.json["target_type"]} with id \ {request.json["target_id"]}') - -app.run(port=80) From ae875950cd17a97b3069bf3b8c154c76c252af67 Mon Sep 17 00:00:00 2001 From: Stefan Kratochwil Date: Tue, 4 Nov 2025 20:32:00 +0100 Subject: [PATCH 07/10] Enabled --update flag for differential flashing --- software/flash.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/flash.sh b/software/flash.sh index 6acd447..459db12 100755 --- a/software/flash.sh +++ b/software/flash.sh @@ -41,7 +41,7 @@ flash_via_picotool() local device="${bus_device[1]//[!0-9]/}" echo "Found RP2 with serial $serial on Bus $bus Device $device" - picotool load --bus "$bus" --address "$device" "$IMAGEFILE" + picotool load --update --bus "$bus" --address "$device" "$IMAGEFILE" } FLASH_VIA_MOUNTPOINT=0 From 99ad8582f0fce00b4e3f9c05b8699f6196091eda Mon Sep 17 00:00:00 2001 From: Stefan Kratochwil Date: Tue, 4 Nov 2025 20:57:07 +0100 Subject: [PATCH 08/10] Defined the two endpoints we need for webapi version 1 --- software/src/webserver.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/software/src/webserver.py b/software/src/webserver.py index 63b1a6b..b7e0d7b 100644 --- a/software/src/webserver.py +++ b/software/src/webserver.py @@ -25,13 +25,14 @@ async def index(request): return "TonberryPico says 'Hello World!'" -@webapp.route('/v1/api/playback/control', methods=['POST']) -async def playback_control(request): - if not request.json: - return {'success': False} +@webapp.route('/api/v1/filesystem', methods=['POST']) +async def filesystem_post(request): + # curl -X POST -d "burp" http://192.168.4.1/api/v1/filesystem + print(request) + return {'success': False} - # Example: - # curl -H "Content-Type: application/json" --data '{"action": "play", "target_type": "audio_file", "target_id": "1234"}' http://192.168.4.1/v1/api/playback/control - print(f'Calling {request.json["action"]} on {request.json["target_type"]} with id \ - {request.json["target_id"]}') +@webapp.route('/api/v1/playlist', methods=['POST']) +async def playlist_post(request): + print(request) + return {'success': False} From cd5515ddadc7b75f0021aded3d4679344acff129 Mon Sep 17 00:00:00 2001 From: Stefan Kratochwil Date: Tue, 11 Nov 2025 22:16:45 +0100 Subject: [PATCH 09/10] feat: new micropython variant with support for microdot --- software/boards/tonberry_unix/manifest.py | 5 + .../boards/tonberry_unix/mpconfigvariant.h | 31 +++++ .../boards/tonberry_unix/mpconfigvariant.mk | 3 + .../tonberry_unix/mpconfigvariant_common.h | 126 ++++++++++++++++++ software/build.sh | 4 + 5 files changed, 169 insertions(+) create mode 100644 software/boards/tonberry_unix/manifest.py create mode 100644 software/boards/tonberry_unix/mpconfigvariant.h create mode 100644 software/boards/tonberry_unix/mpconfigvariant.mk create mode 100644 software/boards/tonberry_unix/mpconfigvariant_common.h diff --git a/software/boards/tonberry_unix/manifest.py b/software/boards/tonberry_unix/manifest.py new file mode 100644 index 0000000..3af83c7 --- /dev/null +++ b/software/boards/tonberry_unix/manifest.py @@ -0,0 +1,5 @@ +include("$(PORT_DIR)/variants/manifest.py") + +include("$(MPY_DIR)/extmod/asyncio") + +module("microdot.py", "../../lib/microdot/src/microdot/") diff --git a/software/boards/tonberry_unix/mpconfigvariant.h b/software/boards/tonberry_unix/mpconfigvariant.h new file mode 100644 index 0000000..edc9991 --- /dev/null +++ b/software/boards/tonberry_unix/mpconfigvariant.h @@ -0,0 +1,31 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Damien P. George + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// Set base feature level. +#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES) + +// Enable extra Unix features. +#include "mpconfigvariant_common.h" diff --git a/software/boards/tonberry_unix/mpconfigvariant.mk b/software/boards/tonberry_unix/mpconfigvariant.mk new file mode 100644 index 0000000..c91db1a --- /dev/null +++ b/software/boards/tonberry_unix/mpconfigvariant.mk @@ -0,0 +1,3 @@ +# This is the default variant when you `make` the Unix port. + +FROZEN_MANIFEST ?= $(VARIANT_DIR)/manifest.py diff --git a/software/boards/tonberry_unix/mpconfigvariant_common.h b/software/boards/tonberry_unix/mpconfigvariant_common.h new file mode 100644 index 0000000..65c8743 --- /dev/null +++ b/software/boards/tonberry_unix/mpconfigvariant_common.h @@ -0,0 +1,126 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2022 Jim Mussared + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +// This file enables and configures features common to all variants +// other than "minimal". + +// Send raise KeyboardInterrupt directly from the signal handler rather than +// scheduling it into the VM. +#define MICROPY_ASYNC_KBD_INTR (!MICROPY_PY_THREAD_GIL) + +// Enable helpers for printing debugging information. +#ifndef MICROPY_DEBUG_PRINTERS +#define MICROPY_DEBUG_PRINTERS (1) +#endif + +// Enable floating point by default. +#ifndef MICROPY_FLOAT_IMPL +#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_DOUBLE) +#endif + +// Don't use native _Float16 because it increases code size by a lot. +#ifndef MICROPY_FLOAT_USE_NATIVE_FLT16 +#define MICROPY_FLOAT_USE_NATIVE_FLT16 (0) +#endif + +// Enable arbitrary precision long-int by default. +#ifndef MICROPY_LONGINT_IMPL +#define MICROPY_LONGINT_IMPL (MICROPY_LONGINT_IMPL_MPZ) +#endif + +// Enable use of C libraries that need read/write/lseek/fsync, e.g. axtls. +#define MICROPY_STREAMS_POSIX_API (1) + +// REPL conveniences. +#define MICROPY_REPL_EMACS_WORDS_MOVE (1) +#define MICROPY_REPL_EMACS_EXTRA_WORDS_MOVE (1) +#define MICROPY_USE_READLINE_HISTORY (1) +#ifndef MICROPY_READLINE_HISTORY_SIZE +#define MICROPY_READLINE_HISTORY_SIZE (50) +#endif + +// Seed random on import. +#define MICROPY_PY_RANDOM_SEED_INIT_FUNC (mp_random_seed_init()) + +// Allow exception details in low-memory conditions. +#define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (1) +#define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (256) + +// Allow loading of .mpy files. +#define MICROPY_PERSISTENT_CODE_LOAD (1) + +// Extra memory debugging. +#define MICROPY_MALLOC_USES_ALLOCATED_SIZE (1) +#define MICROPY_MEM_STATS (1) + +// Enable a small performance boost for the VM. +#define MICROPY_OPT_COMPUTED_GOTO (1) + +// Return number of collected objects from gc.collect(). +#define MICROPY_PY_GC_COLLECT_RETVAL (1) + +// Enable detailed error messages and warnings. +#define MICROPY_ERROR_REPORTING (MICROPY_ERROR_REPORTING_DETAILED) +#define MICROPY_WARNINGS (1) +#define MICROPY_PY_STR_BYTES_CMP_WARN (1) + +// Configure the "sys" module with features not usually enabled on bare-metal. +#define MICROPY_PY_SYS_ATEXIT (1) +#define MICROPY_PY_SYS_EXC_INFO (1) + +// Configure the "os" module with extra unix features. +#define MICROPY_PY_OS_INCLUDEFILE "ports/unix/modos.c" +#define MICROPY_PY_OS_ERRNO (1) +#define MICROPY_PY_OS_GETENV_PUTENV_UNSETENV (1) +#define MICROPY_PY_OS_SYSTEM (1) +#define MICROPY_PY_OS_URANDOM (1) + +// Enable the unix-specific "time" module. +#define MICROPY_PY_TIME (1) +#define MICROPY_PY_TIME_TIME_TIME_NS (1) +#define MICROPY_PY_TIME_CUSTOM_SLEEP (1) +#define MICROPY_PY_TIME_INCLUDEFILE "ports/unix/modtime.c" + +#if MICROPY_PY_SSL +#define MICROPY_PY_HASHLIB_MD5 (1) +#define MICROPY_PY_HASHLIB_SHA1 (1) +#define MICROPY_PY_CRYPTOLIB (1) +#endif + +// The "select" module is enabled by default, but disable select.select(). +#define MICROPY_PY_SELECT_POSIX_OPTIMISATIONS (1) +#define MICROPY_PY_SELECT_SELECT (0) + +// Enable the "websocket" module. +#define MICROPY_PY_WEBSOCKET (1) + +// Enable the "machine" module, mostly for machine.mem*. +#define MICROPY_PY_MACHINE (1) +#define MICROPY_PY_MACHINE_PULSE (1) +#define MICROPY_PY_MACHINE_PIN_BASE (1) + +#define MICROPY_VFS_ROM (1) +#define MICROPY_VFS_ROM_IOCTL (0) diff --git a/software/build.sh b/software/build.sh index 883173e..b373a8e 100755 --- a/software/build.sh +++ b/software/build.sh @@ -9,6 +9,10 @@ set -eu make -C ports/rp2 BOARD=TONBERRY_RPI_PICO_W BOARD_DIR="$TOPDIR"/boards/RPI_PICO_W clean make -C ports/rp2 BOARD=TONBERRY_RPI_PICO_W BOARD_DIR="$TOPDIR"/boards/RPI_PICO_W \ USER_C_MODULES="$TOPDIR"/modules/micropython.cmake -j "$(nproc)" + + # build tonberry specific unix port of micropython + make -C ports/unix VARIANT_DIR="$TOPDIR"/boards/tonberry_unix clean + make -C ports/unix VARIANT_DIR="$TOPDIR"/boards/tonberry_unix -j "$(nproc)" ) ( cd tools/mklittlefs From e07ee4651849fa203e5f21b68397859cee9b6dbc Mon Sep 17 00:00:00 2001 From: Matthias Blankertz Date: Fri, 28 Nov 2025 17:48:39 +0100 Subject: [PATCH 10/10] style: Fix flake8 complaints Remove unused imports in main.py Add missing "global" in webserver and fix spacing. Signed-off-by: Matthias Blankertz --- software/src/main.py | 2 -- software/src/webserver.py | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/software/src/main.py b/software/src/main.py index 976a318..813b036 100644 --- a/software/src/main.py +++ b/software/src/main.py @@ -9,9 +9,7 @@ import micropython import network import os import time -from math import pi, sin, pow import ubinascii -from microdot import Microdot # Own modules import app diff --git a/software/src/webserver.py b/software/src/webserver.py index b7e0d7b..eeb2a95 100644 --- a/software/src/webserver.py +++ b/software/src/webserver.py @@ -10,9 +10,12 @@ from microdot import Microdot webapp = Microdot() server = None + def start_webserver(): + global server server = asyncio.create_task(webapp.start_server(port=80)) + @webapp.route('/') async def index(request): print("wohoo, a guest :)")