Search code examples
httppostcommandat-commandgprs

How To Send Data Using sim908 GPRS with Http POST?


I am working on a project which sends GPS longtitude and latitude to a server using Http POST method. I use GPRS of sim908 module and AT+Commands to communicate with this module.

Here are the commands related to Http Post:

  1. AT+HTTPPARA="URL","http://'server'/'path':tcpPort'"
  2. AT+HTTPACTION=1
  3. AT+HTTPDATA= 'size','time'

The first command is used to set http parameters:

  1. 'server' = FQDN or IP address
  2. 'path' = path of file or directoy
  3. 'tcpPort' = default is 80

The second commands tells the module whether to use GET or POST method which is POST here.

The third one is used to recieve server response:

  1. 'size' = number of characters to read
  2. 'time' = set enough time to input all data with length of 'size'

I know how to send data using GET method. I must put a string like: "?var1=value1&var2=value2" at the end of the url. Here is an example: "http://www.example.com/test/getdata.php?TI=12.1&TO=22.2&TR=33.3"

But how is the POST method? Could anyone help me please?

Thanks alot.


Solution

  • [SOLVED]:

    SIM908 does actually support post even though it is poorly documented:

    AT+HTTPINIT

    AT+HTTPPARA="CID",1

    AT+HTTPPARA="URL","http://108.167.133.20/.../index.php"

    NB*** AT+HTTPDATA=, ****NB

    Wait for DOWNLOAD response then send data (bytes needs to be exact)

    AT+HTTPACTION=1

    AT+HTTPREAD=1,100000