From f20293905f6b5c9125a6a7c34ab22dd32f0687c7 Mon Sep 17 00:00:00 2001 From: Francesco Stefanni Date: Tue, 9 Mar 2021 12:27:42 +0100 Subject: [PATCH] SIM7000: added methods to get some connection preferences, plus the current connection technology --- src/TinyGsmClientSIM7000.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/TinyGsmClientSIM7000.h b/src/TinyGsmClientSIM7000.h index 0934bf4..68a57d3 100644 --- a/src/TinyGsmClientSIM7000.h +++ b/src/TinyGsmClientSIM7000.h @@ -262,6 +262,7 @@ class TinyGsmSim7000 : public TinyGsmModem, public: String getNetworkModes() { + // Get the help string, not the setting value sendAT(GF("+CNMP=?")); if (waitResponse(GF(GSM_NL "+CNMP:")) != 1) { return ""; } String res = stream.readStringUntil('\n'); @@ -269,6 +270,14 @@ class TinyGsmSim7000 : public TinyGsmModem, return res; } + bool getNetworkMode(int16_t & mode) { + sendAT(GF("+CNMP?")); + if (waitResponse(GF(GSM_NL "+CNMP:")) != 1) { return false; } + mode = streamGetIntBefore('\n'); + waitResponse(); + return true; + } + String setNetworkMode(uint8_t mode) { sendAT(GF("+CNMP="), mode); if (waitResponse(GF(GSM_NL "+CNMP:")) != 1) { return "OK"; } @@ -278,6 +287,7 @@ class TinyGsmSim7000 : public TinyGsmModem, } String getPreferredModes() { + // Get the help string, not the setting value sendAT(GF("+CMNB=?")); if (waitResponse(GF(GSM_NL "+CMNB:")) != 1) { return ""; } String res = stream.readStringUntil('\n'); @@ -285,6 +295,14 @@ class TinyGsmSim7000 : public TinyGsmModem, return res; } + bool getPreferredMode(int16_t & mode) { + sendAT(GF("+CMNB?")); + if (waitResponse(GF(GSM_NL "+CMNB:")) != 1) { return false; } + mode = streamGetIntBefore('\n'); + waitResponse(); + return true; + } + String setPreferredMode(uint8_t mode) { sendAT(GF("+CMNB="), mode); if (waitResponse(GF(GSM_NL "+CMNB:")) != 1) { return "OK"; } @@ -293,6 +311,26 @@ class TinyGsmSim7000 : public TinyGsmModem, return res; } + bool getNetworkSystemMode(bool & n, int16_t & stat) { + // n: whether to automatically report the system mode info + // stat: the current service. 0 if it not connected + sendAT(GF("+CNSMOD?")); + if (waitResponse(GF(GSM_NL "+CNSMOD:")) != 1) { return false; } + n = streamGetIntBefore(',') != 0; + stat = streamGetIntBefore('\n'); + waitResponse(); + return true; + } + + String setNetworkSystemMode(bool n) { + // n: whether to automatically report the system mode info + sendAT(GF("+CNSMOD="), int8_t(n)); + if (waitResponse(GF(GSM_NL "+CNSMOD:")) != 1) { return "OK"; } + String res = stream.readStringUntil('\n'); + waitResponse(); + return res; + } + String getLocalIPImpl() { sendAT(GF("+CIFSR;E0")); String res;