What are the best practices for long-running device discovery in the background? #760
Unanswered
azymohliad
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi! I'm developing a BLE smartwatch companion app for Linux, and it needs to automatically reconnect to the selected device whenever it's in the range. My naive implementation just starts the device discovery whenever the connection is lost. It works well, but when the watch isn't around it would just keep scanning in the background forever. I assume that's wasteful, but I don't exactly know why. Does it increase the power consumption of the Bluetooth adapter? Any other implications?
Is it better to do a periodic discovery instead? Are there any common pitfalls about it I should be aware of? Is there an extra cost to starting and stopping device discovery frequently (besides the cost of D-Bus messages)?
I'd like keep the detection latency low, so I was thinking to use the interval between discoveries of 10-20 seconds, and a discovery duration of a 2-3 seconds (it seems enough in my tests most of the time), plus maybe a longer discovery once per couple of minutes just to be sure. Does that sound like a good idea?
Beta Was this translation helpful? Give feedback.
All reactions