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:
Mon May 09 14:37:02 2016 -0700
Revision:
40:1a94db9139ea
Parent:
37:18310e4d888d
Child:
42:448eecc3676e
1.0.6

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 16:deba40344375 28
AzureIoTClient 40:1a94db9139ea 29 /**
AzureIoTClient 40:1a94db9139ea 30 * @brief Creates a IoT Hub client for communication with an existing
AzureIoTClient 40:1a94db9139ea 31 * IoT Hub using the specified connection string parameter.
AzureIoTClient 40:1a94db9139ea 32 *
AzureIoTClient 40:1a94db9139ea 33 * @param connectionString Pointer to a character string
AzureIoTClient 40:1a94db9139ea 34 * @param protocol Function pointer for protocol implementation
AzureIoTClient 40:1a94db9139ea 35 *
AzureIoTClient 40:1a94db9139ea 36 * Sample connection string:
AzureIoTClient 40:1a94db9139ea 37 * <blockquote>
AzureIoTClient 40:1a94db9139ea 38 * <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 39 * <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 40 * </blockquote>
AzureIoTClient 40:1a94db9139ea 41 *
AzureIoTClient 40:1a94db9139ea 42 * @return A non-NULL @c IOTHUB_CLIENT_HANDLE value that is used when
AzureIoTClient 40:1a94db9139ea 43 * invoking other functions for IoT Hub client and @c NULL on failure.
AzureIoTClient 40:1a94db9139ea 44 */
AzureIoTClient 40:1a94db9139ea 45 extern IOTHUB_CLIENT_HANDLE IoTHubClient_CreateFromConnectionString(const char* connectionString, IOTHUB_CLIENT_TRANSPORT_PROVIDER protocol);
AzureIoTClient 16:deba40344375 46
AzureIoTClient 40:1a94db9139ea 47 /**
AzureIoTClient 40:1a94db9139ea 48 * @brief Creates a IoT Hub client for communication with an existing IoT
AzureIoTClient 40:1a94db9139ea 49 * Hub using the specified parameters.
AzureIoTClient 40:1a94db9139ea 50 *
AzureIoTClient 40:1a94db9139ea 51 * @param config Pointer to an @c IOTHUB_CLIENT_CONFIG structure
AzureIoTClient 40:1a94db9139ea 52 *
AzureIoTClient 40:1a94db9139ea 53 * The API does not allow sharing of a connection across multiple
AzureIoTClient 40:1a94db9139ea 54 * devices. This is a blocking call.
AzureIoTClient 40:1a94db9139ea 55 *
AzureIoTClient 40:1a94db9139ea 56 * @return A non-NULL @c IOTHUB_CLIENT_HANDLE value that is used when
AzureIoTClient 40:1a94db9139ea 57 * invoking other functions for IoT Hub client and @c NULL on failure.
AzureIoTClient 40:1a94db9139ea 58 */
AzureIoTClient 40:1a94db9139ea 59 extern IOTHUB_CLIENT_HANDLE IoTHubClient_Create(const IOTHUB_CLIENT_CONFIG* config);
AzureIoTClient 16:deba40344375 60
AzureIoTClient 40:1a94db9139ea 61 /**
Azure.IoT Build 37:18310e4d888d 62 * @brief Creates a IoT Hub client for communication with an existing IoT
Azure.IoT Build 37:18310e4d888d 63 * Hub using the specified parameters.
Azure.IoT Build 37:18310e4d888d 64 *
Azure.IoT Build 37:18310e4d888d 65 * @param transportHandle TRANSPORT_HANDLE which represents a connection.
Azure.IoT Build 37:18310e4d888d 66 * @param config Pointer to an @c IOTHUB_CLIENT_CONFIG structure
Azure.IoT Build 37:18310e4d888d 67 *
Azure.IoT Build 37:18310e4d888d 68 * The API allows sharing of a connection across multiple
Azure.IoT Build 37:18310e4d888d 69 * devices. This is a blocking call.
Azure.IoT Build 37:18310e4d888d 70 *
Azure.IoT Build 37:18310e4d888d 71 * @return A non-NULL @c IOTHUB_CLIENT_HANDLE value that is used when
Azure.IoT Build 37:18310e4d888d 72 * invoking other functions for IoT Hub client and @c NULL on failure.
Azure.IoT Build 37:18310e4d888d 73 */
Azure.IoT Build 37:18310e4d888d 74 extern IOTHUB_CLIENT_HANDLE IoTHubClient_CreateWithTransport(TRANSPORT_HANDLE transportHandle, const IOTHUB_CLIENT_CONFIG* config);
Azure.IoT Build 37:18310e4d888d 75
AzureIoTClient 40:1a94db9139ea 76 /**
AzureIoTClient 40:1a94db9139ea 77 * @brief Disposes of resources allocated by the IoT Hub client. This is a
AzureIoTClient 40:1a94db9139ea 78 * blocking call.
AzureIoTClient 40:1a94db9139ea 79 *
AzureIoTClient 40:1a94db9139ea 80 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 40:1a94db9139ea 81 */
AzureIoTClient 40:1a94db9139ea 82 extern void IoTHubClient_Destroy(IOTHUB_CLIENT_HANDLE iotHubClientHandle);
AzureIoTClient 16:deba40344375 83
AzureIoTClient 40:1a94db9139ea 84 /**
AzureIoTClient 40:1a94db9139ea 85 * @brief Asynchronous call to send the message specified by @p eventMessageHandle.
AzureIoTClient 40:1a94db9139ea 86 *
AzureIoTClient 40:1a94db9139ea 87 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 40:1a94db9139ea 88 * @param eventMessageHandle The handle to an IoT Hub message.
AzureIoTClient 40:1a94db9139ea 89 * @param eventConfirmationCallback The callback specified by the device for receiving
AzureIoTClient 40:1a94db9139ea 90 * confirmation of the delivery of the IoT Hub message.
AzureIoTClient 40:1a94db9139ea 91 * This callback can be expected to invoke the
AzureIoTClient 40:1a94db9139ea 92 * ::IoTHubClient_SendEventAsync function for the
AzureIoTClient 40:1a94db9139ea 93 * same message in an attempt to retry sending a failing
AzureIoTClient 40:1a94db9139ea 94 * message. The user can specify a @c NULL value here to
AzureIoTClient 40:1a94db9139ea 95 * indicate that no callback is required.
AzureIoTClient 40:1a94db9139ea 96 * @param userContextCallback User specified context that will be provided to the
AzureIoTClient 40:1a94db9139ea 97 * callback. This can be @c NULL.
AzureIoTClient 40:1a94db9139ea 98 *
AzureIoTClient 40:1a94db9139ea 99 * @b NOTE: The application behavior is undefined if the user calls
AzureIoTClient 40:1a94db9139ea 100 * the ::IoTHubClient_Destroy function from within any callback.
AzureIoTClient 40:1a94db9139ea 101 *
AzureIoTClient 40:1a94db9139ea 102 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 40:1a94db9139ea 103 */
AzureIoTClient 40:1a94db9139ea 104 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 105
AzureIoTClient 40:1a94db9139ea 106 /**
AzureIoTClient 40:1a94db9139ea 107 * @brief This function returns the current sending status for IoTHubClient.
AzureIoTClient 40:1a94db9139ea 108 *
AzureIoTClient 40:1a94db9139ea 109 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 40:1a94db9139ea 110 * @param iotHubClientStatus The sending state is populated at the address pointed
AzureIoTClient 40:1a94db9139ea 111 * at by this parameter. The value will be set to
AzureIoTClient 40:1a94db9139ea 112 * @c IOTHUBCLIENT_SENDSTATUS_IDLE if there is currently
AzureIoTClient 40:1a94db9139ea 113 * no item to be sent and @c IOTHUBCLIENT_SENDSTATUS_BUSY
AzureIoTClient 40:1a94db9139ea 114 * if there are.
AzureIoTClient 40:1a94db9139ea 115 *
AzureIoTClient 40:1a94db9139ea 116 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 40:1a94db9139ea 117 */
AzureIoTClient 40:1a94db9139ea 118 extern IOTHUB_CLIENT_RESULT IoTHubClient_GetSendStatus(IOTHUB_CLIENT_HANDLE iotHubClientHandle, IOTHUB_CLIENT_STATUS *iotHubClientStatus);
AzureIoTClient 16:deba40344375 119
AzureIoTClient 40:1a94db9139ea 120 /**
AzureIoTClient 40:1a94db9139ea 121 * @brief Sets up the message callback to be invoked when IoT Hub issues a
AzureIoTClient 40:1a94db9139ea 122 * message to the device. This is a blocking call.
AzureIoTClient 40:1a94db9139ea 123 *
AzureIoTClient 40:1a94db9139ea 124 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 40:1a94db9139ea 125 * @param messageCallback The callback specified by the device for receiving
AzureIoTClient 40:1a94db9139ea 126 * messages from IoT Hub.
AzureIoTClient 40:1a94db9139ea 127 * @param userContextCallback User specified context that will be provided to the
AzureIoTClient 40:1a94db9139ea 128 * callback. This can be @c NULL.
AzureIoTClient 40:1a94db9139ea 129 *
AzureIoTClient 40:1a94db9139ea 130 * @b NOTE: The application behavior is undefined if the user calls
AzureIoTClient 40:1a94db9139ea 131 * the ::IoTHubClient_Destroy function from within any callback.
AzureIoTClient 40:1a94db9139ea 132 *
AzureIoTClient 40:1a94db9139ea 133 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 40:1a94db9139ea 134 */
AzureIoTClient 40:1a94db9139ea 135 extern IOTHUB_CLIENT_RESULT IoTHubClient_SetMessageCallback(IOTHUB_CLIENT_HANDLE iotHubClientHandle, IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC messageCallback, void* userContextCallback);
AzureIoTClient 16:deba40344375 136
AzureIoTClient 40:1a94db9139ea 137 /**
AzureIoTClient 40:1a94db9139ea 138 * @brief This function returns in the out parameter @p lastMessageReceiveTime
AzureIoTClient 40:1a94db9139ea 139 * what was the value of the @c time function when the last message was
AzureIoTClient 40:1a94db9139ea 140 * received at the client.
AzureIoTClient 40:1a94db9139ea 141 *
AzureIoTClient 40:1a94db9139ea 142 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 40:1a94db9139ea 143 * @param lastMessageReceiveTime Out parameter containing the value of @c time function
AzureIoTClient 40:1a94db9139ea 144 * when the last message was received.
AzureIoTClient 40:1a94db9139ea 145 *
AzureIoTClient 40:1a94db9139ea 146 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 40:1a94db9139ea 147 */
AzureIoTClient 40:1a94db9139ea 148 extern IOTHUB_CLIENT_RESULT IoTHubClient_GetLastMessageReceiveTime(IOTHUB_CLIENT_HANDLE iotHubClientHandle, time_t* lastMessageReceiveTime);
AzureIoTClient 16:deba40344375 149
AzureIoTClient 40:1a94db9139ea 150 /**
AzureIoTClient 40:1a94db9139ea 151 * @brief This API sets a runtime option identified by parameter @p optionName
AzureIoTClient 40:1a94db9139ea 152 * to a value pointed to by @p value. @p optionName and the data type
AzureIoTClient 40:1a94db9139ea 153 * @p value is pointing to are specific for every option.
AzureIoTClient 40:1a94db9139ea 154 *
AzureIoTClient 40:1a94db9139ea 155 * @param iotHubClientHandle The handle created by a call to the create function.
AzureIoTClient 40:1a94db9139ea 156 * @param optionName Name of the option.
AzureIoTClient 40:1a94db9139ea 157 * @param value The value.
AzureIoTClient 40:1a94db9139ea 158 *
AzureIoTClient 40:1a94db9139ea 159 * The options that can be set via this API are:
AzureIoTClient 40:1a94db9139ea 160 * - @b timeout - the maximum time in milliseconds a communication is
AzureIoTClient 40:1a94db9139ea 161 * allowed to use. @p value is a pointer to an @c unsigned @c int with
AzureIoTClient 40:1a94db9139ea 162 * the timeout value in milliseconds. This is only supported for the HTTP
AzureIoTClient 40:1a94db9139ea 163 * protocol as of now. When the HTTP protocol uses CURL, the meaning of
AzureIoTClient 40:1a94db9139ea 164 * the parameter is <em>total request time</em>. When the HTTP protocol uses
AzureIoTClient 40:1a94db9139ea 165 * winhttp, the meaning is the same as the @c dwSendTimeout and
AzureIoTClient 40:1a94db9139ea 166 * @c dwReceiveTimeout parameters of the
AzureIoTClient 40:1a94db9139ea 167 * <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa384116(v=vs.85).aspx">
AzureIoTClient 40:1a94db9139ea 168 * WinHttpSetTimeouts</a> API.
AzureIoTClient 40:1a94db9139ea 169 * - @b CURLOPT_LOW_SPEED_LIMIT - only available for HTTP protocol and only
AzureIoTClient 40:1a94db9139ea 170 * when CURL is used. It has the same meaning as CURL's option with the same
AzureIoTClient 40:1a94db9139ea 171 * name. @p value is pointer to a long.
AzureIoTClient 40:1a94db9139ea 172 * - @b CURLOPT_LOW_SPEED_TIME - only available for HTTP protocol and only
AzureIoTClient 40:1a94db9139ea 173 * when CURL is used. It has the same meaning as CURL's option with the same
AzureIoTClient 40:1a94db9139ea 174 * name. @p value is pointer to a long.
AzureIoTClient 40:1a94db9139ea 175 * - @b CURLOPT_FORBID_REUSE - 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_FRESH_CONNECT - 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_VERBOSE - 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 messageTimeout - the maximum time in milliseconds until a message
AzureIoTClient 40:1a94db9139ea 185 * is timeouted. The time starts at IoTHubClient_SendEventAsync. By default,
AzureIoTClient 40:1a94db9139ea 186 * messages do not expire.
AzureIoTClient 40:1a94db9139ea 187 * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
AzureIoTClient 40:1a94db9139ea 188 */
AzureIoTClient 40:1a94db9139ea 189 extern IOTHUB_CLIENT_RESULT IoTHubClient_SetOption(IOTHUB_CLIENT_HANDLE iotHubClientHandle, const char* optionName, const void* value);
AzureIoTClient 16:deba40344375 190
AzureIoTClient 16:deba40344375 191 #ifdef __cplusplus
AzureIoTClient 16:deba40344375 192 }
AzureIoTClient 16:deba40344375 193 #endif
AzureIoTClient 16:deba40344375 194
AzureIoTClient 16:deba40344375 195 #endif /* IOTHUB_CLIENT_H */