-
-
Notifications
You must be signed in to change notification settings - Fork 217
Description
Hi,
I had a small problem with OTA using platformio: The upload worked fine, but platformio reported "[ERROR]: Error response from device". I was able to fix the problem in espota.py. Now I want to contribute the fix, but I don't know where. Platformio does not seem to take the file from github, but rather from bintray.com. The "official" github version is different from the bintray one.
Anyway, here's the fix: The problem is that TCP is a stream-based protocol and the "OK" response from the ESP can be read by an earlier recv call. When espota.py later tries to receive the "OK" again, it is already gone.
Therefore I added a little flag that is set if a response contains "OK" so that we don't continue looking for it afterwards.
diff --git a/espota.py b/espota.py
index 1aa5425..8618e88 100755
--- a/espota.py
+++ b/espota.py
@@ -179,21 +179,21 @@ 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,13 +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:
How can I get this fix into platformio?