Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
comment and add comments about eth.setDefault()
  • Loading branch information
d-a-v committed Mar 4, 2022
commit 95b6601bc3949088cccc135894566a8ea9bf570f
5 changes: 5 additions & 0 deletions cores/esp8266/LwipIntfDev.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ class LwipIntfDev: public LwipIntf, public RawDev
return IPAddress(ip4_addr_get_u32(ip_2_ip4(&_netif.gw)));
}

// Use `::setDefault()` to force routing through this interface.
// Default is set to false. In this case lwIP selects the best suited
// output interface matching the destination address.
// If several interfaces match, the first one is picked.
// On esp8266/Arduno: WiFi interfaces are checked first.
void setDefault(bool deflt = true);

// true if interface has a valid IPv4 address
Expand Down
6 changes: 3 additions & 3 deletions libraries/lwIP_Ethernet/examples/EthClient/EthClient.ino
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ void setup() {

Serial.println("\nEthernet\n");

// Uncomment to force routing through this interface.
// Default is set to false. In this case lwIP searches for
// the best suited output interface matching the destination address.
// Uncomment `eth.setDefault(true)` to force routing through this interface.
// Default is set to false. In this case lwIP selects the best suited
// output interface matching the destination address.
// If several interfaces match, the first one is picked.
// On esp8266/Arduno: WiFi interfaces are checked first.
// eth.setDefault(true); // default route set through this interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ void setup() {

Serial.println("\nEthernet\n");

eth.setDefault(true); // default route set through this interface
// Uncomment `eth.setDefault(true)` to force routing through this interface.
// Default is set to false. In this case lwIP selects the best suited
// output interface matching the destination address.
// If several interfaces match, the first one is picked.
// On esp8266/Arduno: WiFi interfaces are checked first.
// eth.setDefault(true); // default route set through this interface

if (!ethInitStatic(eth, LOCAL_IP, LOCAL_GW, LOCAL_MASK, DNS)) {
// enabling debug message will show the real cause
Serial.printf("no hardware found or bad network configuration\n");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,13 @@ void setup() {

Serial.println("\nEthernet\n");

eth.setDefault(true); // default route set through this interface
// Uncomment `eth.setDefault(true)` to force routing through this interface.
// Default is set to false. In this case lwIP selects the best suited
// output interface matching the destination address.
// If several interfaces match, the first one is picked.
// On esp8266/Arduno: WiFi interfaces are checked first.
// eth.setDefault(true); // default route set through this interface

if (!ethInitDHCP(eth)) {
Serial.printf("no hardware found\n");
while (1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,13 @@ void setup(void) {

Serial.println("\nEthernet\n");

eth.setDefault(true); // default route set through this interface
// Uncomment `eth.setDefault(true)` to force routing through this interface.
// Default is set to false. In this case lwIP selects the best suited
// output interface matching the destination address.
// If several interfaces match, the first one is picked.
// On esp8266/Arduno: WiFi interfaces are checked first.
// eth.setDefault(true); // default route set through this interface

if (!ethInitDHCP(eth)) {
Serial.printf("no hardware found\n");
while (1) {
Expand Down