[Feature]add MT2731_MP2_MR2_SVN388 baseline version
Change-Id: Ief04314834b31e27effab435d3ca8ba33b499059
diff --git a/src/lynq/lib/liblynq-protcl/include/ftp/lynq_ftp.h b/src/lynq/lib/liblynq-protcl/include/ftp/lynq_ftp.h
new file mode 100644
index 0000000..12e3f09
--- /dev/null
+++ b/src/lynq/lib/liblynq-protcl/include/ftp/lynq_ftp.h
@@ -0,0 +1,171 @@
+#include<stdio.h>
+#include<sys/socket.h>
+#include<stdlib.h>
+#include<string.h>
+#include<strings.h>
+#include<unistd.h>
+#include<netinet/in.h>
+#include<netdb.h>
+#include<errno.h>
+#include<sys/types.h>
+#include<sys/stat.h>
+#include<fcntl.h>
+#include "liblog/liblog.h"
+#include "liblog/lynq_deflog.h"
+
+
+#define SERV_PORT 21
+#define MAXSIZE 1024
+//#define MAXBUF 1024
+#define FTP_FILE_TYPE_LEN 4
+#define FTP_MAX_ASCII_LEN 1024
+#define FTPSHMPATH "/"
+#define FTPSHMID 'K'
+
+
+int error;
+char errorbuf[10];
+
+#if 1
+/*log error info */
+
+#define FTP_NET_ERROR 31 //network
+#define FTP_DNS_ERROR 32 //DNS
+#define FTP_CONNECT_ERROR 33 //connect
+#define FTP_TIMEROUT 34 //time out
+#define FTP_SERVER_ERROR 35 //server
+#define FTP_OPERATION_NOT_ALLOW 36 //operation not allow
+#define FTP_REPLAY_ERROR 37 //replay
+#define FTP_USER_ERROR 38 //user
+#define FTP_PASSWORD_ERROR 39 //pwd
+#define FTP_TYPE_ERROR 40 //type
+#define FTP_REST_ERROR 41 //rest
+#define FTP_PASSIVE_ERROR 42 //passive
+#define FTP_ACTIVE_ERROR 43 //active
+#define FTP_OPERATE_ERROR 44 //operate
+#define FTP_UPLOAD_ERROR 45 //upload
+#define FTP_DOWNLOAD_ERROR 46 //download
+#define FTP_FILE_ACTION_ERROR 47 //action error
+#define FTP_MANUAL_QUIT 48 //manual quit
+#define FTP_ERROR_FLAG 49
+#define FTP_SOCK_ERROR 50 //socket error
+#define FTP_RCV_ERROR 51 //rcv error
+#define FTP_SEND_ERROR 52 //send error
+#define FTP_CLOSE_ERROR 53 //close error
+#define FTP_READ_ERROR 54 //read error
+#define FTP_WRITE_ERROR 55 //write error
+#define FTP_LS_ERROR 55 //ls error
+
+#endif
+
+#if 1
+/***********ftp return vauil******************/
+
+#define FTP_100_INIT_WAIT_LAST_CMD 100
+#define FTP_125_TRANSFER_START 125
+#define FTP_150_OPEN_DATA_CONNECT 150
+
+#define FTP_200_COMMAND_SUCCESSFUL 200
+#define FTP_213_FILE_STATUS 213
+#define FTP_220_SERVER_READY_FOR_NEW_USER 220
+#define FTP_221_CLOSE_CONTROL_CONNECT 221
+#define FTP_226_TRANSFER_COMPLATE 226
+#define FTP_227_ENTRY_PASV_MODE 227
+#define FTP_230_USER_LOGGED_IN 230
+#define FTP_250_REQUEST_FILE_ACTION_OK 250
+#define FTP_257_PATH_NAME 257
+
+
+#define FTP_331_NAMEOK_PASS_REQUIRE 331
+#define FTP_350_FILE_OPER_OK_WAIT_NEXT 350
+
+#define FTP_421_CONTROL_LINK_SHUTDOWN 421
+#define FTP_425_CANNOT_OPEN_DATA_CONNECT 425
+
+
+#define FTP_500_COMMAND_ERROR 500
+#define FTP_501_PARAMETER_ERROR 501
+#define FTP_502_COMMAND_NOT_IMP 502
+#define FTP_503_BAD_SEQUENCE_OF_CMD 503
+
+#define FTP_530_CANNOT_LOG_IN 530
+#define FTP_532_NEED_ACCOUNT 532
+#define FTP_534_CANNOT_CONN_CAUSE_SSL 534
+#define FTP_550_FILE_CANT_FIND 550
+
+
+#endif
+
+typedef struct ftp_socket_info
+{
+ int id;
+ int index;
+ char protocol[10];
+ int session;
+ char action[10];
+
+ int control_sockfd;
+ int portnum;//port num 1~65535
+ char is_pasv_mode[225];//0:initiative 1:pasv
+ char file_type[FTP_FILE_TYPE_LEN+1];//type "A" or "I"
+ char put_opt[FTP_FILE_TYPE_LEN+1];// "APPE", "STOU", "STOR"
+ int rest; //xu chuan wei zhi;
+ char sevname[FTP_MAX_ASCII_LEN + 1];//addr :192.168.1.89;
+ char username[FTP_MAX_ASCII_LEN + 1];//user
+ char pw[FTP_MAX_ASCII_LEN + 1];//password
+ char getfilename[FTP_MAX_ASCII_LEN + 1];//get file name;
+ char getfilename_path[FTP_MAX_ASCII_LEN + 1];//get file path;
+ char putfilename[FTP_MAX_ASCII_LEN + 1];//put file name;
+ char putfilename_path[FTP_MAX_ASCII_LEN + 1];//put file path;
+ //char conmd[255];
+ char dir[1024];
+ char del_mkr_filename[1024];
+ char respond[1024];
+ int flag;
+ int flag1;
+ int modify_thread;
+ int add_thread;
+}lynq_ftp_socker_info;
+
+
+int control_sockfd;
+int login_yes;
+int f;
+char putpathname[225];
+char hoster[255];
+struct sockaddr_in servaddr;
+char rbuf[1024],rbuf1[1024],wbuf[1024],wbuf1[1024];
+int ftpshm_id;
+lynq_ftp_socker_info *FTP;
+
+int uartfd;
+int usbfd;
+//char BUF[1024];
+
+
+
+int lynq_ftp_put(int sck,char *pUploadFileName_s);
+extern int lynq_ftp_login(lynq_ftp_socker_info *FTP);
+extern void zeromery(char *a,int len);
+extern char *itoa(int value, char *string, int radix);
+extern void lynq_ftp_pwd(int control_sockfd);
+extern int strtosrv(char *str);
+extern void lynq_ftp_get(int sck, char *pDownloadFileName, int session);
+extern void lynq_ftp_rest(int control_sockfd);
+extern int cliopen(char *hoster, int port);
+extern int lynq_ftp_download(lynq_ftp_socker_info* FTP);
+extern int lynq_ftp_up(lynq_ftp_socker_info* FTP);
+int lynq_ftp_ls(lynq_ftp_socker_info* FTP);
+void lynq_ftp_cd(lynq_ftp_socker_info* FTP);
+void lynq_ftp_creat_mkd(lynq_ftp_socker_info* FTP);
+void lynq_ftp_delete_mkd(lynq_ftp_socker_info* FTP);
+void ftp_list(int sockfd, int session);
+void lynq_ftp_quit(lynq_ftp_socker_info* FTP);
+void lynq_ftp_deletefile_mkd(lynq_ftp_socker_info* FTP);
+
+
+extern void init(lynq_ftp_socker_info* FTP);
+extern int lynq_ftpshm_create( void );
+extern lynq_ftp_socker_info *ftpshm_act(int shmid);
+extern void lynq_ftpshm_deact(lynq_ftp_socker_info *shm);
+extern void lynq_ftpshm_del(int shmid);
diff --git a/src/lynq/lib/liblynq-protcl/include/http/lynq_http.h b/src/lynq/lib/liblynq-protcl/include/http/lynq_http.h
new file mode 100644
index 0000000..455abc2
--- /dev/null
+++ b/src/lynq/lib/liblynq-protcl/include/http/lynq_http.h
@@ -0,0 +1,185 @@
+#ifndef _LYNQ_HTTP_H_
+#define _LYNQ_HTTP_H_
+
+#define HTTP_API
+
+
+#include "lynq_http_parser.h"
+#include "lynq_msgq.h"
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <pthread.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/select.h>
+#include <time.h>
+#include <ctype.h>
+#include <netdb.h>
+#include <strings.h>
+#include <openssl/ssl.h>
+#include <openssl/err.h>
+
+#ifdef _cplusplus
+extern "C" {
+#endif
+
+#define HTTP_INVALID_SOCKET -1
+#define HTTP_EINTR EINTR
+#define HTTP_EINPROGRESS EINPROGRESS
+#define HTTP_EWOULDBLOCK EWOULDBLOCK
+#define HTTP_EALREADY EALREADY
+
+#define free_member(member) if((member)) { free(member); (member) = NULL; }
+#define close_socket(fd) if(fd != HTTP_INVALID_SOCKET) { socket_close(fd); fd = HTTP_INVALID_SOCKET; }
+#define close_file(pf) if(pf != NULL) { fclose(pf); pf = NULL; }
+
+#define RECV_BUF_SIZE 4 * 1024
+
+#define socket_close close
+
+
+enum parser_statue_e { PARSERD_NONE = 0, PARSERD_FIELD, PARSERD_VALUE, PARSERD_BODY };
+
+enum proto_type_e { PROTO_HTTP = 0, PROTO_HTTPS };
+ typedef enum http_request_method_e
+ {
+ M_GET = 0,
+ M_POST,
+ M_HEAD
+ } http_request_method_e;
+
+ typedef enum http_connent_method_e
+ {
+ M_CLOSE = 0,
+ M_KEEP,
+ } http_connent_method_e;
+
+ enum http_error_e
+ {
+ ERR_OK = 0,
+
+ ERR_INVALID_PARAM,
+ ERR_OUT_MEMORY,
+ ERR_OPEN_FILE,
+ ERR_PARSE_REP,
+ ERR_URL_INVALID,
+ ERR_URL_INVALID_PROTO,
+ ERR_URL_INVALID_HOST,
+ ERR_URL_INVALID_IP,
+ ERR_URL_RESOLVED_HOST,
+ ERR_SOCKET_CREATE = 10,
+ ERR_SOCKET_SET_OPT,
+ ERR_SOCKET_NOBLOCKING,
+ ERR_SOCKET_CONNECT,
+ ERR_SOCKET_CONNECT_TIMEOUT,
+ ERR_SOCKET_SELECT,
+ ERR_SOCKET_WRITE,
+ ERR_SOCKET_READ,
+ ERR_SOCKET_TIMEOUT,
+ ERR_SOCKET_CLOSED,
+ ERR_SOCKET_GET_OPT = 20,
+ ERR_SSL_CREATE_CTX,
+ ERR_SSL_CREATE_SSL,
+ ERR_SSL_SET_FD,
+ ERR_SSL_CONNECT,
+ ERR_SSL_WRITE,
+ ERR_SSL_READ,
+ ERR_NOCERT,
+ ERR_MSG
+ };
+
+ struct lynq_http_client_t;
+ typedef struct lynq_http_client_t lynq_http_client_t;
+ typedef int (*data_recv_cb_t)( lynq_http_client_t* http, const char* data, int size, int total, void* user);
+
+ typedef int socket_t;
+
+
+ struct lynq_http_client_t
+ {
+ int index;
+
+ char protocol[10];
+ int session;
+
+ char action[10];
+ char *data;
+ char *section;
+ int request_method;
+ int connent_method;
+ int sockfd;
+ int modify_thread;
+ int add_thread;
+
+ FILE* pf;
+ char* filename;
+ char* body;
+ char* redirect_url;
+ char* header_field;
+ char* header_value;
+
+ char* post_data;
+ char* url;
+ int post_data_len;
+ struct http_parser_url u;
+ char* user_header;
+ int user_header_len;
+
+ http_parser_settings parser_setting;
+ struct http_parser parser;
+
+
+ char* user;
+ data_recv_cb_t recv_cb;
+
+ unsigned long body_len;
+ unsigned long content_length;
+
+ enum http_request_method_e method;
+ enum http_connent_method_e conn_method;
+ enum proto_type_e proto_type;
+
+ unsigned short field_size;
+ unsigned short value_size;
+ unsigned short cur_field_size;
+ unsigned short cur_value_size;
+ SSL_CTX *ctx;
+ SSL *ssl;
+
+ socket_t fd;
+ int timeout;
+
+ short status_code;
+ char parser_statue;
+ char error_code;
+ unsigned cancel : 1;
+ unsigned exit : 1;
+ unsigned download : 1;
+ unsigned redirect : 1;
+};
+
+
+int lynq_http_init(void);
+lynq_http_client_t* lynq_http_new();
+void lynq_http_destroy(lynq_http_client_t* http);
+int lynq_http_get_error_code(lynq_http_client_t* http);
+const char* lynq_http_sync_request(lynq_http_client_t* http, const char* url, http_request_method_e m, http_connent_method_e c_m);
+const char* lynq_http_sync_post_request(lynq_http_client_t* http, char* url, char* post_data, http_request_method_e m, http_connent_method_e c_m);
+int lynq_http_sync_download_file(lynq_http_client_t* http, char* url, char* filepath, http_request_method_e m, http_connent_method_e c_m);
+int lynq_http_set_data_recv_cb(lynq_http_client_t* http, data_recv_cb_t cb, void* user);
+int lynq_http_exit(lynq_http_client_t* http);
+int lynq_http_data_send(char *data);
+void *lynq_http_write_head_data(lynq_http_client_t* http);
+#ifdef _cplusplus
+}
+#endif
+#endif
+
diff --git a/src/lynq/lib/liblynq-protcl/include/http/lynq_http_parser.h b/src/lynq/lib/liblynq-protcl/include/http/lynq_http_parser.h
new file mode 100644
index 0000000..99d9f20
--- /dev/null
+++ b/src/lynq/lib/liblynq-protcl/include/http/lynq_http_parser.h
@@ -0,0 +1,220 @@
+#ifndef _LYNQ_HTTP_PARSER_H_
+#define _LYNQ_HTTP_PARSER_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define HTTP_PARSER_VERSION_MAJOR 2
+#define HTTP_PARSER_VERSION_MINOR 5
+#define HTTP_PARSER_VERSION_PATCH 0
+#include <stddef.h>
+#include <stdint.h>
+#include "liblog/liblog.h"
+#include "liblog/lynq_deflog.h"
+
+
+
+#ifndef HTTP_PARSER_STRICT
+# define HTTP_PARSER_STRICT 1
+#endif
+
+#ifndef HTTP_MAX_HEADER_SIZE
+# define HTTP_MAX_HEADER_SIZE (80*1024)
+#endif
+
+ typedef struct http_parser http_parser;
+ typedef struct http_parser_settings http_parser_settings;
+
+ typedef int (*http_data_cb) (http_parser*, const char *at, size_t length);
+ typedef int (*http_cb) (http_parser*);
+
+
+ /* Request Methods */
+#define HTTP_METHOD_MAP(XX) \
+ XX(0, DELETE, DELETE) \
+ XX(1, GET, GET) \
+ XX(2, HEAD, HEAD) \
+ XX(3, POST, POST) \
+ XX(4, PUT, PUT) \
+ /* pathological */ \
+ XX(5, CONNECT, CONNECT) \
+ XX(6, OPTIONS, OPTIONS) \
+ XX(7, TRACE, TRACE) \
+ /* WebDAV */ \
+ XX(8, COPY, COPY) \
+ XX(9, LOCK, LOCK) \
+ XX(10, MKCOL, MKCOL) \
+ XX(11, MOVE, MOVE) \
+ XX(12, PROPFIND, PROPFIND) \
+ XX(13, PROPPATCH, PROPPATCH) \
+ XX(14, SEARCH, SEARCH) \
+ XX(15, UNLOCK, UNLOCK) \
+ XX(16, BIND, BIND) \
+ XX(17, REBIND, REBIND) \
+ XX(18, UNBIND, UNBIND) \
+ XX(19, ACL, ACL) \
+ /* subversion */ \
+ XX(20, REPORT, REPORT) \
+ XX(21, MKACTIVITY, MKACTIVITY) \
+ XX(22, CHECKOUT, CHECKOUT) \
+ XX(23, MERGE, MERGE) \
+ /* upnp */ \
+ XX(24, MSEARCH, M-SEARCH) \
+ XX(25, NOTIFY, NOTIFY) \
+ XX(26, SUBSCRIBE, SUBSCRIBE) \
+ XX(27, UNSUBSCRIBE, UNSUBSCRIBE) \
+ /* RFC-5789 */ \
+ XX(28, PATCH, PATCH) \
+ XX(29, PURGE, PURGE) \
+ /* CalDAV */ \
+ XX(30, MKCALENDAR, MKCALENDAR) \
+
+ enum http_method
+ {
+#define XX(num, name, string) HTTP_##name = num,
+ HTTP_METHOD_MAP(XX)
+#undef XX
+ };
+
+
+ enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH };
+ enum flags
+ { F_CHUNKED = 1 << 0
+ , F_CONNECTION_KEEP_ALIVE = 1 << 1
+ , F_CONNECTION_CLOSE = 1 << 2
+ , F_CONNECTION_UPGRADE = 1 << 3
+ , F_TRAILING = 1 << 4
+ , F_UPGRADE = 1 << 5
+ , F_SKIPBODY = 1 << 6
+ };
+
+#define HTTP_ERRNO_MAP(XX) \
+ /* No error */ \
+ XX(OK, "success") \
+ \
+ /* Callback-related errors */ \
+ XX(CB_message_begin, "the on_message_begin callback failed") \
+ XX(CB_url, "the on_url callback failed") \
+ XX(CB_header_field, "the on_header_field callback failed") \
+ XX(CB_header_value, "the on_header_value callback failed") \
+ XX(CB_headers_complete, "the on_headers_complete callback failed") \
+ XX(CB_body, "the on_body callback failed") \
+ XX(CB_message_complete, "the on_message_complete callback failed") \
+ XX(CB_status, "the on_status callback failed") \
+ XX(CB_chunk_header, "the on_chunk_header callback failed") \
+ XX(CB_chunk_complete, "the on_chunk_complete callback failed") \
+ \
+ /* Parsing-related errors */ \
+ XX(INVALID_EOF_STATE, "stream ended at an unexpected time") \
+ XX(HEADER_OVERFLOW, \
+ "too many header bytes seen; overflow detected") \
+ XX(CLOSED_CONNECTION, \
+ "data received after completed connection: close message") \
+ XX(INVALID_VERSION, "invalid HTTP version") \
+ XX(INVALID_STATUS, "invalid HTTP status code") \
+ XX(INVALID_METHOD, "invalid HTTP method") \
+ XX(INVALID_URL, "invalid URL") \
+ XX(INVALID_HOST, "invalid host") \
+ XX(INVALID_PORT, "invalid port") \
+ XX(INVALID_PATH, "invalid path") \
+ XX(INVALID_QUERY_STRING, "invalid query string") \
+ XX(INVALID_FRAGMENT, "invalid fragment") \
+ XX(LF_EXPECTED, "LF character expected") \
+ XX(INVALID_HEADER_TOKEN, "invalid character in header") \
+ XX(INVALID_CONTENT_LENGTH, \
+ "invalid character in content-length header") \
+ XX(INVALID_CHUNK_SIZE, \
+ "invalid character in chunk size header") \
+ XX(INVALID_CONSTANT, "invalid constant string") \
+ XX(INVALID_INTERNAL_STATE, "encountered unexpected internal state")\
+ XX(STRICT, "strict mode assertion failed") \
+ XX(PAUSED, "parser is paused") \
+ XX(UNKNOWN, "an unknown error occurred")
+
+#define HTTP_ERRNO_GEN(n, s) HPE_##n,
+ enum http_errno {
+ HTTP_ERRNO_MAP(HTTP_ERRNO_GEN)
+ };
+#undef HTTP_ERRNO_GEN
+
+#define HTTP_PARSER_ERRNO(p) ((enum http_errno) (p)->http_errno)
+
+ struct http_parser {
+ unsigned int type : 2; /* enum http_parser_type */
+ unsigned int flags : 7; /* F_* values from 'flags' enum; semi-public */
+ unsigned int state : 7; /* enum state from http_parser.c */
+ unsigned int header_state : 8; /* enum header_state from http_parser.c */
+ unsigned int index : 8; /* index into current matcher */
+
+ uint32_t nread; /* # bytes read in various scenarios */
+ uint64_t content_length; /* # bytes in body (0 if no Content-Length header) */
+
+ unsigned short http_major;
+ unsigned short http_minor;
+ unsigned int status_code : 16;
+ unsigned int method : 8;
+ unsigned int http_errno : 7;
+ unsigned int upgrade : 1;
+ void *data;
+ };
+
+
+ struct http_parser_settings {
+ http_cb on_message_begin;
+ http_data_cb on_url;
+ http_data_cb on_status;
+ http_data_cb on_header_field;
+ http_data_cb on_header_value;
+ http_cb on_headers_complete;
+ http_data_cb on_body;
+ http_cb on_message_complete;
+ http_cb on_chunk_header;
+ http_cb on_chunk_complete;
+ };
+
+
+ enum http_parser_url_fields
+ {
+ UF_SCHEMA = 0,
+ UF_HOST = 1,
+ UF_PORT = 2,
+ UF_PATH = 3,
+ UF_QUERY = 4,
+ UF_FRAGMENT = 5,
+ UF_USERINFO = 6,
+ UF_MAX = 7,
+ };
+
+ struct http_parser_url {
+ uint16_t field_set; /* Bitmask of (1 << UF_*) values */
+ uint16_t port; /* Converted UF_PORT string */
+
+ struct {
+ uint16_t off; /* Offset into buffer in which field starts */
+ uint16_t len; /* Length of run in buffer */
+ } field_data[UF_MAX];
+ };
+
+ unsigned long http_parser_version(void);
+ void http_parser_init(http_parser *parser, enum http_parser_type type);
+ void http_parser_settings_init(http_parser_settings *settings);
+ size_t http_parser_execute(http_parser *parser,
+ const http_parser_settings *settings,
+ const char *data,
+ size_t len);
+
+ int http_should_keep_alive(const http_parser *parser);
+ const char *http_method_str(enum http_method m);
+ const char *http_errno_name(enum http_errno err);
+ const char *http_errno_description(enum http_errno err);
+ int http_parser_parse_url(const char *buf, size_t buflen,
+ int is_connect,
+ struct http_parser_url *u);
+ void http_parser_pause(http_parser *parser, int paused);
+ int http_body_is_final(const http_parser *parser);
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/src/lynq/lib/liblynq-protcl/include/http/lynq_msgq.h b/src/lynq/lib/liblynq-protcl/include/http/lynq_msgq.h
new file mode 100644
index 0000000..784e077
--- /dev/null
+++ b/src/lynq/lib/liblynq-protcl/include/http/lynq_msgq.h
@@ -0,0 +1,19 @@
+#ifndef _LYNQ_MSGQ_H_
+#define _LYNQ_MSGQ_H_
+
+#include <sys/msg.h>
+#include <sys/ipc.h>
+#include "liblog/liblog.h"
+#include "liblog/lynq_deflog.h"
+#include "http/lynq_http.h"
+
+struct mymesg{
+ long int mtype;
+ char mtext[512];
+};
+
+int lynq_msgq_init(char *pathname, int create);
+int lynq_msgq_send(int queueId, struct mymesg *ckxmsg);
+
+#endif
+
diff --git a/src/lynq/lib/liblynq-protcl/include/lynq_mqtt/lynq_mqtt.h b/src/lynq/lib/liblynq-protcl/include/lynq_mqtt/lynq_mqtt.h
new file mode 100644
index 0000000..0422faa
--- /dev/null
+++ b/src/lynq/lib/liblynq-protcl/include/lynq_mqtt/lynq_mqtt.h
@@ -0,0 +1,70 @@
+#ifndef __LYNQ_MQTT_H__
+#define __LYNQ_MQTT_H__
+#include <mosquitto.h>
+
+
+struct mqtt_set_will{
+ int will_flag;
+ char *will_topic;
+ int will_payloadlen;
+ char *will_payload;
+ int will_qos;
+ bool retain;
+};
+
+struct mqtt_set_parament
+{
+ char *protocol;
+ int session;
+ char *action;
+ int modify_thread;
+ int add_thread;
+
+ char *usrname; //服务端用户名
+ char *pwd; //服务端密码
+ char *ip_addr;
+ int port;
+ int keep_time;
+
+ int subscribe_qos;
+ int publish_qos;
+
+ char *subscribe_topic;
+ char *unsubscribe_topic; //lt add @2021.7.13 for unsubscribe topic
+
+ char *publish_topic;
+ char *publish_data;
+
+ char *client_id;
+ bool clean_session;
+
+ struct mqtt_set_will set_will;
+
+};
+
+
+#define NO_ERROR 0
+#define CREATE_LIENT_ERROR 1
+#define USER_PWD_ERROR 2
+#define CONNECT_FAIL 3
+#define CREATE_LOOP_FAIL 4
+#define MQTT_DISCONNECT_FAIL 5
+#define MQTT_CONNECT_FAIL 6
+
+
+int lynq_mqtt_connect_init(struct mqtt_set_parament mqtt_message);
+void lynq_mosquitto_set_connect_callback(void (*connect_callback)(struct mosquitto *mosq, void *userdata, int result));
+void lynq_mosquitto_set_message_callback(void (*message_callback)(struct mosquitto *mosq, void *userdata, const struct mosquitto_message *message));
+void lynq_mosquitto_set_subscribe_callback(void (*subscribe_callback)(struct mosquitto *mosq, void *userdata, int mid, int qos_count, const int *granted_qos));
+void lynq_mosquitto_set_disconnect_callback( void (*disconnect_callback)( struct mosquitto *mosq,void *obj, int rc));
+void lynq_mosquitto_set_publish_callback(void (*on_publish)(struct mosquitto *mosq, void *obj, int mid));
+
+void lynq_mosquitto_publish_message(char *pub_topic,int pub_buf_len,char *pub_buf,int qos); //发布
+void lynq_mosquitto_subscribe_message(char *sub_topic,int sub_qos); // 订阅
+void lynq_mosquitto_disconnect(void); //断开
+
+int lynq_mqtt_login(struct mqtt_set_parament mqtt_message);
+void lynq_mosquitto_subscribe_message(char *sub_topic,int sub_qos);
+void lynq_mosquitto_publish_message(char *pub_topic,int pub_buf_len,char *pub_buf,int qos);
+void lynq_mosquitto_unsubscribe_message(char *unsub_topic);
+#endif //__LYNQ_MQTT_H__