void sim900a_test(void)
{
u8 key=0;
u8 timex=0;
u8 sim_ready=0;
POINT_COLOR=RED;
Show_Str_Mid(0,30,"ATK-SIM900A 测试程序",16,240);
while(sim900a_send_cmd("AT","OK",100))
{
Show_Str(40,55,200,16,"未检测到模块!!!",16,0); //没有数据发挥
delay_ms(800);
LCD_Fill(40,55,200,55+16,WHITE);
Show_Str(40,55,200,16,"尝试连接模块...",16,0);
delay_ms(400);
}
LCD_Fill(40,55,200,55+16,WHITE);
key+=sim900a_send_cmd("ATE0","OK",200);//不回显
sim900a_mtest_ui(40,30);//打印信息
while(1)
{
delay_ms(10);
sim_at_response(1);//检查GSM模块发送过来的数据,及时上传给电脑
if(sim_ready)//SIM卡就绪.
{
key=KEY_Scan(0);
if(key)
{
switch(key)
{
case KEY0_PRES:
sim900a_call_test();//拨号测试
break;
case KEY1_PRES:
sim900a_sms_test(); //短信测试
break;
case WKUP_PRES:
sim900a_gprs_test();//GPRS测试
break;
}
sim900a_mtest_ui(40,30); //打印信息
timex=0;
}
}
if(timex==0) //2.5秒左右更新一次
{
if(sim900a_gsminfo_show(40,225)==0)
sim_ready=1;
else sim_ready=0;
}
if((timex%20)==0)
LED0=!LED0;//200ms闪烁
timex++;
}
}
进入后先检查卡是否存在,如果不存在sim_ready=0;timex++;那么下次循环就不在进入键盘扫描,也不会进入卡状态确认,一直循环下去。
是否需要将if(timex==0)改成if(timex!=0)
|