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:
39:2719651a5bee
Parent:
38:a05929a75111
Child:
40:1a94db9139ea
--- a/iothub_client_ll.c	Fri Apr 08 13:24:33 2016 -0700
+++ b/iothub_client_ll.c	Sun Apr 24 16:40:16 2016 -0700
@@ -17,7 +17,7 @@
 #include "iothub_client_version.h"
 #include "iothub_transport_ll.h"
 
-#define LOG_ERROR LogError("result = %s\r\n", ENUM_TO_STRING(IOTHUB_CLIENT_RESULT, result));
+#define LOG_ERROR LogError("result = %s", ENUM_TO_STRING(IOTHUB_CLIENT_RESULT, result));
 #define INDEFINITE_TIME ((time_t)(-1))
 
 DEFINE_ENUM_STRINGS(IOTHUB_CLIENT_RESULT, IOTHUB_CLIENT_RESULT_VALUES);
@@ -47,16 +47,16 @@
 
     /*Codes_SRS_IOTHUBCLIENT_LL_05_001: [IoTHubClient_LL_CreateFromConnectionString shall obtain the version string by a call to IoTHubClient_GetVersionString.]*/
     /*Codes_SRS_IOTHUBCLIENT_LL_05_002: [IoTHubClient_LL_CreateFromConnectionString shall print the version string to standard output.]*/
