[mw_shl_code=c,true]//SIM900A发短信测试
void sim900a_sms_send_test(void)
{
u8 *p="Congratulations! You succeed!";
sim900a_init();
if(sim900a_send_cmd("AT+CMGS="18030491065"
",">",200)==0);//设置要发送的手机号码
{
delay_ms(500);
if(sim900a_check_cmd(">"))//是否收到">"
{
LED1=!LED1;
u3_printf((char*)p); //发短息内容到GSM模块
if(sim900a_send_cmd((u8*)0X1A,"+CMGS:",1000)==0)//发送结束符,等待发送完成(最长等待10秒,因为短信长了的话,等待时间会长些)
{
LED1=!LED1;
}
USART3_RX_STA=0;
}
}
}
void sim900a_init(void)
{
delay_ms(10);
if(sim900a_send_cmd("AT
","OK",100)==0)//检测是否应答AT指令 默认是回显,所以返回的AT OK
{
if(sim900a_send_cmd("ATE0
","OK",100)==0)//不回显
{
if(sim900a_send_cmd("AT+CSCS="GSM"
","OK",100)==0)//设置 GSM字符集
{
sim900a_send_cmd("AT+CMGF=1
","OK",100);//设置文本模式
sim900a_send_cmd("AT+CNMI=2,1
","OK",100);//设置消息提示
}
}
}
}[/mw_shl_code]
[mw_shl_code=c,true]/*-------------------------------------------------------------------------------------------[/mw_shl_code]
[mw_shl_code=c,true]以上是英文短信核心代码[/mw_shl_code]
[mw_shl_code=c,true]-------------------------------------------------------------------------------------------*/[/mw_shl_code]
[mw_shl_code=c,true]
[/mw_shl_code]
[mw_shl_code=c,true]
[/mw_shl_code]
[mw_shl_code=c,true]
[mw_shl_code=c,true]const u8* sim900a_test_msg="您好,HQ一条测试短信,由ATK-SIM900A GSM模块发送,模块购买地址:http://openedv.taobao.com,谢谢支持!";
void sim900a_sms_send_test(void)
{
u8 *p,*p1,*p2;
sim900a_init();
if(sim900a_send_cmd("AT+CMGS="18030491065"
",">",200)==0);//设置要发送的手机号码
{
delay_ms(500);
sim900a_unigbk_exchange((u8*)sim900a_test_msg,p1,1);//将短信内容转换为unicode字符串.
if(sim900a_send_cmd("AT+CMGS="18030491065"
",">",200)==0) //发送短信命令+电话号码
{
LED1=!LED1;
u3_printf((char*) p1); //发短息内容到GSM模块
if(sim900a_send_cmd((u8*)0X1A,"+CMGS:",1000)==0)//发送结束符,等待发送完成(最长等待10秒,因为短信长了的话,等待时间会长些)
{
LED1=!LED1;
}
USART3_RX_STA=0;
}
}
}[/mw_shl_code]
/*-------------------------------------------------------------------------------------------
发送中文核心代码,有问题,接收是空白短信,而且我申请内存了,反而不能发了,所以没有申请内存
-------------------------------------------------------------------------------------------*/
[/mw_shl_code]
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
-------------------------------
原子哥我的是探索者,现在PA9与RXD 用短接冒连在一起的,取了没影响吗?
---------------------------------
取了串口1就不连接在CH340了.
---------------------------------
不连接串口1,那连接在哪儿?不会在COM3吧,我要在串口助手看数据,总要找个地方连接下
一周热门 更多>