tzapu / WiFiManager

ESP8266 WiFi Connection manager with web captive portal
http://tzapu.com/esp8266-wifi-connection-manager-library-arduino-ide/
MIT License
6.45k stars 1.94k forks source link

Custom page addition matching current layout and format #1719

Open letis009 opened 3 months ago

letis009 commented 3 months ago

Basic Infos

Awesome library guys. really is a lifesaver. Feature request maybe or just missing instructions. We looking to use CSS format set in Main and PARAMS, going to /custom presents a blank page with text, is there a method to use all the styles and scripts from index and params ?

I have already added backgrounds and icons to styling but do I need to duplicate the entire page in code again ?

Hardware

WiFimanager Branch/Release: Master

Esp8266/Esp32: ESP32c3

Hardware: Custom ESP32C3 board

Description

Problem description

Settings in IDE

Arduino Release v2.0.14 based on ESP-IDF v4.4.6

Module: esp32c3

Additional libraries:

Sketch

#BEGIN
#include <Arduino.h>
#include "WiFiManager.h"

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 handleRoute(){
  Serial.println("[HTTP] handle route");
  wm.server->send(200, "text/plain", "hello from user code");
}

void bindServerCallback(){
  wm.server->on("/custom",handleRoute); // this is now crashing esp32 for some reason
  // wm.server->on("/info",handleRoute); // you can override wm!
}
void setup() {
    wm.setWebServerCallback(bindServerCallback);
    wm.setCustomHeadElement(icon);
    wm.setCustomHeadElement(base64img);
    const char* menuhtml = "<form action='/custom' method='get'><button>Advanced</button></form><br/>\n";
    wm.setCustomMenuHTML(menuhtml);
    std::vector<const char *> menu = {"wifi", "update", "info", "param", "custom", "sep", "restart", "exit"};
    wm.setMenu(menu);
}

void loop() {

}
#END

Debug Messages

messages here