Skip to content

Commit

Permalink
Update enableGPRS()
Browse files Browse the repository at this point in the history
  • Loading branch information
botletics committed Nov 22, 2022
1 parent 92f9b75 commit e2a6926
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 52 deletions.
22 changes: 5 additions & 17 deletions examples/LTE_Demo/LTE_Demo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
22 changes: 5 additions & 17 deletions examples/SIM7XXX_LTE_Demo/SIM7XXX_LTE_Demo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down
29 changes: 11 additions & 18 deletions src/BotleticsSIM7000.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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();

Expand Down Expand Up @@ -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) {
Expand All @@ -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 {
Expand All @@ -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;
Expand Down

0 comments on commit e2a6926

Please sign in to comment.