MQTT Server: D:/my_data/GIT/network_apps/netapps/mqtt/server/server_pkts.h Source File

MQTT Server Package

MQTT Server 1.0.0
D:/my_data/GIT/network_apps/netapps/mqtt/server/server_pkts.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 *
00003 *   Copyright (C) 2014 Texas Instruments Incorporated
00004 *
00005 *   All rights reserved. Property of Texas Instruments Incorporated.
00006 *   Restricted rights to use, duplicate or disclose this code are
00007 *   granted through contract.
00008 *
00009 *   The program may not be used without the written permission of
00010 *   Texas Instruments Incorporated or against the terms and conditions
00011 *   stipulated in the agreement under which this program has been supplied,
00012 *   and under no circumstances can it be used with non-TI connectivity device.
00013 *
00014 ******************************************************************************/
00015 
00016 #ifndef __SERVER_PKTS_H__
00017 #define __SERVER_PKTS_H__
00018 
00019 #include "mqtt_common.h"
00020 
00021 /*-----------------------------------------------------------------------------
00022  * Note: Do not create additional dependency of this file on any header other
00023  * than mqtt_common.h. Specifically, server_pkts.[hc] in conjunction with the
00024  * mqtt_common.[hc] files must be facilitated to create a stand-alone library.
00025  *-----------------------------------------------------------------------------
00026  */
00027 
00076 #define MQ_CONN_UTF8_BUF(utf8)      ((utf8)? (utf8)->buffer : NULL)
00077 
00079 #define MQ_CONN_UTF8_LEN(utf8)      ((utf8)? (utf8)->length : 0)
00080 
00081 #define MQC_UTF8_CLIENTID(utf8_vec) (utf8_vec[0]) 
00082 #define MQC_UTF8_WILL_TOP(utf8_vec) (utf8_vec[1]) 
00083 #define MQC_UTF8_WILL_MSG(utf8_vec) (utf8_vec[2]) 
00084 #define MQC_UTF8_USERNAME(utf8_vec) (utf8_vec[3]) 
00085 #define MQC_UTF8_PASSWORD(utf8_vec) (utf8_vec[4]) 
00087 #define MQC_CLIENTID_BUF(utf8_vec)  MQ_CONN_UTF8_BUF(MQC_UTF8_CLIENTID(utf8_vec))
00088 #define MQC_CLIENTID_LEN(utf8_vec)  MQ_CONN_UTF8_LEN(MQC_UTF8_CLIENTID(utf8_vec))
00089 
00090 #define MQC_WILL_TOP_BUF(utf8_vec)  MQ_CONN_UTF8_BUF(MQC_UTF8_WILL_TOP(utf8_vec))
00091 #define MQC_WILL_TOP_LEN(utf8_vec)  MQ_CONN_UTF8_LEN(MQC_UTF8_WILL_TOP(utf8_vec))
00092 
00093 #define MQC_WILL_MSG_BUF(utf8_vec)  MQ_CONN_UTF8_BUF(MQC_UTF8_WILL_MSG(utf8_vec))
00094 #define MQC_WILL_MSG_LEN(utf8_vec)  MQ_CONN_UTF8_LEN(MQC_UTF8_WILL_MSG(utf8_vec))
00095 
00096 #define MQC_USERNAME_BUF(utf8_vec)  MQ_CONN_UTF8_BUF(MQC_UTF8_USERNAME(utf8_vec))
00097 #define MQC_USERNAME_LEN(utf8_vec)  MQ_CONN_UTF8_LEN(MQC_UTF8_USERNAME(utf8_vec))
00098 
00099 #define MQC_PASSWORD_BUF(utf8_vec)  MQ_CONN_UTF8_BUF(MQC_UTF8_PASSWORD(utf8_vec))
00100 #define MQC_PASSWORD_LEN(utf8_vec)  MQ_CONN_UTF8_LEN(MQC_UTF8_PASSWORD(utf8_vec))
00101 
00104 #ifndef CFG_SR_MAX_MQP_RX_LEN
00105 #define MQP_SERVER_RX_LEN  1024  
00106 #else
00107 #define MQP_SERVER_RX_LEN  CFG_SR_MAX_MQP_RX_LEN
00108 #endif
00109 
00122 i32 mqtt_vh_msg_send(void *ctx_cl, u8 msg_type, enum mqtt_qos qos,
00123                      bool has_vh, u16 vh_data);
00124 
00134 i32 mqtt_vh_msg_send_locked(void *ctx_cl, u8 msg_type, enum mqtt_qos qos,
00135                             bool has_vh, u16 vh_data);
00136 
00160 i32 mqtt_server_pub_dispatch(void *ctx_cl, struct mqtt_packet *mqp, bool dup);
00161 
00171 i32 mqtt_server_pub_dispatch_locked(void *ctx_cl, struct mqtt_packet *mqp,
00172                                     bool dup);
00173 
00190 i32 mqtt_server_run(u32 wait_secs);
00191 
00201 i32 mqtt_server_register_net_svc(const struct device_net_services *net);
00202 
00203 
00214 struct mqtt_server_msg_cbs {
00215 
00249         u16  (*connect_rx)(void *ctx_cl, u8 conn_flags,
00250                            struct utf8_string * const *utf8_vec, void **usr);
00251 
00277         bool (*sub_msg_rx)(void *usr_cl, const struct utf8_strqos *qos_topics,
00278                           u32 n_topics, u16 msg_id, u8 *acks);
00279 
00296         bool (*un_sub_msg)(void *usr_cl, const struct utf8_string *topics,
00297                            u32 n_topics, u16 msg_id);
00298 
00324         bool (*pub_msg_rx)(void *usr_cl, const struct utf8_string *topic,
00325                            const u8 *data_buf, u32 data_len, u16 msg_id,
00326                            bool dup, enum mqtt_qos qos, bool retain);
00327 
00343         bool (*ack_notify)(void *usr_cl, u8 msg_type, u16 msg_id);
00344 
00359         void (*on_cl_net_close)(void *usr_cl, bool due2err);
00360 
00371         void (*on_connack_send)(void *usr_cl, bool clean_session);
00372 };
00373 
00374 struct mqtt_server_lib_cfg {
00375 
00377         u16   listener_port;
00378 
00385         u16   loopback_port;
00386 
00388         void  *mutex;
00389         void (*mutex_lockin)(void *mutex);
00390         void (*mutex_unlock)(void *mutex);
00391 
00392         i32  (*debug_printf)(const i8 *format, ...);  
00393         bool   aux_debug_en;  
00395 };
00396 
00420 i32 mqtt_server_lib_init(const struct mqtt_server_lib_cfg *cfg,
00421                          const struct mqtt_server_msg_cbs *cbs);
00422  /* End of server_pktlib */
00424 
00425 #endif
Generated on Mon Nov 17 2014 12:12:08 for MQTT Server by  doxygen 1.7.4