Two different HTTP servers (ETH and Wi-Fi) on WT32-ETH01
Two different HTTP servers (ETH and Wi-Fi) on WT32-ETH01
My device needs to handle HTTP requests over both Wi-Fi and an Ethernet cable. The WT32-ETH01 is perfect for this. Unfortunately, I haven't worked with ESP32 before. I'm seeking advice: is it possible to implement two HTTP servers using LwIP + FreeRTOS on the WT32-ETH01 board? Could you please suggest some examples or where to start? Maybe there are examples specifically for this board. I would be grateful for any advice.
-
nopnop2002
- Posts: 347
- Joined: Thu Oct 03, 2019 10:52 pm
- Contact:
Re: Two different HTTP servers (ETH and Wi-Fi) on WT32-ETH01
Any ESP32 with WiFi functionality allows you to run two HTTP servers simultaneously.
The first server uses WiFi.
The second server uses Ethernet.
The WT32-ETH01 comes equipped with a LAN8720 Ethernet module, so no external PHY is required.
It's important to set config.server_port and config.ctrl_port to different ports for WiFi and Ethernet.
192.168.0.137 is Ethernet connection.
192.168.0.138 is WiFi connection.
The first server uses WiFi.
The second server uses Ethernet.
The WT32-ETH01 comes equipped with a LAN8720 Ethernet module, so no external PHY is required.
It's important to set config.server_port and config.ctrl_port to different ports for WiFi and Ethernet.
Code: Select all
httpd_handle_t server = NULL;
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
// Purge "Least Recently Used”connection
config.lru_purge_enable = true;
// TCP Port number for receiving and transmitting HTTP traffic
config.server_port = server_port;
// TCP Port number for control
config.ctrl_port = ctrl_port;
192.168.0.138 is WiFi connection.
Code: Select all
I (15127) example_common: Connected to example_netif_eth
I (15137) example_common: - IPv4 address: 192.168.0.137,
I (15137) example_common: Connected to example_netif_sta
I (15147) example_common: - IPv4 address: 192.168.0.138,
I (15147) HTTP_SERVER_STA: Starting HTTP server on 192.168.0.138:8080
I (15157) HTTP_SERVER_STA: param.server_port=[8080]
I (15157) HTTP_SERVER_STA: param.ctrl_port=[32767]
I (15167) HTTP_SERVER_ETH: Starting HTTP server on 192.168.0.137:8081
I (15177) HTTP_SERVER_ETH: param.server_port=[8081]
I (15177) HTTP_SERVER_ETH: param.ctrl_port=[32768]
- Attachments
-
- wifi.jpg (35.62 KiB) Viewed 4211 times
-
- ethernet.jpg (34.73 KiB) Viewed 4211 times
Re: Two different HTTP servers (ETH and Wi-Fi) on WT32-ETH01
Thank you very much for your answer! I will definitely take your advice about the ports into account.
However, the initialization of LwIP when using both interfaces simultaneously is not entirely clear to me. This is because in the examples, both Ethernet and Wi-Fi use the same functions to initialize the netif:
Calling these functions once during Wi-Fi initialization and a second time during Ethernet initialization would cause a conflict.
However, the initialization of LwIP when using both interfaces simultaneously is not entirely clear to me. This is because in the examples, both Ethernet and Wi-Fi use the same functions to initialize the netif:
Code: Select all
esp_netif_init()
esp_event_loop_create_default()-
nopnop2002
- Posts: 347
- Joined: Thu Oct 03, 2019 10:52 pm
- Contact:
Re: Two different HTTP servers (ETH and Wi-Fi) on WT32-ETH01
We are currently preparing to release a sample project.
We will let you know once it is ready.
We will let you know once it is ready.
Re: Two different HTTP servers (ETH and Wi-Fi) on WT32-ETH01
That would be wonderful. I'm looking forward to hearing from you. I hope you won't forget about me.
-
nopnop2002
- Posts: 347
- Joined: Thu Oct 03, 2019 10:52 pm
- Contact:
Re: Two different HTTP servers (ETH and Wi-Fi) on WT32-ETH01
I found that it is possible to start two HTTP servers not only on the WT32-ETH01 but on all ESP32s.is it possible to implement two HTTP servers using LwIP + FreeRTOS on the WT32-ETH01 board?
https://github.com/nopnop2002/esp-idf-d ... /tree/main
Re: Two different HTTP servers (ETH and Wi-Fi) on WT32-ETH01
I'm very grateful, I'll try running your example on my end.
Who is online
Users browsing this forum: Amazon [Bot], Bytespider, PetalBot, Semrush [Bot] and 4 guests