Enabling WiFi & Ethernet together

ESP_Sprite
Posts: 9709
Joined: Thu Nov 26, 2015 4:08 am

Re: Enabling WiFi & Ethernet together

Postby ESP_Sprite » Tue Aug 14, 2018 7:22 am

Hard to say without looking at the code. Have you tried decoding the backtrace, see where it ends up?

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Enabling WiFi & Ethernet together

Postby Ritesh » Tue Aug 14, 2018 11:44 am

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
Regards,
Ritesh Prajapati

lnunez
Posts: 2
Joined: Wed Aug 22, 2018 6:05 pm

Re: Enabling WiFi & Ethernet together

Postby lnunez » Wed Aug 22, 2018 7:42 pm

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!!

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Enabling WiFi & Ethernet together

Postby ESP_Angus » Thu Aug 23, 2018 1:44 am

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.

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Enabling WiFi & Ethernet together

Postby Ritesh » Thu Aug 23, 2018 4:29 pm

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.
Regards,
Ritesh Prajapati

bhakti
Posts: 12
Joined: Fri Oct 05, 2018 6:52 am

Re: Enabling WiFi & Ethernet together

Postby bhakti » 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();
}
------------------------------

Thanks and Best regards,
Bhakti Deshpande.

bhakti
Posts: 12
Joined: Fri Oct 05, 2018 6:52 am

Re: Enabling WiFi & Ethernet together

Postby bhakti » Fri Mar 15, 2019 5:29 am

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.
------------------------------

Thanks and Best regards,
Bhakti Deshpande.

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Enabling WiFi & Ethernet together

Postby Ritesh » Sat Mar 16, 2019 1:38 pm

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.
Regards,
Ritesh Prajapati

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Enabling WiFi & Ethernet together

Postby Ritesh » Fri Jun 21, 2019 2:17 pm

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.
Regards,
Ritesh Prajapati

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Enabling WiFi & Ethernet together

Postby Ritesh » Sat Jun 22, 2019 10:47 am

Hello ESP_Sprite,

Any update for last few questions which i have asked into this post?
Regards,
Ritesh Prajapati

Who is online

Users browsing this forum: Gaston1980 and 109 guests