Alpha version of ModBus-MQTT and MQTT-APRS software.

This commit is contained in:
marcel
2025-08-14 15:39:50 +02:00
parent f5a6937786
commit ce1b59fb6f
6 changed files with 71 additions and 72 deletions

View File

@@ -6,6 +6,7 @@ global:
#program-log: /home/marcel/rs458.log # All program output will be written to this file (0 = do not log to file)
mqtt-server: mqtt.meezenest.nl
mqtt-port: 1883
telemetry-interval: 10 # number of seconds between transmissions
# APRS settings
aprs:
@@ -14,12 +15,10 @@ aprs:
to_call: PE1RXF-1 # Call of the receiver
destination: APZMDM # APRS destination
digipath: 0 # Digipeater path for weather reports (0 = no path)
interval: 30
# - port: ax1 # Linux AX.25 port to which APRS weather report is sent
# call: PE1RXF-13 # Call from which transmissions are made (can be a different call from the call assigned to the AX.25 port)
# destination: APZMDM # APRS destination
# digipath: WIDE2-1 # Digipeater path for weather reports (0 = no path)
# interval: 30
# Define the MQTT data to transmit over AX25. The order of the items is the order the data is combined to the telemetry string.
mqtt:

View File

@@ -58,6 +58,7 @@ class config_reader:
tmp = self.config_file_settings['global']['program-log']
tmp = self.config_file_settings['global']['mqtt-server']
tmp = self.config_file_settings['global']['mqtt-port']
tmp = self.config_file_settings['global']['telemetry-interval']
except:
print ("Error in the global section of the configuration file.")
return 0
@@ -72,7 +73,6 @@ class config_reader:
tmp = entry['to_call']
tmp = entry['destination']
tmp = entry['digipath']
tmp = entry['interval']
except:
print ("Error in the aprs section of the configuration file.")
return 0

View File

@@ -43,7 +43,7 @@ class MqttHandler:
self.config = config
# Define list with length equal to the number of subscriptions defined in the config file
self.number_of_mqtt_subscriptions = len(config['mqtt']['subscribe'])
self.aprs_telemetry_data = ['0.0']*self.number_of_mqtt_subscriptions
self.aprs_telemetry_data = [bytes(b'0.0')]*self.number_of_mqtt_subscriptions
def process_message(self, client, userdata, message):
@@ -191,16 +191,13 @@ def send_data_to_aprs(weather_data, configuration):
logging.error("Failed to send data to APRS radio.")
logging.error(f"Command returned: {e}")
def main():
Configuration, MqttClient, mqtt_handler = setup()
LoopCounter = 0
Configuration, MqttClient, mqtt_handler = setup()
LoopCounter = 0
while (1):
time.sleep(3) # Sleep for 3 seconds
# Send APRS telemetry every 10 cycles = every 10 minutes
LoopCounter = LoopCounter + 1
if LoopCounter >= 1:
while (1):
time.sleep(Configuration.config_file_settings['global']['telemetry-interval']) # Sleep for number of seconds set in config.yaml
# Send data to LoRa radio via external program (/usr/sbin/beacon). Make sure we use all radios defined in the configuration file.
for entry in Configuration.config_file_settings['aprs']:
@@ -209,7 +206,6 @@ while (1):
# We cannot send multiple APRS messages in a short period of time, so we wait 3 deconds between messages.
time.sleep(3)
LoopCounter = 0
if __name__ == '__main__':
main()