SIM300 GPRS TCP-IP Client mode problem

Status
Not open for further replies.

dhruv_electro

Advanced Member level 4
Joined
Dec 17, 2010
Messages
118
Helped
9
Reputation
18
Reaction score
8
Trophy points
1,298
Location
India
Activity points
2,378
Hi there,

I have used sim300 for GSM SMS application for one or two time successfully. Now this time I want to use sim300 as TCP-IP client and send some text or data to a remote TCP-IP server. So I have connected my GSM Modem (sim300) to my PC and communicate it with "terminal.exe".(Very simple but powerful app for Com port debugging). I have already used it for many times successfully. And I have used "socket test" for TCP IP server on another PC which is connected with internet. But when I have used following commands finally I got nothing: ('>>' for transmition and '<<' for reception)

Code:
>>AT+CIPSHUT $0D    //Disconnect wireless connection
<<SHUT OK

>>AT+CIPSTATUS $0D    //Query current connection status
<<OK
<<STATE: IP INITIAL

>>AT+CIPSPRT=1 $0D    //Set echo ‘>’ prompt and show ‘send ok’
 <<OK

>>AT+CDNSORIP=0 $0D    //Connect with IP address
<<OK

>>AT+CIPSRIP=1 $0D    //Set whether display ‘IP’ add and ‘port’ of sender when receive data
<<OK

>>AT+CIPHEAD=1 $0D    //Add IP Header when receiving data
<<OK

>>AT+CGDCONT=1,"IP","rcomnet" $0D    //Set IP and APN
<<OK

>>AT+CSTT="rcomnet","","" $0D    //Set APN, User Name, Password
<<OK

>>AT+CIICR $0D    //Bring up wireless connection with GPRS
<<OK

>>AT+CIPSTATUS $0D    //Query current connection status
<<OK
<<STATE: IP GPRSACT

>>AT+CIFSR $0D    //Get local IP address
<<115.246.168.26

>>AT+CIPSTATUS $0D    //Query current connection status
<<OK
<<STATE: IP STATUS

>>AT+CIPSTART="TCP","192.168.1.9","21"  $0D    //Star up TCP connection
<<OK
<<STATE: IP CLOSE
<<CONNECT FAIL


my service provider says my SIM card is activated with gprs data plan and i have tested it on gprs supported mobile. I just want to use it with SIM300 and want to send "Hellow there" to a remote PC and want to receive "Fine Here". There is no IP and Port problem because i have used two PC and socket test soft on both PC and successfully communicated with one client and one server
 

you need a public IP to do that. IP that is accessible through internet

Is is so that I can not send data to my internet connected second PC (Its IP is known to me)?

---------- Post added at 18:24 ---------- Previous post was at 18:05 ----------

Yes agreed my IP is in the range of private IP addresses. so what should I do? is there any software that temporarily assign public IP to my PC on which I want to send data or string?

---------- Post added at 18:38 ---------- Previous post was at 18:24 ----------

Is it possible that i send some string/data from my one PC COM port to SIM300 via gprs and receive this string/data on other PC which is connected to internet using some wifi or LAN or any network.

---------- Post added at 18:46 ---------- Previous post was at 18:38 ----------

Hay i got my public ip but when i try to set tcp-ip server in socket test software using that ip it shows me error..??:sad:
 

Hay i got my public ip but when i try to set tcp-ip server in socket test software using that ip it shows me error..?
It doesn't work this way. You need to configure your internet router for forwarding TCP port 21 to the PC and start the port 21 server at the PC. Then you should be able to connect to it through internet using the dynamic IP address of your router. Incomming connections to ports without defined forwarding are rejected at the router.
 
dhruv_electro your AT command is right.
but as FvM pointed out you have to use public IP
first configure router to open incoming port (in your case port 21)forward to the local server-PC (in your case 192.168.1.9)
second- make an exception entry in your firewall, on server-PC
then find out your current public IP by checking your status page of your router
now connect with that IP using AT+CIPSTART

goodluck
 

