func (d *smaDiscoverer) run() {
	devices := make(chan *sunny.Device)

	go func() {
		for device := range devices {
			d.mux.Lock()
			d.devices[device.SerialNumber()] = device
			d.mux.Unlock()
		}
	}()

	// discover devices and wait for results
	ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
	d.conn.DiscoverDevices(ctx, devices, "")
	cancel()
	close(devices)

	// mark discover as done
	atomic.AddUint32(&d.done, 1)
}
// run discover and store found devices
run discover and store found devices
// run discover and store found devices
func (d *smaDiscoverer) run() {
	devices := make(chan *sunny.Device)
	go func() {
		for device := range devices {
			d.mux.Lock()
			d.devices[device.SerialNumber()] = device
			d.mux.Unlock()
		}
	}()
	ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
	d.conn.DiscoverDevices(ctx, devices, "")
	cancel()
	close(devices)
	atomic.AddUint32(&d.done, 1)
}
func ( d * smaDiscoverer ) run ( ) { devices := make ( chan * sunny . Device ) go func ( ) { for device := range devices { d . mux . Lock ( ) d . devices [ device . SerialNumber ( ) ] = device d . mux . Unlock ( ) } } ( ) ctx , cancel := context . WithTimeout ( context . Background ( ) , 3 * time . Second ) d . conn . DiscoverDevices ( ctx , devices , " " ) cancel ( ) close ( devices ) atomic . AddUint32 ( & d . done , 1 ) }
run discover and store found devices
run discover and store found devices
// discover devices and wait for results // mark discover as done