Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions pyUC.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
transmit_enable = True # Make sure that UC is half duplex
useQRZ = True
level_every_sample = 1
NAT_ping_timer = 0

listbox = None # tk object (talkgroup)
transmitButton = None # tk object
Expand Down Expand Up @@ -240,7 +241,10 @@ def showQRZImage( msg, in_label ):
current_name.set(msg[3])

###################################################################################

def ping_thread():
while done == False:
sleep(20.0)
sendUSRPCommand(bytes("PING", 'ASCII'), USRP_TYPE_PING)

###################################################################################
# Log output to console
Expand Down Expand Up @@ -687,7 +691,8 @@ def listAudioDevices(want_input):
numdevices = info.get('deviceCount')
for i in range(0, numdevices):
is_input = p.get_device_info_by_host_api_device_index(0, i).get('maxInputChannels') > 0
if (is_input and want_input) or (want_input == False and is_input == False):
is_output = p.get_device_info_by_host_api_device_index(0, i).get('maxOutputChannels') > 0
if (is_input and want_input) or (want_input == False and is_output):
devices.append(p.get_device_info_by_host_api_device_index(0, i).get('name'))
logging.info("Device id {} - {}".format(i, p.get_device_info_by_host_api_device_index(0, i).get('name')))
return devices
Expand Down Expand Up @@ -943,6 +948,8 @@ def disconnect():
###################################################################################
def popup_toast(msg):
global toast_frame
if toast_frame != None: # If a toast is still on the screen, kill it first
toast_frame.destroy()
toast_frame = Toplevel()
toast_frame.wm_title(msg[1])
toast_frame.overrideredirect(1)
Expand All @@ -956,13 +963,16 @@ def popup_toast(msg):
toast_frame.after(2000, toast_fade_away)

def toast_fade_away():
alpha = toast_frame.attributes("-alpha")
if alpha > 0:
alpha -= .1
toast_frame.attributes("-alpha", alpha)
toast_frame.after(100, toast_fade_away)
else:
toast_frame.destroy()
global toast_frame
if toast_frame != None:
alpha = toast_frame.attributes("-alpha")
if alpha > 0:
alpha -= .1
toast_frame.attributes("-alpha", alpha)
toast_frame.after(100, toast_fade_away)
else:
toast_frame.destroy()
toast_frame = None

def process_queue():
try:
Expand Down Expand Up @@ -1559,6 +1569,7 @@ def popupFocusOut(self,event=None):
asl_mode = makeTkVar(IntVar, config.get('DEFAULTS', "aslMode").split(None)[0])
useQRZ = bool(readValue(config, 'DEFAULTS', 'useQRZ', True, int))
level_every_sample = int(readValue(config, 'DEFAULTS', 'levelEverySample', 2, int))
NAT_ping_timer = int(readValue(config, 'DEFAULTS', 'pingTimer', 0, int))

in_index = readValue(config, 'DEFAULTS', 'in_index', None, int)
out_index = readValue(config, 'DEFAULTS', 'out_index', None, int)
Expand Down Expand Up @@ -1611,6 +1622,8 @@ def popupFocusOut(self,event=None):
if in_index != -1: # Do not launch the TX thread if the user wants RX only access
_thread.start_new_thread( txAudioStream, () )
_thread.start_new_thread( html_thread, () ) # Start up the HTML thread for background image loads
if NAT_ping_timer > 0:
_thread.start_new_thread( ping_thread, () )

disconnect() # Start out in the disconnected state
start() # Begin the handshake with AB (register)
Expand Down