Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: sht15_remote_monitoring RobotArmDemo iothub_client_sample_amqp f767zi_mqtt ... more
Revision 92:97148cf9aa2a, committed 2018-09-11
- Comitter:
- AzureIoTClient
- Date:
- Tue Sep 11 11:13:11 2018 -0700
- Parent:
- 91:bbf806070c5f
- Child:
- 93:7c0bbb86b167
- Commit message:
- 1.2.9
Changed in this revision
--- a/internal/blob.h Thu Jul 12 18:09:13 2018 -0700 +++ b/internal/blob.h Tue Sep 11 11:13:11 2018 -0700 @@ -2,12 +2,12 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. /** @file blob.h -* @brief Contains blob APIs needed for File Upload feature of IoTHub client. +* @brief Contains blob APIs needed for File Upload feature of IoTHub client. * -* @details IoTHub client needs to upload a byte array by using blob storage API -* IoTHub service provides the complete SAS URI to execute a PUT request -* that will upload the data. -* +* @details IoTHub client needs to upload a byte array by using blob storage API +* IoTHub service provides the complete SAS URI to execute a PUT request +* that will upload the data. +* */ #ifndef BLOB_H @@ -57,7 +57,7 @@ * @param certificates A null terminated string containing CA certificates to be used * @param proxyOptions A structure that contains optional web proxy information * -* @return A @c BLOB_RESULT. BLOB_OK means the blob has been uploaded successfully. Any other value indicates an error +* @return A @c BLOB_RESULT. BLOB_OK means the blob has been uploaded successfully. Any other value indicates an error */ MOCKABLE_FUNCTION(, BLOB_RESULT, Blob_UploadMultipleBlocksFromSasUri, const char*, SASURI, IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK_EX, getDataCallbackEx, void*, context, unsigned int*, httpStatus, BUFFER_HANDLE, httpResponse, const char*, certificates, HTTP_PROXY_OPTIONS*, proxyOptions)
--- a/internal/iothub_client_authorization.h Thu Jul 12 18:09:13 2018 -0700
+++ b/internal/iothub_client_authorization.h Tue Sep 11 11:13:11 2018 -0700
@@ -4,16 +4,16 @@
#ifndef IOTHUB_CLIENT_AUTHORIZATION_H
#define IOTHUB_CLIENT_AUTHORIZATION_H
+#include "azure_c_shared_utility/macro_utils.h"
+#include "azure_c_shared_utility/umock_c_prod.h"
+#include "azure_c_shared_utility/xio.h"
+
#ifdef __cplusplus
extern "C" {
#else
#include <stdbool.h>
#endif /* __cplusplus */
-#include "azure_c_shared_utility/macro_utils.h"
-#include "azure_c_shared_utility/umock_c_prod.h"
-#include "azure_c_shared_utility/xio.h"
-
typedef struct IOTHUB_AUTHORIZATION_DATA_TAG* IOTHUB_AUTHORIZATION_HANDLE;
#define IOTHUB_CREDENTIAL_TYPE_VALUES \
--- a/internal/iothub_client_diagnostic.h Thu Jul 12 18:09:13 2018 -0700
+++ b/internal/iothub_client_diagnostic.h Tue Sep 11 11:13:11 2018 -0700
@@ -2,7 +2,7 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
/** @file iothub_client_diagnostic.h
-* @brief The @c diagnostic is a component that helps to add predefined diagnostic
+* @brief The @c diagnostic is a component that helps to add predefined diagnostic
properties to message for end to end diagnostic purpose
*/
@@ -29,15 +29,15 @@
} IOTHUB_DIAGNOSTIC_SETTING_DATA;
/**
- * @brief Adds diagnostic information to message if:
+ * @brief Adds diagnostic information to message if:
* a. diagSetting->diagSamplingPercentage > 0 and
* b. the number of current message matches sample rule specified by diagSetting->diagSamplingPercentage
*
- * @param diagSetting Pointer to an @c IOTHUB_DIAGNOSTIC_SETTING_DATA structure
+ * @param diagSetting Pointer to an @c IOTHUB_DIAGNOSTIC_SETTING_DATA structure
*
- * @param messageHandle message handle
+ * @param messageHandle message handle
*
- * @return 0 upon success
+ * @return 0 upon success
*/
MOCKABLE_FUNCTION(, int, IoTHubClient_Diagnostic_AddIfNecessary, IOTHUB_DIAGNOSTIC_SETTING_DATA *, diagSetting, IOTHUB_MESSAGE_HANDLE, messageHandle);
--- a/internal/iothub_client_ll_uploadtoblob.h Thu Jul 12 18:09:13 2018 -0700 +++ b/internal/iothub_client_ll_uploadtoblob.h Tue Sep 11 11:13:11 2018 -0700 @@ -2,22 +2,22 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. /** @file iothub_client_ll.h -* @brief APIs that allow a user (usually a device) to communicate -* with an Azure IoTHub. +* @brief APIs that allow a user (usually a device) to communicate +* with an Azure IoTHub. * -* @details IoTHubClient_LL is a module that allows a user (usually a -* device) to communicate with an Azure IoTHub. It can send events -* and receive messages. At any given moment in time there can only -* be at most 1 message callback function. +* @details IoTHubClient_LL is a module that allows a user (usually a +* device) to communicate with an Azure IoTHub. It can send events +* and receive messages. At any given moment in time there can only +* be at most 1 message callback function. * -* This API surface contains a set of APIs that allows the user to -* interact with the lower layer portion of the IoTHubClient. These APIs -* contain @c _LL_ in their name, but retain the same functionality like the -* @c IoTHubClient_... APIs, with one difference. If the @c _LL_ APIs are -* used then the user is responsible for scheduling when the actual work done -* by the IoTHubClient happens (when the data is sent/received on/from the wire). -* This is useful for constrained devices where spinning a separate thread is -* often not desired. +* This API surface contains a set of APIs that allows the user to +* interact with the lower layer portion of the IoTHubClient. These APIs +* contain @c _LL_ in their name, but retain the same functionality like the +* @c IoTHubClient_... APIs, with one difference. If the @c _LL_ APIs are +* used then the user is responsible for scheduling when the actual work done +* by the IoTHubClient happens (when the data is sent/received on/from the wire). +* This is useful for constrained devices where spinning a separate thread is +* often not desired. */ #ifndef DONT_USE_UPLOADTOBLOB
--- a/internal/iothub_client_private.h Thu Jul 12 18:09:13 2018 -0700
+++ b/internal/iothub_client_private.h Tue Sep 11 11:13:11 2018 -0700
@@ -63,7 +63,7 @@
{
IOTHUB_MESSAGE_HANDLE messageHandle;
IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK callback;
- void* context;
+ void* context;
DLIST_ENTRY entry;
tickcounter_ms_t ms_timesOutAfter; /* a value of "0" means "no timeout", if the IOTHUBCLIENT_LL's handle tickcounter > msTimesOutAfer then the message shall timeout*/
}IOTHUB_MESSAGE_LIST;
--- a/internal/iothub_transport_ll_private.h Thu Jul 12 18:09:13 2018 -0700
+++ b/internal/iothub_transport_ll_private.h Tue Sep 11 11:13:11 2018 -0700
@@ -31,16 +31,16 @@
{
#endif
- /** @brief This struct captures device configuration. */
+ /** @brief This struct captures device configuration. */
typedef struct IOTHUB_DEVICE_CONFIG_TAG
{
- /** @brief A string that identifies the device. */
+ /** @brief A string that identifies the device. */
const char* deviceId;
- /** @brief The device key used to authenticate the device. */
+ /** @brief The device key used to authenticate the device. */
const char* deviceKey;
- /** @brief The device SAS used to authenticate the device in place of using the device key. */
+ /** @brief The device SAS used to authenticate the device in place of using the device key. */
const char* deviceSasToken;
IOTHUB_AUTHORIZATION_HANDLE authorization_module; // with either SAS Token, x509 Certs, and Device SAS Token
--- a/internal/iothubtransport.h Thu Jul 12 18:09:13 2018 -0700
+++ b/internal/iothubtransport.h Tue Sep 11 11:13:11 2018 -0700
@@ -25,7 +25,7 @@
#endif
#include "azure_c_shared_utility/umock_c_prod.h"
-
+
/** @brief This struct captures IoTHub transport configuration. */
struct IOTHUBTRANSPORT_CONFIG_TAG
{
@@ -34,9 +34,9 @@
IOTHUB_AUTHORIZATION_HANDLE auth_module_handle;
const char* moduleId;
};
-
+
typedef void(*IOTHUB_CLIENT_MULTIPLEXED_DO_WORK)(void* iotHubClientInstance);
-
+
MOCKABLE_FUNCTION(, LOCK_HANDLE, IoTHubTransport_GetLock, TRANSPORT_HANDLE, transportHandle);
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubTransport_StartWorkerThread, TRANSPORT_HANDLE, transportHandle, IOTHUB_CLIENT_CORE_HANDLE, clientHandle, IOTHUB_CLIENT_MULTIPLEXED_DO_WORK, muxDoWork);
MOCKABLE_FUNCTION(, bool, IoTHubTransport_SignalEndWorkerThread, TRANSPORT_HANDLE, transportHandle, IOTHUB_CLIENT_CORE_HANDLE, clientHandle);
--- a/iothub.c Thu Jul 12 18:09:13 2018 -0700 +++ b/iothub.c Tue Sep 11 11:13:11 2018 -0700 @@ -1,7 +1,7 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -#include <stdlib.h> +#include <stdlib.h> #include "azure_c_shared_utility/platform.h" #include "azure_c_shared_utility/xlogging.h"
--- a/iothub_client.c Thu Jul 12 18:09:13 2018 -0700 +++ b/iothub_client.c Tue Sep 11 11:13:11 2018 -0700 @@ -1,7 +1,7 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -#include <stdlib.h> +#include <stdlib.h> #include "azure_c_shared_utility/umock_c_prod.h" #include "azure_c_shared_utility/gballoc.h"
--- a/iothub_client.h Thu Jul 12 18:09:13 2018 -0700
+++ b/iothub_client.h Tue Sep 11 11:13:11 2018 -0700
@@ -2,14 +2,14 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
/** @file iothub_client.h
-* @brief Extends the IoTHubCLient_LL module with additional features.
+* @brief Extends the IoTHubCLient_LL module with additional features.
*
-* @details IoTHubClient is a module that extends the IoTHubCLient_LL
-* module with 2 features:
-* - scheduling the work for the IoTHubCLient from a
-* thread, so that the user does not need to create their
-* own thread
-* - thread-safe APIs
+* @details IoTHubClient is a module that extends the IoTHubCLient_LL
+* module with 2 features:
+* - scheduling the work for the IoTHubCLient from a
+* thread, so that the user does not need to create their
+* own thread
+* - thread-safe APIs
*/
#ifndef IOTHUB_CLIENT_H
@@ -36,331 +36,331 @@
#endif
/**
- * @brief Creates a IoT Hub client for communication with an existing
- * IoT Hub using the specified connection string parameter.
+ * @brief Creates a IoT Hub client for communication with an existing
+ * IoT Hub using the specified connection string parameter.
*
- * @param connectionString Pointer to a character string
- * @param protocol Function pointer for protocol implementation
+ * @param connectionString Pointer to a character string
+ * @param protocol Function pointer for protocol implementation
*
- * Sample connection string:
- * <blockquote>
- * <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>
+ * Sample connection string:
+ * <blockquote>
+ * <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>
* <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>
- * </blockquote>
+ * </blockquote>
*
- * @return A non-NULL @c IOTHUB_CLIENT_HANDLE value that is used when
- * invoking other functions for IoT Hub client and @c NULL on failure.
+ * @return A non-NULL @c IOTHUB_CLIENT_HANDLE value that is used when
+ * invoking other functions for IoT Hub client and @c NULL on failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_HANDLE, IoTHubClient_CreateFromConnectionString, const char*, connectionString, IOTHUB_CLIENT_TRANSPORT_PROVIDER, protocol);
/**
- * @brief Creates a IoT Hub client for communication with an existing IoT
- * Hub using the specified parameters.
+ * @brief Creates a IoT Hub client for communication with an existing IoT
+ * Hub using the specified parameters.
*
- * @param config Pointer to an @c IOTHUB_CLIENT_CONFIG structure
+ * @param config Pointer to an @c IOTHUB_CLIENT_CONFIG structure
*
- * The API does not allow sharing of a connection across multiple
- * devices. This is a blocking call.
+ * The API does not allow sharing of a connection across multiple
+ * devices. This is a blocking call.
*
- * @return A non-NULL @c IOTHUB_CLIENT_HANDLE value that is used when
- * invoking other functions for IoT Hub client and @c NULL on failure.
+ * @return A non-NULL @c IOTHUB_CLIENT_HANDLE value that is used when
+ * invoking other functions for IoT Hub client and @c NULL on failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_HANDLE, IoTHubClient_Create, const IOTHUB_CLIENT_CONFIG*, config);
/**
- * @brief Creates a IoT Hub client for communication with an existing IoT
- * Hub using the specified parameters.
+ * @brief Creates a IoT Hub client for communication with an existing IoT
+ * Hub using the specified parameters.
*
- * @param transportHandle TRANSPORT_HANDLE which represents a connection.
- * @param config Pointer to an @c IOTHUB_CLIENT_CONFIG structure
+ * @param transportHandle TRANSPORT_HANDLE which represents a connection.
+ * @param config Pointer to an @c IOTHUB_CLIENT_CONFIG structure
*
- * The API allows sharing of a connection across multiple
- * devices. This is a blocking call.
+ * The API allows sharing of a connection across multiple
+ * devices. This is a blocking call.
*
- * @return A non-NULL @c IOTHUB_CLIENT_HANDLE value that is used when
- * invoking other functions for IoT Hub client and @c NULL on failure.
+ * @return A non-NULL @c IOTHUB_CLIENT_HANDLE value that is used when
+ * invoking other functions for IoT Hub client and @c NULL on failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_HANDLE, IoTHubClient_CreateWithTransport, TRANSPORT_HANDLE, transportHandle, const IOTHUB_CLIENT_CONFIG*, config);
/**
- * @brief Creates a IoT Hub client for communication with an existing IoT
- * Hub using the device auth module.
+ * @brief Creates a IoT Hub client for communication with an existing IoT
+ * Hub using the device auth module.
*
- * @param iothub_uri Pointer to an ioThub hostname received in the registration process
- * @param device_id Pointer to the device Id of the device
- * @param protocol Function pointer for protocol implementation
+ * @param iothub_uri Pointer to an ioThub hostname received in the registration process
+ * @param device_id Pointer to the device Id of the device
+ * @param protocol Function pointer for protocol implementation
*
- * @return A non-NULL @c IOTHUB_CLIENT_LL_HANDLE value that is used when
- * invoking other functions for IoT Hub client and @c NULL on failure.
+ * @return A non-NULL @c IOTHUB_CLIENT_LL_HANDLE value that is used when
+ * invoking other functions for IoT Hub client and @c NULL on failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_HANDLE, IoTHubClient_CreateFromDeviceAuth, const char*, iothub_uri, const char*, device_id, IOTHUB_CLIENT_TRANSPORT_PROVIDER, protocol);
/**
- * @brief Disposes of resources allocated by the IoT Hub client. This is a
- * blocking call.
+ * @brief Disposes of resources allocated by the IoT Hub client. This is a
+ * blocking call.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param iotHubClientHandle The handle created by a call to the create function.
*/
MOCKABLE_FUNCTION(, void, IoTHubClient_Destroy, IOTHUB_CLIENT_HANDLE, iotHubClientHandle);
/**
- * @brief Asynchronous call to send the message specified by @p eventMessageHandle.
+ * @brief Asynchronous call to send the message specified by @p eventMessageHandle.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param eventMessageHandle The handle to an IoT Hub message.
- * @param eventConfirmationCallback The callback specified by the device for receiving
- * confirmation of the delivery of the IoT Hub message.
- * This callback can be expected to invoke the
- * ::IoTHubClient_SendEventAsync function for the
- * same message in an attempt to retry sending a failing
- * message. The user can specify a @c NULL value here to
- * indicate that no callback is required.
- * @param userContextCallback User specified context that will be provided to the
- * callback. This can be @c NULL.
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param eventMessageHandle The handle to an IoT Hub message.
+ * @param eventConfirmationCallback The callback specified by the device for receiving
+ * confirmation of the delivery of the IoT Hub message.
+ * This callback can be expected to invoke the
+ * ::IoTHubClient_SendEventAsync function for the
+ * same message in an attempt to retry sending a failing
+ * message. The user can specify a @c NULL value here to
+ * indicate that no callback is required.
+ * @param userContextCallback User specified context that will be provided to the
+ * callback. This can be @c NULL.
*
- * @b NOTE: The application behavior is undefined if the user calls
- * the ::IoTHubClient_Destroy function from within any callback.
+ * @b NOTE: The application behavior is undefined if the user calls
+ * the ::IoTHubClient_Destroy function from within any callback.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_SendEventAsync, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_MESSAGE_HANDLE, eventMessageHandle, IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK, eventConfirmationCallback, void*, userContextCallback);
/**
- * @brief This function returns the current sending status for IoTHubClient.
+ * @brief This function returns the current sending status for IoTHubClient.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param iotHubClientStatus The sending state is populated at the address pointed
- * at by this parameter. The value will be set to
- * @c IOTHUBCLIENT_SENDSTATUS_IDLE if there is currently
- * no item to be sent and @c IOTHUBCLIENT_SENDSTATUS_BUSY
- * if there are.
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param iotHubClientStatus The sending state is populated at the address pointed
+ * at by this parameter. The value will be set to
+ * @c IOTHUBCLIENT_SENDSTATUS_IDLE if there is currently
+ * no item to be sent and @c IOTHUBCLIENT_SENDSTATUS_BUSY
+ * if there are.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_GetSendStatus, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_STATUS*, iotHubClientStatus);
/**
- * @brief Sets up the message callback to be invoked when IoT Hub issues a
- * message to the device. This is a blocking call.
+ * @brief Sets up the message callback to be invoked when IoT Hub issues a
+ * message to the device. This is a blocking call.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param messageCallback The callback specified by the device for receiving
- * messages from IoT Hub.
- * @param userContextCallback User specified context that will be provided to the
- * callback. This can be @c NULL.
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param messageCallback The callback specified by the device for receiving
+ * messages from IoT Hub.
+ * @param userContextCallback User specified context that will be provided to the
+ * callback. This can be @c NULL.
*
- * @b NOTE: The application behavior is undefined if the user calls
- * the ::IoTHubClient_Destroy function from within any callback.
+ * @b NOTE: The application behavior is undefined if the user calls
+ * the ::IoTHubClient_Destroy function from within any callback.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_SetMessageCallback, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC, messageCallback, void*, userContextCallback);
/**
- * @brief Sets up the connection status callback to be invoked representing the status of
+ * @brief Sets up the connection status callback to be invoked representing the status of
* the connection to IOT Hub. This is a blocking call.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param connectionStatusCallback The callback specified by the device for receiving
- * updates about the status of the connection to IoT Hub.
- * @param userContextCallback User specified context that will be provided to the
- * callback. This can be @c NULL.
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param connectionStatusCallback The callback specified by the device for receiving
+ * updates about the status of the connection to IoT Hub.
+ * @param userContextCallback User specified context that will be provided to the
+ * callback. This can be @c NULL.
*
- * @b NOTE: The application behavior is undefined if the user calls
- * the ::IoTHubClient_LL_Destroy function from within any callback.
+ * @b NOTE: The application behavior is undefined if the user calls
+ * the ::IoTHubClient_LL_Destroy function from within any callback.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_SetConnectionStatusCallback, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_CONNECTION_STATUS_CALLBACK, connectionStatusCallback, void*, userContextCallback);
/**
- * @brief Sets up the connection status callback to be invoked representing the status of
+ * @brief Sets up the connection status callback to be invoked representing the status of
* the connection to IOT Hub. This is a blocking call.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param retryPolicy The policy to use to reconnect to IoT Hub when a
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param retryPolicy The policy to use to reconnect to IoT Hub when a
* connection drops.
- * @param retryTimeoutLimitInSeconds Maximum amount of time(seconds) to attempt reconnection when a
+ * @param retryTimeoutLimitInSeconds Maximum amount of time(seconds) to attempt reconnection when a
* connection drops to IOT Hub.
*
- * @b NOTE: The application behavior is undefined if the user calls
- * the ::IoTHubClient_LL_Destroy function from within any callback.
+ * @b NOTE: The application behavior is undefined if the user calls
+ * the ::IoTHubClient_LL_Destroy function from within any callback.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_SetRetryPolicy, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_RETRY_POLICY, retryPolicy, size_t, retryTimeoutLimitInSeconds);
/**
- * @brief Sets up the connection status callback to be invoked representing the status of
+ * @brief Sets up the connection status callback to be invoked representing the status of
* the connection to IOT Hub. This is a blocking call.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param retryPolicy Out parameter containing the policy to use to reconnect to IoT Hub.
- * @param retryTimeoutLimitInSeconds Out parameter containing maximum amount of time in seconds to attempt reconnection
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param retryPolicy Out parameter containing the policy to use to reconnect to IoT Hub.
+ * @param retryTimeoutLimitInSeconds Out parameter containing maximum amount of time in seconds to attempt reconnection
to IOT Hub.
*
- * @b NOTE: The application behavior is undefined if the user calls
- * the ::IoTHubClient_LL_Destroy function from within any callback.
+ * @b NOTE: The application behavior is undefined if the user calls
+ * the ::IoTHubClient_LL_Destroy function from within any callback.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_GetRetryPolicy, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_RETRY_POLICY*, retryPolicy, size_t*, retryTimeoutLimitInSeconds);
/**
- * @brief This function returns in the out parameter @p lastMessageReceiveTime
- * what was the value of the @c time function when the last message was
- * received at the client.
+ * @brief This function returns in the out parameter @p lastMessageReceiveTime
+ * what was the value of the @c time function when the last message was
+ * received at the client.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param lastMessageReceiveTime Out parameter containing the value of @c time function
- * when the last message was received.
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param lastMessageReceiveTime Out parameter containing the value of @c time function
+ * when the last message was received.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_GetLastMessageReceiveTime, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, time_t*, lastMessageReceiveTime);
/**
- * @brief This API sets a runtime option identified by parameter @p optionName
- * to a value pointed to by @p value. @p optionName and the data type
- * @p value is pointing to are specific for every option.
+ * @brief This API sets a runtime option identified by parameter @p optionName
+ * to a value pointed to by @p value. @p optionName and the data type
+ * @p value is pointing to are specific for every option.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param optionName Name of the option.
- * @param value The value.
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param optionName Name of the option.
+ * @param value The value.
*
- * The options that can be set via this API are:
- * - @b timeout - the maximum time in milliseconds a communication is
- * allowed to use. @p value is a pointer to an @c unsigned @c int with
- * the timeout value in milliseconds. This is only supported for the HTTP
- * protocol as of now. When the HTTP protocol uses CURL, the meaning of
- * the parameter is <em>total request time</em>. When the HTTP protocol uses
- * winhttp, the meaning is the same as the @c dwSendTimeout and
- * @c dwReceiveTimeout parameters of the
- * <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa384116(v=vs.85).aspx">
- * WinHttpSetTimeouts</a> API.
- * - @b CURLOPT_LOW_SPEED_LIMIT - only available for HTTP protocol and only
- * when CURL is used. It has the same meaning as CURL's option with the same
- * name. @p value is pointer to a long.
- * - @b CURLOPT_LOW_SPEED_TIME - only available for HTTP protocol and only
- * when CURL is used. It has the same meaning as CURL's option with the same
- * name. @p value is pointer to a long.
- * - @b CURLOPT_FORBID_REUSE - only available for HTTP protocol and only
- * when CURL is used. It has the same meaning as CURL's option with the same
- * name. @p value is pointer to a long.
- * - @b CURLOPT_FRESH_CONNECT - only available for HTTP protocol and only
- * when CURL is used. It has the same meaning as CURL's option with the same
- * name. @p value is pointer to a long.
- * - @b CURLOPT_VERBOSE - only available for HTTP protocol and only
- * when CURL is used. It has the same meaning as CURL's option with the same
- * name. @p value is pointer to a long.
- * - @b messageTimeout - the maximum time in milliseconds until a message
+ * The options that can be set via this API are:
+ * - @b timeout - the maximum time in milliseconds a communication is
+ * allowed to use. @p value is a pointer to an @c unsigned @c int with
+ * the timeout value in milliseconds. This is only supported for the HTTP
+ * protocol as of now. When the HTTP protocol uses CURL, the meaning of
+ * the parameter is <em>total request time</em>. When the HTTP protocol uses
+ * winhttp, the meaning is the same as the @c dwSendTimeout and
+ * @c dwReceiveTimeout parameters of the
+ * <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa384116(v=vs.85).aspx">
+ * WinHttpSetTimeouts</a> API.
+ * - @b CURLOPT_LOW_SPEED_LIMIT - only available for HTTP protocol and only
+ * when CURL is used. It has the same meaning as CURL's option with the same
+ * name. @p value is pointer to a long.
+ * - @b CURLOPT_LOW_SPEED_TIME - only available for HTTP protocol and only
+ * when CURL is used. It has the same meaning as CURL's option with the same
+ * name. @p value is pointer to a long.
+ * - @b CURLOPT_FORBID_REUSE - only available for HTTP protocol and only
+ * when CURL is used. It has the same meaning as CURL's option with the same
+ * name. @p value is pointer to a long.
+ * - @b CURLOPT_FRESH_CONNECT - only available for HTTP protocol and only
+ * when CURL is used. It has the same meaning as CURL's option with the same
+ * name. @p value is pointer to a long.
+ * - @b CURLOPT_VERBOSE - only available for HTTP protocol and only
+ * when CURL is used. It has the same meaning as CURL's option with the same
+ * name. @p value is pointer to a long.
+ * - @b messageTimeout - the maximum time in milliseconds until a message
* is timeouted. The time starts at IoTHubClient_SendEventAsync. By default,
* messages do not expire. @p is a pointer to a uint64_t
- * - @b svc2cl_keep_alive_timeout_secs - the AMQP service side keep alive interval in seconds.
- * After the connection established the client requests the server to set the
+ * - @b svc2cl_keep_alive_timeout_secs - the AMQP service side keep alive interval in seconds.
+ * After the connection established the client requests the server to set the
* keep alive interval for given time.
- * If it is not set then the default 240 sec applies.
+ * If it is not set then the default 240 sec applies.
* If it is set to zero the server will not send keep alive messages to the client.
- * - @b cl2svc_keep_alive_send_ratio - the AMQP client side keep alive interval in seconds.
+ * - @b cl2svc_keep_alive_send_ratio - the AMQP client side keep alive interval in seconds.
* After the connection established the server requests the client to set the
* keep alive interval for given time.
* If it is not set then the default ratio of 1/2 is applied.
* The ratio has to be greater than 0.0 and equal to or less than 0.9
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_SetOption, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, const char*, optionName, const void*, value);
/**
- * @brief This API specifies a call back to be used when the device receives a state update.
+ * @brief This API specifies a call back to be used when the device receives a state update.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param deviceTwinCallback The callback specified by the device client to be used for updating
- * the desired state. The callback will be called in response to a
- * request send by the IoTHub services. The payload will be passed to the
- * callback, along with two version numbers:
- * - Desired:
- * - LastSeenReported:
- * @param userContextCallback User specified context that will be provided to the
- * callback. This can be @c NULL.
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param deviceTwinCallback The callback specified by the device client to be used for updating
+ * the desired state. The callback will be called in response to a
+ * request send by the IoTHub services. The payload will be passed to the
+ * callback, along with two version numbers:
+ * - Desired:
+ * - LastSeenReported:
+ * @param userContextCallback User specified context that will be provided to the
+ * callback. This can be @c NULL.
*
- * @b NOTE: The application behavior is undefined if the user calls
- * the ::IoTHubClient_Destroy function from within any callback.
+ * @b NOTE: The application behavior is undefined if the user calls
+ * the ::IoTHubClient_Destroy function from within any callback.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_SetDeviceTwinCallback, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_DEVICE_TWIN_CALLBACK, deviceTwinCallback, void*, userContextCallback);
/**
- * @brief This API sends a report of the device's properties and their current values.
+ * @brief This API sends a report of the device's properties and their current values.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param reportedState The current device property values to be 'reported' to the IoTHub.
- * @param reportedStateCallback The callback specified by the device client to be called with the
- * result of the transaction.
- * @param userContextCallback User specified context that will be provided to the
- * callback. This can be @c NULL.
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param reportedState The current device property values to be 'reported' to the IoTHub.
+ * @param reportedStateCallback The callback specified by the device client to be called with the
+ * result of the transaction.
+ * @param userContextCallback User specified context that will be provided to the
+ * callback. This can be @c NULL.
*
- * @b NOTE: The application behavior is undefined if the user calls
- * the ::IoTHubClient_Destroy function from within any callback.
+ * @b NOTE: The application behavior is undefined if the user calls
+ * the ::IoTHubClient_Destroy function from within any callback.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_SendReportedState, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, const unsigned char*, reportedState, size_t, size, IOTHUB_CLIENT_REPORTED_STATE_CALLBACK, reportedStateCallback, void*, userContextCallback);
/**
- * @brief This API sets callback for cloud to device method call.
+ * @brief This API sets callback for cloud to device method call.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param deviceMethodCallback The callback which will be called by IoTHub.
- * @param userContextCallback User specified context that will be provided to the
- * callback. This can be @c NULL.
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param deviceMethodCallback The callback which will be called by IoTHub.
+ * @param userContextCallback User specified context that will be provided to the
+ * callback. This can be @c NULL.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_SetDeviceMethodCallback, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_DEVICE_METHOD_CALLBACK_ASYNC, deviceMethodCallback, void*, userContextCallback);
/**
- * @brief This API sets callback for async cloud to device method call.
+ * @brief This API sets callback for async cloud to device method call.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param inboundDeviceMethodCallback The callback which will be called by IoTHub.
- * @param userContextCallback User specified context that will be provided to the
- * callback. This can be @c NULL.
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param inboundDeviceMethodCallback The callback which will be called by IoTHub.
+ * @param userContextCallback User specified context that will be provided to the
+ * callback. This can be @c NULL.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_SetDeviceMethodCallback_Ex, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_INBOUND_DEVICE_METHOD_CALLBACK, inboundDeviceMethodCallback, void*, userContextCallback);
/**
- * @brief This API responses to a asnyc method callback identified the methodId.
+ * @brief This API responses to a asnyc method callback identified the methodId.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param methodId The methodId of the Device Method callback.
- * @param response The response data for the method callback.
- * @param response_size The size of the response data buffer.
- * @param status_response The status response of the method callback.
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param methodId The methodId of the Device Method callback.
+ * @param response The response data for the method callback.
+ * @param response_size The size of the response data buffer.
+ * @param status_response The status response of the method callback.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_DeviceMethodResponse, IOTHUB_CLIENT_HANDLE, iotHubClientHandle, METHOD_HANDLE, methodId, const unsigned char*, response, size_t, response_size, int, statusCode);
#ifndef DONT_USE_UPLOADTOBLOB
/**
- * @brief IoTHubClient_UploadToBlobAsync uploads data from memory to a file in Azure Blob Storage.
+ * @brief IoTHubClient_UploadToBlobAsync uploads data from memory to a file in Azure Blob Storage.
*
- * @param iotHubClientHandle The handle created by a call to the IoTHubClient_Create function.
- * @param destinationFileName The name of the file to be created in Azure Blob Storage.
- * @param source The source of data.
- * @param size The size of data.
+ * @param iotHubClientHandle The handle created by a call to the IoTHubClient_Create function.
+ * @param destinationFileName The name of the file to be created in Azure Blob Storage.
+ * @param source The source of data.
+ * @param size The size of data.
* @param iotHubClientFileUploadCallback A callback to be invoked when the file upload operation has finished.
* @param context A user-provided context to be passed to the file upload callback.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, 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);
- /**
+ /**
** DEPRECATED: Use IoTHubClient_UploadMultipleBlocksToBlobAsyncEx instead **
* @brief Uploads a file to a Blob storage in chunks, fed through the callback function provided by the user.
* @remarks This function allows users to upload large files in chunks, not requiring the whole file content to be passed in memory.
--- a/iothub_client_authorization.c Thu Jul 12 18:09:13 2018 -0700
+++ b/iothub_client_authorization.c Tue Sep 11 11:13:11 2018 -0700
@@ -6,7 +6,7 @@
#include "azure_c_shared_utility/macro_utils.h"
#include "azure_c_shared_utility/umock_c_prod.h"
#include "azure_c_shared_utility/crt_abstractions.h"
-#include "azure_c_shared_utility/agenttime.h"
+#include "azure_c_shared_utility/agenttime.h"
#include "azure_c_shared_utility/xlogging.h"
#include "azure_c_shared_utility/strings.h"
#include "azure_c_shared_utility/sastoken.h"
@@ -333,7 +333,7 @@
LogError("failure getting seconds from epoch");
result = NULL;
}
- else
+ else
{
memset(&dev_auth_cred, 0, sizeof(DEVICE_AUTH_CREDENTIAL_INFO));
size_t expiry_time = sec_since_epoch+expiry_time_relative_seconds;
@@ -400,7 +400,7 @@
LogError("failure getting seconds from epoch");
result = NULL;
}
- else
+ else
{
/* Codes_SRS_IoTHub_Authorization_07_011: [ IoTHubClient_Auth_Get_ConnString shall call SASToken_CreateString to construct the sas token. ] */
size_t expiry_time = sec_since_epoch+expiry_time_relative_seconds;
@@ -539,7 +539,17 @@
#ifdef USE_EDGE_MODULES
char* IoTHubClient_Auth_Get_TrustBundle(IOTHUB_AUTHORIZATION_HANDLE handle)
{
- return iothub_device_auth_get_trust_bundle(handle->device_auth_handle);
+ char* result;
+ if (handle == NULL)
+ {
+ LogError("Security Handle is NULL");
+ result = NULL;
+ }
+ else
+ {
+ result = iothub_device_auth_get_trust_bundle(handle->device_auth_handle);
+ }
+ return result;
}
#endif
--- a/iothub_client_core.c Thu Jul 12 18:09:13 2018 -0700
+++ b/iothub_client_core.c Tue Sep 11 11:13:11 2018 -0700
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-#include <stdlib.h>
+#include <stdlib.h>
#include "azure_c_shared_utility/umock_c_prod.h"
#include "azure_c_shared_utility/gballoc.h"
@@ -29,9 +29,7 @@
THREAD_HANDLE ThreadHandle;
LOCK_HANDLE LockHandle;
sig_atomic_t StopThread;
-#ifndef DONT_USE_UPLOADTOBLOB
- SINGLYLINKEDLIST_HANDLE savedDataToBeCleaned; /*list containing UPLOADTOBLOB_SAVED_DATA*/
-#endif
+ SINGLYLINKEDLIST_HANDLE httpWorkerThreadInfoList; /*list containing HTTPWORKER_THREAD_INFO*/
int created_with_transport_handle;
VECTOR_HANDLE saved_user_callback_list;
IOTHUB_CLIENT_DEVICE_TWIN_CALLBACK desired_state_callback;
@@ -47,7 +45,12 @@
struct IOTHUB_QUEUE_CONTEXT_TAG* method_user_context;
} IOTHUB_CLIENT_CORE_INSTANCE;
-#ifndef DONT_USE_UPLOADTOBLOB
+typedef enum HTTPWORKER_THREAD_TYPE_TAG
+{
+ HTTPWORKER_THREAD_UPLOAD_TO_BLOB,
+ HTTPWORKER_THREAD_INVOKE_METHOD
+} HTTPWORKER_THREAD_TYPE;
+
typedef struct UPLOADTOBLOB_SAVED_DATA_TAG
{
unsigned char* source;
@@ -61,19 +64,29 @@
IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK_EX getDataCallbackEx;
}UPLOADTOBLOB_MULTIBLOCK_SAVED_DATA;
-typedef struct UPLOADTOBLOB_THREAD_INFO_TAG
+typedef struct INVOKE_METHOD_SAVED_DATA_TAG
{
+ const char* deviceId;
+ const char* moduleId;
+ const char* methodName;
+ const char* methodPayload;
+ unsigned int timeout;
+ IOTHUB_METHOD_INVOKE_CALLBACK methodInvokeCallback;
+} INVOKE_METHOD_SAVED_DATA;
+
+typedef struct HTTPWORKER_THREAD_INFO_TAG
+{
+ HTTPWORKER_THREAD_TYPE workerThreadType;
char* destinationFileName;
- THREAD_HANDLE uploadingThreadHandle;
+ THREAD_HANDLE threadHandle;
LOCK_HANDLE lockGarbage;
- int canBeGarbageCollected; /*flag indicating that the UPLOADTOBLOB_SAVED_DATA structure can be freed because the thread deadling with it finished*/
+ int canBeGarbageCollected; /*flag indicating that the structure can be freed because the thread deadling with it finished*/
IOTHUB_CLIENT_CORE_HANDLE iotHubClientHandle;
void* context;
UPLOADTOBLOB_SAVED_DATA uploadBlobSavedData;
+ INVOKE_METHOD_SAVED_DATA invokeMethodSavedData;
UPLOADTOBLOB_MULTIBLOCK_SAVED_DATA uploadBlobMultiblockSavedData;
-}UPLOADTOBLOB_THREAD_INFO;
-
-#endif
+}HTTPWORKER_THREAD_INFO;
#define USER_CALLBACK_TYPE_VALUES \
CALLBACK_TYPE_DEVICE_TWIN, \
@@ -165,12 +178,22 @@
CREATE_HUB_INSTANCE_FROM_DEVICE_AUTH
} CREATE_HUB_INSTANCE_TYPE;
-#ifndef DONT_USE_UPLOADTOBLOB
-static void freeUploadToBlobThreadInfo(UPLOADTOBLOB_THREAD_INFO* threadInfo)
+static void freeHttpWorkerThreadInfo(HTTPWORKER_THREAD_INFO* threadInfo)
{
Lock_Deinit(threadInfo->lockGarbage);
- free(threadInfo->uploadBlobSavedData.source);
- free(threadInfo->destinationFileName);
+ if (threadInfo->workerThreadType == HTTPWORKER_THREAD_UPLOAD_TO_BLOB)
+ {
+ free(threadInfo->uploadBlobSavedData.source);
+ free(threadInfo->destinationFileName);
+ }
+ else if (threadInfo->workerThreadType == HTTPWORKER_THREAD_INVOKE_METHOD)
+ {
+ free((char*)threadInfo->invokeMethodSavedData.deviceId);
+ free((char*)threadInfo->invokeMethodSavedData.moduleId);
+ free((char*)threadInfo->invokeMethodSavedData.methodName);
+ free((char*)threadInfo->invokeMethodSavedData.methodPayload);
+ }
+
free(threadInfo);
}
@@ -179,10 +202,10 @@
{
/*see if any savedData structures can be disposed of*/
/*Codes_SRS_IOTHUBCLIENT_02_072: [ All threads marked as disposable (upon completion of a file upload) shall be joined and the data structures build for them shall be freed. ]*/
- LIST_ITEM_HANDLE item = singlylinkedlist_get_head_item(iotHubClientInstance->savedDataToBeCleaned);
+ LIST_ITEM_HANDLE item = singlylinkedlist_get_head_item(iotHubClientInstance->httpWorkerThreadInfoList);
while (item != NULL)
{
- UPLOADTOBLOB_THREAD_INFO* threadInfo = (UPLOADTOBLOB_THREAD_INFO*)singlylinkedlist_item_get_value(item);
+ HTTPWORKER_THREAD_INFO* threadInfo = (HTTPWORKER_THREAD_INFO*)singlylinkedlist_item_get_value(item);
LIST_ITEM_HANDLE old_item = item;
item = singlylinkedlist_get_next_item(item);
@@ -195,17 +218,17 @@
if (threadInfo->canBeGarbageCollected == 1)
{
int notUsed;
- if (ThreadAPI_Join(threadInfo->uploadingThreadHandle, ¬Used) != THREADAPI_OK)
+ if (ThreadAPI_Join(threadInfo->threadHandle, ¬Used) != THREADAPI_OK)
{
LogError("unable to ThreadAPI_Join");
}
- (void)singlylinkedlist_remove(iotHubClientInstance->savedDataToBeCleaned, old_item);
+ (void)singlylinkedlist_remove(iotHubClientInstance->httpWorkerThreadInfoList, old_item);
if (Unlock(threadInfo->lockGarbage) != LOCK_OK)
{
LogError("unable to unlock after locking");
}
- freeUploadToBlobThreadInfo(threadInfo);
+ freeHttpWorkerThreadInfo(threadInfo);
}
else
{
@@ -217,7 +240,7 @@
}
}
}
-#endif
+
static bool iothub_ll_message_callback(MESSAGE_CALLBACK_INFO* messageData, void* userContextCallback)
{
@@ -599,7 +622,7 @@
}
break;
case CALLBACK_TYPE_MESSAGE:
- if (message_callback)
+ if (message_callback && message_user_context_handle)
{
IOTHUBMESSAGE_DISPOSITION_RESULT disposition = message_callback(queued_cb->iothub_callback.message_cb_info->messageHandle, queued_cb->userContextCallback);
@@ -653,9 +676,7 @@
{
IOTHUB_CLIENT_CORE_INSTANCE* iotHubClientInstance = (IOTHUB_CLIENT_CORE_INSTANCE*)iotHubClientHandle;
-#ifndef DONT_USE_UPLOADTOBLOB
garbageCollectorImpl(iotHubClientInstance);
-#endif
if (Lock(iotHubClientInstance->LockHandle) == LOCK_OK)
{
VECTOR_HANDLE call_backs = VECTOR_move(iotHubClientInstance->saved_user_callback_list);
@@ -696,9 +717,7 @@
/* Codes_SRS_IOTHUBCLIENT_01_039: [All calls to IoTHubClientCore_LL_DoWork shall be protected by the lock created in IotHubClient_Create.] */
IoTHubClientCore_LL_DoWork(iotHubClientInstance->IoTHubClientLLHandle);
-#ifndef DONT_USE_UPLOADTOBLOB
garbageCollectorImpl(iotHubClientInstance);
-#endif
VECTOR_HANDLE call_backs = VECTOR_move(iotHubClientInstance->saved_user_callback_list);
(void)Unlock(iotHubClientInstance->LockHandle);
if (call_backs == NULL)
@@ -766,6 +785,8 @@
/* Codes_SRS_IOTHUBCLIENT_01_004: [If allocating memory for the new IoTHubClient instance fails, then IoTHubClient_Create shall return NULL.] */
if (result != NULL)
{
+ memset((void *)result, 0, sizeof(IOTHUB_CLIENT_CORE_INSTANCE));
+
/* Codes_SRS_IOTHUBCLIENT_01_029: [IoTHubClient_Create shall create a lock object to be used later for serializing IoTHubClient calls.] */
if ((result->saved_user_callback_list = VECTOR_create(sizeof(USER_CALLBACK_INFO))) == NULL)
{
@@ -775,9 +796,8 @@
}
else
{
-#ifndef DONT_USE_UPLOADTOBLOB
/*Codes_SRS_IOTHUBCLIENT_02_060: [ IoTHubClient_Create shall create a SINGLYLINKEDLIST_HANDLE containing THREAD_HANDLE (created by future calls to IoTHubClient_UploadToBlobAsync). ]*/
- if ((result->savedDataToBeCleaned = singlylinkedlist_create()) == NULL)
+ if ((result->httpWorkerThreadInfoList = singlylinkedlist_create()) == NULL)
{
/*Codes_SRS_IOTHUBCLIENT_02_061: [ If creating the SINGLYLINKEDLIST_HANDLE fails then IoTHubClient_Create shall fail and return NULL. ]*/
LogError("unable to singlylinkedlist_create");
@@ -786,7 +806,6 @@
result = NULL;
}
else
-#endif
{
result->TransportHandle = transportHandle;
result->created_with_transport_handle = 0;
@@ -914,13 +933,11 @@
/* Codes_SRS_IOTHUBCLIENT_01_003: [If IoTHubClientCore_LL_Create fails, then IoTHubClient_Create shall return NULL.] */
/* Codes_SRS_IOTHUBCLIENT_01_031: [If IoTHubClient_Create fails, all resources allocated by it shall be freed.] */
/* Codes_SRS_IOTHUBCLIENT_17_006: [ If IoTHubTransport_GetLock fails, then IoTHubClient_CreateWithTransport shall return NULL. ]*/
- if (transportHandle == NULL)
+ if ((transportHandle == NULL) && (result->LockHandle != NULL))
{
Lock_Deinit(result->LockHandle);
}
-#ifndef DONT_USE_UPLOADTOBLOB
- singlylinkedlist_destroy(result->savedDataToBeCleaned);
-#endif
+ singlylinkedlist_destroy(result->httpWorkerThreadInfoList);
LogError("Failure creating iothub handle");
VECTOR_destroy(result->saved_user_callback_list);
free(result);
@@ -1025,7 +1042,7 @@
/* Codes_SRS_IOTHUBCLIENT_12_022: [** `IoTHubClient_CreateFromDeviceAuth` shall create a lock object to be used later for serializing IoTHubClient calls. **] */
/* Codes_SRS_IOTHUBCLIENT_12_023: [** If creating the lock fails, then IoTHubClient_CreateFromDeviceAuth shall return NULL. **] */
/* Codes_SRS_IOTHUBCLIENT_12_024: [** If IoTHubClient_CreateFromDeviceAuth fails, all resources allocated by it shall be freed. **] */
- /* Codes_SRS_IOTHUBCLIENT_12_025: [** `IoTHubClient_CreateFromDeviceAuth` shall instantiate a new `IoTHubClientCore_LL` instance by calling `IoTHubClientCore_LL_CreateFromDeviceAuth` and passing iothub_uri, device_id and protocol argument. **] */
+ /* Codes_SRS_IOTHUBCLIENT_12_025: [** `IoTHubClient_CreateFromDeviceAuth` shall instantiate a new `IoTHubClientCore_LL` instance by calling `IoTHubClientCore_LL_CreateFromDeviceAuth` and passing iothub_uri, device_id and protocol argument. **] */
result = create_iothub_instance(CREATE_HUB_INSTANCE_FROM_DEVICE_AUTH, NULL, NULL, NULL, protocol, iothub_uri, device_id);
}
return result;
@@ -1104,19 +1121,17 @@
LogError("unable to Lock - - will still proceed to try to end the thread without locking");
}
-#ifndef DONT_USE_UPLOADTOBLOB
/*Codes_SRS_IOTHUBCLIENT_02_069: [ IoTHubClient_Destroy shall free all data created by IoTHubClient_UploadToBlobAsync ]*/
/*wait for all uploading threads to finish*/
- while (singlylinkedlist_get_head_item(iotHubClientInstance->savedDataToBeCleaned) != NULL)
+ while (singlylinkedlist_get_head_item(iotHubClientInstance->httpWorkerThreadInfoList) != NULL)
{
garbageCollectorImpl(iotHubClientInstance);
}
- if (iotHubClientInstance->savedDataToBeCleaned != NULL)
+ if (iotHubClientInstance->httpWorkerThreadInfoList != NULL)
{
- singlylinkedlist_destroy(iotHubClientInstance->savedDataToBeCleaned);
+ singlylinkedlist_destroy(iotHubClientInstance->httpWorkerThreadInfoList);
}
-#endif
/* Codes_SRS_IOTHUBCLIENT_01_006: [That includes destroying the IoTHubClientCore_LL instance by calling IoTHubClientCore_LL_Destroy.] */
IoTHubClientCore_LL_Destroy(iotHubClientInstance->IoTHubClientLLHandle);
@@ -1963,31 +1978,38 @@
return result;
}
-#ifndef DONT_USE_UPLOADTOBLOB
-static IOTHUB_CLIENT_RESULT startUploadToBlobWorkerThread(UPLOADTOBLOB_THREAD_INFO* threadInfo, THREAD_START_FUNC uploadThreadFunc)
+#if !defined(DONT_USE_UPLOADTOBLOB) || defined(USE_EDGE_MODULES)
+static IOTHUB_CLIENT_RESULT startHttpWorkerThread(IOTHUB_CLIENT_CORE_HANDLE iotHubClientHandle, HTTPWORKER_THREAD_INFO* threadInfo, THREAD_START_FUNC httpWorkerThreadFunc)
{
IOTHUB_CLIENT_RESULT result;
LIST_ITEM_HANDLE item;
- if (Lock(threadInfo->iotHubClientHandle->LockHandle) != LOCK_OK)
+ // StartWorkerThreadIfNeeded creates the "main" worker thread used for transports. Though its not used
+ // for these HTTP based worker threads (see ThreadAPI_Create call below) the main one is needed for garbage collection.
+ if ((result = StartWorkerThreadIfNeeded(iotHubClientHandle)) != IOTHUB_CLIENT_OK)
+ {
+ /*Codes_SRS_IOTHUBCLIENT_02_053: [ If copying to the structure or spawning the thread fails, then IoTHubClient_UploadToBlobAsync shall fail and return IOTHUB_CLIENT_ERROR. ]*/
+ LogError("Could not start worker thread");
+ }
+ else if (Lock(threadInfo->iotHubClientHandle->LockHandle) != LOCK_OK)
{
LogError("Lock failed");
result = IOTHUB_CLIENT_ERROR;
}
else
{
- if ((item = singlylinkedlist_add(threadInfo->iotHubClientHandle->savedDataToBeCleaned, threadInfo)) == NULL)
+ if ((item = singlylinkedlist_add(threadInfo->iotHubClientHandle->httpWorkerThreadInfoList, threadInfo)) == NULL)
{
LogError("Adding item to list failed");
result = IOTHUB_CLIENT_ERROR;
}
- else if (ThreadAPI_Create(&threadInfo->uploadingThreadHandle, uploadThreadFunc, threadInfo) != THREADAPI_OK)
+ else if (ThreadAPI_Create(&threadInfo->threadHandle, httpWorkerThreadFunc, threadInfo) != THREADAPI_OK)
{
/*Codes_SRS_IOTHUBCLIENT_02_053: [ If copying to the structure or spawning the thread fails, then IoTHubClient_UploadToBlobAsync shall fail and return IOTHUB_CLIENT_ERROR. ]*/
LogError("unable to ThreadAPI_Create");
// Remove the item from linked list here, while we're still under lock. Final garbage collector also does it under lock.
- (void)singlylinkedlist_remove(threadInfo->iotHubClientHandle->savedDataToBeCleaned, item);
+ (void)singlylinkedlist_remove(threadInfo->iotHubClientHandle->httpWorkerThreadInfoList, item);
result = IOTHUB_CLIENT_ERROR;
}
else
@@ -2000,38 +2022,7 @@
return result;
}
-static UPLOADTOBLOB_THREAD_INFO* allocateUploadToBlob(const char* destinationFileName, IOTHUB_CLIENT_CORE_HANDLE iotHubClientHandle, void* context)
-{
- UPLOADTOBLOB_THREAD_INFO* threadInfo = (UPLOADTOBLOB_THREAD_INFO*)malloc(sizeof(UPLOADTOBLOB_THREAD_INFO));
- if (threadInfo == NULL)
- {
- LogError("unable to allocate thread object");
- }
- else
- {
- memset(threadInfo, 0, sizeof(UPLOADTOBLOB_THREAD_INFO));
- threadInfo->iotHubClientHandle = iotHubClientHandle;
- threadInfo->context = context;
-
- if (mallocAndStrcpy_s(&threadInfo->destinationFileName, destinationFileName) != 0)
- {
- /*Codes_SRS_IOTHUBCLIENT_02_053: [ If copying to the structure or spawning the thread fails, then IoTHubClient_UploadToBlobAsync shall fail and return IOTHUB_CLIENT_ERROR. ]*/
- LogError("unable to mallocAndStrcpy_s");
- freeUploadToBlobThreadInfo(threadInfo);
- threadInfo = NULL;
- }
- else if ((threadInfo->lockGarbage = Lock_Init()) == NULL)
- {
- LogError("unable to allocate a lock");
- freeUploadToBlobThreadInfo(threadInfo);
- threadInfo = NULL;
- }
- }
-
- return threadInfo;
-}
-
-static int markThreadReadyToBeGarbageCollected(UPLOADTOBLOB_THREAD_INFO* threadInfo)
+static int markThreadReadyToBeGarbageCollected(HTTPWORKER_THREAD_INFO* threadInfo)
{
/*Codes_SRS_IOTHUBCLIENT_02_071: [ The thread shall mark itself as disposable. ]*/
if (Lock(threadInfo->lockGarbage) != LOCK_OK)
@@ -2053,7 +2044,43 @@
return 0;
}
-static IOTHUB_CLIENT_RESULT initializeUploadToBlobData(UPLOADTOBLOB_THREAD_INFO* threadInfo, const unsigned char* source, size_t size, IOTHUB_CLIENT_FILE_UPLOAD_CALLBACK iotHubClientFileUploadCallback)
+#endif // !defined(DONT_USE_UPLOADTOBLOB) || defined(USE_EDGE_MODULES)
+
+#if !defined(DONT_USE_UPLOADTOBLOB)
+static HTTPWORKER_THREAD_INFO* allocateUploadToBlob(const char* destinationFileName, IOTHUB_CLIENT_CORE_HANDLE iotHubClientHandle, void* context)
+{
+ HTTPWORKER_THREAD_INFO* threadInfo = (HTTPWORKER_THREAD_INFO*)malloc(sizeof(HTTPWORKER_THREAD_INFO));
+ if (threadInfo == NULL)
+ {
+ LogError("unable to allocate thread object");
+ }
+ else
+ {
+ memset(threadInfo, 0, sizeof(HTTPWORKER_THREAD_INFO));
+ threadInfo->workerThreadType = HTTPWORKER_THREAD_UPLOAD_TO_BLOB;
+ threadInfo->iotHubClientHandle = iotHubClientHandle;
+ threadInfo->context = context;
+
+ if (mallocAndStrcpy_s(&threadInfo->destinationFileName, destinationFileName) != 0)
+ {
+ /*Codes_SRS_IOTHUBCLIENT_02_053: [ If copying to the structure or spawning the thread fails, then IoTHubClient_UploadToBlobAsync shall fail and return IOTHUB_CLIENT_ERROR. ]*/
+ LogError("unable to mallocAndStrcpy_s");
+ freeHttpWorkerThreadInfo(threadInfo);
+ threadInfo = NULL;
+ }
+ else if ((threadInfo->lockGarbage = Lock_Init()) == NULL)
+ {
+ LogError("unable to allocate a lock");
+ freeHttpWorkerThreadInfo(threadInfo);
+ threadInfo = NULL;
+ }
+ }
+
+ return threadInfo;
+}
+
+
+static IOTHUB_CLIENT_RESULT initializeUploadToBlobData(HTTPWORKER_THREAD_INFO* threadInfo, const unsigned char* source, size_t size, IOTHUB_CLIENT_FILE_UPLOAD_CALLBACK iotHubClientFileUploadCallback)
{
IOTHUB_CLIENT_RESULT result;
@@ -2085,7 +2112,7 @@
static int uploadingThread(void *data)
{
IOTHUB_CLIENT_FILE_UPLOAD_RESULT upload_result;
- UPLOADTOBLOB_THREAD_INFO* threadInfo = (UPLOADTOBLOB_THREAD_INFO*)data;
+ HTTPWORKER_THREAD_INFO* threadInfo = (HTTPWORKER_THREAD_INFO*)data;
/*it so happens that IoTHubClientCore_LL_UploadToBlob is thread-safe because there's no saved state in the handle and there are no globals, so no need to protect it*/
/*not having it protected means multiple simultaneous uploads can happen*/
@@ -2134,7 +2161,7 @@
else
{
/*Codes_SRS_IOTHUBCLIENT_02_051: [IoTHubClient_UploadToBlobAsync shall copy the souce, size, iotHubClientFileUploadCallback, context into a structure.]*/
- UPLOADTOBLOB_THREAD_INFO *threadInfo = allocateUploadToBlob(destinationFileName, iotHubClientHandle, context);
+ HTTPWORKER_THREAD_INFO *threadInfo = allocateUploadToBlob(destinationFileName, iotHubClientHandle, context);
if (threadInfo == NULL)
{
/*Codes_SRS_IOTHUBCLIENT_02_053: [ If copying to the structure or spawning the thread fails, then IoTHubClient_UploadToBlobAsync shall fail and return IOTHUB_CLIENT_ERROR. ]*/
@@ -2147,18 +2174,12 @@
LogError("unable to initialize upload blob info");
result = IOTHUB_CLIENT_ERROR;
}
- else if ((result = StartWorkerThreadIfNeeded(iotHubClientHandle)) != IOTHUB_CLIENT_OK)
- {
- /*Codes_SRS_IOTHUBCLIENT_02_053: [ If copying to the structure or spawning the thread fails, then IoTHubClient_UploadToBlobAsync shall fail and return IOTHUB_CLIENT_ERROR. ]*/
- LogError("Could not start worker thread");
- freeUploadToBlobThreadInfo(threadInfo);
- }
/*Codes_SRS_IOTHUBCLIENT_02_052: [ IoTHubClient_UploadToBlobAsync shall spawn a thread passing the structure build in SRS IOTHUBCLIENT 02 051 as thread data.]*/
- else if ((result = startUploadToBlobWorkerThread(threadInfo, uploadingThread)) != IOTHUB_CLIENT_OK)
+ else if ((result = startHttpWorkerThread(iotHubClientHandle, threadInfo, uploadingThread)) != IOTHUB_CLIENT_OK)
{
/*Codes_SRS_IOTHUBCLIENT_02_053: [ If copying to the structure or spawning the thread fails, then IoTHubClient_UploadToBlobAsync shall fail and return IOTHUB_CLIENT_ERROR. ]*/
LogError("unable to start upload thread");
- freeUploadToBlobThreadInfo(threadInfo);
+ freeHttpWorkerThreadInfo(threadInfo);
}
else
{
@@ -2171,7 +2192,7 @@
static int uploadMultipleBlock_thread(void* data)
{
- UPLOADTOBLOB_THREAD_INFO* threadInfo = (UPLOADTOBLOB_THREAD_INFO*)data;
+ HTTPWORKER_THREAD_INFO* threadInfo = (HTTPWORKER_THREAD_INFO*)data;
IOTHUB_CLIENT_CORE_LL_HANDLE llHandle = threadInfo->iotHubClientHandle->IoTHubClientLLHandle;
/*Codes_SRS_IOTHUBCLIENT_99_078: [ The thread shall call `IoTHubClientCore_LL_UploadMultipleBlocksToBlob` or `IoTHubClientCore_LL_UploadMultipleBlocksToBlobEx` passing the information packed in the structure. ]*/
@@ -2214,7 +2235,7 @@
else
{
/*Codes_SRS_IOTHUBCLIENT_99_075: [ `IoTHubClient_UploadMultipleBlocksToBlobAsync(Ex)` shall copy the `destinationFileName`, `getDataCallback`, `context` and `iotHubClientHandle` into a structure. ]*/
- UPLOADTOBLOB_THREAD_INFO *threadInfo = allocateUploadToBlob(destinationFileName, iotHubClientHandle, context);
+ HTTPWORKER_THREAD_INFO *threadInfo = allocateUploadToBlob(destinationFileName, iotHubClientHandle, context);
if (threadInfo == NULL)
{
/*Codes_SRS_IOTHUBCLIENT_02_053: [ If copying to the structure or spawning the thread fails, then IoTHubClient_UploadToBlobAsync shall fail and return IOTHUB_CLIENT_ERROR. ]*/
@@ -2227,17 +2248,11 @@
threadInfo->uploadBlobMultiblockSavedData.getDataCallback = getDataCallback;
threadInfo->uploadBlobMultiblockSavedData.getDataCallbackEx = getDataCallbackEx;
- if ((result = StartWorkerThreadIfNeeded(iotHubClientHandle)) != IOTHUB_CLIENT_OK)
- {
- /*Codes_SRS_IOTHUBCLIENT_02_053: [ If copying to the structure or spawning the thread fails, then IoTHubClient_UploadToBlobAsync shall fail and return IOTHUB_CLIENT_ERROR. ]*/
- LogError("Could not start worker thread");
- freeUploadToBlobThreadInfo(threadInfo);
- }
- else if ((result = startUploadToBlobWorkerThread(threadInfo, uploadMultipleBlock_thread)) != IOTHUB_CLIENT_OK)
+ if ((result = startHttpWorkerThread(iotHubClientHandle, threadInfo, uploadMultipleBlock_thread)) != IOTHUB_CLIENT_OK)
{
/*Codes_SRS_IOTHUBCLIENT_02_053: [ If copying to the structure or spawning the thread fails, then IoTHubClient_UploadToBlobAsync shall fail and return IOTHUB_CLIENT_ERROR. ]*/
LogError("unable to start upload thread");
- freeUploadToBlobThreadInfo(threadInfo);
+ freeHttpWorkerThreadInfo(threadInfo);
}
else
{
@@ -2313,7 +2328,7 @@
inputMessageCallbackContext.iotHubClientHandle = iotHubClientHandle;
inputMessageCallbackContext.eventHandlerCallback = eventHandlerCallback;
inputMessageCallbackContext.userContextCallback = userContextCallback;
-
+
result = IoTHubClientCore_LL_SetInputMessageCallbackEx(iotHubClientInstance->IoTHubClientLLHandle, inputName, iothub_ll_inputmessage_callback, (void*)&inputMessageCallbackContext, sizeof(inputMessageCallbackContext));
(void)Unlock(iotHubClientInstance->LockHandle);
}
@@ -2323,27 +2338,105 @@
return result;
}
-/* Temporary function until replacement during iothub_client refactor*/
#ifdef USE_EDGE_MODULES
-IOTHUB_CLIENT_RESULT IoTHubClientCore_GenericMethodInvoke(IOTHUB_CLIENT_CORE_HANDLE iotHubClientHandle, const char* deviceId, const char* moduleId, const char* methodName, const char* methodPayload, unsigned int timeout, int* responseStatus, unsigned char** responsePayload, size_t* responsePayloadSize)
+
+HTTPWORKER_THREAD_INFO * allocateMethodInvoke(IOTHUB_CLIENT_CORE_HANDLE iotHubClientHandle, const char* deviceId, const char* moduleId, const char* methodName, const char* methodPayload, unsigned int timeout, IOTHUB_METHOD_INVOKE_CALLBACK methodInvokeCallback, void* context)
{
- IOTHUB_CLIENT_RESULT result;
- if (iotHubClientHandle == NULL)
+ HTTPWORKER_THREAD_INFO* threadInfo = (HTTPWORKER_THREAD_INFO*)malloc(sizeof(HTTPWORKER_THREAD_INFO));
+ if (threadInfo == NULL)
{
- LogError("Argument cannot be NULL");
- result = IOTHUB_CLIENT_INVALID_ARG;
- }
- else if (Lock(iotHubClientHandle->LockHandle) != LOCK_OK)
- {
- LogError("failed locking for dispatch_user_callbacks");
- result = IOTHUB_CLIENT_ERROR;
+ LogError("unable to allocate thread object");
}
else
{
- result = IoTHubClientCore_LL_GenericMethodInvoke(iotHubClientHandle->IoTHubClientLLHandle, deviceId, moduleId, methodName, methodPayload, timeout, responseStatus, responsePayload, responsePayloadSize);
- (void)Unlock(iotHubClientHandle->LockHandle);
+ memset(threadInfo, 0, sizeof(HTTPWORKER_THREAD_INFO));
+ threadInfo->workerThreadType = HTTPWORKER_THREAD_INVOKE_METHOD;
+ threadInfo->iotHubClientHandle = iotHubClientHandle;
+ threadInfo->context = context;
+
+ threadInfo->invokeMethodSavedData.timeout = timeout;
+ threadInfo->invokeMethodSavedData.methodInvokeCallback = methodInvokeCallback;
+
+ if ((mallocAndStrcpy_s((char**)&threadInfo->invokeMethodSavedData.deviceId, deviceId) != 0) ||
+ ((moduleId != NULL) && mallocAndStrcpy_s((char**)&threadInfo->invokeMethodSavedData.moduleId, moduleId) != 0) ||
+ (mallocAndStrcpy_s((char**)&threadInfo->invokeMethodSavedData.methodName, methodName) != 0) ||
+ (mallocAndStrcpy_s((char**)&threadInfo->invokeMethodSavedData.methodPayload, methodPayload) != 0))
+ {
+ LogError("Allocating resources failed");
+ freeHttpWorkerThreadInfo(threadInfo);
+ threadInfo = NULL;
+ }
+ else if ((threadInfo->lockGarbage = Lock_Init()) == NULL)
+ {
+ LogError("unable to allocate a lock");
+ freeHttpWorkerThreadInfo(threadInfo);
+ threadInfo = NULL;
+ }
}
+ return threadInfo;
+}
+
+static int uploadMethodInvoke_thread(void* data)
+{
+ IOTHUB_CLIENT_RESULT result;
+
+ HTTPWORKER_THREAD_INFO* threadInfo = (HTTPWORKER_THREAD_INFO*)data;
+
+ int responseStatus;
+ unsigned char* responsePayload = NULL;
+ size_t responsePayloadSize;
+
+ result = IoTHubClientCore_LL_GenericMethodInvoke(threadInfo->iotHubClientHandle->IoTHubClientLLHandle,
+ threadInfo->invokeMethodSavedData.deviceId,
+ threadInfo->invokeMethodSavedData.moduleId,
+ threadInfo->invokeMethodSavedData.methodName,
+ threadInfo->invokeMethodSavedData.methodPayload,
+ threadInfo->invokeMethodSavedData.timeout,
+ &responseStatus,
+ &responsePayload,
+ &responsePayloadSize);
+
+ if (threadInfo->invokeMethodSavedData.methodInvokeCallback != NULL)
+ {
+ threadInfo->invokeMethodSavedData.methodInvokeCallback(result, responseStatus, responsePayload, responsePayloadSize, threadInfo->context);
+ }
+
+ if (responsePayload != NULL)
+ {
+ free(responsePayload);
+ }
+
+ (void)markThreadReadyToBeGarbageCollected(threadInfo);
+ return result;
+}
+
+
+IOTHUB_CLIENT_RESULT IoTHubClientCore_GenericMethodInvoke(IOTHUB_CLIENT_CORE_HANDLE iotHubClientHandle, const char* deviceId, const char* moduleId, const char* methodName, const char* methodPayload, unsigned int timeout, IOTHUB_METHOD_INVOKE_CALLBACK methodInvokeCallback, void* context)
+{
+ IOTHUB_CLIENT_RESULT result;
+ HTTPWORKER_THREAD_INFO *threadInfo;
+
+ if ((iotHubClientHandle == NULL) || (deviceId == NULL) || (methodName == NULL) || (methodPayload == NULL))
+ {
+ LogError("Invalid argument (iotHubClientHandle=%p, deviceId=%p, methodName=%p, methodPayload=%p)", iotHubClientHandle, deviceId, methodName, methodPayload);
+ result = IOTHUB_CLIENT_INVALID_ARG;
+ }
+ else if ((threadInfo = allocateMethodInvoke(iotHubClientHandle, deviceId, moduleId, methodName, methodPayload, timeout, methodInvokeCallback, context)) == NULL)
+ {
+ LogError("failed allocating method invoke thread info");
+ result = IOTHUB_CLIENT_ERROR;
+ }
+ else if ((result = startHttpWorkerThread(iotHubClientHandle, threadInfo, uploadMethodInvoke_thread)) != IOTHUB_CLIENT_OK)
+ {
+ LogError("unable to start method invoke thread");
+ freeHttpWorkerThreadInfo(threadInfo);
+ }
+ else
+ {
+ result = IOTHUB_CLIENT_OK;
+ }
return result;
}
#endif /* USE_EDGE_MODULES */
+
--- a/iothub_client_core.h Thu Jul 12 18:09:13 2018 -0700
+++ b/iothub_client_core.h Tue Sep 11 11:13:11 2018 -0700
@@ -2,14 +2,14 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
/** @file iothub_client_core.h
-* @brief Extends the IoTHubCLient_LL module with additional features.
+* @brief Extends the IoTHubClientCore_LL module with additional features.
*
-* @details IoTHubClient is a module that extends the IoTHubCLient_LL
-* module with 2 features:
-* - scheduling the work for the IoTHubCLient from a
-* thread, so that the user does not need to create their
-* own thread
-* - thread-safe APIs
+* @details IoTHubClientCore is a module that extends the IoTHubClientCore_LL
+* module with 2 features:
+* - scheduling the work for the IoTHubCLient from a
+* thread, so that the user does not need to create their
+* own thread
+* - thread-safe APIs
*/
#ifndef IOTHUB_CLIENT_CORE_H
@@ -60,7 +60,7 @@
#ifdef USE_EDGE_MODULES
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_CORE_HANDLE, IoTHubClientCore_CreateFromEnvironment, IOTHUB_CLIENT_TRANSPORT_PROVIDER, protocol);
- MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClientCore_GenericMethodInvoke, IOTHUB_CLIENT_CORE_HANDLE, iotHubClientHandle, const char*, deviceId, const char*, moduleId, const char*, methodName, const char*, methodPayload, unsigned int, timeout, int*, responseStatus, unsigned char**, responsePayload, size_t*, responsePayloadSize);
+ MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClientCore_GenericMethodInvoke, IOTHUB_CLIENT_CORE_HANDLE, iotHubClientHandle, const char*, deviceId, const char*, moduleId, const char*, methodName, const char*, methodPayload, unsigned int, timeout, IOTHUB_METHOD_INVOKE_CALLBACK, methodInvokeCallback, void*, context);
#endif /* USE_EDGE_MODULES */
#ifdef __cplusplus
--- a/iothub_client_core_common.h Thu Jul 12 18:09:13 2018 -0700
+++ b/iothub_client_core_common.h Tue Sep 11 11:13:11 2018 -0700
@@ -36,6 +36,8 @@
DEFINE_ENUM(IOTHUB_CLIENT_RESULT, IOTHUB_CLIENT_RESULT_VALUES);
+ typedef void(*IOTHUB_METHOD_INVOKE_CALLBACK)(IOTHUB_CLIENT_RESULT result, int responseStatus, unsigned char* responsePayload, size_t responsePayloadSize, void* context);
+
#define IOTHUB_CLIENT_RETRY_POLICY_VALUES \
IOTHUB_CLIENT_RETRY_NONE, \
IOTHUB_CLIENT_RETRY_IMMEDIATE, \
@@ -46,8 +48,8 @@
IOTHUB_CLIENT_RETRY_RANDOM
/** @brief Enumeration passed in by the IoT Hub when the event confirmation
- * callback is invoked to indicate status of the event processing in
- * the hub.
+ * callback is invoked to indicate status of the event processing in
+ * the hub.
*/
DEFINE_ENUM(IOTHUB_CLIENT_RETRY_POLICY, IOTHUB_CLIENT_RETRY_POLICY_VALUES);
@@ -59,7 +61,7 @@
IOTHUB_CLIENT_SEND_STATUS_BUSY
/** @brief Enumeration returned by the ::IoTHubClient_LL_GetSendStatus
- * API to indicate the current sending status of the IoT Hub client.
+ * API to indicate the current sending status of the IoT Hub client.
*/
DEFINE_ENUM(IOTHUB_CLIENT_STATUS, IOTHUB_CLIENT_STATUS_VALUES);
@@ -83,7 +85,7 @@
IOTHUBMESSAGE_ABANDONED
/** @brief Enumeration returned by the callback which is invoked whenever the
- * IoT Hub sends a message to the device.
+ * IoT Hub sends a message to the device.
*/
DEFINE_ENUM(IOTHUBMESSAGE_DISPOSITION_RESULT, IOTHUBMESSAGE_DISPOSITION_RESULT_VALUES);
@@ -103,8 +105,8 @@
IOTHUB_CLIENT_CONFIRMATION_ERROR \
/** @brief Enumeration passed in by the IoT Hub when the event confirmation
- * callback is invoked to indicate status of the event processing in
- * the hub.
+ * callback is invoked to indicate status of the event processing in
+ * the hub.
*/
DEFINE_ENUM(IOTHUB_CLIENT_CONFIRMATION_RESULT, IOTHUB_CLIENT_CONFIRMATION_RESULT_VALUES);
@@ -114,8 +116,8 @@
/** @brief Enumeration passed in by the IoT Hub when the connection status
- * callback is invoked to indicate status of the connection in
- * the hub.
+ * callback is invoked to indicate status of the connection in
+ * the hub.
*/
DEFINE_ENUM(IOTHUB_CLIENT_CONNECTION_STATUS, IOTHUB_CLIENT_CONNECTION_STATUS_VALUES);
@@ -129,8 +131,8 @@
IOTHUB_CLIENT_CONNECTION_OK \
/** @brief Enumeration passed in by the IoT Hub when the connection status
- * callback is invoked to indicate status of the connection in
- * the hub.
+ * callback is invoked to indicate status of the connection in
+ * the hub.
*/
DEFINE_ENUM(IOTHUB_CLIENT_CONNECTION_STATUS_REASON, IOTHUB_CLIENT_CONNECTION_STATUS_REASON_VALUES);
@@ -155,7 +157,6 @@
typedef int(*IOTHUB_CLIENT_DEVICE_METHOD_CALLBACK_ASYNC)(const char* method_name, const unsigned char* payload, size_t size, unsigned char** response, size_t* response_size, void* userContextCallback);
typedef int(*IOTHUB_CLIENT_INBOUND_DEVICE_METHOD_CALLBACK)(const char* method_name, const unsigned char* payload, size_t size, METHOD_HANDLE method_id, void* userContextCallback);
-#ifndef DONT_USE_UPLOADTOBLOB
#define IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_RESULT_VALUES \
IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_OK, \
@@ -173,47 +174,46 @@
* It should return IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_OK otherwise.
* If a NULL is provided for parameter "data" and/or zero is provided for "size", the user indicates to the client that the complete file has been uploaded.
* In such case this callback will be invoked only once more to indicate the status of the final block upload.
- * If result is not FILE_UPLOAD_OK, the download is cancelled and this callback stops being invoked.
- * When this callback is called for the last time, no data or size is expected, so data and size are set to NULL
+ * If result is not FILE_UPLOAD_OK, the upload is cancelled and this callback stops being invoked.
+ * When this callback is called for the last time, no data or size is expected, so data and size are NULL
*/
typedef void(*IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK)(IOTHUB_CLIENT_FILE_UPLOAD_RESULT result, unsigned char const ** data, size_t* size, void* context);
typedef IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_RESULT(*IOTHUB_CLIENT_FILE_UPLOAD_GET_DATA_CALLBACK_EX)(IOTHUB_CLIENT_FILE_UPLOAD_RESULT result, unsigned char const ** data, size_t* size, void* context);
-#endif /* DONT_USE_UPLOADTOBLOB */
- /** @brief This struct captures IoTHub client configuration. */
+ /** @brief This struct captures IoTHub client configuration. */
typedef struct IOTHUB_CLIENT_CONFIG_TAG
{
/** @brief A function pointer that is passed into the @c IoTHubClientCreate.
- * A function definition for AMQP is defined in the include @c iothubtransportamqp.h.
+ * A function definition for AMQP is defined in the include @c iothubtransportamqp.h.
* A function definition for HTTP is defined in the include @c iothubtransporthttp.h
* A function definition for MQTT is defined in the include @c iothubtransportmqtt.h */
IOTHUB_CLIENT_TRANSPORT_PROVIDER protocol;
- /** @brief A string that identifies the device. */
+ /** @brief A string that identifies the device. */
const char* deviceId;
- /** @brief The device key used to authenticate the device.
+ /** @brief The device key used to authenticate the device.
If neither deviceSasToken nor deviceKey is present then the authentication is assumed x509.*/
const char* deviceKey;
- /** @brief The device SAS Token used to authenticate the device in place of device key.
+ /** @brief The device SAS Token used to authenticate the device in place of device key.
If neither deviceSasToken nor deviceKey is present then the authentication is assumed x509.*/
const char* deviceSasToken;
- /** @brief The IoT Hub name to which the device is connecting. */
+ /** @brief The IoT Hub name to which the device is connecting. */
const char* iotHubName;
- /** @brief IoT Hub suffix goes here, e.g., private.azure-devices-int.net. */
+ /** @brief IoT Hub suffix goes here, e.g., private.azure-devices-int.net. */
const char* iotHubSuffix;
const char* protocolGatewayHostName;
} IOTHUB_CLIENT_CONFIG;
- /** @brief This struct captures IoTHub client device configuration. */
+ /** @brief This struct captures IoTHub client device configuration. */
typedef struct IOTHUB_CLIENT_DEVICE_CONFIG_TAG
{
/** @brief A function pointer that is passed into the @c IoTHubClientCreate.
- * A function definition for AMQP is defined in the include @c iothubtransportamqp.h.
+ * A function definition for AMQP is defined in the include @c iothubtransportamqp.h.
* A function definition for HTTP is defined in the include @c iothubtransporthttp.h
* A function definition for MQTT is defined in the include @c iothubtransportmqtt.h */
IOTHUB_CLIENT_TRANSPORT_PROVIDER protocol;
@@ -221,14 +221,14 @@
/** @brief a transport handle implementing the protocol */
void * transportHandle;
- /** @brief A string that identifies the device. */
+ /** @brief A string that identifies the device. */
const char* deviceId;
- /** @brief The device key used to authenticate the device.
+ /** @brief The device key used to authenticate the device.
x509 authentication is is not supported for multiplexed connections*/
const char* deviceKey;
- /** @brief The device SAS Token used to authenticate the device in place of device key.
+ /** @brief The device SAS Token used to authenticate the device in place of device key.
x509 authentication is is not supported for multiplexed connections.*/
const char* deviceSasToken;
} IOTHUB_CLIENT_DEVICE_CONFIG;
--- a/iothub_client_core_ll.c Thu Jul 12 18:09:13 2018 -0700
+++ b/iothub_client_core_ll.c Tue Sep 11 11:13:11 2018 -0700
@@ -12,7 +12,7 @@
#include "azure_c_shared_utility/tickcounter.h"
#include "azure_c_shared_utility/constbuffer.h"
#include "azure_c_shared_utility/platform.h"
-#include "azure_c_shared_utility/singlylinkedlist.h"
+#include "azure_c_shared_utility/singlylinkedlist.h"
#include "azure_c_shared_utility/shared_util_options.h"
#include "azure_c_shared_utility/agenttime.h"
@@ -144,8 +144,8 @@
static const char* ENVIRONMENT_VAR_EDGEMODULEID = "IOTEDGE_MODULEID";
static const char* ENVIRONMENT_VAR_EDGEHUBHOSTNAME = "IOTEDGE_IOTHUBHOSTNAME";
static const char* ENVIRONMENT_VAR_EDGEGATEWAYHOST = "IOTEDGE_GATEWAYHOSTNAME";
+static const char* SAS_TOKEN_AUTH = "sasToken";
-static const char* SAS_TOKEN_AUTH = "sasToken";
typedef struct EDGE_ENVIRONMENT_VARIABLES_TAG
{
@@ -286,8 +286,8 @@
/* There is no way to currently distinguish a regular module from a edge module, so this handle is created regardless of if appropriate.
However, as a gateway hostname is required in order to create an Edge Handle, we need to at least make sure that exists
in order to prevent errors.
-
- The end result is that all edge modules will have an EdgeHandle, but only some non-edge modules will have it.
+
+ The end result is that all edge modules will have an EdgeHandle, but only some non-edge modules will have it.
Regardless, non-edge modules will never be able to use the handle.
*/
if (config->protocolGatewayHostName != NULL)
@@ -534,7 +534,7 @@
else
{
memset(IoTHubName, 0, whereIsDot - hostname + 1);
- (void)strncpy(IoTHubName, hostname, whereIsDot - hostname);
+ (void)memcpy(IoTHubName, hostname, whereIsDot - hostname);
(void)strcpy(IoTHubSuffix, whereIsDot+1);
actual_config.deviceId = device_config->deviceId;
@@ -678,7 +678,7 @@
}
static uint32_t get_next_item_id(IOTHUB_CLIENT_CORE_LL_HANDLE_DATA* handleData)
-{
+{
if (handleData->data_msg_id+1 >= UINT32_MAX)
{
handleData->data_msg_id = 1;
@@ -1143,7 +1143,7 @@
{
IOTHUB_CLIENT_CORE_LL_HANDLE result;
/*Codes_SRS_IOTHUBCLIENT_LL_02_001: [IoTHubClientCore_LL_Create shall return NULL if config parameter is NULL or protocol field is NULL.]*/
- if(
+ if(
(config == NULL) ||
(config->protocol == NULL)
)
@@ -1506,7 +1506,7 @@
}
else
{
- /*Codes_SRS_IOTHUBCLIENT_LL_10_023: [If parameter messageCallback is NULL then IoTHubClientCore_LL_SetMessageCallback_Ex shall call the underlying layer's _Unsubscribe function and return IOTHUB_CLIENT_OK.] */
+ /*Codes_SRS_IOTHUBCLIENT_LL_10_023: [If parameter messageCallback is NULL then IoTHubClientCore_LL_SetMessageCallback_Ex shall call the underlying layer's _Unsubscribe function and return IOTHUB_CLIENT_OK.] */
handleData->IoTHubTransport_Unsubscribe(handleData->deviceHandle);
handleData->messageCallback.type = CALLBACK_TYPE_NONE;
handleData->messageCallback.callbackSync = NULL;
@@ -1624,7 +1624,7 @@
/*Codes_SRS_IOTHUBCLIENT_LL_07_010: [ If 'IoTHubTransport_ProcessItem' returns IOTHUB_PROCESS_CONTINUE or IOTHUB_PROCESS_NOT_CONNECTED IoTHubClientCore_LL_DoWork shall continue on to call the underlaying layer's _DoWork function. ]*/
break;
}
- else
+ else
{
DList_RemoveEntryList(client_item);
if (process_results == IOTHUB_PROCESS_OK)
@@ -1813,7 +1813,7 @@
bool result;
/* Codes_SRS_IOTHUBCLIENT_LL_09_004: [IoTHubClient_LL_GetLastMessageReceiveTime shall return lastMessageReceiveTime in localtime] */
handleData->lastMessageReceiveTime = get_time(NULL);
-
+
switch (handleData->messageCallback.type)
{
case CALLBACK_TYPE_NONE:
@@ -1883,7 +1883,7 @@
static bool is_event_equal(IOTHUB_EVENT_CALLBACK *event_callback, const char *input_name)
{
bool result;
-
+
if (event_callback != NULL)
{
const char* event_input_name = STRING_c_str(event_callback->inputName);
@@ -1939,9 +1939,9 @@
else
{
const char* inputName = IoTHubMessage_GetInputName(messageData->messageHandle);
-
+
LIST_ITEM_HANDLE item_handle = NULL;
-
+
item_handle = singlylinkedlist_find(handleData->event_callbacks, is_event_equal_for_match, (const void*)inputName);
if (item_handle == NULL)
@@ -1977,7 +1977,7 @@
{
// Codes_SRS_IOTHUBCLIENT_LL_31_139: [ `IoTHubClient_LL_MessageCallbackFromInput` shall the callback from the given inputName queue if it has been registered.** ]
IOTHUBMESSAGE_DISPOSITION_RESULT cb_result = event_callback->callbackAsync(messageData->messageHandle, event_callback->userContextCallback);
-
+
// Codes_SRS_IOTHUBCLIENT_LL_31_140: [ `IoTHubClient_LL_MessageCallbackFromInput` shall send the message disposition as returned by the client to the underlying layer and return `true` if an input queue match is found.** ]
if (handleData->IoTHubTransport_SendMessageDisposition(messageData, cb_result) != IOTHUB_CLIENT_OK)
{
@@ -2192,7 +2192,7 @@
result = IOTHUB_CLIENT_OK;
}
}
- else if (strcmp(optionName, OPTION_BLOB_UPLOAD_TIMEOUT_SECS) == 0)
+ else if ((strcmp(optionName, OPTION_BLOB_UPLOAD_TIMEOUT_SECS) == 0) || (strcmp(optionName, OPTION_CURL_VERBOSE) == 0))
{
#ifndef DONT_USE_UPLOADTOBLOB
// This option just gets passed down into IoTHubClientCore_LL_UploadToBlob
@@ -2200,10 +2200,10 @@
result = IoTHubClient_LL_UploadToBlob_SetOption(handleData->uploadToBlobHandle, optionName, value);
if(result != IOTHUB_CLIENT_OK)
{
- LogError("unable to IoTHubClientCore_LL_UploadToBlob_SetOption");
+ LogError("unable to IoTHubClientCore_LL_UploadToBlob_SetOption, result=%d", result);
}
#else
- LogError("OPTION_BLOB_TRANSFER_TIMEOUT option being set with DONT_USE_UPLOADTOBLOB compiler switch");
+ LogError("%s option being set with DONT_USE_UPLOADTOBLOB compiler switch", optionName);
result = IOTHUB_CLIENT_ERROR;
#endif /*DONT_USE_UPLOADTOBLOB*/
}
@@ -2211,7 +2211,7 @@
{
// This section is unusual for SetOption calls because it attempts to pass unhandled options
// to two downstream targets (IoTHubTransport_SetOption and IoTHubClientCore_LL_UploadToBlob_SetOption) instead of one.
-
+
/*Codes_SRS_IOTHUBCLIENT_LL_30_011: [ IoTHubClientCore_LL_SetOption shall always pass unhandled options to Transport_SetOption. ]*/
/*Codes_SRS_IOTHUBCLIENT_LL_30_012: [ If Transport_SetOption fails, IoTHubClientCore_LL_SetOption shall return that failure code. ]*/
result = handleData->IoTHubTransport_SetOption(handleData->transportHandle, optionName, value);
@@ -2592,6 +2592,7 @@
}
return result;
}
+#endif // DONT_USE_UPLOADTOBLOB
IOTHUB_CLIENT_RESULT IoTHubClientCore_LL_SendEventToOutputAsync(IOTHUB_CLIENT_CORE_LL_HANDLE iotHubClientHandle, IOTHUB_MESSAGE_HANDLE eventMessageHandle, const char* outputName, IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK eventConfirmationCallback, void* userContextCallback)
{
@@ -2681,7 +2682,7 @@
event_callback->userContextCallback = userContextCallback;
}
- if ((userContextCallbackEx != NULL) &&
+ if ((userContextCallbackEx != NULL) &&
(NULL == (event_callback->userContextCallbackEx = malloc(userContextCallbackExLength))))
{
LogError("Unable to allocate userContextCallback");
@@ -2724,7 +2725,7 @@
{
// Codes_SRS_IOTHUBCLIENT_LL_31_132: [ If `eventHandlerCallback` is NULL, `IoTHubClient_LL_SetInputMessageCallback` shall return `IOTHUB_CLIENT_ERROR` if the `inputName` is not present. ]
LogError("Input name %s was not present", inputName);
- result = IOTHUB_CLIENT_ERROR;
+ result = IOTHUB_CLIENT_ERROR;
}
else
{
@@ -2837,4 +2838,3 @@
/*end*/
-#endif /* DONT_USE_UPLOADTOBLOB */
--- a/iothub_client_core_ll.h Thu Jul 12 18:09:13 2018 -0700 +++ b/iothub_client_core_ll.h Tue Sep 11 11:13:11 2018 -0700 @@ -1,23 +1,23 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -/** @file iothub_client_ll.h -* @brief APIs that allow a user (usually a device) to communicate -* with an Azure IoTHub. +/** @file iothub_client_core_ll.h +* @brief APIs that allow a user (usually a device) to communicate +* with an Azure IoTHub. * -* @details IoTHubClient_LL is a module that allows a user (usually a -* device) to communicate with an Azure IoTHub. It can send events -* and receive messages. At any given moment in time there can only -* be at most 1 message callback function. +* @details IoTHubClientCore_LL is a module that allows a user (usually a +* device) to communicate with an Azure IoTHub. It can send events +* and receive messages. At any given moment in time there can only +* be at most 1 message callback function. * -* This API surface contains a set of APIs that allows the user to -* interact with the lower layer portion of the IoTHubClient. These APIs -* contain @c _LL_ in their name, but retain the same functionality like the -* @c IoTHubClient_... APIs, with one difference. If the @c _LL_ APIs are -* used then the user is responsible for scheduling when the actual work done -* by the IoTHubClient happens (when the data is sent/received on/from the wire). -* This is useful for constrained devices where spinning a separate thread is -* often not desired. +* This API surface contains a set of APIs that allows the user to +* interact with the lower layer portion of the IoTHubClient. These APIs +* contain @c _LL_ in their name, but retain the same functionality like the +* @c IoTHubClient_... APIs, with one difference. If the @c _LL_ APIs are +* used then the user is responsible for scheduling when the actual work done +* by the IoTHubClient happens (when the data is sent/received on/from the wire). +* This is useful for constrained devices where spinning a separate thread is +* often not desired. */ #ifndef IOTHUB_CLIENT_CORE_LL_H
--- a/iothub_client_diagnostic.c Thu Jul 12 18:09:13 2018 -0700
+++ b/iothub_client_diagnostic.c Tue Sep 11 11:13:11 2018 -0700
@@ -141,6 +141,7 @@
LogError("Failed getting current time");
free(result->diagnosticId);
free(result);
+ free(timeBuffer);
result = NULL;
}
else
--- a/iothub_client_ll.h Thu Jul 12 18:09:13 2018 -0700
+++ b/iothub_client_ll.h Tue Sep 11 11:13:11 2018 -0700
@@ -2,22 +2,22 @@
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
/** @file iothub_client_ll.h
-* @brief APIs that allow a user (usually a device) to communicate
-* with an Azure IoTHub.
+* @brief APIs that allow a user (usually a device) to communicate
+* with an Azure IoTHub.
*
-* @details IoTHubClient_LL is a module that allows a user (usually a
-* device) to communicate with an Azure IoTHub. It can send events
-* and receive messages. At any given moment in time there can only
-* be at most 1 message callback function.
+* @details IoTHubClient_LL is a module that allows a user (usually a
+* device) to communicate with an Azure IoTHub. It can send events
+* and receive messages. At any given moment in time there can only
+* be at most 1 message callback function.
*
-* This API surface contains a set of APIs that allows the user to
-* interact with the lower layer portion of the IoTHubClient. These APIs
-* contain @c _LL_ in their name, but retain the same functionality like the
-* @c IoTHubClient_... APIs, with one difference. If the @c _LL_ APIs are
-* used then the user is responsible for scheduling when the actual work done
-* by the IoTHubClient happens (when the data is sent/received on/from the wire).
-* This is useful for constrained devices where spinning a separate thread is
-* often not desired.
+* This API surface contains a set of APIs that allows the user to
+* interact with the lower layer portion of the IoTHubClient. These APIs
+* contain @c _LL_ in their name, but retain the same functionality like the
+* @c IoTHubClient_... APIs, with one difference. If the @c _LL_ APIs are
+* used then the user is responsible for scheduling when the actual work done
+* by the IoTHubClient happens (when the data is sent/received on/from the wire).
+* This is useful for constrained devices where spinning a separate thread is
+* often not desired.
*/
#ifndef IOTHUB_CLIENT_LL_H
@@ -28,247 +28,247 @@
#include "azure_c_shared_utility/umock_c_prod.h"
+#include "iothub_transport_ll.h"
+#include "iothub_client_core_ll.h"
+
#ifdef __cplusplus
extern "C"
{
#endif
-#include "iothub_transport_ll.h"
-#include "iothub_client_core_ll.h"
-
typedef struct IOTHUB_CLIENT_CORE_LL_HANDLE_DATA_TAG* IOTHUB_CLIENT_LL_HANDLE;
/**
- * @brief Creates a IoT Hub client for communication with an existing
- * IoT Hub using the specified connection string parameter.
+ * @brief Creates a IoT Hub client for communication with an existing
+ * IoT Hub using the specified connection string parameter.
*
- * @param connectionString Pointer to a character string
- * @param protocol Function pointer for protocol implementation
+ * @param connectionString Pointer to a character string
+ * @param protocol Function pointer for protocol implementation
*
- * Sample connection string:
- * <blockquote>
- * <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>
- * </blockquote>
+ * Sample connection string:
+ * <blockquote>
+ * <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>
+ * </blockquote>
*
- * @return A non-NULL @c IOTHUB_CLIENT_LL_HANDLE value that is used when
- * invoking other functions for IoT Hub client and @c NULL on failure.
+ * @return A non-NULL @c IOTHUB_CLIENT_LL_HANDLE value that is used when
+ * invoking other functions for IoT Hub client and @c NULL on failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_LL_HANDLE, IoTHubClient_LL_CreateFromConnectionString, const char*, connectionString, IOTHUB_CLIENT_TRANSPORT_PROVIDER, protocol);
/**
- * @brief Creates a IoT Hub client for communication with an existing IoT
- * Hub using the specified parameters.
+ * @brief Creates a IoT Hub client for communication with an existing IoT
+ * Hub using the specified parameters.
*
- * @param config Pointer to an @c IOTHUB_CLIENT_CONFIG structure
+ * @param config Pointer to an @c IOTHUB_CLIENT_CONFIG structure
*
- * The API does not allow sharing of a connection across multiple
- * devices. This is a blocking call.
+ * The API does not allow sharing of a connection across multiple
+ * devices. This is a blocking call.
*
- * @return A non-NULL @c IOTHUB_CLIENT_LL_HANDLE value that is used when
- * invoking other functions for IoT Hub client and @c NULL on failure.
+ * @return A non-NULL @c IOTHUB_CLIENT_LL_HANDLE value that is used when
+ * invoking other functions for IoT Hub client and @c NULL on failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_LL_HANDLE, IoTHubClient_LL_Create, const IOTHUB_CLIENT_CONFIG*, config);
/**
- * @brief Creates a IoT Hub client for communication with an existing IoT
- * Hub using an existing transport.
+ * @brief Creates a IoT Hub client for communication with an existing IoT
+ * Hub using an existing transport.
*
- * @param config Pointer to an @c IOTHUB_CLIENT_DEVICE_CONFIG structure
+ * @param config Pointer to an @c IOTHUB_CLIENT_DEVICE_CONFIG structure
*
- * The API *allows* sharing of a connection across multiple
- * devices. This is a blocking call.
+ * The API *allows* sharing of a connection across multiple
+ * devices. This is a blocking call.
*
- * @return A non-NULL @c IOTHUB_CLIENT_LL_HANDLE value that is used when
- * invoking other functions for IoT Hub client and @c NULL on failure.
+ * @return A non-NULL @c IOTHUB_CLIENT_LL_HANDLE value that is used when
+ * invoking other functions for IoT Hub client and @c NULL on failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_LL_HANDLE, IoTHubClient_LL_CreateWithTransport, const IOTHUB_CLIENT_DEVICE_CONFIG*, config);
/**
- * @brief Creates a IoT Hub client for communication with an existing IoT
- * Hub using the device auth module.
+ * @brief Creates a IoT Hub client for communication with an existing IoT
+ * Hub using the device auth module.
*
- * @param iothub_uri Pointer to an ioThub hostname received in the registration process
- * @param device_id Pointer to the device Id of the device
- * @param device_auth_handle a device auth handle used to generate the connection string
- * @param protocol Function pointer for protocol implementation
+ * @param iothub_uri Pointer to an ioThub hostname received in the registration process
+ * @param device_id Pointer to the device Id of the device
+ * @param device_auth_handle a device auth handle used to generate the connection string
+ * @param protocol Function pointer for protocol implementation
*
- * @return A non-NULL @c IOTHUB_CLIENT_LL_HANDLE value that is used when
- * invoking other functions for IoT Hub client and @c NULL on failure.
+ * @return A non-NULL @c IOTHUB_CLIENT_LL_HANDLE value that is used when
+ * invoking other functions for IoT Hub client and @c NULL on failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_LL_HANDLE, IoTHubClient_LL_CreateFromDeviceAuth, const char*, iothub_uri, const char*, device_id, IOTHUB_CLIENT_TRANSPORT_PROVIDER, protocol);
/**
- * @brief Disposes of resources allocated by the IoT Hub client. This is a
- * blocking call.
+ * @brief Disposes of resources allocated by the IoT Hub client. This is a
+ * blocking call.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param iotHubClientHandle The handle created by a call to the create function.
*/
MOCKABLE_FUNCTION(, void, IoTHubClient_LL_Destroy, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle);
/**
- * @brief Asynchronous call to send the message specified by @p eventMessageHandle.
+ * @brief Asynchronous call to send the message specified by @p eventMessageHandle.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param eventMessageHandle The handle to an IoT Hub message.
- * @param eventConfirmationCallback The callback specified by the device for receiving
- * confirmation of the delivery of the IoT Hub message.
- * This callback can be expected to invoke the
- * ::IoTHubClient_LL_SendEventAsync function for the
- * same message in an attempt to retry sending a failing
- * message. The user can specify a @c NULL value here to
- * indicate that no callback is required.
- * @param userContextCallback User specified context that will be provided to the
- * callback. This can be @c NULL.
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param eventMessageHandle The handle to an IoT Hub message.
+ * @param eventConfirmationCallback The callback specified by the device for receiving
+ * confirmation of the delivery of the IoT Hub message.
+ * This callback can be expected to invoke the
+ * ::IoTHubClient_LL_SendEventAsync function for the
+ * same message in an attempt to retry sending a failing
+ * message. The user can specify a @c NULL value here to
+ * indicate that no callback is required.
+ * @param userContextCallback User specified context that will be provided to the
+ * callback. This can be @c NULL.
*
- * @b NOTE: The application behavior is undefined if the user calls
- * the ::IoTHubClient_LL_Destroy function from within any callback.
+ * @b NOTE: The application behavior is undefined if the user calls
+ * the ::IoTHubClient_LL_Destroy function from within any callback.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_SendEventAsync, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_MESSAGE_HANDLE, eventMessageHandle, IOTHUB_CLIENT_EVENT_CONFIRMATION_CALLBACK, eventConfirmationCallback, void*, userContextCallback);
/**
- * @brief This function returns the current sending status for IoTHubClient.
+ * @brief This function returns the current sending status for IoTHubClient.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param iotHubClientStatus The sending state is populated at the address pointed
- * at by this parameter. The value will be set to
- * @c IOTHUBCLIENT_SENDSTATUS_IDLE if there is currently
- * no item to be sent and @c IOTHUBCLIENT_SENDSTATUS_BUSY
- * if there are.
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param iotHubClientStatus The sending state is populated at the address pointed
+ * at by this parameter. The value will be set to
+ * @c IOTHUBCLIENT_SENDSTATUS_IDLE if there is currently
+ * no item to be sent and @c IOTHUBCLIENT_SENDSTATUS_BUSY
+ * if there are.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_GetSendStatus, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_STATUS*, iotHubClientStatus);
/**
- * @brief Sets up the message callback to be invoked when IoT Hub issues a
- * message to the device. This is a blocking call.
+ * @brief Sets up the message callback to be invoked when IoT Hub issues a
+ * message to the device. This is a blocking call.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param messageCallback The callback specified by the device for receiving
- * messages from IoT Hub.
- * @param userContextCallback User specified context that will be provided to the
- * callback. This can be @c NULL.
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param messageCallback The callback specified by the device for receiving
+ * messages from IoT Hub.
+ * @param userContextCallback User specified context that will be provided to the
+ * callback. This can be @c NULL.
*
- * @b NOTE: The application behavior is undefined if the user calls
- * the ::IoTHubClient_LL_Destroy function from within any callback.
+ * @b NOTE: The application behavior is undefined if the user calls
+ * the ::IoTHubClient_LL_Destroy function from within any callback.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_SetMessageCallback, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC, messageCallback, void*, userContextCallback);
/**
- * @brief Sets up the connection status callback to be invoked representing the status of
+ * @brief Sets up the connection status callback to be invoked representing the status of
* the connection to IOT Hub. This is a blocking call.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param connectionStatusCallback The callback specified by the device for receiving
- * updates about the status of the connection to IoT Hub.
- * @param userContextCallback User specified context that will be provided to the
- * callback. This can be @c NULL.
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param connectionStatusCallback The callback specified by the device for receiving
+ * updates about the status of the connection to IoT Hub.
+ * @param userContextCallback User specified context that will be provided to the
+ * callback. This can be @c NULL.
*
- * @b NOTE: The application behavior is undefined if the user calls
- * the ::IoTHubClient_LL_Destroy function from within any callback.
+ * @b NOTE: The application behavior is undefined if the user calls
+ * the ::IoTHubClient_LL_Destroy function from within any callback.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_SetConnectionStatusCallback, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_CONNECTION_STATUS_CALLBACK, connectionStatusCallback, void*, userContextCallback);
/**
- * @brief Sets up the connection status callback to be invoked representing the status of
+ * @brief Sets up the connection status callback to be invoked representing the status of
* the connection to IOT Hub. This is a blocking call.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param retryPolicy The policy to use to reconnect to IoT Hub when a
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param retryPolicy The policy to use to reconnect to IoT Hub when a
* connection drops.
- * @param retryTimeoutLimitInSeconds Maximum amount of time(seconds) to attempt reconnection when a
+ * @param retryTimeoutLimitInSeconds Maximum amount of time(seconds) to attempt reconnection when a
* connection drops to IOT Hub.
*
- * @b NOTE: The application behavior is undefined if the user calls
- * the ::IoTHubClient_LL_Destroy function from within any callback.
+ * @b NOTE: The application behavior is undefined if the user calls
+ * the ::IoTHubClient_LL_Destroy function from within any callback.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_SetRetryPolicy, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_RETRY_POLICY, retryPolicy, size_t, retryTimeoutLimitInSeconds);
/**
- * @brief Sets up the connection status callback to be invoked representing the status of
+ * @brief Sets up the connection status callback to be invoked representing the status of
* the connection to IOT Hub. This is a blocking call.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param retryPolicy Out parameter containing the policy to use to reconnect to IoT Hub.
- * @param retryTimeoutLimitInSeconds Out parameter containing maximum amount of time in seconds to attempt reconnection
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param retryPolicy Out parameter containing the policy to use to reconnect to IoT Hub.
+ * @param retryTimeoutLimitInSeconds Out parameter containing maximum amount of time in seconds to attempt reconnection
to IOT Hub.
*
- * @b NOTE: The application behavior is undefined if the user calls
- * the ::IoTHubClient_LL_Destroy function from within any callback.
+ * @b NOTE: The application behavior is undefined if the user calls
+ * the ::IoTHubClient_LL_Destroy function from within any callback.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_GetRetryPolicy, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_RETRY_POLICY*, retryPolicy, size_t*, retryTimeoutLimitInSeconds);
/**
- * @brief This function returns in the out parameter @p lastMessageReceiveTime
- * what was the value of the @c time function when the last message was
- * received at the client.
+ * @brief This function returns in the out parameter @p lastMessageReceiveTime
+ * what was the value of the @c time function when the last message was
+ * received at the client.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param lastMessageReceiveTime Out parameter containing the value of @c time function
- * when the last message was received.
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param lastMessageReceiveTime Out parameter containing the value of @c time function
+ * when the last message was received.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_GetLastMessageReceiveTime, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, time_t*, lastMessageReceiveTime);
/**
- * @brief This function is meant to be called by the user when work
- * (sending/receiving) can be done by the IoTHubClient.
+ * @brief This function is meant to be called by the user when work
+ * (sending/receiving) can be done by the IoTHubClient.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param iotHubClientHandle The handle created by a call to the create function.
*
- * All IoTHubClient interactions (in regards to network traffic
- * and/or user level callbacks) are the effect of calling this
- * function and they take place synchronously inside _DoWork.
+ * All IoTHubClient interactions (in regards to network traffic
+ * and/or user level callbacks) are the effect of calling this
+ * function and they take place synchronously inside _DoWork.
*/
MOCKABLE_FUNCTION(, void, IoTHubClient_LL_DoWork, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle);
/**
- * @brief This API sets a runtime option identified by parameter @p optionName
- * to a value pointed to by @p value. @p optionName and the data type
- * @p value is pointing to are specific for every option.
+ * @brief This API sets a runtime option identified by parameter @p optionName
+ * to a value pointed to by @p value. @p optionName and the data type
+ * @p value is pointing to are specific for every option.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param optionName Name of the option.
- * @param value The value.
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param optionName Name of the option.
+ * @param value The value.
*
- * The options that can be set via this API are:
- * - @b timeout - the maximum time in milliseconds a communication is
- * allowed to use. @p value is a pointer to an @c unsigned @c int with
- * the timeout value in milliseconds. This is only supported for the HTTP
- * protocol as of now. When the HTTP protocol uses CURL, the meaning of
- * the parameter is <em>total request time</em>. When the HTTP protocol uses
- * winhttp, the meaning is the same as the @c dwSendTimeout and
- * @c dwReceiveTimeout parameters of the
- * <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa384116(v=vs.85).aspx">
- * WinHttpSetTimeouts</a> API.
- * - @b CURLOPT_LOW_SPEED_LIMIT - only available for HTTP protocol and only
- * when CURL is used. It has the same meaning as CURL's option with the same
- * name. @p value is pointer to a long.
- * - @b CURLOPT_LOW_SPEED_TIME - only available for HTTP protocol and only
- * when CURL is used. It has the same meaning as CURL's option with the same
- * name. @p value is pointer to a long.
- * - @b CURLOPT_FORBID_REUSE - only available for HTTP protocol and only
- * when CURL is used. It has the same meaning as CURL's option with the same
- * name. @p value is pointer to a long.
- * - @b CURLOPT_FRESH_CONNECT - only available for HTTP protocol and only
- * when CURL is used. It has the same meaning as CURL's option with the same
- * name. @p value is pointer to a long.
- * - @b CURLOPT_VERBOSE - only available for HTTP protocol and only
- * when CURL is used. It has the same meaning as CURL's option with the same
- * name. @p value is pointer to a long.
+ * The options that can be set via this API are:
+ * - @b timeout - the maximum time in milliseconds a communication is
+ * allowed to use. @p value is a pointer to an @c unsigned @c int with
+ * the timeout value in milliseconds. This is only supported for the HTTP
+ * protocol as of now. When the HTTP protocol uses CURL, the meaning of
+ * the parameter is <em>total request time</em>. When the HTTP protocol uses
+ * winhttp, the meaning is the same as the @c dwSendTimeout and
+ * @c dwReceiveTimeout parameters of the
+ * <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa384116(v=vs.85).aspx">
+ * WinHttpSetTimeouts</a> API.
+ * - @b CURLOPT_LOW_SPEED_LIMIT - only available for HTTP protocol and only
+ * when CURL is used. It has the same meaning as CURL's option with the same
+ * name. @p value is pointer to a long.
+ * - @b CURLOPT_LOW_SPEED_TIME - only available for HTTP protocol and only
+ * when CURL is used. It has the same meaning as CURL's option with the same
+ * name. @p value is pointer to a long.
+ * - @b CURLOPT_FORBID_REUSE - only available for HTTP protocol and only
+ * when CURL is used. It has the same meaning as CURL's option with the same
+ * name. @p value is pointer to a long.
+ * - @b CURLOPT_FRESH_CONNECT - only available for HTTP protocol and only
+ * when CURL is used. It has the same meaning as CURL's option with the same
+ * name. @p value is pointer to a long.
+ * - @b CURLOPT_VERBOSE - only available for HTTP protocol and only
+ * when CURL is used. It has the same meaning as CURL's option with the same
+ * name. @p value is pointer to a long.
* - @b keepalive - available for MQTT protocol. Integer value that sets the
* interval in seconds when pings are sent to the server.
* - @b logtrace - available for MQTT protocol. Boolean value that turns on and
@@ -276,95 +276,95 @@
* - @b sas_token_lifetime - available for MQTT & AMQP protocol. size_t value that that determines the
* sas token timeout length.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_SetOption, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, const char*, optionName, const void*, value);
/**
- * @brief This API specifies a call back to be used when the device receives a desired state update.
+ * @brief This API specifies a call back to be used when the device receives a desired state update.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param deviceTwinCallback The callback specified by the device client to be used for updating
- * the desired state. The callback will be called in response to patch
- * request send by the IoTHub services. The payload will be passed to the
- * callback, along with two version numbers:
- * - Desired:
- * - LastSeenReported:
- * @param userContextCallback User specified context that will be provided to the
- * callback. This can be @c NULL.
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param deviceTwinCallback The callback specified by the device client to be used for updating
+ * the desired state. The callback will be called in response to patch
+ * request send by the IoTHub services. The payload will be passed to the
+ * callback, along with two version numbers:
+ * - Desired:
+ * - LastSeenReported:
+ * @param userContextCallback User specified context that will be provided to the
+ * callback. This can be @c NULL.
*
- * @b NOTE: The application behavior is undefined if the user calls
- * the ::IoTHubClient_LL_Destroy function from within any callback.
+ * @b NOTE: The application behavior is undefined if the user calls
+ * the ::IoTHubClient_LL_Destroy function from within any callback.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_SetDeviceTwinCallback, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_DEVICE_TWIN_CALLBACK, deviceTwinCallback, void*, userContextCallback);
/**
- * @brief This API sneds a report of the device's properties and their current values.
+ * @brief This API sneds a report of the device's properties and their current values.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param reportedState The current device property values to be 'reported' to the IoTHub.
- * @param reportedStateCallback The callback specified by the device client to be called with the
- * result of the transaction.
- * @param userContextCallback User specified context that will be provided to the
- * callback. This can be @c NULL.
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param reportedState The current device property values to be 'reported' to the IoTHub.
+ * @param reportedStateCallback The callback specified by the device client to be called with the
+ * result of the transaction.
+ * @param userContextCallback User specified context that will be provided to the
+ * callback. This can be @c NULL.
*
- * @b NOTE: The application behavior is undefined if the user calls
- * the ::IoTHubClient_LL_Destroy function from within any callback.
+ * @b NOTE: The application behavior is undefined if the user calls
+ * the ::IoTHubClient_LL_Destroy function from within any callback.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_SendReportedState, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, const unsigned char*, reportedState, size_t, size, IOTHUB_CLIENT_REPORTED_STATE_CALLBACK, reportedStateCallback, void*, userContextCallback);
/**
- * @brief This API sets callback for cloud to device method call.
+ * @brief This API sets callback for cloud to device method call.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param deviceMethodCallback The callback which will be called by IoTHub.
- * @param userContextCallback User specified context that will be provided to the
- * callback. This can be @c NULL.
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param deviceMethodCallback The callback which will be called by IoTHub.
+ * @param userContextCallback User specified context that will be provided to the
+ * callback. This can be @c NULL.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_SetDeviceMethodCallback, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_DEVICE_METHOD_CALLBACK_ASYNC, deviceMethodCallback, void*, userContextCallback);
/**
- * @brief This API sets callback for async cloud to device method call.
+ * @brief This API sets callback for async cloud to device method call.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param inboundDeviceMethodCallback The callback which will be called by IoTHub.
- * @param userContextCallback User specified context that will be provided to the
- * callback. This can be @c NULL.
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param inboundDeviceMethodCallback The callback which will be called by IoTHub.
+ * @param userContextCallback User specified context that will be provided to the
+ * callback. This can be @c NULL.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_SetDeviceMethodCallback_Ex, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_INBOUND_DEVICE_METHOD_CALLBACK, inboundDeviceMethodCallback, void*, userContextCallback);
/**
- * @brief This API responses to a asnyc method callback identified the methodId.
+ * @brief This API responses to a asnyc method callback identified the methodId.
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param methodId The methodId of the Device Method callback.
- * @param response The response data for the method callback.
- * @param response_size The size of the response data buffer.
- * @param status_response The status response of the method callback.
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param methodId The methodId of the Device Method callback.
+ * @param response The response data for the method callback.
+ * @param response_size The size of the response data buffer.
+ * @param status_response The status response of the method callback.
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_DeviceMethodResponse, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, METHOD_HANDLE, methodId, const unsigned char*, response, size_t, respSize, int, statusCode);
#ifndef DONT_USE_UPLOADTOBLOB
/**
- * @brief This API uploads to Azure Storage the content pointed to by @p source having the size @p size
+ * @brief This API uploads to Azure Storage the content pointed to by @p source having the size @p size
* under the blob name devicename/@pdestinationFileName
*
- * @param iotHubClientHandle The handle created by a call to the create function.
- * @param destinationFileName name of the file.
- * @param source pointer to the source for file content (can be NULL)
+ * @param iotHubClientHandle The handle created by a call to the create function.
+ * @param destinationFileName name of the file.
+ * @param source pointer to the source for file content (can be NULL)
* @param size the size of the source in memory (if @p source is NULL then size needs to be 0).
*
- * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
+ * @return IOTHUB_CLIENT_OK upon success or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClient_LL_UploadToBlob, IOTHUB_CLIENT_LL_HANDLE, iotHubClientHandle, const char*, destinationFileName, const unsigned char*, source, size_t, size);
--- a/iothub_client_ll_uploadtoblob.c Thu Jul 12 18:09:13 2018 -0700
+++ b/iothub_client_ll_uploadtoblob.c Tue Sep 11 11:13:11 2018 -0700
@@ -57,6 +57,13 @@
const char* x509privatekey;
}UPLOADTOBLOB_X509_CREDENTIALS;
+typedef enum UPOADTOBLOB_CURL_VERBOSITY_TAG
+{
+ UPOADTOBLOB_CURL_VERBOSITY_UNSET,
+ UPOADTOBLOB_CURL_VERBOSITY_ON,
+ UPOADTOBLOB_CURL_VERBOSITY_OFF
+} UPOADTOBLOB_CURL_VERBOSITY;
+
typedef struct IOTHUB_CLIENT_LL_UPLOADTOBLOB_HANDLE_DATA_TAG
{
STRING_HANDLE deviceId; /*needed for file upload*/
@@ -69,7 +76,7 @@
} credentials; /*needed for file upload*/
char* certificates; /*if there are any certificates used*/
HTTP_PROXY_OPTIONS http_proxy_options;
- size_t curl_verbose;
+ UPOADTOBLOB_CURL_VERBOSITY curl_verbosity_level;
size_t blob_upload_timeout_secs;
}IOTHUB_CLIENT_LL_UPLOADTOBLOB_HANDLE_DATA;
@@ -122,7 +129,7 @@
handleData->certificates = NULL;
memset(&(handleData->http_proxy_options), 0, sizeof(HTTP_PROXY_OPTIONS));
- handleData->curl_verbose = 0;
+ handleData->curl_verbosity_level = UPOADTOBLOB_CURL_VERBOSITY_UNSET;
handleData->blob_upload_timeout_secs = 0;
if ((config->deviceSasToken != NULL) && (config->deviceKey == NULL))
@@ -170,7 +177,7 @@
}
}
return (IOTHUB_CLIENT_LL_UPLOADTOBLOB_HANDLE)handleData;
-
+
}
/*returns 0 when correlationId, sasUri contain data*/
@@ -531,7 +538,7 @@
{
/*Codes_SRS_IOTHUBCLIENT_LL_32_008: [ The returned file name shall be URL encoded before passing back to the cloud. ]*/
STRING_HANDLE fileName = URL_EncodeString(json_blobName);
-
+
if (fileName == NULL)
{
/*Codes_SRS_IOTHUBCLIENT_LL_32_009: [ If URL_EncodeString fails then IoTHubClient_LL_UploadMultipleBlocksToBlob(Ex) shall fail and return IOTHUB_CLIENT_ERROR. ]*/
@@ -539,7 +546,7 @@
result = __FAILURE__;
}
- else
+ else
{
if (!(
(STRING_concat(sasUri, json_hostName) == 0) &&
@@ -558,9 +565,9 @@
{
result = 0; /*success in step 1*/
}
-
+
STRING_delete(fileName);
- }
+ }
}
}
}
@@ -859,7 +866,11 @@
}
else
{
- (void)HTTPAPIEX_SetOption(iotHubHttpApiExHandle, OPTION_CURL_VERBOSE, &handleData->curl_verbose);
+ if (handleData->curl_verbosity_level != UPOADTOBLOB_CURL_VERBOSITY_UNSET)
+ {
+ size_t curl_verbose = (handleData->curl_verbosity_level == UPOADTOBLOB_CURL_VERBOSITY_ON);
+ (void)HTTPAPIEX_SetOption(iotHubHttpApiExHandle, OPTION_CURL_VERBOSE, &curl_verbose);
+ }
if (
(handleData->authorizationScheme == X509) &&
@@ -1047,12 +1058,12 @@
}
HTTPAPIEX_Destroy(iotHubHttpApiExHandle);
}
+
+ /*Codes_SRS_IOTHUBCLIENT_LL_99_003: [ If `IoTHubClient_LL_UploadMultipleBlocksToBlob(Ex)` return `IOTHUB_CLIENT_OK`, it shall call `getDataCallbackEx` with `result` set to `FILE_UPLOAD_OK`, and `data` and `size` set to NULL. ]*/
+ /*Codes_SRS_IOTHUBCLIENT_LL_99_004: [ If `IoTHubClient_LL_UploadMultipleBlocksToBlob(Ex)` does not return `IOTHUB_CLIENT_OK`, it shall call `getDataCallbackEx` with `result` set to `FILE_UPLOAD_ERROR`, and `data` and `size` set to NULL. ]*/
+ (void)getDataCallbackEx(result == IOTHUB_CLIENT_OK ? FILE_UPLOAD_OK : FILE_UPLOAD_ERROR, NULL, NULL, context);
}
- /*Codes_SRS_IOTHUBCLIENT_LL_99_003: [ If `IoTHubClient_LL_UploadMultipleBlocksToBlob(Ex)` return `IOTHUB_CLIENT_OK`, it shall call `getDataCallbackEx` with `result` set to `FILE_UPLOAD_OK`, and `data` and `size` set to NULL. ]*/
- /*Codes_SRS_IOTHUBCLIENT_LL_99_004: [ If `IoTHubClient_LL_UploadMultipleBlocksToBlob(Ex)` does not return `IOTHUB_CLIENT_OK`, it shall call `getDataCallbackEx` with `result` set to `FILE_UPLOAD_ERROR`, and `data` and `size` set to NULL. ]*/
- (void)getDataCallbackEx(result == IOTHUB_CLIENT_OK ? FILE_UPLOAD_OK : FILE_UPLOAD_ERROR, NULL, NULL, context);
-
return result;
}
@@ -1248,7 +1259,7 @@
else if (strcmp(optionName, OPTION_HTTP_PROXY) == 0)
{
HTTP_PROXY_OPTIONS* proxy_options = (HTTP_PROXY_OPTIONS *)value;
-
+
if (proxy_options->host_address == NULL)
{
/* Codes_SRS_IOTHUBCLIENT_LL_32_006: [ If `host_address` is NULL, `IoTHubClient_LL_UploadToBlob_SetOption` shall fail and return `IOTHUB_CLIENT_INVALID_ARG`. ]*/
@@ -1279,7 +1290,7 @@
free((char *)handleData->http_proxy_options.password);
handleData->http_proxy_options.password = NULL;
}
-
+
handleData->http_proxy_options.port = proxy_options->port;
if (mallocAndStrcpy_s((char **)(&handleData->http_proxy_options.host_address), proxy_options->host_address) != 0)
@@ -1305,7 +1316,7 @@
}
else if (strcmp(optionName, OPTION_CURL_VERBOSE) == 0)
{
- handleData->curl_verbose = *(size_t*)value;
+ handleData->curl_verbosity_level = ((*(bool*)value) == 0) ? UPOADTOBLOB_CURL_VERBOSITY_OFF : UPOADTOBLOB_CURL_VERBOSITY_ON;
result = IOTHUB_CLIENT_OK;
}
else if (strcmp(optionName, OPTION_BLOB_UPLOAD_TIMEOUT_SECS) == 0)
--- a/iothub_client_options.h Thu Jul 12 18:09:13 2018 -0700
+++ b/iothub_client_options.h Tue Sep 11 11:13:11 2018 -0700
@@ -35,7 +35,7 @@
static STATIC_VAR_UNUSED const char* OPTION_MIN_POLLING_TIME = "MinimumPollingTime";
static STATIC_VAR_UNUSED const char* OPTION_BATCHING = "Batching";
- /* DEPRECATED:: OPTION_MESSAGE_TIMEOUT is DEPRECATED! Use OPTION_SERVICE_SIDE_KEEP_ALIVE_FREQ_SECS for AMQP; MQTT has no option available. OPTION_MESSAGE_TIMEOUT legacy variable will be kept for back-compat. */
+ /* DEPRECATED:: OPTION_MESSAGE_TIMEOUT is DEPRECATED! Use OPTION_SERVICE_SIDE_KEEP_ALIVE_FREQ_SECS for AMQP; MQTT has no option available. OPTION_MESSAGE_TIMEOUT legacy variable will be kept for back-compat. */
static STATIC_VAR_UNUSED const char* OPTION_MESSAGE_TIMEOUT = "messageTimeout";
static STATIC_VAR_UNUSED const char* OPTION_BLOB_UPLOAD_TIMEOUT_SECS = "blob_upload_timeout_secs";
static STATIC_VAR_UNUSED const char* OPTION_PRODUCT_INFO = "product_info";
@@ -54,24 +54,24 @@
*/
static STATIC_VAR_UNUSED const char* OPTION_SERVICE_SIDE_KEEP_ALIVE_FREQ_SECS = "svc2cl_keep_alive_timeout_secs";
- /* DEPRECATED:: OPTION_C2D_KEEP_ALIVE_FREQ_SECS is DEPRECATED! Use OPTION_SERVICE_SIDE_KEEP_ALIVE_FREQ_SECS, but OPTION_C2D_KEEP_ALIVE_FREQ_SECS legacy variable kept for back-compat. */
- static STATIC_VAR_UNUSED const char* OPTION_C2D_KEEP_ALIVE_FREQ_SECS = "c2d_keep_alive_freq_secs";
+ /* DEPRECATED:: OPTION_C2D_KEEP_ALIVE_FREQ_SECS is DEPRECATED! Use OPTION_SERVICE_SIDE_KEEP_ALIVE_FREQ_SECS, but OPTION_C2D_KEEP_ALIVE_FREQ_SECS legacy variable kept for back-compat. */
+ static STATIC_VAR_UNUSED const char* OPTION_C2D_KEEP_ALIVE_FREQ_SECS = "c2d_keep_alive_freq_secs";
/*
* @brief Ratio to be used for client side pings in AMQP protocol.
* The client must use this ratio to send keep-alives before service side remote idle timeout is reached, otherwise the service will disconnect the client.
- * The default value for this option is 1/2 of the remote idle value sent by the service.
+ * The default value for this option is 1/2 of the remote idle value sent by the service.
* For AMQP remote idle set to 4 minutes, default client ping will be 2 minutes. For AMQP remote idle set to 25 minutes configured via per Hub basis, the default ping will be 12.5 minutes.
*/
- static STATIC_VAR_UNUSED const char* OPTION_REMOTE_IDLE_TIMEOUT_RATIO = "cl2svc_keep_alive_send_ratio";
+ static STATIC_VAR_UNUSED const char* OPTION_REMOTE_IDLE_TIMEOUT_RATIO = "cl2svc_keep_alive_send_ratio";
- /*
- * @brief This option should be used instead of OPTION_MESSAGE_TIMEOUT if using AMQP protocol.
- * It defines the maximum ammount of time, in seconds, the client will wait for a telemetry message to complete sending before returning it with a IOTHUB_CLIENT_CONFIRMATION_MESSAGE_TIMEOUT error.
- * The default value 5 (five) minutes.
- * This option is applicable only to AMQP protocol.
- */
- static STATIC_VAR_UNUSED const char* OPTION_EVENT_SEND_TIMEOUT_SECS = "event_send_timeout_secs";
+ /*
+ * @brief This option should be used instead of OPTION_MESSAGE_TIMEOUT if using AMQP protocol.
+ * It defines the maximum ammount of time, in seconds, the client will wait for a telemetry message to complete sending before returning it with a IOTHUB_CLIENT_CONFIRMATION_MESSAGE_TIMEOUT error.
+ * The default value 5 (five) minutes.
+ * This option is applicable only to AMQP protocol.
+ */
+ static STATIC_VAR_UNUSED const char* OPTION_EVENT_SEND_TIMEOUT_SECS = "event_send_timeout_secs";
//diagnostic sampling percentage value, [0-100]
static STATIC_VAR_UNUSED const char* OPTION_DIAGNOSTIC_SAMPLING_PERCENTAGE = "diag_sampling_percentage";
--- a/iothub_client_version.h Thu Jul 12 18:09:13 2018 -0700 +++ b/iothub_client_version.h Tue Sep 11 11:13:11 2018 -0700 @@ -2,13 +2,13 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. /** @file iothub_client_version.h -* @brief Functions for managing the client SDK version. +* @brief Functions for managing the client SDK version. */ #ifndef IOTHUB_CLIENT_VERSION_H #define IOTHUB_CLIENT_VERSION_H -#define IOTHUB_SDK_VERSION "1.2.8" +#define IOTHUB_SDK_VERSION "1.2.9" #include "azure_c_shared_utility/umock_c_prod.h"
--- a/iothub_device_client.c Thu Jul 12 18:09:13 2018 -0700 +++ b/iothub_device_client.c Tue Sep 11 11:13:11 2018 -0700 @@ -1,7 +1,7 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -#include <stdlib.h> +#include <stdlib.h> #include "azure_c_shared_utility/umock_c_prod.h" #include "azure_c_shared_utility/gballoc.h"
--- a/iothub_device_client.h Thu Jul 12 18:09:13 2018 -0700
+++ b/iothub_device_client.h Tue Sep 11 11:13:11 2018 -0700
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-/** @file iothub_client.h
+/** @file iothub_device_client.h
* @brief Extends the IoTHubCLient_LL module with additional features.
*
* @details IoTHubClient is a module that extends the IoTHubCLient_LL
@@ -257,9 +257,9 @@
* is timeouted. The time starts at IoTHubDeviceClient_SendEventAsync. By default,
* messages do not expire. @p is a pointer to a uint64_t
* - @b svc2cl_keep_alive_timeout_secs - the AMQP service side keep alive interval in seconds.
- * After the connection established the client requests the server to set the
+ * After the connection established the client requests the server to set the
* keep alive interval for given time.
- * If it is not set then the default 240 sec applies.
+ * If it is not set then the default 240 sec applies.
* If it is set to zero the server will not send keep alive messages to the client.
* - @b cl2svc_keep_alive_send_ratio - the AMQP client side keep alive interval in seconds.
* After the connection established the server requests the client to set the
@@ -272,11 +272,11 @@
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_SetOption, IOTHUB_DEVICE_CLIENT_HANDLE, iotHubClientHandle, const char*, optionName, const void*, value);
/**
- * @brief This API specifies a call back to be used when the device receives a state update.
+ * @brief This API specifies a callback to be used when the device receives a state update.
*
* @param iotHubClientHandle The handle created by a call to the create function.
* @param deviceTwinCallback The callback specified by the device client to be used for updating
- * the desired state. The callback will be called in response to a
+ * the desired state. The callback will be called in response to a
* request send by the IoTHub services. The payload will be passed to the
* callback, along with two version numbers:
* - Desired:
@@ -309,7 +309,7 @@
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_SendReportedState, IOTHUB_DEVICE_CLIENT_HANDLE, iotHubClientHandle, const unsigned char*, reportedState, size_t, size, IOTHUB_CLIENT_REPORTED_STATE_CALLBACK, reportedStateCallback, void*, userContextCallback);
/**
- * @brief This API sets callback for async cloud to device method call.
+ * @brief This API sets the callback for async cloud to device method calls.
*
* @param iotHubClientHandle The handle created by a call to the create function.
* @param inboundDeviceMethodCallback The callback which will be called by IoTHub.
@@ -321,7 +321,7 @@
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_SetDeviceMethodCallback, IOTHUB_DEVICE_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_DEVICE_METHOD_CALLBACK_ASYNC, deviceMethodCallback, void*, userContextCallback);
/**
- * @brief This API responses to a asnyc method callback identified the methodId.
+ * @brief This API responds to an asnyc method callback identified the methodId.
*
* @param iotHubClientHandle The handle created by a call to the create function.
* @param methodId The methodId of the Device Method callback.
--- a/iothub_device_client_ll.h Thu Jul 12 18:09:13 2018 -0700
+++ b/iothub_device_client_ll.h Tue Sep 11 11:13:11 2018 -0700
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-/** @file iothub_client_ll.h
+/** @file iothub_device_client_ll.h
* @brief APIs that allow a user (usually a device) to communicate
* with an Azure IoTHub.
*
@@ -29,14 +29,14 @@
#include "azure_c_shared_utility/macro_utils.h"
#include "azure_c_shared_utility/umock_c_prod.h"
+#include "iothub_transport_ll.h"
+#include "iothub_client_core_ll.h"
+
#ifdef __cplusplus
extern "C"
{
#endif
-#include "iothub_transport_ll.h"
-#include "iothub_client_core_ll.h"
-
typedef struct IOTHUB_CLIENT_CORE_LL_HANDLE_DATA_TAG* IOTHUB_DEVICE_CLIENT_LL_HANDLE;
@@ -282,11 +282,11 @@
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_LL_SetOption, IOTHUB_DEVICE_CLIENT_LL_HANDLE, iotHubClientHandle, const char*, optionName, const void*, value);
/**
- * @brief This API specifies a call back to be used when the device receives a desired state update.
+ * @brief This API specifies a callback to be used when the device receives a desired state update.
*
* @param iotHubClientHandle The handle created by a call to the create function.
* @param deviceTwinCallback The callback specified by the device client to be used for updating
- * the desired state. The callback will be called in response to patch
+ * the desired state. The callback will be called in response to patch
* request send by the IoTHub services. The payload will be passed to the
* callback, along with two version numbers:
* - Desired:
@@ -302,7 +302,7 @@
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_LL_SetDeviceTwinCallback, IOTHUB_DEVICE_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_DEVICE_TWIN_CALLBACK, deviceTwinCallback, void*, userContextCallback);
/**
- * @brief This API sneds a report of the device's properties and their current values.
+ * @brief This API sends a report of the device's properties and their current values.
*
* @param iotHubClientHandle The handle created by a call to the create function.
* @param reportedState The current device property values to be 'reported' to the IoTHub.
@@ -318,7 +318,7 @@
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_LL_SendReportedState, IOTHUB_DEVICE_CLIENT_LL_HANDLE, iotHubClientHandle, const unsigned char*, reportedState, size_t, size, IOTHUB_CLIENT_REPORTED_STATE_CALLBACK, reportedStateCallback, void*, userContextCallback);
/**
- * @brief This API sets callback for async cloud to device method call.
+ * @brief This API sets the callback for async cloud to device method calls.
*
* @param iotHubClientHandle The handle created by a call to the create function.
* @param inboundDeviceMethodCallback The callback which will be called by IoTHub.
@@ -330,7 +330,7 @@
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_LL_SetDeviceMethodCallback, IOTHUB_DEVICE_CLIENT_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_DEVICE_METHOD_CALLBACK_ASYNC, deviceMethodCallback, void*, userContextCallback);
/**
- * @brief This API responses to a asnyc method callback identified the methodId.
+ * @brief This API responds to an asnyc method callback identified the methodId.
*
* @param iotHubClientHandle The handle created by a call to the create function.
* @param methodId The methodId of the Device Method callback.
--- a/iothub_message.c Thu Jul 12 18:09:13 2018 -0700
+++ b/iothub_message.c Tue Sep 11 11:13:11 2018 -0700
@@ -41,7 +41,7 @@
const char* iterator = asciiValue;
while (iterator != NULL && *iterator != '\0')
{
- // Allow only printable ascii char
+ // Allow only printable ascii char
if (*iterator < ' ' || *iterator > '~')
{
result = false;
@@ -232,7 +232,7 @@
memset(result, 0, sizeof(*result));
/*Codes_SRS_IOTHUBMESSAGE_02_032: [The type of the new message shall be IOTHUBMESSAGE_STRING.] */
result->contentType = IOTHUBMESSAGE_STRING;
-
+
/*Codes_SRS_IOTHUBMESSAGE_02_027: [IoTHubMessage_CreateFromString shall call STRING_construct passing source as parameter.] */
if ((result->value.string = STRING_construct(source)) == NULL)
{
@@ -625,7 +625,7 @@
{
IOTHUB_MESSAGE_RESULT result;
- // Codes_SRS_IOTHUBMESSAGE_09_001: [If any of the parameters are NULL then IoTHubMessage_SetContentTypeSystemProperty shall return a IOTHUB_MESSAGE_INVALID_ARG value.]
+ // Codes_SRS_IOTHUBMESSAGE_09_001: [If any of the parameters are NULL then IoTHubMessage_SetContentTypeSystemProperty shall return a IOTHUB_MESSAGE_INVALID_ARG value.]
if (iotHubMessageHandle == NULL || contentType == NULL)
{
LogError("Invalid argument (iotHubMessageHandle=%p, contentType=%p)", iotHubMessageHandle, contentType);
@@ -635,7 +635,7 @@
{
IOTHUB_MESSAGE_HANDLE_DATA* handleData = (IOTHUB_MESSAGE_HANDLE_DATA*)iotHubMessageHandle;
- // Codes_SRS_IOTHUBMESSAGE_09_002: [If the IOTHUB_MESSAGE_HANDLE `contentType` is not NULL it shall be deallocated.]
+ // Codes_SRS_IOTHUBMESSAGE_09_002: [If the IOTHUB_MESSAGE_HANDLE `contentType` is not NULL it shall be deallocated.]
if (handleData->userDefinedContentType != NULL)
{
free(handleData->userDefinedContentType);
@@ -645,7 +645,7 @@
if (mallocAndStrcpy_s(&handleData->userDefinedContentType, contentType) != 0)
{
LogError("Failed saving a copy of contentType");
- // Codes_SRS_IOTHUBMESSAGE_09_003: [If the allocation or the copying of `contentType` fails, then IoTHubMessage_SetContentTypeSystemProperty shall return IOTHUB_MESSAGE_ERROR.]
+ // Codes_SRS_IOTHUBMESSAGE_09_003: [If the allocation or the copying of `contentType` fails, then IoTHubMessage_SetContentTypeSystemProperty shall return IOTHUB_MESSAGE_ERROR.]
result = IOTHUB_MESSAGE_ERROR;
}
else
@@ -662,7 +662,7 @@
{
const char* result;
- // Codes_SRS_IOTHUBMESSAGE_09_005: [If any of the parameters are NULL then IoTHubMessage_GetContentTypeSystemProperty shall return a IOTHUB_MESSAGE_INVALID_ARG value.]
+ // Codes_SRS_IOTHUBMESSAGE_09_005: [If any of the parameters are NULL then IoTHubMessage_GetContentTypeSystemProperty shall return a IOTHUB_MESSAGE_INVALID_ARG value.]
if (iotHubMessageHandle == NULL)
{
LogError("Invalid argument (iotHubMessageHandle is NULL)");
@@ -672,7 +672,7 @@
{
IOTHUB_MESSAGE_HANDLE_DATA* handleData = iotHubMessageHandle;
- // Codes_SRS_IOTHUBMESSAGE_09_006: [IoTHubMessage_GetContentTypeSystemProperty shall return the `contentType` as a const char* ]
+ // Codes_SRS_IOTHUBMESSAGE_09_006: [IoTHubMessage_GetContentTypeSystemProperty shall return the `contentType` as a const char* ]
result = (const char*)handleData->userDefinedContentType;
}
@@ -683,7 +683,7 @@
{
IOTHUB_MESSAGE_RESULT result;
- // Codes_SRS_IOTHUBMESSAGE_09_006: [If any of the parameters are NULL then IoTHubMessage_SetContentEncodingSystemProperty shall return a IOTHUB_MESSAGE_INVALID_ARG value.]
+ // Codes_SRS_IOTHUBMESSAGE_09_006: [If any of the parameters are NULL then IoTHubMessage_SetContentEncodingSystemProperty shall return a IOTHUB_MESSAGE_INVALID_ARG value.]
if (iotHubMessageHandle == NULL || contentEncoding == NULL)
{
LogError("Invalid argument (iotHubMessageHandle=%p, contentEncoding=%p)", iotHubMessageHandle, contentEncoding);
@@ -693,7 +693,7 @@
{
IOTHUB_MESSAGE_HANDLE_DATA* handleData = (IOTHUB_MESSAGE_HANDLE_DATA*)iotHubMessageHandle;
- // Codes_SRS_IOTHUBMESSAGE_09_007: [If the IOTHUB_MESSAGE_HANDLE `contentEncoding` is not NULL it shall be deallocated.]
+ // Codes_SRS_IOTHUBMESSAGE_09_007: [If the IOTHUB_MESSAGE_HANDLE `contentEncoding` is not NULL it shall be deallocated.]
if (handleData->contentEncoding != NULL)
{
free(handleData->contentEncoding);
@@ -720,7 +720,7 @@
{
const char* result;
- // Codes_SRS_IOTHUBMESSAGE_09_010: [If any of the parameters are NULL then IoTHubMessage_GetContentEncodingSystemProperty shall return a IOTHUB_MESSAGE_INVALID_ARG value.]
+ // Codes_SRS_IOTHUBMESSAGE_09_010: [If any of the parameters are NULL then IoTHubMessage_GetContentEncodingSystemProperty shall return a IOTHUB_MESSAGE_INVALID_ARG value.]
if (iotHubMessageHandle == NULL)
{
LogError("Invalid argument (iotHubMessageHandle is NULL)");
@@ -730,7 +730,7 @@
{
IOTHUB_MESSAGE_HANDLE_DATA* handleData = iotHubMessageHandle;
- // Codes_SRS_IOTHUBMESSAGE_09_011: [IoTHubMessage_GetContentEncodingSystemProperty shall return the `contentEncoding` as a const char* ]
+ // Codes_SRS_IOTHUBMESSAGE_09_011: [IoTHubMessage_GetContentEncodingSystemProperty shall return the `contentEncoding` as a const char* ]
result = (const char*)handleData->contentEncoding;
}
@@ -740,7 +740,7 @@
const IOTHUB_MESSAGE_DIAGNOSTIC_PROPERTY_DATA* IoTHubMessage_GetDiagnosticPropertyData(IOTHUB_MESSAGE_HANDLE iotHubMessageHandle)
{
const IOTHUB_MESSAGE_DIAGNOSTIC_PROPERTY_DATA* result;
- // Codes_SRS_IOTHUBMESSAGE_10_001: [If any of the parameters are NULL then IoTHubMessage_GetDiagnosticPropertyData shall return a NULL value.]
+ // Codes_SRS_IOTHUBMESSAGE_10_001: [If any of the parameters are NULL then IoTHubMessage_GetDiagnosticPropertyData shall return a NULL value.]
if (iotHubMessageHandle == NULL)
{
LogError("Invalid argument (iotHubMessageHandle is NULL)");
@@ -757,21 +757,21 @@
IOTHUB_MESSAGE_RESULT IoTHubMessage_SetDiagnosticPropertyData(IOTHUB_MESSAGE_HANDLE iotHubMessageHandle, const IOTHUB_MESSAGE_DIAGNOSTIC_PROPERTY_DATA* diagnosticData)
{
IOTHUB_MESSAGE_RESULT result;
- // Codes_SRS_IOTHUBMESSAGE_10_003: [If any of the parameters are NULL then IoTHubMessage_SetDiagnosticId shall return a IOTHUB_MESSAGE_INVALID_ARG value.]
- if (iotHubMessageHandle == NULL ||
+ // Codes_SRS_IOTHUBMESSAGE_10_003: [If any of the parameters are NULL then IoTHubMessage_SetDiagnosticId shall return a IOTHUB_MESSAGE_INVALID_ARG value.]
+ if (iotHubMessageHandle == NULL ||
diagnosticData == NULL ||
diagnosticData->diagnosticCreationTimeUtc == NULL ||
diagnosticData->diagnosticId == NULL)
{
- LogError("Invalid argument (iotHubMessageHandle=%p, diagnosticData=%p, diagnosticData->diagnosticId=%p, diagnosticData->diagnosticCreationTimeUtc=%p)",
- iotHubMessageHandle, diagnosticData,
+ LogError("Invalid argument (iotHubMessageHandle=%p, diagnosticData=%p, diagnosticData->diagnosticId=%p, diagnosticData->diagnosticCreationTimeUtc=%p)",
+ iotHubMessageHandle, diagnosticData,
diagnosticData == NULL ? NULL : diagnosticData->diagnosticId,
diagnosticData == NULL ? NULL : diagnosticData->diagnosticCreationTimeUtc);
result = IOTHUB_MESSAGE_INVALID_ARG;
}
else
{
- // Codes_SRS_IOTHUBMESSAGE_10_004: [If the IOTHUB_MESSAGE_HANDLE `diagnosticData` is not NULL it shall be deallocated.]
+ // Codes_SRS_IOTHUBMESSAGE_10_004: [If the IOTHUB_MESSAGE_HANDLE `diagnosticData` is not NULL it shall be deallocated.]
if (iotHubMessageHandle->diagnosticData != NULL)
{
DestroyDiagnosticPropertyData(iotHubMessageHandle->diagnosticData);
--- a/iothub_message.h Thu Jul 12 18:09:13 2018 -0700 +++ b/iothub_message.h Tue Sep 11 11:13:11 2018 -0700 @@ -2,7 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. /** @file iothub_message.h -* @brief The @c IoTHub_Message component encapsulates one message that +* @brief The @c IoTHub_Message component encapsulates one message that * can be transferred by an IoT hub client. */ @@ -10,7 +10,7 @@ #define IOTHUB_MESSAGE_H #include "azure_c_shared_utility/macro_utils.h" -#include "azure_c_shared_utility/map.h" +#include "azure_c_shared_utility/map.h" #include "azure_c_shared_utility/umock_c_prod.h" #ifdef __cplusplus @@ -170,7 +170,9 @@ MOCKABLE_FUNCTION(, const char*, IoTHubMessage_GetContentEncodingSystemProperty, IOTHUB_MESSAGE_HANDLE, iotHubMessageHandle); /** +** DEPRECATED: Use IoTHubMessage_SetProperty and IoTHubMessage_GetProperty instead. ** * @brief Gets a handle to the message's properties map. +* Note that when sending messages via the HTTP transport, the key names in the map must not contain spaces. * * @param iotHubMessageHandle Handle to the message. * @@ -183,7 +185,7 @@ * * @param iotHubMessageHandle Handle to the message. * -* @param key name of the property to set. +* @param key name of the property to set. Note that when sending messages via the HTTP transport, this value must not contain spaces. * * @param value of the property to set. *
--- a/iothubtransport.c Thu Jul 12 18:09:13 2018 -0700
+++ b/iothubtransport.c Tue Sep 11 11:13:11 2018 -0700
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-#include <stdlib.h>
+#include <stdlib.h>
#include <signal.h>
#include <stddef.h>
#include "azure_c_shared_utility/gballoc.h"
@@ -137,7 +137,7 @@
}
}
}
-
+
return result;
}
