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.
iothub_client_sample_amqp.c@79:21537a6b9511, 2017-09-11 (annotated)
- Committer:
- AzureIoTClient
- Date:
- Mon Sep 11 09:24:14 2017 -0700
- Revision:
- 79:21537a6b9511
- Parent:
- 78:7acff4261af4
- Child:
- 80:ea6f6bd92023
1.1.23
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AzureIoTClient | 17:d01a2794d5d7 | 1 | // Copyright (c) Microsoft. All rights reserved. |
AzureIoTClient | 17:d01a2794d5d7 | 2 | // Licensed under the MIT license. See LICENSE file in the project root for full license information. |
AzureIoTClient | 17:d01a2794d5d7 | 3 | |
AzureIoTClient | 17:d01a2794d5d7 | 4 | #include <stdio.h> |
AzureIoTClient | 17:d01a2794d5d7 | 5 | #include <stdlib.h> |
AzureIoTClient | 17:d01a2794d5d7 | 6 | |
AzureIoTClient | 39:87752a84df87 | 7 | #include "azure_c_shared_utility/platform.h" |
Azure.IoT Build | 47:d87920c7f211 | 8 | #include "azure_c_shared_utility/threadapi.h" |
Azure.IoT Build | 47:d87920c7f211 | 9 | #include "azure_c_shared_utility/crt_abstractions.h" |
AzureIoTClient | 17:d01a2794d5d7 | 10 | #include "iothub_client.h" |
AzureIoTClient | 79:21537a6b9511 | 11 | #include "iothub_client_options.h" |
AzureIoTClient | 17:d01a2794d5d7 | 12 | #include "iothub_message.h" |
AzureIoTClient | 17:d01a2794d5d7 | 13 | #include "iothubtransportamqp.h" |
AzureIoTClient | 17:d01a2794d5d7 | 14 | |
AzureIoTClient | 17:d01a2794d5d7 | 15 | #ifdef MBED_BUILD_TIMESTAMP |
AzureIoTClient | 79:21537a6b9511 | 16 | #define SET_TRUSTED_CERT_IN_SAMPLES |
AzureIoTClient | 79:21537a6b9511 | 17 | #endif // MBED_BUILD_TIMESTAMP |
AzureIoTClient | 79:21537a6b9511 | 18 | |
AzureIoTClient | 79:21537a6b9511 | 19 | #ifdef SET_TRUSTED_CERT_IN_SAMPLES |
AzureIoTClient | 17:d01a2794d5d7 | 20 | #include "certs.h" |
AzureIoTClient | 79:21537a6b9511 | 21 | #endif // SET_TRUSTED_CERT_IN_SAMPLES |
AzureIoTClient | 17:d01a2794d5d7 | 22 | |
AzureIoTClient | 40:548ef685e177 | 23 | /*String containing Hostname, Device Id & Device Key in the format: */ |
AzureIoTClient | 40:548ef685e177 | 24 | /* "HostName=<host_name>;DeviceId=<device_id>;SharedAccessKey=<device_key>" */ |
AzureIoTClient | 40:548ef685e177 | 25 | /* "HostName=<host_name>;DeviceId=<device_id>;SharedAccessSignature=<device_sas_token>" */ |
AzureIoTClient | 28:a1105bba4bb1 | 26 | static const char* connectionString = "[device connection string]"; |
AzureIoTClient | 40:548ef685e177 | 27 | |
AzureIoTClient | 17:d01a2794d5d7 | 28 | static int callbackCounter; |
AzureIoTClient | 43:a4b2614eb860 | 29 | static bool g_continueRunning; |
Azure.IoT Build | 47:d87920c7f211 | 30 | static char msgText[1024]; |
Azure.IoT Build | 47:d87920c7f211 | 31 | static char propText[1024]; |
Azure.IoT Build | 47:d87920c7f211 | 32 | #define MESSAGE_COUNT 5 |
Azure.IoT Build | 47:d87920c7f211 | 33 | #define DOWORK_LOOP_NUM 3 |
AzureIoTClient | 17:d01a2794d5d7 | 34 | |
AzureIoTClient | 17:d01a2794d5d7 | 35 | typedef struct EVENT_INSTANCE_TAG |
AzureIoTClient | 17:d01a2794d5d7 | 36 | { |
AzureIoTClient | 17:d01a2794d5d7 | 37 | IOTHUB_MESSAGE_HANDLE messageHandle; |
AzureIoTClient | 48:ecd0964514f8 | 38 | size_t messageTrackingId; // For tracking the messages within the user callback. |
AzureIoTClient | 17:d01a2794d5d7 | 39 | } EVENT_INSTANCE; |
AzureIoTClient | 17:d01a2794d5d7 | 40 | |
AzureIoTClient | 17:d01a2794d5d7 | 41 | static IOTHUBMESSAGE_DISPOSITION_RESULT ReceiveMessageCallback(IOTHUB_MESSAGE_HANDLE message, void* userContextCallback) |
AzureIoTClient | 17:d01a2794d5d7 | 42 | { |
AzureIoTClient | 17:d01a2794d5d7 | 43 | int* counter = (int*)userContextCallback; |
Azure.IoT Build | 31:7a8aed41e109 | 44 | const unsigned char* buffer = NULL; |
Azure.IoT Build | 31:7a8aed41e109 | 45 | size_t size = 0; |
AzureIoTClient | 43:a4b2614eb860 | 46 | const char* messageId; |
AzureIoTClient | 43:a4b2614eb860 | 47 | const char* correlationId; |
AzureIoTClient | 78:7acff4261af4 | 48 | const char* userDefinedContentType; |
AzureIoTClient | 78:7acff4261af4 | 49 | const char* userDefinedContentEncoding; |
AzureIoTClient | 40:548ef685e177 | 50 | |
AzureIoTClient | 63:14e9684b52e3 | 51 | // Message properties |
AzureIoTClient | 43:a4b2614eb860 | 52 | if ((messageId = IoTHubMessage_GetMessageId(message)) == NULL) |
AzureIoTClient | 43:a4b2614eb860 | 53 | { |
AzureIoTClient | 43:a4b2614eb860 | 54 | messageId = "<null>"; |
AzureIoTClient | 43:a4b2614eb860 | 55 | } |
AzureIoTClient | 40:548ef685e177 | 56 | |
AzureIoTClient | 43:a4b2614eb860 | 57 | if ((correlationId = IoTHubMessage_GetCorrelationId(message)) == NULL) |
AzureIoTClient | 43:a4b2614eb860 | 58 | { |
AzureIoTClient | 43:a4b2614eb860 | 59 | correlationId = "<null>"; |
AzureIoTClient | 43:a4b2614eb860 | 60 | } |
AzureIoTClient | 40:548ef685e177 | 61 | |
AzureIoTClient | 78:7acff4261af4 | 62 | if ((userDefinedContentType = IoTHubMessage_GetContentTypeSystemProperty(message)) == NULL) |
AzureIoTClient | 78:7acff4261af4 | 63 | { |
AzureIoTClient | 78:7acff4261af4 | 64 | userDefinedContentType = "<null>"; |
AzureIoTClient | 78:7acff4261af4 | 65 | } |
AzureIoTClient | 78:7acff4261af4 | 66 | |
AzureIoTClient | 78:7acff4261af4 | 67 | if ((userDefinedContentEncoding = IoTHubMessage_GetContentEncodingSystemProperty(message)) == NULL) |
AzureIoTClient | 78:7acff4261af4 | 68 | { |
AzureIoTClient | 78:7acff4261af4 | 69 | userDefinedContentEncoding = "<null>"; |
AzureIoTClient | 78:7acff4261af4 | 70 | } |
AzureIoTClient | 78:7acff4261af4 | 71 | |
AzureIoTClient | 63:14e9684b52e3 | 72 | // Message content |
Azure.IoT Build | 31:7a8aed41e109 | 73 | IOTHUBMESSAGE_CONTENT_TYPE contentType = IoTHubMessage_GetContentType(message); |
AzureIoTClient | 19:de28463ff3cc | 74 | |
Azure.IoT Build | 31:7a8aed41e109 | 75 | if (contentType == IOTHUBMESSAGE_BYTEARRAY) |
Azure.IoT Build | 31:7a8aed41e109 | 76 | { |
Azure.IoT Build | 31:7a8aed41e109 | 77 | if (IoTHubMessage_GetByteArray(message, &buffer, &size) == IOTHUB_MESSAGE_OK) |
Azure.IoT Build | 31:7a8aed41e109 | 78 | { |
AzureIoTClient | 78:7acff4261af4 | 79 | (void)printf("Received Message [%d]\r\n Message ID: %s\r\n Correlation ID: %s\r\n Content-Type: %s\r\n Content-Encoding: %s\r\n BINARY Data: <<<%.*s>>> & Size=%d\r\n", |
AzureIoTClient | 78:7acff4261af4 | 80 | *counter, messageId, correlationId, userDefinedContentType, userDefinedContentEncoding, (int)size, buffer, (int)size); |
Azure.IoT Build | 31:7a8aed41e109 | 81 | } |
Azure.IoT Build | 31:7a8aed41e109 | 82 | else |
Azure.IoT Build | 31:7a8aed41e109 | 83 | { |
Azure.IoT Build | 31:7a8aed41e109 | 84 | (void)printf("Failed getting the BINARY body of the message received.\r\n"); |
Azure.IoT Build | 31:7a8aed41e109 | 85 | } |
Azure.IoT Build | 31:7a8aed41e109 | 86 | } |
Azure.IoT Build | 31:7a8aed41e109 | 87 | else if (contentType == IOTHUBMESSAGE_STRING) |
AzureIoTClient | 17:d01a2794d5d7 | 88 | { |
AzureIoTClient | 48:ecd0964514f8 | 89 | if ((buffer = (const unsigned char*)IoTHubMessage_GetString(message)) != NULL && (size = strlen((const char*)buffer)) > 0) |
Azure.IoT Build | 31:7a8aed41e109 | 90 | { |
AzureIoTClient | 78:7acff4261af4 | 91 | (void)printf("Received Message [%d]\r\n Message ID: %s\r\n Correlation ID: %s\r\n Content-Type: %s\r\n Content-Encoding: %s\r\n STRING Data: <<<%.*s>>> & Size=%d\r\n", |
AzureIoTClient | 78:7acff4261af4 | 92 | *counter, messageId, correlationId, userDefinedContentType, userDefinedContentEncoding, (int)size, buffer, (int)size); |
AzureIoTClient | 43:a4b2614eb860 | 93 | |
AzureIoTClient | 43:a4b2614eb860 | 94 | // If we receive the work 'quit' then we stop running |
Azure.IoT Build | 31:7a8aed41e109 | 95 | } |
Azure.IoT Build | 31:7a8aed41e109 | 96 | else |
Azure.IoT Build | 31:7a8aed41e109 | 97 | { |
Azure.IoT Build | 31:7a8aed41e109 | 98 | (void)printf("Failed getting the STRING body of the message received.\r\n"); |
Azure.IoT Build | 31:7a8aed41e109 | 99 | } |
Azure.IoT Build | 31:7a8aed41e109 | 100 | } |
Azure.IoT Build | 31:7a8aed41e109 | 101 | else |
Azure.IoT Build | 31:7a8aed41e109 | 102 | { |
Azure.IoT Build | 31:7a8aed41e109 | 103 | (void)printf("Failed getting the body of the message received (type %i).\r\n", contentType); |
AzureIoTClient | 17:d01a2794d5d7 | 104 | } |
AzureIoTClient | 17:d01a2794d5d7 | 105 | |
AzureIoTClient | 17:d01a2794d5d7 | 106 | // Retrieve properties from the message |
AzureIoTClient | 17:d01a2794d5d7 | 107 | MAP_HANDLE mapProperties = IoTHubMessage_Properties(message); |
AzureIoTClient | 17:d01a2794d5d7 | 108 | if (mapProperties != NULL) |
AzureIoTClient | 17:d01a2794d5d7 | 109 | { |
AzureIoTClient | 17:d01a2794d5d7 | 110 | const char*const* keys; |
AzureIoTClient | 17:d01a2794d5d7 | 111 | const char*const* values; |
AzureIoTClient | 17:d01a2794d5d7 | 112 | size_t propertyCount = 0; |
AzureIoTClient | 17:d01a2794d5d7 | 113 | if (Map_GetInternals(mapProperties, &keys, &values, &propertyCount) == MAP_OK) |
AzureIoTClient | 17:d01a2794d5d7 | 114 | { |
AzureIoTClient | 17:d01a2794d5d7 | 115 | if (propertyCount > 0) |
AzureIoTClient | 17:d01a2794d5d7 | 116 | { |
Azure.IoT Build | 31:7a8aed41e109 | 117 | size_t index; |
Azure.IoT Build | 31:7a8aed41e109 | 118 | |
AzureIoTClient | 63:14e9684b52e3 | 119 | printf(" Message Properties:\r\n"); |
Azure.IoT Build | 31:7a8aed41e109 | 120 | for (index = 0; index < propertyCount; index++) |
AzureIoTClient | 17:d01a2794d5d7 | 121 | { |
AzureIoTClient | 17:d01a2794d5d7 | 122 | printf("\tKey: %s Value: %s\r\n", keys[index], values[index]); |
AzureIoTClient | 17:d01a2794d5d7 | 123 | } |
AzureIoTClient | 17:d01a2794d5d7 | 124 | printf("\r\n"); |
AzureIoTClient | 17:d01a2794d5d7 | 125 | } |
AzureIoTClient | 17:d01a2794d5d7 | 126 | } |
AzureIoTClient | 17:d01a2794d5d7 | 127 | } |
AzureIoTClient | 17:d01a2794d5d7 | 128 | |
AzureIoTClient | 69:06d895ef6bfc | 129 | if (size == (strlen("quit") * sizeof(char)) && memcmp(buffer, "quit", size) == 0) |
AzureIoTClient | 43:a4b2614eb860 | 130 | { |
AzureIoTClient | 43:a4b2614eb860 | 131 | g_continueRunning = false; |
AzureIoTClient | 43:a4b2614eb860 | 132 | } |
AzureIoTClient | 43:a4b2614eb860 | 133 | |
AzureIoTClient | 17:d01a2794d5d7 | 134 | /* Some device specific action code goes here... */ |
AzureIoTClient | 17:d01a2794d5d7 | 135 | (*counter)++; |
AzureIoTClient | 17:d01a2794d5d7 | 136 | return IOTHUBMESSAGE_ACCEPTED; |
AzureIoTClient | 17:d01a2794d5d7 | 137 | } |
AzureIoTClient | 17:d01a2794d5d7 | 138 | |
AzureIoTClient | 17:d01a2794d5d7 | 139 | static void SendConfirmationCallback(IOTHUB_CLIENT_CONFIRMATION_RESULT result, void* userContextCallback) |
AzureIoTClient | 17:d01a2794d5d7 | 140 | { |
AzureIoTClient | 17:d01a2794d5d7 | 141 | EVENT_INSTANCE* eventInstance = (EVENT_INSTANCE*)userContextCallback; |
AzureIoTClient | 48:ecd0964514f8 | 142 | (void)printf("Confirmation[%d] received for message tracking id = %zu with result = %s\r\n", callbackCounter, eventInstance->messageTrackingId, ENUM_TO_STRING(IOTHUB_CLIENT_CONFIRMATION_RESULT, result)); |
AzureIoTClient | 17:d01a2794d5d7 | 143 | /* Some device specific action code goes here... */ |
AzureIoTClient | 17:d01a2794d5d7 | 144 | callbackCounter++; |
AzureIoTClient | 17:d01a2794d5d7 | 145 | IoTHubMessage_Destroy(eventInstance->messageHandle); |
AzureIoTClient | 17:d01a2794d5d7 | 146 | } |
AzureIoTClient | 17:d01a2794d5d7 | 147 | |
AzureIoTClient | 17:d01a2794d5d7 | 148 | void iothub_client_sample_amqp_run(void) |
Azure.IoT Build | 31:7a8aed41e109 | 149 | { |
AzureIoTClient | 43:a4b2614eb860 | 150 | IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle; |
AzureIoTClient | 17:d01a2794d5d7 | 151 | |
AzureIoTClient | 17:d01a2794d5d7 | 152 | EVENT_INSTANCE messages[MESSAGE_COUNT]; |
AzureIoTClient | 17:d01a2794d5d7 | 153 | |
AzureIoTClient | 43:a4b2614eb860 | 154 | g_continueRunning = true; |
AzureIoTClient | 17:d01a2794d5d7 | 155 | srand((unsigned int)time(NULL)); |
AzureIoTClient | 17:d01a2794d5d7 | 156 | double avgWindSpeed = 10.0; |
AzureIoTClient | 17:d01a2794d5d7 | 157 | |
AzureIoTClient | 17:d01a2794d5d7 | 158 | callbackCounter = 0; |
AzureIoTClient | 17:d01a2794d5d7 | 159 | int receiveContext = 0; |
AzureIoTClient | 17:d01a2794d5d7 | 160 | |
AzureIoTClient | 17:d01a2794d5d7 | 161 | (void)printf("Starting the IoTHub client sample AMQP...\r\n"); |
Azure.IoT Build | 34:b7f31511a8ad | 162 | |
Azure.IoT Build | 34:b7f31511a8ad | 163 | if (platform_init() != 0) |
AzureIoTClient | 17:d01a2794d5d7 | 164 | { |
Azure.IoT Build | 34:b7f31511a8ad | 165 | printf("Failed to initialize the platform.\r\n"); |
AzureIoTClient | 17:d01a2794d5d7 | 166 | } |
AzureIoTClient | 17:d01a2794d5d7 | 167 | else |
AzureIoTClient | 17:d01a2794d5d7 | 168 | { |
AzureIoTClient | 43:a4b2614eb860 | 169 | if ((iotHubClientHandle = IoTHubClient_LL_CreateFromConnectionString(connectionString, AMQP_Protocol)) == NULL) |
AzureIoTClient | 17:d01a2794d5d7 | 170 | { |
Azure.IoT Build | 34:b7f31511a8ad | 171 | (void)printf("ERROR: iotHubClientHandle is NULL!\r\n"); |
AzureIoTClient | 17:d01a2794d5d7 | 172 | } |
AzureIoTClient | 17:d01a2794d5d7 | 173 | else |
AzureIoTClient | 17:d01a2794d5d7 | 174 | { |
AzureIoTClient | 43:a4b2614eb860 | 175 | bool traceOn = true; |
AzureIoTClient | 43:a4b2614eb860 | 176 | IoTHubClient_LL_SetOption(iotHubClientHandle, "logtrace", &traceOn); |
AzureIoTClient | 17:d01a2794d5d7 | 177 | |
AzureIoTClient | 79:21537a6b9511 | 178 | // Set keep alive is optional. If it is not set the default (240 secs) will be used. |
AzureIoTClient | 74:d20e4ff30068 | 179 | uint32_t c2d_keep_alive_freq_secs = 120; |
AzureIoTClient | 79:21537a6b9511 | 180 | IoTHubClient_LL_SetOption(iotHubClientHandle, OPTION_C2D_KEEP_ALIVE_FREQ_SECS, &c2d_keep_alive_freq_secs); |
AzureIoTClient | 74:d20e4ff30068 | 181 | |
AzureIoTClient | 79:21537a6b9511 | 182 | #ifdef SET_TRUSTED_CERT_IN_SAMPLES |
Azure.IoT Build | 34:b7f31511a8ad | 183 | // For mbed add the certificate information |
AzureIoTClient | 43:a4b2614eb860 | 184 | if (IoTHubClient_LL_SetOption(iotHubClientHandle, "TrustedCerts", certificates) != IOTHUB_CLIENT_OK) |
AzureIoTClient | 17:d01a2794d5d7 | 185 | { |
Azure.IoT Build | 34:b7f31511a8ad | 186 | printf("failure to set option \"TrustedCerts\"\r\n"); |
Azure.IoT Build | 34:b7f31511a8ad | 187 | } |
AzureIoTClient | 79:21537a6b9511 | 188 | #endif // SET_TRUSTED_CERT_IN_SAMPLES |
Azure.IoT Build | 34:b7f31511a8ad | 189 | |
Azure.IoT Build | 34:b7f31511a8ad | 190 | /* Setting Message call back, so we can receive Commands. */ |
AzureIoTClient | 43:a4b2614eb860 | 191 | if (IoTHubClient_LL_SetMessageCallback(iotHubClientHandle, ReceiveMessageCallback, &receiveContext) != IOTHUB_CLIENT_OK) |
Azure.IoT Build | 34:b7f31511a8ad | 192 | { |
Azure.IoT Build | 34:b7f31511a8ad | 193 | (void)printf("ERROR: IoTHubClient_SetMessageCallback..........FAILED!\r\n"); |
Azure.IoT Build | 34:b7f31511a8ad | 194 | } |
Azure.IoT Build | 34:b7f31511a8ad | 195 | else |
Azure.IoT Build | 34:b7f31511a8ad | 196 | { |
Azure.IoT Build | 34:b7f31511a8ad | 197 | (void)printf("IoTHubClient_SetMessageCallback...successful.\r\n"); |
Azure.IoT Build | 34:b7f31511a8ad | 198 | |
Azure.IoT Build | 34:b7f31511a8ad | 199 | /* Now that we are ready to receive commands, let's send some messages */ |
AzureIoTClient | 43:a4b2614eb860 | 200 | size_t iterator = 0; |
AzureIoTClient | 43:a4b2614eb860 | 201 | do |
AzureIoTClient | 17:d01a2794d5d7 | 202 | { |
AzureIoTClient | 43:a4b2614eb860 | 203 | if (iterator < MESSAGE_COUNT) |
AzureIoTClient | 17:d01a2794d5d7 | 204 | { |
AzureIoTClient | 43:a4b2614eb860 | 205 | sprintf_s(msgText, sizeof(msgText), "{\"deviceId\":\"myFirstDevice\",\"windSpeed\":%.2f}", avgWindSpeed + (rand() % 4 + 2)); |
AzureIoTClient | 43:a4b2614eb860 | 206 | if ((messages[iterator].messageHandle = IoTHubMessage_CreateFromByteArray((const unsigned char*)msgText, strlen(msgText))) == NULL) |
Azure.IoT Build | 34:b7f31511a8ad | 207 | { |
AzureIoTClient | 43:a4b2614eb860 | 208 | (void)printf("ERROR: iotHubMessageHandle is NULL!\r\n"); |
Azure.IoT Build | 34:b7f31511a8ad | 209 | } |
Azure.IoT Build | 34:b7f31511a8ad | 210 | else |
Azure.IoT Build | 34:b7f31511a8ad | 211 | { |
AzureIoTClient | 43:a4b2614eb860 | 212 | messages[iterator].messageTrackingId = iterator; |
AzureIoTClient | 43:a4b2614eb860 | 213 | |
AzureIoTClient | 43:a4b2614eb860 | 214 | MAP_HANDLE propMap = IoTHubMessage_Properties(messages[iterator].messageHandle); |
AzureIoTClient | 48:ecd0964514f8 | 215 | (void)sprintf_s(propText, sizeof(propText), "PropMsg_%zu", iterator); |
AzureIoTClient | 43:a4b2614eb860 | 216 | if (Map_AddOrUpdate(propMap, "PropName", propText) != MAP_OK) |
AzureIoTClient | 43:a4b2614eb860 | 217 | { |
AzureIoTClient | 43:a4b2614eb860 | 218 | (void)printf("ERROR: Map_AddOrUpdate Failed!\r\n"); |
AzureIoTClient | 43:a4b2614eb860 | 219 | } |
AzureIoTClient | 43:a4b2614eb860 | 220 | |
AzureIoTClient | 78:7acff4261af4 | 221 | (void)IoTHubMessage_SetContentTypeSystemProperty(messages[iterator].messageHandle, "application/json"); |
AzureIoTClient | 78:7acff4261af4 | 222 | (void)IoTHubMessage_SetContentEncodingSystemProperty(messages[iterator].messageHandle, "utf-8"); |
AzureIoTClient | 78:7acff4261af4 | 223 | |
AzureIoTClient | 43:a4b2614eb860 | 224 | if (IoTHubClient_LL_SendEventAsync(iotHubClientHandle, messages[iterator].messageHandle, SendConfirmationCallback, &messages[iterator]) != IOTHUB_CLIENT_OK) |
AzureIoTClient | 43:a4b2614eb860 | 225 | { |
AzureIoTClient | 43:a4b2614eb860 | 226 | (void)printf("ERROR: IoTHubClient_SendEventAsync..........FAILED!\r\n"); |
AzureIoTClient | 43:a4b2614eb860 | 227 | } |
AzureIoTClient | 43:a4b2614eb860 | 228 | else |
AzureIoTClient | 43:a4b2614eb860 | 229 | { |
AzureIoTClient | 43:a4b2614eb860 | 230 | (void)printf("IoTHubClient_SendEventAsync accepted data for transmission to IoT Hub.\r\n"); |
AzureIoTClient | 43:a4b2614eb860 | 231 | } |
Azure.IoT Build | 34:b7f31511a8ad | 232 | } |
AzureIoTClient | 17:d01a2794d5d7 | 233 | } |
AzureIoTClient | 43:a4b2614eb860 | 234 | IoTHubClient_LL_DoWork(iotHubClientHandle); |
AzureIoTClient | 43:a4b2614eb860 | 235 | ThreadAPI_Sleep(1); |
Azure.IoT Build | 34:b7f31511a8ad | 236 | |
AzureIoTClient | 43:a4b2614eb860 | 237 | iterator++; |
AzureIoTClient | 43:a4b2614eb860 | 238 | } while (g_continueRunning); |
Azure.IoT Build | 47:d87920c7f211 | 239 | |
AzureIoTClient | 60:ae07786385f9 | 240 | (void)printf("iothub_client_sample_amqp has gotten quit message, call DoWork %d more time to complete final sending...\r\n", DOWORK_LOOP_NUM); |
Azure.IoT Build | 47:d87920c7f211 | 241 | for (size_t index = 0; index < DOWORK_LOOP_NUM; index++) |
Azure.IoT Build | 47:d87920c7f211 | 242 | { |
Azure.IoT Build | 47:d87920c7f211 | 243 | IoTHubClient_LL_DoWork(iotHubClientHandle); |
Azure.IoT Build | 47:d87920c7f211 | 244 | ThreadAPI_Sleep(1); |
Azure.IoT Build | 47:d87920c7f211 | 245 | } |
AzureIoTClient | 17:d01a2794d5d7 | 246 | } |
AzureIoTClient | 43:a4b2614eb860 | 247 | IoTHubClient_LL_Destroy(iotHubClientHandle); |
AzureIoTClient | 17:d01a2794d5d7 | 248 | } |
Azure.IoT Build | 34:b7f31511a8ad | 249 | platform_deinit(); |
AzureIoTClient | 17:d01a2794d5d7 | 250 | } |
AzureIoTClient | 17:d01a2794d5d7 | 251 | } |
AzureIoTClient | 43:a4b2614eb860 | 252 | |
AzureIoTClient | 43:a4b2614eb860 | 253 | int main(void) |
AzureIoTClient | 43:a4b2614eb860 | 254 | { |
AzureIoTClient | 43:a4b2614eb860 | 255 | iothub_client_sample_amqp_run(); |
AzureIoTClient | 43:a4b2614eb860 | 256 | return 0; |
AzureIoTClient | 43:a4b2614eb860 | 257 | } |