General

How can list and receive SMS

userHead pierrot10 2014-09-24 05:04:10 1899 Views0 Replies
Dear All,

I am trying hard the receive SMS to my TEL0051.

I red the document AT command and I undertood, I have to the following command

First I set the text mod
Code: Select all
sendATcommand("AT+CMGF=1","OK",2000,true,false,false,false)
Second I select the memory storage
Code: Select all
sendATcommand("AT+CPMS=\"SM\",\"SM\",\"SM\"","+CPMS:",2000,true,false,false,false)
The I list all UREAD meddage
Code: Select all
sendATcommand("AT+CMGL=\"REC UNREAD\"","OK",5000,true,false,true,false);
When my project is running, I sent a SMS to it and it never display any message. It display the first 20 message
Code: Select all
for(int m=1; m<=20;m++)
          {
            sms_read(m,sms_from_number,sms_date,sms_time,sms_text);
           }

void sms_read(int sms_pos,char *sms_from_number, char *sms_date, char *sms_time, char *sms_text)
{
  // Definie une variable
  char cmd[12];
  // Defini la command
  sprintf(cmd,"AT+CMGR=%d,1",sms_pos);
  sendATcommand(cmd,"OK",2000,true,false,false,true);
  
  // J'affiche le message recu
  //Serial.print(F("Message :")); Serial.println(buffer_by_line[3]);
  strcpy(sms_text,buffer_by_line[3]);

  splitString(supprimeCaractere(buffer_by_line[2],'"'),splitedString);
  strcpy(sms_from_number,splitedString[1]);
  strcpy(sms_date,splitedString[3]);
  strcpy(sms_time,splitedString[4]); 
  
  #ifdef DEBUG_SMS
    Serial.print(F("Stat :")); Serial.print(buffer_by_line[0]); Serial.print(F(" - "));Serial.println(splitedString[0]);
    Serial.print(F("From :")); Serial.println(sms_from_number);
    Serial.print(F("Date :")); Serial.println(sms_date);
    Serial.print(F("Time :")); Serial.println(sms_time);
    Serial.print(F("Message :")); Serial.println(sms_text);
    Serial.println("");
  #endif
}
That function work, but it never display new messages that I just sent.

I also saw this command AT+CNMI
Code: Select all
sendATcommand("AT+CNMI=2,1,0,0,0","OK",1000,true,false,false,false);
But I do not really understand how it work and at which time it should be used

Someone could tellme in which order I have to enter my command to have a result with
AT+CMGL=\"REC UNREAD\"

A second question.

Can I put those command
Code: Select all
sendATcommand("AT+CMGF=1","OK",2000,true,false,false,false)
sendATcommand("AT+CPMS=\"SM\",\"SM\",\"SM\"","+CPMS:",2000,true,false,false,false)
in my setup() loop or should it call each time a request an SMS command as
AT+CMGL to list
AT+CMGR to read.


Mayn thank for your helps
Cheers