Skip to content

Commit

Permalink
flush
Browse files Browse the repository at this point in the history
  • Loading branch information
8cH9azbsFifZ committed Nov 14, 2023
1 parent 9a7c229 commit 7eef56a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions udp2mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import config
import socket
import time
import sys

logging.basicConfig(level=logging.DEBUG, format='%(message)s', )

Expand All @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 7eef56a

Please sign in to comment.