Added WiFi support
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
/*!
|
||||
* @file WC_AP_HTML.h
|
||||
*
|
||||
* HTML snippets to build the Access Point portal and the Parameters Portal.
|
||||
*
|
||||
* Written by Stuart Blair
|
||||
*
|
||||
* GNU General Public License v3.0 licence, all text here must be included in any redistribution and you should receive a copy of the license file.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef WC_AP_HTML
|
||||
#define WC_AP_HTML ///< Define to stop re-inclusion
|
||||
/*! \def char AP_HTTP_HEAD[] PROGMEM
|
||||
Start of HTML output
|
||||
*/
|
||||
const char AP_HTTP_HEAD[] PROGMEM = "<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\"/><title>{v}</title>";
|
||||
/*! \def AP_HTTP_STYLE[] PROGMEM
|
||||
Style for our access point
|
||||
*/
|
||||
const char AP_HTTP_STYLE[] PROGMEM = "<style type=\"text/css\">h1 { font-weight: normal; } .msgbox { font-size:1.2rem; line-height: 1.8em; padding: 0.5em; background-color: #ddffff; border-left: 6px solid #ccc; margin-bottom:1em; } .c{text-align:center}div,input{padding:5px;font-size:1em}input{width:95%;margin-top:5px;margin-bottom:10px}body{text-align:center;font-family:verdana;}button{border:0;border-radius:.3rem;background-color:#1fa3ec;color:#fff;line-height:2.6rem;font-size:1.2rem;width:100%}.q{float:right;width:64px;text-align:right}.l{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAALVBMVEX///8EBwfBwsLw8PAzNjaCg4NTVVUjJiZDRUUUFxdiZGSho6OSk5Pg4eFydHTCjaf3AAAAZElEQVQ4je2NSw7AIAhEBamKn97/uMXEGBvozkWb9C2Zx4xzWykBhFAeYp9gkLyZE0zIMno9n4g19hmdY39scwqVkOXaxph0ZCXQcqxSpgQpONa59wkRDOL93eAXvimwlbPbwwVAegLS1HGfZAAAAABJRU5ErkJggg==) no-repeat left center;background-size:1em;}.cfail,.cok{text-align:center; font-size:1.2rem; line-height: 2em; margin-top: 1em; padding: 0.7em; display:none;} .cfail{color: #FFFFFF;background-color: #ff8433;} .cok{ background-color: #6aff33;}</style>";
|
||||
/** Scripts for our page */
|
||||
const char AP_HTTP_SCRIPT[] PROGMEM = "<script>function c(l){document.getElementById('s').value=l.innerText||l.textContent;document.getElementById('p').focus();}</script>";
|
||||
/** End of the header section and beginning of the body */
|
||||
const char AP_HTTP_HEAD_END[] PROGMEM = "</head><body><div style='text-align:left;display:inline-block;min-width:260px;'>";
|
||||
/** Start of our HTMl configuration Form */
|
||||
const char AP_HTTP_PORTAL_OPTIONS[] PROGMEM = "<div class=\"msgbox\">Connect this device to a WiFi network. Select the option to find a WiFi network.</div><form action=\"/wifi\" method=\"get\"><button>Configure WiFi (Auto Scan)</button></form><br/><form action=\"/0wifi\" method=\"get\"><button style=\"background-color:#bbbbbb;\">Configure WiFi (Manual)</button></form><!--<br/><form action=\"/i\" method=\"get\"><button>Info</button></form><br/></form>-->";
|
||||
/** HTML snippet for wifi scanning */
|
||||
const char AP_HTTP_ITEM[] PROGMEM = "<div><a href='#p' onclick='c(this)'>{v}</a> <span class='q {i}'>{r}%</span></div>";
|
||||
/** HTML form for saving wifi connection details */
|
||||
const char AP_HTTP_FORM_START[] PROGMEM ="<form method=\"post\" action=\"wifisave\"><label>Enter WiFi Name ('SSID'):</label><input id=\"s\" name=\"s\" length=32 placeholder=\"Example: Home_Network_2002\"><label>Enter WiFi Password:</label><input id=\"p\" name=\"p\" length=64 type=\"password\" placeholder=\"Password123\"><br/>";;
|
||||
/** HTML snippet for our custom parameters */
|
||||
const char AP_HTTP_FORM_PARAM[] PROGMEM = "<br/><input id='{i}' name='{n}' maxlength={l} placeholder='{p}' value='{v}' {c}>";
|
||||
/** The end of our HTML Form */
|
||||
const char AP_HTTP_FORM_END[] PROGMEM = "<br/><button type='submit'>Save and Connect</button></form>";
|
||||
/** HTML snippet to recan for networks */
|
||||
const char AP_HTTP_SCAN_LINK[] PROGMEM = "<br/><div class=\"c\"><a href=\"/wifi\">Re-scan</a></div>";
|
||||
/** HTML snippet for saved confirmation */
|
||||
// https://stackoverflow.com/questions/20760635/why-does-setting-xmlhttprequest-responsetype-before-calling-open-throw
|
||||
// https://esprima.org/demo/validate.html
|
||||
// https://javascript-minifier.com/
|
||||
|
||||
/* Use JavaScript to ping the ESP periodically @ the AP IP address.
|
||||
* If it comes back as an AP again then we know the connection to the WiFi didn't work.
|
||||
* We wait about 30 seconds to determine this outcome. This isn't 100% foolproof, but should be good enough.
|
||||
*/
|
||||
/*
|
||||
<script type="text/javascript">
|
||||
function doPing() {
|
||||
//if ( timeout_count > 20 ) {
|
||||
if ( attempt_count > 20 ) { // wait about a minute
|
||||
window.clearInterval(myPinger), document.getElementById("conn_ok").style.display = "block"
|
||||
}
|
||||
|
||||
var o = new XMLHttpRequest;
|
||||
o.onload = function() {
|
||||
console.log(this.responseText), document.getElementById("conn_fail").style.display = "block", window.clearInterval(myPinger)
|
||||
}, o.ontimeout = function(o) {
|
||||
console.log("Timeout Counter is: " + timeout_count++)
|
||||
}, o.open("GET", "/foo"), o.timeout = 1000, o.send(null), console.log("Ping counter is: " + attempt_count++)
|
||||
}
|
||||
|
||||
attempt_count = 0;
|
||||
timeout_count = 0;
|
||||
var myPinger = window.setInterval(doPing, 3000);
|
||||
|
||||
</script>
|
||||
*/
|
||||
const char AP_HTTP_SAVED[] PROGMEM = "<div>Credentials Saved.<br />Attempting to connect to WiFi network. Please wait.... <br /><script type=\"text/javascript\">function doPing(){attempt_count>20&&(window.clearInterval(myPinger),document.getElementById(\"conn_ok\").style.display=\"block\");var t=new XMLHttpRequest;t.onload=function(){console.log(this.responseText),document.getElementById(\"conn_fail\").style.display=\"block\",window.clearInterval(myPinger)},t.ontimeout=function(t){console.log(\"Timeout Counter is: \"+timeout_count++)},t.open(\"GET\",\"/foo\"),t.timeout=1e3,t.send(null),console.log(\"Ping counter is: \"+attempt_count++)}attempt_count=0,timeout_count=0;var myPinger=window.setInterval(doPing,3e3);</script><div class=\"cok\" id=\"conn_ok\">Connected to {ap} !<br />You may now close this window. </div><div class=\"cfail\" id=\"conn_fail\">Failed to connect to {ap}!<br /><a href=\"/\">Click here</a> to try again.</div></div>";
|
||||
/** End of the HTML page */
|
||||
const char AP_HTTP_END[] PROGMEM = "</div></body></html>";
|
||||
/** HTML snippet for our custom parameters portal form */
|
||||
const char AP_HTTP_PORTAL_PARAM_OPTIONS[] PROGMEM = "<form action=\"/params\" method=\"get\"><button>Configure Parameters</button></form><br/><form action=\"/i\" method=\"get\"><button>Info</button></form><br/>";
|
||||
/** HTML snippet for our custom parameters save */
|
||||
const char AP_HTTP_FORM_PARAM_START[] PROGMEM ="<form method=\"get\" action=\"wifisave\">";
|
||||
|
||||
#endif
|
||||
+1337
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,187 @@
|
||||
/*!
|
||||
@file WiFiConnect.h
|
||||
|
||||
This is the documentation for WiFiConnect for the Arduino platform.
|
||||
It is a WiFi connection manager for use with the popular ESP8266 and ESP32 chips.
|
||||
It contains a captive portal to allow easy connection and changing of WiFi netwoks
|
||||
via a web based interface and allows for additional user parameters.
|
||||
|
||||
You can view the project at <a href="https://github.com/smurf0969/WiFiConnect">https://github.com/smurf0969/WiFiConnect</a>.
|
||||
Further information is also available in the project <a href="https://github.com/smurf0969/WiFiConnect/wiki">Wiki</a>.
|
||||
|
||||
This is a heavily customised version from the origional <a href="https://github.com/tzapu/WiFiManager">WiFiManager</a>
|
||||
developed by https://github.com/tzapu .
|
||||
|
||||
This library depends on <a href="https://github.com/esp8266/Arduino">
|
||||
ESP8266 Arduino Core</a> and <a href="https://github.com/espressif/arduino-esp32">ESP32 Arduino Core</a> being present on your system.
|
||||
Please make sure you have installed the latest version before using this library.
|
||||
|
||||
Written by Stuart Blair.
|
||||
|
||||
GNU General Public License v3.0 licence, all text here must be included in any redistribution and you should receive a copy of the license file.
|
||||
|
||||
*/
|
||||
#ifndef WiFiConnect_h
|
||||
#define WiFiConnect_h
|
||||
#include <Arduino.h>
|
||||
#if defined(ESP8266)
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#else
|
||||
#include <WiFi.h>
|
||||
#include <WebServer.h>
|
||||
#endif
|
||||
#include <DNSServer.h>
|
||||
#include <memory>
|
||||
|
||||
#if defined(ESP8266)
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
#define ESP_getChipId() (ESP.getChipId()) ///< Gets an ID from the chip
|
||||
#else
|
||||
#include <esp_wifi.h>
|
||||
#define ESP_getChipId() ((uint32_t)ESP.getEfuseMac())///< Gets an ID from the chip
|
||||
#endif
|
||||
|
||||
#include "WC_AP_HTML.h"
|
||||
#include "WiFiConnectParam.h"
|
||||
/** Options for how a access point should continue if no WiFi connected */
|
||||
enum AP_Continue {
|
||||
AP_NONE, ///< No action, continues to run code
|
||||
AP_LOOP, ///< Stalls execution with an infinate loop
|
||||
AP_RESTART, ///< Restarts the chip, allowing it to try to setup again. Handy for sensors when wifi is lost.
|
||||
AP_RESET, ///< Same as AP_RESTART
|
||||
AP_WAIT // Keep the AP and webserver running, sit quietly and be patient.
|
||||
};
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Class that helps to connect to WiFi networks, that also has
|
||||
captive portal web interface for configuration.
|
||||
This is the base class for WiFiConntectOLED which displays
|
||||
information on a OLED display.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
class WiFiConnect {
|
||||
public:
|
||||
/// Create WiFiConnect class
|
||||
WiFiConnect();
|
||||
|
||||
boolean startConfigurationPortal();
|
||||
boolean startConfigurationPortal(AP_Continue apcontinue);
|
||||
boolean startConfigurationPortal(AP_Continue apcontinue, const char* apName, const char* apPassword = NULL, bool paramsMode = false);
|
||||
|
||||
boolean startParamsPortal();
|
||||
boolean startParamsPortal(AP_Continue apcontinue);
|
||||
boolean startParamsPortal(AP_Continue apcontinue, const char* apName, const char* apPassword = NULL);
|
||||
|
||||
void addParameter(WiFiConnectParam *p);
|
||||
|
||||
void setAPName(const char* apName);
|
||||
const char* getAPName();
|
||||
|
||||
void resetSettings();
|
||||
|
||||
boolean autoConnect();
|
||||
boolean autoConnect(const char* ssidName, const char* ssidPassword = NULL, WiFiMode_t acWiFiMode = WIFI_STA);
|
||||
|
||||
|
||||
//sets a custom ip /gateway /subnet configuration
|
||||
void setAPStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn);
|
||||
//sets config for a static IP
|
||||
void setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn);
|
||||
|
||||
//called when AP mode and config portal is started
|
||||
void setAPCallback( void (*func)(WiFiConnect*) );
|
||||
//called when settings have been changed and connection was successful
|
||||
void setSaveConfigCallback( void (*func)(void) );
|
||||
|
||||
void setDebug(boolean isDebug);
|
||||
|
||||
void setRetryAttempts(int attempts);
|
||||
void setConnectionTimeoutSecs(int timeout);
|
||||
void setAPModeTimeoutMins(int mins);
|
||||
|
||||
boolean captivePortal();
|
||||
|
||||
//helpers
|
||||
const char* statusToString(int state);
|
||||
int getRSSIasQuality(int RSSI);
|
||||
boolean isIp(String str);
|
||||
String toStringIp(IPAddress ip);
|
||||
virtual void displayTurnOFF(int ms = 5000); ///< Virtual method overriden in WiFiConnectOLED
|
||||
virtual void displayLoop(); ///< Virtual method overriden in WiFiConnectOLED
|
||||
virtual void displayON(); ///< Virtual method overriden in WiFiConnectOLED
|
||||
protected:
|
||||
boolean _debug = false; ///< Flag to determine wheter to output mesages or not
|
||||
template <typename Generic>
|
||||
void DEBUG_WC(Generic text);
|
||||
virtual void displayConnecting(int attempt, int totalAttempts); ///< Virtual method overriden in WiFiConnectOLED
|
||||
virtual void displayConnected(); ///< Virtual method overriden in WiFiConnectOLED
|
||||
virtual void displayAP(); ///< Virtual method overriden in WiFiConnectOLED
|
||||
virtual void displayParams(); ///< Virtual method overriden in WiFiConnectOLED
|
||||
virtual void displayManualReset(); ///< Virtual method overriden in WiFiConnectOLED
|
||||
|
||||
private:
|
||||
|
||||
|
||||
int _retryAttempts = 3; ///< Number of attempts when trying to connect to WiFi network
|
||||
int _connectionTimeoutSecs = 10; ///< How log to wait for the connection to succeed or fail
|
||||
int _apTimeoutMins = 3; ///< The amount of minutes of inactivity before the access point exits it routine
|
||||
// DNS server
|
||||
const byte DNS_PORT = 53; ///< Standard DNS Port number
|
||||
|
||||
long _lastAPPage = 0; ///< The last time a page was accessed in the portal. Used for the inactivity timeout.
|
||||
boolean _removeDuplicateAPs = true; ///< Flag to remove duplicate networks from scan results.
|
||||
int _minimumQuality = 8; ///< The minimum netqork quality to be included in scan results.
|
||||
int _paramsCount = 0; ///< The amount of custom parameters added via addParameter
|
||||
boolean _readyToConnect = false; ///< Flag used in access point to determine if it should try to connect to the network.
|
||||
String _ssid = " "; ///< Tempory holder for the network ssid
|
||||
String _password = " "; ///< Tempory holder for the network password
|
||||
|
||||
WiFiConnectParam* _params[WiFiConnect_MAX_PARAMS]; ///< Array to hold custom parameters
|
||||
|
||||
std::unique_ptr<DNSServer> dnsServer; ///< DNS Server for captive portal to redirect to Access Point
|
||||
#ifdef ESP8266
|
||||
std::unique_ptr<ESP8266WebServer> server; ///< Web server for serving access point pages
|
||||
#else
|
||||
std::unique_ptr<WebServer> server; ///< Web server for serving access point pages
|
||||
#endif
|
||||
|
||||
char _apName[33] ; ///< Holder for the access point name
|
||||
char _apPassword[65] ; ///< Holder for the access point password
|
||||
|
||||
IPAddress _ap_static_ip; ///< Variable for holding Static IP Address for the access point
|
||||
IPAddress _ap_static_gw; ///< Variable for holding Static Gateway IP Address for the access point
|
||||
IPAddress _ap_static_sn; ///< Variable for holding Static Subnet Mask IP Address for the access point
|
||||
IPAddress _sta_static_ip; ///< Variable for holding Static IP Address for the network connection
|
||||
IPAddress _sta_static_gw; ///< Variable for holding Static Gateway IP Address for the network connection
|
||||
IPAddress _sta_static_sn; ///< Variable for holding Static Subnet Mask IP Address for the network connection
|
||||
|
||||
void (*_apcallback)(WiFiConnect*) = NULL;
|
||||
void (*_savecallback)(void) = NULL;
|
||||
|
||||
|
||||
|
||||
void handleRoot();
|
||||
void handleParamRoot();
|
||||
void handleParams();
|
||||
void handleWifi(boolean scan);
|
||||
void handleWifiSave();
|
||||
void handleInfo();
|
||||
void handleReset();
|
||||
void handle204();
|
||||
void handleNotFound();
|
||||
|
||||
template <class T>
|
||||
auto optionalIPFromString(T *obj, const char *s) -> decltype( obj->fromString(s) ) {
|
||||
return obj->fromString(s);
|
||||
}
|
||||
auto optionalIPFromString(...) -> bool {
|
||||
DEBUG_WC("NO fromString METHOD ON IPAddress, you need ESP8266 core 2.1.0 or newer for Custom IP configuration to work.");
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,166 @@
|
||||
/*!
|
||||
@file WiFiConnectParam.cpp
|
||||
|
||||
WiFi Connection Manager with Captive Portal
|
||||
|
||||
Introduction
|
||||
|
||||
This is the documentation for WiFiConnect for the Arduino platform.
|
||||
It is a WiFi connection manager for use with the popular ESP8266 and ESP32 chips.
|
||||
It contains a captive portal to allow easy connection and changing of WiFi netwoks
|
||||
via a web based interface and allows for additional user parameters.
|
||||
It can also display messages via a OLED screen see WiFiConnectOLED class.
|
||||
|
||||
This is a heavily customised version from the original <a href="https://github.com/tzapu/WiFiManager">WiFiManager</a>
|
||||
developed by https://github.com/tzapu .
|
||||
|
||||
Dependencies
|
||||
|
||||
This library depends on <a href="https://github.com/esp8266/Arduino">
|
||||
ESP8266 Arduino Core</a> and <a href="https://github.com/espressif/arduino-esp32">ESP32 Arduino Core</a> being present on your system.
|
||||
Please make sure you have installed the latest version before using this library.
|
||||
|
||||
|
||||
Written by Stuart Blair.
|
||||
|
||||
License
|
||||
|
||||
GNU General Public License v3.0 licence, all text here must be included in any redistribution and you should receive a copy of the license file.
|
||||
|
||||
*/
|
||||
#include "WiFiConnectParam.h"
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Class object initialiser
|
||||
@param custom
|
||||
Custom HTML to be displayed in the access point for this item.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
WiFiConnectParam::WiFiConnectParam(const char *custom) {
|
||||
_id = NULL;
|
||||
_placeholder = NULL;
|
||||
_length = 0;
|
||||
_value = NULL;
|
||||
|
||||
_customHTML = custom;
|
||||
}
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Class object initialiser
|
||||
@param id
|
||||
The unique ID for the html input box markup for this item
|
||||
@param placeholder
|
||||
Text to be displayed as the input box placeholder for this item
|
||||
@param defaultValue
|
||||
Default text to be displayed in the input box for this item
|
||||
@param length
|
||||
The maximum input text length for this item
|
||||
*/
|
||||
/**************************************************************************/
|
||||
WiFiConnectParam::WiFiConnectParam(const char *id, const char *placeholder, const char *defaultValue, int length) {
|
||||
init(id, placeholder, defaultValue, length, "");
|
||||
}
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Class object initialiser
|
||||
@param id
|
||||
The unique ID for the html input box markup for this item
|
||||
@param placeholder
|
||||
Text to be displayed as the input box placeholder for this item
|
||||
@param defaultValue
|
||||
Default text to be displayed in the input box for this item
|
||||
@param length
|
||||
The maximum input text length for this item
|
||||
@param custom
|
||||
Custom HTML to be displayed in the access point for this item.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
WiFiConnectParam::WiFiConnectParam(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom) {
|
||||
init(id, placeholder, defaultValue, length, custom);
|
||||
}
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Initialiser method
|
||||
@param id
|
||||
The unique ID for the html input box markup for this item
|
||||
@param placeholder
|
||||
Text to be displayed as the input box placeholder for this item
|
||||
@param defaultValue
|
||||
Default text to be displayed in the input box for this item
|
||||
@param length
|
||||
The maximum input text length for this item
|
||||
@param custom
|
||||
Custom HTML to be displayed in the access point for this item.
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void WiFiConnectParam::init(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom) {
|
||||
_id = id;
|
||||
_placeholder = placeholder;
|
||||
_length = length;
|
||||
setValue(defaultValue);
|
||||
|
||||
_customHTML = custom;
|
||||
}
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Method to change the current value of the item
|
||||
@param newValue
|
||||
The new string value for the item
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void WiFiConnectParam::setValue(const char *newValue){
|
||||
if(_length>0){
|
||||
_value = new char[_length + 1];
|
||||
for (int i = 0; i < _length; i++) {
|
||||
_value[i] = 0;
|
||||
}
|
||||
if (newValue != NULL) {
|
||||
strncpy(_value, newValue, _length);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Function to get the current value of the item
|
||||
@return The current value
|
||||
*/
|
||||
/**************************************************************************/
|
||||
const char* WiFiConnectParam::getValue() {
|
||||
return _value;
|
||||
}
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Function to get the current id of the item
|
||||
@return The current id
|
||||
*/
|
||||
/**************************************************************************/
|
||||
const char* WiFiConnectParam::getID() {
|
||||
return _id;
|
||||
}
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Function to get the current placeholder text of the item
|
||||
@return The current placeholder text
|
||||
*/
|
||||
/**************************************************************************/
|
||||
const char* WiFiConnectParam::getPlaceholder() {
|
||||
return _placeholder;
|
||||
}
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Function to get the maximum length allowed for the value of the item
|
||||
@return The current maximum value length
|
||||
*/
|
||||
/**************************************************************************/
|
||||
int WiFiConnectParam::getValueLength() {
|
||||
return _length;
|
||||
}
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Function to get the current custom html markup of the item
|
||||
@return The current custom html markup
|
||||
*/
|
||||
/**************************************************************************/
|
||||
const char* WiFiConnectParam::getCustomHTML() {
|
||||
return _customHTML;
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*!
|
||||
@file WiFiConnectParam.h
|
||||
|
||||
WiFi Connection Manager with Captive Portal
|
||||
|
||||
Introduction
|
||||
|
||||
This is the documentation for WiFiConnect for the Arduino platform.
|
||||
It is a WiFi connection manager for use with the popular ESP8266 and ESP32 chips.
|
||||
It contains a captive portal to allow easy connection and changing of WiFi netwoks
|
||||
via a web based interface and allows for additional user parameters.
|
||||
It can also display messages via a OLED screen see WiFiConnectOLED class.
|
||||
|
||||
This is a heavily customised version from the original <a href="https://github.com/tzapu/WiFiManager">WiFiManager</a>
|
||||
developed by https://github.com/tzapu .
|
||||
|
||||
Dependencies
|
||||
|
||||
This library depends on <a href="https://github.com/esp8266/Arduino">
|
||||
ESP8266 Arduino Core</a> and <a href="https://github.com/espressif/arduino-esp32">ESP32 Arduino Core</a> being present on your system.
|
||||
Please make sure you have installed the latest version before using this library.
|
||||
|
||||
|
||||
Written by Stuart Blair.
|
||||
|
||||
License
|
||||
|
||||
GNU General Public License v3.0 licence, all text here must be included in any redistribution and you should receive a copy of the license file.
|
||||
|
||||
*/
|
||||
#ifndef WIFI_CONNECT_PARAM
|
||||
#define WIFI_CONNECT_PARAM
|
||||
|
||||
#ifndef WiFiConnect_MAX_PARAMS
|
||||
#define WiFiConnect_MAX_PARAMS 10 ///< The maximum size of the param array and how many custom parameters we may have
|
||||
#endif
|
||||
|
||||
#include <Arduino.h>
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Class that stores a custom parameter
|
||||
*/
|
||||
/**************************************************************************/
|
||||
class WiFiConnectParam {
|
||||
public:
|
||||
WiFiConnectParam(const char *custom);
|
||||
WiFiConnectParam(const char *id, const char *placeholder, const char *defaultValue, int length);
|
||||
WiFiConnectParam(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom);
|
||||
|
||||
const char *getID();
|
||||
const char *getValue();
|
||||
const char *getPlaceholder();
|
||||
int getValueLength();
|
||||
const char *getCustomHTML();
|
||||
void setValue(const char *newValue);
|
||||
private:
|
||||
const char *_id;
|
||||
const char *_placeholder;
|
||||
char *_value;
|
||||
int _length;
|
||||
const char *_customHTML;
|
||||
|
||||
void init(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom);
|
||||
|
||||
friend class WiFiConnect; ///< Declarion for WiFiConnect class
|
||||
|
||||
};
|
||||
#endif
|
||||
+2
-1
@@ -1,3 +1,4 @@
|
||||
/*
|
||||
const uint8_t Aura2Regular12pt8bBitmaps[] PROGMEM = {
|
||||
0xFF, 0xFF, 0xFF, 0xC2, 0xF0, 0xCF, 0x3C, 0xF3, 0x8E, 0x30, 0x08, 0xC0,
|
||||
0x8C, 0x18, 0xC1, 0x8C, 0x7F, 0xF1, 0x8C, 0x18, 0x81, 0x88, 0x11, 0x83,
|
||||
@@ -5072,7 +5073,7 @@ const GFXfont Aura2Regular8pt8b PROGMEM = {
|
||||
(uint8_t *)Aura2Regular8pt8bBitmaps,
|
||||
(GFXglyph *)Aura2Regular8pt8bGlyphs,
|
||||
0x20, 0x400, 20 };
|
||||
|
||||
*/
|
||||
const uint8_t Aura2Pro_Light7pt8bBitmaps[] PROGMEM = {
|
||||
0xFF, 0x60, 0x99, 0x99, 0x24, 0x48, 0x93, 0xF2, 0x49, 0x12, 0x24, 0xFC,
|
||||
0x91, 0x20, 0x10, 0xE5, 0x64, 0x91, 0x43, 0x85, 0x14, 0x51, 0x7E, 0x10,
|
||||
|
||||
+73
-10
@@ -1,6 +1,6 @@
|
||||
// [number of languages][number of texts][max. length of text]
|
||||
|
||||
const char myLanguage[9][51][100] = {
|
||||
static const char myLanguage[9][58][78] = {
|
||||
{ "English", // English
|
||||
"Rotary direction changed",
|
||||
"Please release button",
|
||||
@@ -51,7 +51,14 @@ const char myLanguage[9][51][100] = {
|
||||
"Europe",
|
||||
"USA",
|
||||
"Show underscore in RDS",
|
||||
"USB mode"
|
||||
"USB mode",
|
||||
"Wi-Fi active",
|
||||
"Configure Wi-Fi",
|
||||
"Connect to: ",
|
||||
"to configure Wi-Fi",
|
||||
"Trying to connect with Wi-Fi",
|
||||
"FAILED.. WiFi disabled",
|
||||
"CONNECTED!"
|
||||
},
|
||||
|
||||
{ "Nederlands", // Dutch
|
||||
@@ -104,7 +111,14 @@ const char myLanguage[9][51][100] = {
|
||||
"Europa",
|
||||
"USA",
|
||||
"Toon underscore in RDS",
|
||||
"USB mode"
|
||||
"USB mode",
|
||||
"Wi-Fi aktief",
|
||||
"Configureer Wi-Fi",
|
||||
"Verbind met: ",
|
||||
"om Wi-Fi in te stellen",
|
||||
"Verbinden met Wi-Fi...",
|
||||
"MISLUKT.. WiFi uitgeschakeld",
|
||||
"VERBONDEN!"
|
||||
},
|
||||
|
||||
{ "Polski", // Polish
|
||||
@@ -157,7 +171,14 @@ const char myLanguage[9][51][100] = {
|
||||
"Europa",
|
||||
"USA",
|
||||
"Pokaz podkreslenia w RDS",
|
||||
"Tryb USB"
|
||||
"Tryb USB",
|
||||
"Wi-Fi active",
|
||||
"Configure Wi-Fi",
|
||||
"Connect to: ",
|
||||
"to configure Wi-Fi",
|
||||
"Trying to connect with Wi-Fi",
|
||||
"FAILED.. WiFi disabled",
|
||||
"CONNECTED!"
|
||||
},
|
||||
|
||||
{ "Hrvatski", // Croatian
|
||||
@@ -210,7 +231,14 @@ const char myLanguage[9][51][100] = {
|
||||
"Europa",
|
||||
"SAD",
|
||||
"Prikaži donju crtu u RDS-u",
|
||||
"Način rada USB-a"
|
||||
"Način rada USB-a",
|
||||
"Wi-Fi active",
|
||||
"Configure Wi-Fi",
|
||||
"Connect to: ",
|
||||
"to configure Wi-Fi",
|
||||
"Trying to connect with Wi-Fi",
|
||||
"FAILED.. WiFi disabled",
|
||||
"CONNECTED!"
|
||||
},
|
||||
|
||||
{ "Ελληνικά", // Greek
|
||||
@@ -263,7 +291,14 @@ const char myLanguage[9][51][100] = {
|
||||
"Ευρώπη",
|
||||
"Η.Π.Α.",
|
||||
"Εμφάνιση κάτω παύλας στο RDS",
|
||||
"USB mode"
|
||||
"USB mode",
|
||||
"Wi-Fi active",
|
||||
"Configure Wi-Fi",
|
||||
"Connect to: ",
|
||||
"to configure Wi-Fi",
|
||||
"Trying to connect with Wi-Fi",
|
||||
"FAILED.. WiFi disabled",
|
||||
"CONNECTED!"
|
||||
},
|
||||
|
||||
{ "Romana", // Romana
|
||||
@@ -316,7 +351,14 @@ const char myLanguage[9][51][100] = {
|
||||
"Europa",
|
||||
"SUA",
|
||||
"Arata evidentiat in RDS",
|
||||
"USB mode"
|
||||
"USB mode",
|
||||
"Wi-Fi active",
|
||||
"Configure Wi-Fi",
|
||||
"Connect to: ",
|
||||
"to configure Wi-Fi",
|
||||
"Trying to connect with Wi-Fi",
|
||||
"FAILED.. WiFi disabled",
|
||||
"CONNECTED!"
|
||||
},
|
||||
|
||||
{ "Deutsch", // German
|
||||
@@ -369,7 +411,14 @@ const char myLanguage[9][51][100] = {
|
||||
"Europa",
|
||||
"USA",
|
||||
"Zeige Unterstrich im RDS",
|
||||
"USB mode"
|
||||
"USB mode",
|
||||
"Wi-Fi active",
|
||||
"Configure Wi-Fi",
|
||||
"Connect to: ",
|
||||
"to configure Wi-Fi",
|
||||
"Trying to connect with Wi-Fi",
|
||||
"FAILED.. WiFi disabled",
|
||||
"CONNECTED!"
|
||||
},
|
||||
{ "Czech", // English
|
||||
"Směr enkóderu byl změněn",
|
||||
@@ -421,7 +470,14 @@ const char myLanguage[9][51][100] = {
|
||||
"Evropa",
|
||||
"USA",
|
||||
"Zobrazit podtržítka v RDS",
|
||||
"USB mode"
|
||||
"USB mode",
|
||||
"Wi-Fi active",
|
||||
"Configure Wi-Fi",
|
||||
"Connect to: ",
|
||||
"to configure Wi-Fi",
|
||||
"Trying to connect with Wi-Fi",
|
||||
"FAILED.. WiFi disabled",
|
||||
"CONNECTED!"
|
||||
},
|
||||
{ "Slovak", // English
|
||||
"Smer enkóderu bol zmenený",
|
||||
@@ -473,6 +529,13 @@ const char myLanguage[9][51][100] = {
|
||||
"Európa",
|
||||
"USA",
|
||||
"Zobraziť podtržítka v RDS",
|
||||
"USB mode"
|
||||
"USB mode",
|
||||
"Wi-Fi active",
|
||||
"Configure Wi-Fi",
|
||||
"Connect to: ",
|
||||
"to configure Wi-Fi",
|
||||
"Trying to connect with Wi-Fi",
|
||||
"FAILED.. WiFi disabled",
|
||||
"CONNECTED!"
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user