Skip to content

Commit 8c47474

Browse files
committed
net: lib: mqtt_helper: Allow to bind with specific network interface
Allow the mqtt_helper library to bind with a specific network interface so that the application can control which interface is used for communication in an environment with multiple network interfaces. Signed-off-by: Robert Lubos <[email protected]>
1 parent 7cad078 commit 8c47474

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

include/net/mqtt_helper.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,11 @@ struct mqtt_helper_conn_params {
8888
struct mqtt_helper_buf device_id;
8989
struct mqtt_helper_buf user_name;
9090
struct mqtt_helper_buf password;
91+
92+
/** Name of the interface that the MQTT helper should be bound to.
93+
* Leave as NULL if not specified.
94+
*/
95+
const char *if_name;
9196
};
9297

9398
/** @brief Initialize the MQTT helper.

subsys/net/lib/mqtt_helper/mqtt_helper.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ static int client_connect(struct mqtt_helper_conn_params *conn_params)
483483
mqtt_client.will_message = &last_will_message;
484484
#endif
485485

486+
mqtt_client.transport.if_name = conn_params->if_name;
486487
#if defined(CONFIG_MQTT_LIB_TLS)
487488
mqtt_client.transport.type = MQTT_TRANSPORT_SECURE;
488489
#else

0 commit comments

Comments
 (0)