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

Fix wrong return value of setNetworkMode and setPreferredMode #119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

raphac
Copy link

@raphac raphac commented Jun 9, 2021

The example doesn't work for me. I had an endless loop. The return value of setNetworkMode and setPreferredMode is not a string, it's a bool. See:
https://github.com/vshymanskyy/TinyGSM/blob/07b402721d23e2b392251ad95cc157505bbeeb8d/src/TinyGsmClientSIM70xx.h#L213

@Mr-HaleYa
Copy link
Contributor

After TinyGSM updated to 11.0.0 they changed from

LINK

  String setNetworkMode(uint8_t mode) {
    sendAT(GF("+CNMP="), mode);
    if (waitResponse(GF(GSM_NL "+CNMP:")) != 1) { return "OK"; }
    String res = stream.readStringUntil('\n');
    waitResponse();
    return res;
  }

  String setPreferredMode(uint8_t mode) {
    sendAT(GF("+CMNB="), mode);
    if (waitResponse(GF(GSM_NL "+CMNB:")) != 1) { return "OK"; }
    String res = stream.readStringUntil('\n');
    waitResponse();
    return res;
  }

to this
LINK

  bool setNetworkMode(uint8_t mode) {
    // 2 Automatic
    // 13 GSM only
    // 38 LTE only
    // 51 GSM and LTE only
    thisModem().sendAT(GF("+CNMP="), mode);
    return thisModem().waitResponse() == 1;
  }

  bool setPreferredMode(uint8_t mode) {
    // 1 CAT-M
    // 2 NB-IoT
    // 3 CAT-M and NB-IoT
    thisModem().sendAT(GF("+CMNB="), mode);
    return thisModem().waitResponse() == 1;
  }

so yes this should be approved and all users should update their TinyGSM library

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

Successfully merging this pull request may close these issues.

2 participants