-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Closed
Description
Core Installation version: 1.0.4
IDE name: Arduino 1.8.9
Flash Frequency: 80MHz
PSRAM enabled: ?no? ?yes?
Upload Speed: 921600
Computer OS: Windows 7/64 pro
Browser: Firefox 77.0.1
Adafruit Feather ESP32
setup() code for wifiserver and webserver works fine on ESP8266 and appearently also is fine for ESP32, but then it crashes when creating the website.
What is wrong with the website code?
What is it not esp8266-compatible but crashes?
#include <WiFi.h>
#include <WebServer.h>
IPAddress this_ip(192, 168, 2, 201); //
IPAddress gateway(192, 168, 2, 1); // <<< LAN Gateway IP
IPAddress subnet(255, 255, 255, 0); // <<< LAN Subnet Mask
WiFiServer wifiserver(8080);
WebServer webserver(8081);
const char* ssid="ssss"; // WIFI network name
const char* password="pppp"; // WIFI network password
//...
void setup() {
Serial.begin(115200);
delay(1000);
//----------------------------------------
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.println("Connecting to WiFi: ");
Serial.println( WiFi.gatewayIP().toString() );
WiFi.mode(WIFI_STA);
WiFi.config(this_ip, gateway, subnet, gateway, gateway); // dns = gateway
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("WiFi connected: ");
Serial.println(WiFi.gatewayIP());
//----------------------------------------
wifiserver.begin();
Serial.println("WiFi Server started");
//----------------------------------------
webserver.on("/", handleRoot) ;
webserver.on("/client/client0/", handleClients);
delay(10);
webserver.begin();
Serial.println("ESP webserver started");
// Print the IP address
Serial.print("Use this URL to connect: ");
Serial.print("http://"); Serial.print(WiFi.localIP());
Serial.print(":"); Serial.print(8080);
Serial.println("/");
Serial.println((String)"myweb.sytes.net" + ":" + (String)(8080) + "/");
Serial.println("setup done ");
}
void loop() {
Serial.println("\nDEBUG:\n new loop");
static double ftmp;
static unsigned long tsec = millis(), tms = millis();
Serial.println("\nDEBUG:\n handleWebsite()");
handleWebsite(); // <<<<<<<<<<<<<<<<<<<<<<<<<< CRASH !!
Serial.println("\nDEBUG:\n webserver.handleClient()"); // <<<<<<<<<< not executed any more
webserver.handleClient();
//---------------------------------------
// Read local data
ftmp = -99;
//ftmp = bmp_x77.readTemperature();
//
}
void handleWebsite() {
WiFiClient client = wifiserver.available();
String request = client.readStringUntil('\r');
Serial.println(request);
client.flush();
String script = "";
script += ("HTTP/1.1 200 OK \n");
script += ("Content-Type: text/html \n");
script += ("\n");
script += ("<!DOCTYPE html> \n");
script += ("<html> \n");
// head + title
script += ("<head> \n");
// autom. Aktualisierung alle 20 sec.
script += "<meta http-equiv=\"refresh\" content=\"20; URL=";
script += (String)"myweb.sytes.net" + ":" + (String)(8080) + "\"> \n" ;
// utf-8 für "°" Zeichen
script += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> \n" ;
script += ("<title>");
script += "myweb.sytes.net";
script += ("</title> \n");
script += ("</head> \n");
// body + caption
script += ("<body> \n");
script += ("<h1> <p> ");
script += (String)"test" + " " + WiFi.localIP().toString() + " " + (String)ssid + " <br>" ;
script += "</p> </h1> \n";
script += "</body> \n";
script += "</html> \n";
script += ("<br> \n");
script += ("<br> \n");
client.print(script);
script = "";
delay(1);
}
void handleRoot() {;}
void handleClients() {;}
Connecting to WiFi:
0.0.0.0
.
WiFi connected: 192.168.2.1
WiFi Server started
ESP webserver started
Use this URL to connect: http://192.168.2.201:8080/
myweb.sytes.net:8080/
setup done
DEBUG:
new loop
DEBUG:
handleWebsite()
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x400d6ab4 PS : 0x00060630 A0 : 0x800d6b88 A1 : 0x3ffb1e10
A2 : 0x00000000 A3 : 0x3ffb1e5f A4 : 0x00000001 A5 : 0x00000001
A6 : 0x00060220 A7 : 0x00000000 A8 : 0x00000000 A9 : 0x00000000
A10 : 0x00000000 A11 : 0x00000080 A12 : 0x00000050 A13 : 0x00000001
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x0000000a EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000008 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffff9
Backtrace: 0x400d6ab4:0x3ffb1e10 0x400d6b85:0x3ffb1e30 0x4014ae16:0x3ffb1e50 0x400dbfb1:0x3ffb1e80 0x400dc049:0x3ffb1ea0 0x400d4491:0x3ffb1ec0 0x400d4827:0x3ffb1f80 0x400deac5:0x3ffb1fb0 0x400896d9:0x3ffb1fd0
Rebooting...
ets Jun 8 2016 00:22:57
Metadata
Metadata
Assignees
Labels
No labels