# Path: groundstation/gref.py
# def valid_path(path):
#     def __init__(self, store, channel, identifier):
#     def __str__(self):
#     def exists(self):
#     def tips(self):
#     def node_path(self):
#     def write_tip(self, tip, signature):
#     def tip_path(self, tip):
#     def __iter__(self):
#     def get_signature(self, tip):
#     def remove_tip(self, tip, silent=False):
#     def direct_parents(self, tip):
#     def parents(self, tips=None):
#     def marshall(self, crypto_adaptor=None):
#         def _process(node):
#     def as_dict(self):
# class Gref(object):
# 
# Path: groundstation/logger.py
#     LEVEL = getattr(logging, os.getenv("GROUNDSTATION_DEBUG"))
#     LEVEL = logging.DEBUG
# CONSOLE_FORMATTER = _get_formatter()
# CONSOLE_HANDLER = _get_console_handler()
# LOGGERS = {}  # Cache for instanciated loggers
# def fix_oid(oid):
# def _get_formatter():
# def _get_console_handler():
# def getLogger(name):  # Not threadsafe


import struct
import base64
import quietnet.listen as listen
from groundstation.gref import Gref, Tip
from groundstation import logger


log = logger.getLogger(__name__)

def reset_header():
    return 0, [0, 0], None

def reset_payload():
    return list()

class AudioReceiver(object):
    def __init__(self, tones, station):
        self.tones = tones
        self.station = station

    def start_listening(self):
        header_byte_count, header_bytes, header_length = reset_header()
        payload = reset_payload()
        listen.setup_processes(self.tones)

# Path: groundstation/gref.py
# def valid_path(path):
#     def __init__(self, store, channel, identifier):
#     def __str__(self):
#     def exists(self):
#     def tips(self):
#     def node_path(self):
#     def write_tip(self, tip, signature):
#     def tip_path(self, tip):
#     def __iter__(self):
#     def get_signature(self, tip):
#     def remove_tip(self, tip, silent=False):
#     def direct_parents(self, tip):
#     def parents(self, tips=None):
#     def marshall(self, crypto_adaptor=None):
#         def _process(node):
#     def as_dict(self):
# class Gref(object):
# 
# Path: groundstation/logger.py
#     LEVEL = getattr(logging, os.getenv("GROUNDSTATION_DEBUG"))
#     LEVEL = logging.DEBUG
# CONSOLE_FORMATTER = _get_formatter()
# CONSOLE_HANDLER = _get_console_handler()
# LOGGERS = {}  # Cache for instanciated loggers
# def fix_oid(oid):
# def _get_formatter():
# def _get_console_handler():
# def getLogger(name):  # Not threadsafe


# Path: groundstation/audio_receiver.py
import struct
import base64
import quietnet.listen as listen
from groundstation.gref import Gref, Tip
from groundstation import logger



log = logger.getLogger(__name__)

def reset_header():
    return 0, [0, 0], None

def reset_payload():
    return list()

class AudioReceiver(object):
    def __init__(self, tones, station):
        self.tones = tones
        self.station = station

    def start_listening(self):
        header_byte_count, header_bytes, header_length = reset_header()
        payload = reset_payload()
        listen.setup_processes(self.tones)

        for char in listen.start_analysing_stream():