From 4285e0a93b018051c99fef185efda349f96377a7 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Sat, 8 Dec 2018 19:24:29 +0100 Subject: [PATCH] fix OTA https://github.com/esp8266/Arduino/issues/4283#issuecomment-445447030 --- tools/espota.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/espota.py b/tools/espota.py index 862a48c1a1..36d5f8c313 100755 --- a/tools/espota.py +++ b/tools/espota.py @@ -144,6 +144,8 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm sock.close() return 1 + received_ok = False + try: f = open(filename, "rb") if (PROGRESS): @@ -160,7 +162,9 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm connection.settimeout(10) try: connection.sendall(chunk) - res = connection.recv(4) + if connection.recv(32).decode().find('O') >= 0: + # connection will receive only digits or 'OK' + received_ok = True; except: sys.stderr.write('\n') logging.error('Error Uploading') @@ -176,8 +180,10 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm # the connection before receiving the 'O' of 'OK' try: connection.settimeout(60) - while True: - if connection.recv(32).decode().find('O') >= 0: break + while not received_ok: + if connection.recv(32).decode().find('O') >= 0: + # connection will receive only digits or 'OK' + received_ok = True; logging.info('Result: OK') connection.close() f.close()