@@ -76,7 +76,8 @@ def _parse_http_status(status_code, status_reason):
76
76
raise TypeError ("Error {0}: {1}" .format (status_code , status_reason ))
77
77
78
78
def get_hub_message (self , device_id ):
79
- """Returns a message from a Microsoft Azure IoT Hub (Cloud-to-Device), or -1 if the message queue is empty.
79
+ """Returns a message from a Microsoft Azure IoT Hub (Cloud-to-Device), or -1
80
+ if the message queue is empty.
80
81
NOTE: HTTP Cloud-to-Device messages are throttled. Poll every 25 minutes, or more.
81
82
:param int device_id: Device identifier.
82
83
"""
@@ -92,13 +93,14 @@ def get_hub_message(self, device_id):
92
93
reject_message = False
93
94
# prepare the device-bound completion URL
94
95
etag = etag .strip ('\' "' )
95
- path_complete = "{0}/devices/{1}/messages/deviceBound/{2}?api-version={3}" .format (self ._iot_hub_url , device_id , etag , AZ_API_VER )
96
+ path_complete = "{0}/devices/{1}/messages/deviceBound/{2}?api-version={3}" .format (
97
+ self ._iot_hub_url , device_id , etag , AZ_API_VER )
96
98
if reject_message :
97
99
path_complete += '&reject'
98
100
del_status = self ._delete (path_complete , is_c2d = True )
99
- if del_status == 204 :
100
- return data [0 ]
101
- return - 1
101
+ if del_status == 204 :
102
+ return data [0 ]
103
+ return - 1
102
104
103
105
# Device Messaging
104
106
def send_device_message (self , device_id , message ):
@@ -169,7 +171,7 @@ def _post(self, path, payload, return_response=True):
169
171
self ._parse_http_status (response .status_code , response .reason )
170
172
if return_response :
171
173
return response .json ()
172
- response .close ()
174
+ return response .text
173
175
174
176
def _get (self , path , is_c2d = False ):
175
177
"""HTTP GET
0 commit comments