Skip to content

Instantly share code, notes, and snippets.

@amanjeetsingh150
Created September 23, 2018 14:24
Show Gist options
  • Save amanjeetsingh150/3f08e93430a324f68810a10cb228d814 to your computer and use it in GitHub Desktop.
Save amanjeetsingh150/3f08e93430a324f68810a10cb228d814 to your computer and use it in GitHub Desktop.
mqttc=mqtt.Client("DriverClient",clean_session=False)
#YOUR MQTT SERVER USERNAME PASSWORD HERE
mqttc.username_pw_set("username","password")
#YOUR MQTT SERVER URI AND PORT HERE
mqttc.connect("SERVER URI","PORT",60)
#Publishing the location update in interval of 1 second.
for latLng in latLngList:
s=str(latLng)
b = bytearray()
b.extend(s)
print latLng
mqttc.publish("location/track", b, qos=0)
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment