#ifndef __LINKKIT_GATEWAY_COMMON_H
#define __LINKKIT_GATEWAY_COMMON_H

/***************HEADER FILES****************/
#include <string.h>
#include <syslog.h>
#include "ipc_session.h"
#include "lnxall_list.h"
#include "mosquitto.h"
#include "dy_utils/dy_common.h"
#include "dy_utils/dy_ds.h"
#include "dy_utils/kv_array.h"
#include "dy_utils/dy_ipc.h"

#include "azure_macro_utils/macro_utils.h"
#include "azure_c_shared_utility/threadapi.h"
#include "azure_c_shared_utility/platform.h"
#include "iothub_device_client.h"
#include "iothub_client_options.h"
#include "iothub.h"
#include "iothub_message.h"
#include "parson.h"

#include "iothubtransportmqtt.h"
//#include "certs.h"


/******************************************/
typedef struct
{
	char sn[SN_MAX_LEN];          ///<设备SN
	int connected;
	char connectionString[192]; ///<Azure IoT connectionString
	IOTHUB_DEVICE_CLIENT_HANDLE iotHubClientHandle;
	IOTHUB_CLIENT_TRANSPORT_PROVIDER protocol;
}azure_dev_info_t;

typedef struct
{
    list_t list;
	azure_dev_info_t azure_dev;
}azure_info_list_t;

typedef struct
{
    list_t list;
	int type;
    ipc_msg_t mqtt;
}data_list_t;

typedef struct _azure_var_t
{
    list_t node_list;
	
	int data_flag;
	int data_cnt;
	list_t data_list;
	int link_node_cnt;

	int get_msg_timer;
	int mqtt_list_cnt;
	list_t send_mqtt_list;
	char response_event[128];
	
	ipc_session_t *session; //内部broker的MQTT client，用于进程间通信
    nodes_cfg_table_t *nodes_cfg_table; //节点信息
    template_table_t *template_table; //模板信息
    char sn_str[SN_MAX_LEN];
    char proc_name[PROGRAM_NAME_LEN];
    kv_array_t identifier_backup;
}azure_var_t;

typedef struct {
    char *dy_sn;
    char *azure_sn;
}azure_iot_sn_map_t;


#endif /* __LINKKIT_GATEWAY_COMMON_H */
