5 Commits
Author SHA1 Message Date
Simon Schmidt 278f746b33 templ ini 2021-06-23 13:34:54 +02:00
Simon Schmidt 642ee7d0a6 gzip works from FS 2021-06-23 02:13:48 +02:00
Simon Schmidt 6596346d3d ls -l implement and ota fw fix 2021-06-23 01:30:28 +02:00
Simon Schmidt b696703d45 littefs working 2021-06-22 23:38:39 +02:00
Simon Schmidt baecaf02da cleanup 2021-06-22 20:36:53 +02:00
13 changed files with 512 additions and 60 deletions

No files matched your search

+3 -1
View File
@@ -10,6 +10,8 @@
"vector": "cpp",
"string_view": "cpp",
"memory": "cpp",
"ranges": "cpp"
"ranges": "cpp",
"initializer_list": "cpp",
"utility": "cpp"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 531 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

+40
View File
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
<title>ESP8266 Treppenlicht</title>
<!-- main style sheet -->
<link href="/favicon.png" rel="icon" type="image/png" sizes="16x16">
<link href="/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="topbar">
ESP8266 Treppenlicht Controller
</div>
<div class="control">
<div class="brightness">
</div>
<div class="onoff">
toggle all
<label id="l_onoff"></label>
<label class="switch">
<input type="checkbox">
<span class="slider round"></span>
</label>
</div>
<div class="pwm">
<label id="label_pwm"></label>
<input type="range" min="1" max="100" value="50" class="rangeslider" id="range1">
</div>
<div class="timer">
<label id="label_timer"></label>
<input type="range" min="1" max="100" value="50" class="rangeslider" id="timer_range">
</div>
</div>
</body>
<script src="/input.js"></script>
</html>
+8
View File
@@ -0,0 +1,8 @@
var slider = document.getElementById("range1");
var output = document.getElementById("l_pwm");
output.innerHTML = slider.value; // Display the default slider value
// Update the current slider value (each time you drag the slider handle)
slider.oninput = function() {
output.innerHTML = this.value;
}
+132
View File
@@ -0,0 +1,132 @@
html {
font-size: 10px;
font-family: sans-serif, Arial, Helvetica;
background-color: #b3b3b3;
}
.topbar {
padding: 1em;
background-color: #1f1f1f;
color: white;
font-size: x-large;
text-align: center;
}
.control {
padding: 1em;
}
p, li {
font-size: 16px;
line-height: 2;
letter-spacing: 1px;
}
body {
margin: 0 auto;
border: 1px solid black;
border-radius: 3;
}
/* The switch - the box around the slider */
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
/* Hide default HTML checkbox */
.switch input {
opacity: 0;
width: 0;
height: 0;
}
/* The slider */
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #04AA6D;
}
input:focus + .slider {
box-shadow: 0 0 1px #04AA6D;
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
/* Rounded sliders */
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
/* The slider itself */
.rangeslider {
-webkit-appearance: none; /* Override default CSS styles */
appearance: none;
width: 50%; /* Full-width */
height: 34px; /* Specified height */
border-radius: 34px; /* range round corners */
background: #d3d3d3; /* Grey background */
outline: none; /* Remove outline */
opacity: 0.7; /* Set transparency (for mouse-over effects on hover) */
-webkit-transition: .2s; /* 0.2 seconds transition on hover */
transition: opacity .2s;
}
/* Mouse-over effects */
.rangeslider:hover {
opacity: 1; /* Fully shown on mouse-over */
}
/* The slider handle (use -webkit- (Chrome, Opera, Safari, Edge) and -moz- (Firefox) to override default look) */
.rangeslider::-webkit-slider-thumb {
-webkit-appearance: none; /* Override default look */
appearance: none;
width: 26px; /* Set a specific slider handle width */
height: 26px; /* Slider handle height */
border-radius: 50%; /* Round Element */
background: #04AA6D; /* Green background */
cursor: pointer; /* Cursor on hover */
}
.rangeslider::-moz-range-thumb {
width: 26px; /* Set a specific slider handle width */
height: 26px; /* Slider handle height */
background: #04AA6D; /* Green background */
cursor: pointer; /* Cursor on hover */
}
+75
View File
@@ -0,0 +1,75 @@
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, 0x2A, 0x67, 0x5B, 0xA4, 0x66,
0x32, 0x60, 0x79, 0x6D, 0xE4, 0xCC, 0x6B, 0x4D, 0xA4, 0x26,
0x7E, 0x06, 0x12, 0x6E, 0x3B, 0xB5, 0x55, 0x05, 0x42, 0x37,
0x75, 0x2C, 0x89, 0xB7, 0x94, 0xA7, 0x28, 0x97, 0x4A, 0x2E,
0x0B, 0x90, 0xFD, 0x66, 0xE8, 0xD4, 0x7C, 0xC6, 0x09, 0xFA,
0x1D, 0xED, 0x54, 0x43, 0x27, 0x65, 0x49, 0xF5, 0x17, 0x03,
0x1F, 0x4E, 0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, 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
BIN
View File
Binary file not shown.
+30
View File
@@ -22,4 +22,34 @@ GDB-Version aus Arduino Toolchain hat Support
```sh
$ ./start_xtensa_gdb_stub.sh
```
### __Achtung !__
Don`t forget __\r__
ESP-OTA wird von ufw oder Defender geblockt.
- Windows -> Python needs to be granted with rights
- Linux -> open udp port in ufw ->
```sh
platform.ini
upload_flags =
--host-port <PORT>
...
$ sudo ufw allow tcp/<PORT>
```
```c++
server.streamFile(f, mime::getContentType(SRH::_path), requestMethod);
=====>
const String& p = SRH::_path;
if(p.endsWith(".gzip")) {
server.sendHeader("Content-Encoding", "gzip");
server.streamFile(f, mime::getContentType(p.substring(0, p.length()-5)), requestMethod);
}
else
server.streamFile(f, mime::getContentType(SRH::_path), requestMethod);
```
+15
View File
@@ -0,0 +1,15 @@
#ifndef __FILESYS_H
#define __FILESYS_H
#include <LittleFS.h>
bool mount_fs();
bool format_fs();
void ls(const char * dirname);
void readFile(const char * path);
void writeFile(const char * path, const char * message);
void appendFile(const char * path, const char * message);
void renameFile(const char * path1, const char * path2);
void deleteFile(const char * path);
#endif // __FILESYS_H
+133
View File
@@ -0,0 +1,133 @@
#include "filesys.h"
// listDir("/");
// deleteFile("/hello.txt");
// writeFile("/hello.txt", "Hello ");
// appendFile("/hello.txt", "World!\n\r");
// readFile("/hello.txt");
// listDir("/");
FSInfo fsinfo;
void ls(const char * dirname) {
Serial.printf("ls -l %s\n\r", dirname);
Dir root = LittleFS.openDir(dirname);
while (root.next()) {
File file = root.openFile("r");
time_t lw = file.getLastWrite();
struct tm * tmstruct = localtime(&lw);
Serial.printf("%8d %02d %02d %02d:%02d %s\n\r",
file.size(),
tmstruct->tm_mon + 1,
tmstruct->tm_mday,
tmstruct->tm_hour,
tmstruct->tm_min,
root.fileName().c_str());
file.close();
}
Serial.println();
}
void readFile(const char * path) {
Serial.printf("Reading file: %s\n\r", path);
File file = LittleFS.open(path, "r");
if (!file) {
Serial.println("Failed to open file for reading");
return;
}
Serial.print("Read from file: ");
while (file.available()) {
Serial.write(file.read());
}
file.close();
}
void writeFile(const char * path, const char * message) {
Serial.printf("Writing file: %s\n\r", path);
File file = LittleFS.open(path, "w");
if (!file) {
Serial.println("Failed to open file for writing");
return;
}
if (file.print(message)) {
Serial.println("File written");
} else {
Serial.println("Write failed");
}
delay(2000); // Make sure the CREATE and LASTWRITE times are different
file.close();
}
void appendFile(const char * path, const char * message) {
Serial.printf("Appending to file: %s\n\r", path);
File file = LittleFS.open(path, "a");
if (!file) {
Serial.println("Failed to open file for appending");
return;
}
if(file.print(message)) {
Serial.println("Message appended");
} else {
Serial.println("Append failed");
}
file.close();
}
void renameFile(const char * path1, const char * path2) {
Serial.printf("Renaming file %s to %s\n\r", path1, path2);
if (LittleFS.rename(path1, path2)) {
Serial.println("File renamed");
} else {
Serial.println("Rename failed");
}
}
void deleteFile(const char * path) {
Serial.printf("Deleting file: %s\n\r", path);
if (LittleFS.remove(path)) {
Serial.println("File deleted");
} else {
Serial.println("Delete failed");
}
}
bool mount_fs() {
if(!LittleFS.begin()) {
Serial.println("[ERROR] LittleFS.info(), reset ...");
return false;
}
if(!LittleFS.info(fsinfo)) {
Serial.println("[ERROR] LittleFS.info(), reset ...");
return false;
}
printf("Filesystem opened:\n\r");
printf("\ttotalBytes:\t%d\n\r", fsinfo.totalBytes);
printf("\tusedBytes:\t%d\n\r", fsinfo.usedBytes);
printf("\tblockSize:\t%d\n\r", fsinfo.blockSize);
printf("\tpageSize:\t%d\n\r", fsinfo.pageSize);
printf("\tmaxOpenFiles:\t%d\n\r", fsinfo.maxOpenFiles);
printf("\tmaxPathLength:\t%d\n\r", fsinfo.maxPathLength);
printf("\n\r");
return true;
}
bool format_fs() {
printf("Formatting FS ! \n\r");
return LittleFS.format();
}
+67 -56
View File
@@ -13,38 +13,13 @@ extern "C" {
#define ESP12_LED 2
#define NODEMCU_LED 16
os_timer_t Timer1; // Verwaltungsstruktur des Timers
int c;
bool toggle = false;
uint32_t m=0;
uint32_t dimmtimer = 0;
uint8_t direction = 1;
uint8_t onoff = 1;
void ledsequence(uint8_t direction, uint8_t onoff, uint8_t factor);
uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval, uint8_t factor);
void timerCallback(void *pArg)
{
*((int *) pArg) += 1;
ledsequence(direction, onoff, 4);
// Serial.print("[");
// Serial.print(micros()-m);
// Serial.print("] timerCallback\n");
// m = micros();
}
// OTA & WEB
#include "wifi_credentials.h"
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include "filesys.h"
#include <ESP8266WebServer.h>
#include <WiFiClient.h>
@@ -57,6 +32,9 @@ void timerCallback(void *pArg)
const char* ssid = STASSID;
const char* password = STAPSK;
os_timer_t timer1;
int timer_arg;
void setup_webserver();
void setup_ota();
void setup_pwm_pca9685();
@@ -106,25 +84,16 @@ void handleNotFound() {
void setup_webserver() {
pinMode(led, OUTPUT);
digitalWrite(led, 0);
Serial.println("");
// 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/");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
server.on("/", handleRootGz);
server.on("/style.css", handleCssGz);
server.on("/favicon.png", handleFaviconGz);
server.onNotFound(handleNotFound);
server.begin();
@@ -182,6 +151,23 @@ void setup_pwm_pca9685() {
Serial.println(pwmController.getChannelPWM(0)); // Should output 2048, which is 128 << 4
}
uint32_t dimmtimer = 0;
uint8_t direction = 1;
uint8_t onoff = 1;
void ledsequence(uint8_t direction, uint8_t onoff, uint8_t factor);
uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval, uint8_t factor);
uint8_t flag = 0;
void timer_callback(void *pArg)
{
*((int *) pArg) += 1;
flag = 1;
}
void setup() {
#ifdef WITH_DEBUGGING_ON
Serial.begin(460800);
@@ -192,6 +178,12 @@ void setup() {
Serial.println(F("Booting ...."));
mount_fs();
//format_fs();
ls("/");
ls("http/");
// readFile("/test.txt");
pinMode(NODEMCU_LED, OUTPUT);
pinMode(ESP12_LED, OUTPUT);
@@ -207,23 +199,36 @@ void setup() {
ESP.restart();
}
os_timer_setfn(&Timer1, timerCallback, &c);
os_timer_arm(&Timer1, 1, true);
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
os_timer_setfn(&timer1, timer_callback, &timer_arg);
os_timer_arm(&timer1, 1000, true);
Serial.println("Ready");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
setup_ota();
pinMode(led, OUTPUT);
digitalWrite(led, 0);
Serial.println("");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
setup_webserver();
setup_pwm_pca9685();
}
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); }
uint8_t softstart_led(uint8_t led, uint16_t startval, uint16_t stopval, uint8_t factor){
static uint8_t lastled = 255;
static uint8_t current_pwm = 0;
@@ -306,11 +311,11 @@ void ledsequence(uint8_t direction, uint8_t onoff, uint8_t factor){
}
}
uint32_t _t=0;
#define SP_US(_str,_a) Serial.print(_str); Serial.print(" took: "); Serial.print(_a); Serial.println("us")
#define TIMEIF_US(_f, _l, _str) _t=micros(); _f; _t=micros()-_t; if(_t > _l) { SP_US(_str, _t); }
void loop() {
if(millis() - dimmtimer > 2){
//ledsequence(direction, onoff, 4);
dimmtimer = millis();
@@ -318,8 +323,14 @@ void loop() {
if(millis() > 25000 && onoff == 1 && direction == 1) onoff = 0;
if(millis() > 35000 && direction == 1){
onoff = 1;
direction = 0;
direction = 0;
}
TIMEIF_US(ArduinoOTA.handle(), 1000, "OTA");
TIMEIF_US(server.handleClient(), 1000, "HTTP");
if(flag) {
flag = 0;
ledsequence(direction, onoff, 4);
Serial.printf("[%lu] interrupt\n\r", millis());
}
TIMEIF_US("OTA", ArduinoOTA.handle(), 1000);
TIMEIF_US("HTTP", server.handleClient(), 1000);
}
+9 -3
View File
@@ -12,23 +12,29 @@
platform = espressif8266
board = nodemcuv2
framework = arduino
; for http files
board_build.filesystem = littlefs
board_build.ldscript = eagle.flash.4m1m.ld
extra_scripts = pre:create_gz_files.py
monitor_speed = 115200
extra_scripts = pre:extra_script.py
[env:serial]
upload_protocol = esptool
upload_speed = 921600
[env:ota]
; stuff for OTA
; https://docs.platformio.org/en/latest/platforms/espressif8266.html#over-the-air-ota-update
; OTA => https://docs.platformio.org/en/latest/platforms/espressif8266.html#over-the-air-ota-update
upload_protocol = espota
upload_port = <!! IP ADDRESS !!>
upload_flags =
--port=8266
--host_port=<!! PORT !!>
--auth=admin
[env:debug]
; look at doku.md
build_flags = -DWITH_DEBUGGING_ON -Os -g3 -ggdb3
upload_protocol = esptool
upload_speed = 921600