Go Down

Topic: Sending SMS using adafruit FONA working but returning Failed (Read 364 times) previous topic - next topic

J-M-L

Hello - Please do not PM me for help,  others will benefit as well if you post your question publicly on the forums.
Bonjour Pas de messages privés SVP, postez dans le forum directement pour que ça profite à tous

danangs

Hi jantromp,

You have the same problem as I do.  I have tried several options and hope this will solve the problem.

There are several response lines obtained after the message sending command(AT+CMGS=)
Response when the message delivery process is successful maybe like this

>
>
+CMGS: 112


OK

the "+CMGS" character appears on the third line. this may be fine when our module type is identified by the library. in the sendSMS() function that you mentioned before(Adafruit_FONA.cpp), When the module we use is not identified (???), the response that is read is the character in the first line. And then when data on replybuffer checking using strstr(replybuffer, "+CMGS") == 0   the result will be false
   
Code: [Select]

if ((_type == FONA3G_A) || (_type == FONA3G_E)) {
    // Eat two sets of CRLF
    readline(200);
    // DEBUG_PRINT("Line 1: "); DEBUG_PRINTLN(strlen(replybuffer));
    readline(200);
    // DEBUG_PRINT("Line 2: "); DEBUG_PRINTLN(strlen(replybuffer));
  }
  readline(10000,true); // read the +CMGS reply, wait up to 10 seconds!!!
  //DEBUG_PRINT("Line 3: "); DEBUG_PRINTLN(strlen(replybuffer));
  DEBUG_PRINTLN(replybuffer); //read replybuffer data
  if (strstr(replybuffer, "+CMGS") == 0) {
    return false;
  }




the solution is to add a readline() function to read the first and second line responses like this
Code: [Select]

if ((_type == FONA3G_A) || (_type == FONA3G_E)) {
    // Eat two sets of CRLF
    readline(200);
    // DEBUG_PRINT("Line 1: "); DEBUG_PRINTLN(strlen(replybuffer));
    readline(200);
    // DEBUG_PRINT("Line 2: "); DEBUG_PRINTLN(strlen(replybuffer));
  }else{
// Eat two sets of CRLF
    readline(200);
    // DEBUG_PRINT("Line 1: "); DEBUG_PRINTLN(strlen(replybuffer));
    readline(200);
    // DEBUG_PRINT("Line 2: "); DEBUG_PRINTLN(strlen(replybuffer)); 
  }
  readline(10000); // read the +CMGS reply, wait up to 10 seconds!!!
  // DEBUG_PRINT("Line 3: "); DEBUG_PRINTLN(strlen(replybuffer));
  if (strstr(replybuffer, "+CMGS") == 0) {
    return false;
  }
   
  //continue to catch OK response




J-M-L

The proper way to handle any request would be to read the full answer until OK not taking a guess at which line to read... and then parse it (or to listen to the answer looking for a specific keyword for a while and then trying to empty the incoming buffer for the rest of the answer).
Hello - Please do not PM me for help,  others will benefit as well if you post your question publicly on the forums.
Bonjour Pas de messages privés SVP, postez dans le forum directement pour que ça profite à tous

Go Up