Skip to content

Commit

Permalink
Merge branch 'master' into ewertons/fix_blob_upload_fail_mbedtls_1995
Browse files Browse the repository at this point in the history
  • Loading branch information
ewertons committed Aug 4, 2021
2 parents 19d9080 + 5d65573 commit 2bffb4b
Show file tree
Hide file tree
Showing 74 changed files with 3,881 additions and 1,598 deletions.
2 changes: 1 addition & 1 deletion build_all/linux/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ process_args $*
rm -r -f $build_folder
mkdir –m777 -p $build_folder
pushd $build_folder
cmake $toolchainfile $cmake_install_prefix -Drun_valgrind:BOOL=$run_valgrind -DcompileOption_C:STRING="$extracloptions" -Drun_e2e_tests:BOOL=$run_e2e_tests -Drun_sfc_tests:BOOL=$run-sfc-tests -Drun_longhaul_tests=$run_longhaul_tests -Duse_amqp:BOOL=$build_amqp -Duse_http:BOOL=$build_http -Duse_mqtt:BOOL=$build_mqtt -Ddont_use_uploadtoblob:BOOL=$no_blob -Drun_unittests:BOOL=$run_unittests -Dbuild_python:STRING=$build_python -Dno_logging:BOOL=$no_logging $build_root -Duse_prov_client:BOOL=$prov_auth -Duse_tpm_simulator:BOOL=$prov_use_tpm_simulator -Duse_edge_modules=$use_edge_modules
cmake $toolchainfile $cmake_install_prefix -Drun_valgrind:BOOL=$run_valgrind -DcompileOption_C=-Wstrict-prototypes -DcompileOption_C:STRING="$extracloptions" -Drun_e2e_tests:BOOL=$run_e2e_tests -Drun_sfc_tests:BOOL=$run-sfc-tests -Drun_longhaul_tests=$run_longhaul_tests -Duse_amqp:BOOL=$build_amqp -Duse_http:BOOL=$build_http -Duse_mqtt:BOOL=$build_mqtt -Ddont_use_uploadtoblob:BOOL=$no_blob -Drun_unittests:BOOL=$run_unittests -Dbuild_python:STRING=$build_python -Dno_logging:BOOL=$no_logging $build_root -Duse_prov_client:BOOL=$prov_auth -Duse_tpm_simulator:BOOL=$prov_use_tpm_simulator -Duse_edge_modules=$use_edge_modules
chmod --recursive ugo+rw ../../cmake

if [ "$make" = true ]
Expand Down
1 change: 1 addition & 0 deletions iothub_client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ set(iothub_client_h_files
./inc/iothub_module_client_ll.h
./inc/iothub_transport_ll.h
./inc/iothub_message.h
./inc/internal/iothub_message_private.h
./inc/internal/iothubtransport.h
)

Expand Down
2 changes: 1 addition & 1 deletion iothub_client/inc/internal/iothub_client_ll_uploadtoblob.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extern "C"
#include <stddef.h>
#endif

#define BLOCK_SIZE (4*1024*1024)
#define BLOCK_SIZE (100*1024*1024)

typedef struct IOTHUB_CLIENT_LL_UPLOADTOBLOB_HANDLE_DATA* IOTHUB_CLIENT_LL_UPLOADTOBLOB_HANDLE;

Expand Down
4 changes: 2 additions & 2 deletions iothub_client/inc/internal/iothub_client_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ extern "C"
#define CLIENT_DEVICE_TYPE_PREFIX "iothubclient"
#define CLIENT_DEVICE_BACKSLASH "/"

typedef bool(*IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC_EX)(MESSAGE_CALLBACK_INFO* messageData, void* userContextCallback);
typedef bool(*IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC_EX)(IOTHUB_MESSAGE_HANDLE message, void* userContextCallback);

MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClientCore_LL_SetMessageCallback_Ex, IOTHUB_CLIENT_CORE_LL_HANDLE, iotHubClientHandle, IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC_EX, messageCallback, void*, userContextCallback);
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClientCore_LL_SendMessageDisposition, IOTHUB_CLIENT_CORE_LL_HANDLE, iotHubClientHandle, MESSAGE_CALLBACK_INFO*, messageData, IOTHUBMESSAGE_DISPOSITION_RESULT, disposition);
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClientCore_LL_SendMessageDisposition, IOTHUB_CLIENT_CORE_LL_HANDLE, iotHubClientHandle, IOTHUB_MESSAGE_HANDLE, message, IOTHUBMESSAGE_DISPOSITION_RESULT, disposition);
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClientCore_LL_SetInputMessageCallbackEx, IOTHUB_CLIENT_CORE_LL_HANDLE, iotHubClientHandle, const char*, inputName, IOTHUB_CLIENT_MESSAGE_CALLBACK_ASYNC_EX, eventHandlerCallbackEx, void *, userContextCallback, size_t, userContextCallbackLength);
MOCKABLE_FUNCTION(, int, IoTHubClientCore_LL_GetTransportCallbacks, TRANSPORT_CALLBACKS_INFO*, transport_cb);

Expand Down
53 changes: 53 additions & 0 deletions iothub_client/inc/internal/iothub_message_private.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

/** @file iothub_message_private.h
* @brief For internal use of the Azure IoT C SDK only.
*/

#ifndef IOTHUB_MESSAGE_PRIVATE_H
#define IOTHUB_MESSAGE_PRIVATE_H

#include "azure_macro_utils/macro_utils.h"
#include "umock_c/umock_c_prod.h"
#include "iothub_message.h"

#ifdef __cplusplus
#include <cstddef>
extern "C"
{
#else
#include <stddef.h>
#endif

struct MESSAGE_DISPOSITION_CONTEXT_TAG;
typedef struct MESSAGE_DISPOSITION_CONTEXT_TAG* MESSAGE_DISPOSITION_CONTEXT_HANDLE;

typedef void(*MESSAGE_DISPOSITION_CONTEXT_DESTROY_FUNCTION)(MESSAGE_DISPOSITION_CONTEXT_HANDLE dispositionContext);

/**
* @brief Sets the context for the transport layer to send a DISPOSITION or ACK for a cloud-to-device message.
*
* @param iotHubMessageHandle The message on which to have the context set.
* @param dispositionContext The transport context for disposition.
* @param dispositionContextDestroyFunction A function defined by the transport for destroying the context instance.
*
* @return An #IOTHUB_MESSAGE_RESULT with the result of the operation.
*/
MOCKABLE_FUNCTION(, IOTHUB_MESSAGE_RESULT, IoTHubMessage_SetDispositionContext, IOTHUB_MESSAGE_HANDLE, iotHubMessageHandle, MESSAGE_DISPOSITION_CONTEXT_HANDLE, dispositionContext, MESSAGE_DISPOSITION_CONTEXT_DESTROY_FUNCTION, dispositionContextDestroyFunction);

/**
* @brief Gets the context for the transport layer to send a DISPOSITION or ACK for a cloud-to-device message.
*
* @param iotHubMessageHandle The message to have the context set on.
* @param dispositionContext Variable to hold the transport context for disposition.
*
* @return An #IOTHUB_MESSAGE_RESULT with the result of the operation.
*/
MOCKABLE_FUNCTION(, IOTHUB_MESSAGE_RESULT, IoTHubMessage_GetDispositionContext, IOTHUB_MESSAGE_HANDLE, iotHubMessageHandle, MESSAGE_DISPOSITION_CONTEXT_HANDLE*, dispositionContext);

#ifdef __cplusplus
}
#endif

#endif /* IOTHUB_MESSAGE_PRIVATE_H */
14 changes: 3 additions & 11 deletions iothub_client/inc/internal/iothub_transport_ll_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,15 @@ typedef union IOTHUB_IDENTITY_INFO_TAG IOTHUB_IDENTITY_INFO;
#include "internal/iothub_client_authorization.h"
#include "iothub_message.h"

