Created
October 5, 2019 06:33
-
-
Save avirup171/bba8c4741ec02959c5651a335913c89d 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 | |
def on_connect(client, userdata, flags, rc): | |
print(mqtt_topic) | |
client.subscribe(mqtt_topic,qos=1) | |
print("Connected") | |
def on_publish(client, userdata, mid): | |
print("mid: "+str(mid)) | |
def on_subscribe(client, userdata, mid, granted_qos): | |
print("Subscribed: "+str(mid)+" "+str(granted_qos)) | |
def init_mqtt(client,device_type,device_id,mqtt_host,mqtt_port,mqtt_topic): | |
jstemp['device_type']=device_type | |
jstemp['device_id']=device_id | |
client.on_connect = on_connect | |
client.on_publish = on_publish | |
client.on_subscribe=on_subscribe | |
client.connect(mqtt_host, int(mqtt_port)) | |
print(mqtt_host) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment