Giter VIP home page Giter VIP logo

Comments (5)

cotestatnt avatar cotestatnt commented on May 30, 2024

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.

Nickhofr avatar Nickhofr commented on May 30, 2024

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.

Nickhofr avatar Nickhofr commented on May 30, 2024

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.

Nickhofr avatar Nickhofr commented on May 30, 2024

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.

Nickhofr avatar Nickhofr commented on May 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.