diff --git a/client.go b/client.go index 409bd26..524a6ee 100644 --- a/client.go +++ b/client.go @@ -19,7 +19,8 @@ type WPAConn interface { // Client represents a wireless client type Client struct { - conn WPAConn + conn WPAConn + ScanTimeout time.Duration } // NewClient will create a new client by connecting to the @@ -68,6 +69,12 @@ func (cl *Client) Status() (State, error) { // Scan will scan for networks and return the APs it finds func (cl *Client) Scan() (nets APs, err error) { + timeout := cl.ScanTimeout + + if timeout == 0 { + timeout = 2 * time.Second + } + err = cl.conn.SendCommandBool(CmdScan) if err != nil { return @@ -84,7 +91,7 @@ func (cl *Client) Scan() (nets APs, err error) { return case <-results.Next(): return - case <-time.NewTimer(time.Second * 2).C: + case <-time.NewTimer(cl.ScanTimeout).C: return } }