Skip to main content
Roma Jam
Associate
November 19, 2014
Question

SPWF01SA HTTP Request

  • November 19, 2014
  • 11 replies
  • 2085 views
Posted on November 19, 2014 at 14:43

Hello everybody!

It is interesting to me to make an electronic device which can receive data from the mobile devices (e.g. Mobile Phone or Computer). The main idea is to send data to electronic device by using the html web page and internal browser of the mobile device. So I bought module SPWF01SA.

Using the reference manual to the SPWF module I understood that it can working in two modes which is interesting to me. Either the Mini AP mode or a IBSS mode.

In the IBSS mode i can use the HTML web pages was writed in internal memory (like an output_demo.html) and to send the string to my SPWF module and get it by the UART port. Yes I done it.

But my question is next.

Is there any ways to get raw HTTP request from the client to my server (either in IBSS mode or miniAP mode) by the UART (or SPI)?

Hope, somebody can help me or say smth interesting about this. 

Grazie!

#spwf01sa #wifi
    This topic has been closed for replies.

    11 replies

    Gerardo GALLUCCI
    ST Employee
    November 20, 2014
    Posted on November 20, 2014 at 03:23

    Hi Roman,

    whatever mode you are running (ibss, sta or miniAP), there is always (by default) active a webserver running on port 80.

    If you want to implement your own webserver-like application, you can:

    1 - turn off that server (by AT+S.HTTPD=0 or AT+S.SCFG=ip_use_httpd,0 and AT&W)

    2 - turn on your own TCP socket server (AT+S.SOCKD=80,t)

    3 - receive requests (automatically switches in ''data mode'' on incoming socket client event)

    Let me know if it helps

    Roma Jam
    Roma JamAuthor
    Associate
    November 20, 2014
    Posted on November 20, 2014 at 09:03

    Thank you so much for quick reply!

    I'll start to try it...

    Roma Jam
    Roma JamAuthor
    Associate
    November 20, 2014
    Posted on November 20, 2014 at 09:27

    Yes, I have recieved a raw HTTP request. Seems so like what i need.

    Thank you so much again!!! 

    Gerardo GALLUCCI
    ST Employee
    November 20, 2014
    Posted on November 20, 2014 at 09:43

    Great!

    Roma Jam
    Roma JamAuthor
    Associate
    November 20, 2014
    Posted on November 20, 2014 at 10:24

    Thank you so much for very-very quick reply! 

    So my new question is the next.

    Is there some documentation how i should work with the module STWF in data_mode?

    Gerardo GALLUCCI
    ST Employee
    November 20, 2014
    Posted on November 20, 2014 at 11:08

    I'm currently out of office.

    Use thread called ''STEVAL-IDW001V1 documentation?'', and download socketserver pdf

    jerry

    Roma Jam
    Roma JamAuthor
    Associate
    November 20, 2014
    Posted on November 20, 2014 at 12:32

    Yeah! Got it! Many thanks.

    And i got how clearly send response to the HTTP request in ''data_mode''.

    When client browser is send the request, such as:

    +WIND:60:Now in Data Mode

     

    GET / HTTP/1.1

     

    Host: 192.168.0.50

     

    User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 0_0_0 like Mac OS X) AppleWebKit/000.00 (KHTML, like Gecko) Version/0.0 Mobile/000 Safari/0000.00.0

     

    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

     

    Accept-Language: XX

     

    Accept-Encoding: gzip, deflate

     

    Connection: keep-alive

     

    and then wait an answer to client, which I shoul input by the UART.

    I suppose to send answer like an example the following (page 19 UM1695 - ''Command set reference guide for ''AT full stack'' for SPWF01Sx series of Wi-Fi modules'', HTTPGET Example):

    HTTP/1.0 200 OK

     

    Server: lwIP/1.3.1 (http://savannah.nongnu.org/projects/lwip)

     

    Content-type: text/html

    <html>

     

    /* HTML_CONTENT */

     

    </html>

     

    but the client browser is waiting data from the server infinitely.

    After that I understand that the response in ''data_mode'' must have following structure:

    HTTP/1.1 200 OK  - HTTP version as in GET

    Server: server_name not necessary

     

    Content-type: text/html - content type

     

    Content-length: length_value - Length of html-content, length_value - is a number of bytes

    EMPTY LINE must present after content

    <html>

    /* HTML_CONTENT */

    </html>

     

    After send this header, the browser will stopped to waiting data from server after reception of length_value bytes and will show html-page correctly.

    Writing about because think it may be usefull for someone.

    Thanks so much for the soon reply!

    Roma Jam
    Roma JamAuthor
    Associate
    November 20, 2014
    Posted on November 20, 2014 at 12:41

    Also forgot to add:

    All the lines must ended by the <CR><LF> by standart HTTP.

    Gerardo GALLUCCI
    ST Employee
    November 20, 2014
    Posted on November 20, 2014 at 16:04

    Did you already tried to send your reply through a single one-shot string?

    I mean, when you are in data mode, messages are sent on every timeout is found from the module.

    Maybe, what's happening is that browser receives only the first line (the 200 OK), and that it parses/renders only this line of original reply sent. The remaining part of your reply is discarded by browser.

    If you send ''HTTP/1.1 200 OK<CR><LF>'' and  then (after more than a timeout) ''Server: server_name<CR><LF>'', you are sending 2 replies. You nees to send a single string containing ''HTTP/1.1 200 OK<CR><LF>Server: server_name<CR><LF>''.

    1 - <CR> and <LF> are not special characters. They are used as normal chars.

    2 - the timeout mechanism is the only way to force a send. <CR> and <LF> have no meaning in data mode

    3 - the max length of reply message (one-shot) is currently limited to 1Kbytes. You you try to send 2 KB (for example), 2 messages containing 1Kb each are sent.

    Hope to be helpful

    Sorry but I'm really far from my office. I can not try what I'm suggesting you :)

    jerry

    Roma Jam
    Roma JamAuthor
    Associate
    November 20, 2014
    Posted on November 20, 2014 at 18:35

    Yes, indeed I sent reply like a single shot string.

    ''I mean, when you are in data mode, messages are sent on every timeout is found from the module.'' - what message do you mean? Message from SPWF module to the client browser? Or what?

    If yes, I saw it. When I typing something characters in my terminal TX window this content appears in browser with timeout and by packs. 

    Yes, <CR> and <LF> is an abbreviation from Carriage Return and Line Feed, I know :) Indeed I send 0x0D and 0x0A. Or '\r' and '\n'.

     Max length of reply message it's interesting, thanks for information!

    Now I'm starting to write firmware for external controller to parse AT msgs and control the other electronics.

    No problem what you out of office, anyway thank you so much for support!