示例#1
0
def init_mqtt(name, broker_ip):
    '''Creates a MQTT client, set the message callback, subscribe to timestamp updates'''

    client = MQTTClient(name, broker_ip)  # create a new mqtt client
    client.keepalive = 60
    client.cb = cb
    client.connect()  # connect to the mqtt broker

    client.subscribe("esys/time")  # subscribe to timestamp topic

    return client