remove sapbr commands from 7000SSL
Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
This commit is contained in:
@@ -93,7 +93,8 @@ class TinyGsmSim7000SSL
|
|||||||
public:
|
public:
|
||||||
GsmClientSecureSIM7000SSL() {}
|
GsmClientSecureSIM7000SSL() {}
|
||||||
|
|
||||||
GsmClientSecureSIM7000SSL(TinyGsmSim7000SSL& modem, uint8_t mux = 0)
|
explicit GsmClientSecureSIM7000SSL(TinyGsmSim7000SSL& modem,
|
||||||
|
uint8_t mux = 0)
|
||||||
: GsmClientSim7000SSL(modem, mux) {}
|
: GsmClientSim7000SSL(modem, mux) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -101,7 +102,8 @@ class TinyGsmSim7000SSL
|
|||||||
return at->setCertificate(certificateName, mux);
|
return at->setCertificate(certificateName, mux);
|
||||||
}
|
}
|
||||||
|
|
||||||
int connect(const char* host, uint16_t port, int timeout_s) {
|
virtual int connect(const char* host, uint16_t port,
|
||||||
|
int timeout_s) override {
|
||||||
stop();
|
stop();
|
||||||
TINY_GSM_YIELD();
|
TINY_GSM_YIELD();
|
||||||
rx.clear();
|
rx.clear();
|
||||||
@@ -217,26 +219,6 @@ class TinyGsmSim7000SSL
|
|||||||
const char* pwd = NULL) {
|
const char* pwd = NULL) {
|
||||||
gprsDisconnect();
|
gprsDisconnect();
|
||||||
|
|
||||||
// Bearer settings for applications based on IP
|
|
||||||
// Set the connection type to GPRS
|
|
||||||
sendAT(GF("+SAPBR=3,1,\"Contype\",\"GPRS\""));
|
|
||||||
waitResponse();
|
|
||||||
|
|
||||||
// Set the APN
|
|
||||||
sendAT(GF("+SAPBR=3,1,\"APN\",\""), apn, '"');
|
|
||||||
waitResponse();
|
|
||||||
|
|
||||||
// Set the user name
|
|
||||||
if (user && strlen(user) > 0) {
|
|
||||||
sendAT(GF("+SAPBR=3,1,\"USER\",\""), user, '"');
|
|
||||||
waitResponse();
|
|
||||||
}
|
|
||||||
// Set the password
|
|
||||||
if (pwd && strlen(pwd) > 0) {
|
|
||||||
sendAT(GF("+SAPBR=3,1,\"PWD\",\""), pwd, '"');
|
|
||||||
waitResponse();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define the PDP context
|
// Define the PDP context
|
||||||
sendAT(GF("+CGDCONT=1,\"IP\",\""), apn, '"');
|
sendAT(GF("+CGDCONT=1,\"IP\",\""), apn, '"');
|
||||||
waitResponse();
|
waitResponse();
|
||||||
@@ -249,13 +231,6 @@ class TinyGsmSim7000SSL
|
|||||||
// For who only knows what reason, doing so screws up the rest of the
|
// For who only knows what reason, doing so screws up the rest of the
|
||||||
// process
|
// process
|
||||||
|
|
||||||
// Open the definied GPRS bearer context
|
|
||||||
sendAT(GF("+SAPBR=1,1"));
|
|
||||||
waitResponse(85000L);
|
|
||||||
// Query the GPRS bearer context status
|
|
||||||
sendAT(GF("+SAPBR=2,1"));
|
|
||||||
if (waitResponse(30000L) != 1) { return false; }
|
|
||||||
|
|
||||||
// Bearer settings for applications based on IP
|
// Bearer settings for applications based on IP
|
||||||
// Set the user name and password
|
// Set the user name and password
|
||||||
// AT+CNCFG=<ip_type>[,<APN>[,<usename>,<password>[,<authentication>]]]
|
// AT+CNCFG=<ip_type>[,<APN>[,<usename>,<password>[,<authentication>]]]
|
||||||
@@ -286,17 +261,17 @@ class TinyGsmSim7000SSL
|
|||||||
// <mode> 0: Deactive
|
// <mode> 0: Deactive
|
||||||
// 1: Active
|
// 1: Active
|
||||||
// 2: Auto Active
|
// 2: Auto Active
|
||||||
int res = 0;
|
bool res = false;
|
||||||
int ntries = 0;
|
int ntries = 0;
|
||||||
while (res != 1 && ntries < 5) {
|
while (!res && ntries < 5) {
|
||||||
sendAT(GF("+CNACT=1,\""), apn, GF("\""));
|
sendAT(GF("+CNACT=1,\""), apn, GF("\""));
|
||||||
res = waitResponse(60000L, GF(GSM_NL "+APP PDP: ACTIVE"),
|
res = waitResponse(60000L, GF(GSM_NL "+APP PDP: ACTIVE"),
|
||||||
GF(GSM_NL "+APP PDP: DEACTIVE"));
|
GF(GSM_NL "+APP PDP: DEACTIVE")) == 1;
|
||||||
waitResponse();
|
waitResponse();
|
||||||
ntries++;
|
ntries++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res == 1;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gprsDisconnectImpl() {
|
bool gprsDisconnectImpl() {
|
||||||
@@ -527,8 +502,8 @@ class TinyGsmSim7000SSL
|
|||||||
// we need to fill in the missing muxes
|
// we need to fill in the missing muxes
|
||||||
if (ret_mux > muxNo) {
|
if (ret_mux > muxNo) {
|
||||||
for (int extra_mux = muxNo; extra_mux < ret_mux; extra_mux++) {
|
for (int extra_mux = muxNo; extra_mux < ret_mux; extra_mux++) {
|
||||||
GsmClientSim7000SSL* sock = sockets[extra_mux];
|
GsmClientSim7000SSL* isock = sockets[extra_mux];
|
||||||
if (sock) { sock->sock_available = 0; }
|
if (isock) { isock->sock_available = 0; }
|
||||||
}
|
}
|
||||||
muxNo = ret_mux;
|
muxNo = ret_mux;
|
||||||
}
|
}
|
||||||
@@ -537,8 +512,8 @@ class TinyGsmSim7000SSL
|
|||||||
// so we set any we haven't gotten to yet to 0
|
// so we set any we haven't gotten to yet to 0
|
||||||
for (int extra_mux = muxNo; extra_mux < TINY_GSM_MUX_COUNT;
|
for (int extra_mux = muxNo; extra_mux < TINY_GSM_MUX_COUNT;
|
||||||
extra_mux++) {
|
extra_mux++) {
|
||||||
GsmClientSim7000SSL* sock = sockets[extra_mux];
|
GsmClientSim7000SSL* isock = sockets[extra_mux];
|
||||||
if (sock) { sock->sock_available = 0; }
|
if (isock) { isock->sock_available = 0; }
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
@@ -577,8 +552,8 @@ class TinyGsmSim7000SSL
|
|||||||
// we need to fill in the missing muxes
|
// we need to fill in the missing muxes
|
||||||
if (ret_mux > muxNo) {
|
if (ret_mux > muxNo) {
|
||||||
for (int extra_mux = muxNo; extra_mux < ret_mux; extra_mux++) {
|
for (int extra_mux = muxNo; extra_mux < ret_mux; extra_mux++) {
|
||||||
GsmClientSim7000SSL* sock = sockets[extra_mux];
|
GsmClientSim7000SSL* isock = sockets[extra_mux];
|
||||||
if (sock) { sock->sock_connected = false; }
|
if (isock) { isock->sock_connected = false; }
|
||||||
}
|
}
|
||||||
muxNo = ret_mux;
|
muxNo = ret_mux;
|
||||||
}
|
}
|
||||||
@@ -587,8 +562,8 @@ class TinyGsmSim7000SSL
|
|||||||
// so we set any we haven't gotten to yet to 0
|
// so we set any we haven't gotten to yet to 0
|
||||||
for (int extra_mux = muxNo; extra_mux < TINY_GSM_MUX_COUNT;
|
for (int extra_mux = muxNo; extra_mux < TINY_GSM_MUX_COUNT;
|
||||||
extra_mux++) {
|
extra_mux++) {
|
||||||
GsmClientSim7000SSL* sock = sockets[extra_mux];
|
GsmClientSim7000SSL* isock = sockets[extra_mux];
|
||||||
if (sock) { sock->sock_connected = false; }
|
if (isock) { isock->sock_connected = false; }
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
@@ -680,15 +655,6 @@ class TinyGsmSim7000SSL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
data = "";
|
data = "";
|
||||||
} else if (data.endsWith(GF("CLOSED" GSM_NL))) {
|
|
||||||
int8_t nl = data.lastIndexOf(GSM_NL, data.length() - 8);
|
|
||||||
int8_t coma = data.indexOf(',', nl + 2);
|
|
||||||
int8_t mux = data.substring(nl + 2, coma).toInt();
|
|
||||||
if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) {
|
|
||||||
sockets[mux]->sock_connected = false;
|
|
||||||
}
|
|
||||||
data = "";
|
|
||||||
DBG("### Closed: ", mux);
|
|
||||||
} else if (data.endsWith(GF("*PSNWID:"))) {
|
} else if (data.endsWith(GF("*PSNWID:"))) {
|
||||||
streamSkipUntil('\n'); // Refresh network name by network
|
streamSkipUntil('\n'); // Refresh network name by network
|
||||||
data = "";
|
data = "";
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class TinyGsmSim7080 : public TinyGsmSim70xx<TinyGsmSim7080>,
|
|||||||
public:
|
public:
|
||||||
GsmClientSecureSIM7080() {}
|
GsmClientSecureSIM7080() {}
|
||||||
|
|
||||||
GsmClientSecureSIM7080(TinyGsmSim7080& modem, uint8_t mux = 0)
|
explicit GsmClientSecureSIM7080(TinyGsmSim7080& modem, uint8_t mux = 0)
|
||||||
: GsmClientSim7080(modem, mux) {}
|
: GsmClientSim7080(modem, mux) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -100,7 +100,8 @@ class TinyGsmSim7080 : public TinyGsmSim70xx<TinyGsmSim7080>,
|
|||||||
return at->setCertificate(certificateName, mux);
|
return at->setCertificate(certificateName, mux);
|
||||||
}
|
}
|
||||||
|
|
||||||
int connect(const char* host, uint16_t port, int timeout_s) {
|
virtual int connect(const char* host, uint16_t port,
|
||||||
|
int timeout_s) override {
|
||||||
stop();
|
stop();
|
||||||
TINY_GSM_YIELD();
|
TINY_GSM_YIELD();
|
||||||
rx.clear();
|
rx.clear();
|
||||||
@@ -265,9 +266,9 @@ class TinyGsmSim7080 : public TinyGsmSim70xx<TinyGsmSim7080>,
|
|||||||
// <action> 0: Deactive
|
// <action> 0: Deactive
|
||||||
// 1: Active
|
// 1: Active
|
||||||
// 2: Auto Active
|
// 2: Auto Active
|
||||||
int res = 0;
|
bool res = false;
|
||||||
int ntries = 0;
|
int ntries = 0;
|
||||||
while (res != 1 && ntries < 5) {
|
while (!res && ntries < 5) {
|
||||||
sendAT(GF("+CNACT=0,1"));
|
sendAT(GF("+CNACT=0,1"));
|
||||||
res = waitResponse(60000L, GF(GSM_NL "+APP PDP: 0,ACTIVE"),
|
res = waitResponse(60000L, GF(GSM_NL "+APP PDP: 0,ACTIVE"),
|
||||||
GF(GSM_NL "+APP PDP: 0,DEACTIVE"));
|
GF(GSM_NL "+APP PDP: 0,DEACTIVE"));
|
||||||
@@ -275,7 +276,7 @@ class TinyGsmSim7080 : public TinyGsmSim70xx<TinyGsmSim7080>,
|
|||||||
ntries++;
|
ntries++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res == 1;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gprsDisconnectImpl() {
|
bool gprsDisconnectImpl() {
|
||||||
@@ -504,8 +505,8 @@ class TinyGsmSim7080 : public TinyGsmSim70xx<TinyGsmSim7080>,
|
|||||||
// we need to fill in the missing muxes
|
// we need to fill in the missing muxes
|
||||||
if (ret_mux > muxNo) {
|
if (ret_mux > muxNo) {
|
||||||
for (int extra_mux = muxNo; extra_mux < ret_mux; extra_mux++) {
|
for (int extra_mux = muxNo; extra_mux < ret_mux; extra_mux++) {
|
||||||
GsmClientSim7080* sock = sockets[extra_mux];
|
GsmClientSim7080* isock = sockets[extra_mux];
|
||||||
if (sock) { sock->sock_available = 0; }
|
if (isock) { isock->sock_available = 0; }
|
||||||
}
|
}
|
||||||
muxNo = ret_mux;
|
muxNo = ret_mux;
|
||||||
}
|
}
|
||||||
@@ -514,8 +515,8 @@ class TinyGsmSim7080 : public TinyGsmSim70xx<TinyGsmSim7080>,
|
|||||||
// so we set any we haven't gotten to yet to 0
|
// so we set any we haven't gotten to yet to 0
|
||||||
for (int extra_mux = muxNo; extra_mux < TINY_GSM_MUX_COUNT;
|
for (int extra_mux = muxNo; extra_mux < TINY_GSM_MUX_COUNT;
|
||||||
extra_mux++) {
|
extra_mux++) {
|
||||||
GsmClientSim7080* sock = sockets[extra_mux];
|
GsmClientSim7080* isock = sockets[extra_mux];
|
||||||
if (sock) { sock->sock_available = 0; }
|
if (isock) { isock->sock_available = 0; }
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
@@ -554,8 +555,8 @@ class TinyGsmSim7080 : public TinyGsmSim70xx<TinyGsmSim7080>,
|
|||||||
// we need to fill in the missing muxes
|
// we need to fill in the missing muxes
|
||||||
if (ret_mux > muxNo) {
|
if (ret_mux > muxNo) {
|
||||||
for (int extra_mux = muxNo; extra_mux < ret_mux; extra_mux++) {
|
for (int extra_mux = muxNo; extra_mux < ret_mux; extra_mux++) {
|
||||||
GsmClientSim7080* sock = sockets[extra_mux];
|
GsmClientSim7080* isock = sockets[extra_mux];
|
||||||
if (sock) { sock->sock_connected = false; }
|
if (isock) { isock->sock_connected = false; }
|
||||||
}
|
}
|
||||||
muxNo = ret_mux;
|
muxNo = ret_mux;
|
||||||
}
|
}
|
||||||
@@ -564,8 +565,8 @@ class TinyGsmSim7080 : public TinyGsmSim70xx<TinyGsmSim7080>,
|
|||||||
// so we set any we haven't gotten to yet to 0
|
// so we set any we haven't gotten to yet to 0
|
||||||
for (int extra_mux = muxNo; extra_mux < TINY_GSM_MUX_COUNT;
|
for (int extra_mux = muxNo; extra_mux < TINY_GSM_MUX_COUNT;
|
||||||
extra_mux++) {
|
extra_mux++) {
|
||||||
GsmClientSim7080* sock = sockets[extra_mux];
|
GsmClientSim7080* isock = sockets[extra_mux];
|
||||||
if (sock) { sock->sock_connected = false; }
|
if (isock) { isock->sock_connected = false; }
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
@@ -657,15 +658,6 @@ class TinyGsmSim7080 : public TinyGsmSim70xx<TinyGsmSim7080>,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
data = "";
|
data = "";
|
||||||
} else if (data.endsWith(GF("CLOSED" GSM_NL))) {
|
|
||||||
int8_t nl = data.lastIndexOf(GSM_NL, data.length() - 8);
|
|
||||||
int8_t coma = data.indexOf(',', nl + 2);
|
|
||||||
int8_t mux = data.substring(nl + 2, coma).toInt();
|
|
||||||
if (mux >= 0 && mux < TINY_GSM_MUX_COUNT && sockets[mux]) {
|
|
||||||
sockets[mux]->sock_connected = false;
|
|
||||||
}
|
|
||||||
data = "";
|
|
||||||
DBG("### Closed: ", mux);
|
|
||||||
} else if (data.endsWith(GF("*PSNWID:"))) {
|
} else if (data.endsWith(GF("*PSNWID:"))) {
|
||||||
streamSkipUntil('\n'); // Refresh network name by network
|
streamSkipUntil('\n'); // Refresh network name by network
|
||||||
data = "";
|
data = "";
|
||||||
|
|||||||
Reference in New Issue
Block a user