void sim800c_sms_read_test(void)
{
u8 *p,*p1,*p2;
u8 timex=0;
u8 msgindex[3];
u8 msglen=0;
u8 msgmaxnum=0; //¶ìDÅ×î′óìõêy
u8 key=0;
u8 smsreadsta=0; //êÇ·ñÔú¶ìDÅÏÔê¾×′ì¬
p=mymalloc(SRAMIN,200);//éêÇë200¸ö×Ö½úμÄÄú′æ
LCD_Clear(WHITE);
POINT_COLOR=RED;
sim800c_send_cmd("AT+CNMI=2,1","OK",200);
Show_Str_Mid(0,30,"ATK-SIM800C ¶á¶ìDÅ2aêÔ",16,240);
Show_Str(30,50,200,16,"¶áè¡: ×üDÅÏ¢:",16,0);
kbd_fn_tbl[0]="¶áè¡";
kbd_fn_tbl[1]="·μ»Ø";
sim800c_load_keyboard(0,180,(u8**)kbd_tbl1);//ÏÔê¾¼üÅì
while(1)
{
key=sim800c_get_keynum(0,180);
if(sim800c_check_cmd("+CMTI:"))//½óêÕμ½DÂÏûÏ¢
{
Show_Str(40,500,200,16,"hhh",16,0);
LED1=0;
}
if(key)
{
if(smsreadsta)
{
LCD_Fill(30,75,239,179,WHITE);//Çå3yÏÔê¾μĶìDÅÄúèY
u3_printf("AT+CTTS=0\r\n");
smsreadsta=0;
}
if(key<10||key==11)
{
if(msglen<2)
{
msgindex[msglen++]=kbd_tbl[key-1][0];
u3_printf("AT+CLDTMF=2,\"%c\"\r\n",kbd_tbl[key-1][0]);
}
if(msglen==2)
{
key=(msgindex[0]-'0')*10+msgindex[1]-'0';
if(key>msgmaxnum)
{
msgindex[0]=msgmaxnum/10+'0';
msgindex[1]=msgmaxnum%10+'0';
}
}
}else
{
if(key==10||key==12) u3_printf("AT+CTTS=0\r\n"); //AT+CTTS=0í£Ö12¥·Åμ±Ç°oÏ3éμÄóïòô
if(key==13)
{
u3_printf("AT+CTTS=0\r\n");if(msglen)msglen--;//é¾3y
}
if(key==14&&msglen)//Ö′DD¶á衶ìDÅ
{
LCD_Fill(30,75,239,179,WHITE);//Çå3y֮ǰμÄÏÔê¾
sprintf((char*)p,"AT+CMGR=%s",msgindex);
if(sim800c_send_cmd(p,"+CMGR:",200)==0)//¶á衶ìDÅ
{
POINT_COLOR=RED;
Show_Str(30,75,200,12,"×′ì¬:",12,0);
Show_Str(30+75,75,200,12,"à′×Ô:",12,0);
Show_Str(30,90,200,12,"½óêÕê±¼ä:",12,0);
Show_Str(30,105,200,12,"ÄúèY:",12,0);
POINT_COLOR=BLUE;
if(strstr((const char*)(USART3_RX_BUF),"UNREAD")==0)
Show_Str(30+30,75,200,12,"òѶá",12,0);
else Show_Str(30+30,75,200,12,"Î′¶á",12,0);
p1=(u8*)strstr((const char*)(USART3_RX_BUF),",");
p2=(u8*)strstr((const char*)(p1+2),"\"");
p2[0]=0;//¼óèë½áêø·û
sim800c_unigbk_exchange(p1+2,p,0); //½«unicode×Ö·û×a»»ÎagbkÂë
Show_Str(30+75+30,75,200,12,p,12,0); //ÏÔê¾μç»°oÅÂë
p1=(u8*)strstr((const char*)(p2+1),"/");
p2=(u8*)strstr((const char*)(p1),"+");
p2[0]=0;//¼óèë½áêø·û
Show_Str(30+54,90,200,12,p1-2,12,0); //ÏÔê¾½óêÕê±¼ä
p1=(u8*)strstr((const char*)(p2+1),"\r"); //Ñ°Õò»Ø3μ·û
sim800c_unigbk_exchange(p1+2,p,0); //½«unicode×Ö·û×a»»ÎagbkÂë
Show_Str(30+30,105,180,75,p,12,0); //ÏÔ꾶ìDÅÄúèY
u3_printf("AT+CTTS=2,\"%s\"\r\n",p); //TTS¶á衶ìDÅ ASCIIÄ£ê½
smsreadsta=1; //±ê¼ÇóDÏÔ꾶ìDÅÄúèY
}else
{
Show_Str(30,75,200,12,"ÎT¶ìDÅÄúèY!!!Çë¼ì2é!!",12,0);
u3_printf("AT+CTTS=2,\"ÎT¶ìDÅÄúèYÇë¼ì2é\"\r\n");
delay_ms(1000);
delay_ms(1000);
LCD_Fill(30,75,239,75+12,WHITE);//Çå3yÏÔê¾
}
USART3_RX_STA=0;
}
if(key==15){u3_printf("AT+CTTS=0\r\n"); break;}
}
msgindex[msglen]=0;
LCD_Fill(30+40,50,86,50+16,WHITE);
Show_Str(30+40,50,86,16,msgindex,16,0); //????
}
if(timex==0) //2.5Ãë×óóò¸üDÂò»′Î
{
if(sim800c_send_cmd("AT+CPMS?","+CPMS:",200)==0) //2éÑˉóÅÑ¡ÏûÏ¢′æ′¢Æ÷
{
p1=(u8*)strstr((const char*)(USART3_RX_BUF),",");
p2=(u8*)strstr((const char*)(p1+1),",");
p2[0]='/';
if(p2[3]==',')//D¡óú64K SIM¿¨£¬×î¶à′æ′¢¼¸ê®ìõ¶ìDÅ
{
msgmaxnum=(p2[1]-'0')*10+p2[2]-'0'; //»ñè¡×î′ó′æ′¢¶ìDÅìõêy
p2[3]=0;
}else //èç1ûêÇ64K SIM¿¨£¬ÔòÄü′æ′¢100ìõòÔéÏμÄDÅÏ¢
{
msgmaxnum=(p2[1]-'0')*100+(p2[2]-'0')*10+p2[3]-'0';//»ñè¡×î′ó′æ′¢¶ìDÅìõêy
p2[4]=0;
}
sprintf((char*)p,"%s",p1+1);
Show_Str(30+17*8,50,200,16,p,16,0);//????
USART3_RX_STA=0;
}
}
if((timex%20)==0)LED0=!LED0;//200mséá˸
timex++;
delay_ms(10);
if(USART3_RX_STA&0X8000)sim_at_response(1);//¼ì2é′óGSMÄ£¿é½óêÕμ½μÄêy¾Y
}//ìø3öwhile
myfree(SRAMIN,p);
}
在读短信测试里面加了红色的地方为什么不行呢,仿照接电话程序改的啊,求大神
|