Hello,
I'm connecting a Sony Ericsson k700i phone to Arduino Uno. I'm able to send AT commands but cannot get all the bytes when requesting a SMS read. I wrote a small function to execute AT commands and get reply but it does not show the reply from phone.
What am i doing wrong? Could someone please help me correct this code to make it work?
I'm trying to reproduce the schetch from http://www.power7.net/apk_file/SmsRemoteControl.pde
Thanks a lot!
With the function below I want to read the value of first SMS and if the pdu format contains a specific string I want to turn on a led.
The function code:
/*
EX: executare_comanda_at_v2("AT");
executare_comanda_at_v2("AT");
executare_comanda_at_v2("ATE=0");//Echo off
executare_comanda_at_v2("AT+CPMS=\"ME\",\"SM\"");
executare_comanda_at_v2("AT+CMGR=1");
*/
void executare_comanda_at_v2(String comanda_at) {
String readString="";//format readString...
char c=NULL;
Serial.begin(9600);
Serial.println("--START COMANDA--");
//delay(3000);
readString="";//format readString...
Serial.println(comanda_at);
// read phone reply if available
while(Serial.available() > 0)
{
Serial.print( c=Serial.read());
readString+=c;
}
//delay(1000);
Serial.println(readString);//serial monitor display sms pdu format
//delay(3000);
if (readString.indexOf("026F37")>0)// if admin number=true and sms pdu on=true
{
digitalWrite(indicatorPin, HIGH);//only for test led on
//pulsesIR_Toyotomi.SendACCodeOn();//AC Toyotomi on
delay(5000);
//sendsms_temp();//send sms to admin temperature room
digitalWrite(indicatorPin, LOW);//only for test
}
Serial.println("--STOP COMANDA--\r\n");
Serial.flush();
delay(3000);//delay start loop again for check new sms...
}