Skip to content

Commit 4285e0a

Browse files
committed
1 parent 783f817 commit 4285e0a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tools/espota.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
144144
sock.close()
145145
return 1
146146

147+
received_ok = False
148+
147149
try:
148150
f = open(filename, "rb")
149151
if (PROGRESS):
@@ -160,7 +162,9 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
160162
connection.settimeout(10)
161163
try:
162164
connection.sendall(chunk)
163-
res = connection.recv(4)
165+
if connection.recv(32).decode().find('O') >= 0:
166+
# connection will receive only digits or 'OK'
167+
received_ok = True;
164168
except:
165169
sys.stderr.write('\n')
166170
logging.error('Error Uploading')
@@ -176,8 +180,10 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
176180
# the connection before receiving the 'O' of 'OK'
177181
try:
178182
connection.settimeout(60)
179-
while True:
180-
if connection.recv(32).decode().find('O') >= 0: break
183+
while not received_ok:
184+
if connection.recv(32).decode().find('O') >= 0:
185+
# connection will receive only digits or 'OK'
186+
received_ok = True;
181187
logging.info('Result: OK')
182188
connection.close()
183189
f.close()

0 commit comments

Comments
 (0)