It's kinda the Windows Browser is waiting for more Data and stucks while loading.
Here is the sample Code:
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <SPI.h>
#include <SD.h>
#include <mcp_can.h>
#define DBG_OUTPUT_PORT Serial
const char *ssid = "Heisenberg";
const char *password = "Heisenberg";
IPAddress ip(192, 168, 0, 1);
static bool hasSD = false;
ESP8266WebServer server(80);
MCP_CAN CAN0(D2);
void setup() {
//Serielle Schnittstelle einstellen
Serial.begin(115200);
Serial.println("Serielle Schnittstelle initialisiert");
// WiFi einstellen
WiFi.mode(WIFI_AP);
// WiFi.mode(WIFI_AP_STA);
WiFi.softAP(ssid,password);
WiFi.softAPConfig(ip, ip, IPAddress(255, 0, 0, 0));
WiFi.setPhyMode(WIFI_PHY_MODE_11N);;
server.onNotFound(handleNotFound);
server.begin();
Serial.println("HTTP server initialisiert");
//SD-Card einstellen
if (SD.begin(SS)){
DBG_OUTPUT_PORT.println("SD Card initialisiert");
hasSD = true;
}
//CAN-Schnittstelle einstellen
if(CAN0.begin(CAN_500KBPS,MCP_8MHz) == CAN_OK) Serial.println("CAN initialisiert");
else Serial.println("CAN Fehler");
}
void loop() {
server.handleClient();
}
bool loadFromSdCard(String path){
String dataType = "text/plain";
if(path.endsWith("/")) path += "index.htm";
if(path.endsWith(".src")) path = path.substring(0, path.lastIndexOf("."));
else if(path.endsWith(".htm")) dataType = "text/html";
else if(path.endsWith(".css")) dataType = "text/css";
else if(path.endsWith(".js")) dataType = "application/javascript";
else if(path.endsWith(".png")) dataType = "image/png";
else if(path.endsWith(".gif")) dataType = "image/gif";
else if(path.endsWith(".jpg")) dataType = "image/jpeg";
else if(path.endsWith(".ico")) dataType = "image/x-icon";
else if(path.endsWith(".xml")) dataType = "text/xml";
else if(path.endsWith(".pdf")) dataType = "application/pdf";
else if(path.endsWith(".zip")) dataType = "application/zip";
File dataFile = SD.open(path.c_str());
if(dataFile.isDirectory()){
path += "/index.htm";
dataType = "text/html";
dataFile = SD.open(path.c_str());
}
if (!dataFile)
return false;
if (server.hasArg("download")) dataType = "application/octet-stream";
if (server.streamFile(dataFile, dataType) != dataFile.size()) {
DBG_OUTPUT_PORT.println("Sent less data than expected!");
}
dataFile.close();
return true;
}
void handleNotFound(){
// Send CAN message from POST
int16_t ID = strtol(server.arg("ID").c_str(), NULL, 16);
if(ID > 1)
{
unsigned char DATA[8] = {0, 1, 2, 3, 4, 5, 6, 7};
int8_t ML = strtol(server.arg("ML").c_str(), NULL, 16);
DATA[0] = strtol(server.arg("D1").c_str(), NULL, 16);
DATA[1] = strtol(server.arg("D2").c_str(), NULL, 16);
DATA[2] = strtol(server.arg("D3").c_str(), NULL, 16);
DATA[3] = strtol(server.arg("D4").c_str(), NULL, 16);
DATA[4] = strtol(server.arg("D5").c_str(), NULL, 16);
DATA[5] = strtol(server.arg("D6").c_str(), NULL, 16);
DATA[6] = strtol(server.arg("D7").c_str(), NULL, 16);
DATA[7] = strtol(server.arg("D8").c_str(), NULL, 16);
CAN0.sendMsgBuf(ID, 0, ML, DATA);
}
if(hasSD && loadFromSdCard(server.uri())) return;
String message = "SDCARD Not Detected\n\n";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET)?"GET":"POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i=0; i<server.args(); i++){
message += " NAME:"+server.argName(i) + "\n VALUE:" + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);
DBG_OUTPUT_PORT.print(message);
}