Best way to stream base64 encoded string to a web client #7615
Replies: 1 comment
-
Posted at 2020-01-24 by @gfwilliams New firmwares should have 'Storage' which will allow you to store complete files. It might make more sense to use that. The IDE at espruino.com/ide will work with serial devices and has a storage manager that allows you to upload files from your PC, and if you use one of the 'cutting edge' builds you can use Posted at 2020-01-24 by nistvan.86 Is it possible to upload to a named storage entry with the Espruino CLI? I'm currently using that with save on send to upload my code. A similar thing for this html asset would be nice. Posted at 2020-01-25 by Robin Sat 2020.01.25 @nistvan.86 Not entirely sure about the 'this html asset' part, but would any part of this section of the reference apply? Posted at 2020-01-25 by nistvan.86 I'm familiar with how to create Storage entries using the interpreter over the serial connection. My problem is that with the Espruino CLI I can't seem to send other than the main script file going to I tried to do something like this:
It's not possible to remove the Even if it's the only way to do it, I can't find any instructions on how to flash this hex file to the ESP8266 (probably with the esptool.py). But I would rather not do that and use only the Espruino CLI if possible. I think it's clear now why I'm thinking about bundling the assets to the main script file instead. Also it's funny that even though I don't connect to any device during the above command, it mentions that I'm using an old firmware.
Am I using an old Espruino dependency or the board definition triggers this and there's a new ESP8266 name available I'm not aware of? Posted at 2020-01-25 by @MaBecker Well, I use a two step approach
Posted at 2020-01-25 by nistvan.86 Thank you! So handcrafting something is the only way for now. Is it okay to do something like Posted at 2020-01-26 by @MaBecker I personally split html in logical parts like head and body as needed and use this style to keep easy to read.
I have no experience with large data amounts you are trying to handle, max was 3k.
see E.setBootCode() and Boot process: (v2.0 and later) It looks for files in Storage named .boot0, .boot1, .boot2 and .boot3 and executes them in sequence. Posted at 2020-01-26 by @MaBecker it is possible to include values as vars, which are replaced during upload
Posted at 2020-01-26 by nistvan.86 I've written a small tool which creates a helper script, and can be executed on the board as suggested to create the environment. I'm sending the file in small 32 byte chunks as a byte array. It goes like:
The problem is, that only the first write succeeds, and only the first 32 bytes can be read from the entry. If I manually execute the lines in the interpreter, only the first write returns true, others are not even returning false. Any idea what causing this? I think something fails silently in the native code. This works:
Also it seems I have more than enough memory left in storage:
Posted at 2020-01-26 by nistvan.86 Okay, I've figured it out. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-24 by nistvan.86
I would like to serve up a minified single HTML (including CSS, JS, images, etc.) from my Espruino. To minimize space, I'm going to gzip the resulting file and use the Content-Encoding HTTP header when serving it up.
I'm also thinking about inlining this gzip file in my Espruino JS code, and base64 encode it. What is the most memory efficient way to stream this from the Espruino, and not decode the whole string into memory first?
Or is there a better idea to do this? I don't have an SD card storage, just the flash of my ESP8266 board.
Beta Was this translation helpful? Give feedback.
All reactions