sim900 c code startcode to work with

Status
Not open for further replies.

Brecht

Newbie level 5
Joined
Dec 8, 2012
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,349
Dear,

Im a student

I would like to connect this* gprs-module to lpc1768, this is an arm-processor.

So I would have to write C/C++ files, Im currently using mbed.org but this library doesnt include gsm/gprs-files.

I need to send data like I would feed data to pachube/cosm.com,
I would send data to a webserver basically (the gprs part is done by me, the webserver is made by somebody else)

I would only receive a simple command like 'reset the system'

Is it possible for me to use code from this:

https://code.google.com/p/gsm-s...

I would like to have a startcode to work with/modify
but starting from scratch would not be possible for my current programming skilllevel/time schedule

thanks if you can help me out..

ps: somebody told Im supposed to use sockets, is this true or false?

*https://www.open-electronics.org/small-breakout-for-sim900-gsm-module/
 

Your link to the code is broken so we can't view that.
Look at the last FAQ on this page **broken link removed**; it shows you how to send data to a web server.
Sockets is an operating system API for communicating over a network. If you were writing a program for the PC you would use sockets.
 

thank you for the reply

its to clear to me if still got some research to do, so this site is very useful

if I bump in some new clearly defined problems, i can post them later on

sincere

- - - Updated - - -

https://code.google.com/p/gsm-shield-arduino/source/browse/branches/CompatibleVer/?r=42

i hope this link works now

- - - Updated - - -

Do I need to use sockets on the microcontroller side if I want to receive data?

the thing that confuses me is that Im using at-command but also sockets while I get the impression everything is done by at-commands

and sockets is used in wifi / networks?
or does my gprs have its own ip-adres?

but unfortunately I dont really know yet where Im talking about..

please help

- - - Updated - - -

let say I use

http://www.prasannatech.net/2008/07/socket-programming-tutorial.html

http://www.pythonprasanna.com/Papers%20and%20Articles/Sockets/tcpserver.c

how would at-commands fit in here?

also do I need to use udp or tcp?

thx..
 

You don't use Sockets on a micro-controller. You control the SIM900 by sending it AT commands; which, once you get a grasp of the concept, is quite simple. You'll need to do a bit of research to figure out what is required. Check out this web site: http://www.developershome.com/sms/atCommandsIntro.asp

does my gprs have its own ip-adres?
Once you connect make a connection to the network the SIM900 will be given an IP address.

These examples use Sockets and are not applicable

also do I need to use udp or tcp?
If you are sending to a Web Server then you would use TCP.
 

wow supergreat reply

thank you!

they confused me with these sockets, at-commands is pretty simple

I used arduino prototype to start with.. it was just basically nothing but at-commands (link: **broken link removed**)

I will use tcp

thanks again.. supergreat help

I will keep working on it

- - - Updated - - -

allow me to ask one more question:

how is the receiving done?

is this a loop that makes the microcontroller do an aerial search for a system that wants to connect with it (lets say every second),
and the computer tries to make connection ( lets say for a duration of 5 seconds)

is this how it gets done ? Is this kind of thinking correct?

thanks for help..
 

I'm not exactly sure of what you are asking.

Once the SIM900 is turned on (and it's been configured properly) it will start search for cell towers - often it will find several in the area. It will register itself with the one that is part of your service provider's network (i.e AT&T, T-Mobile, etc.) and that has the best connection. It will continue to monitor the connection without any intervention on your part and switch cell towers if necessary; for example if your device is moving.

When you want to send data to your web server, you send AT commands to create a GPRS connection and then send your data - as outline in **broken link removed**
 

Dear,

sorry I might have been incomplete with my question

I also wish to send data from the web server to the microcontroller/gprs-module

Is this done similar as sending data to the web server?
I was thinking this would be some kind of loop that uses one or more at-commands..

thanks for the help..
 

I also wish to send data from the web server to the microcontroller/gprs-module.
Getting a web server to send a request to your SIM900 is a bit tricky and there are several obstacles you have to overcome to accomplish that:
  • The SIM900 must be put into Server mode - this can be really tricky if you want to simultaneously support client mode
  • Since the SIM900 will get it's IP address from the network, and is therefore not known in advance, you must have a means to tell your clients what the SIM900's IP address is - your service provider may give you a fixed IP address, but in most cases it won't
  • Your service provider must allow incoming connections - for security purposes, most service providers block incoming requests
Assuming you can meet those 3 points, you can configure the SIM900 to be a server by following the instruction in this document: http://www.svtehs.com/simcom/docs/SIM900_AN_TCPIP_V100.pdf


However, if you want to both send data to the server and get data from it there's another way...
In a network-based conversation between 2 devices one is considered the client (the one that makes a request) and one is considered the server (the one that replies to the request). When you open a browser and go to a web site, your browser (computer) is the client and the web site is the server. When you make a request to the server you can give it parameters that tell it to do something. And the web server can return just about anything as a response to your request. It can return a web page, picture, XML data, or text that means something to your application - all depends on how your server is configured.

Let's say you have a web site with a web page named "StoreData.php", and the purpose of the web page is to store data you send it in a database. To make the example simple lets send the data in a "GET" request. A request to this page may be something like "74.125.228.35/StoreData.php?Data=this_is_my_data". Once you've established a GPRS connection you could make this request by sending the following:
Code:
AT+CIPSTART='TCP','74.125.228.35','80' \n                       // Will return 'CONNECT OK' to indicate it's connected to the server
AT+CIPSEND\n                                                    // Issue Send Command (wait for module to return '>' to indicate it's ready to receive data

GET /StoreData.php?Data=this_is_my_data HTTP/1.1\n             // Send request 
Host: 74.125.228.35\n
Accept: */*\n
Accept-Language: en-us\n
\n
Ctrl-Z

Anything the server returns as a response will be sent out the SIM900's serial port after you send the Ctrl-z. For example, in this case it could return a status message or the ID of the data it just stored.


To get the data from the server you could have another page "GetData.php" that returns data to the SIM900. A request to this page may be something like "74.125.228.35/GetData.php?ID=1". The following commands would accomplish that:
Code:
AT+CIPSTART='TCP','74.125.228.35','80' \n                       // Will return 'CONNECT OK' to indicate it's connected to the server
AT+CIPSEND\n                                                    // Issue Send Command (wait for module to return '>' to indicate it's ready to receive data

GET /GetData.php?ID=1 HTTP/1.1\n                     // Send request 
Host: 74.125.228.35\n
Accept: */*\n
Accept-Language: en-us\n
\n
Ctrl-Z

The server will return the data you requested - the SIM900 will send it out the serial port after you send the Ctrl-Z.
 

Dear GSM Man,

currently I use pachube/cosm to send data to,
Is there a site (free or pay) that I can use to test the receiving part?

sincere
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…