This commit is contained in:
xyj 2024-01-25 16:39:49 +08:00
parent 51dc7f8d5d
commit f0c8bc256b
2 changed files with 3 additions and 2 deletions

View File

@ -30,6 +30,7 @@ class MQTTClient:
def on_connect(self, client, userdata, flags, rc): def on_connect(self, client, userdata, flags, rc):
if rc == 0: if rc == 0:
print("连接成功")
self.client.subscribe(self.topic) self.client.subscribe(self.topic)
client.publish(info_topic, payload=publish_payload(code=200, msg='成功订阅' + self.topic), client.publish(info_topic, payload=publish_payload(code=200, msg='成功订阅' + self.topic),
qos=0) qos=0)

View File

@ -3,5 +3,5 @@
# 订阅的控制主题,必须和系统设置的相同 # 订阅的控制主题,必须和系统设置的相同
subscribe_topic=xumu_d001 subscribe_topic=xumu_d001
info_topic=info_xumu_d001 info_topic=info_xumu_d001
username=lihai_lot_land1 username=lihai_lot_land_1
password=lihai_lot_land1 password=lihai_lot_land_1