func (d *smaDiscoverer) deviceBySerial(serial uint32) *sunny.Device {
	start := time.Now()
	for time.Since(start) < time.Second*3 {
		// discover done -> return immediately regardless of result
		if atomic.LoadUint32(&d.done) != 0 {
			return d.get(serial)
		}

		// device with serial found -> return
		if device := d.get(serial); device != nil {
			return device
		}

		time.Sleep(time.Millisecond * 10)
	}
	return d.get(serial)
}
// deviceBySerial with the given serial number
deviceBySerial with the given serial number
// deviceBySerial with the given serial number
func (d *smaDiscoverer) deviceBySerial(serial uint32) *sunny.Device {
	start := time.Now()
	for time.Since(start) < time.Second*3 {
		if atomic.LoadUint32(&d.done) != 0 {
			return d.get(serial)
		}
		if device := d.get(serial); device != nil {
			return device
		}
		time.Sleep(time.Millisecond * 10)
	}
	return d.get(serial)
}
func ( d * smaDiscoverer ) deviceBySerial ( serial uint32 ) * sunny . Device { start := time . Now ( ) for time . Since ( start ) < time . Second * 3 { if atomic . LoadUint32 ( & d . done ) != 0 { return d . get ( serial ) } if device := d . get ( serial ) ; device != nil { return device } time . Sleep ( time . Millisecond * 10 ) } return d . get ( serial ) }
deviceBySerial with the given serial number
deviceBySerial with the given serial number
// discover done -> return immediately regardless of result // device with serial found -> return