Skip to content

Commit 0cd68cc

Browse files
committed
fixed docstring formatting, fixed Logger type for Sphinx, Sphinx version to latest
1 parent eedefb9 commit 0cd68cc

File tree

10 files changed

+59
-16
lines changed

10 files changed

+59
-16
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ jobs:
4242
# (e.g. - apt-get: gettext, etc; pip: circuitpython-build-tools, requirements.txt; etc.)
4343
run: |
4444
source actions-ci/install.sh
45-
- name: Pip install Sphinx 4.3.2, pre-commit
45+
- name: Pip install Sphinx, pre-commit
4646
run: |
47-
pip install --force-reinstall Sphinx==4.3.2 sphinx-rtd-theme pre-commit
47+
pip install --force-reinstall Sphinx sphinx-rtd-theme pre-commit
4848
- name: Library version
4949
run: git describe --dirty --always --tags
5050
- name: Pre-commit hooks

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ To create an Azure IoT Hub instance or an Azure IoT Central app, you will need a
6363

6464
- If you are not a student, head to `aka.ms/FreeAz <https://aka.ms/FreeAz>`_ and sign up to get $200 of credit for 30 days, as well as free tiers of a load of services. You will need a credit card for validation only, your card will not be charged.
6565

66-
ESP32SPI Networking
67-
===================
66+
ESP32 AirLift Networking
67+
========================
6868

6969
To use this library, you will need to create an ESP32_SPI WifiManager, connected to WiFi. You will also need to set the current time, as this is used to generate time-based authentication keys. One way to do this is via the `Adafruit CircuitPython NTP <https://github.com/adafruit/Adafruit_CircuitPython_NTP>`_ library with the following code:
7070

@@ -79,7 +79,7 @@ To use this library, you will need to create an ESP32_SPI WifiManager, connected
7979
8080
Native Networking
8181
=================
82-
To use this library, with boards that have native networking support, you need to be connected to a network. You will also need to set the current time, as this is used to generate time-based authentication keys. One way to do this is by using the `Adafruit IoT Time Service <https://io.adafruit.com/api/docs/#time>`_ via the `Adafruit Requests library <https://github.com/adafruit/Adafruit_CircuitPython_Requests>`_ with the following code:
82+
To use this library, with boards that have native networking support, you need to be connected to a network. You will also need to set the current time, as this is used to generate time-based authentication keys. One way to do this is by using the `Adafruit IoT Time API <https://io.adafruit.com/api/docs/#time>`_ via the `Adafruit Requests library <https://github.com/adafruit/Adafruit_CircuitPython_Requests>`_ with the following code:
8383

8484
.. code-block:: python
8585

adafruit_azureiot/device_registration.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ def __init__(
5353
logger: Logger = None,
5454
):
5555
"""Creates an instance of the device registration service
56+
5657
:param socket: The network socket
5758
:param str id_scope: The ID scope of the device to register
5859
:param str device_id: The device ID of the device to register
@@ -163,6 +164,7 @@ def register_device(self, expiry: int) -> str:
163164
"""
164165
Registers the device with the IoT Central device registration service.
165166
Returns the hostname of the IoT hub to use over MQTT
167+
166168
:param int expiry: The expiry time for the registration
167169
:returns: The underlying IoT Hub that this device should connect to
168170
:rtype: str

adafruit_azureiot/iot_error.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class IoTError(Exception):
2020

2121
def __init__(self, message: str):
2222
"""Create the IoT Error
23+
2324
:param str message: The error message
2425
"""
2526
super().__init__(message)

adafruit_azureiot/iot_mqtt.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import adafruit_minimqtt.adafruit_minimqtt as MQTT
2121
import adafruit_logging as logging
22+
from adafruit_logging import Logger
2223

2324
from .iot_error import IoTError
2425
from .keys import compute_derived_symmetric_key
@@ -31,6 +32,7 @@ class IoTResponse:
3132

3233
def __init__(self, code: int, message: str):
3334
"""Creates an IoT Response object
35+
3436
:param int code: The HTTP response code for this method call, for example 200 if the method was handled successfully
3537
:param str message: The HTTP response message for this method call
3638
"""
@@ -43,17 +45,20 @@ class IoTMQTTCallback:
4345

4446
def message_sent(self, data: str) -> None:
4547
"""Called when a message is sent to the cloud
48+
4649
:param str data: The data send with the message
4750
"""
4851

