This commit is contained in:
xyj 2023-12-12 10:09:40 +08:00
parent 86497a23ab
commit 8a3a5885f8
4 changed files with 18 additions and 13 deletions

View File

@ -0,0 +1,3 @@
#!/bin/bash
rm /home/pi/device_name
cp ../conf/tmp/device_name /home/pi

View File

@ -1,47 +1,48 @@
# 设备1
[lot_mqtt_device1]
# 编号
[lihai_lot_walnutpi_dev_1]
# 订阅的控制主题,必须和系统设置的相同
subscribe_topic=lot_mqtt_device1
subscribe_topic=lihai_lot_walnutpi_dev_1
# 发布消息的主题
publish_topic=device1
username=demo
password=123456
####################################
[lot_mqtt_device2]
[lihai_lot_walnutpi_dev_2]
# 订阅的控制主题,必须和系统设置的相同
subscribe_topic=lot_mqtt_device2
subscribe_topic=lihai_lot_walnutpi_dev_2
# 发布消息的主题
publish_topic=device2
username=demo
password=123456
####################################
[lot_mqtt_device3]
[lihai_lot_walnutpi_dev_3]
# 订阅的控制主题,必须和系统设置的相同
subscribe_topic=lot_mqtt_device3
subscribe_topic=lihai_lot_walnutpi_dev_3
# 发布消息的主题
publish_topic=device3
username=demo
password=123456
####################################
[lot_mqtt_device4]
[lihai_lot_walnutpi_dev_4]
# 订阅的控制主题,必须和系统设置的相同
subscribe_topic=lot_mqtt_device4
subscribe_topic=lihai_lot_walnutpi_dev_4
# 发布消息的主题
publish_topic=device4
username=demo
password=123456
####################################
[lot_mqtt_device5]
[lihai_lot_walnutpi_dev_5]
# 订阅的控制主题,必须和系统设置的相同
subscribe_topic=lot_mqtt_device5
subscribe_topic=lihai_lot_walnutpi_dev_5
# 发布消息的主题
publish_topic=device5
username=demo
password=123456
####################################
[lot_mqtt_device6]
[lihai_lot_walnutpi_dev_6]
# 订阅的控制主题,必须和系统设置的相同
subscribe_topic=lot_mqtt_device6
subscribe_topic=lihai_lot_walnutpi_dev_6
# 发布消息的主题
publish_topic=device6
username=demo

1
conf/tmp/device_name Normal file
View File

@ -0,0 +1 @@
lihai_lot_walnutpi_dev_1

View File

@ -233,7 +233,7 @@ def on_connect(client, userdata, flags, rc):
if __name__ == '__main__':
print(broker, port, subscribe_topic, publish_topic, username, password)
# print(broker, port, subscribe_topic, publish_topic, username, password)
# 千万不要指定client_id 不然死翘翘!!!
client = mqtt.Client()
client.username_pw_set(username, password)