Skip to content

Commit bdc45e3

Browse files
Gei0rme-no-dev
authored andcommitted
[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.
1 parent a7ddf39 commit bdc45e3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: tools/espota.py

+8
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
179179
try:
180180
connection.sendall(chunk)
181181
res = connection.recv(10)
182+
lastResponseContainedOK = 'OK' in res.decode()
182183
except:
183184
sys.stderr.write('\n')
184185
logging.error('Error Uploading')
@@ -187,6 +188,13 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
187188
sock.close()
188189
return 1
189190

191+
if lastResponseContainedOK:
192+
logging.info('Success')
193+
connection.close()
194+
f.close()
195+
sock.close()
196+
return 0
197+
190198
sys.stderr.write('\n')
191199
logging.info('Waiting for result...')
192200
try:

0 commit comments

Comments
 (0)