def connect(self, **options):
        if self.dev is None:
            raise IOError(errno.ENODEV, os.strerror(errno.ENODEV))
        
        log.debug("connect({0})".format(options))

        terminate = options.get('terminate', lambda: False)
        rdwr_options = options.get('rdwr')
        llcp_options = options.get('llcp')
        card_options = options.get('card')

        if isinstance(rdwr_options, dict):
            rdwr_options.setdefault('targets', [
                    TTA(br=106, cfg=None, uid=None), TTB(br=106),
                    TTF(br=424, idm=None, pmm=None, sys=None),
                    TTF(br=212, idm=None, pmm=None, sys=None)])
            if 'on-startup' in rdwr_options:
                targets = rdwr_options.get('targets')
                targets = rdwr_options['on-startup'](self, targets)
                if targets is None: rdwr_options = None
                else: rdwr_options['targets'] = targets
            if rdwr_options is not None:
                if not 'on-connect' in rdwr_options:
                    rdwr_options['on-connect'] = lambda tag: True
        elif rdwr_options is not None:
            raise TypeError("argument *rdrw* must be a dictionary")
        
        if isinstance(llcp_options, dict):
            llc = nfc.llcp.llc.LogicalLinkController(
                recv_miu=llcp_options.get('miu', 128),
                send_lto=llcp_options.get('lto', 100),
                send_agf=llcp_options.get('agf', True),
                symm_log=llcp_options.get('symm-log', True))
            if 'on-startup' in llcp_options:
                llc = llcp_options['on-startup'](self, llc)
                if llc is None: llcp_options = None
            if llcp_options is not None:
                if not 'on-connect' in llcp_options:
                    llcp_options['on-connect'] = lambda llc: True
        elif llcp_options is not None:
            raise TypeError("argument *llcp* must be a dictionary")

        if isinstance(card_options, dict):
            if 'on-startup' in card_options:
                targets = card_options.get('targets', [])
                targets = card_options['on-startup'](self, targets)
                if targets is None: card_options = None
                else: card_options['targets'] = targets
            if card_options is not None:
                if not card_options.get('targets'):
                    log.error("a target must be specified to connect as tag")
                    return None
                if not 'on-connect' in card_options:
                    card_options['on-connect'] = lambda tag, command: True
        elif card_options is not None:
            raise TypeError("argument *card* must be a dictionary")

        some_options = rdwr_options or llcp_options or card_options
        if not some_options:
            log.warning("no options left to connect")
            return None
        
        try:
            while not terminate():
                if llcp_options:
                    result = self._llcp_connect(llcp_options, llc, terminate)
                    if bool(result) is True: return result
                if rdwr_options:
                    result = self._rdwr_connect(rdwr_options, terminate)
                    if bool(result) is True: return result
                if card_options:
                    result = self._card_connect(card_options, terminate)
                    if bool(result) is True: return result
        except KeyboardInterrupt as error:
            log.debug(error)
            return False
        except IOError as error:
            log.error(error)
            return False
Connect with a contactless target or become connected as a
dataset/ETHPy150Open javgh/greenaddress-pos-tools/nfc/clf.py/ContactlessFrontend.connect