-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Description
Basic Infos
I have developed a web server that serves a webpage stored in flash (SPIFFS) to a browser. Overall this works great but only with two browsers, Windows Internet Explorer and iPhone Safari. On PC Firefox, Chrome, iPad Safari, and Mac Safari it is either slow and times out or does not work at all.
I thought about and started re-writing this using \arduino-1.8.0\hardware\esp8266com\esp8266\libraries\ESP8266WiFi but this does not easily support all of the GET and POST data transfer that ESP8266WebServer does.
Hardware
Hardware: NodeMCU/ESP-12 (version 0.9 and 1.0)
Core Version: 1.8.0 libraries
Description
Problem description
- ESP8266 is set up as access point
- All devices (PC, Mac, iPhone, iPad) connect with no apparent problem
- Only certain browsers work (see basic description above), other browsers do not work
Settings in IDE
Module: NodeMCU 1.0
Flash Size: 4M(3M SPIFFS)
CPU Frequency: 80Mhz
Flash Mode: SPIFFS
Flash Frequency: ?
Upload Using: Serial
Reset Method: power on
Sketch
#include <Arduino.h>
/*
********************************************************
* Name : setup
* inputs : nil
* :
* returns : nil
* Description : Set up main actions.
********************************************************
*/
void setup(void)
{
// LEDs on board.
const short int BUILTIN_LED1 = 2;
const short int BUILTIN_LED2 = 16;
// Wait a second.
delay(1000);
// Set up serial port.
Serial.begin(115200);
Serial.println (" ");
// Start the file system.
if (true != SPIFFS.begin ())
{
DBG_PRINTF2(DEBUG_FATAL, "PROBLEM OPENING SPIFFS AT: ", __LINE__);
reportError(__FILE__, __LINE__);
// Fatal error, stop.
while (1) {delay(1000);}
}
// Initialize GPIO and LCD functionality.
gpio_init ();
initLCD ();
// Initialize the BUILTIN_LED's pin as outputa.
pinMode(BUILTIN_LED1, OUTPUT);
pinMode(BUILTIN_LED2, OUTPUT);
// If button down is pressed then wifi mode, otherwise run mode.
if ((LOW == digitalRead(BUTTON_DOWN)) || (LOW == digitalRead(BUTTON_UP)))
{
DBG_PRINTF1(DEBUG_INFO, "CONFIGURING ACCESS POINT...");
//Our ESP8266-12E is an AccessPoint.
WiFi.mode (WIFI_AP);
WiFi.softAP(ssid, password);
server.begin();
delay(250);
IPAddress myIP = WiFi.softAPIP();
int32_t wifi_channel = WiFi.channel();
DBG_PRINTF4(DEBUG_DIAGNOSTIC, "AP IP ADDRESS: ", myIP, ", CHANNEL: ", wifi_channel);
// Display PROGRAM MODE on LCD.
clearLCD ();
displayOutput (ROW0, "PROGRAM MODE");
displayOutput (ROW1, "192.168.4.1");
// Server actions.
server.on("/", readHTML);
server.on("/save", saveTable);
server.on("/load", loadTable);
server.on("/delete", deleteTable);
// Called when the url is not defined here
// Use it to load content from SPIFFS
server.onNotFound([](){
if(!handleFileRead(server.uri()))
{
server.send(200, "text/plain", "File Not Found");
DBG_PRINTF2(DEBUG_ERROR, "FILE NOT FOUND AT: ", __LINE__);
}
});
DBG_PRINTF1(DEBUG_INFO, "HTTP server started");
// Turn the LED ON by making the voltage LOW
digitalWrite(BUILTIN_LED1, LOW);
digitalWrite(BUILTIN_LED2, HIGH);
}
else
{
DBG_PRINTF1(DEBUG_INFO, "CONFIGURING RUN MODE...");
// Indicate not wifi mode.
wifi_startup = false;
// Turn the LED ON by making the voltage LOW
digitalWrite(BUILTIN_LED1, HIGH);
digitalWrite(BUILTIN_LED2, LOW);
}
}
/*
********************************************************
* Name : loop
* inputs : nil
* :
* returns : nil
* Description : Main loop.
********************************************************
*/
void loop()
{
// Depending on mode run wifi or runtime enviromnent.
if (true == wifi_startup)
{
server.handleClient();
}
else
{
run_setlist ();
}
}
Debug Messages
GOOD PASS SHOWN BELOW (serial debug output)
handleFileRead: /html/index.html
streamFile done
FREE HEAP = : 28632
THIS SKETCH SIZE = : 318048
FREE SKETCH SPACE = : 729088
handleFileRead: /css/bootstrap.min.css
streamFile done
handleFileRead: /css/style.css
streamFile done
handleFileRead: /js/jquery-2.2.0.min.js
streamFile done
handleFileRead: /js/bootstrap.min.js
streamFile done
handleFileRead: /js/underscore-min.js
streamFile done
handleFileRead: /fonts/glyphicons.eot
streamFile done
handleFileRead: /images/blurredimage.jpg
streamFile done
handleFileRead: /js/index.js
streamFile done
BAD PASS SHOWN BELOW
handleFileRead: /html/index.html
streamFile done
FREE HEAP = : 28400
THIS SKETCH SIZE = : 318048
FREE SKETCH SPACE = : 729088
handleFileRead: /css/bootstrap.min.css
Times out...