changed port

This commit is contained in:
2024-12-02 12:58:14 +00:00
parent 1563528b67
commit dd2a1b56c4

View File

@@ -3,14 +3,16 @@ import paho.mqtt.client as mqtt
app = Flask(__name__) app = Flask(__name__)
kobuki_message = "empty"
def on_message(client, userdata, message): def on_message(client, userdata, message):
global kobuki_message #set scope for this variable global kobuki_message #set scope for this variable
kobuki_message = str(message.payload.decode("utf-8")) kobuki_message = str(message.payload.decode("utf-8"))
print(kobuki_message)
# Create an MQTT client instance # Create an MQTT client instance
mqtt_client = mqtt.Client() mqtt_client = mqtt.Client()
mqtt_client.username_pw_set("server", "serverwachtwoordofzo") mqtt_client.username_pw_set("server", "serverwachtwoordofzo")
mqtt_client.connect("localhost", 8080, 60) mqtt_client.connect("localhost", 1884, 60)
mqtt_client.loop_start() mqtt_client.loop_start()
mqtt_client.subscribe("kobuki/data") mqtt_client.subscribe("kobuki/data")
mqtt_client.on_message = on_message # this lines needs to be under the function definition otherwise it cant find which function it needs to use mqtt_client.on_message = on_message # this lines needs to be under the function definition otherwise it cant find which function it needs to use