Microsoft Azure IoTHub client libraries

Dependents:   sht15_remote_monitoring RobotArmDemo iothub_client_sample_amqp f767zi_mqtt ... more

This library implements the Microsoft Azure IoTHub client library. The code is replicated from https://github.com/Azure/azure-iot-sdks

Revision:
92:97148cf9aa2a
Parent:
88:248736be106e
--- a/iothub_client_ll_uploadtoblob.c	Thu Jul 12 18:09:13 2018 -0700
+++ b/iothub_client_ll_uploadtoblob.c	Tue Sep 11 11:13:11 2018 -0700
@@ -57,6 +57,13 @@
     const char* x509privatekey;
 }UPLOADTOBLOB_X509_CREDENTIALS;
 
+typedef enum UPOADTOBLOB_CURL_VERBOSITY_TAG
+{
+    UPOADTOBLOB_CURL_VERBOSITY_UNSET,
+    UPOADTOBLOB_CURL_VERBOSITY_ON,
+    UPOADTOBLOB_CURL_VERBOSITY_OFF
+} UPOADTOBLOB_CURL_VERBOSITY;
+
 typedef struct IOTHUB_CLIENT_LL_UPLOADTOBLOB_HANDLE_DATA_TAG
 {
     STRING_HANDLE deviceId;                     /*needed for file upload*/
@@ -69,7 +76,7 @@
     } credentials;                              /*needed for file upload*/
     char* certificates; /*if there are any certificates used*/
     HTTP_PROXY_OPTIONS http_proxy_options;
-    size_t curl_verbose;
+    UPOADTOBLOB_CURL_VERBOSITY curl_verbosity_level;
     size_t blob_upload_timeout_secs;
 }IOTHUB_CLIENT_LL_UPLOADTOBLOB_HANDLE_DATA;
 
@@ -122,7 +129,7 @@
 
                 handleData->certificates = NULL;
                 memset(&(handleData->http_proxy_options), 0, sizeof(HTTP_PROXY_OPTIONS));
-                handleData->curl_verbose = 0;
+                handleData->curl_verbosity_level = UPOADTOBLOB_CURL_VERBOSITY_UNSET;
                 handleData->blob_upload_timeout_secs = 0;
 
                 if ((config->deviceSasToken != NULL) && (config->deviceKey == NULL))
@@ -170,7 +177,7 @@
         }
     }
     return (IOTHUB_CLIENT_LL_UPLOADTOBLOB_HANDLE)handleData;
-    
+
 }
 
 /*returns 0 when correlationId, sasUri contain data*/
@@ -531,7 +538,7 @@
                                                                         {
                                                                             /*Codes_SRS_IOTHUBCLIENT_LL_32_008: [ The returned file name shall be URL encoded before passing back to the cloud. ]*/
                                                                             STRING_HANDLE fileName = URL_EncodeString(json_blobName);
-                                                                            
+
                                                                             if (fileName == NULL)
                                                                             {
                                                                                 /*Codes_SRS_IOTHUBCLIENT_LL_32_009: [ If URL_EncodeString fails then IoTHubClient_LL_UploadMultipleBlocksToBlob(Ex) shall fail and return IOTHUB_CLIENT_ERROR. ]*/
@@ -539,7 +546,7 @@
                                                                                 result = __FAILURE__;
                                                                             }
 
-                                                                            else 
+                                                                            else
                                                                             {
                                                                                 if (!(
                                                                                     (STRING_concat(sasUri, json_hostName) == 0) &&
@@ -558,9 +565,9 @@
                                                                                 {
                                                                                     result = 0; /*success in step 1*/
                                                                                 }
-                                                                                
+
                                                                                 STRING_delete(fileName);
-                                                                            }	
+                                                                            }
                                                                         }
                                                                     }
                                                                 }