Hay I have added my port no to port forwarding in my router and then use my dynamic ip (allocated diffrently every time when i restart my system) to send the data and i got received my communication successfully. thanky FvM and taroot. I will give complete step how this can work later on this thread thank you.

---------- Post added at 21:01 ---------- Previous post was at 20:31 ----------

Step to do "Hellow there" and "Fine here" from SIM300 connected PC/MCU to PC which is connected with internet using TCP-IP mode.

1. Add your any port number (in our case it is 21)to your router's port forwarding setting. for help you can see this video(for xp):
How to Forward a TCP/UDP Port on a Router ?

you can find other by googling..

2. Now download terminal.exe and socket test from my first post.

4. Now in socket test soft in "server" tab set your ip (used in port fwd setting in router). and port no (in our case 21).

5. Press start listening button.

6. Find out your dynamic (public IP) using google "my ip". (say this ip as your "dynamic ip" appeared to out side world)

7. Now call your service provider cost care of the SIM card you have used with sim300 and ask for your apn and user name and pass.

8. Now connect your sim300 with terminal.exe (set your port setting). Type the AT cmd listed below in your terminal.exe('>>' for tx and '<<' for rx ):

Code:
>>AT+CIPSHUT $0D    //Disconnect wireless connection
<<SHUT OK

>>AT+CIPSTATUS $0D    //Query current connection status
<<OK
<<STATE: IP INITIAL

>>AT+CIPSPRT=1 $0D    //Set echo ‘>’ prompt and show ‘send ok’
 <<OK

>>AT+CDNSORIP=0 $0D    //Connect with IP address
<<OK

>>AT+CIPSRIP=1 $0D    //Set whether display ‘IP’ add and ‘port’ of sender when receive data
<<OK

>>AT+CIPHEAD=1 $0D    //Add IP Header when receiving data
<<OK

>>AT+CGDCONT=1,"IP","***your APN****" $0D    //Set IP and APN
<<OK

>>AT+CSTT="***your APN***","***your USERNAME***","***your PASS***" $0D    //Set APN, User Name, Password
<<OK

>>AT+CIICR $0D    //Bring up wireless connection with GPRS


please wait here until it appears like bellow:

Code:
<<OK

>>AT+CIPSTATUS $0D    //Query current connection status
<<OK
<<STATE: IP GPRSACT

>>AT+CIFSR $0D    //Get local IP address
<<***your IP for sim300***

>>AT+CIPSTATUS $0D    //Query current connection status
<<OK
<<STATE: IP STATUS

>>AT+CIPSTART="TCP","***your dynamic IP***","***port NO***(21 in this case)"  $0D    //Star up TCP connection
<<OK

now wait again until:

Code:
<<CONNECT OK

>>AT+CIPSEND
> Hellow there$1A

wait again until:

Code:
<<SEND OK

9. Now see in the socket test soft your msg received there.

10. you can type in msg field "Fine here" and press send button. you will find in terminal.exe:

Code:
<<RECV FROM:***your dynamic IP***:***port NO***(21 in this case)
<<+IPD13:Fine here


11. Now you can use this method and establish tcp server on any other pc (must be internet connected and have port forwareded).

12. enjoy

thank you everyone who have supported.
 
Hi dhruv_electro,

Thanks for detailed information regarding connectivity with SIM300 modem. I am doing the same using Wavecom M1206B modem. I think commands are quite different in my modem. But I want to try what you told in your first post about communication between two pcs via TCP/IP. I have downloaded socket test and use built-in hyperterminal to communicate between two pcs...But I can't manage that I don't know why hyperterm is saying unable to connect the ip and port. if you can say in-detailed how to transfer data between two pc both have net connection and one has public ip and other has dynamic ip and port forwarded; it will be really helpful.
 

After you query I have tried to send some text between two pc connected to the interenet using Socket Test and it worked.

