Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hold SMSs ? #12

Open
eried opened this issue Jun 24, 2020 · 3 comments
Open

Hold SMSs ? #12

eried opened this issue Jun 24, 2020 · 3 comments

Comments

@eried
Copy link

eried commented Jun 24, 2020

Hello, is there a way to hold the SMS messages so they do not pop when received? (i.e. I am waiting for some HTTP POST, and in the middle there is an SMS received so it gets outputed in the middle)

@apeman76
Copy link

apeman76 commented Jul 9, 2020

Yes, use this code:

String dump(bool printData) {
  byte while_cunt = 0;
  while (swSer.available() == 0){
    while_cunt++;
    delay(15); // It can change for a proper delay
    if(while_cunt >=250){  // If the data from serial was not received past 3.75 seconds
      Serial.println("return");
      return "";   // Exit from dump function
    }
  }
  String content = "";
  while (swSer.available() > 0) {
    content += swSer.readString();
  }

  if (printData) {
    Serial.println(content);
  }
  return content;
}
  swSer.println("AT+CPMS=\"SM\",\"SM\",\"SM\"");
  delay(1000);
  swSer.println("AT+CMGR=1");
  delay(1000);
  String str =  dump(true);

str now holds the answer of the command

@eried
Copy link
Author

eried commented Jul 9, 2020

But what if you get an sms while reading that? It will get included too

@apeman76
Copy link

apeman76 commented Jul 9, 2020

Ah, I misunderstood your question.
AT+CNMI=2,0,0,0,0
Try just this, forget the other code.

//edit
hmm I see the 2nd 0 is default: https://www.logicbus.com.mx/pdf/31/Comandos_AT_generales.pdf
Maybe disabling serial read while waiting for that post and enabling it after receiving the post is the best idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants