再公开几个测试例子:
读SIM卡电话本。
SIM900A_puts("AT+CPBS=\"SM\"\r");
读第一条电话本记录
//get SIM no.1 phoneid
SIM900A_puts("AT+CPBR=1,1\r");
memset(buffer,'\0',sizeof(buffer));
if(SIM900A_gets(buffer)>0)
{printf("\n\r%s\n\r",buffer);}
for(i=0;i<11;i++)
{
//AT+CPBR=1,1
//+CPBR: 1,"13925101136",129,"yuanxihua"
// printf("\n\r%c",buffer[24+i]);
callphoneid= buffer[24+i];
}
//
发中文短信。
SIM900A_puts("AT+CMGF=1\r"); //TEXT Mode
memset(buffer,'\0',sizeof(buffer));
if(SIM900A_gets(buffer)>0)
{printf("\n\r%s\n\r",buffer);}
SIM900A_puts("AT+CSCS=\"UCS2\"\r"); //for CHINESE
memset(buffer,'\0',sizeof(buffer));
if(SIM900A_gets(buffer)>0)
{printf("\n\r%s\n\r",buffer);}
//不用配置短信服务中心号码
/*
SIM900A_puts("AT+CSCA=\"002B0038003600310033003800300030003200300030003500300030\",145\r"); //+8613800200500 短信中心号码
memset(buffer,'\0',sizeof(buffer));
if(SIM900A_gets(buffer)>0)
{printf("\n\r%s\n\r",buffer);}
*/
SIM900A_puts("AT+CSMP=17,167,0,25\r");
memset(buffer,'\0',sizeof(buffer));
if(SIM900A_gets(buffer)>0)
{printf("\n\r%s\n\r",buffer);}
// SIM900A_puts("AT+CMGS=\"00310033003900320035003100300031003100330036\"\r"); //13925101136 被叫号码,不固定,从SIM卡读。
SIM900A_puts("AT+CMGS=\"");
for(i=0;i<11;i++)
{
SIM900A_puts("003");
SIM900A_putchar(callphoneid);
}
SIM900A_puts("\"\r");
memset(buffer,'\0',sizeof(buffer));
if(SIM900A_gets(buffer)>0)
{printf("\n\r%s\n\r",buffer);}
SIM900A_puts("4F60597D ");
//你好 短信内容,UNICODE格式;
SIM900A_putchar(26); //<Ctrl+Z>
memset(buffer,'\0',sizeof(buffer));
if(SIM900A_gets(buffer)>0);
{printf("\n\r%s\n\r",buffer);}
打电话
printf("SIM900A Phone a call by AT-commond @ 9600 bps !!!\n\r");
// Call a phone
SIM900A_puts("ATD");
for(i=0;i<11;i++)
{
SIM900A_putchar(callphoneid);
}
SIM900A_puts(";\r");
memset(buffer,'\0',sizeof(buffer));
if(SIM900A_gets(buffer)>0)
{printf("\n\r%s\n\r",buffer);}
发英文短信
printf("SIM900A Send a English SMS by AT-commond @ 9600 bps !!!\n\r");
//init SIM900A for SMS
SIM900A_puts("AT+CMGF=1\r"); //TEXT Mode
memset(buffer,'\0',sizeof(buffer));
if(SIM900A_gets(buffer)>0)
{printf("\n\r%s\n\r",buffer);}
SIM900A_puts("AT+CSCS=\"GSM\"\r");
memset(buffer,'\0',sizeof(buffer));
if(SIM900A_gets(buffer)>0)
{printf("\n\r%s\n\r",buffer);}
//prepore config SIM900A for sendding a SMS
SIM900A_puts("AT+CMGS=\"+86");
for(i=0;i<11;i++)
{
SIM900A_putchar(callphoneid);
}
SIM900A_puts("\"\r");
memset(buffer,'\0',sizeof(buffer));
if(SIM900A_gets(buffer)>0)
{printf("\n\r%s\n\r",buffer);}
//send a SMS to SIM900A
SIM900A_puts("This a report from yuanxihua@21cn.com!!!\x1a");// \x1a = <Ctrl+Z>
memset(buffer,'\0',sizeof(buffer));
if(SIM900A_gets(buffer)>0)
{printf("\n\r%s\n\r",buffer);} |