Skip to content

Commit 57cabc1

Browse files
authored
Merge pull request #5 from bcmi-labs/rename_package
all: Rename python package.
2 parents b0b7008 + b3bd566 commit 57cabc1

File tree

8 files changed

+48
-48
lines changed

8 files changed

+48
-48
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Python AIoT Cloud ☁️🐍☁️
2-
AIoT cloud implementation for Python and MicroPython.
1+
# Arduino IoT Cloud Micro/Python client ☁️🐍☁️
2+
Arduino IoT cloud client for Python and MicroPython.
33

44
## Testing on Linux
5-
If a crypto device is available, the following steps can be skipped, otherwise AIoT cloud can be tested on Linux using SoftHSM.
5+
If a crypto device is available, the following steps can be skipped, otherwise Arduino IoT cloud can be tested on Linux using SoftHSM.
66

77
#### Create softhsm token
88
Using the first available slot, in this case 0
@@ -43,12 +43,12 @@ softhsm2-util --delete-token --token "arduino"
4343
```
4444

4545
### Run the example script
46-
* Set `KEY_URI`, `CERT_URI`, `DEVICE_ID`, `THING_ID` in `aiotcloud_example.py`.
46+
* Set `KEY_URI`, `CERT_URI`, `DEVICE_ID`, `THING_ID` in `example.py`.
4747
* Provide a CA certificate in a `ca-root.pem` file or set `CA_PATH` to `None` if it's not used.
4848
* Override the default `pin` and provide `ENGINE_PATH` and `MODULE_PATH` in `ssl_params` if needed.
4949
* Clone this repository and run the following:
5050
```bash
51-
python aiotcloud_example.py
51+
python example.py
5252
```
5353

5454
## Testing on MicroPython
@@ -69,7 +69,7 @@ CERT_PATH = "cert.der"
6969
async def main():
7070
with open(KEY_PATH, "rb") as fin: key = fin.read()
7171
with open(CERT_PATH, "rb") as fin: cert = fin.read()
72-
aiot = AIOTCloud(device_id=DEVICE_ID, keepalive=10, ssl_params = {"key":key, "cert":cert})
72+
client = AIOTClient(device_id=DEVICE_ID, keepalive=10, ssl_params = {"key":key, "cert":cert})
7373
....
7474
```
7575

aiotcloud/__init__.py renamed to arduino_iot_cloud/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file is part of the Python AIoT Cloud.
1+
# This file is part of the Arduino IoT Cloud Python client.
22
#
33
# The MIT License (MIT)
44
#
File renamed without changes.

aiotcloud/ucloud.py renamed to arduino_iot_cloud/ucloud.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file is part of the Python AIoT Cloud.
1+
# This file is part of the Arduino IoT Cloud Python client.
22
#
33
# The MIT License (MIT)
44
#
@@ -25,7 +25,7 @@
2525
import time
2626
from kpn_senml import SenmlPack
2727
from kpn_senml import SenmlRecord
28-
from aiotcloud.umqtt import MQTTClient
28+
from arduino_iot_cloud.umqtt import MQTTClient
2929

3030
try:
3131
import logging
@@ -35,7 +35,7 @@
3535
except ImportError:
3636
import ulogging as logging
3737
import uasyncio as asyncio
38-
from aiotcloud import ntptime
38+
from arduino_iot_cloud import ntptime
3939
from uasyncio.core import CancelledError
4040

4141
# MicroPython doesn't have this exception
@@ -148,13 +148,13 @@ def senml_callback(self, record, **kwargs):
148148
self.updated = False
149149
self.on_write_scheduled = True
150150

151-
async def run(self, aiot):
151+
async def run(self, client):
152152
while True:
153153
if self.on_read is not None:
154-
self.value = self.on_read(aiot)
154+
self.value = self.on_read(client)
155155
if self.on_write is not None and self.on_write_scheduled:
156156
self.on_write_scheduled = False
157-
self.on_write(aiot, self if isinstance(self.value, dict) else self.value)
157+
self.on_write(client, self if isinstance(self.value, dict) else self.value)
158158
await asyncio.sleep(self.interval)
159159

