Skip to content

Commit

Permalink
Merge pull request #65 from janakelarsson/clearchoose
Browse files Browse the repository at this point in the history
Add a choice of what messages to preserve to clear()
  • Loading branch information
aentinger authored Dec 9, 2020
2 parents cff06db + 1504346 commit e194599
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
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
7 changes: 6 additions & 1 deletion src/NB_SMS.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@

#include <Stream.h>

#define NB_SMS_CLEAR_READ (1)
#define NB_SMS_CLEAR_READ_SENT (2)
#define NB_SMS_CLEAR_READ_SENT_UNSENT (3)
#define NB_SMS_CLEAR_ALL (4)

class NB_SMS : public Stream {

public:
Expand Down Expand Up @@ -86,7 +91,7 @@ class NB_SMS : public Stream {

/** Delete all read and sent SMS from Modem memory and process answer
*/
void clear();
void clear(int flag = NB_SMS_CLEAR_READ_SENT);

private:
bool _synch;
Expand Down

0 comments on commit e194599

Please sign in to comment.