Arduino ESP8266显示收到的http响应
我正在使用ESP8266模块。我已经成功地创建了一个草图,它向我的本地服务器发送一个HTTP请求。服务器发送响应,但是,我无法在Arduino IDE的串行监视器中显示它。我在互联网上找不到任何地方,如何显示收到的信息。我唯一能显示的是整个GET请求 甚至可以从服务器获取、解析和显示响应吗?如果是的话,谁能提供一个代码示例Arduino ESP8266显示收到的http响应,arduino,esp8266,Arduino,Esp8266,我正在使用ESP8266模块。我已经成功地创建了一个草图,它向我的本地服务器发送一个HTTP请求。服务器发送响应,但是,我无法在Arduino IDE的串行监视器中显示它。我在互联网上找不到任何地方,如何显示收到的信息。我唯一能显示的是整个GET请求 甚至可以从服务器获取、解析和显示响应吗?如果是的话,谁能提供一个代码示例 HTTPClient http; USE_SERIAL.print("[HTTP] begin...\n"); // con
HTTPClient http;
USE_SERIAL.print("[HTTP] begin...\n");
// configure traged server and url
//http.begin("https://192.168.1.12/test.html", "7a 9c f4 db 40 d3 62 5a 6e 21 bc 5c cc 66 c8 3e a1 45 59 38"); //HTTPS
http.begin("http://192.168.1.12/test.html"); //HTTP
USE_SERIAL.print("[HTTP] GET...\n");
// start connection and send HTTP header
int httpCode = http.GET();
// httpCode will be negative on error
if(httpCode) {
// HTTP header has been send and Server response header has been handled
USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode);
// file found at server
if(httpCode == HTTP_CODE_OK) {
String payload = http.getString();
// print only part of the string
USE_SERIAL.println(payload.substring(0,200));
}
} else {
USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end();
那对你有用吗?
关键是:有效载荷。子串(0200)
嗯