Adafruit_FONA icon indicating copy to clipboard operation
Adafruit_FONA copied to clipboard

ignore unsolicited

Open ladyada opened this issue 10 years ago • 3 comments

unsolicited messages are annoying and confuse the parser - so maybe have a flag in readline() that if its an unsolicited message, retry the read?

ladyada avatar Jun 10 '15 12:06 ladyada

You can tell if it's a URC by turning on AT+CFGRI=1 and then watching the RI pin. I'm not sure how to do it without having a big table of URC's otherwise.

chaselambda avatar Nov 02 '15 01:11 chaselambda

Revision: It looks like AT+CFGRI=1 only changes the RI pin in a small subset of URC's. Additionally, the occurrence of the RI pin and the URC coming over serial can be tricky to match up. For example, if SoftwareSerial is used, there's not much of a way to tell if the current message was sent during an RI change. Beyond this, there are references in the documentation that specifies URC's do not have to happen when the RI pin is down.

What this means is that the RI pin should only be used to.. do things that aren't related to URC's.

Currently, I see two solutions to ignoring URC's:

  1. In readline, put in something like this:
        if (!multiline) {
          if (memcmp("+CMTI", replybuffer, 5) == 0) { // Check that the message is any of the URC's
            Serial.println("+CMTI skipped");
            timeout = 5000; // Increase the timeout somehow
            replyidx = 0;
            continue;
          } else {
            timeout = 0;
            break;
          }
        }
  1. Go through section 19.3 of the command manual, and turn off all that's possible of the URC's in setup. Two examples:
  // Turn off SMS URC's
  sendCheckReply(F("AT+CNMI=2,0,0,0,0"), F("OK"));
  delay(100);
  // Turn off sim card URC's
  sendCheckReply(F("AT+CSMINS=0"), F("OK"));
  delay(100);

I'd hope there was a better solution though.. some way to more easily determine if a command is a URC or not should be accessible.

chaselambda avatar Nov 03 '15 21:11 chaselambda

I would not say ignore them, I would say process them apropriately. Unsolicited messages are usually high-importance things like incoming calls, incoming messages, etc

dmayhem avatar Feb 26 '16 21:02 dmayhem