Page 2 of 2

Re: Enabling WiFi & Ethernet together

Posted: Tue Aug 14, 2018 7:22 am
by ESP_Sprite
Hard to say without looking at the code. Have you tried decoding the backtrace, see where it ends up?

Re: Enabling WiFi & Ethernet together

Posted: Tue Aug 14, 2018 11:44 am
by Ritesh
ESP_Sprite wrote:Hard to say without looking at the code. Have you tried decoding the backtrace, see where it ends up?
Hi ESP_Sprite,

Do you have any reference code or example with Event Handler to use both Ethernet and WiFi together? Let me know if anyone has that type of code example and tried it successfully without any issue

Re: Enabling WiFi & Ethernet together

Posted: Wed Aug 22, 2018 7:42 pm
by lnunez
ESP_Angus wrote:Hi mertkahyaoglu,

From the software side, this is possible at the moment if you enable both WiFi and Ethernet in the "Component Config" section of IDF config. (At the moment, due to a bug, you have enable both in configuration but you don't have to use both.)

The two interfaces will be treated as independent in the LWIP TCP/IP library (ie you can bind sockets to either interface, and outgoing packets should be routed based IP packet destination address). We don't have support for source based routing or routing packets between the interfaces (ie there's no support for the ESP32 to act as a tiny WiFi router), although I think this could be technically possible.

There also isn't an example for this configuration in IDF yet, but you can make one by combining the code from one of the WiFi-based examples with the Ethernet example. Let us know if you have any trouble making this work.

From the hardware side, we don't have an official ethernet reference design yet but one will be available.

Angus
Hi ESP_angus

I am new with the ESP32 and maybe I have to search a little more about this. You said "you can bind sockets to either interface", i was wondering, how can you bind a socket with an interface?, I haven´t found yet any function in the API to do this. Maybe the sending interface is selected based on inteface´s ip?

thanks!!

Re: Enabling WiFi & Ethernet together

Posted: Thu Aug 23, 2018 1:44 am
by ESP_Angus
lnunez wrote:i was wondering, how can you bind a socket with an interface?, I haven´t found yet any function in the API to do this. Maybe the sending interface is selected based on inteface´s ip?
That's right, ESP-IDF supports the BSD socket interface of LWIP, so you can use the bind() API call to bind a socket to a local address, before using it.

Depending on the local address supplied, you can bind to a particular interface.

Re: Enabling WiFi & Ethernet together

Posted: Thu Aug 23, 2018 4:29 pm
by Ritesh
ESP_Angus wrote:
lnunez wrote:i was wondering, how can you bind a socket with an interface?, I haven´t found yet any function in the API to do this. Maybe the sending interface is selected based on inteface´s ip?
That's right, ESP-IDF supports the BSD socket interface of LWIP, so you can use the bind() API call to bind a socket to a local address, before using it.

Depending on the local address supplied, you can bind to a particular interface.
I think ESP32 supports both BSD Sockets and Netconn Sockets to create communication using TCP Layer sockets.

So, You can use either BSD Socket or Netconn for that. Let me correct if I am wrong.

Re: Enabling WiFi & Ethernet together

Posted: Tue Mar 12, 2019 12:17 pm
by bhakti
In ethernet and wifi bridge condition , Can we use ethernet as independent interface as well?
I tried it in this code https://github.com/espressif/esp-iot-so ... s/eth2wifi by assigning static ip address to ethernet but either it is working in bridge mode or as independent interface using static ip.

Board : ESP32-EVB Rev.D (Olimex)

Code: Select all


// The IP address that we want our device to have.
#define DEVICE_IP          "192.168.10.254"

// The Gateway address where we wish to send packets.
// This will commonly be our access point.
#define DEVICE_GW          "192.168.10.1"

// The netmask specification.
#define DEVICE_NETMASK     "255.255.0.0"

