From e38d6abb1284f360253321d0a7624a72fcbdbeca Mon Sep 17 00:00:00 2001 From: sqozz Date: Thu, 16 Jan 2020 18:55:38 +0100 Subject: [PATCH] Remove automatic reconnect --- sem6000.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/sem6000.py b/sem6000.py index df36d5f..7622a78 100644 --- a/sem6000.py +++ b/sem6000.py @@ -4,7 +4,6 @@ import uuid class SEMSocket(): password = "0000" - auto_reconnect_timeout = None powered = False voltage = 0 current = 0 @@ -17,9 +16,8 @@ class SEMSocket(): _notify_char = None _btle_device = None - def __init__(self, mac, auto_reconnect_timeout = None): + def __init__(self, mac): self.mac_address = mac - self.auto_reconnect_timeout = auto_reconnect_timeout self._btle_device = btle.Peripheral(None ,addrType=btle.ADDR_TYPE_PUBLIC,iface=0) try: self.reconnect() @@ -80,18 +78,9 @@ class SEMSocket(): except: return False - def __reconnect(self): + def reconnect(self): self.disconnect() self.connect() - - def reconnect(self, timeout = None): - if timeout == None: - self.__reconnect() - else: - reconnect_start = time.time() - while abs(reconnect_start - time.time()) < timeout or timeout == -1: - self.__reconnect() - if not self.connected: raise self.NotConnectedException @@ -182,7 +171,7 @@ class SEMSocket(): def send(self): if not self.__btle_device.connected: - self.__btle_device.reconnect(self.__btle_device.auto_reconnect_timeout) + self.__btle_device.reconnect() self.__btle_device._write_char.write(self.__data, True) self.__btle_device._btle_device.waitForNotifications(5)