Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pygatt/backends/gatttool/gatttool.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,12 @@ def __init__(self, hci_device='hci0', gatttool_logfile=None,
self._address = None
self._send_lock = threading.Lock()
self._auto_reconnect = False
self._reconnecting = False
self._search_window_size = search_window_size
self._scan = None
self._max_read = max_read


self.reconnecting = False

def sendline(self, command):
"""
send a raw command to gatttool
Expand Down Expand Up @@ -478,12 +479,14 @@ def reconnect(self, timeout=DEFAULT_CONNECT_TIMEOUT_S):
log.info("Connecting to %s with timeout=%s", self._address,
timeout)
try:
self.reconnecting = True
cmd = "connect"
with self._receiver.event("connect", timeout):
self.sendline(cmd)
# reenable all notifications
self._connected_device.resubscribe_all()
log.info("Connection to %s reestablished.")
self.reconnecting = False
break # finished reconnecting
except NotificationTimeout:
message = ("Timed out connecting to {0} after {1} seconds. "
Expand All @@ -496,6 +499,7 @@ def reconnect(self, timeout=DEFAULT_CONNECT_TIMEOUT_S):
@at_most_one_device
def disconnect(self, *args, **kwargs):
self._auto_reconnect = False # disables any running reconnection
self.reconnecting = False
if not self._receiver.is_set("disconnected"):
self.sendline('disconnect')
self._connected_device = None
Expand Down