Added way to include connection header
This commit is contained in:
Родитель
6136552a41
Коммит
c03ac9799a
|
@ -29,7 +29,8 @@ typedef enum ARGUEMENT_TYPE_TAG
|
|||
ARGUEMENT_TYPE_CONNECTION_STRING,
|
||||
ARGUEMENT_TYPE_SCOPE_ID,
|
||||
ARGUEMENT_TYPE_DEVICE_ID,
|
||||
ARGUEMENT_TYPE_DEVICE_KEY
|
||||
ARGUEMENT_TYPE_DEVICE_KEY,
|
||||
ARGUEMENT_TYPE_EXCLUDE_CONN_HEADER
|
||||
} ARGUEMENT_TYPE;
|
||||
|
||||
typedef struct MEM_ANALYTIC_INFO_TAG
|
||||
|
@ -37,6 +38,7 @@ typedef struct MEM_ANALYTIC_INFO_TAG
|
|||
int create_device;
|
||||
const char* connection_string;
|
||||
IOTHUB_DEVICE device_info;
|
||||
int exclude_conn_header;
|
||||
} MEM_ANALYTIC_INFO;
|
||||
|
||||
static int initialize_sdk()
|
||||
|
@ -210,7 +212,7 @@ static int construct_dev_conn_string(MEM_ANALYTIC_INFO* mem_info, CONNECTION_INF
|
|||
|
||||
static int parse_command_line(int argc, char* argv[], MEM_ANALYTIC_INFO* mem_info, CONNECTION_INFO* conn_info)
|
||||
{
|
||||
// -c "[connection_string]" -d [device_name] -k [device_key]
|
||||
// -c "[connection_string]" -d [device_name] -k [device_key] -x -s [scope_id]
|
||||
int result = 0;
|
||||
ARGUEMENT_TYPE argument_type = ARGUEMENT_TYPE_UNKNOWN;
|
||||
|
||||
|
@ -234,6 +236,11 @@ static int parse_command_line(int argc, char* argv[], MEM_ANALYTIC_INFO* mem_inf
|
|||
{
|
||||
argument_type = ARGUEMENT_TYPE_SCOPE_ID;
|
||||
}
|
||||
else if (argv[index][0] == '-' && (argv[index][1] == 'x' || argv[index][1] == 'X'))
|
||||
{
|
||||
argument_type = ARGUEMENT_TYPE_EXCLUDE_CONN_HEADER;
|
||||
mem_info->exclude_conn_header = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -271,17 +278,17 @@ static int parse_command_line(int argc, char* argv[], MEM_ANALYTIC_INFO* mem_inf
|
|||
return result;
|
||||
}
|
||||
|
||||
static void send_network_info(CONNECTION_INFO* conn_info, REPORT_HANDLE report_handle)
|
||||
static void send_network_info(CONNECTION_INFO* conn_info, REPORT_HANDLE report_handle, int exclude_conn_header)
|
||||
{
|
||||
// MQTT Sending
|
||||
#ifdef USE_MQTT
|
||||
initiate_lower_level_operation(conn_info, report_handle, PROTOCOL_MQTT, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
|
||||
initiate_lower_level_operation(conn_info, report_handle, PROTOCOL_MQTT_WS, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
|
||||
initiate_lower_level_operation(conn_info, report_handle, PROTOCOL_MQTT, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY, exclude_conn_header);
|
||||
initiate_lower_level_operation(conn_info, report_handle, PROTOCOL_MQTT_WS, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY, exclude_conn_header);
|
||||
#endif
|
||||
// AMQP Sending
|
||||
#ifdef USE_AMQP
|
||||
initiate_lower_level_operation(conn_info, report_handle, PROTOCOL_AMQP, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
|
||||
initiate_lower_level_operation(conn_info, report_handle, PROTOCOL_AMQP_WS, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY);
|
||||
initiate_lower_level_operation(conn_info, report_handle, PROTOCOL_AMQP, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY, exclude_conn_header);
|
||||
initiate_lower_level_operation(conn_info, report_handle, PROTOCOL_AMQP_WS, MESSAGES_TO_USE, USE_MSG_BYTE_ARRAY, exclude_conn_header);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -319,7 +326,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
else
|
||||
{
|
||||
send_network_info(&conn_info, report_handle);
|
||||
send_network_info(&conn_info, report_handle, mem_info.exclude_conn_header);
|
||||
|
||||
result = 0;
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ typedef struct IOTHUB_CLIENT_SAMPLE_INFO_TAG
|
|||
{
|
||||
int connected;
|
||||
int stop_running;
|
||||
int exclude_conn_header;
|
||||
} IOTHUB_CLIENT_INFO;
|
||||
|
||||
static IOTHUB_CLIENT_TRANSPORT_PROVIDER initialize(MEM_ANALYSIS_INFO* iot_mem_info, PROTOCOL_TYPE protocol, size_t num_msgs_to_send)
|
||||
|
@ -83,7 +84,10 @@ static void iothub_connection_status(IOTHUB_CLIENT_CONNECTION_STATUS result, IOT
|
|||
{
|
||||
iothub_info->connected = 1;
|
||||
// Reset the Metrics so to not get the connection preamble included, just the sends
|
||||
gbnetwork_resetMetrics();
|
||||
if (iothub_info->exclude_conn_header == 0)
|
||||
{
|
||||
gbnetwork_resetMetrics();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -106,7 +110,7 @@ static void send_confirm_callback(IOTHUB_CLIENT_CONFIRMATION_RESULT result, void
|
|||
}
|
||||
}
|
||||
|
||||
int initiate_lower_level_operation(const CONNECTION_INFO* conn_info, REPORT_HANDLE report_handle, PROTOCOL_TYPE protocol, size_t num_msgs_to_send, bool use_byte_array_msg)
|
||||
int initiate_lower_level_operation(const CONNECTION_INFO* conn_info, REPORT_HANDLE report_handle, PROTOCOL_TYPE protocol, size_t num_msgs_to_send, bool use_byte_array_msg, int exclude_conn_header)
|
||||
{
|
||||
int result;
|
||||
if (protocol == PROTOCOL_HTTP)
|
||||
|
@ -151,6 +155,7 @@ int initiate_lower_level_operation(const CONNECTION_INFO* conn_info, REPORT_HAND
|
|||
size_t msg_count = 0;
|
||||
iothub_info.stop_running = 0;
|
||||
iothub_info.connected = 0;
|
||||
iothub_info.exclude_conn_header = exclude_conn_header;
|
||||
|
||||
if (protocol == PROTOCOL_HTTP)
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@ extern "C" {
|
|||
|
||||
#include "mem_reporter.h"
|
||||
|
||||
extern int initiate_lower_level_operation(const CONNECTION_INFO* conn_info, REPORT_HANDLE report_handle, PROTOCOL_TYPE protocol, size_t num_msgs_to_send, bool use_byte_array_msg);
|
||||
extern int initiate_lower_level_operation(const CONNECTION_INFO* conn_info, REPORT_HANDLE report_handle, PROTOCOL_TYPE protocol, size_t num_msgs_to_send, bool use_byte_array_msg, int exclude_conn_header);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче