Comments (5)
Karel; I just realised I simply closed this without providing any explanation. Apologies for that, it was rude of me.
I basically think that developing such a script is a good fun exercise in scripting etc
.
But is it also re-inventing the wheel.. there are built-in tools in Linux that can do this already, I could generate a compressed and encoded header file very simply like this:
gzip -kf index.html && xxd -i index.html.gz > index.html.h
xxd
is part of the vim toolkit, it generates a c-header file from the source file defining index_html_gz[]
with the contents in hex form and index_html_gz_len
with the size.
Adding that to a Makefile in a traditional development environment is easy, adding it to the Arduino IDE is hard.
Since this project has lots of free memory (note that the HTML is in PROGMEM, not RAM) it's not an issue here, and since the page is only loaded once the data saved by compression is insignificant vs the bandwidth needed for a video stream.
from esp32-cam-webserver.
Hello Owen, thank you for your detailed response and I can fully understand your reasoning. Your explanation actually provides the EXACT solution for my original problem - I spend some time searching for what xxd -i -u
is providing out-of-the-box and I never found a single mention of xxd
along the way 😃
I think this would be a valuable addition to my original stackoverflow post and I of course I will be mentioning you as the original author of this solution.
EDIT: Just out of curiosity - why does gzip -kfc index.html | xxd -i -u
provide different output ?
from esp32-cam-webserver.
I cant remember where I heard of xxd either, just one of these random things I learned somewhere..
The reason why the simpler command you show produces different output is because when you run xxd -i
without an input file (stdin) it only generates the hex content, and not the whole structure. When xxd
has a input filename I uses that to generate full definition instead of just the contents.
See the effect for yourself like this:
$ echo "hello" > hello.txt
$ cat hello.txt | xxd -i
0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x0a
$ xxd -i hello.txt
unsigned char hello_txt[] = {
0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x0a
};
unsigned int hello_txt_len = 6;
from esp32-cam-webserver.
I had run across another option for encoding the html through Cyberchef here. From that I made the following recipes:
decode
from esp32-cam-webserver.
Nice, A good solution for windows users I guess.
If I was making a commercial device with maybe dozens of complex html pages, javascript, graphics etc this would make sense. .. but If I were doing that I would also be using something more complex as my development environment, and I'd simply script something up with bash/xxd and put it as a pre-run script in my buildfiles.
For this project the advantages of keeping the html trivial to edit far, far outweigh any advantages zipping and hex encoding it.
from esp32-cam-webserver.
Related Issues (20)
- Flashing went well but no wifi network
- cam hangs after 2-3 days HOT 2
- Save and restore SSID and Passwd in config file
- Support mic and speaker
- Compiler warnings and errors in Arduino2.2.1
- started getting this HOT 5
- Error while compiling with Arduino IDE 1.8.19 HOT 1
- ssid issue
- init error
- Error when compiling for Xiao ESP32S3 HOT 1
- Internet access with Wifi-sta mode
- flash bin to device via ota
- Custom hostname not working
- how to get working with ov2640 HOT 1
- Streaming on Andorid Phone not possible HOT 1
- exit status 1 esp_int_wdt.h: No such file or directory HOT 8
- Start Recording and led on off issues HOT 1
- Stream Window is not rotated on port 81
- Sending data to Serial2 from the video stream.
- Watchdog API changes in arduino-esp32 version 3.x.x
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp32-cam-webserver.