This is more of an algo that i want to implement...i need help
1)shud i be concerned about the reply i get from the gsm modem?(like OK,ERROR...)
2)how shud i den implement it...?
#include <stdio.h>externunsignedchar cmgf[]="AT+CMGF=1";externunsignedchar cmgs[]="AT+CMGS=\"9952082259\"";externunsignedchar msg1[]="WELCOME TO GSM\0";externunsignedchar msg2[]="USER HAS CROSSED THE BOUNDARY\0";externunsignedchar msg3[]="I’M IN DANGER\0";externunsignedchar msg4[]="PULSE RATE HAS BEEN INCREASING DRASTICALLY\0";externunsignedchar readall[]="AT+CMGR=\"REC UNREAD\"\r\n";void main(){
pinsel0 =0x00000000;// Enable GPIO on all pins
init_serial();
gsmperform();}void gsmperform(){while(!(sendstring("AT\r\n")));//wait till u receive OK
delaygsm();
sendstring("AT+CNMI=2,1,0,0\r\n");//enable read new message
delaygsm();
sendstring(cmgf);
txu1(0x0d);// equivalent of
txu1(0x0a);// enter key
delaygsm();
sendstring(cmgs);
txu1(0x0d);
txu1(0x0a);
delaygsm();if(/* SOS key pressed*/){
sendstring(msg3);
txu1(0x0d);
txu1(0x0a);}if(/*output of pulse generator >reference*/){
sendstring(msg4);
txu1(0x0d);
txu1(0x0a);}if(/* latitude,longitude >reference){sendstring(msg2);txu1(0x0d);txu1(0x0a); }}void init_serial (void) /* Initialize Serial Interface */{
PINSEL0 &=0xFFFFFF0F;// Reset P0.2,P0.3 Pin Config
PINSEL0 |=0x00000010;// Select P0.2 = TxD(UART0)
PINSEL0 |=0x00000040;// Select P0.3 = RxD(UART0)
PINSEL1|=0x00000000;
PINSEL2|=0x00000000;
U1LCR =0x00000083;/* 8 bits, no Parity, 1 Stop bit */
U1DLL =0x000000C2;/* 9600 Baud Rate @ 30MHz VPB Clock */
U0FDR =0x67;// Fractional Divider
U1LCR =0x00000003;/* DLAB = 0 *//* MORE HELP FRON UNCLE*/
VICIntSelect&=0xffffff7f;
VICVectAddr2=(unsignedint)uart1_irq;
VICIntEnable|=0x00000080;
VICVectCntl0=0x0000002F;/*select a priority slot 4a gvn interrupt*/}void txuart1(unsignedchar data)//Transmit a byte of data through UART1{while(!(U1LSR &0x20));//Wait until UART1 ready to send character
U1THR = data;
delay(100);//waiting for the receiver to start working
rxuart1();}unsignedchar my_arr[16];//for general purpose//unsignedchar* rxuart1(){char* ptr = my_arr;while(1){while((U1LSR&0x01)!=1);{*ptr++= U1RBR;}if(*(--ptr)==0x0A)break;}}int sendstring(unsignedchar*p)//Sends a string of data through UART1{while(1){if(*p=='\0')break;
txuart1(*p++);}if(my_arr==”OK”)return1;return0;}void delaygsm()//delay function{int i,j;for(i=0;i<60000;i++)for(j=0;j<51;j++);}