|
运行后串口报错:
运行is=0
读取返回数据开始
HTTP/1.1 200 OK
Access-Control-Allow-Origin: *
Content-Type: application/json; charset=UTF-8
Vary: Origin
Date: Sun, 23 Feb 2020 13:45:53 GMT
Content-Length: 69
Connection: close
{"data":[[{"a":33,"b":56,"c":66}]],"msg":"","result":true,"status":0}
ERROR:InvalidInput
没有连接到服务器
开始连接服务器
连接服务器2
运行is=0
帮看看源码、是哪里写错了?
//处理服务器信息
void Tcp_Handler(String &data ){
Serial.println("读取返回数据开始");
while (client.connected() || client.available())
{
if (client.available())
{
data+=client.readStringUntil('\r');
}
}
Serial.println(data);
StaticJsonDocument<256> doc;
DeserializationError err = deserializeJson(doc, data);
if (err){
Serial.print("ERROR:");
Serial.println(err.c_str());
return;
}
int le = doc["data"][0][0]["a"];
Serial.println(le);
Serial.println("应打33");
}
//loop如下
void loop() {
is=0;
delay(1000);
if(is==0){
Serial.println("运行is=0");
client.print("GET http://192.168.5.48:9090/api2/test2 HTTP/1.1\r\n" \
"Host:192.168.5.48\r\n" \
"Connection:close\r\n\r\n");
is=1;
};
String data = "";
Tcp_Handler(data); //读取服务器信息,并处理
}
}
|
|