IoTHub raw messaging client sample using MQTT

Dependencies:   EthernetInterface NTPClient mbed-rtos mbed wolfSSL azure_c_shared_utility iothub_client azure_umqtt_c iothub_mqtt_transport

Revision:
30:0a147a179e7e
Parent:
27:7c908b91210a
Child:
36:eb9d95ee6d63
--- a/iothub_client_sample_mqtt.c	Fri Feb 10 17:02:35 2017 -0800
+++ b/iothub_client_sample_mqtt.c	Fri Feb 24 14:02:44 2017 -0800
@@ -39,23 +39,38 @@
     int* counter = (int*)userContextCallback;
     const char* buffer;
     size_t size;
+    MAP_HANDLE mapProperties;
+    const char* messageId;
+    const char* correlationId;
 
+    // Message properties
+    if ((messageId = IoTHubMessage_GetMessageId(message)) == NULL)
+    {
+        messageId = "<null>";
+    }
+
+    if ((correlationId = IoTHubMessage_GetCorrelationId(message)) == NULL)
+    {
+        correlationId = "<null>";
+    }
+
+    // Message content
     if (IoTHubMessage_GetByteArray(message, (const unsigned char**)&buffer, &size) != IOTHUB_MESSAGE_OK)
     {
         (void)printf("unable to retrieve the message data\r\n");
     }
     else
     {
-        (void)printf("Received Message [%d] with Data: <<<%.*s>>> & Size=%d\r\n", *counter, (int)size, buffer, (int)size);
+        (void)printf("Received Message [%d]\r\n Message ID: %s\r\n Correlation ID: %s\r\n Data: <<<%.*s>>> & Size=%d\r\n", *counter, messageId, correlationId, (int)size, buffer, (int)size);
         // If we receive the work 'quit' then we stop running
-		if (size == (strlen("quit") * sizeof(char)) && memcmp(buffer, "quit", size) == 0)
+        if (size == (strlen("quit") * sizeof(char)) && memcmp(buffer, "quit", size) == 0)
         {
             g_continueRunning = false;
         }
     }
 
     // Retrieve properties from the message
-    MAP_HANDLE mapProperties = IoTHubMessage_Properties(message);
+    mapProperties = IoTHubMessage_Properties(message);
     if (mapProperties != NULL)
     {
         const char*const* keys;
@@ -65,7 +80,9 @@
         {
             if (propertyCount > 0)
             {
-                size_t index = 0;
+                size_t index;
+
+                printf(" Message Properties:\r\n");
                 for (index = 0; index < propertyCount; index++)
                 {
                     (void)printf("\tKey: %s Value: %s\r\n", keys[index], values[index]);