|
33 | 33 | from asyncio import CancelledError
|
34 | 34 | from asyncio import InvalidStateError
|
35 | 35 | except ImportError:
|
| 36 | + import ntptime |
36 | 37 | import ulogging as logging
|
37 | 38 | import uasyncio as asyncio
|
38 |
| - from arduino_iot_cloud import ntptime |
39 | 39 | from uasyncio.core import CancelledError
|
40 | 40 |
|
41 | 41 | # MicroPython doesn't have this exception
|
42 | 42 | class InvalidStateError(Exception):
|
43 | 43 | pass
|
44 | 44 |
|
45 | 45 | # Server/port for basic auth.
|
46 |
| -_DEFAULT_UP_SERVER = ("mqtts-up.iot.arduino.cc", 8884) |
| 46 | +_DEFAULT_SERVER = "iot.arduino.cc" |
47 | 47 |
|
48 |
| -# Default server/port for key/cert auth. |
49 |
| -_DEFAULT_SA_SERVER = ("mqtts-sa.iot.arduino.cc", 8883) |
| 48 | +# Default port for cert based auth and basic auth. |
| 49 | +_DEFAULT_PORT = (8883, 8884) |
50 | 50 |
|
51 | 51 |
|
52 | 52 | def timestamp():
|
@@ -198,16 +198,17 @@ def __init__(
|
198 | 198 | if "certfile" in ssl_params and "der" in ssl_params["certfile"]:
|
199 | 199 | with open(ssl_params.pop("certfile"), "rb") as f:
|
200 | 200 | ssl_params["cert"] = f.read()
|
| 201 | + |
201 | 202 | if "ca_certs" in ssl_params and "der" in ssl_params["ca_certs"]:
|
202 | 203 | with open(ssl_params.pop("ca_certs"), "rb") as f:
|
203 | 204 | ssl_params["cadata"] = f.read()
|
204 | 205 |
|
205 | 206 | # If no server/port were passed in args, set the default server/port
|
206 | 207 | # based on authentication type.
|
207 | 208 | if server is None:
|
208 |
| - server = _DEFAULT_SA_SERVER[0] if password is None else _DEFAULT_UP_SERVER[0] |
| 209 | + server = _DEFAULT_SERVER |
209 | 210 | if port is None:
|
210 |
| - port = _DEFAULT_SA_SERVER[1] if password is None else _DEFAULT_UP_SERVER[1] |
| 211 | + port = _DEFAULT_PORT[0] if password is None else _DEFAULT_PORT[1] |
211 | 212 |
|
212 | 213 | # Create MQTT client.
|
213 | 214 | self.mqtt = MQTTClient(
|
|
0 commit comments