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

Tue Jan 14 2020, 07:08 AM
shubham kharade
when i am trying to simulate the program in Proteus 8 professional, I am getting some errors as cannot find module file dhtxx.md can u help me
Tue Dec 17 2019, 01:44 PM
Devangi
hello..i am programming industrial timer using 8051 with 24lc64 eeprom. i have query in storing the 3 diff value in eeprom with enter button. can anyone share c code ?
Tue Dec 17 2019, 10:30 AM
Andrius
Hello. Can anyone share the code in Bascon and scheme in Proteus?
Thu Nov 21 2019, 12:30 PM
raj2555
how to interface 8051 microcontroller with NRF24L01+ module
ExperimenterUK
Sat Oct 12 2019, 10:23 PM
Log in.. then post your code in the 8051 forum
Sat Oct 12 2019, 10:18 AM
Bhadra Sajikumar
i am doing a countdown timer with 8051 for my project, unfortunately our professor had to take a leave of absence before he could teach us most of it.. can someone explain the .asm code of it for me?
Mon Sep 23 2019, 07:37 AM
Nathaniel
I am doing a project for my schools wireless security system with cameras,sensors and spot lights using 8051 micro controller, could you help me out with the design and its source code.
Wed Sep 18 2019, 08:48 PM
Caryn Kover
Thank you for your time,
ExperimenterUK
Mon Aug 05 2019, 07:09 PM
@Ismail ..post in forum, give details
Mon Aug 05 2019, 04:33 PM
Ismail balghmi
Hello. Please I won't download

Downloads

Comments

Nippy56
Sun Jan 19 2020, 02:13 AM
usb5962
Sat Jan 11 2020, 10:42 AM
elt
Tue Jan 07 2020, 06:53 PM
mg3914697
Tue Jan 07 2020, 12:42 PM
afds43
Sun Dec 29 2019, 05:54 AM
Rupeshpatil
Fri Dec 27 2019, 06:14 PM
pyxus
Sat Dec 14 2019, 12:31 PM
Istika
Thu Dec 12 2019, 12:04 PM

Online

Guests: 14, Members: 0 ...

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

Members: 38116
Newest member: Nippy56
Forum Activity
ExperimenterUK Avatar
Posted By ExperimenterUK
Fri Jan 17 2020, 10:24 PM
We will need the circuit diagram.A Proteus simulat...
Billz Avatar
Posted By Billz
Sat Jan 11 2020, 05:43 PM
hi everyone please attached files are my c code fo...
ExperimenterUK Avatar
Posted By ExperimenterUK
Tue Jan 07 2020, 08:18 PM
Not a stupid question.Setting up "Eclipse" can be...
elt Avatar
Posted By elt
Tue Jan 07 2020, 07:06 PM
So i have just began learning programming micros a...
Billz Avatar
Posted By Billz
Mon Jan 06 2020, 09:22 PM
I think it would be better if you guys try to come...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Jan 06 2020, 12:22 AM
Can you post a circuit diagram and any code you ha...
Billz Avatar
Posted By Billz
Sun Jan 05 2020, 08:17 PM
Need help regarding C code (specifically for PIC 1...
ExperimenterUK Avatar
Posted By ExperimenterUK
Mon Dec 30 2019, 06:42 PM
Can you give more details of your problem.
Rupeshpatil Avatar
Posted By Rupeshpatil
Fri Dec 27 2019, 06:21 PM
How to copy program my old microcontroller to new ...
ilylily07 Avatar
Posted By ilylily07
Thu Dec 12 2019, 02:26 PM
wil do.thank you for your advice!