These are chat archives for esp8266/Arduino

9th
Nov 2018
mega-hz
@mega-hz
Nov 09 2018 10:33
hi, does someone has an example how to load a website out of the SPIFFS?
but there's also the serveStatic() method if you're more into giving access to a whole forlder rather than whitelisting
mega-hz
@mega-hz
Nov 09 2018 10:40
i have to load the wbsite and some button-pics out of the SPIFFS, also the CSS, so what method would be better?
tobozo
@tobozo
Nov 09 2018 11:03
serveStatic with an additional 404 handler
mega-hz
@mega-hz
Nov 09 2018 12:17
that works fine with
server.serveStatic("/", SPIFFS, "/chicken-control.html");
// server.on("/", Ereignis_Index);
but in the css part it won't load those pictures..
background-image: url(/automatik_off.png);
should be the url include the ip adr?
mega-hz
@mega-hz
Nov 09 2018 12:30
this works: [code] server.serveStatic("/", SPIFFS, "/chicken-control.html");
server.serveStatic("/automatik_off.png", SPIFFS, "/automatik_off.png");
server.serveStatic("/automatik_on.png", SPIFFS, "/automatik_on.png");
server.serveStatic("/aussenlicht_off.png", SPIFFS, "/aussenlicht_off.png");
server.serveStatic("/aussenlicht_on.png", SPIFFS, "/aussenlicht_on.png");
server.serveStatic("/innenlicht_off.png", SPIFFS, "/innenlicht_off.png");
server.serveStatic("/innenlicht_on.png", SPIFFS, "/innenlicht_on.png");
server.serveStatic("/fan_off.png", SPIFFS, "/fan_off.png");
server.serveStatic("/fan_on.png", SPIFFS, "/fan_on.png");
server.serveStatic("/klappe_zu.png", SPIFFS, "/klappe_zu.png");
server.serveStatic("/klappe_auf.png", SPIFFS, "/klappe_auf.png");
[/code]
how can i insert code in this ?
anyway, thank you for your help!!
Develo
@devyte
Nov 09 2018 13:03
@exscape using a voltage div to power the ESP is a Very Bad Idea. The ESP has power spikes which have historically shown very weird side effects. The current recommendation is to use a very big power source to develop to make sure the application is correct, then try trimming the power source down. I've never seen those "half-bits" before, but I wouldn't be surprised at all that's the reason.
tobozo
@tobozo
Nov 09 2018 13:34
@mega-hz you don't have to be explicit on all files you can just specify a folder e.g.
    server.serveStatic("/", SPIFFS, "/", "max-age=86400");
    server.onNotFound ( handleNotFound );
(also beware of the max-age, it can be confusing if you don't clear your browser cache after reflashing the ESP)
mega-hz
@mega-hz
Nov 09 2018 13:37
ok. thank you!!!
mega-hz
@mega-hz
Nov 09 2018 13:46
if i do that, the ajax - switch buttons - doesnt work anymore!

``` server.serveStatic("/", SPIFFS, "/chicken-control.html");
// server.serveStatic("/", SPIFFS, "/");
server.serveStatic("/automatik_off.png", SPIFFS, "/automatik_off.png");
server.serveStatic("/automatik_on.png", SPIFFS, "/automatik_on.png");
server.serveStatic("/aussenlicht_off.png", SPIFFS, "/aussenlicht_off.png");
server.serveStatic("/aussenlicht_on.png", SPIFFS, "/aussenlicht_on.png");
server.serveStatic("/innenlicht_off.png", SPIFFS, "/innenlicht_off.png");
server.serveStatic("/innenlicht_on.png", SPIFFS, "/innenlicht_on.png");
server.serveStatic("/fan_off.png", SPIFFS, "/fan_off.png");
server.serveStatic("/fan_on.png", SPIFFS, "/fan_on.png");
server.serveStatic("/klappe_zu.png", SPIFFS, "/klappe_zu.png");
server.serveStatic("/klappe_auf.png", SPIFFS, "/klappe_auf.png");
// server.on("/", Ereignis_Index);
server.on("/schalte.php", Ereignis_Schalte);
server.on("/zustand.php", Ereignis_Zustand);
server.on("/log.txt", Ereignis_log);
server.on("/timer.html", Ereignis_Timers_Zeigen);
server.on("/settimer.php", Ereignis_NeueTimer);
server.on("/delete.php", Ereignis_DeleteTimer);
server.on("/Timers.js", Ereignis_js);
server.on("/deletelog.php", Ereignis_DeleteLog);

server.on("/daten.js", Ereignis_daten);
server.on("/setup.php", formular);

server.onNotFound ( handleNotFound );
server.begin(); // Starte den Server
```

tobozo
@tobozo
Nov 09 2018 13:50
this isn't a case-insensitive filesystem, maybe double check your filenames ?
mega-hz
@mega-hz
Nov 09 2018 13:52
the filenames are ok, i rather think like /daten.js will redirect ti spiffs too
tobozo
@tobozo
Nov 09 2018 14:31
huhu just spotted the .php extensions
does it mean anything you declared as server.on(...) is dynamic content ?
very curious to know what this chicken looks like anyway :D
mega-hz
@mega-hz
Nov 09 2018 14:58
you can see that here:
mega-hz
@mega-hz
Nov 09 2018 15:19
switching is only allowed when automatik is set to manuel!
is it allowed to write
mega-hz
@mega-hz
Nov 09 2018 15:36
server.serveStatic("/*.png", SPIFFS, "/")`/code
ahh, now it s right
mega-hz
@mega-hz
Nov 09 2018 15:41
ok, with *.png it doesn't work...
Thomas Backman
@exscape
Nov 09 2018 15:42
@devyte The divider is not on the power line, of course, but on the RX line. :) The power supply has a linear regulator with 560 uF after it.
Develo
@devyte
Nov 09 2018 16:09
@exscape Ah, ok. BTW, I don't think that the pullup is irrelevant vs. your divider. I've seen similar mistakes when reading from the ADC through a voltage divider, and then users complain why is the reading is off (looks not calibrated), because the board divider wasn't taken into account. In your case, I'd guess that the pullup is similar in value to the Rs you have in your divider.
That's just a WAG, tho
tobozo
@tobozo
Nov 09 2018 16:27
@mega-hz do I need a specific browser for this to work ? visiting with Firefox for linux and while I see a XHR is made every 2 seconds, all I have on the screen is control buttons
looks like some of the XHR requests never get an answer, since you're using setinterval it may end with many unclosed connections on the browser side
mega-hz
@mega-hz
Nov 09 2018 16:28
i use firefox also, there are only 5 buttons to see, try to switch the automatik
what should i use instead of setinterval?
tobozo
@tobozo
Nov 09 2018 16:31
maybe async/await
mega-hz
@mega-hz
Nov 09 2018 16:31
i dont know that :-(
tobozo
@tobozo
Nov 09 2018 16:32
or a global variable you set to True in Lesen() just before opening the connection
mega-hz
@mega-hz
Nov 09 2018 16:32
did you try to switch the automatik?
tobozo
@tobozo
Nov 09 2018 16:32
and set to false when the response and rendering are processed
I've slowly clicked on all buttons and seen it was sending to the ESP ok, with a response, but only the state of the button changed in the UI, should I expect a video stream or other image ?
mega-hz
@mega-hz
Nov 09 2018 16:34
no, only the button-images are changing, but ONLY, if the button automatik is set to manuell!
then, the other buttons can be swiched!
it works fine on my pc and smartphone...