feat: last connected tag uid available at /api/v1/last_tag_uid
Some checks failed
Build RPi Pico firmware image / Build-Firmware (push) Has been cancelled
Check code formatting / Check-C-Format (push) Has been cancelled
Check code formatting / Check-Python-Flake8 (push) Has been cancelled
Check code formatting / Check-Bash-Shellcheck (push) Has been cancelled
Run unit tests on host / Run-Unit-Tests (push) Has been cancelled
Run pytests / Check-Pytest (push) Has been cancelled

This commit is contained in:
2025-12-16 22:40:13 +01:00
parent 19dff763bd
commit 07acc2777c
2 changed files with 13 additions and 1 deletions

View File

@@ -63,6 +63,7 @@ class PlayerApp:
self._onIdle()
def __del__(self):
print("app __del__")
if self.mp3file is not None:
self.mp3file.close()
self.mp3file = None
@@ -190,3 +191,6 @@ class PlayerApp:
self.timer_manager.cancel(self.onIdleTimeout)
self.leds.set_state(self.leds.PLAYING)
self.playing = True
def get_nfc(self):
return self.nfc

View File

@@ -11,13 +11,15 @@ webapp = Microdot()
server = None
config = None
app = None
nfc = None
def start_webserver(config_, app_):
global server, config, app
global server, config, app, nfc
server = asyncio.create_task(webapp.start_server(port=80))
config = config_
app = app_
nfc = app.get_nfc()
@webapp.before_request
@@ -64,3 +66,9 @@ async def config_put(request):
except ValueError as ex:
return str(ex), 400
return '', 204
@webapp.route('/api/v1/last_tag_uid', methods=['GET'])
async def last_tag_uid_get(request):
tag, _ = nfc.get_last_uid()
return "No tag present" if tag is None else tag