-
function onPageRequest(req, res) { var a = url.parse(req.url, true); console.log(a); console.log(req.headers); console.log(req.method);
headers:
{ "Host": "192.168.1.13", "Connection": "keep-alive", "Cache-Control": "max-age=0", "Upgrade-Insecure-Requests": "1", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.96 Safari/537.36", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "Accept-Encoding": "gzip, deflate, sdch", "Accept-Language": "en-GB,en-US;q=0.8,en;q=0.6" }
-
If you are looking to server static content, then you don't need the espruino todo the heavy lifting, you can leave that to the much more powerful browser.
On the sd card, store .gz versions of the files, and then have the onPageRequest handler server the compressed content:
function onPageRequest(req, res) { var a = url.parse(req.url, true); console.log(a); file=a.pathname; if (file == '/') { file='/index.htm'; } var headers= {}; var f; try { f = E.openFile('www' + file, "r"); } catch(e) { console.log('no file'); // look for compressed try { f = E.openFile('www' + file + '.gz', "r"); headers['Content-Encoding']='gzip'; } catch(e) {} } if (f !== undefined) { mime='text/html'; if ( file.substr(-2) == 'js' ) mime='application/javascript'; if ( file.substr(-3) == 'css' ) mime='text/css'; if ( file.substr(-3) == 'ico' ) mime='image/vnd.microsoft.icon'; headers['Content-Type']= mime; res.writeHead(200, headers); console.log('started ' + file ); f.pipe(res,{chunkSize:512, end:false, complete:function(){ console.log("Complete"); f.close(); res.end(); } } ); } else { res.writeHead(404, { 'Content-Type': 'text/plain' }); res.end("404: Page " + a.pathname + " not found"); } }
This assumes all of the web assets are in
www
( you could use sub folders www/css)As an example of fetching:
http://192.168.15.13/pure-min.css
The difference is:
pure-min.css 31KB 2 secs to fetch
pure-min.css.gz 600ms secs to fetch -
-
-
-
If you look in chrome in the developer tools, in the network tab you can see the requests sent.
You'll see the requests that never get fulfilled...
As the http server can only handle one request at a time, when they overlap it does not work and buffers get ful and it all goes to custard!
One work around is to use github and the github.io with your user name. You can out the CSS and js file and images there, and have the espruino just send the main code.
-
-
Not quite sure what you are asking....
Here is a thread for connection the Nokia display to the esp8266... not sure which board you are using..
http://forum.espruino.com/conversations/287196/#comment13070259 -
-
-
Hi, this in prepartion for ota updates. The espruino_partition.bin contains these partitions:
factory 0x10000 ota_0 0x200000
When there is a ota type partition the esp-idf checks to see if there is valid code in the partition. At this stage nothing is uploaded to 0x200000, and the data is 0xff.
The
esp_ota_get_boot_partition()
call checks the ota partition and finds invalid data, so spits out this error.It could be suppressed and added back when the ota updates are sorted out, however it can be safely ignored.
-
-
This Reddit shows a video controlling with tv remote...
https://www.reddit.com/r/hardware/comments/1wzzax/superbowl_led_hat_hacks_firing_pixmob_leds_w/
My son has a sonic screwdriver remote that turns off and on all tvs, so that might be worth a try...
-
It was at Eden park in a large stadium - they could control sections of seating and when it was out turn to move, it would light up and buzz. They also could strobe the colours matching a laser display - its quite impressive. There where quite a few left on empty seats, so I though they would be handy to have....
-
I went the 2017 world masters game opening ceremony where these bands were used. Apparently they are controlled by Ir.
I found this on github, but the guy was unable to brute force the ir codes.
https://github.com/yeokm1/reverse-engineering-ndp2016-wristband
It has 3xrgb leds, an accelerometer and an ir reciever, and runs off 2x cr2032 coin cells. Rather than break up for parts I thought it would be good to see if it could be controlled via Espruino
Anyone got any ideas how how to work out how to control the wrist band?
-
Here is an example from the forum
http://forum.espruino.com/conversations/300344/
Please paste your code....
-
http://www.espruino.com/Reference#l_DataView_DataView
function DataView.getInt16(byteOffset)
-
-
-
-
I'm also at a loss as to why the limited space for code - given that the ESP12 has 3 meg spare? I wonder if there are any plans to check for that and expand user space accordingly?
The esp8266 has bags of FLASH, but bugger all RAM. There is only 80K and a lot of this is taken up by the OS and interpreter. Quite a bit of work has been done to strings into flash to free up precious RAM. The amount of
save()
code space is 12K compressed, so this works out to be about 20K of js code.
After flashing the USB/serial device gets left in an odd state.
I have found if you connect with a serial programme ( screen on linux, putty ) on windows with a baud of 115200 after flashing, you get a command prompt. Then quit this, and try the connection from the web ide with baud rate 115200.
The other related factor is the ESP8266 outputs on the UART and boot at 76800 baud and spits out:
I think this output confuses the web ide, an if you look in the console you see 'overrun' or something similar, and the nodejs serialport connection is disconnected. Perhaps this could be commented out and see if this works a work around?