update wifi manager
This commit is contained in:
@@ -13,7 +13,7 @@ void setup() {
|
||||
|
||||
// reset settings - wipe stored credentials for testing
|
||||
// these are stored by the esp library
|
||||
//wm.resetSettings();
|
||||
wm.resetSettings();
|
||||
|
||||
// Automatically connect using saved credentials,
|
||||
// if connection fails, it starts an access point with the specified name ( "AutoConnectAP"),
|
||||
|
||||
@@ -23,7 +23,6 @@ WiFiManager wm;
|
||||
|
||||
|
||||
// TEST OPTION FLAGS
|
||||
bool TEST_CP = false; // always start the configportal, even if ap found
|
||||
bool TEST_CP = true; // always start the configportal, even if ap found
|
||||
int TESP_CP_TIMEOUT = 90; // test cp timeout
|
||||
|
||||
@@ -66,7 +65,7 @@ void handleRoute(){
|
||||
}
|
||||
|
||||
void setup() {
|
||||
WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
|
||||
// WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
|
||||
|
||||
// put your setup code here, to run once:
|
||||
Serial.begin(115200);
|
||||
@@ -91,6 +90,7 @@ void setup() {
|
||||
// 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);
|
||||
@@ -144,6 +144,14 @@ void setup() {
|
||||
custom_html.setValue("test",4);
|
||||
custom_token.setValue("test",4);
|
||||
|
||||
// set custom html head content , inside <head>
|
||||
const char* headhtml = "<meta name='color-scheme' content='dark light'><style></style><script></script>";
|
||||
wm.setCustomHeadElement(headhtml);
|
||||
|
||||
// set custom html menu content , inside <head>
|
||||
const char* menuhtml = "<form action='/custom' method='get'><button>Custom</button></form><br/>\n";
|
||||
wm.setCustomMenuHTML(menuhtml);
|
||||
|
||||
// invert theme, dark
|
||||
wm.setDarkMode(true);
|
||||
|
||||
@@ -156,7 +164,7 @@ void setup() {
|
||||
wm.setMenu(menu,9); // custom menu array must provide length
|
||||
*/
|
||||
|
||||
std::vector<const char *> menu = {"wifi","wifinoscan","info","param","close","sep","erase","update","restart","exit"};
|
||||
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!
|
||||
@@ -235,6 +243,9 @@ void setup() {
|
||||
|
||||
wifiInfo();
|
||||
|
||||
// to preload autoconnect with credentials
|
||||
// wm.preloadWiFi("ssid","password");
|
||||
|
||||
if(!wm.autoConnect("WM_AutoConnectAP","12345678")) {
|
||||
Serial.println("failed to connect and hit timeout");
|
||||
}
|
||||
@@ -243,7 +254,7 @@ void setup() {
|
||||
delay(1000);
|
||||
Serial.println("TEST_CP ENABLED");
|
||||
wm.setConfigPortalTimeout(TESP_CP_TIMEOUT);
|
||||
wm.startConfigPortal("WM_ConnectAP");
|
||||
wm.startConfigPortal("WM_ConnectAP","12345678");
|
||||
}
|
||||
else {
|
||||
//if you get here you have connected to the WiFi
|
||||
@@ -260,10 +271,11 @@ void setup() {
|
||||
}
|
||||
|
||||
void wifiInfo(){
|
||||
WiFi.printDiag(Serial);
|
||||
Serial.println("SAVED: " + (String)wm.getWiFiIsSaved() ? "YES" : "NO");
|
||||
Serial.println("SSID: " + (String)wm.getWiFiSSID());
|
||||
Serial.println("PASS: " + (String)wm.getWiFiPass());
|
||||
Serial.println("[WIFI] WIFI INFO DEBUG");
|
||||
// WiFi.printDiag(Serial);
|
||||
Serial.println("[WIFI] SAVED: " + (String)(wm.getWiFiIsSaved() ? "YES" : "NO"));
|
||||
Serial.println("[WIFI] SSID: " + (String)wm.getWiFiSSID());
|
||||
Serial.println("[WIFI] PASS: " + (String)wm.getWiFiPass());
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
Reference in New Issue
Block a user