Skip to content

Commit d188960

Browse files
committed
fix(ota): Re-send invitation on failure
1 parent 7566046 commit d188960

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tools/espota.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,22 @@ def serve(
297297
logging.info("SHA256 password failed, trying MD5 password hash")
298298
sys.stderr.write("Retrying with MD5 password...")
299299
sys.stderr.flush()
300+
301+
# Device is back in OTA_IDLE after auth failure, need to send new invitation
302+
success, data, error = send_invitation_and_get_auth_challenge(remote_addr, remote_port, message)
303+
if not success:
304+
sys.stderr.write("FAIL\n")
305+
logging.error("Failed to get new challenge for MD5 retry: %s", error)
306+
return 1
307+
308+
if not data.startswith("AUTH"):
309+
sys.stderr.write("FAIL\n")
310+
logging.error("Expected AUTH challenge for MD5 retry, got: %s", data)
311+
return 1
312+
313+
# Get new nonce for second attempt
314+
nonce = data.split()[1]
315+
300316
auth_success, auth_error = authenticate(
301317
remote_addr, remote_port, password,
302318
use_md5_password=True, use_old_protocol=False,

0 commit comments

Comments
 (0)