Skip to content

Commit

Permalink
Improve OTAv2 error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
OttoWinter committed Nov 10, 2018
1 parent 8203b8f commit 04dc848
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions esphomeyaml/espota2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import random
import socket
import sys
import time

from esphomeyaml.core import ESPHomeYAMLError

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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")

Expand Down

0 comments on commit 04dc848

Please sign in to comment.