Skip to content

ESP32 support + example fix (AVR DebugUtils removal) #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/ConnectionHandlerDemo/ConnectionHandlerDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ void setup() {
Serial.begin(9600);
/* Give a few seconds for the Serial connection to be available */
delay(4000);

#ifndef __AVR__
setDebugMessageLevel(DBG_INFO);

#endif
conMan.addCallback(NetworkConnectionEvent::CONNECTED, onNetworkConnect);
conMan.addCallback(NetworkConnectionEvent::DISCONNECTED, onNetworkDisconnect);
conMan.addCallback(NetworkConnectionEvent::ERROR, onNetworkError);
Expand Down
11 changes: 11 additions & 0 deletions src/Arduino_ConnectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,17 @@
#define WIFI_FIRMWARE_VERSION_REQUIRED WIFI_FIRMWARE_REQUIRED
#endif

#if defined(ESP32)
#include <WiFi.h>
#include <WiFiUdp.h>
#define BOARD_HAS_WIFI
#define NETWORK_HARDWARE_ERROR WL_NO_SHIELD
#define NETWORK_IDLE_STATUS WL_IDLE_STATUS
#define NETWORK_CONNECTED WL_CONNECTED
#define WIFI_FIRMWARE_VERSION_REQUIRED WIFI_FIRMWARE_REQUIRED

#endif

/******************************************************************************
INCLUDES
******************************************************************************/
Expand Down
12 changes: 6 additions & 6 deletions src/Arduino_WiFiConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ WiFiConnectionHandler::WiFiConnectionHandler(char const * ssid, char const * pas

unsigned long WiFiConnectionHandler::getTime()
{
#if !defined(BOARD_ESP8266)
#if !defined(BOARD_ESP8266) && !defined(ESP32)
return WiFi.getTime();
#else
return 0;
Expand All @@ -54,7 +54,7 @@ unsigned long WiFiConnectionHandler::getTime()

NetworkConnectionState WiFiConnectionHandler::update_handleInit()
{
#ifndef BOARD_ESP8266
#if !defined(BOARD_ESP8266) && !defined(ESP32)
#if !defined(__AVR__)
Debug.print(DBG_INFO, F("WiFi.status(): %d"), WiFi.status());
#endif
Expand Down Expand Up @@ -87,14 +87,14 @@ NetworkConnectionState WiFiConnectionHandler::update_handleInit()
delay(300);
WiFi.begin(_ssid, _pass);
delay(1000);
#endif /* ifndef BOARD_ESP8266 */
#endif /* #if !defined(BOARD_ESP8266) && !defined(ESP32) */

return NetworkConnectionState::CONNECTING;
}

NetworkConnectionState WiFiConnectionHandler::update_handleConnecting()
{
#ifndef BOARD_ESP8266
#if !defined(BOARD_ESP8266) && !defined(ESP32)
if (WiFi.status() != WL_CONNECTED)
{
WiFi.begin(_ssid, _pass);
Expand All @@ -114,7 +114,7 @@ NetworkConnectionState WiFiConnectionHandler::update_handleConnecting()
#if !defined(__AVR__)
Debug.print(DBG_INFO, F("Connected to \"%s\""), _ssid);
#endif
#ifdef BOARD_ESP8266
#if defined(BOARD_ESP8266) || defined(ESP32)
configTime(0, 0, "time.arduino.cc", "pool.ntp.org", "time.nist.gov");
#endif
return NetworkConnectionState::CONNECTED;
Expand Down Expand Up @@ -149,7 +149,7 @@ NetworkConnectionState WiFiConnectionHandler::update_handleDisconnecting()

NetworkConnectionState WiFiConnectionHandler::update_handleDisconnected()
{
#ifndef BOARD_ESP8266
#if !defined(BOARD_ESP8266) && !defined(ESP32)
WiFi.end();
#endif /* ifndef BOARD_ESP8266 */
if (_keep_alive)
Expand Down