Bridging Wifi SoftAP with Ethernet

Gustav_1997
Posts: 2
Joined: Wed May 03, 2023 11:46 am

Bridging Wifi SoftAP with Ethernet

Postby Gustav_1997 » Wed May 03, 2023 1:37 pm

Hi,

I would like to configure my ESP32 to have a bridged connection between the Ethernet and WiFi SoftAP in Arduino Code. I have a working Ethernet connection with my ESP32 board using an IP101 phy. Also have a Working WiFi SoftAP running on the ESP32 at same time. But the connection between the ESP32's Ethernet and WiFi AP isn't bridged.

Have anyone been able to bridge their Ethernet and Wifi SoftAP?

See posted below a couple snippets of my code (mostly included important parts with regards to ethernet and wifi softAP). If anyone have any information on how I can bridge the two interfaces please let me know.

******** File Start **********

#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiClientSecure.h>
#include <WiFiAP.h>
#include <ETH.h>
#include <esp_eth.h>
#include <esp_eth_phy.h>
#include <phy.h>

#define ETH_PHY_ADDR 1
#define ETH_MDC_GPIO 23
#define ETH_MDIO_GPIO 18
#define ETH_POWER_PIN -1
#define ETH_TYPE ETH_PHY_TLK110
#define ETH_PHY_CLK_PIN 0

const char *ssid = "MyWifiSSID";
const char *password = "MyWiFIPassword";

WiFiServer server(80);

// ******** Setup (Init) function START *********
void setup() {

pinMode(ETH_PHY_CLK_PIN, INPUT);

Serial.begin(115200);
Serial.println();
Serial.println("Configuring access point...");

//Ethernet IP, Gateway, Subnet and DNS config
IPAddress eth_ip(192, 168, 1, 12);
IPAddress eth_subnet(255, 255, 255, 0);
IPAddress eth_gateway(192, 168, 1, 1);
IPAddress eth_dns(8, 8, 8, 8);

//Access Point IPs & Subnet
IPAddress APip(192,168,1,13);
IPAddress APSubnet(255,255,255,0);

//getting ETH MAC addr
uint8_t mac[6];
ETH.macAddress(mac);
IPAddress eth_mac(mac);


Serial.print("Starting Ethernet *************");
ETH.begin(ETH_PHY_ADDR, ETH_POWER_PIN, ETH_MDC_GPIO, ETH_MDIO_GPIO, ETH_TYPE);
ETH.config(eth_ip, eth_gateway, eth_subnet, eth_dns);


while (ETH.linkSpeed() == 0) {
Serial.println("Connecting to Ethernet...");
delay(1000);
}
Serial.println("Connected to Ethernet");

WiFi.softAPConfig(APip,eth_ip,APSubnet);

if (!WiFi.softAP(ssid, password)) {
log_e("Soft AP creation failed.");
while(1);
}

} // ******* Setup (Init) function END *******

// in the loop function I basically only have the SoftAP example code running.

Who is online

Users browsing this forum: No registered users and 34 guests