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

nbAccess.begin fails on second loop of TestGPRS example sketch #71

Open
calvino80 opened this issue Jan 14, 2021 · 2 comments · May be fixed by #72
Open

nbAccess.begin fails on second loop of TestGPRS example sketch #71

calvino80 opened this issue Jan 14, 2021 · 2 comments · May be fixed by #72
Assignees
Labels
type: imperfection Perceived defect in any part of project

Comments

@calvino80
Copy link

calvino80 commented Jan 14, 2021

arduino model: MKR NB 1500
modem model: SARA-R410M rev. 02B-00
modem firmware: 05.08
MKRNB library version: 1.5.1

with the example sketch TestGPRS, the modem will not complete more than one loop unless line 58 is changed from these values:

if (nbAccess.begin("") != NB_READY) {
....

to these values:

if (nbAccess.begin("", false, true) != NB_READY) {
....

this occurs in all versions since MKRNB v1.4.0, and appears to be related to fix #55

Mike

@calvino80 calvino80 changed the title nbAccess.begin fails on second loop of gprs.test example sketch nbAccess.begin hangs on second loop of gprs.test example sketch Jan 14, 2021
@calvino80 calvino80 changed the title nbAccess.begin hangs on second loop of gprs.test example sketch nbAccess.begin fails on second loop of gprs.test example sketch Jan 14, 2021
@calvino80 calvino80 changed the title nbAccess.begin fails on second loop of gprs.test example sketch nbAccess.begin fails on second loop of TestGPRS example sketch Jan 14, 2021
@per1234 per1234 added the type: imperfection Perceived defect in any part of project label Jan 14, 2021
@giulcioffi giulcioffi linked a pull request Feb 9, 2021 that will close this issue
@giulcioffi
Copy link
Contributor

Hi @calvino80, could you please test the changes that I proposed in PR #72 and let me know if this solves your issue?

@joshbober
Copy link

joshbober commented Jul 12, 2021

Weighing in here with results from my testing:

I think that the "hanging" is a result of the code entering a "while(true);" statement in case of failure to connect.

From TestGPRS.ino:

if (nbAccess.begin(PINNUMBER,"wireless.dish.com") != NB_READY) {
  Serial.println(errortext);
  while (true);
}
Serial.println(oktext);

I am currently diagnosing issues with connection to my provider, so running the example sketch with this code always results in the error condition and loop hanging. I do not know if this is also the case for @calvino80, but if so, I think the real issue is with the example sketch as coded.

My recommendation is to use the connection loop from the SendSMS example sketch (or similar). If the modem needs to be restarted in between "failure-to-connects", then simply set a boolean "restart" variable that gets passed in on subsequent connection attempts. Example below:

  Serial.print("Connecting NB IoT / LTE Cat M1 network...");
  bool connected = false;
  bool restart = false;
  while (!connected) {
    if (nbAccess.begin(PINNUMBER,"",restart,true) == NB_READY) {
      connected = true;
    } else {
      Serial.println("Error - could not connect");
      restart = true;
      delay(1000);
    }
  }
  Serial.println(oktext);

PR #72 causes a modem restart on first execution of the NB begin(). I do not know if this is necessary, since (at least in my case), the first execution of begin() occurs at startup, so it may be considered redundant unless I am misunderstanding something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants