-
Notifications
You must be signed in to change notification settings - Fork 117
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
Scan and pick first available hci device #369
base: main
Are you sure you want to change the base?
Conversation
Per more tests I just ran, when the device jumps from hci0 to hci1, when the kernel encounter an issue with the later, the device goes back to hci0. [edit] it even jumped once to hci2 and reverted later to hci0. Perhaps a better solution would be to allow via command line to specific which device to use but most people only have a single BLE device. |
return nil, fmt.Errorf("failed to find available Bluetooth adapter: %w", err) | ||
} | ||
|
||
log.Printf("Using Bluetooth adapter: %s", hciName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably use log.Debug
Is there a reliable way to reproduce this on a raspberry Pi? I do most of my Linux-based testing on one and haven't encountered this issue. |
If hci jumps around, how about specifying wanted device with it's mac address, or some other unique id? And then search for it? |
I have proposed a new PR with my suggestion. |
Same here, I have a few hundred BLE users, I never had this issue, some have this regularly but until now, I did not find the root cause. This PR helps to get rid of the issue, though. |
@Lenart12 I didn't think of going with the BLE MAC addr , I admit I like your approach better than mine as it covers someone with 2+ BLE devices... perhaps for someone with a big house and 2 garages on apposite side that each requires their own dongle :) I'll leave this PR open for now but I vote for your approach. |
My PR will not work, check my comment there :^( |
I made a PR (#373) that will switch the bluetooth backend to use BlueZ. It allows us to nicely specify which adapter to use (hciX). You can use external tooling to find the wanted hci id (first available/mac address). Hopefully that also means that a lot of wierd bluetooth issues people were experiencing will be fixed. |
Description
This PR enables
tesla-control
to automatically select, at least under Linux, the first availablehci
device. Currently,tesla-control
only tries to usehci0
and lacks the ability to dynamically choose the first available Bluetooth device.In our project, an add-on for Home Assistant,
tesla-control
is used to fetch data and control Tesla vehicles.We’ve received multiple reports from different people seeing always the same issue. This happens on Raspberry Pi (recent and old models), Synology NAS, and similar systems. After a fresh reboot, the Bluetooth device initially appears as hci0, but after a short time, it jumps to hci1. After this,
tesla-control
becomes useless.I am not a pro Go programmer but the tests I ran seem to be a solution for #261
Fixes #261
Type of change
Please select all options that apply to this change:
Checklist:
Confirm you have completed the following steps: