corrected version (with typedef struct IOTHUB_CLIENT_LL_UPLOADTOBLOB_HANDLE_DATA* IOTHUB_CLIENT_LL_UPLOADTOBLOB_HANDLE;) included in the sources

Dependents:   STM32F746_iothub_client_sample_mqtt

Fork of iothub_client by Azure IoT

Committer:
AzureIoTClient
Date:
Tue Jun 07 10:49:08 2016 -0700
Revision:
42:448eecc3676e
Parent:
40:1a94db9139ea
Child:
43:038d8511e817
1.0.8

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AzureIoTClient 16:deba40344375 1 // Copyright (c) Microsoft. All rights reserved.
AzureIoTClient 16:deba40344375 2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
AzureIoTClient 16:deba40344375 3
AzureIoTClient 16:deba40344375 4 /** @file iothub_client.h
AzureIoTClient 16:deba40344375 5 * @brief Extends the IoTHubCLient_LL module with additional features.
AzureIoTClient 16:deba40344375 6 *
AzureIoTClient 16:deba40344375 7 * @details IoTHubClient is a module that extends the IoTHubCLient_LL
AzureIoTClient 16:deba40344375 8 * module with 2 features:
AzureIoTClient 40:1a94db9139ea 9 * - scheduling the work for the IoTHubCLient from a
AzureIoTClient 16:deba40344375 10 * thread, so that the user does not need to create their
AzureIoTClient 16:deba40344375 11 * own thread
AzureIoTClient 16:deba40344375 12 * - thread-safe APIs
AzureIoTClient 16:deba40344375 13 */
AzureIoTClient 16:deba40344375 14
AzureIoTClient 16:deba40344375 15 #ifndef IOTHUB_CLIENT_H
AzureIoTClient 22:b8732db970af 16 #define IOTHUB_CLIENT_H
AzureIoTClient 16:deba40344375 17
Azure.IoT Build 37:18310e4d888d 18 typedef struct IOTHUB_CLIENT_INSTANCE_TAG* IOTHUB_CLIENT_HANDLE;
Azure.IoT Build 37:18310e4d888d 19
AzureIoTClient 16:deba40344375 20 #include "iothub_client_ll.h"
Azure.IoT Build 37:18310e4d888d 21 #include "iothubtransport.h"
AzureIoTClient 16:deba40344375 22
AzureIoTClient 16:deba40344375 23 #ifdef __cplusplus
AzureIoTClient 16:deba40344375 24 extern "C"
AzureIoTClient 16:deba40344375 25 {
AzureIoTClient 16:deba40344375 26 #endif
AzureIoTClient 16:deba40344375 27
AzureIoTClient 42:448eecc3676e 28 #define IOTHUB_CLIENT_FILE_UPLOAD_RESULT_VALUES \
AzureIoTClient 42:448eecc3676e 29 FILE_UPLOAD_OK ,\
AzureIoTClient 42:448eecc3676e 30 FILE_UPLOAD_ERROR
AzureIoTClient 42:448eecc3676e 31
AzureIoTClient 42:448eecc3676e 32 DEFINE_ENUM(IOTHUB_CLIENT_FILE_UPLOAD_RESULT, IOTHUB_CLIENT_FILE_UPLOAD_RESULT_VALUES)
AzureIoTClient 42:448eecc3676e 33 typedef void(*IOTHUB_CLIENT_FILE_UPLOAD_CALLBACK)(IOTHUB_CLIENT_FILE_UPLOAD_RESULT result, void* userContextCallback);
AzureIoTClient 16:deba40344375 34
AzureIoTClient 40:1a94db9139ea 35 /**
AzureIoTClient 40:1a94db9139ea 36 * @brief Creates a IoT Hub client for communication with an existing
AzureIoTClient 40:1a94db9139ea 37 * IoT Hub using the specified connection string parameter.
AzureIoTClient 40:1a94db9139ea 38 *
AzureIoTClient 40:1a94db9139ea 39 * @param connectionString Pointer to a character string
AzureIoTClient 40:1a94db9139ea 40 * @param protocol Function pointer for protocol implementation
AzureIoTClient 40:1a94db9139ea 41 *
AzureIoTClient 40:1a94db9139ea 42 * Sample connection string:
AzureIoTClient 40:1a94db9139ea 43 * <blockquote>
AzureIoTClient 40:1a94db9139ea 44 * <pre>HostName=[IoT Hub name goes here].[IoT Hub suffix goes here, e.g., private.azure-devices-int.net];DeviceId=[Device ID goes here];SharedAccessKey=[Device key goes here];</pre>
AzureIoTClient 40:1a94db9139ea 45 * <pre>HostName=[IoT Hub name goes here].[IoT Hub suffix goes here, e.g., private.azure-devices-int.net];DeviceId=[Device ID goes here];SharedAccessSignature=SharedAccessSignature sr=[IoT Hub name goes here].[IoT Hub suffix goes here, e.g., private.azure-devices-int.net]/devices/[Device ID goes here]&sig=[SAS Token goes here]&se=[Expiry Time goes here];</pre>
AzureIoTClient 40:1a94db9139ea 46 * </blockquote>
AzureIoTClient 40:1a94db9139ea 47 *
AzureIoTClient 40:1a94db9139ea 48 * @return A non-NULL @c IOTHUB_CLIENT_HANDLE value that is used when
AzureIoTClient 40:1a94db9139ea 49 * invoking other functions for IoT Hub client and @c NULL on failure.
AzureIoTClient 40:1a94db9139ea 50 */
AzureIoTClient 40:1a94db9139ea 51 extern IOTHUB_CLIENT_HANDLE IoTHubClient_CreateFromConnectionString(const char* connectionString, IOTHUB_CLIENT_TRANSPORT_PROVIDER protocol);
AzureIoTClient 16:deba40344375 52
AzureIoTClient 40:1a94db9139ea 53 /**
AzureIoTClient 40:1a94db9139ea 54 * @brief Creates a IoT Hub client for communication with an existing IoT
AzureIoTClient 40:1a94db9139ea 55 * Hub using the specified parameters.
AzureIoTClient 40:1a94db9139ea 56 *
AzureIoTClient 40:1a94db9139ea 57 * @param config Pointer to an @c IOTHUB_CLIENT_CONFIG structure
AzureIoTClient 40:1a94db9139ea 58 *
AzureIoTClient 40:1a94db9139ea 59 * The API does not allow sharing of a connection across multiple
AzureIoTClient 40:1a94db9139ea 60 * devices. This is a blocking call.
AzureIoTClient 40:1a94db9139ea 61 *
AzureIoTClient 40:1a94db9139ea 62 * @return A non-NULL @c IOTHUB_CLIENT_HANDLE value that is used when
AzureIoTClient 40:1a94db9139ea 63 * invoking other functions for IoT Hub client and @c NULL on failure.
AzureIoTClient 40:1a94db9139ea 64 */
AzureIoTClient 40:1a94db9139ea 65 extern IOTHUB_CLIENT_HANDLE IoTHubClient_Create(const IOTHUB_CLIENT_CONFIG* config);
AzureIoTClient 16:deba40344375 66
AzureIoTClient 40:1a94db9139ea 67 /**
Azure.IoT Build 37:18310e4d888d 68 * @brief Creates a IoT Hub client for communication with an existing IoT
Azure.IoT Build 37:18310e4d888d 69 * Hub using the specified parameters.
Azure.IoT Build 37:18310e4d888d 70 *
Azure.IoT Build 37:18310e4d888d 71 * @param transportHandle TRANSPORT_HANDLE which represents a connection.
Azure.IoT Build 37:18310e4d888d 72 * @param config Pointer to an @c IOTHUB_CLIENT_CONFIG structure
Azure.IoT Build 37:18310e4d888d 73 *
Azure.IoT Build 37:18310e4d888d 74 * The API allows sharing of a connection across multiple
Azure.IoT Build 37:18310e4d888d 75 * devices. This is a blocking call.
Azure.IoT Build 37:18310e4d888d 76 *
Azure.IoT Build 37:18310e4d888d 77 * @return A non-NULL @c IOTHUB_CLIENT_HANDLE value that is used when
Azure.IoT Build 37:18310e4d888d 78 * invoking other functions for IoT Hub client and @c NULL on failure.
Azure.IoT Build 37:18310e4d888d 79 */
Azure.IoT Build 37:18310e4d888d 80 extern IOTHUB_CLIENT_HANDLE IoTHubClient_CreateWithTransport(TRANSPORT_HANDLE transportHandle, const IOTHUB_CLIENT_CONFIG* config);
Azure.IoT Build 37:18310e4d888d 81
AzureIoTClient 40:1a94db9139ea 82 /**
AzureIoTClient 40:1a94db9139ea 83 * @brief Disposes of resources allocated by the IoT Hub client. This is a
AzureIoTClient 40:1a94db9139ea 84 * blocking call.
AzureIoTClient 40:1a94db9139ea 85 *
AzureIoTClient 40:1a94db9139ea 86 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 40:1a94db9139ea 87 */
AzureIoTClient 40:1a94db9139ea 88 extern void IoTHubClient_Destroy(IOTHUB_CLIENT_HANDLE iotHubClientHandle);
AzureIoTClient 16:deba40344375 89
AzureIoTClient 40:1a94db9139ea 90 /**
AzureIoTClient 40:1a94db9139ea 91 * @brief Asynchronous call to send the message specified by @p eventMessageHandle.
AzureIoTClient 40:1a94db9139ea 92 *
AzureIoTClient 40:1a94db9139ea 93 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 40:1a94db9139ea 94 * @param eventMessageHandle The handle to an IoT Hub message.
AzureIoTClient 40:1a94db9139ea 95 * @param eventConfirmationCallback The callback specified by the device for receiving
AzureIoTClient 40:1a94db9139ea 96 * confirmation of the delivery of the IoT Hub message.
AzureIoTClient 40:1a94db9139ea 97 * This callback can be expected to invoke the
AzureIoTClient 40:1a94db9139ea 98 * ::IoTHubClient_SendEventAsync function for the
AzureIoTClient 40:1a94db9139ea 99 * same message in an attempt to retry sending a failing
AzureIoTClient 40:1a94db9139ea 100 * message. The user can specify a @c NULL value here to
AzureIoTClient 40:1a94db9139ea 101 * indicate that no callback is required.
AzureIoTClient 40:1a94db9139ea 102 * @param userContextCallback User specified context that will be provided to the
AzureIoTClient 40:1a94db9139ea 103 * callback. This can be @c NULL.
AzureIoTClient 40:1a94db9139ea 104 *
AzureIoTClient 40:1a94db9139ea 105 * @b NOTE: The application behavior is undefined if the user calls
AzureIoTClient 40:1a94db9139ea 106 * the ::IoTHubClient_Destroy function from within any callback.
AzureIoTClient 40:1a94db9139ea 107 *
AzureIoTClient 40:1a94db9139ea 108 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 40:1a94db9139ea 109 */
AzureIoTClient 40:1a94db9139ea 110 extern IOTHUB_CLIENT_RESULT IoTHubClient_SendEventAsync(IOTHUB_CLIENT_HANDLE iotHubClientHandle, IOTHUB_MESSAGE_HANDLE eventMessageHandle, IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK eventConfirmationCallback, void* userContextCallback);
AzureIoTClient 16:deba40344375 111
AzureIoTClient 40:1a94db9139ea 112 /**
AzureIoTClient 40:1a94db9139ea 113 * @brief This function returns the current sending status for IoTHubClient.
AzureIoTClient 40:1a94db9139ea 114 *
AzureIoTClient 40:1a94db9139ea 115 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 40:1a94db9139ea 116 * @param iotHubClientStatus The sending state is populated at the address pointed
AzureIoTClient 40:1a94db9139ea 117 * at by this parameter. The value will be set to
AzureIoTClient 40:1a94db9139ea 118 * @c IOTHUBCLIENT_SENDSTATUS_IDLE if there is currently
AzureIoTClient 40:1a94db9139ea 119 * no item to be sent and @c IOTHUBCLIENT_SENDSTATUS_BUSY
AzureIoTClient 40:1a94db9139ea 120 * if there are.
AzureIoTClient 40:1a94db9139ea 121 *
AzureIoTClient 40:1a94db9139ea 122 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 40:1a94db9139ea 123 */
AzureIoTClient 40:1a94db9139ea 124 extern IOTHUB_CLIENT_RESULT IoTHubClient_GetSendStatus(IOTHUB_CLIENT_HANDLE iotHubClientHandle, IOTHUB_CLIENT_STATUS *iotHubClientStatus);
AzureIoTClient 16:deba40344375 125
AzureIoTClient 40:1a94db9139ea 126 /**
AzureIoTClient 40:1a94db9139ea 127 * @brief Sets up the message callback to be invoked when IoT Hub issues a
AzureIoTClient 40:1a94db9139ea 128 * message to the device. This is a blocking call.
AzureIoTClient 40:1a94db9139ea 129 *
AzureIoTClient 40:1a94db9139ea 130 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 40:1a94db9139ea 131 * @param messageCallback The callback specified by the device for receiving
AzureIoTClient 40:1a94db9139ea 132 * messages from IoT Hub.
AzureIoTClient 40:1a94db9139ea 133 * @param userContextCallback User specified context that will be provided to the
AzureIoTClient 40:1a94db9139ea 134 * callback. This can be @c NULL.
AzureIoTClient 40:1a94db9139ea 135 *
AzureIoTClient 40:1a94db9139ea 136 * @b NOTE: The application behavior is undefined if the user calls
AzureIoTClient 40:1a94db9139ea 137 * the ::IoTHubClient_Destroy function from within any callback.
AzureIoTClient 40:1a94db9139ea 138 *
AzureIoTClient 40:1a94db9139ea 139 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 40:1a94db9139ea 140 */
AzureIoTClient 40:1a94db9139ea 141 extern IOTHUB_CLIENT_RESULT IoTHubClient_SetMessageCallback(IOTHUB_CLIENT_HANDLE iotHubClientHandle, IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC messageCallback, void* userContextCallback);
AzureIoTClient 16:deba40344375 142
AzureIoTClient 40:1a94db9139ea 143 /**
AzureIoTClient 40:1a94db9139ea 144 * @brief This function returns in the out parameter @p lastMessageReceiveTime
AzureIoTClient 40:1a94db9139ea 145 * what was the value of the @c time function when the last message was
AzureIoTClient 40:1a94db9139ea 146 * received at the client.
AzureIoTClient 40:1a94db9139ea 147 *
AzureIoTClient 40:1a94db9139ea 148 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 40:1a94db9139ea 149 * @param lastMessageReceiveTime Out parameter containing the value of @c time function
AzureIoTClient 40:1a94db9139ea 150 * when the last message was received.
AzureIoTClient 40:1a94db9139ea 151 *
AzureIoTClient 40:1a94db9139ea 152 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 40:1a94db9139ea 153 */
AzureIoTClient 40:1a94db9139ea 154 extern IOTHUB_CLIENT_RESULT IoTHubClient_GetLastMessageReceiveTime(IOTHUB_CLIENT_HANDLE iotHubClientHandle, time_t* lastMessageReceiveTime);
AzureIoTClient 16:deba40344375 155
AzureIoTClient 40:1a94db9139ea 156 /**
AzureIoTClient 40:1a94db9139ea 157 * @brief This API sets a runtime option identified by parameter @p optionName
AzureIoTClient 40:1a94db9139ea 158 * to a value pointed to by @p value. @p optionName and the data type
AzureIoTClient 40:1a94db9139ea 159 * @p value is pointing to are specific for every option.
AzureIoTClient 40:1a94db9139ea 160 *
AzureIoTClient 40:1a94db9139ea 161 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 40:1a94db9139ea 162 * @param optionName Name of the option.
AzureIoTClient 40:1a94db9139ea 163 * @param value The value.
AzureIoTClient 40:1a94db9139ea 164 *
AzureIoTClient 40:1a94db9139ea 165 * The options that can be set via this API are:
AzureIoTClient 40:1a94db9139ea 166 * - @b timeout - the maximum time in milliseconds a communication is
AzureIoTClient 40:1a94db9139ea 167 * allowed to use. @p value is a pointer to an @c unsigned @c int with
AzureIoTClient 40:1a94db9139ea 168 * the timeout value in milliseconds. This is only supported for the HTTP
AzureIoTClient 40:1a94db9139ea 169 * protocol as of now. When the HTTP protocol uses CURL, the meaning of
AzureIoTClient 40:1a94db9139ea 170 * the parameter is <em>total request time</em>. When the HTTP protocol uses
AzureIoTClient 40:1a94db9139ea 171 * winhttp, the meaning is the same as the @c dwSendTimeout and
AzureIoTClient 40:1a94db9139ea 172 * @c dwReceiveTimeout parameters of the
AzureIoTClient 40:1a94db9139ea 173 * <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa384116(v=vs.85).aspx">
AzureIoTClient 40:1a94db9139ea 174 * WinHttpSetTimeouts</a> API.
AzureIoTClient 40:1a94db9139ea 175 * - @b CURLOPT_LOW_SPEED_LIMIT - only available for HTTP protocol and only
AzureIoTClient 40:1a94db9139ea 176 * when CURL is used. It has the same meaning as CURL's option with the same
AzureIoTClient 40:1a94db9139ea 177 * name. @p value is pointer to a long.
AzureIoTClient 40:1a94db9139ea 178 * - @b CURLOPT_LOW_SPEED_TIME - only available for HTTP protocol and only
AzureIoTClient 40:1a94db9139ea 179 * when CURL is used. It has the same meaning as CURL's option with the same
AzureIoTClient 40:1a94db9139ea 180 * name. @p value is pointer to a long.
AzureIoTClient 40:1a94db9139ea 181 * - @b CURLOPT_FORBID_REUSE - only available for HTTP protocol and only
AzureIoTClient 40:1a94db9139ea 182 * when CURL is used. It has the same meaning as CURL's option with the same
AzureIoTClient 40:1a94db9139ea 183 * name. @p value is pointer to a long.
AzureIoTClient 40:1a94db9139ea 184 * - @b CURLOPT_FRESH_CONNECT - only available for HTTP protocol and only
AzureIoTClient 40:1a94db9139ea 185 * when CURL is used. It has the same meaning as CURL's option with the same
AzureIoTClient 40:1a94db9139ea 186 * name. @p value is pointer to a long.
AzureIoTClient 40:1a94db9139ea 187 * - @b CURLOPT_VERBOSE - only available for HTTP protocol and only
AzureIoTClient 40:1a94db9139ea 188 * when CURL is used. It has the same meaning as CURL's option with the same
AzureIoTClient 40:1a94db9139ea 189 * name. @p value is pointer to a long.
AzureIoTClient 40:1a94db9139ea 190 * - @b messageTimeout - the maximum time in milliseconds until a message
AzureIoTClient 40:1a94db9139ea 191 * is timeouted. The time starts at IoTHubClient_SendEventAsync. By default,
AzureIoTClient 42:448eecc3676e 192 * messages do not expire. @p is a pointer to a uint64_t
AzureIoTClient 40:1a94db9139ea 193 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 40:1a94db9139ea 194 */
AzureIoTClient 40:1a94db9139ea 195 extern IOTHUB_CLIENT_RESULT IoTHubClient_SetOption(IOTHUB_CLIENT_HANDLE iotHubClientHandle, const char* optionName, const void* value);
AzureIoTClient 42:448eecc3676e 196
AzureIoTClient 42:448eecc3676e 197 /**
AzureIoTClient 42:448eecc3676e 198 * @brief IoTHubClient_UploadToBlobAsync uploads data from memory to a file in Azure Blob Storage.
AzureIoTClient 42:448eecc3676e 199 *
AzureIoTClient 42:448eecc3676e 200 * @param iotHubClientHandle The handle created by a call to the IoTHubClient_Create function.
AzureIoTClient 42:448eecc3676e 201 * @param destinationFileName The name of the file to be created in Azure Blob Storage.
AzureIoTClient 42:448eecc3676e 202 * @param source The source of data.
AzureIoTClient 42:448eecc3676e 203 * @param size The size of data.
AzureIoTClient 42:448eecc3676e 204 * @param iotHubClientFileUploadCallback A callback to be invoked when the file upload operation has finished.
AzureIoTClient 42:448eecc3676e 205 * @param context A user-provided context to be passed to the file upload callback.
AzureIoTClient 42:448eecc3676e 206 *
AzureIoTClient 42:448eecc3676e 207 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 42:448eecc3676e 208 */
AzureIoTClient 42:448eecc3676e 209 extern IOTHUB_CLIENT_RESULT IoTHubClient_UploadToBlobAsync(IOTHUB_CLIENT_HANDLE iotHubClientHandle, const char* destinationFileName, const unsigned char* source, size_t size, IOTHUB_CLIENT_FILE_UPLOAD_CALLBACK iotHubClientFileUploadCallback, void* context);
AzureIoTClient 16:deba40344375 210 #ifdef __cplusplus
AzureIoTClient 16:deba40344375 211 }
AzureIoTClient 16:deba40344375 212 #endif
AzureIoTClient 16:deba40344375 213
AzureIoTClient 16:deba40344375 214 #endif /* IOTHUB_CLIENT_H */