This commit is contained in:
xyj 2023-12-11 14:45:46 +08:00
parent bdb16c98b8
commit f85258431e
1 changed files with 3 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import paho.mqtt.client as mqtt
from device import device_name from device import device_name
from tool import * from tool import *
config = configparser.ConfigParser() config = configparser.ConfigParser()
config.read('/home/pi/lot_manager/conf/main/config.conf') config.read('/home/pi/lot_manager/conf/main/config.conf')
times = 6 times = 6
@ -18,6 +19,7 @@ class DataUploadClient:
self.username = username self.username = username
self.password = password self.password = password
self.client = mqtt.Client(client_id=device_name) self.client = mqtt.Client(client_id=device_name)
self.client.username_pw_set(self.username, self.password)
self.client.on_connect = self.on_connect self.client.on_connect = self.on_connect
self.client.on_disconnect = self.on_disconnect self.client.on_disconnect = self.on_disconnect
@ -32,7 +34,6 @@ class DataUploadClient:
subprocess.Popen(['/usr/bin/bash /home/pi/lot_manager/bash/stop_data_upload.sh'], shell=True) subprocess.Popen(['/usr/bin/bash /home/pi/lot_manager/bash/stop_data_upload.sh'], shell=True)
def start(self): def start(self):
self.client.username_pw_set(self.username, self.password)
self.client.connect(self.broker, self.port) self.client.connect(self.broker, self.port)