Discussion in "New Ideas regarding projects" started by    shirazi2589    Aug 22, 2010.
Thu Apr 07 2011, 03:58 am


he is setting up a server called Hercules SW...below is the image

shirazi2589


Handy program, it works for me .
should work for you.

Some routers have extra settings to block access from outside.
ask your friend to double check his router.
What model is it ?

Try doing local tests using a second computer in your house or your friends.

Ask other people to set up test servers,your friends system may be
unusual in some way.
Tue Apr 12 2011, 02:28 am
#include<reg52.h>

#include<string.h>

sbit one = P2^0;
sbit two = P2^1;


void init()
{
	TMOD=0X20;
	TH1=0XFD;
	SCON=0X50;
	IE=0x10;
	TR1=1;
}

char serialrx(void)
{
	  
     
	  while(RI==0);
	  RI=0;
	  return(SBUF);
}

void serialtx(unsigned char x)
{
	  SBUF=x;
	  while(TI==0);
	  TI=0;
}

void trans(unsigned char * x)
{
  while(*x!='\0')
    {
	   serialtx(*x);
	   x++;
	}
}

void check(unsigned char *p)
{
   if(strcmp(p,"AT+CIPSTART=\"TCP\",\"www.google.com\",\"80\"\r")==0)
     {
   while(serialrx()!='O');
   while(serialrx()!='K');
   while(serialrx()!='\r');
   while(serialrx()!='C');
   while(serialrx()!='O');
   while(serialrx()!='N');
   while(serialrx()!='N');
   while(serialrx()!='E');
   while(serialrx()!='C');
   while(serialrx()!='T');
   while(serialrx()!=' ');
   while(serialrx()!='O');
   while(serialrx()!='K');
   while(serialrx()!='\r');
   return;
   }

else if(strcmp(p,"AT+CIFSR\r\n")==0)
	 {
	    unsigned char z[15];
	    unsigned char j,k=0;
		unsigned char p=0;
		
   haha: j=0; 
         while(serialrx()!='\r')
		{
		  z[j]=serialrx();
		  j++;
		}
		 //trans("\r\n bhao  \r\n");
	    z[j+1]='\0';
	//	serialtx('\r');
        while(z[p]!='\0')
		{
		  if(z[p]=='.')k++;
		  //trans("\r\n bhao  \r\n");}
		  p++;
		 
		} 
		 if(k==3){
		    trans("\r\n bhao  \r\n");  
		    return;}
	else goto haha;
	}
else 
{
  	while(serialrx()!='O');
   while(serialrx()!='K');
   while(serialrx()!='\r');
   return;
}

}


void main()

{
   unsigned char *s1,*s2,*s3,*s4,*s5,*s6,*s7,*s8,*s9,*s10,*s11,*s12;
   unsigned char z;
   unsigned char killit[6];
   init();
 //  q="\r\nAT\r\n";
   
s1="AT\r\n";
s2="AT+CGATT=1\r\n";
s3="AT+CGDCONT=1,\"IP\",\"airtelgprs.com\"\r\n";
s4="AT+CSTT=\"airtelgprs.com\",\"\",\"\"\r";
s5="AT+CIICR\r\n";
s6="AT+CIFSR\r\n";
s7="AT+CIPSTART=\"TCP\",\"www.google.com\",\"80\"\r";
s8="AT+CIPSEND\r\n";
s9="AT+CLOSE\r\n";
s10="AT+SHUT\r\n";
s11="\r\n$GPRMC,161229.487,A,1904.3636,N,07254.0158,E,0.13,309.62,120598, ,*10,shadab\r\n";
s12="\r\n$GPRMC,161229.487,A,1904.9505,N,07252.7876,E,0.13,309.62,120598, ,*10,ehsan\r\n";

   trans(s1);
   check(s1);
   
   trans(s2);
   check(s2);
  
   trans(s3);
   check(s3);
 
   trans(s4);
   check(s4);
   
   trans(s5);
   check(s5);
   
   trans(s6);
   check(s6);
   
   trans(s7);
   check(s7);
   
   trans(s8);
   while(serialrx()!='>
');
   do
   {
	trans(s11);
    trans(s12);
    for(z=0;z<6;z++)killit[z]=serialrx();
	killit[6]='\0';
   	trans("\r\n");
	trans(killit);
	trans("\r\n");
   } 
   	while(strncmp(killit,"killit",6)!=0);
   
   
   {
   trans(s11);
   trans(s12);
   } */
   trans(s9);
   check(s9);
   
   trans(s10);
   check(s10);

  	while(1);
   
}


the above is the code for my GSM modem..its working in proteus. i havent tried actually.
the problem is i want to improve my code.
1) while(serialrx()!='>');
do
   {
	trans(s11);
    trans(s12);
    for(z=0;z<6;z++)killit[z]=serialrx();
	killit[6]='\0';
   	trans("\r\n");
	trans(killit);
	trans("\r\n");
   } 
   	while(strncmp(killit,"killit",6)!=0);

