Skip to content

Commit

Permalink
fix initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
doudz committed Nov 8, 2020
1 parent 504dcd4 commit ceabcc8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions zigpy_zigate/uart.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ def data_received(self, data):
length,
len(frame) - 6)
self._buffer = self._buffer[endpos + 1:]
endpos = self._buffer.find(self.END)
continue
if self._checksum(frame[:4], lqi, f_data) != checksum:
LOGGER.warning("Invalid checksum: %s, data: 0x%s",
checksum,
binascii.hexlify(frame).decode())
self._buffer = self._buffer[endpos + 1:]
endpos = self._buffer.find(self.END)
continue
LOGGER.debug("Frame received: %s", binascii.hexlify(frame).decode())
self._api.data_received(cmd, f_data, lqi)
Expand Down
6 changes: 5 additions & 1 deletion zigpy_zigate/zigbee/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ def __init__(self, config: Dict[str, Any]):
async def startup(self, auto_form=False):
"""Perform a complete application startup"""
self._api = await ZiGate.new(self._config[CONF_DEVICE], self)
await self._api.set_raw_mode()
try:
await self._api.set_raw_mode()
except NoResponseError:
# retry, sometimes after reboot it fails for some reasons
await self._api.set_raw_mode()
version, lqi = await self._api.version()
version = '{:x}'.format(version[1])
version = '{}.{}'.format(version[0], version[1:])
Expand Down

0 comments on commit ceabcc8

Please sign in to comment.