4952
def connection_status_change(self, connected: bool) -> None:
5053
"""Called when the connection status changes
54+
5155
:param bool connected: True if the device is connected, otherwise false
5256
"""
5357

5458
# pylint: disable=W0613, R0201
5559
def direct_method_invoked(self, method_name: str, payload: str) -> IoTResponse:
5660
"""Called when a direct method is invoked
61+
5762
:param str method_name: The name of the method that was invoked
5863
:param str payload: The payload with the message
5964
:returns: A response with a code and status to show if the method was correctly handled
@@ -64,6 +69,7 @@ def direct_method_invoked(self, method_name: str, payload: str) -> IoTResponse:
6469
# pylint: disable=C0103
6570
def cloud_to_device_message_received(self, body: str, properties: dict) -> None:
6671
"""Called when a cloud to device message is received
72+
6773
:param str body: The body of the message
6874
:param dict properties: The propreties sent with the mesage
6975
"""
@@ -72,6 +78,7 @@ def device_twin_desired_updated(
7278
self, desired_property_name: str, desired_property_value, desired_version: int
7379
) -> None:
7480
"""Called when the device twin desired properties are updated
81+
7582
:param str desired_property_name: The name of the desired property that was updated
7683
:param desired_property_value: The value of the desired property that was updated
7784
:param int desired_version: The version of the desired property that was updated
@@ -84,6 +91,7 @@ def device_twin_reported_updated(
8491
reported_version: int,
8592
) -> None:
8693
"""Called when the device twin reported values are updated
94+
8795
:param str reported_property_name: The name of the reported property that was updated
8896
:param reported_property_value: The value of the reported property that was updated
8997
:param int reported_version: The version of the reported property that was updated
@@ -319,17 +327,18 @@ def __init__(
319327
device_id: str,
320328
device_sas_key: str,
321329
token_expires: int = 21600,
322-
logger: logging = None,
330+
logger: Logger = None,
323331
):
324332
"""Create the Azure IoT MQTT client
333+
325334
:param IoTMQTTCallback callback: A callback class
326335
:param socket: The socket to communicate over
327336
:param iface: The network interface to communicate over
328337
:param str hostname: The hostname of the MQTT broker to connect to, get this by registering the device
329338
:param str device_id: The device ID of the device to register
330339
:param str device_sas_key: The primary or secondary key of the device to register
331340
:param int token_expires: The number of seconds till the token expires, defaults to 6 hours
332-
:param adafruit_logging logger: The logger
341+
:param Logger logger: The logger
333342
"""
334343
self._callback = callback
335344
self._socket = socket
@@ -372,6 +381,7 @@ def _subscribe_to_twin_topics(self):
372381

373382
def connect(self) -> bool:
374383
"""Connects to the MQTT broker
384+
375385
:returns: True if the connection is successful, otherwise False
376386
:rtype: bool
377387
"""
@@ -426,6 +436,7 @@ def reconnect(self) -> None:
426436

427437
def is_connected(self) -> bool:
428438
"""Gets if there is an open connection to the MQTT broker
439+
429440
:returns: True if there is an open connection, False if not
430441
:rtype: bool
431442
"""
@@ -443,6 +454,7 @@ def send_device_to_cloud_message(
443454
self, message, system_properties: dict = None
444455
) -> None:
445456
"""Send a device to cloud message from this device to Azure IoT Hub
457+
446458
:param message: The message data as a JSON string or a dictionary
447459
:param system_properties: System properties to send with the message
448460
:raises: ValueError if the message is not a string or dictionary
@@ -472,6 +484,7 @@ def send_device_to_cloud_message(
472484

473485
def send_twin_patch(self, patch) -> None:
474486
"""Send a patch for the reported properties of the device twin
487+
475488
:param patch: The patch as a JSON string or a dictionary
476489
:raises: IoTError if the data is not a string or dictionary
477490
:raises RuntimeError: if the internet connection is not responding or is unable to connect

adafruit_azureiot/iotcentral_device.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import json
1616
import time
1717
import adafruit_logging as logging
18+
from adafruit_logging import Logger
1819
from .device_registration import DeviceRegistration
1920
from .iot_error import IoTError
2021
from .iot_mqtt import IoTMQTT, IoTMQTTCallback, IoTResponse
@@ -25,6 +26,7 @@ class IoTCentralDevice(IoTMQTTCallback):
2526

2627
def connection_status_change(self, connected: bool) -> None:
2728
"""Called when the connection status changes
29+
2830
:param bool connected: True if the device is connected, otherwise false
2931
"""
3032
if self.on_connection_status_changed is not None:
@@ -34,6 +36,7 @@ def connection_status_change(self, connected: bool) -> None:
3436
# pylint: disable=W0613, R0201
3537
def direct_method_called(self, method_name: str, payload: str) -> IoTResponse:
3638
"""Called when a direct method is invoked
39+
3740
:param str method_name: The name of the method that was invoked
3841
:param str payload: The payload with the message
3942
:returns: A response with a code and status to show if the method was correctly handled
@@ -49,6 +52,7 @@ def device_twin_desired_updated(
4952
self, desired_property_name: str, desired_property_value, desired_version: int
5053
) -> None:
5154
"""Called when the device twin desired properties are updated
55+
5256
:param str desired_property_name: The name of the desired property that was updated
5357
:param desired_property_value: The value of the desired property that was updated
5458
:param int desired_version: The version of the desired property that was updated
@@ -69,6 +73,7 @@ def device_twin_reported_updated(
6973
reported_version: int,
7074
) -> None:
7175
"""Called when the device twin reported values are updated
76+
7277
:param str reported_property_name: The name of the reported property that was updated
7378
:param reported_property_value: The value of the reported property that was updated
7479
:param int reported_version: The version of the reported property that was updated
@@ -88,16 +93,17 @@ def __init__(
8893
device_id: str,
8994
device_sas_key: str,
9095
token_expires: int = 21600,
91-
logger: logging = None,
96+
logger: Logger = None,
9297
):
9398
"""Create the Azure IoT Central device client
99+
94100
:param socket: The network socket
95101
:param iface: The network interface
96102
:param str id_scope: The ID Scope of the device in IoT Central
97103
:param str device_id: The device ID of the device in IoT Central
98104
:param str device_sas_key: The primary or secondary key of the device in IoT Central
99105
:param int token_expires: The number of seconds till the token expires, defaults to 6 hours
100-
:param adafruit_logging logger: The logger
106+
:param Logger logger: The logger
101107
"""
102108
self._socket = socket
103109
self._iface = iface
@@ -132,6 +138,7 @@ def property_changed(_property_name: str, property_value, version: int) -> None
132138

133139
def connect(self) -> None:
134140
"""Connects to Azure IoT Central
141+
135142
:raises DeviceRegistrationError: if the device cannot be registered successfully
136143
:raises RuntimeError: if the internet connection is not responding or is unable to connect
137144
"""
@@ -166,6 +173,7 @@ def connect(self) -> None:
166173

167174
def disconnect(self) -> None:
168175
"""Disconnects from the MQTT broker
176+
169177
:raises IoTError: if there is no open connection to the MQTT broker
170178
"""
171179
if self._mqtt is None:
@@ -182,13 +190,15 @@ def reconnect(self) -> None:
182190

183191
def is_connected(self) -> bool:
184192
"""Gets if there is an open connection to the MQTT broker
193+
185194
:returns: True if there is an open connection, False if not
186195
:rtype: bool
187196
"""
188197
return self._mqtt.is_connected() if self._mqtt is not None else False
189198

190199
def loop(self) -> None:
191200
"""Listens for MQTT messages
201+
192202
:raises IoTError: if there is no open connection to the MQTT broker
193203
"""
194204
if self._mqtt is None:
@@ -198,6 +208,7 @@ def loop(self) -> None:
198208

199209
def send_property(self, property_name: str, value) -> None:
200210
"""Updates the value of a writable property
211+
201212
:param str property_name: The name of the property to write to
202213
:param value: The value to set on the property
203214
:raises IoTError: if there is no open connection to the MQTT broker
@@ -211,6 +222,7 @@ def send_property(self, property_name: str, value) -> None:
211222

212223
def send_telemetry(self, data) -> None:
213224
"""Sends telemetry to the IoT Central app
225+
214226
:param data: The telemetry data to send
215227
:raises IoTError: if there is no open connection to the MQTT broker
216228
"""

adafruit_azureiot/iothub_device.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import json
2121
import adafruit_logging as logging
22+
from adafruit_logging import Logger
2223
from .iot_error import IoTError
2324
from .iot_mqtt import IoTMQTT, IoTMQTTCallback, IoTResponse
2425

@@ -65,6 +66,7 @@ class IoTHubDevice(IoTMQTTCallback):
6566

6667
def connection_status_change(self, connected: bool) -> None:
6768
"""Called when the connection status changes
69+
6870
:param bool connected: True if the device is connected, otherwise false
6971
"""
7072
if self._on_connection_status_changed is not None:
@@ -74,6 +76,7 @@ def connection_status_change(self, connected: bool) -> None:
7476
# pylint: disable=W0613, R0201
7577
def direct_method_invoked(self, method_name: str, payload: str) -> IoTResponse:
7678
"""Called when a direct method is invoked
79+
7780
:param str method_name: The name of the method that was invoked
7881
:param str payload: The payload with the message
7982
:returns: A response with a code and status to show if the method was correctly handled
@@ -88,6 +91,7 @@ def direct_method_invoked(self, method_name: str, payload: str) -> IoTResponse:
8891
# pylint: disable=C0103
8992
def cloud_to_device_message_received(self, body: str, properties: dict) -> None:
9093
"""Called when a cloud to device message is received
94+
9195
:param str body: The body of the message
9296
:param dict properties: The propreties sent with the mesage
9397
"""
@@ -102,6 +106,7 @@ def device_twin_desired_updated(
102106
desired_version: int,
103107
) -> None:
104108
"""Called when the device twin desired properties are updated
109+
105110
:param str desired_property_name: The name of the desired property that was updated
106111
:param desired_property_value: The value of the desired property that was updated
107112
:param int desired_version: The version of the desired property that was updated
@@ -119,6 +124,7 @@ def device_twin_reported_updated(
119124
reported_version: int,
120125
) -> None:
121126
"""Called when the device twin reported values are updated
127+
122128
:param str reported_property_name: The name of the reported property that was updated
123129
:param reported_property_value: The value of the reported property that was updated
124130
:param int reported_version: The version of the reported property that was updated
@@ -135,14 +141,15 @@ def __init__(
135141
iface,
136142
device_connection_string: str,
137143
token_expires: int = 21600,
138-
logger: logging = None,
144+
logger: Logger = None,
139145
):
140146
"""Create the Azure IoT Central device client
147+
141148
:param socket: The network socket
142149
:param iface: The network interface
143150
:param str device_connection_string: The Iot Hub device connection string
144151
:param int token_expires: The number of seconds till the token expires, defaults to 6 hours
145-
:param adafruit_logging logger: The logger
152+
:param Logger logger: The logger
146153
"""
147154
self._socket = socket
148155
self._iface = iface
@@ -286,6 +293,7 @@ def device_twin_reported_updated(reported_property_name: str, reported_property_
286293

287294
def connect(self) -> None:
288295
"""Connects to Azure IoT Hub
296+
289297
:raises RuntimeError: if the internet connection is not responding or is unable to connect
290298
"""
291299
self._mqtt = IoTMQTT(
@@ -308,6 +316,7 @@ def connect(self) -> None:
308316

309317
def loop(self) -> None:
310318
"""Listens for MQTT messages
319+
311320
:raises IoTError: if there is no open connection to the MQTT broker
312321
"""
313322
if self._mqtt is None:
@@ -317,6 +326,7 @@ def loop(self) -> None:
317326

318327
def disconnect(self) -> None:
319328
"""Disconnects from the MQTT broker
329+
320330
:raises IoTError: if there is no open connection to the MQTT broker
321331
"""
322332
if self._mqtt is None:
@@ -333,6 +343,7 @@ def reconnect(self) -> None:
333343

334344
def is_connected(self) -> bool:
335345
"""Gets if there is an open connection to the MQTT broker
346+
336347
:returns: True if there is an open connection, False if not
337348
:rtype: bool
338349
"""
@@ -342,6 +353,7 @@ def send_device_to_cloud_message(
342353
self, message: Union[str, dict], system_properties: dict = None
343354
) -> None:
344355
"""Send a device to cloud message from this device to Azure IoT Hub
356+
345357
:param message: The message data as a JSON string or a dictionary
346358
:param system_properties: System properties to send with the message
347359
:raises: ValueError if the message is not a string or dictionary
@@ -354,6 +366,7 @@ def send_device_to_cloud_message(
354366

355367
def update_twin(self, patch: Union[str, dict]) -> None:
356368
"""Updates the reported properties in the devices device twin
369+
357370
:param patch: The JSON patch to apply to the device twin reported properties
358371
"""
359372
if self._mqtt is None:

0 commit comments

Comments
 (0)