-->
Page 1 of 2

Hosting JS and CSS in chip? (including maybe jquery?)

PostPosted: Thu Oct 22, 2015 10:25 pm
by Chris Carter
Hey guys,

I have a semi-complicated webpage that I'd like to host entirely "in chip" on my ESP8266.

At the moment I host the CSS and JS on my web-page, and use the google hosted version of jquery.

When I try to host the CSS it's ok, but longer JS files seem to crash the ESP8266 (wdt rst, which I assume means Watchdog Timer Reset?).

Has anyone had any success hosting CSS or JavaScript on the chip itself? With a server.on("/style.css") type command?

Re: Hosting JS and CSS in chip? (including maybe jquery?)

PostPosted: Fri Oct 23, 2015 2:53 am
by ElGalloGringo
I was coming here to post this exact thing. Though not 100% completed yet, I have a working example of this where you can essentially design your entire website offline, then run it through my simple Python script to generate the entire website in FLASH on the chip. There usually are a few functions you need to implement in code that involve talking to hardware. In my example you can see how I get the AccessPoint or WifiClient mode, the SSID, and password (I know super insecure). The website is based of the super simple responsive template at getskeleton.com.

The github project is at:
https://github.com/jpswensen/ESP8266_WebGen

Let me know what you think.

Re: Hosting JS and CSS in chip? (including maybe jquery?)

PostPosted: Fri Oct 23, 2015 8:26 am
by mrburnette
Chris Carter wrote:<...>
When I try to host the CSS it's ok, but longer JS files seem to crash the ESP8266 (wdt rst, which I assume means Watchdog Timer Reset?).


This is classic WDT reset because the RTOS is not being "feed" enough from the Arduino Sketch. Your Arduino code must return to the top of loop() reasonably quickly all the time - OR, you must use delay(0) or the synonym yield() to allow the RTOS to return control to the native code of the ESP8266 hardware: the radio and protocol stacks, etc.

When you execute some long function from within your Arduino sketch and do not provide for the RTOS to be "feed" often enough, the WDT will kick in and reboot the ESP8266. The is a software architectural issue and the solution is specific to every sketch that fails.

Ray

Re: Hosting JS and CSS in chip? (including maybe jquery?)

PostPosted: Fri Oct 23, 2015 10:16 am
by martinayotte
Chris Carter wrote:but longer JS files seem to crash the ESP8266


Are you sure that the crash is a watchdog issue ? maybe it is the way you handle the JS content ...
Are you using some PROGMEM along with proper server.send_P() ?
Because if you handle it in simple string, it ends up been copied into RAM and maybe your crash is caused by an overflow.