# Path: src/apex/util.py
# def echo_colorized_frame(frame, port_name, direction_in):
#     formatted_aprs = '>'.join([click.style(frame['source'], fg='green'), click.style(frame['destination'], fg='blue')])
#     paths = []
#     for path in frame['path']:
#         paths.append(click.style(path, fg='cyan'))
#     paths = ','.join(paths)
#     if frame['path']:
#         formatted_aprs = ','.join([formatted_aprs, paths])
#     formatted_aprs += ':'
#     formatted_aprs += frame['text']
#     if direction_in:
#         click.echo(click.style(port_name + ' << ', fg='magenta') + formatted_aprs)
#     else:
#         click.echo(click.style(port_name + ' >> ', fg='magenta', bold=True, blink=True) + formatted_aprs)
# 
# Path: src/apex/util.py
# def echo_colorized_warning(text):
#     click.echo(click.style('Warning: ', fg='yellow') + click.style(text))


import threading
import time
import cachetools
from apex.aprs import util as aprs_util
from .util import echo_colorized_frame
from .util import echo_colorized_warning
        self.packet_layer = packet_layer
        self.to_packet_layer = cachetools.TTLCache(10, 30)
        self.current_index = 0
        self.from_packet_layer = cachetools.TTLCache(10, 30)
        self.connect_thread = None
        self.lock = threading.Lock()
        self.running = False
        self.reconnect_wait_time = self.STARTING_WAIT_TIME
        self.last_connect_attempt = None
        self.connect_args = None
        self.connect_kwargs = None
        self.connected = False

    def __increment_wait_time(self):
        self.reconnect_wait_time *= self.WAIT_TIME_MULTIPLIER
        if self.reconnect_wait_time > self.MAX_WAIT_TIME:
            self.reconnect_wait_time = self.MAX_WAIT_TIME

    def __reset_wait_time(self):
        self.reconnect_wait_time = self.STARTING_WAIT_TIME

    def __run(self):
        while self.running:
            if not self.connected:
                if not self.last_connect_attempt or time.time() - self.last_connect_attempt > self.reconnect_wait_time:
                    try:
                        self.last_connect_attempt = time.time()
                        self.packet_layer.connect(*self.connect_args, **self.connect_kwargs)
                        self.connected = True
                    except IOError:

# Path: src/apex/util.py
# def echo_colorized_frame(frame, port_name, direction_in):
#     formatted_aprs = '>'.join([click.style(frame['source'], fg='green'), click.style(frame['destination'], fg='blue')])
#     paths = []
#     for path in frame['path']:
#         paths.append(click.style(path, fg='cyan'))
#     paths = ','.join(paths)
#     if frame['path']:
#         formatted_aprs = ','.join([formatted_aprs, paths])
#     formatted_aprs += ':'
#     formatted_aprs += frame['text']
#     if direction_in:
#         click.echo(click.style(port_name + ' << ', fg='magenta') + formatted_aprs)
#     else:
#         click.echo(click.style(port_name + ' >> ', fg='magenta', bold=True, blink=True) + formatted_aprs)
# 
# Path: src/apex/util.py
# def echo_colorized_warning(text):
#     click.echo(click.style('Warning: ', fg='yellow') + click.style(text))


# Path: src/apex/buffers.py
import threading
import time
import cachetools
from apex.aprs import util as aprs_util
from .util import echo_colorized_frame
from .util import echo_colorized_warning

        self.packet_layer = packet_layer
        self.to_packet_layer = cachetools.TTLCache(10, 30)
        self.current_index = 0
        self.from_packet_layer = cachetools.TTLCache(10, 30)
        self.connect_thread = None
        self.lock = threading.Lock()
        self.running = False
        self.reconnect_wait_time = self.STARTING_WAIT_TIME
        self.last_connect_attempt = None
        self.connect_args = None
        self.connect_kwargs = None
        self.connected = False

    def __increment_wait_time(self):
        self.reconnect_wait_time *= self.WAIT_TIME_MULTIPLIER
        if self.reconnect_wait_time > self.MAX_WAIT_TIME:
            self.reconnect_wait_time = self.MAX_WAIT_TIME

    def __reset_wait_time(self):
        self.reconnect_wait_time = self.STARTING_WAIT_TIME

    def __run(self):
        while self.running:
            if not self.connected:
                if not self.last_connect_attempt or time.time() - self.last_connect_attempt > self.reconnect_wait_time:
                    try:
                        self.last_connect_attempt = time.time()
                        self.packet_layer.connect(*self.connect_args, **self.connect_kwargs)
                        self.connected = True
                    except IOError:

                        echo_colorized_warning('Could not connect, will reattempt.')