MQTT[1]消息队列遥测传输(Message Queuing Telemetry Transport)
subscribe to a topic and publish messages on that topic.
The core of the client library is the client class which provides all of the functions to publish messages and subscribe to topics.
Main Client Methods
The paho mqtt client class has several methods.The main ones are:
- connect() and disconnect()
- subscribe() and unsubscribe()
- publish()
Each of these methods is associated with a callback.
1. create a client instance
client = paho.mqtt.client(client_name)
2. connect to a broker or server
Before you can publish messages or subscribe to topics you need to establish a connection to a broker.
client.conect(host_name)
3. subscribe to a topic
4. publish messages
publish(topic, payload=None, qos=0, retain=False)
MQTT meeting:
1. ask for the host address, port, so that you can connect to their broker/server.
2. what should I subscribe to?
https://www.zhihu.com/question/19801131
来源:https://www.cnblogs.com/dulun/p/12258275.html