From bd75a426949c402e12315f0229fb90c61c8c94e6 Mon Sep 17 00:00:00 2001 From: David Barroso Date: Mon, 1 Nov 2021 08:41:57 +0100 Subject: [PATCH] gattc/linux: DiscoverServices times out in 10s --- gattc_linux.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gattc_linux.go b/gattc_linux.go index 8a8c5dc..4edad9a 100644 --- a/gattc_linux.go +++ b/gattc_linux.go @@ -38,6 +38,8 @@ func (s *DeviceService) UUID() UUID { // On Linux with BlueZ, this just waits for the ServicesResolved signal (if // services haven't been resolved yet) and uses this list of cached services. func (d *Device) DiscoverServices(uuids []UUID) ([]DeviceService, error) { + start := time.Now() + for { resolved, err := d.device.GetServicesResolved() if err != nil { @@ -48,6 +50,9 @@ func (d *Device) DiscoverServices(uuids []UUID) ([]DeviceService, error) { } // This is a terrible hack, but I couldn't find another way. time.Sleep(10 * time.Millisecond) + if time.Since(start) > 10*time.Second { + return nil, errors.New("timeout on DiscoverServices") + } } services := []DeviceService{}