|
当一条短信来了会返回+CMTI:XXXX 等消息,然后表明这条短信填到那个坑里 你要做的就是读取这个坑里的短信。
if(strstr(ReadBuff,"+CMTI: \"SM\",") && strlen(ReadBuff) < 18 )//if any sms received!
{
pos1 = 0;
pos2 = strlen(ReadBuff)-12;
for(;pos1 < pos2-1; pos1++)
{
smsposition[pos1] = ReadBuff[12+pos1];
}
printf("\n A Short Message received!");
sendatcommand(fd,"at+cmgf=1","OK") ;
sprintf(order,"%s%s","at+cmgr=",smsposition);
sprintf(sms,"%s",getresult(fd,order,"OK"));
executeflag = smsjob(fd,sms);
if(executeflag == -1 ) printf("\nmessage invalid!");
memset((void *)order,'\0',sizeof(char)* BIG_SIZE);
sprintf(order,"%s%s","at+cmgd=",smsposition);
sendatcommand(fd,order,"OK");
} |
|