发送短信与STM32l152和SIM900 [英] Send SMS with STM32l152 and SIM900
本文介绍了发送短信与STM32l152和SIM900的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我发送短信Hello World,但是在我的手机上,我收到这个消息 ATAT + CMGS =xxxxxx> HelloWorld 。可能导致这种情况?
I send the SMS "Hello World", but on my cellular I get this message ATAT+CMGS="xxxxxx">HelloWorld instead. What can be causing this?
void controlAT()
{
clearString();
wait_ms(100);
SIM900.printf("AT\r");
wait_ms(1000);
if(result=="\r\nOK\r\n") {
pc.printf("\r\n----OK AT----\r\n");
}else {
pc.printf("-- ERROR AT --");
}
pc.printf("%s",result.c_str());
}
/*send SMS */
void sendSMS_Raw()
{
clearString();
SIM900.printf("AT+CMGS=");
SIM900.printf("\"");
SIM900.printf("+xxxxxxxxxxxxx");
SIM900.printf("\"");
SIM900.printf("\r");
SIM900.printf("Hello World");
SIM900.printf("\r");
SIM900.putc(0x1A);
wait_ms(200);
pc.printf("%s",result.c_str());
clearString();
})
/**MAIN**/
int main() {
pc.printf("\r\n GSM 900 TEST\n");
SIM900.attach(&callback_rx);
SIM900.baud(9600);
wait_ms(100);
while(1) {
wait(1.0); // 1 sec
pc.printf("\r\n---MAIN---\n");
controlAT();
sendSMS_Raw();
pc.printf("\r\n---FINE---\n");
wait(2.0); // 1 sec
}
}
推荐答案
修复它在这个metod:
the fix it in this metod:
void sendSMS_Raw()
{
pc.printf("\r\n----sendSMS2----\r\n");
clearString();
SIM900.printf("AT+CMGS=");
SIM900.printf("\"");
SIM900.printf("+xxxxxxxxx");
SIM900.printf("\"");
SIM900.printf("\r");
wait_ms(200); // this create the problem
SIM900.printf("Hello");
SIM900.printf("\r");
SIM900.putc(0x1A);
wait_ms(200);
pc.printf("%s",result.c_str());
clearString();
}
感谢所有。
这篇关于发送短信与STM32l152和SIM900的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文