Remove WiFiManager and MycilaWebSerial
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
---------------------
|
||||
|
||||
Copyright © 2023-2024, Mathieu Carbou
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -1,67 +0,0 @@
|
||||
# MycilaWebSerial
|
||||
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
[](https://github.com/mathieucarbou/MycilaWebSerial/actions/workflows/ci.yml)
|
||||
[](https://registry.platformio.org/libraries/mathieucarbou/MycilaWebSerial)
|
||||
|
||||
MycilaWebSerial is a Serial Monitor for ESP32 that can be accessed remotely via a web browser. Webpage is stored in program memory of the microcontroller.
|
||||
|
||||
This library is based on the UI from [asjdf/WebSerialLite](https://github.com/asjdf/WebSerialLite) (and this part falls under GPL v3).
|
||||
|
||||
## Changes
|
||||
|
||||
- Simplified callbacks
|
||||
- Fixed UI
|
||||
- Fixed Web Socket auto reconnect
|
||||
- Fixed Web Socket client cleanup (See `WEBSERIAL_MAX_WS_CLIENTS`)
|
||||
- Command history (up/down arrow keys) saved in local storage
|
||||
- Support logo and fallback to title if not found.
|
||||
- Arduino 3 / ESP-IDF 5.1 Compatibility
|
||||
- Improved performance: can stream up to 20 lines per second is possible
|
||||
|
||||
To add a logo, add a handler for `/logo` to serve your logo in the image format you want, gzipped or not.
|
||||
You can use the [ESP32 embedding mechanism](https://docs.platformio.org/en/latest/platforms/espressif32.html).
|
||||
|
||||
## Preview
|
||||
|
||||

|
||||
|
||||
[DemoVideo](https://www.bilibili.com/video/BV1Jt4y1E7kj)
|
||||
|
||||
## Features
|
||||
|
||||
- Works on WebSockets
|
||||
- Realtime logging
|
||||
- Any number of Serial Monitors can be opened on the browser
|
||||
- Uses Async Webserver for better performance
|
||||
- Light weight (<3k)
|
||||
- Timestamp
|
||||
- Event driven
|
||||
|
||||
## Dependencies
|
||||
|
||||
- [mathieucarbou/ESPAsyncWebServer](https://github.com/mathieucarbou/ESPAsyncWebServer)
|
||||
|
||||
## Usage
|
||||
|
||||
```c++
|
||||
WebSerial.onMessage([](const String& msg) { Serial.println(msg); });
|
||||
WebSerial.begin(server);
|
||||
|
||||
WebSerial.print("foo bar baz");
|
||||
```
|
||||
|
||||
If you need line buffering to use print(c), printf, write(c), etc:
|
||||
|
||||
```c++
|
||||
WebSerial.onMessage([](const String& msg) { Serial.println(msg); });
|
||||
WebSerial.begin(server);
|
||||
|
||||
WebSerial.setBuffer(100); // initial buffer size
|
||||
|
||||
WebSerial.printf("Line 1: %" PRIu32 "\nLine 2: %" PRIu32, count, ESP.getFreeHeap());
|
||||
WebSerial.println();
|
||||
WebSerial.print("Line ");
|
||||
WebSerial.print(3);
|
||||
WebSerial.println();
|
||||
```
|
||||
@@ -1,8 +0,0 @@
|
||||
# bundle exec jekyll serve --host=0.0.0.0
|
||||
|
||||
title: MycilaWebSerial
|
||||
description: "MycilaWebSerial is a Serial Monitor for ESP32 that can be accessed remotely via a web browser."
|
||||
remote_theme: pages-themes/cayman@v0.2.0
|
||||
plugins:
|
||||
- jekyll-remote-theme
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
# MycilaWebSerial
|
||||
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
[](https://github.com/mathieucarbou/MycilaWebSerial/actions/workflows/ci.yml)
|
||||
[](https://registry.platformio.org/libraries/mathieucarbou/MycilaWebSerial)
|
||||
|
||||
MycilaWebSerial is a Serial Monitor for ESP32 that can be accessed remotely via a web browser. Webpage is stored in program memory of the microcontroller.
|
||||
|
||||
This library is based on the UI from [asjdf/WebSerialLite](https://github.com/asjdf/WebSerialLite) (and this part falls under GPL v3).
|
||||
|
||||
## Changes
|
||||
|
||||
- Simplified callbacks
|
||||
- Fixed UI
|
||||
- Fixed Web Socket auto reconnect
|
||||
- Fixed Web Socket client cleanup (See `WEBSERIAL_MAX_WS_CLIENTS`)
|
||||
- Command history (up/down arrow keys) saved in local storage
|
||||
- Support logo and fallback to title if not found.
|
||||
- Arduino 3 / ESP-IDF 5.1 Compatibility
|
||||
- Improved performance: can stream up to 20 lines per second is possible
|
||||
|
||||
To add a logo, add a handler for `/logo` to serve your logo in the image format you want, gzipped or not.
|
||||
You can use the [ESP32 embedding mechanism](https://docs.platformio.org/en/latest/platforms/espressif32.html).
|
||||
|
||||
## Preview
|
||||
|
||||

|
||||
|
||||
[DemoVideo](https://www.bilibili.com/video/BV1Jt4y1E7kj)
|
||||
|
||||
## Features
|
||||
|
||||
- Works on WebSockets
|
||||
- Realtime logging
|
||||
- Any number of Serial Monitors can be opened on the browser
|
||||
- Uses Async Webserver for better performance
|
||||
- Light weight (<3k)
|
||||
- Timestamp
|
||||
- Event driven
|
||||
|
||||
## Dependencies
|
||||
|
||||
- [mathieucarbou/ESPAsyncWebServer](https://github.com/mathieucarbou/ESPAsyncWebServer)
|
||||
|
||||
## Usage
|
||||
|
||||
```c++
|
||||
WebSerial.onMessage([](const String& msg) { Serial.println(msg); });
|
||||
WebSerial.begin(server);
|
||||
|
||||
WebSerial.print("foo bar baz");
|
||||
```
|
||||
|
||||
If you need line buffering to use print(c), printf, write(c), etc:
|
||||
|
||||
```c++
|
||||
WebSerial.onMessage([](const String& msg) { Serial.println(msg); });
|
||||
WebSerial.begin(server);
|
||||
|
||||
WebSerial.setBuffer(100); // initial buffer size
|
||||
|
||||
WebSerial.printf("Line 1: %" PRIu32 "\nLine 2: %" PRIu32, count, ESP.getFreeHeap());
|
||||
WebSerial.println();
|
||||
WebSerial.print("Line ");
|
||||
WebSerial.print(3);
|
||||
WebSerial.println();
|
||||
```
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* This example shows how to use WebSerial variant to send data to the browser when timing, speed and latency are important.
|
||||
* WebSerial focuses on reducing latency and increasing speed by enqueueing messages and sending them in a single packet.
|
||||
*
|
||||
* The responsibility is left to the caller to ensure that the messages sent are not too large or not too small and frequent.
|
||||
* For example, use of printf(), write(c), print(c), etc are not recommended.
|
||||
*
|
||||
* This variant can allow WebSerial to support a high speed of more than 20 messages per second like in this example.
|
||||
*
|
||||
* It can be used to log data, debug, or send data to the browser in real-time without any delay.
|
||||
*
|
||||
* You might want to look at the Logging variant to see how to better use WebSerial for streaming logging.
|
||||
*
|
||||
* You might want to control these flags to control the async library performance:
|
||||
* -D CONFIG_ASYNC_TCP_QUEUE_SIZE=128
|
||||
* -D CONFIG_ASYNC_TCP_RUNNING_CORE=1
|
||||
* -D WS_MAX_QUEUED_MESSAGES=128
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#if defined(ESP8266)
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESPAsyncTCP.h>
|
||||
#elif defined(ESP32)
|
||||
#include <AsyncTCP.h>
|
||||
#include <WiFi.h>
|
||||
#endif
|
||||
#include <DNSServer.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <WString.h>
|
||||
#include <MycilaWebSerial.h>
|
||||
|
||||
AsyncWebServer server(80);
|
||||
|
||||
static const char* dict = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890";
|
||||
static uint32_t last = millis();
|
||||
static uint32_t count = 0;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
WiFi.softAP("WSLDemo");
|
||||
Serial.print("IP Address: ");
|
||||
Serial.println(WiFi.softAPIP().toString());
|
||||
|
||||
WebSerial.onMessage([](const String& msg) { Serial.println(msg); });
|
||||
WebSerial.begin(&server);
|
||||
|
||||
server.onNotFound([](AsyncWebServerRequest* request) { request->redirect("/webserial"); });
|
||||
server.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (millis() - last > 50) {
|
||||
count++;
|
||||
long r = random(10, 250) + 15;
|
||||
String buffer;
|
||||
buffer.reserve(r);
|
||||
buffer += count;
|
||||
while (buffer.length() < 10) {
|
||||
buffer += " ";
|
||||
}
|
||||
buffer += "";
|
||||
for (int i = 0; i < r; i++) {
|
||||
buffer += dict[random(0, 62)];
|
||||
}
|
||||
WebSerial.print(buffer);
|
||||
last = millis();
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* This example shows how to use WebSerial variant to send logging data to the browser.
|
||||
*
|
||||
* Before using this example, make sure to look at the WebSerial example before and its description.\
|
||||
*
|
||||
* You might want to control these flags to control the async library performance:
|
||||
* -D CONFIG_ASYNC_TCP_QUEUE_SIZE=128
|
||||
* -D CONFIG_ASYNC_TCP_RUNNING_CORE=1
|
||||
* -D WS_MAX_QUEUED_MESSAGES=128
|
||||
*/
|
||||
#include <Arduino.h>
|
||||
#if defined(ESP8266)
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESPAsyncTCP.h>
|
||||
#elif defined(ESP32)
|
||||
#include <AsyncTCP.h>
|
||||
#include <WiFi.h>
|
||||
#endif
|
||||
#include <DNSServer.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <WString.h>
|
||||
#include <MycilaWebSerial.h>
|
||||
|
||||
AsyncWebServer server(80);
|
||||
|
||||
static uint32_t last = millis();
|
||||
static uint32_t count = 0;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
WiFi.softAP("WSLDemo");
|
||||
Serial.print("IP Address: ");
|
||||
Serial.println(WiFi.softAPIP().toString());
|
||||
|
||||
WebSerial.onMessage([](const String& msg) { Serial.println(msg); });
|
||||
WebSerial.begin(&server);
|
||||
WebSerial.setBuffer(100);
|
||||
|
||||
server.onNotFound([](AsyncWebServerRequest* request) { request->redirect("/webserial"); });
|
||||
server.begin();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (millis() - last > 1000) {
|
||||
count++;
|
||||
|
||||
WebSerial.print(F("IP address: "));
|
||||
WebSerial.println(WiFi.softAPIP());
|
||||
WebSerial.printf("Uptime: %lums\n", millis());
|
||||
WebSerial.printf("Free heap: %" PRIu32 "\n", ESP.getFreeHeap());
|
||||
|
||||
last = millis();
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
{
|
||||
"name": "MycilaWebSerial",
|
||||
"version": "6.3.0",
|
||||
"keywords": "MycilaWebSerial, serial, monitor, ESP8266, ESP32, webpage, websocket, wireless",
|
||||
"description": "MycilaWebSerial is a webpage based Serial Monitor to log, monitor, or debug your code remotely.",
|
||||
"homepage": "https://github.com/mathieucarbou/MycilaWebSerial",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mathieucarbou/MycilaWebSerial.git"
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Mathieu Carbou",
|
||||
"email": "mathieu.carbou@gmail.com",
|
||||
"maintainer": true
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": ["espressif8266", "espressif32"],
|
||||
"headers": ["MycilaWebSerial.h"],
|
||||
"dependencies": [
|
||||
{
|
||||
"owner": "mathieucarbou",
|
||||
"name": "ESPAsyncWebServer",
|
||||
"version": "^3.1.2",
|
||||
"platforms": ["espressif8266", "espressif32"]
|
||||
}
|
||||
],
|
||||
"export": {
|
||||
"include": [
|
||||
"examples",
|
||||
"src",
|
||||
"library.json",
|
||||
"library.properties",
|
||||
"LICENSE",
|
||||
"README.md"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
name=MycilaWebSerial
|
||||
version=6.3.0
|
||||
author=Mathieu Carbou <mathieu.carbou@gmail.com>
|
||||
category=Communication
|
||||
maintainer=Mathieu Carbou <mathieu.carbou@gmail.com>
|
||||
sentence=A Web based Serial Monitor for ESP8266 & ESP32 to debug your code remotely.
|
||||
paragraph=MycilaWebSerial is a webpage based Serial Monitor to log, monitor, or debug your code remotely.
|
||||
url=https://github.com/mathieucarbou/MycilaWebSerial
|
||||
architectures=esp8266,esp32
|
||||
license=MIT
|
||||
@@ -1,42 +0,0 @@
|
||||
[env]
|
||||
framework = arduino
|
||||
build_flags =
|
||||
-Wall -Wextra
|
||||
-D CONFIG_ARDUHAL_LOG_COLORS
|
||||
-D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
||||
-D CONFIG_ASYNC_TCP_QUEUE_SIZE=128
|
||||
-D CONFIG_ASYNC_TCP_RUNNING_CORE=1
|
||||
-D WS_MAX_QUEUED_MESSAGES=128
|
||||
lib_deps =
|
||||
mathieucarbou/ESPAsyncWebServer @ 3.1.2
|
||||
upload_protocol = esptool
|
||||
monitor_speed = 115200
|
||||
monitor_filters = esp32_exception_decoder, log2file
|
||||
|
||||
[platformio]
|
||||
lib_dir = .
|
||||
src_dir = examples/Demo
|
||||
; src_dir = examples/Demo_AP
|
||||
; src_dir = examples/HighPerf
|
||||
; src_dir = examples/Logging
|
||||
|
||||
[env:arduino]
|
||||
platform = espressif32
|
||||
board = esp32dev
|
||||
|
||||
[env:arduino-2]
|
||||
platform = espressif32@6.8.1
|
||||
board = esp32dev
|
||||
|
||||
[env:arduino-3]
|
||||
platform = espressif32
|
||||
platform_packages=
|
||||
platformio/framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#3.0.4
|
||||
platformio/framework-arduinoespressif32-libs @ https://github.com/espressif/arduino-esp32/releases/download/3.0.4/esp32-arduino-libs-3.0.4.zip
|
||||
board = esp32dev
|
||||
|
||||
[env:esp8266]
|
||||
platform = espressif8266
|
||||
board = huzzah
|
||||
lib_deps =
|
||||
mathieucarbou/ESPAsyncWebServer @ 3.1.2
|
||||
@@ -1,674 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
@@ -1,19 +0,0 @@
|
||||
# Frontend
|
||||
|
||||
The `index.html` is the only page of MycilaWebSerial and you can modify the page yourself and regenerate it.
|
||||
|
||||
In addition, I am also very happy that you can participate in fixing the bugs of the library or enhancing the functions of the library.
|
||||
|
||||
## Quick Start
|
||||
|
||||
You can modify and regenerate the page in three step. The execution of the following commands is based on the project root directory and you should install NodeJS and pnpm first.
|
||||
|
||||
```shell
|
||||
cd .\frontend\
|
||||
pnpm i
|
||||
pnpm build
|
||||
```
|
||||
|
||||
The `finalize.js` will compress and html and generate a new `WebSerialWebPage.h` in `../src` floder automatically.
|
||||
|
||||
Then you can rebuild your program, the new page ought be embedded in the firmware as expected.
|
||||
@@ -1,66 +0,0 @@
|
||||
let path = require('path');
|
||||
let fs = require('fs');
|
||||
const {minify} = require('html-minifier-terser');
|
||||
let gzipAsync = require('@gfx/zopfli').gzipAsync;
|
||||
|
||||
const SAVE_PATH = '../src';
|
||||
|
||||
function chunkArray(myArray, chunk_size) {
|
||||
let index = 0;
|
||||
let arrayLength = myArray.length;
|
||||
let tempArray = [];
|
||||
for (index = 0; index < arrayLength; index += chunk_size) {
|
||||
let myChunk = myArray.slice(index, index + chunk_size);
|
||||
tempArray.push(myChunk);
|
||||
}
|
||||
return tempArray;
|
||||
}
|
||||
|
||||
function addLineBreaks(buffer) {
|
||||
let data = '';
|
||||
let chunks = chunkArray(buffer, 30);
|
||||
chunks.forEach((chunk, index) => {
|
||||
data += chunk.join(',');
|
||||
if (index + 1 !== chunks.length) {
|
||||
data += ',\n';
|
||||
}
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
(async function(){
|
||||
const indexHtml = fs.readFileSync(path.resolve(__dirname, './index.html')).toString();
|
||||
const indexHtmlMinify = await minify(indexHtml, {
|
||||
collapseWhitespace: true,
|
||||
removeComments: true,
|
||||
removeAttributeQuotes: true,
|
||||
removeRedundantAttributes: true,
|
||||
removeScriptTypeAttributes: true,
|
||||
removeStyleLinkTypeAttributes: true,
|
||||
useShortDoctype: true,
|
||||
minifyCSS: true,
|
||||
minifyJS: true,
|
||||
sortAttributes: true, // 不会改变生成的html长度 但会优化压缩后体积
|
||||
sortClassName: true, // 不会改变生成的html长度 但会优化压缩后体积
|
||||
});
|
||||
console.log(`[finalize.js] Minified index.html | Original Size: ${(indexHtml.length / 1024).toFixed(2) }KB | Minified Size: ${(indexHtmlMinify.length / 1024).toFixed(2) }KB`);
|
||||
|
||||
try{
|
||||
const GZIPPED_INDEX = await gzipAsync(indexHtmlMinify, { numiterations: 15 });
|
||||
|
||||
const FILE =
|
||||
`
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#pragma once
|
||||
const uint32_t WEBSERIAL_HTML_SIZE = ${GZIPPED_INDEX.length};
|
||||
const uint8_t WEBSERIAL_HTML[] PROGMEM = {
|
||||
${ addLineBreaks(GZIPPED_INDEX) }
|
||||
};
|
||||
`;
|
||||
|
||||
fs.writeFileSync(path.resolve(__dirname, SAVE_PATH+'/MycilaWebSerialPage.h'), FILE);
|
||||
console.log(`[finalize.js] Compressed Bundle into MycilaWebSerialPage.h header file | Total Size: ${(GZIPPED_INDEX.length / 1024).toFixed(2) }KB`)
|
||||
}catch(err){
|
||||
return console.error(err);
|
||||
}
|
||||
})();
|
||||
@@ -1,368 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<title>Web Console</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<style type="text/css">
|
||||
div {
|
||||
display: block;
|
||||
}
|
||||
|
||||
a {
|
||||
margin: 0.4rem;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
*,
|
||||
::after,
|
||||
::before {
|
||||
-webkit-box-sizing: inherit;
|
||||
box-sizing: inherit;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0 0 1rem;
|
||||
}
|
||||
|
||||
body {
|
||||
overscroll-behavior: none;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI",
|
||||
Roboto, "Helvetica Neue", sans-serif;
|
||||
}
|
||||
|
||||
.text-center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.gray {
|
||||
color: #667189;
|
||||
}
|
||||
|
||||
.shadow {
|
||||
filter: drop-shadow(0 4px 3px rgb(0 0 0 / 0.07)) drop-shadow(0 2px 2px rgb(0 0 0 / 0.06));
|
||||
}
|
||||
|
||||
.w-full {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.gap-2 {
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.grow {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.justify-items-end {
|
||||
justify-items: end;
|
||||
}
|
||||
|
||||
.rounded {
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
|
||||
.section {
|
||||
box-sizing: border-box;
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.main {
|
||||
/* padding-top: 3rem; */
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
height: 100dvh;
|
||||
}
|
||||
|
||||
.main .pannel {
|
||||
position: relative;
|
||||
border: #fff;
|
||||
border-style: solid;
|
||||
border-width: 0.5rem;
|
||||
border-radius: 1rem;
|
||||
background-color: #fff;
|
||||
width: calc(100% - 1rem);
|
||||
font-size: medium;
|
||||
margin-top: 2.5rem;
|
||||
}
|
||||
|
||||
.pannel button {
|
||||
cursor: pointer;
|
||||
padding: 8px 10px 8px;
|
||||
font-size: medium;
|
||||
outline-style: none;
|
||||
border: 0px;
|
||||
color: #fff;
|
||||
background-color: #0067f4;
|
||||
}
|
||||
|
||||
.pannel button:disabled {
|
||||
background-color: #5a6169;
|
||||
}
|
||||
|
||||
.pannel #record {
|
||||
min-height: 3.25rem;
|
||||
padding: 0.5rem;
|
||||
resize: vertical;
|
||||
overscroll-behavior: none;
|
||||
}
|
||||
|
||||
#control-button {
|
||||
position: absolute;
|
||||
top: 0.5rem;
|
||||
right: 0.5rem;
|
||||
}
|
||||
|
||||
#control-button button {
|
||||
background-color: #5a6169;
|
||||
}
|
||||
|
||||
.alert span {
|
||||
user-select: none;
|
||||
background: #ffe14d;
|
||||
padding: 2px 10px;
|
||||
display: block;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.footer {
|
||||
padding: 1rem 0.5rem;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
.copyright {
|
||||
padding-bottom: 1rem;
|
||||
}
|
||||
|
||||
.float-left {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.float-right {
|
||||
float: right;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="section main text-center">
|
||||
<h1 id="title" style="display: none;">Web Console</h1>
|
||||
<a href="/">
|
||||
<img id="logo" src="/logo" onerror="removeLogo();" />
|
||||
</a>
|
||||
|
||||
<div class="pannel shadow grid gap-2">
|
||||
<div id="control-button">
|
||||
<button class="rounded shadow" onclick="terminalClean()">
|
||||
<svg viewBox="64 64 896 896" focusable="false" data-icon="delete" width="1em" height="1em"
|
||||
fill="currentColor" aria-hidden="true">
|
||||
<path
|
||||
d="M864 256H736v-80c0-35.3-28.7-64-64-64H352c-35.3 0-64 28.7-64 64v80H160c-17.7 0-32 14.3-32 32v32c0 4.4 3.6 8 8 8h60.4l24.7 523c1.6 34.1 29.8 61 63.9 61h454c34.2 0 62.3-26.8 63.9-61l24.7-523H888c4.4 0 8-3.6 8-8v-32c0-17.7-14.3-32-32-32zm-200 0H360v-72h304v72z">
|
||||
</path>
|
||||
</svg>
|
||||
</button>
|
||||
<button class="rounded shadow" onclick="enableFlowLock=!enableFlowLock">
|
||||
<svg viewBox="64 64 896 896" focusable="false" data-icon="lock" width="1em" height="1em"
|
||||
fill="currentColor" aria-hidden="true">
|
||||
<path
|
||||
d="M832 464h-68V240c0-70.7-57.3-128-128-128H388c-70.7 0-128 57.3-128 128v224h-68c-17.7 0-32 14.3-32 32v384c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V496c0-17.7-14.3-32-32-32zM332 240c0-30.9 25.1-56 56-56h248c30.9 0 56 25.1 56 56v224H332V240zm460 600H232V536h560v304zM484 701v53c0 4.4 3.6 8 8 8h40c4.4 0 8-3.6 8-8v-53a48.01 48.01 0 10-56 0z">
|
||||
</path>
|
||||
</svg>
|
||||
</button>
|
||||
<button class="rounded shadow" onclick="enableTimestamp=!enableTimestamp">
|
||||
<svg viewBox="64 64 896 896" focusable="false" data-icon="clock-circle" width="1em" height="1em"
|
||||
fill="currentColor" aria-hidden="true">
|
||||
<path
|
||||
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z">
|
||||
</path>
|
||||
<path
|
||||
d="M686.7 638.6L544.1 535.5V288c0-4.4-3.6-8-8-8H488c-4.4 0-8 3.6-8 8v275.4c0 2.6 1.2 5 3.3 6.5l165.4 120.6c3.6 2.6 8.6 1.8 11.2-1.7l28.6-39c2.6-3.7 1.8-8.7-1.8-11.2z">
|
||||
</path>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<textarea class="w-full rounded" title="record" id="record" cols="30" rows="40" disabled></textarea>
|
||||
<!--<div class="flex w-full grid gap-2" id="terminal">
|
||||
<input type="text" name="cmd" id="command-text" class="grow rounded" /><button
|
||||
class="grid justify-items-end rounded shadow" id="command-button">
|
||||
SEND
|
||||
</button>
|
||||
</div>!-->
|
||||
</div>
|
||||
<h1 />
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
let gateway = `ws://${window.location.host + window.location.pathname}ws`;
|
||||
let websocket;
|
||||
let textArea = document.getElementById("record");
|
||||
let enableFlowLock = true;
|
||||
let enableTimestamp = true;
|
||||
let pingTimeout;
|
||||
let connectTimeout;
|
||||
let commandHistory = [];
|
||||
let commandHistoryIdx = 0;
|
||||
|
||||
function removeLogo() {
|
||||
document.getElementById("logo").remove();
|
||||
document.getElementById("title").style.display = "block";
|
||||
}
|
||||
|
||||
function initWebPage() {
|
||||
//document.getElementById("command-button").disabled = true;
|
||||
//document.getElementById("command-text").disabled = true;
|
||||
initCommandHistory();
|
||||
initWebSocket();
|
||||
//initButton();
|
||||
//trapKeyPress();
|
||||
}
|
||||
|
||||
function initCommandHistory() {
|
||||
const json = localStorage.history;
|
||||
commandHistory = json ? JSON.parse(json) : [];
|
||||
commandHistoryIdx = commandHistory.length;
|
||||
}
|
||||
|
||||
function initWebSocket() {
|
||||
clearTimeout(connectTimeout);
|
||||
clearTimeout(pingTimeout);
|
||||
pingTimeout = false;
|
||||
connectTimeout = setTimeout(() => {
|
||||
terminalWrite("[WebSerial] Connect timeout.");
|
||||
websocket.close();
|
||||
initWebSocket();
|
||||
}, 3000);
|
||||
terminalWrite("[WebSerial] Connecting...");
|
||||
websocket = new WebSocket(gateway);
|
||||
websocket.onopen = onOpen;
|
||||
websocket.onclose = onClose;
|
||||
websocket.onmessage = onMessage;
|
||||
websocket.onerror = onError;
|
||||
}
|
||||
|
||||
/*
|
||||
function initButton() {
|
||||
document.getElementById("command-button").addEventListener("click", sendCommand);
|
||||
}
|
||||
|
||||
function trapKeyPress() {
|
||||
document.getElementById("command-text").addEventListener("keypress", (event) => {
|
||||
if (event.code === "Enter") {
|
||||
event.preventDefault();
|
||||
document.getElementById("command-button").click();
|
||||
}
|
||||
});
|
||||
document.addEventListener("keydown", (event) => {
|
||||
if (document.activeElement && document.activeElement.id === 'command-text') {
|
||||
if (event.code === "ArrowUp") {
|
||||
commandHistoryIdx--;
|
||||
if (commandHistoryIdx < 0)
|
||||
commandHistoryIdx = commandHistory.length > 0 ? commandHistory.length - 1 : 0;
|
||||
if (commandHistoryIdx >= 0 && commandHistoryIdx < commandHistory.length)
|
||||
document.getElementById("command-text").value = commandHistory[commandHistoryIdx];
|
||||
|
||||
} else if (event.code === "ArrowDown") {
|
||||
commandHistoryIdx++;
|
||||
if (commandHistoryIdx >= commandHistory.length)
|
||||
commandHistoryIdx = 0;
|
||||
if (commandHistoryIdx >= 0 && commandHistoryIdx < commandHistory.length)
|
||||
document.getElementById("command-text").value = commandHistory[commandHistoryIdx];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
function onOpen(event) {
|
||||
clearTimeout(connectTimeout);
|
||||
terminalWrite("[WebSerial] Connected...");
|
||||
//document.getElementById("command-button").disabled = false;
|
||||
//document.getElementById("command-text").disabled = false;
|
||||
}
|
||||
|
||||
function onError(e) {
|
||||
console.log("[WebSerial] Error!", e);
|
||||
websocket.close();
|
||||
}
|
||||
|
||||
function onClose(e) {
|
||||
console.log("[WebSerial] Connection closed.", e);
|
||||
}
|
||||
|
||||
function onMessage(event) {
|
||||
if (event.data == 'pong') {
|
||||
clearTimeout(pingTimeout);
|
||||
pingTimeout = false;
|
||||
} else {
|
||||
terminalWrite(event.data);
|
||||
}
|
||||
}
|
||||
|
||||
function terminalWrite(raw) {
|
||||
if (enableTimestamp) {
|
||||
let now = new Date();
|
||||
raw = "[" + now.toLocaleTimeString() + "] " + raw + "\n";
|
||||
}
|
||||
textArea.value += raw + "\n";
|
||||
if (!enableFlowLock) {
|
||||
textArea.scrollTop = textArea.scrollHeight;
|
||||
}
|
||||
}
|
||||
|
||||
function terminalClean() {
|
||||
textArea.value = "";
|
||||
textArea.scrollTop = textArea.scrollHeight;
|
||||
}
|
||||
|
||||
/*
|
||||
function sendCommand() {
|
||||
let cmd = document.getElementById("command-text").value;
|
||||
console.log('send command: ', cmd);
|
||||
websocket.send(cmd);
|
||||
commandHistory.push(cmd);
|
||||
console.log('history size: ', commandHistory.length);
|
||||
if (commandHistory.length > 20) {
|
||||
console.log('history cleanup');
|
||||
commandHistory.splice(0, commandHistory.length - 20);
|
||||
console.log('history size: ', commandHistory.length);
|
||||
}
|
||||
commandHistoryIdx = commandHistory.length;
|
||||
document.getElementById("command-text").value = "";
|
||||
localStorage.history = JSON.stringify(commandHistory);
|
||||
}
|
||||
*/
|
||||
|
||||
setInterval(() => {
|
||||
if (!pingTimeout && websocket.readyState == WebSocket.OPEN) {
|
||||
pingTimeout = setTimeout(() => {
|
||||
terminalWrite("[WebSerial] Ping timeout.");
|
||||
websocket.close();
|
||||
initWebSocket();
|
||||
}, 10000);
|
||||
websocket.send("ping");
|
||||
}
|
||||
}, 2000);
|
||||
|
||||
window.addEventListener("DOMContentLoaded", function () {
|
||||
initWebPage();
|
||||
}, false);
|
||||
</script>
|
||||
|
||||
</html>
|
||||
240
lib/MycilaWebSerial/portal/package-lock.json
generated
240
lib/MycilaWebSerial/portal/package-lock.json
generated
@@ -1,240 +0,0 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"dependencies": {
|
||||
"@gfx/zopfli": "^1.0.15",
|
||||
"html-minifier-terser": "^7.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@gfx/zopfli": {
|
||||
"version": "1.0.15",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"base64-js": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/gen-mapping": {
|
||||
"version": "0.3.3",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jridgewell/set-array": "^1.0.1",
|
||||
"@jridgewell/sourcemap-codec": "^1.4.10",
|
||||
"@jridgewell/trace-mapping": "^0.3.9"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/resolve-uri": {
|
||||
"version": "3.1.1",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/set-array": {
|
||||
"version": "1.1.2",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/source-map": {
|
||||
"version": "0.3.5",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jridgewell/gen-mapping": "^0.3.0",
|
||||
"@jridgewell/trace-mapping": "^0.3.9"
|
||||
}
|
||||
},
|
||||
"node_modules/@jridgewell/sourcemap-codec": {
|
||||
"version": "1.4.15",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@jridgewell/trace-mapping": {
|
||||
"version": "0.3.19",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jridgewell/resolve-uri": "^3.1.0",
|
||||
"@jridgewell/sourcemap-codec": "^1.4.14"
|
||||
}
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "8.10.0",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/base64-js": {
|
||||
"version": "1.5.1",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/buffer-from": {
|
||||
"version": "1.1.2",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/camel-case": {
|
||||
"version": "4.1.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"pascal-case": "^3.1.2",
|
||||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/clean-css": {
|
||||
"version": "5.3.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"source-map": "~0.6.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/commander": {
|
||||
"version": "10.0.1",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/dot-case": {
|
||||
"version": "3.0.4",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"no-case": "^3.0.4",
|
||||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/entities": {
|
||||
"version": "4.5.0",
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">=0.12"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/fb55/entities?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/html-minifier-terser": {
|
||||
"version": "7.2.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"camel-case": "^4.1.2",
|
||||
"clean-css": "~5.3.2",
|
||||
"commander": "^10.0.0",
|
||||
"entities": "^4.4.0",
|
||||
"param-case": "^3.0.4",
|
||||
"relateurl": "^0.2.7",
|
||||
"terser": "^5.15.1"
|
||||
},
|
||||
"bin": {
|
||||
"html-minifier-terser": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.13.1 || >=16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/lower-case": {
|
||||
"version": "2.0.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/no-case": {
|
||||
"version": "3.0.4",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"lower-case": "^2.0.2",
|
||||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/param-case": {
|
||||
"version": "3.0.4",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dot-case": "^3.0.4",
|
||||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/pascal-case": {
|
||||
"version": "3.1.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"no-case": "^3.0.4",
|
||||
"tslib": "^2.0.3"
|
||||
}
|
||||
},
|
||||
"node_modules/relateurl": {
|
||||
"version": "0.2.7",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map": {
|
||||
"version": "0.6.1",
|
||||
"license": "BSD-3-Clause",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map-support": {
|
||||
"version": "0.5.21",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"buffer-from": "^1.0.0",
|
||||
"source-map": "^0.6.0"
|
||||
}
|
||||
},
|
||||
"node_modules/terser": {
|
||||
"version": "5.21.0",
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"@jridgewell/source-map": "^0.3.3",
|
||||
"acorn": "^8.8.2",
|
||||
"commander": "^2.20.0",
|
||||
"source-map-support": "~0.5.20"
|
||||
},
|
||||
"bin": {
|
||||
"terser": "bin/terser"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/terser/node_modules/commander": {
|
||||
"version": "2.20.3",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.6.2",
|
||||
"license": "0BSD"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"scripts": {
|
||||
"build": "node finalize.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@gfx/zopfli": "^1.0.15",
|
||||
"html-minifier-terser": "^7.1.0"
|
||||
}
|
||||
}
|
||||
177
lib/MycilaWebSerial/portal/pnpm-lock.yaml
generated
177
lib/MycilaWebSerial/portal/pnpm-lock.yaml
generated
@@ -1,177 +0,0 @@
|
||||
lockfileVersion: 5.3
|
||||
|
||||
specifiers:
|
||||
'@gfx/zopfli': ^1.0.15
|
||||
html-minifier-terser: ^7.1.0
|
||||
|
||||
dependencies:
|
||||
'@gfx/zopfli': 1.0.15
|
||||
html-minifier-terser: 7.1.0
|
||||
|
||||
packages:
|
||||
|
||||
/@gfx/zopfli/1.0.15:
|
||||
resolution: {integrity: sha512-7mBgpi7UD82fsff5ThQKet0uBTl4BYerQuc+/qA1ELTwWEiIedRTcD3JgiUu9wwZ2kytW8JOb165rSdAt8PfcQ==}
|
||||
engines: {node: '>= 8'}
|
||||
dependencies:
|
||||
base64-js: 1.5.1
|
||||
dev: false
|
||||
|
||||
/@jridgewell/gen-mapping/0.3.2:
|
||||
resolution: {integrity: sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
dependencies:
|
||||
'@jridgewell/set-array': 1.1.2
|
||||
'@jridgewell/sourcemap-codec': 1.4.14
|
||||
'@jridgewell/trace-mapping': 0.3.17
|
||||
dev: false
|
||||
|
||||
/@jridgewell/resolve-uri/3.1.0:
|
||||
resolution: {integrity: sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
dev: false
|
||||
|
||||
/@jridgewell/set-array/1.1.2:
|
||||
resolution: {integrity: sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
dev: false
|
||||
|
||||
/@jridgewell/source-map/0.3.2:
|
||||
resolution: {integrity: sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==}
|
||||
dependencies:
|
||||
'@jridgewell/gen-mapping': 0.3.2
|
||||
'@jridgewell/trace-mapping': 0.3.17
|
||||
dev: false
|
||||
|
||||
/@jridgewell/sourcemap-codec/1.4.14:
|
||||
resolution: {integrity: sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==}
|
||||
dev: false
|
||||
|
||||
/@jridgewell/trace-mapping/0.3.17:
|
||||
resolution: {integrity: sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g==}
|
||||
dependencies:
|
||||
'@jridgewell/resolve-uri': 3.1.0
|
||||
'@jridgewell/sourcemap-codec': 1.4.14
|
||||
dev: false
|
||||
|
||||
/acorn/8.8.2:
|
||||
resolution: {integrity: sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==}
|
||||
engines: {node: '>=0.4.0'}
|
||||
hasBin: true
|
||||
dev: false
|
||||
|
||||
/base64-js/1.5.1:
|
||||
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
|
||||
dev: false
|
||||
|
||||
/buffer-from/1.1.2:
|
||||
resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==}
|
||||
dev: false
|
||||
|
||||
/camel-case/4.1.2:
|
||||
resolution: {integrity: sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==}
|
||||
dependencies:
|
||||
pascal-case: 3.1.2
|
||||
tslib: 2.5.0
|
||||
dev: false
|
||||
|
||||
/clean-css/5.2.0:
|
||||
resolution: {integrity: sha512-2639sWGa43EMmG7fn8mdVuBSs6HuWaSor+ZPoFWzenBc6oN+td8YhTfghWXZ25G1NiiSvz8bOFBS7PdSbTiqEA==}
|
||||
engines: {node: '>= 10.0'}
|
||||
dependencies:
|
||||
source-map: 0.6.1
|
||||
dev: false
|
||||
|
||||
/commander/2.20.3:
|
||||
resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==}
|
||||
dev: false
|
||||
|
||||
/commander/9.5.0:
|
||||
resolution: {integrity: sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==}
|
||||
engines: {node: ^12.20.0 || >=14}
|
||||
dev: false
|
||||
|
||||
/dot-case/3.0.4:
|
||||
resolution: {integrity: sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==}
|
||||
dependencies:
|
||||
no-case: 3.0.4
|
||||
tslib: 2.5.0
|
||||
dev: false
|
||||
|
||||
/entities/4.4.0:
|
||||
resolution: {integrity: sha512-oYp7156SP8LkeGD0GF85ad1X9Ai79WtRsZ2gxJqtBuzH+98YUV6jkHEKlZkMbcrjJjIVJNIDP/3WL9wQkoPbWA==}
|
||||
engines: {node: '>=0.12'}
|
||||
dev: false
|
||||
|
||||
/html-minifier-terser/7.1.0:
|
||||
resolution: {integrity: sha512-BvPO2S7Ip0Q5qt+Y8j/27Vclj6uHC6av0TMoDn7/bJPhMWHI2UtR2e/zEgJn3/qYAmxumrGp9q4UHurL6mtW9Q==}
|
||||
engines: {node: ^14.13.1 || >=16.0.0}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
camel-case: 4.1.2
|
||||
clean-css: 5.2.0
|
||||
commander: 9.5.0
|
||||
entities: 4.4.0
|
||||
param-case: 3.0.4
|
||||
relateurl: 0.2.7
|
||||
terser: 5.16.3
|
||||
dev: false
|
||||
|
||||
/lower-case/2.0.2:
|
||||
resolution: {integrity: sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==}
|
||||
dependencies:
|
||||
tslib: 2.5.0
|
||||
dev: false
|
||||
|
||||
/no-case/3.0.4:
|
||||
resolution: {integrity: sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==}
|
||||
dependencies:
|
||||
lower-case: 2.0.2
|
||||
tslib: 2.5.0
|
||||
dev: false
|
||||
|
||||
/param-case/3.0.4:
|
||||
resolution: {integrity: sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==}
|
||||
dependencies:
|
||||
dot-case: 3.0.4
|
||||
tslib: 2.5.0
|
||||
dev: false
|
||||
|
||||
/pascal-case/3.1.2:
|
||||
resolution: {integrity: sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==}
|
||||
dependencies:
|
||||
no-case: 3.0.4
|
||||
tslib: 2.5.0
|
||||
dev: false
|
||||
|
||||
/relateurl/0.2.7:
|
||||
resolution: {integrity: sha1-VNvzd+UUQKypCkzSdGANP/LYiKk=}
|
||||
engines: {node: '>= 0.10'}
|
||||
dev: false
|
||||
|
||||
/source-map-support/0.5.21:
|
||||
resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==}
|
||||
dependencies:
|
||||
buffer-from: 1.1.2
|
||||
source-map: 0.6.1
|
||||
dev: false
|
||||
|
||||
/source-map/0.6.1:
|
||||
resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
dev: false
|
||||
|
||||
/terser/5.16.3:
|
||||
resolution: {integrity: sha512-v8wWLaS/xt3nE9dgKEWhNUFP6q4kngO5B8eYFUuebsu7Dw/UNAnpUod6UHo04jSSkv8TzKHjZDSd7EXdDQAl8Q==}
|
||||
engines: {node: '>=10'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
'@jridgewell/source-map': 0.3.2
|
||||
acorn: 8.8.2
|
||||
commander: 2.20.3
|
||||
source-map-support: 0.5.21
|
||||
dev: false
|
||||
|
||||
/tslib/2.5.0:
|
||||
resolution: {integrity: sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==}
|
||||
dev: false
|
||||
@@ -1,151 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
/*
|
||||
* Copyright (C) 2023-2024 Mathieu Carbou
|
||||
*/
|
||||
#include "MycilaWebSerial.h"
|
||||
|
||||
#include "MycilaWebSerialPage.h"
|
||||
|
||||
void WebSerialClass::setAuthentication(const String& username, const String& password) {
|
||||
_username = username;
|
||||
_password = password;
|
||||
_authenticate = !_username.isEmpty() && !_password.isEmpty();
|
||||
if (_ws) {
|
||||
_ws->setAuthentication(_username.c_str(), _password.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void WebSerialClass::begin(AsyncWebServer* server, const char* url) {
|
||||
_server = server;
|
||||
|
||||
String backendUrl = url;
|
||||
backendUrl.concat("ws");
|
||||
_ws = new AsyncWebSocket(backendUrl);
|
||||
|
||||
if (_authenticate) {
|
||||
_ws->setAuthentication(_username.c_str(), _password.c_str());
|
||||
}
|
||||
|
||||
_server->on(url, HTTP_GET, [&](AsyncWebServerRequest* request) {
|
||||
if (_authenticate) {
|
||||
if (!request->authenticate(_username.c_str(), _password.c_str()))
|
||||
return request->requestAuthentication();
|
||||
}
|
||||
AsyncWebServerResponse* response = request->beginResponse(200, "text/html", WEBSERIAL_HTML, sizeof(WEBSERIAL_HTML));
|
||||
response->addHeader("Content-Encoding", "gzip");
|
||||
request->send(response);
|
||||
});
|
||||
|
||||
_ws->onEvent([&](__unused AsyncWebSocket* server, AsyncWebSocketClient* client, AwsEventType type, __unused void* arg, uint8_t* data, __unused size_t len) -> void {
|
||||
if (type == WS_EVT_CONNECT) {
|
||||
client->setCloseClientOnQueueFull(false);
|
||||
return;
|
||||
}
|
||||
if (type == WS_EVT_DATA) {
|
||||
AwsFrameInfo* info = (AwsFrameInfo*)arg;
|
||||
if (info->final && info->index == 0 && info->len == len) {
|
||||
if (info->opcode == WS_TEXT) {
|
||||
data[len] = 0;
|
||||
}
|
||||
if (strcmp((char*)data, "ping") == 0)
|
||||
client->text("pong");
|
||||
else if (_recv)
|
||||
_recv(data, len);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
_server->addHandler(_ws);
|
||||
}
|
||||
|
||||
void WebSerialClass::onMessage(WSLMessageHandler recv) {
|
||||
_recv = recv;
|
||||
}
|
||||
|
||||
void WebSerialClass::onMessage(WSLStringMessageHandler callback) {
|
||||
_recvString = callback;
|
||||
_recv = [&](uint8_t* data, size_t len) {
|
||||
if (data && len) {
|
||||
String msg;
|
||||
msg.reserve(len);
|
||||
msg.concat((char*)data);
|
||||
_recvString(msg);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
size_t WebSerialClass::write(uint8_t m) {
|
||||
if (!_ws)
|
||||
return 0;
|
||||
|
||||
// We do not support non-buffered write on webserial for the HIGH_PERF version
|
||||
// we fail with a stack trace allowing the user to change the code to use write(const uint8_t* buffer, size_t size) instead
|
||||
if (!_initialBufferCapacity) {
|
||||
#ifdef ESP8266
|
||||
ets_printf("'-D WSL_FAIL_ON_NON_BUFFERED_WRITE' is set: non-buffered write is not supported. Please use write(const uint8_t* buffer, size_t size) instead.");
|
||||
#else
|
||||
log_e("'-D WSL_FAIL_ON_NON_BUFFERED_WRITE' is set: non-buffered write is not supported. Please use write(const uint8_t* buffer, size_t size) instead.");
|
||||
#endif
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
write(&m, 1);
|
||||
return (1);
|
||||
}
|
||||
|
||||
size_t WebSerialClass::write(const uint8_t* buffer, size_t size) {
|
||||
if (!_ws || size == 0)
|
||||
return 0;
|
||||
|
||||
// No buffer, send directly (i.e. use case for log streaming)
|
||||
if (!_initialBufferCapacity) {
|
||||
size = buffer[size - 1] == '\n' ? size - 1 : size;
|
||||
_send(buffer, size);
|
||||
return size;
|
||||
}
|
||||
|
||||
// fill the buffer while sending data for each EOL
|
||||
size_t start = 0, end = 0;
|
||||
while (end < size) {
|
||||
if (buffer[end] == '\n') {
|
||||
if (end > start) {
|
||||
_buffer.concat(reinterpret_cast<const char*>(buffer + start), end - start);
|
||||
}
|
||||
_send(reinterpret_cast<const uint8_t*>(_buffer.c_str()), _buffer.length());
|
||||
start = end + 1;
|
||||
}
|
||||
end++;
|
||||
}
|
||||
if (end > start) {
|
||||
_buffer.concat(reinterpret_cast<const char*>(buffer + start), end - start);
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
void WebSerialClass::_send(const uint8_t* buffer, size_t size) {
|
||||
if (_ws && size > 0) {
|
||||
_ws->cleanupClients(WSL_MAX_WS_CLIENTS);
|
||||
if (_ws->count()) {
|
||||
_ws->textAll((const char*)buffer, size);
|
||||
}
|
||||
}
|
||||
|
||||
// if buffer grew too much, free it, otherwise clear it
|
||||
if (_initialBufferCapacity) {
|
||||
if (_buffer.length() > _initialBufferCapacity) {
|
||||
setBuffer(_initialBufferCapacity);
|
||||
} else {
|
||||
_buffer.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WebSerialClass::setBuffer(size_t initialCapacity) {
|
||||
assert(initialCapacity <= UINT16_MAX);
|
||||
_initialBufferCapacity = initialCapacity;
|
||||
_buffer = String();
|
||||
_buffer.reserve(initialCapacity);
|
||||
}
|
||||
|
||||
WebSerialClass WebSerial;
|
||||
@@ -1,70 +0,0 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
/*
|
||||
* Copyright (C) 2023-2024 Mathieu Carbou
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#if defined(ESP8266)
|
||||
#include "ESP8266WiFi.h"
|
||||
#elif defined(ESP32)
|
||||
#include "WiFi.h"
|
||||
#endif
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <functional>
|
||||
|
||||
#define WSL_VERSION "6.3.0"
|
||||
#define WSL_VERSION_MAJOR 6
|
||||
#define WSL_VERSION_MINOR 3
|
||||
#define WSL_VERSION_REVISION 0
|
||||
|
||||
#ifndef WSL_MAX_WS_CLIENTS
|
||||
#define WSL_MAX_WS_CLIENTS DEFAULT_MAX_WS_CLIENTS
|
||||
#endif
|
||||
|
||||
// High performance mode:
|
||||
// - Low memory footprint (no stack allocation, no global buffer by default)
|
||||
// - Low latency (messages sent immediately to the WebSocket queue)
|
||||
// - High throughput (up to 20 messages per second, no locking mechanism)
|
||||
// Also recommended to tweak AsyncTCP and ESPAsyncWebServer settings, for example:
|
||||
// -D CONFIG_ASYNC_TCP_QUEUE_SIZE=128 // AsyncTCP queue size
|
||||
// -D CONFIG_ASYNC_TCP_RUNNING_CORE=1 // core for the async_task
|
||||
// -D WS_MAX_QUEUED_MESSAGES=128 // WS message queue size
|
||||
|
||||
typedef std::function<void(uint8_t* data, size_t len)> WSLMessageHandler;
|
||||
typedef std::function<void(const String& msg)> WSLStringMessageHandler;
|
||||
|
||||
class WebSerialClass : public Print {
|
||||
public:
|
||||
void begin(AsyncWebServer* server, const char* url = "/webserial");
|
||||
inline void setAuthentication(const char* username, const char* password) { setAuthentication(String(username), String(password)); }
|
||||
void setAuthentication(const String& username, const String& password);
|
||||
void onMessage(WSLMessageHandler recv);
|
||||
void onMessage(WSLStringMessageHandler recv);
|
||||
size_t write(uint8_t) override;
|
||||
size_t write(const uint8_t* buffer, size_t size) override;
|
||||
|
||||
// A buffer (shared across cores) can be initialised with an initial capacity to be able to use any Print functions event those that are not buffered and would
|
||||
// create a performance impact for WS calls. The goal of this buffer is to be used with lines ending with '\n', like log messages.
|
||||
// The buffer size will eventually grow until a '\n' is found, then the message will be sent to the WS clients and a new buffer will be created.
|
||||
// Set initialCapacity to 0 to disable buffering.
|
||||
// Must be called before begin(): calling it after will erase the buffer and its content will be lost.
|
||||
// The buffer is not enabled by default.
|
||||
void setBuffer(size_t initialCapacity);
|
||||
|
||||
private:
|
||||
// Server
|
||||
AsyncWebServer* _server;
|
||||
AsyncWebSocket* _ws;
|
||||
WSLMessageHandler _recv = nullptr;
|
||||
WSLStringMessageHandler _recvString = nullptr;
|
||||
bool _authenticate = false;
|
||||
String _username;
|
||||
String _password;
|
||||
size_t _initialBufferCapacity = 0;
|
||||
String _buffer;
|
||||
void _send(const uint8_t* buffer, size_t size);
|
||||
};
|
||||
|
||||
extern WebSerialClass WebSerial;
|
||||
@@ -1,84 +0,0 @@
|
||||
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#pragma once
|
||||
const uint32_t WEBSERIAL_HTML_SIZE = 2320;
|
||||
const uint8_t WEBSERIAL_HTML[] PROGMEM = {
|
||||
31,139,8,0,0,0,0,0,2,3,116,85,247,146,179,54,16,127,21,197,95,202,57,99,225,242,117,48,78,239,
|
||||
189,231,95,33,45,160,156,144,136,36,184,115,24,222,61,139,4,87,231,238,108,107,181,179,229,183,85,199,119,132,
|
||||
225,254,220,2,169,125,163,78,199,249,23,152,56,29,27,240,140,240,154,89,7,62,239,124,73,223,44,60,163,61,
|
||||
104,159,175,190,249,34,7,81,193,10,149,125,75,225,223,78,246,249,223,244,143,79,232,103,166,105,153,151,133,130,
|
||||
211,209,75,143,199,95,80,144,207,140,118,70,193,113,27,89,15,140,93,73,225,235,92,64,47,57,208,112,217,72,
|
||||
45,189,100,138,58,206,20,228,251,21,209,172,129,188,151,112,213,26,235,79,71,231,207,104,71,200,126,16,210,181,
|
||||
138,157,211,66,25,126,57,178,161,97,182,146,58,77,94,88,104,50,15,215,158,10,224,198,34,38,163,83,109,52,
|
||||
140,31,110,210,148,149,30,44,158,5,148,198,194,64,175,160,184,148,158,22,230,154,58,249,159,212,85,42,117,13,
|
||||
86,250,236,49,107,108,23,39,59,178,35,123,244,51,22,70,156,7,211,131,117,220,26,165,104,1,53,235,165,177,
|
||||
193,97,86,131,172,106,159,238,119,187,247,178,16,94,36,23,35,89,203,132,64,251,72,149,152,18,90,178,70,170,
|
||||
115,74,89,219,42,160,238,236,60,52,155,120,208,78,110,62,85,82,95,254,192,248,111,129,243,37,106,108,86,191,
|
||||
65,101,128,252,241,205,106,243,171,41,140,55,155,213,215,160,122,240,146,51,242,35,116,176,218,56,166,29,117,8,
|
||||
191,28,147,144,21,142,169,7,59,4,154,41,89,233,52,114,198,164,178,236,60,112,163,16,254,179,87,175,94,239,
|
||||
223,188,29,19,87,51,97,174,134,82,42,20,73,133,53,45,141,172,139,29,121,209,94,147,231,248,181,85,129,183,
|
||||
233,127,75,146,221,235,245,154,220,151,59,160,204,225,145,220,171,245,122,76,174,104,217,41,53,220,38,103,66,33,
|
||||
197,77,113,167,11,178,88,75,15,3,254,166,201,203,41,235,73,169,224,250,70,102,186,76,106,8,115,34,233,68,
|
||||
165,251,49,249,167,115,94,150,103,42,49,91,142,130,22,195,61,78,10,26,77,91,211,105,1,98,40,140,21,96,
|
||||
169,101,66,118,110,113,227,128,79,221,51,220,105,133,89,14,57,89,193,248,101,21,244,233,156,180,242,77,249,182,
|
||||
100,99,210,48,169,239,193,203,2,48,33,109,52,152,162,124,215,232,108,193,51,15,68,16,165,206,51,235,179,80,
|
||||
153,25,104,172,207,157,110,18,125,29,157,144,164,101,90,131,26,90,227,100,176,108,65,49,47,123,200,34,80,196,
|
||||
84,150,51,77,195,236,164,206,40,41,22,86,76,124,8,55,187,159,130,169,189,31,133,24,205,69,37,206,20,191,
|
||||
152,74,70,104,152,133,117,108,98,204,19,164,13,160,141,102,110,116,234,77,155,30,230,148,70,188,164,232,188,199,
|
||||
196,242,206,58,180,218,26,25,34,92,230,225,13,54,203,126,135,63,72,60,182,106,58,175,164,134,24,78,24,180,
|
||||
37,216,93,118,7,229,99,236,187,221,171,215,229,139,7,24,82,172,19,43,20,136,225,177,194,75,246,106,255,234,
|
||||
237,141,194,51,11,28,29,13,13,198,52,23,227,121,114,8,185,91,144,199,76,90,8,120,123,176,211,32,170,236,
|
||||
169,5,49,62,155,42,143,124,26,177,220,150,145,21,88,166,206,67,134,185,91,140,78,14,35,253,80,111,73,231,
|
||||
211,17,48,133,88,136,195,64,134,206,77,173,0,10,184,159,147,119,163,53,37,14,246,47,196,77,56,135,185,16,
|
||||
217,189,101,155,221,228,115,135,163,104,204,180,78,22,141,169,19,8,130,124,170,121,198,132,155,246,28,98,89,116,
|
||||
112,152,16,125,131,170,113,180,13,243,84,65,233,135,64,166,19,185,176,163,94,228,7,122,60,110,227,139,112,220,
|
||||
198,23,108,90,200,167,163,144,61,225,138,57,151,175,194,152,204,131,76,238,44,192,21,190,121,123,34,69,30,94,
|
||||
38,18,172,228,75,152,152,151,7,239,87,189,63,29,25,169,45,148,249,150,156,142,178,169,38,93,101,42,67,80,
|
||||
214,90,99,115,132,143,133,254,30,89,23,107,226,44,207,183,10,105,68,198,238,1,138,107,145,132,157,70,166,253,
|
||||
70,98,123,173,162,20,90,189,95,220,211,49,158,139,254,188,177,72,180,179,66,247,92,73,126,153,99,76,216,152,
|
||||
76,125,166,128,233,139,53,62,149,125,69,152,149,140,214,82,8,208,185,183,29,16,193,60,163,18,61,228,2,20,
|
||||
120,32,165,84,42,231,157,181,152,149,207,166,50,145,210,240,46,140,68,94,50,245,63,173,85,181,237,214,14,3,
|
||||
127,69,55,239,210,146,101,89,86,46,115,15,190,148,222,187,92,56,204,252,245,149,189,147,148,185,93,49,206,140,
|
||||
33,123,76,231,207,96,90,234,191,165,48,182,223,195,127,31,223,252,54,51,133,8,62,183,30,103,48,93,228,161,
|
||||
248,253,215,120,4,236,192,211,223,102,219,30,2,41,182,86,179,93,161,115,99,204,133,50,138,83,69,211,41,172,
|
||||
229,34,109,224,192,81,133,5,9,166,87,206,107,201,184,97,170,84,131,204,2,73,41,247,60,203,85,150,198,160,
|
||||
164,144,201,192,251,111,199,152,244,64,52,196,69,114,75,129,103,165,4,50,39,7,75,96,153,230,145,239,104,209,
|
||||
22,132,0,131,73,159,142,145,15,18,45,141,230,24,205,215,220,189,245,238,25,28,199,16,232,87,216,7,29,211,
|
||||
193,197,76,166,112,119,136,194,12,188,150,141,175,176,202,78,102,189,170,114,55,11,231,251,199,136,44,156,136,116,
|
||||
97,39,124,166,159,179,103,71,221,132,255,15,142,175,183,142,163,254,211,155,245,217,39,13,62,8,213,15,180,55,
|
||||
11,168,233,14,154,63,22,237,246,86,238,95,175,82,198,36,190,140,107,217,189,13,10,184,215,97,41,128,136,87,
|
||||
34,163,131,15,185,236,218,24,58,53,208,128,166,176,99,202,109,106,17,53,92,112,209,232,177,206,237,253,30,109,
|
||||
231,104,57,77,51,51,205,65,10,37,44,6,197,34,221,17,245,54,96,14,96,112,48,184,62,191,181,104,217,255,
|
||||
224,221,161,26,131,49,175,73,0,37,219,78,9,191,51,235,221,182,186,66,229,116,85,242,59,171,82,249,221,117,
|
||||
84,242,19,117,226,4,83,202,144,184,79,133,191,215,138,121,184,123,248,44,30,17,135,39,177,100,222,4,62,189,
|
||||
102,90,95,52,216,118,207,218,193,15,60,26,74,146,208,252,35,166,100,48,233,87,229,224,206,133,57,42,170,254,
|
||||
122,196,21,138,17,31,212,50,39,93,52,136,236,238,144,193,133,91,168,74,224,140,185,10,38,51,178,81,138,120,
|
||||
190,170,65,196,101,14,3,133,37,186,172,173,248,149,41,175,77,223,220,168,130,101,39,219,42,170,125,181,228,66,
|
||||
229,177,184,55,70,37,237,94,163,247,223,154,6,214,33,96,116,24,48,248,149,212,66,125,105,11,25,36,18,40,
|
||||
193,100,48,42,7,201,130,129,36,76,214,66,61,20,62,84,14,41,164,152,168,30,72,32,152,231,77,122,70,181,
|
||||
147,232,84,177,231,93,244,161,133,20,133,151,149,88,5,147,235,32,16,254,43,57,158,193,132,161,61,25,57,225,
|
||||
185,187,187,49,47,91,153,201,145,78,224,180,237,127,127,11,132,54,228,124,164,73,214,89,190,101,151,98,135,185,
|
||||
189,227,186,160,170,65,117,241,20,134,113,146,97,183,54,114,189,159,197,201,72,198,23,215,156,194,12,148,225,140,
|
||||
109,228,70,63,243,221,179,33,162,253,104,58,186,26,173,198,183,94,232,204,56,6,141,39,246,118,9,54,195,171,
|
||||
151,65,180,129,229,19,156,2,28,72,113,178,227,136,66,13,255,108,252,28,42,11,7,234,72,254,61,48,91,189,
|
||||
222,117,188,41,104,196,188,64,152,250,139,157,24,85,198,230,93,162,91,187,187,55,206,15,204,95,238,66,186,135,
|
||||
33,201,2,193,187,11,218,138,33,216,71,37,184,215,251,71,207,10,74,66,244,132,241,238,137,219,231,39,42,170,
|
||||
143,1,238,238,42,93,60,29,27,91,213,71,242,199,175,148,130,22,15,37,94,232,246,116,24,57,218,83,193,244,
|
||||
204,16,74,228,19,38,130,48,101,252,76,65,159,111,148,244,243,138,104,230,21,73,252,92,70,230,11,175,238,26,
|
||||
141,243,203,91,53,4,116,235,190,30,36,65,162,139,70,228,131,223,2,202,82,221,174,244,20,183,197,216,12,164,
|
||||
203,113,249,1,137,104,89,140,2,123,187,147,18,184,243,252,195,155,215,184,11,181,1,10,108,235,212,20,165,20,
|
||||
81,130,30,218,81,119,1,49,58,244,95,130,170,27,80,208,20,35,140,39,204,22,152,88,27,89,114,101,181,3,
|
||||
46,105,32,190,82,74,153,188,61,141,51,212,151,122,108,129,146,31,46,2,168,199,170,252,149,61,8,170,153,13,
|
||||
10,2,225,178,0,176,192,99,211,192,41,57,101,124,29,214,25,191,216,44,134,41,68,98,83,106,56,200,150,182,
|
||||
154,58,104,59,173,116,53,1,45,43,253,6,31,9,221,135,131,140,7,238,153,112,16,199,70,13,29,239,149,127,
|
||||
75,185,97,142,173,244,35,247,92,238,69,240,64,225,130,93,184,120,149,80,248,69,182,45,123,87,222,116,152,180,
|
||||
5,86,66,170,235,37,86,8,135,147,9,79,44,249,197,158,103,41,70,225,196,189,126,33,208,106,98,163,73,138,
|
||||
179,66,38,149,30,18,41,65,184,238,120,135,94,22,99,108,43,205,67,208,111,121,233,176,177,58,7,180,115,204,
|
||||
176,41,72,242,131,228,212,97,224,161,178,192,132,173,240,72,82,65,230,131,173,209,37,101,57,249,149,145,28,114,
|
||||
242,83,147,121,60,230,196,190,42,247,32,151,129,220,57,210,102,51,186,144,11,23,210,143,213,68,118,72,79,125,
|
||||
83,79,34,78,110,22,211,212,149,36,132,95,214,232,220,128,125,166,209,30,106,54,37,215,202,222,108,182,220,96,
|
||||
212,44,142,62,88,92,251,138,92,84,129,120,243,246,209,107,92,67,208,185,122,13,191,69,189,171,22,240,42,108,
|
||||
180,5,13,232,130,18,23,0,97,142,189,230,234,187,233,63,170,40,30,237,131,182,47,199,198,130,134,154,146,135,
|
||||
111,94,33,232,172,163,85,170,128,130,112,26,179,138,121,76,14,105,180,133,224,217,233,53,13,114,167,231,255,151,
|
||||
253,15,145,100,45,14,173,21,0,0
|
||||
};
|
||||
@@ -1,9 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
idf_component_register(
|
||||
SRCS "WiFiManager.cpp"
|
||||
INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES arduino
|
||||
)
|
||||
|
||||
project(WiFiManager)
|
||||
@@ -1,22 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 tzapu
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
@@ -1,576 +0,0 @@
|
||||
|
||||
# WiFiManager
|
||||
|
||||
Espressif ESPx WiFi Connection manager with fallback web configuration portal
|
||||
|
||||
:warning: This Documentation is out of date, see notes below
|
||||
|
||||
<a name="release"></a>
|
||||
[](#release)
|
||||
|
||||
[](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)
|
||||
[](https://www.espressif.com/en/products/socs/esp32-S3)
|
||||
|
||||
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/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.
|
||||
|
||||
Works with the [ESP8266 Arduino](https://github.com/esp8266/Arduino) and [ESP32 Arduino](https://github.com/espressif/arduino-esp32) platforms.
|
||||
|
||||
### Known Issues
|
||||
|
||||
* Documentation needs to be updated, see [https://github.com/tzapu/WiFiManager/issues/500](https://github.com/tzapu/WiFiManager/issues/500)
|
||||
-------
|
||||
|
||||
## Contents
|
||||
- [How it works](#how-it-works)
|
||||
- [Wishlist](#wishlist)
|
||||
- [Quick start](#quick-start)
|
||||
- Installing
|
||||
- [Arduino - Through Library Manager](#install-through-library-manager)
|
||||
- [Arduino - From Github](#checkout-from-github)
|
||||
- [PlatformIO](#install-using-platformio)
|
||||
- [Using](#using)
|
||||
- [Documentation](#documentation)
|
||||
- [Access Point Password](#password-protect-the-configuration-access-point)
|
||||
- [Callbacks](#callbacks)
|
||||
- [Configuration Portal Timeout](#configuration-portal-timeout)
|
||||
- [On Demand Configuration](#on-demand-configuration-portal)
|
||||
- [Custom Parameters](#custom-parameters)
|
||||
- [Custom IP Configuration](#custom-ip-configuration)
|
||||
- [Filter Low Quality Networks](#filter-networks)
|
||||
- [Debug Output](#debug)
|
||||
- [Troubleshooting](#troubleshooting)
|
||||
- [Releases](#releases)
|
||||
- [Contributors](#contributions-and-thanks)
|
||||
|
||||
|
||||
## How It Works
|
||||
- When your ESP starts up, it sets it up in Station mode and tries to connect to a previously saved Access Point
|
||||
- if this is unsuccessful (or no previous network saved) it moves the ESP into Access Point mode and spins up a DNS and WebServer (default ip 192.168.4.1)
|
||||
- using any wifi enabled device with a browser (computer, phone, tablet) connect to the newly created Access Point
|
||||
- because of the Captive Portal and the DNS server you will either get a 'Join to network' type of popup or get any domain you try to access redirected to the configuration portal
|
||||
- choose one of the access points scanned, enter password, click save
|
||||
- ESP will try to connect. If successful, it relinquishes control back to your app. If not, reconnect to AP and reconfigure.
|
||||
- There are options to change this behavior or manually start the configportal and webportal independantly as well as run them in non blocking mode.
|
||||
|
||||
## How It Looks
|
||||
 
|
||||
|
||||
## Wishlist
|
||||
- [x] remove dependency on EEPROM library
|
||||
- [x] move HTML Strings to PROGMEM
|
||||
- [x] cleanup and streamline code (although this is ongoing)
|
||||
- [x] if timeout is set, extend it when a page is fetched in AP mode
|
||||
- [x] add ability to configure more parameters than ssid/password
|
||||
- [x] maybe allow setting ip of ESP after reboot
|
||||
- [x] add to Arduino Library Manager
|
||||
- [x] add to PlatformIO
|
||||
- [ ] add multiple sets of network credentials
|
||||
- [x] allow users to customize CSS
|
||||
- [ ] rewrite documentation for simplicity, based on scenarios/goals
|
||||
|
||||
### Development
|
||||
- [x] ESP32 support
|
||||
- [x] rely on the SDK's built in auto connect more than forcing a connect
|
||||
- [x] add non blocking mode
|
||||
- [x] easy customization of strings
|
||||
- [x] hostname support
|
||||
- [x] fix various bugs and workarounds for esp SDK issues
|
||||
- [x] additional info page items
|
||||
- [x] last status display / faiilure reason
|
||||
- [x] customizeable menu
|
||||
- [x] seperate custom params page
|
||||
- [x] ondemand webportal
|
||||
- [x] complete refactor of code to segment functions
|
||||
- [x] wiif scan icons or percentage display
|
||||
- [x] invert class for dark mode
|
||||
- [x] more template tokens
|
||||
- [x] progmem for all strings
|
||||
- [ ] new callbacks
|
||||
- [ ] new callouts / filters
|
||||
- [ ] shared web server instance
|
||||
- [x] latest esp idf/sdk support
|
||||
- [x] wm is now non persistent, will not erase or change stored esp config on esp8266
|
||||
- [x] tons of debugging output / levels
|
||||
- [ ] disable captiveportal
|
||||
- [ ] preload wiifscans, faster page loads
|
||||
- [ ] softap stability fixes when sta is not connected
|
||||
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Installing
|
||||
You can either install through the Arduino Library Manager or checkout the latest changes or a release from github
|
||||
|
||||
#### Install through Library Manager
|
||||
__Currently version 0.8+ works with release 2.4.0 or newer of the [ESP8266 core for Arduino](https://github.com/esp8266/Arduino)__
|
||||
- in Arduino IDE got to Sketch/Include Library/Manage Libraries
|
||||

|
||||
|
||||
- search for WiFiManager
|
||||

|
||||
|
||||
- click Install and start [using it](#using)
|
||||
|
||||
#### Checkout from github
|
||||
__Github version works with release 2.4.0 or newer of the [ESP8266 core for Arduino](https://github.com/esp8266/Arduino)__
|
||||
- Checkout library to your Arduino libraries folder
|
||||
|
||||
### Using
|
||||
- Include in your sketch
|
||||
```cpp
|
||||
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager WiFi Configuration Magic
|
||||
```
|
||||
|
||||
- Initialize library, in your setup function add, NOTEif you are using non blocking you will make sure you create this in global scope or handle appropriatly , it will not work if in setup and using non blocking mode.
|
||||
```cpp
|
||||
WiFiManager wifiManager;
|
||||
```
|
||||
|
||||
- Also in the setup function add
|
||||
```cpp
|
||||
//first parameter is name of access point, second is the password
|
||||
wifiManager.autoConnect("AP-NAME", "AP-PASSWORD");
|
||||
```
|
||||
if you just want an unsecured access point
|
||||
```cpp
|
||||
wifiManager.autoConnect("AP-NAME");
|
||||
```
|
||||
or if you want to use and auto generated name from 'ESP' and the esp's Chip ID use
|
||||
```cpp
|
||||
wifiManager.autoConnect();
|
||||
```
|
||||
|
||||
After you write your sketch and start the ESP, it will try to connect to WiFi. If it fails it starts in Access Point mode.
|
||||
While in AP mode, connect to it then open a browser to the gateway IP, default 192.168.4.1, configure wifi, save and it should reboot and connect.
|
||||
|
||||
Also see [examples](https://github.com/tzapu/WiFiManager/tree/master/examples).
|
||||
|
||||
#### Install Using PlatformIO
|
||||
|
||||
[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.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
|
||||
`lib_deps` key like so:
|
||||
|
||||
```
|
||||
[env]
|
||||
lib_deps =
|
||||
WiFiManager
|
||||
```
|
||||
|
||||
|
||||
```
|
||||
[env]
|
||||
lib_deps =
|
||||
https://github.com/tzapu/WiFiManager.git
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
#### Password protect the configuration Access Point
|
||||
You can and should password protect the configuration access point. Simply add the password as a second parameter to `autoConnect`.
|
||||
A short password seems to have unpredictable results so use one that's around 8 characters or more in length.
|
||||
The guidelines are that a wifi password must consist of 8 to 63 ASCII-encoded characters in the range of 32 to 126 (decimal)
|
||||
```cpp
|
||||
wifiManager.autoConnect("AutoConnectAP", "password")
|
||||
```
|
||||
|
||||
#### Callbacks
|
||||
##### Enter Config mode
|
||||
Use this if you need to do something when your device enters configuration mode on failed WiFi connection attempt.
|
||||
Before `autoConnect()`
|
||||
```cpp
|
||||
wifiManager.setAPCallback(configModeCallback);
|
||||
```
|
||||
`configModeCallback` declaration and example
|
||||
```cpp
|
||||
void configModeCallback (WiFiManager *myWiFiManager) {
|
||||
Serial.println("Entered config mode");
|
||||
Serial.println(WiFi.softAPIP());
|
||||
|
||||
Serial.println(myWiFiManager->getConfigPortalSSID());
|
||||
}
|
||||
```
|
||||
|
||||
##### Save settings
|
||||
This gets called when custom parameters have been set **AND** a connection has been established. Use it to set a flag, so when all the configuration finishes, you can save the extra parameters somewhere.
|
||||
|
||||
|
||||
IF YOU NEED TO SAVE PARAMETERS EVEN ON WIFI FAIL OR EMPTY, you must set `setBreakAfterConfig` to true, or else saveConfigCallback will not be called.
|
||||
|
||||
```C++
|
||||
//if this is set, it will exit after config, even if connection is unsuccessful.
|
||||
void setBreakAfterConfig(boolean shouldBreak);
|
||||
```
|
||||
|
||||
See [AutoConnectWithFSParameters Example](https://github.com/tzapu/WiFiManager/tree/master/examples/Parameters/SPIFFS/AutoConnectWithFSParameters).
|
||||
```cpp
|
||||
wifiManager.setSaveConfigCallback(saveConfigCallback);
|
||||
```
|
||||
`saveConfigCallback` declaration and example
|
||||
```cpp
|
||||
//flag for saving data
|
||||
bool shouldSaveConfig = false;
|
||||
|
||||
//callback notifying us of the need to save config
|
||||
void saveConfigCallback () {
|
||||
Serial.println("Should save config");
|
||||
shouldSaveConfig = true;
|
||||
}
|
||||
```
|
||||
|
||||
#### Configuration Portal Timeout
|
||||
If you need to set a timeout so the ESP doesn't hang waiting to be configured, for instance after a power failure, you can add
|
||||
```cpp
|
||||
wifiManager.setConfigPortalTimeout(180);
|
||||
```
|
||||
which will wait 3 minutes (180 seconds). When the time passes, the autoConnect function will return, no matter the outcome.
|
||||
Check for connection and if it's still not established do whatever is needed (on some modules I restart them to retry, on others I enter deep sleep)
|
||||
|
||||
#### On Demand Configuration Portal
|
||||
If you would rather start the configuration portal on demand rather than automatically on a failed connection attempt, then this is for you.
|
||||
|
||||
Instead of calling `autoConnect()` which does all the connecting and failover configuration portal setup for you, you need to use `startConfigPortal()`. __Do not use BOTH.__
|
||||
|
||||
Example usage
|
||||
```cpp
|
||||
void loop() {
|
||||
// is configuration portal requested?
|
||||
if ( digitalRead(TRIGGER_PIN) == LOW ) {
|
||||
WiFiManager wifiManager;
|
||||
wifiManager.startConfigPortal("OnDemandAP");
|
||||
Serial.println("connected...yeey :)");
|
||||
}
|
||||
}
|
||||
```
|
||||
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.
|
||||
If you'd prefer to exit without joining a WiFi network, say becuase you're going to put the ESP into AP mode, then press the "Exit" button
|
||||
on the main webpage.
|
||||
If started via `autoConnect` or `startConfigPortal` then it will return `false (portalAbortResult)`
|
||||
|
||||
#### Custom Parameters
|
||||
You can use WiFiManager to collect more parameters than just SSID and password.
|
||||
This could be helpful for configuring stuff like MQTT host and port, [blynk](http://www.blynk.cc) or [emoncms](http://emoncms.org) tokens, just to name a few.
|
||||
**You are responsible for saving and loading these custom values.** The library just collects and displays the data for you as a convenience.
|
||||
Usage scenario would be:
|
||||
- load values from somewhere (EEPROM/FS) or generate some defaults
|
||||
- add the custom parameters to WiFiManager using
|
||||
```cpp
|
||||
// id/name, placeholder/prompt, default, length
|
||||
WiFiManagerParameter custom_mqtt_server("server", "mqtt server", mqtt_server, 40);
|
||||
wifiManager.addParameter(&custom_mqtt_server);
|
||||
|
||||
```
|
||||
- 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 WiFiManager returns control to your application, read and save the new values using the `WiFiManagerParameter` object.
|
||||
```cpp
|
||||
mqtt_server = custom_mqtt_server.getValue();
|
||||
```
|
||||
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/Parameters/SPIFFS/AutoConnectWithFSParameters)
|
||||
- *Save and load custom parameters to EEPROM* (not done yet)
|
||||
|
||||
#### Custom IP Configuration
|
||||
You can set a custom IP for both AP (access point, config mode) and STA (station mode, client mode, normal project state)
|
||||
|
||||
##### Custom Access Point IP Configuration
|
||||
This will set your captive portal to a specific IP should you need/want such a feature. Add the following snippet before `autoConnect()`
|
||||
```cpp
|
||||
//set custom ip for portal
|
||||
wifiManager.setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
|
||||
```
|
||||
|
||||
##### Custom Station (client) Static IP Configuration
|
||||
This will make use the specified IP configuration instead of using DHCP in station mode.
|
||||
```cpp
|
||||
wifiManager.setSTAStaticIPConfig(IPAddress(192,168,0,99), IPAddress(192,168,0,1), IPAddress(255,255,255,0)); // optional DNS 4th argument
|
||||
```
|
||||
There are a couple of examples in the examples folder that show you how to set a static IP and even how to configure it through the web configuration portal.
|
||||
|
||||
NOTE: You should fill DNS server if you have HTTP requests with hostnames or syncronize time (NTP). It's the same as gateway ip or a popular (Google DNS: 8.8.8.8).
|
||||
|
||||
#### Custom HTML, CSS, Javascript
|
||||
There are various ways in which you can inject custom HTML, CSS or Javascript into the configuration portal.
|
||||
The options are:
|
||||
- inject custom head element
|
||||
You can use this to any html bit to the head of the configuration portal. If you add a `<style>` element, bare in mind it overwrites the included css, not replaces.
|
||||
```cpp
|
||||
wifiManager.setCustomHeadElement("<style>html{filter: invert(100%); -webkit-filter: invert(100%);}</style>");
|
||||
```
|
||||
- inject a custom bit of html in the configuration/param form
|
||||
```cpp
|
||||
WiFiManagerParameter custom_text("<p>This is just a text paragraph</p>");
|
||||
wifiManager.addParameter(&custom_text);
|
||||
```
|
||||
- inject a custom bit of html in a configuration form element
|
||||
Just add the bit you want added as the last parameter to the custom parameter constructor.
|
||||
```cpp
|
||||
WiFiManagerParameter custom_mqtt_server("server", "mqtt server", "iot.eclipse", 40, " readonly");
|
||||
wifiManager.addParameter(&custom_mqtt_server);
|
||||
```
|
||||
|
||||
#### Theming
|
||||
You can customize certain elements of the default template with some builtin classes
|
||||
```CPP
|
||||
wifiManager.setClass("invert"); // dark theme
|
||||
wifiManager.setScanDispPerc(true); // display percentages instead of graphs for RSSI
|
||||
```
|
||||
There are additional classes in the css you can use in your custom html , see the example template.
|
||||
|
||||
#### Filter Networks
|
||||
You can filter networks based on signal quality and show/hide duplicate networks.
|
||||
|
||||
- If you would like to filter low signal quality networks you can tell WiFiManager to not show networks below an arbitrary quality %;
|
||||
```cpp
|
||||
wifiManager.setMinimumSignalQuality(10);
|
||||
```
|
||||
will not show networks under 10% signal quality. If you omit the parameter it defaults to 8%;
|
||||
|
||||
- You can also remove or show duplicate networks (default is remove).
|
||||
Use this function to show (or hide) all networks.
|
||||
```cpp
|
||||
wifiManager.setRemoveDuplicateAPs(false);
|
||||
```
|
||||
|
||||
#### Debug
|
||||
Debug is enabled by default on `Serial` in non-stable releases. To disable add before autoConnect/startConfigPortal
|
||||
```cpp
|
||||
wifiManager.setDebugOutput(false);
|
||||
```
|
||||
|
||||
You can pass in a custom stream via constructor
|
||||
```CPP
|
||||
WiFiManager wifiManager(Serial1);
|
||||
```
|
||||
|
||||
You can customize the debug level by changing `_debugLevel` in source
|
||||
options are:
|
||||
* DEBUG_ERROR
|
||||
* DEBUG_NOTIFY
|
||||
* DEBUG_VERBOSE
|
||||
* DEBUG_DEV
|
||||
* DEBUG_MAX
|
||||
|
||||
## Troubleshooting
|
||||
If you get compilation errors, more often than not, you may need to install a newer version of the ESP8266 core for Arduino.
|
||||
|
||||
Changes added on 0.8 should make the latest trunk work without compilation errors. Tested down to ESP8266 core 2.0.0. **Please update to version 0.8**
|
||||
|
||||
I am trying to keep releases working with release versions of the core, so they can be installed through boards manager, but if you checkout the latest version directly from github, sometimes, the library will only work if you update the ESP8266 core to the latest version because I am using some newly added function.
|
||||
|
||||
If you connect to the created configuration Access Point but the configuration portal does not show up, just open a browser and type in the IP of the web portal, by default `192.168.4.1`.
|
||||
|
||||
If trying to connect ends up in an endless loop, try to add `setConnectTimeout(60)` before `autoConnect();`. The parameter is timeout to try connecting in seconds.
|
||||
|
||||
I get stuck in ap mode when the power goes out or modem resets, try a setConfigPortalTimeout(seconds). This will cause the configportal to close after no activity, and you can reboot or attempt reconnection in your code.
|
||||
|
||||
## Releases
|
||||
### 1.0.1
|
||||
|
||||
### Development Overview
|
||||
|
||||
#### Added Public Methods
|
||||
`setConfigPortalBlocking`
|
||||
|
||||
`setShowStaticFields`
|
||||
|
||||
`setCaptivePortalEnable`
|
||||
|
||||
`setRestorePersistent`
|
||||
|
||||
`setCaptivePortalClientCheck`
|
||||
|
||||
`setWebPortalClientCheck`
|
||||
|
||||
`startWebPortal`
|
||||
|
||||
`stopWebPortal`
|
||||
|
||||
`process`
|
||||
|
||||
`disconnect`
|
||||
|
||||
`erase`
|
||||
|
||||
` debugSoftAPConfig`
|
||||
|
||||
` debugPlatformInfo`
|
||||
|
||||
`setScanDispPerc`
|
||||
|
||||
`setHostname`
|
||||
|
||||
`setMenu(menu_page_t[])`
|
||||
|
||||
`setWiFiAutoReconnect`
|
||||
|
||||
` setSTAStaticIPConfig(..,dns)`
|
||||
|
||||
`setShowDnsFields`
|
||||
|
||||
`getLastConxResult`
|
||||
|
||||
`getWLStatusString`
|
||||
|
||||
`getModeString`
|
||||
|
||||
`getWiFiIsSaved`
|
||||
|
||||
`setShowInfoErase`
|
||||
|
||||
`setEnableConfigPortal`
|
||||
|
||||
`setCountry`
|
||||
|
||||
`setClass`
|
||||
|
||||
`htmleEtities`
|
||||
|
||||
|
||||
#### WiFiManagerParameter
|
||||
`WiFiManagerParameter(id,label)`
|
||||
|
||||
`WiFiManagerParameter.setValue(value,length)`
|
||||
|
||||
`getParameters`
|
||||
|
||||
`getParametersCount`
|
||||
|
||||
|
||||
#### Constructors
|
||||
`WiFiManager(Stream& consolePort)`
|
||||
|
||||
#### define flags
|
||||
❗️ **Defines cannot be set in user sketches**
|
||||
`#define WM_MDNS // use MDNS`
|
||||
|
||||
`#define WM_FIXERASECONFIG // use erase flash fix, esp8266 2.4.0`
|
||||
|
||||
`#define WM_ERASE_NVS // esp32 erase(true) will erase NVS`
|
||||
|
||||
`#include <rom/rtc.h> // esp32 info page will show last reset reasons if this file is included`
|
||||
|
||||
#### Changes Overview
|
||||
- ESP32 support ( fairly stable )
|
||||
- complete refactor of strings `strings_en.h`
|
||||
- adds new tokens for wifiscan, and some classes (left , invert icons, MSG color)
|
||||
- adds status callout panel default, primary, special colors
|
||||
- adds tons of info on info page, and erase capability
|
||||
- adds signal icons, replaces percentage ( has hover titles )
|
||||
- adds labels to all inputs (replaces placeholders)
|
||||
- all html ( and eventually all strings except debug) moved to `strings_en.h`
|
||||
- added additional debugging, compressed debug lines, debuglevels
|
||||
- persistent disabled, and restored via de/con-stuctor (uses `setRestorePersistent`)
|
||||
- should retain all user modes including AP, should not overwrite or persist user modes or configs,even STA (`storeSTAmode`) (BUGGY)
|
||||
- ⚠️ return values may have changed depending on portal abort, or timeout ( `portalTimeoutResult`,`portalAbortResult`)
|
||||
- params memory is auto allocated by increment of `WIFI_MANAGER_MAX_PARAMS(5)` when exceeded, user no longer needs to specify this at all.
|
||||
- addparameter now returns bool, and it returns false if param ID is not alphanum [0-9,A-Z,a-z,_]
|
||||
- param field ids allow {I} token to use param_n instead of string in case someones wants to change this due to i18n or character issues
|
||||
- provides `#DEFINE FIXERASECONFIG` to help deal with https://github.com/esp8266/Arduino/pull/3635
|
||||
- failure reason reporting on portal
|
||||
- set esp8266 sta hostname, esp32 sta+ap hostname ( DHCP client id)
|
||||
- pass in debug stream in constructor WiFiManager(Stream& consolePort)
|
||||
- you can force ip fields off with showxfields(false) if you set _disableIpFields=true
|
||||
- param menu/page (setup) added to separate params from wifi page, handled automatically by setMenu
|
||||
- set custom root menu
|
||||
- disable configportal on autoconnect
|
||||
- wm parameters init is now protected, allowing child classes, example included
|
||||
- wifiscans are precached and async for faster page loads, refresh forces rescan
|
||||
- adds esp32 gettemperature ( currently commented out, useful for relative measurement only )
|
||||
|
||||
#### 0.12
|
||||
- removed 204 header response
|
||||
- fixed incompatibility with other libs using isnan and other std:: functions without namespace
|
||||
|
||||
##### 0.11
|
||||
- a lot more reliable reconnecting to networks
|
||||
- custom html in custom parameters (for read only params)
|
||||
- custom html in custom parameter form (like labels)
|
||||
- custom head element (like custom css)
|
||||
- sort networks based on signal quality
|
||||
- remove duplicate networks
|
||||
|
||||
##### 0.10
|
||||
- some css changes
|
||||
- bug fixes and speed improvements
|
||||
- added an alternative to waitForConnectResult() for debugging
|
||||
- changed `setTimeout(seconds)` to `setConfigPortalTimeout(seconds)`
|
||||
|
||||
### Contributions and thanks
|
||||
The support and help I got from the community has been nothing short of phenomenal. I can't thank you guys enough. This is my first real attept in developing open source stuff and I must say, now I understand why people are so dedicated to it, it is because of all the wonderful people involved.
|
||||
|
||||
__THANK YOU__
|
||||
|
||||
The esp8266 and esp32 arduino and idf maintainers!
|
||||
|
||||
[Shawn A aka tablatronix](https://github.com/tablatronix)
|
||||
|
||||
[liebman](https://github.com/liebman)
|
||||
|
||||
[Evgeny Dontsov](https://github.com/dontsovcmc)
|
||||
|
||||
[Chris Marrin](https://github.com/cmarrin)
|
||||
|
||||
[bbx10](https://github.com/bbx10)
|
||||
|
||||
[kentaylor](https://github.com/kentaylor)
|
||||
|
||||
[Maximiliano Duarte](https://github.com/domonetic)
|
||||
|
||||
[alltheblinkythings](https://github.com/alltheblinkythings)
|
||||
|
||||
[Niklas Wall](https://github.com/niklaswall)
|
||||
|
||||
[Jakub Piasecki](https://github.com/zaporylie)
|
||||
|
||||
[Peter Allan](https://github.com/alwynallan)
|
||||
|
||||
[John Little](https://github.com/j0hnlittle)
|
||||
|
||||
[markaswift](https://github.com/markaswift)
|
||||
|
||||
[franklinvv](https://github.com/franklinvv)
|
||||
|
||||
[Alberto Ricci Bitti](https://github.com/riccibitti)
|
||||
|
||||
[SebiPanther](https://github.com/SebiPanther)
|
||||
|
||||
[jonathanendersby](https://github.com/jonathanendersby)
|
||||
|
||||
[walthercarsten](https://github.com/walthercarsten)
|
||||
|
||||
And countless others
|
||||
|
||||
#### Inspiration
|
||||
* http://www.esp8266.com/viewtopic.php?f=29&t=2520
|
||||
* https://github.com/chriscook8/esp-arduino-apboot
|
||||
* https://github.com/esp8266/Arduino/tree/master/libraries/DNSServer/examples/CaptivePortalAdvanced
|
||||
* Built by AlexT https://github.com/tzapu
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,870 +0,0 @@
|
||||
/**
|
||||
* WiFiManager.h
|
||||
*
|
||||
* 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 WiFiManager_h
|
||||
#define WiFiManager_h
|
||||
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
|
||||
#ifdef ESP8266
|
||||
#include <core_version.h>
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
|
||||
// #define WM_MDNS // includes MDNS, also set MDNS with sethostname
|
||||
// #define WM_FIXERASECONFIG // use erase flash fix
|
||||
// #define WM_ERASE_NVS // esp32 erase(true) will erase NVS
|
||||
// #define WM_RTC // esp32 info page will include reset reasons
|
||||
|
||||
// #define WM_JSTEST // build flag for enabling js xhr tests
|
||||
// #define WIFI_MANAGER_OVERRIDE_STRINGS // build flag for using own strings include
|
||||
|
||||
#ifdef ARDUINO_ESP8266_RELEASE_2_3_0
|
||||
#warning "ARDUINO_ESP8266_RELEASE_2_3_0, some WM features disabled"
|
||||
// @todo check failing on platform = espressif8266@1.7.3
|
||||
#define WM_NOASYNC // esp8266 no async scan wifi
|
||||
#define WM_NOCOUNTRY // esp8266 no country
|
||||
#define WM_NOAUTH // no httpauth
|
||||
#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
|
||||
// autoreconnect is WORKING https://github.com/espressif/arduino-esp32/issues/653#issuecomment-405604766
|
||||
|
||||
#define WM_WEBSERVERSHIM // use webserver shim lib
|
||||
#define WM_ASYNCWEBSERVER // use async webserver
|
||||
|
||||
#define WM_G(string_literal) (String(FPSTR(string_literal)).c_str())
|
||||
|
||||
#ifdef ESP8266
|
||||
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
#include <ESP8266WiFi.h>
|
||||
|
||||
#ifdef WM_ASYNCWEBSERVER
|
||||
#include <ESPAsyncTCP.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#else
|
||||
#include <ESP8266WebServer.h>
|
||||
#endif
|
||||
|
||||
#ifdef WM_MDNS
|
||||
#include <ESP8266mDNS.h>
|
||||
#endif
|
||||
|
||||
#define WIFI_getChipId() ESP.getChipId()
|
||||
#define WM_WIFIOPEN ENC_TYPE_NONE
|
||||
|
||||
#elif defined(ESP32)
|
||||
|
||||
#include <WiFi.h>
|
||||
#include <esp_wifi.h>
|
||||
#include <Update.h>
|
||||
|
||||
#define WIFI_getChipId() (uint32_t)ESP.getEfuseMac()
|
||||
#define WM_WIFIOPEN WIFI_AUTH_OPEN
|
||||
|
||||
#ifdef WM_ASYNCWEBSERVER
|
||||
#include <PsychicHttp.h>
|
||||
#include <PsychicHttpsServer.h>
|
||||
#else
|
||||
#ifndef WEBSERVER_H
|
||||
#ifdef WM_WEBSERVERSHIM
|
||||
#include <WebServer.h>
|
||||
#else
|
||||
#include <ESP8266WebServer.h>
|
||||
// Forthcoming official ? probably never happening
|
||||
// https://github.com/esp8266/ESPWebServer
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef WM_ERASE_NVS
|
||||
#include <nvs.h>
|
||||
#include <nvs_flash.h>
|
||||
#endif
|
||||
|
||||
#ifdef WM_MDNS
|
||||
#include <ESPmDNS.h>
|
||||
#endif
|
||||
|
||||
#ifdef WM_RTC
|
||||
#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
|
||||
#endif
|
||||
|
||||
#include <DNSServer.h>
|
||||
#include <memory>
|
||||
|
||||
|
||||
// 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
|
||||
#endif
|
||||
|
||||
#define WFM_LABEL_BEFORE 1
|
||||
#define WFM_LABEL_AFTER 2
|
||||
#define WFM_NO_LABEL 0
|
||||
#define WFM_LABEL_DEFAULT 1
|
||||
|
||||
class WiFiManagerParameter {
|
||||
public:
|
||||
/**
|
||||
Create custom parameters that can be added to the WiFiManager setup web page
|
||||
@id is used for HTTP queries and must not contain spaces nor other special characters
|
||||
*/
|
||||
WiFiManagerParameter();
|
||||
WiFiManagerParameter(const char *custom);
|
||||
WiFiManagerParameter(const char *id, const char *label);
|
||||
WiFiManagerParameter(const char *id, const char *label, const char *defaultValue, int length);
|
||||
WiFiManagerParameter(const char *id, const char *label, const char *defaultValue, int length, const char *custom);
|
||||
WiFiManagerParameter(const char *id, const char *label, const char *defaultValue, int length, const char *custom, int labelPlacement);
|
||||
~WiFiManagerParameter();
|
||||
// WiFiManagerParameter& operator=(const WiFiManagerParameter& rhs);
|
||||
|
||||
const char *getID() const;
|
||||
const char *getValue() const;
|
||||
const char *getLabel() const;
|
||||
const char *getPlaceholder() const; // @deprecated, use getLabel
|
||||
int getValueLength() const;
|
||||
int getLabelPlacement() const;
|
||||
virtual const char *getCustomHTML() const;
|
||||
void setValue(const char *defaultValue, int length);
|
||||
|
||||
protected:
|
||||
void init(const char *id, const char *label, const char *defaultValue, int length, const char *custom, int labelPlacement);
|
||||
|
||||
WiFiManagerParameter& operator=(const WiFiManagerParameter&);
|
||||
const char *_id;
|
||||
const char *_label;
|
||||
char *_value;
|
||||
int _length;
|
||||
int _labelPlacement;
|
||||
|
||||
const char *_customHTML;
|
||||
friend class WiFiManager;
|
||||
};
|
||||
|
||||
|
||||
// debugging
|
||||
typedef enum {
|
||||
WM_DEBUG_SILENT = 0, // debug OFF but still compiled for runtime
|
||||
WM_DEBUG_ERROR = 1, // error only
|
||||
WM_DEBUG_NOTIFY = 2, // default stable,INFO
|
||||
WM_DEBUG_VERBOSE = 3, // move verbose info
|
||||
WM_DEBUG_DEV = 4, // development useful debugging info
|
||||
WM_DEBUG_MAX = 5 // MAX extra dev auditing, var dumps etc (MAX+1 will print timing,mem and frag info)
|
||||
} wm_debuglevel_t;
|
||||
|
||||
class WiFiManager
|
||||
{
|
||||
public:
|
||||
WiFiManager(Print& consolePort);
|
||||
WiFiManager(const char* user, const char* password);
|
||||
WiFiManager();
|
||||
~WiFiManager();
|
||||
void WiFiManagerInit();
|
||||
|
||||
// auto connect to saved wifi, or custom, and start config portal on failures
|
||||
boolean autoConnect();
|
||||
boolean autoConnect(char const *apName, char const *apPassword = NULL);
|
||||
|
||||
//manually start the config portal, autoconnect does this automatically on connect failure
|
||||
boolean startConfigPortal(); // auto generates apname
|
||||
boolean startConfigPortal(char const *apName, char const *apPassword = NULL);
|
||||
|
||||
//manually stop the config portal if started manually, stop immediatly if non blocking, flag abort if blocking
|
||||
bool stopConfigPortal();
|
||||
|
||||
//manually start the web portal, autoconnect does this automatically on connect failure
|
||||
void startWebPortal();
|
||||
|
||||
//manually stop the web portal if started manually
|
||||
void stopWebPortal();
|
||||
|
||||
// Run webserver processing, if setConfigPortalBlocking(false)
|
||||
boolean process();
|
||||
|
||||
// get the AP name of the config portal, so it can be used in the callback
|
||||
String getConfigPortalSSID();
|
||||
int getRSSIasQuality(int RSSI);
|
||||
|
||||
// erase wifi credentials
|
||||
void resetSettings();
|
||||
|
||||
// reset wifi scan
|
||||
void resetScan();
|
||||
|
||||
// reboot esp
|
||||
void reboot();
|
||||
|
||||
// disconnect wifi, without persistent saving or erasing
|
||||
bool disconnect();
|
||||
|
||||
// erase esp
|
||||
bool erase();
|
||||
bool erase(bool opt);
|
||||
|
||||
//adds a custom parameter, returns false on failure
|
||||
bool addParameter(WiFiManagerParameter *p);
|
||||
|
||||
//returns the list of Parameters
|
||||
WiFiManagerParameter** getParameters();
|
||||
|
||||
// returns the Parameters Count
|
||||
int getParametersCount();
|
||||
|
||||
// SET CALLBACKS
|
||||
|
||||
//called after AP mode and config portal has started
|
||||
void setAPCallback( std::function<void(WiFiManager*)> func );
|
||||
|
||||
//called after webserver has started
|
||||
void setWebServerCallback( std::function<void()> func );
|
||||
|
||||
//called when settings reset have been triggered
|
||||
void setConfigResetCallback( std::function<void()> func );
|
||||
|
||||
//called when wifi settings have been changed and connection was successful ( or setBreakAfterConfig(true) )
|
||||
void setSaveConfigCallback( 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 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
|
||||
//in seconds setConfigPortalTimeout is a new name for setTimeout, ! not used if setConfigPortalBlocking
|
||||
void setConfigPortalTimeout(unsigned long seconds);
|
||||
void setTimeout(unsigned long seconds); // @deprecated, alias
|
||||
|
||||
//sets timeout for which to attempt connecting, useful if you get a lot of failed connects
|
||||
void setConnectTimeout(unsigned long seconds);
|
||||
|
||||
// sets number of retries for autoconnect, force retry after wait failure exit
|
||||
void setConnectRetries(uint8_t numRetries); // default 1
|
||||
|
||||
//sets timeout for which to attempt connecting on saves, useful if there are bugs in esp waitforconnectloop
|
||||
void setSaveConnectTimeout(unsigned long seconds);
|
||||
|
||||
// lets you disable automatically connecting after save from webportal
|
||||
void setSaveConnect(bool connect = true);
|
||||
|
||||
// toggle debug output
|
||||
void setDebugOutput(boolean debug);
|
||||
void setDebugOutput(boolean debug, String prefix); // log line prefix, default "*wm:"
|
||||
void setDebugOutput(boolean debug, wm_debuglevel_t level ); // log line prefix, default "*wm:"
|
||||
|
||||
//set min quality percentage to include in scan, defaults to 8% if not specified
|
||||
void setMinimumSignalQuality(int quality = 8);
|
||||
|
||||
//sets a custom ip /gateway /subnet configuration
|
||||
void setAPStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn);
|
||||
|
||||
//sets config for a static IP
|
||||
void setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn);
|
||||
|
||||
//sets config for a static IP with DNS
|
||||
void setSTAStaticIPConfig(IPAddress ip, IPAddress gw, IPAddress sn, IPAddress dns);
|
||||
|
||||
//if this is set, it will exit after config, even if connection is unsuccessful.
|
||||
void setBreakAfterConfig(boolean shouldBreak);
|
||||
|
||||
// if this is set, portal will be blocking and wait until save or exit,
|
||||
// is false user must manually `process()` to handle config portal,
|
||||
// setConfigPortalTimeout is ignored in this mode, user is responsible for closing configportal
|
||||
void setConfigPortalBlocking(boolean shouldBlock);
|
||||
|
||||
//add custom html at inside <head> for all pages
|
||||
void setCustomHeadElement(const char* html);
|
||||
|
||||
//if this is set, customise style
|
||||
void setCustomMenuHTML(const char* html);
|
||||
|
||||
//if this is true, remove duplicated Access Points - defaut true
|
||||
void setRemoveDuplicateAPs(boolean removeDuplicates);
|
||||
|
||||
//setter for ESP wifi.persistent so we can remember it and restore user preference, as WIFi._persistent is protected
|
||||
void setRestorePersistent(boolean persistent);
|
||||
|
||||
//if true, always show static net inputs, IP, subnet, gateway, else only show if set via setSTAStaticIPConfig
|
||||
void setShowStaticFields(boolean alwaysShow);
|
||||
|
||||
//if true, always show static dns, esle only show if set via setSTAStaticIPConfig
|
||||
void setShowDnsFields(boolean alwaysShow);
|
||||
|
||||
// toggle showing the saved wifi password in wifi form, could be a security issue.
|
||||
void setShowPassword(boolean show);
|
||||
|
||||
//if false, disable captive portal redirection
|
||||
void setCaptivePortalEnable(boolean enabled);
|
||||
|
||||
//if false, timeout captive portal even if a STA client connected to softAP (false), suggest disabling if captiveportal is open
|
||||
void setAPClientCheck(boolean enabled);
|
||||
|
||||
//if true, reset timeout when webclient connects (true), suggest disabling if captiveportal is open
|
||||
void setWebPortalClientCheck(boolean enabled);
|
||||
|
||||
// if true, enable autoreconnecting
|
||||
void setWiFiAutoReconnect(boolean enabled);
|
||||
|
||||
// if true, wifiscan will show percentage instead of quality icons, until we have better templating
|
||||
void setScanDispPerc(boolean enabled);
|
||||
|
||||
// if true (default) then start the config portal from autoConnect if connection failed
|
||||
void setEnableConfigPortal(boolean enable);
|
||||
|
||||
// if true (default) then stop the config portal from autoConnect when wifi is saved
|
||||
void setDisableConfigPortal(boolean enable);
|
||||
|
||||
// if true then find the AP with the best RSSI for the given SSID
|
||||
void setFindBestRSSI(boolean enabled);
|
||||
|
||||
// set a custom hostname, sets sta and ap dhcp client id for esp32, and sta for esp8266
|
||||
bool setHostname(const char * hostname);
|
||||
bool setHostname(String hostname);
|
||||
|
||||
// show erase wifi onfig button on info page, true
|
||||
void setShowInfoErase(boolean enabled);
|
||||
|
||||
// show OTA upload button on info page
|
||||
void setShowInfoUpdate(boolean enabled);
|
||||
|
||||
// set ap channel
|
||||
void setWiFiAPChannel(int32_t channel);
|
||||
|
||||
// set ap hidden
|
||||
void setWiFiAPHidden(bool hidden); // default false
|
||||
|
||||
// clean connect, always disconnect before connecting
|
||||
void setCleanConnect(bool enable); // default false
|
||||
|
||||
// set custom menu items and order, vector or arr
|
||||
// see _menutokens for ids
|
||||
void setMenu(std::vector<const char*>& menu);
|
||||
void setMenu(const char* menu[], uint8_t size);
|
||||
|
||||
// set the webapp title, default WiFiManager
|
||||
void setTitle(String title);
|
||||
|
||||
// add params to its own menu page and remove from wifi, NOT TO BE COMBINED WITH setMenu!
|
||||
void setParamsPage(bool enable);
|
||||
|
||||
// get last connection result, includes autoconnect and wifisave
|
||||
uint8_t getLastConxResult();
|
||||
|
||||
// get a status as string
|
||||
String getWLStatusString(uint8_t status);
|
||||
String getWLStatusString();
|
||||
|
||||
// get wifi mode as string
|
||||
String getModeString(uint8_t mode);
|
||||
|
||||
// check if the module has a saved ap to connect to
|
||||
bool getWiFiIsSaved();
|
||||
|
||||
// helper to get saved password, if persistent get stored, else get current if connected
|
||||
String getWiFiPass(bool persistent = true);
|
||||
|
||||
// helper to get saved ssid, if persistent get stored, else get current if connected
|
||||
String getWiFiSSID(bool persistent = true);
|
||||
|
||||
// debug output the softap config
|
||||
void debugSoftAPConfig();
|
||||
|
||||
// debug output platform info and versioning
|
||||
void debugPlatformInfo();
|
||||
|
||||
// helper for html
|
||||
String htmlEntities(String str, bool whitespace = false);
|
||||
|
||||
// set the country code for wifi settings, CN
|
||||
void setCountry(String cc);
|
||||
|
||||
// set body class (invert), may be used for hacking in alt classes
|
||||
void setClass(String str);
|
||||
|
||||
// set dark mode via invert class
|
||||
void setDarkMode(bool enable);
|
||||
|
||||
// get default ap esp uses , esp_chipid etc
|
||||
String getDefaultAPName();
|
||||
|
||||
// set port of webserver, 80
|
||||
void setHttpPort(uint16_t port);
|
||||
|
||||
// check if config portal is active (true)
|
||||
bool getConfigPortalActive();
|
||||
|
||||
// check if web portal is active (true)
|
||||
bool getWebPortalActive();
|
||||
|
||||
// to preload autoconnect for test fixtures or other uses that skip esp sta config
|
||||
bool preloadWiFi(String ssid, String pass);
|
||||
|
||||
// get hostname helper
|
||||
String getWiFiHostname();
|
||||
|
||||
|
||||
std::unique_ptr<DNSServer> dnsServer;
|
||||
PsychicHttpServer* server;
|
||||
|
||||
protected:
|
||||
// vars
|
||||
std::vector<uint8_t> _menuIds;
|
||||
std::vector<const char *> _menuIdsParams = {"wifi","param","info","exit"};
|
||||
std::vector<const char *> _menuIdsUpdate = {"wifi","param","info","update","exit"};
|
||||
std::vector<const char *> _menuIdsDefault = {"wifi","info","exit","sep","update"};
|
||||
|
||||
// ip configs @todo struct ?
|
||||
IPAddress _ap_static_ip;
|
||||
IPAddress _ap_static_gw;
|
||||
IPAddress _ap_static_sn;
|
||||
IPAddress _sta_static_ip;
|
||||
IPAddress _sta_static_gw;
|
||||
IPAddress _sta_static_sn;
|
||||
IPAddress _sta_static_dns;
|
||||
|
||||
unsigned long _configPortalStart = 0; // ms config portal start time (updated for timeouts)
|
||||
unsigned long _webPortalAccessed = 0; // ms last web access time
|
||||
uint8_t _lastconxresult = WL_IDLE_STATUS; // store last result when doing connect operations
|
||||
int _numNetworks = 0; // init index for numnetworks wifiscans
|
||||
unsigned long _lastscan = 0; // ms for timing wifi scans
|
||||
unsigned long _startscan = 0; // ms for timing wifi scans
|
||||
unsigned long _startconn = 0; // ms for timing wifi connects
|
||||
|
||||
// defaults
|
||||
const byte DNS_PORT = 53;
|
||||
String _apName = "no-net";
|
||||
String _apPassword = "";
|
||||
String _ssid = ""; // var temp ssid
|
||||
String _pass = ""; // var temp psk
|
||||
String _defaultssid = ""; // preload ssid
|
||||
String _defaultpass = ""; // preload pass
|
||||
|
||||
// options flags
|
||||
unsigned long _configPortalTimeout = 0; // ms close config portal loop if set (depending on _cp/webClientCheck options)
|
||||
unsigned long _connectTimeout = 0; // ms stop trying to connect to ap if set
|
||||
unsigned long _saveTimeout = 0; // ms stop trying to connect to ap on saves, in case bugs in esp waitforconnectresult
|
||||
|
||||
WiFiMode_t _usermode = WIFI_STA; // Default user mode
|
||||
String _wifissidprefix = FPSTR(S_ssidpre); // auto apname prefix prefix+chipid
|
||||
int _cpclosedelay = 2000; // delay before wifisave, prevents captive portal from closing to fast.
|
||||
bool _cleanConnect = false; // disconnect before connect in connectwifi, increases stability on connects
|
||||
bool _connectonsave = true; // connect to wifi when saving creds
|
||||
bool _disableSTA = false; // disable sta when starting ap, always
|
||||
bool _disableSTAConn = true; // disable sta when starting ap, if sta is not connected ( stability )
|
||||
bool _channelSync = false; // use same wifi sta channel when starting ap
|
||||
int32_t _apChannel = 0; // default channel to use for ap, 0 for auto
|
||||
bool _apHidden = false; // store softap hidden value
|
||||
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
|
||||
// on some conn failure modes will add delays and many retries to work around esp and ap bugs, ie, anti de-auth protections
|
||||
// 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;
|
||||
static uint8_t _lastconxresulttmp; // tmp var for esp32 callback
|
||||
#endif
|
||||
|
||||
#ifndef WL_STATION_WRONG_PASSWORD
|
||||
uint8_t WL_STATION_WRONG_PASSWORD = 7; // @kludge define a WL status for wrong password
|
||||
#endif
|
||||
|
||||
// parameter options
|
||||
int _minimumQuality = -1; // filter wifiscan ap by this rssi
|
||||
int _staShowStaticFields = 0; // ternary 1=always show static ip fields, 0=only if set, -1=never(cannot change ips via web!)
|
||||
int _staShowDns = 0; // ternary 1=always show dns, 0=only if set, -1=never(cannot change dns via web!)
|
||||
boolean _removeDuplicateAPs = true; // remove dup aps from wifiscan
|
||||
boolean _showPassword = false; // show or hide saved password on wifi form, might be a security issue!
|
||||
boolean _shouldBreakAfterConfig = false; // stop configportal on save failure
|
||||
boolean _configPortalIsBlocking = true; // configportal enters blocking loop
|
||||
boolean _enableCaptivePortal = true; // enable captive portal redirection
|
||||
boolean _userpersistent = true; // users preffered persistence to restore
|
||||
boolean _wifiAutoReconnect = true; // there is no platform getter for this, we must assume its true and make it so
|
||||
boolean _apClientCheck = false; // keep cp alive if ap have station
|
||||
boolean _webClientCheck = true; // keep cp alive if web have client
|
||||
boolean _scanDispOptions = false; // show percentage in scans not icons
|
||||
boolean _paramsInWifi = true; // show custom parameters on wifi page
|
||||
boolean _showInfoErase = true; // info page erase button
|
||||
boolean _showInfoUpdate = true; // info page update button
|
||||
boolean _showBack = false; // show back button
|
||||
boolean _enableConfigPortal = true; // FOR autoconnect - start config portal if autoconnect failed
|
||||
boolean _disableConfigPortal = true; // FOR autoconnect - stop config portal if cp wifi save
|
||||
boolean _findBestRSSI = false; // find best rssi ap in wifiscan
|
||||
String _hostname = ""; // hostname for esp8266 for dhcp, and or MDNS
|
||||
|
||||
const char* _customHeadElement = ""; // store custom head element html from user isnide <head>
|
||||
const char* _customMenuHTML = ""; // store custom head element html from user inside <>
|
||||
String _bodyClass = ""; // class to add to body
|
||||
String _title = FPSTR(S_brand); // app title - default WiFiManager
|
||||
|
||||
// internal options
|
||||
|
||||
bool _rebootNeeded = false; // async reboot flag
|
||||
|
||||
// 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
|
||||
// might be slightly buggy since captive portals hammer the home page, @todo workaround this somehow.
|
||||
// cache time helps throttle this
|
||||
// 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
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// preload scanning causes AP to delay showing for users, but also caches and lets the cp load faster once its open
|
||||
// my scan takes 7-10 seconds
|
||||
public:
|
||||
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
|
||||
bool wifiConnectDefault();
|
||||
protected:
|
||||
|
||||
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
|
||||
|
||||
String _wificountry = ""; // country code, @todo define in strings lang
|
||||
|
||||
// wrapper functions for handling setting and unsetting persistent for now.
|
||||
bool esp32persistent = false;
|
||||
bool _hasBegun = false; // flag wm loaded,unloaded
|
||||
void _begin();
|
||||
void _end();
|
||||
|
||||
void setupConfigPortal();
|
||||
bool shutdownConfigPortal();
|
||||
bool setupHostname(bool restart);
|
||||
void setupHTTPServer();
|
||||
void teardownHTTPServer();
|
||||
|
||||
#ifdef NO_EXTRA_4K_HEAP
|
||||
boolean _tryWPS = false; // try WPS on save failure, unsupported
|
||||
void startWPS();
|
||||
#endif
|
||||
|
||||
bool startAP();
|
||||
void setupDNSD();
|
||||
|
||||
uint8_t connectWifi(String ssid, String pass, bool connect = true);
|
||||
bool setSTAConfig();
|
||||
bool wifiConnectNew(String ssid, String pass,bool connect = true);
|
||||
|
||||
uint8_t waitForConnectResult();
|
||||
uint8_t waitForConnectResult(uint32_t timeout);
|
||||
void updateConxResult(uint8_t status);
|
||||
public:
|
||||
bool WiFi_scanNetworks(bool force,bool async);
|
||||
protected:
|
||||
// webserver handlers
|
||||
esp_err_t handleRoot(PsychicRequest *request);
|
||||
esp_err_t handleWifi(PsychicRequest *request,bool scan);
|
||||
esp_err_t handleWifiSave(PsychicRequest *request);
|
||||
esp_err_t handleInfo(PsychicRequest *request);
|
||||
esp_err_t handleReset(PsychicRequest *request);
|
||||
esp_err_t handleNotFound(PsychicRequest *request);
|
||||
esp_err_t handleExit(PsychicRequest *request);
|
||||
esp_err_t handleClose(PsychicRequest *request);
|
||||
// esp_err_t handleErase(PsychicRequest *request);
|
||||
esp_err_t handleErase(PsychicRequest *request, bool opt);
|
||||
esp_err_t handleParam(PsychicRequest *request);
|
||||
esp_err_t handleWiFiStatus(PsychicRequest *request);
|
||||
esp_err_t handleParamSave(PsychicRequest *request);
|
||||
void doParamSave(PsychicRequest *request);
|
||||
|
||||
void handleRequest();
|
||||
esp_err_t HTTPSend(PsychicRequest *request, String page);
|
||||
|
||||
boolean captivePortal(PsychicRequest *request);
|
||||
boolean configPortalHasTimeout();
|
||||
uint8_t processConfigPortal();
|
||||
void stopCaptivePortal();
|
||||
// OTA Update handler
|
||||
esp_err_t handleUpdate(PsychicRequest *request);
|
||||
void handleUpdating(String filename, size_t index, uint8_t *data, size_t len, bool final);
|
||||
esp_err_t handleUpdateDone(PsychicRequest *request);
|
||||
|
||||
// wifi platform abstractions
|
||||
bool WiFi_Mode(WiFiMode_t m);
|
||||
bool WiFi_Mode(WiFiMode_t m,bool persistent);
|
||||
bool WiFi_Disconnect();
|
||||
bool WiFi_enableSTA(bool enable);
|
||||
bool WiFi_enableSTA(bool enable,bool persistent);
|
||||
bool WiFi_eraseConfig();
|
||||
uint8_t WiFi_softap_num_stations();
|
||||
bool WiFi_hasAutoConnect();
|
||||
void WiFi_autoReconnect();
|
||||
String WiFi_SSID(bool persistent = true) const;
|
||||
String WiFi_psk(bool persistent = true) const;
|
||||
bool WiFi_scanNetworks();
|
||||
bool WiFi_scanNetworks(unsigned int cachetime,bool async);
|
||||
bool WiFi_scanNetworks(unsigned int cachetime);
|
||||
void WiFi_scanComplete(int networksFound);
|
||||
bool WiFiSetCountry();
|
||||
|
||||
#ifdef ESP32
|
||||
|
||||
// check for arduino or system event system, handle esp32 arduino v2 and IDF
|
||||
#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
|
||||
void WiFiEvent(WiFiEvent_t event, system_event_info_t info);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// output helpers
|
||||
String getParamOut();
|
||||
String getIpForm(String id, String title, String value);
|
||||
String getScanItemOut();
|
||||
String getStaticOut();
|
||||
String getHTTPHead(String title);
|
||||
String getMenuOut();
|
||||
//helpers
|
||||
boolean isIp(String str);
|
||||
String toStringIp(IPAddress ip);
|
||||
boolean validApPassword();
|
||||
String encryptionTypeStr(uint8_t authmode);
|
||||
void reportStatus(String &page);
|
||||
String getInfoData(String id);
|
||||
|
||||
// flags
|
||||
boolean connect = false;
|
||||
boolean abort = false;
|
||||
boolean reset = false;
|
||||
boolean configPortalActive = false;
|
||||
|
||||
|
||||
// these are state flags for portal mode, we are either in webportal mode(STA) or configportal mode(AP)
|
||||
// these are mutually exclusive as STA+AP mode is not supported due to channel restrictions and stability
|
||||
// if we decide to support this, these checks will need to be replaced with something client aware to check if client origin is ap or web
|
||||
// These state checks are critical and used for internal function checks
|
||||
boolean webPortalActive = false;
|
||||
boolean portalTimeoutResult = false;
|
||||
|
||||
boolean portalAbortResult = false;
|
||||
boolean storeSTAmode = true; // option store persistent STA mode in connectwifi
|
||||
int timer = 0; // timer for debug throttle for numclients, and portal timeout messages
|
||||
|
||||
// WiFiManagerParameter
|
||||
int _paramsCount = 0;
|
||||
int _max_params;
|
||||
WiFiManagerParameter** _params = NULL;
|
||||
|
||||
boolean _debug = true;
|
||||
String _debugPrefix = FPSTR(S_debugPrefix);
|
||||
|
||||
wm_debuglevel_t debugLvlShow = WM_DEBUG_VERBOSE; // at which level start showing [n] level tags
|
||||
|
||||
// build debuglevel support
|
||||
// @todo use DEBUG_ESP_x?
|
||||
|
||||
// Set default debug level
|
||||
#ifndef WM_DEBUG_LEVEL
|
||||
#define WM_DEBUG_LEVEL WM_DEBUG_NOTIFY
|
||||
#endif
|
||||
|
||||
// override debug level OFF
|
||||
#ifdef WM_NODEBUG
|
||||
#undef WM_DEBUG_LEVEL
|
||||
#endif
|
||||
|
||||
#ifdef WM_DEBUG_LEVEL
|
||||
uint8_t _debugLevel = (uint8_t)WM_DEBUG_LEVEL;
|
||||
#else
|
||||
uint8_t _debugLevel = 0; // default debug level
|
||||
#endif
|
||||
|
||||
// @todo use DEBUG_ESP_PORT ?
|
||||
#ifdef WM_DEBUG_PORT
|
||||
Print& _debugPort = WM_DEBUG_PORT;
|
||||
#else
|
||||
Print& _debugPort = Serial; // debug output stream ref
|
||||
#endif
|
||||
|
||||
template <typename Generic>
|
||||
void DEBUG_WM(Generic text);
|
||||
|
||||
template <typename Generic>
|
||||
void DEBUG_WM(wm_debuglevel_t level,Generic text);
|
||||
template <typename Generic, typename Genericb>
|
||||
void DEBUG_WM(Generic text,Genericb textb);
|
||||
template <typename Generic, typename Genericb>
|
||||
void DEBUG_WM(wm_debuglevel_t level, Generic text,Genericb textb);
|
||||
|
||||
// callbacks
|
||||
// @todo use cb list (vector) maybe event ids, allow no return value
|
||||
std::function<void(WiFiManager*)> _apcallback;
|
||||
std::function<void()> _webservercallback;
|
||||
std::function<void()> _savewificallback;
|
||||
std::function<void()> _presavewificallback;
|
||||
std::function<void()> _presaveparamscallback;
|
||||
std::function<void()> _saveparamscallback;
|
||||
std::function<void()> _resetcallback;
|
||||
std::function<void()> _preotaupdatecallback;
|
||||
std::function<void()> _configportaltimeoutcallback;
|
||||
|
||||
bool _hasCredentials = false;
|
||||
char _credUser[31] = {0};
|
||||
char _credPassword[31] = {0};
|
||||
|
||||
template <class T>
|
||||
auto optionalIPFromString(T *obj, const char *s) -> decltype( obj->fromString(s) ) {
|
||||
return obj->fromString(s);
|
||||
}
|
||||
auto optionalIPFromString(...) -> bool {
|
||||
// DEBUG_WM("NO fromString METHOD ON IPAddress, you need ESP8266 core 2.1.0 or newer for Custom IP configuration to work.");
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,141 +0,0 @@
|
||||
/**
|
||||
* WiFiManager advanced demo, contains advanced configurartion options
|
||||
* Implements TRIGGEN_PIN button press, press for ondemand configportal, hold for 3 seconds for reset settings.
|
||||
*/
|
||||
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
|
||||
|
||||
#define TRIGGER_PIN 0
|
||||
|
||||
// wifimanager can run in a blocking mode or a non blocking mode
|
||||
// Be sure to know how to process loops with no delay() if using non blocking
|
||||
bool wm_nonblocking = false; // change to true to use non blocking
|
||||
|
||||
WiFiManager wm; // global wm instance
|
||||
WiFiManagerParameter custom_field; // global param ( for non blocking w params )
|
||||
|
||||
void setup() {
|
||||
WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
|
||||
Serial.begin(115200);
|
||||
Serial.setDebugOutput(true);
|
||||
delay(3000);
|
||||
Serial.println("\n Starting");
|
||||
|
||||
pinMode(TRIGGER_PIN, INPUT);
|
||||
|
||||
// wm.resetSettings(); // wipe settings
|
||||
|
||||
if(wm_nonblocking) wm.setConfigPortalBlocking(false);
|
||||
|
||||
// add a custom input field
|
||||
int customFieldLength = 40;
|
||||
|
||||
|
||||
// new (&custom_field) WiFiManagerParameter("customfieldid", "Custom Field Label", "Custom Field Value", customFieldLength,"placeholder=\"Custom Field Placeholder\"");
|
||||
|
||||
// test custom html input type(checkbox)
|
||||
// new (&custom_field) WiFiManagerParameter("customfieldid", "Custom Field Label", "Custom Field Value", customFieldLength,"placeholder=\"Custom Field Placeholder\" type=\"checkbox\""); // custom html type
|
||||
|
||||
// test custom html(radio)
|
||||
const char* custom_radio_str = "<br/><label for='customfieldid'>Custom Field Label</label><input type='radio' name='customfieldid' value='1' checked> One<br><input type='radio' name='customfieldid' value='2'> Two<br><input type='radio' name='customfieldid' value='3'> Three";
|
||||
new (&custom_field) WiFiManagerParameter(custom_radio_str); // custom html input
|
||||
|
||||
wm.addParameter(&custom_field);
|
||||
wm.setSaveParamsCallback(saveParamCallback);
|
||||
|
||||
// custom menu via array or vector
|
||||
//
|
||||
// menu tokens, "wifi","wifinoscan","info","param","close","sep","erase","restart","exit" (sep is seperator) (if param is in menu, params will not show up in wifi page!)
|
||||
// const char* menu[] = {"wifi","info","param","sep","restart","exit"};
|
||||
// wm.setMenu(menu,6);
|
||||
std::vector<const char *> menu = {"wifi","info","param","sep","restart","exit"};
|
||||
wm.setMenu(menu);
|
||||
|
||||
// set dark theme
|
||||
wm.setClass("invert");
|
||||
|
||||
|
||||
//set static ip
|
||||
// wm.setSTAStaticIPConfig(IPAddress(10,0,1,99), IPAddress(10,0,1,1), IPAddress(255,255,255,0)); // set static ip,gw,sn
|
||||
// wm.setShowStaticFields(true); // force show static ip fields
|
||||
// wm.setShowDnsFields(true); // force show dns field always
|
||||
|
||||
// wm.setConnectTimeout(20); // how long to try to connect for before continuing
|
||||
wm.setConfigPortalTimeout(30); // auto close configportal after n seconds
|
||||
// wm.setCaptivePortalEnable(false); // disable captive portal redirection
|
||||
// wm.setAPClientCheck(true); // avoid timeout if client connected to softap
|
||||
|
||||
// wifi scan settings
|
||||
// wm.setRemoveDuplicateAPs(false); // do not remove duplicate ap names (true)
|
||||
// wm.setMinimumSignalQuality(20); // set min RSSI (percentage) to show in scans, null = 8%
|
||||
// wm.setShowInfoErase(false); // do not show erase button on info page
|
||||
// wm.setScanDispPerc(true); // show RSSI as percentage not graph icons
|
||||
|
||||
// wm.setBreakAfterConfig(true); // always exit configportal even if wifi save fails
|
||||
|
||||
bool res;
|
||||
// res = wm.autoConnect(); // auto generated AP name from chipid
|
||||
// res = wm.autoConnect("AutoConnectAP"); // anonymous ap
|
||||
res = wm.autoConnect("AutoConnectAP","password"); // password protected ap
|
||||
|
||||
if(!res) {
|
||||
Serial.println("Failed to connect or hit timeout");
|
||||
// ESP.restart();
|
||||
}
|
||||
else {
|
||||
//if you get here you have connected to the WiFi
|
||||
Serial.println("connected...yeey :)");
|
||||
}
|
||||
}
|
||||
|
||||
void checkButton(){
|
||||
// check for button press
|
||||
if ( digitalRead(TRIGGER_PIN) == LOW ) {
|
||||
// poor mans debounce/press-hold, code not ideal for production
|
||||
delay(50);
|
||||
if( digitalRead(TRIGGER_PIN) == LOW ){
|
||||
Serial.println("Button Pressed");
|
||||
// still holding button for 3000 ms, reset settings, code not ideaa for production
|
||||
delay(3000); // reset delay hold
|
||||
if( digitalRead(TRIGGER_PIN) == LOW ){
|
||||
Serial.println("Button Held");
|
||||
Serial.println("Erasing Config, restarting");
|
||||
wm.resetSettings();
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
// start portal w delay
|
||||
Serial.println("Starting config portal");
|
||||
wm.setConfigPortalTimeout(120);
|
||||
|
||||
if (!wm.startConfigPortal("OnDemandAP","password")) {
|
||||
Serial.println("failed to connect or hit timeout");
|
||||
delay(3000);
|
||||
// ESP.restart();
|
||||
} else {
|
||||
//if you get here you have connected to the WiFi
|
||||
Serial.println("connected...yeey :)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String getParam(String name){
|
||||
//read parameter from server, for customhmtl input
|
||||
String value;
|
||||
if(wm.server->hasArg(name)) {
|
||||
value = wm.server->arg(name);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
void saveParamCallback(){
|
||||
Serial.println("[CALLBACK] saveParamCallback fired");
|
||||
Serial.println("PARAM customfieldid = " + getParam("customfieldid"));
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if(wm_nonblocking) wm.process(); // avoid delays() in loop when non-blocking and other long running code
|
||||
checkButton();
|
||||
// put your main code here, to run repeatedly:
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
|
||||
|
||||
|
||||
void setup() {
|
||||
// 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:
|
||||
Serial.begin(115200);
|
||||
|
||||
//WiFiManager, Local intialization. Once its business is done, there is no need to keep it around
|
||||
WiFiManager wm;
|
||||
|
||||
// reset settings - wipe stored credentials for testing
|
||||
// these are stored by the esp library
|
||||
// wm.resetSettings();
|
||||
|
||||
// Automatically connect using saved credentials,
|
||||
// if connection fails, it starts an access point with the specified name ( "AutoConnectAP"),
|
||||
// if empty will auto generate SSID, if password is blank it will be anonymous AP (wm.autoConnect())
|
||||
// then goes into a blocking loop awaiting configuration and will return success result
|
||||
|
||||
bool res;
|
||||
// res = wm.autoConnect(); // auto generated AP name from chipid
|
||||
// res = wm.autoConnect("AutoConnectAP"); // anonymous ap
|
||||
res = wm.autoConnect("AutoConnectAP","password"); // password protected ap
|
||||
|
||||
if(!res) {
|
||||
Serial.println("Failed to connect");
|
||||
// ESP.restart();
|
||||
}
|
||||
else {
|
||||
//if you get here you have connected to the WiFi
|
||||
Serial.println("connected...yeey :)");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
|
||||
WiFiManager wm;
|
||||
|
||||
void setup() {
|
||||
WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
|
||||
//reset settings - wipe credentials for testing
|
||||
//wm.resetSettings();
|
||||
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.setConfigPortalTimeout(60);
|
||||
//automatically connect using saved credentials if they exist
|
||||
//If connection fails it starts an access point with the specified name
|
||||
if(wm.autoConnect("AutoConnectAP")){
|
||||
Serial.println("connected...yeey :)");
|
||||
}
|
||||
else {
|
||||
Serial.println("Configportal running");
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
wm.process();
|
||||
// put your main code here, to run repeatedly:
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
|
||||
WiFiManager wm;
|
||||
WiFiManagerParameter custom_mqtt_server("server", "mqtt server", "", 40);
|
||||
|
||||
void setup() {
|
||||
WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
|
||||
//reset settings - wipe credentials for testing
|
||||
//wm.resetSettings();
|
||||
wm.addParameter(&custom_mqtt_server);
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.setSaveParamsCallback(saveParamsCallback);
|
||||
|
||||
//automatically connect using saved credentials if they exist
|
||||
//If connection fails it starts an access point with the specified name
|
||||
if(wm.autoConnect("AutoConnectAP")){
|
||||
Serial.println("connected...yeey :)");
|
||||
}
|
||||
else {
|
||||
Serial.println("Configportal running");
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
wm.process();
|
||||
// put your main code here, to run repeatedly:
|
||||
}
|
||||
|
||||
void saveParamsCallback () {
|
||||
Serial.println("Get Params:");
|
||||
Serial.print(custom_mqtt_server.getID());
|
||||
Serial.print(" : ");
|
||||
Serial.println(custom_mqtt_server.getValue());
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/**
|
||||
* OnDemandNonBlocking.ino
|
||||
* example of running the webportal or configportal manually and non blocking
|
||||
* trigger pin will start a webportal for 120 seconds then turn it off.
|
||||
* startAP = true will start both the configportal AP and webportal
|
||||
*/
|
||||
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
|
||||
|
||||
// include MDNS
|
||||
#ifdef ESP8266
|
||||
#include <ESP8266mDNS.h>
|
||||
#elif defined(ESP32)
|
||||
#include <ESPmDNS.h>
|
||||
#endif
|
||||
|
||||
// select which pin will trigger the configuration portal when set to LOW
|
||||
#define TRIGGER_PIN 0
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
unsigned int timeout = 120; // seconds to run for
|
||||
unsigned int startTime = millis();
|
||||
bool portalRunning = false;
|
||||
bool startAP = false; // start AP and webserver if true, else start only webserver
|
||||
|
||||
void setup() {
|
||||
WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
|
||||
// put your setup code here, to run once
|
||||
Serial.begin(115200);
|
||||
Serial.setDebugOutput(true);
|
||||
delay(1000);
|
||||
Serial.println("\n Starting");
|
||||
|
||||
pinMode(TRIGGER_PIN, INPUT_PULLUP);
|
||||
|
||||
// wm.resetSettings();
|
||||
wm.setHostname("MDNSEXAMPLE");
|
||||
// wm.setEnableConfigPortal(false);
|
||||
// wm.setConfigPortalBlocking(false);
|
||||
wm.autoConnect();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
#ifdef ESP8266
|
||||
MDNS.update();
|
||||
#endif
|
||||
doWiFiManager();
|
||||
// put your main code here, to run repeatedly:
|
||||
}
|
||||
|
||||
void doWiFiManager(){
|
||||
// is auto timeout portal running
|
||||
if(portalRunning){
|
||||
wm.process(); // do processing
|
||||
|
||||
// check for timeout
|
||||
if((millis()-startTime) > (timeout*1000)){
|
||||
Serial.println("portaltimeout");
|
||||
portalRunning = false;
|
||||
if(startAP){
|
||||
wm.stopConfigPortal();
|
||||
}
|
||||
else{
|
||||
wm.stopWebPortal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// is configuration portal requested?
|
||||
if(digitalRead(TRIGGER_PIN) == LOW && (!portalRunning)) {
|
||||
if(startAP){
|
||||
Serial.println("Button Pressed, Starting Config Portal");
|
||||
wm.setConfigPortalBlocking(false);
|
||||
wm.startConfigPortal();
|
||||
}
|
||||
else{
|
||||
Serial.println("Button Pressed, Starting Web Portal");
|
||||
wm.startWebPortal();
|
||||
}
|
||||
portalRunning = true;
|
||||
startTime = millis();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
|
||||
|
||||
void configModeCallback (WiFiManager *myWiFiManager) {
|
||||
Serial.println("Entered config mode");
|
||||
Serial.println(WiFi.softAPIP());
|
||||
//if you used auto generated SSID, print it
|
||||
Serial.println(myWiFiManager->getConfigPortalSSID());
|
||||
}
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
|
||||
//WiFiManager
|
||||
//Local intialization. Once its business is done, there is no need to keep it around
|
||||
WiFiManager wifiManager;
|
||||
//reset settings - for testing
|
||||
//wifiManager.resetSettings();
|
||||
|
||||
//set callback that gets called when connecting to previous WiFi fails, and enters Access Point mode
|
||||
wifiManager.setAPCallback(configModeCallback);
|
||||
|
||||
//fetches ssid and pass and tries to connect
|
||||
//if it does not connect it starts an access point with the specified name
|
||||
//here "AutoConnectAP"
|
||||
//and goes into a blocking loop awaiting configuration
|
||||
if(!wifiManager.autoConnect()) {
|
||||
Serial.println("failed to connect and hit timeout");
|
||||
//reset and try again, or maybe put it to deep sleep
|
||||
ESP.restart();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
//if you get here you have connected to the WiFi
|
||||
Serial.println("connected...yeey :)");
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
#include <FS.h> // this needs to be first, or it all crashes and burns...
|
||||
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
|
||||
//WiFiManager
|
||||
//Local intialization. Once its business is done, there is no need to keep it around
|
||||
WiFiManager wifiManager;
|
||||
|
||||
//exit after config instead of connecting
|
||||
wifiManager.setBreakAfterConfig(true);
|
||||
|
||||
//reset settings - for testing
|
||||
//wifiManager.resetSettings();
|
||||
|
||||
|
||||
//tries to connect to last known settings
|
||||
//if it does not connect it starts an access point with the specified name
|
||||
//here "AutoConnectAP" with password "password"
|
||||
//and goes into a blocking loop awaiting configuration
|
||||
if (!wifiManager.autoConnect("AutoConnectAP", "password")) {
|
||||
Serial.println("failed to connect, we should reset as see if it connects");
|
||||
delay(3000);
|
||||
ESP.restart();
|
||||
delay(5000);
|
||||
}
|
||||
|
||||
//if you get here you have connected to the WiFi
|
||||
Serial.println("connected...yeey :)");
|
||||
|
||||
|
||||
Serial.println("local ip");
|
||||
Serial.println(WiFi.localIP());
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
|
||||
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
#include <FS.h> // this needs to be first, or it all crashes and burns...
|
||||
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
|
||||
|
||||
/**************************************************************************************
|
||||
* this example shows how to set a static IP configuration for the ESP
|
||||
* although the IP shows in the config portal, the changes will revert
|
||||
* to the IP set in the source file.
|
||||
* if you want the ability to configure and persist the new IP configuration
|
||||
* look at the FS examples, which save the config to file
|
||||
*************************************************************************************/
|
||||
|
||||
//default custom static IP
|
||||
//char static_ip[16] = "10.0.1.59";
|
||||
//char static_gw[16] = "10.0.1.1";
|
||||
//char static_sn[16] = "255.255.255.0";
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
|
||||
//WiFiManager
|
||||
//Local intialization. Once its business is done, there is no need to keep it around
|
||||
WiFiManager wifiManager;
|
||||
|
||||
//reset settings - for testing
|
||||
//wifiManager.resetSettings();
|
||||
|
||||
//set static ip
|
||||
//block1 should be used for ESP8266 core 2.1.0 or newer, otherwise use block2
|
||||
|
||||
//start-block1
|
||||
//IPAddress _ip,_gw,_sn;
|
||||
//_ip.fromString(static_ip);
|
||||
//_gw.fromString(static_gw);
|
||||
//_sn.fromString(static_sn);
|
||||
//end-block1
|
||||
|
||||
//start-block2
|
||||
IPAddress _ip = IPAddress(10, 0, 1, 78);
|
||||
IPAddress _gw = IPAddress(10, 0, 1, 1);
|
||||
IPAddress _sn = IPAddress(255, 255, 255, 0);
|
||||
//end-block2
|
||||
|
||||
wifiManager.setSTAStaticIPConfig(_ip, _gw, _sn);
|
||||
|
||||
|
||||
//tries to connect to last known settings
|
||||
//if it does not connect it starts an access point with the specified name
|
||||
//here "AutoConnectAP" with password "password"
|
||||
//and goes into a blocking loop awaiting configuration
|
||||
if (!wifiManager.autoConnect("AutoConnectAP", "password")) {
|
||||
Serial.println("failed to connect, we should reset as see if it connects");
|
||||
delay(3000);
|
||||
ESP.restart();
|
||||
delay(5000);
|
||||
}
|
||||
|
||||
//if you get here you have connected to the WiFi
|
||||
Serial.println("connected...yeey :)");
|
||||
|
||||
|
||||
Serial.println("local ip");
|
||||
Serial.println(WiFi.localIP());
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
|
||||
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
|
||||
//WiFiManager
|
||||
//Local intialization. Once its business is done, there is no need to keep it around
|
||||
WiFiManager wifiManager;
|
||||
//reset settings - for testing
|
||||
//wifiManager.resetSettings();
|
||||
|
||||
//sets timeout until configuration portal gets turned off
|
||||
//useful to make it all retry or go to sleep
|
||||
//in seconds
|
||||
wifiManager.setConfigPortalTimeout(180);
|
||||
|
||||
//fetches ssid and pass and tries to connect
|
||||
//if it does not connect it starts an access point with the specified name
|
||||
//here "AutoConnectAP"
|
||||
//and goes into a blocking loop awaiting configuration
|
||||
if(!wifiManager.autoConnect("AutoConnectAP")) {
|
||||
Serial.println("failed to connect and hit timeout");
|
||||
delay(3000);
|
||||
//reset and try again, or maybe put it to deep sleep
|
||||
ESP.restart();
|
||||
delay(5000);
|
||||
}
|
||||
|
||||
//if you get here you have connected to the WiFi
|
||||
Serial.println("connected...yeey :)");
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/**
|
||||
* OnDemandConfigPortal.ino
|
||||
* example of running the configPortal AP manually, independantly from the captiveportal
|
||||
* trigger pin will start a configPortal AP for 120 seconds then turn it off.
|
||||
*
|
||||
*/
|
||||
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
|
||||
|
||||
// select which pin will trigger the configuration portal when set to LOW
|
||||
#define TRIGGER_PIN 0
|
||||
|
||||
int timeout = 120; // seconds to run for
|
||||
|
||||
void setup() {
|
||||
WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
Serial.println("\n Starting");
|
||||
pinMode(TRIGGER_PIN, INPUT_PULLUP);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// is configuration portal requested?
|
||||
if ( digitalRead(TRIGGER_PIN) == LOW) {
|
||||
WiFiManager wm;
|
||||
|
||||
//reset settings - for testing
|
||||
//wm.resetSettings();
|
||||
|
||||
// set configportal timeout
|
||||
wm.setConfigPortalTimeout(timeout);
|
||||
|
||||
if (!wm.startConfigPortal("OnDemandAP")) {
|
||||
Serial.println("failed to connect and hit timeout");
|
||||
delay(3000);
|
||||
//reset and try again, or maybe put it to deep sleep
|
||||
ESP.restart();
|
||||
delay(5000);
|
||||
}
|
||||
|
||||
//if you get here you have connected to the WiFi
|
||||
Serial.println("connected...yeey :)");
|
||||
|
||||
}
|
||||
|
||||
// put your main code here, to run repeatedly:
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/**
|
||||
* OnDemandWebPortal.ino
|
||||
* example of running the webportal (always NON blocking)
|
||||
*/
|
||||
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
|
||||
|
||||
// select which pin will trigger the configuration portal when set to LOW
|
||||
#define TRIGGER_PIN 0
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
bool portalRunning = false;
|
||||
|
||||
void setup() {
|
||||
WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
|
||||
// put your setup code here, to run once
|
||||
Serial.begin(115200);
|
||||
Serial.println("\n Starting");
|
||||
pinMode(TRIGGER_PIN, INPUT_PULLUP);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
checkButton();
|
||||
// put your main code here, to run repeatedly:
|
||||
}
|
||||
|
||||
void checkButton(){
|
||||
// is auto timeout portal running
|
||||
if(portalRunning){
|
||||
wm.process();
|
||||
}
|
||||
|
||||
// is configuration portal requested?
|
||||
if(digitalRead(TRIGGER_PIN) == LOW) {
|
||||
delay(50);
|
||||
if(digitalRead(TRIGGER_PIN) == LOW) {
|
||||
if(!portalRunning){
|
||||
Serial.println("Button Pressed, Starting Portal");
|
||||
wm.startWebPortal();
|
||||
portalRunning = true;
|
||||
}
|
||||
else{
|
||||
Serial.println("Button Pressed, Stopping Portal");
|
||||
wm.stopWebPortal();
|
||||
portalRunning = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
/**
|
||||
* 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 :)");
|
||||
}
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
#include <FS.h> //this needs to be first, or it all crashes and burns...
|
||||
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
|
||||
|
||||
#ifdef ESP32
|
||||
#include <SPIFFS.h>
|
||||
#endif
|
||||
|
||||
#include <ArduinoJson.h> //https://github.com/bblanchon/ArduinoJson
|
||||
|
||||
//define your default values here, if there are different values in config.json, they are overwritten.
|
||||
char mqtt_server[40];
|
||||
char mqtt_port[6] = "8080";
|
||||
char api_token[34] = "YOUR_API_TOKEN";
|
||||
|
||||
//flag for saving data
|
||||
bool shouldSaveConfig = false;
|
||||
|
||||
//callback notifying us of the need to save config
|
||||
void saveConfigCallback () {
|
||||
Serial.println("Should save config");
|
||||
shouldSaveConfig = true;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
|
||||
//clean FS, for testing
|
||||
//SPIFFS.format();
|
||||
|
||||
//read configuration from FS json
|
||||
Serial.println("mounting FS...");
|
||||
|
||||
if (SPIFFS.begin()) {
|
||||
Serial.println("mounted file system");
|
||||
if (SPIFFS.exists("/config.json")) {
|
||||
//file exists, reading and loading
|
||||
Serial.println("reading config file");
|
||||
File configFile = SPIFFS.open("/config.json", "r");
|
||||
if (configFile) {
|
||||
Serial.println("opened config file");
|
||||
size_t size = configFile.size();
|
||||
// Allocate a buffer to store contents of the file.
|
||||
std::unique_ptr<char[]> buf(new char[size]);
|
||||
|
||||
configFile.readBytes(buf.get(), size);
|
||||
|
||||
#if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6
|
||||
DynamicJsonDocument json(1024);
|
||||
auto deserializeError = deserializeJson(json, buf.get());
|
||||
serializeJson(json, Serial);
|
||||
if ( ! deserializeError ) {
|
||||
#else
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
JsonObject& json = jsonBuffer.parseObject(buf.get());
|
||||
json.printTo(Serial);
|
||||
if (json.success()) {
|
||||
#endif
|
||||
Serial.println("\nparsed json");
|
||||
strcpy(mqtt_server, json["mqtt_server"]);
|
||||
strcpy(mqtt_port, json["mqtt_port"]);
|
||||
strcpy(api_token, json["api_token"]);
|
||||
} else {
|
||||
Serial.println("failed to load json config");
|
||||
}
|
||||
configFile.close();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Serial.println("failed to mount FS");
|
||||
}
|
||||
//end read
|
||||
|
||||
// The extra parameters to be configured (can be either global or just in the setup)
|
||||
// After connecting, parameter.getValue() will get you the configured value
|
||||
// id/name placeholder/prompt default length
|
||||
WiFiManagerParameter custom_mqtt_server("server", "mqtt server", mqtt_server, 40);
|
||||
WiFiManagerParameter custom_mqtt_port("port", "mqtt port", mqtt_port, 6);
|
||||
WiFiManagerParameter custom_api_token("apikey", "API token", api_token, 32);
|
||||
|
||||
//WiFiManager
|
||||
//Local intialization. Once its business is done, there is no need to keep it around
|
||||
WiFiManager wifiManager;
|
||||
|
||||
//set config save notify callback
|
||||
wifiManager.setSaveConfigCallback(saveConfigCallback);
|
||||
|
||||
//set static ip
|
||||
wifiManager.setSTAStaticIPConfig(IPAddress(10, 0, 1, 99), IPAddress(10, 0, 1, 1), IPAddress(255, 255, 255, 0));
|
||||
|
||||
//add all your parameters here
|
||||
wifiManager.addParameter(&custom_mqtt_server);
|
||||
wifiManager.addParameter(&custom_mqtt_port);
|
||||
wifiManager.addParameter(&custom_api_token);
|
||||
|
||||
//reset settings - for testing
|
||||
//wifiManager.resetSettings();
|
||||
|
||||
//set minimu quality of signal so it ignores AP's under that quality
|
||||
//defaults to 8%
|
||||
//wifiManager.setMinimumSignalQuality();
|
||||
|
||||
//sets timeout until configuration portal gets turned off
|
||||
//useful to make it all retry or go to sleep
|
||||
//in seconds
|
||||
//wifiManager.setTimeout(120);
|
||||
|
||||
//fetches ssid and pass and tries to connect
|
||||
//if it does not connect it starts an access point with the specified name
|
||||
//here "AutoConnectAP"
|
||||
//and goes into a blocking loop awaiting configuration
|
||||
if (!wifiManager.autoConnect("AutoConnectAP", "password")) {
|
||||
Serial.println("failed to connect and hit timeout");
|
||||
delay(3000);
|
||||
//reset and try again, or maybe put it to deep sleep
|
||||
ESP.restart();
|
||||
delay(5000);
|
||||
}
|
||||
|
||||
//if you get here you have connected to the WiFi
|
||||
Serial.println("connected...yeey :)");
|
||||
|
||||
//read updated parameters
|
||||
strcpy(mqtt_server, custom_mqtt_server.getValue());
|
||||
strcpy(mqtt_port, custom_mqtt_port.getValue());
|
||||
strcpy(api_token, custom_api_token.getValue());
|
||||
Serial.println("The values in the file are: ");
|
||||
Serial.println("\tmqtt_server : " + String(mqtt_server));
|
||||
Serial.println("\tmqtt_port : " + String(mqtt_port));
|
||||
Serial.println("\tapi_token : " + String(api_token));
|
||||
|
||||
//save the custom parameters to FS
|
||||
if (shouldSaveConfig) {
|
||||
Serial.println("saving config");
|
||||
#if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6
|
||||
DynamicJsonDocument json(1024);
|
||||
#else
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
JsonObject& json = jsonBuffer.createObject();
|
||||
#endif
|
||||
json["mqtt_server"] = mqtt_server;
|
||||
json["mqtt_port"] = mqtt_port;
|
||||
json["api_token"] = api_token;
|
||||
|
||||
File configFile = SPIFFS.open("/config.json", "w");
|
||||
if (!configFile) {
|
||||
Serial.println("failed to open config file for writing");
|
||||
}
|
||||
|
||||
#if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6
|
||||
serializeJson(json, Serial);
|
||||
serializeJson(json, configFile);
|
||||
#else
|
||||
json.printTo(Serial);
|
||||
json.printTo(configFile);
|
||||
#endif
|
||||
configFile.close();
|
||||
//end save
|
||||
}
|
||||
|
||||
Serial.println("local ip");
|
||||
Serial.println(WiFi.localIP());
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
|
||||
}
|
||||
@@ -1,194 +0,0 @@
|
||||
#include <FS.h> //this needs to be first, or it all crashes and burns...
|
||||
|
||||
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
|
||||
|
||||
#ifdef ESP32
|
||||
#include <SPIFFS.h>
|
||||
#endif
|
||||
|
||||
#include <ArduinoJson.h> //https://github.com/bblanchon/ArduinoJson
|
||||
|
||||
//define your default values here, if there are different values in config.json, they are overwritten.
|
||||
//length should be max size + 1
|
||||
char mqtt_server[40];
|
||||
char mqtt_port[6] = "8080";
|
||||
char api_token[34] = "YOUR_APITOKEN";
|
||||
//default custom static IP
|
||||
char static_ip[16] = "10.0.1.56";
|
||||
char static_gw[16] = "10.0.1.1";
|
||||
char static_sn[16] = "255.255.255.0";
|
||||
|
||||
//flag for saving data
|
||||
bool shouldSaveConfig = false;
|
||||
|
||||
//callback notifying us of the need to save config
|
||||
void saveConfigCallback () {
|
||||
Serial.println("Should save config");
|
||||
shouldSaveConfig = true;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
|
||||
//clean FS, for testing
|
||||
//SPIFFS.format();
|
||||
|
||||
//read configuration from FS json
|
||||
Serial.println("mounting FS...");
|
||||
|
||||
if (SPIFFS.begin()) {
|
||||
Serial.println("mounted file system");
|
||||
if (SPIFFS.exists("/config.json")) {
|
||||
//file exists, reading and loading
|
||||
Serial.println("reading config file");
|
||||
File configFile = SPIFFS.open("/config.json", "r");
|
||||
if (configFile) {
|
||||
Serial.println("opened config file");
|
||||
size_t size = configFile.size();
|
||||
// Allocate a buffer to store contents of the file.
|
||||
std::unique_ptr<char[]> buf(new char[size]);
|
||||
|
||||
configFile.readBytes(buf.get(), size);
|
||||
#if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6
|
||||
DynamicJsonDocument json(1024);
|
||||
auto deserializeError = deserializeJson(json, buf.get());
|
||||
serializeJson(json, Serial);
|
||||
if ( ! deserializeError ) {
|
||||
#else
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
JsonObject& json = jsonBuffer.parseObject(buf.get());
|
||||
json.printTo(Serial);
|
||||
if (json.success()) {
|
||||
#endif
|
||||
Serial.println("\nparsed json");
|
||||
|
||||
strcpy(mqtt_server, json["mqtt_server"]);
|
||||
strcpy(mqtt_port, json["mqtt_port"]);
|
||||
strcpy(api_token, json["api_token"]);
|
||||
|
||||
if (json["ip"]) {
|
||||
Serial.println("setting custom ip from config");
|
||||
strcpy(static_ip, json["ip"]);
|
||||
strcpy(static_gw, json["gateway"]);
|
||||
strcpy(static_sn, json["subnet"]);
|
||||
Serial.println(static_ip);
|
||||
} else {
|
||||
Serial.println("no custom ip in config");
|
||||
}
|
||||
} else {
|
||||
Serial.println("failed to load json config");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Serial.println("failed to mount FS");
|
||||
}
|
||||
//end read
|
||||
Serial.println(static_ip);
|
||||
Serial.println(api_token);
|
||||
Serial.println(mqtt_server);
|
||||
|
||||
|
||||
// The extra parameters to be configured (can be either global or just in the setup)
|
||||
// After connecting, parameter.getValue() will get you the configured value
|
||||
// id/name placeholder/prompt default length
|
||||
WiFiManagerParameter custom_mqtt_server("server", "mqtt server", mqtt_server, 40);
|
||||
WiFiManagerParameter custom_mqtt_port("port", "mqtt port", mqtt_port, 5);
|
||||
WiFiManagerParameter custom_api_token("apikey", "API token", api_token, 34);
|
||||
|
||||
//WiFiManager
|
||||
//Local intialization. Once its business is done, there is no need to keep it around
|
||||
WiFiManager wifiManager;
|
||||
|
||||
//set config save notify callback
|
||||
wifiManager.setSaveConfigCallback(saveConfigCallback);
|
||||
|
||||
//set static ip
|
||||
IPAddress _ip, _gw, _sn;
|
||||
_ip.fromString(static_ip);
|
||||
_gw.fromString(static_gw);
|
||||
_sn.fromString(static_sn);
|
||||
|
||||
wifiManager.setSTAStaticIPConfig(_ip, _gw, _sn);
|
||||
|
||||
//add all your parameters here
|
||||
wifiManager.addParameter(&custom_mqtt_server);
|
||||
wifiManager.addParameter(&custom_mqtt_port);
|
||||
wifiManager.addParameter(&custom_api_token);
|
||||
|
||||
//reset settings - for testing
|
||||
//wifiManager.resetSettings();
|
||||
|
||||
//set minimu quality of signal so it ignores AP's under that quality
|
||||
//defaults to 8%
|
||||
wifiManager.setMinimumSignalQuality();
|
||||
|
||||
//sets timeout until configuration portal gets turned off
|
||||
//useful to make it all retry or go to sleep
|
||||
//in seconds
|
||||
//wifiManager.setTimeout(120);
|
||||
|
||||
//fetches ssid and pass and tries to connect
|
||||
//if it does not connect it starts an access point with the specified name
|
||||
//here "AutoConnectAP"
|
||||
//and goes into a blocking loop awaiting configuration
|
||||
if (!wifiManager.autoConnect("AutoConnectAP", "password")) {
|
||||
Serial.println("failed to connect and hit timeout");
|
||||
delay(3000);
|
||||
//reset and try again, or maybe put it to deep sleep
|
||||
ESP.restart();
|
||||
delay(5000);
|
||||
}
|
||||
|
||||
//if you get here you have connected to the WiFi
|
||||
Serial.println("connected...yeey :)");
|
||||
|
||||
//read updated parameters
|
||||
strcpy(mqtt_server, custom_mqtt_server.getValue());
|
||||
strcpy(mqtt_port, custom_mqtt_port.getValue());
|
||||
strcpy(api_token, custom_api_token.getValue());
|
||||
|
||||
//save the custom parameters to FS
|
||||
if (shouldSaveConfig) {
|
||||
Serial.println("saving config");
|
||||
#if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6
|
||||
DynamicJsonDocument json(1024);
|
||||
#else
|
||||
DynamicJsonBuffer jsonBuffer;
|
||||
JsonObject& json = jsonBuffer.createObject();
|
||||
#endif
|
||||
json["mqtt_server"] = mqtt_server;
|
||||
json["mqtt_port"] = mqtt_port;
|
||||
json["api_token"] = api_token;
|
||||
|
||||
json["ip"] = WiFi.localIP().toString();
|
||||
json["gateway"] = WiFi.gatewayIP().toString();
|
||||
json["subnet"] = WiFi.subnetMask().toString();
|
||||
|
||||
File configFile = SPIFFS.open("/config.json", "w");
|
||||
if (!configFile) {
|
||||
Serial.println("failed to open config file for writing");
|
||||
}
|
||||
|
||||
#if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6
|
||||
serializeJson(json, Serial);
|
||||
serializeJson(json, configFile);
|
||||
#else
|
||||
json.printTo(Serial);
|
||||
json.printTo(configFile);
|
||||
#endif
|
||||
configFile.close();
|
||||
//end save
|
||||
}
|
||||
|
||||
Serial.println("local ip");
|
||||
Serial.println(WiFi.localIP());
|
||||
Serial.println(WiFi.gatewayIP());
|
||||
Serial.println(WiFi.subnetMask());
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// put your main code here, to run repeatedly:
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
/**
|
||||
* WiFiManagerParameter child class example
|
||||
*/
|
||||
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
|
||||
#include <Arduino.h>
|
||||
#include <EEPROM.h>
|
||||
|
||||
#define SETUP_PIN 0
|
||||
|
||||
class IPAddressParameter : public WiFiManagerParameter {
|
||||
public:
|
||||
IPAddressParameter(const char *id, const char *placeholder, IPAddress address)
|
||||
: WiFiManagerParameter("") {
|
||||
init(id, placeholder, address.toString().c_str(), 16, "", WFM_LABEL_BEFORE);
|
||||
}
|
||||
|
||||
bool getValue(IPAddress &ip) {
|
||||
return ip.fromString(WiFiManagerParameter::getValue());
|
||||
}
|
||||
};
|
||||
|
||||
class IntParameter : public WiFiManagerParameter {
|
||||
public:
|
||||
IntParameter(const char *id, const char *placeholder, long value, const uint8_t length = 10)
|
||||
: WiFiManagerParameter("") {
|
||||
init(id, placeholder, String(value).c_str(), length, "", WFM_LABEL_BEFORE);
|
||||
}
|
||||
|
||||
long getValue() {
|
||||
return String(WiFiManagerParameter::getValue()).toInt();
|
||||
}
|
||||
};
|
||||
|
||||
class FloatParameter : public WiFiManagerParameter {
|
||||
public:
|
||||
FloatParameter(const char *id, const char *placeholder, float value, const uint8_t length = 10)
|
||||
: WiFiManagerParameter("") {
|
||||
init(id, placeholder, String(value).c_str(), length, "", WFM_LABEL_BEFORE);
|
||||
}
|
||||
|
||||
float getValue() {
|
||||
return String(WiFiManagerParameter::getValue()).toFloat();
|
||||
}
|
||||
};
|
||||
|
||||
struct Settings {
|
||||
float f;
|
||||
int i;
|
||||
char s[20];
|
||||
uint32_t ip;
|
||||
} sett;
|
||||
|
||||
|
||||
void setup() {
|
||||
WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
|
||||
pinMode(SETUP_PIN, INPUT_PULLUP);
|
||||
Serial.begin(115200);
|
||||
|
||||
//Delay to push SETUP button
|
||||
Serial.println("Press setup button");
|
||||
for (int sec = 3; sec > 0; sec--) {
|
||||
Serial.print(sec);
|
||||
Serial.print("..");
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
// warning for example only, this will initialize empty memory into your vars
|
||||
// always init flash memory or add some checksum bits
|
||||
EEPROM.begin( 512 );
|
||||
EEPROM.get(0, sett);
|
||||
Serial.println("Settings loaded");
|
||||
|
||||
if (digitalRead(SETUP_PIN) == LOW) {
|
||||
// Button pressed
|
||||
Serial.println("SETUP");
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
sett.s[19] = '\0'; //add null terminator at the end cause overflow
|
||||
WiFiManagerParameter param_str( "str", "param_string", sett.s, 20);
|
||||
FloatParameter param_float( "float", "param_float", sett.f);
|
||||
IntParameter param_int( "int", "param_int", sett.i);
|
||||
|
||||
IPAddress ip(sett.ip);
|
||||
IPAddressParameter param_ip("ip", "param_ip", ip);
|
||||
|
||||
wm.addParameter( ¶m_str );
|
||||
wm.addParameter( ¶m_float );
|
||||
wm.addParameter( ¶m_int );
|
||||
wm.addParameter( ¶m_ip );
|
||||
|
||||
//SSID & password parameters already included
|
||||
wm.startConfigPortal();
|
||||
|
||||
strncpy(sett.s, param_str.getValue(), 20);
|
||||
sett.s[19] = '\0';
|
||||
sett.f = param_float.getValue();
|
||||
sett.i = param_int.getValue();
|
||||
|
||||
Serial.print("String param: ");
|
||||
Serial.println(sett.s);
|
||||
Serial.print("Float param: ");
|
||||
Serial.println(sett.f);
|
||||
Serial.print("Int param: ");
|
||||
Serial.println(sett.i, DEC);
|
||||
|
||||
if (param_ip.getValue(ip)) {
|
||||
sett.ip = ip;
|
||||
|
||||
Serial.print("IP param: ");
|
||||
Serial.println(ip);
|
||||
} else {
|
||||
Serial.println("Incorrect IP");
|
||||
}
|
||||
|
||||
EEPROM.put(0, sett);
|
||||
if (EEPROM.commit()) {
|
||||
Serial.println("Settings saved");
|
||||
} else {
|
||||
Serial.println("EEPROM error");
|
||||
}
|
||||
}
|
||||
else {
|
||||
Serial.println("WORK");
|
||||
|
||||
//connect to saved SSID
|
||||
WiFi.begin();
|
||||
|
||||
//do smth
|
||||
Serial.print("String param: ");
|
||||
Serial.println(sett.s);
|
||||
Serial.print("Float param: ");
|
||||
Serial.println(sett.f);
|
||||
Serial.print("Int param: ");
|
||||
Serial.println(sett.i, DEC);
|
||||
Serial.print("IP param: ");
|
||||
IPAddress ip(sett.ip);
|
||||
Serial.println(ip);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
||||
@@ -1,444 +0,0 @@
|
||||
/**
|
||||
* This is a kind of unit test for DEV for now
|
||||
* It contains many of the public methods
|
||||
*
|
||||
*/
|
||||
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define USEOTA
|
||||
// enable OTA
|
||||
#ifdef USEOTA
|
||||
#include <WiFiUdp.h>
|
||||
#include <ArduinoOTA.h>
|
||||
#endif
|
||||
|
||||
const char* modes[] = { "NULL", "STA", "AP", "STA+AP" };
|
||||
|
||||
unsigned long mtime = 0;
|
||||
|
||||
|
||||
WiFiManager wm;
|
||||
|
||||
|
||||
// TEST OPTION FLAGS
|
||||
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)
|
||||
bool ALLOWONDEMAND = true; // enable on demand
|
||||
int ONDDEMANDPIN = 0; // gpio for button
|
||||
bool WMISBLOCKING = true; // use blocking or non blocking mode, non global params wont work in non blocking
|
||||
|
||||
uint8_t BUTTONFUNC = 1; // 0 resetsettings, 1 configportal, 2 autoconnect
|
||||
|
||||
// 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");
|
||||
}
|
||||
|
||||
//gets called when WiFiManager enters configuration mode
|
||||
void configModeCallback (WiFiManager *myWiFiManager) {
|
||||
Serial.println("[CALLBACK] configModeCallback fired");
|
||||
// myWiFiManager->setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
|
||||
// Serial.println(WiFi.softAPIP());
|
||||
//if you used auto generated SSID, print it
|
||||
// Serial.println(myWiFiManager->getConfigPortalSSID());
|
||||
//
|
||||
// esp_wifi_set_bandwidth(WIFI_IF_AP, WIFI_BW_HT20);
|
||||
}
|
||||
|
||||
void saveParamCallback(){
|
||||
Serial.println("[CALLBACK] saveParamCallback fired");
|
||||
// wm.stopConfigPortal();
|
||||
}
|
||||
|
||||
void bindServerCallback(){
|
||||
wm.server->on("/custom",handleRoute);
|
||||
|
||||
// you can override wm route endpoints, I have not found a way to remove handlers, but this would let you disable them or add auth etc.
|
||||
// wm.server->on("/info",handleNotFound);
|
||||
// wm.server->on("/update",handleNotFound);
|
||||
wm.server->on("/erase",handleNotFound); // disable erase
|
||||
}
|
||||
|
||||
void handleRoute(){
|
||||
Serial.println("[HTTP] handle custom route");
|
||||
wm.server->send(200, "text/plain", "hello from user code");
|
||||
}
|
||||
|
||||
void handleNotFound(){
|
||||
Serial.println("[HTTP] override handle route");
|
||||
wm.handleNotFound();
|
||||
}
|
||||
|
||||
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 can default to STA+AP
|
||||
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
delay(3000);
|
||||
// Serial.setDebugOutput(true);
|
||||
|
||||
// WiFi.setTxPower(WIFI_POWER_8_5dBm);
|
||||
|
||||
Serial.println("\n Starting");
|
||||
// WiFi.setSleepMode(WIFI_NONE_SLEEP); // disable sleep, can improve ap stability
|
||||
|
||||
Serial.println("Error - TEST");
|
||||
Serial.println("Information- - TEST");
|
||||
|
||||
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_DEBUG_DEV);
|
||||
wm.debugPlatformInfo();
|
||||
|
||||
//reset settings - for testing
|
||||
// wm.resetSettings();
|
||||
// wm.erase();
|
||||
|
||||
// setup some parameters
|
||||
|
||||
WiFiManagerParameter custom_html("<p style=\"color:pink;font-weight:Bold;\">This Is Custom HTML</p>"); // only custom html
|
||||
WiFiManagerParameter custom_mqtt_server("server", "mqtt server", "", 40);
|
||||
WiFiManagerParameter custom_mqtt_port("port", "mqtt port", "", 6);
|
||||
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);
|
||||
|
||||
const char *bufferStr = R"(
|
||||
<!-- INPUT CHOICE -->
|
||||
<br/>
|
||||
<p>Select Choice</p>
|
||||
<input style='display: inline-block;' type='radio' id='choice1' name='program_selection' value='1'>
|
||||
<label for='choice1'>Choice1</label><br/>
|
||||
<input style='display: inline-block;' type='radio' id='choice2' name='program_selection' value='2'>
|
||||
<label for='choice2'>Choice2</label><br/>
|
||||
|
||||
<!-- INPUT SELECT -->
|
||||
<br/>
|
||||
<label for='input_select'>Label for Input Select</label>
|
||||
<select name="input_select" id="input_select" class="button">
|
||||
<option value="0">Option 1</option>
|
||||
<option value="1" selected>Option 2</option>
|
||||
<option value="2">Option 3</option>
|
||||
<option value="3">Option 4</option>
|
||||
</select>
|
||||
)";
|
||||
|
||||
WiFiManagerParameter custom_html_inputs(bufferStr);
|
||||
|
||||
// callbacks
|
||||
wm.setAPCallback(configModeCallback);
|
||||
wm.setWebServerCallback(bindServerCallback);
|
||||
wm.setSaveConfigCallback(saveWifiCallback);
|
||||
wm.setSaveParamsCallback(saveParamCallback);
|
||||
wm.setPreOtaUpdateCallback(handlePreOtaUpdateCallback);
|
||||
|
||||
// add all your parameters here
|
||||
wm.addParameter(&custom_html);
|
||||
wm.addParameter(&custom_mqtt_server);
|
||||
wm.addParameter(&custom_mqtt_port);
|
||||
wm.addParameter(&custom_token);
|
||||
wm.addParameter(&custom_tokenb);
|
||||
wm.addParameter(&custom_ipaddress);
|
||||
wm.addParameter(&custom_checkbox);
|
||||
wm.addParameter(&custom_input_type);
|
||||
|
||||
wm.addParameter(&custom_html_inputs);
|
||||
|
||||
// set values later if you want
|
||||
custom_html.setValue("test",4);
|
||||
custom_token.setValue("test",4);
|
||||
|
||||
// const char* icon = "
|
||||
// <link rel='icon' type='image/png' sizes='16x16' href='data:image/png;base64,
|
||||
// iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAMFBMVEU0OkArMjhobHEoPUPFEBIu
|
||||
// O0L+AAC2FBZ2JyuNICOfGx7xAwTjCAlCNTvVDA1aLzQ3COjMAAAAVUlEQVQI12NgwAaCDSA0888G
|
||||
// CItjn0szWGBJTVoGSCjWs8TleQCQYV95evdxkFT8Kpe0PLDi5WfKd4LUsN5zS1sKFolt8bwAZrCa
|
||||
// GqNYJAgFDEpQAAAzmxafI4vZWwAAAABJRU5ErkJggg==' />";
|
||||
|
||||
|
||||
// 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);
|
||||
|
||||
// invert theme, dark
|
||||
wm.setDarkMode(true);
|
||||
|
||||
// show scan RSSI as percentage, instead of signal stength graphic
|
||||
// wm.setScanDispPerc(true);
|
||||
|
||||
/*
|
||||
Set cutom menu via menu[] or vector
|
||||
const char* menu[] = {"wifi","wifinoscan","info","param","close","sep","erase","restart","exit"};
|
||||
wm.setMenu(menu,9); // custom menu array must provide length
|
||||
*/
|
||||
|
||||
std::vector<const char *> menu = {"wifi","wifinoscan","info","param","custom","close","sep","erase","update","restart","exit"};
|
||||
// wm.setMenu(menu); // custom menu, pass vector
|
||||
|
||||
// wm.setParamsPage(true); // move params to seperate page, not wifi, do not combine with setmenu!
|
||||
|
||||
// set STA static ip
|
||||
// wm.setSTAStaticIPConfig(IPAddress(10,0,1,99), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
|
||||
// wm.setShowStaticFields(false);
|
||||
// wm.setShowDnsFields(false);
|
||||
|
||||
// set AP static ip
|
||||
// wm.setAPStaticIPConfig(IPAddress(10,0,1,1), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
|
||||
// wm.setAPStaticIPConfig(IPAddress(10,0,1,99), IPAddress(10,0,1,1), IPAddress(255,255,255,0));
|
||||
|
||||
// set country
|
||||
// setting wifi country seems to improve OSX soft ap connectivity,
|
||||
// may help others as well, default is CN which has different channels
|
||||
|
||||
// wm.setCountry("US"); // crashing on esp32 2.0
|
||||
|
||||
// set Hostname
|
||||
|
||||
// wm.setHostname(("WM_"+wm.getDefaultAPName()).c_str());
|
||||
// wm.setHostname("WM_RANDO_1234");
|
||||
|
||||
// set custom channel
|
||||
// wm.setWiFiAPChannel(13);
|
||||
|
||||
// set AP hidden
|
||||
// wm.setAPHidden(true);
|
||||
|
||||
// show password publicly in form
|
||||
// wm.setShowPassword(true);
|
||||
|
||||
// sets wether wm configportal is a blocking loop(legacy) or not, use wm.process() in loop if false
|
||||
// wm.setConfigPortalBlocking(false);
|
||||
|
||||
if(!WMISBLOCKING){
|
||||
wm.setConfigPortalBlocking(false);
|
||||
}
|
||||
|
||||
|
||||
//sets timeout until configuration portal gets turned off
|
||||
//useful to make it all retry or go to sleep in seconds
|
||||
wm.setConfigPortalTimeout(TESP_CP_TIMEOUT);
|
||||
|
||||
// set min quality to show in web list, default 8%
|
||||
// wm.setMinimumSignalQuality(50);
|
||||
|
||||
// set connection timeout
|
||||
// wm.setConnectTimeout(20);
|
||||
|
||||
// set wifi connect retries
|
||||
// wm.setConnectRetries(2);
|
||||
|
||||
// connect after portal save toggle
|
||||
// wm.setSaveConnect(false); // do not connect, only save
|
||||
|
||||
// show static ip fields
|
||||
// wm.setShowStaticFields(true);
|
||||
|
||||
// wm.startConfigPortal("AutoConnectAP", "password");
|
||||
|
||||
// This is sometimes necessary, it is still unknown when and why this is needed but it may solve some race condition or bug in esp SDK/lib
|
||||
// wm.setCleanConnect(true); // disconnect before connect, clean connect
|
||||
|
||||
wm.setBreakAfterConfig(true); // needed to use saveWifiCallback
|
||||
|
||||
// set custom webserver port, automatic captive portal does not work with custom ports!
|
||||
// wm.setHttpPort(8080);
|
||||
|
||||
//fetches ssid and pass and tries to connect
|
||||
//if it does not connect it starts an access point with the specified name
|
||||
//here "AutoConnectAP"
|
||||
//and goes into a blocking loop awaiting configuration
|
||||
|
||||
// use autoconnect, but prevent configportal from auto starting
|
||||
// wm.setEnableConfigPortal(false);
|
||||
|
||||
wifiInfo();
|
||||
|
||||
// to preload autoconnect with credentials
|
||||
// wm.preloadWiFi("ssid","password");
|
||||
|
||||
if(!wm.autoConnect("WM_AutoConnectAP","12345678")) {
|
||||
Serial.println("failed to connect and hit timeout");
|
||||
}
|
||||
else if(TEST_CP) {
|
||||
// start configportal always
|
||||
delay(1000);
|
||||
Serial.println("TEST_CP ENABLED");
|
||||
wm.setConfigPortalTimeout(TESP_CP_TIMEOUT);
|
||||
wm.startConfigPortal("WM_ConnectAP","12345678");
|
||||
}
|
||||
else {
|
||||
//if you get here you have connected to the WiFi
|
||||
Serial.println("connected...yeey :)");
|
||||
}
|
||||
|
||||
wifiInfo();
|
||||
pinMode(ONDDEMANDPIN, INPUT_PULLUP);
|
||||
|
||||
#ifdef USEOTA
|
||||
ArduinoOTA.begin();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
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] MODE: " + (String)(wm.getModeString(WiFi.getMode())));
|
||||
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() {
|
||||
|
||||
if(!WMISBLOCKING){
|
||||
wm.process();
|
||||
}
|
||||
|
||||
|
||||
#ifdef USEOTA
|
||||
ArduinoOTA.handle();
|
||||
#endif
|
||||
// is configuration portal requested?
|
||||
if (ALLOWONDEMAND && digitalRead(ONDDEMANDPIN) == LOW ) {
|
||||
delay(100);
|
||||
if ( digitalRead(ONDDEMANDPIN) == LOW || BUTTONFUNC == 2){
|
||||
Serial.println("BUTTON PRESSED");
|
||||
|
||||
// button reset/reboot
|
||||
if(BUTTONFUNC == 0){
|
||||
wm.resetSettings();
|
||||
wm.reboot();
|
||||
delay(200);
|
||||
return;
|
||||
}
|
||||
|
||||
// start configportal
|
||||
if(BUTTONFUNC == 1){
|
||||
if (!wm.startConfigPortal("OnDemandAP","12345678")) {
|
||||
Serial.println("failed to connect and hit timeout");
|
||||
delay(3000);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//test autoconnect as reconnect etc.
|
||||
if(BUTTONFUNC == 2){
|
||||
wm.setConfigPortalTimeout(TESP_CP_TIMEOUT);
|
||||
wm.autoConnect();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
//if you get here you have connected to the WiFi
|
||||
Serial.println("connected...yeey :)");
|
||||
getTime();
|
||||
}
|
||||
}
|
||||
|
||||
// every 10 seconds
|
||||
if(millis()-mtime > 10000 ){
|
||||
if(WiFi.status() == WL_CONNECTED){
|
||||
getTime();
|
||||
}
|
||||
else Serial.println("No Wifi");
|
||||
mtime = millis();
|
||||
}
|
||||
// put your main code here, to run repeatedly:
|
||||
delay(100);
|
||||
}
|
||||
|
||||
void getTime() {
|
||||
int tz = -5;
|
||||
int dst = 0;
|
||||
time_t now = time(nullptr);
|
||||
unsigned timeout = 5000; // try for timeout
|
||||
unsigned start = millis();
|
||||
configTime(tz * 3600, dst * 3600, "pool.ntp.org", "time.nist.gov");
|
||||
Serial.print("Waiting for NTP time sync: ");
|
||||
while (now < 8 * 3600 * 2 ) { // what is this ?
|
||||
delay(100);
|
||||
Serial.print(".");
|
||||
now = time(nullptr);
|
||||
if((millis() - start) > timeout){
|
||||
Serial.println("\n[ERROR] Failed to get NTP time.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
Serial.println("");
|
||||
struct tm timeinfo;
|
||||
gmtime_r(&now, &timeinfo);
|
||||
Serial.print("Current time: ");
|
||||
Serial.print(asctime(&timeinfo));
|
||||
}
|
||||
|
||||
void debugchipid(){
|
||||
// WiFi.mode(WIFI_STA);
|
||||
// WiFi.printDiag(Serial);
|
||||
// Serial.println(modes[WiFi.getMode()]);
|
||||
|
||||
// ESP.eraseConfig();
|
||||
// wm.resetSettings();
|
||||
// wm.erase(true);
|
||||
WiFi.mode(WIFI_AP);
|
||||
// WiFi.softAP();
|
||||
WiFi.enableAP(true);
|
||||
delay(500);
|
||||
// esp_wifi_start();
|
||||
delay(1000);
|
||||
WiFi.printDiag(Serial);
|
||||
delay(60000);
|
||||
ESP.restart();
|
||||
|
||||
// AP esp_267751
|
||||
// 507726A4AE30
|
||||
// ESP32 Chip ID = 507726A4AE30
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
// 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(){
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
#include <WiFiManager.h> // https://github.com/tzapu/WiFiManager
|
||||
|
||||
bool _enteredConfigMode = false;
|
||||
|
||||
void setup(){
|
||||
Serial.begin(115200);
|
||||
WiFiManager wifiManager;
|
||||
|
||||
// wifiManager.setAPCallback([this](WiFiManager* wifiManager) {
|
||||
wifiManager.setAPCallback([&](WiFiManager* wifiManager) {
|
||||
Serial.printf("Entered config mode:ip=%s, ssid='%s'\n",
|
||||
WiFi.softAPIP().toString().c_str(),
|
||||
wifiManager->getConfigPortalSSID().c_str());
|
||||
_enteredConfigMode = true;
|
||||
});
|
||||
wifiManager.resetSettings();
|
||||
if (!wifiManager.autoConnect()) {
|
||||
Serial.printf("*** Failed to connect and hit timeout\n");
|
||||
ESP.restart();
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
void loop(){
|
||||
|
||||
}
|
||||
@@ -1,400 +0,0 @@
|
||||
<!-- HTTP_HEAD -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\"/>
|
||||
<title>{v}</title>
|
||||
<!-- /HTTP_HEAD -->
|
||||
<!-- HTTP_STYLE -->
|
||||
<style>
|
||||
|
||||
:root{
|
||||
/* CSS VARIABLE THEME COLOR */
|
||||
/*--primarycolor:#9933CC;*/
|
||||
--primarycolor:#1fa3ec;
|
||||
}
|
||||
|
||||
body.invert,
|
||||
body.invert a,
|
||||
body.invert h1 {
|
||||
background-color:#060606;
|
||||
color:white;
|
||||
}
|
||||
body.invert .msg{
|
||||
background-color: #282828;
|
||||
border-top: 1px solid #555;
|
||||
border-right: 1px solid #555;
|
||||
border-bottom: 1px solid #555;
|
||||
color:#fff;
|
||||
}
|
||||
body.invert .q[role=img] {
|
||||
-webkit-filter: invert(1);
|
||||
filter: invert(1);
|
||||
}
|
||||
.c,
|
||||
body {
|
||||
text-align: center;
|
||||
font-family: verdana
|
||||
}
|
||||
.wrap {
|
||||
text-align:left;
|
||||
display:inline-block;
|
||||
min-width:260px;
|
||||
max-width:500px;
|
||||
}
|
||||
div,
|
||||
input,select {
|
||||
padding: 5px;
|
||||
font-size: 1em;
|
||||
/*width: 100%;*/
|
||||
/*/*margin: 3px 0 10px 0; // BEFORE spacing shows label closer to input, but need to do same for AFTER*/
|
||||
margin: 5px 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
div{
|
||||
margin: 5px 0;
|
||||
}
|
||||
input,button,select,.msg{
|
||||
border-radius:.3rem;
|
||||
width: 100%;
|
||||
}
|
||||
input[type=radio],input[type=checkbox]{
|
||||
width: auto;
|
||||
}
|
||||
button,input[type="button"],input[type="submit"] {
|
||||
border: 0;
|
||||
background-color: var(--primarycolor);
|
||||
color: #fff;
|
||||
line-height: 2.4rem;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
input[type="file"]{
|
||||
border: 1px solid var(--primarycolor);
|
||||
}
|
||||
a {
|
||||
color: #000;
|
||||
font-weight: 700;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
color: var(--primarycolor);
|
||||
text-decoration: underline;
|
||||
}
|
||||
.h {
|
||||
display: none;
|
||||
}
|
||||
.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=');
|
||||
}
|
||||
@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 {
|
||||
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: var(--primarycolor);
|
||||
}
|
||||
.msg.P h4 {
|
||||
color: var(--primarycolor);
|
||||
}
|
||||
.msg.S {
|
||||
border-left-color: #5cb85c;
|
||||
}
|
||||
.msg.S h4 {
|
||||
color: #5cb85c;
|
||||
}
|
||||
.msg.D {
|
||||
border-left-color: #dc3630;
|
||||
}
|
||||
.msg.D h4 {
|
||||
color: #dc3630;
|
||||
}
|
||||
|
||||
dt {
|
||||
font-weight: bold;
|
||||
}
|
||||
dd {
|
||||
margin: 0;
|
||||
padding: 0 0 0.5em 0;
|
||||
}
|
||||
td {
|
||||
vertical-align: top;
|
||||
}
|
||||
button.D{
|
||||
background-color:#dc3630;
|
||||
}
|
||||
|
||||
button{
|
||||
/*transition: 0s filter;*/
|
||||
transition: 0s opacity;
|
||||
transition-delay: 3s;
|
||||
transition-duration: 0s;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button:active{
|
||||
opacity: 50% !important;
|
||||
/*filter: brightness(50%);*/
|
||||
cursor: wait;
|
||||
transition-delay: 0s;
|
||||
}
|
||||
|
||||
button:hover{
|
||||
/*opacity: 80%;*/
|
||||
}
|
||||
|
||||
:disabled {
|
||||
opacity: 0.5;
|
||||
}
|
||||
</style>
|
||||
<!-- /HTTP_STYLE -->
|
||||
<!-- HTTP_SCRIPT -->
|
||||
<script>
|
||||
function c(l){document.getElementById('s').value=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>
|
||||
<!-- /HTTP_SCRIPT -->
|
||||
<!-- HTTP_HEAD_END -->
|
||||
</head>
|
||||
<body class="invert">
|
||||
<div class='wrap'>
|
||||
<!-- <div class='wrap ql qinv'> -->
|
||||
<!-- /HTTP_HEAD_END -->
|
||||
<!-- SAMPLE -->
|
||||
<h2>/</h2><hR>
|
||||
<!-- /SAMPLE -->
|
||||
<!-- HTTP_PORTAL_OPTIONS -->
|
||||
<!-- /HTTP_PORTAL_OPTIONS -->
|
||||
<!-- HTTP_PORTAL_MENU[] -->
|
||||
<form action='/wifi' method='get'><button>Configure WiFi</button></form><br/>
|
||||
<form action='/0wifi' method='get'><button>Configure WiFi (No Scan)</button></form><br/>
|
||||
<form action='/info' method='get'><button>Info</button></form><br/>
|
||||
<form action='/param' method='get'><button>Setup</button></form><br/>
|
||||
<Hr><br/>
|
||||
<form action='/close' method='post'><button>Close</button></form><br/>
|
||||
<form action='/erase' method='post'><button class='D'>Erase</button></form><br/>
|
||||
<form action='/restart' method='post'><button>Restart</button></form><br/>
|
||||
<form action='/exit' method='post'><button>Exit</button></form><br/>
|
||||
<form action='/exit' method='post'><button>Update</button></form><br/>
|
||||
<form action='/' method='post'><button>Back</button></form><br/>
|
||||
<!-- /HTTP_PORTAL_MENU -->
|
||||
<!-- SAMPLE -->
|
||||
<h2>/wifi</h2><hr>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 01</a><div role='img' aria-label='88%' title='88%' class='q q-4 l'></div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 02</a><div role='img' aria-label='88%' title='88%' class='q q-4'></div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 03</a><div role='img' aria-label='60%' title='60%' class='q q-3 l'></div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 04</a><div role='img' aria-label='60%' title='60%' class='q q-3'></div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 05</a><div role='img' aria-label='60%' title='60%' class='q q-3'></div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 06</a><div role='img' aria-label='40%' title='40%' class='q q-2'></div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 07</a><div role='img' aria-label='40%' title='40%' class='q q-2 l'></div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 08</a><div role='img' aria-label='20%' title='20%' class='q q-1'></div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 09</a><div role='img' aria-label='20%' title='20%' class='q q-1'></div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 10</a><div role='img' aria-label='20%' title='20%' class='q q-4 l'></div><div class='q '>100%</div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 11</a><div role='img' aria-label='10%' title='10%' class='q q-3'></div><div class='q '>70%</div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 12</a><div role='img' aria-label='10%' title='10%' class='q q-1 l'></div><div class='q '>10%</div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 13</a><div role='img' aria-label='10%' title='10%' class='q q-0 h'></div><div class='q '>100%</div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 14</a><div class='q'>66%</div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 15</a><div class='q'>56%</div></div>
|
||||
<!-- /SAMPLE -->
|
||||
<!-- HTTP_ITEM -->
|
||||
<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'><input type='checkbox' id='show-password' onclick='f()'> <label for='show-password'>Show Password</label><br/>
|
||||
<!-- /HTTP_FORM_START -->
|
||||
<!-- SAMPLE -->
|
||||
<h3>custom parameter</h3><hr>
|
||||
<br/><label for='custom'>Label for Custom Param</label>
|
||||
<br/><input id='custom' name='custom' length='255' placeholder='placeholder' value='' {c}>
|
||||
<!-- /SAMPLE -->
|
||||
<!-- HTTP_FORM_LABEL -->
|
||||
<br/><label for='{i}'>{p}</label>
|
||||
<!-- /HTTP_FORM_LABEL -->
|
||||
<!-- HTTP_FORM_PARAM -->
|
||||
<br/><input id='{i}' name='{n}' length='{l}' placeholder='{p}' value='{v}' {c}>
|
||||
<!-- /HTTP_FORM_PARAM -->
|
||||
<!-- HTTP_FORM_END -->
|
||||
<br/><button type='submit'>Save</button></form>
|
||||
<!-- /HTTP_FORM_END -->
|
||||
<!-- HTTP_SCAN_LINK -->
|
||||
<br/><form action='/wifi' method='get'><button>Refresh</button></form>
|
||||
<!-- /HTTP_SCAN_LINK -->
|
||||
<!-- HTTP_SAVED -->
|
||||
<div class='msg'><h4>Saving Credentials</h4>Trying to connect ESP to network.<br />If it fails reconnect to AP to try again</div>
|
||||
<!-- /HTTP_SAVED -->
|
||||
<!-- HTTP_STATUS_ON -->
|
||||
<div class='msg P'><strong>Connected</strong> to {v}<br/><em><small>with IP {i}</small></em></div>
|
||||
<!-- /HTTP_STATUS_ON -->
|
||||
<!-- HTTP_STATUS_OFF -->
|
||||
<div class='msg {c}'><strong>Not Connected</strong> to {v}{r}</div>
|
||||
<!-- /HTTP_STATUS_OFF -->
|
||||
<!-- sample -->
|
||||
<div class='msg D'><strong>Not Connected</strong> to apname
|
||||
<!-- /sample -->
|
||||
<!-- HTTP_STATUS_OFFPW -->
|
||||
<br/>Authentication Failure
|
||||
<!-- /HTTP_STATUS_OFFPW -->
|
||||
<!-- HTTP_STATUS_OFFNOAP -->
|
||||
<br/>AP not found
|
||||
<!-- /HTTP_STATUS_OFFNOAP -->
|
||||
<!-- HTTP_STATUS_OFFFAIL -->
|
||||
<br/>Could not Connect
|
||||
<!-- /HTTP_STATUS_OFFFAIL -->
|
||||
</div>
|
||||
<!-- HTTP_STATUS_NONE -->
|
||||
<div class='msg'>No AP set</div>
|
||||
<!-- /HTTP_STATUS_NONE -->
|
||||
<!-- SAMPLE -->
|
||||
<div class='msg P'><h4>H4 Color Header P</h4>content</div>
|
||||
<!-- /SAMPLE -->
|
||||
<!-- SAMPLE -->
|
||||
<div class='msg S'><h4>H4 Color Header S</h4>content</div>
|
||||
<!-- /SAMPLE -->
|
||||
<!-- SAMPLE -->
|
||||
<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>
|
||||
<dt>IDE Flash Size</dt><dd>4194304 bytes</dd>
|
||||
<dt>Real Flash Size</dt><dd>4194304 bytes</dd>
|
||||
<dt>Empty</dt><dd></dd>
|
||||
<dt>Soft AP IP</dt><dd>192.168.4.1</dd>
|
||||
<dt>Soft AP MAC</dt><dd>00:00:00:00:00:00</dd>
|
||||
<dt>Station MAC</dt><dd>00:00:00:00:00:00</dd>
|
||||
</dl>
|
||||
<!-- /SAMPLE -->
|
||||
<!-- HTTP_HELP -->
|
||||
<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='/close'>/close</a></td>
|
||||
<td>Close the configuration server and configuration WiFi network.</td></tr>
|
||||
<tr><td><a href='/info'>/info</a></td>
|
||||
<td>Information page</td></tr>
|
||||
<tr><td><a href='/close'>/close</a></td>
|
||||
<td>Close the captiveportal popup,configportal will remain active</td></tr>
|
||||
<tr><td><a href='/exit'>/exit</a></td>
|
||||
<td>Exit Config Portal, configportal will close</td></tr>
|
||||
<tr><td><a href='/restart'>/restart</a></td>
|
||||
<td>Reboot the device</td></tr>
|
||||
<tr><td><a href='/erase'>/erase</a></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>
|
||||
<h3>About</h3><hr>
|
||||
Version v1.x.x-xxxxx<Br/>
|
||||
Build_date<br/>
|
||||
Build_file<br/>
|
||||
Arduino_version<br/>
|
||||
<p/>Github <a href='https://github.com/tzapu/WiFiManager'>https://github.com/tzapu/WiFiManager</a>
|
||||
<!-- /HTTP_HELP -->
|
||||
<!-- FORM_UPLOAD -->
|
||||
<Br/><br/>Form UPLOAD<br/>
|
||||
<form method='POST' action='u' enctype='multipart/form-data'>
|
||||
<input type='file' name='update' accept='.bin,application/octet-stream' onchange="(function(el){document.getElementById('uploadbin').style.display = el.value=='' ? 'none' : 'initial';})(this)">
|
||||
<button id='uploadbin' class="h">Submit</button>
|
||||
<a href='http://192.168.4.1' target='_blank'><small>* Upload may not function inside captive portal, Open in browser - http://192.168.4.1</a></small>
|
||||
<!-- /FORM_UPLOAD -->
|
||||
|
||||
|
||||
<!-- FORM_EXTRAS -->
|
||||
<br/><br/><br/><hr>
|
||||
<br/>
|
||||
<label for='custom'>Label for Custom Param</label>
|
||||
<br/>
|
||||
<input id='custom' name='custom' length='255' placeholder='placeholder' value='' {c}>
|
||||
<br/>
|
||||
|
||||
<!-- INOUT CHECKBOX -->
|
||||
<!-- <label for='input_checkbox'>Label for Input Checkbox</label> -->
|
||||
<input id='input_checkbox' name='input_checkbox' placeholder='placeholder' value='' type="checkbox" {c}>
|
||||
<label for='input_checkbox'>Label for Input Checkbox</label>
|
||||
<br/>
|
||||
|
||||
<!-- INPUT CHOICE -->
|
||||
<p>Select Choice</p>
|
||||
<input style='display: inline-block;' type='radio' id='choice1' name='program_selection' value='1'>
|
||||
<label for='choice1'>Choice1</label><br>
|
||||
<input style='display: inline-block;' type='radio' id='choice2' name='program_selection' value='2'>
|
||||
<label for='choice2'>Choice2</label><br>
|
||||
|
||||
<!-- INPUT SELECT -->
|
||||
<br/>
|
||||
<label for='input_select'>Label for Input Select</label>
|
||||
<select name="input_select" id="input_select" class="button">
|
||||
<option value="0">Option 1</option>
|
||||
<option value="1" selected>Option 2</option>
|
||||
<option value="2">Option 3</option>
|
||||
<option value="3">Option 4</option>
|
||||
</select>
|
||||
|
||||
</form>
|
||||
|
||||
<!-- /FORM_EXTRAS -->
|
||||
|
||||
<!-- HTTP_END -->
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<!-- /HTTP_END -->
|
||||
@@ -1,60 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
console.log('starting');
|
||||
|
||||
const inFile = 'WiFiManager.template.html';
|
||||
const outFile = 'template.h';
|
||||
|
||||
const defineRegEx = /<!-- ([A-Z_]+) -->/gm;
|
||||
console.log('parsing', inFile);
|
||||
|
||||
fs.readFile(inFile, 'utf8', function (err,data) {
|
||||
if (err) {
|
||||
return console.log(err);
|
||||
}
|
||||
//console.log(data);
|
||||
|
||||
let defines = data.match(defineRegEx);
|
||||
|
||||
//console.log(defines);
|
||||
var stream = fs.createWriteStream(outFile);
|
||||
stream.once('open', function(fd) {
|
||||
for (const i in defines) {
|
||||
|
||||
const start = defines[i];
|
||||
const end = start.replace('<!-- ', '<!-- /')
|
||||
defineRegEx.lastIndex = 0;
|
||||
const constantName = defineRegEx.exec(start)[1];
|
||||
|
||||
console.log(constantName);
|
||||
var extractRE = new RegExp(start + '([\\s\\S]+)' + end, 'gm');
|
||||
let extractArray = extractRE.exec(data);
|
||||
if(extractArray.length > 1) {
|
||||
let def = extractArray[1];
|
||||
//console.log(def);
|
||||
//minimise a bit
|
||||
def = def.replace(/\s+/g, ' ');
|
||||
def = def.replace(/>\s+</g, '><');
|
||||
def = def.trim();
|
||||
//more extraneous spaces - possible bad results, needs to be checked
|
||||
//def = def.replace(/(\w)\s(\W)|(\W)\s(\w)|(\W)\s(\W)/g, '$1$2$3$4$5$6');
|
||||
def = def.replace(/(\w)\s(\W)|(\W)\s(\w)/g, '$1$2$3$4');
|
||||
//escape double quotes
|
||||
def = def.replace(/\\([\s\S])|(")/g, "\\$1$2");
|
||||
|
||||
|
||||
console.log(def);
|
||||
//const char HTTP_HEAD[] PROGMEM =
|
||||
let string = 'const char ' + constantName + '[] PROGMEM';
|
||||
for (let i = string.length; i < 42; i++) {
|
||||
string += ' ';
|
||||
}
|
||||
string += '= "' + def + '";\n';
|
||||
stream.write(string);
|
||||
}
|
||||
}
|
||||
stream.end();
|
||||
});
|
||||
});
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 58 KiB |
@@ -1,12 +0,0 @@
|
||||
const char HTTP_HEAD[] PROGMEM = "<!DOCTYPE html><html lang=\"en\"><head><meta name=\"viewport\"content=\"width=device-width,initial-scale=1,user-scalable=no\"/><title>{v}</title>";
|
||||
const char HTTP_STYLE[] PROGMEM = "<style> .c{text-align:center;}div,input{padding:5px;font-size:1em;}input{width:95%;}body{text-align:center;font-family:verdana;}button{border:0;border-radius:0.3rem;background-color:#1fa3ec;color:#fff;line-height:2.4rem;font-size:1.2rem;width:100%;} .q{float:right;width:64px;text-align:right;} .l{background:url(\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAALVBMVEX///8EBwfBwsLw8PAzNjaCg4NTVVUjJiZDRUUUFxdiZGSho6OSk5Pg4eFydHTCjaf3AAAAZElEQVQ4je2NSw7AIAhEBamKn97/uMXEGBvozkWb9C2Zx4xzWykBhFAeYp9gkLyZE0zIMno9n4g19hmdY39scwqVkOXaxph0ZCXQcqxSpgQpONa59wkRDOL93eAXvimwlbPbwwVAegLS1HGfZAAAAABJRU5ErkJggg==\")no-repeat left center;background-size:1em;} </style>";
|
||||
const char HTTP_SCRIPT[] PROGMEM = "<script>function c(l){document.getElementById('s').value=l.innerText||l.textContent;document.getElementById('p').focus();} </script>";
|
||||
const char HTTP_HEAD_END[] PROGMEM = "</head><body><div style=\"text-align:left;display:inline-block;min-width:260px;\">";
|
||||
const char HTTP_PORTAL_OPTIONS[] PROGMEM = "<form action=\"/wifi\"method=\"get\"><button>Configure WiFi</button></form><br/><form action=\"/0wifi\"method=\"get\"><button>Configure WiFi(No Scan)</button></form><br/><form action=\"/i\"method=\"get\"><button>Info</button></form><br/><form action=\"/r\"method=\"post\"><button>Reset</button></form>";
|
||||
const char HTTP_ITEM[] PROGMEM = "<div><a href='#p'onclick='c(this)'>{v}</a> <span class='q{i}'>{r}%</span></div>";
|
||||
const char HTTP_FORM_START[] PROGMEM = "<form method='get'action='wifisave'><input id='s'name='s'length=32 placeholder='SSID'><br/><input id='p'name='p'length=64 type='password'placeholder='password'><br/>";
|
||||
const char HTTP_FORM_PARAM[] PROGMEM = "<br/><input id='{i}'name='{n}'length={l}placeholder='{p}'value='{v}' {c}>";
|
||||
const char HTTP_FORM_END[] PROGMEM = "<br/><button type='submit'>save</button></form>";
|
||||
const char HTTP_SCAN_LINK[] PROGMEM = "<br/><div class=\"c\"><a href=\"/wifi\">Scan</a></div>";
|
||||
const char HTTP_SAVED[] PROGMEM = "<div>Credentials Saved<br/>Trying to connect ESP to network.<br/>If it fails reconnect to AP to try again</div>";
|
||||
const char HTTP_END[] PROGMEM = "</div></body></html>";
|
||||
@@ -1,182 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
|
||||
<title>Config ESP</title>
|
||||
<script>
|
||||
|
||||
function c(l,e) {
|
||||
console.log(l);
|
||||
// preventDefault();
|
||||
document.getElementById('s').value = l.innerText || l.textContent;
|
||||
// document.location.href = document.location +"#wmform";
|
||||
p = l.nextElementSibling.classList.contains("l");
|
||||
document.getElementById('p').disabled = !p;
|
||||
if(p)document.getElementById('p').focus();
|
||||
return false;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.c,
|
||||
body {
|
||||
text-align: center
|
||||
}
|
||||
|
||||
div,
|
||||
input {
|
||||
padding: 5px;
|
||||
font-size: 1em
|
||||
}
|
||||
|
||||
input {
|
||||
width: 95%
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: verdana
|
||||
}
|
||||
|
||||
button {
|
||||
border: 0;
|
||||
border-radius: .3rem;
|
||||
background-color: #1fa3ec;
|
||||
color: #fff;
|
||||
line-height: 2.4rem;
|
||||
font-size: 1.2rem;
|
||||
width: 100%
|
||||
}
|
||||
|
||||
a {
|
||||
color: #000;
|
||||
font-weight: 700;
|
||||
text-decoration: none
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #1fa3ec;
|
||||
text-decoration: underline
|
||||
}
|
||||
|
||||
.q {
|
||||
height: 16px;
|
||||
margin: 0;
|
||||
padding: 0 5px;
|
||||
text-align: right;
|
||||
min-width: 38px
|
||||
}
|
||||
|
||||
.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
|
||||
}
|
||||
|
||||
.qr .q {
|
||||
float: right
|
||||
}
|
||||
|
||||
.qinv .q {
|
||||
-webkit-filter: invert(1);
|
||||
filter: invert(1)
|
||||
}
|
||||
|
||||
.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=');
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
input:disabled {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- classes, left/right invert -->
|
||||
<div class="qr" style='text-align:left;display:inline-block;min-width:260px;'>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 01</a><div role='img' aria-label='88%' title='88%' class='q q-4 l'></div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 02</a><div role='img' aria-label='88%' title='88%' class='q q-4'></div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 03</a><div role='img' aria-label='88%' title='88%' class='q q-3'></div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 04</a><div role='img' aria-label='88%' title='88%' class='q q-3'></div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 05</a><div role='img' aria-label='88%' title='88%' class='q q-3'></div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 06</a><div role='img' aria-label='88%' title='88%' class='q q-2'></div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 07</a><div role='img' aria-label='88%' title='88%' class='q q-2'></div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 08</a><div role='img' aria-label='88%' title='88%' class='q q-1'></div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 09</a><div role='img' aria-label='88%' title='88%' class='q q-1'></div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 10</a><div role='img' aria-label='88%' title='88%' class='q q-1'></div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 11</a><div role='img' aria-label='88%' title='88%' class='q q-0'></div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 12</a><div role='img' aria-label='88%' title='88%' class='q q-0'></div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 13</a><div role='img' aria-label='88%' title='88%' class='q q-0'></div></div>
|
||||
<div><a href='#p' onclick='c(this)'>Access Point 14</a><div role='img' aria-label='88%' title='88%' class='q q-0 l'></div></div>
|
||||
<br/>
|
||||
<form id="wmform" method='get' action='wifisave'>
|
||||
<input id='s' name='s' length=32 placeholder='SSID'>
|
||||
<br/>
|
||||
<input id='p' name='p' length=64 type='password' placeholder='password'>
|
||||
<br/>
|
||||
<br/>
|
||||
<input id='server' name='server' length=4 placeholder='mqtt server' value=''>
|
||||
<br/>
|
||||
<input id='port' name='port' length=5 placeholder='mqtt port' value='8080'>
|
||||
<br/>
|
||||
<input id='blynk' name='blynk' length=3 placeholder='blynk token' value='YOUR_BLYNK_TOKEN'>
|
||||
<br/>
|
||||
<br/>
|
||||
<input id='ip' name='ip' length=15 placeholder='Static IP' value='10.0.1.56'>
|
||||
<br/>
|
||||
<input id='gw' name='gw' length=15 placeholder='Static Gateway' value='10.0.1.1'>
|
||||
<br/>
|
||||
<input id='sn' name='sn' length=15 placeholder='Subnet' value='255.255.255.0'>
|
||||
<br/>
|
||||
<br/>
|
||||
<button type='submit'>save</button>
|
||||
</form>
|
||||
<br/>
|
||||
<div class="c"><a href="/wifi">Scan</a></div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -1,39 +0,0 @@
|
||||
#######################################
|
||||
# Syntax Coloring Map For WifiManager
|
||||
#######################################
|
||||
|
||||
#######################################
|
||||
# Datatypes (KEYWORD1)
|
||||
#######################################
|
||||
|
||||
WiFiManager KEYWORD1
|
||||
WiFiManagerParameter KEYWORD1
|
||||
|
||||
|
||||
#######################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
#######################################
|
||||
autoConnect KEYWORD2
|
||||
getSSID KEYWORD2
|
||||
getPassword KEYWORD2
|
||||
getConfigPortalSSID KEYWORD2
|
||||
resetSettings KEYWORD2
|
||||
setConfigPortalTimeout KEYWORD2
|
||||
setConnectTimeout KEYWORD2
|
||||
setDebugOutput KEYWORD2
|
||||
setMinimumSignalQuality KEYWORD2
|
||||
setAPStaticIPConfig KEYWORD2
|
||||
setSTAStaticIPConfig KEYWORD2
|
||||
setAPCallback KEYWORD2
|
||||
setSaveConfigCallback KEYWORD2
|
||||
addParameter KEYWORD2
|
||||
getID KEYWORD2
|
||||
getValue KEYWORD2
|
||||
getPlaceholder KEYWORD2
|
||||
getValueLength KEYWORD2
|
||||
|
||||
#######################################
|
||||
# Constants (LITERAL1)
|
||||
#######################################
|
||||
|
||||
# LITERAL1
|
||||
@@ -1,29 +0,0 @@
|
||||
{
|
||||
"name": "WiFiManager",
|
||||
"version": "2.0.17",
|
||||
"keywords": "wifi,wi-fi,esp,esp8266,esp32,espressif8266,espressif32,nodemcu,wemos,arduino",
|
||||
"description": "WiFi Configuration manager with web configuration portal for ESP boards",
|
||||
"authors":
|
||||
[
|
||||
{
|
||||
"name": "tzapu",
|
||||
"url": "https://github.com/tzapu"
|
||||
},
|
||||
{
|
||||
"name": "tablatronix",
|
||||
"url": "https://github.com/tablatronix",
|
||||
"maintainer": true
|
||||
}
|
||||
],
|
||||
"repository":
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/tzapu/WiFiManager.git"
|
||||
},
|
||||
"frameworks": "arduino",
|
||||
"platforms":
|
||||
[
|
||||
"espressif8266",
|
||||
"espressif32"
|
||||
]
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
name=WiFiManager
|
||||
version=2.0.17
|
||||
author=tzapu
|
||||
maintainer=tablatronix
|
||||
sentence=WiFi Configuration manager with web configuration portal for Espressif ESPx boards, by tzapu
|
||||
paragraph=Library for configuring ESP8266/ESP32 modules WiFi credentials and custom parameters at runtime with captive portal.
|
||||
category=Communication
|
||||
url=https://github.com/tzapu/WiFiManager.git
|
||||
architectures=esp8266,esp32
|
||||
@@ -1,15 +0,0 @@
|
||||
/**
|
||||
* Contents of this file have moved to 2 new locations
|
||||
* wm_strings_nn.h
|
||||
* wm_consts_nn.h
|
||||
*/
|
||||
|
||||
#warning "This file is deprecated"
|
||||
|
||||
#ifndef _STRINGS_EN_H_
|
||||
#define _STRINGS_EN_H_
|
||||
|
||||
// strings files must include a consts file!
|
||||
#include "wm_strings_en.h" // include constants, tokens, routes
|
||||
|
||||
#endif
|
||||
@@ -1,60 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
function build_examples()
|
||||
{
|
||||
excludes=("$@")
|
||||
# track the exit code for this platform
|
||||
local exit_code=0
|
||||
# loop through results and add them to the array
|
||||
examples=($(find $PWD/examples/ -name "*.pde" -o -name "*.ino"))
|
||||
|
||||
# get the last example in the array
|
||||
local last="${examples[@]:(-1)}"
|
||||
|
||||
# loop through example sketches
|
||||
for example in "${examples[@]}"; do
|
||||
|
||||
# store the full path to the example's sketch directory
|
||||
local example_dir=$(dirname $example)
|
||||
|
||||
# store the filename for the example without the path
|
||||
local example_file=$(basename $example)
|
||||
|
||||
# skip files listed as excludes
|
||||
for exclude in "${excludes[@]}"; do
|
||||
if [ "${example_file}" == "${exclude}" ] ; then
|
||||
echo ">>>>>>>>>>>>>>>>>>>>>>>> Skipping ${example_file} <<<<<<<<<<<<<<<<<<<<<<<<<<"
|
||||
continue 2
|
||||
fi
|
||||
done
|
||||
|
||||
echo "$example_file: "
|
||||
local sketch="$example_dir/$example_file"
|
||||
echo "$sketch"
|
||||
#arduino -v --verbose-build --verify $sketch
|
||||
|
||||
# verify the example, and save stdout & stderr to a variable
|
||||
# we have to avoid reading the exit code of local:
|
||||
# "when declaring a local variable in a function, the local acts as a command in its own right"
|
||||
local build_stdout
|
||||
build_stdout=$(arduino --verify $sketch 2>&1)
|
||||
|
||||
# echo output if the build failed
|
||||
if [ $? -ne 0 ]; then
|
||||
# heavy X
|
||||
echo -e "\xe2\x9c\x96"
|
||||
echo -e "----------------------------- DEBUG OUTPUT -----------------------------\n"
|
||||
echo "$build_stdout"
|
||||
echo -e "\n------------------------------------------------------------------------\n"
|
||||
|
||||
# mark as fail
|
||||
exit_code=1
|
||||
|
||||
else
|
||||
# heavy checkmark
|
||||
echo -e "\xe2\x9c\x93"
|
||||
fi
|
||||
done
|
||||
|
||||
return $exit_code
|
||||
}
|
||||
@@ -1,265 +0,0 @@
|
||||
/**
|
||||
* 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.17";
|
||||
|
||||
static const char _wifi_token[] PROGMEM = "wifi";
|
||||
static const char _wifinoscan_token[] PROGMEM = "wifinoscan";
|
||||
static const char _info_token[] PROGMEM = "info";
|
||||
static const char _param_token[] PROGMEM = "param";
|
||||
static const char _close_token[] PROGMEM = "close";
|
||||
static const char _restart_token[] PROGMEM = "restart";
|
||||
static const char _exit_token[] PROGMEM = "exit";
|
||||
static const char _erase_token[] PROGMEM = "erase";
|
||||
static const char _update_token[] PROGMEM = "update";
|
||||
static const char _sep_token[] PROGMEM = "sep";
|
||||
static const char _custom_token[] PROGMEM = "custom";
|
||||
static PGM_P _menutokens[] PROGMEM = {
|
||||
_wifi_token,
|
||||
_wifinoscan_token,
|
||||
_info_token,
|
||||
_param_token,
|
||||
_close_token,
|
||||
_restart_token,
|
||||
_exit_token,
|
||||
_erase_token,
|
||||
_update_token,
|
||||
_sep_token,
|
||||
_custom_token
|
||||
};
|
||||
const uint8_t _nummenutokens = (sizeof(_menutokens) / sizeof(PGM_P));
|
||||
|
||||
|
||||
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
|
||||
@@ -1,275 +0,0 @@
|
||||
/**
|
||||
* 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' id='showpass' onclick='f()'> <label for='showpass'>Show Password</label><br/>";
|
||||
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
|
||||
@@ -1,282 +0,0 @@
|
||||
/**
|
||||
* SAMPLE SAMPLE SAMPLE
|
||||
*
|
||||
* wm_strings_es.h
|
||||
* spanish strings for
|
||||
* WiFiManager, a library for the ESPX/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_
|
||||
|
||||
|
||||
/**
|
||||
* ADD TO BUILD FLAGS
|
||||
* -DWM_STRINGS_FILE="\"wm_strings_es.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!
|
||||
// Copy and change to custom locale tokens if necessary, but strings should be good enough
|
||||
#include "wm_consts_en.h" // include constants, tokens, routes
|
||||
|
||||
const char WM_LANGUAGE[] PROGMEM = "es-ES"; // 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>Configurar WiFi</button></form><br/>\n", // MENU_WIFI
|
||||
"<form action='/0wifi' method='get'><button>Configurar WiFi (sin escanear)</button></form><br/>\n", // MENU_WIFINOSCAN
|
||||
"<form action='/info' method='get'><button>Información</button></form><br/>\n", // MENU_INFO
|
||||
"<form action='/param' method='get'><button>Configuración</button></form><br/>\n",//MENU_PARAM
|
||||
"<form action='/close' method='get'><button>Cerca</button></form><br/>\n", // MENU_CLOSE
|
||||
"<form action='/restart' method='get'><button>Reanudar</button></form><br/>\n",// MENU_RESTART
|
||||
"<form action='/exit' method='get'><button>Salida</button></form><br/>\n", // MENU_EXIT
|
||||
"<form action='/erase' method='get'><button class='D'>Borrar</button></form><br/>\n", // MENU_ERASE
|
||||
"<form action='/update' method='get'><button>Actualizer</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'>Contraseña</label><input id='p' name='p' maxlength='64' type='password' placeholder='{p}'><input type='checkbox' onclick='f()'> Mostrar contraseña";
|
||||
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>Actualizer</button></form>";
|
||||
const char HTTP_BACKBTN[] PROGMEM = "<hr><br/><form action='/' method='get'><button>Atrás</button></form>";
|
||||
|
||||
const char HTTP_STATUS_ON[] PROGMEM = "<div class='msg S'><strong>Conectado</strong> a {v}<br/><em><small>con IP {i}</small></em></div>";
|
||||
const char HTTP_STATUS_OFF[] PROGMEM = "<div class='msg {c}'><strong>No conectado</strong> a {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/>No Encontrado"; // WL_NO_SSID_AVAIL
|
||||
const char HTTP_STATUS_OFFFAIL[] PROGMEM = "<br/>No se pudo conectar"; // WL_CONNECT_FAILED
|
||||
const char HTTP_STATUS_NONE[] PROGMEM = "<div class='msg'>Sin AP establecido</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,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 = "--------------------";
|
||||
|
||||
|
||||
// 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
|
||||
Reference in New Issue
Block a user