Skip to content

Commit 0cd15b4

Browse files
committed
Merge branch 'master' of https://github.com/espressif/arduino-esp32 into idf-update
2 parents 0a779dd + a7b627c commit 0cd15b4

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

Diff for: tools/espota.exe

151 Bytes
Binary file not shown.

Diff for: tools/espota.py

+31-14
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
106106
sock2.close()
107107
logging.error('Host %s Not Found', remoteAddr)
108108
return 1
109-
sock2.settimeout(1)
109+
sock2.settimeout(TIMEOUT)
110110
try:
111111
data = sock2.recv(37).decode()
112112
break;
@@ -162,7 +162,6 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
162162
logging.error('No response from device')
163163
sock.close()
164164
return 1
165-
166165
try:
167166
f = open(filename, "rb")
168167
if (PROGRESS):
@@ -191,18 +190,26 @@ def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, comm
191190
sys.stderr.write('\n')
192191
logging.info('Waiting for result...')
193192
try:
194-
connection.settimeout(60)
195-
data = connection.recv(32).decode()
196-
logging.info('Result: %s' ,data)
197-
connection.close()
198-
f.close()
199-
sock.close()
200-
if (data != "OK"):
201-
sys.stderr.write('\n')
202-
logging.error('%s', data)
203-
return 1;
204-
return 0
205-
except:
193+
count = 0
194+
while True:
195+
count=count+1
196+
connection.settimeout(60)
197+
data = connection.recv(32).decode()
198+
logging.info('Result: %s' ,data)
199+
200+
if data == "OK":
201+
logging.info('Success')
202+
connection.close()
203+
f.close()
204+
sock.close()
205+
return 0;
206+
if count == 5:
207+
logging.error('Error response from device')
208+
connection.close()
209+
f.close()
210+
sock.close()
211+
return 1
212+
except e:
206213
logging.error('No Result!')
207214
connection.close()
208215
f.close()
@@ -292,6 +299,12 @@ def parser(unparsed_args):
292299
action = "store_true",
293300
default = False
294301
)
302+
group.add_option("-t", "--timeout",
303+
dest = "timeout",
304+
type = "int",
305+
help = "Timeout to wait for the ESP8266 to accept invitation",
306+
default = 10
307+
)
295308
parser.add_option_group(group)
296309

297310
(options, args) = parser.parse_args(unparsed_args)
@@ -312,6 +325,10 @@ def main(args):
312325
# check options
313326
global PROGRESS
314327
PROGRESS = options.progress
328+
329+
global TIMEOUT
330+
TIMEOUT = options.timeout
331+
315332
if (not options.esp_ip or not options.image):
316333
logging.critical("Not enough arguments.")
317334
return 1

0 commit comments

Comments
 (0)