Skip to content

Commit ba5f79b

Browse files
committed
feat(netif): Rename route priority method names and add notes
1 parent ff7076b commit ba5f79b

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

libraries/Network/src/NetworkInterface.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,22 +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

616622
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 5, 0)
617-
int NetworkInterface::route_prio(int prio) {
623+
int NetworkInterface::setRoutePrio(int prio) {
618624
if (_esp_netif == NULL) {
619625
return -1;
620626
}
621627
return esp_netif_set_route_prio(_esp_netif, prio);
622628
}
623629
#endif
624630

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+
*/
625636
bool NetworkInterface::setDefault() {
626637
if (_esp_netif == NULL) {
627638
return false;

libraries/Network/src/NetworkInterface.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ class NetworkInterface : public Printable {
5757
const char *desc() const;
5858
String impl_name() const;
5959
int impl_index() const;
60-
int route_prio() const;
60+
int getRoutePrio() const;
6161
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 5, 0)
62-
int route_prio(int prio);
62+
int setRoutePrio(int prio);
6363
#endif
6464
bool setDefault();
6565
bool isDefault() const;

0 commit comments

Comments
 (0)