Skip to content

Commit d00392a

Browse files
author
Jim Bennett
committed
Changes to work with the latest miniMQTT updates
1 parent 4b62d0f commit d00392a

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

adafruit_azureiot/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"""
1414

1515
# The version of the IoT Central MQTT API this code is built against
16-
IOTC_API_VERSION = "2016-11-14"
16+
IOTC_API_VERSION = "2019-03-30"
1717

1818
# The version of the Azure Device Provisioning Service this code is built against
1919
DPS_API_VERSION = "2018-11-01"

adafruit_azureiot/device_registration.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ def _parse_http_status(status_code: int, status_reason: str) -> None:
5959
)
6060

6161
def __init__(
62-
self, socket, id_scope: str, device_id: str, key: str, logger: Logger = None
62+
self, socket, iface, id_scope: str, device_id: str, key: str, logger: Logger = None
6363
):
6464
"""Creates an instance of the device registration service
6565
:param socket: The network socket
66+
:param iface: The network interface
6667
:param str id_scope: The ID scope of the device to register
6768
:param str device_id: The device ID of the device to register
6869
:param str key: The primary or secondary key of the device to register
@@ -73,7 +74,8 @@ def __init__(
7374
self._key = key
7475
self._logger = logger if logger is not None else logging.getLogger("log")
7576

76-
requests.set_socket(socket)
77+
socket.set_interface(iface)
78+
requests.set_socket(socket, iface)
7779

7880
def _loop_assign(self, operation_id, headers) -> str:
7981
uri = "https://%s/%s/registrations/%s/operations/%s?api-version=%s" % (

adafruit_azureiot/iot_mqtt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,10 @@ def _create_mqtt_client(self) -> None:
118118
port=8883,
119119
keep_alive=120,
120120
is_ssl=True,
121-
client_id=self._device_id,
122-
log=True,
121+
client_id=self._device_id
123122
)
124123

124+
self._mqtts.logger = self._logger
125125
self._mqtts.logger.setLevel(self._logger.getEffectiveLevel())
126126

127127
# set actions to take throughout connection lifecycle

adafruit_azureiot/iotcentral_device.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,12 @@ def connect(self) -> None:
136136
:raises RuntimeError: if the internet connection is not responding or is unable to connect
137137
"""
138138
self._device_registration = DeviceRegistration(
139-
self._socket, self._id_scope, self._device_id, self._key, self._logger
139+
self._socket,
140+
self._iface,
141+
self._id_scope,
142+
self._device_id,
143+
self._key,
144+
self._logger
140145
)
141146

142147
token_expiry = int(time.time() + self._token_expires)
@@ -152,6 +157,10 @@ def connect(self) -> None:
152157
self._logger,
153158
)
154159

160+
self._logger.debug("Hostname: " + hostname)
161+
self._logger.debug("Device Id: " + self._device_id)
162+
self._logger.debug("Shared Access Key: " + self._key)
163+
155164
self._mqtt.connect()
156165
self._mqtt.subscribe_to_twins()
157166

0 commit comments

Comments
 (0)