Hello,
I'm trying to use the MQTT library from ESP-IDF, but I need to be able to dynamically choose between WiFi, Ethernet and PPPoS.
I can't find anywhere in the documentation how to choose which interface is used by the library.
Actually, as a more general question, I couldn't find anywhere in the documentation how to choose the interface for any TCP socket connection using LWIP
Does anyone know how to do this?
Thank you!
Selecting MQTT interface [IDF-1576]
Re: Selecting MQTT interface [IDF-1576]
Moderator's note: edit the topic title for issue tracking, thanks.
Thanks for the suggestion, we will evaluate, thanks.
Thanks for the suggestion, we will evaluate, thanks.
-
- Posts: 69
- Joined: Thu Nov 01, 2018 8:32 am
Re: Selecting MQTT interface [IDF-1576]
Hi aderregibus
lwIP uses the *default interface* for a socket to connect to, it is chosen based on user's API `netif_set_default()` provided the netif status is *up*.
ESP abstraction to the interface routing (and to the TCP/IP stack in general) is a component called esp-netif, documented here: https://docs.espressif.com/projects/esp ... netif.html
It uses an attribute `route_prio` to adjust routing priorities of multiple interfaces (if more netif's are up, the one with highest prio is chosen to be the default netif)
Updating routing priorities can be done for example like this: https://github.com/espressif/esp-idf/bl ... tif.c#L203
Please note that it might be problematic to pick the exact interface from user code if more interfaces point to the same subnet (might be a common usecase for WiFi + ethernet), it is however possible to override pre-route hooks in lwip, for details please check this comment https://github.com/espressif/esp-idf/is ... -519940878
lwIP uses the *default interface* for a socket to connect to, it is chosen based on user's API `netif_set_default()` provided the netif status is *up*.
ESP abstraction to the interface routing (and to the TCP/IP stack in general) is a component called esp-netif, documented here: https://docs.espressif.com/projects/esp ... netif.html
It uses an attribute `route_prio` to adjust routing priorities of multiple interfaces (if more netif's are up, the one with highest prio is chosen to be the default netif)
Updating routing priorities can be done for example like this: https://github.com/espressif/esp-idf/bl ... tif.c#L203
Please note that it might be problematic to pick the exact interface from user code if more interfaces point to the same subnet (might be a common usecase for WiFi + ethernet), it is however possible to override pre-route hooks in lwip, for details please check this comment https://github.com/espressif/esp-idf/is ... -519940878
-
- Posts: 4
- Joined: Mon Apr 13, 2020 6:36 pm
Re: Selecting MQTT interface [IDF-1576]
Thank you very much for your answer ESP_cermak.
Updating routing priorities should do the trick.
Updating routing priorities should do the trick.
Re: Selecting MQTT interface [IDF-1576]
There is a known issue regarding routing for ppp interface that needs fix:ESP_cermak wrote: ↑Wed Apr 15, 2020 7:57 amHi aderregibus
lwIP uses the *default interface* for a socket to connect to, it is chosen based on user's API `netif_set_default()` provided the netif status is *up*.
https://github.com/espressif/esp-idf/issues/5069
Who is online
Users browsing this forum: Baidu [Spider] and 66 guests