Skip to content

Commit 6099b7a

Browse files
committed
fix(tion): read data from notification topic after collecting data
It should prevent situation when breezer don't send new data and waiting for something like in #7
1 parent 3a52a39 commit 6099b7a

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

tion_btle/tion.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,23 @@
1313
class TionDelegation(DefaultDelegate):
1414
def __init__(self):
1515
self._data: List = []
16+
self.__topic = None
1617
DefaultDelegate.__init__(self)
1718

1819
def handleNotification(self, handle: int, data: bytes):
1920
self._data.append(data)
2021
_LOGGER.debug("Got data in %d response %s", handle, bytes(data).hex())
22+
self.__topic.read()
2123

2224
def handleDiscovery(self, dev, isNewDev, isNewData):
2325
if isNewDev:
2426
_LOGGER.debug("Discovered device %s", dev.addr)
2527
elif isNewData:
2628
_LOGGER.debug("Received new data from %s", dev.addr)
2729

30+
def setReadTopic(self, topic):
31+
self.__topic = topic
32+
2833
@property
2934
def data(self) -> bytes:
3035
return self._data.pop(0)
@@ -356,6 +361,7 @@ def _enable_notifications(self):
356361
_LOGGER.debug("Result is %s", result)
357362
self._btle.withDelegate(self._delegation)
358363
self.notify.read()
364+
self._delegation.setReadTopic(self.notify)
359365

360366
@property
361367
def fan_speed(self):

0 commit comments

Comments
 (0)