* Initial changes to compile under ESP-IDF v5.1
* Initial import for ESP-IDF v5.1 libs
* Update toolchain
* Update esp32-hal-psram.c
* Add missing LDs
* Update platform.txt
* Stop some CI jobs, because they will always fail
* Fix examples
* Update app_httpd.cpp
* Update ResetReason.ino
* Warnings fixes
* Added the example guideline and template (#7665)
* Added the example guideline and template
* PR review changes with some typos and grammar fixes
* Changes according to the PR review
* Added ESP32-S3 link to the datasheet (#7738)
* Update HiFreq_ADC.ino
* Replace periph_ctrl.h use because of deprecation
* Replace esp_spi_flash.h use because of deprecation
* Add includes to male mDNS::enableWorkstation compile
* Fix ssl_client mbedtls_pk_parse_key callback
* Update temperature sensor driver
* Allow sketch_utils to compile with arduino-cli
* Run CI with arduino-cli
* Fix arduino-cli CI build on Windows
* Refactor platform.txt to not use components installed through the board manager when running from git
* Initial Peripheral Manager Implementation
* Update SigmaDelta driver to use the new ESP-IDF driver API
* Small improvements to peripheral manager and SigmaDelta
* Remove deleted function from SigmaDelta header
* Update DAC driver to use the new ESP-IDF driver API
* Adds softAp(String) to make it compatible with ESP8266 (#7801)
* Fix commentary (#7800)
Minor fix based on observation done in https://github.com/espressif/arduino-esp32/issues/7795#issuecomment-1416868611
* add adafruit new board feather esp32s2 reserve tft (#7794)
* bugfix: add <stdint.h> for uint8_t to avoid compilation failure (GCC 11.2.0) (#7744)
* Adding 3rd party boards for VALTRACK-V4-VTS-ESP32-C3 & VALTRACK-V4-MFW-ESP32-C3 (#7735)
* Added VALTRACK-V4-VTS-ESP32-C3 board definition
Created pins_arduino.h & made changes to boards.txt with necessary changes
* Modified the URL
* Renamed json
* renamed all auRL
* Adding VALTRACK-V4 series board definitions
Added VALTRACK-V4-VTS-ESP32C3 & VALTRACK-V4-MFW-ESP32-C3 board variants
* Adding VALTRACK-V4 series board definitions
Added VALTRACK-V4-VTS-ESP32C3 & VALTRACK-V4-MFW-ESP32-C3 board variants
* Reverted package_esp32_index.template.json
restored package_esp32_index.template.json from edits
* Reverted package_esp32_index.template.json
Added new line to package_esp32_index.template.json
* Update Platformio CI (#7725)
* WiFiClient example fix (#7711)
* Modified WiFiClient example to use thingspeak instead of non-functionig sparkfun
* Moved instructions to README
* Fixed spelling
* Added link to S3 datasheet
---------
Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com>
* Mirror update from Heltec repository (#7709)
Heltec updated the I2C pins in
|
||
|---|---|---|
| .. | ||
| .skip.esp32h2 | ||
| MultiHomedServers.ino | ||
| README.md | ||
Multi Homed Servers
This example tests support for multi-homed servers, i.e. a distinct web servers on distinct IP interface.
It only tests the case n=2 because on a basic ESP32 device, we only have two IP interfaces, namely the WiFi station interfaces and the WiFi soft AP interface. For this to work, the WebServer and the WiFiServer classes must correctly handle the case where an IP address is passed to their relevant constructor. It also requires WebServer to work with multiple, simultaneous instances.
Testing the WebServer and the WiFiServer constructors was the primary purpose of this script. The part of WebServer used by this sketch does seem to work with multiple, simultaneous instances. However there is much functionality in WebServer that is not tested here. It may all be well, but that is not proven here.
This sketch starts the mDNS server, as did HelloServer, and it resolves esp32.local on both interfaces, but was not otherwise tested. This script also tests that a server not bound to a specific IP address still works.
We create three, simultaneous web servers, one specific to each interface and one that listens on both:
| name | IP Address | Port |
|---|---|---|
| server0 | INADDR_ANY | 8080 |
| server1 | station address | 8081 |
| server2 | soft AP address | 8081 |
The expected responses to a browser's requests are as follows:
1. The Client connected to the same WLAN as the station:
| Request URL | Response |
|---|---|
| http://stationaddress:8080 | Hello from server0 who listens on both WLAN and own Soft AP |
| http://stationaddress:8081 | Hello from server1 who listens only on WLAN |
2. The Client is connected to the soft AP:
| Request URL | Response |
|---|---|
| http://softAPaddress:8080 | Hello from server0 who listens on both WLAN and own Soft AP |
| http://softAPaddress:8081 | Hello from server2 who listens only on own Soft AP |
3. The Client is connect to either WLAN or SoftAP:
| Request URL | Response |
|---|---|
| http://esp32.local:8080 | Hello from server0 who listens on both WLAN and own Soft AP |
| http://esp32.local:8081 | Hello from server1 who listens only on WLAN |
MultiHomedServers was originally based on HelloServer.
Supported Targets
Currently, this example supports the following targets.
| Supported Targets | ESP32 | ESP32-S2 | ESP32-C3 | ESP32-S3 |
|---|
How to Use Example
Change the SSID and password in the example to your WiFi and flash the example. Open a serial terminal and the example will write the exact addresses with used IP addresses you can use to test the servers.
- How to install the Arduino IDE: Install Arduino IDE.
Using Arduino IDE
To get more information about the Espressif boards see Espressif Development Kits.
- Before Compile/Verify, select the correct board:
Tools -> Board. - Select the COM port:
Tools -> Port: xxxwhere thexxxis the detected COM port.
Using Platform IO
- Select the COM port:
Devicesor set theupload_portoption on theplatformio.inifile.
Example Log Output
Multi-homed Servers example starting
Connecting ...
Connected to "WiFi_SSID", IP address: "192.168.42.24
Soft AP SSID: "ESP32", IP address: 192.168.4.1
MDNS responder started
SSID: WiFi_SSID
http://192.168.42.24:8080
http://192.168.42.24:8081
SSID: ESP32
http://192.168.4.1:8080
http://192.168.4.1:8081
Any of the above SSIDs
http://esp32.local:8080
http://esp32.local:8081
HTTP server0 started
HTTP server1 started
HTTP server2 started
Known issues
http://esp32.local Does not work on some Android phones
Troubleshooting
Important: Make sure you are using a good quality USB cable and that you have a reliable power source
Contribute
To know how to contribute to this project, see How to contribute.
If you have any feedback or issue to report on this example/library, please open an issue or fix it by creating a new PR. Contributions are more than welcome!
Before creating a new issue, be sure to try Troubleshooting and check if the same issue was already created by someone else.
Resources
- Official ESP32 Forum: Link
- Arduino-ESP32 Official Repository: espressif/arduino-esp32
- ESP32 Datasheet: Link to datasheet
- ESP32-S2 Datasheet: Link to datasheet
- ESP32-C3 Datasheet: Link to datasheet
- Official ESP-IDF documentation: ESP-IDF