-
Notifications
You must be signed in to change notification settings - Fork 146
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
Cannot connect to device #320
Comments
I would suggest look at the examples here https://github.com/tinygo-org/bluetooth/tree/release/examples/discover and here https://github.com/tinygo-org/bluetooth/tree/release/examples/heartrate-monitor for how to connect as a Central to a Peripheral. Hope that helps! |
I tried those . I've done more testing and the problem seems to be only when running on Linux . Runs fine on Mac, in fact: 1: Run on linux, get unable to connect - Times out - bluetooth: failed to connect: le-connection-abort-by-local After a while Linux stops working and I have to run it on the mac again I suspect this is something to do with Bluez so feel free to close this ticket unless anyone out there has a clue why, otherwise I'll go to Stack Overflow :) |
Hi! Were you able to find out anything else? For example, I can't connect to a known device on my Mac in scan mode for ex, i do like this:
I just get stuck on connecting and nothing happens |
It seems that in my case the problem was that I was trying to connect in scanning mode, but I had to stop scanning first. |
Oh that could be it , will try that today. I wasn’t aware there were modes
…On Sat, 8 Feb 2025 at 02:59, Artem ***@***.***> wrote:
It seems that in my case the problem was that I was trying to connect in
scanning mode, but I had to stop scanning first.
—
Reply to this email directly, view it on GitHub
<#320 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAANV6EVWWJJDVSYNHIXUXT2OVXIVAVCNFSM6AAAAABUSOHI6CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNBUGQ2TEMBRHE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Tried and failed :( I used the heart rate monitor code as a base to prove if this would fix it or not and no joy. var (
adapter = bluetooth.DefaultAdapter
requiredAddress = "08:6B:D7:8F:10:BD"
)
func main() {
must("enable BLE stack", adapter.Enable())
ch := make(chan bluetooth.ScanResult, 1)
println("scanning...")
adapter.Scan(func(adapter *bluetooth.Adapter, result bluetooth.ScanResult) {
if result.Address.String() == requiredAddress {
println("found device:", result.Address.String(), result.RSSI)
adapter.StopScan()
ch <- result
}
})
select {
case result := <-ch:
println("Connect to device:", result.Address.String())
_, err := adapter.Connect(result.Address, bluetooth.ConnectionParams{})
if err != nil {
println(err.Error())
return
}
println("connected to ", result.Address.String())
}
}
As before, it says it just sits at 'Connecting' forever. I even tried adding parameters to tell it to timeout after 30 seconds but that doesn't appear to affect it. |
News Flash... it didn't work on a Raspberry Pi with Raspbian.. It Did Work Fedora on an AMD box.. there is hope |
I have a BLE device that I've successfully scanned for and connected to in a simple diagnostic SwiftUI app, now I'm trying to talk to it from a command line app written in Go that will ultimately run on Linux.
I can scan for my device and read the advertised manufacturer data but when I try to connect (which should take no longer than 4-5 seconds) the code just sits there and never responds.
I've created a minimal example of what I'm doing:
When I run this the only output is:
Am I doing something fundamentally wrong?
I've also successfully connected to the same device using Rust/btleplug so I'm confident the device works.
The text was updated successfully, but these errors were encountered: