mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-25 20:02:37 +03:00
fix OTA (#5454)
https://github.com/esp8266/Arduino/issues/4283#issuecomment-445447030
This commit is contained in:
parent
783f817c16
commit
e4c6030e48
@ -144,6 +144,8 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
|
|||||||
sock.close()
|
sock.close()
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
received_ok = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
f = open(filename, "rb")
|
f = open(filename, "rb")
|
||||||
if (PROGRESS):
|
if (PROGRESS):
|
||||||
@ -160,7 +162,9 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
|
|||||||
connection.settimeout(10)
|
connection.settimeout(10)
|
||||||
try:
|
try:
|
||||||
connection.sendall(chunk)
|
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:
|
except:
|
||||||
sys.stderr.write('\n')
|
sys.stderr.write('\n')
|
||||||
logging.error('Error Uploading')
|
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'
|
# the connection before receiving the 'O' of 'OK'
|
||||||
try:
|
try:
|
||||||
connection.settimeout(60)
|
connection.settimeout(60)
|
||||||
while True:
|
while not received_ok:
|
||||||
if connection.recv(32).decode().find('O') >= 0: break
|
if connection.recv(32).decode().find('O') >= 0:
|
||||||
|
# connection will receive only digits or 'OK'
|
||||||
|
received_ok = True;
|
||||||
logging.info('Result: OK')
|
logging.info('Result: OK')
|
||||||
connection.close()
|
connection.close()
|
||||||
f.close()
|
f.close()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user