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

Feature request: Clear MO/MT buffers using AT+SBDD #10

Open
PaulZC opened this issue Feb 4, 2018 · 2 comments
Open

Feature request: Clear MO/MT buffers using AT+SBDD #10

PaulZC opened this issue Feb 4, 2018 · 2 comments

Comments

@PaulZC
Copy link

PaulZC commented Feb 4, 2018

Hi Mikal,
Not an issue as such - more a feature request for the next release:
Could you add a function to clear the MO/MT/both buffers using AT+SBDD0/1/2 ?
The reason I ask is that:
If I send an MO message using sendSBDText
then send an empty message to check for an MT reply using sendReceiveSBDText(NULL, sbdBuffer, bufferSize)
the 9603N automatically resends the old text message stored in the MO buffer!
I'm using a messy workaround in my code to force the clear using ssIridium.println("AT+SBDD0"); and then discarding the reply.
It would be great to have this incorporated properly into the library.
Sincere thanks,
Paul

@mikalhart
Copy link
Owner

This is a good idea, but it's not implemented yet. Keeping it alive for future work.

@PaulZC
Copy link
Author

PaulZC commented Oct 14, 2019

Thanks Mikal.
I did put a solution together a while ago:

In the .h:

#define ISBD_CLEAR_MO		0
#define ISBD_CLEAR_MT		1
#define ISBD_CLEAR_BOTH		2
//public:
   int clearBuffers(int buffers = ISBD_CLEAR_MO);
//private:
   int internalClearBuffers(int buffers = 0);

In the .cpp:

//public:
// High-level wrapper for AT+SBDD
int IridiumSBD::clearBuffers(int buffers)
{
   if (this->reentrant)
      return ISBD_REENTRANT;

   this->reentrant = true;
   int ret = internalClearBuffers(buffers);
   this->reentrant = false;
   return ret;
}
//private:
int IridiumSBD::internalClearBuffers(int buffers)
// Clear the MO/MT/Both buffers
// Defaults to clearing the MO buffer to avoid resending old messages
{
   if (this->asleep)
      return ISBD_IS_ASLEEP;

   if (buffers == ISBD_CLEAR_MT) // Clear MT buffer
   {
      send(F("AT+SBDD1\r"));
   }
   else if (buffers == ISBD_CLEAR_BOTH) // Clear both buffers
   {
      send(F("AT+SBDD2\r"));
   }
   else // Clear MO buffer
   {
      send(F("AT+SBDD0\r"));
   }
   if (!waitForATResponse())
      return cancelled() ? ISBD_CANCELLED : ISBD_PROTOCOL_ERROR;

   return ISBD_SUCCESS;
}

If you would like a Pull Request, just let me know.
All the best,
Paul

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