Skip to content

Commit 68b530b

Browse files
committed
misc: Rename AIOTClient and AIOTObject classes.
1 parent 5830b63 commit 68b530b

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def on_switch_changed(client, value):
1414
# 1. Create a client object, which is used to connect to the IoT cloud and link local
1515
# objects to cloud objects. Note a username and password can be used for basic authentication
1616
# on both CPython and MicroPython. For more advanced authentication methods, please see the examples.
17-
client = AIOTClient(device_id=b"DEVICE_ID", username=b"DEVICE_ID", password=b"SECRET_KEY")
17+
client = ArduinoCloud(device_id=b"DEVICE_ID", username=b"DEVICE_ID", password=b"SECRET_KEY")
1818

1919
# 2. Register cloud objects.
2020
# Note: The following objects must be created first in the dashboard and linked to the device.

examples/example.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import time
55
import logging
66
from time import strftime
7-
from arduino_iot_cloud import AIOTClient
7+
from arduino_iot_cloud import ArduinoCloud
88
from arduino_iot_cloud import Location
99
from arduino_iot_cloud import Schedule
1010
from arduino_iot_cloud import ColoredLight
@@ -59,8 +59,8 @@ def user_task(client):
5959
# To use a secure element, set the token's "pin" and URI in "keyfile" and "certfile", and
6060
# the CA certificate (if any) in "ssl_params". Alternatively, a username and password can
6161
# be used to authenticate, for example:
62-
# client = AIOTClient(device_id=b"DEVICE_ID", username=b"DEVICE_ID", password=b"SECRET_KEY")
63-
client = AIOTClient(
62+
# client = ArduinoCloud(device_id=b"DEVICE_ID", username=b"DEVICE_ID", password=b"SECRET_KEY")
63+
client = ArduinoCloud(
6464
device_id=DEVICE_ID,
6565
ssl_params={
6666
"pin": "1234",

examples/micropython.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import network
77
import logging
88
from time import strftime
9-
from arduino_iot_cloud import AIOTClient
9+
from arduino_iot_cloud import ArduinoCloud
1010
from arduino_iot_cloud import Location
1111
from arduino_iot_cloud import Schedule
1212
from arduino_iot_cloud import ColoredLight
@@ -68,8 +68,8 @@ def wifi_connect():
6868
# Create a client object to connect to the Arduino IoT cloud.
6969
# For MicroPython, the key and cert files must be stored in DER format on the filesystem.
7070
# Alternatively, a username and password can be used to authenticate:
71-
# client = AIOTClient(device_id=b"DEVICE_ID", username=b"DEVICE_ID", password=b"SECRET_KEY")
72-
client = AIOTClient(
71+
# client = ArduinoCloud(device_id=b"DEVICE_ID", username=b"DEVICE_ID", password=b"SECRET_KEY")
72+
client = ArduinoCloud(
7373
device_id=DEVICE_ID,
7474
ssl_params={
7575
"keyfile": KEY_PATH, "certfile": CERT_PATH, "cadata": CADATA, "cert_reqs": ussl.CERT_REQUIRED

src/arduino_iot_cloud/__init__.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# License, v. 2.0. If a copy of the MPL was not distributed with this
55
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
66

7-
from .ucloud import AIOTClient # noqa
8-
from .ucloud import AIOTObject
7+
from .ucloud import ArduinoCloud # noqa
8+
from .ucloud import ArduinoCloudObject
99
from .ucloud import timestamp
1010

1111
try:
@@ -36,27 +36,27 @@
3636
)
3737

3838

39-
class Location(AIOTObject):
39+
class Location(ArduinoCloudObject):
4040
def __init__(self, name, **kwargs):
4141
super().__init__(name, keys={"lat", "lon"}, **kwargs)
4242

4343

44-
class Color(AIOTObject):
44+
class Color(ArduinoCloudObject):
4545
def __init__(self, name, **kwargs):
4646
super().__init__(name, keys={"hue", "sat", "bri"}, **kwargs)
4747

4848

49-
class ColoredLight(AIOTObject):
49+
class ColoredLight(ArduinoCloudObject):
5050
def __init__(self, name, **kwargs):
5151
super().__init__(name, keys={"swi", "hue", "sat", "bri"}, **kwargs)
5252

5353

54-
class DimmedLight(AIOTObject):
54+
class DimmedLight(ArduinoCloudObject):
5555
def __init__(self, name, **kwargs):
5656
super().__init__(name, keys={"swi", "bri"}, **kwargs)
5757

5858

59-
class Schedule(AIOTObject):
59+
class Schedule(ArduinoCloudObject):
6060
def __init__(self, name, **kwargs):
6161
kwargs.update({("runnable", True)}) # Force task creation.
6262
self.on_active = kwargs.pop("on_active", None)
@@ -78,7 +78,7 @@ async def run(self, aiot):
7878
await asyncio.sleep(self.interval)
7979

8080

81-
class Task(AIOTObject):
81+
class Task(ArduinoCloudObject):
8282
def __init__(self, name, **kwargs):
8383
kwargs.update({("runnable", True)}) # Force task creation.
8484
self.on_run = kwargs.pop("on_run", None)

src/arduino_iot_cloud/ucloud.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def timestamp():
3737
return int(time.time())
3838

3939

40-
class AIOTObject(SenmlRecord):
40+
class ArduinoCloudObject(SenmlRecord):
4141
def __init__(self, name, **kwargs):
4242
self.on_read = kwargs.pop("on_read", None)
4343
self.on_write = kwargs.pop("on_write", None)
@@ -46,7 +46,7 @@ def __init__(self, name, **kwargs):
4646
value = kwargs.pop("value", None)
4747
if keys := kwargs.pop("keys", {}):
4848
value = { # Create a complex object (with sub-records).
49-
k: AIOTObject(f"{name}:{k}", value=v, callback=self.senml_callback)
49+
k: ArduinoCloudObject(f"{name}:{k}", value=v, callback=self.senml_callback)
5050
for (k, v) in {k: kwargs.pop(k, None) for k in keys}.items()
5151
}
5252
self._updated = False
@@ -157,7 +157,7 @@ async def run(self, client):
157157
await asyncio.sleep(self.interval)
158158

159159

160-
class AIOTClient:
160+
class ArduinoCloud:
161161
def __init__(
162162
self,
163163
device_id,
@@ -256,9 +256,9 @@ def register(self, aiotobj, coro=None, **kwargs):
256256
if isinstance(aiotobj, str):
257257
if kwargs.get("value", None) is None and kwargs.get("on_read", None) is not None:
258258
kwargs["value"] = kwargs.get("on_read")(self)
259-
aiotobj = AIOTObject(aiotobj, **kwargs)
259+
aiotobj = ArduinoCloudObject(aiotobj, **kwargs)
260260

261-
# Register the AIOTObject
261+
# Register the ArduinoCloudObject
262262
self.records[aiotobj.name] = aiotobj
263263

264264
# Create a task for this object if it has any callbacks.

0 commit comments

Comments
 (0)