IoTHub raw messaging client sample using AMQP
Dependencies: iothub_client EthernetInterface NTPClient iothub_amqp_transport azure_c_shared_utility mbed-rtos mbed azure_uamqp_c wolfSSL
This sample showcases the usage of Azure IoT client libraries with the AMQP transport for sending/receiving raw messages from an IoT Hub.
Diff: iothub_client_sample_amqp.c
- Revision:
- 63:14e9684b52e3
- Parent:
- 60:ae07786385f9
- Child:
- 69:06d895ef6bfc
--- a/iothub_client_sample_amqp.c Fri Feb 10 17:01:57 2017 -0800 +++ b/iothub_client_sample_amqp.c Fri Feb 24 14:02:03 2017 -0800 @@ -42,7 +42,7 @@ const char* messageId; const char* correlationId; - // AMQP message properties + // Message properties if ((messageId = IoTHubMessage_GetMessageId(message)) == NULL) { messageId = "<null>"; @@ -53,14 +53,14 @@ correlationId = "<null>"; } - // AMQP message content. + // Message content IOTHUBMESSAGE_CONTENT_TYPE contentType = IoTHubMessage_GetContentType(message); if (contentType == IOTHUBMESSAGE_BYTEARRAY) { if (IoTHubMessage_GetByteArray(message, &buffer, &size) == IOTHUB_MESSAGE_OK) { - (void)printf("Received Message [%d] (message-id: %s, correlation-id: %s) with BINARY Data: <<<%.*s>>> & Size=%d\r\n", *counter, messageId, correlationId,(int)size, buffer, (int)size); + (void)printf("Received Message [%d]\r\n Message ID: %s\r\n Correlation ID: %s\r\n BINARY Data: <<<%.*s>>> & Size=%d\r\n", *counter, messageId, correlationId, (int)size, buffer, (int)size); } else { @@ -71,7 +71,7 @@ { if ((buffer = (const unsigned char*)IoTHubMessage_GetString(message)) != NULL && (size = strlen((const char*)buffer)) > 0) { - (void)printf("Received Message [%d] (message-id: %s, correlation-id: %s) with STRING Data: <<<%.*s>>> & Size=%d\r\n", *counter, messageId, correlationId, (int)size, buffer, (int)size); + (void)printf("Received Message [%d]\r\n Message ID: %s\r\n Correlation ID: %s\r\n STRING Data: <<<%.*s>>> & Size=%d\r\n", *counter, messageId, correlationId, (int)size, buffer, (int)size); // If we receive the work 'quit' then we stop running } @@ -98,7 +98,7 @@ { size_t index; - printf("Message Properties:\r\n"); + printf(" Message Properties:\r\n"); for (index = 0; index < propertyCount; index++) { printf("\tKey: %s Value: %s\r\n", keys[index], values[index]);