1
0
mirror of https://github.com/esphome/esphome.git synced 2025-03-14 06:38:17 +00:00
This commit is contained in:
Otto Winter 2018-10-13 15:56:45 +02:00
parent f6ae1b31a8
commit afc81df682
No known key found for this signature in database
GPG Key ID: DB66C0BE6013F97E
2 changed files with 7 additions and 6 deletions

View File

@ -223,9 +223,10 @@ def upload_program(config, args, port):
password = ota.get_auth(config)
res = espota2.run_ota(host, remote_port, password, bin_file)
if res != 0:
_LOGGER.warn("OTA v2 method failed. Trying with legacy OTA...")
espota2.run_legacy_ota(verbose, host_port, host, remote_port, password, bin_file)
if res == 0:
return res
_LOGGER.warn("OTA v2 method failed. Trying with legacy OTA...")
return espota2.run_legacy_ota(verbose, host_port, host, remote_port, password, bin_file)
def show_logs(config, args, port, escape=False):

View File

@ -138,9 +138,9 @@ def perform_ota(sock, password, file_handle, filename):
if not password:
raise OTAError("ESP requests password, but no password given!")
nonce = receive_exactly(sock, 32, 'authentication nonce', [], decode=False)
_LOGGER.debug("Auth: Nonce is {}".format(nonce))
_LOGGER.debug("Auth: Nonce is %s", nonce)
cnonce = hashlib.md5(str(random.random()).encode()).hexdigest()
_LOGGER.debug("Auth: CNonce is {}".format(cnonce))
_LOGGER.debug("Auth: CNonce is %s", cnonce)
send_check(sock, cnonce, 'auth cnonce')
@ -149,7 +149,7 @@ def perform_ota(sock, password, file_handle, filename):
result_md5.update(nonce.encode())
result_md5.update(cnonce.encode())
result = result_md5.hexdigest()
_LOGGER.debug("Auth: Result is {}".format(result))
_LOGGER.debug("Auth: Result is %s", result)
send_check(sock, result, 'auth result')
receive_exactly(sock, 1, 'auth result', RESPONSE_AUTH_OK)