muka / go-bluetooth

Golang bluetooth client based on bluez DBus interfaces
Apache License 2.0
652 stars 125 forks source link

BLE Auto Connection #128

Closed daleknauss closed 2 years ago

daleknauss commented 3 years ago

Hello,

I'm trying to build in auto-reconnect for a BLE device so that if the device is powered off and then later powered on, I will automatically reconnect to it. I'm struggling to find the right way to do it without resorting to hacks.

Currently, if the devices goes offline, I just set a Ticker and then just keep trying to Connect to the device at a regular interval. However, this seems hacky and is leading to some other issues.

For bluetooth classic devices, I am able to continue to monitor properties after disconnect and am able to auto-reconnect already.

My questions are:

  1. Do you have any examples of auto-reconnect working for BLE devices?
  2. Is there a way to check if a cached device is able to be connected to without just trying to connect?

Thanks for the support and also thank you for building such a useful library!

muka commented 2 years ago

Sorry for the long delay, I have no direct answer I guess your best bet is to search for an example implemetation in another library. If you find a proper way and think can provide value to other users, please open a PR!

Closing, please reopen if you have updates. Thanks