-    LogInfo("IoT Hub SDK for C, version %s\r\n", IoTHubClient_GetVersionString());
+    LogInfo("IoT Hub SDK for C, version %s", IoTHubClient_GetVersionString());
 
     /* SRS_IOTHUBCLIENT_LL_12_003: [IoTHubClient_LL_CreateFromConnectionString shall verify the input parameter and if it is NULL then return NULL] */
     if (connectionString == NULL)
     {
-        LogError("Input parameter is NULL: connectionString\r\n");
+        LogError("Input parameter is NULL: connectionString");
     }
     else if (protocol == NULL)
     {
-        LogError("Input parameter is NULL: protocol\r\n");
+        LogError("Input parameter is NULL: protocol");
     }
     else
     {
@@ -65,7 +65,7 @@
         if (config == NULL)
         {
             /* SRS_IOTHUBCLIENT_LL_12_012: [If the allocation failed IoTHubClient_LL_CreateFromConnectionString  returns NULL]  */
-            LogError("Malloc failed\r\n");
+            LogError("Malloc failed");
             return NULL;
         }
         else
@@ -91,27 +91,27 @@
 
             if ((connString = STRING_construct(connectionString)) == NULL)
             {
-                LogError("Error constructing connectiong String\r\n");
+                LogError("Error constructing connectiong String");
             }
             else if ((tokenizer1 = STRING_TOKENIZER_create(connString)) == NULL)
             {
-                LogError("Error creating Tokenizer\r\n");
+                LogError("Error creating Tokenizer");
             }
             else if ((tokenString = STRING_new()) == NULL)
             {
-                LogError("Error creating Token String\r\n");
+                LogError("Error creating Token String");
             }
             else if ((valueString = STRING_new()) == NULL)
             {
-                LogError("Error creating Value String\r\n");
+                LogError("Error creating Value String");
             }
             else if ((hostNameString = STRING_new()) == NULL)
             {
-                LogError("Error creating HostName String\r\n");
+                LogError("Error creating HostName String");
             }
             else if ((hostSuffixString = STRING_new()) == NULL)
             {
-                LogError("Error creating HostSuffix String\r\n");
+                LogError("Error creating HostSuffix String");
             }
             /* SRS_IOTHUBCLIENT_LL_12_005: [IoTHubClient_LL_CreateFromConnectionString shall try to parse the connectionString input parameter for the following structure: "Key1=value1;key2=value2;key3=value3..."] */
             /* SRS_IOTHUBCLIENT_LL_12_006: [IoTHubClient_LL_CreateFromConnectionString shall verify the existence of the following Key/Value pairs in the connection string: HostName, DeviceId, SharedAccessKey.]  */
@@ -121,7 +121,7 @@
                 {
                     if (STRING_TOKENIZER_get_next_token(tokenizer1, valueString, ";") != 0)
                     {
-                        LogError("Tokenizer error\r\n");
+                        LogError("Tokenizer error");
                         break;
                     }
                     else
@@ -136,7 +136,7 @@
                                 STRING_TOKENIZER_HANDLE tokenizer2 = NULL;
                                 if ((tokenizer2 = STRING_TOKENIZER_create(valueString)) == NULL)
                                 {
-                                    LogError("Error creating Tokenizer\r\n");
+                                    LogError("Error creating Tokenizer");
                                     break;
                                 }
                                 else
@@ -144,7 +144,7 @@
                                     /* SRS_IOTHUBCLIENT_LL_12_015: [If the string split failed, IoTHubClient_LL_CreateFromConnectionString returns NULL ] */
                                     if (STRING_TOKENIZER_get_next_token(tokenizer2, hostNameString, ".") != 0)
                                     {
-                                        LogError("Tokenizer error\r\n");
+                                        LogError("Tokenizer error");
                                         STRING_TOKENIZER_destroy(tokenizer2);
                                         break;
                                     }
@@ -153,7 +153,7 @@
                                         config->iotHubName = STRING_c_str(hostNameString);
                                         if (STRING_TOKENIZER_get_next_token(tokenizer2, hostSuffixString, ";") != 0)
                                         {
-                                            LogError("Tokenizer error\r\n");
+                                            LogError("Tokenizer error");
                                             STRING_TOKENIZER_destroy(tokenizer2);
                                             break;
                                         }
@@ -196,19 +196,19 @@
                 /* parsing is done - check the result */
                 if (config->iotHubName == NULL)
                 {
-                    LogError("iotHubName is not found\r\n");
+                    LogError("iotHubName is not found");
                 }
                 else if (config->iotHubSuffix == NULL)
                 {
-                    LogError("iotHubSuffix is not found\r\n");
+                    LogError("iotHubSuffix is not found");
                 }
                 else if (config->deviceId == NULL)
                 {
-                    LogError("deviceId is not found\r\n");
+                    LogError("deviceId is not found");
                 }
                 else if (config->deviceKey == NULL)
                 {
-                    LogError("deviceId is not found\r\n");
+                    LogError("deviceId is not found");
                 }
                 else
                 {
@@ -216,7 +216,7 @@
                     result = IoTHubClient_LL_Create(config);
                     if (result == NULL)
                     {
-                        LogError("IoTHubClient_LL_Create failed\r\n");
+                        LogError("IoTHubClient_LL_Create failed");
                     }
                 }
             }
@@ -270,14 +270,14 @@
         )
     {
         result = NULL;
-        LogError("invalid configuration (NULL detected)\r\n");
+        LogError("invalid configuration (NULL detected)");
     }
     else
     {
         IOTHUB_CLIENT_LL_HANDLE_DATA* handleData = (IOTHUB_CLIENT_LL_HANDLE_DATA*)malloc(sizeof(IOTHUB_CLIENT_LL_HANDLE_DATA));
         if (handleData == NULL)
         {
-            LogError("malloc failed\r\n");
+            LogError("malloc failed");
             result = NULL;
         }
         else
@@ -303,7 +303,7 @@
             /*Codes_SRS_IOTHUBCLIENT_LL_02_007: [If the underlaying layer _Create function fails them IoTHubClient_LL_Create shall fail and return NULL.] */
             if ((handleData->transportHandle = handleData->IoTHubTransport_Create(&lowerLayerConfig)) == NULL)
             {
-                LogError("underlying transport failed\r\n");
+                LogError("underlying transport failed");
                     tickcounter_destroy(handleData->tickCounter);
                 free(handleData);
                 result = NULL;
@@ -347,7 +347,7 @@
 		)
 	{
 		result = NULL;
-		LogError("invalid configuration (NULL detected)\r\n");
+		LogError("invalid configuration (NULL detected)");
 	}
 	else
 	{
@@ -356,7 +356,7 @@
 		if (handleData == NULL)
 		{
 			/*Codes_SRS_IOTHUBCLIENT_LL_17_003: [If allocation fails, the function shall fail and return NULL.] */
-			LogError("malloc failed\r\n");
+			LogError("malloc failed");
 			result = NULL;
 		}
 		else
@@ -636,7 +636,7 @@
         )
     {
         /*"shall return"*/
-        LogError("invalid arg\r\n");
+        LogError("invalid arg");
     }
     else
     {
@@ -663,7 +663,7 @@
     /*Codes_SRS_IOTHUBCLIENT_LL_02_029: [If parameter handle is NULL then IoTHubClient_LL_MessageCallback shall return IOTHUBMESSAGE_ABANDONED.] */
     if (handle == NULL)
     {
-        LogError("invalid argument\r\n");
+        LogError("invalid argument");
         result = IOTHUBMESSAGE_ABANDONED;
     }
     else
@@ -681,7 +681,7 @@
         else
         {
             /*Codes_SRS_IOTHUBCLIENT_LL_02_032: [If the last callback function was NULL, then IoTHubClient_LL_MessageCallback  shall return IOTHUBMESSAGE_ABANDONED.] */
-            LogError("user callback was NULL\r\n");
+            LogError("user callback was NULL");
             result = IOTHUBMESSAGE_ABANDONED;
         }
     }
@@ -734,7 +734,7 @@
         )
     {
         result = IOTHUB_CLIENT_INVALID_ARG;
-        LogError("invalid argument (NULL)\r\n");
+        LogError("invalid argument (NULL)");
     }
     else
     {
@@ -755,7 +755,7 @@
 
         if (result != IOTHUB_CLIENT_OK)
         {
-            LogError("underlying transport failed, returned = %s\r\n", ENUM_TO_STRING(IOTHUB_CLIENT_RESULT, result));
+            LogError("underlying transport failed, returned = %s", ENUM_TO_STRING(IOTHUB_CLIENT_RESULT, result));
         }
         }
     }