using netif_set_default

srlevitt
Posts: 6
Joined: Tue Sep 14, 2021 12:52 pm

using netif_set_default

Postby srlevitt » Mon Feb 21, 2022 9:10 pm

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?

ESP_YJM
Posts: 300
Joined: Fri Feb 26, 2021 10:30 am

Re: using netif_set_default

Postby ESP_YJM » Thu Mar 03, 2022 2:55 am

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.

Who is online

Users browsing this forum: Baidu [Spider] and 122 guests