Description
Hardware:
Board: esp32doit-devkit-v1
IDE name: Platform.io
Flash Frequency: 80Mhz
Upload Speed: 115200
Computer OS: Mac OSX
Description:
I'm trying to deliver a website for configuration of ssid/password. The site contains several js/css/ajax calls. Everything works flawlessly when using it in Chrome. When using it in Safari (ios or macos) the board stops answering when reloading the site (second or third time, not deterministic).
To serve the site I was trying ESPAsyncWebServer and my own little webserver (essentially a pool of WiFiClients). Every solution shows the same results.
So my question is, who to debug this problem?
The sketch I'm providing shows the symptoms. I know I could scan the networks async and then it would work in this little sketch. But doing it sync was the only way I found to demonstrate the problem. In the real application the scan is done async, but the symptoms remain.
Sketch:
#include <Arduino.h>
#include <ESPAsyncWebServer.h>
#include <SPIFFS.h>
AsyncWebServer server(80);
const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASSWORD";
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
SPIFFS.begin();
if (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.printf("WiFi Failed!\n");
return;
}
Serial.print("IP Address: "); Serial.println(WiFi.localIP());
server.serveStatic("/", SPIFFS, "/").setDefaultFile("index.htm");
server.on("/getNetworkDetails", HTTP_GET, [](AsyncWebServerRequest *request){
String result = "Network details: ";
result += WiFi.SSID() + "/" + WiFi.getHostname();
request->send(200, "plain/text", result);
});
server.on("/getNetworks", HTTP_GET, [](AsyncWebServerRequest *request){
String result = "Found networks: ";
result += WiFi.scanNetworks();
request->send(200, "plain/text", result);
});
server.begin();
}
void loop() {
}
index.htm:
<html>
<body>
<div>
ESP TEST
</div>
<div id="networkDetails">loading network details ...</div>
<div id="networks">loading number of networks ...</div>
<script>
document.addEventListener("DOMContentLoaded", function(event) {
var xhr1 = new XMLHttpRequest();
xhr1.open('GET', 'getNetworkDetails');
xhr1.onload = function() {
document.getElementById("networkDetails").innerHTML = xhr1.responseText;
};
xhr1.send();
var xhr2 = new XMLHttpRequest();
xhr2.open('GET', 'getNetworks');
xhr2.onload = function() {
document.getElementById("networks").innerHTML = xhr2.responseText;
};
xhr2.send();
});
</script>
</body>
</html>
Debug Messages:
There are no error messages, even when setting debug level on verbose.