[poll] Vehicle Tracking using GPS
Mon Apr 04 2011, 12:04 pm
hey ajay,
i started developing the uC code for the above project. but i am going through a lot of probs..
I am trying to send data through GPRS via SIM300 modem. The logic of my program should be.
t should send the data till it receives "dieman" from the server.
i started developing the uC code for the above project. but i am going through a lot of probs..
I am trying to send data through GPRS via SIM300 modem. The logic of my program should be.
t should send the data till it receives "dieman" from the server.
Mon Apr 04 2011, 12:04 pm
AT OK AT+CGATT=1 OK AT+CGDCONT=1,"IP","airtelgprs.com" OK AT+CSTT="airtelgprs.com","","" OK AT+CIICR OK AT+CIFSR 212.22.22.22 //EG OF AN IP ADDRESS AT+CIPSTART="TCP","http://www.google.com","80" OK CONNECT OK AT+CIPSEND > THIS IS THE DATA I WANNA SEND // YOU CAN SEND THE DATA VIA GPRS NOW [CTRL+Z] SEND OK
this is the code which i would like to implement
Mon Apr 04 2011, 12:06 pm
now i implemented the C version but my code is very inefficient. I could have ignored the response from the modem by simply inserting delays but i want my code such that if the reply from the modem is not "OK" it should transmit the command again.
the C code is as follows
pls help me find the correct code
the C code is as follows
#include<reg52.h> #include<string.h> unsigned char msg1[100],x=0; unsigned char *s1="AT"; unsigned char *s2="AT+CGATT=1"; unsigned char *s3="AT+CGDCONT=1,\â€airtelgprs.com\â€"; unsigned char *s4="AT+CSTT=\â€airtelgprs.com\â€,\""\",\"""\"; unsigned char *s5="AT+CIICR"; unsigned char *s6="AT+CIFSR"; unsigned char *s7="AT+CIPSTART=\â€TCP\â€,\â€http://www.google.com\â€,\â€80\â€â€; unsigned char *s8="AT+CIPSEND"; unsigned char *s9="AT+CLOSE"; unsigned char *s10="AT+SHUT"; void send(unsigned char *x) { while(*x!='0') tx(*x); } void tx(unsigned char x) { SBUF=x; while(TI==0); TI=0; } void delay(void) { unsigned int i; for(i=0,i<=65535;i++); } void serialinit() { IE=0X90; TMOD=0X20; TH1=0XFD; SCON=0X50H; TRI=1; } void serialrx(void) interrupt 4 { msg1[x]=SBUF; RI=0; x++; } void main() { char ch; serialinit(); do { send(s1); //send AT delay(); if(!strncmp(msg,"\r\nOK",4)) //compare if OK is received ch=1; else ch=0; } while(ch==0); do { send(s2); //send AT+CGATT=1 delay(); if(!strncmp(msg,"\r\nOK",4)) //compare if OK is received ch=1; else ch=0; } while(ch==0); do { send(s3); //send AT+CGDCONT=1,"IP","airtelgprs.com" delay(); if(!strncmp(msg,"\r\nOK",4)) //compare if OK is received ch=1; else ch=0; } while(ch==0); do { send(s4); //send AT+CSTT="airtelgprs.com","","" delay(); if(!strncmp(msg,"\r\nOK",4)) //compare if OK is received ch=1; else ch=0; } while(ch==0); do { send(s5); //send AT+CIICR delay(); if(!strncmp(msg,"\r\nOK",4)) //compare if OK is received ch=1; else ch=0; } while(ch==0); do { send(s6); //send AT+CIFSR delay(); if(msg[3]> =48 || msg<=57) // its an ip address so it has to be a no. so ascii value compared ch=1; else ch=0; } while(ch==0); send(s7); // SEND AT+CIPSTART="TCP","http://www.google.com","80" delay(); // now here there are 2 responses OK CONNECT OK i dont how to compare // and hence i am just waiting for sometime send(s8); while(msg(0)!='> '); while(strncmp(msg,"\r\ndieman")!=0) send("this is what i want to send"); do { send(s9); //send AT+CIPCLOSE delay(); if(!strncmp(msg,"\r\nOK",4)) //compare if OK is received ch=1; else ch=0; } while(ch==0); do { send(s10); //send AT+CIPSHUT delay(); if(!strncmp(msg,"\r\nOK",4)) //compare if OK is received ch=1; else ch=0; } while(ch==0); }
pls help me find the correct code
Mon Apr 04 2011, 11:39 pm
@ shirazi2589
directly going to a full code in GSM is difficult task
do it step by step even with a simple AT command
now there are some commands that has other parameters not OK response then u ahs to check that also if u use that and if u use simple commands that has only OK response then has to concentrate on this
do it as
suppose u send this command
AT+CIPSEND
after this u has to send enter as in ur code ur not sending it
send it as
unsigned char *s1="AT/r";
instead of
unsigned char *s1="AT";
after this u has to wait for ok
go ahead step by step then it will be easy
directly going to a full code in GSM is difficult task
do it step by step even with a simple AT command
now there are some commands that has other parameters not OK response then u ahs to check that also if u use that and if u use simple commands that has only OK response then has to concentrate on this
do it as
suppose u send this command
AT+CIPSEND
after this u has to send enter as in ur code ur not sending it
send it as
unsigned char *s1="AT/r";
instead of
unsigned char *s1="AT";
after this u has to wait for ok
while(RI==0); if(SBUF=='O') { RI=0; while(RI==0); if(SBUF=='K') { RI=0; // u receive ok now send next command } } else { // send command again }
go ahead step by step then it will be easy
Tue Apr 05 2011, 10:04 am
hello,
can u plz tell me ,is gps has also At command like GSM?
how i can extract data(ALT,Long,speeed etc) from gps masg.
plz remove my confusion.
can u plz tell me ,is gps has also At command like GSM?
how i can extract data(ALT,Long,speeed etc) from gps masg.
plz remove my confusion.
Tue Apr 05 2011, 10:26 am
@ yashshailesh
GPS send a string of data in NMEA format
see this
http://www.kh-gps.de/nmea-faq.htm
normally it send a string @ 1HZ
then u has to find out the data u want from the string
GPS send a string of data in NMEA format
see this
http://www.kh-gps.de/nmea-faq.htm
normally it send a string @ 1HZ
then u has to find out the data u want from the string
Wed Apr 06 2011, 09:57 pm
hey ajay and all,
i am having a problem in setting remote connection via telnet..this is what i am doing.
in my services.msc i have activated TELNET and disabled firewall there.
i asked my friend to do the same. i then asked for his ip from whatsmyip.com. he then gave me the ip. i then asked him to activate the TCP SERVER at port 4444. i the typed on my cmd.
telnet IP add 4444
but Connecting To IP add..Could not open connection to the host, on port 4444:
Connect failed
what should i do..
i am having a problem in setting remote connection via telnet..this is what i am doing.
in my services.msc i have activated TELNET and disabled firewall there.
i asked my friend to do the same. i then asked for his ip from whatsmyip.com. he then gave me the ip. i then asked him to activate the TCP SERVER at port 4444. i the typed on my cmd.
telnet IP add 4444
but Connecting To IP add..Could not open connection to the host, on port 4444:
Connect failed
what should i do..
Wed Apr 06 2011, 09:58 pm
as you said
how should i do it..
pls help
make one of your PC as a server, put WAMPP and Java app on it to make a server.
how should i do it..
pls help
Wed Apr 06 2011, 11:12 pm
but Connecting To IP add..Could not open connection to the host, on port 4444:
Connect failedshirazi2589
Have disabled your firewall in Settings ->Firewall.
Does your friend have a router, and if so, has he set up port forewarding ?
What TCP SERVER is he setting up ?
[ Edited Wed Apr 06 2011, 11:13 pm ]
Thu Apr 07 2011, 01:25 am
Have disabled your firewall in Settings ->Firewall.
yes i have disabled my and his firewall
Does your friend have a router, and if so, has he set up port forewarding ?
He has a router and the port 4444 is forwarded...
What TCP SERVER is he setting up ?
he is setting up a server called Hercules SW...below is the image
Powered by e107 Forum System