None respons from server->args() with WiFiManager.h
Posted: Tue Apr 11, 2017 7:03 am
I have a sketch and it starts up fine but I get no respons on server->args()
What am I doing wrong
And the output when I press a button
What am I doing wrong
Code: Select all
#include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino
//needed for library
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
#include <ESP8266WiFi.h> //https://github.com/esp8266/Arduino
ESP8266WebServer server(80);
void handleWebsite();
void buildWebsite();
String webSite;
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();
//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.reset();
delay(5000);
}
//if you get here you have connected to the WiFi
Serial.println("connected...yeey :)");
Serial.println("local ip");
Serial.println(WiFi.localIP());
server.on("/", handleWebsite);
server.begin();
}
void loop() {
server.handleClient();
}
void buildWebsite(){
webSite = "<!DOCTYPE HTML>\n";
webSite += "<html><form method='get' action=''>";
webSite += "<input type='submit' value='1_On'> <input type='submit' value='1_Off'>";
webSite += "";
webSite += "</form>";
webSite += "";
webSite += "</HTML>\n";
}
void handleWebsite() {
Serial.println(" Load page ");
Serial.println(server.args());
if (server.args() > 0 ) {
for ( uint8_t i = 0; i < server.args(); i++ ) {
Serial.println(server.argName(i));
}
}
buildWebsite();
server.send(200, "text/html", webSite);
}
And the output when I press a button
Code: Select all
load 0x4010f000, len 1264, room
*WM:
*WM: AutoConnect
*WM: Connecting as wifi client...
*WM: Using last saved values, should be faster
*WM: Connection result:
*WM: 3
*WM: IP Address:
*WM: 192.168.1.167
connected...yeey :)
local ip
192.168.1.167
Load page
0
Load page
0
Load page
0