#include <stdio.h> #include <htc.h> #include "usart.h" #include "lcd.h" #include "string.h" __CONFIG(HS & WDTDIS & UNPROTECT & LVPDIS); unsigned char gsmInput[60]; unsigned int i=0; unsigned int lenOfGSMInput = 0; bit OK; bit Error; bit Ring; void showGSM_DATA(char GSM_DATA[]){ //to show the GSM OUTPUT after eliminating the chars '\r' and '\n' if (strcmp(GSM_DATA, "OK") == 0){ OK = 1; } else if (strcmp(GSM_DATA, "ERROR") == 0){ Error = 1; } else if (strcmp(GSM_DATA, "RING") == 0){ Ring = 1; GSM_DATA[0] = '\x00'; puts("AT+CLCC"); putch(0x0D); } else{ lcd_clear(); lcd_goto(0); lcd_puts(GSM_DATA); } GSM_DATA[0] = '\x00'; } // end function showGSM_DATA void main(int argc, char* argv[]){ unsigned char input; INTCON=0; // purpose of disabling the interrupts. lcd_init(); // initiate LCD init_comms(); // set up the USART - settings defined in usart.h puts("ATE0"); putch(0X0D); puts("AT+CMGF=1"); putch(0X0D); while(1){ input = getch(); // read a response from the GSM switch(input){ case '\x0A': // if line feed detected in the GSM output i.e. '\n' break; case '\x0D': // if carriage return detected i.e. '\r' gsmInput[i] = '\x00'; lenOfGSMInput = strlen(gsmInput); if (lenOfGSMInput > 0){ i = 0; lenOfGSMInput = 0; showGSM_DATA(gsmInput); } break; case '\x3E': // if greater-sign (in order to send SMS) break; default: // if characters received gsmInput[i] = input; i++; break; }//end brace for switch } //end brace for while loop }//end brace for main</htc.h></stdio.h>
default
i
60
GSM_DATA[]
strcmp()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)