Discussion in "New Ideas regarding projects" started by    shirazi2589    Aug 22, 2010.
Wed Apr 06 2011, 10:28 PM


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.
Mon Apr 11 2011, 08:58 PM
#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 Mon Apr 11 2011, 08:59 PM ]
Mon Apr 18 2011, 03:51 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, 03:53 PM ]
Mon Apr 18 2011, 05:27 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

Tue Apr 19 2011, 07:33 PM
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









Fri Apr 22 2011, 09:43 PM
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??
Fri Apr 22 2011, 09:49 PM
or can i have a static IP address instead of dynamic one?
Mon Apr 25 2011, 04:37 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, 12:05 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, 12:48 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

Conversation

Thu Jun 11 2020, 06:27 AM
anudee
sir could please send the code for I2C and wifi interfacing with 8051
scena
Tue May 19 2020, 10:29 PM
Does anyone have microcontroller programming software for STC15F104W (core 8051, 4 k, 128 byte, 6 I/O pin, UART ... DIL8), that works?
Sat May 02 2020, 07:38 PM
Tamu Gurung
Hi I am looking for a assembly language program for a digital decimal counter. Time counts max limit of 2 mins starting from 2.00 mins and ending at 0.00. time is to be displayed on 4 7-segment LED displays. Edsim51 simulator to be used. Thanks
Wed Mar 25 2020, 01:39 PM
Tajammul
Sir kindly send the code file i2c for 8051
ExperimenterUK
Fri Mar 13 2020, 10:36 PM
@ Rohitnani,ABEBE..which project ?
Fri Mar 13 2020, 12:55 PM
ABEBE
how can get hadwere of this project
Rohitnani
Sat Mar 07 2020, 05:11 PM
Sir, Could you please send me the zip file input password....
Wed Feb 26 2020, 04:58 PM
Peter Parker
Is it possible to send multiple messages using only 1 GSM module?
Sat Feb 01 2020, 10:12 AM
Pearl Olin
Hello,
Wed Jan 22 2020, 06:16 PM
MINU CHAUDHARY
I m getting errors while simulation process during interfacing socket output and lcd... Can i get the report of ur project which is same as us.

Downloads

Comments

Mirza123
Thu Jun 25 2020, 03:46 PM
eunicelove124
Mon Jun 22 2020, 03:03 PM
cerouno
Tue Jun 16 2020, 05:10 PM
Marce
Sat Jun 13 2020, 09:43 PM
Davidthils
Thu May 21 2020, 12:44 PM
Jakeror
Thu May 21 2020, 01:28 AM
motorCar
Wed May 20 2020, 07:05 PM
Vordrync
Wed May 20 2020, 11:52 AM

Online

Guests: 94, Members: 0 ...

most ever online: 182184
(Members: , Guests: 182184) on 06 Aug 2010: 05:37 AM

Members: 38215
Newest member: Mirza123