@@ -606,13 +606,33 @@ int NetworkInterface::impl_index() const {
606606 return esp_netif_get_netif_impl_index (_esp_netif);
607607}
608608
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 {
610616 if (_esp_netif == NULL ) {
611617 return -1 ;
612618 }
613619 return esp_netif_get_route_prio (_esp_netif);
614620}
615621
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+ */
616636bool NetworkInterface::setDefault () {
617637 if (_esp_netif == NULL ) {
618638 return false ;
@@ -819,7 +839,11 @@ size_t NetworkInterface::printTo(Print &out) const {
819839 if (flags & ESP_NETIF_FLAG_MLDV6_REPORT) {
820840 bytes += out.print (" ,V6_REP" );
821841 }
822- bytes += out.println (" )" );
842+ bytes += out.print (" )" );
843+
844+ bytes += out.print (" PRIO: " );
845+ bytes += out.print (getRoutePrio ());
846+ bytes += out.println (" " );
823847
824848 bytes += out.print (" " );
825849 bytes += out.print (" ether " );
0 commit comments