From 238256f12dc65d256c2f224f8767d8909966c5de Mon Sep 17 00:00:00 2001 From: keepkeyjon Date: Thu, 11 Jul 2019 14:47:01 -0600 Subject: [PATCH] bridge: fix debuglink --- scripts/emulator/bridge.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/emulator/bridge.py b/scripts/emulator/bridge.py index 6a36796bc..3df3a779b 100644 --- a/scripts/emulator/bridge.py +++ b/scripts/emulator/bridge.py @@ -9,30 +9,30 @@ PACKET_SIZE = 64 -device = ('0.0.0.0', 21324) +main = ('0.0.0.0', 21324) debug = ('0.0.0.0', 21325) -s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) -s.connect(device) + +ms = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) +ms.connect(main) + +ds = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) +ds.connect(debug) app = Flask(__name__) @app.route('/exchange/', methods=['GET', 'POST']) def exchange(kind): - kk = device - if kind == 'debug': - kk = debug + kk = ds if kind == 'debug' else ms if request.method == 'POST': - content = request.get_json(silent=True) msg = bytearray.fromhex(content["data"]) - s.send(msg) - + kk.send(msg) return Response('{}', status=200, mimetype='application/json') if request.method == 'GET': - data = s.recv(PACKET_SIZE) + data = kk.recv(PACKET_SIZE) body = '{"data":"' + binascii.hexlify(data).decode("utf-8") + '"}' return Response(body, status=200, mimetype='application/json')