firstly i want the GPRS connection to terminate when i receive "killit" from the server. i have to wait at the end to receive 6 characters before i can check. i want it to continue(without waiting for string) but when the string is received it should compare and then do the necessary action.. how should i do that.
2)also as you can see that the command
while(serialrx()!='O')]
i dont want this instead it should accept the string and then compare with "OK" if its fine then proceed or else again send the command "AT" or as such

how should i improve my code on above basis

THIS IS FOR MY GPRS CONNECTION MODE


[ Edited Tue Apr 12 2011, 02:29 am ]
Mon Apr 18 2011, 09:21 pm

make one of your PC as a server, put WAMPP and Java app on it to make a server.



ajay how do i do it????


[ Edited Mon Apr 18 2011, 09:23 pm ]
Mon Apr 18 2011, 10:57 pm
@ shirazi2589
u has to tackle with serial interrupts for better improvement of coding
as in polling method u has to wait for the data to come
i recently make a code for appliances control using GSM modem sim300dz
u can refer it also

Wed Apr 20 2011, 01:03 am
hey ajay this thing is blowing my head off. ill tell u. i port forwarded my router at port 4444.

i started my TCP server i connected via local host it got connected.

i.e telnet localhost 4444 // it connects

i then found out my ip from whatsmyip.com it was 120.61.138.125 . i then connected via that ip

telnet 120.61.138.125 4444 // Connecting To 120.61.138.125...Could not open connection to the host, on port 44
44: Connect failed // this is the reponse.

ill attach the screen shots below









Sat Apr 23 2011, 03:13 am
also moderators one more doubt, the ip address of my server would keep on changing everytime i log in. so what should i do abt the code written in the uC. I couldnt burn the ip add everytime i start tracking. one thing i have thought, is to send ip add as an SMS message to GSM modem and the uC would extract the ip add.

What do u all think on this??
Sat Apr 23 2011, 03:19 am
or can i have a static IP address instead of dynamic one?
Mon Apr 25 2011, 10:07 pm
you can use dyndns.com to update your dynamic IP. and in your code you just program the domain which you're using.

regardin your port forwarding problem. Its better if you can post screenshot of your router's internal pages, that way it will be easy to help you out.
Sat Apr 30 2011, 05:35 am
heil ajay, heil ajay thnx ajay for making this project complete in every sense. couldnt have been possible without you. all went smoothly in the vivas all were astonished to see this created at a BE level but we did it.
Sat Apr 30 2011, 06:18 pm
@shirazi2589 you did a good amount of hardwork and it paid off
Really happy for you... do post some screenshots of your work

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Michailqfh
Fri Mar 29 2024, 01:53 am
Bobbyerilar
Thu Mar 28 2024, 08:08 am
pb58
Thu Mar 28 2024, 05:54 am
Clarazkafup
Thu Mar 28 2024, 02:24 am
Walterkic
Thu Mar 28 2024, 01:19 am
Davidusawn
Wed Mar 27 2024, 08:30 pm
Richardsop
Tue Mar 26 2024, 10:33 pm
Stevencog
Tue Mar 26 2024, 04:26 pm