Commit bdc45e39 authored by Gei0r's avatar Gei0r Committed by Me No Dev

[OTA] Fix "Error response from device" if OK response comes to early (#1695)

Because TCP is stream-based, an earlier read can 'take away' the "OK" response
from the device, so that a later read doesn't get the message.
parent a7ddf395
......@@ -179,6 +179,7 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
try:
connection.sendall(chunk)
res = connection.recv(10)
lastResponseContainedOK = 'OK' in res.decode()
except:
sys.stderr.write('\n')
logging.error('Error Uploading')
......@@ -187,6 +188,13 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
sock.close()
return 1
if lastResponseContainedOK:
logging.info('Success')
connection.close()
f.close()
sock.close()
return 0
sys.stderr.write('\n')
logging.info('Waiting for result...')
try:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment