我正在尝试从 gsm 调制解调器中收到的短信回复。
问题是,我不知道如何从这一系列字符串中提取电话号码,以便获取发件人的号码。
我必须提取发件人的号码“09279127639”。
+CMGL: 1,"REC READ","09279127639","","13/04/05,08:24:36+22"
注意:发件人的号码是不同的。这只是一个例子。
提取后,我希望它将其值返回到此代码中,以便我可以自动回复他。
void setup()
{ pinMode(8, OUTPUT);
digitalWrite(8, HIGH);
delay(3000);
digitalWrite(8, LOW);
Serial.begin(9600);
Serial1.begin(9600); //Baud rate of the GSM/GPRS Module
Serial.print("\r");
Serial1.print("\r");
delay(1000);
Serial1.print("AT\r");
Serial.print("AT\r");
delay(10000);
Serial1.print("AT\r");
Serial.print("AT\r");
delay(1000);
Serial1.print("AT+CMGF=1\r");
Serial.print("AT+CMGF=1\r");
delay(1000);
Serial1.print("AT+CMGS=\"number here\"\r");
Serial.print("AT+CMGS=\"number here\"\r"); //Number to which you want to send the sms
delay(1000);
Serial1.print("This is a message from a GSM modem.\r");
Serial.print("This is a message from a GSM modem.\r"); //The text of the message to be sent
delay(1000);
Serial1.write(0x1A);
Serial.write(0x1A);
delay(1000);
}
void loop()
{
}
您的回复将不胜感激。谢谢你。