@@ -606,13 +606,33 @@ int NetworkInterface::impl_index() const {
606
606
return esp_netif_get_netif_impl_index (_esp_netif);
607
607
}
608
608
609
- int NetworkInterface::route_prio () const {
609
+ /* *
610
+ * Every netif has a parameter named route_prio, you can refer to file esp_netif_defaults.h.
611
+ * A higher value of route_prio indicates a higher priority.
612
+ * The active interface with highest priority will be used for default route (gateway).
613
+ * Defaults are: STA=100, BR=70, ETH=50, PPP=20, AP/NAN=10
614
+ */
615
+ int NetworkInterface::getRoutePrio () const {
610
616
if (_esp_netif == NULL ) {
611
617
return -1 ;
612
618
}
613
619
return esp_netif_get_route_prio (_esp_netif);
614
620
}
615
621
622
+ #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 5, 0)
623
+ int NetworkInterface::setRoutePrio (int prio) {
624
+ if (_esp_netif == NULL ) {
625
+ return -1 ;
626
+ }
627
+ return esp_netif_set_route_prio (_esp_netif, prio);
628
+ }
629
+ #endif
630
+
631
+ /* *
632
+ * This API overrides the automatic configuration of the default interface based on the route_prio
633
+ * If the selected netif is set default using this API, no other interface could be set-default disregarding
634
+ * its route_prio number (unless the selected netif gets destroyed)
635
+ */
616
636
bool NetworkInterface::setDefault () {
617
637
if (_esp_netif == NULL ) {
618
638
return false ;
@@ -819,7 +839,11 @@ size_t NetworkInterface::printTo(Print &out) const {
819
839
if (flags & ESP_NETIF_FLAG_MLDV6_REPORT) {
820
840
bytes += out.print (" ,V6_REP" );
821
841
}
822
- bytes += out.println (" )" );
842
+ bytes += out.print (" )" );
843
+
844
+ bytes += out.print (" PRIO: " );
845
+ bytes += out.print (getRoutePrio ());
846
+ bytes += out.println (" " );
823
847
824
848
bytes += out.print (" " );
825
849
bytes += out.print (" ether " );
0 commit comments