Shivank wrote:I would like to understand the working of WifiManager.h library. What should I do?
How should I begin?
I suggest (yes really, just to understand things better) to remove the WifiManager from the sketch for now.
The WifiManager is a clever (and handy) way of settings the WiFi-properties (AP to connect to, complete with password) of your ESP, without having to hardcode these parameters in your sketch and having them stored in EEPROM.
For a short explanation, see this YouTube-clip of Brian Lough.
But, to start at the beginning, first use the default (and old) way of setting your WiFi-connection using hardcoded constants inside your sketch.
So, your sketch (derived from the one by TS) will look something like this:
#include <ESP8266WiFi.h>
WiFiServer server(4998);
WiFiClient client;
const char* ssid = "Astrid"; // Change SSID and password to your environment
const char* password = "MySecretPassword";
char data[1500];
int ind = 0;
void setup() {
Serial.begin(115200);
Serial.print("Trying to connect to: ");
Serial.println(ssid);
WiFi.begin(ssid, password);
server.begin();
Serial.println("Server started");
Serial.setDebugOutput(true);
}
void loop() {
if(!client.connected())
{
client = server.available();
}
else
{
if(client.available() > 0)
{
while(client.available())
{
data[ind] = client.read();
ind++;
}
client.flush();
for(int j=0;j < ind; j++)
{
Serial.print(data[j]);
}
ind = 0;
}
}
}
Note: before compiling this sketch, make sure you enter the correct SSID and password for your setup (the const char*'s in lines 6 and 7).
Once you got the hang of things, you can use things like the WiFiManager and it will all become clear.