Switch between network interfaces during runtime (Offloaded modem/Ethernet) #stm32 #driver #ethernet #networking #modem

John Johnson

Hi Zephyr Users,

I wonder how I can make my app switch between which network interface it use during runtime. My idea is to automate the if-selection depending on which of the ifs that has a internet connection.

I have begun simply with using http_get sample and it works fine when I'm using the ifs one at the time. But when I compile in both of them Zephyr wants to use one of the ifs over the other. The setup I'm using is the STM32H747i_disco dev. kit with its built in ethernet-if (aka not offloaded) and Sparkfuns Ublox Sara R4 shield (which is offloaded).

Zephyr always chooses R4 in this sample even though I have set CONFIG_NET_DEFAULT_IF_ETHERNET in prj.conf. Zephyr sets up both my ifs and runs a DCHP request for the ethernet-if. When the sample is done with its HTTP
request (which it does over R4) I can send net cmds like DNS-requests and ping servers with the ethernet-if. Which leads me to believe that the ethernet-if is ready to use by the sample somehow.

So how can I make the sample tell Zephyr to use the ethernet-if instead of the R4?

Further more I'm a bit preplexed because to my untrained eye it seems that Zephyr don't support to use offloaded and non offloaded ifs at the same time from a BSD-socket perspective. When zsock_getaddrinfo() runs it first checks if
CONFIG_NET_SOCKETS_OFFLOAD is enabled and the does the DNS request on the offloaded-if, and thus wont use the internal DNS resolver (which comes after the offloaded check in the code).

Thank you in advance//
John Johnson

Join users@lists.zephyrproject.org to automatically receive all group messages.