我发送短信"Hello“,但在我的手机上,我得到了这个消息ATAT+CMGS="xxxxxx">HelloWorld。是什么导致了这一切?
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
}
} 发布于 2015-07-16 13:35:57
在这个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();
}谢谢大家。
https://stackoverflow.com/questions/31454683
复制相似问题