struct MESSAGE_DISPOSITION_CONTEXT_TAG;
typedef struct MESSAGE_DISPOSITION_CONTEXT_TAG* MESSAGE_DISPOSITION_CONTEXT_HANDLE;
typedef struct MESSAGE_CALLBACK_INFO_TAG
{
IOTHUB_MESSAGE_HANDLE messageHandle;
MESSAGE_DISPOSITION_CONTEXT_HANDLE transportContext;
}MESSAGE_CALLBACK_INFO;

#include "iothub_client_ll.h"

#ifdef __cplusplus
extern "C"
{
#endif

typedef bool (*pfTransport_MessageCallbackFromInput)(MESSAGE_CALLBACK_INFO* messageData, void* ctx);
typedef bool (*pfTransport_MessageCallback)(MESSAGE_CALLBACK_INFO* messageData, void* ctx);
typedef bool (*pfTransport_MessageCallbackFromInput)(IOTHUB_MESSAGE_HANDLE message, void* ctx);
typedef bool (*pfTransport_MessageCallback)(IOTHUB_MESSAGE_HANDLE message, void* ctx);
typedef void (*pfTransport_ConnectionStatusCallBack)(IOTHUB_CLIENT_CONNECTION_STATUS status, IOTHUB_CLIENT_CONNECTION_STATUS_REASON reason, void* ctx);
typedef void (*pfTransport_SendComplete_Callback)(PDLIST_ENTRY completed, IOTHUB_CLIENT_CONFIRMATION_RESULT result, void* ctx);
typedef const char* (*pfTransport_GetOption_Product_Info_Callback)(void* ctx);
Expand Down Expand Up @@ -85,7 +77,7 @@ extern "C"
typedef int (*pfIoTHubTransport_Subscribe_DeviceTwin)(IOTHUB_DEVICE_HANDLE handle);
typedef void (*pfIoTHubTransport_Unsubscribe_DeviceTwin)(IOTHUB_DEVICE_HANDLE handle);
typedef IOTHUB_CLIENT_RESULT(*pfIoTHubTransport_GetTwinAsync)(IOTHUB_DEVICE_HANDLE handle, IOTHUB_CLIENT_DEVICE_TWIN_CALLBACK completionCallback, void* callbackContext);
typedef IOTHUB_CLIENT_RESULT(*pfIotHubTransport_SendMessageDisposition)(MESSAGE_CALLBACK_INFO* messageData, IOTHUBMESSAGE_DISPOSITION_RESULT disposition);
typedef IOTHUB_CLIENT_RESULT(*pfIotHubTransport_SendMessageDisposition)(IOTHUB_DEVICE_HANDLE handle, IOTHUB_MESSAGE_HANDLE message, IOTHUBMESSAGE_DISPOSITION_RESULT disposition);
typedef IOTHUB_PROCESS_ITEM_RESULT(*pfIoTHubTransport_ProcessItem)(TRANSPORT_LL_HANDLE handle, IOTHUB_IDENTITY_TYPE item_type, IOTHUB_IDENTITY_INFO* iothub_item);
typedef int(*pfIoTHubTransport_Subscribe_DeviceMethod)(IOTHUB_DEVICE_HANDLE handle);
typedef void(*pfIoTHubTransport_Unsubscribe_DeviceMethod)(IOTHUB_DEVICE_HANDLE handle);
Expand Down
2 changes: 1 addition & 1 deletion iothub_client/inc/internal/iothubtransport_amqp_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubTransport_AMQP_Common_SetOption,
MOCKABLE_FUNCTION(, IOTHUB_DEVICE_HANDLE, IoTHubTransport_AMQP_Common_Register, TRANSPORT_LL_HANDLE, handle, const IOTHUB_DEVICE_CONFIG*, device, PDLIST_ENTRY, waitingToSend);
MOCKABLE_FUNCTION(, void, IoTHubTransport_AMQP_Common_Unregister, IOTHUB_DEVICE_HANDLE, deviceHandle);
MOCKABLE_FUNCTION(, STRING_HANDLE, IoTHubTransport_AMQP_Common_GetHostname, TRANSPORT_LL_HANDLE, handle);
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubTransport_AMQP_Common_SendMessageDisposition, MESSAGE_CALLBACK_INFO*, message_data, IOTHUBMESSAGE_DISPOSITION_RESULT, disposition);
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubTransport_AMQP_Common_SendMessageDisposition, IOTHUB_DEVICE_HANDLE, handle, IOTHUB_MESSAGE_HANDLE, messageHandle, IOTHUBMESSAGE_DISPOSITION_RESULT, disposition);
MOCKABLE_FUNCTION(, int, IoTHubTransport_AMQP_SetCallbackContext, TRANSPORT_LL_HANDLE, handle, void*, ctx);
MOCKABLE_FUNCTION(, int, IoTHubTransport_AMQP_Common_GetSupportedPlatformInfo, TRANSPORT_LL_HANDLE, handle, PLATFORM_INFO_OPTION*, info);

