Using PDP commands

This commit is contained in:
Sara Damiano
2019-07-17 13:56:45 -04:00
parent a059354629
commit d4d63dabe7

View File

@@ -359,15 +359,6 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
return false;
}
// Actually open the packet network
// NOTE: AT command manual hints this might be depricated or other options preferred
// but all application notes use it
sendAT(GF("+NETOPEN"));
if (waitResponse(60000L) != 1) {
return false;
}
/*
sendAT(GF("+CGATT=1")); // attach to GPRS
if (waitResponse(360000L) != 1) {
return false;
@@ -386,20 +377,38 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
waitResponse();
sendAT(GF("+CGACT=1,1")); // activate PDP profile/context 1
if (waitResponse(150000L) != 1) {
if (waitResponse(75000L) != 1) {
return false;
}
// Actually open network socket
// NOTE: AT command manual hints this might be depricated or other options preferred
// but all application notes use it (and nothing states what *IS* preferred)
sendAT(GF("+NETOPEN"));
if (waitResponse(75000L) != 1) {
return false;
}
*/
return true;
}
bool gprsDisconnect() {
// Close the network (note, all sockets should be closed first)
sendAT(GF("+NETCLOSE"));
if (waitResponse(60000L) != 1)
return false;
sendAT(GF("+CGACT=1,0")); // Deactivate PDP context 1
if (waitResponse(40000L) != 1) {
return false;
}
sendAT(GF("+CGATT=0")); // detach from GPRS
if (waitResponse(360000L) != 1) {
return false;
}
return true;
}