@@ -86,6 +86,7 @@ class MQTT:
8686 def __init__ (self , socket , broker , port = None , username = None ,
8787 password = None , esp = None , client_id = None , is_ssl = True , log = False ):
8888 """Initializes a MQTT client object.
89+
8990 :param socket: Socket object for provided network interface
9091 :param str broker: MQTT Broker URL or IP Address.
9192 :param int port: Optional port definition, defaults to 8883.
@@ -161,7 +162,8 @@ def __exit__(self, exception_type, exception_value, traceback):
161162 self .deinit ()
162163
163164 def deinit (self ):
164- """Disconnects the MQTT client from the broker.
165+ """De-initializes the MQTT client and disconnects from
166+ the mqtt broker.
165167 """
166168 self .disconnect ()
167169
@@ -290,7 +292,8 @@ def connect(self, clean_session=True):
290292 return result
291293
292294 def disconnect (self ):
293- """Disconnects from the broker.
295+ """Disconnects the MiniMQTT client from
296+ the MQTT broker.
294297 """
295298 self .is_connected ()
296299 if self ._logger is not None :
@@ -300,13 +303,14 @@ def disconnect(self):
300303 self ._logger .debug ('Closing socket' )
301304 self ._sock .close ()
302305 self ._is_connected = False
306+ self ._subscribed_topics = None
303307 if self .on_disconnect is not None :
304308 self .on_disconnect (self , self ._user_data , 0 )
305309
306310 def ping (self ):
307311 """Pings the MQTT Broker to confirm if the broker is alive or if
308312 there is an active network connection.
309- Raises a MMQTTException if the broker does not respond with a PINGRESP packet.
313+
310314 """
311315 self .is_connected ()
312316 if self ._logger is not None :
@@ -533,10 +537,9 @@ def unsubscribe(self, topic):
533537
534538 def loop_forever (self ):
535539 """Starts a blocking message loop. Use this
536- method if you want to run a program
537- forever. Network reconnection is handled within
538- this call. Your code will not execute anything
539- below this call.
540+ method if you want to run a program forever.
541+ Network reconnection is handled within this call.
542+ Your code will not execute anything below this call.
540543 """
541544 run = True
542545 while run :
@@ -604,7 +607,7 @@ def _recv_len(self):
604607 sh += 7
605608
606609 def _send_str (self , string ):
607- """Writes a provided string to a socket.
610+ """Packs and encodes a string to a socket.
608611 :param str string: String to write to the socket.
609612 """
610613 self ._sock .write (struct .pack ("!H" , len (string )))
@@ -619,7 +622,7 @@ def _check_topic(topic):
619622 :param str topic: Topic identifier
620623 """
621624 if topic is None :
622- raise MMQTTException ('Topic may not be Nonetype ' )
625+ raise MMQTTException ('Topic may not be NoneType ' )
623626 # [MQTT-4.7.3-1]
624627 elif not topic :
625628 raise MMQTTException ('Topic may not be empty.' )
0 commit comments