Hi,
I have ESP8266 module connected to uP(ATMEGA328PB) by UART.
ESP8266 is working as Web Server, SoftAP mode, AT command.
How to handle request:
+IPD,0,363:GET /favicon.ico HTTP/1.1
assuming I have an icon in the png or ico format.
What should I send (by AT+CIPSEND command)?
Regards,
up8051
Unless you want to send back an icon, you should send a 404 error:
HTTP/1.1 404 Not Found
Connection: close
Content-Type: text/html
<html>
<body>
Not Found
</body>
</html>
I want to send an icon.
Ragrds,
JarekC
Because the project specification forces the ESP8266 module to work in AT Command mode.
Millions of projects with esp8266 and no one knows?
The only solution that I found is defining the icon in the header of the html page.
But how to handle any request for sending file (icon, pictrure..) with ESP8266 and AT Command mode.
Sending data via AT commands works just like you would do utilizing bluetooth modules etc.
It all depends on what device you are sending to. There is no easy workaround. It is all in the
AT command reference.
You can use the TCP send buffer.
There are also some
Examples from Espressif.
I know these documents but I still have no answer how to handle request:
+IPD,0,363:GET /favicon.ico HTTP/1.1
Send raw data or send some html code?
You respond with the icon (bitmap or png from memory, I think a gif will work too), with the appropriate Content type header etc.
You can see the eevblog favico in the top of the address bar, so how about you inspect that request in your browser and you can then see what a proper server sent.
Maybe this video on youtube can get you started:
Since the browser expects data to be text/html, you could send the favicon file as inline base64.
For everything else you might need to consult some http reference.
Packages of up to 1000bytes (?) can be sent via AT+CIPSEND directly -> I do not know the max block size though. For larger chunks of data you need to utilize the send buffer or AT+CIPSENDEX.
https://github.com/MaJerle/ESP8266_AT_Commands_parser/issues/17
I have configured and working ESP8266 Web Serwer.
I also have working my own HTML Web Page (clear html).
Web is sended by AT+CIPSEND command in respond to request
+IPD,0,325:GET / HTTP/1.1
I can add icon to web header
<head><link rel='icon' href='data:image/png;base64,xxx...xxx type='image/x-png' /></head>
where xxx...xxx it is icon definition base64 coded.
But in this method I have to insert icon definition in all sub-web pages.
I think that respond header is build by ESP8266 (Content type, etc..)
Maybe in AT Command there no method to send icon/picture.
This is my frist project with ESP and HTML.
Do you have the webpages hard coded into your firmware, or are you using a filesystem?
Besides: AT send commands do not see "files" and "file types". Look at it as a method of sending and receiving raw bytes of data. There needs to be some kind of interpreter on either end. You can read from a file, divide it up into blocks of data, initiate data transfer, send the blocks and acknowledge that all blocks were sent.
Web page is hard coded in controller firmware (ATMEGA328PB).
ESP8266 is connected by UART as external intefrace and can be connected to controllers with different web pages.
It is used as Web HMI to configure controller.
You can put your base64 code or icon file into a constant char / char array variable and simply point there whenever it should be included.
Are you replying to the GET request with raw html? No HTTP headers?
I tried a quick "echo hello world|nc -l -p 8081" and Chrome only showed ERR_INVALID_HTTP_RESPONSE, while Firefox did show "hello world" after the server closed the connection.
For favico, you can send the following:
--------
HTTP/1.1 200 OK
Content-Length: 1024
Connection: close
Content-Type: image/x-icon
<1024 byte image file>
---------
use "\r\n" after each line in the HTTP header and for the empty line after them.
To send html, just prepend "HTTP/1.1 200 OK\r\nConnection: close\r\nContent-Type: text/html\r\n\r\n".