Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scanning and connecting to sensors doesn't work reliably #4

Open
qwandor-google opened this issue Aug 4, 2020 · 0 comments
Open

Scanning and connecting to sensors doesn't work reliably #4

qwandor-google opened this issue Aug 4, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@qwandor-google
Copy link
Collaborator

Observations:

  1. After restarting bluetoothd, the first scan doesn't discover any services. It appears that services aren't discovered until we try to connect, so the check in find_sensors for having at least one service advertised is wrong.
  2. However, in this state the first attempt to connect almost always fails after some time.
  3. If you first do a connect to the device from bluetoothctl and that succeeds, then connecting here succeeds quickly.
  4. Trying again (but not too soon, if it timed out the first time, or it will fail with an error that it's still trying to connect) may succeed. It usually does for 7 of the sensors we have in the house. I'm not sure what's different about the others.

Ideas:
It would be better to start trying to connect to all sensors at the same time without blocking the rest while waiting for one to finish or time out, maybe retry once, and then finally use all the ones we managed to connect to. I tried to kind of make this happen with the API we have by connecting to each with a small timeout, waiting a bit, then trying again. I couldn't get this to work though.

blurz's BluetoothDevice also has a connect_profile which does something differently (and doesn't have a timeout), but I haven't yet figured out what it actually does or whether it is useful to us.

@qwandor-google qwandor-google added the bug Something isn't working label Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant