aprs_status now returns actual state of transmision.

master
marcel 2 years ago
parent ebbaceaeea
commit f4eb9f81f7
  1. 3
      CHANGELOG.md
  2. 29
      aprs-mqtt-bridge.py

@ -11,3 +11,6 @@ All notable changes to this project will be documented in this file.
## [1.0.0] - 2023-01-13
First working version.
## [1.0.1] - 2023-01-14
Changed: aprs_status (published on the MQTT broker) now returns actual state of transmision (sending, retrying, send or failed) instead if just 'ready' and 'busy'.

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

Loading…
Cancel
Save