Skip to content

Commit

Permalink
Improve stability of BT connection, by reconnecting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lars Falk-Petersen committed Jul 9, 2023
1 parent 9d7ef5a commit cf1812d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion bluedo/bluedoapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

class BlueDo(Gtk.Application):
project_name = 'bluedo'
project_version = 2.3
project_version = 2.4
config_path = appdirs.user_config_dir(project_name) + '/' + project_name + '.ini'
config_section = 'CONFIG'
run_path = os.path.dirname(os.path.realpath(__file__)) + '/'
Expand Down Expand Up @@ -615,6 +615,8 @@ def bluetooth_ping(self, here_callback, away_callback):
syslog.syslog("No connection")
if lost_pings > 0:
syslog.syslog("Lost %s" % lost_pings)
if lost_pings%5 == 0:
attempt_bluetooth_connection(self.bt_address)

if self.enabled:
lost_pings += 1
Expand Down Expand Up @@ -674,6 +676,11 @@ def away_callback(self):
# Static functions
#

def attempt_bluetooth_connection(device):
""" Sometimes ubuntu seems to not reconnect automatically. """
syslog.syslog("Attempting to start a bluetooth connection.")
subprocess.run(f"/usr/bin/bluetoothctl connect {device} > /dev/null", shell=True, check=False)

def run_user_command(cmd=''):
''' Run user supplied command '''
syslog.syslog("Running user command <%s>." % cmd)
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
bluedo (2.4) unstable; urgency=medium

* Reach out to bluetooth device if not connected.

-- Lars Falk-Petersen <dev@falkp.no> Sun, 09 Jul 2023 00:00:00 +0200

bluedo (2.1) unstable; urgency=medium

* Clear viewport before replacing demo animation with static picture. Minimum gtk 3.22. Move settings link to look OK when using large font. Other small changes.
Expand Down
2 changes: 1 addition & 1 deletion debian/copyright
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Source: https://github.com/ways/BlueDo/blob/master/LICENSE

Files: *
Copyright: 2020-2022 Lars Falk-Petersen <dev@falkp.no>
Copyright: 2020-2023 Lars Falk-Petersen <dev@falkp.no>
License: GPL-3+
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
# Specify the Python versions you support here.
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
"Topic :: Desktop Environment",
"Topic :: Desktop Environment :: Gnome",
"Topic :: Security",
Expand Down

0 comments on commit cf1812d

Please sign in to comment.