Skip to content

CPSockets Updates #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions adafruit_azureiot/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
11 changes: 9 additions & 2 deletions adafruit_azureiot/device_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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" % (
Expand Down
3 changes: 1 addition & 2 deletions adafruit_azureiot/iot_mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion adafruit_azureiot/iotcentral_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down