Supports ESP32

pull/11/head
Hieromon Ikasamo 6 years ago
parent 337d35abfc
commit bcf2757968
  1. 8
      examples/HandleClient/HandleClient.ino
  2. 8
      examples/HandlePortal/HandlePortal.ino
  3. 8
      examples/HandlePortalEX/HandlePortalEX.ino
  4. 3
      examples/mqttRSSI/mqttRSSI.ino
  5. 2
      src/AutoConnect.cpp
  6. 11
      src/AutoConnectPage.cpp

@ -22,6 +22,10 @@ ESP8266WebServer server;
WebServer server; WebServer server;
#endif #endif
#ifndef BUILTIN_LED
#define BUILTIN_LED 2 // backward compatibility
#endif
AutoConnect portal(server); AutoConnect portal(server);
void handleRoot() { void handleRoot() {
@ -114,7 +118,11 @@ void loop() {
server.handleClient(); server.handleClient();
portal.handleRequest(); // Need to handle AutoConnect menu. portal.handleRequest(); // Need to handle AutoConnect menu.
if (WiFi.status() == WL_IDLE_STATUS) { if (WiFi.status() == WL_IDLE_STATUS) {
#if defined(ARDUINO_ARCH_ESP8266)
ESP.reset(); ESP.reset();
#elif defined(ARDUINO_ARCH_ESP32)
ESP.restart();
#endif
delay(1000); delay(1000);
} }
} }

@ -23,6 +23,10 @@
#endif #endif
#include <AutoConnect.h> #include <AutoConnect.h>
#ifndef BUILTIN_LED
#define BUILTIN_LED 2 // backward compatibility
#endif
AutoConnect portal; AutoConnect portal;
void handleRoot() { void handleRoot() {
@ -116,7 +120,11 @@ void setup() {
void loop() { void loop() {
portal.handleClient(); portal.handleClient();
if (WiFi.status() == WL_IDLE_STATUS) { if (WiFi.status() == WL_IDLE_STATUS) {
#if defined(ARDUINO_ARCH_ESP8266)
ESP.reset(); ESP.reset();
#elif defined(ARDUINO_ARCH_ESP32)
ESP.restart();
#endif
delay(1000); delay(1000);
} }
} }

@ -25,6 +25,10 @@
#include <PageBuilder.h> #include <PageBuilder.h>
#include <AutoConnect.h> #include <AutoConnect.h>
#ifndef BUILTIN_LED
#define BUILTIN_LED 2 // backward compatibility
#endif
#if defined(ARDUINO_ARCH_ESP8266) #if defined(ARDUINO_ARCH_ESP8266)
ESP8266WebServer server; ESP8266WebServer server;
#elif defined(ARDUINO_ARCH_ESP32) #elif defined(ARDUINO_ARCH_ESP32)
@ -147,7 +151,11 @@ void setup() {
void loop() { void loop() {
portal.handleClient(); portal.handleClient();
if (WiFi.status() == WL_IDLE_STATUS) { if (WiFi.status() == WL_IDLE_STATUS) {
#if defined(ARDUINO_ARCH_ESP8266)
ESP.reset(); ESP.reset();
#elif defined(ARDUINO_ARCH_ESP32)
ESP.restart();
#endif
delay(1000); delay(1000);
} }
} }

@ -55,10 +55,11 @@ bool mqttConnect() {
} else { } else {
Serial.println("Connection failed:" + String(mqttClient.state())); Serial.println("Connection failed:" + String(mqttClient.state()));
if (!--retry) if (!--retry)
return false; break;
} }
delay(3000); delay(3000);
} }
return false;
} }
void mqttPublish(String msg) { void mqttPublish(String msg) {

@ -392,7 +392,7 @@ void AutoConnect::onNotFound(WebServerClass::THandlerFunction fn) {
bool AutoConnect::_loadAvailCredential() { bool AutoConnect::_loadAvailCredential() {
AutoConnectCredential credential(_apConfig.boundaryOffset); AutoConnectCredential credential(_apConfig.boundaryOffset);
if (credential.entries() >= 0) { if (credential.entries() > 0) {
// Scan the vicinity only when the saved credentials are existing. // Scan the vicinity only when the saved credentials are existing.
int8_t nn = WiFi.scanNetworks(false, true); int8_t nn = WiFi.scanNetworks(false, true);
AC_DBG("%d network(s) found\n", (int)nn); AC_DBG("%d network(s) found\n", (int)nn);

@ -804,6 +804,11 @@ String AutoConnect::_token_WIFI_MODE(PageArgument& args) {
case WIFI_AP_STA: case WIFI_AP_STA:
wifiMode = "AP_STA"; wifiMode = "AP_STA";
break; break;
#ifdef ARDUINO_ARCH_ESP32
case WIFI_MODE_MAX:
wifiMode = "MAX";
break;
#endif
} }
return String(wifiMode); return String(wifiMode);
} }
@ -855,7 +860,8 @@ String AutoConnect::_token_STATION_STATUS(PageArgument& args) {
"CONNECTED", "CONNECTED",
"CONNECT_FAILED", "CONNECT_FAILED",
"CONNECTION_LOST", "CONNECTION_LOST",
"DISCONNECTED" "DISCONNECTED",
"NO_SHIELD"
}; };
st = WiFi.status(); st = WiFi.status();
switch (st) { switch (st) {
@ -880,6 +886,9 @@ String AutoConnect::_token_STATION_STATUS(PageArgument& args) {
case WL_DISCONNECTED: case WL_DISCONNECTED:
wlStatusSymbol = wlStatusSymbols[6]; wlStatusSymbol = wlStatusSymbols[6];
break; break;
case WL_NO_SHIELD:
wlStatusSymbol = wlStatusSymbols[7];
break;
} }
#endif #endif

Loading…
Cancel
Save