I have done it in this way.:
1. Forwarded my port shown in video in above posts.
2. Open Socket test in PC1 and in server tab i have entered my local Ip and port no. and started listning to that port. keep this window open
3. Now in PC2 i have opened socket test and in client tab I have entered my PC1's public IP (dynemic IP) and port no and pressed connect.
4. I can send the msg to server and recive reply from server in PC2 now.

Follow this step and you will get it.

I dont know any thing about your modem
 

    V

    Points: 2
    Helpful Answer Positive Rating
Hi dhruv_electro,

That's a great help. I have managed to test that in two pcs in same sub-net and also between two pcs connected remotely via internet.

I will try for wavecom modem now and update in the forum which might be helpful to others.

Enamul
 

Hi there,
i trying to connect my gsm module sim300 to web server through gprs, but enable to connect, i trying at commands & response as follows
at+cgatt=1
OK
at+cgdcont=1,"ip","airtelfun.com"
+CME ERROR: 3
at+cgdcont=1,"ip","airtelgprs.com"
ERROR
at+cgdcont=1
OK
at+cdnscfg="202.56.230.5","202.56.240.5"
OK
at+csit="airtelgprs.com","none","none"
ERROR
at+csit="airtel.com"
ERROR
at+cgdcont=1,"IP","airtelgprs"
OK
at+cdnscfg="202.56.230.5","202.56.240.5"
OK
at+csit="airtelgprs","none"
ERROR
at+csit="airtelgprs"
ERROR
at+csit="airtelgprs","none",""
ERROR
at+ciicr
ERROR
at+ciicr=?
ERROR
at+ciicr?
OK
at+cifsr?
OK
at+csit="airtelgprs","",""
ERROR

apn: airtelgprs
username: none
password: none
 

Hai,

You have to use it like this:
Code:
AT+CGATT=1
>OK
AT+CGDCONT=1,"IP","airtelgprs"
>OK
AT+CSTT="airtelgprs",,
>OK
AT+CIICR
>OK
AT+CIFSR
>will get ip address here
 

i tried & getting result like this

AT+CGATT=1
> +CME ERROR: 107

AT+CGDCONT=1,"IP","airtelgprs"
>OK

AT+CSTT="airtelgprs",,
>OK

AT+CIICR
>OK

AT+CIFSR
>OK

AT+CIPSTATUS
>OK
STATE: IP START
 

AT+CGATT=1
> +CME ERROR: 107

Hai,
According to SIM300 datasheet for AT commands, this error means GPRS services not allowed.
Does your sim has enough balance or is it activated for internet?
 

Hai,
i remove sim card from gsm module & insert in my cell phone & access internet via gprs, able to surf but insert in gsm module & execute command AT+CIPSTATUS module respons is OF TCP connecting but not get result from these responce
 

Hai,
Once you enter into a state other than IP INITIAL, and if you want to start Gprs context again, you have to shut down the current context using AT+CIPSHUT
Code:
at
OK
at+csq
+CSQ: 24,0

OK
at+cgatt=1
OK
at+cgdcont=1,"IP","airtelgprs"
OK
at+cstt="airtelgprs",,
OK
at+cipstatus
OK

STATE: IP START
at+ciicr
OK
at+cipstatus
OK

STATE: IP GPRSACT
at+cifsr
223.183.234.83
at+cipstatus
OK

STATE: IP STATUS
at+cdnsorip=1
OK
at+cipstart="TCP","www.google.com","80"
OK

CONNECT OK
at+cipsend
> hai
SEND OK
at+cipclose
CLOSE OK
at+cipshut
SHUT OK
at+cgdcont=1,"IP","airtelgprs.com"
OK
at+cstt="airtelgprs.com",,
OK
at+ciicr
OK
at+cifsr
223.191.252.229
at+cipstart="TCP","www.google.com","80"
OK

CONNECT OK
at+cipshut
SHUT OK
 



I tried this code but i got CME error 6 and CME error7(on another modem), which says PH-FSIM PIN REQUIRED and PH - FSIM PUK REQUIRED .

I tried to check my modem status (regarding PIN & PUK) using AT+CPIN? , modem gives READY response.

What possible reasons could be for above errors ?
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…