v1.4.1 to auto detect ESP32 core
#### Releases v1.4.1 ##### Warning: Releases v1.4.1+ can be used and autodetect ESP32 core v2.0.0+ or v1.0.6- for WT32_ETH01 1. Auto detect ESP32 core to use for WT32_ETH01 2. Fix bug in WT32_ETH01 examples to reduce connection time
This commit is contained in:
+7
-54
@@ -45,8 +45,9 @@
|
||||
#endif
|
||||
|
||||
// Level from 0-4
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
#define _ETHERNET_WEBSERVER_LOGLEVEL_ 1
|
||||
|
||||
// 300s = 5 minutes to not flooding
|
||||
#define HTTP_REQUEST_INTERVAL 60 //300
|
||||
@@ -167,54 +168,6 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
}
|
||||
}
|
||||
|
||||
void WiFiEvent(WiFiEvent_t event)
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
case SYSTEM_EVENT_ETH_START:
|
||||
Serial.println("\nETH Started");
|
||||
//set eth hostname here
|
||||
ETH.setHostname("WT32-ETH01");
|
||||
break;
|
||||
case SYSTEM_EVENT_ETH_CONNECTED:
|
||||
Serial.println("ETH Connected");
|
||||
break;
|
||||
|
||||
case SYSTEM_EVENT_ETH_GOT_IP:
|
||||
if (!eth_connected)
|
||||
{
|
||||
Serial.print("ETH MAC: ");
|
||||
Serial.print(ETH.macAddress());
|
||||
Serial.print(", IPv4: ");
|
||||
Serial.print(ETH.localIP());
|
||||
|
||||
if (ETH.fullDuplex())
|
||||
{
|
||||
Serial.print(", FULL_DUPLEX");
|
||||
}
|
||||
|
||||
Serial.print(", ");
|
||||
Serial.print(ETH.linkSpeed());
|
||||
Serial.println("Mbps");
|
||||
eth_connected = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SYSTEM_EVENT_ETH_DISCONNECTED:
|
||||
Serial.println("ETH Disconnected");
|
||||
eth_connected = false;
|
||||
break;
|
||||
|
||||
case SYSTEM_EVENT_ETH_STOP:
|
||||
Serial.println("\nETH Stopped");
|
||||
eth_connected = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
@@ -231,6 +184,9 @@ void setup()
|
||||
|
||||
Serial.setDebugOutput(true);
|
||||
|
||||
// To be called before ETH.begin()
|
||||
WT32_ETH01_onEvent();
|
||||
|
||||
//bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO,
|
||||
// eth_phy_type_t type=ETH_PHY_TYPE, eth_clock_mode_t clk_mode=ETH_CLK_MODE);
|
||||
//ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE, ETH_CLK_MODE);
|
||||
@@ -240,10 +196,7 @@ void setup()
|
||||
//bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0);
|
||||
ETH.config(myIP, myGW, mySN, myDNS);
|
||||
|
||||
WiFi.onEvent(WiFiEvent);
|
||||
|
||||
while (!eth_connected)
|
||||
delay(100);
|
||||
WT32_ETH01_waitForConnect();
|
||||
|
||||
Serial.print(F("AsyncHTTPRequest @ IP : "));
|
||||
Serial.println(ETH.localIP());
|
||||
|
||||
@@ -45,8 +45,9 @@
|
||||
#endif
|
||||
|
||||
// Level from 0-4
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
#define ASYNC_HTTP_DEBUG_PORT Serial
|
||||
#define _ASYNC_HTTP_LOGLEVEL_ 1
|
||||
#define _ETHERNET_WEBSERVER_LOGLEVEL_ 1
|
||||
|
||||
// 300s = 5 minutes to not flooding
|
||||
#define HTTP_REQUEST_INTERVAL 60 //300
|
||||
@@ -136,55 +137,6 @@ void requestCB(void* optParm, AsyncHTTPRequest* request, int readyState)
|
||||
}
|
||||
}
|
||||
|
||||
void WiFiEvent(WiFiEvent_t event)
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
case SYSTEM_EVENT_ETH_START:
|
||||
Serial.println("\nETH Started");
|
||||
//set eth hostname here
|
||||
ETH.setHostname("WT32-ETH01");
|
||||
break;
|
||||
case SYSTEM_EVENT_ETH_CONNECTED:
|
||||
Serial.println("ETH Connected");
|
||||
break;
|
||||
|
||||
case SYSTEM_EVENT_ETH_GOT_IP:
|
||||
if (!eth_connected)
|
||||
{
|
||||
Serial.print("ETH MAC: ");
|
||||
Serial.print(ETH.macAddress());
|
||||
Serial.print(", IPv4: ");
|
||||
Serial.print(ETH.localIP());
|
||||
|
||||
if (ETH.fullDuplex())
|
||||
{
|
||||
Serial.print(", FULL_DUPLEX");
|
||||
}
|
||||
|
||||
Serial.print(", ");
|
||||
Serial.print(ETH.linkSpeed());
|
||||
Serial.println("Mbps");
|
||||
eth_connected = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SYSTEM_EVENT_ETH_DISCONNECTED:
|
||||
Serial.println("ETH Disconnected");
|
||||
eth_connected = false;
|
||||
break;
|
||||
|
||||
case SYSTEM_EVENT_ETH_STOP:
|
||||
Serial.println("\nETH Stopped");
|
||||
eth_connected = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
// put your setup code here, to run once:
|
||||
@@ -198,6 +150,9 @@ void setup()
|
||||
|
||||
Serial.setDebugOutput(true);
|
||||
|
||||
// To be called before ETH.begin()
|
||||
WT32_ETH01_onEvent();
|
||||
|
||||
//bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO,
|
||||
// eth_phy_type_t type=ETH_PHY_TYPE, eth_clock_mode_t clk_mode=ETH_CLK_MODE);
|
||||
//ETH.begin(ETH_PHY_ADDR, ETH_PHY_POWER, ETH_PHY_MDC, ETH_PHY_MDIO, ETH_PHY_TYPE, ETH_CLK_MODE);
|
||||
@@ -207,10 +162,7 @@ void setup()
|
||||
//bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = 0, IPAddress dns2 = 0);
|
||||
ETH.config(myIP, myGW, mySN, myDNS);
|
||||
|
||||
WiFi.onEvent(WiFiEvent);
|
||||
|
||||
while (!eth_connected)
|
||||
delay(100);
|
||||
WT32_ETH01_waitForConnect();
|
||||
|
||||
Serial.print(F("\nHTTP WebClient is @ IP : "));
|
||||
Serial.println(ETH.localIP());
|
||||
|
||||
Reference in New Issue
Block a user