Here's the snippets where I think there could be a problem:
BssList accessPoints; // global variable for discovered access points
void listNetworks(bool succeeded, BssList list)
{
if (!succeeded)
{
debugf("Failed to scan networks");
return;
}
for (int i = 0; i < list.count(); i++)
{
Serial.print("\tWiFi: ");
Serial.print(list[i].ssid);
Serial.print(", ");
Serial.print(list[i].getAuthorizationMethodName());
if (list[i].hidden) Serial.print(" (hidden)");
Serial.println();
}
memcpy(&accessPoints, &list, sizeof(list));
}
void onAjaxAP(HttpRequest &request, HttpResponse &response)
{
JsonObjectStream* stream = new JsonObjectStream();
JsonObject& json = stream->getRoot();
JsonObject& ap= json.createNestedArray("ap");
for (int i = 0; i < accessPoint.count(); i++) {
ap.add(accessPoint[i].ssid);
}
response.sendJsonObject(stream);
}
The actual line that causes the reboot is:
ap.add(accessPoint[i].ssid);
accessPoints = list;