From 5d2db1b0b0e5be2d64f4ef3b62f63b381ca5d3c2 Mon Sep 17 00:00:00 2001 From: Patrick <4002194+askpatrickw@users.noreply.github.com> Date: Fri, 26 Mar 2021 11:39:00 -0700 Subject: [PATCH 1/2] SPI - iotcentral device registration --- adafruit_azureiot/device_registration.py | 11 +++++++++-- adafruit_azureiot/iot_mqtt.py | 3 +-- adafruit_azureiot/iotcentral_device.py | 7 ++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/adafruit_azureiot/device_registration.py b/adafruit_azureiot/device_registration.py index 7fbea17..a888818 100644 --- a/adafruit_azureiot/device_registration.py +++ b/adafruit_azureiot/device_registration.py @@ -59,7 +59,13 @@ def _parse_http_status(status_code: int, status_reason: str) -> None: ) def __init__( - self, socket, id_scope: str, device_id: str, key: str, logger: Logger = None + self, + socket, + iface, + id_scope: str, + device_id: str, + key: str, + logger: Logger = None, ): """Creates an instance of the device registration service :param socket: The network socket @@ -73,7 +79,8 @@ def __init__( self._key = key self._logger = logger if logger is not None else logging.getLogger("log") - requests.set_socket(socket) + socket.set_interface(iface) + requests.set_socket(socket, iface) def _loop_assign(self, operation_id, headers) -> str: uri = "https://%s/%s/registrations/%s/operations/%s?api-version=%s" % ( diff --git a/adafruit_azureiot/iot_mqtt.py b/adafruit_azureiot/iot_mqtt.py index 9f32209..bdbdf45 100644 --- a/adafruit_azureiot/iot_mqtt.py +++ b/adafruit_azureiot/iot_mqtt.py @@ -119,9 +119,8 @@ def _create_mqtt_client(self) -> None: keep_alive=120, is_ssl=True, client_id=self._device_id, - log=True, ) - + self._mqtts.logger = self._logger self._mqtts.logger.setLevel(self._logger.getEffectiveLevel()) # set actions to take throughout connection lifecycle diff --git a/adafruit_azureiot/iotcentral_device.py b/adafruit_azureiot/iotcentral_device.py index 84df471..452029b 100644 --- a/adafruit_azureiot/iotcentral_device.py +++ b/adafruit_azureiot/iotcentral_device.py @@ -136,7 +136,12 @@ def connect(self) -> None: :raises RuntimeError: if the internet connection is not responding or is unable to connect """ self._device_registration = DeviceRegistration( - self._socket, self._id_scope, self._device_id, self._key, self._logger + self._socket, + self._iface, + self._id_scope, + self._device_id, + self._key, + self._logger, ) token_expiry = int(time.time() + self._token_expires) From 5faf423a99576ef224e1a6cbb1695d0f040af2d1 Mon Sep 17 00:00:00 2001 From: Patrick <4002194+askpatrickw@users.noreply.github.com> Date: Fri, 26 Mar 2021 23:32:00 -0700 Subject: [PATCH 2/2] updated API versions --- adafruit_azureiot/constants.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_azureiot/constants.py b/adafruit_azureiot/constants.py index f6da145..fd0da9c 100644 --- a/adafruit_azureiot/constants.py +++ b/adafruit_azureiot/constants.py @@ -13,10 +13,10 @@ """ # The version of the IoT Central MQTT API this code is built against -IOTC_API_VERSION = "2016-11-14" +IOTC_API_VERSION = "2018-06-30" # The version of the Azure Device Provisioning Service this code is built against -DPS_API_VERSION = "2018-11-01" +DPS_API_VERSION = "2019-03-31" # The Azure Device Provisioning service endpoint that this library uses to provision IoT Central devices DPS_END_POINT = "global.azure-devices-provisioning.net"