static void initialise_ethernet(void)
{
     esp_err_t ret = ESP_OK;
     tcpip_adapter_ip_info_t ipInfo;

     inet_pton(AF_INET, DEVICE_IP, &ipInfo.ip);
     inet_pton(AF_INET, DEVICE_GW, &ipInfo.gw);
     inet_pton(AF_INET, DEVICE_NETMASK, &ipInfo.netmask);
     tcpip_adapter_init();
     ret = tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_ETH); 
     ESP_LOGI(TAG, "dhcp client stop RESULT: %d", ret);
     tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_ETH, &ipInfo);

    eth_config_t config = DEFAULT_ETHERNET_PHY_CONFIG;
    
   //  Set the PHY address in the example configuration 
    config.phy_addr = CONFIG_PHY_ADDRESS;
    config.gpio_config = eth_gpio_config_rmii;
   // config.tcpip_input = tcpip_adapter_eth_input_sta_output; // for bridge mode
    config.tcpip_input = tcpip_adapter_eth_input; // for ethernet mode
#ifdef CONFIG_PHY_USE_POWER_PIN
   // Replace the default 'power enable' function with an example-specific
   // one that toggles a power GPIO. 
    config.phy_power_enable = phy_device_power_enable_via_gpio;
#endif
    esp_eth_init(&config);
  //esp_eth_init_internal(&config);
    esp_eth_enable();
}

Re: Enabling WiFi & Ethernet together

Posted: Fri Mar 15, 2019 5:29 am
by bhakti
bhakti wrote:
Tue Mar 12, 2019 12:17 pm
In ethernet and wifi bridge condition , Can we use ethernet as independent interface as well?
I tried it in this code https://github.com/espressif/esp-iot-so ... s/eth2wifi by assigning static ip address to ethernet but either it is working in bridge mode or as independent interface using static ip.

Board : ESP32-EVB Rev.D (Olimex)

Code: Select all


// The IP address that we want our device to have.
#define DEVICE_IP          "192.168.10.254"

// The Gateway address where we wish to send packets.
// This will commonly be our access point.
#define DEVICE_GW          "192.168.10.1"

// The netmask specification.
#define DEVICE_NETMASK     "255.255.0.0"

static void initialise_ethernet(void)
{
     esp_err_t ret = ESP_OK;
     tcpip_adapter_ip_info_t ipInfo;

     inet_pton(AF_INET, DEVICE_IP, &ipInfo.ip);
     inet_pton(AF_INET, DEVICE_GW, &ipInfo.gw);
     inet_pton(AF_INET, DEVICE_NETMASK, &ipInfo.netmask);
     tcpip_adapter_init();
     ret = tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_ETH); 
     ESP_LOGI(TAG, "dhcp client stop RESULT: %d", ret);
     tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_ETH, &ipInfo);

    eth_config_t config = DEFAULT_ETHERNET_PHY_CONFIG;
    
   //  Set the PHY address in the example configuration 
    config.phy_addr = CONFIG_PHY_ADDRESS;
    config.gpio_config = eth_gpio_config_rmii;
   // config.tcpip_input = tcpip_adapter_eth_input_sta_output; // for bridge mode
    config.tcpip_input = tcpip_adapter_eth_input; // for ethernet mode
#ifdef CONFIG_PHY_USE_POWER_PIN
   // Replace the default 'power enable' function with an example-specific
   // one that toggles a power GPIO. 
    config.phy_power_enable = phy_device_power_enable_via_gpio;
#endif
    esp_eth_init(&config);
  //esp_eth_init_internal(&config);
    esp_eth_enable();
}
Hello Espressif Developers,

Any updates regarding my question ??

Thanks in advance.

Re: Enabling WiFi & Ethernet together

Posted: Sat Mar 16, 2019 1:38 pm
by Ritesh
Hi ESP32 SDK Developers,

Would you please check last couple of posts or complete thread from your end and provide update as per queries posted into that thread?

We are also planning to use WIFi, Ethernet and GSM Interface together and we may need support from SDK side to work it as per requirement.

Re: Enabling WiFi & Ethernet together

Posted: Fri Jun 21, 2019 2:17 pm
by Ritesh
Hi ESP32 SDK Developers,

Would you please look into this as there are almost few users are waiting for this support from your side? Hope to get some feedback from your side as well.

Re: Enabling WiFi & Ethernet together

Posted: Sat Jun 22, 2019 10:47 am
by Ritesh
Hello ESP_Sprite,

Any update for last few questions which i have asked into this post?