mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-04-17 02:42:29 +00:00
more fixes for !LWIP_ALTCP: move mqtt client struct definitions to mqtt.c
This commit is contained in:
parent
537c258efa
commit
898d3832a7
@ -73,7 +73,60 @@
|
||||
#define MQTT_DEBUG_WARN_STATE (MQTT_DEBUG | LWIP_DBG_LEVEL_WARNING | LWIP_DBG_STATE)
|
||||
#define MQTT_DEBUG_SERIOUS (MQTT_DEBUG | LWIP_DBG_LEVEL_SERIOUS)
|
||||
|
||||
static void mqtt_cyclic_timer(void *arg);
|
||||
/**
|
||||
* Pending request item, binds application callback to pending server requests
|
||||
*/
|
||||
struct mqtt_request_t
|
||||
{
|
||||
/** Next item in list, NULL means this is the last in chain,
|
||||
next pointing at itself means request is unallocated */
|
||||
struct mqtt_request_t *next;
|
||||
/** Callback to upper layer */
|
||||
mqtt_request_cb_t cb;
|
||||
void *arg;
|
||||
/** MQTT packet identifier */
|
||||
u16_t pkt_id;
|
||||
/** Expire time relative to element before this */
|
||||
u16_t timeout_diff;
|
||||
};
|
||||
|
||||
/** Ring buffer */
|
||||
struct mqtt_ringbuf_t {
|
||||
u16_t put;
|
||||
u16_t get;
|
||||
u8_t buf[MQTT_OUTPUT_RINGBUF_SIZE];
|
||||
};
|
||||
|
||||
/** MQTT client */
|
||||
struct mqtt_client_s
|
||||
{
|
||||
/** Timers and timeouts */
|
||||
u16_t cyclic_tick;
|
||||
u16_t keep_alive;
|
||||
u16_t server_watchdog;
|
||||
/** Packet identifier generator*/
|
||||
u16_t pkt_id_seq;
|
||||
/** Packet identifier of pending incoming publish */
|
||||
u16_t inpub_pkt_id;
|
||||
/** Connection state */
|
||||
u8_t conn_state;
|
||||
struct altcp_pcb *conn;
|
||||
/** Connection callback */
|
||||
void *connect_arg;
|
||||
mqtt_connection_cb_t connect_cb;
|
||||
/** Pending requests to server */
|
||||
struct mqtt_request_t *pend_req_queue;
|
||||
struct mqtt_request_t req_list[MQTT_REQ_MAX_IN_FLIGHT];
|
||||
void *inpub_arg;
|
||||
/** Incoming data callback */
|
||||
mqtt_incoming_data_cb_t data_cb;
|
||||
mqtt_incoming_publish_cb_t pub_cb;
|
||||
/** Input */
|
||||
u32_t msg_idx;
|
||||
u8_t rx_buffer[MQTT_VAR_HEADER_BUFFER_LEN];
|
||||
/** Output ring-buffer */
|
||||
struct mqtt_ringbuf_t output;
|
||||
};
|
||||
|
||||
/**
|
||||
* MQTT client connection states
|
||||
@ -121,6 +174,8 @@ enum mqtt_connect_flag {
|
||||
};
|
||||
|
||||
|
||||
static void mqtt_cyclic_timer(void *arg);
|
||||
|
||||
#if defined(LWIP_DEBUG)
|
||||
static const char * const mqtt_message_type_str[15] =
|
||||
{
|
||||
|
@ -132,8 +132,17 @@ enum tcp_state altcp_dbg_get_tcp_state(struct altcp_pcb *conn);
|
||||
|
||||
#include "lwip/tcp.h"
|
||||
|
||||
#define altcp_accept_fn tcp_accept_fn
|
||||
#define altcp_connected_fn tcp_connected_fn
|
||||
#define altcp_recv_fn tcp_recv_fn
|
||||
#define altcp_sent_fn tcp_sent_fn
|
||||
#define altcp_poll_fn tcp_poll_fn
|
||||
#define altcp_err_fn tcp_err_fn
|
||||
|
||||
#define altcp_pcb tcp_pcb
|
||||
#define altcp_tcp_new_ip_type tcp_new_ip_type
|
||||
#define altcp_tcp_new tcp_new
|
||||
#define altcp_tcp_new_ip6 tcp_new_ip6
|
||||
|
||||
#define altcp_arg tcp_arg
|
||||
#define altcp_accept tcp_accept
|
||||
@ -160,6 +169,9 @@ enum tcp_state altcp_dbg_get_tcp_state(struct altcp_pcb *conn);
|
||||
#define altcp_mss tcp_mss
|
||||
#define altcp_sndbuf tcp_sndbuf
|
||||
#define altcp_sndqueuelen tcp_sndqueuelen
|
||||
#define altcp_nagle_disable tcp_nagle_disable
|
||||
#define altcp_nagle_enable tcp_nagle_enable
|
||||
#define altcp_nagle_disabled tcp_nagle_disabled
|
||||
#define altcp_setprio tcp_setprio
|
||||
|
||||
#define altcp_get_tcp_addrinfo tcp_get_tcp_addrinfo
|
||||
|
@ -48,7 +48,6 @@ extern "C" {
|
||||
|
||||
typedef struct mqtt_client_s mqtt_client_t;
|
||||
|
||||
struct altcp_pcb;
|
||||
#if LWIP_ALTCP && LWIP_ALTCP_TLS
|
||||
struct altcp_tls_config;
|
||||
#endif
|
||||
@ -161,62 +160,6 @@ typedef void (*mqtt_incoming_publish_cb_t)(void *arg, const char *topic, u32_t t
|
||||
typedef void (*mqtt_request_cb_t)(void *arg, err_t err);
|
||||
|
||||
|
||||
/**
|
||||
* Pending request item, binds application callback to pending server requests
|
||||
*/
|
||||
struct mqtt_request_t
|
||||
{
|
||||
/** Next item in list, NULL means this is the last in chain,
|
||||
next pointing at itself means request is unallocated */
|
||||
struct mqtt_request_t *next;
|
||||
/** Callback to upper layer */
|
||||
mqtt_request_cb_t cb;
|
||||
void *arg;
|
||||
/** MQTT packet identifier */
|
||||
u16_t pkt_id;
|
||||
/** Expire time relative to element before this */
|
||||
u16_t timeout_diff;
|
||||
};
|
||||
|
||||
/** Ring buffer */
|
||||
struct mqtt_ringbuf_t {
|
||||
u16_t put;
|
||||
u16_t get;
|
||||
u8_t buf[MQTT_OUTPUT_RINGBUF_SIZE];
|
||||
};
|
||||
|
||||
/** MQTT client */
|
||||
struct mqtt_client_s
|
||||
{
|
||||
/** Timers and timeouts */
|
||||
u16_t cyclic_tick;
|
||||
u16_t keep_alive;
|
||||
u16_t server_watchdog;
|
||||
/** Packet identifier generator*/
|
||||
u16_t pkt_id_seq;
|
||||
/** Packet identifier of pending incoming publish */
|
||||
u16_t inpub_pkt_id;
|
||||
/** Connection state */
|
||||
u8_t conn_state;
|
||||
struct altcp_pcb *conn;
|
||||
/** Connection callback */
|
||||
void *connect_arg;
|
||||
mqtt_connection_cb_t connect_cb;
|
||||
/** Pending requests to server */
|
||||
struct mqtt_request_t *pend_req_queue;
|
||||
struct mqtt_request_t req_list[MQTT_REQ_MAX_IN_FLIGHT];
|
||||
void *inpub_arg;
|
||||
/** Incoming data callback */
|
||||
mqtt_incoming_data_cb_t data_cb;
|
||||
mqtt_incoming_publish_cb_t pub_cb;
|
||||
/** Input */
|
||||
u32_t msg_idx;
|
||||
u8_t rx_buffer[MQTT_VAR_HEADER_BUFFER_LEN];
|
||||
/** Output ring-buffer */
|
||||
struct mqtt_ringbuf_t output;
|
||||
};
|
||||
|
||||
|
||||
/** Connect to server */
|
||||
err_t mqtt_client_connect(mqtt_client_t *client, const ip_addr_t *ipaddr, u16_t port, mqtt_connection_cb_t cb, void *arg,
|
||||
const struct mqtt_connect_client_info_t *client_info);
|
||||
|
Loading…
x
Reference in New Issue
Block a user