sim900 with exosite


#1

Hello, I have tried the hello message example written in python with my exosite account and everything works fine, now i want to use the same data but instead of using the python example code i would like to use sim900 module to send the POST http request and update the values of the variables.
I don’t know where to start from, any help??


#2

Absolutely. The format that your POST must fulfill are noted here: http://docs.exosite.com/data. An example ‘write’ POST to update variable on the platfrom would look like:

POST /onep:v1/stack/alias HTTP/1.1 
Host: m2.exosite.com 
X-Exosite-CIK: <CIK> 
Content-Type: application/x-www-form-urlencoded; charset=utf-8 
Content-Length: <length> 
<blank line>
message="Hello World Again"&number=10

I don’t know a whole lot about the Sim900. But first look indicates that it should work fine. It looks like the module communicates with the controller via AT commands, you will have to look at the data sheet for the module to nail down what series of commands that need to be sent.


#3

Here are two open projects that have a microcontroller talking to a cellular modem via AT commands, although different modems than you are using, should help a bit.

https://github.com/exosite-garage/stellaris_atdt_cloud - TI Stellaris (Tiva) talking to Telit GSM unit (JanusRC Terminus)
https://github.com/exosite-garage/novatel_rl78_cloud - Renesas RL78 talking to Novatel CDMA modem

As @MDV mentioned, you need to use the AT commands you have available to open a socket and send our HTTP API via TCP, essentially as a big string. Don’t forget the line ending characters for each line including the blank line in between the headers and the body, shown in the previous post as . (It is really a blank line).

You then have to make the AT commands to listen for responses and parse that data.


#4

what does length in Content-Length: refers to??
does this mean the length of data, for example if data will be message=“Hello World Again”&number=10 so the length will be 37 ???


#5

Hello i tried the following on my hyperterminal

AT+CPIN?

+CPIN: READY

OK
AT+CSQ

+CSQ: 17,0

OK
AT+CREG?

+CREG: 0,1

OK
AT+CGATT?

+CGATT: 1

OK
AT+CSTT=“internet.vodafone.net”,“internet”,“internet”

OK
AT+CIICR

OK
AT+CIFSR

10.47.182.51
AT+CIPSTART=“TCP”,“http://m2.exosite.com”,“80”

OK

CONNECT OK
AT+CIPSEND

POST /api:v1/stack/alias HTTP/1.1
Host: m2.exosite.com
X-Exosite-CIK:
Content-Length: 29
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Accept-Encoding: identity

message=hello+world5&number=5
SEND OK
HTTP/1.1 301 Moved Permanently
Date: Thu, 18 Dec 2014 11:41:49 GMT
Server: Apache
Location: https://m2.exosite.com/api:v1/stack/alias
Vary: Accept-Encoding
Content-Type: text/html; charset=iso-8859-1
Content-Length: 249
X-Cnection: close
Connection: keep-alive

301 Moved Permanently

Moved Permanently

The document has moved here.

so what does that response from the server means??


#6

I also tried to change this line

POST /api:v1/stack/alias HTTP/1.1

into

POST /onep:v1/stack/alias HTTP/1.1

and i have the same result :frowning:


#7

Correct. Also, you don’t need the quotation marks unless you actually want them to be part of the value.

That 301 response is very odd. As far as I’m aware we don’t have any Apache servers involved in OneP traffic at all. Do you have any way to know what IP address the modem is finding for m2.exosite.com? We do use Apache in front of Portals, but that shouldn’t touch any OneP traffic.

It’s also possible that your carrier is trying to force you to upgrade your connection to use TLS (HTTPS), but I actually find that unlikely.

I’ll chat with our DevOps guy when he gets in and see if he has any ideas where that might be coming from.


#8

Hello thanks for your response, i was just trying to change anything in my procedures and then i changed this line in the AT commands
AT+CIPSTART=“TCP”,“http://m2.exosite.com”,"80"
into
AT+CIPSTART=“TCP”,“http://m2.exosite.com/api:v1/stack/alias","80

then in my first attempt i got code: 500 which i understand is a server error, so i retried again and i got this but still the values of the variables didn’t change on the server:

HTTP/1.1 200 OK
Content-Type: text/html
Pragma: no-cache
Refresh: 1; URL=http://m2.exosite.com/api:v1/stack/alias
Transfer-Encoding: chunked

d

0

#9

That also doesn’t look like anything that our server would return. I can’t tell you why, but your requests are not making it to our server, some other server is replying with a redirect.


#10

Here’s one thought. On the AT command sets that I’ve used, you don’t include the http:// in the command to open a socket. After all you’re just opening a TCP socket at this level, it doesn’t know what HTTP even is.

Does using AT+CIPSTART="TCP","m2.exosite.com","80" make a difference?


#11

that was it thanks to you i have finally solved this problem i appreciate your professional support so much :smile: i will post the whole AT commands which works for me here for others if they need, I also checked the variables on the server and they were updated

AT+CPIN?

+CPIN: READY

OK
AT+CSQ

+CSQ: 18,0

OK
AT+CREG?

+CREG: 0,1

OK
AT+CGATT?

+CGATT: 1

OK
AT+CSTT=“internet.vodafone.net”,“internet”,“internet”

OK
AT+CIICR

OK
AT+CIFSR

10.143.52.50
AT+CIPSTART=“TCP”,“m2.exosite.com”,“80”

OK

CONNECT OK
AT+CIPSEND

POST /api:v1/stack/alias HTTP/1.1
Host: m2.exosite.com
Accept-Encoding: identity
Content-Length: 29
Content-Type: application/x-www-form-urlencoded; charset=utf-8
X-Exosite-CIK:

message=hello+world5&number=5
SEND OK
HTTP/1.1 204 No Content
Date: Thu, 18 Dec 2014 15:05:43 GMT
Server: nginx
Content-Length: 0
Connection: keep-alive

CLOSED


#12

Wonderful news!

If you make something cool, be sure to post something about it. We always love seeing all the interesting projects that people are working on!


#13

I have one more problem in the same context, the read http request is not working for me. The server has no response at all to my chip, i follow exactly the same steps above but instead of sending the POST i send the GET request as follows:
GET /api:v1/stack/alias?message&number HTTP/1.1
Host: m2.exosite.com
X-Exosite-CIK: CIK
Accept: application/x-www-form-urlencoded; charset=utf-8

i get from the chip that message is sent but i get no reply from server what so ever until the connection is closed

AT+CPIN?

+CPIN: READY

OK
AT+CSQ

+CSQ: 16,0

OK
AT+CREG?

+CREG: 0,1

OK
AT+CGATT?

+CGATT: 1

OK
AT+CSTT=“internet.vodafone.net”,“internet”,“internet”

OK
AT+CIICR

OK
AT+CIFSR

10.51.33.226
AT+CIPSTART=“TCP”,“m2.exosite.com”,“80”

OK

CONNECT OK
AT+CIPSEND

GET /api:v1/stack/alias?message&number HTTP/1.1
Host: m2.exosite.com
X-Exosite-CIK: CIK
Accept: application/x-www-form-urlencoded; charset=utf-8

SEND OK

CLOSED


#14

Are you sending a blank line at the end of the request? That is you need to have a “\r\n\r\n” at the end. That is how you tell the server that you’re done sending headers.


#15

yes you are right i need 2 blank lines not just only one, that’s it