@@ -75,6 +75,7 @@ def _parse_http_status(status_code, status_reason):
75
75
if error == status_code :
76
76
raise TypeError ("Error {0}: {1}" .format (status_code , status_reason ))
77
77
78
+ # Cloud-to-Device Messaging
78
79
def get_hub_message (self , device_id ):
79
80
"""Returns a message from a Microsoft Azure IoT Hub (Cloud-to-Device), or -1
80
81
if the message queue is empty.
@@ -91,18 +92,16 @@ def get_hub_message(self, device_id):
91
92
etag = data [1 ]['etag' ]
92
93
if etag : # either complete or nack the message
93
94
reject_message = False
94
- # prepare the device-bound completion URL
95
- etag = etag .strip ('\' "' )
96
95
path_complete = "{0}/devices/{1}/messages/deviceBound/{2}?api-version={3}" .format (
97
- self ._iot_hub_url , device_id , etag , AZ_API_VER )
96
+ self ._iot_hub_url , device_id , etag . strip ( ' \' "' ) , AZ_API_VER )
98
97
if reject_message :
99
98
path_complete += '&reject'
100
99
del_status = self ._delete (path_complete )
101
100
if del_status == 204 :
102
101
return data [0 ]
103
102
return - 1
104
103
105
- # Device Messaging
104
+ # Device-to-Cloud Messaging
106
105
def send_device_message (self , device_id , message ):
107
106
"""Sends a device-to-cloud message.
108
107
:param string device_id: Device Identifier.
0 commit comments