I'm using an ESP8266 web server. I'm creating a Wifi AP and I use a web server to host a website that I want to access from my mobile phone's browser:
void wifi::access_point::begin() {
WiFi.mode(WIFI_AP_STA);
WiFi.softAPConfig(ap_ip, ap_gateway, ap_subnet);
WiFi.softAP(ap_ssid, ap_password);
server.on ( "/", [this]() {
handle_root();
});
server.on( "/submit", [this]() {
handle_submit();
});
server.begin();
dns_server.start(dns_port, "my_wifi_config.com", ap_ip);
}
void wifi::access_point::handle_root() {
char html[1000];
snprintf (html, 1000,
"<html>\
<head>\
<title>Wifi Configuration</title>\
<style>\
body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; font-size: 1.5em; Color: #000000; }\
h1 { Color: #AA0000; }\
</style>\
</head>\
<body>\
<center>\
<h1>Wifi Configuration</h1>\
<form action='/submit' method='POST'>\
<p> Wifi SSID: </p>\
<input type='text' name='ssid'>\
<p> Wifi password: <\p>\
<input type='text' name='password'>\
<br>\
<input type='submit' name='Submit'>\
</form>\
</center>\
</body>\
</html>"
);
server.send(200, "text/html", html);
}
From my desktop I can connect to the AP and access the ap_ip and everything works fine. In my phone I can also connect to the WiFi AP, but if I'm connected to the mobile network the browser doesn't load the website, it says "web page not found". If it turn it off, the website loads fine.
I would need to be able to load the website hosted by my ESP8266 web server without having to turn off my mobile data. Any idea why this is happening and how could I avoid this problem?