String issue

PaulS:

+CPMS: 1,70,0,30,1,70

What do these numbers mean?

+CMGR: 1,,24

And these?

they are some answer from the phone (AT COMMAND), i don't know exactly what they mean, but they are useless for me.

i don't know exactly what they mean, but they are useless for me.

If you don't know what they mean, how do you know that they are useless? What if one of the numbers indicated the message length? Wouldn't that be useful information?

PaulS:

i don't know exactly what they mean, but they are useless for me.

If you don't know what they mean, how do you know that they are useless? What if one of the numbers indicated the message length? Wouldn't that be useful information?

No because, the project is: Some codes to see the serial connection with the phone, another command to change the memory to read (AT+CPMS="ME"), after I read the first message. If the message have the word "Ligar" but in PDU format (in PDU format the message content is the end of the line), the code turn a port HIGH. Else, do nothing. If the message have the word "Desligar" but in PDU format, the code turn this same port, LOW.

because, I said this answer were useless for me. The line of the message is always with the same end for the messages I want to parse.

+CMGR: 1,,24 07 91 55 11 18 31 28 00 24 0B 81 10 79 18 69 14 F5 00 00 1 07 91 55 11 18 31 28 00 24 0B 81 10 79 18 69 14 F5 00 00 11 01 31 32 04 81 29 05 CC F4 39 2C 07

looks definitely like some hexdump

lets google...

AT +CMGR - http://www.developershome.com/sms/cmgrCommand.asp - The AT command +CMGR (command name in text: Read Message) is used to read a message from a message storage area. The location of the message to be read from the message storage area is specified by an index number. The message to be retrieved by the AT command +CMGR does not necessarily have to be an SMS message. It can be of other message types such as status reports and cell broadcast messages

AT +CPMS - http://www.developershome.com/sms/cpmsCommand.asp - The AT command +CPMS (command name in text: Preferred Message Storage) serves several purposes. It can be used to: 1. Select the message storage area that will be used when sending, receiving, reading, writing or deleting SMS messages. 2. Find the number of messages that are currently stored in the message storage area. 3. Find the maximum number of messages that can be stored in the message storage area.

robtillaart:

+CMGR: 1,,24 07 91 55 11 18 31 28 00 24 0B 81 10 79 18 69 14 F5 00 00 1 07 91 55 11 18 31 28 00 24 0B 81 10 79 18 69 14 F5 00 00 11 01 31 32 04 81 29 05 CC F4 39 2C 07

looks definitely like some hexdump

lets google...

AT +CMGR - http://www.developershome.com/sms/cmgrCommand.asp - The AT command +CMGR (command name in text: Read Message) is used to read a message from a message storage area. The location of the message to be read from the message storage area is specified by an index number. The message to be retrieved by the AT command +CMGR does not necessarily have to be an SMS message. It can be of other message types such as status reports and cell broadcast messages

AT +CPMS - http://www.developershome.com/sms/cpmsCommand.asp - The AT command +CPMS (command name in text: Preferred Message Storage) serves several purposes. It can be used to: 1. Select the message storage area that will be used when sending, receiving, reading, writing or deleting SMS messages. 2. Find the number of messages that are currently stored in the message storage area. 3. Find the maximum number of messages that can be stored in the message storage area.

yes, about the commands, they are what i said before.

I’m nearst now with this code:

char incomingByte;
#include <NewSoftSerial.h>

NewSoftSerial cell(10,11);
int rele = 12;

String response;


void setup() {
   cell.begin(9600);
   Serial.begin(9600);
   delay(500);
   
pinMode(rele, OUTPUT);   
digitalWrite(rele, LOW);  

   //Set memory to read sms from, ME = phone memory
 cell.println("AT+CPMS=\"ME\"");  
     delay(1000);
  
    cell.flush();
   Serial.flush(); 

     //Read received message
cell.println("AT+CMGR=1");
}
void loop(){
  


  
 if(cell.available() >0 && (!response.startsWith("079") && !response.endsWith("C07")))  {

   incomingByte = cell.read(), BYTE;
       // say what you got:       
       Serial.print(incomingByte);
       
       response = response + incomingByte;
 }
 

//se a mensagem tiver a palavra Ligar, ligar o rele.
if (response.substring(response.length()-12) == ("05CCF4392C07")) {

digitalWrite(rele, HIGH);

}

But the problem is with the loop.

After read the message, I have to delete it and continue verifying new messages to compare the content.

How can I do it?

thank all!