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

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

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

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

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

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

Loading…
Cancel
Save