uint16_t temph,templ,temp;
double tempwr;	
double tempwr2;

#define START	0x08
#define MT_SLA_ACK	0x18
#define MT_SLA_NACK	0x20
#define MT_DATA_ACK 0x28
#define MT_DATA_NACK 0x30
#define MR_SLA_ACK	0x40
#define MR_DATA_ACK 0x50
#define MR_DATA_NACK 0x58
#define SLA_W	0b10010000
#define SLA_R	0b10010001
#define SLA2_W	0b10010010
#define SLA2_R	0b10010011
#define START	0x08
#define MT_SLA_ACK	0x18
#define MT_SLA_NACK	0x20
#define MT_DATA_ACK 0x28
#define MT_DATA_NACK 0x30
#define MR_SLA_ACK	0x40
#define MR_DATA_ACK 0x50
#define MR_DATA_NACK 0x58




						//Send_UART("ATH");
	
						//if(!waitOK())
						//	return 0;
						
						//while (	getchar_UART()!=10);
					
						//Togle_REL2();	
						//	DDRD ^= 0x10;//toggle BUZ pin to buz or not

/////////////////////////////////////////////////////////////


//	while(1)
//		putchr(0x55);


//////////////////////////////////////////////////////////
/*
	if(rx_counter == 0)
		goto AT;
		else if(at[0] != getchar_UART())
				goto AT;
	if(at[1] == getchar_UART())
				flag=flag+1;	*/
	/*		
	else
		{
		Send_UART("AT");	
		a=65535;
		while(--a!=0);
		}
	*/
		
		/*
	Send_UART("AT");	
	a=65535;
	while(--a!=0);
 
 	if(!waitOK())
		return 0;

	*/

/////////////////////////////////////////////////////////////////////////////////////////////
/*
putchr ('A');
a=65535;
while(--a!=0);
putchr ('T');
a=65535;
while(--a!=0);
putchr (13);
a=655355;
while(--a!=0);



putchr ('A');
a=65535;
while(--a!=0);
putchr ('T');
a=65535;
while(--a!=0);
putchr (13);
a=65535;
while(--a!=0);

a=65535;
*/


/////////////////////////////////////////////////////////////////////////////////////////////

while(1)
if (rx_counter != 0) 
	temp_array[k++]=getchar_UART();


/////////////////////////////////////////////////////////////////////////////////////////
/*	if(PORTC & 0x80)
			sprintf(message,"RELAY1 ON");
		else sprintf(message,"RELAY1 OFF");
*/
////////////////////////////////////////////////////////////////////////////////////////////

made on :17.01.2008

/*
//act as PowerKey
	DDRA  |=0b00000100;//PA2 out in zero
	PORTA &=0b11111011;
	a=955556;
	while(--a!=0);
	//delay_ms(900);
	DDRA  &=0b11111011;//PA2 back input 

//waiting for Call Ready
	while(rx_counter==0);
	proba=getchar_UART();
	while(proba !=10)
		proba=getchar_UART();
	a=65555;
	while(--a!=0);
	//delay_ms(400);
//	while(proba !=10)
//		proba=getchar_UART();
//	a=65555;
	proba=0;	
	//wait for "Charge to Normal mode"

			do
  				{
				proba=getchar_UART();
				if ((proba != 10) && (proba != 13)) temp_array[k++]=proba;
				}
				while(proba != 10); 
			do
  				{
				proba=getchar_UART();
			//	if ((proba != 10) && (proba != 13)) temp_array[k++]=proba;				 
				}
				while(proba != 10);
			a=65555;
//wait for Call Ready

			do
  				{
				proba=getchar_UART();
				if ((proba != 10) && (proba != 13)) temp_array[k++]=proba;				 
				}
				while(proba != 10); 
*/		
//wait 2-3 seconds auto baudrate taking place
/*
while(1)
{		if (ring_state)
		{
			ring_state=0;
			Togle_REL1();
			
			Send_UART("AT");	
			a=655555;
			while(--a!=0);	
			}
		//	if (rx_counter !=0)
		//		while(proba !=10)
		//		proba=getchar_UART();
				}
*/
			//	if(!waitOK())
	//	return 0;
////////////////////////////////////////////////////////////////////
	//Send_UART('U');
//  while(rx_counter != 0) temp_array[k++]=getchar_UART();
/////////////////////////////////////////////////////////////////
								Send_UART(sms_send);
									a=65535;
									while(--a!=0);
									if (rx_counter != 0)
										{
										while(!(proba == '>'))	//HERE sending SMS works
											proba=getchar_UART();
										Send_UART2(message);
										}//end sending
									if(!waitplus())
										return 0;
									do 
										{
										proba=getchar_UART();
										index1=index1;
										}
									while(proba != 10);	//skip first line, read message text on second line
									if(!waitOK())
										return 0;
////////////////////////////////////////////////////////////////////////////

								Send_UART(sms_send);
								a=65535;
								while(--a!=0);
								if (rx_counter != 0)
									{
									while(!(proba == '>'))	//HERE sending SMS works
									proba=getchar_UART();
		
									Send_UART2(message);
									}//end sending
								if(!waitplus())
									return 0;
								do 
									{
									proba=getchar_UART();
									index1=index1;
									}
								while(proba != 10);	//skip first line, read message text on second line
								if(!waitOK())
									return 0;
///////////////////////////////////////////////////////////////////////////////
	else
			{	
				for (k=0;k<64;k++)
					temp_array[k]="";
				k=0;
                temp_array[k++]=proba;		
				do
  			 		{
			 	proba=getchar_UART();
				if ((proba != 10) ) temp_array[k++]=proba;
					}
				while(proba != 10); 		//LF 			 
	
		 		if(Compare()) 	
					{	
						Togle_REL2();	
						DDRD ^= 0x10;//toggle BUZ pin to buz or not
						Send_UART("ATH");
						if (ring_state)
						{
							ring_state=0;
							DDRD &= 0x11101111;	
							
							Send_UART("AT+CHFA=1");//switch to auxilary audio channel
							a=65535;
							while(--a!=0);

							if(!waitOK())
									return 0;

							Send_UART("ATA");
							a=65535;
							while(--a!=0);

		

							while (	getchar_UART()!=10) //wait new line 
								{
								l=l;
								}
	
							while(ok[l++]==getchar_UART()) //read ok
								{
								flag=flag+1;
								}
			
							while (	getchar_UART()!=10)
								{
									l=l;
								}
						
							waitcarrier();
						}
					}

					
			}//end RING recognition
///////////////////////////////////////////////////////////////////
Send_UART(sms_send);
									a=65535;
									while(--a!=0);
									if (rx_counter != 0)
										{
										while(!(proba == '>'))	//HERE sending SMS works
											proba=getchar_UART();
										Send_UART2("Command execution failure");
										}//end sending
									if(!waitplus())
										return 0;
									do 
										{
										proba=getchar_UART();
										index1=index1;
										}
									while(proba != 10);	//skip first line, read message text on second line
									if(!waitOK())
										return 0;
//////////////////////////////////////////////////////////////////////////////////
Send_UART(sms_send);
									a=65535;
									while(--a!=0);
									if (rx_counter != 0)
										{
										while(!(proba == '>'))	//HERE sending SMS works
											proba=getchar_UART();
										Send_UART2("Command execution failure");
										}//end sending
									if(!waitplus())
										return 0;
									do 
										{
										proba=getchar_UART();
										index1=index1;
										}
									while(proba != 10);	//skip first line, read message text on second line
									if(!waitOK())
										return 0;
/////////////////////////////////////////////////////////////////////////////////
