'A single connection attempt, with esp32r0 workaround options'

def _connect_attempt(self, mode='default_reset', esp32r0_delay=False):

    last_error = None
    if (mode != 'no_reset'):
        self._port.setDTR(False)
        self._port.setRTS(True)
        time.sleep(0.1)
        if esp32r0_delay:
            time.sleep(1.2)
        self._port.setDTR(True)
        self._port.setRTS(False)
        if esp32r0_delay:
            time.sleep(0.4)
        time.sleep(0.05)
        self._port.setDTR(False)
    self._port.timeout = SYNC_TIMEOUT
    for _ in range(5):
        try:
            self.flush_input()
            self._port.flushOutput()
            self.sync()
            self._port.timeout = DEFAULT_TIMEOUT
            return None
        except FatalError as e:
            if esp32r0_delay:
                print('_', end='')
            else:
                print('.', end='')
            sys.stdout.flush()
            time.sleep(0.05)
            last_error = e
    return last_error
