gattc/linux: DiscoverServices times out in 10s
This commit is contained in:
parent
7f3b96cff9
commit
bd75a42694
@ -38,6 +38,8 @@ func (s *DeviceService) UUID() UUID {
|
|||||||
// On Linux with BlueZ, this just waits for the ServicesResolved signal (if
|
// 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.
|
// services haven't been resolved yet) and uses this list of cached services.
|
||||||
func (d *Device) DiscoverServices(uuids []UUID) ([]DeviceService, error) {
|
func (d *Device) DiscoverServices(uuids []UUID) ([]DeviceService, error) {
|
||||||
|
start := time.Now()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
resolved, err := d.device.GetServicesResolved()
|
resolved, err := d.device.GetServicesResolved()
|
||||||
if err != nil {
|
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.
|
// This is a terrible hack, but I couldn't find another way.
|
||||||
time.Sleep(10 * time.Millisecond)
|
time.Sleep(10 * time.Millisecond)
|
||||||
|
if time.Since(start) > 10*time.Second {
|
||||||
|
return nil, errors.New("timeout on DiscoverServices")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
services := []DeviceService{}
|
services := []DeviceService{}
|
||||||
|
Loading…
Reference in New Issue
Block a user