Skip to content

Commit

Permalink
Return clear error for connection timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyRN committed Oct 18, 2024
1 parent 70dde1f commit c8c13e2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gap_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,6 @@ func (a *Adapter) Connect(address Address, params ConnectionParams) (Device, err
return Device{}, err
}

if params.ConnectionTimeout <= 0 {
params.ConnectionTimeout = NewDuration(30 * time.Second)
}
connectChan := make(chan error)
go func() {
for sig := range signal {
Expand All @@ -392,12 +389,15 @@ func (a *Adapter) Connect(address Address, params ConnectionParams) (Device, err
}
}()
go func() {
if params.ConnectionTimeout <= 0 {
params.ConnectionTimeout = NewDuration(30 * time.Second)
}
time.Sleep(time.Duration(params.ConnectionTimeout))
connected, err := device.device.GetProperty("org.bluez.Device1.Connected")
if !connected.Value().(bool) || err != nil {
a.bus.RemoveSignal(signal)
close(signal)
connectChan <- err
connectChan <- fmt.Errorf("connection timeout exceeded: %w", err)
}
}()

Expand Down

0 comments on commit c8c13e2

Please sign in to comment.