mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-25 18:14:53 +00:00
mqtt: allow calling mqtt_set_inpub_callback before mqtt_client_connect
See also patch #10037
This commit is contained in:
parent
600e248f06
commit
d7a0757764
@ -1295,6 +1295,9 @@ mqtt_client_connect(mqtt_client_t *client, const ip_addr_t *ip_addr, u16_t port,
|
|||||||
u16_t remaining_length = 2 + 4 + 1 + 1 + 2;
|
u16_t remaining_length = 2 + 4 + 1 + 1 + 2;
|
||||||
u8_t flags = 0, will_topic_len = 0, will_msg_len = 0;
|
u8_t flags = 0, will_topic_len = 0, will_msg_len = 0;
|
||||||
u16_t client_user_len = 0, client_pass_len = 0;
|
u16_t client_user_len = 0, client_pass_len = 0;
|
||||||
|
mqtt_incoming_data_cb_t data_cb;
|
||||||
|
mqtt_incoming_publish_cb_t pub_cb;
|
||||||
|
void *inpub_arg;
|
||||||
|
|
||||||
LWIP_ASSERT_CORE_LOCKED();
|
LWIP_ASSERT_CORE_LOCKED();
|
||||||
LWIP_ASSERT("mqtt_client_connect: client != NULL", client != NULL);
|
LWIP_ASSERT("mqtt_client_connect: client != NULL", client != NULL);
|
||||||
@ -1307,8 +1310,15 @@ mqtt_client_connect(mqtt_client_t *client, const ip_addr_t *ip_addr, u16_t port,
|
|||||||
return ERR_ISCONN;
|
return ERR_ISCONN;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wipe clean */
|
/* Wipe clean, but keep callbacks */
|
||||||
|
data_cb = client->data_cb;
|
||||||
|
pub_cb = client->pub_cb;
|
||||||
|
inpub_arg = client->inpub_arg;
|
||||||
memset(client, 0, sizeof(mqtt_client_t));
|
memset(client, 0, sizeof(mqtt_client_t));
|
||||||
|
client->data_cb = data_cb;
|
||||||
|
client->pub_cb = pub_cb;
|
||||||
|
client->inpub_arg = inpub_arg;
|
||||||
|
|
||||||
client->connect_arg = arg;
|
client->connect_arg = arg;
|
||||||
client->connect_cb = cb;
|
client->connect_cb = cb;
|
||||||
client->keep_alive = client_info->keep_alive;
|
client->keep_alive = client_info->keep_alive;
|
||||||
|
@ -183,7 +183,7 @@ void mqtt_client_free(mqtt_client_t* client);
|
|||||||
|
|
||||||
u8_t mqtt_client_is_connected(mqtt_client_t *client);
|
u8_t mqtt_client_is_connected(mqtt_client_t *client);
|
||||||
|
|
||||||
void mqtt_set_inpub_callback(mqtt_client_t *client, mqtt_incoming_publish_cb_t,
|
void mqtt_set_inpub_callback(mqtt_client_t *client, mqtt_incoming_publish_cb_t pub_cb,
|
||||||
mqtt_incoming_data_cb_t data_cb, void *arg);
|
mqtt_incoming_data_cb_t data_cb, void *arg);
|
||||||
|
|
||||||
err_t mqtt_sub_unsub(mqtt_client_t *client, const char *topic, u8_t qos, mqtt_request_cb_t cb, void *arg, u8_t sub);
|
err_t mqtt_sub_unsub(mqtt_client_t *client, const char *topic, u8_t qos, mqtt_request_cb_t cb, void *arg, u8_t sub);
|
||||||
|
Loading…
Reference in New Issue
Block a user