@@ -124,7 +124,8 @@ class MQTT:
124
124
"""MQTT Client for CircuitPython.
125
125
126
126
:param str broker: MQTT Broker URL or IP Address.
127
- :param int port: Optional port definition, defaults to 8883.
127
+ :param int port: Optional port definition, defaults to MQTT_TLS_PORT if is_ssl is True,
128
+ MQTT_TCP_PORT otherwise.
128
129
:param str username: Username for broker authentication.
129
130
:param str password: Password for broker authentication.
130
131
:param network_manager: NetworkManager object, such as WiFiManager from ESPSPI_WiFiManager.
@@ -252,7 +253,7 @@ def _get_connect_socket(self, host, port, *, timeout=1):
252
253
if not isinstance (port , int ):
253
254
raise RuntimeError ("Port must be an integer" )
254
255
255
- if port == 8883 and not self ._ssl_context :
256
+ if port == MQTT_TLS_PORT and not self ._ssl_context :
256
257
raise RuntimeError (
257
258
"ssl_context must be set before using adafruit_mqtt for secure MQTT."
258
259
)
@@ -282,7 +283,7 @@ def _get_connect_socket(self, host, port, *, timeout=1):
282
283
continue
283
284
284
285
connect_host = addr_info [- 1 ][0 ]
285
- if port == 8883 :
286
+ if port == MQTT_TLS_PORT :
286
287
sock = self ._ssl_context .wrap_socket (sock , server_hostname = host )
287
288
connect_host = host
288
289
sock .settimeout (timeout )
0 commit comments