我是ESP8266的初学者,每隔1:30分钟就会得到异常(9),我不知道为什么;经过一些测试后,我发现下面的代码是问题所在,但不知道为什么
struct Schedule
{
int temperatureMin;
int temperatureMax;
bool manual;
const char* startTime;
int id;
int systemId;
const char* stopTime;
};
Schedule GetScheduleBySystem(int systemId)
{
Schedule sch;
http.begin(api+"/systems/"+systemId+"/schedule",fingerPrint); //Specify the URL
int httpCode = http.GET();
if (httpCode > 0) { //Check for the returning code
String payload = http.getString();
Serial.println(httpCode);
const size_t capacity = JSON_OBJECT_SIZE(7) + 238;
DynamicJsonBuffer jsonBuffer(capacity);
JsonObject& root = jsonBuffer.parseObject(payload);
sch.startTime = root["start"]; // "2019-12-02T21:51:00"
sch.temperatureMin = root["temperatureMin"]; // 22
sch.temperatureMax = root["temperatureMax"]; // 32
sch.manual = root["manual"]; // true
sch.id = root["id"];
sch.stopTime = root["stop"];
sch.systemId = root["systemId"];
}
else
{
Serial.println("Error on HTTP request");
}
http.end(); //Free the resources
return sch;
}发布于 2020-02-25 04:49:19
深入研究了一段时间后,发现问题来自这行代码'http.getString()‘。通过将ESP8266软件版本从2.6.3降级到2.5.2,我摆脱了这个例外。
https://stackoverflow.com/questions/59429043
复制相似问题