@@ -859,7 +866,11 @@
         }
         else
         {
-            (void)HTTPAPIEX_SetOption(iotHubHttpApiExHandle, OPTION_CURL_VERBOSE, &handleData->curl_verbose);
+            if (handleData->curl_verbosity_level != UPOADTOBLOB_CURL_VERBOSITY_UNSET)
+            {
+                size_t curl_verbose = (handleData->curl_verbosity_level == UPOADTOBLOB_CURL_VERBOSITY_ON);
+                (void)HTTPAPIEX_SetOption(iotHubHttpApiExHandle, OPTION_CURL_VERBOSE, &curl_verbose);
+            }
 
             if (
                 (handleData->authorizationScheme == X509) &&
@@ -1047,12 +1058,12 @@
             }
             HTTPAPIEX_Destroy(iotHubHttpApiExHandle);
         }
+
+        /*Codes_SRS_IOTHUBCLIENT_LL_99_003: [ If `IoTHubClient_LL_UploadMultipleBlocksToBlob(Ex)` return `IOTHUB_CLIENT_OK`, it shall call `getDataCallbackEx` with `result` set to `FILE_UPLOAD_OK`, and `data` and `size` set to NULL. ]*/
+        /*Codes_SRS_IOTHUBCLIENT_LL_99_004: [ If `IoTHubClient_LL_UploadMultipleBlocksToBlob(Ex)` does not return `IOTHUB_CLIENT_OK`, it shall call `getDataCallbackEx` with `result` set to `FILE_UPLOAD_ERROR`, and `data` and `size` set to NULL. ]*/
+        (void)getDataCallbackEx(result == IOTHUB_CLIENT_OK ? FILE_UPLOAD_OK : FILE_UPLOAD_ERROR, NULL, NULL, context);
     }
 
-    /*Codes_SRS_IOTHUBCLIENT_LL_99_003: [ If `IoTHubClient_LL_UploadMultipleBlocksToBlob(Ex)` return `IOTHUB_CLIENT_OK`, it shall call `getDataCallbackEx` with `result` set to `FILE_UPLOAD_OK`, and `data` and `size` set to NULL. ]*/
-    /*Codes_SRS_IOTHUBCLIENT_LL_99_004: [ If `IoTHubClient_LL_UploadMultipleBlocksToBlob(Ex)` does not return `IOTHUB_CLIENT_OK`, it shall call `getDataCallbackEx` with `result` set to `FILE_UPLOAD_ERROR`, and `data` and `size` set to NULL. ]*/
-    (void)getDataCallbackEx(result == IOTHUB_CLIENT_OK ? FILE_UPLOAD_OK : FILE_UPLOAD_ERROR, NULL, NULL, context);
-
     return result;
 }
 
@@ -1248,7 +1259,7 @@
         else if (strcmp(optionName, OPTION_HTTP_PROXY) == 0)
         {
             HTTP_PROXY_OPTIONS* proxy_options = (HTTP_PROXY_OPTIONS *)value;
-            
+
             if (proxy_options->host_address == NULL)
             {
                 /* Codes_SRS_IOTHUBCLIENT_LL_32_006: [ If `host_address` is NULL, `IoTHubClient_LL_UploadToBlob_SetOption` shall fail and return `IOTHUB_CLIENT_INVALID_ARG`. ]*/
@@ -1279,7 +1290,7 @@
                     free((char *)handleData->http_proxy_options.password);
                     handleData->http_proxy_options.password = NULL;
                 }
-                
+
                 handleData->http_proxy_options.port = proxy_options->port;
 
                 if (mallocAndStrcpy_s((char **)(&handleData->http_proxy_options.host_address), proxy_options->host_address) != 0)
@@ -1305,7 +1316,7 @@
         }
         else if (strcmp(optionName, OPTION_CURL_VERBOSE) == 0)
         {
-            handleData->curl_verbose = *(size_t*)value;
+            handleData->curl_verbosity_level = ((*(bool*)value) == 0) ? UPOADTOBLOB_CURL_VERBOSITY_OFF : UPOADTOBLOB_CURL_VERBOSITY_ON;
             result = IOTHUB_CLIENT_OK;
         }
         else if (strcmp(optionName, OPTION_BLOB_UPLOAD_TIMEOUT_SECS) == 0)