diff --git a/adafruit_azureiot/__init__.py b/adafruit_azureiot/__init__.py index a744bf8..43d901d 100644 --- a/adafruit_azureiot/__init__.py +++ b/adafruit_azureiot/__init__.py @@ -27,7 +27,8 @@ **With Native Networking** -* CircuitPython's Wifi Module: https://docs.circuitpython.org/en/latest/shared-bindings/wifi/index.html +* CircuitPython's Wifi Module: + https://docs.circuitpython.org/en/latest/shared-bindings/wifi/index.html * Adafruit's Requests Library: https://github.com/adafruit/Adafruit_CircuitPython_Requests/ """ diff --git a/adafruit_azureiot/constants.py b/adafruit_azureiot/constants.py index 619875d..82e1c4a 100644 --- a/adafruit_azureiot/constants.py +++ b/adafruit_azureiot/constants.py @@ -7,7 +7,8 @@ `constants` ================================================================================ -This file is for maintaining Microsoft Azure IoT constants that could be changed or added to over time for different scenarios +This file is for maintaining Microsoft Azure IoT constants that could be changed or added to over +time for different scenarios * Author(s): Jim Bennett, Elena Horton """ @@ -18,5 +19,6 @@ # The version of the Azure Device Provisioning Service this code is built against DPS_API_VERSION = "2019-03-31" -# The Azure Device Provisioning service endpoint that this library uses to provision IoT Central devices +# The Azure Device Provisioning service endpoint that this library uses to provision IoT Central +# devices DPS_END_POINT = "global.azure-devices-provisioning.net" diff --git a/adafruit_azureiot/device_registration.py b/adafruit_azureiot/device_registration.py index 21d3464..92fd80c 100644 --- a/adafruit_azureiot/device_registration.py +++ b/adafruit_azureiot/device_registration.py @@ -115,7 +115,8 @@ def _connect_to_mqtt(self) -> None: self._mqtt.loop() self._logger.info( - f" - device_registration :: connect :: on_connect must be fired. Connected ? {self._mqtt.is_connected()}" + " - device_registration :: connect :: on_connect must be fired. Connected ?" + f"{self._mqtt.is_connected()}" ) if not self._mqtt.is_connected(): @@ -148,7 +149,8 @@ def _start_registration(self) -> None: def _wait_for_operation(self) -> None: message = json.dumps({"operationId": self._operation_id}) self._mqtt.publish( - f"$dps/registrations/GET/iotdps-get-operationstatus/?$rid={self._device_id}&operationId={self._operation_id}", + "$dps/registrations/GET/iotdps-get-operationstatus/?$rid=" + f"{self._device_id}&operationId={self._operation_id}", message, ) @@ -176,7 +178,10 @@ def register_device(self, expiry: int) -> str: :raises RuntimeError: if the internet connection is not responding or is unable to connect """ - username = f"{self._id_scope}/registrations/{self._device_id}/api-version={constants.DPS_API_VERSION}" + username = ( + f"{self._id_scope}/registrations/{self._device_id}/api-version=" + + f"{constants.DPS_API_VERSION}" + ) # pylint: disable=C0103 sr = self._id_scope + "%2Fregistrations%2F" + self._device_id @@ -184,7 +189,10 @@ def register_device(self, expiry: int) -> str: self._device_sas_key, sr + "\n" + str(expiry) ) sig_encoded = quote(sig_no_encode, "~()*!.'") - auth_string = f"SharedAccessSignature sr={sr}&sig={sig_encoded}&se={expiry}&skn=registration" + auth_string = ( + f"SharedAccessSignature sr={sr}&sig={sig_encoded}&se={expiry}" + "&skn=registration" + ) MQTT.set_socket(self._socket, self._iface) diff --git a/adafruit_azureiot/hmac.py b/adafruit_azureiot/hmac.py index 24504e3..df2512d 100644 --- a/adafruit_azureiot/hmac.py +++ b/adafruit_azureiot/hmac.py @@ -14,7 +14,7 @@ """ -# pylint: disable=C0103, W0108, R0915, C0116, C0115 +# pylint: disable=C0103, W0108, R0915, C0116, C0115, unnecessary-lambda-assignment try: from typing import Union diff --git a/adafruit_azureiot/iot_mqtt.py b/adafruit_azureiot/iot_mqtt.py index fa7fa84..9df04cc 100644 --- a/adafruit_azureiot/iot_mqtt.py +++ b/adafruit_azureiot/iot_mqtt.py @@ -33,7 +33,8 @@ class IoTResponse: def __init__(self, code: int, message: str): """Creates an IoT Response object - :param int code: The HTTP response code for this method call, for example 200 if the method was handled successfully + :param int code: The HTTP response code for this method call, for example 200 if the method + was handled successfully :param str message: The HTTP response message for this method call """ self.response_code = code @@ -120,9 +121,12 @@ def _gen_sas_token(self) -> str: def _create_mqtt_client(self) -> None: MQTT.set_socket(self._socket, self._iface) + log_text = ( + f"- iot_mqtt :: _on_connect :: username = {self._username}, password = " + + f"{self._passwd}" + ) self._logger.debug( - str.replace( - f"- iot_mqtt :: _on_connect :: username = {self._username}, password = {self._passwd}", + log_text.replace( "%", "%%", ) @@ -334,7 +338,8 @@ def __init__( :param IoTMQTTCallback callback: A callback class :param socket: The socket to communicate over :param iface: The network interface to communicate over - :param str hostname: The hostname of the MQTT broker to connect to, get this by registering the device + :param str hostname: The hostname of the MQTT broker to connect to, get this by registering + the device :param str device_id: The device ID of the device to register :param str device_sas_key: The primary or secondary key of the device to register :param int token_expires: The number of seconds till the token expires, defaults to 6 hours diff --git a/adafruit_azureiot/iotcentral_device.py b/adafruit_azureiot/iotcentral_device.py index ae54244..445a6b0 100644 --- a/adafruit_azureiot/iotcentral_device.py +++ b/adafruit_azureiot/iotcentral_device.py @@ -21,7 +21,7 @@ from .iot_mqtt import IoTMQTT, IoTMQTTCallback, IoTResponse -class IoTCentralDevice(IoTMQTTCallback): +class IoTCentralDevice(IoTMQTTCallback): # pylint: disable=too-many-instance-attributes """A device client for the Azure IoT Central service""" def connection_status_change(self, connected: bool) -> None: @@ -120,23 +120,27 @@ def __init__( self._mqtt = None self.on_connection_status_changed = None - """A callback method that is called when the connection status is changed. This method should have the following signature: + """A callback method that is called when the connection status is changed. + This method should have the following signature: def connection_status_changed(connected: bool) -> None """ self.on_command_executed = None - """A callback method that is called when a command is executed on the device. This method should have the following signature: + """A callback method that is called when a command is executed on the device. + This method should have the following signature: def connection_status_changed(method_name: str, payload: str) -> IoTResponse: - This method returns an IoTResponse containing a status code and message from the command call. Set this appropriately - depending on if the command was successfully handled or not. For example, if the command was handled successfully, set - the code to 200 and message to "OK": + This method returns an IoTResponse containing a status code and message from the command + call. Set this appropriately depending on if the command was successfully handled or not. + For example, if the command was handled successfully, set the code to 200 and message to + "OK": return IoTResponse(200, "OK") """ self.on_property_changed = None - """A callback method that is called when property values are updated. This method should have the following signature: + """A callback method that is called when property values are updated. + This method should have the following signature: def property_changed(_property_name: str, property_value, version: int) -> None """ diff --git a/adafruit_azureiot/iothub_device.py b/adafruit_azureiot/iothub_device.py index dfa66b0..02e5cdf 100755 --- a/adafruit_azureiot/iothub_device.py +++ b/adafruit_azureiot/iothub_device.py @@ -61,7 +61,7 @@ def _validate_keys(connection_string_parts: Mapping) -> None: ] -class IoTHubDevice(IoTMQTTCallback): +class IoTHubDevice(IoTMQTTCallback): # pylint: disable=too-many-instance-attributes """A device client for the Azure IoT Hub service""" def connection_status_change(self, connected: bool) -> None: @@ -135,7 +135,7 @@ def device_twin_reported_updated( reported_property_name, reported_property_value, reported_version ) - def __init__( + def __init__( # pylint: disable=too-many-arguments self, socket, iface, @@ -168,7 +168,8 @@ def __init__( ) except (ValueError, AttributeError) as e: raise ValueError( - "Connection string is required and should not be empty or blank and must be supplied as a string" + "Connection string is required and should not be empty or blank and must be" + "supplied as a string" ) from e if len(cs_args) != len(connection_string_values): @@ -194,7 +195,8 @@ def __init__( @property def on_connection_status_changed(self) -> Callable: - """A callback method that is called when the connection status is changed. This method should have the following signature: + """A callback method that is called when the connection status is changed. + This method should have the following signature: def connection_status_changed(connected: bool) -> None """ return self._on_connection_status_changed @@ -203,19 +205,22 @@ def connection_status_changed(connected: bool) -> None def on_connection_status_changed( self, new_on_connection_status_changed: Callable ) -> None: - """A callback method that is called when the connection status is changed. This method should have the following signature: + """A callback method that is called when the connection status is changed. + This method should have the following signature: def connection_status_changed(connected: bool) -> None """ self._on_connection_status_changed = new_on_connection_status_changed @property def on_direct_method_invoked(self) -> Callable: - """A callback method that is called when a direct method is invoked. This method should have the following signature: + """A callback method that is called when a direct method is invoked. + This method should have the following signature: def direct_method_invoked(method_name: str, payload: str) -> IoTResponse: - This method returns an IoTResponse containing a status code and message from the method invocation. Set this appropriately - depending on if the method was successfully handled or not. For example, if the method was handled successfully, set - the code to 200 and message to "OK": + This method returns an IoTResponse containing a status code and message from the method + invocation. Set this appropriately depending on if the method was successfully handled or + not. For example, if the method was handled successfully, set the code to 200 and message + to "OK": return IoTResponse(200, "OK") """ @@ -223,12 +228,14 @@ def direct_method_invoked(method_name: str, payload: str) -> IoTResponse: @on_direct_method_invoked.setter def on_direct_method_invoked(self, new_on_direct_method_invoked: Callable) -> None: - """A callback method that is called when a direct method is invoked. This method should have the following signature: + """A callback method that is called when a direct method is invoked. + This method should have the following signature: def direct_method_invoked(method_name: str, payload: str) -> IoTResponse: - This method returns an IoTResponse containing a status code and message from the method invocation. Set this appropriately - depending on if the method was successfully handled or not. For example, if the method was handled successfully, set - the code to 200 and message to "OK": + This method returns an IoTResponse containing a status code and message from the method + invocation. Set this appropriately depending on if the method was successfully handled or + not. For example, if the method was handled successfully, set the code to 200 and message + to "OK": return IoTResponse(200, "OK") """ @@ -236,7 +243,8 @@ def direct_method_invoked(method_name: str, payload: str) -> IoTResponse: @property def on_cloud_to_device_message_received(self) -> Callable: - """A callback method that is called when a cloud to device message is received. This method should have the following signature: + """A callback method that is called when a cloud to device message is received. + This method should have the following signature: def cloud_to_device_message_received(body: str, properties: dict) -> None: """ return self._on_cloud_to_device_message_received @@ -245,7 +253,8 @@ def cloud_to_device_message_received(body: str, properties: dict) -> None: def on_cloud_to_device_message_received( self, new_on_cloud_to_device_message_received: Callable ) -> None: - """A callback method that is called when a cloud to device message is received. This method should have the following signature: + """A callback method that is called when a cloud to device message is received. + This method should have the following signature: def cloud_to_device_message_received(body: str, properties: dict) -> None: """ self._on_cloud_to_device_message_received = ( @@ -254,9 +263,10 @@ def cloud_to_device_message_received(body: str, properties: dict) -> None: @property def on_device_twin_desired_updated(self) -> Callable: - """A callback method that is called when the desired properties of the devices device twin are updated. - This method should have the following signature: - def device_twin_desired_updated(desired_property_name: str, desired_property_value, desired_version: int) -> None: + """A callback method that is called when the desired properties of the devices device twin + are updated. This method should have the following signature: + def device_twin_desired_updated(desired_property_name: str, desired_property_value, + desired_version: int) -> None: """ return self._on_device_twin_desired_updated @@ -264,9 +274,10 @@ def device_twin_desired_updated(desired_property_name: str, desired_property_val def on_device_twin_desired_updated( self, new_on_device_twin_desired_updated: Callable ) -> None: - """A callback method that is called when the desired properties of the devices device twin are updated. - This method should have the following signature: - def device_twin_desired_updated(desired_property_name: str, desired_property_value, desired_version: int) -> None: + """A callback method that is called when the desired properties of the devices device twin + are updated. This method should have the following signature: + def device_twin_desired_updated(desired_property_name: str, desired_property_value, + desired_version: int) -> None: """ self._on_device_twin_desired_updated = new_on_device_twin_desired_updated @@ -275,9 +286,10 @@ def device_twin_desired_updated(desired_property_name: str, desired_property_val @property def on_device_twin_reported_updated(self) -> Callable: - """A callback method that is called when the reported properties of the devices device twin are updated. - This method should have the following signature: - def device_twin_reported_updated(reported_property_name: str, reported_property_value, reported_version: int) -> None: + """A callback method that is called when the reported properties of the devices device twin + are updated. This method should have the following signature: + def device_twin_reported_updated(reported_property_name: str, reported_property_value, + reported_version: int) -> None: """ return self._on_device_twin_reported_updated @@ -285,9 +297,10 @@ def device_twin_reported_updated(reported_property_name: str, reported_property_ def on_device_twin_reported_updated( self, new_on_device_twin_reported_updated: Callable ) -> None: - """A callback method that is called when the reported properties of the devices device twin are updated. - This method should have the following signature: - def device_twin_reported_updated(reported_property_name: str, reported_property_value, reported_version: int) -> None: + """A callback method that is called when the reported properties of the devices device twin + are updated. This method should have the following signature: + def device_twin_reported_updated(reported_property_name: str, reported_property_value, + reported_version: int) -> None: """ self._on_device_twin_reported_updated = new_on_device_twin_reported_updated diff --git a/examples/azureiot_esp32spi/azureiot_central_commands.py b/examples/azureiot_esp32spi/azureiot_central_commands.py index da20664..535cc06 100644 --- a/examples/azureiot_esp32spi/azureiot_central_commands.py +++ b/examples/azureiot_esp32spi/azureiot_central_commands.py @@ -79,11 +79,13 @@ # If you are not a student, head to 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 # -# Create an Azure IoT Central app by following these instructions: https://aka.ms/CreateIoTCentralApp +# Create an Azure IoT Central app by following these instructions: +# https://aka.ms/CreateIoTCentralApp # Add a device template with telemetry, properties and commands, as well as a view to visualize the # telemetry and execute commands, and a form to set properties. # -# Next create a device using the device template, and select Connect to get the device connection details. +# Next create a device using the device template, and select Connect to get the device connection +# details. # Add the connection details to your secrets.py file, using the following values: # # 'id_scope' - the devices ID scope @@ -92,7 +94,7 @@ # # The adafruit-circuitpython-azureiot library depends on the following libraries: # -# From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): +# From the Adafruit CircuitPython Bundle https://github.com/adafruit/Adafruit_CircuitPython_Bundle: # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests # pylint: disable=wrong-import-position diff --git a/examples/azureiot_esp32spi/azureiot_central_notconnected.py b/examples/azureiot_esp32spi/azureiot_central_notconnected.py index e3cf32b..f78afd1 100644 --- a/examples/azureiot_esp32spi/azureiot_central_notconnected.py +++ b/examples/azureiot_esp32spi/azureiot_central_notconnected.py @@ -73,11 +73,13 @@ # If you are not a student, head to 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 # -# Create an Azure IoT Central app by following these instructions: https://aka.ms/CreateIoTCentralApp +# Create an Azure IoT Central app by following these instructions: +# https://aka.ms/CreateIoTCentralApp # Add a device template with telemetry, properties and commands, as well as a view to visualize the # telemetry and execute commands, and a form to set properties. # -# Next create a device using the device template, and select Connect to get the device connection details. +# Next create a device using the device template, and select Connect to get the device connection +# details. # Add the connection details to your secrets.py file, using the following values: # # 'id_scope' - the devices ID scope @@ -86,7 +88,7 @@ # # The adafruit-circuitpython-azureiot library depends on the following libraries: # -# From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): +# From the Adafruit CircuitPython Bundle https://github.com/adafruit/Adafruit_CircuitPython_Bundle: # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests # pylint: disable=wrong-import-position diff --git a/examples/azureiot_esp32spi/azureiot_central_properties.py b/examples/azureiot_esp32spi/azureiot_central_properties.py index 78f1476..c7b3515 100644 --- a/examples/azureiot_esp32spi/azureiot_central_properties.py +++ b/examples/azureiot_esp32spi/azureiot_central_properties.py @@ -80,11 +80,13 @@ # If you are not a student, head to 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 # -# Create an Azure IoT Central app by following these instructions: https://aka.ms/CreateIoTCentralApp +# Create an Azure IoT Central app by following these instructions: +# https://aka.ms/CreateIoTCentralApp # Add a device template with telemetry, properties and commands, as well as a view to visualize the # telemetry and execute commands, and a form to set properties. # -# Next create a device using the device template, and select Connect to get the device connection details. +# Next create a device using the device template, and select Connect to get the device connection +# details. # Add the connection details to your secrets.py file, using the following values: # # 'id_scope' - the devices ID scope @@ -93,7 +95,7 @@ # # The adafruit-circuitpython-azureiot library depends on the following libraries: # -# From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): +# From the Adafruit CircuitPython Bundle https://github.com/adafruit/Adafruit_CircuitPython_Bundle: # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests from adafruit_azureiot import IoTCentralDevice # pylint: disable=wrong-import-position diff --git a/examples/azureiot_esp32spi/azureiot_central_simpletest.py b/examples/azureiot_esp32spi/azureiot_central_simpletest.py index 10e1616..546b5d0 100644 --- a/examples/azureiot_esp32spi/azureiot_central_simpletest.py +++ b/examples/azureiot_esp32spi/azureiot_central_simpletest.py @@ -81,11 +81,13 @@ # If you are not a student, head to 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 # -# Create an Azure IoT Central app by following these instructions: https://aka.ms/CreateIoTCentralApp +# Create an Azure IoT Central app by following these instructions: +# https://aka.ms/CreateIoTCentralApp # Add a device template with telemetry, properties and commands, as well as a view to visualize the # telemetry and execute commands, and a form to set properties. # -# Next create a device using the device template, and select Connect to get the device connection details. +# Next create a device using the device template, and select Connect to get the device connection +# details. # Add the connection details to your secrets.py file, using the following values: # # 'id_scope' - the devices ID scope @@ -94,7 +96,7 @@ # # The adafruit-circuitpython-azureiot library depends on the following libraries: # -# From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): +# From the Adafruit CircuitPython Bundle https://github.com/adafruit/Adafruit_CircuitPython_Bundle: # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests from adafruit_azureiot import IoTCentralDevice # pylint: disable=wrong-import-position diff --git a/examples/azureiot_esp32spi/azureiot_hub_directmethods.py b/examples/azureiot_esp32spi/azureiot_hub_directmethods.py index de21baa..8d4fb31 100644 --- a/examples/azureiot_esp32spi/azureiot_hub_directmethods.py +++ b/examples/azureiot_esp32spi/azureiot_hub_directmethods.py @@ -76,7 +76,8 @@ # If you are not a student, head to 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 # -# Create an Azure IoT Hub and an IoT device in the Azure portal here: https://aka.ms/AzurePortalHome. +# Create an Azure IoT Hub and an IoT device in the Azure portal here: +# https://aka.ms/AzurePortalHome. # Instructions to create an IoT Hub and device are here: https://aka.ms/CreateIoTHub # # The free tier of IoT Hub allows up to 8,000 messages a day, so try not to send messages too often @@ -87,7 +88,7 @@ # # The adafruit-circuitpython-azureiot library depends on the following libraries: # -# From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): +# From the Adafruit CircuitPython Bundle https://github.com/adafruit/Adafruit_CircuitPython_Bundle: # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests # pylint: disable=wrong-import-position diff --git a/examples/azureiot_esp32spi/azureiot_hub_messages.py b/examples/azureiot_esp32spi/azureiot_hub_messages.py index b57fd9e..cc276ca 100644 --- a/examples/azureiot_esp32spi/azureiot_hub_messages.py +++ b/examples/azureiot_esp32spi/azureiot_hub_messages.py @@ -78,7 +78,8 @@ # If you are not a student, head to 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 # -# Create an Azure IoT Hub and an IoT device in the Azure portal here: https://aka.ms/AzurePortalHome. +# Create an Azure IoT Hub and an IoT device in the Azure portal here: +# https://aka.ms/AzurePortalHome. # Instructions to create an IoT Hub and device are here: https://aka.ms/CreateIoTHub # # The free tier of IoT Hub allows up to 8,000 messages a day, so try not to send messages too often @@ -89,7 +90,7 @@ # # The adafruit-circuitpython-azureiot library depends on the following libraries: # -# From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): +# From the Adafruit CircuitPython Bundle https://github.com/adafruit/Adafruit_CircuitPython_Bundle: # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests from adafruit_azureiot import IoTHubDevice # pylint: disable=wrong-import-position diff --git a/examples/azureiot_esp32spi/azureiot_hub_simpletest.py b/examples/azureiot_esp32spi/azureiot_hub_simpletest.py index 643be96..2e16a57 100644 --- a/examples/azureiot_esp32spi/azureiot_hub_simpletest.py +++ b/examples/azureiot_esp32spi/azureiot_hub_simpletest.py @@ -78,7 +78,8 @@ # If you are not a student, head to 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 # -# Create an Azure IoT Hub and an IoT device in the Azure portal here: https://aka.ms/AzurePortalHome. +# Create an Azure IoT Hub and an IoT device in the Azure portal here: +# https://aka.ms/AzurePortalHome. # Instructions to create an IoT Hub and device are here: https://aka.ms/CreateIoTHub # # The free tier of IoT Hub allows up to 8,000 messages a day, so try not to send messages too often @@ -89,7 +90,7 @@ # # The adafruit-circuitpython-azureiot library depends on the following libraries: # -# From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): +# From the Adafruit CircuitPython Bundle https://github.com/adafruit/Adafruit_CircuitPython_Bundle: # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests from adafruit_azureiot import IoTHubDevice # pylint: disable=wrong-import-position diff --git a/examples/azureiot_esp32spi/azureiot_hub_twin_operations.py b/examples/azureiot_esp32spi/azureiot_hub_twin_operations.py index 35ad3b5..d2d01a6 100644 --- a/examples/azureiot_esp32spi/azureiot_hub_twin_operations.py +++ b/examples/azureiot_esp32spi/azureiot_hub_twin_operations.py @@ -77,7 +77,8 @@ # If you are not a student, head to 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 # -# Create an Azure IoT Hub and an IoT device in the Azure portal here: https://aka.ms/AzurePortalHome. +# Create an Azure IoT Hub and an IoT device in the Azure portal here: +# https://aka.ms/AzurePortalHome. # Instructions to create an IoT Hub and device are here: https://aka.ms/CreateIoTHub # # The free tier of IoT Hub allows up to 8,000 messages a day, so try not to send messages too often @@ -91,7 +92,7 @@ # # The adafruit-circuitpython-azureiot library depends on the following libraries: # -# From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): +# From the Adafruit CircuitPython Bundle https://github.com/adafruit/Adafruit_CircuitPython_Bundle: # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests from adafruit_azureiot import IoTHubDevice # pylint: disable=wrong-import-position @@ -132,8 +133,8 @@ def device_twin_desired_updated( try: if message_counter >= 60: # Send a reported property twin update every minute - # You can see these in the portal by selecting the device in the IoT Hub blade, selecting - # Device Twin then looking for the updates in the 'reported' section + # You can see these in the portal by selecting the device in the IoT Hub blade, + # selecting device Twin then looking for the updates in the 'reported' section patch = {"Temperature": random.randint(0, 50)} device.update_twin(patch) message_counter = 0 diff --git a/examples/azureiot_native_networking/azureiot_central_commands.py b/examples/azureiot_native_networking/azureiot_central_commands.py index 86c789f..7f0e413 100644 --- a/examples/azureiot_native_networking/azureiot_central_commands.py +++ b/examples/azureiot_native_networking/azureiot_central_commands.py @@ -48,11 +48,13 @@ # If you are not a student, head to 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 # -# Create an Azure IoT Central app by following these instructions: https://aka.ms/CreateIoTCentralApp +# Create an Azure IoT Central app by following these instructions: +# https://aka.ms/CreateIoTCentralApp # Add a device template with telemetry, properties and commands, as well as a view to visualize the # telemetry and execute commands, and a form to set properties. # -# Next create a device using the device template, and select Connect to get the device connection details. +# Next create a device using the device template, and select Connect to get the device connection +# details. # Add the connection details to your secrets.py file, using the following values: # # 'id_scope' - the devices ID scope @@ -61,7 +63,7 @@ # # The adafruit-circuitpython-azureiot library depends on the following libraries: # -# From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): +# From the Adafruit CircuitPython Bundle https://github.com/adafruit/Adafruit_CircuitPython_Bundle: # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests diff --git a/examples/azureiot_native_networking/azureiot_central_notconnected.py b/examples/azureiot_native_networking/azureiot_central_notconnected.py index 782cd6a..5ad0f47 100644 --- a/examples/azureiot_native_networking/azureiot_central_notconnected.py +++ b/examples/azureiot_native_networking/azureiot_central_notconnected.py @@ -52,11 +52,13 @@ # If you are not a student, head to 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 # -# Create an Azure IoT Central app by following these instructions: https://aka.ms/CreateIoTCentralApp +# Create an Azure IoT Central app by following these instructions: +# https://aka.ms/CreateIoTCentralApp # Add a device template with telemetry, properties and commands, as well as a view to visualize the # telemetry and execute commands, and a form to set properties. # -# Next create a device using the device template, and select Connect to get the device connection details. +# Next create a device using the device template, and select Connect to get the device connection +# details. # Add the connection details to your secrets.py file, using the following values: # # 'id_scope' - the devices ID scope @@ -65,7 +67,7 @@ # # The adafruit-circuitpython-azureiot library depends on the following libraries: # -# From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): +# From the Adafruit CircuitPython Bundle https://github.com/adafruit/Adafruit_CircuitPython_Bundle: # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests diff --git a/examples/azureiot_native_networking/azureiot_central_properties.py b/examples/azureiot_native_networking/azureiot_central_properties.py index 7f0dbd0..d14d145 100644 --- a/examples/azureiot_native_networking/azureiot_central_properties.py +++ b/examples/azureiot_native_networking/azureiot_central_properties.py @@ -48,11 +48,13 @@ # If you are not a student, head to 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 # -# Create an Azure IoT Central app by following these instructions: https://aka.ms/CreateIoTCentralApp +# Create an Azure IoT Central app by following these instructions: +# https://aka.ms/CreateIoTCentralApp # Add a device template with telemetry, properties and commands, as well as a view to visualize the # telemetry and execute commands, and a form to set properties. # -# Next create a device using the device template, and select Connect to get the device connection details. +# Next create a device using the device template, and select Connect to get the device connection +# details. # Add the connection details to your secrets.py file, using the following values: # # 'id_scope' - the devices ID scope @@ -61,7 +63,7 @@ # # The adafruit-circuitpython-azureiot library depends on the following libraries: # -# From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): +# From the Adafruit CircuitPython Bundle https://github.com/adafruit/Adafruit_CircuitPython_Bundle: # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests diff --git a/examples/azureiot_native_networking/azureiot_central_simpletest.py b/examples/azureiot_native_networking/azureiot_central_simpletest.py index 06e34b5..0595783 100644 --- a/examples/azureiot_native_networking/azureiot_central_simpletest.py +++ b/examples/azureiot_native_networking/azureiot_central_simpletest.py @@ -49,11 +49,13 @@ # If you are not a student, head to 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 # -# Create an Azure IoT Central app by following these instructions: https://aka.ms/CreateIoTCentralApp +# Create an Azure IoT Central app by following these instructions: +# https://aka.ms/CreateIoTCentralApp # Add a device template with telemetry, properties and commands, as well as a view to visualize the # telemetry and execute commands, and a form to set properties. # -# Next create a device using the device template, and select Connect to get the device connection details. +# Next create a device using the device template, and select Connect to get the device connection +# details. # Add the connection details to your secrets.py file, using the following values: # # 'id_scope' - the devices ID scope @@ -62,7 +64,7 @@ # # The adafruit-circuitpython-azureiot library depends on the following libraries: # -# From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): +# From the Adafruit CircuitPython Bundle https://github.com/adafruit/Adafruit_CircuitPython_Bundle: # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests diff --git a/examples/azureiot_native_networking/azureiot_hub_directmethods.py b/examples/azureiot_native_networking/azureiot_hub_directmethods.py index 6755a0e..5d9107b 100644 --- a/examples/azureiot_native_networking/azureiot_hub_directmethods.py +++ b/examples/azureiot_native_networking/azureiot_hub_directmethods.py @@ -45,7 +45,8 @@ # If you are not a student, head to 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 # -# Create an Azure IoT Hub and an IoT device in the Azure portal here: https://aka.ms/AzurePortalHome. +# Create an Azure IoT Hub and an IoT device in the Azure portal here: +# https://aka.ms/AzurePortalHome. # Instructions to create an IoT Hub and device are here: https://aka.ms/CreateIoTHub # # The free tier of IoT Hub allows up to 8,000 messages a day, so try not to send messages too often @@ -56,7 +57,7 @@ # # The adafruit-circuitpython-azureiot library depends on the following libraries: # -# From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): +# From the Adafruit CircuitPython Bundle https://github.com/adafruit/Adafruit_CircuitPython_Bundle: # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests diff --git a/examples/azureiot_native_networking/azureiot_hub_messages.py b/examples/azureiot_native_networking/azureiot_hub_messages.py index 61d05fc..a16dff4 100644 --- a/examples/azureiot_native_networking/azureiot_hub_messages.py +++ b/examples/azureiot_native_networking/azureiot_hub_messages.py @@ -46,7 +46,8 @@ # If you are not a student, head to 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 # -# Create an Azure IoT Hub and an IoT device in the Azure portal here: https://aka.ms/AzurePortalHome. +# Create an Azure IoT Hub and an IoT device in the Azure portal here: +# https://aka.ms/AzurePortalHome. # Instructions to create an IoT Hub and device are here: https://aka.ms/CreateIoTHub # # The free tier of IoT Hub allows up to 8,000 messages a day, so try not to send messages too often @@ -57,7 +58,7 @@ # # The adafruit-circuitpython-azureiot library depends on the following libraries: # -# From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): +# From the Adafruit CircuitPython Bundle https://github.com/adafruit/Adafruit_CircuitPython_Bundle: # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests diff --git a/examples/azureiot_native_networking/azureiot_hub_simpletest.py b/examples/azureiot_native_networking/azureiot_hub_simpletest.py index 5e1317f..acc7a94 100644 --- a/examples/azureiot_native_networking/azureiot_hub_simpletest.py +++ b/examples/azureiot_native_networking/azureiot_hub_simpletest.py @@ -46,7 +46,8 @@ # If you are not a student, head to 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 # -# Create an Azure IoT Hub and an IoT device in the Azure portal here: https://aka.ms/AzurePortalHome. +# Create an Azure IoT Hub and an IoT device in the Azure portal here: +# https://aka.ms/AzurePortalHome. # Instructions to create an IoT Hub and device are here: https://aka.ms/CreateIoTHub # # The free tier of IoT Hub allows up to 8,000 messages a day, so try not to send messages too often @@ -57,7 +58,7 @@ # # The adafruit-circuitpython-azureiot library depends on the following libraries: # -# From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): +# From the Adafruit CircuitPython Bundle https://github.com/adafruit/Adafruit_CircuitPython_Bundle: # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests diff --git a/examples/azureiot_native_networking/azureiot_hub_twin_operations.py b/examples/azureiot_native_networking/azureiot_hub_twin_operations.py index e75b2e7..803e901 100644 --- a/examples/azureiot_native_networking/azureiot_hub_twin_operations.py +++ b/examples/azureiot_native_networking/azureiot_hub_twin_operations.py @@ -45,7 +45,8 @@ # If you are not a student, head to 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 # -# Create an Azure IoT Hub and an IoT device in the Azure portal here: https://aka.ms/AzurePortalHome. +# Create an Azure IoT Hub and an IoT device in the Azure portal here: +# https://aka.ms/AzurePortalHome. # Instructions to create an IoT Hub and device are here: https://aka.ms/CreateIoTHub # # The free tier of IoT Hub allows up to 8,000 messages a day, so try not to send messages too often @@ -56,7 +57,7 @@ # # The adafruit-circuitpython-azureiot library depends on the following libraries: # -# From the Adafruit CircuitPython Bundle (https://github.com/adafruit/Adafruit_CircuitPython_Bundle): +# From the Adafruit CircuitPython Bundle https://github.com/adafruit/Adafruit_CircuitPython_Bundle: # * adafruit-circuitpython-minimqtt # * adafruit-circuitpython-requests @@ -97,8 +98,8 @@ def device_twin_desired_updated( try: if message_counter >= 60: # Send a reported property twin update every minute - # You can see these in the portal by selecting the device in the IoT Hub blade, selecting - # Device Twin then looking for the updates in the 'reported' section + # You can see these in the portal by selecting the device in the IoT Hub blade, + # selecting device Twin then looking for the updates in the 'reported' section patch = {"Temperature": random.randint(0, 50)} device.update_twin(patch) message_counter = 0 diff --git a/examples/azureiot_secrets_example.py b/examples/azureiot_secrets_example.py index 26eff42..37e618c 100644 --- a/examples/azureiot_secrets_example.py +++ b/examples/azureiot_secrets_example.py @@ -18,7 +18,8 @@ # WiFi settings "ssid": "", "password": "", - # Azure IoT Central settings - if you are connecting to Azure IoT Central, fill in these three values + # Azure IoT Central settings - if you are connecting to Azure IoT Central, fill in these three + # values # To get these values, select your device in Azure IoT Central, # then select the Connect button # A dialog will appear with these three values @@ -29,9 +30,9 @@ "device_id": "", "device_sas_key": "", # Azure IoT Hub settings - if you are connecting to Azure IoT Hub, fill in this value - # To get this value, from the Azure Portal (https://aka.ms/AzurePortalHome), select your IoT Hub, - # then select Explorers -> IoT devices, select your device, then copy the entire primary or secondary - # connection string using the copy button next to the value and set this here. + # To get this value, from the Azure Portal (https://aka.ms/AzurePortalHome), select your IoT + # Hub, then select Explorers -> IoT devices, select your device, then copy the entire primary + # or secondary connection string using the copy button next to the value and set this here. # It will be in the format: # HostName=.azure-devices.net;DeviceId=;SharedAccessKey= # Note - you need the primary or secondary connection string, NOT the primary or secondary key