@@ -193,19 +193,23 @@ def __exit__(self, exception_type, exception_value, traceback):
193193 self .deinit ()
194194
195195 def deinit (self ):
196- """De-initializes the MQTT client and disconnects from
197- the mqtt broker.
198-
196+ """De-initializes the MQTT client and disconnects from the mqtt broker.
199197 """
200198 self .disconnect ()
201199
202200 def will_set (self , topic = None , payload = None , qos = 0 , retain = False ):
203201 """Sets the last will and testament properties. MUST be called before `connect()`.
204202
205203 :param str topic: MQTT Broker topic.
206- :param str payload: Last will disconnection payload.
207- :param int qos: Quality of Service level.
208- :param bool retain: Specifies if the payload is to be retained when it is published.
204+ :param int,float,str payload: Last will disconnection payload.
205+ payloads of type int & float are converted to a string.
206+ :param int qos: Quality of Service level, defaults to
207+ zero. Conventional options are ``0`` (send at least once), ``1``
208+ (send at most once), or ``2`` (send exactly once).
209+
210+ .. note:: Only options ``1`` or ``0`` are QoS levels supported by this library.
211+ :param bool retain: Specifies if the payload is to be retained when
212+ it is published.
209213 """
210214 if self .logger is not None :
211215 self .logger .debug ("Setting last will properties" )
@@ -226,7 +230,7 @@ def will_set(self, topic=None, payload=None, qos=0, retain=False):
226230 def add_topic_callback (self , mqtt_topic , callback_method ):
227231 """Registers a callback_method for a specific MQTT topic.
228232
229- :param str mqtt_topic: MQTT topic.
233+ :param str mqtt_topic: MQTT topic identifier .
230234 :param str callback_method: Name of callback method.
231235 """
232236 if mqtt_topic is None or callback_method is None :
@@ -236,7 +240,7 @@ def add_topic_callback(self, mqtt_topic, callback_method):
236240 def remove_topic_callback (self , mqtt_topic ):
237241 """Removes a registered callback method.
238242
239- :param str mqtt_topic: MQTT topic.
243+ :param str mqtt_topic: MQTT topic identifier string .
240244 """
241245 if mqtt_topic is None :
242246 raise ValueError ("MQTT Topic must be defined." )
@@ -249,8 +253,7 @@ def remove_topic_callback(self, mqtt_topic):
249253 def on_message (self ):
250254 """Called when a new message has been received on a subscribed topic.
251255
252- Expected method signature is:
253- on_message(client, topic, message)
256+ Expected method signature is ``on_message(client, topic, message)``
254257 """
255258 return self ._on_message
256259
@@ -300,8 +303,7 @@ def connect(self, clean_session=True):
300303 raise MMQTTException ("Invalid broker address defined." , e )
301304
302305 # Fixed Header
303- fixed_header = bytearray ()
304- fixed_header .append (0x10 )
306+ fixed_header = bytearray ([0x10 ])
305307
306308 # NOTE: Variable header is
307309 # MQTT_HDR_CONNECT = bytearray(b"\x04MQTT\x04\x02\0\0")
@@ -413,11 +415,13 @@ def publish(self, topic, msg, retain=False, qos=0):
413415 """Publishes a message to a topic provided.
414416
415417 :param str topic: Unique topic identifier.
416- :param str msg: Data to send to the broker.
417- :param int msg: Data to send to the broker.
418- :param float msg: Data to send to the broker.
418+ :param str,int,float msg: Data to send to the broker.
419419 :param bool retain: Whether the message is saved by the broker.
420- :param int qos: Quality of Service level for the message.
420+ :param int qos: Quality of Service level for the message, defaults to
421+ zero. Conventional options are ``0`` (send at least once), ``1``
422+ (send at most once), or ``2`` (send exactly once).
423+
424+ .. note:: Only options ``1`` or ``0`` are QoS levels supported by this library.
421425
422426 Example of sending an integer, 3, to the broker on topic 'piVal'.
423427
@@ -514,10 +518,16 @@ def subscribe(self, topic, qos=0):
514518 """Subscribes to a topic on the MQTT Broker.
515519 This method can subscribe to one topics or multiple topics.
516520
517- :param str topic: Unique MQTT topic identifier.
518- :param int qos: Quality of Service level for the topic, defaults to zero.
519- :param tuple topic: Tuple containing topic identifier strings and qos level integers.
520- :param list topic: List of tuples containing topic identifier strings and qos.
521+ :param str,tuple,list topic: Unique MQTT topic identifier string. If
522+ this is a `tuple`, then the tuple should contain topic identifier
523+ string and qos level integer. If this is a `list`, then each list
524+ element should be a tuple containing a topic identifier string and
525+ qos level integer.
526+ :param int qos: Quality of Service level for the topic, defaults to
527+ zero. Conventional options are ``0`` (send at least once), ``1``
528+ (send at most once), or ``2`` (send exactly once).
529+
530+ .. note:: Only options ``1`` or ``0`` are QoS levels supported by this library.
521531
522532 Example of subscribing a topic string.
523533
@@ -593,8 +603,9 @@ def subscribe(self, topic, qos=0):
593603 def unsubscribe (self , topic ):
594604 """Unsubscribes from a MQTT topic.
595605
596- :param str topic: Unique MQTT topic identifier.
597- :param list topic: List of tuples containing topic identifier strings.
606+ :param str,list topic: Unique MQTT topic identifier string or a list
607+ of tuples, where each tuple contains an MQTT topic identier
608+ string.
598609
599610 Example of unsubscribing from a topic string.
600611
@@ -804,7 +815,7 @@ def _set_interface(self):
804815
805816 def is_connected (self ):
806817 """Returns MQTT client session status as True if connected, raises
807- a MMQTTException if False.
818+ a ` MMQTTException` if ` False` .
808819 """
809820 if self ._sock is None or self ._is_connected is False :
810821 raise MMQTTException ("MiniMQTT is not connected." )
@@ -837,6 +848,8 @@ def set_logger_level(self, log_level):
837848 """Sets the level of the logger, if defined during init.
838849
839850 :param str log_level: Level of logging to output to the REPL.
851+ Acceptable options are ``DEBUG``, ``INFO``, ``WARNING``, or
852+ ``ERROR``.
840853 """
841854 if self .logger is None :
842855 raise MMQTTException (
0 commit comments