bluetooth
bluetooth copied to clipboard
Allow changing adapter ID in Linux backend
The bluetooth library used for Linux simply returns hci0 as the DefaultAdapter. This is constant and never changes. On all systems, DefaultAdapter will be hci0, even if hci0 doesn't exist. Sometimes, hci0 does exist, but users cannot or don't want to use it for one reason or another. There should be a way to use a specific adapter ID.
I'm thinking something like func AdapterByID(id string) (*Adapter, bool) should be added. This would return an adapter and true on Linux, and nil and false on other platforms. It could be used like so:
adapter, ok := bluetooth.AdapterByID(adapterID)
if !ok {
adapter = bluetooth.DefaultAdapter
}