diff --git a/data_upload.py b/data_upload.py index 05e9d88..2895826 100644 --- a/data_upload.py +++ b/data_upload.py @@ -5,6 +5,7 @@ import paho.mqtt.client as mqtt from device import device_name from tool import * + config = configparser.ConfigParser() config.read('/home/pi/lot_manager/conf/main/config.conf') times = 6 @@ -18,6 +19,7 @@ class DataUploadClient: self.username = username self.password = password 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_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) def start(self): - self.client.username_pw_set(self.username, self.password) self.client.connect(self.broker, self.port) @@ -53,4 +54,4 @@ if __name__ == '__main__': time.sleep(10) if times == 0: MQTT.on_disconnect(None, None, None) - times -= 1 \ No newline at end of file + times -= 1