Created
October 5, 2019 07:09
-
-
Save avirup171/899a3c53f9db1161b4b5faecb33d55b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mqtt.on_connect() | |
def handle_connect(client, userdata, flags, rc): | |
mqtt.subscribe(data['mqtt_topic']) | |
@mqtt.on_message() | |
def handle_mqtt_message(client, userdata, message): | |
data = dict( | |
topic=message.topic, | |
payload=message.payload.decode() | |
) | |
print(data) | |
socketio.emit('mqtt_message', data=data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment