Browse Source

tryin on win

tags/v0.3.0
Simon Schmidt 3 years ago
parent
commit
4b608c42ca
9 changed files with 15 additions and 121 deletions
  1. 0
    0
      data/compressed.html.gzip
  2. 0
    0
      data/favicon.png
  3. BIN
      data/http/firefox.png
  4. 0
    0
      data/index.html
  5. 0
    0
      data/input.js
  6. 0
    0
      data/style.css
  7. 0
    75
      data/test.txt
  8. 14
    45
      src/main.cpp
  9. 1
    1
      templ_platformio_ini

data/tt.html.gzip → data/compressed.html.gzip View File


data/http/favicon.png → data/favicon.png View File


BIN
data/http/firefox.png View File


data/http/index.html → data/index.html View File


data/http/input.js → data/input.js View File


data/http/style.css → data/style.css View File


+ 0
- 75
data/test.txt View File

@@ -1,75 +0,0 @@
0xEA, 0x0C, 0xD2, 0x04, 0xE1, 0x9D, 0xC4, 0x18, 0xF6, 0xC1,
0x40, 0xA7, 0x08, 0x35, 0x3D, 0x67, 0x1A, 0xB5, 0x23, 0x81,
0x4C, 0x96, 0x42, 0xFD, 0x43, 0xDA, 0x99, 0x71, 0x68, 0xF1,
0xEA, 0x1E, 0xB9, 0xE4, 0xD0, 0xBB, 0x05, 0xAC, 0xF7, 0x5E,
0x38, 0x0B, 0x31, 0x66, 0x0D, 0x8A, 0x1B, 0x6F, 0x29, 0x2B,
0xEC, 0x8C, 0xED, 0xAD, 0x03, 0xE2, 0x44, 0xBA, 0xB3, 0xA1,
0xB8, 0x85, 0xFC, 0xF6, 0xFB, 0xD1, 0x12, 0x63, 0x7E, 0x86,
0x5A, 0x22, 0x6F, 0xEF, 0x55, 0xD4, 0x27, 0x3F, 0xCC, 0xE9,
0x9A, 0x60, 0xC5, 0xD0, 0xF8, 0x29, 0x0B, 0x06, 0x2C, 0x9B,
0xDC, 0x95, 0xDD, 0xA6, 0x22, 0x65, 0x3F, 0xCC, 0x7E, 0x6C,
0xD3, 0x77, 0x26, 0x23, 0x9C, 0x5C, 0xD3, 0x8E, 0xB2, 0xBD,
0xD1, 0xC8, 0xEA, 0xC1, 0x87,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, 0x77, 0xB0, 0x81, 0xB3, 0x2C, 0x3C, 0xB2,
0x05, 0x1C, 0x3A, 0x66, 0xF5, 0xE0, 0x4F, 0xEE, 0x5B, 0xC8,
0xD6, 0x52, 0x97, 0x9F, 0x1B, 0x80, 0x44, 0x53, 0xD7, 0x5D,
0x8A, 0xB9, 0xA2, 0xDD, 0x99, 0xB4, 0xFA, 0xFB, 0xB9, 0xAA,
0xA0, 0xA8, 0x11, 0xFA, 0xCF, 0xF5, 0xB6, 0xDF, 0xB4, 0xD7,
0x56, 0x11, 0xD1, 0xE1, 0xF0, 0x45, 0xA0, 0x6C, 0xA1, 0xAE,
0x92, 0xD7, 0x6F, 0xD0, 0x18, 0xF7, 0x73, 0x07, 0x15, 0xDC,
0xEE, 0x37, 0xD8, 0xB1, 0x72, 0x2C, 0xAC, 0x57, 0x99, 0x57,
0xD5, 0x59, 0xC7, 0xE8, 0x

+ 14
- 45
src/main.cpp View File

@@ -27,7 +27,6 @@ extern "C" {
#include "style.css.gz.h"
#include "favicon.png.gz.h"
// images are possible
// maybe check out FS <- SPIFFS

const char* ssid = STASSID;
const char* password = STAPSK;
@@ -38,33 +37,13 @@ int timer_arg;
void setup_webserver();
void setup_ota();
void setup_pwm_pca9685();
void handleRootGz();
void handleCssGz();
void handleNotFound();

const int led = 13;
ESP8266WebServer server(80);
PCA9685 pwmController;

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);
}

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 handleFaviconGz() {
const char* dataType = "image/png";
server.sendHeader(F("Content-Encoding"), F("gzip"));
server.send(200, dataType, (const char*)favicon_png_gz, favicon_png_gz_len);
}

void handleNotFound() {
digitalWrite(led, 1);
String message = "File Not Found\n\n";
message += "URI: ";
message += server.uri();
@@ -77,27 +56,23 @@ void handleNotFound() {
for (uint8_t i = 0; i < server.args(); i++) {
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}

server.send(404, "text/plain", message);
digitalWrite(led, 0);
}


void setup_webserver() {
// server.on("/", handleRootGz);
// server.on("/style.css", handleCssGz);
// server.on("/favicon.png", handleFaviconGz);
// void serveStatic(const char* uri, fs::FS& fs, const char* path, const char* cache_header = NULL );
server.serveStatic("/static", LittleFS, "/tt.html.gzip");
server.serveStatic("/http", LittleFS, "/http/");
server.serveStatic("/http", LittleFS, "/http/");
server.serveStatic("/http", LittleFS, "/http/");

// //experimental, see doku.md
// server.serveStatic("/compressed", LittleFS, "/compressed.html.gzip");

server.serveStatic("", LittleFS, "/index.html");
server.serveStatic("/", LittleFS, "/index.html");
server.serveStatic("/#", LittleFS, "/index.html");
server.serveStatic("/style.css", LittleFS, "/style.css");
server.serveStatic("/index.js", LittleFS, "/index.js");
server.serveStatic("/favicon.png", LittleFS, "/favicon.png");
server.onNotFound(handleNotFound);

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

void setup_ota() {
@@ -199,8 +174,8 @@ void setup() {
ESP.restart();
}

pinMode(led, OUTPUT);
digitalWrite(led, 0);
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
@@ -216,17 +191,11 @@ void setup() {

setup_ota();

pinMode(led, OUTPUT);
digitalWrite(led, 0);
Serial.println("");

// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
setup_webserver();
Serial.println("HTTP server started !");

setup_pwm_pca9685();
Serial.println("PCA9685 connected !");
}

uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval, uint8_t factor){

+ 1
- 1
templ_platformio_ini View File

@@ -13,7 +13,7 @@ platform = espressif8266
board = nodemcuv2
framework = arduino
monitor_speed = 115200
extra_scripts = pre:extra_script.py
extra_scripts = pre:create_gz_files.py

[env:serial]
upload_protocol = esptool

Loading…
Cancel
Save