0
\$\begingroup\$

I have a SIM5360 module, with a Vodafone card, and I would like to connect to some web services, to send and receive data in JSON format, which I have implemented on an AWS server.

To execute the AT Commands I use the Putty tool.

I tried to do it first using HTTP functions with the following calls:

AT+CHTTPACT=”XX.XXX.XXX.169″, 8080<CR>

+CHTTPACT:REQUEST

GET /XXXDWP/rest/user/list HTTP/1.1<CR><LF>
Host: XX.XXX.XXX.169:8080<CR><LF>
Content-Type: application/json<CR><LF>
Accept: */*<CR><LF>
<CR><LF>
<CR><LF>
<SUB>

<Ctrl + Z>

Other examples:

GET /XXXDWP/rest/user/list HTTP/1.1\r\nHost: XX.XXX.XXX.169:8080\r\nAccept: */*\r\nContent-Type: application/json\r\n
GET /XXXDWP/rest/user/list HTTP/1.1 Host: XX.XXX.XXX.169:8080 Accept: */* Content-Type: application/json

But the result of my calls is always:

+ CHTTPACT: 227

I have also tried to do it using TCP functions with the following calls:

AT+NETOPEN

AT+CIPOPEN=0,”TCP”,”XX.XXX.XXX.169″,8080

AT+CIPSEND=0,
>GET /XXXDWP/rest/user/list HTTP/1.1<CR><LF>
Host: XX.XXX.XXX.169:8080<CR><LF>
Content-Type: application/json<CR><LF>
Accept: */*<CR><LF>
<CR><LF>
<CR><LF>
<SUB>

<Ctrl + Z>

Other examples:

>GET /XXXDWP/rest/user/list HTTP/1.1\r\nHost: XX.XXX.XXX.169:8080\r\nAccept: */*\r\nContent-Type: application/json\r\n
>GET /XXXDWP/rest/user/list HTTP/1.1 Host: XX.XXX.XXX.169:8080 Accept: */* Content-Type: application/json

But the result of my calls is always:

……..
http/1.1 400 bad request
server: apache-coyote/1.1
transfer-encoding: chunked
……..

If someone could give me a hand and give me the steps to follow to correctly configure the SIM5360 and be able to make GET / POST calls to the server.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

The sequence below is taken from the SIM5360 AT command manual, chapter 18.5.

Make sure you have good network by checking it from

AT+COPS?

Now we're going to use the Secure Hyper Text Transfer Protocol Service. Start by sending

AT+CHTTPSSTART

wait for OK, then send

AT+CHTTPSOPSE="<host>",<port>[,<server_type>]

and wait for OK, then send

AT+CHTTPSSEND=<len>[,<filename>]

len is the length of request in bytes and filename is the name of the file you want the data to upload from. After this command you will receive >, now send your GET request

GET /xxxx.xxx
Host: xxx.xxxx.xxx    
User-Agent: curl/x.xx.x    
Content-Length: x

Once your request matches the length you specified, SIM5360 will send your data and return

OK
+CHTTPS: RECV EVENT

indicating that the server responded. You can read the response by giving the command:

AT+CHTTPSRECV=<len>

The peer can close automatically depending upon the server, but if you want to close it manually then send

AT+CHTTPSCLSE

and you will receive

+CHTTPSNOTIFY: PEER CLOSED
OK

At this point, since the Secure HTTP Service is still running, you can send another GET request from AT+CHTTPSOPSE command. But if you want to stop the service, you can send

AT+CHTTPSSTOP

and SIM5360 will correspondingly respond OK on success.


I used api.thingspeak.com server for GET request and the server responded as expected by "1". In my case the URL for the GET request is api.thingspeak.com/update?api_key=xxxxxxxxxxxxxxxxx&field1=xx

Below is copied from my terminal:

AT+CHTTPSOPSE="api.thingspeak.com",80,1
OK

AT+CHTTPSSEND=122
>GET /update?api_key=xxxxxxxxxxxxxxxxx&field1=xx
Host: api.thingspeak.com
User-Agent: curl/7.45.0
Content-Length: 0    
OK
+CHTTPS: RECV EVENT
+CHTTPSNOTIFY: PEER CLOSED

AT+CHTTPSQECV=512
OK
+CHTTPSRECV: DATA,1
1
+CHTTPSRECV: 0

Hope this helps.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.