-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhttp_server.h
41 lines (33 loc) · 989 Bytes
/
http_server.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "m2_web_page.h"
// Create AsyncWebServer object on port 80
WebServer server(80);
void handleRoot(){
server.send(200, "text/html", index_html); //Send web page
}
void handleHorizontalDrag(){
server.send(200, "text/html", horizontal_drag_html); //Send web page
}
void handleVerticalDrag(){
server.send(200, "text/html", vertical_drag_html); //Send web page
}
void webCtrlServer(){
server.on("/", handleRoot);
server.on("/horiDrag", handleHorizontalDrag);
server.on("/vertDrag", handleVerticalDrag);
server.on("/js", [](){
String jsonCmdWebString = server.arg(0);
deserializeJson(jsonCmdReceive, jsonCmdWebString);
jsonCmdReceiveHandler();
serializeJson(jsonInfoHttp, jsonFeedbackWeb);
server.send(200, "text/plane", jsonFeedbackWeb);
jsonFeedbackWeb = "";
jsonInfoHttp.clear();
jsonCmdReceive.clear();
});
// Start server
server.begin();
Serial.println("Server Starts.");
}
void initHttpWebServer(){
webCtrlServer();
}