mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-27 10:41:12 +08:00
mqtt: Allow setting server port to connect
This is a mqtt client, so it does not make sense to determinate the server port at compile time. Update mqtt_client_connect() function to allow setting server port. Signed-off-by: Axel Lin <axel.lin@ingics.com>
This commit is contained in:
committed by
Dirk Ziegelmeier
parent
2e4b368c8c
commit
bfa0358a52
@@ -1187,13 +1187,14 @@ mqtt_client_new(void)
|
||||
* Connect to MQTT server
|
||||
* @param client MQTT client
|
||||
* @param ip_addr Server IP
|
||||
* @param port Server port
|
||||
* @param cb Connection state change callback
|
||||
* @param arg User supplied argument to connection callback
|
||||
* @param client_info Client identification and connection options
|
||||
* @return ERR_OK if successful, @see err_t enum for other results
|
||||
*/
|
||||
err_t
|
||||
mqtt_client_connect(mqtt_client_t *client, const ip_addr_t *ip_addr, mqtt_connection_cb_t cb, void *arg,
|
||||
mqtt_client_connect(mqtt_client_t *client, const ip_addr_t *ip_addr, u16_t port, mqtt_connection_cb_t cb, void *arg,
|
||||
const struct mqtt_connect_client_info_t *client_info)
|
||||
{
|
||||
err_t err;
|
||||
@@ -1265,10 +1266,10 @@ mqtt_client_connect(mqtt_client_t *client, const ip_addr_t *ip_addr, mqtt_connec
|
||||
LWIP_DEBUGF(MQTT_DEBUG_WARN,("mqtt_client_connect: Error binding to local ip/port, %d\n", err));
|
||||
goto tcp_fail;
|
||||
}
|
||||
LWIP_DEBUGF(MQTT_DEBUG_TRACE,("mqtt_client_connect: Connecting to host: %s at port:%d\n", ipaddr_ntoa(ip_addr), MQTT_PORT));
|
||||
LWIP_DEBUGF(MQTT_DEBUG_TRACE,("mqtt_client_connect: Connecting to host: %s at port:%"U16_F"\n", ipaddr_ntoa(ip_addr), port));
|
||||
|
||||
/* Connect to server */
|
||||
err = tcp_connect(client->conn, ip_addr, MQTT_PORT, mqtt_tcp_connect_cb);
|
||||
err = tcp_connect(client->conn, ip_addr, port, mqtt_tcp_connect_cb);
|
||||
if(err != ERR_OK) {
|
||||
LWIP_DEBUGF(MQTT_DEBUG_TRACE,("mqtt_client_connect: Error connecting to remote ip/port, %d\n", err));
|
||||
goto tcp_fail;
|
||||
|
||||
Reference in New Issue
Block a user