Enabling WiFi & Ethernet together
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: Enabling WiFi & Ethernet together
Hard to say without looking at the code. Have you tried decoding the backtrace, see where it ends up?
Re: Enabling WiFi & Ethernet together
Hi ESP_Sprite,ESP_Sprite wrote:Hard to say without looking at the code. Have you tried decoding the backtrace, see where it ends up?
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
Ritesh Prajapati
Re: Enabling WiFi & Ethernet together
Hi ESP_angusESP_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
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
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.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?
Depending on the local address supplied, you can bind to a particular interface.
Re: Enabling WiFi & Ethernet together
I think ESP32 supports both BSD Sockets and Netconn Sockets to create communication using TCP Layer sockets.ESP_Angus wrote: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.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?
Depending on the local address supplied, you can bind to a particular interface.
So, You can use either BSD Socket or Netconn for that. Let me correct if I am wrong.
Regards,
Ritesh Prajapati
Ritesh Prajapati
Re: Enabling WiFi & Ethernet together
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)
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.
Thanks and Best regards,
Bhakti Deshpande.
Re: Enabling WiFi & Ethernet together
Hello Espressif Developers,bhakti wrote: ↑Tue Mar 12, 2019 12:17 pmIn 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(); }
Any updates regarding my question ??
Thanks in advance.
------------------------------
Thanks and Best regards,
Bhakti Deshpande.
Thanks and Best regards,
Bhakti Deshpande.
Re: Enabling WiFi & Ethernet together
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.
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 Prajapati
Re: Enabling WiFi & Ethernet together
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.
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 Prajapati
Re: Enabling WiFi & Ethernet together
Hello ESP_Sprite,
Any update for last few questions which i have asked into this post?
Any update for last few questions which i have asked into this post?
Regards,
Ritesh Prajapati
Ritesh Prajapati
Who is online
Users browsing this forum: Bing [Bot], ok-home and 96 guests