mirror of
https://gitlab.fdmci.hva.nl/technische-informatica-sm3/ti-projectten/rooziinuubii79.git
synced 2025-08-03 03:45:00 +00:00
reorginisatie
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
from flask import Flask
|
||||
from flask_mqtt import Mqtt
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
# MQTT configuratie
|
||||
app.config['MQTT_BROKER_URL'] = '145.109.226.204'
|
||||
app.config['MQTT_BROKER_PORT'] = 1883
|
||||
app.config['MQTT_USERNAME'] = 'ishak'
|
||||
app.config['MQTT_PASSWORD'] = 'kobuki'
|
||||
app.config['MQTT_KEEPALIVE'] = 60
|
||||
app.config['MQTT_TLS_ENABLED'] = False # TLS uitschakelen indien niet nodig
|
||||
|
||||
mqtt = Mqtt(app)
|
||||
|
||||
# Callback voor wanneer de verbinding tot stand komt
|
||||
@mqtt.on_connect()
|
||||
def handle_connect(client, userdata, flags, rc):
|
||||
print(f"Connected with result code {rc}")
|
||||
mqtt.subscribe("move")
|
||||
|
||||
# Callback voor wanneer een bericht binnenkomt
|
||||
@mqtt.on_message()
|
||||
def handle_mqtt_message(client, userdata, message):
|
||||
command = message.payload.decode()
|
||||
print(f"Received command: {command}")
|
||||
# Voeg hier je code toe om het commando uit te voeren
|
||||
|
||||
# Start de Flask applicatie
|
||||
if __name__ == '__main__':
|
||||
app.run(host='0.0.0.0', port=5000)
|
Reference in New Issue
Block a user