mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 13:34:54 +01:00
Improve OTAv2 error messages
This commit is contained in:
parent
8203b8fcd3
commit
04dc848620
1 changed files with 4 additions and 2 deletions
|
@ -3,6 +3,7 @@ import logging
|
|||
import random
|
||||
import socket
|
||||
import sys
|
||||
import time
|
||||
|
||||
from esphomeyaml.core import ESPHomeYAMLError
|
||||
|
||||
|
@ -75,9 +76,9 @@ def receive_exactly(sock, amount, msg, expect, decode=True):
|
|||
|
||||
try:
|
||||
check_error(data, expect)
|
||||
except OTAError:
|
||||
except OTAError as err:
|
||||
sock.close()
|
||||
raise
|
||||
raise OTAError("Error {}: {}".format(msg, err))
|
||||
|
||||
while len(data) < amount:
|
||||
try:
|
||||
|
@ -201,6 +202,7 @@ def perform_ota(sock, password, file_handle, filename):
|
|||
receive_exactly(sock, 1, 'receive OK', RESPONSE_RECEIVE_OK)
|
||||
receive_exactly(sock, 1, 'Update end', RESPONSE_UPDATE_END_OK)
|
||||
send_check(sock, RESPONSE_OK, 'end acknowledgement')
|
||||
time.sleep(0.25)
|
||||
|
||||
_LOGGER.info("OTA successful")
|
||||
|
||||
|
|
Loading…
Reference in a new issue