mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 11:47:30 +01:00
Improve OTAv2 error messages
This commit is contained in:
parent
8203b8fcd3
commit
04dc848620
@ -3,6 +3,7 @@ import logging
|
|||||||
import random
|
import random
|
||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
|
||||||
from esphomeyaml.core import ESPHomeYAMLError
|
from esphomeyaml.core import ESPHomeYAMLError
|
||||||
|
|
||||||
@ -75,9 +76,9 @@ def receive_exactly(sock, amount, msg, expect, decode=True):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
check_error(data, expect)
|
check_error(data, expect)
|
||||||
except OTAError:
|
except OTAError as err:
|
||||||
sock.close()
|
sock.close()
|
||||||
raise
|
raise OTAError("Error {}: {}".format(msg, err))
|
||||||
|
|
||||||
while len(data) < amount:
|
while len(data) < amount:
|
||||||
try:
|
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, 'receive OK', RESPONSE_RECEIVE_OK)
|
||||||
receive_exactly(sock, 1, 'Update end', RESPONSE_UPDATE_END_OK)
|
receive_exactly(sock, 1, 'Update end', RESPONSE_UPDATE_END_OK)
|
||||||
send_check(sock, RESPONSE_OK, 'end acknowledgement')
|
send_check(sock, RESPONSE_OK, 'end acknowledgement')
|
||||||
|
time.sleep(0.25)
|
||||||
|
|
||||||
_LOGGER.info("OTA successful")
|
_LOGGER.info("OTA successful")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user