From 7eef56a16a803a651b45948bb278340ac3e150b6 Mon Sep 17 00:00:00 2001
From: 8cH9azbsFifZ <g@ziegenhain.com>
Date: Tue, 14 Nov 2023 19:32:54 +0100
Subject: [PATCH] flush

---
 udp2mqtt.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/udp2mqtt.py b/udp2mqtt.py
index 249a345..33ce797 100644
--- a/udp2mqtt.py
+++ b/udp2mqtt.py
@@ -6,6 +6,7 @@
 import config
 import socket
 import time
+import sys
 
 logging.basicConfig(level=logging.DEBUG, format='%(message)s', )
 
@@ -20,30 +21,36 @@
 
 def on_connect(mqttc, obj, flags, rc):
     print("rc: " + str(rc))
+    sys.stdout.flush() # TODO: use logging
 
 def on_message(mqttc, obj, msg):
     print(msg.topic + " " + str(msg.qos) + " " + str(msg.payload))
 
     r = mopp.decode_message(msg.payload)
     print (r)
+    sys.stdout.flush() # TODO: use logging
 
     client_socket.send(msg.payload)
 
 def on_publish(mqttc, obj, mid):
     print("mid: " + str(mid))
+    sys.stdout.flush() # TODO: use logging
     pass
 
 def on_subscribe(mqttc, obj, mid, granted_qos):
     print("Subscribed: " + str(mid) + " " + str(granted_qos))
+    sys.stdout.flush() # TODO: use logging
 
 def on_log(mqttc, obj, level, string):
     print(string)
+    sys.stdout.flush() # TODO: use logging
 
 
 
 
 # MQTT
 print ("Connecting to MQTT")
+sys.stdout.flush() # TODO: use logging
 mqttc = paho.Client()
 mqttc.on_message = on_message
 mqttc.on_connect = on_connect
@@ -64,6 +71,7 @@ def on_log(mqttc, obj, level, string):
     client = addr[0] + ':' + str(addr[1])
     r = mopp.decode_message(data_bytes)
     print (r)
+    sys.stdout.flush() # TODO: use logging
     
     # Beep if message received
     if not "Keepalive" in r: