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 ## [1.0.0] - 2023-01-13
First working version. 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 #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'

Loading…
Cancel
Save