These are chat archives for esp8266/Arduino

21st
Jun 2016
Helio Machado
@0x2b3bfa0
Jun 21 2016 07:19
This message was deleted
Brendan Smith
@brendanheyu
Jun 21 2016 08:14
Hi all
My esp units will all be sending data to a Mqtt server - I'd like each unit to identify itself. Can I get them to discover they're own host name? I can assign the hostname from the DHCP on my router...
Me No Dev
@me-no-dev
Jun 21 2016 08:22
I don't think that you can currently get the hostname from the DHCP server
Helio Machado
@0x2b3bfa0
Jun 21 2016 11:14
Hi! Only two questions:
  1. Can I run a command each a few seconds without being on the loop (which is already busy with DHCP and so on)?
  1. How can I see the serial port output via OTA?
crosofg
@crosofg
Jun 21 2016 18:31
@/all has anyone used I2S for audio input with ESP ?
Me No Dev
@me-no-dev
Jun 21 2016 19:16
@crosofg I have not heard of anyone and I'm not positive that we have all register info required to get it going
though if you have spare time, I can maybe help
Russ Mathis
@RussMathis
Jun 21 2016 22:57
Hey guys, I'm having issues with SPIFFS streamFile, I've split my html page into two files, a header and a footer. In code the header file gets streamed to the client then I send some more html based on the clients request followed up with streaming the footer. However I'm getting "HTTP/1.1 200 OK Content-Type: text/html Content-Length: 974 Connection: close Access-Control-Allow-Origin: *" one the client's browser each time I stream a file.
I'm trying to using multiple files from SPIFFs and generated code to create the final html output. It seems to be working but the header information keeps getting displayed as text on the client browser. Is there a way to stop this from happening?
Hagai Shatz
@hagai-shatz
Jun 21 2016 23:04
Can you share more details, like your code and the files you are serving?
@crushedice2000
@crushedice2000 , you can add more code to your loop, the DNS code does not take very long to execute, you can use code similar to the example of blink without delay. Alternatively, you can use a liberty like Timer that invoke a callback in a specific time period, however, it might not suit your needs since you should not call delay inside the callback code.
Russ Mathis
@RussMathis
Jun 21 2016 23:11
Hi, sure but I'm not doing much i have a func sendPageHeader that: server.sendHeader("Cache-Control", ...); sendHeader("Pragma", .. Expires and setContentLength(CONTENT_LENGTH_UNKNOWN) then the html header file gets sent via server.streamFile next some code that iterates over files in SPIFFs building a c string that gets sent with server.client().print() then simple simple send the html footer file the same way the header was sent with server.streamFile.
Hagai Shatz
@hagai-shatz
Jun 21 2016 23:12
You can see the serial output only when you connect your computer to the serial port of the ESP. You can write the sketch to save a log into a file in SPIFFS and then serve that log file in http request.
Russ Mathis
@RussMathis
Jun 21 2016 23:12
But for some reason each time a file is streamed from SPIFFs and end up with the header information printed out before each file contents that get streamed. wierd?
Here is the sendPageHeader()
void sendPageHeader()
{
server.sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
server.sendHeader("Pragma", "no-cache");
server.sendHeader("Expires", "-1");
server.setContentLength(CONTENT_LENGTH_UNKNOWN);
server.send(200, "text/html", "");
File df = SPIFFS.open("/web/header.html", "r");
if (df) {
server.streamFile(df, "text/html");// "text/html");
df.close();
}
else
{
server.client().print("Could not open file");
}
}
Here is the sendPageFooter()
void sendPageFooter()
{
File df = SPIFFS.open("/web/footer.html", "r");
if (df) {
server.streamFile(df, "text/html");// "text/html");
df.close();
}
else
{
server.client().print("Could not open file");
}
}
here is the fileListing()

void pageFileList() {
String buf;
Dir d = SPIFFS.openDir("/");
sendPageHeader();
server.sendContent("-----Page: File List-----<br>");
while (d.next()) {

    buf += d.fileName().c_str();
    buf += " size: ";
    buf += d.fileSize();
    buf += "<br>";
    yield();
}
server.sendContent(buf);
sendPageFooter();

}

Hagai Shatz
@hagai-shatz
Jun 21 2016 23:16
What server are you using?
Russ Mathis
@RussMathis
Jun 21 2016 23:17
Here is the first line in the client browser:HTTP/1.1 200 OK Content-Type: text/html Content-Length: 974 Connection: close Access-Control-Allow-Origin: *
The content I generate programmatically looks great.
but then at the bottom of the page I get: HTTP/1.1 200 OK Content-Type: text/html Content-Length: 21 Connection: close Access-Control-Allow-Origin: *
I seem to see this, out of place, header information each time a file is streamed from SPIFFs.
ESP8266WebServer.h
Hagai Shatz
@hagai-shatz
Jun 21 2016 23:21
I think you have to read each file into memory and send the concert specifically, using stream file adds headers for you.
Russ Mathis
@RussMathis
Jun 21 2016 23:22
bumber, OK! Thanks!