@ -41,6 +41,7 @@ class mqtt_settings:
#retry
#retry
#topics
#topics
state = ' ready '
state = ' ready '
aprs_state = ' idle '
pass
pass
mqtt = mqtt_settings ( )
mqtt = mqtt_settings ( )
@ -282,6 +283,7 @@ def process_message(data, payload):
#os.system(aprs.beacon_program_with_arguments)
#os.system(aprs.beacon_program_with_arguments)
print ( ' APRS message ' + aprs . message + ' send to ' + aprs . call_of_wait_for_ack + ' . ' )
print ( ' APRS message ' + aprs . message + ' send to ' + aprs . call_of_wait_for_ack + ' . ' )
mqtt . state = ' busy '
mqtt . state = ' busy '
mqtt . aprs_state = ' sending message '
aprs . request_to_send = 1 ;
aprs . request_to_send = 1 ;
else :
else :
mqtt . state = ' busy '
mqtt . state = ' busy '
@ -299,9 +301,10 @@ def run():
client . loop_start ( )
client . loop_start ( )
# Send ready to MQTT broker to indicate we are meaning business
# Send ready to MQTT broker to indicate we are meaning business
topic = mqtt . topic_root + ' /aprs_status '
mqtt . aprs_state = ' ready '
publish ( client , topic , ' ready ' )
#topic = mqtt.topic_root + '/aprs_status'
mqtt . state = ' ready '
#publish(client,topic,'ready')
mqtt . state = ' busy '
aprs . time_out_timer = time . time ( )
aprs . time_out_timer = time . time ( )
while True :
while True :
@ -347,9 +350,10 @@ def run():
aprs . wait_for_ack = 0
aprs . wait_for_ack = 0
aprs . busy = 0
aprs . busy = 0
aprs . retry_counter = 0
aprs . retry_counter = 0
topic = mqtt . topic_root + ' /aprs_status '
mqtt . aprs_state = ' message send '
publish ( client , topic , ' ready ' )
#topic = mqtt.topic_root + '/aprs_status'
mqtt . state = ' ready '
#publish(client,topic,mqtt.aprs_state)
mqtt . state = ' busy '
# Time out waiting for acknowledge
# Time out waiting for acknowledge
@ -362,6 +366,8 @@ def run():
aprs . request_to_send = 1 ;
aprs . request_to_send = 1 ;
#os.system(aprs.beacon_program_with_arguments)
#os.system(aprs.beacon_program_with_arguments)
print ( ' Retry: APRS ' + aprs . message + ' message send to ' + aprs . call_of_wait_for_ack + ' . ' )
print ( ' Retry: APRS ' + aprs . message + ' message send to ' + aprs . call_of_wait_for_ack + ' . ' )
mqtt . aprs_state = ' sending message (retry ' + str ( aprs . retry_counter ) + ' ) '
mqtt . state = ' busy '
else :
else :
# Give up
# Give up
print ( ' No acknowledge received from ' + aprs . call_of_wait_for_ack + ' . Giving up. ' )
print ( ' No acknowledge received from ' + aprs . call_of_wait_for_ack + ' . Giving up. ' )
@ -369,13 +375,14 @@ def run():
aprs . wait_for_ack = 0
aprs . wait_for_ack = 0
aprs . busy = 0
aprs . busy = 0
aprs . retry_counter = 0
aprs . retry_counter = 0
topic = mqtt . topic_root + ' /aprs_status '
mqtt . aprs_state = ' sending message failed '
publish ( client , topic , ' ready ' )
#topic = mqtt.topic_root + '/aprs_status'
mqtt . state = ' ready '
#publish(client,topic,mqtt.aprs_state)
# If APRS system is still waiting for acknowledge, keep on waiting and send an MQTT update
mqtt . state = ' busy '
# If APRS system is transmitting, retrying and still waiting for acknowledge, keep on waiting and send an MQTT update
if mqtt . state == ' busy ' :
if mqtt . state == ' busy ' :
topic = mqtt . topic_root + ' /aprs_status '
topic = mqtt . topic_root + ' /aprs_status '
publish ( client , topic , ' busy ' )
publish ( client , topic , mqtt . aprs_state )
mqtt . state = ' ready '
mqtt . state = ' ready '