Expand Down
3 changes: 2 additions & 1 deletion iothub_client/inc/internal/iothubtransport_amqp_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ MOCKABLE_FUNCTION(, int, amqp_device_send_message_disposition, AMQP_DEVICE_HANDL
MOCKABLE_FUNCTION(, int, amqp_device_set_retry_policy, AMQP_DEVICE_HANDLE, handle, IOTHUB_CLIENT_RETRY_POLICY, policy, size_t, retry_timeout_limit_in_seconds);
MOCKABLE_FUNCTION(, int, amqp_device_set_option, AMQP_DEVICE_HANDLE, handle, const char*, name, void*, value);
MOCKABLE_FUNCTION(, OPTIONHANDLER_HANDLE, amqp_device_retrieve_options, AMQP_DEVICE_HANDLE, handle);

MOCKABLE_FUNCTION(, DEVICE_MESSAGE_DISPOSITION_INFO*, amqp_device_clone_message_disposition_info, DEVICE_MESSAGE_DISPOSITION_INFO*, disposition_info);
MOCKABLE_FUNCTION(, void, amqp_device_destroy_message_disposition_info, DEVICE_MESSAGE_DISPOSITION_INFO*, disposition_info);

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion iothub_client/inc/internal/iothubtransport_mqtt_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ MOCKABLE_FUNCTION(, TRANSPORT_LL_HANDLE, IoTHubTransport_MQTT_Common_Register, T
MOCKABLE_FUNCTION(, void, IoTHubTransport_MQTT_Common_Unregister, TRANSPORT_LL_HANDLE, deviceHandle);
MOCKABLE_FUNCTION(, int, IoTHubTransport_MQTT_Common_SetRetryPolicy, TRANSPORT_LL_HANDLE, handle, IOTHUB_CLIENT_RETRY_POLICY, retryPolicy, size_t, retryTimeoutLimitInSeconds);
MOCKABLE_FUNCTION(, STRING_HANDLE, IoTHubTransport_MQTT_Common_GetHostname, TRANSPORT_LL_HANDLE, handle);
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubTransport_MQTT_Common_SendMessageDisposition, MESSAGE_CALLBACK_INFO*, message_data, IOTHUBMESSAGE_DISPOSITION_RESULT, disposition);
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubTransport_MQTT_Common_SendMessageDisposition, IOTHUB_DEVICE_HANDLE, handle, IOTHUB_MESSAGE_HANDLE, messageHandle, IOTHUBMESSAGE_DISPOSITION_RESULT, disposition);
MOCKABLE_FUNCTION(, int, IoTHubTransport_MQTT_Common_Subscribe_InputQueue, TRANSPORT_LL_HANDLE, handle);
MOCKABLE_FUNCTION(, void, IoTHubTransport_MQTT_Common_Unsubscribe_InputQueue, TRANSPORT_LL_HANDLE, handle);
MOCKABLE_FUNCTION(, int, IoTHubTransport_MQTT_SetCallbackContext, TRANSPORT_LL_HANDLE, handle, void*, ctx);
Expand Down
2 changes: 2 additions & 0 deletions iothub_client/inc/iothub_client_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ extern "C"
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 */

MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubClientCore_SendMessageDisposition, IOTHUB_CLIENT_CORE_HANDLE, iotHubClientHandle, IOTHUB_MESSAGE_HANDLE, message, IOTHUBMESSAGE_DISPOSITION_RESULT, disposition);

