ESP8266 serwer AT Command - favicon.ico - Page 1
Forum section: electronics / general

author: up8051
author_rank: Frequent Contributor
timestamp: January 21, 2018, 09:07:34 pm
content: 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:Code:+IPD,0,363:GET /favicon.ico HTTP/1.1assuming I have an icon in the png or ico format.What should I send (by AT+CIPSEND command)?Regards,up8051

author: hamster_nz
author_rank: Super Contributor
timestamp: January 22, 2018, 01:07:09 am
content: Unless you want to send back an icon, you should send a 404 error:Code:HTTP/1.1 404 Not FoundConnection: closeContent-Type: text/html<html><body>Not Found</body></html>

author: up8051
author_rank: Frequent Contributor
timestamp: January 22, 2018, 08:58:25 am
content: I want to send an icon.Ragrds,JarekC

author: frozenfrogz
author_rank: Frequent Contributor
timestamp: January 22, 2018, 09:16:40 am
content: Favicon request debuggingWhy not use the ESP8266WebServer library and SPIFFS?SPIFFS man

author: up8051
author_rank: Frequent Contributor
timestamp: January 22, 2018, 09:55:44 am
content: Because the project specification forces the ESP8266 module to work inAT 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.

author: frozenfrogz
author_rank: Frequent Contributor
timestamp: January 22, 2018, 11:51:44 am
content: 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 theAT command reference.You can use the TCP send buffer.There are also someExamples from Espressif.

author: up8051
author_rank: Frequent Contributor
timestamp: January 22, 2018, 12:02:18 pm
content: I know these documents but I still have no answer how to handle request:Code:+IPD,0,363:GET /favicon.ico HTTP/1.1Send raw data or send some html code?

author: sleemanj
author_rank: Super Contributor
timestamp: January 22, 2018, 12:27:32 pm
content: 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.

author: frozenfrogz
author_rank: Frequent Contributor
timestamp: January 22, 2018, 12:30:43 pm
content: 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

author: up8051
author_rank: Frequent Contributor
timestamp: January 22, 2018, 12:55:54 pm
content: 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 requestCode:+IPD,0,325:GET / HTTP/1.1I can add icon to web headerCode:<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.

author: frozenfrogz
author_rank: Frequent Contributor
timestamp: January 22, 2018, 01:38:36 pm
content: 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.

author: up8051
author_rank: Frequent Contributor
timestamp: January 22, 2018, 01:51:09 pm
content: 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.

author: frozenfrogz
author_rank: Frequent Contributor
timestamp: January 22, 2018, 02:01:31 pm
content: 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.

author: nrxnrx
author_rank: Unknown
timestamp: January 22, 2018, 03:30:49 pm
content: 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 OKContent-Length: 1024Connection: closeContent-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".