2014-11-19 05:43 AM
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 #wifi2014-11-19 06:23 PM
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 helps2014-11-20 12:03 AM
Thank you so much for quick reply!
I'll start to try it...2014-11-20 12:27 AM
Yes, I have recieved a raw HTTP request. Seems so like what i need.
Thank you so much again!!!2014-11-20 12:43 AM
Great!
2014-11-20 01:24 AM
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?2014-11-20 02:08 AM
I'm currently out of office.
Use thread called ''STEVAL-IDW001V1 documentation?'', and download socketserver pdf jerry2014-11-20 03:32 AM
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 ModeGET / 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 GETServer: server_name - not necessary
Content-type: text/html - content type
Content-length: length_value - Length of html-content, length_value - is a number of bytesEMPTY 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!
2014-11-20 03:41 AM
Also forgot to add:
All the lines must ended by the <CR><LF> by standart HTTP.2014-11-20 07:04 AM
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