160160

@@ -275,7 +275,7 @@ async def mqtt_task(self, interval=0.100):
275275
if record.updated:
276276
record.add_to_pack(self.senmlpack)
277277
if len(self.senmlpack._data):
278-
logging.debug("Pushing records to AIoT Cloud:")
278+
logging.debug("Pushing records to Arduino IoT cloud:")
279279
for record in self.senmlpack:
280280
logging.debug(f" ==> record: {record.name} value: {str(record.value)[:48]}...")
281281
self.mqtt.publish(self.topic_out, self.senmlpack.to_cbor(), qos=True)
@@ -287,9 +287,9 @@ async def mqtt_task(self, interval=0.100):
287287
await asyncio.sleep(interval)
288288

289289
async def run(self, user_main=None):
290-
logging.info("Connecting to AIoT cloud...")
290+
logging.info("Connecting to Arduino IoT cloud...")
291291
if not self.mqtt.connect():
292-
logging.error("Failed to connect AIoT cloud.")
292+
logging.error("Failed to connect Arduino IoT cloud.")
293293
return
294294

295295
self.mqtt.subscribe(self.device_topic)

aiotcloud/umqtt.py renamed to arduino_iot_cloud/umqtt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import socket
2929
import struct
3030
import logging
31-
from aiotcloud.ussl import wrap_socket
31+
from arduino_iot_cloud.ussl import wrap_socket
3232
except ImportError:
3333
import usocket as socket
3434
import ustruct as struct

aiotcloud/ussl.py renamed to arduino_iot_cloud/ussl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file is part of the Python AIoT Cloud.
1+
# This file is part of the Arduino IoT Cloud Python client.
22
#
33
# The MIT License (MIT)
44
#
@@ -22,7 +22,7 @@
2222
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
# THE SOFTWARE.
2424
#
25-
# ussl module with m2crypto backend for HSM support.
25+
# SSL module with m2crypto backend for HSM support.
2626

2727
from M2Crypto import Engine, m2, SSL
2828

aiotcloud_example.py renamed to example.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434
from time import strftime
3535
else:
3636
from ulogging.ustrftime import strftime
37-
from aiotcloud import AIOTClient
38-
from aiotcloud import Location
39-
from aiotcloud import Schedule
40-
from aiotcloud import ColoredLight
37+
from arduino_iot_cloud import AIOTClient
38+
from arduino_iot_cloud import Location
39+
from arduino_iot_cloud import Schedule
40+
from arduino_iot_cloud import ColoredLight
4141
from random import randint, choice
4242

4343
DEBUG_ENABLED = True
@@ -48,72 +48,72 @@
4848
DEVICE_ID = b"25deeda1-3fda-4d06-9c3c-dd31be382cd2"
4949

5050

51-
async def user_main(aiot):
51+
async def user_main(client):
5252
"""
5353
Add your code here.
5454
NOTE: To allow other tasks to run, this function must yield
5555
execution periodically by calling asyncio.sleep(seconds).
5656
"""
5757
while True:
5858
# The composite cloud object's fields can be assigned to individually:
59-
aiot["clight"].hue = randint(0, 100)
60-
aiot["clight"].bri = randint(0, 100)
61-
aiot["user"] = choice(["=^.. ^=", "=^ ..^="])
59+
client["clight"].hue = randint(0, 100)
60+
client["clight"].bri = randint(0, 100)
61+
client["user"] = choice(["=^.. ^=", "=^ ..^="])
6262
await asyncio.sleep(1.0)
6363

6464

65-
def on_switch_changed(aiot, value):
65+
def on_switch_changed(client, value):
6666
"""
6767
This is a write callback for the switch that toggles the LED variable. The LED
68-
variable can be accessed via the aiot cloud object passed in the first argument.
68+
variable can be accessed via the client object passed in the first argument.
6969
"""
7070
if value and not hasattr(on_switch_changed, "init"):
7171
on_switch_changed.init = True
7272
logging.info("Someone left the lights on!")
73-
aiot["led"] = value
73+
client["led"] = value
7474

7575

