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

[bluetooth] Fix disappearing bluetooth devices in Inbox #10187

Merged
merged 2 commits into from
Feb 25, 2021

Conversation

PRosenb
Copy link
Contributor

@PRosenb PRosenb commented Feb 17, 2021

I had troubles with detecting Bluetooth devices. On first scan, it listed multiple devices but when I did the scan again a bit later, the list was mostly empty.

The code that handles Bluetooth device detection is quite complex (too complex I feel). I analysed the code and used the debugger to get a basic understanding.

Suggested changes to improve Bluetooth device detection:

  • Notify Things again when they are removed from listeners like Inbox

@Hilbrand Hilbrand changed the title Improve bluetooth device discovery [bluetooth] Improve bluetooth device discovery Feb 17, 2021
@Hilbrand Hilbrand added the enhancement An enhancement or new feature for an existing add-on label Feb 17, 2021
@cpmeister
Copy link
Contributor

The rssi is highly variable and can change many times a second. Discovery recalculation should only occur if the previous result expired or there is new immutable information about the device that might cause it to get discovered differently. Signal strength is not "immutable" information and as such should not cause a new discovery attempt.

…like Inbox

Signed-off-by: Peter Rosenberg <prosenb.dev@gmail.com>
@PRosenb
Copy link
Contributor Author

PRosenb commented Feb 19, 2021

Thanks for the explanation. Yes, that could change too often then.
I removed the RSSI related commit.

Copy link
Member

@kaikreuzer kaikreuzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @PRosenb, this is awesome! I had exactly the same issue and tried to fix it with #10154, which miserably failed.
I tested your fix and can confirm that it is working nicely - I now have a stable list of devices in the inbox on subsequent scans.
@cpmeister Ieave merging to you as you're the expert for the code in question.
If you allow, I have to agree with @PRosenb that the discovery code is tough to read and it gave me a hard time - so hard that I didn't feel comfortable of doing changes to it...

@kaikreuzer kaikreuzer added bug An unexpected problem or unintended behavior of an add-on and removed enhancement An enhancement or new feature for an existing add-on labels Feb 21, 2021
@kaikreuzer kaikreuzer changed the title [bluetooth] Improve bluetooth device discovery [bluetooth] Fix disappearing bluetooth devices in Inbox Feb 21, 2021
Signed-off-by: Peter Rosenberg <prosenb.dev@gmail.com>
@cpmeister cpmeister merged commit cdf044c into openhab:main Feb 25, 2021
@cpmeister cpmeister added this to the 3.1 milestone Feb 25, 2021
themillhousegroup pushed a commit to themillhousegroup/openhab2-addons that referenced this pull request May 10, 2021
* [bluetooth] Notify things again when they are removed from listeners like Inbox
* [bluetooth] Add javadoc on retractDiscoveryResult()

Signed-off-by: Peter Rosenberg <prosenb.dev@gmail.com>
Signed-off-by: John Marshall <john.marshall.au@gmail.com>
computergeek1507 pushed a commit to computergeek1507/openhab-addons that referenced this pull request Jul 13, 2021
* [bluetooth] Notify things again when they are removed from listeners like Inbox
* [bluetooth] Add javadoc on retractDiscoveryResult()

Signed-off-by: Peter Rosenberg <prosenb.dev@gmail.com>
thinkingstone pushed a commit to thinkingstone/openhab-addons that referenced this pull request Nov 7, 2021
* [bluetooth] Notify things again when they are removed from listeners like Inbox
* [bluetooth] Add javadoc on retractDiscoveryResult()

Signed-off-by: Peter Rosenberg <prosenb.dev@gmail.com>
marcfischerboschio pushed a commit to bosch-io/openhab-addons that referenced this pull request May 5, 2022
* [bluetooth] Notify things again when they are removed from listeners like Inbox
* [bluetooth] Add javadoc on retractDiscoveryResult()

Signed-off-by: Peter Rosenberg <prosenb.dev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants