@@ -75,6 +75,7 @@ class MMQTTException(Exception):
7575# Legacy ESP32SPI Socket API
7676def set_socket (sock , iface = None ):
7777 """Legacy API for setting the socket and network interface.
78+
7879 :param sock: socket object.
7980 :param iface: internet interface object
8081
@@ -116,6 +117,7 @@ def wrap_socket(self, socket, server_hostname=None):
116117
117118class MQTT :
118119 """MQTT Client for CircuitPython.
120+
119121 :param str broker: MQTT Broker URL or IP Address.
120122 :param int port: Optional port definition, defaults to 8883.
121123 :param str username: Username for broker authentication.
@@ -209,6 +211,7 @@ def __init__(
209211 # pylint: disable=too-many-branches
210212 def _get_connect_socket (self , host , port , * , timeout = 1 ):
211213 """Obtains a new socket and connects to a broker.
214+
212215 :param str host: Desired broker hostname
213216 :param int port: Desired broker port
214217 :param int timeout: Desired socket timeout
@@ -409,6 +412,7 @@ def _handle_on_message(self, client, topic, message):
409412
410413 def username_pw_set (self , username , password = None ):
411414 """Set client's username and an optional password.
415+
412416 :param str username: Username to use with your MQTT broker.
413417 :param str password: Password to use with your MQTT broker.
414418
@@ -422,6 +426,7 @@ def username_pw_set(self, username, password=None):
422426 # pylint: disable=too-many-branches, too-many-statements, too-many-locals
423427 def connect (self , clean_session = True , host = None , port = None , keep_alive = None ):
424428 """Initiates connection with the MQTT Broker.
429+
425430 :param bool clean_session: Establishes a persistent session.
426431 :param str host: Hostname or IP address of the remote broker.
427432 :param int port: Network port of the remote broker.
@@ -563,6 +568,7 @@ def ping(self):
563568 # pylint: disable=too-many-branches, too-many-statements
564569 def publish (self , topic , msg , retain = False , qos = 0 ):
565570 """Publishes a message to a topic provided.
571+
566572 :param str topic: Unique topic identifier.
567573 :param str,int,float,bytes msg: Data to send to the broker.
568574 :param bool retain: Whether the message is saved by the broker.
@@ -706,6 +712,7 @@ def subscribe(self, topic, qos=0):
706712
707713 def unsubscribe (self , topic ):
708714 """Unsubscribes from a MQTT topic.
715+
709716 :param str,list topic: Unique MQTT topic identifier string or list.
710717
711718 """
@@ -754,6 +761,7 @@ def unsubscribe(self, topic):
754761
755762 def reconnect (self , resub_topics = True ):
756763 """Attempts to reconnect to the MQTT broker.
764+
757765 :param bool resub_topics: Resubscribe to previously subscribed topics.
758766
759767 """
@@ -777,6 +785,7 @@ def loop(self, timeout=1):
777785 """Non-blocking message loop. Use this method to
778786 check incoming subscription messages.
779787 Returns response codes of any messages received.
788+
780789 :param int timeout: Socket timeout, in seconds.
781790
782791 """
@@ -884,6 +893,7 @@ def _sock_exact_recv(self, bufsize):
884893 terms of the minimum size of the buffer, which could be 1 byte. This is a
885894 wrapper for socket recv() to ensure that no less than the expected number of
886895 bytes is returned or trigger a timeout exception.
896+
887897 :param int bufsize: number of bytes to receive
888898
889899 """
@@ -920,6 +930,7 @@ def _sock_exact_recv(self, bufsize):
920930
921931 def _send_str (self , string ):
922932 """Encodes a string and sends it to a socket.
933+
923934 :param str string: String to write to the socket.
924935
925936 """
@@ -933,6 +944,7 @@ def _send_str(self, string):
933944 @staticmethod
934945 def _valid_topic (topic ):
935946 """Validates if topic provided is proper MQTT topic format.
947+
936948 :param str topic: Topic identifier
937949
938950 """
@@ -948,6 +960,7 @@ def _valid_topic(topic):
948960 @staticmethod
949961 def _valid_qos (qos_level ):
950962 """Validates if the QoS level is supported by this library
963+
951964 :param int qos_level: Desired QoS level.
952965
953966 """
@@ -968,6 +981,7 @@ def is_connected(self):
968981 # Logging
969982 def enable_logger (self , logger , log_level = 20 ):
970983 """Enables library logging provided a logger object.
984+
971985 :param logger: A python logger pacakge.
972986 :param log_level: Numeric value of a logging level, defaults to INFO.
973987
0 commit comments