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

Class GSM and other use private variables instead of protected #84

Open
johncpang opened this issue Mar 31, 2019 · 3 comments
Open

Class GSM and other use private variables instead of protected #84

johncpang opened this issue Mar 31, 2019 · 3 comments
Assignees

Comments

@johncpang
Copy link

I'm looking for a reusable-way to use the library in async. Started with the GsmWebClient example, I tried to rewrite the first call GSM::begin(PINNUMBER) into synchronized function. My attempt is to sub-class GSM as AsyncGSM, and send synchronous=false to begin(). The overloaded function will take a callback (pointer-to-function) so that when begin() finished (whether success or failed), it will callback the caller.

To my understanding, I should rewrite the following code from GSM::begin() in my overloaded function, and run the code via main loop().

  unsigned long start = millis();

  while (ready() == 0) {
    if (_timeout && !((millis() - start) < _timeout)) {
      _state = ERROR;
      break;
    }

    delay(100);
  }

However, I cannot access _timeout as it is a private variable instead of protected. I believe, the whole library should consider using protected over private, or provide both getters and setters, so that we can extend the library by sub-classing.

@sandeepmistry
Copy link
Contributor

Hi @johncpang,

Adding a getter for it sounds good, would you be able to submit a pull request for this?

@johncpang
Copy link
Author

Hi @sandeepmistry, I'd like to do that. When I've got the library works in async, then I'll make a pull request.

I'm able to make class GSM works aysnc. But MODEM.begin() is a synchronized function and it takes 10 seconds to completed. Can class MODEM works in async mode? Is there an async-version MODEM?

As a test or indicator, I blink the onboard LED using a Timer. It stops blinking when MODEM.begin() called, and resumes when MODEM.begin() returned.

@johncpang
Copy link
Author

@sandeepmistry Hi, I've submitted a pull request for this. Please help and merge it.

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