balena-labs-projects / bluetooth

Optimized bluetooth agent for balenaOS. Based on BlueZ 5.0.
https://hub.balena.io/blocks
23 stars 11 forks source link

Automatically reconnect to remembered devices #9

Closed klutchell closed 3 years ago

klutchell commented 3 years ago

Recent releases of balenaOS will "remember" connected devices in /var/lib/bluetooth.

https://github.com/balena-os/meta-balena/commit/3815e42f24167c0ce84a39cf0653434bacb0bd88

I've confirmed this on the following device:

ID="balena-os"
NAME="balenaOS"
VERSION="2.60.1+rev1"
VERSION_ID="2.60.1+rev1"
PRETTY_NAME="balenaOS 2.60.1+rev1"
MACHINE="raspberrypi3"
VARIANT="Development"
VARIANT_ID="dev"
META_BALENA_VERSION="2.60.1"
RESIN_BOARD_REV="a28e387"
META_RESIN_REV="9aed19a"
SLUG="raspberrypi3"

However, this bluetooth block does not reconnect to devices automatically after a power cycle. I suspect this is something that can be added via this block, but if balenaOS changes are required we can open a new issue there.

Note that this was previously fixed in balenaSound before it started using this bluetooth block.

https://github.com/balenalabs/balena-sound/commit/78a727a9f406c05946028f69458849ad1c4eaa45

Not sure if the same fix would apply to this block since it looks like we are now relying on the host OS for more components.

jellyfish-bot commented 3 years ago

[klutchell] This issue has attached support thread https://jel.ly.fish/151e8524-cc67-451d-acad-37af75f5e3f2

tmigone commented 3 years ago

Nice, I think if paired devices are now being persisted we can use dbus to attempt the reconnect. I'll give it a shot.

tmigone commented 3 years ago

Needs a tad bit more testing, but so far it works great. PR up here: #10

oivivio commented 3 years ago

Hi @tmigone , thank you for your help with this issue.

How does my balenasound device (Rpi4) receive the changes? Do I need to perform an update or anything?

Thanks!