I have a PIC board with built in GSM capability (must insert valid SIM card into board) that I'm programming for a senior design project. The board came bundled with code, however the code didn't seem to be correct because I can not get the damn thing to send a text message. If you look at the code, the send_sms function along with many of the other functions were set up with the use of a web form in mind (as a means of data input (phone number and message content). However, I simply want to hard code the sms number and message and have the board send a text once it's powered on. You can see that's what I tried to do in the send_sms function, but there is something not right. I'm thinking its my AT command syntax. Any help would be greatly appreciated since I'm not a programmer but I do have to complete this task.
int send_sms(char * number,char * message,int timeout)
{
int tmt=timeout;
//int k=sizeof(LCDText);
/*
tmp[0]='A';
tmp[1]='T';
tmp[2]='+';
tmp[3]='C';
tmp[4]='M';
tmp[5]='G';
tmp[6]='S';
tmp[7]='=';
tmp[8]='"';
tmp[9]='+';
//memcpy(tmp+10,LCDText,number_length);
memcpy(tmp+10, number, number_length);
tmp[number_length+10]='"';
tmp[number_length+11]='\0';
*/
//SendUART2(tmp);
//SendUART2("AT+CMGF=1");
//SendUART2("AT+CMGS=\"9086161265\"");
//SendUART3(message);
SendUART("AT");
SendUART("AT+CMGF=1");
SendUART("AT+CMGS=\"+19086161265\"");
SendUART3("TEST");
//add handle for custom GSM number
a=65535;
//while(--a!=0);
if (rx_counter != 0)
{
while(!(proba == '>')) //HERE sending SMS works
proba=getchar_UART(70000);
SendUART3(message);
}//end sending
//if(!waitplus(7000))
return 0;
do
{
proba=getchar_UART(70000);
a=a;
}
while((proba != 10)&& (--timeout!=0)); //skip first line, read message text on second line
if(!waitOK())
return 0;
a=65535;
return 1;
}
|