merge master
This commit is contained in:
@@ -61,6 +61,8 @@ file(GLOB SRCFILES
|
||||
Logger.cpp
|
||||
# include/RTOS.h
|
||||
lib/WiFiManager/WiFiManager.cpp
|
||||
lib/WiFiManager/wm_consts_en.h
|
||||
lib/WiFiManager/wm_strings_en.h
|
||||
lib/Crc16/Crc16.h
|
||||
lib/nuki_ble/src/NukiBle.cpp
|
||||
lib/nuki_ble/src/NukiBle.hpp
|
||||
|
||||
2
Config.h
2
Config.h
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#define NUKI_HUB_VERSION "7.3-esp-mqtt"
|
||||
#define NUKI_HUB_VERSION "7.3-esp-mqtt-2"
|
||||
|
||||
#define MQTT_QOS_LEVEL 1
|
||||
#define MQTT_CLEAN_SESSIONS false
|
||||
20
Network.cpp
20
Network.cpp
@@ -147,7 +147,7 @@ void Network::initialize()
|
||||
}
|
||||
}
|
||||
|
||||
int Network::update()
|
||||
bool Network::update()
|
||||
{
|
||||
unsigned long ts = millis();
|
||||
|
||||
@@ -182,28 +182,24 @@ int Network::update()
|
||||
|
||||
}
|
||||
|
||||
if(!_device->isConnected())
|
||||
if(!_device->mqttClient()->connected())
|
||||
{
|
||||
if(_networkTimeout > 0 && (ts - _lastConnectedTs > _networkTimeout * 1000))
|
||||
if(_networkTimeout > 0 && (ts - _lastConnectedTs > _networkTimeout * 1000) && ts > 60000)
|
||||
{
|
||||
Log->println("Network timeout has been reached, restarting ...");
|
||||
delay(200);
|
||||
ESP.restart();
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
_lastConnectedTs = ts;
|
||||
|
||||
if(!_device->mqttClient()->connected())
|
||||
{
|
||||
bool success = reconnect();
|
||||
if(!success)
|
||||
{
|
||||
return 1;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
_lastConnectedTs = ts;
|
||||
|
||||
if(_presenceCsv != nullptr && strlen(_presenceCsv) > 0)
|
||||
{
|
||||
bool success = publishString(_mqttPresencePrefix, mqtt_topic_presence, _presenceCsv);
|
||||
@@ -234,9 +230,7 @@ int Network::update()
|
||||
_lastMaintenanceTs = ts;
|
||||
}
|
||||
|
||||
// TODO
|
||||
// _device->mqttClient()->poll();
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Network::reconnect()
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
explicit Network(Preferences* preferences, const String& maintenancePathPrefix);
|
||||
|
||||
void initialize();
|
||||
int update();
|
||||
bool update();
|
||||
void registerMqttReceiver(MqttReceiver* receiver);
|
||||
void reconfigureDevice();
|
||||
void setMqttPresencePath(char* path);
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
language: c
|
||||
sudo: false
|
||||
|
||||
before_install:
|
||||
- "/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16"
|
||||
- sleep 3
|
||||
- export DISPLAY=:1.0
|
||||
- wget http://downloads.arduino.cc/arduino-1.8.10-linux64.tar.xz
|
||||
- tar xf arduino-1.8.10-linux64.tar.xz
|
||||
- sudo mv arduino-1.8.10 /usr/local/share/arduino
|
||||
- sudo ln -s /usr/local/share/arduino/arduino /usr/local/bin/arduino
|
||||
|
||||
install:
|
||||
- ln -s $PWD /usr/local/share/arduino/libraries/WiFiManager
|
||||
- arduino --pref "boardsmanager.additional.urls=http://arduino.esp8266.com/stable/package_esp8266com_index.json,http://dl.espressif.com/dl/package_esp32_index.json" --save-prefs
|
||||
- arduino --install-library "ArduinoJson:6.18.0"
|
||||
- arduino --install-boards esp8266:esp8266
|
||||
- arduino --pref "compiler.warning_level=all" --save-prefs
|
||||
# install esp32
|
||||
- arduino --install-boards esp32:esp32
|
||||
|
||||
script:
|
||||
- "echo $PWD"
|
||||
- "echo $HOME"
|
||||
- "ls $PWD"
|
||||
- source $TRAVIS_BUILD_DIR/travis/common.sh
|
||||
- arduino --board esp8266:esp8266:generic:xtal=80,eesz=4M1M,FlashMode=qio,FlashFreq=80,dbg=Serial,lvl=CORE --save-prefs
|
||||
- build_examples
|
||||
- arduino --board esp32:esp32:esp32:FlashFreq=80,FlashSize=4M,DebugLevel=info --save-prefs
|
||||
# some examples fail (SPIFFS defines differ esp32 vs esp8266) so we exclude them
|
||||
- build_examples
|
||||
# - arduino -v --verbose-build --verify $PWD/examples/AutoConnect/AutoConnect.ino
|
||||
|
||||
# no coverage generated, no need to run
|
||||
#
|
||||
#after_success:
|
||||
# - bash <(curl -s https://codecov.io/bash)
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: change
|
||||
on_failure: change
|
||||
9
lib/WiFiManager/CMakeLists.txt
Normal file
9
lib/WiFiManager/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
idf_component_register(
|
||||
SRCS "WiFiManager.cpp"
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES arduino
|
||||
)
|
||||
|
||||
project(WiFiManager)
|
||||
@@ -1,6 +1,5 @@
|
||||
|
||||
# WiFiManager
|
||||
## DEVELOPMENT Version
|
||||
|
||||
Espressif ESPx WiFi Connection manager with fallback web configuration portal
|
||||
|
||||
@@ -8,26 +7,25 @@ Espressif ESPx WiFi Connection manager with fallback web configuration portal
|
||||
|
||||

|
||||
|
||||

|
||||
[](https://github.com/tzapu/WiFiManager/actions/workflows/compile_library.yml)
|
||||
|
||||

|
||||
[](https://github.com/tzapu/WiFiManager/actions/workflows/compile_examples.yaml)
|
||||
|
||||
[](https://www.ardu-badge.com/WiFiManager)
|
||||
|
||||
[](https://platformio.org/lib/show/567/WiFiManager/installation)
|
||||
|
||||

|
||||
[](https://www.espressif.com/en/products/socs/esp8266)
|
||||
|
||||

|
||||

|
||||

|
||||
[](https://www.espressif.com/en/products/socs/esp32)
|
||||
[](https://www.espressif.com/en/products/socs/esp32-s2)
|
||||
[](https://www.espressif.com/en/products/socs/esp32-c3)
|
||||
|
||||
Member to Member Support / Chat
|
||||
|
||||
[](https://gitter.im/tablatronix/WiFiManager?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
[](https://discord.gg/dkjJbHwC)
|
||||
|
||||
[](https://discord.gg/nS5WGkaQH5)
|
||||
The configuration portal is of the captive variety, so on various devices it will present the configuration dialogue as soon as you connect to the created access point.
|
||||
|
||||
**This works with the ESP8266 Arduino platform**
|
||||
@@ -171,8 +169,8 @@ Also see [examples](https://github.com/tzapu/WiFiManager/tree/master/examples).
|
||||
|
||||
[PlatformIO](https://platformio.org/) is an emerging ecosystem for IoT development, and
|
||||
is an alternative to using the Arduino IDE. Install `WiFiManager`
|
||||
using the platformio [library manager](https://docs.platformio.org/en/latest/librarymanager/index.htm) in your editor,
|
||||
or using the [PlatformIO Core CLI](https://docs.platformio.org/en/latest/userguide/demo.html#library-manager),
|
||||
using the platformio [library manager](https://docs.platformio.org/en/latest/librarymanager/index.html#librarymanager) in your editor,
|
||||
or using the [PlatformIO Core CLI](https://docs.platformio.org/en/latest/core/index.html),
|
||||
or by adding it to your `platformio.ini` as shown below (recommended approach).
|
||||
|
||||
The simplest way is to open the `platformio.ini` file at the root of your project, and `WifiManager` to the common top-level env
|
||||
@@ -229,7 +227,7 @@ IF YOU NEED TO SAVE PARAMETERS EVEN ON WIFI FAIL OR EMPTY, you must set `setBrea
|
||||
void setBreakAfterConfig(boolean shouldBreak);
|
||||
```
|
||||
|
||||
See [AutoConnectWithFSParameters Example](https://github.com/tzapu/WiFiManager/tree/master/examples/AutoConnectWithFSParameters).
|
||||
See [AutoConnectWithFSParameters Example](https://github.com/tzapu/WiFiManager/tree/master/examples/Parameters/SPIFFS/AutoConnectWithFSParameters).
|
||||
```cpp
|
||||
wifiManager.setSaveConfigCallback(saveConfigCallback);
|
||||
```
|
||||
@@ -269,7 +267,7 @@ void loop() {
|
||||
}
|
||||
}
|
||||
```
|
||||
See example for a more complex version. [OnDemandConfigPortal](https://github.com/tzapu/WiFiManager/tree/master/examples/OnDemandConfigPortal)
|
||||
See example for a more complex version. [OnDemandConfigPortal](https://github.com/tzapu/WiFiManager/tree/master/examples/OnDemand/OnDemandConfigPortal)
|
||||
|
||||
#### Exiting from the Configuration Portal
|
||||
Normally, once entered, the configuration portal will continue to loop until WiFi credentials have been successfully entered or a timeout is reached.
|
||||
@@ -291,7 +289,7 @@ Usage scenario would be:
|
||||
|
||||
```
|
||||
- if connection to AP fails, configuration portal starts and you can set /change the values (or use on demand configuration portal)
|
||||
- once configuration is done and connection is established [save config callback]() is called
|
||||
- once configuration is done and connection is established save config callback() is called
|
||||
- once WiFiManager returns control to your application, read and save the new values using the `WiFiManagerParameter` object.
|
||||
```cpp
|
||||
mqtt_server = custom_mqtt_server.getValue();
|
||||
@@ -299,7 +297,7 @@ Usage scenario would be:
|
||||
This feature is a lot more involved than all the others, so here are some examples to fully show how it is done.
|
||||
You should also take a look at adding custom HTML to your form.
|
||||
|
||||
- Save and load custom parameters to file system in json form [AutoConnectWithFSParameters](https://github.com/tzapu/WiFiManager/tree/master/examples/AutoConnectWithFSParameters)
|
||||
- Save and load custom parameters to file system in json form [AutoConnectWithFSParameters](https://github.com/tzapu/WiFiManager/tree/master/examples/Parameters/SPIFFS/AutoConnectWithFSParameters)
|
||||
- *Save and load custom parameters to EEPROM* (not done yet)
|
||||
|
||||
#### Custom IP Configuration
|
||||
|
||||
@@ -33,7 +33,7 @@ WiFiManagerParameter::WiFiManagerParameter(const char *custom) {
|
||||
_id = NULL;
|
||||
_label = NULL;
|
||||
_length = 1;
|
||||
_value = NULL;
|
||||
_value = nullptr;
|
||||
_labelPlacement = WFM_LABEL_DEFAULT;
|
||||
_customHTML = custom;
|
||||
}
|
||||
@@ -59,6 +59,8 @@ void WiFiManagerParameter::init(const char *id, const char *label, const char *d
|
||||
_label = label;
|
||||
_labelPlacement = labelPlacement;
|
||||
_customHTML = custom;
|
||||
_length = 1;
|
||||
_value = nullptr;
|
||||
setValue(defaultValue,length);
|
||||
}
|
||||
|
||||
@@ -87,8 +89,14 @@ void WiFiManagerParameter::setValue(const char *defaultValue, int length) {
|
||||
// // return false; //@todo bail
|
||||
// }
|
||||
|
||||
if(_length != length || _value == nullptr){
|
||||
_length = length;
|
||||
if( _value != nullptr){
|
||||
delete[] _value;
|
||||
}
|
||||
_value = new char[_length + 1];
|
||||
}
|
||||
|
||||
memset(_value, 0, _length + 1); // explicit null
|
||||
|
||||
if (defaultValue != NULL) {
|
||||
@@ -200,7 +208,7 @@ int WiFiManager::getParametersCount() {
|
||||
**/
|
||||
|
||||
// constructors
|
||||
WiFiManager::WiFiManager(Stream& consolePort):_debugPort(consolePort){
|
||||
WiFiManager::WiFiManager(Print& consolePort):_debugPort(consolePort){
|
||||
WiFiManagerInit();
|
||||
}
|
||||
|
||||
@@ -227,7 +235,7 @@ WiFiManager::~WiFiManager() {
|
||||
_params = NULL;
|
||||
}
|
||||
|
||||
// @todo remove event
|
||||
// remove event
|
||||
// WiFi.onEvent(std::bind(&WiFiManager::WiFiEvent,this,_1,_2));
|
||||
#ifdef ESP32
|
||||
WiFi.removeEvent(wm_event_id);
|
||||
@@ -272,7 +280,28 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(F("AutoConnect"));
|
||||
#endif
|
||||
if(getWiFiIsSaved()){
|
||||
|
||||
// bool wifiIsSaved = getWiFiIsSaved();
|
||||
|
||||
#ifdef ESP32
|
||||
setupHostname(true);
|
||||
|
||||
if(_hostname != ""){
|
||||
// disable wifi if already on
|
||||
if(WiFi.getMode() & WIFI_STA){
|
||||
WiFi.mode(WIFI_OFF);
|
||||
int timeout = millis()+1200;
|
||||
// async loop for mode change
|
||||
while(WiFi.getMode()!= WIFI_OFF && millis()<timeout){
|
||||
delay(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// check if wifi is saved, (has autoconnect) to speed up cp start
|
||||
// NOT wifi init safe
|
||||
// if(wifiIsSaved){
|
||||
_startconn = millis();
|
||||
_begin();
|
||||
|
||||
@@ -298,10 +327,11 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
|
||||
// so we must force it on else, if not connectimeout then waitforconnectionresult gets stuck endless loop
|
||||
WiFi_autoReconnect();
|
||||
|
||||
// set hostname before stating
|
||||
#ifdef ESP8266
|
||||
if(_hostname != ""){
|
||||
setupHostname(true);
|
||||
}
|
||||
#endif
|
||||
|
||||
// if already connected, or try stored connect
|
||||
// @note @todo ESP32 has no autoconnect, so connectwifi will always be called unless user called begin etc before
|
||||
@@ -313,7 +343,7 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
|
||||
DEBUG_WM(F("AutoConnect: ESP Already Connected"));
|
||||
#endif
|
||||
setSTAConfig();
|
||||
// @todo not sure if this check makes sense, causes dup setSTAConfig in connectwifi,
|
||||
// @todo not sure if this is safe, causes dup setSTAConfig in connectwifi,
|
||||
// and we have no idea WHAT we are connected to
|
||||
}
|
||||
|
||||
@@ -324,6 +354,7 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("Connected in"),(String)((millis()-_startconn)) + " ms");
|
||||
DEBUG_WM(F("STA IP Address:"),WiFi.localIP());
|
||||
#endif
|
||||
// Serial.println("Connected in " + (String)((millis()-_startconn)) + " ms");
|
||||
_lastconxresult = WL_CONNECTED;
|
||||
|
||||
if(_hostname != ""){
|
||||
@@ -337,12 +368,12 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(F("AutoConnect: FAILED"));
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(F("No Credentials are Saved, skipping connect"));
|
||||
#endif
|
||||
}
|
||||
// }
|
||||
// else {
|
||||
// #ifdef WM_DEBUG_LEVEL
|
||||
// DEBUG_WM(F("No Credentials are Saved, skipping connect"));
|
||||
// #endif
|
||||
// }
|
||||
|
||||
// possibly skip the config portal
|
||||
if (!_enableConfigPortal) {
|
||||
@@ -387,13 +418,21 @@ bool WiFiManager::setupHostname(bool restart){
|
||||
#endif
|
||||
#elif defined(ESP32)
|
||||
// @note hostname must be set after STA_START
|
||||
delay(200); // do not remove, give time for STA_START
|
||||
// @note, this may have changed at some point, now it wont work, I have to set it before.
|
||||
// same for S2, must set it before mode(STA) now
|
||||
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("Setting WiFi hostname"));
|
||||
#endif
|
||||
|
||||
res = WiFi.setHostname(_hostname.c_str());
|
||||
// esp_err_t err;
|
||||
// // err = set_esp_interface_hostname(ESP_IF_WIFI_STA, "TEST_HOSTNAME");
|
||||
// err = esp_netif_set_hostname(esp_netifs[ESP_IF_WIFI_STA], "TEST_HOSTNAME");
|
||||
// if(err){
|
||||
// log_e("Could not set hostname! %d", err);
|
||||
// return false;
|
||||
// }
|
||||
// #ifdef ESP32MDNS_H
|
||||
#ifdef WM_MDNS
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
@@ -487,7 +526,7 @@ bool WiFiManager::startAP(){
|
||||
|
||||
if(_debugLevel >= DEBUG_DEV) debugSoftAPConfig();
|
||||
|
||||
// @todo add softAP retry here
|
||||
// @todo add softAP retry here to dela with unknown failures
|
||||
|
||||
delay(500); // slight delay to make sure we get an AP IP
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
@@ -595,29 +634,29 @@ void WiFiManager::setupHTTPServer(){
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("[CB] _webservercallback calling"));
|
||||
#endif
|
||||
_webservercallback();
|
||||
_webservercallback(); // @CALLBACK
|
||||
}
|
||||
// @todo add a new callback maybe, after webserver started, callback cannot override handlers, but can grab them first
|
||||
|
||||
/* Setup httpd callbacks, web pages: root, wifi config pages, SO captive portal detectors and not found. */
|
||||
|
||||
// G macro workaround for Uri() bug https://github.com/esp8266/Arduino/issues/7102
|
||||
server->on(G(R_root), std::bind(&WiFiManager::handleRoot, this));
|
||||
server->on(G(R_wifi), std::bind(&WiFiManager::handleWifi, this, true));
|
||||
server->on(G(R_wifinoscan), std::bind(&WiFiManager::handleWifi, this, false));
|
||||
server->on(G(R_wifisave), std::bind(&WiFiManager::handleWifiSave, this));
|
||||
server->on(G(R_info), std::bind(&WiFiManager::handleInfo, this));
|
||||
server->on(G(R_param), std::bind(&WiFiManager::handleParam, this));
|
||||
server->on(G(R_paramsave), std::bind(&WiFiManager::handleParamSave, this));
|
||||
server->on(G(R_restart), std::bind(&WiFiManager::handleReset, this));
|
||||
server->on(G(R_exit), std::bind(&WiFiManager::handleExit, this));
|
||||
server->on(G(R_close), std::bind(&WiFiManager::handleClose, this));
|
||||
server->on(G(R_erase), std::bind(&WiFiManager::handleErase, this, false));
|
||||
server->on(G(R_status), std::bind(&WiFiManager::handleWiFiStatus, this));
|
||||
server->on(WM_G(R_root), std::bind(&WiFiManager::handleRoot, this));
|
||||
server->on(WM_G(R_wifi), std::bind(&WiFiManager::handleWifi, this, true));
|
||||
server->on(WM_G(R_wifinoscan), std::bind(&WiFiManager::handleWifi, this, false));
|
||||
server->on(WM_G(R_wifisave), std::bind(&WiFiManager::handleWifiSave, this));
|
||||
server->on(WM_G(R_info), std::bind(&WiFiManager::handleInfo, this));
|
||||
server->on(WM_G(R_param), std::bind(&WiFiManager::handleParam, this));
|
||||
server->on(WM_G(R_paramsave), std::bind(&WiFiManager::handleParamSave, this));
|
||||
server->on(WM_G(R_restart), std::bind(&WiFiManager::handleReset, this));
|
||||
server->on(WM_G(R_exit), std::bind(&WiFiManager::handleExit, this));
|
||||
server->on(WM_G(R_close), std::bind(&WiFiManager::handleClose, this));
|
||||
server->on(WM_G(R_erase), std::bind(&WiFiManager::handleErase, this, false));
|
||||
server->on(WM_G(R_status), std::bind(&WiFiManager::handleWiFiStatus, this));
|
||||
server->onNotFound (std::bind(&WiFiManager::handleNotFound, this));
|
||||
|
||||
server->on(G(R_update), std::bind(&WiFiManager::handleUpdate, this));
|
||||
server->on(G(R_updatedone), HTTP_POST, std::bind(&WiFiManager::handleUpdateDone, this), std::bind(&WiFiManager::handleUpdating, this));
|
||||
server->on(WM_G(R_update), std::bind(&WiFiManager::handleUpdate, this));
|
||||
server->on(WM_G(R_updatedone), HTTP_POST, std::bind(&WiFiManager::handleUpdateDone, this), std::bind(&WiFiManager::handleUpdating, this));
|
||||
|
||||
server->begin(); // Web server start
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
@@ -678,9 +717,11 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
|
||||
if(!validApPassword()) return false;
|
||||
|
||||
// HANDLE issues with STA connections, shutdown sta if not connected, or else this will hang channel scanning and softap will not respond
|
||||
// @todo sometimes still cannot connect to AP for no known reason, no events in log either
|
||||
if(_disableSTA || (!WiFi.isConnected() && _disableSTAConn)){
|
||||
// this fixes most ap problems, however, simply doing mode(WIFI_AP) does not work if sta connection is hanging, must `wifi_station_disconnect`
|
||||
#ifdef WM_DISCONWORKAROUND
|
||||
WiFi.mode(WIFI_AP_STA);
|
||||
#endif
|
||||
WiFi_Disconnect();
|
||||
WiFi_enableSTA(false);
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
@@ -688,8 +729,7 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
// @todo even if sta is connected, it is possible that softap connections will fail, IOS says "invalid password", windows says "cannot connect to this network" researching
|
||||
WiFi_enableSTA(true);
|
||||
// WiFi_enableSTA(true);
|
||||
}
|
||||
|
||||
// init configportal globals to known states
|
||||
@@ -750,6 +790,12 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
|
||||
#endif
|
||||
shutdownConfigPortal();
|
||||
result = abort ? portalAbortResult : portalTimeoutResult; // false, false
|
||||
if (_configportaltimeoutcallback != NULL) {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("[CB] config portal timeout callback"));
|
||||
#endif
|
||||
_configportaltimeoutcallback(); // @CALLBACK
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -757,6 +803,7 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
|
||||
|
||||
// status change, break
|
||||
// @todo what is this for, should be moved inside the processor
|
||||
// I think.. this is to detect autoconnect by esp in background, there are also many open issues about autoreconnect not working
|
||||
if(state != WL_IDLE_STATUS){
|
||||
result = (state == WL_CONNECTED); // true if connected
|
||||
DEBUG_WM(DEBUG_DEV,F("configportal loop break"));
|
||||
@@ -785,28 +832,36 @@ boolean WiFiManager::process(){
|
||||
MDNS.update();
|
||||
#endif
|
||||
|
||||
if(configPortalActive && !_configPortalIsBlocking){
|
||||
if(configPortalHasTimeout()) shutdownConfigPortal();
|
||||
}
|
||||
|
||||
if(webPortalActive || (configPortalActive && !_configPortalIsBlocking)){
|
||||
|
||||
// if timed out or abort, break
|
||||
if(_allowExit && (configPortalHasTimeout() || abort)){
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(DEBUG_DEV,F("process loop abort"));
|
||||
#endif
|
||||
webPortalActive = false;
|
||||
shutdownConfigPortal();
|
||||
if (_configportaltimeoutcallback != NULL) {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("[CB] config portal timeout callback"));
|
||||
#endif
|
||||
_configportaltimeoutcallback(); // @CALLBACK
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
uint8_t state = processConfigPortal();
|
||||
uint8_t state = processConfigPortal(); // state is WL_IDLE or WL_CONNECTED/FAILED
|
||||
return state == WL_CONNECTED;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//using esp wl_status enums as returns for now, should be fine
|
||||
/**
|
||||
* [processConfigPortal description]
|
||||
* using esp wl_status enums as returns for now, should be fine
|
||||
* returns WL_IDLE_STATUS or WL_CONNECTED/WL_CONNECT_FAILED upon connect/save flag
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
uint8_t WiFiManager::processConfigPortal(){
|
||||
if(configPortalActive){
|
||||
//DNS handler
|
||||
@@ -848,7 +903,7 @@ uint8_t WiFiManager::processConfigPortal(){
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("[CB] _savewificallback calling"));
|
||||
#endif
|
||||
_savewificallback();
|
||||
_savewificallback(); // @CALLBACK
|
||||
}
|
||||
if(!_connectonsave) return WL_IDLE_STATUS;
|
||||
if(_disableConfigPortal) shutdownConfigPortal();
|
||||
@@ -868,7 +923,7 @@ uint8_t WiFiManager::processConfigPortal(){
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("[CB] WiFi/Param save callback"));
|
||||
#endif
|
||||
_savewificallback();
|
||||
_savewificallback(); // @CALLBACK
|
||||
}
|
||||
if(_disableConfigPortal) shutdownConfigPortal();
|
||||
return WL_CONNECT_FAILED; // CONNECT FAIL
|
||||
@@ -915,6 +970,7 @@ bool WiFiManager::shutdownConfigPortal(){
|
||||
server->handleClient();
|
||||
|
||||
// @todo what is the proper way to shutdown and free the server up
|
||||
// debug - many open issues aobut port not clearing for use with other servers
|
||||
server->stop();
|
||||
server.reset();
|
||||
|
||||
@@ -972,7 +1028,7 @@ uint8_t WiFiManager::connectWifi(String ssid, String pass, bool connect) {
|
||||
// make sure sta is on before `begin` so it does not call enablesta->mode while persistent is ON ( which would save WM AP state to eeprom !)
|
||||
// WiFi.setAutoReconnect(false);
|
||||
if(_cleanConnect) WiFi_Disconnect(); // disconnect before begin, in case anything is hung, this causes a 2 seconds delay for connect
|
||||
// @todo find out what status is when this is needed, can we detect it and handle it, say in between states or idle_status
|
||||
// @todo find out what status is when this is needed, can we detect it and handle it, say in between states or idle_status to avoid these
|
||||
|
||||
// if retry without delay (via begin()), the IDF is still busy even after returning status
|
||||
// E (5130) wifi:sta is connecting, return error
|
||||
@@ -1423,11 +1479,20 @@ bool WiFiManager::WiFi_scanNetworks(bool force,bool async){
|
||||
// DEBUG_WM(DEBUG_DEV,_numNetworks,(millis()-_lastscan ));
|
||||
// DEBUG_WM(DEBUG_DEV,"scanNetworks force:",force == true);
|
||||
#endif
|
||||
if(_numNetworks == 0){
|
||||
|
||||
// if 0 networks, rescan @note this was a kludge, now disabling to test real cause ( maybe wifi not init etc)
|
||||
// enable only if preload failed?
|
||||
if(_numNetworks == 0 && _autoforcerescan){
|
||||
DEBUG_WM(DEBUG_DEV,"NO APs found forcing new scan");
|
||||
force = true;
|
||||
}
|
||||
if(force || (_lastscan>0 && (millis()-_lastscan > 60000))){
|
||||
|
||||
// if scan is empty or stale (last scantime > _scancachetime), this avoids fast reloading wifi page and constant scan delayed page loads appearing to freeze.
|
||||
if(!_lastscan || (_lastscan>0 && (millis()-_lastscan > _scancachetime))){
|
||||
force = true;
|
||||
}
|
||||
|
||||
if(force){
|
||||
int8_t res;
|
||||
_startscan = millis();
|
||||
if(async && _asyncScan){
|
||||
@@ -1668,7 +1733,7 @@ String WiFiManager::getParamOut(){
|
||||
char valLength[5];
|
||||
|
||||
for (int i = 0; i < _paramsCount; i++) {
|
||||
Serial.println((String)_params[i]->_length);
|
||||
//Serial.println((String)_params[i]->_length);
|
||||
if (_params[i] == NULL || _params[i]->_length == 0 || _params[i]->_length > 99999) {
|
||||
// try to detect param scope issues, doesnt always catch but works ok
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
@@ -1744,17 +1809,11 @@ void WiFiManager::handleWifiSave() {
|
||||
#endif
|
||||
handleRequest();
|
||||
|
||||
// @todo use new callback for before paramsaves
|
||||
if (!_paramsInWifi && _presavecallback != NULL) {
|
||||
_presavecallback();
|
||||
}
|
||||
|
||||
//SAVE/connect here
|
||||
_ssid = server->arg(F("s")).c_str();
|
||||
_pass = server->arg(F("p")).c_str();
|
||||
|
||||
if(_paramsInWifi) doParamSave();
|
||||
|
||||
// set static ips from server args
|
||||
if (server->arg(FPSTR(S_ip)) != "") {
|
||||
//_sta_static_ip.fromString(server->arg(FPSTR(S_ip));
|
||||
String ip = server->arg(FPSTR(S_ip));
|
||||
@@ -1785,6 +1844,12 @@ void WiFiManager::handleWifiSave() {
|
||||
#endif
|
||||
}
|
||||
|
||||
if (_presavewificallback != NULL) {
|
||||
_presavewificallback(); // @CALLBACK
|
||||
}
|
||||
|
||||
if(_paramsInWifi) doParamSave();
|
||||
|
||||
String page;
|
||||
|
||||
if(_ssid == ""){
|
||||
@@ -1795,6 +1860,8 @@ void WiFiManager::handleWifiSave() {
|
||||
page = getHTTPHead(FPSTR(S_titlewifisaved)); // @token titlewifisaved
|
||||
page += FPSTR(HTTP_SAVED);
|
||||
}
|
||||
|
||||
if(_showBack) page += FPSTR(HTTP_BACKBTN);
|
||||
page += FPSTR(HTTP_END);
|
||||
|
||||
server->sendHeader(FPSTR(HTTP_HEAD_CORS), FPSTR(HTTP_HEAD_CORS_ALLOW_ALL)); // @HTTPHEAD send cors
|
||||
@@ -1821,6 +1888,7 @@ void WiFiManager::handleParamSave() {
|
||||
|
||||
String page = getHTTPHead(FPSTR(S_titleparamsaved)); // @token titleparamsaved
|
||||
page += FPSTR(HTTP_PARAMSAVED);
|
||||
if(_showBack) page += FPSTR(HTTP_BACKBTN);
|
||||
page += FPSTR(HTTP_END);
|
||||
|
||||
HTTPSend(page);
|
||||
@@ -1832,8 +1900,8 @@ void WiFiManager::handleParamSave() {
|
||||
|
||||
void WiFiManager::doParamSave(){
|
||||
// @todo use new callback for before paramsaves, is this really needed?
|
||||
if ( _presavecallback != NULL) {
|
||||
_presavecallback();
|
||||
if ( _presaveparamscallback != NULL) {
|
||||
_presaveparamscallback(); // @CALLBACK
|
||||
}
|
||||
|
||||
//parameters
|
||||
@@ -1871,7 +1939,7 @@ void WiFiManager::doParamSave(){
|
||||
}
|
||||
|
||||
if ( _saveparamscallback != NULL) {
|
||||
_saveparamscallback();
|
||||
_saveparamscallback(); // @CALLBACK
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1926,7 +1994,7 @@ void WiFiManager::handleInfo() {
|
||||
|
||||
#elif defined(ESP32)
|
||||
// add esp_chip_info ?
|
||||
infos = 26;
|
||||
infos = 27;
|
||||
String infoids[] = {
|
||||
F("esphead"),
|
||||
F("uptime"),
|
||||
@@ -1939,6 +2007,8 @@ void WiFiManager::handleInfo() {
|
||||
F("memsketch"),
|
||||
F("memsmeter"),
|
||||
F("lastreset"),
|
||||
F("temp"),
|
||||
// F("hall"),
|
||||
F("wifihead"),
|
||||
F("conx"),
|
||||
F("stassid"),
|
||||
@@ -1954,7 +2024,6 @@ void WiFiManager::handleInfo() {
|
||||
F("apmac"),
|
||||
F("aphost"),
|
||||
F("apbssid")
|
||||
// F("temp")
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -1989,9 +2058,16 @@ void WiFiManager::handleInfo() {
|
||||
String WiFiManager::getInfoData(String id){
|
||||
|
||||
String p;
|
||||
// @todo add WM versioning
|
||||
if(id==F("esphead"))p = FPSTR(HTTP_INFO_esphead);
|
||||
else if(id==F("wifihead"))p = FPSTR(HTTP_INFO_wifihead);
|
||||
if(id==F("esphead")){
|
||||
p = FPSTR(HTTP_INFO_esphead);
|
||||
#ifdef ESP32
|
||||
p.replace(FPSTR(T_1), (String)ESP.getChipModel());
|
||||
#endif
|
||||
}
|
||||
else if(id==F("wifihead")){
|
||||
p = FPSTR(HTTP_INFO_wifihead);
|
||||
p.replace(FPSTR(T_1),getModeString(WiFi.getMode()));
|
||||
}
|
||||
else if(id==F("uptime")){
|
||||
// subject to rollover!
|
||||
p = FPSTR(HTTP_INFO_uptime);
|
||||
@@ -2169,15 +2245,17 @@ String WiFiManager::getInfoData(String id){
|
||||
p.replace(FPSTR(T_1),WiFi.getAutoConnect() ? FPSTR(S_enable) : FPSTR(S_disable));
|
||||
}
|
||||
#endif
|
||||
#ifdef ESP32
|
||||
#if defined(ESP32) && !defined(WM_NOTEMP)
|
||||
else if(id==F("temp")){
|
||||
// temperature is not calibrated, varying large offsets are present, use for relative temp changes only
|
||||
p = FPSTR(HTTP_INFO_temp);
|
||||
p.replace(FPSTR(T_1),(String)temperatureRead());
|
||||
p.replace(FPSTR(T_2),(String)((temperatureRead()+32)*1.8));
|
||||
// p.replace(FPSTR(T_3),(String)hallRead());
|
||||
p.replace(FPSTR(T_3),"NA");
|
||||
}
|
||||
// else if(id==F("hall")){
|
||||
// p = FPSTR(HTTP_INFO_hall);
|
||||
// p.replace(FPSTR(T_1),(String)hallRead()); // hall sensor reads can cause issues with adcs
|
||||
// }
|
||||
#endif
|
||||
else if(id==F("aboutver")){
|
||||
p = FPSTR(HTTP_INFO_aboutver);
|
||||
@@ -2206,7 +2284,7 @@ String WiFiManager::getInfoData(String id){
|
||||
}
|
||||
else if(id==F("aboutdate")){
|
||||
p = FPSTR(HTTP_INFO_aboutdate);
|
||||
p.replace(FPSTR(T_1),String(__DATE__) + " " + String(__TIME__));
|
||||
p.replace(FPSTR(T_1),String(__DATE__ " " __TIME__));
|
||||
}
|
||||
return p;
|
||||
}
|
||||
@@ -2316,7 +2394,7 @@ void WiFiManager::handleNotFound() {
|
||||
*/
|
||||
boolean WiFiManager::captivePortal() {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(DEBUG_DEV,"-> " + server->hostHeader());
|
||||
DEBUG_WM(DEBUG_MAX,"-> " + server->hostHeader());
|
||||
#endif
|
||||
|
||||
if(!_enableCaptivePortal) return false; // skip redirections, @todo maybe allow redirection even when no cp ? might be useful
|
||||
@@ -2517,7 +2595,7 @@ void WiFiManager::resetSettings() {
|
||||
WiFi_enableSTA(true,true); // must be sta to disconnect erase
|
||||
delay(500); // ensure sta is enabled
|
||||
if (_resetcallback != NULL){
|
||||
_resetcallback();
|
||||
_resetcallback(); // @CALLBACK
|
||||
}
|
||||
|
||||
#ifdef ESP32
|
||||
@@ -2700,6 +2778,15 @@ void WiFiManager::setSaveConfigCallback( std::function<void()> func ) {
|
||||
_savewificallback = func;
|
||||
}
|
||||
|
||||
/**
|
||||
* setPreSaveConfigCallback, set a callback to fire before saving wifi or params
|
||||
* @access public
|
||||
* @param {[type]} void (*func)(void)
|
||||
*/
|
||||
void WiFiManager::setPreSaveConfigCallback( std::function<void()> func ) {
|
||||
_presavewificallback = func;
|
||||
}
|
||||
|
||||
/**
|
||||
* setConfigResetCallback, set a callback to occur when a resetSettings() occurs
|
||||
* @access public
|
||||
@@ -2719,12 +2806,12 @@ void WiFiManager::setSaveParamsCallback( std::function<void()> func ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* setPreSaveConfigCallback, set a callback to fire before saving wifi or params
|
||||
* setPreSaveParamsCallback, set a pre save params callback on params save prior to anything else
|
||||
* @access public
|
||||
* @param {[type]} void (*func)(void)
|
||||
*/
|
||||
void WiFiManager::setPreSaveConfigCallback( std::function<void()> func ) {
|
||||
_presavecallback = func;
|
||||
void WiFiManager::setPreSaveParamsCallback( std::function<void()> func ) {
|
||||
_presaveparamscallback = func;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2737,12 +2824,12 @@ void WiFiManager::setPreOtaUpdateCallback( std::function<void()> func ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* setDisconnectedCallback, set a callback to fire when WiFi is disconnected
|
||||
* setConfigPortalTimeoutCallback, set a callback to config portal is timeout
|
||||
* @access public
|
||||
* @param {[type]} void (*func)(void)
|
||||
*/
|
||||
void WiFiManager::setDisconnectedCallback( std::function<void()> func ) {
|
||||
_disconnectedcallback = func;
|
||||
void WiFiManager::setConfigPortalTimeoutCallback( std::function<void()> func ) {
|
||||
_configportaltimeoutcallback = func;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -3287,26 +3374,25 @@ void WiFiManager::debugPlatformInfo(){
|
||||
#ifdef ESP8266
|
||||
system_print_meminfo();
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(F("getCoreVersion(): "),ESP.getCoreVersion());
|
||||
DEBUG_WM(F("system_get_sdk_version(): "),system_get_sdk_version());
|
||||
DEBUG_WM(F("system_get_boot_version():"),system_get_boot_version());
|
||||
DEBUG_WM(F("getFreeHeap(): "),(String)ESP.getFreeHeap());
|
||||
DEBUG_WM(F("[SYS] getCoreVersion(): "),ESP.getCoreVersion());
|
||||
DEBUG_WM(F("[SYS] system_get_sdk_version(): "),system_get_sdk_version());
|
||||
DEBUG_WM(F("[SYS] system_get_boot_version():"),system_get_boot_version());
|
||||
DEBUG_WM(F("[SYS] getFreeHeap(): "),(String)ESP.getFreeHeap());
|
||||
#endif
|
||||
#elif defined(ESP32)
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(F("Free heap: "), ESP.getFreeHeap());
|
||||
DEBUG_WM(F("ESP SDK version: "), ESP.getSdkVersion());
|
||||
DEBUG_WM(F("[SYS] WM version: "), WM_VERSION_STR);
|
||||
DEBUG_WM(F("[SYS] Arduino version: "), VER_ARDUINO_STR);
|
||||
DEBUG_WM(F("[SYS] ESP SDK version: "), ESP.getSdkVersion());
|
||||
DEBUG_WM(F("[SYS] Free heap: "), ESP.getFreeHeap());
|
||||
#endif
|
||||
// esp_chip_info_t chipInfo;
|
||||
// esp_chip_info(&chipInfo);
|
||||
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
// DEBUG_WM("Chip Info: Model: ",chipInfo.model);
|
||||
// DEBUG_WM("Chip Info: Cores: ",chipInfo.cores);
|
||||
// DEBUG_WM("Chip Info: Rev: ",chipInfo.revision);
|
||||
// DEBUG_WM(printf("Chip Info: Model: %d, cores: %d, revision: %d", chipInfo.model.c_str(), chipInfo.cores, chipInfo.revision));
|
||||
// DEBUG_WM("Chip Rev: ",(String)ESP.getChipRevision());
|
||||
DEBUG_WM(F("[SYS] Chip ID:"),WIFI_getChipId());
|
||||
DEBUG_WM(F("[SYS] Chip Model:"), ESP.getChipModel());
|
||||
DEBUG_WM(F("[SYS] Chip Cores:"), ESP.getChipCores());
|
||||
DEBUG_WM(F("[SYS] Chip Rev:"), ESP.getChipRevision());
|
||||
#endif
|
||||
// core version is not avail
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -3353,7 +3439,7 @@ boolean WiFiManager::validApPassword(){
|
||||
DEBUG_WM(F("AccessPoint set password is INVALID or <8 chars"));
|
||||
#endif
|
||||
_apPassword = "";
|
||||
return false; // @todo FATAL or fallback to empty ?
|
||||
return false; // @todo FATAL or fallback to empty , currently fatal, fail secure.
|
||||
}
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("AccessPoint set password is VALID"));
|
||||
@@ -3373,6 +3459,7 @@ String WiFiManager::htmlEntities(String str, bool whitespace) {
|
||||
str.replace("&","&");
|
||||
str.replace("<","<");
|
||||
str.replace(">",">");
|
||||
str.replace("'","'");
|
||||
if(whitespace) str.replace(" "," ");
|
||||
// str.replace("-","–");
|
||||
// str.replace("\"",""");
|
||||
@@ -3432,20 +3519,29 @@ bool WiFiManager::WiFiSetCountry(){
|
||||
// ret = esp_wifi_set_bandwidth(WIFI_IF_AP,WIFI_BW_HT20); // WIFI_BW_HT40
|
||||
#ifdef ESP32
|
||||
esp_err_t err = ESP_OK;
|
||||
// @todo check if wifi is init, no idea how, doesnt seem to be exposed atm ( might be now! )
|
||||
// @todo check if wifi is init, no idea how, doesnt seem to be exposed atm ( check again it might be now! )
|
||||
if(WiFi.getMode() == WIFI_MODE_NULL){
|
||||
DEBUG_WM(DEBUG_ERROR,"[ERROR] cannot set country, wifi not init");
|
||||
} // exception if wifi not init!
|
||||
else if(_wificountry == "US") err = esp_wifi_set_country(&WM_COUNTRY_US);
|
||||
else if(_wificountry == "JP") err = esp_wifi_set_country(&WM_COUNTRY_JP);
|
||||
else if(_wificountry == "CN") err = esp_wifi_set_country(&WM_COUNTRY_CN);
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
else{
|
||||
DEBUG_WM(DEBUG_ERROR,"[ERROR] country code not found");
|
||||
// Assumes that _wificountry is set to one of the supported country codes : "01"(world safe mode) "AT","AU","BE","BG","BR",
|
||||
// "CA","CH","CN","CY","CZ","DE","DK","EE","ES","FI","FR","GB","GR","HK","HR","HU",
|
||||
// "IE","IN","IS","IT","JP","KR","LI","LT","LU","LV","MT","MX","NL","NO","NZ","PL","PT",
|
||||
// "RO","SE","SI","SK","TW","US"
|
||||
// If an invalid country code is passed, ESP_ERR_WIFI_ARG will be returned
|
||||
// This also uses 802.11d mode, which matches the STA to the country code of the AP it connects to (meaning
|
||||
// that the country code will be overridden if connecting to a "foreign" AP)
|
||||
else {
|
||||
#ifndef WM_NOCOUNTRY
|
||||
err = esp_wifi_set_country_code(_wificountry.c_str(), true);
|
||||
#else
|
||||
DEBUG_WM(DEBUG_ERROR,"[ERROR] esp wifi set country is not available");
|
||||
err = true;
|
||||
#endif
|
||||
}
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
if(err){
|
||||
if(err == ESP_ERR_WIFI_NOT_INIT) DEBUG_WM(DEBUG_ERROR,"[ERROR] ESP_ERR_WIFI_NOT_INIT");
|
||||
else if(err == ESP_ERR_INVALID_ARG) DEBUG_WM(DEBUG_ERROR,"[ERROR] ESP_ERR_WIFI_ARG");
|
||||
else if(err == ESP_ERR_INVALID_ARG) DEBUG_WM(DEBUG_ERROR,"[ERROR] ESP_ERR_WIFI_ARG (invalid country code)");
|
||||
else if(err != ESP_OK)DEBUG_WM(DEBUG_ERROR,"[ERROR] unknown error",(String)err);
|
||||
}
|
||||
#endif
|
||||
@@ -3482,7 +3578,7 @@ bool WiFiManager::WiFi_Mode(WiFiMode_t m,bool persistent) {
|
||||
return ret;
|
||||
#elif defined(ESP32)
|
||||
if(persistent && esp32persistent) WiFi.persistent(true);
|
||||
ret = WiFi.mode(m); // @todo persistent check persistant mode , NI
|
||||
ret = WiFi.mode(m); // @todo persistent check persistant mode, was eventually added to esp lib, but have to add version checking probably
|
||||
if(persistent && esp32persistent) WiFi.persistent(false);
|
||||
return ret;
|
||||
#endif
|
||||
@@ -3499,7 +3595,7 @@ bool WiFiManager::WiFi_Disconnect() {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(DEBUG_DEV,F("WiFi station disconnect"));
|
||||
#endif
|
||||
ETS_UART_INTR_DISABLE(); // @todo probably not needed
|
||||
ETS_UART_INTR_DISABLE(); // @todo possibly not needed
|
||||
ret = wifi_station_disconnect();
|
||||
ETS_UART_INTR_ENABLE();
|
||||
return ret;
|
||||
@@ -3577,7 +3673,7 @@ bool WiFiManager::WiFi_eraseConfig() {
|
||||
bool ret;
|
||||
WiFi.mode(WIFI_AP_STA); // cannot erase if not in STA mode !
|
||||
WiFi.persistent(true);
|
||||
ret = WiFi.disconnect(true,true);
|
||||
ret = WiFi.disconnect(true,true); // disconnect(bool wifioff, bool eraseap)
|
||||
delay(500);
|
||||
WiFi.persistent(false);
|
||||
return ret;
|
||||
@@ -3672,12 +3768,6 @@ String WiFiManager::WiFi_psk(bool persistent) const {
|
||||
// DEBUG_WM(DEBUG_VERBOSE,"[EVENT]",event);
|
||||
#endif
|
||||
if(event == ARDUINO_EVENT_WIFI_STA_DISCONNECTED){
|
||||
|
||||
if(_disconnectedcallback != nullptr)
|
||||
{
|
||||
_disconnectedcallback();
|
||||
}
|
||||
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(DEBUG_VERBOSE,F("[EVENT] WIFI_REASON: "),info.wifi_sta_disconnected.reason);
|
||||
#endif
|
||||
@@ -3698,7 +3788,7 @@ String WiFiManager::WiFi_psk(bool persistent) const {
|
||||
WiFi.reconnect();
|
||||
#endif
|
||||
}
|
||||
else if(event == ARDUINO_EVENT_WIFI_SCAN_DONE){
|
||||
else if(event == ARDUINO_EVENT_WIFI_SCAN_DONE && _asyncScan){
|
||||
uint16_t scans = WiFi.scanComplete();
|
||||
WiFi_scanComplete(scans);
|
||||
}
|
||||
@@ -3751,7 +3841,8 @@ void WiFiManager::handleUpdating(){
|
||||
// combine route handlers into one callback and use argument or post checking instead of mutiple functions maybe, if POST process else server upload page?
|
||||
// [x] add upload checking, do we need too check file?
|
||||
// convert output to debugger if not moving to example
|
||||
if (captivePortal()) return; // If captive portal redirect instead of displaying the page
|
||||
|
||||
// if (captivePortal()) return; // If captive portal redirect instead of displaying the page
|
||||
bool error = false;
|
||||
unsigned long _configPortalTimeoutSAV = _configPortalTimeout; // store cp timeout
|
||||
_configPortalTimeout = 0; // disable timeout
|
||||
@@ -3762,12 +3853,12 @@ void WiFiManager::handleUpdating(){
|
||||
|
||||
// UPLOAD START
|
||||
if (upload.status == UPLOAD_FILE_START) {
|
||||
if(_debug) Serial.setDebugOutput(true);
|
||||
// if(_debug) Serial.setDebugOutput(true);
|
||||
uint32_t maxSketchSpace;
|
||||
|
||||
// Use new callback for before OTA update
|
||||
if (_preotaupdatecallback != NULL) {
|
||||
_preotaupdatecallback();
|
||||
_preotaupdatecallback(); // @CALLBACK
|
||||
}
|
||||
#ifdef ESP8266
|
||||
WiFiUDP::stopAll();
|
||||
@@ -3780,9 +3871,14 @@ void WiFiManager::handleUpdating(){
|
||||
#endif
|
||||
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(DEBUG_VERBOSE,"Update file: ", upload.filename.c_str());
|
||||
DEBUG_WM(DEBUG_VERBOSE,"[OTA] Update file: ", upload.filename.c_str());
|
||||
#endif
|
||||
|
||||
// Update.onProgress(THandlerFunction_Progress fn);
|
||||
// Update.onProgress([](unsigned int progress, unsigned int total) {
|
||||
// Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
|
||||
// });
|
||||
|
||||
if (!Update.begin(maxSketchSpace)) { // start with max available size
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(DEBUG_ERROR,F("[ERROR] OTA Update ERROR"), Update.getError());
|
||||
@@ -3793,7 +3889,7 @@ void WiFiManager::handleUpdating(){
|
||||
}
|
||||
// UPLOAD WRITE
|
||||
else if (upload.status == UPLOAD_FILE_WRITE) {
|
||||
Serial.print(".");
|
||||
// Serial.print(".");
|
||||
if (Update.write(upload.buf, upload.currentSize) != upload.currentSize) {
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
DEBUG_WM(DEBUG_ERROR,F("[ERROR] OTA Update WRITE ERROR"), Update.getError());
|
||||
@@ -3811,7 +3907,7 @@ void WiFiManager::handleUpdating(){
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
Update.printError(Serial);
|
||||
// Update.printError(Serial);
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
@@ -3828,7 +3924,7 @@ void WiFiManager::handleUpdating(){
|
||||
// upload and ota done, show status
|
||||
void WiFiManager::handleUpdateDone() {
|
||||
DEBUG_WM(DEBUG_VERBOSE, F("<- Handle update done"));
|
||||
if (captivePortal()) return; // If captive portal redirect instead of displaying the page
|
||||
// if (captivePortal()) return; // If captive portal redirect instead of displaying the page
|
||||
|
||||
String page = getHTTPHead(FPSTR(S_options)); // @token options
|
||||
String str = FPSTR(HTTP_ROOT_MAIN);
|
||||
|
||||
@@ -39,6 +39,23 @@
|
||||
#define WM_NOSOFTAPSSID // no softapssid() @todo shim
|
||||
#endif
|
||||
|
||||
// #ifdef CONFIG_IDF_TARGET_ESP32S2
|
||||
// #warning ESP32S2
|
||||
// #endif
|
||||
|
||||
// #ifdef CONFIG_IDF_TARGET_ESP32C3
|
||||
// #warning ESP32C3
|
||||
// #endif
|
||||
|
||||
// #ifdef CONFIG_IDF_TARGET_ESP32S3
|
||||
// #warning ESP32S3
|
||||
// #endif
|
||||
|
||||
#if defined(ARDUINO_ESP32S3_DEV) || defined(CONFIG_IDF_TARGET_ESP32S3)
|
||||
#warning "WM_NOTEMP"
|
||||
#define WM_NOTEMP // disabled temp sensor, have to determine which chip we are on
|
||||
#endif
|
||||
|
||||
// #include "soc/efuse_reg.h" // include to add efuse chip rev to info, getChipRevision() is almost always the same though, so not sure why it matters.
|
||||
|
||||
// #define esp32autoreconnect // implement esp32 autoreconnect event listener kludge, @DEPRECATED
|
||||
@@ -46,32 +63,7 @@
|
||||
|
||||
#define WM_WEBSERVERSHIM // use webserver shim lib
|
||||
|
||||
#define G(string_literal) (String(FPSTR(string_literal)).c_str())
|
||||
|
||||
#define STRING2(x) #x
|
||||
#define STRING(x) STRING2(x)
|
||||
|
||||
// #include <esp_idf_version.h>
|
||||
#ifdef ESP_IDF_VERSION
|
||||
// #pragma message "ESP_IDF_VERSION_MAJOR = " STRING(ESP_IDF_VERSION_MAJOR)
|
||||
// #pragma message "ESP_IDF_VERSION_MINOR = " STRING(ESP_IDF_VERSION_MINOR)
|
||||
// #pragma message "ESP_IDF_VERSION_PATCH = " STRING(ESP_IDF_VERSION_PATCH)
|
||||
#define VER_IDF_STR STRING(ESP_IDF_VERSION_MAJOR) "." STRING(ESP_IDF_VERSION_MINOR) "." STRING(ESP_IDF_VERSION_PATCH)
|
||||
#endif
|
||||
|
||||
// #include "esp_arduino_version.h"
|
||||
#ifdef ESP_ARDUINO_VERSION
|
||||
// #pragma message "ESP_ARDUINO_VERSION_MAJOR = " STRING(ESP_ARDUINO_VERSION_MAJOR)
|
||||
// #pragma message "ESP_ARDUINO_VERSION_MINOR = " STRING(ESP_ARDUINO_VERSION_MINOR)
|
||||
// #pragma message "ESP_ARDUINO_VERSION_PATCH = " STRING(ESP_ARDUINO_VERSION_PATCH)
|
||||
#define VER_ARDUINO_STR STRING(ESP_ARDUINO_VERSION_MAJOR) "." STRING(ESP_ARDUINO_VERSION_MINOR) "." STRING(ESP_ARDUINO_VERSION_PATCH)
|
||||
#else
|
||||
// #include <core_version.h>
|
||||
// #pragma message "ESP_ARDUINO_VERSION_GIT = " STRING(ARDUINO_ESP32_GIT_VER)// 0x46d5afb1
|
||||
// #pragma message "ESP_ARDUINO_VERSION_DESC = " STRING(ARDUINO_ESP32_GIT_DESC) // 1.0.6
|
||||
#define VER_ARDUINO_STR "Unknown"
|
||||
// #pragma message "ESP_ARDUINO_VERSION_REL = " STRING(ARDUINO_ESP32_RELEASE) //"1_0_6"
|
||||
#endif
|
||||
#define WM_G(string_literal) (String(FPSTR(string_literal)).c_str())
|
||||
|
||||
#ifdef ESP8266
|
||||
|
||||
@@ -117,7 +109,21 @@
|
||||
#endif
|
||||
|
||||
#ifdef WM_RTC
|
||||
#include <rom/rtc.h>
|
||||
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
|
||||
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
|
||||
#include "esp32/rom/rtc.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/rom/rtc.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/rtc.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/rtc.h"
|
||||
#else
|
||||
#error Target CONFIG_IDF_TARGET is not supported
|
||||
#endif
|
||||
#else // ESP32 Before IDF 4.0
|
||||
#include "rom/rtc.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#else
|
||||
@@ -125,7 +131,60 @@
|
||||
|
||||
#include <DNSServer.h>
|
||||
#include <memory>
|
||||
#include "strings_en.h"
|
||||
|
||||
|
||||
// Include wm strings vars
|
||||
// Pass in strings env override via WM_STRINGS_FILE
|
||||
#ifndef WM_STRINGS_FILE
|
||||
#define WM_STRINGS_FILE "wm_strings_en.h" // this includes constants as dependency
|
||||
#endif
|
||||
#include WM_STRINGS_FILE
|
||||
|
||||
// prep string concat vars
|
||||
#define WM_STRING2(x) #x
|
||||
#define WM_STRING(x) WM_STRING2(x)
|
||||
|
||||
// #include <esp_idf_version.h>
|
||||
#ifdef ESP_IDF_VERSION
|
||||
// #pragma message "ESP_IDF_VERSION_MAJOR = " WM_STRING(ESP_IDF_VERSION_MAJOR)
|
||||
// #pragma message "ESP_IDF_VERSION_MINOR = " WM_STRING(ESP_IDF_VERSION_MINOR)
|
||||
// #pragma message "ESP_IDF_VERSION_PATCH = " WM_STRING(ESP_IDF_VERSION_PATCH)
|
||||
#define VER_IDF_STR WM_STRING(ESP_IDF_VERSION_MAJOR) "." WM_STRING(ESP_IDF_VERSION_MINOR) "." WM_STRING(ESP_IDF_VERSION_PATCH)
|
||||
#else
|
||||
#define VER_IDF_STR "Unknown"
|
||||
#endif
|
||||
|
||||
#ifdef Arduino_h
|
||||
#ifdef ESP32
|
||||
// #include "esp_arduino_version.h" // esp32 arduino > 2.x
|
||||
#endif
|
||||
// esp_get_idf_version
|
||||
#ifdef ESP_ARDUINO_VERSION
|
||||
// #pragma message "ESP_ARDUINO_VERSION_MAJOR = " WM_STRING(ESP_ARDUINO_VERSION_MAJOR)
|
||||
// #pragma message "ESP_ARDUINO_VERSION_MINOR = " WM_STRING(ESP_ARDUINO_VERSION_MINOR)
|
||||
// #pragma message "ESP_ARDUINO_VERSION_PATCH = " WM_STRING(ESP_ARDUINO_VERSION_PATCH)
|
||||
#ifdef ESP_ARDUINO_VERSION_MAJOR
|
||||
#define VER_ARDUINO_STR WM_STRING(ESP_ARDUINO_VERSION_MAJOR) "." WM_STRING(ESP_ARDUINO_VERSION_MINOR) "." WM_STRING(ESP_ARDUINO_VERSION_PATCH)
|
||||
#else
|
||||
#define VER_ARDUINO_STR "Unknown"
|
||||
#endif
|
||||
#else
|
||||
#include <core_version.h>
|
||||
// #pragma message "ESP_ARDUINO_VERSION_GIT = " WM_STRING(ARDUINO_ESP32_GIT_VER)// 0x46d5afb1
|
||||
// #pragma message "ESP_ARDUINO_VERSION_DESC = " WM_STRING(ARDUINO_ESP32_GIT_DESC) // 1.0.6
|
||||
// #pragma message "ESP_ARDUINO_VERSION_REL = " WM_STRING(ARDUINO_ESP32_RELEASE) //"1_0_6"
|
||||
#ifdef ESP_ARDUINO_VERSION_MAJOR
|
||||
#define VER_ARDUINO_STR WM_STRING(ESP_ARDUINO_VERSION_MAJOR) "." WM_STRING(ESP_ARDUINO_VERSION_MINOR) "." WM_STRING(ESP_ARDUINO_VERSION_PATCH)
|
||||
#else
|
||||
#define VER_ARDUINO_STR "Unknown"
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#define VER_ARDUINO_STR "Unknown"
|
||||
#endif
|
||||
|
||||
// #pragma message "VER_IDF_STR = " WM_STRING(VER_IDF_STR)
|
||||
// #pragma message "VER_ARDUINO_STR = " WM_STRING(VER_ARDUINO_STR)
|
||||
|
||||
#ifndef WIFI_MANAGER_MAX_PARAMS
|
||||
#define WIFI_MANAGER_MAX_PARAMS 5 // params will autoincrement and realloc by this amount when max is reached
|
||||
@@ -179,7 +238,7 @@ class WiFiManagerParameter {
|
||||
class WiFiManager
|
||||
{
|
||||
public:
|
||||
WiFiManager(Stream& consolePort);
|
||||
WiFiManager(Print& consolePort);
|
||||
WiFiManager();
|
||||
~WiFiManager();
|
||||
void WiFiManagerInit();
|
||||
@@ -244,17 +303,20 @@ class WiFiManager
|
||||
//called when wifi settings have been changed and connection was successful ( or setBreakAfterConfig(true) )
|
||||
void setSaveConfigCallback( std::function<void()> func );
|
||||
|
||||
//called when saving either params-in-wifi or params page
|
||||
void setSaveParamsCallback( std::function<void()> func );
|
||||
|
||||
//called when saving params-in-wifi or params before anything else happens (eg wifi)
|
||||
void setPreSaveConfigCallback( std::function<void()> func );
|
||||
|
||||
//called when saving params before anything else happens
|
||||
void setPreSaveParamsCallback( std::function<void()> func );
|
||||
|
||||
//called when saving either params-in-wifi or params page
|
||||
void setSaveParamsCallback( std::function<void()> func );
|
||||
|
||||
//called just before doing OTA update
|
||||
void setPreOtaUpdateCallback( std::function<void()> func );
|
||||
|
||||
//called when WiFi has disconnected
|
||||
void setDisconnectedCallback( std::function<void()> func );
|
||||
//called when config portal is timeout
|
||||
void setConfigPortalTimeoutCallback( std::function<void()> func );
|
||||
|
||||
//sets timeout before AP,webserver loop ends and exits even if there has been no setup.
|
||||
//useful for devices that failed to connect at some point and got stuck in a webserver loop
|
||||
@@ -487,9 +549,10 @@ class WiFiManager
|
||||
uint16_t _httpPort = 80; // port for webserver
|
||||
// uint8_t _retryCount = 0; // counter for retries, probably not needed if synchronous
|
||||
uint8_t _connectRetries = 1; // number of sta connect retries, force reconnect, wait loop (connectimeout) does not always work and first disconnect bails
|
||||
bool _aggresiveReconn = false; // use an agrressive reconnect strategy, WILL delay conxs
|
||||
bool _aggresiveReconn = true; // use an agrressive reconnect strategy, WILL delay conxs
|
||||
// on some conn failure modes will add delays and many retries to work around esp and ap bugs, ie, anti de-auth protections
|
||||
bool _allowExit = true; // allow exit non blocking
|
||||
// https://github.com/tzapu/WiFiManager/issues/1067
|
||||
bool _allowExit = true; // allow exit in nonblocking, else user exit/abort calls will be ignored including cptimeout
|
||||
|
||||
#ifdef ESP32
|
||||
wifi_event_id_t wm_event_id = 0;
|
||||
@@ -530,6 +593,7 @@ class WiFiManager
|
||||
// internal options
|
||||
|
||||
// wifiscan notes
|
||||
// currently disabled due to issues with caching, sometimes first scan is empty esp32 wifi not init yet race, or portals hit server nonstop flood
|
||||
// The following are background wifi scanning optimizations
|
||||
// experimental to make scans faster, preload scans after starting cp, and visiting home page, so when you click wifi its already has your list
|
||||
// ideally we would add async and xhr here but I am holding off on js requirements atm
|
||||
@@ -538,9 +602,16 @@ class WiFiManager
|
||||
// async enables asyncronous scans, so they do not block anything
|
||||
// the refresh button bypasses cache
|
||||
// no aps found is problematic as scans are always going to want to run, leading to page load delays
|
||||
boolean _preloadwifiscan = false; // preload wifiscan if true
|
||||
boolean _asyncScan = false; // perform wifi network scan async
|
||||
unsigned int _scancachetime = 30000; // ms cache time for background scans
|
||||
//
|
||||
// These settings really only make sense with _preloadwifiscan true
|
||||
// but not limited to, we could run continuous background scans on various page hits, or xhr hits
|
||||
// which would be better coupled with asyncscan
|
||||
// atm preload is only done on root hit and startcp
|
||||
boolean _preloadwifiscan = true; // preload wifiscan if true
|
||||
unsigned int _scancachetime = 30000; // ms cache time for preload scans
|
||||
boolean _asyncScan = true; // perform wifi network scan async
|
||||
|
||||
boolean _autoforcerescan = false; // automatically force rescan if scan networks is 0, ignoring cache
|
||||
|
||||
boolean _disableIpFields = false; // modify function of setShow_X_Fields(false), forces ip fields off instead of default show if set, eg. _staShowStaticFields=-1
|
||||
|
||||
@@ -627,15 +698,28 @@ class WiFiManager
|
||||
#if defined(ESP_ARDUINO_VERSION) && defined(ESP_ARDUINO_VERSION_VAL)
|
||||
|
||||
#define WM_ARDUINOVERCHECK ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(2, 0, 0)
|
||||
#define WM_ARDUINOVERCHECK_204 ESP_ARDUINO_VERSION <= ESP_ARDUINO_VERSION_VAL(2, 0, 5)
|
||||
|
||||
#ifdef WM_ARDUINOVERCHECK
|
||||
#define WM_ARDUINOEVENTS
|
||||
#else
|
||||
#define WM_NOSOFTAPSSID
|
||||
#define WM_NOCOUNTRY
|
||||
#endif
|
||||
|
||||
#ifdef WM_ARDUINOVERCHECK_204
|
||||
#define WM_DISCONWORKAROUND
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define WM_NOCOUNTRY
|
||||
#endif
|
||||
|
||||
#ifdef WM_NOCOUNTRY
|
||||
#warning "ESP32 set country unavailable"
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WM_ARDUINOEVENTS
|
||||
void WiFiEvent(WiFiEvent_t event, arduino_event_info_t info);
|
||||
#else
|
||||
@@ -693,7 +777,7 @@ class WiFiManager
|
||||
|
||||
// Set default debug level
|
||||
#ifndef WM_DEBUG_LEVEL
|
||||
#define WM_DEBUG_LEVEL DEBUG_VERBOSE // development default, not release
|
||||
#define WM_DEBUG_LEVEL DEBUG_NOTIFY
|
||||
#endif
|
||||
|
||||
// override debug level OFF
|
||||
@@ -704,14 +788,14 @@ class WiFiManager
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
uint8_t _debugLevel = (uint8_t)WM_DEBUG_LEVEL;
|
||||
#else
|
||||
uint8_t _debugLevel = DEBUG_VERBOSE; // default debug level
|
||||
uint8_t _debugLevel = 0; // default debug level
|
||||
#endif
|
||||
|
||||
// @todo use DEBUG_ESP_PORT ?
|
||||
#ifdef WM_DEBUG_PORT
|
||||
Stream& _debugPort = WM_DEBUG_PORT;
|
||||
Print& _debugPort = WM_DEBUG_PORT;
|
||||
#else
|
||||
Stream& _debugPort = Serial; // debug output stream ref
|
||||
Print& _debugPort = Serial; // debug output stream ref
|
||||
#endif
|
||||
|
||||
template <typename Generic>
|
||||
@@ -729,11 +813,12 @@ class WiFiManager
|
||||
std::function<void(WiFiManager*)> _apcallback;
|
||||
std::function<void()> _webservercallback;
|
||||
std::function<void()> _savewificallback;
|
||||
std::function<void()> _presavecallback;
|
||||
std::function<void()> _presavewificallback;
|
||||
std::function<void()> _presaveparamscallback;
|
||||
std::function<void()> _saveparamscallback;
|
||||
std::function<void()> _resetcallback;
|
||||
std::function<void()> _preotaupdatecallback;
|
||||
std::function<void()> _disconnectedcallback = nullptr;
|
||||
std::function<void()> _configportaltimeoutcallback;
|
||||
|
||||
template <class T>
|
||||
auto optionalIPFromString(T *obj, const char *s) -> decltype( obj->fromString(s) ) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
|
||||
void setup() {
|
||||
WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
|
||||
// WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
|
||||
// it is a good practice to make sure your code sets wifi mode how you want it.
|
||||
|
||||
// put your setup code here, to run once:
|
||||
@@ -13,7 +13,7 @@ void setup() {
|
||||
|
||||
// reset settings - wipe stored credentials for testing
|
||||
// these are stored by the esp library
|
||||
wm.resetSettings();
|
||||
// wm.resetSettings();
|
||||
|
||||
// Automatically connect using saved credentials,
|
||||
// if connection fails, it starts an access point with the specified name ( "AutoConnectAP"),
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* Basic example using LittleFS to store data
|
||||
*/
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <LittleFS.h>
|
||||
#include <FS.h>
|
||||
|
||||
String readFile(fs::FS &fs, const char * path){
|
||||
Serial.printf("Reading file: %s\r\n", path);
|
||||
File file = fs.open(path, "r");
|
||||
if(!file || file.isDirectory()){
|
||||
Serial.println("- empty file or failed to open file");
|
||||
return String();
|
||||
}
|
||||
Serial.println("- read from file:");
|
||||
String fileContent;
|
||||
while(file.available()){
|
||||
fileContent+=String((char)file.read());
|
||||
}
|
||||
file.close();
|
||||
Serial.println(fileContent);
|
||||
return fileContent;
|
||||
}
|
||||
void writeFile(fs::FS &fs, const char * path, const char * message){
|
||||
Serial.printf("Writing file: %s\r\n", path);
|
||||
File file = fs.open(path, "w");
|
||||
if(!file){
|
||||
Serial.println("- failed to open file for writing");
|
||||
return;
|
||||
}
|
||||
if(file.print(message)){
|
||||
Serial.println("- file written");
|
||||
} else {
|
||||
Serial.println("- write failed");
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
int data = 4;
|
||||
|
||||
#include <WiFiManager.h>
|
||||
#define TRIGGER_PIN 2
|
||||
int timeout = 120; // seconds to run for
|
||||
|
||||
void setup() {
|
||||
if (!LittleFS.begin()) { //to start littlefs
|
||||
Serial.println("LittleFS mount failed");
|
||||
return;
|
||||
}
|
||||
data = readFile(LittleFS, "/data.txt").toInt();
|
||||
WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
|
||||
// put your setup code here, to run once:
|
||||
pinMode(TRIGGER_PIN, INPUT_PULLUP);
|
||||
WiFiManager wm;
|
||||
//wm.resetSettings();
|
||||
bool res;
|
||||
res = wm.autoConnect("Setup");
|
||||
if(!res) {
|
||||
Serial.println("Failed to connect");
|
||||
// ESP.restart();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if ( digitalRead(TRIGGER_PIN) == LOW) {
|
||||
WiFiManager wm;
|
||||
//wm.resetSettings();
|
||||
wm.setConfigPortalTimeout(timeout);
|
||||
if (!wm.startConfigPortal("Sharmander")) {
|
||||
Serial.println("failed to connect and hit timeout");
|
||||
delay(3000);
|
||||
ESP.restart();
|
||||
delay(5000);
|
||||
}
|
||||
Serial.println("connected...yeey :)");
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ void setup() {
|
||||
|
||||
configFile.readBytes(buf.get(), size);
|
||||
|
||||
#ifdef ARDUINOJSON_VERSION_MAJOR >= 6
|
||||
#if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6
|
||||
DynamicJsonDocument json(1024);
|
||||
auto deserializeError = deserializeJson(json, buf.get());
|
||||
serializeJson(json, Serial);
|
||||
@@ -133,7 +133,7 @@ void setup() {
|
||||
//save the custom parameters to FS
|
||||
if (shouldSaveConfig) {
|
||||
Serial.println("saving config");
|
||||
#ifdef ARDUINOJSON_VERSION_MAJOR >= 6
|
||||
#if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6
|
||||
DynamicJsonDocument json(1024);
|
||||
#else
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
@@ -148,7 +148,7 @@ void setup() {
|
||||
Serial.println("failed to open config file for writing");
|
||||
}
|
||||
|
||||
#ifdef ARDUINOJSON_VERSION_MAJOR >= 6
|
||||
#if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6
|
||||
serializeJson(json, Serial);
|
||||
serializeJson(json, configFile);
|
||||
#else
|
||||
|
||||
@@ -51,7 +51,7 @@ void setup() {
|
||||
std::unique_ptr<char[]> buf(new char[size]);
|
||||
|
||||
configFile.readBytes(buf.get(), size);
|
||||
#ifdef ARDUINOJSON_VERSION_MAJOR >= 6
|
||||
#if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6
|
||||
DynamicJsonDocument json(1024);
|
||||
auto deserializeError = deserializeJson(json, buf.get());
|
||||
serializeJson(json, Serial);
|
||||
@@ -153,7 +153,7 @@ void setup() {
|
||||
//save the custom parameters to FS
|
||||
if (shouldSaveConfig) {
|
||||
Serial.println("saving config");
|
||||
#ifdef ARDUINOJSON_VERSION_MAJOR >= 6
|
||||
#if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6
|
||||
DynamicJsonDocument json(1024);
|
||||
#else
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
@@ -172,7 +172,7 @@ void setup() {
|
||||
Serial.println("failed to open config file for writing");
|
||||
}
|
||||
|
||||
#ifdef ARDUINOJSON_VERSION_MAJOR >= 6
|
||||
#if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6
|
||||
serializeJson(json, Serial);
|
||||
serializeJson(json, configFile);
|
||||
#else
|
||||
|
||||
@@ -23,7 +23,7 @@ WiFiManager wm;
|
||||
|
||||
|
||||
// TEST OPTION FLAGS
|
||||
bool TEST_CP = true; // always start the configportal, even if ap found
|
||||
bool TEST_CP = false; // always start the configportal, even if ap found
|
||||
int TESP_CP_TIMEOUT = 90; // test cp timeout
|
||||
|
||||
bool TEST_NET = true; // do a network test after connect, (gets ntp time)
|
||||
@@ -34,6 +34,23 @@ bool WMISBLOCKING = true; // use blocking or non blocking mode, non global pa
|
||||
// char ssid[] = "*************"; // your network SSID (name)
|
||||
// char pass[] = "********"; // your network password
|
||||
|
||||
|
||||
//callbacks
|
||||
// called after AP mode and config portal has started
|
||||
// setAPCallback( std::function<void(WiFiManager*)> func );
|
||||
// called after webserver has started
|
||||
// setWebServerCallback( std::function<void()> func );
|
||||
// called when settings reset have been triggered
|
||||
// setConfigResetCallback( std::function<void()> func );
|
||||
// called when wifi settings have been changed and connection was successful ( or setBreakAfterConfig(true) )
|
||||
// setSaveConfigCallback( std::function<void()> func );
|
||||
// called when saving either params-in-wifi or params page
|
||||
// setSaveParamsCallback( std::function<void()> func );
|
||||
// called when saving params-in-wifi or params before anything else happens (eg wifi)
|
||||
// setPreSaveConfigCallback( std::function<void()> func );
|
||||
// called just before doing OTA update
|
||||
// setPreOtaUpdateCallback( std::function<void()> func );
|
||||
|
||||
void saveWifiCallback(){
|
||||
Serial.println("[CALLBACK] saveCallback fired");
|
||||
}
|
||||
@@ -64,15 +81,19 @@ void handleRoute(){
|
||||
wm.server->send(200, "text/plain", "hello from user code");
|
||||
}
|
||||
|
||||
void handlePreOtaUpdateCallback(){
|
||||
Update.onProgress([](unsigned int progress, unsigned int total) {
|
||||
Serial.printf("CUSTOM Progress: %u%%\r", (progress / (total / 100)));
|
||||
});
|
||||
}
|
||||
|
||||
void setup() {
|
||||
// WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
|
||||
// WiFi.mode(WIFI_STA); // explicitly set mode, esp can default to STA+AP
|
||||
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
// Serial1.begin(115200);
|
||||
|
||||
// Serial.setDebugOutput(true);
|
||||
delay(1000);
|
||||
|
||||
Serial.println("\n Starting");
|
||||
// WiFi.setSleepMode(WIFI_NONE_SLEEP); // disable sleep, can improve ap stability
|
||||
@@ -83,6 +104,12 @@ void setup() {
|
||||
Serial.println("[ERROR] TEST");
|
||||
Serial.println("[INFORMATION] TEST");
|
||||
|
||||
|
||||
// WiFi.setScanMethod(WIFI_ALL_CHANNEL_SCAN); // wifi_scan_method_t scanMethod
|
||||
// WiFi.setSortMethod(WIFI_CONNECT_AP_BY_SIGNAL); // wifi_sort_method_t sortMethod - WIFI_CONNECT_AP_BY_SIGNAL,WIFI_CONNECT_AP_BY_SECURITY
|
||||
// WiFi.setMinSecurity(WIFI_AUTH_WPA2_PSK);
|
||||
|
||||
wm.setDebugOutput(true);
|
||||
wm.debugPlatformInfo();
|
||||
|
||||
//reset settings - for testing
|
||||
@@ -97,6 +124,7 @@ void setup() {
|
||||
WiFiManagerParameter custom_token("api_token", "api token", "", 16);
|
||||
WiFiManagerParameter custom_tokenb("invalid token", "invalid token", "", 0); // id is invalid, cannot contain spaces
|
||||
WiFiManagerParameter custom_ipaddress("input_ip", "input IP", "", 15,"pattern='\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}'"); // custom input attrs (ip mask)
|
||||
WiFiManagerParameter custom_input_type("input_pwd", "input pass", "", 15,"type='password'"); // custom input attrs (ip mask)
|
||||
|
||||
const char _customHtml_checkbox[] = "type=\"checkbox\"";
|
||||
WiFiManagerParameter custom_checkbox("my_checkbox", "My Checkbox", "T", 2, _customHtml_checkbox,WFM_LABEL_AFTER);
|
||||
@@ -128,6 +156,7 @@ void setup() {
|
||||
wm.setWebServerCallback(bindServerCallback);
|
||||
wm.setSaveConfigCallback(saveWifiCallback);
|
||||
wm.setSaveParamsCallback(saveParamCallback);
|
||||
wm.setPreOtaUpdateCallback(handlePreOtaUpdateCallback);
|
||||
|
||||
// add all your parameters here
|
||||
wm.addParameter(&custom_html);
|
||||
@@ -137,6 +166,7 @@ void setup() {
|
||||
wm.addParameter(&custom_tokenb);
|
||||
wm.addParameter(&custom_ipaddress);
|
||||
wm.addParameter(&custom_checkbox);
|
||||
wm.addParameter(&custom_input_type);
|
||||
|
||||
wm.addParameter(&custom_html_inputs);
|
||||
|
||||
@@ -144,11 +174,21 @@ void setup() {
|
||||
custom_html.setValue("test",4);
|
||||
custom_token.setValue("test",4);
|
||||
|
||||
// set custom html head content , inside <head>
|
||||
const char* headhtml = "<meta name='color-scheme' content='dark light'><style></style><script></script>";
|
||||
wm.setCustomHeadElement(headhtml);
|
||||
// const char* icon = "
|
||||
// <link rel='icon' type='image/png' sizes='16x16' href='data:image/png;base64,
|
||||
// iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAMFBMVEU0OkArMjhobHEoPUPFEBIu
|
||||
// O0L+AAC2FBZ2JyuNICOfGx7xAwTjCAlCNTvVDA1aLzQ3COjMAAAAVUlEQVQI12NgwAaCDSA0888G
|
||||
// CItjn0szWGBJTVoGSCjWs8TleQCQYV95evdxkFT8Kpe0PLDi5WfKd4LUsN5zS1sKFolt8bwAZrCa
|
||||
// GqNYJAgFDEpQAAAzmxafI4vZWwAAAABJRU5ErkJggg==' />";
|
||||
|
||||
// set custom html menu content , inside <head>
|
||||
|
||||
// set custom html head content , inside <head>
|
||||
// examples of favicon, or meta tags etc
|
||||
// const char* headhtml = "<link rel='icon' type='image/png' href='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAADQElEQVRoQ+2YjW0VQQyE7Q6gAkgFkAogFUAqgFQAVACpAKiAUAFQAaECQgWECggVGH1PPrRvn3dv9/YkFOksoUhhfzwz9ngvKrc89JbnLxuA/63gpsCmwCADWwkNEji8fVNgotDM7osI/x777x5l9F6JyB8R4eeVql4P0y8yNsjM7KGIPBORp558T04A+CwiH1UVUItiUQmZ2XMReSEiAFgjAPBeVS96D+sCYGaUx4cFbLfmhSpnqnrZuqEJgJnd8cQplVLciAgX//Cf0ToIeOB9wpmloLQAwpnVmAXgdf6pwjpJIz+XNoeZQQZlODV9vhc1Tuf6owrAk/8qIhFbJH7eI3eEzsvydQEICqBEkZwiALfF70HyHPpqScPV5HFjeFu476SkRA0AzOfy4hYwstj2ZkDgaphE7m6XqnoS7Q0BOPs/sw0kDROzjdXcCMFCNwzIy0EcRcOvBACfh4k0wgOmBX4xjfmk4DKTS31hgNWIKBCI8gdzogTgjYjQWFMw+o9LzJoZ63GUmjWm2wGDc7EvDDOj/1IVMIyD9SUAL0WEhpriRlXv5je5S+U1i2N88zdPuoVkeB+ls4SyxCoP3kVm9jsjpEsBLoOBNC5U9SwpGdakFkviuFP1keblATkTENTYcxkzgxTKOI3jyDxqLkQT87pMA++H3XvJBYtsNbBN6vuXq5S737WqHkW1VgMQNXJ0RshMqbbT33sJ5kpHWymzcJjNTeJIymJZtSQd9NHQHS1vodoFoTMkfbJzpRnLzB2vi6BZAJxWaCr+62BC+jzAxVJb3dmmiLzLwZhZNPE5e880Suo2AZgB8e8idxherqUPnT3brBDTlPxO3Z66rVwIwySXugdNd+5ejhqp/+NmgIwGX3Py3QBmlEi54KlwmjkOytQ+iJrLJj23S4GkOeecg8G091no737qvRRdzE+HLALQoMTBbJgBsCj5RSWUlUVJiZ4SOljb05eLFWgoJ5oY6yTyJp62D39jDANoKKcSocPJD5dQYzlFAFZJflUArgTPZKZwLXAnHmerfJquUkKZEgyzqOb5TuDt1P3nwxobqwPocZA11m4A1mBx5IxNgRH21ti7KbAGiyNn3HoF/gJ0w05A8xclpwAAAABJRU5ErkJggg==' />";
|
||||
// const char* headhtml = "<meta name='color-scheme' content='dark light'><style></style><script></script>";
|
||||
// wm.setCustomHeadElement(headhtml);
|
||||
|
||||
// set custom html menu content , inside menu item "custom", see setMenu()
|
||||
const char* menuhtml = "<form action='/custom' method='get'><button>Custom</button></form><br/>\n";
|
||||
wm.setCustomMenuHTML(menuhtml);
|
||||
|
||||
@@ -187,6 +227,7 @@ void setup() {
|
||||
// set Hostname
|
||||
|
||||
wm.setHostname(("WM_"+wm.getDefaultAPName()).c_str());
|
||||
// wm.setHostname("WM_RANDO_1234");
|
||||
|
||||
// set custom channel
|
||||
// wm.setWiFiAPChannel(13);
|
||||
@@ -271,11 +312,13 @@ void setup() {
|
||||
}
|
||||
|
||||
void wifiInfo(){
|
||||
// can contain gargbage on esp32 if wifi is not ready yet
|
||||
Serial.println("[WIFI] WIFI INFO DEBUG");
|
||||
// WiFi.printDiag(Serial);
|
||||
Serial.println("[WIFI] SAVED: " + (String)(wm.getWiFiIsSaved() ? "YES" : "NO"));
|
||||
Serial.println("[WIFI] SSID: " + (String)wm.getWiFiSSID());
|
||||
Serial.println("[WIFI] PASS: " + (String)wm.getWiFiPass());
|
||||
Serial.println("[WIFI] HOSTNAME: " + (String)WiFi.getHostname());
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@@ -348,7 +391,7 @@ void getTime() {
|
||||
}
|
||||
Serial.println("");
|
||||
struct tm timeinfo;
|
||||
gmtime_r(&now, &timeinfo); // @NOTE doesnt work in esp2.3.0
|
||||
gmtime_r(&now, &timeinfo);
|
||||
Serial.print("Current time: ");
|
||||
Serial.print(asctime(&timeinfo));
|
||||
}
|
||||
|
||||
51
lib/WiFiManager/examples/Tests/wifi_softap/wifi_softap.ino
Normal file
51
lib/WiFiManager/examples/Tests/wifi_softap/wifi_softap.ino
Normal file
@@ -0,0 +1,51 @@
|
||||
// wifi_basic.ino
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <WiFi.h>
|
||||
|
||||
// #define NVSERASE
|
||||
#ifdef NVSERASE
|
||||
#include <nvs.h>
|
||||
#include <nvs_flash.h>
|
||||
#endif
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
delay(2000);
|
||||
Serial.println("Startup....");
|
||||
|
||||
#ifdef NVSERASE
|
||||
esp_err_t err;
|
||||
err = nvs_flash_init();
|
||||
err = nvs_flash_erase();
|
||||
#endif
|
||||
|
||||
Serial.setDebugOutput(true);
|
||||
|
||||
WiFi.begin("hellowifi","noonehere");
|
||||
|
||||
while (WiFi.status() != WL_CONNECTED && millis()<15000) {
|
||||
delay(500);
|
||||
Serial.print(".");
|
||||
}
|
||||
|
||||
if(WiFi.status() == WL_CONNECTED){
|
||||
Serial.println("");
|
||||
Serial.println("WiFi connected.");
|
||||
Serial.println("IP address: ");
|
||||
// Serial.println(WiFi.localIP());
|
||||
}
|
||||
else {
|
||||
Serial.println("WiFi NOT CONNECTED, starting ap");
|
||||
///////////////
|
||||
/// BUG
|
||||
// WiFi.enableSTA(false); // BREAKS softap start, says ok BUT no ap found
|
||||
|
||||
delay(2000);
|
||||
WiFi.softAP("espsoftap","12345678");
|
||||
}
|
||||
}
|
||||
|
||||
void loop(){
|
||||
|
||||
}
|
||||
@@ -192,9 +192,8 @@ button:hover{
|
||||
/*opacity: 80%;*/
|
||||
}
|
||||
|
||||
input:disabled {
|
||||
:disabled {
|
||||
opacity: 0.5;
|
||||
/* not working in cp ?? */
|
||||
}
|
||||
</style>
|
||||
<!-- /HTTP_STYLE -->
|
||||
@@ -204,6 +203,7 @@ input:disabled {
|
||||
p = l.nextElementSibling.classList.contains('l');
|
||||
document.getElementById('p').disabled = !p;
|
||||
if(p)document.getElementById('p').focus()};
|
||||
function f() {var x = document.getElementById('p');x.type==='password'?x.type='text':x.type='password';}
|
||||
</script>
|
||||
<!-- /HTTP_SCRIPT -->
|
||||
<!-- HTTP_HEAD_END -->
|
||||
@@ -251,7 +251,7 @@ input:disabled {
|
||||
<div><a href='#p' onclick='c(this)'>{v}</a><div role='img' aria-label='{r}%' title='{r}%' class='q q-{q} {i}'></div></div>
|
||||
<!-- /HTTP_ITEM -->
|
||||
<!-- HTTP_FORM_START -->
|
||||
<form method='get' action='wifisave'><label for='s'>SSID</label><br/><input id='s' name='s' length=32 placeholder='SSID'><br/><label for='p'>Password</label><input id='p' name='p' length=64 type='password' placeholder='password'><br/>
|
||||
<form method='get' action='wifisave'><label for='s'>SSID</label><br/><input id='s' name='s' length=32 placeholder='SSID'><br/><label for='p'>Password</label><input id='p' name='p' length=64 type='password' placeholder='password'><input type='checkbox' onclick='f()'> Show Password<br/>
|
||||
<!-- /HTTP_FORM_START -->
|
||||
<!-- SAMPLE -->
|
||||
<h3>custom parameter</h3><hr>
|
||||
@@ -302,7 +302,11 @@ input:disabled {
|
||||
<div class='msg S'><h4>H4 Color Header S</h4>content</div>
|
||||
<!-- /SAMPLE -->
|
||||
<!-- SAMPLE -->
|
||||
<h2>/info</h3><hr>
|
||||
<h1>Heading 1</h1>
|
||||
<h2>Heading 2</h2>
|
||||
<h3>Heading 3</h3>
|
||||
<h4>Heading 4</h4>
|
||||
<h3>WIFI HEAD <small><em>(WIFI_OFF)</em></small></h3><hr>
|
||||
<dl>
|
||||
<dt>Chip ID</dt><dd>123456</dd>
|
||||
<dt>Flash Chip ID</dt><dd>1234556</dd>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "WiFiManager",
|
||||
"version": "2.0.11-beta",
|
||||
"version": "2.0.15-rc.1",
|
||||
"keywords": "wifi,wi-fi,esp,esp8266,esp32,espressif8266,espressif32,nodemcu,wemos,arduino",
|
||||
"description": "WiFi Configuration manager with web configuration portal for ESP boards",
|
||||
"authors":
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name=WiFiManager
|
||||
version=2.0.11-beta
|
||||
version=2.0.15-rc.1
|
||||
author=tzapu
|
||||
maintainer=tablatronix
|
||||
sentence=WiFi Configuration manager with web configuration portal for Espressif ESPx boards, by tzapu
|
||||
|
||||
@@ -1,499 +1,15 @@
|
||||
/**
|
||||
* strings_en.h
|
||||
* engligh strings for
|
||||
* WiFiManager, a library for the ESP8266/Arduino platform
|
||||
* for configuration of WiFi credentials using a Captive Portal
|
||||
*
|
||||
* @author Creator tzapu
|
||||
* @author tablatronix
|
||||
* @version 0.0.0
|
||||
* @license MIT
|
||||
* Contents of this file have moved to 2 new locations
|
||||
* wm_strings_nn.h
|
||||
* wm_consts_nn.h
|
||||
*/
|
||||
|
||||
#ifndef _WM_STRINGS_H_
|
||||
#define _WM_STRINGS_H_
|
||||
#warning "This file is deprecated"
|
||||
|
||||
#ifndef _STRINGS_EN_H_
|
||||
#define _STRINGS_EN_H_
|
||||
|
||||
#ifndef WIFI_MANAGER_OVERRIDE_STRINGS
|
||||
// !!! ABOVE WILL NOT WORK if you define in your sketch, must be build flag, if anyone one knows how to order includes to be able to do this it would be neat.. I have seen it done..
|
||||
// strings files must include a consts file!
|
||||
#include "wm_strings_en.h" // include constants, tokens, routes
|
||||
|
||||
const char WM_VERSION_STR[] PROGMEM = "v1.0.11-beta";
|
||||
|
||||
const char HTTP_HEAD_START[] PROGMEM = "<!DOCTYPE html>"
|
||||
"<html lang='en'><head>"
|
||||
"<meta name='format-detection' content='telephone=no'>"
|
||||
"<meta charset='UTF-8'>"
|
||||
"<meta name='viewport' content='width=device-width,initial-scale=1,user-scalable=no'/>"
|
||||
"<title>{v}</title>";
|
||||
|
||||
const char HTTP_SCRIPT[] PROGMEM = "<script>function c(l){"
|
||||
"document.getElementById('s').value=l.getAttribute('data-ssid')||l.innerText||l.textContent;"
|
||||
"p = l.nextElementSibling.classList.contains('l');"
|
||||
"document.getElementById('p').disabled = !p;"
|
||||
"if(p)document.getElementById('p').focus();}</script>"; // @todo add button states, disable on click , show ack , spinner etc
|
||||
|
||||
const char HTTP_HEAD_END[] PROGMEM = "</head><body class='{c}'><div class='wrap'>"; // {c} = _bodyclass
|
||||
// example of embedded logo, base64 encoded inline, No styling here
|
||||
// const char HTTP_ROOT_MAIN[] PROGMEM = "<img title=' alt=' src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAADQElEQVRoQ+2YjW0VQQyE7Q6gAkgFkAogFUAqgFQAVACpAKiAUAFQAaECQgWECggVGH1PPrRvn3dv9/YkFOksoUhhfzwz9ngvKrc89JbnLxuA/63gpsCmwCADWwkNEji8fVNgotDM7osI/x777x5l9F6JyB8R4eeVql4P0y8yNsjM7KGIPBORp558T04A+CwiH1UVUItiUQmZ2XMReSEiAFgjAPBeVS96D+sCYGaUx4cFbLfmhSpnqnrZuqEJgJnd8cQplVLciAgX//Cf0ToIeOB9wpmloLQAwpnVmAXgdf6pwjpJIz+XNoeZQQZlODV9vhc1Tuf6owrAk/8qIhFbJH7eI3eEzsvydQEICqBEkZwiALfF70HyHPpqScPV5HFjeFu476SkRA0AzOfy4hYwstj2ZkDgaphE7m6XqnoS7Q0BOPs/sw0kDROzjdXcCMFCNwzIy0EcRcOvBACfh4k0wgOmBX4xjfmk4DKTS31hgNWIKBCI8gdzogTgjYjQWFMw+o9LzJoZ63GUmjWm2wGDc7EvDDOj/1IVMIyD9SUAL0WEhpriRlXv5je5S+U1i2N88zdPuoVkeB+ls4SyxCoP3kVm9jsjpEsBLoOBNC5U9SwpGdakFkviuFP1keblATkTENTYcxkzgxTKOI3jyDxqLkQT87pMA++H3XvJBYtsNbBN6vuXq5S737WqHkW1VgMQNXJ0RshMqbbT33sJ5kpHWymzcJjNTeJIymJZtSQd9NHQHS1vodoFoTMkfbJzpRnLzB2vi6BZAJxWaCr+62BC+jzAxVJb3dmmiLzLwZhZNPE5e880Suo2AZgB8e8idxherqUPnT3brBDTlPxO3Z66rVwIwySXugdNd+5ejhqp/+NmgIwGX3Py3QBmlEi54KlwmjkOytQ+iJrLJj23S4GkOeecg8G091no737qvRRdzE+HLALQoMTBbJgBsCj5RSWUlUVJiZ4SOljb05eLFWgoJ5oY6yTyJp62D39jDANoKKcSocPJD5dQYzlFAFZJflUArgTPZKZwLXAnHmerfJquUkKZEgyzqOb5TuDt1P3nwxobqwPocZA11m4A1mBx5IxNgRH21ti7KbAGiyNn3HoF/gJ0w05A8xclpwAAAABJRU5ErkJggg==' /><h1>{v}</h1><h3>WiFiManager</h3>";
|
||||
const char HTTP_ROOT_MAIN[] PROGMEM = "<h1>{t}</h1><h3>{v}</h3>";
|
||||
|
||||
const char * const HTTP_PORTAL_MENU[] PROGMEM = {
|
||||
"<form action='/wifi' method='get'><button>Configure WiFi</button></form><br/>\n", // MENU_WIFI
|
||||
"<form action='/0wifi' method='get'><button>Configure WiFi (No Scan)</button></form><br/>\n", // MENU_WIFINOSCAN
|
||||
"<form action='/info' method='get'><button>Info</button></form><br/>\n", // MENU_INFO
|
||||
"<form action='/param' method='get'><button>Setup</button></form><br/>\n",//MENU_PARAM
|
||||
"<form action='/close' method='get'><button>Close</button></form><br/>\n", // MENU_CLOSE
|
||||
"<form action='/restart' method='get'><button>Restart</button></form><br/>\n",// MENU_RESTART
|
||||
"<form action='/exit' method='get'><button>Exit</button></form><br/>\n", // MENU_EXIT
|
||||
"<form action='/erase' method='get'><button class='D'>Erase</button></form><br/>\n", // MENU_ERASE
|
||||
"<form action='/update' method='get'><button>Update</button></form><br/>\n",// MENU_UPDATE
|
||||
"<hr><br/>" // MENU_SEP
|
||||
};
|
||||
|
||||
// const char HTTP_PORTAL_OPTIONS[] PROGMEM = strcat(HTTP_PORTAL_MENU[0] , HTTP_PORTAL_MENU[3] , HTTP_PORTAL_MENU[7]);
|
||||
const char HTTP_PORTAL_OPTIONS[] PROGMEM = "";
|
||||
const char HTTP_ITEM_QI[] PROGMEM = "<div role='img' aria-label='{r}%' title='{r}%' class='q q-{q} {i} {h}'></div>"; // rssi icons
|
||||
const char HTTP_ITEM_QP[] PROGMEM = "<div class='q {h}'>{r}%</div>"; // rssi percentage {h} = hidden showperc pref
|
||||
const char HTTP_ITEM[] PROGMEM = "<div><a href='#p' onclick='c(this)' data-ssid='{V}'>{v}</a>{qi}{qp}</div>"; // {q} = HTTP_ITEM_QI, {r} = HTTP_ITEM_QP
|
||||
// const char HTTP_ITEM[] PROGMEM = "<div><a href='#p' onclick='c(this)'>{v}</a> {R} {r}% {q} {e}</div>"; // test all tokens
|
||||
|
||||
const char HTTP_FORM_START[] PROGMEM = "<form method='POST' action='{v}'>";
|
||||
const char HTTP_FORM_WIFI[] PROGMEM = "<label for='s'>SSID</label><input id='s' name='s' maxlength='32' autocorrect='off' autocapitalize='none' placeholder='{v}'><br/><label for='p'>Password</label><input id='p' name='p' maxlength='64' type='password' placeholder='{p}'>";
|
||||
const char HTTP_FORM_WIFI_END[] PROGMEM = "";
|
||||
const char HTTP_FORM_STATIC_HEAD[] PROGMEM = "<hr><br/>";
|
||||
const char HTTP_FORM_END[] PROGMEM = "<br/><br/><button type='submit'>Save</button></form>";
|
||||
const char HTTP_FORM_LABEL[] PROGMEM = "<label for='{i}'>{t}</label>";
|
||||
const char HTTP_FORM_PARAM_HEAD[] PROGMEM = "<hr><br/>";
|
||||
const char HTTP_FORM_PARAM[] PROGMEM = "<br/><input id='{i}' name='{n}' maxlength='{l}' value='{v}' {c}>\n"; // do not remove newline!
|
||||
|
||||
const char HTTP_SCAN_LINK[] PROGMEM = "<br/><form action='/wifi?refresh=1' method='POST'><button name='refresh' value='1'>Refresh</button></form>";
|
||||
const char HTTP_SAVED[] PROGMEM = "<div class='msg'>Saving Credentials<br/>Trying to connect ESP to network.<br />If it fails reconnect to AP to try again</div>";
|
||||
const char HTTP_PARAMSAVED[] PROGMEM = "<div class='msg S'>Saved<br/></div>";
|
||||
const char HTTP_END[] PROGMEM = "</div></body></html>";
|
||||
const char HTTP_ERASEBTN[] PROGMEM = "<br/><form action='/erase' method='get'><button class='D'>Erase WiFi Config</button></form>";
|
||||
const char HTTP_UPDATEBTN[] PROGMEM = "<br/><form action='/update' method='get'><button>Update</button></form>";
|
||||
const char HTTP_BACKBTN[] PROGMEM = "<hr><br/><form action='/' method='get'><button>Back</button></form>";
|
||||
|
||||
const char HTTP_STATUS_ON[] PROGMEM = "<div class='msg S'><strong>Connected</strong> to {v}<br/><em><small>with IP {i}</small></em></div>";
|
||||
const char HTTP_STATUS_OFF[] PROGMEM = "<div class='msg {c}'><strong>Not Connected</strong> to {v}{r}</div>"; // {c=class} {v=ssid} {r=status_off}
|
||||
const char HTTP_STATUS_OFFPW[] PROGMEM = "<br/>Authentication Failure"; // STATION_WRONG_PASSWORD, no eps32
|
||||
const char HTTP_STATUS_OFFNOAP[] PROGMEM = "<br/>AP not found"; // WL_NO_SSID_AVAIL
|
||||
const char HTTP_STATUS_OFFFAIL[] PROGMEM = "<br/>Could not Connect"; // WL_CONNECT_FAILED
|
||||
const char HTTP_STATUS_NONE[] PROGMEM = "<div class='msg'>No AP set</div>";
|
||||
const char HTTP_BR[] PROGMEM = "<br/>";
|
||||
|
||||
const char HTTP_STYLE[] PROGMEM = "<style>"
|
||||
".c,body{text-align:center;font-family:verdana}div,input,select{padding:5px;font-size:1em;margin:5px 0;box-sizing:border-box}"
|
||||
"input,button,select,.msg{border-radius:.3rem;width: 100%}input[type=radio],input[type=checkbox]{width:auto}"
|
||||
"button,input[type='button'],input[type='submit']{cursor:pointer;border:0;background-color:#1fa3ec;color:#fff;line-height:2.4rem;font-size:1.2rem;width:100%}"
|
||||
"input[type='file']{border:1px solid #1fa3ec}"
|
||||
".wrap {text-align:left;display:inline-block;min-width:260px;max-width:500px}"
|
||||
// links
|
||||
"a{color:#000;font-weight:700;text-decoration:none}a:hover{color:#1fa3ec;text-decoration:underline}"
|
||||
// quality icons
|
||||
".q{height:16px;margin:0;padding:0 5px;text-align:right;min-width:38px;float:right}.q.q-0:after{background-position-x:0}.q.q-1:after{background-position-x:-16px}.q.q-2:after{background-position-x:-32px}.q.q-3:after{background-position-x:-48px}.q.q-4:after{background-position-x:-64px}.q.l:before{background-position-x:-80px;padding-right:5px}.ql .q{float:left}.q:after,.q:before{content:'';width:16px;height:16px;display:inline-block;background-repeat:no-repeat;background-position: 16px 0;"
|
||||
"background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAAAQCAMAAADeZIrLAAAAJFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADHJj5lAAAAC3RSTlMAIjN3iJmqu8zd7vF8pzcAAABsSURBVHja7Y1BCsAwCASNSVo3/v+/BUEiXnIoXkoX5jAQMxTHzK9cVSnvDxwD8bFx8PhZ9q8FmghXBhqA1faxk92PsxvRc2CCCFdhQCbRkLoAQ3q/wWUBqG35ZxtVzW4Ed6LngPyBU2CobdIDQ5oPWI5nCUwAAAAASUVORK5CYII=');}"
|
||||
// icons @2x media query (32px rescaled)
|
||||
"@media (-webkit-min-device-pixel-ratio: 2),(min-resolution: 192dpi){.q:before,.q:after {"
|
||||
"background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALwAAAAgCAMAAACfM+KhAAAALVBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAOrOgAAAADnRSTlMAESIzRGZ3iJmqu8zd7gKjCLQAAACmSURBVHgB7dDBCoMwEEXRmKlVY3L//3NLhyzqIqSUggy8uxnhCR5Mo8xLt+14aZ7wwgsvvPA/ofv9+44334UXXngvb6XsFhO/VoC2RsSv9J7x8BnYLW+AjT56ud/uePMdb7IP8Bsc/e7h8Cfk912ghsNXWPpDC4hvN+D1560A1QPORyh84VKLjjdvfPFm++i9EWq0348XXnjhhT+4dIbCW+WjZim9AKk4UZMnnCEuAAAAAElFTkSuQmCC');"
|
||||
"background-size: 95px 16px;}}"
|
||||
// msg callouts
|
||||
".msg{padding:20px;margin:20px 0;border:1px solid #eee;border-left-width:5px;border-left-color:#777}.msg h4{margin-top:0;margin-bottom:5px}.msg.P{border-left-color:#1fa3ec}.msg.P h4{color:#1fa3ec}.msg.D{border-left-color:#dc3630}.msg.D h4{color:#dc3630}.msg.S{border-left-color: #5cb85c}.msg.S h4{color: #5cb85c}"
|
||||
// lists
|
||||
"dt{font-weight:bold}dd{margin:0;padding:0 0 0.5em 0;min-height:12px}"
|
||||
"td{vertical-align: top;}"
|
||||
".h{display:none}"
|
||||
"button{transition: 0s opacity;transition-delay: 3s;transition-duration: 0s;cursor: pointer}"
|
||||
"button.D{background-color:#dc3630}"
|
||||
"button:active{opacity:50% !important;cursor:wait;transition-delay: 0s}"
|
||||
// invert
|
||||
"body.invert,body.invert a,body.invert h1 {background-color:#060606;color:#fff;}"
|
||||
"body.invert .msg{color:#fff;background-color:#282828;border-top:1px solid #555;border-right:1px solid #555;border-bottom:1px solid #555;}"
|
||||
"body.invert .q[role=img]{-webkit-filter:invert(1);filter:invert(1);}"
|
||||
"input:disabled {opacity: 0.5;}"
|
||||
"</style>";
|
||||
|
||||
#ifndef WM_NOHELP
|
||||
const char HTTP_HELP[] PROGMEM =
|
||||
"<br/><h3>Available Pages</h3><hr>"
|
||||
"<table class='table'>"
|
||||
"<thead><tr><th>Page</th><th>Function</th></tr></thead><tbody>"
|
||||
"<tr><td><a href='/'>/</a></td>"
|
||||
"<td>Menu page.</td></tr>"
|
||||
"<tr><td><a href='/wifi'>/wifi</a></td>"
|
||||
"<td>Show WiFi scan results and enter WiFi configuration.(/0wifi noscan)</td></tr>"
|
||||
"<tr><td><a href='/wifisave'>/wifisave</a></td>"
|
||||
"<td>Save WiFi configuration information and configure device. Needs variables supplied.</td></tr>"
|
||||
"<tr><td><a href='/param'>/param</a></td>"
|
||||
"<td>Parameter page</td></tr>"
|
||||
"<tr><td><a href='/info'>/info</a></td>"
|
||||
"<td>Information page</td></tr>"
|
||||
"<tr><td><a href='/u'>/u</a></td>"
|
||||
"<td>OTA Update</td></tr>"
|
||||
"<tr><td><a href='/close'>/close</a></td>"
|
||||
"<td>Close the captiveportal popup,configportal will remain active</td></tr>"
|
||||
"<tr><td>/exit</td>"
|
||||
"<td>Exit Config Portal, configportal will close</td></tr>"
|
||||
"<tr><td>/restart</td>"
|
||||
"<td>Reboot the device</td></tr>"
|
||||
"<tr><td>/erase</td>"
|
||||
"<td>Erase WiFi configuration and reboot Device. Device will not reconnect to a network until new WiFi configuration data is entered.</td></tr>"
|
||||
"</table>"
|
||||
"<p/>Github <a href='https://github.com/tzapu/WiFiManager'>https://github.com/tzapu/WiFiManager</a>.";
|
||||
#else
|
||||
const char HTTP_HELP[] PROGMEM = "";
|
||||
#endif
|
||||
|
||||
const char HTTP_UPDATE[] PROGMEM = "Upload New Firmware<br/><form method='POST' action='u' enctype='multipart/form-data' onchange=\"(function(el){document.getElementById('uploadbin').style.display = el.value=='' ? 'none' : 'initial';})(this)\"><input type='file' name='update' accept='.bin,application/octet-stream'><button id='uploadbin' type='submit' class='h D'>Update</button></form><small><a href='http://192.168.4.1/update' target='_blank'>* May not function inside captive portal, Open in browser http://192.168.4.1</a><small>";
|
||||
const char HTTP_UPDATE_FAIL[] PROGMEM = "<div class='msg D'><strong>Update Failed!</strong><Br/>Reboot device and try again</div>";
|
||||
const char HTTP_UPDATE_SUCCESS[] PROGMEM = "<div class='msg S'><strong>Update Successful. </strong> <br/> Device Rebooting now...</div>";
|
||||
|
||||
#ifdef WM_JSTEST
|
||||
const char HTTP_JS[] PROGMEM =
|
||||
"<script>function postAjax(url, data, success) {"
|
||||
" var params = typeof data == 'string' ? data : Object.keys(data).map("
|
||||
" function(k){ return encodeURIComponent(k) + '=' + encodeURIComponent(data[k]) }"
|
||||
" ).join('&');"
|
||||
" var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject(\"Microsoft.XMLHTTP\");"
|
||||
" xhr.open('POST', url);"
|
||||
" xhr.onreadystatechange = function() {"
|
||||
" if (xhr.readyState>3 && xhr.status==200) { success(xhr.responseText); }"
|
||||
" };"
|
||||
" xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');"
|
||||
" xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');"
|
||||
" xhr.send(params);"
|
||||
" return xhr;}"
|
||||
"postAjax('/status', 'p1=1&p2=Hello+World', function(data){ console.log(data); });"
|
||||
"postAjax('/status', { p1: 1, p2: 'Hello World' }, function(data){ console.log(data); });"
|
||||
"</script>";
|
||||
#endif
|
||||
|
||||
// Info html
|
||||
// @todo remove html elements from progmem, repetetive strings
|
||||
#ifdef ESP32
|
||||
const char HTTP_INFO_esphead[] PROGMEM = "<h3>esp32</h3><hr><dl>";
|
||||
const char HTTP_INFO_chiprev[] PROGMEM = "<dt>Chip Rev</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_lastreset[] PROGMEM = "<dt>Last reset reason</dt><dd>CPU0: {1}<br/>CPU1: {2}</dd>";
|
||||
const char HTTP_INFO_aphost[] PROGMEM = "<dt>Access Point Hostname</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_psrsize[] PROGMEM = "<dt>PSRAM Size</dt><dd>{1} bytes</dd>";
|
||||
const char HTTP_INFO_temp[] PROGMEM = "<dt>Temperature</dt><dd>{1} C° / {2} F°</dd><dt>Hall</dt><dd>{3}</dd>";
|
||||
#else
|
||||
const char HTTP_INFO_esphead[] PROGMEM = "<h3>esp8266</h3><hr><dl>";
|
||||
const char HTTP_INFO_fchipid[] PROGMEM = "<dt>Flash Chip ID</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_corever[] PROGMEM = "<dt>Core Version</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_bootver[] PROGMEM = "<dt>Boot Version</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_lastreset[] PROGMEM = "<dt>Last reset reason</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_flashsize[] PROGMEM = "<dt>Real Flash Size</dt><dd>{1} bytes</dd>";
|
||||
#endif
|
||||
|
||||
const char HTTP_INFO_memsmeter[] PROGMEM = "<br/><progress value='{1}' max='{2}'></progress></dd>";
|
||||
const char HTTP_INFO_memsketch[] PROGMEM = "<dt>Memory - Sketch Size</dt><dd>Used / Total bytes<br/>{1} / {2}";
|
||||
const char HTTP_INFO_freeheap[] PROGMEM = "<dt>Memory - Free Heap</dt><dd>{1} bytes available</dd>";
|
||||
const char HTTP_INFO_wifihead[] PROGMEM = "<br/><h3>WiFi</h3><hr>";
|
||||
const char HTTP_INFO_uptime[] PROGMEM = "<dt>Uptime</dt><dd>{1} Mins {2} Secs</dd>";
|
||||
const char HTTP_INFO_chipid[] PROGMEM = "<dt>Chip ID</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_idesize[] PROGMEM = "<dt>Flash Size</dt><dd>{1} bytes</dd>";
|
||||
const char HTTP_INFO_sdkver[] PROGMEM = "<dt>SDK Version</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_cpufreq[] PROGMEM = "<dt>CPU Frequency</dt><dd>{1}MHz</dd>";
|
||||
const char HTTP_INFO_apip[] PROGMEM = "<dt>Access Point IP</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_apmac[] PROGMEM = "<dt>Access Point MAC</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_apssid[] PROGMEM = "<dt>Access Point SSID</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_apbssid[] PROGMEM = "<dt>BSSID</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_stassid[] PROGMEM = "<dt>Station SSID</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_staip[] PROGMEM = "<dt>Station IP</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_stagw[] PROGMEM = "<dt>Station Gateway</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_stasub[] PROGMEM = "<dt>Station Subnet</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_dnss[] PROGMEM = "<dt>DNS Server</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_host[] PROGMEM = "<dt>Hostname</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_stamac[] PROGMEM = "<dt>Station MAC</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_conx[] PROGMEM = "<dt>Connected</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_autoconx[] PROGMEM = "<dt>Autoconnect</dt><dd>{1}</dd>";
|
||||
|
||||
const char HTTP_INFO_aboutver[] PROGMEM = "<dt>WiFiManager</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_aboutarduino[] PROGMEM = "<dt>Arduino</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_aboutsdk[] PROGMEM = "<dt>ESP-SDK/IDF</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_aboutdate[] PROGMEM = "<dt>Build Date</dt><dd>{1}</dd>";
|
||||
|
||||
const char S_brand[] PROGMEM = "WiFiManager";
|
||||
const char S_debugPrefix[] PROGMEM = "*wm:";
|
||||
const char S_y[] PROGMEM = "Yes";
|
||||
const char S_n[] PROGMEM = "No";
|
||||
const char S_enable[] PROGMEM = "Enabled";
|
||||
const char S_disable[] PROGMEM = "Disabled";
|
||||
const char S_GET[] PROGMEM = "GET";
|
||||
const char S_POST[] PROGMEM = "POST";
|
||||
const char S_NA[] PROGMEM = "Unknown";
|
||||
const char S_passph[] PROGMEM = "********";
|
||||
const char S_titlewifisaved[] PROGMEM = "Credentials Saved";
|
||||
const char S_titlewifisettings[] PROGMEM = "Settings Saved";
|
||||
const char S_titlewifi[] PROGMEM = "Config ESP";
|
||||
const char S_titleinfo[] PROGMEM = "Info";
|
||||
const char S_titleparam[] PROGMEM = "Setup";
|
||||
const char S_titleparamsaved[] PROGMEM = "Setup Saved";
|
||||
const char S_titleexit[] PROGMEM = "Exit";
|
||||
const char S_titlereset[] PROGMEM = "Reset";
|
||||
const char S_titleerase[] PROGMEM = "Erase";
|
||||
const char S_titleclose[] PROGMEM = "Close";
|
||||
const char S_options[] PROGMEM = "options";
|
||||
const char S_nonetworks[] PROGMEM = "No networks found. Refresh to scan again.";
|
||||
const char S_staticip[] PROGMEM = "Static IP";
|
||||
const char S_staticgw[] PROGMEM = "Static Gateway";
|
||||
const char S_staticdns[] PROGMEM = "Static DNS";
|
||||
const char S_subnet[] PROGMEM = "Subnet";
|
||||
const char S_exiting[] PROGMEM = "Exiting";
|
||||
const char S_resetting[] PROGMEM = "Module will reset in a few seconds.";
|
||||
const char S_closing[] PROGMEM = "You can close the page, portal will continue to run";
|
||||
const char S_error[] PROGMEM = "An Error Occured";
|
||||
const char S_notfound[] PROGMEM = "File Not Found\n\n";
|
||||
const char S_uri[] PROGMEM = "URI: ";
|
||||
const char S_method[] PROGMEM = "\nMethod: ";
|
||||
const char S_args[] PROGMEM = "\nArguments: ";
|
||||
const char S_parampre[] PROGMEM = "param_";
|
||||
|
||||
// debug strings
|
||||
const char D_HR[] PROGMEM = "--------------------";
|
||||
|
||||
// END WIFI_MANAGER_OVERRIDE_STRINGS
|
||||
#endif
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
// DO NOT EDIT BELOW THIS LINE
|
||||
|
||||
const uint8_t _nummenutokens = 11;
|
||||
const char * const _menutokens[_nummenutokens] PROGMEM = {
|
||||
"wifi",
|
||||
"wifinoscan",
|
||||
"info",
|
||||
"param",
|
||||
"close",
|
||||
"restart",
|
||||
"exit",
|
||||
"erase",
|
||||
"update",
|
||||
"sep",
|
||||
"custom"
|
||||
};
|
||||
|
||||
const char R_root[] PROGMEM = "/";
|
||||
const char R_wifi[] PROGMEM = "/wifi";
|
||||
const char R_wifinoscan[] PROGMEM = "/0wifi";
|
||||
const char R_wifisave[] PROGMEM = "/wifisave";
|
||||
const char R_info[] PROGMEM = "/info";
|
||||
const char R_param[] PROGMEM = "/param";
|
||||
const char R_paramsave[] PROGMEM = "/paramsave";
|
||||
const char R_restart[] PROGMEM = "/restart";
|
||||
const char R_exit[] PROGMEM = "/exit";
|
||||
const char R_close[] PROGMEM = "/close";
|
||||
const char R_erase[] PROGMEM = "/erase";
|
||||
const char R_status[] PROGMEM = "/status";
|
||||
const char R_update[] PROGMEM = "/update";
|
||||
const char R_updatedone[] PROGMEM = "/u";
|
||||
|
||||
|
||||
//Strings
|
||||
const char S_ip[] PROGMEM = "ip";
|
||||
const char S_gw[] PROGMEM = "gw";
|
||||
const char S_sn[] PROGMEM = "sn";
|
||||
const char S_dns[] PROGMEM = "dns";
|
||||
|
||||
// softap ssid default prefix
|
||||
#ifdef ESP8266
|
||||
const char S_ssidpre[] PROGMEM = "ESP";
|
||||
#elif defined(ESP32)
|
||||
const char S_ssidpre[] PROGMEM = "ESP32";
|
||||
#else
|
||||
const char S_ssidpre[] PROGMEM = "WM";
|
||||
#endif
|
||||
|
||||
//Tokens
|
||||
//@todo consolidate and reduce
|
||||
const char T_ss[] PROGMEM = "{"; // token start sentinel
|
||||
const char T_es[] PROGMEM = "}"; // token end sentinel
|
||||
const char T_1[] PROGMEM = "{1}"; // @token 1
|
||||
const char T_2[] PROGMEM = "{2}"; // @token 2
|
||||
const char T_3[] PROGMEM = "{3}"; // @token 2
|
||||
const char T_v[] PROGMEM = "{v}"; // @token v
|
||||
const char T_V[] PROGMEM = "{V}"; // @token v
|
||||
const char T_I[] PROGMEM = "{I}"; // @token I
|
||||
const char T_i[] PROGMEM = "{i}"; // @token i
|
||||
const char T_n[] PROGMEM = "{n}"; // @token n
|
||||
const char T_p[] PROGMEM = "{p}"; // @token p
|
||||
const char T_t[] PROGMEM = "{t}"; // @token t
|
||||
const char T_l[] PROGMEM = "{l}"; // @token l
|
||||
const char T_c[] PROGMEM = "{c}"; // @token c
|
||||
const char T_e[] PROGMEM = "{e}"; // @token e
|
||||
const char T_q[] PROGMEM = "{q}"; // @token q
|
||||
const char T_r[] PROGMEM = "{r}"; // @token r
|
||||
const char T_R[] PROGMEM = "{R}"; // @token R
|
||||
const char T_h[] PROGMEM = "{h}"; // @token h
|
||||
|
||||
// http
|
||||
const char HTTP_HEAD_CL[] PROGMEM = "Content-Length";
|
||||
const char HTTP_HEAD_CT[] PROGMEM = "text/html";
|
||||
const char HTTP_HEAD_CT2[] PROGMEM = "text/plain";
|
||||
const char HTTP_HEAD_CORS[] PROGMEM = "Access-Control-Allow-Origin";
|
||||
const char HTTP_HEAD_CORS_ALLOW_ALL[] PROGMEM = "*";
|
||||
|
||||
const char * const WIFI_STA_STATUS[] PROGMEM
|
||||
{
|
||||
"WL_IDLE_STATUS", // 0 STATION_IDLE
|
||||
"WL_NO_SSID_AVAIL", // 1 STATION_NO_AP_FOUND
|
||||
"WL_SCAN_COMPLETED", // 2
|
||||
"WL_CONNECTED", // 3 STATION_GOT_IP
|
||||
"WL_CONNECT_FAILED", // 4 STATION_CONNECT_FAIL, STATION_WRONG_PASSWORD(NI)
|
||||
"WL_CONNECTION_LOST", // 5
|
||||
"WL_DISCONNECTED", // 6
|
||||
"WL_STATION_WRONG_PASSWORD" // 7 KLUDGE
|
||||
};
|
||||
|
||||
#ifdef ESP32
|
||||
const char * const AUTH_MODE_NAMES[] PROGMEM
|
||||
{
|
||||
"OPEN",
|
||||
"WEP",
|
||||
"WPA_PSK",
|
||||
"WPA2_PSK",
|
||||
"WPA_WPA2_PSK",
|
||||
"WPA2_ENTERPRISE",
|
||||
"MAX"
|
||||
};
|
||||
#elif defined(ESP8266)
|
||||
const char * const AUTH_MODE_NAMES[] PROGMEM
|
||||
{
|
||||
"",
|
||||
"",
|
||||
"WPA_PSK", // 2 ENC_TYPE_TKIP
|
||||
"",
|
||||
"WPA2_PSK", // 4 ENC_TYPE_CCMP
|
||||
"WEP", // 5 ENC_TYPE_WEP
|
||||
"",
|
||||
"OPEN", //7 ENC_TYPE_NONE
|
||||
"WPA_WPA2_PSK", // 8 ENC_TYPE_AUTO
|
||||
};
|
||||
#endif
|
||||
|
||||
const char* const WIFI_MODES[] PROGMEM = { "NULL", "STA", "AP", "STA+AP" };
|
||||
|
||||
|
||||
#ifdef ESP32
|
||||
// as 2.5.2
|
||||
// typedef struct {
|
||||
// char cc[3]; /**< country code string */
|
||||
// uint8_t schan; /**< start channel */
|
||||
// uint8_t nchan; /**< total channel number */
|
||||
// int8_t max_tx_power; /**< This field is used for getting WiFi maximum transmitting power, call esp_wifi_set_max_tx_power to set the maximum transmitting power. */
|
||||
// wifi_country_policy_t policy; /**< country policy */
|
||||
// } wifi_country_t;
|
||||
const wifi_country_t WM_COUNTRY_US{"US",1,11,CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER,WIFI_COUNTRY_POLICY_AUTO};
|
||||
const wifi_country_t WM_COUNTRY_CN{"CN",1,13,CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER,WIFI_COUNTRY_POLICY_AUTO};
|
||||
const wifi_country_t WM_COUNTRY_JP{"JP",1,14,CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER,WIFI_COUNTRY_POLICY_AUTO};
|
||||
#elif defined(ESP8266) && !defined(WM_NOCOUNTRY)
|
||||
// typedef struct {
|
||||
// char cc[3]; /**< country code string */
|
||||
// uint8_t schan; /**< start channel */
|
||||
// uint8_t nchan; /**< total channel number */
|
||||
// uint8_t policy; /**< country policy */
|
||||
// } wifi_country_t;
|
||||
const wifi_country_t WM_COUNTRY_US{"US",1,11,WIFI_COUNTRY_POLICY_AUTO};
|
||||
const wifi_country_t WM_COUNTRY_CN{"CN",1,13,WIFI_COUNTRY_POLICY_AUTO};
|
||||
const wifi_country_t WM_COUNTRY_JP{"JP",1,14,WIFI_COUNTRY_POLICY_AUTO};
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* ESP32 WiFi Events
|
||||
|
||||
0 SYSTEM_EVENT_WIFI_READY < ESP32 WiFi ready
|
||||
1 SYSTEM_EVENT_SCAN_DONE < ESP32 finish scanning AP
|
||||
2 SYSTEM_EVENT_STA_START < ESP32 station start
|
||||
3 SYSTEM_EVENT_STA_STOP < ESP32 station stop
|
||||
4 SYSTEM_EVENT_STA_CONNECTED < ESP32 station connected to AP
|
||||
5 SYSTEM_EVENT_STA_DISCONNECTED < ESP32 station disconnected from AP
|
||||
6 SYSTEM_EVENT_STA_AUTHMODE_CHANGE < the auth mode of AP connected by ESP32 station changed
|
||||
7 SYSTEM_EVENT_STA_GOT_IP < ESP32 station got IP from connected AP
|
||||
8 SYSTEM_EVENT_STA_LOST_IP < ESP32 station lost IP and the IP is reset to 0
|
||||
9 SYSTEM_EVENT_STA_WPS_ER_SUCCESS < ESP32 station wps succeeds in enrollee mode
|
||||
10 SYSTEM_EVENT_STA_WPS_ER_FAILED < ESP32 station wps fails in enrollee mode
|
||||
11 SYSTEM_EVENT_STA_WPS_ER_TIMEOUT < ESP32 station wps timeout in enrollee mode
|
||||
12 SYSTEM_EVENT_STA_WPS_ER_PIN < ESP32 station wps pin code in enrollee mode
|
||||
13 SYSTEM_EVENT_AP_START < ESP32 soft-AP start
|
||||
14 SYSTEM_EVENT_AP_STOP < ESP32 soft-AP stop
|
||||
15 SYSTEM_EVENT_AP_STACONNECTED < a station connected to ESP32 soft-AP
|
||||
16 SYSTEM_EVENT_AP_STADISCONNECTED < a station disconnected from ESP32 soft-AP
|
||||
17 SYSTEM_EVENT_AP_STAIPASSIGNED < ESP32 soft-AP assign an IP to a connected station
|
||||
18 SYSTEM_EVENT_AP_PROBEREQRECVED < Receive probe request packet in soft-AP interface
|
||||
19 SYSTEM_EVENT_GOT_IP6 < ESP32 station or ap or ethernet interface v6IP addr is preferred
|
||||
20 SYSTEM_EVENT_ETH_START < ESP32 ethernet start
|
||||
21 SYSTEM_EVENT_ETH_STOP < ESP32 ethernet stop
|
||||
22 SYSTEM_EVENT_ETH_CONNECTED < ESP32 ethernet phy link up
|
||||
23 SYSTEM_EVENT_ETH_DISCONNECTED < ESP32 ethernet phy link down
|
||||
24 SYSTEM_EVENT_ETH_GOT_IP < ESP32 ethernet got IP from connected AP
|
||||
25 SYSTEM_EVENT_MAX
|
||||
|
||||
|
||||
typedef enum {
|
||||
ARDUINO_EVENT_WIFI_READY = 0,
|
||||
ARDUINO_EVENT_WIFI_SCAN_DONE,
|
||||
ARDUINO_EVENT_WIFI_STA_START,
|
||||
ARDUINO_EVENT_WIFI_STA_STOP,
|
||||
ARDUINO_EVENT_WIFI_STA_CONNECTED,
|
||||
ARDUINO_EVENT_WIFI_STA_DISCONNECTED,
|
||||
ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE,
|
||||
ARDUINO_EVENT_WIFI_STA_GOT_IP,
|
||||
ARDUINO_EVENT_WIFI_STA_GOT_IP6,
|
||||
ARDUINO_EVENT_WIFI_STA_LOST_IP,
|
||||
ARDUINO_EVENT_WIFI_AP_START,
|
||||
ARDUINO_EVENT_WIFI_AP_STOP,
|
||||
ARDUINO_EVENT_WIFI_AP_STACONNECTED,
|
||||
ARDUINO_EVENT_WIFI_AP_STADISCONNECTED,
|
||||
ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED,
|
||||
ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED,
|
||||
ARDUINO_EVENT_WIFI_AP_GOT_IP6,
|
||||
ARDUINO_EVENT_WIFI_FTM_REPORT,
|
||||
ARDUINO_EVENT_ETH_START,
|
||||
ARDUINO_EVENT_ETH_STOP,
|
||||
ARDUINO_EVENT_ETH_CONNECTED,
|
||||
ARDUINO_EVENT_ETH_DISCONNECTED,
|
||||
ARDUINO_EVENT_ETH_GOT_IP,
|
||||
ARDUINO_EVENT_ETH_GOT_IP6,
|
||||
ARDUINO_EVENT_WPS_ER_SUCCESS,
|
||||
ARDUINO_EVENT_WPS_ER_FAILED,
|
||||
ARDUINO_EVENT_WPS_ER_TIMEOUT,
|
||||
ARDUINO_EVENT_WPS_ER_PIN,
|
||||
ARDUINO_EVENT_WPS_ER_PBC_OVERLAP,
|
||||
ARDUINO_EVENT_SC_SCAN_DONE,
|
||||
ARDUINO_EVENT_SC_FOUND_CHANNEL,
|
||||
ARDUINO_EVENT_SC_GOT_SSID_PSWD,
|
||||
ARDUINO_EVENT_SC_SEND_ACK_DONE,
|
||||
ARDUINO_EVENT_PROV_INIT,
|
||||
ARDUINO_EVENT_PROV_DEINIT,
|
||||
ARDUINO_EVENT_PROV_START,
|
||||
ARDUINO_EVENT_PROV_END,
|
||||
ARDUINO_EVENT_PROV_CRED_RECV,
|
||||
ARDUINO_EVENT_PROV_CRED_FAIL,
|
||||
ARDUINO_EVENT_PROV_CRED_SUCCESS,
|
||||
ARDUINO_EVENT_MAX
|
||||
} arduino_event_id_t;
|
||||
|
||||
typedef union {
|
||||
wifi_event_sta_scan_done_t wifi_scan_done;
|
||||
wifi_event_sta_authmode_change_t wifi_sta_authmode_change;
|
||||
wifi_event_sta_connected_t wifi_sta_connected;
|
||||
wifi_event_sta_disconnected_t wifi_sta_disconnected;
|
||||
wifi_event_sta_wps_er_pin_t wps_er_pin;
|
||||
wifi_event_sta_wps_fail_reason_t wps_fail_reason;
|
||||
wifi_event_ap_probe_req_rx_t wifi_ap_probereqrecved;
|
||||
wifi_event_ap_staconnected_t wifi_ap_staconnected;
|
||||
wifi_event_ap_stadisconnected_t wifi_ap_stadisconnected;
|
||||
wifi_event_ftm_report_t wifi_ftm_report;
|
||||
ip_event_ap_staipassigned_t wifi_ap_staipassigned;
|
||||
ip_event_got_ip_t got_ip;
|
||||
ip_event_got_ip6_t got_ip6;
|
||||
smartconfig_event_got_ssid_pswd_t sc_got_ssid_pswd;
|
||||
esp_eth_handle_t eth_connected;
|
||||
wifi_sta_config_t prov_cred_recv;
|
||||
wifi_prov_sta_fail_reason_t prov_fail_reason;
|
||||
} arduino_event_info_t;
|
||||
|
||||
*/
|
||||
#endif
|
||||
253
lib/WiFiManager/wm_consts_en.h
Normal file
253
lib/WiFiManager/wm_consts_en.h
Normal file
@@ -0,0 +1,253 @@
|
||||
/**
|
||||
* wm_consts.h
|
||||
* internal const strings/tokens
|
||||
* WiFiManager, a library for the ESP8266/Arduino platform
|
||||
* for configuration of WiFi credentials using a Captive Portal
|
||||
*
|
||||
* @author Creator tzapu
|
||||
* @author tablatronix
|
||||
* @version 0.0.0
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
#ifndef _WM_CONSTS_H
|
||||
#define _WM_CONSTS_H
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
// TOKENS
|
||||
|
||||
const char WM_VERSION_STR[] PROGMEM = "v2.0.15-rc.1";
|
||||
|
||||
const uint8_t _nummenutokens = 11;
|
||||
const char * const _menutokens[_nummenutokens] PROGMEM = {
|
||||
"wifi",
|
||||
"wifinoscan",
|
||||
"info",
|
||||
"param",
|
||||
"close",
|
||||
"restart",
|
||||
"exit",
|
||||
"erase",
|
||||
"update",
|
||||
"sep",
|
||||
"custom"
|
||||
};
|
||||
|
||||
const char R_root[] PROGMEM = "/";
|
||||
const char R_wifi[] PROGMEM = "/wifi";
|
||||
const char R_wifinoscan[] PROGMEM = "/0wifi";
|
||||
const char R_wifisave[] PROGMEM = "/wifisave";
|
||||
const char R_info[] PROGMEM = "/info";
|
||||
const char R_param[] PROGMEM = "/param";
|
||||
const char R_paramsave[] PROGMEM = "/paramsave";
|
||||
const char R_restart[] PROGMEM = "/restart";
|
||||
const char R_exit[] PROGMEM = "/exit";
|
||||
const char R_close[] PROGMEM = "/close";
|
||||
const char R_erase[] PROGMEM = "/erase";
|
||||
const char R_status[] PROGMEM = "/status";
|
||||
const char R_update[] PROGMEM = "/update";
|
||||
const char R_updatedone[] PROGMEM = "/u";
|
||||
|
||||
|
||||
//Strings
|
||||
const char S_ip[] PROGMEM = "ip";
|
||||
const char S_gw[] PROGMEM = "gw";
|
||||
const char S_sn[] PROGMEM = "sn";
|
||||
const char S_dns[] PROGMEM = "dns";
|
||||
|
||||
|
||||
|
||||
//Tokens
|
||||
//@todo consolidate and reduce
|
||||
const char T_ss[] PROGMEM = "{"; // token start sentinel
|
||||
const char T_es[] PROGMEM = "}"; // token end sentinel
|
||||
const char T_1[] PROGMEM = "{1}"; // @token 1
|
||||
const char T_2[] PROGMEM = "{2}"; // @token 2
|
||||
const char T_3[] PROGMEM = "{3}"; // @token 2
|
||||
const char T_v[] PROGMEM = "{v}"; // @token v
|
||||
const char T_V[] PROGMEM = "{V}"; // @token v
|
||||
const char T_I[] PROGMEM = "{I}"; // @token I
|
||||
const char T_i[] PROGMEM = "{i}"; // @token i
|
||||
const char T_n[] PROGMEM = "{n}"; // @token n
|
||||
const char T_p[] PROGMEM = "{p}"; // @token p
|
||||
const char T_t[] PROGMEM = "{t}"; // @token t
|
||||
const char T_l[] PROGMEM = "{l}"; // @token l
|
||||
const char T_c[] PROGMEM = "{c}"; // @token c
|
||||
const char T_e[] PROGMEM = "{e}"; // @token e
|
||||
const char T_q[] PROGMEM = "{q}"; // @token q
|
||||
const char T_r[] PROGMEM = "{r}"; // @token r
|
||||
const char T_R[] PROGMEM = "{R}"; // @token R
|
||||
const char T_h[] PROGMEM = "{h}"; // @token h
|
||||
|
||||
// http
|
||||
const char HTTP_HEAD_CL[] PROGMEM = "Content-Length";
|
||||
const char HTTP_HEAD_CT[] PROGMEM = "text/html";
|
||||
const char HTTP_HEAD_CT2[] PROGMEM = "text/plain";
|
||||
const char HTTP_HEAD_CORS[] PROGMEM = "Access-Control-Allow-Origin";
|
||||
const char HTTP_HEAD_CORS_ALLOW_ALL[] PROGMEM = "*";
|
||||
|
||||
const char * const WIFI_STA_STATUS[] PROGMEM
|
||||
{
|
||||
"WL_IDLE_STATUS", // 0 STATION_IDLE
|
||||
"WL_NO_SSID_AVAIL", // 1 STATION_NO_AP_FOUND
|
||||
"WL_SCAN_COMPLETED", // 2
|
||||
"WL_CONNECTED", // 3 STATION_GOT_IP
|
||||
"WL_CONNECT_FAILED", // 4 STATION_CONNECT_FAIL, STATION_WRONG_PASSWORD(NI)
|
||||
"WL_CONNECTION_LOST", // 5
|
||||
"WL_DISCONNECTED", // 6
|
||||
"WL_STATION_WRONG_PASSWORD" // 7 KLUDGE
|
||||
};
|
||||
|
||||
#ifdef ESP32
|
||||
const char * const AUTH_MODE_NAMES[] PROGMEM
|
||||
{
|
||||
"OPEN",
|
||||
"WEP",
|
||||
"WPA_PSK",
|
||||
"WPA2_PSK",
|
||||
"WPA_WPA2_PSK",
|
||||
"WPA2_ENTERPRISE",
|
||||
"MAX"
|
||||
};
|
||||
#elif defined(ESP8266)
|
||||
const char * const AUTH_MODE_NAMES[] PROGMEM
|
||||
{
|
||||
"",
|
||||
"",
|
||||
"WPA_PSK", // 2 ENC_TYPE_TKIP
|
||||
"",
|
||||
"WPA2_PSK", // 4 ENC_TYPE_CCMP
|
||||
"WEP", // 5 ENC_TYPE_WEP
|
||||
"",
|
||||
"OPEN", //7 ENC_TYPE_NONE
|
||||
"WPA_WPA2_PSK", // 8 ENC_TYPE_AUTO
|
||||
};
|
||||
#endif
|
||||
|
||||
const char* const WIFI_MODES[] PROGMEM = { "NULL", "STA", "AP", "STA+AP" };
|
||||
|
||||
|
||||
#ifdef ESP32
|
||||
// as 2.5.2
|
||||
// typedef struct {
|
||||
// char cc[3]; /**< country code string */
|
||||
// uint8_t schan; /**< start channel */
|
||||
// uint8_t nchan; /**< total channel number */
|
||||
// int8_t max_tx_power; /**< This field is used for getting WiFi maximum transmitting power, call esp_wifi_set_max_tx_power to set the maximum transmitting power. */
|
||||
// wifi_country_policy_t policy; /**< country policy */
|
||||
// } wifi_country_t;
|
||||
const wifi_country_t WM_COUNTRY_US{"US",1,11,CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER,WIFI_COUNTRY_POLICY_AUTO};
|
||||
const wifi_country_t WM_COUNTRY_CN{"CN",1,13,CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER,WIFI_COUNTRY_POLICY_AUTO};
|
||||
const wifi_country_t WM_COUNTRY_JP{"JP",1,14,CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER,WIFI_COUNTRY_POLICY_AUTO};
|
||||
#elif defined(ESP8266) && !defined(WM_NOCOUNTRY)
|
||||
// typedef struct {
|
||||
// char cc[3]; /**< country code string */
|
||||
// uint8_t schan; /**< start channel */
|
||||
// uint8_t nchan; /**< total channel number */
|
||||
// uint8_t policy; /**< country policy */
|
||||
// } wifi_country_t;
|
||||
const wifi_country_t WM_COUNTRY_US{"US",1,11,WIFI_COUNTRY_POLICY_AUTO};
|
||||
const wifi_country_t WM_COUNTRY_CN{"CN",1,13,WIFI_COUNTRY_POLICY_AUTO};
|
||||
const wifi_country_t WM_COUNTRY_JP{"JP",1,14,WIFI_COUNTRY_POLICY_AUTO};
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* ESP32 WiFi Events
|
||||
|
||||
0 SYSTEM_EVENT_WIFI_READY < ESP32 WiFi ready
|
||||
1 SYSTEM_EVENT_SCAN_DONE < ESP32 finish scanning AP
|
||||
2 SYSTEM_EVENT_STA_START < ESP32 station start
|
||||
3 SYSTEM_EVENT_STA_STOP < ESP32 station stop
|
||||
4 SYSTEM_EVENT_STA_CONNECTED < ESP32 station connected to AP
|
||||
5 SYSTEM_EVENT_STA_DISCONNECTED < ESP32 station disconnected from AP
|
||||
6 SYSTEM_EVENT_STA_AUTHMODE_CHANGE < the auth mode of AP connected by ESP32 station changed
|
||||
7 SYSTEM_EVENT_STA_GOT_IP < ESP32 station got IP from connected AP
|
||||
8 SYSTEM_EVENT_STA_LOST_IP < ESP32 station lost IP and the IP is reset to 0
|
||||
9 SYSTEM_EVENT_STA_WPS_ER_SUCCESS < ESP32 station wps succeeds in enrollee mode
|
||||
10 SYSTEM_EVENT_STA_WPS_ER_FAILED < ESP32 station wps fails in enrollee mode
|
||||
11 SYSTEM_EVENT_STA_WPS_ER_TIMEOUT < ESP32 station wps timeout in enrollee mode
|
||||
12 SYSTEM_EVENT_STA_WPS_ER_PIN < ESP32 station wps pin code in enrollee mode
|
||||
13 SYSTEM_EVENT_AP_START < ESP32 soft-AP start
|
||||
14 SYSTEM_EVENT_AP_STOP < ESP32 soft-AP stop
|
||||
15 SYSTEM_EVENT_AP_STACONNECTED < a station connected to ESP32 soft-AP
|
||||
16 SYSTEM_EVENT_AP_STADISCONNECTED < a station disconnected from ESP32 soft-AP
|
||||
17 SYSTEM_EVENT_AP_STAIPASSIGNED < ESP32 soft-AP assign an IP to a connected station
|
||||
18 SYSTEM_EVENT_AP_PROBEREQRECVED < Receive probe request packet in soft-AP interface
|
||||
19 SYSTEM_EVENT_GOT_IP6 < ESP32 station or ap or ethernet interface v6IP addr is preferred
|
||||
20 SYSTEM_EVENT_ETH_START < ESP32 ethernet start
|
||||
21 SYSTEM_EVENT_ETH_STOP < ESP32 ethernet stop
|
||||
22 SYSTEM_EVENT_ETH_CONNECTED < ESP32 ethernet phy link up
|
||||
23 SYSTEM_EVENT_ETH_DISCONNECTED < ESP32 ethernet phy link down
|
||||
24 SYSTEM_EVENT_ETH_GOT_IP < ESP32 ethernet got IP from connected AP
|
||||
25 SYSTEM_EVENT_MAX
|
||||
|
||||
|
||||
typedef enum {
|
||||
ARDUINO_EVENT_WIFI_READY = 0,
|
||||
ARDUINO_EVENT_WIFI_SCAN_DONE,
|
||||
ARDUINO_EVENT_WIFI_STA_START,
|
||||
ARDUINO_EVENT_WIFI_STA_STOP,
|
||||
ARDUINO_EVENT_WIFI_STA_CONNECTED,
|
||||
ARDUINO_EVENT_WIFI_STA_DISCONNECTED,
|
||||
ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE,
|
||||
ARDUINO_EVENT_WIFI_STA_GOT_IP,
|
||||
ARDUINO_EVENT_WIFI_STA_GOT_IP6,
|
||||
ARDUINO_EVENT_WIFI_STA_LOST_IP,
|
||||
ARDUINO_EVENT_WIFI_AP_START,
|
||||
ARDUINO_EVENT_WIFI_AP_STOP,
|
||||
ARDUINO_EVENT_WIFI_AP_STACONNECTED,
|
||||
ARDUINO_EVENT_WIFI_AP_STADISCONNECTED,
|
||||
ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED,
|
||||
ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED,
|
||||
ARDUINO_EVENT_WIFI_AP_GOT_IP6,
|
||||
ARDUINO_EVENT_WIFI_FTM_REPORT,
|
||||
ARDUINO_EVENT_ETH_START,
|
||||
ARDUINO_EVENT_ETH_STOP,
|
||||
ARDUINO_EVENT_ETH_CONNECTED,
|
||||
ARDUINO_EVENT_ETH_DISCONNECTED,
|
||||
ARDUINO_EVENT_ETH_GOT_IP,
|
||||
ARDUINO_EVENT_ETH_GOT_IP6,
|
||||
ARDUINO_EVENT_WPS_ER_SUCCESS,
|
||||
ARDUINO_EVENT_WPS_ER_FAILED,
|
||||
ARDUINO_EVENT_WPS_ER_TIMEOUT,
|
||||
ARDUINO_EVENT_WPS_ER_PIN,
|
||||
ARDUINO_EVENT_WPS_ER_PBC_OVERLAP,
|
||||
ARDUINO_EVENT_SC_SCAN_DONE,
|
||||
ARDUINO_EVENT_SC_FOUND_CHANNEL,
|
||||
ARDUINO_EVENT_SC_GOT_SSID_PSWD,
|
||||
ARDUINO_EVENT_SC_SEND_ACK_DONE,
|
||||
ARDUINO_EVENT_PROV_INIT,
|
||||
ARDUINO_EVENT_PROV_DEINIT,
|
||||
ARDUINO_EVENT_PROV_START,
|
||||
ARDUINO_EVENT_PROV_END,
|
||||
ARDUINO_EVENT_PROV_CRED_RECV,
|
||||
ARDUINO_EVENT_PROV_CRED_FAIL,
|
||||
ARDUINO_EVENT_PROV_CRED_SUCCESS,
|
||||
ARDUINO_EVENT_MAX
|
||||
} arduino_event_id_t;
|
||||
|
||||
typedef union {
|
||||
wifi_event_sta_scan_done_t wifi_scan_done;
|
||||
wifi_event_sta_authmode_change_t wifi_sta_authmode_change;
|
||||
wifi_event_sta_connected_t wifi_sta_connected;
|
||||
wifi_event_sta_disconnected_t wifi_sta_disconnected;
|
||||
wifi_event_sta_wps_er_pin_t wps_er_pin;
|
||||
wifi_event_sta_wps_fail_reason_t wps_fail_reason;
|
||||
wifi_event_ap_probe_req_rx_t wifi_ap_probereqrecved;
|
||||
wifi_event_ap_staconnected_t wifi_ap_staconnected;
|
||||
wifi_event_ap_stadisconnected_t wifi_ap_stadisconnected;
|
||||
wifi_event_ftm_report_t wifi_ftm_report;
|
||||
ip_event_ap_staipassigned_t wifi_ap_staipassigned;
|
||||
ip_event_got_ip_t got_ip;
|
||||
ip_event_got_ip6_t got_ip6;
|
||||
smartconfig_event_got_ssid_pswd_t sc_got_ssid_pswd;
|
||||
esp_eth_handle_t eth_connected;
|
||||
wifi_sta_config_t prov_cred_recv;
|
||||
wifi_prov_sta_fail_reason_t prov_fail_reason;
|
||||
} arduino_event_info_t;
|
||||
|
||||
*/
|
||||
|
||||
#endif
|
||||
275
lib/WiFiManager/wm_strings_en.h
Normal file
275
lib/WiFiManager/wm_strings_en.h
Normal file
@@ -0,0 +1,275 @@
|
||||
/**
|
||||
* wm_strings_en.h
|
||||
* engligh strings for
|
||||
* WiFiManager, a library for the ESP8266/Arduino platform
|
||||
* for configuration of WiFi credentials using a Captive Portal
|
||||
*
|
||||
* @author Creator tzapu
|
||||
* @author tablatronix
|
||||
* @version 0.0.0
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
#ifndef _WM_STRINGS_EN_H_
|
||||
#define _WM_STRINGS_EN_H_
|
||||
|
||||
|
||||
#ifndef WIFI_MANAGER_OVERRIDE_STRINGS
|
||||
// !!! ABOVE WILL NOT WORK if you define in your sketch, must be build flag, if anyone one knows how to order includes to be able to do this it would be neat.. I have seen it done..
|
||||
|
||||
// strings files must include a consts file!
|
||||
#include "wm_consts_en.h" // include constants, tokens, routes
|
||||
|
||||
const char WM_LANGUAGE[] PROGMEM = "en-US"; // i18n lang code
|
||||
|
||||
const char HTTP_HEAD_START[] PROGMEM = "<!DOCTYPE html>"
|
||||
"<html lang='en'><head>"
|
||||
"<meta name='format-detection' content='telephone=no'>"
|
||||
"<meta charset='UTF-8'>"
|
||||
"<meta name='viewport' content='width=device-width,initial-scale=1,user-scalable=no'/>"
|
||||
"<title>{v}</title>";
|
||||
|
||||
const char HTTP_SCRIPT[] PROGMEM = "<script>function c(l){"
|
||||
"document.getElementById('s').value=l.getAttribute('data-ssid')||l.innerText||l.textContent;"
|
||||
"p = l.nextElementSibling.classList.contains('l');"
|
||||
"document.getElementById('p').disabled = !p;"
|
||||
"if(p)document.getElementById('p').focus();};"
|
||||
"function f() {var x = document.getElementById('p');x.type==='password'?x.type='text':x.type='password';}"
|
||||
"</script>"; // @todo add button states, disable on click , show ack , spinner etc
|
||||
|
||||
const char HTTP_HEAD_END[] PROGMEM = "</head><body class='{c}'><div class='wrap'>"; // {c} = _bodyclass
|
||||
// example of embedded logo, base64 encoded inline, No styling here
|
||||
// const char HTTP_ROOT_MAIN[] PROGMEM = "<img title=' alt=' src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAADQElEQVRoQ+2YjW0VQQyE7Q6gAkgFkAogFUAqgFQAVACpAKiAUAFQAaECQgWECggVGH1PPrRvn3dv9/YkFOksoUhhfzwz9ngvKrc89JbnLxuA/63gpsCmwCADWwkNEji8fVNgotDM7osI/x777x5l9F6JyB8R4eeVql4P0y8yNsjM7KGIPBORp558T04A+CwiH1UVUItiUQmZ2XMReSEiAFgjAPBeVS96D+sCYGaUx4cFbLfmhSpnqnrZuqEJgJnd8cQplVLciAgX//Cf0ToIeOB9wpmloLQAwpnVmAXgdf6pwjpJIz+XNoeZQQZlODV9vhc1Tuf6owrAk/8qIhFbJH7eI3eEzsvydQEICqBEkZwiALfF70HyHPpqScPV5HFjeFu476SkRA0AzOfy4hYwstj2ZkDgaphE7m6XqnoS7Q0BOPs/sw0kDROzjdXcCMFCNwzIy0EcRcOvBACfh4k0wgOmBX4xjfmk4DKTS31hgNWIKBCI8gdzogTgjYjQWFMw+o9LzJoZ63GUmjWm2wGDc7EvDDOj/1IVMIyD9SUAL0WEhpriRlXv5je5S+U1i2N88zdPuoVkeB+ls4SyxCoP3kVm9jsjpEsBLoOBNC5U9SwpGdakFkviuFP1keblATkTENTYcxkzgxTKOI3jyDxqLkQT87pMA++H3XvJBYtsNbBN6vuXq5S737WqHkW1VgMQNXJ0RshMqbbT33sJ5kpHWymzcJjNTeJIymJZtSQd9NHQHS1vodoFoTMkfbJzpRnLzB2vi6BZAJxWaCr+62BC+jzAxVJb3dmmiLzLwZhZNPE5e880Suo2AZgB8e8idxherqUPnT3brBDTlPxO3Z66rVwIwySXugdNd+5ejhqp/+NmgIwGX3Py3QBmlEi54KlwmjkOytQ+iJrLJj23S4GkOeecg8G091no737qvRRdzE+HLALQoMTBbJgBsCj5RSWUlUVJiZ4SOljb05eLFWgoJ5oY6yTyJp62D39jDANoKKcSocPJD5dQYzlFAFZJflUArgTPZKZwLXAnHmerfJquUkKZEgyzqOb5TuDt1P3nwxobqwPocZA11m4A1mBx5IxNgRH21ti7KbAGiyNn3HoF/gJ0w05A8xclpwAAAABJRU5ErkJggg==' /><h1>{v}</h1><h3>WiFiManager</h3>";
|
||||
const char HTTP_ROOT_MAIN[] PROGMEM = "<h1>{t}</h1><h3>{v}</h3>";
|
||||
|
||||
const char * const HTTP_PORTAL_MENU[] PROGMEM = {
|
||||
"<form action='/wifi' method='get'><button>Configure WiFi</button></form><br/>\n", // MENU_WIFI
|
||||
"<form action='/0wifi' method='get'><button>Configure WiFi (No scan)</button></form><br/>\n", // MENU_WIFINOSCAN
|
||||
"<form action='/info' method='get'><button>Info</button></form><br/>\n", // MENU_INFO
|
||||
"<form action='/param' method='get'><button>Setup</button></form><br/>\n",//MENU_PARAM
|
||||
"<form action='/close' method='get'><button>Close</button></form><br/>\n", // MENU_CLOSE
|
||||
"<form action='/restart' method='get'><button>Restart</button></form><br/>\n",// MENU_RESTART
|
||||
"<form action='/exit' method='get'><button>Exit</button></form><br/>\n", // MENU_EXIT
|
||||
"<form action='/erase' method='get'><button class='D'>Erase</button></form><br/>\n", // MENU_ERASE
|
||||
"<form action='/update' method='get'><button>Update</button></form><br/>\n",// MENU_UPDATE
|
||||
"<hr><br/>" // MENU_SEP
|
||||
};
|
||||
|
||||
// const char HTTP_PORTAL_OPTIONS[] PROGMEM = strcat(HTTP_PORTAL_MENU[0] , HTTP_PORTAL_MENU[3] , HTTP_PORTAL_MENU[7]);
|
||||
const char HTTP_PORTAL_OPTIONS[] PROGMEM = "";
|
||||
const char HTTP_ITEM_QI[] PROGMEM = "<div role='img' aria-label='{r}%' title='{r}%' class='q q-{q} {i} {h}'></div>"; // rssi icons
|
||||
const char HTTP_ITEM_QP[] PROGMEM = "<div class='q {h}'>{r}%</div>"; // rssi percentage {h} = hidden showperc pref
|
||||
const char HTTP_ITEM[] PROGMEM = "<div><a href='#p' onclick='c(this)' data-ssid='{V}'>{v}</a>{qi}{qp}</div>"; // {q} = HTTP_ITEM_QI, {r} = HTTP_ITEM_QP
|
||||
// const char HTTP_ITEM[] PROGMEM = "<div><a href='#p' onclick='c(this)'>{v}</a> {R} {r}% {q} {e}</div>"; // test all tokens
|
||||
|
||||
const char HTTP_FORM_START[] PROGMEM = "<form method='POST' action='{v}'>";
|
||||
const char HTTP_FORM_WIFI[] PROGMEM = "<label for='s'>SSID</label><input id='s' name='s' maxlength='32' autocorrect='off' autocapitalize='none' placeholder='{v}'><br/><label for='p'>Password</label><input id='p' name='p' maxlength='64' type='password' placeholder='{p}'><input type='checkbox' onclick='f()'> Show Password";
|
||||
const char HTTP_FORM_WIFI_END[] PROGMEM = "";
|
||||
const char HTTP_FORM_STATIC_HEAD[] PROGMEM = "<hr><br/>";
|
||||
const char HTTP_FORM_END[] PROGMEM = "<br/><br/><button type='submit'>Save</button></form>";
|
||||
const char HTTP_FORM_LABEL[] PROGMEM = "<label for='{i}'>{t}</label>";
|
||||
const char HTTP_FORM_PARAM_HEAD[] PROGMEM = "<hr><br/>";
|
||||
const char HTTP_FORM_PARAM[] PROGMEM = "<br/><input id='{i}' name='{n}' maxlength='{l}' value='{v}' {c}>\n"; // do not remove newline!
|
||||
|
||||
const char HTTP_SCAN_LINK[] PROGMEM = "<br/><form action='/wifi?refresh=1' method='POST'><button name='refresh' value='1'>Refresh</button></form>";
|
||||
const char HTTP_SAVED[] PROGMEM = "<div class='msg'>Saving Credentials<br/>Trying to connect ESP to network.<br />If it fails reconnect to AP to try again</div>";
|
||||
const char HTTP_PARAMSAVED[] PROGMEM = "<div class='msg S'>Saved<br/></div>";
|
||||
const char HTTP_END[] PROGMEM = "</div></body></html>";
|
||||
const char HTTP_ERASEBTN[] PROGMEM = "<br/><form action='/erase' method='get'><button class='D'>Erase WiFi config</button></form>";
|
||||
const char HTTP_UPDATEBTN[] PROGMEM = "<br/><form action='/update' method='get'><button>Update</button></form>";
|
||||
const char HTTP_BACKBTN[] PROGMEM = "<hr><br/><form action='/' method='get'><button>Back</button></form>";
|
||||
|
||||
const char HTTP_STATUS_ON[] PROGMEM = "<div class='msg S'><strong>Connected</strong> to {v}<br/><em><small>with IP {i}</small></em></div>";
|
||||
const char HTTP_STATUS_OFF[] PROGMEM = "<div class='msg {c}'><strong>Not connected</strong> to {v}{r}</div>"; // {c=class} {v=ssid} {r=status_off}
|
||||
const char HTTP_STATUS_OFFPW[] PROGMEM = "<br/>Authentication failure"; // STATION_WRONG_PASSWORD, no eps32
|
||||
const char HTTP_STATUS_OFFNOAP[] PROGMEM = "<br/>AP not found"; // WL_NO_SSID_AVAIL
|
||||
const char HTTP_STATUS_OFFFAIL[] PROGMEM = "<br/>Could not connect"; // WL_CONNECT_FAILED
|
||||
const char HTTP_STATUS_NONE[] PROGMEM = "<div class='msg'>No AP set</div>";
|
||||
const char HTTP_BR[] PROGMEM = "<br/>";
|
||||
|
||||
const char HTTP_STYLE[] PROGMEM = "<style>"
|
||||
".c,body{text-align:center;font-family:verdana}div,input,select{padding:5px;font-size:1em;margin:5px 0;box-sizing:border-box}"
|
||||
"input,button,select,.msg{border-radius:.3rem;width: 100%}input[type=radio],input[type=checkbox]{width:auto}"
|
||||
"button,input[type='button'],input[type='submit']{cursor:pointer;border:0;background-color:#1fa3ec;color:#fff;line-height:2.4rem;font-size:1.2rem;width:100%}"
|
||||
"input[type='file']{border:1px solid #1fa3ec}"
|
||||
".wrap {text-align:left;display:inline-block;min-width:260px;max-width:500px}"
|
||||
// links
|
||||
"a{color:#000;font-weight:700;text-decoration:none}a:hover{color:#1fa3ec;text-decoration:underline}"
|
||||
// quality icons
|
||||
".q{height:16px;margin:0;padding:0 5px;text-align:right;min-width:38px;float:right}.q.q-0:after{background-position-x:0}.q.q-1:after{background-position-x:-16px}.q.q-2:after{background-position-x:-32px}.q.q-3:after{background-position-x:-48px}.q.q-4:after{background-position-x:-64px}.q.l:before{background-position-x:-80px;padding-right:5px}.ql .q{float:left}.q:after,.q:before{content:'';width:16px;height:16px;display:inline-block;background-repeat:no-repeat;background-position: 16px 0;"
|
||||
"background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAAAQCAMAAADeZIrLAAAAJFBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADHJj5lAAAAC3RSTlMAIjN3iJmqu8zd7vF8pzcAAABsSURBVHja7Y1BCsAwCASNSVo3/v+/BUEiXnIoXkoX5jAQMxTHzK9cVSnvDxwD8bFx8PhZ9q8FmghXBhqA1faxk92PsxvRc2CCCFdhQCbRkLoAQ3q/wWUBqG35ZxtVzW4Ed6LngPyBU2CobdIDQ5oPWI5nCUwAAAAASUVORK5CYII=');}"
|
||||
// icons @2x media query (32px rescaled)
|
||||
"@media (-webkit-min-device-pixel-ratio: 2),(min-resolution: 192dpi){.q:before,.q:after {"
|
||||
"background-image:url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALwAAAAgCAMAAACfM+KhAAAALVBMVEX///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAOrOgAAAADnRSTlMAESIzRGZ3iJmqu8zd7gKjCLQAAACmSURBVHgB7dDBCoMwEEXRmKlVY3L//3NLhyzqIqSUggy8uxnhCR5Mo8xLt+14aZ7wwgsvvPA/ofv9+44334UXXngvb6XsFhO/VoC2RsSv9J7x8BnYLW+AjT56ud/uePMdb7IP8Bsc/e7h8Cfk912ghsNXWPpDC4hvN+D1560A1QPORyh84VKLjjdvfPFm++i9EWq0348XXnjhhT+4dIbCW+WjZim9AKk4UZMnnCEuAAAAAElFTkSuQmCC');"
|
||||
"background-size: 95px 16px;}}"
|
||||
// msg callouts
|
||||
".msg{padding:20px;margin:20px 0;border:1px solid #eee;border-left-width:5px;border-left-color:#777}.msg h4{margin-top:0;margin-bottom:5px}.msg.P{border-left-color:#1fa3ec}.msg.P h4{color:#1fa3ec}.msg.D{border-left-color:#dc3630}.msg.D h4{color:#dc3630}.msg.S{border-left-color: #5cb85c}.msg.S h4{color: #5cb85c}"
|
||||
// lists
|
||||
"dt{font-weight:bold}dd{margin:0;padding:0 0 0.5em 0;min-height:12px}"
|
||||
"td{vertical-align: top;}"
|
||||
".h{display:none}"
|
||||
"button{transition: 0s opacity;transition-delay: 3s;transition-duration: 0s;cursor: pointer}"
|
||||
"button.D{background-color:#dc3630}"
|
||||
"button:active{opacity:50% !important;cursor:wait;transition-delay: 0s}"
|
||||
// invert
|
||||
"body.invert,body.invert a,body.invert h1 {background-color:#060606;color:#fff;}"
|
||||
"body.invert .msg{color:#fff;background-color:#282828;border-top:1px solid #555;border-right:1px solid #555;border-bottom:1px solid #555;}"
|
||||
"body.invert .q[role=img]{-webkit-filter:invert(1);filter:invert(1);}"
|
||||
":disabled {opacity: 0.5;}"
|
||||
"</style>";
|
||||
|
||||
#ifndef WM_NOHELP
|
||||
const char HTTP_HELP[] PROGMEM =
|
||||
"<br/><h3>Available pages</h3><hr>"
|
||||
"<table class='table'>"
|
||||
"<thead><tr><th>Page</th><th>Function</th></tr></thead><tbody>"
|
||||
"<tr><td><a href='/'>/</a></td>"
|
||||
"<td>Menu page.</td></tr>"
|
||||
"<tr><td><a href='/wifi'>/wifi</a></td>"
|
||||
"<td>Show WiFi scan results and enter WiFi configuration.(/0wifi noscan)</td></tr>"
|
||||
"<tr><td><a href='/wifisave'>/wifisave</a></td>"
|
||||
"<td>Save WiFi configuration information and configure device. Needs variables supplied.</td></tr>"
|
||||
"<tr><td><a href='/param'>/param</a></td>"
|
||||
"<td>Parameter page</td></tr>"
|
||||
"<tr><td><a href='/info'>/info</a></td>"
|
||||
"<td>Information page</td></tr>"
|
||||
"<tr><td><a href='/u'>/u</a></td>"
|
||||
"<td>OTA Update</td></tr>"
|
||||
"<tr><td><a href='/close'>/close</a></td>"
|
||||
"<td>Close the captiveportal popup, config portal will remain active</td></tr>"
|
||||
"<tr><td>/exit</td>"
|
||||
"<td>Exit Config portal, config portal will close</td></tr>"
|
||||
"<tr><td>/restart</td>"
|
||||
"<td>Reboot the device</td></tr>"
|
||||
"<tr><td>/erase</td>"
|
||||
"<td>Erase WiFi configuration and reboot device. Device will not reconnect to a network until new WiFi configuration data is entered.</td></tr>"
|
||||
"</table>"
|
||||
"<p/>Github <a href='https://github.com/tzapu/WiFiManager'>https://github.com/tzapu/WiFiManager</a>.";
|
||||
#else
|
||||
const char HTTP_HELP[] PROGMEM = "";
|
||||
#endif
|
||||
|
||||
const char HTTP_UPDATE[] PROGMEM = "Upload new firmware<br/><form method='POST' action='u' enctype='multipart/form-data' onchange=\"(function(el){document.getElementById('uploadbin').style.display = el.value=='' ? 'none' : 'initial';})(this)\"><input type='file' name='update' accept='.bin,application/octet-stream'><button id='uploadbin' type='submit' class='h D'>Update</button></form><small><a href='http://192.168.4.1/update' target='_blank'>* May not function inside captive portal, open in browser http://192.168.4.1</a><small>";
|
||||
const char HTTP_UPDATE_FAIL[] PROGMEM = "<div class='msg D'><strong>Update failed!</strong><Br/>Reboot device and try again</div>";
|
||||
const char HTTP_UPDATE_SUCCESS[] PROGMEM = "<div class='msg S'><strong>Update successful. </strong> <br/> Device rebooting now...</div>";
|
||||
|
||||
#ifdef WM_JSTEST
|
||||
const char HTTP_JS[] PROGMEM =
|
||||
"<script>function postAjax(url, data, success) {"
|
||||
" var params = typeof data == 'string' ? data : Object.keys(data).map("
|
||||
" function(k){ return encodeURIComponent(k) + '=' + encodeURIComponent(data[k]) }"
|
||||
" ).join('&');"
|
||||
" var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject(\"Microsoft.XMLHTTP\");"
|
||||
" xhr.open('POST', url);"
|
||||
" xhr.onreadystatechange = function() {"
|
||||
" if (xhr.readyState>3 && xhr.status==200) { success(xhr.responseText); }"
|
||||
" };"
|
||||
" xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');"
|
||||
" xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');"
|
||||
" xhr.send(params);"
|
||||
" return xhr;}"
|
||||
"postAjax('/status', 'p1=1&p2=Hello+World', function(data){ console.log(data); });"
|
||||
"postAjax('/status', { p1: 1, p2: 'Hello World' }, function(data){ console.log(data); });"
|
||||
"</script>";
|
||||
#endif
|
||||
|
||||
// Info html
|
||||
// @todo remove html elements from progmem, repetetive strings
|
||||
#ifdef ESP32
|
||||
const char HTTP_INFO_esphead[] PROGMEM = "<h3>esp32</h3><hr><dl>";
|
||||
const char HTTP_INFO_chiprev[] PROGMEM = "<dt>Chip rev</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_lastreset[] PROGMEM = "<dt>Last reset reason</dt><dd>CPU0: {1}<br/>CPU1: {2}</dd>";
|
||||
const char HTTP_INFO_aphost[] PROGMEM = "<dt>Access point hostname</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_psrsize[] PROGMEM = "<dt>PSRAM Size</dt><dd>{1} bytes</dd>";
|
||||
const char HTTP_INFO_temp[] PROGMEM = "<dt>Temperature</dt><dd>{1} C° / {2} F°</dd>";
|
||||
const char HTTP_INFO_hall[] PROGMEM = "<dt>Hall</dt><dd>{1}</dd>";
|
||||
#else
|
||||
const char HTTP_INFO_esphead[] PROGMEM = "<h3>esp8266</h3><hr><dl>";
|
||||
const char HTTP_INFO_fchipid[] PROGMEM = "<dt>Flash chip ID</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_corever[] PROGMEM = "<dt>Core version</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_bootver[] PROGMEM = "<dt>Boot version</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_lastreset[] PROGMEM = "<dt>Last reset reason</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_flashsize[] PROGMEM = "<dt>Real flash size</dt><dd>{1} bytes</dd>";
|
||||
#endif
|
||||
|
||||
const char HTTP_INFO_memsmeter[] PROGMEM = "<br/><progress value='{1}' max='{2}'></progress></dd>";
|
||||
const char HTTP_INFO_memsketch[] PROGMEM = "<dt>Memory - Sketch size</dt><dd>Used / Total bytes<br/>{1} / {2}";
|
||||
const char HTTP_INFO_freeheap[] PROGMEM = "<dt>Memory - Free heap</dt><dd>{1} bytes available</dd>";
|
||||
const char HTTP_INFO_wifihead[] PROGMEM = "<br/><h3>WiFi</h3><hr>";
|
||||
const char HTTP_INFO_uptime[] PROGMEM = "<dt>Uptime</dt><dd>{1} mins {2} secs</dd>";
|
||||
const char HTTP_INFO_chipid[] PROGMEM = "<dt>Chip ID</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_idesize[] PROGMEM = "<dt>Flash size</dt><dd>{1} bytes</dd>";
|
||||
const char HTTP_INFO_sdkver[] PROGMEM = "<dt>SDK version</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_cpufreq[] PROGMEM = "<dt>CPU frequency</dt><dd>{1}MHz</dd>";
|
||||
const char HTTP_INFO_apip[] PROGMEM = "<dt>Access point IP</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_apmac[] PROGMEM = "<dt>Access point MAC</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_apssid[] PROGMEM = "<dt>Access point SSID</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_apbssid[] PROGMEM = "<dt>BSSID</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_stassid[] PROGMEM = "<dt>Station SSID</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_staip[] PROGMEM = "<dt>Station IP</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_stagw[] PROGMEM = "<dt>Station gateway</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_stasub[] PROGMEM = "<dt>Station subnet</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_dnss[] PROGMEM = "<dt>DNS Server</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_host[] PROGMEM = "<dt>Hostname</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_stamac[] PROGMEM = "<dt>Station MAC</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_conx[] PROGMEM = "<dt>Connected</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_autoconx[] PROGMEM = "<dt>Autoconnect</dt><dd>{1}</dd>";
|
||||
|
||||
const char HTTP_INFO_aboutver[] PROGMEM = "<dt>WiFiManager</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_aboutarduino[] PROGMEM = "<dt>Arduino</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_aboutsdk[] PROGMEM = "<dt>ESP-SDK/IDF</dt><dd>{1}</dd>";
|
||||
const char HTTP_INFO_aboutdate[] PROGMEM = "<dt>Build date</dt><dd>{1}</dd>";
|
||||
|
||||
const char S_brand[] PROGMEM = "WiFiManager";
|
||||
const char S_debugPrefix[] PROGMEM = "*wm:";
|
||||
const char S_y[] PROGMEM = "Yes";
|
||||
const char S_n[] PROGMEM = "No";
|
||||
const char S_enable[] PROGMEM = "Enabled";
|
||||
const char S_disable[] PROGMEM = "Disabled";
|
||||
const char S_GET[] PROGMEM = "GET";
|
||||
const char S_POST[] PROGMEM = "POST";
|
||||
const char S_NA[] PROGMEM = "Unknown";
|
||||
const char S_passph[] PROGMEM = "********";
|
||||
const char S_titlewifisaved[] PROGMEM = "Credentials saved";
|
||||
const char S_titlewifisettings[] PROGMEM = "Settings saved";
|
||||
const char S_titlewifi[] PROGMEM = "Config ESP";
|
||||
const char S_titleinfo[] PROGMEM = "Info";
|
||||
const char S_titleparam[] PROGMEM = "Setup";
|
||||
const char S_titleparamsaved[] PROGMEM = "Setup saved";
|
||||
const char S_titleexit[] PROGMEM = "Exit";
|
||||
const char S_titlereset[] PROGMEM = "Reset";
|
||||
const char S_titleerase[] PROGMEM = "Erase";
|
||||
const char S_titleclose[] PROGMEM = "Close";
|
||||
const char S_options[] PROGMEM = "options";
|
||||
const char S_nonetworks[] PROGMEM = "No networks found. Refresh to scan again.";
|
||||
const char S_staticip[] PROGMEM = "Static IP";
|
||||
const char S_staticgw[] PROGMEM = "Static gateway";
|
||||
const char S_staticdns[] PROGMEM = "Static DNS";
|
||||
const char S_subnet[] PROGMEM = "Subnet";
|
||||
const char S_exiting[] PROGMEM = "Exiting";
|
||||
const char S_resetting[] PROGMEM = "Module will reset in a few seconds.";
|
||||
const char S_closing[] PROGMEM = "You can close the page, portal will continue to run";
|
||||
const char S_error[] PROGMEM = "An error occured";
|
||||
const char S_notfound[] PROGMEM = "File not found\n\n";
|
||||
const char S_uri[] PROGMEM = "URI: ";
|
||||
const char S_method[] PROGMEM = "\nMethod: ";
|
||||
const char S_args[] PROGMEM = "\nArguments: ";
|
||||
const char S_parampre[] PROGMEM = "param_";
|
||||
|
||||
// debug strings
|
||||
const char D_HR[] PROGMEM = "--------------------";
|
||||
|
||||
|
||||
// softap ssid default prefix
|
||||
#ifdef ESP8266
|
||||
const char S_ssidpre[] PROGMEM = "ESP";
|
||||
#elif defined(ESP32)
|
||||
const char S_ssidpre[] PROGMEM = "ESP32";
|
||||
#else
|
||||
const char S_ssidpre[] PROGMEM = "WM";
|
||||
#endif
|
||||
|
||||
// END WIFI_MANAGER_OVERRIDE_STRINGS
|
||||
#endif
|
||||
|
||||
#endif
|
||||
14
main.cpp
14
main.cpp
@@ -31,24 +31,20 @@ void networkTask(void *pvParameters)
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
bool r = network->update();
|
||||
bool connected = network->update();
|
||||
|
||||
switch(r)
|
||||
if(connected)
|
||||
{
|
||||
// Network Device and MQTT is connected. Process all updates.
|
||||
case 0:
|
||||
case 1:
|
||||
if(openerEnabled)
|
||||
{
|
||||
networkOpener->update();
|
||||
}
|
||||
network->update();
|
||||
webCfgServer->update();
|
||||
break;
|
||||
// Neither Network Devicc or MQTT is connected. Call network to allow for a reconnect.
|
||||
default:
|
||||
}
|
||||
else
|
||||
{
|
||||
network->update();
|
||||
break;
|
||||
}
|
||||
|
||||
delay(200);
|
||||
|
||||
@@ -90,9 +90,12 @@ void WifiDevice::initialize()
|
||||
|
||||
if(_restartOnDisconnect)
|
||||
{
|
||||
_wm.setDisconnectedCallback([&]()
|
||||
WiFi.onEvent([&](WiFiEvent_t event, WiFiEventInfo_t info)
|
||||
{
|
||||
if(event == ARDUINO_EVENT_WIFI_STA_DISCONNECTED)
|
||||
{
|
||||
onDisconnected();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user