diff --git a/adafruit_minimqtt/adafruit_minimqtt.py b/adafruit_minimqtt/adafruit_minimqtt.py index 5028dcd..5a21dee 100644 --- a/adafruit_minimqtt/adafruit_minimqtt.py +++ b/adafruit_minimqtt/adafruit_minimqtt.py @@ -393,12 +393,13 @@ def username_pw_set(self, username: str, password: Optional[str] = None) -> None if password is not None: self._password = password - def connect( + def connect( # noqa: PLR0913, too many arguments in function definition self, clean_session: bool = True, host: Optional[str] = None, port: Optional[int] = None, keep_alive: Optional[int] = None, + session_id: Optional[str] = None, ) -> int: """Initiates connection with the MQTT Broker. Will perform exponential back-off on connect failures. @@ -408,7 +409,8 @@ def connect( :param int port: Network port of the remote broker. :param int keep_alive: Maximum period allowed for communication within single connection attempt, in seconds. - + :param str session_id: unique session ID, + used for multiple simultaneous connections to the same host """ last_exception = None @@ -430,6 +432,7 @@ def connect( host=host, port=port, keep_alive=keep_alive, + session_id=session_id, ) self._reset_reconnect_backoff() return ret @@ -476,12 +479,13 @@ def _send_bytes( continue raise - def _connect( # noqa: PLR0912, PLR0915, Too many branches, Too many statements + def _connect( # noqa: PLR0912, PLR0913, PLR0915, Too many branches, Too many arguments, Too many statements self, clean_session: bool = True, host: Optional[str] = None, port: Optional[int] = None, keep_alive: Optional[int] = None, + session_id: Optional[str] = None, ) -> int: """Initiates connection with the MQTT Broker. @@ -489,6 +493,8 @@ def _connect( # noqa: PLR0912, PLR0915, Too many branches, Too many statements :param str host: Hostname or IP address of the remote broker. :param int port: Network port of the remote broker. :param int keep_alive: Maximum period allowed for communication, in seconds. + :param str session_id: unique session ID, + used for multiple simultaneous connections to the same host """ if host: @@ -511,6 +517,7 @@ def _connect( # noqa: PLR0912, PLR0915, Too many branches, Too many statements self.broker, self.port, proto="mqtt:", + session_id=session_id, timeout=self._socket_timeout, is_ssl=self._is_ssl, ssl_context=self._ssl_context,