Comments (5)
Hi @Nickhofr
The function for connecting to WiFi is integrated into the setup page.
To do what you need you could simply make your own custom copy without verifying the password field and associate your function with the connection button by removing the default one.
For example:
- add this literal string to you project (it's simply the copy and paste of the function without checking the password) and at the bottom an instruction to change the association with the click of the button
static const char custom_wifi_conenction[] = R"literal_string(
function doConnectionCustom(e, f) {
console.log('This is password-less WiFi connection function');
if ($('ssid').value === ''){
openModalMessage('Connect to WiFi','Please insert a SSID');
return;
}
var formdata = new FormData();
formdata.append("ssid", $('ssid').value);
formdata.append("password", $('password').value);
formdata.append("persistent", $('persistent').checked);
if (typeof f !== 'undefined')
formdata.append("newSSID", true);
if ($('no-dhcp').checked) {
formdata.append("ip_address", $('ip').value);
formdata.append("gateway", $('gateway').value);
formdata.append("subnet", $('subnet').value);
}
var requestOptions = {
method: 'POST',
body: formdata,
redirect: 'follow'
};
$('loader').classList.remove('hide');
var s;
fetch('/connect', requestOptions)
.then(function(res) {
s = res.status;
return res.text();
})
.then(function(data) {
if (s === 200) {
if (data.includes("already")) {
openModalMessage('Connect to WiFi', data, () => {doConnection(e, true)});
$('loader').classList.add('hide');
}
else
openModalMessage('Connect to WiFi', data, restartESP);
}
else
openModalMessage('Error!', data);
$('loader').classList.add('hide');
})
.catch((error) => {
openModalMessage('Connect to WiFi', error);
$('loader').classList.add('hide');
});
}
// Associate the new function doConnectionCustom with the wifi connection button HTML element
$('connect-wifi').removeEventListener("click", doConnection);
$('connect-wifi').addEventListener("click", doConnectionCustom);
)literal_string";
- add this statement to your webserver before starting it
myWebServer.addJavascript(custom_wifi_conenction, "wifi");
from esp-fs-webserver.
Hi thank you I appreciate your help. Forgive me but this is a little new for me. Could you give me more of a step by step instructions. Which file to edit, where to put code? I see there are a number of files in the setup folder. TIA.
from esp-fs-webserver.
My persistence has payed off!
I was able to copy your code of the function doConnection and replace the code from the app.js file.
I followed the instructions from the readme.md file to run node minify.js in cmd.
The issue that took me a while to resolve was that the compiler made a "static const unsigned char SETUP_HTML[] PROGMEM =" in the setup_htm.h rather then "static const unsigned char _acsetup_min_htm[] =".
That resulted in an error when I tried sending the program to the esp32 in the arduino program.
Eventually I renamed the heading in the setup_htm.h. It worked. Connected to WIFI without having to issue a Password.
Huge thanks!
from esp-fs-webserver.
I would say my issue is now it won't store my SSID. Every time I restart my Esp32 It sets up an AP rather then connect to the last WIFI SSID that I connected to.
from esp-fs-webserver.
Hi can you help me this? I have tried a few things and can't get it to store my Wifi SSID.
from esp-fs-webserver.
Related Issues (20)
- Error run node minify.js to generate setup_htm.h HOT 3
- Feature Request : Add WiFi PEAP Auth HOT 2
- How to update variable value on custom html example? HOT 9
- Interface not working using reverse proxy (HTTPS and/or subdirectory) HOT 1
- Is possible to add more than one custom_html? HOT 1
- How to show json value to custom html page? HOT 1
- Add more supported editor files (for example like .yaml) HOT 3
- Difficult to load web-based configuration when the Wifi AP disappears for a long time after connected HOT 1
- Error compiling for board esp8266 HOT 2
- Disable Captive Portal?? HOT 2
- compilation error in platformio HOT 1
- What is the libraries need to use this library? HOT 4
- NO ISSUE, just question FILE DOWNLOAD ? HOT 28
- Problem with Options Box rename HOT 3
- Crash loading examples HOT 2
- can
- on version 2.0.2 ,the saveOption function does not take effect when used in loop. HOT 4
- Won't Store Wifi Credentials when Password is empty. HOT 4
- WDT exception
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp-fs-webserver.