问题
I'm currently using a SIM5320e 3G development board with CoolTerm and a PL203 serial to USB connector. The aim is once I can make a successful HTTP/HTTPS GET request I can then incorporate it into a micro-controller project that will transmit data from a remote sensor to the internet vis EDGE/GPRS/3G.
However my issue is I have yet to make a successful GET request. I have searched the internet and this site and there is not a vast amount of info on this board, besides the data sheet, which is quite complex. I'm sure I'm missing a crucial step but can't see what it is.
Here is the (typical) terminal output alongside my comments
AT
OK // Module is working
AT+CGSOCKCONT=1,"IP","giffgaff.com" // Setting the APN I am using Giffgaff UK sim card, this is the APN
OK
AT+CSOCKSETPN=1 // Not sure what this step is, but seems to need to happen according to the application note
OK
AT+CIPMODE=0 // Same again
OK
AT+NETOPEN=,,1
Network opened
OK // Opens the network connection via GPRS
AT+IPADDR
+IPADDR: 10.146.130.153
OK // Appears to successfully get a network address
AT+CHTTPSSTART
OK // Starts the HTTPS/HTTP stack
AT+CHTTPSOPSE="www.iforce2d.net", 80,1
OK // Opens a connection to the host on port 80
AT+CHTTPSSEND=23 // Request to send 23 chars of data
>GET /test.php HTTP/1.1 // Web page exists, displays the time in UTC
OK // Says OK
AT+CHTTPSSEND
OK
+CHTTPSSEND: 0 // Says sent with no issue
AT+CHTTPSSEND? // However, I query it
+CHTTPSSEND: 0 // However has sent no chars!
OK
+CHTTPSNOTIFY: PEER CLOSED
AT+CHTTPSRECV? //Query if anything has been received?
+CHTTPSRECV: LEN,0 // Hasn't received anything!
OK
What am I missing?
Thanks for looking.
Will.
回答1:
I hope this will be useful. I used TeraTerm to send these commands to my SIM5320E
. So I used <Ctrl M>
and <Ctrl J>
instead of '<CR> <LF> OR /n/r'
characters.
Network setup
AT+CGDCONT=1,"IP","<your APN>","0.0.0.0"
AT+CGSOCKCONT=1,"IP","<your APN>"
AT+CSOCKSETPN=1
Start HTTP service You can stop and start service if it's not responding properly.
AT+CHTTPSSTART
AT+CHTTPACT="www.iforce2d.net",80
HTTP GET request
GET /test.php HTTP/1.1 <-- don't hit enter, instead hit the below 2 keys
<Ctrl M>
<Ctrl J>
Host: www.iforce2d.net <-- don't hit enter, instead hit the below 2 keys
<Ctrl M>
<Ctrl J>
Connection: close <-- don't hit enter, instead hit the below 4 keys. This is useful when connecting to REST APIs to download the the respective result only.
<Ctrl M>
<Ctrl J>
<Ctrl M>
<Ctrl J>
To end the command and to receive results:
<Ctrl Z>
You will receive a lot of data here.
Stop HTTP service
AT+CHTTPSCLSE
AT+CHTTPSSTOP
You will get the contents of the website. Probably it should contain the data you need (I didn't test the content. May be you will need to tweek the result a bit.)
来源:https://stackoverflow.com/questions/48399785/sim5320e-https-stack-cant-make-successful-get-request