From 0c1d0d449af201ed47d4831967cb7f5458259226 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stanis=C5=82aw?= Date: Wed, 9 May 2018 14:37:22 +0200 Subject: [PATCH] sending version info on connection --- assets/python/server/sockets.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/assets/python/server/sockets.py b/assets/python/server/sockets.py index 9a2afe5..0b7eb1f 100644 --- a/assets/python/server/sockets.py +++ b/assets/python/server/sockets.py @@ -5,17 +5,24 @@ from log import logname import frame from hardware import Hardware +from version import version_info logger = logname("sockets") sio = socketio.AsyncServer(async_mode='aiohttp') app = web.Application() sio.attach(app) + hardware = Hardware() @sio.on('connect') async def connect(sid, environ): logger.info("connected %s", sid) + await sio.emit('response', { + 'ws_server_ver' : version_info, + 'firmware_ver' : '0.0.0', + 'wifi_dongle' : 'Unavailable' + }) @sio.on('motors') @@ -47,3 +54,8 @@ async def signal(sid): async def signal(sid): temperature = hardware.getTemperature() await sio.emit('temperature', temperature) + +# TODO: symlink this +@sio.on('update') +async def signal(sid): + subprocess.Popen(['python3', 'updater.py'])