tgr8db:
(The reason I want GET)
Why? POST is the way to go when sending data over to the server?
If you want low latency, I'd suggest you use WebSockets. (It keeps the connection open, with GET or POST, you need to establish a new connection everytime you send a message, which is slow).
From what I read online, it is perfectly possible to use WebSockets with Unreal Engine 4. Receiving WebSockets, and running a WebSocket server on the ESP8266 is quite easy as well, using this library.
With that out of the way, I'll try to explain how it works:
ESP8266WebServer server(80);
This line creates a web server on port 80. This means that your browser can connect on this port and send HTTP requests, to get a webpage, for example.
server.on("/",HTTP_GET, webpage);
server.begin();
Here we add a handler for "/", meaning that if the server gets a GET request for the address "/" (root), the function 'webpage' is executed.
After that, we start the server, so it can start taking requests.
void webpage() {
server.send(200, "text/html", "<html><body><form name='frm' method='post'><input type='text' name='x' ><input type='submit' value='Submit'> </form></body></html>");
}
This is that handler function that is executed when GET "/" is requested.
The server sends a HTTP 200 status code, meaning that everything is ok, it understood the request, and knows what to send back. Then we say that we are going to send HTML (HyperText Markup Language, the language webpages are written in), and finally, we send the actual HTML.
The browser will then receive this response, and display the webpage.
The browser can also add parameters (arguments) to the URL, e.g. "/?fw=10.3&lr=2.8"
To get the value for these parameters, we can use
char * fw = server.arg("fw");
But first we want to check whether or not the browser added these parameters, we can check that using
if(server.hasArg("fw")){
String fw = server.arg("fw");
}
Finally, we can convert this string of characters to a floating point number, using the 'toFloat()' function
if(server.hasArg("fw")){
String fw = server.arg("fw");
float forward = fw.toFloat();
}
if(server.hasArg("lr")){
String lr = server.arg("lr");
float left_right= lr.toFloat();
}
Then you can use that value to drive your motors.
I only mentioned the browser as a client, but this can be pretty much any modern application.