Author Topic: ESP8266 serwer AT Command - favicon.ico  (Read 3341 times)

0 Members and 1 Guest are viewing this topic.

Offline up8051Topic starter

  • Frequent Contributor
  • **
  • Posts: 288
  • Country: pl
ESP8266 serwer AT Command - favicon.ico
« on: January 21, 2018, 09:07:34 pm »
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: [Select]
+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

 

Offline hamster_nz

  • Super Contributor
  • ***
  • Posts: 2803
  • Country: nz
Re: ESP8266 serwer AT Command - favicon.ico
« Reply #1 on: January 22, 2018, 01:07:09 am »
Unless you want to send back an icon, you should send a 404 error:

Code: [Select]
HTTP/1.1 404 Not Found
Connection: close
Content-Type: text/html

<html>
  <body>
      Not Found
  </body>
</html>
Gaze not into the abyss, lest you become recognized as an abyss domain expert, and they expect you keep gazing into the damn thing.
 

Offline up8051Topic starter

  • Frequent Contributor
  • **
  • Posts: 288
  • Country: pl
Re: ESP8266 serwer AT Command - favicon.ico
« Reply #2 on: January 22, 2018, 08:58:25 am »
I want to send an icon.

Ragrds,
JarekC
 

Offline frozenfrogz

  • Frequent Contributor
  • **
  • Posts: 936
  • Country: de
  • Having fun with Arduino and Raspberry Pi
Re: ESP8266 serwer AT Command - favicon.ico
« Reply #3 on: January 22, 2018, 09:16:40 am »
Favicon request debugging

Why not use the ESP8266WebServer library and SPIFFS?
SPIFFS man
« Last Edit: January 22, 2018, 09:18:31 am by frozenfrogz »
He’s like a trained ape. Without the training.
 

Offline up8051Topic starter

  • Frequent Contributor
  • **
  • Posts: 288
  • Country: pl
Re: ESP8266 serwer AT Command - favicon.ico
« Reply #4 on: January 22, 2018, 09:55:44 am »
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.
 

Offline frozenfrogz

  • Frequent Contributor
  • **
  • Posts: 936
  • Country: de
  • Having fun with Arduino and Raspberry Pi
Re: ESP8266 serwer AT Command - favicon.ico
« Reply #5 on: January 22, 2018, 11:51:44 am »
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.
He’s like a trained ape. Without the training.
 

Offline up8051Topic starter

  • Frequent Contributor
  • **
  • Posts: 288
  • Country: pl
Re: ESP8266 serwer AT Command - favicon.ico
« Reply #6 on: January 22, 2018, 12:02:18 pm »
I know these documents but I still have no answer how to handle request:
Code: [Select]
+IPD,0,363:GET /favicon.ico  HTTP/1.1

Send raw data or send  some html code?
 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3024
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: ESP8266 serwer AT Command - favicon.ico
« Reply #7 on: January 22, 2018, 12:27:32 pm »
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.
~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Offline frozenfrogz

  • Frequent Contributor
  • **
  • Posts: 936
  • Country: de
  • Having fun with Arduino and Raspberry Pi
Re: ESP8266 serwer AT Command - favicon.ico
« Reply #8 on: January 22, 2018, 12:30:43 pm »
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
He’s like a trained ape. Without the training.
 

Offline up8051Topic starter

  • Frequent Contributor
  • **
  • Posts: 288
  • Country: pl
Re: ESP8266 serwer AT Command - favicon.ico
« Reply #9 on: January 22, 2018, 12:55:54 pm »
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
Code: [Select]
+IPD,0,325:GET / HTTP/1.1
 I can add icon to web header
Code: [Select]
<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.



 

Offline frozenfrogz

  • Frequent Contributor
  • **
  • Posts: 936
  • Country: de
  • Having fun with Arduino and Raspberry Pi
Re: ESP8266 serwer AT Command - favicon.ico
« Reply #10 on: January 22, 2018, 01:38:36 pm »
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.
« Last Edit: January 22, 2018, 01:43:15 pm by frozenfrogz »
He’s like a trained ape. Without the training.
 

Offline up8051Topic starter

  • Frequent Contributor
  • **
  • Posts: 288
  • Country: pl
Re: ESP8266 serwer AT Command - favicon.ico
« Reply #11 on: January 22, 2018, 01:51:09 pm »
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.
 

Offline frozenfrogz

  • Frequent Contributor
  • **
  • Posts: 936
  • Country: de
  • Having fun with Arduino and Raspberry Pi
Re: ESP8266 serwer AT Command - favicon.ico
« Reply #12 on: January 22, 2018, 02:01:31 pm »
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.
He’s like a trained ape. Without the training.
 

Offline nrxnrx

  • Supporter
  • ****
  • Posts: 68
  • Country: ro
Re: ESP8266 serwer AT Command - favicon.ico
« Reply #13 on: January 22, 2018, 03:30:49 pm »
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".
« Last Edit: January 22, 2018, 04:29:40 pm by nrxnrx »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf