driver: retrieve hw_rev after conn is established
This commit is contained in:
parent
c267c30b89
commit
27bf573010
@ -606,6 +606,7 @@ class Kirdy:
|
||||
self.device = Device(self._send_cmd, self._send_raw_cmd)
|
||||
self.laser = Laser(self._send_cmd)
|
||||
self.thermostat = Thermostat(self._send_cmd, self._send_raw_cmd)
|
||||
self.hw_rev = None
|
||||
|
||||
self._task_queue, self._int_msg_queue, self._report_queue = None, None, None
|
||||
self._timeout = 5.0
|
||||
@ -625,6 +626,8 @@ class Kirdy:
|
||||
|
||||
self.connected_event = None
|
||||
|
||||
def get_hw_rev(self):
|
||||
return self.hw_rev
|
||||
|
||||
def set_report_sig(self, sig):
|
||||
"""
|
||||
@ -756,10 +759,17 @@ class Kirdy:
|
||||
while True:
|
||||
if self._state == State.disconnected:
|
||||
try:
|
||||
self.hw_rev = None
|
||||
await self.__coninit(self._timeout)
|
||||
self.read_response_task = asyncio.create_task(self._read_response_handler())
|
||||
task = None
|
||||
logging.info("Connected to %s:%d", self._host, self._ctrl_port)
|
||||
|
||||
hw_rev = await self.device.get_hw_rev()
|
||||
self.hw_rev = hw_rev["hw_rev"]
|
||||
|
||||
if self._connected_sig is not None:
|
||||
self._connected_sig.emit(True)
|
||||
self.connected_event.set()
|
||||
|
||||
# State Transition
|
||||
@ -849,9 +859,6 @@ class Kirdy:
|
||||
self._reader, self._writer = await asyncio.wait_for(asyncio.open_connection(self._host, self._ctrl_port), timeout)
|
||||
writer_sock = self._writer.get_extra_info("socket")
|
||||
writer_sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
||||
|
||||
if self._connected_sig is not None:
|
||||
self._connected_sig.emit(True)
|
||||
|
||||
async def _read_response(self, buffer_size=16384):
|
||||
raw_response = b''
|
||||
|
Loading…
Reference in New Issue
Block a user