Browse Source

added gzip for webpage and preprocessor timing wrapper

tags/v0.1.0
Simon Schmidt 3 years ago
parent
commit
03d9f87159

+ 5
- 0
.vscode/settings.json View File

{
"files.associations": {
"random": "cpp"
}
}

+ 28
- 14
extra_script.py View File



import os
import os, gzip
# https://www.mischianti.org/2020/10/26/web-server-with-esp8266-and-esp32-byte-array-gzipped-pages-and-spiffs-2/


# https://stackoverflow.com/questions/49449430/python-bytes-to-c-array-like-xxd-program/49450004
def bytes_to_c_arr(data, lowercase=True):
return [format(b, '#04x' if lowercase else '#04X') for b in data]
def convert_to_gzip(src, out, f):
input_file = f'{src}{f}'
output_file = f'{out}{f}.gz.h'
output_charp = f'{f.replace(".", "_")}_gz'


src = 'include/http'
out = 'include'
top = ''
with open(input_file, 'rb') as f_in:
gz = gzip.compress(f_in.read())
gzlen = len(gz)


for f in os.listdir(src):
with open(f'{src}/{f}', 'rb') as f_in:
with open(f'{out}/{f}.h', 'wb') as f_out:
buf = 'const char {}[] = {{{}}};'.format(
f.replace('.', '_'),
', '.join(bytes_to_c_arr(f_in.read()))
)
f_out.write(buf.encode(encoding='ascii'))
top += f'// filename: {f}.gz.h\n'
top += f'#define {output_charp}_len {gzlen}\n'
top += f'const char {output_charp}[] = '
top += '{'

with open(output_file, 'wb') as f_out:
for i, b in enumerate(gz):
if not i%10:
top += '\n '
top += f'0x{b:02X}, '
top = top[:-2]
top += '};'
f_out.write(top.encode(encoding='utf-8'))




src='include/http/'
out='include/'

for f in os.listdir(src):
convert_to_gzip(src, out, f)

+ 5500
- 0
include/firefox.png.gz.h
File diff suppressed because it is too large
View File


BIN
include/http/firefox.png View File


+ 19
- 15
include/http/index.html View File

<!DOCTYPE html>
<html> <html>
<head>
<meta charset="utf-8">
<title>My test page</title>
<link href="http://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet" type="text/css">
<link href="styles/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1>Mozilla is cool</h1>
<p>At Mozilla, we’re a global community of</p>


<head>
<meta http-equiv='refresh' content='5' />
<title>ESP8266 Demo</title>
<style>
body {
background-color: #cccccc;
font-family: Arial, Helvetica, Sans-Serif;
Color: #000088;
}
</style>
</head>
<ul> <!-- changed to list in the tutorial -->
<li>technologists</li>
<li>thinkers</li>
<li>builders</li>
</ul>


<body>
<h1>Hello from ESP8266!</h1>
</body>
<p>working together to keep the Internet alive and accessible, so people worldwide can be informed contributors and creators of the Web. We believe this act of human collaboration across an open platform is essential to individual growth and our collective future.</p>


</html>
<p>Read the <a href="https://www.mozilla.org/en-US/about/manifesto/">Mozilla Manifesto</a> to learn even more about the values and principles that guide the pursuit of our mission.</p>
</body>
</html>

+ 41
- 0
include/http/style.css View File

html {
font-size: 10px;
font-family: 'Open Sans', sans-serif;
}


h1 {
font-size: 60px;
text-align: center;
}

p, li {
font-size: 16px;
line-height: 2;
letter-spacing: 1px;
}


html {
background-color: #00539F;
}

body {
width: 600px;
margin: 0 auto;
background-color: #FF9500;
padding: 0 20px 20px 20px;
border: 5px solid black;
}

h1 {
margin: 0;
padding: 20px 0;
color: #00539F;
text-shadow: 3px 3px 1px black;
}

img {
display: block;
margin: 0 auto;
}

+ 60
- 0
include/index.html.gz.h View File

