Page 1 of 1

using netif_set_default

Posted: Mon Feb 21, 2022 9:10 pm
by srlevitt
I have a SLIP connection on a uart to another device, on 10.0.0.1. I have a wifi STA connection to a router; the router assigns 192.168.88.252 to the esp32. When the esp32 code tries to send a UDP packet to 192.168.90.100, it gets sent down the SLIP interface.

I think what I really need is the ability to set the default interface to be the Wifi STA , so that the UDP packet gets sent out to the wifi router.

This is also affecting the NAT port forwarding I am trying to do from the other device--slip-->esp32--STA-->wifi router-->server.

I have tried calling "netif_set_default()" in my code, but the compiler complains about the argument I pass. How can I get the correct argument for "netif_set_default()" from the esp_netif_t WiFiSTA?

Re: using netif_set_default

Posted: Thu Mar 03, 2022 2:55 am
by ESP_YJM
Every netif has a parameter named route_prio, you can refer to file esp_netif_defaults.h. A higher value of route_prio indicates a higher priority. The STA wifi route_prio is higher than SLIP in default and will use STA wifi netif with default route. You can foucs on the route_prio and check the code logic.