- Thu Jun 01, 2017 11:50 am
#66613
Example using Google.com.
- First create a connection using AT+CIPSTART:
If successful. it will return:
- After connecting, you'll have to tell the server what you want; in your case GET (retrieve) a page.
Code: Select allGET / HTTP/1.0
Host: google.com
Connection: keep-alive
Accept: */*
First you need to know (by counting) the length of your request (in above example it's 68) and send it using the AT+CIPSEND=<length> command.
when succesful, it will return: - Now you need to send your request and headers:
Code: Select allGET / HTTP/1.0
Host: google.com
Connection: keep-alive
Accept: */*
When succesful, you'll get this as a result:
- To get the actual data, use the command +IPD,<length>:
This *should* (see below for note) get you the actual HTTP-answer including payload (in our case an HTML page):
Code: Select allHTTP/1.0 302 Found
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Referrer-Policy: no-referrer
Location: http://www.google.nl/?gfe_rd=cr&ei=nzswWdXxMbOk8weHu5ioDw
Content-Length: 258
Date: Thu, 01 Jun 2017 16:06:55 GMT
Connection: Keep-Alive
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.nl/?gfe_rd=cr&ei=nzswWdXxMbOk8weHu5ioDw">here</A>.
</BODY></HTML>
- Lastly, close the connection with the server using the command:
Which wil return:
Because I'm living in The Netherlands, Google will redirect me to the Dutch server (in the .nl TLD) of Google.
NOTE: To be honoust, I wasn't able to get the actual page, but
ESPlorer does, so I must be doing something (minor?) wrong on a manual console.
Either way: I don't think using AT-command would be the way to go, but this is how it *should* be done.
Assumption is the mother of all f*ckups. At least: that's what I'm assuming.