def cli(wio):
    '''
    Add a new device with USB connect.

    \b
    DOES:
        Guides you through setting up a new device, and getting it on your network.

    \b
    USE:
        wio setup
    '''
    token = wio.config.get("token", None)
    mserver_url = wio.config.get("mserver", None)
    msvr_ip = wio.config.get("mserver_ip", None)
    if not mserver_url or not token:
        click.echo(click.style('>> ', fg='red') + "Please login, use " +
            click.style("wio login", fg='green'))
        return
    msvr = urlparse(mserver_url).hostname
    xsvr = msvr
    xsvr_ip = msvr_ip
    board = ''

    click.secho('> ', fg='green', nl=False)
    click.echo("Setup is easy! Let's get started...\n")
    click.secho('! ', fg='green', nl=False)
    click.echo("PROTIP: " +
        click.style("Hold the ", fg='white') +
        click.style("Configure ", fg='green') +
        click.style("button ~4s into Configure Mode!", fg='white'))
    click.secho('! ', fg='green', nl=False)
    click.echo("PROTIP: " +
        click.style("Please make sure you are ", fg='white') +
        click.style("connected ", fg='green') +
        click.style("to the ", fg='white') +
        click.style("Server", fg='green'))
    click.echo()
    click.secho('? ', fg='green', nl=False)
    if not click.confirm(click.style('Would you like continue?', bold=True), default=True):
        click.echo('Quit setup!')
        return

    ### choice board
    while 1:
        for x in range(len(boards)):
            click.echo("%s.) %s" %(x, boards[x]))
        click.secho('? ', fg='green', nl=False)
        value = click.prompt(click.style('Please choice the board type', bold=True), type=int)
        if value >= 0 and value < len(boards):
            board = boards[value]
            break
        else:
            click.echo(click.style('>> ', fg='red') + "invalid input.")

    r = get_new(mserver_url, token, board)
    if not r:
        return
    node_key = r["node_key"]
    node_sn = r["node_sn"]

    ### list wio with serial
    if board == WIO_LINK_V1_0:
        try:
            ports = serial_list.serial_ports()
        except serial.SerialException as e:
            click.secho('>> ', fg='red', nl=False)
            click.echo(e)
            if e.errno == 13:
                click.echo("For more information, see https://github.com/Seeed-Studio/wio-cli#serial-port-permissions")
            return
        # click.echo(ports)
        count = len(ports)
        port = None
        if count == 0:
            pass #scan
        elif count == 1:
            port = ports[0]
        elif count >= 2:
            while 1:
                for x in range(len(ports)):
                    click.echo("%s.) %s" %(x, ports[x]))
                click.secho('? ', fg='green', nl=False)
                value = click.prompt(click.style('Please choice a device', bold=True), type=int)
                if value >= 0 and value < len(ports):
                    port = ports[value]
                    break
                else:
                    click.echo(click.style('>> ', fg='red') + "invalid input.")

        if not port:
            click.secho('> ', fg='green', nl=False)
            click.echo("No devices detected via USB.")
            # click.echo('>> change your network to wio_?')
            click.secho('? ', fg='green', nl=False)
            value = click.confirm(
                click.style('Would you like to enter Wi-Fi setup mode?', bold=True), default=True)

            #### udp setup
            r = upd_send(msvr, msvr_ip, xsvr, xsvr_ip, node_sn, node_key)
            if not r:
                return
            d_name = r['name']
            check_connect(mserver_url, token, node_sn, d_name)
            return
            
        click.echo(click.style('> ', fg='green') + "I have detected a " +
            click.style("Wio ", fg='green') + "connected via USB.")

        r = serial_send(msvr, msvr_ip, xsvr, xsvr_ip, node_sn, node_key, port)
        if not r:
            return
        d_name = r['name']
        check_connect(mserver_url, token, node_sn, d_name)
    elif board == WIO_NODE_V1_0:
        r = upd_send(msvr, msvr_ip, xsvr, xsvr_ip, node_sn, node_key)
        if not r:
            return
        d_name = r['name']
        check_connect(mserver_url, token, node_sn, d_name)