2023-06-08 01:29:22 -04:00
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- |
2023-06-01 16:44:11 -04:00
# WiFi station to "Wired" interface L2 forwarder
2023-06-08 01:29:22 -04:00
(See the README.md file in the upper level 'examples' directory for more information about examples.)
2023-06-01 16:44:11 -04:00
This example aims to demonstrate 1-1 bridge using WiFi station and one of these interfaces (so called *wired* in this example)
- Ethernet (supported for all targets)
- USB acting as NCM device (supported for ESP32-S2 and ESP32-S3)
2023-06-08 01:29:22 -04:00
2023-06-01 16:44:11 -04:00
It also allows for reconfiguring WiFi settings using a virtual network in the Ethernet. The reconfiguration mode is initialized if the WiFi settings are not available, connection fails or manually by long pressing the Boot button (GPIO0).
2023-06-08 01:29:22 -04:00
It is possible to configure WiFi settings (SSID and password) in a browser on an address `"wifi.settings"` or using unified provisioning.
2023-06-01 16:44:11 -04:00
## How to use example
2023-06-08 01:29:22 -04:00
2023-06-01 16:44:11 -04:00
This example could be used to *bring* wireless connectivity to devices that support only Ethernet (or USB Ethernet implemented as NCM device).
This example also supports runtime configuration of WiFi settings by means of a webpage or unified provisioning.
2023-06-08 01:29:22 -04:00
2023-06-01 16:44:11 -04:00
### Hardware Required
2023-06-08 01:29:22 -04:00
2023-06-01 16:44:11 -04:00
Any board with either Ethernet of USB-OTG supported.
2023-06-08 01:29:22 -04:00
### Configure the project
Open the project configuration menu (`idf.py menuconfig`).
In the `Example Configuration` menu choose the provisioning method:
* `EXAMPLE_WIFI_CONFIGURATION_MANUAL` for manual configuration using a webpage
* `EXAMPLE_WIFI_CONFIGURATION_PROVISIONING` for standard provisioning over the virtual USB network
To provision the device using IDF provisioning tools (if `EXAMPLE_WIFI_CONFIGURATION_PROVISIONING` is selected) you can use idf provisioning utility with transport set to `softap` :
```bash
2023-06-01 16:44:11 -04:00
esp-idf/tools/esp_prov$ python esp_prov.py --transport httpd ...
2023-06-08 01:29:22 -04:00
```
2023-06-08 12:01:21 -04:00
Please refer to the provisioning documentation and `esp_prov` script [documentation ](../../../tools/esp_prov/README.md ) for more details.
2023-06-08 01:29:22 -04:00
### Build, Flash, and Run
Build the project and flash it to the board, then run monitor tool to view serial output:
```
idf.py -p PORT build flash monitor
```
(Replace PORT with the name of the serial port to use.)
(To exit the serial monitor, type ``Ctrl-]``.)
See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
## Example Output
After the flashing you should see the output at idf monitor:
2023-06-01 16:44:11 -04:00
(note that this is the output of USB configuration)
2023-06-08 01:29:22 -04:00
```
2023-06-01 16:44:11 -04:00
I (1740) example_sta2wired: Wi-Fi STA connected
I (1740) example_sta2wired: WiFi station connected successfully
W (1750) TinyUSB: The device's configuration descriptor is not provided by user, using default.
W (1760) TinyUSB: The device's string descriptor is not provided by user, using default.
W (1770) TinyUSB: The device's device descriptor is not provided by user, using default.
I (1770) wifi:AP's beacon interval = 102400 us, DTIM period = 1
I (1780) tusb_desc:
2023-06-08 01:29:22 -04:00
┌─────────────────────────────────┐
│ USB Device Descriptor Summary │
├───────────────────┬─────────────┤
│bDeviceClass │ 239 │
├───────────────────┼─────────────┤
│bDeviceSubClass │ 2 │
├───────────────────┼─────────────┤
│bDeviceProtocol │ 1 │
├───────────────────┼─────────────┤
│bMaxPacketSize0 │ 64 │
├───────────────────┼─────────────┤
│idVendor │ 0x303a │
├───────────────────┼─────────────┤
│idProduct │ 0x4002 │
├───────────────────┼─────────────┤
│bcdDevice │ 0x100 │
├───────────────────┼─────────────┤
│iManufacturer │ 0x1 │
├───────────────────┼─────────────┤
│iProduct │ 0x2 │
├───────────────────┼─────────────┤
│iSerialNumber │ 0x3 │
├───────────────────┼─────────────┤
│bNumConfigurations │ 0x1 │
└───────────────────┴─────────────┘
I (915) TinyUSB: TinyUSB Driver installed
```