0
我試圖發送AT命令到STM32但在發送AT命令我得到錯誤錯誤而來自STM32發送AT命令到SIM卡800
#include "mbed.h"
#include <string>
Serial pc(SERIAL_TX, SERIAL_RX); // pc comunication
Serial SIM900(PA_9, PA_10); //tx, rx SIM 900
string result;
char x;
void clearString()
{
result.clear();
}
}
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 --"); //this is a error
}
pc.printf("%s",result.c_str());
}
void sendSMS()
{
pc.printf("\r\n----sendSMS2----\r\n");
clearString();
SIM900.printf("AT+CMGS=");
SIM900.printf("\"");
SIM900.printf("074xxxxx");
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();
}
int main() {
pc.printf("\r\n GSM 900 TEST\n");
SIM900.baud(9600)
wait_ms(200);
controlAT();
wait_ms(200);
sendSMS(); // SEND SMS
wait_ms(200);
}
我收到錯誤controlAT()函數,它總是打印 pc.printf(「 - ERROR AT - 」); //這是一個錯誤
請幫我解決這個問題
但在下面的鏈接它說,它的工作http://stackoverflow.com/questions/31454683/send-sms-with -stm32l152-和SIM900 – Gautam