Skip to content

Commit 713c835

Browse files
committed
ESP32 support
1 parent dbfb0e2 commit 713c835

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/Arduino_ConnectionHandler.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,17 @@
114114
#define WIFI_FIRMWARE_VERSION_REQUIRED WIFI_FIRMWARE_REQUIRED
115115
#endif
116116

117+
#if defined(ESP32)
118+
#include <WiFi.h>
119+
#include <WiFiUdp.h>
120+
#define BOARD_HAS_WIFI
121+
#define NETWORK_HARDWARE_ERROR WL_NO_SHIELD
122+
#define NETWORK_IDLE_STATUS WL_IDLE_STATUS
123+
#define NETWORK_CONNECTED WL_CONNECTED
124+
#define WIFI_FIRMWARE_VERSION_REQUIRED WIFI_FIRMWARE_REQUIRED
125+
126+
#endif
127+
117128
/******************************************************************************
118129
INCLUDES
119130
******************************************************************************/

src/Arduino_WiFiConnectionHandler.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ WiFiConnectionHandler::WiFiConnectionHandler(char const * ssid, char const * pas
4141

4242
unsigned long WiFiConnectionHandler::getTime()
4343
{
44-
#if !defined(BOARD_ESP8266)
44+
#if !defined(BOARD_ESP8266) && !defined(ESP32)
4545
return WiFi.getTime();
4646
#else
4747
return 0;
@@ -54,7 +54,7 @@ unsigned long WiFiConnectionHandler::getTime()
5454

5555
NetworkConnectionState WiFiConnectionHandler::update_handleInit()
5656
{
57-
#ifndef BOARD_ESP8266
57+
#if !defined(BOARD_ESP8266) && !defined(ESP32)
5858
#if !defined(__AVR__)
5959
Debug.print(DBG_INFO, F("WiFi.status(): %d"), WiFi.status());
6060
#endif
@@ -87,14 +87,14 @@ NetworkConnectionState WiFiConnectionHandler::update_handleInit()
8787
delay(300);
8888
WiFi.begin(_ssid, _pass);
8989
delay(1000);
90-
#endif /* ifndef BOARD_ESP8266 */
90+
#endif /* #if !defined(BOARD_ESP8266) && !defined(ESP32) */
9191

9292
return NetworkConnectionState::CONNECTING;
9393
}
9494

9595
NetworkConnectionState WiFiConnectionHandler::update_handleConnecting()
9696
{
97-
#ifndef BOARD_ESP8266
97+
#if !defined(BOARD_ESP8266) && !defined(ESP32)
9898
if (WiFi.status() != WL_CONNECTED)
9999
{
100100
WiFi.begin(_ssid, _pass);
@@ -114,7 +114,7 @@ NetworkConnectionState WiFiConnectionHandler::update_handleConnecting()
114114
#if !defined(__AVR__)
115115
Debug.print(DBG_INFO, F("Connected to \"%s\""), _ssid);
116116
#endif
117-
#ifdef BOARD_ESP8266
117+
#if defined(BOARD_ESP8266) || defined(ESP32)
118118
configTime(0, 0, "time.arduino.cc", "pool.ntp.org", "time.nist.gov");
119119
#endif
120120
return NetworkConnectionState::CONNECTED;
@@ -149,7 +149,7 @@ NetworkConnectionState WiFiConnectionHandler::update_handleDisconnecting()
149149

150150
NetworkConnectionState WiFiConnectionHandler::update_handleDisconnected()
151151
{
152-
#ifndef BOARD_ESP8266
152+
#if !defined(BOARD_ESP8266) && !defined(ESP32)
153153
WiFi.end();
154154
#endif /* ifndef BOARD_ESP8266 */
155155
if (_keep_alive)

0 commit comments

Comments
 (0)