// filename: index.html.gz.h
#define index_html_gz_len 569
const char index_html_gz[] = {
0x1F, 0x8B, 0x08, 0x00, 0x37, 0x8A, 0xC2, 0x60, 0x02, 0xFF,
0x8D, 0x53, 0x4D, 0x6F, 0xD4, 0x30, 0x10, 0xBD, 0xF7, 0x57,
0x4C, 0x73, 0xA5, 0x1B, 0xAB, 0x37, 0x84, 0xB2, 0x41, 0x08,
0x38, 0x70, 0xA8, 0x8A, 0x28, 0x08, 0x71, 0x74, 0x9C, 0x49,
0x62, 0xD5, 0xF1, 0x58, 0xF6, 0xB8, 0x61, 0x39, 0xF1, 0x37,
0xF8, 0x7B, 0xFC, 0x12, 0xC6, 0xCE, 0x16, 0x15, 0xF5, 0xC2,
0x65, 0x93, 0xCC, 0xD7, 0x7B, 0x6F, 0xE6, 0x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
0x89, 0x08, 0xEB, 0x47, 0xFB, 0x60, 0xC7, 0x2C, 0x5F, 0x73,
0xA4, 0x8D, 0x97, 0x8A, 0x4E, 0x39, 0xD6, 0x79, 0x68, 0xB8,
0x28, 0x9A, 0x32, 0xE7, 0x88, 0xED, 0x93, 0xDB, 0x84, 0xFE,
0x93, 0x98, 0xA0, 0x32, 0xEB, 0xF4, 0x13, 0xCB, 0x26, 0xF1,
0xEC, 0xB6, 0x6D, 0xED, 0xBA, 0x1F, 0xBB, 0xA5, 0x38, 0x2B,
0xF4, 0x87, 0x2F, 0x77, 0x4A, 0xA8, 0x65, 0x56, 0x42, 0xD4,
0x4E, 0x62, 0x7E, 0x52, 0xCD, 0x5F, 0xBF, 0xDC, 0x3C, 0xC6,
0x3A, 0xA5, 0xFB, 0x7A, 0x64, 0xD4, 0xD1, 0x83, 0xA8, 0xF4,
0xB0, 0x52, 0x31, 0x4A, 0x69, 0xAD, 0x58, 0x0F, 0xDA, 0x65,
0xDC, 0x17, 0x14, 0xA2, 0xF5, 0xC6, 0xCA, 0x56, 0x93, 0x64,
0x34, 0xC3, 0x9C, 0xCB, 0x5E, 0x4B, 0x51, 0xC8, 0x31, 0x65,
0x5B, 0x37, 0x53, 0x74, 0xAC, 0x56, 0x0E, 0x41, 0x7E, 0x67,
0x5F, 0xEE, 0xBA, 0xBB, 0x56, 0xEC, 0x59, 0xFF, 0xBC, 0x7F,
0x00, 0x2D, 0xEF, 0xEA, 0xF3, 0xD4, 0x03, 0x00, 0x00};

+ 0
- 1
include/index.html.h View File

const char index_html[] = {0x3c, 0x68, 0x74, 0x6d, 0x6c, 0x3e, 0x0d, 0x0a, 0x0d, 0x0a, 0x3c, 0x68, 0x65, 0x61, 0x64, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x6d, 0x65, 0x74, 0x61, 0x20, 0x68, 0x74, 0x74, 0x70, 0x2d, 0x65, 0x71, 0x75, 0x69, 0x76, 0x3d, 0x27, 0x72, 0x65, 0x66, 0x72, 0x65, 0x73, 0x68, 0x27, 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x3d, 0x27, 0x35, 0x27, 0x20, 0x2f, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x45, 0x53, 0x50, 0x38, 0x32, 0x36, 0x36, 0x20, 0x44, 0x65, 0x6d, 0x6f, 0x3c, 0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x7b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x62, 0x61, 0x63, 0x6b, 0x67, 0x72, 0x6f, 0x75, 0x6e, 0x64, 0x2d, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x23, 0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6f, 0x6e, 0x74, 0x2d, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x3a, 0x20, 0x41, 0x72, 0x69, 0x61, 0x6c, 0x2c, 0x20, 0x48, 0x65, 0x6c, 0x76, 0x65, 0x74, 0x69, 0x63, 0x61, 0x2c, 0x20, 0x53, 0x61, 0x6e, 0x73, 0x2d, 0x53, 0x65, 0x72, 0x69, 0x66, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3a, 0x20, 0x23, 0x30, 0x30, 0x30, 0x30, 0x38, 0x38, 0x3b, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x7d, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x2f, 0x73, 0x74, 0x79, 0x6c, 0x65, 0x3e, 0x0d, 0x0a, 0x3c, 0x2f, 0x68, 0x65, 0x61, 0x64, 0x3e, 0x0d, 0x0a, 0x0d, 0x0a, 0x3c, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x68, 0x31, 0x3e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x66, 0x72, 0x6f, 0x6d, 0x20, 0x45, 0x53, 0x50, 0x38, 0x32, 0x36, 0x36, 0x21, 0x3c, 0x2f, 0x68, 0x31, 0x3e, 0x0d, 0x0a, 0x3c, 0x2f, 0x62, 0x6f, 0x64, 0x79, 0x3e, 0x0d, 0x0a, 0x0d, 0x0a, 0x3c, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x3e};

+ 31
- 0
include/style.css.gz.h View File

// filename: style.css.gz.h
#define style_css_gz_len 279
const char style_css_gz[] = {
0x1F, 0x8B, 0x08, 0x00, 0x37, 0x8A, 0xC2, 0x60, 0x02, 0xFF,
0x6D, 0x91, 0xCF, 0x6E, 0xC3, 0x20, 0x0C, 0xC6, 0xEF, 0x3C,
0x85, 0xA5, 0x1D, 0x7A, 0x29, 0x12, 0x6D, 0x95, 0x4A, 0x25,
0xF7, 0x5C, 0x7B, 0xD8, 0x13, 0x90, 0x40, 0xC0, 0x1A, 0x01,
0x04, 0x54, 0x6D, 0x37, 0xF5, 0xDD, 0x47, 0x58, 0xBA, 0x3F,
0xED, 0x0E, 0x80, 0x64, 0x7F, 0xFE, 0xF9, 0xB3, 0x31, 0x79,
0xB2, 0x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0xEC, 0x8A, 0x6E, 0x3E, 0x65,
0xFC, 0x5F, 0x6C, 0x9C, 0x74, 0x85, 0x4B, 0x4C, 0xC1, 0x8A,
0xF2, 0x55, 0xBD, 0xF5, 0x73, 0xEA, 0x79, 0xBA, 0x1B, 0xF9,
0x04, 0xE0, 0x3A, 0x1B, 0x2A, 0xEF, 0x01, 0x00, 0x00};

+ 44
- 0
includeindex.html.gz.h View File


// filename: include/http/index.html.gz.h
// uncompressed: index.html, gzip: 622
#define index_html_gz 622
const char index_html_gz[] = {
0x1F, 0x8B, 0x08, 0x00, 0x22, 0x7E, 0xC2, 0x60, 0x02, 0xFF, 0x8D, 0x54, 0xCD, 0x6E, 0xD4, 0x30,
0x10, 0xBE, 0xF3, 0x14, 0x43, 0xAE, 0x74, 0x63, 0xF5, 0x86, 0xAA, 0x6C, 0x10, 0x82, 0x22, 0x71,
0xA8, 0x8A, 0x68, 0x11, 0xE2, 0xE8, 0x38, 0x93, 0xC4, 0xAA, 0xE3, 0xB1, 0xEC, 0x71, 0xB7, 0xCB,
0x89, 0xD7, 0xE0, 0xF5, 0x78, 0x12, 0xC6, 0xCE, 0xB6, 0x2A, 0xEA, 0x85, 0x4B, 0x12, 0xCF, 0xDF,
0xF7, 0x7D, 0x33, 0xE3, 0x74, 0xAF, 0x3F, 0x5E, 0x7F, 0xB8, 0xFD, 0xF1, 0xE5, 0x12, 0x16, 0x5E,
0x5D, 0xFF, 0xAA, 0xDB, 0x5E, 0x00, 0xDD, 0x82, 0x7A, 0x2C, 0x1F, 0xF2, 0xB9, 0x22, 0x6B, 0x30,
0x8B, 0x8E, 0x09, 0x79, 0xDF, 0x64, 0x9E, 0x76, 0x6F, 0x9B, 0x93, 0x8B, 0x2D, 0x3B, 0xEC, 0xAF,
0x8E, 0xC0, 0x98, 0x18, 0x82, 0x9E, 0xB1, 0x53, 0x9B, 0x6D, 0xF3, 0x3B, 0xEB, 0xEF, 0x60, 0x89,
0x38, 0xED, 0x9B, 0x85, 0x39, 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E, 0x1A, 0x2E, 0x8A, 0xA6, 0xCC, 0x39, 0x62, 0xFB, 0x6C, 0x36, 0xA1, 0xFF,
0x2A, 0x5B, 0x56, 0x99, 0x75, 0xFA, 0xD9, 0x9D, 0x48, 0x72, 0x29, 0x0E, 0x87, 0x43, 0xBB, 0x6E,
0xC3, 0x6E, 0x29, 0xCE, 0x0A, 0xFD, 0xEE, 0xDB, 0x8D, 0x12, 0x6A, 0x99, 0x95, 0x10, 0xB5, 0x93,
0xDC, 0x2E, 0x52, 0xCD, 0xD3, 0x42, 0x5E, 0x3D, 0xDA, 0x3A, 0xA5, 0xFB, 0x3A, 0x64, 0xD4, 0xD1,
0x83, 0xA8, 0xF4, 0xB0, 0x52, 0x59, 0x94, 0x92, 0x5A, 0xB1, 0xEE, 0xB5, 0xCB, 0xB8, 0x35, 0x28,
0x44, 0xEB, 0x8D, 0x95, 0xAE, 0x26, 0xF1, 0x68, 0x86, 0x39, 0x97, 0xBE, 0x96, 0xA0, 0x90, 0x63,
0xCA, 0xB6, 0x76, 0xA6, 0xE8, 0x58, 0xAD, 0x0C, 0x82, 0xFC, 0xC6, 0xBE, 0xCC, 0x75, 0xBB, 0x16,
0xB2, 0xFF, 0xF5, 0xEF, 0xF0, 0x17, 0x2C, 0x3C, 0x3D, 0x28, 0x35, 0x04, 0x00, 0x00};