#ifdef __cplusplus
}
#endif
Expand Down
3 changes: 2 additions & 1 deletion iothub_client/inc/iothub_client_core_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ extern "C"
#define IOTHUBMESSAGE_DISPOSITION_RESULT_VALUES \
IOTHUBMESSAGE_ACCEPTED, \
IOTHUBMESSAGE_REJECTED, \
IOTHUBMESSAGE_ABANDONED
IOTHUBMESSAGE_ABANDONED, \
IOTHUBMESSAGE_ASYNC_ACK

/** @brief Enumeration returned by the callback which is invoked whenever the
* IoT Hub sends a message to the device.
Expand Down
20 changes: 20 additions & 0 deletions iothub_client/inc/iothub_device_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,26 @@ extern "C"

#endif /* DONT_USE_UPLOADTOBLOB */

/**
* @brief This API sends an acknowledgement to Azure IoT Hub that a cloud-to-device message has been received and frees resources associated with the message.
*
* @param iotHubClientHandle The handle created by a call to a create function.
* @param message The cloud-to-device message received through the callback provided to IoTHubDeviceClient_SetMessageCallback.
* @param disposition Acknowledgement option for the message.
*
* @warning This function is to be used only when IOTHUBMESSAGE_ASYNC_ACK is used in the callback for incoming cloud-to-device messages.
* @remarks
* If your cloud-to-device message callback returned IOTHUBMESSAGE_ASYNC_ACK, it MUST call this API eventually.
* Beyond sending acknowledgment to the service, this method also handles freeing message's memory.
* Not calling this function will result in memory leaks.
* Depending on the protocol used, this API will acknowledge cloud-to-device messages differently:
* AMQP: A MESSAGE DISPOSITION is sent using the `disposition` option provided.
* MQTT: A PUBACK is sent if `disposition` is `IOTHUBMESSAGE_ACCEPTED`. Passing any other option results in no PUBACK sent for the message.
* HTTP: A HTTP request is sent using the `disposition` option provided.
* @return IOTHUB_CLIENT_OK upon success, or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_SendMessageDisposition, IOTHUB_DEVICE_CLIENT_HANDLE, iotHubClientHandle, IOTHUB_MESSAGE_HANDLE, message, IOTHUBMESSAGE_DISPOSITION_RESULT, disposition);

#ifdef __cplusplus
}
#endif
Expand Down
20 changes: 20 additions & 0 deletions iothub_client/inc/iothub_device_client_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,26 @@ typedef struct IOTHUB_CLIENT_CORE_LL_HANDLE_DATA_TAG* IOTHUB_DEVICE_CLIENT_LL_HA

#endif /*DONT_USE_UPLOADTOBLOB*/

/**
* @brief This API sends an acknowledgement to Azure IoT Hub that a cloud-to-device message has been received and frees resources associated with the message.
*
* @param device_ll_handle The handle created by a call to a create function.
* @param message The cloud-to-device message received through the callback provided to IoTHubDeviceClient_LL_SetMessageCallback.
* @param disposition Acknowledgement option for the message.
*
* @warning This function is to be used only when IOTHUBMESSAGE_ASYNC_ACK is used in the callback for incoming cloud-to-device messages.
* @remarks
* If your cloud-to-device message callback returned IOTHUBMESSAGE_ASYNC_ACK, it MUST call this API eventually.
* Beyond sending acknowledgment to the service, this method also handles freeing message's memory.
* Not calling this function will result in memory leaks.
* Depending on the protocol used, this API will acknowledge cloud-to-device messages differently:
* AMQP: A MESSAGE DISPOSITION is sent using the `disposition` option provided.
* MQTT: A PUBACK is sent if `disposition` is `IOTHUBMESSAGE_ACCEPTED`. Passing any other option results in no PUBACK sent for the message.
* HTTP: A HTTP request is sent using the `disposition` option provided.
* @return IOTHUB_CLIENT_OK upon success, or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubDeviceClient_LL_SendMessageDisposition, IOTHUB_DEVICE_CLIENT_LL_HANDLE, device_ll_handle, IOTHUB_MESSAGE_HANDLE, message, IOTHUBMESSAGE_DISPOSITION_RESULT, disposition);

#ifdef __cplusplus
}
#endif
Expand Down
20 changes: 20 additions & 0 deletions iothub_client/inc/iothub_module_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,26 @@ extern "C"

#endif /*USE_EDGE_MODULES*/

/**
* @brief This API sends an acknowledgement to Azure IoT Hub that a cloud-to-device message has been received and frees resources associated with the message.
*
* @param iotHubModuleClientHandle The handle created by a call to a create function.
* @param message The cloud-to-device message received through the callback provided to IoTHubModuleClient_SetMessageCallback or IoTHubModuleClient_SetInputMessageCallback.
* @param disposition Acknowledgement option for the message.
*
* @warning This function is to be used only when IOTHUBMESSAGE_ASYNC_ACK is used in the callback for incoming cloud-to-device messages.
* @remarks
* If your cloud-to-device message callback returned IOTHUBMESSAGE_ASYNC_ACK, it MUST call this API eventually.
* Beyond sending acknowledgment to the service, this method also handles freeing message's memory.
* Not calling this function will result in memory leaks.
* Depending on the protocol used, this API will acknowledge cloud-to-device messages differently:
* AMQP: A MESSAGE DISPOSITION is sent using the `disposition` option provided.
* MQTT: A PUBACK is sent if `disposition` is `IOTHUBMESSAGE_ACCEPTED`. Passing any other option results in no PUBACK sent for the message.
* HTTP: A HTTP request is sent using the `disposition` option provided.
* @return IOTHUB_CLIENT_OK upon success, or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_SendMessageDisposition, IOTHUB_MODULE_CLIENT_HANDLE, iotHubModuleClientHandle, IOTHUB_MESSAGE_HANDLE, message, IOTHUBMESSAGE_DISPOSITION_RESULT, disposition);

#ifdef __cplusplus
}
#endif
Expand Down
21 changes: 21 additions & 0 deletions iothub_client/inc/iothub_module_client_ll.h
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,27 @@ extern "C"

#endif /*USE_EDGE_MODULES*/

/**
* @brief This API sends an acknowledgement to Azure IoT Hub that a cloud-to-device message has been received and frees resources associated with the message.
*
* @param module_ll_handle The handle created by a call to a create function.
* @param message The cloud-to-device message received through the callback provided to IoTHubModuleClient_LL_SetMessageCallback or IoTHubModuleClient_LL_SetInputMessageCallback.
* @param disposition Acknowledgement option for the message.
*
* @warning This function is to be used only when IOTHUBMESSAGE_ASYNC_ACK is used in the callback for incoming cloud-to-device messages.
* @remarks
* If your cloud-to-device message callback returned IOTHUBMESSAGE_ASYNC_ACK, it MUST call this API eventually.
* Beyond sending acknowledgment to the service, this method also handles freeing message's memory.
* Not calling this function will result in memory leaks.
* Depending on the protocol used, this API will acknowledge cloud-to-device messages differently:
* AMQP: A MESSAGE DISPOSITION is sent using the `disposition` option provided.
* MQTT: A PUBACK is sent if `disposition` is `IOTHUBMESSAGE_ACCEPTED`. Passing any other option results in no PUBACK sent for the message.
* HTTP: A HTTP request is sent using the `disposition` option provided.
*
* @return IOTHUB_CLIENT_OK upon success, or an error code upon failure.
*/
MOCKABLE_FUNCTION(, IOTHUB_CLIENT_RESULT, IoTHubModuleClient_LL_SendMessageDisposition, IOTHUB_MODULE_CLIENT_LL_HANDLE, module_ll_handle, IOTHUB_MESSAGE_HANDLE, message, IOTHUBMESSAGE_DISPOSITION_RESULT, disposition);

#ifdef __cplusplus
}
#endif
Expand Down
Loading

0 comments on commit 2bffb4b

Please sign in to comment.