76-
def on_clight_changed(aiot, clight):
76+
def on_clight_changed(client, clight):
7777
logging.info(f"ColoredLight changed. Swi: {clight.swi} Bri: {clight.bri} Sat: {clight.sat} Hue: {clight.hue}")
7878

7979

8080
async def main():
81-
aiot = AIOTClient(
81+
client = AIOTClient(
8282
device_id=DEVICE_ID,
8383
ssl_params={"pin": "1234", "keyfile": KEY_URI, "certfile": CERT_URI, "ca_certs": CA_PATH},
8484
)
8585
# This cloud object is initialized with its last known value from the cloud.
86-
aiot.register("sw1", value=None, on_write=on_switch_changed, interval=0.250)
86+
client.register("sw1", value=None, on_write=on_switch_changed, interval=0.250)
8787

8888
# This cloud object is initialized with its last known value from the cloud,
8989
# and gets manually updated from the switch's on_write_change callback.
90-
aiot.register("led", value=None)
90+
client.register("led", value=None)
9191

9292
# This is a periodic cloud object that gets updated every 1 second.
93-
aiot.register("pot", value=None, on_read=lambda x: randint(0, 1024), interval=1.0)
93+
client.register("pot", value=None, on_read=lambda x: randint(0, 1024), interval=1.0)
9494

9595
# This is a periodic cloud object that gets updated every 1 second,
9696
# with the formatted current time value.
97-
aiot.register("clk", value=None, on_read=lambda x: strftime("%H:%M:%S", time.localtime()), interval=1.0)
97+
client.register("clk", value=None, on_read=lambda x: strftime("%H:%M:%S", time.localtime()), interval=1.0)
9898

9999
# This variable is an example for a composite object (a colored light object in this case),
100100
# which is composed of multiple variables. Once initialized, the object's variables can be
101-
# accessed as normal attributes, using dot notation (e.g: aiot["clight"].swi = False)
102-
aiot.register(ColoredLight("clight", swi=True, hue=22, sat=75, bri=10, on_write=on_clight_changed))
101+
# accessed as normal attributes, using dot notation (e.g: client["clight"].swi = False)
102+
client.register(ColoredLight("clight", swi=True, hue=22, sat=75, bri=10, on_write=on_clight_changed))
103103

104104
# This variable is an example for a composite object (a map location).
105-
aiot.register(Location("treasureisland", lat=31.264694, lon=29.979987))
105+
client.register(Location("treasureisland", lat=31.264694, lon=29.979987))
106106

107107
# This variable is updated manually from user_main.
108-
aiot.register("user", value="")
108+
client.register("user", value="")
109109

110110
# This object allows scheduling recurring events from the cloud UI. On activation of the event, if
111-
# on_active callback is provided, it gets called with the aiot object and the schedule object value.
112-
# The activation status of the object can also be polled using aiot["schedule"].active.
113-
aiot.register(Schedule("schedule", on_active=lambda aiot, value: logging.info(f"Schedule activated {value}!")))
111+
# on_active callback is provided, it gets called with the client object and the schedule object value.
112+
# The activation status of the object can also be polled using client["schedule"].active.
113+
client.register(Schedule("schedule", on_active=lambda client, value: logging.info(f"Schedule activated {value}!")))
114114

115-
# Start the AIoT client.
116-
await aiot.run(user_main)
115+
# Start the Arduino IoT cloud client.
116+
await client.run(user_main)
117117

118118

119119
if __name__ == "__main__":

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
long_description = fh.read()
55

66
setuptools.setup(
7-
name="aiotcloud",
7+
name="arduino_iot_cloud",
88
version="0.0.2",
9-
url="https://github.com/bcmi-labs/python-aiotcloud",
9+
url="https://github.com/bcmi-labs/arduino-iot-cloud",
1010
author="Ibrahim Abdelkader",
1111
author_email="[email protected]",
12-
description="Arduino IoT cloud Python module",
12+
description="Arduino IoT Cloud Python client",
1313
long_description=long_description,
1414
long_description_content_type="text/markdown",
1515
license="MIT",

0 commit comments

Comments
 (0)