gmag11 / FSBrowserNG

Full autocontained (on SPIFFS) async web server on ESP8266. Written as a Library.
Other
158 stars 70 forks source link

Crashes on saving config #9

Closed flurl closed 7 years ago

flurl commented 7 years ago

Hello!

First thanks for that wonderful lib. It's exactly what I needed. :-)

But I stumbled upon a few crashes, which were related to sending Page_WaitAndReload and Page_Restart to the browser. As both are stored in PROGMEM replacing request->send with request->send_P solved the first crashes and made saving the config possible.

The second kind of crash was due to the use of delay() in AsyncFSWebServer::send_network_configuration_html() and AsyncFSWebServer::restart_esp().

I'm new to ESP8266 programming but if I understand correctly, delay() shouldn't be used within a handler. At least removing those two delay() calls fixed it for me.

nscnm87 commented 7 years ago

Hi! I'm having the same crashes but the corrections listed above didn't fixed the problem for me. After saving the config I get this on the serial monitor:

`Save config
{
  "ssid": "ssid",
  "pass": "pass",
  "ip": [
    192,
    168,
    1,
    4
  ],
  "netmask": [
    255,
    255,
    255,
    0
  ],
  "gateway": [
    192,
    168,
    1,
    1
  ],
  "dns": [
    192,
    168,
    1,
    1
  ],
  "dhcp": true,
  "ntp": "pool.ntp.org",
  "NTPperiod": 15,
  "timeZone": 10,
  "daylight": true,
  "deviceName": "azz"
}
state: 5 -> 0 (0)
rm 0
del if0
usl
void AsyncFSWebServer::send_network_configuration_html(AsyncWebServerRequest*)
case STA_DISCONNECTED
Disconnected for 0 seconds

 ets Jan  8 2013,rst cause:2, boot mode:(3,7)

load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
v3de0c112
~ld`

Hope we can fix this, this library is perfect from my projects.

Thank you very much Regards, Fabio

sekt1953 commented 7 years ago

The Fix work for me. using Arduino IDE 1.8.2

minida28 commented 7 years ago

@nscnm87 not sure what you've meant with crash... do you mean the esp will restart every time you press the save the config button? Looking at the code, the restart instruction is there in the code (means the restart is by design). https://github.com/gmag11/FSBrowserNG/blob/master/FSWebServerLib.cpp#L832

My problem is slightly different, sometimes the browser won't reload after pressing the save config button, or sometimes the esp stuck in the boot loop similar to a reset that is caused by wdt reset. But that maybe related to my own code, still need to investigate that though...

nscnm87 commented 7 years ago

In my case the config is saved but the esp go in a reboot loop printing this error:

ets Jan  8 2013,rst cause:2, boot mode:(3,7)

load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
v3de0c112
~ld
minida28 commented 7 years ago

Hi @nscnm87 If I understand it correctly , rst cause:2 means OK, should be fine and not a crash... But you said the esp stuck in reboot loop, than that's problem.

Maybe you've set wrong led or ap_enable pin? Try disable those pin settings (set to -1) and see if the esp can escape the reboot loop.

gmag11 commented 7 years ago

I've made several test and not found any loop. Every time a config is saved, ESP is restarted to ensure new config is loaded. Maybe it is not the most elegant way to do it but, as you normally do the config once, I think it is a minor problem.

species5618 commented 7 years ago

there is a known issue where it may not retsart properly after an upload, if a ESP.reset is issued in the code

so if you have just upload some code the next save (esp.reset) hangs the device, until you hard reset / waggle dtr (which i do)

see https://github.com/esp8266/Arduino/issues/1722

gmag11 commented 7 years ago

Yes, this is a known behabiour of ESP8266. After 1st hard reset it works as expected.

It is a good to know advise, but it cannot be controlled in software.