Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
newr1/location_app/app/mqtt/__init__.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
18 lines (14 sloc)
463 Bytes
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
from flask_mqtt import Mqtt | |
from app.mqtt import mqtt_message_handler | |
def init_app(app): | |
""" | |
Function to connect the mqtt to the app and setup | |
on connect and on message callbacks | |
""" | |
mqtt = Mqtt(app) | |
@mqtt.on_connect() | |
def handle_connect(client, userdata, flags, rc): | |
mqtt.subscribe('owntracks/4009user/#') | |
@mqtt.on_message() | |
def handle_mqtt_message(client, userdata, msg): | |
mqtt_message_handler.getMsg(msg) |