import random
import paho.mqtt.client as mqtt
import paho.mqtt.publish as mqttpublish
import time, threading
HOST = "127.0.0.1" # "broker.emqx.io" #
PORT = 1883
TOPIC = "/test/sx789"
USER, PASSWORD = "", "" # "admin", "123456"
def connect_mqtt():
client_id = f"C{
int(time.time() * 1000)}_{
random.randint(0, 1000)}"
client = mqtt.Client(client_id)
if USER:
client.username_pw_set
paho-mqtt 通讯测试代码
最新推荐文章于 2023-08-01 14:59:02 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)