From e2a6926c1bf1c7683aba78b7833be8d27fa1de27 Mon Sep 17 00:00:00 2001 From: Timothy Woo Date: Tue, 22 Nov 2022 15:57:16 -0500 Subject: [PATCH] Update enableGPRS() --- examples/LTE_Demo/LTE_Demo.ino | 22 ++++---------- .../SIM7XXX_LTE_Demo/SIM7XXX_LTE_Demo.ino | 22 ++++---------- src/BotleticsSIM7000.cpp | 29 +++++++------------ 3 files changed, 21 insertions(+), 52 deletions(-) diff --git a/examples/LTE_Demo/LTE_Demo.ino b/examples/LTE_Demo/LTE_Demo.ino index 9204dfd..f6f5782 100644 --- a/examples/LTE_Demo/LTE_Demo.ino +++ b/examples/LTE_Demo/LTE_Demo.ino @@ -895,15 +895,9 @@ void loop() { case 'g': { // disable data - #if defined(SIMCOM_7000) || defined (SIMCOM_7070) - if (!modem.openWirelessConnection(false)) - Serial.println(F("Failed to turn off")); - break; - #else - if (!modem.enableGPRS(false)) - Serial.println(F("Failed to turn off")); - break; - #endif + if (!modem.enableGPRS(false)) + Serial.println(F("Failed to turn off")); + break; } case 'G': { // turn GPRS off first for SIM7500 @@ -912,15 +906,9 @@ void loop() { #endif // enable data - #if defined(SIMCOM_7000) || defined (SIMCOM_7070) - if (!modem.openWirelessConnection(true)) + if (!modem.enableGPRS(true)) Serial.println(F("Failed to turn on")); - break; - #else - if (!modem.enableGPRS(true)) - Serial.println(F("Failed to turn on")); - break; - #endif + break; } case 'l': { // check for GSMLOC (requires GPRS) diff --git a/examples/SIM7XXX_LTE_Demo/SIM7XXX_LTE_Demo.ino b/examples/SIM7XXX_LTE_Demo/SIM7XXX_LTE_Demo.ino index 6c29486..760da4a 100644 --- a/examples/SIM7XXX_LTE_Demo/SIM7XXX_LTE_Demo.ino +++ b/examples/SIM7XXX_LTE_Demo/SIM7XXX_LTE_Demo.ino @@ -687,15 +687,9 @@ void loop() { case 'g': { // disable data - #if defined(SIMCOM_7000) || defined (SIMCOM_7070) - if (!modem.openWirelessConnection(false)) - Serial.println(F("Failed to turn off")); - break; - #else - if (!modem.enableGPRS(false)) - Serial.println(F("Failed to turn off")); - break; - #endif + if (!modem.enableGPRS(false)) + Serial.println(F("Failed to turn off")); + break; } case 'G': { // turn GPRS off first for SIM7500 @@ -704,15 +698,9 @@ void loop() { #endif // enable data - #if defined(SIMCOM_7000) || defined (SIMCOM_7070) - if (!modem.openWirelessConnection(true)) + if (!modem.enableGPRS(true)) Serial.println(F("Failed to turn on")); - break; - #else - if (!modem.enableGPRS(true)) - Serial.println(F("Failed to turn on")); - break; - #endif + break; } case '1': { // Get connection type, cellular band, carrier name, etc. diff --git a/src/BotleticsSIM7000.cpp b/src/BotleticsSIM7000.cpp index b37bf6a..b7f079e 100644 --- a/src/BotleticsSIM7000.cpp +++ b/src/BotleticsSIM7000.cpp @@ -1613,17 +1613,15 @@ boolean Botletics_modem::enableGPRS(boolean onoff) { } else { if (onoff) { - // if (_type < SIM7000) { // UNCOMMENT FOR LTE ONLY! - // disconnect all sockets - sendCheckReply(F("AT+CIPSHUT"), F("SHUT OK"), 20000); + // disconnect all sockets + sendCheckReply(F("AT+CIPSHUT"), F("SHUT OK"), 20000); - if (! sendCheckReply(F("AT+CGATT=1"), ok_reply, 10000)) - return false; + if (! sendCheckReply(F("AT+CGATT=1"), ok_reply, 10000)) + return false; // set bearer profile! connection type GPRS if (! sendCheckReply(F("AT+SAPBR=3,1,\"CONTYPE\",\"GPRS\""), ok_reply, 10000)) return false; - // } // UNCOMMENT FOR LTE ONLY! delay(200); // This seems to help the next line run the first time @@ -1633,7 +1631,6 @@ boolean Botletics_modem::enableGPRS(boolean onoff) { if (! sendCheckReplyQuoted(F("AT+SAPBR=3,1,\"APN\","), apn, ok_reply, 10000)) return false; - // if (_type < SIM7000) { // UNCOMMENT FOR LTE ONLY! // send AT+CSTT,"apn","user","pass" flushInput(); @@ -1663,7 +1660,6 @@ boolean Botletics_modem::enableGPRS(boolean onoff) { DEBUG_PRINTLN("\""); if (! expectReply(ok_reply)) return false; - // } // UNCOMMENT FOR LTE ONLY! // set username/password if (apnusername) { @@ -1682,13 +1678,11 @@ boolean Botletics_modem::enableGPRS(boolean onoff) { if (! sendCheckReply(F("AT+SAPBR=1,1"), ok_reply, 30000)) return false; - // if (_type < SIM7000) { // UNCOMMENT FOR LTE ONLY! - // bring up wireless connection - if (! sendCheckReply(F("AT+CIICR"), ok_reply, 10000)) - return false; - // } // UNCOMMENT FOR LTE ONLY! + // bring up wireless connection + if (! sendCheckReply(F("AT+CIICR"), ok_reply, 10000)) + return false; - // if (! openWirelessConnection(true)) return false; + openWirelessConnection(true); // if (! wirelessConnStatus()) return false; } else { @@ -1700,11 +1694,10 @@ boolean Botletics_modem::enableGPRS(boolean onoff) { if (! sendCheckReply(F("AT+SAPBR=0,1"), ok_reply, 10000)) return false; - // if (_type < SIM7000) { // UNCOMMENT FOR LTE ONLY! - if (! sendCheckReply(F("AT+CGATT=0"), ok_reply, 10000)) - return false; - // } // UNCOMMENT FOR LTE ONLY! + if (! sendCheckReply(F("AT+CGATT=0"), ok_reply, 10000)) + return false; + openWirelessConnection(false); } } return true;