I tried that a little while ago with an ESP12 hanging in an upstairs window connected to my home access point and opening up another network and running a simple webserver proxy which i connected to with my android phone to see how far away i could get. It went much further than i could see the home access point network. Here's a photo with how far it got. I think it would have got further if i could have kept line of sight but that was as far as i could go without a tree or something getting in the way.
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
const char* ssid = "BTHub5-72W5";
const char* password = "xxxxxxxxxx";
const char* newssid = "EspTest1";
const char* newpassword = "qaz12345";
const char* host = "data.sparkfun.com";
ESP8266WebServer server(80);
int count = 0;
void setup(void){
Serial.begin(115200);
Serial.println("");
// set both access point and station
WiFi.mode(WIFI_AP_STA);
WiFi.softAP(newssid, newpassword);
Serial.print(newssid);
Serial.print(" server ip: ");
Serial.println(WiFi.softAPIP());
server.on("/", handleRoot);
server.onNotFound(handleNotFound);
server.begin();
Serial.println("HTTP server started");
if (strcmp (WiFi.SSID(),ssid) != 0) {
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
}
while (WiFi.status() != WL_CONNECTED) {
yield();
}
Serial.print("Connected to: ");
Serial.print(WiFi.SSID());
Serial.print(", IP address: ");
Serial.println(WiFi.localIP());
}
void loop(void){
server.handleClient();
}
void handleRoot() {
Serial.print("handleRoot: ");
Serial.println(count);
String s = "request count: ";
s += ++count;
server.send(200, "text/plain", s);
}
void handleNotFound() {
Serial.print("proxy request to ");
Serial.println(host);
count++;
WiFiClient client;
while (!!!client.connect(host, 80)) {
Serial.println("connection failed, retrying...");
}
Serial.print("Requesting uri: ");
String requestUri = server.uri();
// TODO: an easier way to get the request url?
if (server.args() > 0) {
requestUri += "?";
for (int i=0; i<server.args(); i++) {
requestUri += server.argName(i);
requestUri += "=";
requestUri += server.arg(i);
if (i+1<server.args()) {
requestUri += "&";
}
}
}
Serial.println(requestUri);
client.print(String("GET ") + requestUri);
client.print(String(" HTTP/1.1\r\n") +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
while(!!!client.available()){
yield();
}
String response = "";
while(client.available()){
response += client.read();
}
server.send(200, "text/html", response);
client.stop();
}
So that connects to the internet via wifi access point BTHub5-72W5 and starts another access point with ssid EspTest1 password qaz12345, and runs a webserver with local ip 192.168.4.1 port 80 which redirects requests to the real data.sparkfun.com via the other access point.
So if you run that and then use a computer and connect to wifi EspTest1 and then go to http://192.168.4.1/input/Jxyjr7DmxwTD5d ... ewTemp=bla that will get redirected to the actual sparkfun test steam. Which you can check really worked by looking at https://data.sparkfun.com/streams/Jxyjr7DmxwTD5dG1D1Kv and you should see what you sent for "bla".