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

Add a choice of what messages to preserve to clear() #65

Merged
merged 4 commits into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/NB_SMS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,13 +436,15 @@ void NB_SMS::flush()
}
}

void NB_SMS::clear()
void NB_SMS::clear(int flag)
{
_ptrUTF8 = "";

while (MODEM.ready() == 0);

MODEM.sendf("AT+CMGD=0,2");
if (flag<1 || flag>4) flag = 2;

MODEM.sendf("AT+CMGD=0,%d",flag);

if (_synch) {
MODEM.waitForResponse(55000);
Expand Down
6 changes: 5 additions & 1 deletion src/NB_SMS.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ class NB_SMS : public Stream {
void flush();

/** Delete all read and sent SMS from Modem memory and process answer
* flag=1 preserves sent, unsent, and unread messages
* flag=2 preserves unsent and unread messages
* flag=3 preserves unread messages
* flag=4 preserves no messages
*/
void clear();
void clear(int flag=2);

private:
bool _synch;
Expand Down