Skip to content

Commit bd75a42

Browse files
dbarrosopdeadprogram
authored andcommitted
gattc/linux: DiscoverServices times out in 10s
1 parent 7f3b96c commit bd75a42

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

gattc_linux.go

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ func (s *DeviceService) UUID() UUID {
3838
// On Linux with BlueZ, this just waits for the ServicesResolved signal (if
3939
// services haven't been resolved yet) and uses this list of cached services.
4040
func (d *Device) DiscoverServices(uuids []UUID) ([]DeviceService, error) {
41+
start := time.Now()
42+
4143
for {
4244
resolved, err := d.device.GetServicesResolved()
4345
if err != nil {
@@ -48,6 +50,9 @@ func (d *Device) DiscoverServices(uuids []UUID) ([]DeviceService, error) {
4850
}
4951
// This is a terrible hack, but I couldn't find another way.
5052
time.Sleep(10 * time.Millisecond)
53+
if time.Since(start) > 10*time.Second {
54+
return nil, errors.New("timeout on DiscoverServices")
55+
}
5156
}
5257

5358
services := []DeviceService{}

0 commit comments

Comments
 (0)