+ 27
- 45
src/main.cpp View File

#include <Arduino.h> #include <Arduino.h>
#include <Wire.h> #include <Wire.h>


#include "wifi_credentials.h"
#include "PCA9685.h" #include "PCA9685.h"



// OTA & WEB
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <WiFiUdp.h> #include <WiFiUdp.h>
#include <ArduinoOTA.h> #include <ArduinoOTA.h>


#include <WiFiClient.h>
#include <ESP8266WebServer.h> #include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

#include "wifi_credentials.h"
#include <WiFiClient.h> // evtl weghauen ?


#include "index.html.h"
#include "index.html.gz.h"
#include "style.css.gz.h"
// images are possible
// maybe check out FS <- SPIFFS


const char* ssid = STASSID; const char* ssid = STASSID;
const char* password = STAPSK; const char* password = STAPSK;
const int led = 13; const int led = 13;
ESP8266WebServer server(80); ESP8266WebServer server(80);


void handleRoot() {
digitalWrite(led, 1);
// char temp[sizeof(index_html)];
// snprintf(temp, sizeof(index_html), index_html);
void handleRootGz() {
const char* dataType = "text/html";
server.sendHeader(F("Content-Encoding"), F("gzip"));
server.send(200, dataType, (const char*)index_html_gz, index_html_gz_len);
}


server.send(200, "text/html", index_html);
digitalWrite(led, 0);
void handleCssGz() {
const char* dataType = "text/css";
server.sendHeader(F("Content-Encoding"), F("gzip"));
server.send(200, dataType, (const char*)style_css_gz, style_css_gz_len);
} }



void handleNotFound() { void handleNotFound() {
digitalWrite(led, 1); digitalWrite(led, 1);
String message = "File Not Found\n\n"; String message = "File Not Found\n\n";
Serial.print("IP address: "); Serial.print("IP address: ");
Serial.println(WiFi.localIP()); Serial.println(WiFi.localIP());


if (MDNS.begin("esp8266")) {
Serial.println("MDNS responder started");
}

server.on("/", handleRoot);
server.on("/inline", []() {
server.send(200, "text/plain", "this works as well");
});
//server.on("/", handleRoot);
server.on("/", handleRootGz);
server.on("/styles/style.css", handleCssGz);
server.onNotFound(handleNotFound); server.onNotFound(handleNotFound);

server.begin(); server.begin();
Serial.println("HTTP server started"); Serial.println("HTTP server started");
} }
} }




unsigned long i = 0;
unsigned long a = 0;
unsigned long s = 0;
float ard_ota_time = 0;
float server_handle = 0;
uint32_t t;
#define SP_US(_str,_a) Serial.print(_str); Serial.print(" took: "); Serial.print(_a); Serial.println("µs")
#define TIMEIF_US(_str,_f, _l) t=micros(); _f; t=micros()-t; if(t > _l) { SP_US(_str, t); }


void loop() { void loop() {
a = micros();
ArduinoOTA.handle();
ard_ota_time += micros()-a;
TIMEIF_US("OTA", ArduinoOTA.handle(), 20000);
s = micros();
server.handleClient();
server_handle += micros()-s;

if(++i >= 10000) {
Serial.print("Mittlere Laufzeit\tOTA: ");
Serial.print(ard_ota_time/10000.0);
Serial.print("µs\tHTTP: ");
Serial.print(server_handle/10000.0);
Serial.println("µs");

ard_ota_time = 0;
server_handle = 0;
i = 0;
}
TIMEIF_US("HTTP", server.handleClient(), 20000);
} }

Loading…
Cancel
Save