Symbols
loading...
Files
loading (2/5)...

sta2eth sample sample

sta2eth sample is a sample project defining the following symbols:

Most used functions

Name
Location
Summary
Event handler for Ethernet events
Checks if the device has been provisioned
In this scenario of configuring WiFi, we setup Ethernet to create a network and run DHCP server, so it could assign an IP address to the PC ESP32 PC | eth | [ eth-NIC ] | | | (wifi-provisioning) | From the PC's NIC perspective the board acts as a separate network with it's own IP and MAC address (this network's MAC address is the native ESP32's Ethernet interface MAC)
WiFi -- Wired packet path

Other commonly used symbols

Name
Location
Summary
Set this to 1 to runtime update HW addresses in DHCP messages (this is needed if the client uses 61 option and the DHCP server applies strict rules on assigning addresses)
Disable promiscuous mode on Ethernet interface by setting this macro to 0 if disabled, we'd have to rewrite MAC addressed in frames with the actual Eth interface MAC address - this results in better throughput - might cause ARP conflicts if the PC is also connected to the same AP with another NIC
GPIO button functionality
In this scenario of WiFi station to Ethernet bridge mode, we have this configuration (ISP) router ESP32 PC [ AP ] [ sta -- eth ] [ eth-NIC ] From the PC's NIC perspective the L2 forwarding should be transparent and resemble this configuration: (ISP) router PC [ AP ] [ virtual wifi-NIC ] In order for the ESP32 to act as L2 bridge it needs to accept all frames on the interface - For Ethernet we just enable `PROMISCUOUS` mode - For Wifi we could also enable the promiscuous mode, but in that case we'd receive encoded frames from 802.11 and we'd have to decode it and process (using wpa-supplicant). The easier option (in this scenario of only one client -- eth-NIC) we could simply "pretend" that we have the HW mac address of eth-NIC and receive only ethernet frames for "us" from esp_wifi API (we could use the same technique for Ethernet and yield better throughput, see ETH_BRIDGE_PROMISCUOUS flag) This API updates Ethernet frames to swap mac addresses of ESP32 interfaces with those of eth-NIC and AP. For that we'd have to parse initial DHCP packets (manually) to record the HW addresses of the AP and eth-NIC (note, that it is possible to simply spoof the MAC addresses, but that's not recommended technique)

Dependencies