--- a/MqttMonitor/MqttClient.py Sun Jul 18 18:30:15 2021 +0200 +++ b/MqttMonitor/MqttClient.py Sun Jul 18 19:32:16 2021 +0200 @@ -148,22 +148,22 @@ self.stopLoop() self.connectTimeout.emit() - def reinitialise(self, clientId="", cleanSession=True, userdata=None): - """ - Public method to reinitialize the client with given data. - - @param clientId ID to be used for the client - @type str - @param cleanSession flag indicating to start a clean session - @type bool - @param userdata user data - @type any - """ - self.__mqttClient.reinitialise( - client_id=clientId, clean_session=cleanSession, userdata=userdata) - - self.__initCallbacks() - +## def reinitialise(self, clientId="", cleanSession=True, userdata=None): +## """ +## Public method to reinitialize the client with given data. +## +## @param clientId ID to be used for the client +## @type str +## @param cleanSession flag indicating to start a clean session +## @type bool +## @param userdata user data +## @type any +## """ +## self.__mqttClient.reinitialise( +## client_id=clientId, clean_session=cleanSession, userdata=userdata) +## +## self.__initCallbacks() +## def setConnectionTimeout(self, timeout): """ Public method to set the connection timeout value. @@ -295,8 +295,8 @@ trying to connect with the given parameters @type bool """ - if reinit: - self.reinitialise() +## if reinit: +## self.reinitialise() # TODO: MQTTv5: use 'clean_start' set to the remembered 'cleanSession' # TODO: MQTTv5: add support for MQTTv5 properties self.__mqttClient.connect_async( @@ -331,14 +331,9 @@ parametersDict = self.defaultConnectionOptions() parametersDict.update(options) - # step 1: reinitialize to set the client ID and clean session flag - self.reinitialise( - clientId=parametersDict["ClientId"], - cleanSession=parametersDict["CleanSession"] - ) self.setConnectionTimeout(parametersDict["ConnectionTimeout"]) - # step 2: set username and password + # step 1: set username and password if parametersDict["Username"]: if parametersDict["Password"]: self.setUserCredentials( @@ -347,7 +342,7 @@ else: self.setUserCredentials(parametersDict["Username"]) - # step 3: set last will data + # step 2: set last will data if parametersDict["WillTopic"]: if parametersDict["WillMessage"]: willMessage = parametersDict["WillMessage"] @@ -359,7 +354,7 @@ parametersDict["WillQos"], parametersDict["WillRetain"]) - # step 4: set TLS parameters + # step 3: set TLS parameters if parametersDict["TlsEnable"]: if ( parametersDict["TlsCaCert"] and @@ -376,10 +371,10 @@ # use default TLS configuration self.setTLS() - # step 5: connect to server + # step 4: connect to server self.connectToServer(host, port=port, - keepalive=parametersDict["Keepalive"], - reinit=False) + keepalive=parametersDict["Keepalive"]) +## reinit=False) else: keepalive = self.defaultConnectionOptions["Keepalive"] self.connectToServer(host, port=port, keepalive=keepalive,