From 5c25a08dc1e05633c00788f88eabd005949a3abe Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Wed, 3 Nov 2021 19:58:40 +0100 Subject: [PATCH] LttPClient: warn when connection is not made to SNI --- LttPClient.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/LttPClient.py b/LttPClient.py index f8ba296c..a1f76df3 100644 --- a/LttPClient.py +++ b/LttPClient.py @@ -15,6 +15,7 @@ import asyncio from json import loads, dumps import ModuleUpdate + ModuleUpdate.update() from Utils import get_item_name_from_id @@ -143,8 +144,8 @@ class Context(CommonContext): }]) def on_deathlink(self, data: dict): - snes_buffered_write(self, WRAM_START+0xF36D, bytes([0])) - snes_buffered_write(self, WRAM_START+0x0373, bytes([8])) + snes_buffered_write(self, WRAM_START + 0xF36D, bytes([0])) + snes_buffered_write(self, WRAM_START + 0x0373, bytes([8])) asyncio.create_task(snes_flush_writes(self)) self.death_state = True snes_logger.info(f"Received DeathLink from {data['source']}") @@ -527,11 +528,22 @@ async def get_snes_devices(ctx: Context): await socket.send(dumps(DeviceList_Request)) reply = loads(await socket.recv()) devices = reply['Results'] if 'Results' in reply and len(reply['Results']) > 0 else None - + await verify_snes_app(socket) await socket.close() return devices +async def verify_snes_app(socket): + AppVersion_Request = { + "Opcode": "AppVersion", + } + await socket.send(dumps(AppVersion_Request)) + + app: str = loads(await socket.recv())["Results"][0] + if not "SNI" in app: + snes_logger.warning(f"Warning: Did not find SNI as the endpoint, instead {app} was found.") + + async def snes_connect(ctx: Context, address, deviceIndex=-1): global SNES_RECONNECT_DELAY if ctx.snes_socket is not None and ctx.snes_state == SNESState.SNES_CONNECTED: