Microsoft Azure IoTHub client AMQP transport

Dependents:   sht15_remote_monitoring RobotArmDemo iothub_client_sample_amqp iothub_client_sample_amqp ... more

This library implements the AMQP transport for Microsoft Azure IoTHub client. The code is replicated from https://github.com/Azure/azure-iot-sdks

Committer:
AzureIoTClient
Date:
Thu Oct 04 09:14:47 2018 -0700
Revision:
57:56ac1346c70d
Parent:
54:830550fef7ea
1.2.10

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AzureIoTClient 36:f78f9a56869e 1 // Copyright (c) Microsoft. All rights reserved.
AzureIoTClient 36:f78f9a56869e 2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
AzureIoTClient 36:f78f9a56869e 3
AzureIoTClient 36:f78f9a56869e 4 #ifndef IOTHUBTRANSPORT_AMQP_TELEMETRY_MESSENGER
AzureIoTClient 36:f78f9a56869e 5 #define IOTHUBTRANSPORT_AMQP_TELEMETRY_MESSENGER
AzureIoTClient 36:f78f9a56869e 6
AzureIoTClient 36:f78f9a56869e 7 #include "azure_c_shared_utility/umock_c_prod.h"
AzureIoTClient 36:f78f9a56869e 8 #include "azure_c_shared_utility/optionhandler.h"
AzureIoTClient 36:f78f9a56869e 9 #include "azure_uamqp_c/session.h"
AzureIoTClient 50:f3a92c6c6534 10
AzureIoTClient 50:f3a92c6c6534 11 #include "azure_uamqp_c/amqp_definitions_sequence_no.h"
AzureIoTClient 50:f3a92c6c6534 12 #include "azure_uamqp_c/amqp_definitions_delivery_number.h"
AzureIoTClient 50:f3a92c6c6534 13
AzureIoTClient 36:f78f9a56869e 14 #include "iothub_client_private.h"
AzureIoTClient 36:f78f9a56869e 15
AzureIoTClient 36:f78f9a56869e 16 #ifdef __cplusplus
AzureIoTClient 36:f78f9a56869e 17 extern "C"
AzureIoTClient 36:f78f9a56869e 18 {
AzureIoTClient 36:f78f9a56869e 19 #endif
AzureIoTClient 36:f78f9a56869e 20
AzureIoTClient 36:f78f9a56869e 21
AzureIoTClient 51:269e65571b39 22 static const char* TELEMETRY_MESSENGER_OPTION_EVENT_SEND_TIMEOUT_SECS = "telemetry_event_send_timeout_secs";
AzureIoTClient 51:269e65571b39 23 static const char* TELEMETRY_MESSENGER_OPTION_SAVED_OPTIONS = "saved_telemetry_messenger_options";
AzureIoTClient 36:f78f9a56869e 24
AzureIoTClient 36:f78f9a56869e 25 typedef struct TELEMETRY_MESSENGER_INSTANCE* TELEMETRY_MESSENGER_HANDLE;
AzureIoTClient 36:f78f9a56869e 26
AzureIoTClient 36:f78f9a56869e 27 typedef enum TELEMETRY_MESSENGER_SEND_STATUS_TAG
AzureIoTClient 36:f78f9a56869e 28 {
AzureIoTClient 54:830550fef7ea 29 TELEMETRY_MESSENGER_SEND_STATUS_IDLE,
AzureIoTClient 54:830550fef7ea 30 TELEMETRY_MESSENGER_SEND_STATUS_BUSY
AzureIoTClient 36:f78f9a56869e 31 } TELEMETRY_MESSENGER_SEND_STATUS;
AzureIoTClient 36:f78f9a56869e 32
AzureIoTClient 36:f78f9a56869e 33 typedef enum TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT_TAG
AzureIoTClient 36:f78f9a56869e 34 {
AzureIoTClient 54:830550fef7ea 35 TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT_OK,
AzureIoTClient 54:830550fef7ea 36 TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT_ERROR_CANNOT_PARSE,
AzureIoTClient 54:830550fef7ea 37 TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT_ERROR_FAIL_SENDING,
AzureIoTClient 54:830550fef7ea 38 TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT_ERROR_TIMEOUT,
AzureIoTClient 54:830550fef7ea 39 TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT_MESSENGER_DESTROYED
AzureIoTClient 36:f78f9a56869e 40 } TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT;
AzureIoTClient 36:f78f9a56869e 41
AzureIoTClient 36:f78f9a56869e 42 typedef enum TELEMETRY_MESSENGER_DISPOSITION_RESULT_TAG
AzureIoTClient 36:f78f9a56869e 43 {
AzureIoTClient 54:830550fef7ea 44 TELEMETRY_MESSENGER_DISPOSITION_RESULT_NONE,
AzureIoTClient 54:830550fef7ea 45 TELEMETRY_MESSENGER_DISPOSITION_RESULT_ACCEPTED,
AzureIoTClient 54:830550fef7ea 46 TELEMETRY_MESSENGER_DISPOSITION_RESULT_REJECTED,
AzureIoTClient 54:830550fef7ea 47 TELEMETRY_MESSENGER_DISPOSITION_RESULT_RELEASED
AzureIoTClient 36:f78f9a56869e 48 } TELEMETRY_MESSENGER_DISPOSITION_RESULT;
AzureIoTClient 36:f78f9a56869e 49
AzureIoTClient 36:f78f9a56869e 50 typedef enum TELEMETRY_MESSENGER_STATE_TAG
AzureIoTClient 36:f78f9a56869e 51 {
AzureIoTClient 54:830550fef7ea 52 TELEMETRY_MESSENGER_STATE_STARTING,
AzureIoTClient 54:830550fef7ea 53 TELEMETRY_MESSENGER_STATE_STARTED,
AzureIoTClient 54:830550fef7ea 54 TELEMETRY_MESSENGER_STATE_STOPPING,
AzureIoTClient 54:830550fef7ea 55 TELEMETRY_MESSENGER_STATE_STOPPED,
AzureIoTClient 54:830550fef7ea 56 TELEMETRY_MESSENGER_STATE_ERROR
AzureIoTClient 36:f78f9a56869e 57 } TELEMETRY_MESSENGER_STATE;
AzureIoTClient 36:f78f9a56869e 58
AzureIoTClient 36:f78f9a56869e 59 typedef struct TELEMETRY_MESSENGER_MESSAGE_DISPOSITION_INFO_TAG
AzureIoTClient 36:f78f9a56869e 60 {
AzureIoTClient 54:830550fef7ea 61 delivery_number message_id;
AzureIoTClient 54:830550fef7ea 62 char* source;
AzureIoTClient 36:f78f9a56869e 63 } TELEMETRY_MESSENGER_MESSAGE_DISPOSITION_INFO;
AzureIoTClient 36:f78f9a56869e 64
AzureIoTClient 36:f78f9a56869e 65 typedef void(*ON_TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE)(IOTHUB_MESSAGE_LIST* iothub_message_list, TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE_RESULT messenger_event_send_complete_result, void* context);
AzureIoTClient 36:f78f9a56869e 66 typedef void(*ON_TELEMETRY_MESSENGER_STATE_CHANGED_CALLBACK)(void* context, TELEMETRY_MESSENGER_STATE previous_state, TELEMETRY_MESSENGER_STATE new_state);
AzureIoTClient 36:f78f9a56869e 67 typedef TELEMETRY_MESSENGER_DISPOSITION_RESULT(*ON_TELEMETRY_MESSENGER_MESSAGE_RECEIVED)(IOTHUB_MESSAGE_HANDLE message, TELEMETRY_MESSENGER_MESSAGE_DISPOSITION_INFO* disposition_info, void* context);
AzureIoTClient 36:f78f9a56869e 68
AzureIoTClient 36:f78f9a56869e 69 typedef struct TELEMETRY_MESSENGER_CONFIG_TAG
AzureIoTClient 36:f78f9a56869e 70 {
AzureIoTClient 54:830550fef7ea 71 const char* device_id;
AzureIoTClient 54:830550fef7ea 72 const char* module_id;
AzureIoTClient 54:830550fef7ea 73 char* iothub_host_fqdn;
AzureIoTClient 54:830550fef7ea 74 ON_TELEMETRY_MESSENGER_STATE_CHANGED_CALLBACK on_state_changed_callback;
AzureIoTClient 54:830550fef7ea 75 void* on_state_changed_context;
AzureIoTClient 36:f78f9a56869e 76 } TELEMETRY_MESSENGER_CONFIG;
AzureIoTClient 36:f78f9a56869e 77
AzureIoTClient 41:71c01aa3df1a 78 #define AMQP_BATCHING_RESERVE_SIZE (1024)
AzureIoTClient 41:71c01aa3df1a 79
AzureIoTClient 36:f78f9a56869e 80 MOCKABLE_FUNCTION(, TELEMETRY_MESSENGER_HANDLE, telemetry_messenger_create, const TELEMETRY_MESSENGER_CONFIG*, messenger_config, const char*, product_info);
AzureIoTClient 36:f78f9a56869e 81 MOCKABLE_FUNCTION(, int, telemetry_messenger_send_async, TELEMETRY_MESSENGER_HANDLE, messenger_handle, IOTHUB_MESSAGE_LIST*, message, ON_TELEMETRY_MESSENGER_EVENT_SEND_COMPLETE, on_messenger_event_send_complete_callback, void*, context);
AzureIoTClient 36:f78f9a56869e 82 MOCKABLE_FUNCTION(, int, telemetry_messenger_subscribe_for_messages, TELEMETRY_MESSENGER_HANDLE, messenger_handle, ON_TELEMETRY_MESSENGER_MESSAGE_RECEIVED, on_message_received_callback, void*, context);
AzureIoTClient 36:f78f9a56869e 83 MOCKABLE_FUNCTION(, int, telemetry_messenger_unsubscribe_for_messages, TELEMETRY_MESSENGER_HANDLE, messenger_handle);
AzureIoTClient 36:f78f9a56869e 84 MOCKABLE_FUNCTION(, int, telemetry_messenger_send_message_disposition, TELEMETRY_MESSENGER_HANDLE, messenger_handle, TELEMETRY_MESSENGER_MESSAGE_DISPOSITION_INFO*, disposition_info, TELEMETRY_MESSENGER_DISPOSITION_RESULT, disposition_result);
AzureIoTClient 36:f78f9a56869e 85 MOCKABLE_FUNCTION(, int, telemetry_messenger_get_send_status, TELEMETRY_MESSENGER_HANDLE, messenger_handle, TELEMETRY_MESSENGER_SEND_STATUS*, send_status);
AzureIoTClient 36:f78f9a56869e 86 MOCKABLE_FUNCTION(, int, telemetry_messenger_start, TELEMETRY_MESSENGER_HANDLE, messenger_handle, SESSION_HANDLE, session_handle);
AzureIoTClient 36:f78f9a56869e 87 MOCKABLE_FUNCTION(, int, telemetry_messenger_stop, TELEMETRY_MESSENGER_HANDLE, messenger_handle);
AzureIoTClient 36:f78f9a56869e 88 MOCKABLE_FUNCTION(, void, telemetry_messenger_do_work, TELEMETRY_MESSENGER_HANDLE, messenger_handle);
AzureIoTClient 36:f78f9a56869e 89 MOCKABLE_FUNCTION(, void, telemetry_messenger_destroy, TELEMETRY_MESSENGER_HANDLE, messenger_handle);
AzureIoTClient 36:f78f9a56869e 90 MOCKABLE_FUNCTION(, int, telemetry_messenger_set_option, TELEMETRY_MESSENGER_HANDLE, messenger_handle, const char*, name, void*, value);
AzureIoTClient 36:f78f9a56869e 91 MOCKABLE_FUNCTION(, OPTIONHANDLER_HANDLE, telemetry_messenger_retrieve_options, TELEMETRY_MESSENGER_HANDLE, messenger_handle);
AzureIoTClient 36:f78f9a56869e 92
AzureIoTClient 36:f78f9a56869e 93
AzureIoTClient 36:f78f9a56869e 94 #ifdef __cplusplus
AzureIoTClient 36:f78f9a56869e 95 }
AzureIoTClient 36:f78f9a56869e 96 #endif
AzureIoTClient 36:f78f9a56869e 97
AzureIoTClient 36:f78f9a56869e 98 #endif /*IOTHUBTRANSPORT_AMQP_TELEMETRY_MESSENGER*/