Skip to content

Commit 3c91544

Browse files
committed
ucloud.py: Add support for simple authentication.
1 parent 6e7342f commit 3c91544

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

aiotcloud/ucloud.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,16 @@ async def run(self, aiot):
159159

160160

161161
class AIOTClient:
162-
def __init__(self, device_id, ssl_params=None, server="mqtts-sa.iot.oniudra.cc", port=8883, keepalive=10):
162+
def __init__(
163+
self,
164+
device_id,
165+
username=None,
166+
password=None,
167+
ssl_params=None,
168+
server="mqtts-sa.iot.oniudra.cc",
169+
port=8883,
170+
keepalive=10
171+
):
163172
self.tasks = {}
164173
self.records = {}
165174
self.thing_id = None
@@ -168,7 +177,7 @@ def __init__(self, device_id, ssl_params=None, server="mqtts-sa.iot.oniudra.cc",
168177
self.last_ping = timestamp()
169178
self.device_topic = b"/a/d/" + device_id + b"/e/i"
170179
self.senmlpack = SenmlPack("urn:uuid:" + device_id.decode("utf-8"), self.senml_generic_callback)
171-
self.mqtt = MQTTClient(device_id, server, port, ssl_params, keepalive=keepalive, callback=self.mqtt_callback)
180+
self.mqtt = MQTTClient(device_id, server, port, ssl_params, username, password, keepalive, self.mqtt_callback)
172181
# Note: the following internal objects are initialized by the cloud.
173182
for name in ["thing_id", "tz_offset", "tz_dst_until"]:
174183
self.register(name, value=None)

0 commit comments

Comments
 (0)